From 22d3567b5fdf988260a9c62f791c391c759e04b1 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 1 Sep 2025 13:50:00 +0000 Subject: [PATCH 001/129] chore: sync repo --- .config/dotnet-tools.json | 13 + .editorconfig | 237 +-- .gitattributes | 63 - .github/workflows/ci.yml | 63 + .github/workflows/dotnet-core.yml | 83 - .gitignore | 268 +-- .stats.yml | 4 + .vscode/tasks.json | 123 -- CHANGELOG.md | 74 - ImageKitSample/Program.cs | 482 ----- ImageKitSample/test.jpg | Bin 27405 -> 0 bytes .../FileVersion/FileVersionTestAsync.cs | 481 ----- .../FileVersion/FileVersionTestNonAsync.cs | 482 ----- .../ImageKitRequestModelValidation.cs | 850 -------- Imagekit.UnitTests/ImageKitTestCasesAsync.cs | 726 ------- .../ImageKitTestCasesNonAsync.cs | 734 ------- Imagekit.UnitTests/Imagekit.UnitTests.csproj | 77 - .../ManageFolder/ManageFolderTestAsync.cs | 299 --- .../ManageFolder/ManageFolderTestNonAsync.cs | 296 --- .../MetaData/MetaDataTestAsync.cs | 557 ----- .../MetaData/MetaDataTestNonAsync.cs | 546 ----- Imagekit.UnitTests/Sample/test.jpg | Bin 27405 -> 0 bytes .../Tags/ManageTagsTestAsync.cs | 240 --- .../Tags/ManageTagsTestNonAsync.cs | 240 --- Imagekit.UnitTests/TestHelpers.cs | 85 - .../Upload/UploadTestCasesAsync.cs | 431 ---- .../Upload/UploadTestCasesNonAsync.cs | 421 ---- Imagekit.crdata | 19 - Imagekit.sln | 42 +- Imagekit.sln.CodeItRight.xml | 6 - Imagekit/Constant/UrlHandler.cs | 42 - Imagekit/Constant/errorMessages.cs | 73 - Imagekit/GlobalSuppressions.cs | 49 - Imagekit/Helper/GetJsonBody.cs | 423 ---- Imagekit/Helper/ImageKitException.cs | 26 - Imagekit/Helper/ImagekitBase.cs | 83 - Imagekit/Helper/ImagekitParams.cs | 73 - Imagekit/Helper/MultipartFormDataModel.cs | 180 -- Imagekit/Helper/Transformation.cs | 281 --- Imagekit/Helper/TransformationTypes.cs | 268 --- Imagekit/Helper/Url.cs | 184 -- Imagekit/Helper/ValidateParamater.cs | 397 ---- Imagekit/IImageKit.cs | 62 - Imagekit/Imagekit.cs | 367 ---- Imagekit/Imagekit.csproj | 124 -- Imagekit/Models/AITagsRequest.cs | 23 - Imagekit/Models/AuthParamResponse.cs | 18 - Imagekit/Models/CopyFileRequest.cs | 15 - Imagekit/Models/CopyFolderRequest.cs | 15 - Imagekit/Models/CreateFolderRequest.cs | 13 - .../CustomMetaDataFieldCreateRequest.cs | 22 - .../Models/CustomMetaDataFieldSchemaObject.cs | 51 - .../CustomMetaDataFieldUpdateRequest.cs | 13 - Imagekit/Models/DeleteFileVersionRequest.cs | 13 - Imagekit/Models/DeleteFolderRequest.cs | 11 - Imagekit/Models/ExtensionModel.cs | 32 - Imagekit/Models/FileCreateRequest.cs | 47 - Imagekit/Models/FileUpdateRequest.cs | 24 - Imagekit/Models/GetFileListRequest.cs | 27 - Imagekit/Models/MoveFileRequest.cs | 10 - Imagekit/Models/MoveFolderRequest.cs | 10 - Imagekit/Models/PublishStatus.cs | 11 - Imagekit/Models/RenameFileRequest.cs | 28 - Imagekit/Models/Response/MetaData.cs | 30 - Imagekit/Models/Response/Result.cs | 109 - .../Models/Response/ResultBulkJobStatus.cs | 14 - Imagekit/Models/Response/ResultCache.cs | 13 - Imagekit/Models/Response/ResultCacheStatus.cs | 13 - .../Response/ResultCustomMetaDataField.cs | 18 - .../Response/ResultCustomMetaDataFieldList.cs | 12 - Imagekit/Models/Response/ResultEmptyBlock.cs | 9 - Imagekit/Models/Response/ResultException.cs | 12 - Imagekit/Models/Response/ResultFileDelete.cs | 16 - .../Response/ResultFileVersionDetails.cs | 54 - .../Models/Response/ResultFileVersions.cs | 12 - Imagekit/Models/Response/ResultList.cs | 60 - Imagekit/Models/Response/ResultMetaData.cs | 16 - Imagekit/Models/Response/ResultNoContent.cs | 10 - .../Models/Response/ResultOfFolderActions.cs | 11 - Imagekit/Models/Response/ResultRenameFile.cs | 10 - Imagekit/Models/Response/ResultTags.cs | 12 - Imagekit/Models/ResponseMetaData.cs | 10 - Imagekit/Models/TagsRequest.cs | 12 - Imagekit/Models/UploadTransformation.cs | 47 - Imagekit/Properties/AssemblyProperties.cs | 5 - Imagekit/RestClient.cs | 1876 ----------------- Imagekit/Util/Calculation.cs | 47 - Imagekit/Util/Constants.cs | 26 - Imagekit/Util/Utils.cs | 86 - Imagekit/stylecop.json | 14 - LICENSE | 213 +- README.md | 976 +-------- SECURITY.md | 27 + codecov.yml | 15 - .../ImagekitExample/ImagekitExample.csproj | 12 + scripts/bootstrap | 8 + scripts/build | 8 + scripts/format | 8 + scripts/lint | 9 + scripts/mock | 41 + scripts/test | 56 + src/Imagekit.Tests/Imagekit.Tests.csproj | 20 + .../Services/Accounts/AccountServiceTest.cs | 3 + .../Accounts/Origins/OriginServiceTest.cs | 73 + .../URLEndpoints/URLEndpointServiceTest.cs | 47 + .../Accounts/Usage/UsageServiceTest.cs | 20 + .../Services/Assets/AssetServiceTest.cs | 16 + .../Services/Beta/BetaServiceTest.cs | 3 + .../Services/Beta/V2/Files/FileServiceTest.cs | 15 + .../Services/Beta/V2/V2ServiceTest.cs | 3 + .../Services/Cache/CacheServiceTest.cs | 3 + .../Invalidation/InvalidationServiceTest.cs | 24 + .../CustomMetadataFieldServiceTest.cs | 59 + .../Services/Files/Bulk/BulkServiceTest.cs | 40 + .../Services/Files/FileServiceTest.cs | 70 + .../Files/Metadata/MetadataServiceTest.cs | 22 + .../Files/Versions/VersionServiceTest.cs | 43 + .../Services/Folders/FolderServiceTest.cs | 57 + .../Services/Folders/Job/JobServiceTest.cs | 13 + .../Services/Webhooks/WebhookServiceTest.cs | 3 + src/Imagekit.Tests/TestBase.cs | 21 + src/Imagekit/ApiEnum.cs | 56 + src/Imagekit/HttpException.cs | 29 + src/Imagekit/IImageKitClient.cs | 56 + src/Imagekit/IVariant.cs | 8 + src/Imagekit/ImageKitClient.cs | 116 + src/Imagekit/Imagekit.csproj | 38 + src/Imagekit/ModelBase.cs | 202 ++ src/Imagekit/ModelConverter.cs | 30 + .../Accounts/Origins/OriginCreateParams.cs | 64 + .../Accounts/Origins/OriginDeleteParams.cs | 34 + .../Accounts/Origins/OriginGetParams.cs | 33 + .../Accounts/Origins/OriginListParams.cs | 28 + .../Models/Accounts/Origins/OriginRequest.cs | 360 ++++ .../OriginRequestProperties/AkeneoPim.cs | 233 ++ .../OriginRequestProperties/AzureBlob.cs | 197 ++ .../CloudinaryBackup.cs | 209 ++ .../Origins/OriginRequestProperties/Gcs.cs | 197 ++ .../Origins/OriginRequestProperties/S3.cs | 209 ++ .../OriginRequestProperties/S3Compatible.cs | 254 +++ .../OriginRequestProperties/WebFolder.cs | 163 ++ .../OriginRequestProperties/WebProxy.cs | 125 ++ .../Origins/OriginRequestVariants/All.cs | 123 ++ .../Models/Accounts/Origins/OriginResponse.cs | 361 ++++ .../OriginResponseProperties/AkeneoPim.cs | 168 ++ .../OriginResponseProperties/AzureBlob.cs | 205 ++ .../CloudinaryBackup.cs | 191 ++ .../Origins/OriginResponseProperties/Gcs.cs | 205 ++ .../Origins/OriginResponseProperties/S3.cs | 191 ++ .../OriginResponseProperties/S3Compatible.cs | 239 +++ .../OriginResponseProperties/WebFolder.cs | 193 ++ .../OriginResponseProperties/WebProxy.cs | 145 ++ .../Origins/OriginResponseVariants/All.cs | 123 ++ .../Accounts/Origins/OriginUpdateParams.cs | 69 + .../URLEndpoints/URLEndpointCreateParams.cs | 131 ++ .../URLRewriter.cs | 176 ++ .../URLRewriterProperties/Cloudinary.cs | 73 + .../URLRewriterVariants/All.cs | 39 + .../URLEndpoints/URLEndpointDeleteParams.cs | 34 + .../URLEndpoints/URLEndpointGetParams.cs | 33 + .../URLEndpoints/URLEndpointListParams.cs | 29 + .../URLEndpoints/URLEndpointRequest.cs | 136 ++ .../URLRewriter.cs | 176 ++ .../URLRewriterProperties/Cloudinary.cs | 73 + .../URLRewriterVariants/All.cs | 39 + .../URLEndpoints/URLEndpointResponse.cs | 155 ++ .../URLRewriter.cs | 176 ++ .../URLRewriterProperties/Cloudinary.cs | 83 + .../URLRewriterVariants/All.cs | 39 + .../URLEndpoints/URLEndpointUpdateParams.cs | 136 ++ .../URLRewriter.cs | 176 ++ .../URLRewriterProperties/Cloudinary.cs | 73 + .../URLRewriterVariants/All.cs | 39 + .../Models/Accounts/Usage/UsageGetParams.cs | 75 + .../Models/Accounts/Usage/UsageGetResponse.cs | 139 ++ src/Imagekit/Models/Assets/AssetListParams.cs | 210 ++ .../AssetListParamsProperties/FileType.cs | 52 + .../Assets/AssetListParamsProperties/Sort.cs | 82 + .../Assets/AssetListParamsProperties/Type.cs | 56 + .../Models/Assets/AssetListResponse.cs | 147 ++ .../Assets/AssetListResponseVariants/All.cs | 34 + src/Imagekit/Models/BaseOverlay.cs | 70 + .../Models/Beta/V2/Files/FileUploadParams.cs | 561 +++++ .../FileUploadParamsProperties/Extension.cs | 177 ++ .../AutoTaggingExtension.cs | 100 + .../AutoTaggingExtensionProperties/Name.cs | 46 + .../ExtensionProperties/RemoveBg.cs | 74 + .../RemoveBgProperties/Options.cs | 122 ++ .../ExtensionVariants/All.cs | 46 + .../ResponseField.cs | 62 + .../Transformation.cs | 92 + .../TransformationProperties/Post.cs | 225 ++ .../PostProperties/Abs.cs | 103 + .../PostProperties/AbsProperties/Protocol.cs | 46 + .../PostProperties/GifToVideo.cs | 77 + .../PostProperties/Thumbnail.cs | 76 + .../PostProperties/Transformation.cs | 85 + .../PostVariants/All.cs | 61 + .../Beta/V2/Files/FileUploadResponse.cs | 616 ++++++ .../FileUploadResponseProperties/AITag.cs | 96 + .../ExtensionStatus.cs | 129 ++ .../AIAutoDescription.cs | 50 + .../AwsAutoTagging.cs | 50 + .../GoogleAutoTagging.cs | 50 + .../ExtensionStatusProperties/RemoveBg.cs | 46 + .../VersionInfo.cs | 76 + .../Invalidation/InvalidationCreateParams.cs | 65 + .../InvalidationCreateResponse.cs | 56 + .../Invalidation/InvalidationGetParams.cs | 32 + .../Invalidation/InvalidationGetResponse.cs | 57 + .../Status.cs | 46 + .../CustomMetadataField.cs | 129 ++ .../CustomMetadataFieldCreateParams.cs | 111 + .../Schema.cs | 243 +++ .../SchemaProperties/DefaultValue.cs | 176 ++ .../UnnamedSchemaWithArrayParent1.cs | 140 ++ .../All.cs | 35 + .../DefaultValueVariants/All.cs | 50 + .../SchemaProperties/MaxValue.cs | 109 + .../SchemaProperties/MaxValueVariants/All.cs | 21 + .../SchemaProperties/MinValue.cs | 109 + .../SchemaProperties/MinValueVariants/All.cs | 21 + .../SchemaProperties/SelectOption.cs | 138 ++ .../SelectOptionVariants/All.cs | 31 + .../SchemaProperties/Type.cs | 61 + .../CustomMetadataFieldDeleteParams.cs | 33 + .../CustomMetadataFieldDeleteResponse.cs | 31 + .../CustomMetadataFieldListParams.cs | 51 + .../CustomMetadataFieldProperties/Schema.cs | 240 +++ .../SchemaProperties/DefaultValue.cs | 175 ++ .../UnnamedSchemaWithArrayParent0.cs | 140 ++ .../All.cs | 35 + .../DefaultValueVariants/All.cs | 50 + .../SchemaProperties/MaxValue.cs | 109 + .../SchemaProperties/MaxValueVariants/All.cs | 21 + .../SchemaProperties/MinValue.cs | 109 + .../SchemaProperties/MinValueVariants/All.cs | 21 + .../SchemaProperties/SelectOption.cs | 138 ++ .../SelectOptionVariants/All.cs | 31 + .../SchemaProperties/Type.cs | 61 + .../CustomMetadataFieldUpdateParams.cs | 95 + .../Schema.cs | 207 ++ .../SchemaProperties/DefaultValue.cs | 183 ++ .../UnnamedSchemaWithArrayParent2.cs | 145 ++ .../All.cs | 35 + .../DefaultValueVariants/All.cs | 50 + .../SchemaProperties/MaxValue.cs | 117 + .../SchemaProperties/MaxValueVariants/All.cs | 21 + .../SchemaProperties/MinValue.cs | 117 + .../SchemaProperties/MinValueVariants/All.cs | 21 + .../SchemaProperties/SelectOption.cs | 145 ++ .../SelectOptionVariants/All.cs | 31 + .../Models/Files/Bulk/BulkAddTagsParams.cs | 86 + .../Models/Files/Bulk/BulkAddTagsResponse.cs | 54 + .../Models/Files/Bulk/BulkDeleteParams.cs | 71 + .../Models/Files/Bulk/BulkDeleteResponse.cs | 54 + .../Files/Bulk/BulkRemoveAITagsParams.cs | 86 + .../Files/Bulk/BulkRemoveAITagsResponse.cs | 56 + .../Models/Files/Bulk/BulkRemoveTagsParams.cs | 86 + .../Files/Bulk/BulkRemoveTagsResponse.cs | 56 + src/Imagekit/Models/Files/File.cs | 550 +++++ src/Imagekit/Models/Files/FileCopyParams.cs | 118 ++ src/Imagekit/Models/Files/FileCopyResponse.cs | 27 + src/Imagekit/Models/Files/FileDeleteParams.cs | 35 + src/Imagekit/Models/Files/FileGetParams.cs | 33 + src/Imagekit/Models/Files/FileMoveParams.cs | 94 + src/Imagekit/Models/Files/FileMoveResponse.cs | 27 + .../Models/Files/FileProperties/AITag.cs | 95 + .../Models/Files/FileProperties/Type.cs | 46 + .../Files/FileProperties/VersionInfo.cs | 76 + src/Imagekit/Models/Files/FileRenameParams.cs | 129 ++ .../Models/Files/FileRenameResponse.cs | 52 + src/Imagekit/Models/Files/FileUpdateParams.cs | 67 + .../FileUpdateParamsProperties/Update.cs | 123 ++ .../ChangePublicationStatus.cs | 54 + .../Publish.cs | 85 + .../UpdateProperties/UpdateFileDetails.cs | 215 ++ .../UpdateFileDetailsProperties/Extension.cs | 177 ++ .../AutoTaggingExtension.cs | 100 + .../AutoTaggingExtensionProperties/Name.cs | 46 + .../ExtensionProperties/RemoveBg.cs | 74 + .../RemoveBgProperties/Options.cs | 122 ++ .../ExtensionVariants/All.cs | 46 + .../RemoveAITags.cs | 115 + .../RemoveAITagsVariants/All.cs | 26 + .../UpdateVariants/All.cs | 33 + .../Models/Files/FileUpdateResponse.cs | 600 ++++++ .../IntersectionMember1.cs | 52 + .../ExtensionStatus.cs | 118 ++ .../AIAutoDescription.cs | 50 + .../AwsAutoTagging.cs | 50 + .../GoogleAutoTagging.cs | 50 + .../ExtensionStatusProperties/RemoveBg.cs | 46 + src/Imagekit/Models/Files/FileUploadParams.cs | 638 ++++++ .../FileUploadParamsProperties/Extension.cs | 177 ++ .../AutoTaggingExtension.cs | 100 + .../AutoTaggingExtensionProperties/Name.cs | 46 + .../ExtensionProperties/RemoveBg.cs | 74 + .../RemoveBgProperties/Options.cs | 122 ++ .../ExtensionVariants/All.cs | 46 + .../ResponseField.cs | 62 + .../Transformation.cs | 92 + .../TransformationProperties/Post.cs | 225 ++ .../PostProperties/Abs.cs | 103 + .../PostProperties/AbsProperties/Protocol.cs | 46 + .../PostProperties/GifToVideo.cs | 77 + .../PostProperties/Thumbnail.cs | 76 + .../PostProperties/Transformation.cs | 85 + .../PostVariants/All.cs | 61 + .../Models/Files/FileUploadResponse.cs | 612 ++++++ .../FileUploadResponseProperties/AITag.cs | 96 + .../ExtensionStatus.cs | 129 ++ .../AIAutoDescription.cs | 50 + .../AwsAutoTagging.cs | 50 + .../GoogleAutoTagging.cs | 50 + .../ExtensionStatusProperties/RemoveBg.cs | 46 + .../VersionInfo.cs | 76 + src/Imagekit/Models/Files/Folder.cs | 171 ++ .../Models/Files/FolderProperties/Type.cs | 43 + src/Imagekit/Models/Files/Metadata.cs | 338 +++ .../Metadata/MetadataGetFromURLParams.cs | 52 + .../Files/Metadata/MetadataGetParams.cs | 36 + .../Models/Files/MetadataProperties/Exif.cs | 183 ++ .../MetadataProperties/ExifProperties/Exif.cs | 526 +++++ .../MetadataProperties/ExifProperties/Gps.cs | 54 + .../ExifProperties/Image.cs | 241 +++ .../ExifProperties/Interoperability.cs | 70 + .../ExifProperties/Thumbnail.cs | 146 ++ .../Files/Versions/VersionDeleteParams.cs | 36 + .../Files/Versions/VersionDeleteResponse.cs | 27 + .../Models/Files/Versions/VersionGetParams.cs | 34 + .../Files/Versions/VersionListParams.cs | 32 + .../Files/Versions/VersionRestoreParams.cs | 34 + .../Models/Folders/FolderCopyParams.cs | 120 ++ .../Models/Folders/FolderCopyResponse.cs | 64 + .../Models/Folders/FolderCreateParams.cs | 99 + .../Models/Folders/FolderCreateResponse.cs | 27 + .../Models/Folders/FolderDeleteParams.cs | 64 + .../Models/Folders/FolderDeleteResponse.cs | 27 + .../Models/Folders/FolderMoveParams.cs | 95 + .../Models/Folders/FolderMoveResponse.cs | 64 + .../Models/Folders/FolderRenameParams.cs | 126 ++ .../Models/Folders/FolderRenameResponse.cs | 64 + .../Models/Folders/Job/JobGetParams.cs | 31 + .../Models/Folders/Job/JobGetResponse.cs | 125 ++ .../Job/JobGetResponseProperties/Status.cs | 46 + .../Job/JobGetResponseProperties/Type.cs | 49 + src/Imagekit/Models/ImageOverlay.cs | 184 ++ .../IntersectionMember1.cs | 140 ++ .../IntersectionMember1Properties/Encoding.cs | 52 + src/Imagekit/Models/Overlay.cs | 253 +++ src/Imagekit/Models/OverlayPosition.cs | 106 + .../Models/OverlayPositionProperties/Focus.cs | 68 + .../Models/OverlayPositionProperties/X.cs | 110 + .../XVariants/All.cs | 21 + .../Models/OverlayPositionProperties/Y.cs | 110 + .../YVariants/All.cs | 21 + src/Imagekit/Models/OverlayTiming.cs | 106 + .../OverlayTimingProperties/Duration.cs | 118 ++ .../DurationVariants/All.cs | 21 + .../Models/OverlayTimingProperties/End.cs | 111 + .../EndVariants/All.cs | 21 + .../Models/OverlayTimingProperties/Start.cs | 115 + .../StartVariants/All.cs | 21 + src/Imagekit/Models/OverlayVariants/All.cs | 78 + src/Imagekit/Models/SolidColorOverlay.cs | 158 ++ .../IntersectionMember1.cs | 114 + .../Models/SolidColorOverlayTransformation.cs | 174 ++ .../Gradient.cs | 115 + .../GradientVariants/All.cs | 23 + .../Height.cs | 116 + .../HeightVariants/All.cs | 21 + .../Radius.cs | 106 + .../RadiusVariants/All.cs | 23 + .../Width.cs | 113 + .../WidthVariants/All.cs | 21 + src/Imagekit/Models/SrcOptions.cs | 230 ++ src/Imagekit/Models/StreamingResolution.cs | 65 + src/Imagekit/Models/SubtitleOverlay.cs | 182 ++ .../IntersectionMember1.cs | 138 ++ .../IntersectionMember1Properties/Encoding.cs | 52 + .../Models/SubtitleOverlayTransformation.cs | 220 ++ .../Typography.cs | 56 + src/Imagekit/Models/TextOverlay.cs | 183 ++ .../IntersectionMember1.cs | 139 ++ .../IntersectionMember1Properties/Encoding.cs | 52 + .../Models/TextOverlayTransformation.cs | 345 +++ .../Flip.cs | 52 + .../FontSize.cs | 115 + .../FontSizeVariants/All.cs | 21 + .../InnerAlignment.cs | 53 + .../LineHeight.cs | 123 ++ .../LineHeightVariants/All.cs | 21 + .../Padding.cs | 117 + .../PaddingVariants/All.cs | 21 + .../Radius.cs | 106 + .../RadiusVariants/All.cs | 23 + .../Rotation.cs | 116 + .../RotationVariants/All.cs | 21 + .../Width.cs | 115 + .../WidthVariants/All.cs | 21 + src/Imagekit/Models/Transformation.cs | 1320 ++++++++++++ src/Imagekit/Models/TransformationPosition.cs | 52 + .../TransformationProperties/AIDropShadow.cs | 122 ++ .../AIDropShadowVariants/All.cs | 23 + .../AIRemoveBackground.cs | 48 + .../AIRemoveBackgroundExternal.cs | 49 + .../TransformationProperties/AIRetouch.cs | 48 + .../TransformationProperties/AIUpscale.cs | 48 + .../TransformationProperties/AIVariation.cs | 50 + .../TransformationProperties/AspectRatio.cs | 123 ++ .../AspectRatioVariants/All.cs | 21 + .../TransformationProperties/AudioCodec.cs | 53 + .../ContrastStretch.cs | 48 + .../Models/TransformationProperties/Crop.cs | 55 + .../TransformationProperties/CropMode.cs | 49 + .../TransformationProperties/Duration.cs | 117 + .../DurationVariants/All.cs | 21 + .../TransformationProperties/EndOffset.cs | 121 ++ .../EndOffsetVariants/All.cs | 21 + .../Models/TransformationProperties/Flip.cs | 54 + .../Models/TransformationProperties/Format.cs | 78 + .../TransformationProperties/Gradient.cs | 114 + .../GradientVariants/All.cs | 23 + .../TransformationProperties/Grayscale.cs | 47 + .../Models/TransformationProperties/Height.cs | 118 ++ .../HeightVariants/All.cs | 21 + .../Models/TransformationProperties/Page.cs | 112 + .../PageVariants/All.cs | 21 + .../Models/TransformationProperties/Radius.cs | 106 + .../RadiusVariants/All.cs | 23 + .../TransformationProperties/Rotation.cs | 118 ++ .../RotationVariants/All.cs | 21 + .../Models/TransformationProperties/Shadow.cs | 109 + .../ShadowVariants/All.cs | 23 + .../TransformationProperties/Sharpen.cs | 110 + .../SharpenVariants/All.cs | 23 + .../TransformationProperties/StartOffset.cs | 122 ++ .../StartOffsetVariants/All.cs | 21 + .../Models/TransformationProperties/Trim.cs | 107 + .../TrimVariants/All.cs | 23 + .../TransformationProperties/UnsharpMask.cs | 120 ++ .../UnsharpMaskVariants/All.cs | 23 + .../TransformationProperties/VideoCodec.cs | 56 + .../Models/TransformationProperties/Width.cs | 115 + .../WidthVariants/All.cs | 21 + .../Models/TransformationProperties/X.cs | 107 + .../TransformationProperties/XCenter.cs | 116 + .../XCenterVariants/All.cs | 21 + .../TransformationProperties/XVariants/All.cs | 21 + .../Models/TransformationProperties/Y.cs | 107 + .../TransformationProperties/YCenter.cs | 116 + .../YCenterVariants/All.cs | 21 + .../TransformationProperties/YVariants/All.cs | 21 + src/Imagekit/Models/VideoOverlay.cs | 183 ++ .../IntersectionMember1.cs | 139 ++ .../IntersectionMember1Properties/Encoding.cs | 52 + .../Webhooks/UnsafeUnwrapWebhookEvent.cs | 364 ++++ .../UnsafeUnwrapWebhookEventVariants/All.cs | 163 ++ .../Models/Webhooks/UnwrapWebhookEvent.cs | 338 +++ .../UnwrapWebhookEventVariants/All.cs | 163 ++ .../Webhooks/UploadPostTransformErrorEvent.cs | 145 ++ .../Data.cs | 148 ++ .../DataProperties/Transformation.cs | 58 + .../TransformationProperties/Error.cs | 60 + .../Request.cs | 79 + .../RequestProperties/Transformation.cs | 110 + .../TransformationProperties/Protocol.cs | 46 + .../TransformationProperties/Type.cs | 52 + .../UploadPostTransformSuccessEvent.cs | 146 ++ .../Data.cs | 99 + .../Request.cs | 79 + .../RequestProperties/Transformation.cs | 110 + .../TransformationProperties/Protocol.cs | 46 + .../TransformationProperties/Type.cs | 52 + .../Webhooks/UploadPreTransformErrorEvent.cs | 145 ++ .../Data.cs | 102 + .../DataProperties/Transformation.cs | 58 + .../TransformationProperties/Error.cs | 60 + .../Request.cs | 79 + .../UploadPreTransformSuccessEvent.cs | 149 ++ .../Data.cs | 613 ++++++ .../DataProperties/AITag.cs | 96 + .../DataProperties/ExtensionStatus.cs | 129 ++ .../AIAutoDescription.cs | 50 + .../AwsAutoTagging.cs | 50 + .../GoogleAutoTagging.cs | 50 + .../ExtensionStatusProperties/RemoveBg.cs | 46 + .../DataProperties/VersionInfo.cs | 76 + .../Request.cs | 79 + .../VideoTransformationAcceptedEvent.cs | 149 ++ .../Data.cs | 84 + .../DataProperties/Asset.cs | 63 + .../DataProperties/Transformation.cs | 93 + .../TransformationProperties/Options.cs | 202 ++ .../OptionsProperties/AudioCodec.cs | 50 + .../OptionsProperties/Format.cs | 55 + .../OptionsProperties/StreamProtocol.cs | 50 + .../OptionsProperties/VideoCodec.cs | 53 + .../TransformationProperties/Type.cs | 51 + .../Request.cs | 101 + .../Webhooks/VideoTransformationErrorEvent.cs | 150 ++ .../Data.cs | 81 + .../DataProperties/Asset.cs | 63 + .../DataProperties/Transformation.cs | 115 + .../TransformationProperties/Error.cs | 71 + .../ErrorProperties/Reason.cs | 51 + .../TransformationProperties/Options.cs | 202 ++ .../OptionsProperties/AudioCodec.cs | 50 + .../OptionsProperties/Format.cs | 55 + .../OptionsProperties/StreamProtocol.cs | 50 + .../OptionsProperties/VideoCodec.cs | 53 + .../TransformationProperties/Type.cs | 51 + .../Request.cs | 101 + .../Webhooks/VideoTransformationReadyEvent.cs | 172 ++ .../Data.cs | 81 + .../DataProperties/Asset.cs | 63 + .../DataProperties/Transformation.cs | 115 + .../TransformationProperties/Options.cs | 202 ++ .../OptionsProperties/AudioCodec.cs | 50 + .../OptionsProperties/Format.cs | 55 + .../OptionsProperties/StreamProtocol.cs | 50 + .../OptionsProperties/VideoCodec.cs | 53 + .../TransformationProperties/Output.cs | 86 + .../OutputProperties/VideoMetadata.cs | 121 ++ .../TransformationProperties/Type.cs | 51 + .../Request.cs | 101 + .../Timings.cs | 77 + src/Imagekit/ParamsBase.cs | 164 ++ .../Services/Accounts/AccountService.cs | 34 + .../Services/Accounts/IAccountService.cs | 14 + .../Accounts/Origins/IOriginService.cs | 39 + .../Accounts/Origins/OriginService.cs | 126 ++ .../URLEndpoints/IURLEndpointService.cs | 40 + .../URLEndpoints/URLEndpointService.cs | 126 ++ .../Services/Accounts/Usage/IUsageService.cs | 15 + .../Services/Accounts/Usage/UsageService.cs | 38 + src/Imagekit/Services/Assets/AssetService.cs | 41 + src/Imagekit/Services/Assets/IAssetService.cs | 16 + src/Imagekit/Services/Beta/BetaService.cs | 18 + src/Imagekit/Services/Beta/IBetaService.cs | 8 + .../Services/Beta/V2/Files/FileService.cs | 41 + .../Services/Beta/V2/Files/IFileService.cs | 33 + src/Imagekit/Services/Beta/V2/IV2Service.cs | 8 + src/Imagekit/Services/Beta/V2/V2Service.cs | 18 + src/Imagekit/Services/Cache/CacheService.cs | 18 + src/Imagekit/Services/Cache/ICacheService.cs | 8 + .../Invalidation/IInvalidationService.cs | 19 + .../Cache/Invalidation/InvalidationService.cs | 62 + .../CustomMetadataFieldService.cs | 114 + .../ICustomMetadataFieldService.cs | 34 + .../Services/Files/Bulk/BulkService.cs | 113 + .../Services/Files/Bulk/IBulkService.cs | 36 + src/Imagekit/Services/Files/FileService.cs | 198 ++ src/Imagekit/Services/Files/IFileService.cs | 91 + .../Files/Metadata/IMetadataService.cs | 23 + .../Files/Metadata/MetadataService.cs | 60 + .../Files/Versions/IVersionService.cs | 32 + .../Services/Files/Versions/VersionService.cs | 103 + .../Services/Folders/FolderService.cs | 145 ++ .../Services/Folders/IFolderService.cs | 46 + .../Services/Folders/Job/IJobService.cs | 12 + .../Services/Folders/Job/JobService.cs | 38 + .../Services/Webhooks/IWebhookService.cs | 3 + .../Services/Webhooks/WebhookService.cs | 6 + 565 files changed, 45526 insertions(+), 14349 deletions(-) create mode 100644 .config/dotnet-tools.json delete mode 100644 .gitattributes create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/dotnet-core.yml create mode 100644 .stats.yml delete mode 100644 .vscode/tasks.json delete mode 100644 CHANGELOG.md delete mode 100644 ImageKitSample/Program.cs delete mode 100644 ImageKitSample/test.jpg delete mode 100644 Imagekit.UnitTests/FileVersion/FileVersionTestAsync.cs delete mode 100644 Imagekit.UnitTests/FileVersion/FileVersionTestNonAsync.cs delete mode 100644 Imagekit.UnitTests/ImageKitRequestModelValidation.cs delete mode 100644 Imagekit.UnitTests/ImageKitTestCasesAsync.cs delete mode 100644 Imagekit.UnitTests/ImageKitTestCasesNonAsync.cs delete mode 100644 Imagekit.UnitTests/Imagekit.UnitTests.csproj delete mode 100644 Imagekit.UnitTests/ManageFolder/ManageFolderTestAsync.cs delete mode 100644 Imagekit.UnitTests/ManageFolder/ManageFolderTestNonAsync.cs delete mode 100644 Imagekit.UnitTests/MetaData/MetaDataTestAsync.cs delete mode 100644 Imagekit.UnitTests/MetaData/MetaDataTestNonAsync.cs delete mode 100644 Imagekit.UnitTests/Sample/test.jpg delete mode 100644 Imagekit.UnitTests/Tags/ManageTagsTestAsync.cs delete mode 100644 Imagekit.UnitTests/Tags/ManageTagsTestNonAsync.cs delete mode 100644 Imagekit.UnitTests/TestHelpers.cs delete mode 100644 Imagekit.UnitTests/Upload/UploadTestCasesAsync.cs delete mode 100644 Imagekit.UnitTests/Upload/UploadTestCasesNonAsync.cs delete mode 100644 Imagekit.crdata delete mode 100644 Imagekit.sln.CodeItRight.xml delete mode 100644 Imagekit/Constant/UrlHandler.cs delete mode 100644 Imagekit/Constant/errorMessages.cs delete mode 100644 Imagekit/GlobalSuppressions.cs delete mode 100644 Imagekit/Helper/GetJsonBody.cs delete mode 100644 Imagekit/Helper/ImageKitException.cs delete mode 100644 Imagekit/Helper/ImagekitBase.cs delete mode 100644 Imagekit/Helper/ImagekitParams.cs delete mode 100644 Imagekit/Helper/MultipartFormDataModel.cs delete mode 100644 Imagekit/Helper/Transformation.cs delete mode 100644 Imagekit/Helper/TransformationTypes.cs delete mode 100644 Imagekit/Helper/Url.cs delete mode 100644 Imagekit/Helper/ValidateParamater.cs delete mode 100644 Imagekit/IImageKit.cs delete mode 100644 Imagekit/Imagekit.cs delete mode 100644 Imagekit/Imagekit.csproj delete mode 100644 Imagekit/Models/AITagsRequest.cs delete mode 100644 Imagekit/Models/AuthParamResponse.cs delete mode 100644 Imagekit/Models/CopyFileRequest.cs delete mode 100644 Imagekit/Models/CopyFolderRequest.cs delete mode 100644 Imagekit/Models/CreateFolderRequest.cs delete mode 100644 Imagekit/Models/CustomMetaDataFieldCreateRequest.cs delete mode 100644 Imagekit/Models/CustomMetaDataFieldSchemaObject.cs delete mode 100644 Imagekit/Models/CustomMetaDataFieldUpdateRequest.cs delete mode 100644 Imagekit/Models/DeleteFileVersionRequest.cs delete mode 100644 Imagekit/Models/DeleteFolderRequest.cs delete mode 100644 Imagekit/Models/ExtensionModel.cs delete mode 100644 Imagekit/Models/FileCreateRequest.cs delete mode 100644 Imagekit/Models/FileUpdateRequest.cs delete mode 100644 Imagekit/Models/GetFileListRequest.cs delete mode 100644 Imagekit/Models/MoveFileRequest.cs delete mode 100644 Imagekit/Models/MoveFolderRequest.cs delete mode 100644 Imagekit/Models/PublishStatus.cs delete mode 100644 Imagekit/Models/RenameFileRequest.cs delete mode 100644 Imagekit/Models/Response/MetaData.cs delete mode 100644 Imagekit/Models/Response/Result.cs delete mode 100644 Imagekit/Models/Response/ResultBulkJobStatus.cs delete mode 100644 Imagekit/Models/Response/ResultCache.cs delete mode 100644 Imagekit/Models/Response/ResultCacheStatus.cs delete mode 100644 Imagekit/Models/Response/ResultCustomMetaDataField.cs delete mode 100644 Imagekit/Models/Response/ResultCustomMetaDataFieldList.cs delete mode 100644 Imagekit/Models/Response/ResultEmptyBlock.cs delete mode 100644 Imagekit/Models/Response/ResultException.cs delete mode 100644 Imagekit/Models/Response/ResultFileDelete.cs delete mode 100644 Imagekit/Models/Response/ResultFileVersionDetails.cs delete mode 100644 Imagekit/Models/Response/ResultFileVersions.cs delete mode 100644 Imagekit/Models/Response/ResultList.cs delete mode 100644 Imagekit/Models/Response/ResultMetaData.cs delete mode 100644 Imagekit/Models/Response/ResultNoContent.cs delete mode 100644 Imagekit/Models/Response/ResultOfFolderActions.cs delete mode 100644 Imagekit/Models/Response/ResultRenameFile.cs delete mode 100644 Imagekit/Models/Response/ResultTags.cs delete mode 100644 Imagekit/Models/ResponseMetaData.cs delete mode 100644 Imagekit/Models/TagsRequest.cs delete mode 100644 Imagekit/Models/UploadTransformation.cs delete mode 100644 Imagekit/Properties/AssemblyProperties.cs delete mode 100644 Imagekit/RestClient.cs delete mode 100644 Imagekit/Util/Calculation.cs delete mode 100644 Imagekit/Util/Constants.cs delete mode 100644 Imagekit/Util/Utils.cs delete mode 100644 Imagekit/stylecop.json create mode 100644 SECURITY.md delete mode 100644 codecov.yml create mode 100644 examples/ImagekitExample/ImagekitExample.csproj create mode 100755 scripts/bootstrap create mode 100755 scripts/build create mode 100755 scripts/format create mode 100755 scripts/lint create mode 100755 scripts/mock create mode 100755 scripts/test create mode 100644 src/Imagekit.Tests/Imagekit.Tests.csproj create mode 100644 src/Imagekit.Tests/Services/Accounts/AccountServiceTest.cs create mode 100644 src/Imagekit.Tests/Services/Accounts/Origins/OriginServiceTest.cs create mode 100644 src/Imagekit.Tests/Services/Accounts/URLEndpoints/URLEndpointServiceTest.cs create mode 100644 src/Imagekit.Tests/Services/Accounts/Usage/UsageServiceTest.cs create mode 100644 src/Imagekit.Tests/Services/Assets/AssetServiceTest.cs create mode 100644 src/Imagekit.Tests/Services/Beta/BetaServiceTest.cs create mode 100644 src/Imagekit.Tests/Services/Beta/V2/Files/FileServiceTest.cs create mode 100644 src/Imagekit.Tests/Services/Beta/V2/V2ServiceTest.cs create mode 100644 src/Imagekit.Tests/Services/Cache/CacheServiceTest.cs create mode 100644 src/Imagekit.Tests/Services/Cache/Invalidation/InvalidationServiceTest.cs create mode 100644 src/Imagekit.Tests/Services/CustomMetadataFields/CustomMetadataFieldServiceTest.cs create mode 100644 src/Imagekit.Tests/Services/Files/Bulk/BulkServiceTest.cs create mode 100644 src/Imagekit.Tests/Services/Files/FileServiceTest.cs create mode 100644 src/Imagekit.Tests/Services/Files/Metadata/MetadataServiceTest.cs create mode 100644 src/Imagekit.Tests/Services/Files/Versions/VersionServiceTest.cs create mode 100644 src/Imagekit.Tests/Services/Folders/FolderServiceTest.cs create mode 100644 src/Imagekit.Tests/Services/Folders/Job/JobServiceTest.cs create mode 100644 src/Imagekit.Tests/Services/Webhooks/WebhookServiceTest.cs create mode 100644 src/Imagekit.Tests/TestBase.cs create mode 100644 src/Imagekit/ApiEnum.cs create mode 100644 src/Imagekit/HttpException.cs create mode 100644 src/Imagekit/IImageKitClient.cs create mode 100644 src/Imagekit/IVariant.cs create mode 100644 src/Imagekit/ImageKitClient.cs create mode 100644 src/Imagekit/Imagekit.csproj create mode 100644 src/Imagekit/ModelBase.cs create mode 100644 src/Imagekit/ModelConverter.cs create mode 100644 src/Imagekit/Models/Accounts/Origins/OriginCreateParams.cs create mode 100644 src/Imagekit/Models/Accounts/Origins/OriginDeleteParams.cs create mode 100644 src/Imagekit/Models/Accounts/Origins/OriginGetParams.cs create mode 100644 src/Imagekit/Models/Accounts/Origins/OriginListParams.cs create mode 100644 src/Imagekit/Models/Accounts/Origins/OriginRequest.cs create mode 100644 src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AkeneoPim.cs create mode 100644 src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AzureBlob.cs create mode 100644 src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/CloudinaryBackup.cs create mode 100644 src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/Gcs.cs create mode 100644 src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3.cs create mode 100644 src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3Compatible.cs create mode 100644 src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebFolder.cs create mode 100644 src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebProxy.cs create mode 100644 src/Imagekit/Models/Accounts/Origins/OriginRequestVariants/All.cs create mode 100644 src/Imagekit/Models/Accounts/Origins/OriginResponse.cs create mode 100644 src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AkeneoPim.cs create mode 100644 src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AzureBlob.cs create mode 100644 src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/CloudinaryBackup.cs create mode 100644 src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/Gcs.cs create mode 100644 src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3.cs create mode 100644 src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3Compatible.cs create mode 100644 src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebFolder.cs create mode 100644 src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebProxy.cs create mode 100644 src/Imagekit/Models/Accounts/Origins/OriginResponseVariants/All.cs create mode 100644 src/Imagekit/Models/Accounts/Origins/OriginUpdateParams.cs create mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParams.cs create mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriter.cs create mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/Cloudinary.cs create mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterVariants/All.cs create mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointDeleteParams.cs create mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointGetParams.cs create mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointListParams.cs create mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequest.cs create mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriter.cs create mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/Cloudinary.cs create mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterVariants/All.cs create mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponse.cs create mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriter.cs create mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/Cloudinary.cs create mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterVariants/All.cs create mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParams.cs create mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriter.cs create mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/Cloudinary.cs create mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterVariants/All.cs create mode 100644 src/Imagekit/Models/Accounts/Usage/UsageGetParams.cs create mode 100644 src/Imagekit/Models/Accounts/Usage/UsageGetResponse.cs create mode 100644 src/Imagekit/Models/Assets/AssetListParams.cs create mode 100644 src/Imagekit/Models/Assets/AssetListParamsProperties/FileType.cs create mode 100644 src/Imagekit/Models/Assets/AssetListParamsProperties/Sort.cs create mode 100644 src/Imagekit/Models/Assets/AssetListParamsProperties/Type.cs create mode 100644 src/Imagekit/Models/Assets/AssetListResponse.cs create mode 100644 src/Imagekit/Models/Assets/AssetListResponseVariants/All.cs create mode 100644 src/Imagekit/Models/BaseOverlay.cs create mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParams.cs create mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/Extension.cs create mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ExtensionProperties/AutoTaggingExtension.cs create mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs create mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ExtensionProperties/RemoveBg.cs create mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ExtensionProperties/RemoveBgProperties/Options.cs create mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ExtensionVariants/All.cs create mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ResponseField.cs create mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/Transformation.cs create mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/Post.cs create mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Abs.cs create mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs create mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideo.cs create mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Thumbnail.cs create mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Transformation.cs create mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostVariants/All.cs create mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadResponse.cs create mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/AITag.cs create mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/ExtensionStatus.cs create mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/ExtensionStatusProperties/AIAutoDescription.cs create mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/ExtensionStatusProperties/AwsAutoTagging.cs create mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/ExtensionStatusProperties/GoogleAutoTagging.cs create mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/ExtensionStatusProperties/RemoveBg.cs create mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/VersionInfo.cs create mode 100644 src/Imagekit/Models/Cache/Invalidation/InvalidationCreateParams.cs create mode 100644 src/Imagekit/Models/Cache/Invalidation/InvalidationCreateResponse.cs create mode 100644 src/Imagekit/Models/Cache/Invalidation/InvalidationGetParams.cs create mode 100644 src/Imagekit/Models/Cache/Invalidation/InvalidationGetResponse.cs create mode 100644 src/Imagekit/Models/Cache/Invalidation/InvalidationGetResponseProperties/Status.cs create mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataField.cs create mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParams.cs create mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/Schema.cs create mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValue.cs create mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent1.cs create mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent1Variants/All.cs create mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValueVariants/All.cs create mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MaxValue.cs create mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MaxValueVariants/All.cs create mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MinValue.cs create mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MinValueVariants/All.cs create mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/SelectOption.cs create mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/SelectOptionVariants/All.cs create mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/Type.cs create mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldDeleteParams.cs create mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldDeleteResponse.cs create mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldListParams.cs create mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/Schema.cs create mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValue.cs create mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent0.cs create mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent0Variants/All.cs create mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValueVariants/All.cs create mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MaxValue.cs create mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MaxValueVariants/All.cs create mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MinValue.cs create mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MinValueVariants/All.cs create mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/SelectOption.cs create mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/SelectOptionVariants/All.cs create mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/Type.cs create mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParams.cs create mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/Schema.cs create mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValue.cs create mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent2.cs create mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent2Variants/All.cs create mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValueVariants/All.cs create mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MaxValue.cs create mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MaxValueVariants/All.cs create mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MinValue.cs create mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MinValueVariants/All.cs create mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/SelectOption.cs create mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/SelectOptionVariants/All.cs create mode 100644 src/Imagekit/Models/Files/Bulk/BulkAddTagsParams.cs create mode 100644 src/Imagekit/Models/Files/Bulk/BulkAddTagsResponse.cs create mode 100644 src/Imagekit/Models/Files/Bulk/BulkDeleteParams.cs create mode 100644 src/Imagekit/Models/Files/Bulk/BulkDeleteResponse.cs create mode 100644 src/Imagekit/Models/Files/Bulk/BulkRemoveAITagsParams.cs create mode 100644 src/Imagekit/Models/Files/Bulk/BulkRemoveAITagsResponse.cs create mode 100644 src/Imagekit/Models/Files/Bulk/BulkRemoveTagsParams.cs create mode 100644 src/Imagekit/Models/Files/Bulk/BulkRemoveTagsResponse.cs create mode 100644 src/Imagekit/Models/Files/File.cs create mode 100644 src/Imagekit/Models/Files/FileCopyParams.cs create mode 100644 src/Imagekit/Models/Files/FileCopyResponse.cs create mode 100644 src/Imagekit/Models/Files/FileDeleteParams.cs create mode 100644 src/Imagekit/Models/Files/FileGetParams.cs create mode 100644 src/Imagekit/Models/Files/FileMoveParams.cs create mode 100644 src/Imagekit/Models/Files/FileMoveResponse.cs create mode 100644 src/Imagekit/Models/Files/FileProperties/AITag.cs create mode 100644 src/Imagekit/Models/Files/FileProperties/Type.cs create mode 100644 src/Imagekit/Models/Files/FileProperties/VersionInfo.cs create mode 100644 src/Imagekit/Models/Files/FileRenameParams.cs create mode 100644 src/Imagekit/Models/Files/FileRenameResponse.cs create mode 100644 src/Imagekit/Models/Files/FileUpdateParams.cs create mode 100644 src/Imagekit/Models/Files/FileUpdateParamsProperties/Update.cs create mode 100644 src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/ChangePublicationStatus.cs create mode 100644 src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/ChangePublicationStatusProperties/Publish.cs create mode 100644 src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetails.cs create mode 100644 src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetailsProperties/Extension.cs create mode 100644 src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetailsProperties/ExtensionProperties/AutoTaggingExtension.cs create mode 100644 src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetailsProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs create mode 100644 src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetailsProperties/ExtensionProperties/RemoveBg.cs create mode 100644 src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetailsProperties/ExtensionProperties/RemoveBgProperties/Options.cs create mode 100644 src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetailsProperties/ExtensionVariants/All.cs create mode 100644 src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetailsProperties/RemoveAITags.cs create mode 100644 src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetailsProperties/RemoveAITagsVariants/All.cs create mode 100644 src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateVariants/All.cs create mode 100644 src/Imagekit/Models/Files/FileUpdateResponse.cs create mode 100644 src/Imagekit/Models/Files/FileUpdateResponseProperties/IntersectionMember1.cs create mode 100644 src/Imagekit/Models/Files/FileUpdateResponseProperties/IntersectionMember1Properties/ExtensionStatus.cs create mode 100644 src/Imagekit/Models/Files/FileUpdateResponseProperties/IntersectionMember1Properties/ExtensionStatusProperties/AIAutoDescription.cs create mode 100644 src/Imagekit/Models/Files/FileUpdateResponseProperties/IntersectionMember1Properties/ExtensionStatusProperties/AwsAutoTagging.cs create mode 100644 src/Imagekit/Models/Files/FileUpdateResponseProperties/IntersectionMember1Properties/ExtensionStatusProperties/GoogleAutoTagging.cs create mode 100644 src/Imagekit/Models/Files/FileUpdateResponseProperties/IntersectionMember1Properties/ExtensionStatusProperties/RemoveBg.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParams.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/Extension.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/AutoTaggingExtension.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/RemoveBg.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/RemoveBgProperties/Options.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionVariants/All.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/ResponseField.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/Transformation.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/Post.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Abs.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideo.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Thumbnail.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Transformation.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostVariants/All.cs create mode 100644 src/Imagekit/Models/Files/FileUploadResponse.cs create mode 100644 src/Imagekit/Models/Files/FileUploadResponseProperties/AITag.cs create mode 100644 src/Imagekit/Models/Files/FileUploadResponseProperties/ExtensionStatus.cs create mode 100644 src/Imagekit/Models/Files/FileUploadResponseProperties/ExtensionStatusProperties/AIAutoDescription.cs create mode 100644 src/Imagekit/Models/Files/FileUploadResponseProperties/ExtensionStatusProperties/AwsAutoTagging.cs create mode 100644 src/Imagekit/Models/Files/FileUploadResponseProperties/ExtensionStatusProperties/GoogleAutoTagging.cs create mode 100644 src/Imagekit/Models/Files/FileUploadResponseProperties/ExtensionStatusProperties/RemoveBg.cs create mode 100644 src/Imagekit/Models/Files/FileUploadResponseProperties/VersionInfo.cs create mode 100644 src/Imagekit/Models/Files/Folder.cs create mode 100644 src/Imagekit/Models/Files/FolderProperties/Type.cs create mode 100644 src/Imagekit/Models/Files/Metadata.cs create mode 100644 src/Imagekit/Models/Files/Metadata/MetadataGetFromURLParams.cs create mode 100644 src/Imagekit/Models/Files/Metadata/MetadataGetParams.cs create mode 100644 src/Imagekit/Models/Files/MetadataProperties/Exif.cs create mode 100644 src/Imagekit/Models/Files/MetadataProperties/ExifProperties/Exif.cs create mode 100644 src/Imagekit/Models/Files/MetadataProperties/ExifProperties/Gps.cs create mode 100644 src/Imagekit/Models/Files/MetadataProperties/ExifProperties/Image.cs create mode 100644 src/Imagekit/Models/Files/MetadataProperties/ExifProperties/Interoperability.cs create mode 100644 src/Imagekit/Models/Files/MetadataProperties/ExifProperties/Thumbnail.cs create mode 100644 src/Imagekit/Models/Files/Versions/VersionDeleteParams.cs create mode 100644 src/Imagekit/Models/Files/Versions/VersionDeleteResponse.cs create mode 100644 src/Imagekit/Models/Files/Versions/VersionGetParams.cs create mode 100644 src/Imagekit/Models/Files/Versions/VersionListParams.cs create mode 100644 src/Imagekit/Models/Files/Versions/VersionRestoreParams.cs create mode 100644 src/Imagekit/Models/Folders/FolderCopyParams.cs create mode 100644 src/Imagekit/Models/Folders/FolderCopyResponse.cs create mode 100644 src/Imagekit/Models/Folders/FolderCreateParams.cs create mode 100644 src/Imagekit/Models/Folders/FolderCreateResponse.cs create mode 100644 src/Imagekit/Models/Folders/FolderDeleteParams.cs create mode 100644 src/Imagekit/Models/Folders/FolderDeleteResponse.cs create mode 100644 src/Imagekit/Models/Folders/FolderMoveParams.cs create mode 100644 src/Imagekit/Models/Folders/FolderMoveResponse.cs create mode 100644 src/Imagekit/Models/Folders/FolderRenameParams.cs create mode 100644 src/Imagekit/Models/Folders/FolderRenameResponse.cs create mode 100644 src/Imagekit/Models/Folders/Job/JobGetParams.cs create mode 100644 src/Imagekit/Models/Folders/Job/JobGetResponse.cs create mode 100644 src/Imagekit/Models/Folders/Job/JobGetResponseProperties/Status.cs create mode 100644 src/Imagekit/Models/Folders/Job/JobGetResponseProperties/Type.cs create mode 100644 src/Imagekit/Models/ImageOverlay.cs create mode 100644 src/Imagekit/Models/ImageOverlayProperties/IntersectionMember1.cs create mode 100644 src/Imagekit/Models/ImageOverlayProperties/IntersectionMember1Properties/Encoding.cs create mode 100644 src/Imagekit/Models/Overlay.cs create mode 100644 src/Imagekit/Models/OverlayPosition.cs create mode 100644 src/Imagekit/Models/OverlayPositionProperties/Focus.cs create mode 100644 src/Imagekit/Models/OverlayPositionProperties/X.cs create mode 100644 src/Imagekit/Models/OverlayPositionProperties/XVariants/All.cs create mode 100644 src/Imagekit/Models/OverlayPositionProperties/Y.cs create mode 100644 src/Imagekit/Models/OverlayPositionProperties/YVariants/All.cs create mode 100644 src/Imagekit/Models/OverlayTiming.cs create mode 100644 src/Imagekit/Models/OverlayTimingProperties/Duration.cs create mode 100644 src/Imagekit/Models/OverlayTimingProperties/DurationVariants/All.cs create mode 100644 src/Imagekit/Models/OverlayTimingProperties/End.cs create mode 100644 src/Imagekit/Models/OverlayTimingProperties/EndVariants/All.cs create mode 100644 src/Imagekit/Models/OverlayTimingProperties/Start.cs create mode 100644 src/Imagekit/Models/OverlayTimingProperties/StartVariants/All.cs create mode 100644 src/Imagekit/Models/OverlayVariants/All.cs create mode 100644 src/Imagekit/Models/SolidColorOverlay.cs create mode 100644 src/Imagekit/Models/SolidColorOverlayProperties/IntersectionMember1.cs create mode 100644 src/Imagekit/Models/SolidColorOverlayTransformation.cs create mode 100644 src/Imagekit/Models/SolidColorOverlayTransformationProperties/Gradient.cs create mode 100644 src/Imagekit/Models/SolidColorOverlayTransformationProperties/GradientVariants/All.cs create mode 100644 src/Imagekit/Models/SolidColorOverlayTransformationProperties/Height.cs create mode 100644 src/Imagekit/Models/SolidColorOverlayTransformationProperties/HeightVariants/All.cs create mode 100644 src/Imagekit/Models/SolidColorOverlayTransformationProperties/Radius.cs create mode 100644 src/Imagekit/Models/SolidColorOverlayTransformationProperties/RadiusVariants/All.cs create mode 100644 src/Imagekit/Models/SolidColorOverlayTransformationProperties/Width.cs create mode 100644 src/Imagekit/Models/SolidColorOverlayTransformationProperties/WidthVariants/All.cs create mode 100644 src/Imagekit/Models/SrcOptions.cs create mode 100644 src/Imagekit/Models/StreamingResolution.cs create mode 100644 src/Imagekit/Models/SubtitleOverlay.cs create mode 100644 src/Imagekit/Models/SubtitleOverlayProperties/IntersectionMember1.cs create mode 100644 src/Imagekit/Models/SubtitleOverlayProperties/IntersectionMember1Properties/Encoding.cs create mode 100644 src/Imagekit/Models/SubtitleOverlayTransformation.cs create mode 100644 src/Imagekit/Models/SubtitleOverlayTransformationProperties/Typography.cs create mode 100644 src/Imagekit/Models/TextOverlay.cs create mode 100644 src/Imagekit/Models/TextOverlayProperties/IntersectionMember1.cs create mode 100644 src/Imagekit/Models/TextOverlayProperties/IntersectionMember1Properties/Encoding.cs create mode 100644 src/Imagekit/Models/TextOverlayTransformation.cs create mode 100644 src/Imagekit/Models/TextOverlayTransformationProperties/Flip.cs create mode 100644 src/Imagekit/Models/TextOverlayTransformationProperties/FontSize.cs create mode 100644 src/Imagekit/Models/TextOverlayTransformationProperties/FontSizeVariants/All.cs create mode 100644 src/Imagekit/Models/TextOverlayTransformationProperties/InnerAlignment.cs create mode 100644 src/Imagekit/Models/TextOverlayTransformationProperties/LineHeight.cs create mode 100644 src/Imagekit/Models/TextOverlayTransformationProperties/LineHeightVariants/All.cs create mode 100644 src/Imagekit/Models/TextOverlayTransformationProperties/Padding.cs create mode 100644 src/Imagekit/Models/TextOverlayTransformationProperties/PaddingVariants/All.cs create mode 100644 src/Imagekit/Models/TextOverlayTransformationProperties/Radius.cs create mode 100644 src/Imagekit/Models/TextOverlayTransformationProperties/RadiusVariants/All.cs create mode 100644 src/Imagekit/Models/TextOverlayTransformationProperties/Rotation.cs create mode 100644 src/Imagekit/Models/TextOverlayTransformationProperties/RotationVariants/All.cs create mode 100644 src/Imagekit/Models/TextOverlayTransformationProperties/Width.cs create mode 100644 src/Imagekit/Models/TextOverlayTransformationProperties/WidthVariants/All.cs create mode 100644 src/Imagekit/Models/Transformation.cs create mode 100644 src/Imagekit/Models/TransformationPosition.cs create mode 100644 src/Imagekit/Models/TransformationProperties/AIDropShadow.cs create mode 100644 src/Imagekit/Models/TransformationProperties/AIDropShadowVariants/All.cs create mode 100644 src/Imagekit/Models/TransformationProperties/AIRemoveBackground.cs create mode 100644 src/Imagekit/Models/TransformationProperties/AIRemoveBackgroundExternal.cs create mode 100644 src/Imagekit/Models/TransformationProperties/AIRetouch.cs create mode 100644 src/Imagekit/Models/TransformationProperties/AIUpscale.cs create mode 100644 src/Imagekit/Models/TransformationProperties/AIVariation.cs create mode 100644 src/Imagekit/Models/TransformationProperties/AspectRatio.cs create mode 100644 src/Imagekit/Models/TransformationProperties/AspectRatioVariants/All.cs create mode 100644 src/Imagekit/Models/TransformationProperties/AudioCodec.cs create mode 100644 src/Imagekit/Models/TransformationProperties/ContrastStretch.cs create mode 100644 src/Imagekit/Models/TransformationProperties/Crop.cs create mode 100644 src/Imagekit/Models/TransformationProperties/CropMode.cs create mode 100644 src/Imagekit/Models/TransformationProperties/Duration.cs create mode 100644 src/Imagekit/Models/TransformationProperties/DurationVariants/All.cs create mode 100644 src/Imagekit/Models/TransformationProperties/EndOffset.cs create mode 100644 src/Imagekit/Models/TransformationProperties/EndOffsetVariants/All.cs create mode 100644 src/Imagekit/Models/TransformationProperties/Flip.cs create mode 100644 src/Imagekit/Models/TransformationProperties/Format.cs create mode 100644 src/Imagekit/Models/TransformationProperties/Gradient.cs create mode 100644 src/Imagekit/Models/TransformationProperties/GradientVariants/All.cs create mode 100644 src/Imagekit/Models/TransformationProperties/Grayscale.cs create mode 100644 src/Imagekit/Models/TransformationProperties/Height.cs create mode 100644 src/Imagekit/Models/TransformationProperties/HeightVariants/All.cs create mode 100644 src/Imagekit/Models/TransformationProperties/Page.cs create mode 100644 src/Imagekit/Models/TransformationProperties/PageVariants/All.cs create mode 100644 src/Imagekit/Models/TransformationProperties/Radius.cs create mode 100644 src/Imagekit/Models/TransformationProperties/RadiusVariants/All.cs create mode 100644 src/Imagekit/Models/TransformationProperties/Rotation.cs create mode 100644 src/Imagekit/Models/TransformationProperties/RotationVariants/All.cs create mode 100644 src/Imagekit/Models/TransformationProperties/Shadow.cs create mode 100644 src/Imagekit/Models/TransformationProperties/ShadowVariants/All.cs create mode 100644 src/Imagekit/Models/TransformationProperties/Sharpen.cs create mode 100644 src/Imagekit/Models/TransformationProperties/SharpenVariants/All.cs create mode 100644 src/Imagekit/Models/TransformationProperties/StartOffset.cs create mode 100644 src/Imagekit/Models/TransformationProperties/StartOffsetVariants/All.cs create mode 100644 src/Imagekit/Models/TransformationProperties/Trim.cs create mode 100644 src/Imagekit/Models/TransformationProperties/TrimVariants/All.cs create mode 100644 src/Imagekit/Models/TransformationProperties/UnsharpMask.cs create mode 100644 src/Imagekit/Models/TransformationProperties/UnsharpMaskVariants/All.cs create mode 100644 src/Imagekit/Models/TransformationProperties/VideoCodec.cs create mode 100644 src/Imagekit/Models/TransformationProperties/Width.cs create mode 100644 src/Imagekit/Models/TransformationProperties/WidthVariants/All.cs create mode 100644 src/Imagekit/Models/TransformationProperties/X.cs create mode 100644 src/Imagekit/Models/TransformationProperties/XCenter.cs create mode 100644 src/Imagekit/Models/TransformationProperties/XCenterVariants/All.cs create mode 100644 src/Imagekit/Models/TransformationProperties/XVariants/All.cs create mode 100644 src/Imagekit/Models/TransformationProperties/Y.cs create mode 100644 src/Imagekit/Models/TransformationProperties/YCenter.cs create mode 100644 src/Imagekit/Models/TransformationProperties/YCenterVariants/All.cs create mode 100644 src/Imagekit/Models/TransformationProperties/YVariants/All.cs create mode 100644 src/Imagekit/Models/VideoOverlay.cs create mode 100644 src/Imagekit/Models/VideoOverlayProperties/IntersectionMember1.cs create mode 100644 src/Imagekit/Models/VideoOverlayProperties/IntersectionMember1Properties/Encoding.cs create mode 100644 src/Imagekit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs create mode 100644 src/Imagekit/Models/Webhooks/UnsafeUnwrapWebhookEventVariants/All.cs create mode 100644 src/Imagekit/Models/Webhooks/UnwrapWebhookEvent.cs create mode 100644 src/Imagekit/Models/Webhooks/UnwrapWebhookEventVariants/All.cs create mode 100644 src/Imagekit/Models/Webhooks/UploadPostTransformErrorEvent.cs create mode 100644 src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/Data.cs create mode 100644 src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/DataProperties/Transformation.cs create mode 100644 src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/DataProperties/TransformationProperties/Error.cs create mode 100644 src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/Request.cs create mode 100644 src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/RequestProperties/Transformation.cs create mode 100644 src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/RequestProperties/TransformationProperties/Protocol.cs create mode 100644 src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/RequestProperties/TransformationProperties/Type.cs create mode 100644 src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEvent.cs create mode 100644 src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/Data.cs create mode 100644 src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/Request.cs create mode 100644 src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/RequestProperties/Transformation.cs create mode 100644 src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/RequestProperties/TransformationProperties/Protocol.cs create mode 100644 src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/RequestProperties/TransformationProperties/Type.cs create mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformErrorEvent.cs create mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/Data.cs create mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/DataProperties/Transformation.cs create mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/DataProperties/TransformationProperties/Error.cs create mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/Request.cs create mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEvent.cs create mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/Data.cs create mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/DataProperties/AITag.cs create mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/DataProperties/ExtensionStatus.cs create mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/DataProperties/ExtensionStatusProperties/AIAutoDescription.cs create mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/DataProperties/ExtensionStatusProperties/AwsAutoTagging.cs create mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/DataProperties/ExtensionStatusProperties/GoogleAutoTagging.cs create mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/DataProperties/ExtensionStatusProperties/RemoveBg.cs create mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/DataProperties/VersionInfo.cs create mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/Request.cs create mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEvent.cs create mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/Data.cs create mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/DataProperties/Asset.cs create mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/DataProperties/Transformation.cs create mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/DataProperties/TransformationProperties/Options.cs create mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/DataProperties/TransformationProperties/OptionsProperties/AudioCodec.cs create mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/DataProperties/TransformationProperties/OptionsProperties/Format.cs create mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/DataProperties/TransformationProperties/OptionsProperties/StreamProtocol.cs create mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/DataProperties/TransformationProperties/OptionsProperties/VideoCodec.cs create mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/DataProperties/TransformationProperties/Type.cs create mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/Request.cs create mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationErrorEvent.cs create mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/Data.cs create mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/Asset.cs create mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/Transformation.cs create mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/TransformationProperties/Error.cs create mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/TransformationProperties/ErrorProperties/Reason.cs create mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/TransformationProperties/Options.cs create mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/TransformationProperties/OptionsProperties/AudioCodec.cs create mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/TransformationProperties/OptionsProperties/Format.cs create mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/TransformationProperties/OptionsProperties/StreamProtocol.cs create mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/TransformationProperties/OptionsProperties/VideoCodec.cs create mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/TransformationProperties/Type.cs create mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/Request.cs create mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationReadyEvent.cs create mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/Data.cs create mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/Asset.cs create mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/Transformation.cs create mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/TransformationProperties/Options.cs create mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/TransformationProperties/OptionsProperties/AudioCodec.cs create mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/TransformationProperties/OptionsProperties/Format.cs create mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/TransformationProperties/OptionsProperties/StreamProtocol.cs create mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/TransformationProperties/OptionsProperties/VideoCodec.cs create mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/TransformationProperties/Output.cs create mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/TransformationProperties/OutputProperties/VideoMetadata.cs create mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/TransformationProperties/Type.cs create mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/Request.cs create mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/Timings.cs create mode 100644 src/Imagekit/ParamsBase.cs create mode 100644 src/Imagekit/Services/Accounts/AccountService.cs create mode 100644 src/Imagekit/Services/Accounts/IAccountService.cs create mode 100644 src/Imagekit/Services/Accounts/Origins/IOriginService.cs create mode 100644 src/Imagekit/Services/Accounts/Origins/OriginService.cs create mode 100644 src/Imagekit/Services/Accounts/URLEndpoints/IURLEndpointService.cs create mode 100644 src/Imagekit/Services/Accounts/URLEndpoints/URLEndpointService.cs create mode 100644 src/Imagekit/Services/Accounts/Usage/IUsageService.cs create mode 100644 src/Imagekit/Services/Accounts/Usage/UsageService.cs create mode 100644 src/Imagekit/Services/Assets/AssetService.cs create mode 100644 src/Imagekit/Services/Assets/IAssetService.cs create mode 100644 src/Imagekit/Services/Beta/BetaService.cs create mode 100644 src/Imagekit/Services/Beta/IBetaService.cs create mode 100644 src/Imagekit/Services/Beta/V2/Files/FileService.cs create mode 100644 src/Imagekit/Services/Beta/V2/Files/IFileService.cs create mode 100644 src/Imagekit/Services/Beta/V2/IV2Service.cs create mode 100644 src/Imagekit/Services/Beta/V2/V2Service.cs create mode 100644 src/Imagekit/Services/Cache/CacheService.cs create mode 100644 src/Imagekit/Services/Cache/ICacheService.cs create mode 100644 src/Imagekit/Services/Cache/Invalidation/IInvalidationService.cs create mode 100644 src/Imagekit/Services/Cache/Invalidation/InvalidationService.cs create mode 100644 src/Imagekit/Services/CustomMetadataFields/CustomMetadataFieldService.cs create mode 100644 src/Imagekit/Services/CustomMetadataFields/ICustomMetadataFieldService.cs create mode 100644 src/Imagekit/Services/Files/Bulk/BulkService.cs create mode 100644 src/Imagekit/Services/Files/Bulk/IBulkService.cs create mode 100644 src/Imagekit/Services/Files/FileService.cs create mode 100644 src/Imagekit/Services/Files/IFileService.cs create mode 100644 src/Imagekit/Services/Files/Metadata/IMetadataService.cs create mode 100644 src/Imagekit/Services/Files/Metadata/MetadataService.cs create mode 100644 src/Imagekit/Services/Files/Versions/IVersionService.cs create mode 100644 src/Imagekit/Services/Files/Versions/VersionService.cs create mode 100644 src/Imagekit/Services/Folders/FolderService.cs create mode 100644 src/Imagekit/Services/Folders/IFolderService.cs create mode 100644 src/Imagekit/Services/Folders/Job/IJobService.cs create mode 100644 src/Imagekit/Services/Folders/Job/JobService.cs create mode 100644 src/Imagekit/Services/Webhooks/IWebhookService.cs create mode 100644 src/Imagekit/Services/Webhooks/WebhookService.cs diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json new file mode 100644 index 00000000..b9f69412 --- /dev/null +++ b/.config/dotnet-tools.json @@ -0,0 +1,13 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "csharpier": { + "version": "1.0.1", + "commands": [ + "csharpier" + ], + "rollForward": false + } + } +} \ No newline at end of file diff --git a/.editorconfig b/.editorconfig index 31f2b2a1..4287b5b4 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,229 +1,26 @@ -[*.cs] +root = true -# SA1600: Elements should be documented -dotnet_diagnostic.SA1600.severity = none +# All files +[*] +indent_style = space -# SA1117: Parameters should be on same line or separate lines -dotnet_diagnostic.SA1117.severity = none - -# SA1614: Element parameter documentation should have text -dotnet_diagnostic.SA1614.severity = none - -# SA1606: Element documentation should have summary text -dotnet_diagnostic.SA1606.severity = none - -# SA1402: File may only contain a single type -dotnet_diagnostic.SA1402.severity = none +# Xml files +[*.xml] +indent_size = 2 +# C# files [*.cs] -#### Naming styles #### - -# Naming rules - -dotnet_naming_rule.interface_should_be_begins_with_i.severity = warning -dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface -dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i - -dotnet_naming_rule.types_should_be_pascal_case.severity = warning -dotnet_naming_rule.types_should_be_pascal_case.symbols = types -dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case - -dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = warning -dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members -dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case - -# Symbol specifications - -dotnet_naming_symbols.interface.applicable_kinds = interface -dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected -dotnet_naming_symbols.interface.required_modifiers = - -dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum -dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected -dotnet_naming_symbols.types.required_modifiers = - -dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method -dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected -dotnet_naming_symbols.non_field_members.required_modifiers = - -# Naming styles - -dotnet_naming_style.begins_with_i.required_prefix = I -dotnet_naming_style.begins_with_i.required_suffix = -dotnet_naming_style.begins_with_i.word_separator = -dotnet_naming_style.begins_with_i.capitalization = pascal_case - -dotnet_naming_style.pascal_case.required_prefix = -dotnet_naming_style.pascal_case.required_suffix = -dotnet_naming_style.pascal_case.word_separator = -dotnet_naming_style.pascal_case.capitalization = pascal_case - -dotnet_naming_style.pascal_case.required_prefix = -dotnet_naming_style.pascal_case.required_suffix = -dotnet_naming_style.pascal_case.word_separator = -dotnet_naming_style.pascal_case.capitalization = pascal_case -csharp_using_directive_placement = outside_namespace:silent -csharp_prefer_simple_using_statement = true:suggestion -csharp_prefer_braces = true:silent -csharp_style_namespace_declarations = block_scoped:silent -csharp_style_prefer_method_group_conversion = true:silent -csharp_style_expression_bodied_methods = false:silent -csharp_style_expression_bodied_constructors = false:silent -csharp_style_expression_bodied_operators = false:silent -csharp_style_expression_bodied_properties = true:silent -csharp_style_expression_bodied_indexers = true:silent -csharp_style_expression_bodied_accessors = true:silent -csharp_style_expression_bodied_lambdas = true:silent -csharp_style_expression_bodied_local_functions = false:silent -csharp_indent_labels = one_less_than_current -csharp_space_around_binary_operators = before_and_after -csharp_style_throw_expression = true:suggestion -csharp_style_prefer_null_check_over_type_check = true:suggestion -csharp_prefer_simple_default_expression = true:suggestion -csharp_style_prefer_local_over_anonymous_function = true:suggestion -csharp_style_prefer_index_operator = true:suggestion -csharp_style_prefer_range_operator = true:suggestion -csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion -csharp_style_prefer_tuple_swap = true:suggestion -csharp_style_inlined_variable_declaration = true:suggestion -csharp_style_deconstructed_variable_declaration = true:suggestion -csharp_style_unused_value_assignment_preference = discard_variable:suggestion -csharp_style_unused_value_expression_statement_preference = discard_variable:silent -csharp_prefer_static_local_function = true:suggestion -csharp_style_allow_embedded_statements_on_same_line_experimental = true:silent -csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true:silent -csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true:silent -csharp_style_conditional_delegate_call = true:suggestion -csharp_style_prefer_parameter_null_checking = true:suggestion -csharp_style_prefer_switch_expression = true:suggestion -csharp_style_prefer_pattern_matching = true:silent -csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion -csharp_style_pattern_matching_over_as_with_null_check = true:suggestion -csharp_style_prefer_not_pattern = true:suggestion -csharp_style_prefer_extended_property_pattern = true:suggestion -csharp_style_var_for_built_in_types = false:none -csharp_style_var_when_type_is_apparent = false:none -csharp_style_var_elsewhere = false:none - -# CS8632: The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. -dotnet_diagnostic.CS8632.severity = none - -# SA1310: Field names should not contain underscore -dotnet_diagnostic.SA1310.severity = none - -# IDE0051: Remove unused private members -dotnet_diagnostic.IDE0051.severity = none - -# SA1300: Element should begin with upper-case letter -dotnet_diagnostic.SA1300.severity = none - -# IDE1006: Naming Styles -dotnet_diagnostic.IDE1006.severity = none - -# SA1307: Accessible fields should begin with upper-case letter -dotnet_diagnostic.SA1307.severity = none -# SA1202: Elements should be ordered by access -dotnet_diagnostic.SA1202.severity = none +#### Core EditorConfig Options #### -# SA1201: Elements should appear in the correct order -dotnet_diagnostic.SA1201.severity = none - -# SA1306: Field names should begin with lower-case letter -dotnet_diagnostic.SA1306.severity = none - -# IDE0008: Use explicit type -dotnet_diagnostic.IDE0008.severity = none - -# SA1116: Split parameters should start on line after declaration -dotnet_diagnostic.SA1116.severity = none - -[*.vb] -#### Naming styles #### - -# Naming rules - -dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion -dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface -dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i - -dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion -dotnet_naming_rule.types_should_be_pascal_case.symbols = types -dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case - -dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion -dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members -dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case - -# Symbol specifications - -dotnet_naming_symbols.interface.applicable_kinds = interface -dotnet_naming_symbols.interface.applicable_accessibilities = public, friend, private, protected, protected_friend, private_protected -dotnet_naming_symbols.interface.required_modifiers = - -dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum -dotnet_naming_symbols.types.applicable_accessibilities = public, friend, private, protected, protected_friend, private_protected -dotnet_naming_symbols.types.required_modifiers = - -dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method -dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, friend, private, protected, protected_friend, private_protected -dotnet_naming_symbols.non_field_members.required_modifiers = - -# Naming styles - -dotnet_naming_style.begins_with_i.required_prefix = I -dotnet_naming_style.begins_with_i.required_suffix = -dotnet_naming_style.begins_with_i.word_separator = -dotnet_naming_style.begins_with_i.capitalization = pascal_case - -dotnet_naming_style.pascal_case.required_prefix = -dotnet_naming_style.pascal_case.required_suffix = -dotnet_naming_style.pascal_case.word_separator = -dotnet_naming_style.pascal_case.capitalization = pascal_case - -dotnet_naming_style.pascal_case.required_prefix = -dotnet_naming_style.pascal_case.required_suffix = -dotnet_naming_style.pascal_case.word_separator = -dotnet_naming_style.pascal_case.capitalization = pascal_case - -[*.{cs,vb}] -dotnet_style_operator_placement_when_wrapping = beginning_of_line -tab_width = 4 +# Indentation and spacing indent_size = 4 -end_of_line = crlf +tab_width = 4 -# Default severity for analyzer diagnostics with category 'StyleCop.CSharp.DocumentationRules' -dotnet_analyzer_diagnostic.category-StyleCop.CSharp.DocumentationRules.severity = none -dotnet_style_coalesce_expression = true:suggestion -dotnet_style_null_propagation = true:suggestion -dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion -dotnet_style_prefer_auto_properties = true:none -dotnet_style_object_initializer = true:suggestion -dotnet_style_collection_initializer = true:suggestion -dotnet_style_prefer_simplified_boolean_expressions = true:suggestion -dotnet_style_prefer_conditional_expression_over_assignment = true:silent -dotnet_style_prefer_conditional_expression_over_return = true:silent -dotnet_style_explicit_tuple_names = true:suggestion -dotnet_style_prefer_inferred_tuple_names = true:suggestion -dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion -dotnet_style_prefer_compound_assignment = true:suggestion -dotnet_style_prefer_simplified_interpolation = true:suggestion -dotnet_style_namespace_match_folder = true:suggestion -dotnet_style_readonly_field = true:suggestion -dotnet_style_predefined_type_for_locals_parameters_members = true:silent -dotnet_style_predefined_type_for_member_access = true:silent -dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent -dotnet_style_allow_multiple_blank_lines_experimental = true:silent -dotnet_style_allow_statement_immediately_after_block_experimental = true:silent -dotnet_code_quality_unused_parameters = all:suggestion -dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent -dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent -dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent -dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent -dotnet_style_qualification_for_field = false:silent -dotnet_style_qualification_for_property = false:silent -dotnet_style_qualification_for_method = false:silent -dotnet_style_qualification_for_event = false:silent +# New line preferences +end_of_line = crlf +insert_final_newline = true -# IDE0032: Use auto property -dotnet_diagnostic.IDE0032.severity = none +dotnet_diagnostic.IDE0060.severity = none # Caused by resource with no methods and no subresources +dotnet_diagnostic.IDE1006.severity = none # Some names may not match up with C# conventions +dotnet_diagnostic.IDE0290.severity = none # Don't prefer primary constructors diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1ff0c423..00000000 --- a/.gitattributes +++ /dev/null @@ -1,63 +0,0 @@ -############################################################################### -# Set default behavior to automatically normalize line endings. -############################################################################### -* text=auto - -############################################################################### -# Set default behavior for command prompt diff. -# -# This is need for earlier builds of msysgit that does not have it on by -# default for csharp files. -# Note: This is only used by command line -############################################################################### -#*.cs diff=csharp - -############################################################################### -# Set the merge driver for project and solution files -# -# Merging from the command prompt will add diff markers to the files if there -# are conflicts (Merging from VS is not affected by the settings below, in VS -# the diff markers are never inserted). Diff markers may cause the following -# file extensions to fail to load in VS. An alternative would be to treat -# these files as binary and thus will always conflict and require user -# intervention with every merge. To do so, just uncomment the entries below -############################################################################### -#*.sln merge=binary -#*.csproj merge=binary -#*.vbproj merge=binary -#*.vcxproj merge=binary -#*.vcproj merge=binary -#*.dbproj merge=binary -#*.fsproj merge=binary -#*.lsproj merge=binary -#*.wixproj merge=binary -#*.modelproj merge=binary -#*.sqlproj merge=binary -#*.wwaproj merge=binary - -############################################################################### -# behavior for image files -# -# image files are treated as binary by default. -############################################################################### -#*.jpg binary -#*.png binary -#*.gif binary - -############################################################################### -# diff behavior for common document formats -# -# Convert binary document formats to text before diffing them. This feature -# is only available from the command line. Turn it on by uncommenting the -# entries below. -############################################################################### -#*.doc diff=astextplain -#*.DOC diff=astextplain -#*.docx diff=astextplain -#*.DOCX diff=astextplain -#*.dot diff=astextplain -#*.DOT diff=astextplain -#*.pdf diff=astextplain -#*.PDF diff=astextplain -#*.rtf diff=astextplain -#*.RTF diff=astextplain diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..34f30288 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,63 @@ +name: CI +on: + push: + branches-ignore: + - 'generated' + - 'codegen/**' + - 'integrated/**' + - 'stl-preview-head/**' + - 'stl-preview-base/**' + pull_request: + branches-ignore: + - 'stl-preview-head/**' + - 'stl-preview-base/**' + +jobs: + lint: + timeout-minutes: 10 + name: lint + runs-on: ${{ github.repository == 'stainless-sdks/imagekit-csharp' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + if: github.event_name == 'push' || github.event.pull_request.head.repo.fork + + steps: + - uses: actions/checkout@v4 + + - name: Set up .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: '8.0.x' + + - name: Run lints + run: ./scripts/lint + build: + timeout-minutes: 10 + name: build + runs-on: ${{ github.repository == 'stainless-sdks/imagekit-csharp' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + if: github.event_name == 'push' || github.event.pull_request.head.repo.fork + + steps: + - uses: actions/checkout@v4 + + - name: Set up .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: '8.0.x' + + - name: Build SDK + run: ./scripts/build + + test: + timeout-minutes: 10 + name: test + runs-on: ${{ github.repository == 'stainless-sdks/imagekit-csharp' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + if: github.event_name == 'push' || github.event.pull_request.head.repo.fork + steps: + - uses: actions/checkout@v4 + + - name: Set up .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: '8.0.x' + + - name: Run tests + run: ./scripts/test diff --git a/.github/workflows/dotnet-core.yml b/.github/workflows/dotnet-core.yml deleted file mode 100644 index 794d8934..00000000 --- a/.github/workflows/dotnet-core.yml +++ /dev/null @@ -1,83 +0,0 @@ -name: CI Pipeline - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - release: - types: - - published -env: - # Disable the .NET logo in the console output. - DOTNET_NOLOGO: true - # Stop wasting time caching packages - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - # Disable sending usage data to Microsoft - DOTNET_CLI_TELEMETRY_OPTOUT: true - GITHUB_FEED: https://nuget.pkg.github.com/cloudmeteor/index.json - GITHUB_USER: cloudmeteor - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NUGET_FEED: https://api.nuget.org/v3/index.json - NUGET_KEY: ${{ secrets.NUGET_APIKEY }} - ATTRIBUTE_NAME: nupkg - NUGET_OUTPUT_PATH: nuget-package - Solution_Name: Imagekit.sln - -jobs: - build: - name: Build and test - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@master - - - name: Setup .NET - uses: actions/setup-dotnet@v1 - with: - dotnet-version: | - 2.1.x - 3.1.x - 5.0.x - 6.0.x - 7.0.x - 8.0.x - - name: Build Release - run: dotnet build Imagekit.sln -c Release /p:ContinuousIntegrationBuild=true - - # run: dotnet test --no-build Imagekit.UnitTests/Imagekit.UnitTests.csproj -c Release - - name: Run test suite - run: dotnet test Imagekit.UnitTests/Imagekit.UnitTests.csproj --verbosity minimal /p:CollectCoverage=true /p:CoverletOutputFormat=opencover - - - name: Upload Coverage to Codecov - uses: codecov/codecov-action@v1 - with: - file: ./Imagekit.UnitTests/coverage.net6.0.opencover.xml - - - name: Pack - run: dotnet pack Imagekit.sln -c Release --no-build --output ${{ env.NUGET_OUTPUT_PATH }} - - - name: 'Upload Artifact' - uses: actions/upload-artifact@v3 - with: - name: ${{ env.ATTRIBUTE_NAME }} - path: ${{ env.NUGET_OUTPUT_PATH }} - - Publish: - needs: build - if: (github.event_name == 'release') || (github.ref == 'refs/tags/*') - runs-on: ubuntu-latest - steps: - - name: Download all workflow run artifacts - uses: actions/download-artifact@v3 - with: - name: ${{ env.ATTRIBUTE_NAME }} - - - name: Setup .NET - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 6.0.x - - - name: Publish NuGet packages to NuGet - run: dotnet nuget push "*.nupkg" -k ${{ secrets.NUGET_APIKEY }} --source ${{ env.NUGET_FEED }} --no-symbols true --skip-duplicate diff --git a/.gitignore b/.gitignore index b3a7da81..cd42ee34 100644 --- a/.gitignore +++ b/.gitignore @@ -1,266 +1,2 @@ -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. - -# User-specific files -*.suo -*.user -*.userosscache -*.sln.docstates - -# User-specific files (MonoDevelop/Xamarin Studio) -*.userprefs - -# Build results -[Dd]ebug/ -[Dd]ebugPublic/ -[Rr]elease/ -[Rr]eleases/ -x64/ -x86/ -bld/ -[Bb]in/ -[Oo]bj/ -[Ll]og/ - -# Visual Studio 2015 cache/options directory -.vs/ -# Uncomment if you have tasks that create the project's static files in wwwroot -#wwwroot/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -# NUNIT -*.VisualState.xml -TestResult.xml - -# Build Results of an ATL Project -[Dd]ebugPS/ -[Rr]eleasePS/ -dlldata.c - -# DNX -project.lock.json -project.fragment.lock.json -artifacts/ - -*_i.c -*_p.c -*_i.h -*.ilk -*.meta -*.obj -*.pch -*.pdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.svclog -*.scc - -# Chutzpah Test files -_Chutzpah* - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opendb -*.opensdf -*.sdf -*.cachefile -*.VC.db -*.VC.VC.opendb - -# Visual Studio profiler -*.psess -*.vsp -*.vspx -*.sap - -# TFS 2012 Local Workspace -$tf/ - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper -*.DotSettings.user - -# JustCode is a .NET coding add-in -.JustCode - -# TeamCity is a build add-in -_TeamCity* - -# Code Coverage -*.dotCover -coverage.cobertura.xml -coverage.info -CoverageReport - - -# NCrunch -_NCrunch_* -.*crunch*.local.xml -nCrunchTemp_* - -# MightyMoose -*.mm.* -AutoTest.Net/ - -# Web workbench (sass) -.sass-cache/ - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.[Pp]ublish.xml -*.azurePubxml -# TODO: Comment the next line if you want to checkin your web deploy settings -# but database connection strings (with potential passwords) will be unencrypted -#*.pubxml -*.publishproj - -# Microsoft Azure Web App publish settings. Comment the next line if you want to -# checkin your Azure Web App publish settings, but sensitive information contained -# in these scripts will be unencrypted -PublishScripts/ - -# NuGet Packages -*.nupkg -# The packages folder can be ignored because of Package Restore -**/packages/* -# except build/, which is used as an MSBuild target. -!**/packages/build/ -# Uncomment if necessary however generally it will be regenerated when needed -#!**/packages/repositories.config -# NuGet v3's project.json files produces more ignoreable files -*.nuget.props -*.nuget.targets - -# Microsoft Azure Build Output -csx/ -*.build.csdef - -# Microsoft Azure Emulator -ecf/ -rcf/ - -# Windows Store app package directories and files -AppPackages/ -BundleArtifacts/ -Package.StoreAssociation.xml -_pkginfo.txt - -# Visual Studio cache files -# files ending in .cache can be ignored -*.[Cc]ache -# but keep track of directories ending in .cache -!*.[Cc]ache/ - -# Others -ClientBin/ -~$* -*~ -*.dbmdl -*.dbproj.schemaview -*.jfm -*.pfx -*.publishsettings -node_modules/ -orleans.codegen.cs - -# Since there are multiple workflows, uncomment next line to ignore bower_components -# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) -#bower_components/ - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file -# to a newer Visual Studio version. Backup files are not needed, -# because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm - -# SQL Server files -*.mdf -*.ldf - -# Business Intelligence projects -*.rdl.data -*.bim.layout -*.bim_*.settings - -# Microsoft Fakes -FakesAssemblies/ - -# GhostDoc plugin setting file -*.GhostDoc.xml - -# Node.js Tools for Visual Studio -.ntvs_analysis.dat - -# Visual Studio 6 build log -*.plg - -# Visual Studio 6 workspace options file -*.opt - -# Visual Studio LightSwitch build output -**/*.HTMLClient/GeneratedArtifacts -**/*.DesktopClient/GeneratedArtifacts -**/*.DesktopClient/ModelManifest.xml -**/*.Server/GeneratedArtifacts -**/*.Server/ModelManifest.xml -_Pvt_Extensions - -# Paket dependency manager -.paket/paket.exe -paket-files/ - -# FAKE - F# Make -.fake/ - -# JetBrains Rider -.idea/ -*.sln.iml - -# CodeRush -.cr/ - -# Python Tools for Visual Studio (PTVS) -__pycache__/ -*.pyc -.DS_Store \ No newline at end of file +bin/ +obj/ diff --git a/.stats.yml b/.stats.yml new file mode 100644 index 00000000..85924bea --- /dev/null +++ b/.stats.yml @@ -0,0 +1,4 @@ +configured_endpoints: 42 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-3d7da4b8ef2ed30aa32c4fb3e98e498e67402e91aaa5fd4c628fc080bfe82ea1.yml +openapi_spec_hash: aaa50fcbccec6f2cf1165f34bc6ac886 +config_hash: 9a8f470bf5b8ed9abcbefb7a7cb68979 diff --git a/.vscode/tasks.json b/.vscode/tasks.json deleted file mode 100644 index 180d9fb6..00000000 --- a/.vscode/tasks.json +++ /dev/null @@ -1,123 +0,0 @@ -{ - "version": "2.0.0", - "tasks": [ - { - "label": "build", - "command": "dotnet", - "type": "process", - "args": [ - "build", - "${workspaceFolder}/Imagekit.UnitTests/Imagekit.UnitTests.csproj", - "/property:GenerateFullPaths=true", - "/consoleloggerparameters:NoSummary" - ], - "problemMatcher": "$msCompile" - }, - { - "label": "build", - "command": "dotnet", - "type": "shell", - "args": [ - "build", - "${workspaceRoot}/Imagekit/Imagekit.csproj", - "-f", - "netstandard2.1" - ], - "group": { - "kind": "build", - "isDefault": true - }, - "presentation": { - "panel": "shared", - "clear": true - }, - "problemMatcher": { - "base": "$msCompile", - "fileLocation": [ - "relative", - "${workspaceFolder}" - ] - } - }, - { - "label": "test", - "group": { - "kind": "test", - "isDefault": true - }, - "type": "process", - "command": "dotnet", - "args": [ - "test", - "${workspaceRoot}/Imagekit.UnitTests/Imagekit.UnitTests.csproj", - "--logger", - "html", - "/p:Configuration=Debug", - "/p:CollectCoverage=true", - "/p:CoverletOutputFormat=cobertura%2clcov", - "/p:Exclude=[*Tests]*" - ], - "presentation": { - "echo": true, - "reveal": "always", - "focus": true, - "panel": "shared", - "showReuseMessage": true, - "clear": true - } - }, - { - "label": "generate test coverage report", - "group": "none", - "command": "dotnet", - "type": "shell", - "args": [ - "reportgenerator", - "\"-reports:${workspaceRoot}/Imagekit.UnitTests/coverage.cobertura.xml\"", - "\"-targetdir:${workspaceRoot}/Imagekit.UnitTests/CoverageReport\"", - "-reportTypes:htmlInline" - ], - "options": { - "cwd": "${workspaceFolder}/Imagekit.UnitTests" - }, - "dependsOn": [ - "test" - ], - "presentation": { - "echo": true, - "reveal": "always", - "focus": true, - "panel": "shared", - "showReuseMessage": true, - "clear": false - }, - "problemMatcher": [] - }, - { - "label": "open test coverage report", - "group": "none", - "osx": { - "command": "open" - }, - "windows": { - "command": "start" - }, - "type": "shell", - "args": [ - "${workspaceRoot}/Imagekit.UnitTests/CoverageReport/index.htm" - ], - "problemMatcher": [], - "dependsOn": [ - "generate test coverage report" - ], - "presentation": { - "echo": true, - "reveal": "always", - "focus": true, - "panel": "shared", - "showReuseMessage": true, - "clear": true - } - } - ] -} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 25fd627e..00000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,74 +0,0 @@ -# Changelog -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - -## [5.0.0] - -### Breaking changes - -**Overlay syntax update** -* In version 5.0.0, we've removed the old overlay syntax parameters for transformations, such as `oi`, `ot`, `obg`, and [more](https://docs.imagekit.io/features/image-transformations/overlay). These parameters are deprecated and will start returning errors when used in URLs. Please migrate to the new layers syntax that supports overlay nesting, provides better positional control, and allows more transformations at the layer level. You can start with [examples](https://docs.imagekit.io/features/image-transformations/overlay-using-layers#examples) to learn quickly. -* You can migrate to the new layers syntax using the `raw` transformation parameter. - -### Added -- Parameters `EffectShadow` and `EffectGradient` for url generation. -- Upload options - - `transformation` for applying `pre` and `post` transformations. - - `checks` to perform server-side validations before file uploads. - - `isPublished` determines whether the file should be uploaded as published. -- Update parameter - - `publish` to configure the publication status of a file and its versions. - -## [4.0.1] -### Fixed -- https://github.com/imagekit-developer/imagekit-dotnet/issues/50 - -## [4.0.0] -### Fixed -- https://github.com/imagekit-developer/imagekit-dotnet/issues/37 -- https://github.com/imagekit-developer/imagekit-dotnet/issues/41 -- https://github.com/imagekit-developer/imagekit-dotnet/issues/40 -- https://github.com/imagekit-developer/imagekit-dotnet/issues/38 -- https://github.com/imagekit-developer/imagekit-dotnet/issues/34 - -## [3.1.6] - 2021-07-21 -### Fixed -- Bug Fix - -## [3.1.5] - 2021-06-05 -### Changed -- Sort, searchQuery options added for ListAPI -- API reponse fields updated - -## [3.1.4] - 2021-04-12 -### Fixed -- Core package install bug fix - -## [3.1.3] - 2020-11-05 -### Fixed -- Delete Api bug fix - -## [3.1.2] - 2020-11-04 -### Fixed -- Upload Api fix - -## [3.1.1] - 2020-09-11 -### Changed -- Fix issue where tags were not set in some cases when uploading a file -- Allow more ways to set tags when updating file details - -## [3.1.0] - 2020-09-03 -### Added -- Async methods for all asynchronous calls -- `ClientImagekit` that supports client upload without the private key -- Support for .NET Standard 2.1 -- `ImagekitResponse.FileId` -- Some XML documentation - -### Changed -- The `Imagekit.Imagekit` class is deprecated; use `ServerImagekit` instead -- Fix issue where `isPrivateFile` was not included on upload -- Fix issue where type of `Gps.GPSLatitude`, `Gps.GPSLongitude`, and `GPSTimeStamp` was incorrect -- Some of the `ArgumentException`s are now `ArgumentNullException` and set the `ParamName` property of the exception. This is not a binary breaking change as `ArgumentNullException` inherits from `ArgumentException`, but if you are specifically looking for the `ArgumentException` type exactly, you may see a runtime issue, although this is very unlikely. diff --git a/ImageKitSample/Program.cs b/ImageKitSample/Program.cs deleted file mode 100644 index 093bb84e..00000000 --- a/ImageKitSample/Program.cs +++ /dev/null @@ -1,482 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - -namespace ImagekitSample -{ - using System; - using System.Collections; - using System.Collections.Generic; - using System.Net; - using Imagekit; - using Imagekit.Models; - using Imagekit.Models.Response; - using Imagekit.Sdk; - using Newtonsoft.Json.Linq; - using static Imagekit.Models.CustomMetaDataFieldSchemaObject; - - internal class Program - { - static void Main(string[] args) - { - - // Create Instance of ImageKit - ImagekitClient imagekit = new ImagekitClient("your_public_key", "your_private_key", "https://ik.imagekit.io/your_imagekit_id/endpoint"); - #region URL Generation - - - // Generating URLs - - string path = "/default_image.jpg"; - Transformation trans = new Transformation() - .Width(400) - .Height(300) - .AspectRatio("4-3") - .Quality(40) - .Crop("force").CropMode("extract"). - Focus("left"). - Format("jpeg"). - Background("A94D34"). - Border("5-A94D34"). - Rotation(90). - Blur(10). - Named("some_name"). - Progressive(true). - Lossless(true). - Trim(5). - Metadata(true). - ColorProfile(true). - DefaultImage("folder/file_name.jpg/"). //trailing slash case - Dpr(3). - EffectSharpen(10). - EffectUsm("2-2-0.8-0.024"). - EffectContrast(true). - EffectGray(). - EffectShadow(). - EffectGradient(). - Original(). - Raw("h-200,w-300,l-image,i-logo.png,l-end"); - - string imageUrl = imagekit.Url(trans).Path(path).TransformationPosition("query").Generate(); - - Console.WriteLine("Generated image URL - {0}", imageUrl); - - ///// Generating Signed URL - var imgUrl1 = "https://ik.imagekit.io/demo/default-image.jpg"; - string[] queryParams = { "b=query", "a=value" }; - try - { - var signedUrl = imagekit.Url(new Transformation().Width(400).Height(300)) - .Src(imgUrl1) - .QueryParameters(queryParams) - .ExpireSeconds(600) - .Signed() - .Generate(); - Console.WriteLine("Signed Url for first image transformed with height: 300, width: 400: - {0}", signedUrl); - } - catch (Exception ex) - { - Console.WriteLine(ex.Message); - } - #endregion - - #region Upload BY URI| Bytes | Base64 - - // Upload By URI - FileCreateRequest request = new FileCreateRequest - { - file = "http://www.google.com/images/logos/ps_logo2.png", - fileName = "file_name.jpg" - }; - Result resp1 = imagekit.Upload(request); - - // Upload by bytes - var webClient = new WebClient(); - byte[] bytes = webClient.DownloadData("http://www.google.com/images/logos/ps_logo2.png"); - - FileCreateRequest ob = new FileCreateRequest - { - file = bytes, - fileName = "file_name1.jpg" - }; - List tags = new List - { - "Software", - "Developer", - "Engineer" - }; - ob.tags = tags; - - string customCoordinates = "10,10,20,20"; - ob.customCoordinates = customCoordinates; - List responseFields = new List - { - "isPrivateFile", - "tags", - "customCoordinates" - }; - ob.responseFields = responseFields; - List ext = new List(); - BackGroundImage bck1 = new BackGroundImage - { - name = "remove-bg", - options = new options() - { add_shadow = true, semitransparency = false, bg_image_url = "http://www.google.com/images/logos/ps_logo2.png" } - }; - AutoTags autoTags = new AutoTags - { - name = "google-auto-tagging", - maxTags = 5, - minConfidence = 95 - }; - TransformationObject transformationObject = new TransformationObject - { - type = "transformation", - value = "w-100" - }; - List postTransformations = new List(); - postTransformations.Add(transformationObject); - UploadTransformation uploadTransformation = new UploadTransformation - { - pre = "l-text,i-Imagekit,fs-50,l-end", - post = postTransformations, - }; - ext.Add(bck1); - ext.Add(autoTags); - ob.extensions = ext; - ob.webhookUrl = "https://webhook.site/c78d617f_33bc_40d9_9e61_608999721e2e"; - ob.useUniqueFileName = true; - ob.folder = "dummy_folder"; - ob.isPrivateFile = false; - ob.overwriteFile = true; - ob.overwriteAITags = true; - ob.overwriteTags = true; - ob.overwriteCustomMetadata = true; - ob.transformation= uploadTransformation; - Result resp2 = imagekit.Upload(ob); - - // Get Base64 - byte[] bytes1 = webClient.DownloadData("http://www.google.com/images/logos/ps_logo2.png"); - - byte[] imageArray = bytes1; - string base64ImageRepresentation = Convert.ToBase64String(imageArray); - - // Upload by Base64 - FileCreateRequest ob2 = new FileCreateRequest - { - file = base64ImageRepresentation, - fileName = Guid.NewGuid().ToString() - }; - Result resp = imagekit.Upload(ob2); - #endregion - - #region UpdateFile - - //Update File Request - FileUpdateRequest updateob = new FileUpdateRequest - { - fileId = "fileId", - }; - List updatetags = new List - { - "Software", - "Developer", - "Engineer" - }; - updateob.tags = updatetags; - - string updatecustomCoordinates = "10,10,20,20"; - updateob.customCoordinates = updatecustomCoordinates; - List updateresponseFields = new List - { - "isPrivateFile", - "tags", - "customCoordinates" - }; - - List extModel = new List(); - BackGroundImage bck = new BackGroundImage - { - name = "remove-bg", - options = new options() { add_shadow = true, semitransparency = false, bg_color = "green" } - }; - extModel.Add(bck); - updateob.extensions = extModel; - updateob.webhookUrl = "https://webhook.site/c78d617f_33bc_40d9_9e61_608999721e2e"; - - Result updateresp = imagekit.UpdateFileDetail(updateob); - - #endregion - - #region File Management - - // List and search files - GetFileListRequest model = new GetFileListRequest - { - Name = "file_name.jpg", - Type = "file", - Limit = 10, - Skip = 0, - Sort = "ASC_CREATED", - SearchQuery = "createdAt >= \"7d\"", - FileType = "image", - Tags = new string[] { "sale", "summer" }, - Path = "/" - }; - ResultList res = imagekit.GetFileListRequest(model); - - // Get File Details - Result res1 = imagekit.GetFileDetail("file_Id"); - - // Delete File by FileId - ResultDelete res2 = imagekit.DeleteFile("file_Id"); - - // Bulk Delete - List ob3 = new List(); - ob3.Add("fileId_1"); - ob3.Add("fileId_2"); - ResultFileDelete resultFileDelete = imagekit.BulkDeleteFiles(ob3); - - // Copy File - CopyFileRequest cpyRequest = new CopyFileRequest - { - sourceFilePath = "path_1", - destinationPath = "path_2" - }; - ResultNoContent resultNoContent = imagekit.CopyFile(cpyRequest); - - // MoveFile - MoveFileRequest moveFile = new MoveFileRequest - { - sourceFilePath = "path_1", - destinationPath = "path_2" - }; - ResultNoContent resultNoContentMoveFile = imagekit.MoveFile(moveFile); - - // RenameFile - RenameFileRequest renameFileRequest = new RenameFileRequest - { - filePath = "path_1", - newFileName = "file_name", - purgeCache = false - }; - ResultRenameFile resultRenameFile = imagekit.RenameFile(renameFileRequest); - - #endregion - - #region Tags - TagsRequest tagsRequest = new TagsRequest - { - tags = new List - { - "tag_1", - "tag_2" - }, - fileIds = new List - { - "fileId_1", - }, - }; - ResultTags resultTags = imagekit.AddTags(tagsRequest); - - TagsRequest removeTagsRequest = new TagsRequest - { - tags = new List - { - "tag_1", - "tag_2" - }, - fileIds = new List - { - "fileId_1", - }, - }; - ResultTags removeTags = imagekit.RemoveTags(removeTagsRequest); - - AITagsRequest removeAITagsRequest = new AITagsRequest - { - AITags = new List - { - "tag_1", - "tag_2" - }, - fileIds = new List - { - "fileId_1", - }, - }; - ResultTags removeAITags = imagekit.RemoveAITags(removeAITagsRequest); - - #endregion - - #region FileVersionRequest - DeleteFileVersionRequest delRequest = new DeleteFileVersionRequest - { - fileId = "file_Id", - versionId = "version_Id" - }; - ResultNoContent resultNoContent1 = imagekit.DeleteFileVersion(delRequest); - - // RestoreFileVersion - Result result = imagekit.RestoreFileVersion("file_Id", "version_Id"); - - // GetFileVersions - ResultFileVersions resultFileVersions = imagekit.GetFileVersions("file_Id"); - - // GetFileVersionDetails - ResultFileVersionDetails resultFileVersionDetails = imagekit.GetFileVersionDetails("file_Id", "version_Id"); - - #endregion - - #region ManageFolder - - CreateFolderRequest createFolderRequest = new CreateFolderRequest - { - folderName = "folder_name", - parentFolderPath = "source/folder/path" - }; - ResultEmptyBlock resultEmptyBlock = imagekit.CreateFolder(createFolderRequest); - - // DeleteFolderRequest - DeleteFolderRequest deleteFolderRequest = new DeleteFolderRequest - { - folderPath = "source/folder/path/folder_name", - }; - ResultNoContent resultNoContent2 = imagekit.DeleteFolder(deleteFolderRequest); - - // CopyFolder - CopyFolderRequest cpyFolderRequest = new CopyFolderRequest - { - sourceFolderPath = "path_1", - destinationPath = "path_2", - includeFileVersions = true - }; - - ResultOfFolderActions resultOfFolderActions = imagekit.CopyFolder(cpyFolderRequest); - - // MoveFolder - MoveFolderRequest moveFolderRequest = new MoveFolderRequest - { - sourceFolderPath = "path_1", - destinationPath = "path_2" - }; - - ResultOfFolderActions resultOfFolderActions1 = imagekit.MoveFolder(moveFolderRequest); - - #endregion - - #region GetBulkJobStatus - ResultBulkJobStatus resultBulkJobStatus = imagekit.GetBulkJobStatus("job_Id"); - - #endregion - - #region Purge - - ResultCache resultCache = imagekit.PurgeCache("url"); - - ResultCacheStatus resultCacheStatus = imagekit.PurgeStatus("request_Id"); - - #endregion - - #region Metadata - ResultMetaData resultMetaData = imagekit.GetFileMetadata("file_Id"); - - ResultMetaData resultMetaData1 = imagekit.GetRemoteFileMetadata("https://ik.imagekit.io/demo/medium_cafe_B1iTdD0C.jpg"); - - // CustomMetaDataFields - ResultCustomMetaDataFieldList resultCustomMetaDataFieldList = imagekit.GetCustomMetaDataFields(true); - - // CreateCustomMetaDataFields - CustomMetaDataFieldCreateRequest requestModelDate = new CustomMetaDataFieldCreateRequest - { - name = "custom_meta_Date", - label = "TestmetaDat" - }; - CustomMetaDataFieldSchemaObject schemaDate = new CustomMetaDataFieldSchemaObject - { - type = CustomMetaDataTypeEnum.Date.ToString(), - minValue = "2022-11-30T10:11:10+00:00", - maxValue = "2022-12-30T10:11:10+00:00", - isValueRequired = true, - defaultValue = "2022-12-30T10:11:10+00:00" - }; - - requestModelDate.schema = schemaDate; - ResultCustomMetaDataField resultCustomMetaDataFieldDate = imagekit.CreateCustomMetaDataFields(requestModelDate); - - - CustomMetaDataFieldCreateRequest requestModel = new CustomMetaDataFieldCreateRequest - { - name = "custom_meta_1", - label = "Testmeta" - }; - CustomMetaDataFieldSchemaObject schema = new CustomMetaDataFieldSchemaObject - { - type = CustomMetaDataTypeEnum.Number.ToString(), - minValue = 2000, - maxValue = 3000, - isValueRequired = true, - defaultValue = 2500 - }; - - requestModel.schema = schema; - ResultCustomMetaDataField resultCustomMetaDataField1 = imagekit.CreateCustomMetaDataFields(requestModel); - - CustomMetaDataFieldCreateRequest requestModel1 = new CustomMetaDataFieldCreateRequest - { - name = "custom_meta_2", - label = "Testmeta" - }; - CustomMetaDataFieldSchemaObject schema1 = new CustomMetaDataFieldSchemaObject - { - type = CustomMetaDataTypeEnum.Text.ToString(), - minLength = 1000, - maxLength = 2000, - isValueRequired = true, - defaultValue = "2500" - }; - - requestModel1.schema = schema1; - ResultCustomMetaDataField resultCustomMetaDataField = imagekit.CreateCustomMetaDataFields(requestModel1); - - CustomMetaDataFieldCreateRequest requestModelSelect = new CustomMetaDataFieldCreateRequest - { - name = "custom_meta_Select1", - label = "TestmetaSelect1" - }; - CustomMetaDataFieldSchemaObject schemaSelect = new CustomMetaDataFieldSchemaObject - { - type = CustomMetaDataTypeEnum.SingleSelect.ToString(), - selectOptions = new string[] { "small", "medium", "large" }, - isValueRequired = true, - defaultValue = "medium" - }; - requestModelSelect.schema = schemaSelect; - ResultCustomMetaDataField resultCustomMetaDataFieldSelect = imagekit.CreateCustomMetaDataFields(requestModelSelect); - - - // UpdateCustomMetaDataFields - CustomMetaDataFieldUpdateRequest requestUpdateModel = new CustomMetaDataFieldUpdateRequest - { - Id = "field_Id", - }; - CustomMetaDataFieldSchemaObject updateschema = new CustomMetaDataFieldSchemaObject - { - type = "Number", - minValue = 300, - maxValue = 500 - }; - - requestUpdateModel.schema = updateschema; - ResultCustomMetaDataField resultCustomMetaDataFieldUpdate = imagekit.UpdateCustomMetaDataFields(requestUpdateModel); - - //Delete Custom MetaData - ResultNoContent resultNoContentDel = imagekit.DeleteCustomMetaDataField("field_id"); - - // Get Authentication Token - var authenticationParameters = imagekit.GetAuthenticationParameters("your_token"); - Console.WriteLine("Authentication Parameters: {0}", JToken.FromObject(authenticationParameters).ToString()); - #endregion - } - } -} diff --git a/ImageKitSample/test.jpg b/ImageKitSample/test.jpg deleted file mode 100644 index 79de088c43e2fa456ef4c476440236c69d0dc2ca..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 27405 zcmb4~1ydYf(C!y^cXxN!;O-t|arxtJ!Gpu%usA^$cX#*T5ZqZHgx~~+kjr~-y&vHA z)KpE)Id!^gs^(Pxx}WoJ{og(STSY-x0RRI71IYZi0ROfCvH(PQ1VjXQL_`EcBqT&+ zRBTjK6cki^Oe}P4B79MFh^2eweHUJg|79I`(;Ujz`WLP)=%*Txbk4wXYAgzsvM{DVUgwOjmm9DsH zXpulh=bDhu%CqEvUN*eBW%!1HQO+wO4YI_qD`1`eu^Ji7|MT^~p8m%*0OsS{AbkvS z;{aek3488egU^@x;pl7e^})YQ0Q$$Qj~O@s zNdOVrSTCcViA!)OYGX2XvjTaL2?2q*sPU|mmy=h;b<+fwU&@nugPEk}e+!IR);zV% zXvYA(Im+R4pY0zQ-nKgIB0B3E%`#hPzgV?0w(!FBh=)m}V+&qLyX^I&Z3H{m4Ez}u zaN2*?`D-xsAu>KKn=k8Gss|ROjh}J)&}ln;(OEyS2|HdWz%b?w7iv1z&u+5Q_o~ye z4SsTU zoT(KyG+_m8u8HQ-9y2T&=Su|1h0EH+o`v{WBcX;%;s8(P(nhQbh{Kf=Zch!gCh5)5 z%un=o;Dl&hcZS>b;WT7wvcm`eFm{bqG=I(05g?G|gqbGwaSi`;qyKX9+Zq86LE>sQ6%+_!}g* ziAOCcikho{&(k(%{OoOx!U*xK+%(PhX)`hf^A*j(ED%2b@E`X;rNuVntng5os{QzN zXdnAj=4nE4`UlN&&h;_m;hkWA-e3zj0kyR8L72Iu`JSmnzVeB|BqDd)sMv##=(&(B zQ)kB!tmHIq_?q2_vIhZ^xKvP7@=pXxIBO_jO`r*DZBs4+)N8cUsyN#S6s^BUdGg+3OC?~aY5az?05P-M`%BRZXW8B9wEfI; zP!l|!-UOBVzEcmfkmvS1UH=@2te-{u(psrGRg7+z$KOp-Ou=q>P5Xm>%tIa0Z|6iX zLS_u2;rhw$6%98*UD|0>n-}aJ5M({m&3^zNG5XtHRbtnl^e{5x?0{3n*~&$R-*>sr zc9Lk(s!Gq_wm8dM$Tbs{xxd54LVo-3SNX6(-3TrkL^aIuD3DL3H+Y~4YI}rZbGA0T zJmgWobM$(CiazUCkjixSgayf}EC!10oBbVC;KLsH)u}_K4H=-h-G1v{o$TjfRA#QR zJ8KG}dQe181R{*79;T}+%0Gt)l|PM2r}vVT-&>d+wGUTy)=SVUz(h^1I~kRpk07yV zrs~Fz(Mz@Dnarz9d3;+H@?sapMi>JXC{ES9DuZ%?vWnTU<0Ezdd5FqV3(?2Bva71+ zkwOC5iy&r$7>KQFh}p?#p46Zf??Zv)Pj`_0e3^snG?ZzhGll4Sen(r2O-g;!(UR`4 zT(1fm4_X${Q)Mgi-r4#HCoPi0a)#>q_8(=QutO`UlkTppHZd-3l_{L;N_Qp1<_A2m z{(lO{tVH!S@jX2vLouTKkbjcEsP?_n=&F%7Ys|AWG709c7z~+ZS#8XP-`QXPm~_QX zz7PyAh(N;?7&eXJQzM)b5YuCs-dEiDjDd3{ZaW|A%yP~=tSmc;^@$g=ZH4vbimCCdXPu?CQBLgKA=Y5=aR%*}>LSGtp)1Slu+ zW)~Y?-iZGIQ7TW!{&MugH6Z5pWqL+jj9QJ{cfHt&M@Lu+jWq!j58Uou1HmIquyAwA zQBu8Ui`jU8kP19%k&$0@lfYMMLh*~Dmt3qMr@dh+ zEA>^#?3e#6xNfUQQ_Eu08MB_08(&ZhpcX|KpB$flaQ4GxDZ7A&=+rUJzEWs}nS-nR zi^CmAV2^!%vZav}JJBB{C2+Eyt=Cv%?6UN5j8U>^UGk=vam0L6cv{rVE|)UGxU#!j zifTw({6lTzWiL%$bIK_-J;0jEO2+I&X;~BHMWG}pUJYt#s%e_pgsCX=4kx?d?`pf6 z1GV~^1+(J*Orzxp)W;{bl_SaB|3NNE2ug^YE4UqZ{hBoKj358>b*4jbX%|eNC?_9v zi4iLx=h5ogxNUEh#oBK0PI@*?2f}qRBm^JY@`xCahGWkKR-J8N}haWj2Iq-yGa)GJ%NOY0!_{hn@q6LI$loEf<|B7)sR zy(`fGXP%4;n!5L*1H}*<%i^AL24e54L+IrUvrw+v+XZ~+S{xx7`pV-im=`%jd zoSX9FCK6s@bUhYQ%+@L$8xjrAFUAn@#SyAa)duOl&)>&!@XN``zS$+pEu~8wk_!f@ zt;>xlelwz?CXagg%eK(iY|+Vt9)SQeV@=5pF%bX$yuxH7Yy!O&PH<&z;w5i#n$G#t zzelI*6OYtH>d2v^Q#LAhMptpp7Y|)ePz6)jQpx{yZ1=M&->&xTA_=jU>MCI)o;c{12bI2i5x-2c#LLkoO5UOO1zI;nFS;Rp%OZBdVM z{RhCTb*)t#S@=U`%$%CZi}JF}ARRr?-Ei;e|Md?c((UV6z52I9Pc|_VV$d7;*)|fB zs-uJJBXmv1O~3OC*>(XwuJY0j%NrxEBK4$7g9;KhscOsqST+I?V?GG}>gGvN!+RTh z3|o+pseqe8W}7s;O!BL^tbF(|SigmW(zzUosm`?&i{)o={g?bgmYdpqph=Yu+=&hr~k=iDfzQ zLMH9P)+}(TGtSeWZl%HNSWRgmjbzw^h1x($mCfw1_)Jw14{F0c>q9;_41u@)wB_l# z<52bAWd;I?Vu8sUg8qVY6$xSEAAS}O*j3W6k4x#ow!O2df-_&1%$|&1ds)fuVb2|z z1yzb?Lp zvvE_Vl=S!v1yMZfTR3B~TAXm}EArH?=H&A7tazC*SoAdsE*b?r^xvc>MQx^^ZBvzl zR8wGGLXkV3f23A#jk0S>coV@8F;hwo_rNqwx#eZHa@m5ch76d)B7%cXS0?nj2oAeXcKf z6w*IV?xd{butH;lgvWz1X6ohw!0^D9i{>)LA4$oFxo);D|bqcF;}vnKVv zF(0L5=dl^rX32O)HNA5koB z@{}~wLu7VS8tuO@oEm%8)QO!%WctA;&)JRe>6R`I35=Z1WHAZ(F+O7YDunPwr7rZN zP&k2g*7T_w{~D2@)+F`iaFpG|ksCHpBrmqheV=Tc;XYG;DaT(2l^?~*y1a&6$`W)P z#>ohSlEl!)0|-5hkZ;E@M8}>_mnEizki_2$@37`HjBV6 z6FWsFb+n6C9<^Eo#%T8wrJ9oMf9_cAD>|#;@h!8A1T!g!rFbsC4Y5yD8U|915*gDN+L+w^6P z2Gh9q8gnx5y|sRmc#B%IXxMpi-1|J&+KEQEhk6u2UuLv6=ztrV@$Es3hcYj@Y>bNA zBDXHv!K06DWTMMM`8p|N+`Ls&w)17VB$@U*$zq9B(HB>VLpLy*G^0`zsLy^rfzw@4 zyWz}uj!M+p-9xR&Xlx#An>(m*QaMoeX#=R)W5qD25-@j(KAuiq|SFvJOr$Br(iu9B^C)i=k&D#YPd<7ZUpLfq~P z(C!HS+BWg>>q-v*~!)yLXacXn=Vu&F0IV zQ-HoATSBc#LNjZ~NrL<+<1mi_Jw^3Zv_~xCR2q5mWI>JW_$yO1l;pKS$&Sq1ZK?Mp z{<_y3WsKiH!^W~wJki_Y<_l_O&ipq`x?#U<^><>BsUK2E>rB%5eqnSY5HG2pV2NBY z9@p<@TVLE8>}JHws@jun-1+HKzn*yZZL-a#&VhFa+Ygis2S+mk6J7164D299OQVh2 zq@pNOrvsnm-y*uSWQOhi-b78F3hl*mJrW=*%#*2pVG98Rn(k$NS+@XY=OWBJz3yM- zU;nco2g>|sR?<(b5ANBf1B(w*#g-3#7TK~8fX$$lPia+T^PGNODMzM_B9FU;;1#!h zE$XqgB4&~96J5{Vk+Di=dFNEfDnu#v$BLPXlT3>$o)E;sZiuofd8t~aGG3OAjfvf7 z;BlaV=cO12r+kN6NE4o|#_}+sg6PqQr3W4=D-bxt()yBo&7;3Dj7{d75!Wwav0eOW z&;Z{7BbW)2&+TZD-F0S4`O_sqP9V=3pdz*(l^yI^SJ{zEH=hQl4*OB&NN`Z~08Shs zbzb^ZYUXDr+zDf&(i=mEGbyD*oIK)5LjVkcdP2c**61imw^w6Y;2w1|zAmNiYN-%j z@=g&YD##5x2D9R`MbX_Kh`gv(=Qobx>ycdoDG}yH#Rb&H{mMr7cZShCXgF``Kfsr- zUC&tKmBL~+BW$L!6sHXiUy07Rgo`<%2dy)0w52UtmGmfQ_11i9eYV;1c9d`^S>#@^!xF4>RR81au^bk@IX zP?2G>iiJ-#{2^OBkfF0BUEo=0-R2-S=VzC`lbkFYueC|+^{Qt=!(aSeTl}?pmwi9d z;7@4}6Nm%OGW$(}{_aE$T3SydE11b-Y@*MKN4#8#oIVJ%83tqn>cKeBCV}yQ| zF_!^PDTz`! z!m$JAG_#mZJJZm$#lc$XQyz?!q*IzFB+8reBX;OIU_s}3kFh2f3PGXH?40#_TH(j( zdk9G_Is7kuxW;+r3xMl+S$LkTkW2(Q%6-bYQW8)9jaEk(Q$RmHhf%vDMG`Cr;>a1B z9SCTdZsHlw-_F(#ntI0#b835kiAh`=A<@^KTwmm4ZH67>q82RCWaqIj{Yi$fzJT6@ z?|_0XyAe{-l{|FNbd%jw$&e7PNLx|)$tg{(j)uVy@vQ8uX|7sdiCw(1uEL&0F|9nA z`GN`66))Mpg($99yRR*I0wTsP?k!QYvHddNeLJulhjI8EfKa zY=plTr-DdaCfYZoQ*_6x(Syv*e~$HHlOX_rRQ;s<&{CFPdz`MeC!fP-IaK1KKN5OM zVNP2C$WN`SIdQy=ONRy3xvWD_D+L`gbBT=VtYIM2ru>^^nIXP|&I{hM7VlALE2*C5 zdL5d2jGA8X5xm`c;pB?$CQDD39;}G>KLBgzHxgP83E~%!y`rql=m-^d1aE$Jq$sWc zrQ%c`NoWzeCgN;F$}CAYRUDF}2Dl7FSdO1M>8~+|1Qj8j$nv&JlG0!P-6uI!`=r1x zWs@X78x{DUjs)Inyn7$mpw-^Y{U*Hpunu6(@n}6?M#tKZGor9@eWGn0sEZAS&ooU| z(M=u{kP)}~U3roT*5ji6g@)^5+4uVd#2mzD0wq0@IbUXB!d0esZ<6A332fTBFCSZW zPF!&PA?2@VyM{tTaaX~YEctV#;Gk3xLEqp+^~d`{)6N6WXLnW*TrBs{P8ug9b+Z6@ zpyCw|CE)Z8^8t%+Bu*1XR4FHB`k6|lZ%Bp+Z`9qjBOz@{vRPp-(JD|W|?qw(^y?azr4TIFbPf?kVVjnlex5W$8epd2hNAJh`-}>EX9D@>-T)fWG{nOBIzlCnzaU+m zZK)eq1|;|q0$?4;WB#VL1L-r=aD%6_ryK5I;7WjIj4_L1i~-B@iqSMA%%B4!8Yn?Z zOb1|1{09)VjvvFCrvIe#hAz`Cy7{wO_#4YjcH78EsfwSdd6k5oD-Vd+f7Ef${;yvkm3_KD>w0fuskGME!Z%MP#4<1I&oORW=mkh3zUS6Y(|6Vr- ze!%gX&0T}d*f|f-S9+!u`OaqP4%5GEWNjT3NkqnFOv%#g2YcwWeEkCJ20cF3cWYkp z#;&1BRKCIS(vt7ZQRHhdX1@yh^!)}y(HOUB5}A_Y`{}VvJ;-#?muCWP$d1SI=jh}* zSeu*~_&cVe3=1vd0+TyN1CNrB@;^L|t~jVd#^?B8#`Zq zn71-opv_%k83=6Scj_pHN-)a4i8NzX4jk({?Ss-xcudk^`k;ku=|F~HR%D!%Y>oT8s%k-ck zX2p=Gt`(yHQ)VS&qFEpkF~!GMfMD&K1d{OoBYaz=ObkzHmt%l#v}WQ~zKqlZbU2og zLt;n_TV6~@9iQMPn6QZF3o=i{!=m2$P|8rhH-XEYZb2F zBXIr_B(M%=*Fqt9Ko#1RguR5e8j!H z)(3pj``;uWh1`yDHejRMgj#V9uQmtaw7_Vt0h8D~}wG~i!1}nnJyV|=|qj^+iNXZXqt-O@aQ+>9+-TSU4lwxi$DI;|74$Qc)@3=Kid8Ij0N2=AkVk6FDiz@} zb}#E#30l~70F?gTbg4uohT4wZCY{Lo6& zxK1-7jGlceg{y)Fx2Uie{EHmd`qfH^Nr9gGthlCr5j=D)H!{%%Mk@LTD6{o9$-YS) zU_hTZDqZ9<{r>tD9zsg6KL{0WeG2DK$n3}wHE0$@!Ru+)&ODhk@M>P%ig~Q~LY`O1 z!8+fnOWf%n=k1_mDjDhaIcr6N#(J6SsO&2Egou&R@ui*&bjh;wXC3L;|X6mh0&N4gadD|p=w?Ghz} z#q48gYx&fgq+Ilu?J%zgF`WD-;wGvqZE2W70rR)8WXM7Tc@>B9$MTGN{ z5A1^}a)&5gRI+Z_8O1AwTx$+tMv5Nx7p*@wz>oZUn^I3}@fcAu_O?tm;imwRN8em{ ziBy-?BydvTwoi(8Sfz<1Z1b@#=y`Lo#&|30SSLAJk+Yf4e5yvZd8a>xWm^nGFRiz| z#Bw>3NQmwdG9RS}Y+65^i$Lu*HD09WK<5={EW-h;^V7z}We&KXo)R{#O^{94bq6+vs+?yc6 z+=$P0ahUIVM1ZrtwCqmKS1+1fB=Qxej(eiu2<2K966~D+Mc1Ekx(+id5#HA zd~i-j+2LbGq12v>=6+7RsI1_QgoNGV);(!&aCtTI3nDSbj}D#CNF#JK)z_1x1)6#< z$9s5E&tSxzm}ZjC=XY$R-k|m{F=~jr`Jg0b!15EVFD-JMhYRXxt zBO_(A6MxrIV90WL1ISR13Y~bI09E?9cWtBZ2Ts`8YVt!K}&!e)XS z9T3X81cbDiPnBY|RVLwBsdIPk*n^-AF0~Wf`fz3sP&nfVe!k2f#W(u z>rmherfI|J7^g&;7qE)(2fk!eC{<1>99^7f&2R-q zxYT$iRSuu1o$3Zg35Y9MU=tAX_oksm>^9yKT*L3qY+c${niM*ar%hWr@^iwR$WDr8 zis_}Zn(I2Y*H&)&8d==9)>%lypQ{UTZG~%Oz37Wul4KbS=xVUP!;o<=n9QXzb1pWJ zZ|RM@FCru+q~R?jvUU28h>&60{3$LSA2I?J?!f=Z_9L2tuB~t0bs3)r;d`UAB)-Xk z$>0pM;K6VVeGU##KNCWD&r{v6sLc9pZ;32DvKdarnF%%nqNazc(J%2L>p#7Y0LAQT zwlEDTXCWCh95DXrqtEJf?p$-#9;o9Z7$l#yJts^I;xI`CKmBRQwALa%=WWY0T#4<^ z{{<23mT6|-Fj5a6h5`Xb;TYdH?=2&*HV-+sAIfvxUnXc%oqi#(#3X%Yf26;?aWObL z-f&m>gg)R8;nA)*RO%Pi_pC4ftEtj9GFCti3rti`B=8TMCQePsSj)U?qixo2xPG1zT+O}-u*j7U%P!MAxq61i9G#@Q}L7I+V(N4 zp7E%mlghz$Z8K78d;w?o_r&7{v2Iaj!~MZlE= zj|pEQs$f(#Vy_!!EkQhb4VEB}P z`1zXzRA{5FLiE@&=)!uny+s-=j{u?fcNS5&lzJ?@i?ueor>iU;L%y~=v1jy1$ z@M>N5X?Z`QiH>?;*0!Kp%MG#H^$ZY83&Y?cGIK=uCrd3`^`TtRwkk5yihA;)^da3a zwDj{m9!gDwf*<0s8Qly{A6+&A>xgRV;}2yY8s!#LQ}y+T$->dqr~I59dSn827Y~#7 z@0=kM*5Ny0R)Ti|U*qjp>YYN@4X_4dI6c_Bu-PTP=OJO&XX_$)} z`uZ3LGCt5U+isIAfQbo>iQpJ+Re2=8qpA}d9KwaF{`$;x0EATTl@2{bo4tad#ChRI zs5OaPaf6DTUyOC%hfg1y$~!^-eN#B8Z=z?wC!o@`k6C)b$w*J)akp&*Y z!juAN-XAU=S1gjw2Wa(iA$acHu08_H2dU|@<@X{ul;ba(cWR`tJ5FBSNsbd<>m=OA zdfT8=$0wFXz`C1eH=LDJ8!|PQs~)SY8UD90z>uc##d-r*nP4L!wc+Od+K4TJ{2c*s zVJu$X>XgP*MBB<;x!bJb@^Zwb+QYKBZF}>M^Ft!T%f<%8Mv4Jfy^-Zm9$_mrQi%Vu z5}p{DJkzkerK^iR43Im@T`b3TY7g`y9&}G4h!oxi8v0*X%ivlfvGhd`SC(90S=}=< z241?KhaT62IxX6sbMmp!{!x6tZh&XqF#P3HHiGN85rg)H&NmPkTyn1ELWNW~k2>;h z?CzV@bl{nwK)FMNdGc<2y*@}{6y0jSIUzk)H$-zbuKAjC5xOKX7S5*}Be-lg-1QHT z*>Cn~eMT03B!N!=WN2yVjPgziK1?c2j^1}#oig~`gtvjUOn1tCk?wkUVTtPu>#B$=5+WJMxVaRvQ_K!+0PsAx+J&#A)q&3 zx23yz8oB?-a?iXQ9KtaacWp(tcEADm4vtlT1rP(5-G2iSn1)fxI;@Fevw8&l^IZv| z4ks)ZyI^A6-rKYj@`zQ*1tqaU%xy+)jA5m`X~Ig7vn4)uMNi@;hRgqimv>5I(AXCb zjSgdpK20A}V`;HAG_G&^;a=F00z+7XWNEv!*)rR|g>scSdn}qnAMy+G2vfbPTL;4I zUkDPzI8Rgm1HedvUB)B~%OHqB`k5S`C`$>Ik^QKV)=ArjAF&m@s)dS|mpn2J!CI%q zokXy4xT1T*M(sj`wJ3`vs+rm2gg%d%&4{YMFz|5r6fosY)&H_cqpw==)_7J`rW%@} z{AnAivJkFm${2ghG2Z|B+WLE{pHLP`yD9*5uUE1$fvYU1PF(4=2;*>CWE@lBd0^Mt z&fmuksyV(wL#sX_uVsF+EMQ-S*9PdN4$(=gtIW(Unu{mR!8%ME*NhL23;GDrc{uju zW5ppxr{^05C8Cj`XrFX;{@rW+v=s{FJ}MMcIKK6|tDPVlA@_I~-_QmLi=YYr)XrjoJ2OgJq2{$D=V`K&thrXC~ z79pdw58wBcdKkOB$KRGF)&!rgcO9(%N`Z6W3~D8aa^l-I>x0`+K^(c!(x{#cF@DdG zFuUOiA*$fD8;0F$x^|5Wr?Yu}3Vq3yL`jk0!Xp+@OJ#Z9Tt*iqIOvRoPlDRHghrk{ z@x18l9DckYPKi9a=B@0q72BF|1A;d;gZW5U5;U%2C2c8op6wAP->T|~@aieV#$c6| zGc_5ly`DBRMirPQ_}#3dqZ(+CURKGNZ^;TjiRcp*7GO%2lA1 zb-51Ua$Jcgu;Zd*ZO!3!_B^Z4m?OANA$wG3p_pcN0v0%w#eq(rbm`fMrbxgoc^Dm4 zB{eQ>DB9u2ZQYy6=^4R^2VjuimnmOww|gswK6|>y5a-;+T4rPiaScC8Omocdw+9q#C3Mk)>bHX zzXB74ESow+krMs^ZkZeApV`|_&5QrmtUqAIayKneJ%P*%i4zf`W(AEGXRn14-zVwW zU(sBu%C*@cEGKoCBBYE>aHen7SCJDD!ssDf#EkaW8<vJ>8FX+#t@^SwVxitCP)5~#cmblu!oK)fN%!cxuT)fn7PU%ZUHj;P71ly+h-L?y-G&cPaVW$5)vb{$qUKLrkMN|{7rhlAiQqElKQ}eH1 z5#}C|?(RtD>5E!fA1Po|*dgsP%-ZBg4e$>fXt*Cy++AY+mmTdjbs+WQi1j4i-4!8h zqFU^Rc8o6^2eAE~0pui#QY5iw7&kB0TZ(pJDDJ#v38)GK;(d=!gd#*uHm(_q3ybKX z(ZE@I$VKfklZun3*Im(>+?Ke%DTv`E<5=l1BzMo13(^-zt?uiXM&9yk2$Q3=Z@~nJ z`x}v<5m0-d8IZs#RkzPB6gaGJNCWC7$+qJSD^lO^gA_5zqM;EO2Og&f0zdyok@Vfa}e6|9=3Rgbj+;d0l-S1;c3s zdOJ%`$6@5j*usdp<%U3Vb#HfN7l(Ipa~wQ7-IP2EC*E`M#Fdy4KLxJHG=9eXu+c+i zol;Dn$?!a51_jtbys7MHdaYT;ta5srj9SBkpZeY5dO(mKR51nfxvnf~eEG)2cG4M= zT8>M;SP+F9TakXGi$##ZO|+a0#<_mfEy5ozsS>PWLrYQm$)#vEynSV>IzCjZXQOm0VYvF+;k7M^?PDP@ppph1A-9kj!f5N*gO+l#S?poR7v@E6)&(g>>m2oCdi{;Ex{_ROy++z1%4#&z- z)hk^8*6AWR3-Oxb7y=UUWZF9~68`L7P5*t?E!Lt9MQUbTygge|m_B}d3`Gu3ryAUo zHJLA~8B09ET>ugY>qDm)F3UG68cfB@=e1$J3_7&RzT^VG?n#2fPAh@p^ghgR4{*s8 z@{+QG-Sv+HYuNGC6Boy7^z$;H*_M7OCGqg)g%K~SsQ*r6;wraFB6I4L$|V9D9E=5)E&K;kylxgndFFh`rcunlXVz_=_KnoQ_3g1(=c5=REj zpPCueiaWO?n-*i{Q5@Ds3ru%$SUFla3!PZD07S=QWg5fwE#g?3g@3Zf*AHQw zJ6{ZgT)T9P=oRi~2*>HKK+SOE8M)`U&TEYKemigyzd72(SHY*4k7k;B)ixu69TL4T zIV25odROELYY2T96OLThV2Vxhc8GwVlvQ*(D<+f(So&03f;NKUREy1) zh~$fPBB#b5ZR7fGJ5BGDQf+IYL>~2gU#5I(so+HJUmV0PO8|od39r?QsGtrN^|l-( z*Tr%Vee+vzx#2K8NZ`I9DYmLcK~Q-?`v;KFm!OG(i#rHoQWMX;c>OK|=^jNZeY~h!M_|Z0PH6fcgza|aYL^Z(LZuypwL~NzmB%8bbGKvUTPXU3n>B?e-sY;cmPJAu+l4oVH z-R#JglA|5Qp=|G%ovSPV3LXC8JOG-7F`pg+Gz=8OQgd}BzcnM zGZ$5fd4g5er=ghf}Mu1e*JbZ(UZ-lJLM~r->MMySuX4iKprY z5CFxB0jc+p*WRe;YA#diD1;4}#JLsIgz>+R*=uOjFO>ysM{Yh1r>Js^C$m;bmlCo!rN3d0kJEY;Jm7EpM`RF+ z$g^BkDlwqA%B-Nv(kD?&lAS7f^v^bZS5(h8tJxZ13n2e3%$#3Mavtd@l3*4LV~7Mde>^Am zOdO=FZ_xb%B~4wQGG=7+2yIe_M>r9Z`uofIv*0F<^xqreJ+LG-fh0}tvCS|AsgO7NZAKAuiQ3hT|aCBgie2hZw|jmve!B24I` zpH4^Jzx5;gzggldd~D3W%-DPkzV?$kGfM3%&mT2?Qs1l?oGA;RhQ(ZD5S;lpG5pZ0 z&lpEydy}iRs!QMFcD`-TnP?f-IAiAh@F;{Ww@_MIE#@UeXmM26M6!bq=W35!^+qo! zjvdPyRY`5nD&ckVrFJlt&IzLnxMXleNDPB0=>{_D{9;F%OK8{`_adXr2+RDC1YTb_ z(qQoUkM&ljBTO9GOlLb-$|Pg+`q!NTad<%;OKJXt;OJsE51kE1mS0T{IEOd3YX$mN zHmD(Nb!vRf%$xx_!pUgZic?k7(udJg_3ZmufI^jt8>=E*6vj5ss2?W*q=m0|C~E)ZDF^u?)3?cyir z9shwRnwBZ%Q{Nn4mw$Sc7Nm=o`1$hkDKf=uOz*<;iAH$2@mt*3kv9YzeX0V6}w$go26y;(wW5L?ymJtwn%`Kn@vjGN;# z4aJaESn=x53@}HFt{-DbHyxSrand)1DE29(-7K#EuF(?PDo4>IN^*vLN5$t$MRs?O zIIax*(dl($zp0lL@{P^tfE<$*ST3v<1elhAu*q1jA;$qZ|kZVt*RE1d?C&&?sDKR>cE^X4B-o4zgK>Cb9jfT^^9M#jV~agckB_1I1{+Ut zw%4M^TRQU9;vS?DLL)O4c9%?){mc$!dg8WIyF*&`{9UszTK*$^zUeV?xY~JGv5ZpU zV&hWxOI?ni3X=2|Cuf@BbsqXQ6Cgbbq@dtC<`M@wTsX@R>j1Gl8hAIOHCdZSshOp0 zsv=3_>!b<)9@XJzyBw!Ibl=F$%?nrkeTpQy7yaQ8`x2jzCRHuZ4^9pb??5QNFKadb zo+$z*5%R?WnS(YTKj&1D*@>kETfsG>JX#GJq1dY3q6&NC@Epl!)g*-ieT8<*U@j*I zJr5yI{`TG0bD$Crsvayqzen05fw)^M6?PbmYry8pj99&Efqj}vLRKeI854O}*A%DY zUI2oNb8AWj?)v(Y*N87h*Rf8tRwB4ovrfGfUDUgz2LULzZKLB-Rb8v=IzJCK;-000 z2~3^K7#s0Hm7fQ5lur!Z1oHVma{@>W4HVk81- z1t2h+bYHv)31lme19}e!NC=npQLIWoJE7h|=AW-#YVk|$mO2Zut3D;|IIXobi>oABR8=K?uNBkGPk5k<;A)7 z^oH3DG4>CRzs_s5+RKURx7Fe#%jt)t-c`e0Wlb+Vb zCtyu@r1YjW(PQf2+A3mIx3$s*1Q>cUY_1hg$`om7=!l#dl&0#AZ*39IkbUki>0Xby zH0Br5T}@bIQw+KG*~~J0Qz7zdGqwjpnD4~Cj+Ij((Q^>`i6$bb!r-SUnL=NM$j3y& zKg53|6fO&>t%W`Mjg1!VO~*=^as^yocI=oLr7uWP(IPlN@`^yx#(4DZGyv0O?UBy+ zED<+?hd$uJQ<%T&i;1lAcNC7?8{33d5gt7)q{=_VQ+4isCQft9Buz3(Z=wZJ8ptzM z;C$E-D;JgW9*RBr5Js9T-uw36vrc(iK}jDX!bpXOt*q6U2z3ydgJJ+D+j2#i5PB5qz0 zfhMn~#tENxQEbTSi8&)e+uH2@7IwUR#-(%f%rbw->?3PjXW1iz|GUx%Ws;>iTI(A? zwG;MAQ@~mdsO#P@n2c?-#hjWz~1-~5CCQtxLd|kEhDZFJiErcU!nwqD|yp=S%HOa};;3=DXVS*Hoo{>99%^S&`lSM*KMByESl2L=NA(cpnrz|C+ z2yrVJbYIq4O)z$Sf&ulSbrh}pK*uk<-{b_MW;=HKp~^mkQADp+(x>|YCm!dgRl4#) zN=8bgFxvLb`7B2UXNH~a9-Ud&zyR@qd@RKM{0OJR!5xh?S{kGp@%KPutfpzbkbyoqFbiXsIZd9` z<@!#N6<10XeX5iK=F~v#@3U?tI#-(%Yz1qborh+TfwDKFm8xx{cyA>aTFsO1seumf zIKMh#cf1)t78GvWXBQIZk#~NiFtnt#ksDhg;9eQ>SDklIA#xHX#JBpnz}n*IqK;@& z=N`$s2RC{)xY{EV5H85iE`D&NV3M#}p8plvwI-|6V9{f2<$PK&Z3mBq(Y-)1r(-q_ zJ*=a2=g4VijEa?Mif-DhDY~;0uI>ppysE3A8Kq;GJS_*eL#d5&oZb3nt^K>hmTa%X zQ4qiSx{WQK0G;u8{%ls-X>oZNV+y18w-t^713p_LZF&UVpIL~UYD;l>t(FF{qU;t` zfE`WAyUQJft8u+*gWfsL)X$%Cn!Z!IK)imty_i*XmhQ|^EOW&_bP+h6ub^D~p8#hn znAH>nwt^`M(&I%Z@~(9KSoU|J=*y$pP6@GCNHB_2TRAP$ZeKdf_QDCUos`8zIR2_- zI(dfuMS2GYjamUHC7I3h9e$OU_MZWM1BN2c5Q}#e@<*b8Ct%b_{Q-8pC7=gaB?W=}(wLWn~~6TGYS0_Yoz9$KON} zcssy!%VAmMt=cxl(xGg2h*tWMYtZ0ZDD;*%~$x|4BU=h>82_E8xpPjHwM>6}-KGAl$+?|D?u{jHe)0FQpG zpRqMEM)zP0WLBTE36}}SIyViP=l=k0XN(Tfc-UBStw(23R|m!I@iz;^Uf#It%4TYA74XWSxaC`SstDV|QdzOdt4$xN6>DT0gIzGf=zJHr z=4)zHak&Yn5|RP-(x4pdx2kT@_QM7^W+M!VCKY4JHsF;l|u}|$5M6sskx+emjxV}2ate3+=XLKcDa%sF$f~V zxd!9=%~k&Nvtlrjsm#j7z&!$xf8G_&lsL)6>&ATIr(KRZ3tOcSTPm`ReQSuf&3<%c zKqJ#}OGu58So4n+hmfz!{hnaGsKF9Q0~VtH0PO)^sbk;Lzb)Y)WbHgrASK2%R1YyA zt7}HT5&g&LC2X+n#BJ$JLzx}H^h zEo`4ti_uw!!<9e*uo}}c00{(o({MzGFe}dXzSO27H&?!{4eB*Wu3VS|QIXxoWKFsg zNK2jWSla&pbvTPJcPwfw0l5a2e7(~bED6{OUwRz0Q1K&_6*_rVH;oI1BK8{A!-xao z&40$Sd{Bappl&(PUd{Nlk2viC4Jq7oto+1ZLvkxa+C*fK`qp|tO|-7g549X$J$l%? z5=C|~n|%#@+BcO(7A8SjJ&t1UW`l~)B<+}=v%Y{N<2>H6y+x~-?&qpkQ3 zHpll<<*EH@?eH>VxHbh^UhJyI=G&4ss{a6JVOO)*wIl%H1^rkGM3#i(Yw9nXKRX~* z#IZIlb3w;lqy#DTu1T3OauH(J{ORxmua8qtZklGuu1TV^4h~|swHUDXZc zO{s-bbFIOumQ9BoI@wbZmM0CUCc7*ORZjQbo}Lq8M=dLfhBmReJujtKKXSf`T04P- z0t>JMtyvURiAr?mRdFsx%O$GM4=BnIk$+lT?(B4Qs9|GH=(bQ;)O)lmWmV9MluV?s zy@}geGDUo*#8BBNKf6Tn00{(h&CZjP3Z)ES+Slj3SmqE$Gng7rQH0fnb)Q#H^A0RtMmT=VH!O;4bjhhif|y^9i>3!gg8M{fX72`0B5&7Gy~AWbtEBm&>vrD5JkugR;-b%s^& zbJsC3WGLNmtJ(+ zW_m@S>LzBkan~x5hs>&`OjLI&^ z52fl^PLY>y=@%a2vdzXgW)p|RktA@e7_R>SKZ%PHO0BmR(x_V$W8<@N%wH6j z5KJ{-3KVx{CF*PB34wNJ(Ew8;vUce4jfZP~cON-a# z?jmHv_NrqNlIxBZ0ABw9YhR~{I}NMztGL5<^`wx0SHwXh%e<*4Mz0NDBiofpMK)0F zslK+QR#*E%9zz{8C&XYGt(T}pD5 z+dL{v7^x1Uo`o1w`3X>J&$8$fwEQ)Si zg4X3~$$LePLD}qk7R`}kVe)ZXath^DzlYtdaxX6(m=1le|s{ z1P)-)y{!v+do(X2P2D1;j%&9-0OkDkqa=O@?**;*&|#4svqhzbzO~t8J;}~=>quh| zgz^TO$OXprVTF;DEy9x4y;Q=4%ovV!af&KcN(}|BYNR=Id!Mt*Pwd7O31G{K7WI+q z!9%0vBd)dY{>&`i&hS70Kd%1(eXH|E7DlvYLvPI1tdMeqS~&hDMGVuNtu*#1z-2dnI{WwfGStoS`HaxBmdv)Vy$U z$sgIP%E+aHbp4s^g#a1_9+kmjy7H$Q4K79KebSMj7WJ;WRCy*Yx)b5jjTsrX(zs*S zMPHj5?n?j#ht8}LI6OIoyI8SveeYp?DZmZCT1F`hae(q>VSR5xpNdC^QqDz%LQ`e1 zxNt>=o7F#SoD41qGha3&0e|kbWcxwwUx4s7WyQ8Boq0tAH{WYkMlWn!FSZ?~;Jh1$ zVDXV>#FuHO%A-i%Kmk2zb81m(55)%=rz6mzTPf;m;}7&UIE1;QSAalqoZS!Z|{oshm~aTzjzI~4Qs{tqW=KjfFf(3eHJIL zc|nmi+BSHVa;AHGcw<1j5Goji%7wJC8&u(DY&2z-+E8&suvHr$x|aGC9?IC^k>t!x zlx@20i#LTr^~Rrjdkd141f@M(Hp|I=TITY7y8k$ zXyvlEhfr(j8JS8Qh|p0IGN^8U&Z5K(NVUZ&*hpRrd$2Y-ohqhPEi;Q|H`>*0B#{W1 zoe1TB%Bxml7&54{jKGoRXeH3-UA9%@NLb2*B#kR0#nDB}5In1C#pm!F6LYy0gyRwx z4Q($sd*Vtb`q_Q`#N5?^&6Sa@XF~*75$+m;8cGViFr4oe(A8 zk)cRz;`H1gNxqinTG`2hw@0Z&s#l)1XW6)k?Jo?|K`%c;NGMVPUtKBQ5g|^|aKW0_ zmv51-JX5pMLv3_W zew89@yoLEtS%a0=O6DR!pM@@mw@S`R%(`aW&|;2Pn&RzkcBx^b6Su{nJ5`u|=&EG^ z^P+Evy~|)boK8|y3-vqEVd3u0;sD>`H2h2$oZ8cpK*(b%;3(W$_cXU4=!6(yhg+_{ zI)s4S-9}T>T5vL|Uiw>lU0GNY^t~^zkefwubp$09Kdu6(hr7Z}n0C0PUw0K6F%%PGY4dS0;-80NK!hL5*yDtMgB2AuxMI#G)>v zh>WUq2J#yHQd3Q@UzvMt8$;~@nE7KDC&O|FI<=4^~5LL)G)EPDq1v> zW+a`o6yzaU7bv~-wd!i6LD**LSkx|!9QfS}_j$7h>$P!$fpt@Dg&d=0@ajcENZs|m z-6@su3Xmb4NMds?*6Bt<4X!!uT!uLX#jH&n;oPNwwE~M}xg;$h2QfwXcBd*K8{b;#F{{RfJS$F&&zV*~JqFaA zfkq@-TMc}v4Od2mCnvJIimXZi7q>%LPCOK5AoH!C7?8Pa!E;|jSe`JKQ@Oak>pSe| zcM`335+2?vbV$i-L#wRT&E zCza^gMwPGF<5u)~c|!~;6q8Nxe-~)@Gv*c;h0G~z<=4V24&sl%V$a%+6U=+cUf#9J zhi9Xo+RxCK0?mP3`-}eoKYda5-X%Sr#{-zCP;}pVyNDR$a1VrAN}}zH=IqZBk+UBF z_e{CGROZtiaPX&@gB(47d>l7Oq4UU4Ckp=otjFCd8I|UokQP^c~7Eulp$GJ6K zh86*>Ry5RRbr;?wYpN;8EoXTgbSM5P;im^)SxfISOd!3 z=n@r|bFDqXogvR1#%tW3W~-!K?7WsNAS(z(6S9H;Hnl1}}RhV1Q+w!LHs*Y|yz|V)b@4F!bTGpOlpNjYU>c~fxE=|~OPdcgg zJTmq+E1&i5e(_hQVhx4#uC5>Q(dPWUXPtbo5cm_sb=1_e7ADA?Rslo^#01Y|ao9;eBrl>4M5Ed*Ul#hXE@Ir0@A1W{cz-?1dEGoe{ zBIpUzQN1vur74ffxI*lm;-Oa{Xmns{#IWa9m@QF1l}sw0RSdw3-nt34l`NDI6b*$+ zxVvp#qD2HX`TMq*RiCtSO2fvO;=1(jO@4p|;=C8O1&3+zV&f>qk#F{iy=3zK)O3H1 z)Y+)SqXY^bK%-&EP|``-%4K2ZO<0vII*lvjjY$J22Dz>-^mJ6!bShqONM~|+8_^-2 zb|4uw8{BV9$}gtYJ5(cp2?k-U7pnUz(_H|3Ov=D0IvQ^Y-ZB=|NZ#g+kwCE*J!%~R zqNbkM4oRv=2sn)Gb8*VYdYFP%LEaI6E|g^iSo5xf;Wa;HU%;C}sdUc7a{$;-io&V^ zO?uN#w>p|n5W0?(wy0!Xl>AOLF`YE5cNUE@HG#jKZE>m!*jq}+ajPn|XPP=bJ3QaC zQJ}rfqoAx_DU`EV8rt@Od@L&&i2z?p=y=aUeDb1w{&dVXHYSCL1f|6n5AciD=h4EB zq;I6+0}mjML|{icwcr?#ymy5>ZJ3-)cehN!v$8_-NuFjP3tXOBbgMqjM1OB^r{QBX&bW~QZOugvPJ!B;fl$sosPeCBieAIv%Ex; zZ?Pi%D&@Ck2vk~Betwk7*qIJs(b!l4s5MuPbKhk)8F>wA;~uL5X3PclzcW-4kYp!Y zoynkv_H^f@SOF5k%-KO8a^8TrsSG{I3t%)h){~I1U>K6UDX0R-r}(I-34=|;n0^PLE=()2#Xm-seE!gqj`W8fWc z(xruxRDwt(C6%??uPTNBq*!)VU|#nE+i7Yflc>V7gO*lu03%>OTCZjWw4WwwBIq4(EYbEl&-LyF8rnCsM6No(7BNn|F*nkslo;E3{QKKUKkq*iIsllmSe`=X{Hxzo*XJ*269nx~Xd?sSn_s@N z`Cn=}KgRv<^m>ks2m^6yA}&x*Is|$twKBIU=UEoba?v87jYl0fxD;3%k;9+XbG<1Atv(9@!-Uhz4i^dz0YhTCC zV0~*Hjvz4um2UBtf%D#q$=LUHzd9@@OC6{akPrjC>Tr{reJgY5;6?h)?kYg&!549_ zTCm`lWIShvIvqwLA*sENaa8e08sJNi^RT^M_HtI2v^+gQ1Pn|^rTk*K)YgwhceCGc zOWl2)?k!dQpqW>Iac=VA1SB8Itew?lBb~2Q9j{>Bnc~AWtrhR)2qL2RFfFsfc*LRQ zY^L@)UaE|PJ7zhyrZG%+I)mj@xS3qL5C{a*al+Lab7teQ*KwBostbrQfw?DdDo!a# zjP;^MO97Z@DZD7p_3xn4O2n~leQ1hp5|F?ilnHMnVRgMmB`gZRDy}*&o8?DgW?4uY zoprTX;M*dubD%VyQxVJto^)gvIvwRYemIw&(R*p6b{QZ zw)dAJ-iuliKGc>VYHEYn`7PO*FK-SZhxk^s6Eq@LMv((t=vY@<$NvB>Cztad_2>Hm zAX}R)54!{rmd1-D_;{BzlSC7fXBMc*i^0aLB$$YmTV^f*KRRigf(fJ3O~*KLN!`9P46HiH zqw}wi7Qq8$#$njr))J{V`qV3B(Q&s*u1sKAU6xBEQ<&ve9}UIFFYPJmWAg!ziQ(l; z(a4TJvcT4F2iiUmc+Vc;*r|$4(}R#Jwq@>P7q}X9-<3{?k?0EHwrcpuRBu?X>1PhY zNF&5?5KhBB7DXr2fn&EpQvRKAbPCUjV;L8^;pM;6E$Z&d;LWI)F~3Uhedn!XW9`oa zl|wE!PFbUMKSC*l?SBZCGVx;)Lt;Q(+S-sW&&sH!6I2+M)U|$P_K}Or+x|AD;2A*I z(!Hk-+y2Z+8oA>*WXvuV*r^_%>MQeav>r2t#`{F$PlUurGzNbRh}o5_2FKR)jPY`b z(EdJ3IUW2Tqp;w~68YHPn~Z^bRd)|0;IPcBH9&9jt0at#dhc11G)a(lB!s>Z2?3REY9t2n8&}UFodLakMZl=hKOoyi z&}&O#wdOBOOQp>zHHwlqGz|w5pNKY8xX@NJk3Hcw<<8Zw;sj-2%s{L^Xe3QQVn>~2 zmuE-EN1b+#OBT7*n#SU!2LAw^YI{#8Alsc{@lAazq2ou=Wd27bIu(_!N39+pN;R}J zq>K$Qhja*T#5W<+33`o8C8I+3wzZ(_l&$?Bz%vk`aS@#c{vlaIbPl<++={;J z{O$WshbbX}#KZx=_QheGb)&tHBI%!_Fwfq|OA}%R>owb_E5LZFmLXkiHMX0d!qs-J zaL^GY*Ta9iL0F#FOwYnNjwV7`S~9AqnI^*Cds1N@O$(EyDIQbBZ;~*lL0~QT)l)D9 zgu2*ialJ`roX2AvrO6h|r)uKD&pp{B19D26R@DZ(GfO&_(r+t!Im&EDLra_)rWvBUU_>m^+V)U+ z?M_D$DvyTr6$PeHT}95Bw4%%1pg(9E(47S-+v!O(<=7G| z2|=5O8jBl!^jZR# z*_PKVK($6ZVuP-{^rU_2A)`CB`4u|(?MqE83noRJ20IRBqoUGfwl5VEEzBNAgPm(btvs%{~I#LO6&Rg{n8u>ERU3NaSqeZ5W^jUbOP+*;cI z05_~3ANJpmT*HV2UjZ@qeHzaIsy8i&y zfx8&uy^k~P4{rNM$BQmIisFndyh!Cz-7Gh%E*&p*h#L9VspI{PV=PV&6&QU6NeJBS ztzvsc*j~_fYY_*(U|qzGWN1%#3EtXswNBLlt};?TUT^?gg<#9r9_erEVOHogI{<4V z*^VfQz_?=0PkZjs87?eTl@|ncts3JYmOli^w=-Di+b4SuAqq!2UTK0SL+47*h>ffS zss;H}F&c|2ixIgr68r@Oy}?NGN)4~|puCbH_=yzkSVReNC}YnlptMF;3YNY0G!Gnx ztdTi|oZMX8)ueM~16x%dCK(ZnE~*WVU2JL0JWL{1Vo2Z4sy3YxX*FXQnL%~}l9Ab0 zP<7{BaM_uO89>(brXb0aLPGN8RUo2-IJ~)|V0qRXk0gEBU~OTjy=*v%v`v`b@~j7H zBr%~SyaQ52A+4LRx<{RMl3<~{&12?}v8%q)V!PQG0xf#ZlU;8f6%&i+<>iu*#v=77 zjh=;lYHCMH(d=`RH0tCl-7Z?%kyd@32lnR;$hm^zWBGW6T1(kZHl8HFAW^rEQhy)1 znc$tD<0-|kQoaK(b1FM{hlxWCfw%K&%;I$8l_#^_G0Pv?;-{0l!o#Lx&9gUIQGRD#O+eyKQX@qQ+7r@-5K%=>BaxJT z0R#>Kjz01B003>~XmfC^J{BCYSeaAdSRs~I zREja-(=p{%_{v?K4^lEr1>o zYWZg?W@0iOZfSuyAXsX83JNW@$*hhD4R9^%Oo_(9j@;=clHipbw9qsD^MZbsViePyGYTE zE=Xh~{pdcGZcy6Rq;Z&W-$d+f-N>zez92t3jfWA#8>@yJa|fM#V9vRaZ`XQyL`RFe z8arqY=R`RX~C6tov!DbzwQZDv4!$Xv$63F(hm# z(nOPtvP6zAav5$u`gF!a3oX>^d(n&p0z%%~RHDTO7B?WgD{-@PwMgL7Ti!A2YH}#e zn=*hrjT|d0cn!wKO0Fd2RY`%3Q!>NeumAyaDn|l@?XNIRS?ic7T`j4i7&B@II-F5X zY^TIv1d#okG8Q!a4n`~ zajDtPzkN38K4}1H?2os(8_VQbuY_Gb;k_>_(T&P5xAd zGX~(2B$#G5(Ye;ZVD%=)t$pr+m|S1wK=Gi~W_h+dh2mV^JXE6k5nyW_+78TPv9Y?O z@+&dijeRTKUxnuYfA4vkt5Q0_n)#dYHqRtnJ~5asygZG$v5@_^jC+A}AJSE5F}BlR0A?M4fy@Xa#98 zFhpVz$E=Lj7v)I91>_?xrHMXtGSEq(7Q-xSb^s~X=D7wKLnAw=YyR&#xk#_2u6DTO zX{e!2>{txPYtSU_%W|y=K#GlJ3{;VOtvByUm69dTl-p}-O{^mJ&8IIqmvlh@YP5Wq zy*42lO5`?0zS~pSXov#k5Oo(njeR7bDit0R&ZQH^M~GzuokT`O@`6IUH=iotjI$A7 zQq?)+PYh~E0Nh%q8B{k0^TaOfo&T7 z1x_^~Y<8$qbVV$_1s)$EQ(>6g=%myYOUvRVY<{%NQ7VfQubHTdbT97tvk>`wfZmnj zXcGr4k~O16R%W)qFemO6YZ3q~yIVjg9Arli2ggjv(kyU0G7Sp=3H*&+kuaHpVb$3Q zB!yoxbfO;#(|RuqLi|4q;#Ut6wa1{Y&4(e)vs*)Ywb@tfeV8@D9RRMFf$5ui`Zz)* z+cn9(5ypfm7w1uwnb_gVNjmiDQ$;KXD_3H;>toi5Ya3fi8ZO9%0^=Yn)})|Ymr+tc zMZwm(1=v^s2Rel8h)W)#)L;%x282{pFy)}vN}46j$+-tYIcZRb$eHbB@cGo017Az} zQGg(M)Gw4>N1YNtwnw@JG}hf~i50K479t6=D8F0R%p3ub3wiHXMOhO71d*Yxh?iY8 zH7k-xaBOO5H1n#WSTsO1AkpKEPWq8u3z%NoRI-KEtfCKxMk7mGO6%bjg^2ml6I;<# zk-b$S>`gG>UogK~8*uD2jB~`TeJ({=SRLzuKsTzQ`5s$_z%!{bHMyH;29((m_hB-h zkkX`OG7F}Qdsy?S0s{uH78~=V8bwS}7kLRz?!zDe=D$18gl@8fYhPZY(w%n~v*@fe z(*FQjUEOYe6V!vC`B2H&OGLy`2EH@1sdOf2&aA zrqyT`*r}361hgzj)Y)(Jrf%e@w}+j-W*5lx6sA+Vik9Nfbjd%0N;y zp)xBd9o?_6u@uq+WzS?b>s>cyv-p$}0qIhSY*nBm;6Ml(X;WyKRg^D^*S)G){A4R? zP5gyUHg51<#VxN=YSJmTCa@jkIv!*iIzkW=;s^&yV7Uc|)K}5DD#Va&sq+4GtE7sy z$YLb!Hj+V!q1tP@f$1&F+Aq048Q5g}Xi(0^M zO+$u*7Yvckd=mnNFKdfXqCo3w3hOs_m%Gq|Vs@*qf|?TGSfL*c!;}h<{qD z7G@yYqDL*Cj~$6MG`Ar*>OF+KL7v# diff --git a/Imagekit.UnitTests/FileVersion/FileVersionTestAsync.cs b/Imagekit.UnitTests/FileVersion/FileVersionTestAsync.cs deleted file mode 100644 index 339de562..00000000 --- a/Imagekit.UnitTests/FileVersion/FileVersionTestAsync.cs +++ /dev/null @@ -1,481 +0,0 @@ -using Imagekit.Constant; -using Imagekit.Models; -using Newtonsoft.Json; -using System; -using System.Net; -using System.Net.Http; -using Xunit; - -namespace Imagekit.UnitTests.FileVersion -{ - - public class FileVersionTestAsync - - { - private const string GOOD_PUBLICKEY = "abc"; - private const string GOOD_URLENDPOINT = "https://dasdsad.dad.io/"; - - - - - - [Fact] - public void Missing_Object_FileVersionException() - { - DeleteFileVersionRequest model = null; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.DeleteFileVersionAsync(model)); - Assert.Equal(ErrorMessages.InvalidDelVerValue, ex.Result.Message); - } - [Fact] - public void Missing_fileId_FileVersionException() - { - DeleteFileVersionRequest model = new DeleteFileVersionRequest - { - versionId = "abc" - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.DeleteFileVersionAsync(model)); - Assert.Equal(ErrorMessages.InvalidFieldIdDelVerValue, ex.Result.Message); - } - - [Fact] - public void Missing_versionId_FileVersionException() - { - DeleteFileVersionRequest model = new DeleteFileVersionRequest - { - versionId = "", - fileId = "sas" - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.DeleteFileVersionAsync(model)); - Assert.Equal(ErrorMessages.InvalidversionIdDelVerValue, ex.Result.Message); - } - - [Fact] - public void CopyFile_Default() - { - CopyFileRequest model = new CopyFileRequest - { - sourceFilePath = "Tst3", - destinationPath = "Tst3", - includeFileVersions = true - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = restClient.CopyFileAsync(model).Result; - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - - [Fact] - public void Missing_Obj_CopyFileException() - { - CopyFileRequest model = null; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.CopyFileAsync(model)); - Assert.Equal(ErrorMessages.InvalidCopyValue, ex.Result.Message); - } - - - - [Fact] - public void Missing_Source_CopyFileException() - { - CopyFileRequest model = new CopyFileRequest - { - destinationPath = "abc" - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.CopyFileAsync(model)); - Assert.Equal(ErrorMessages.InvalidSourceValue, ex.Result.Message); - } - - [Fact] - public void Missing_Destination_CopyFileException() - { - CopyFileRequest model = new CopyFileRequest - { - sourceFilePath = "abc" - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.CopyFileAsync(model)); - Assert.Equal(ErrorMessages.InvalidDestinationValue, ex.Result.Message); - } - - [Fact] - public void MoveFile_Default() - { - MoveFileRequest model = new MoveFileRequest - { - sourceFilePath = "Tst3", - destinationPath = "Tst3" - }; - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = restClient.MoveFileAsync(model).Result; - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - - [Fact] - public void Missing_Obj_MoveFileException() - { - MoveFileRequest model = null; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.MoveFileAsync(model)); - Assert.Equal(ErrorMessages.InvalidCopyValue, ex.Result.Message); - } - - [Fact] - public void Missing_Source_MoveFileException() - { - MoveFileRequest model = new MoveFileRequest - { - destinationPath = "abc" - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.MoveFileAsync(model)); - Assert.Equal(ErrorMessages.InvalidSourceValue, ex.Result.Message); - } - - [Fact] - public void Missing_Destination_MoveFileException() - { - MoveFileRequest model = new MoveFileRequest - { - sourceFilePath = "abc" - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.MoveFileAsync(model)); - Assert.Equal(ErrorMessages.InvalidDestinationValue, ex.Result.Message); - } - - [Fact] - public void RenameFile_Default() - { - RenameFileRequest model = new RenameFileRequest - { - filePath = "Tst3", - newFileName = "Tst4", - purgeCache = false - }; - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = restClient.RenameFileAsync(model).Result; - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - - [Fact] - public void Missing_FilePath_RenameFileException() - { - RenameFileRequest model = new RenameFileRequest - { - newFileName = "test" - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.RenameFileAsync(model)); - Assert.Equal(ErrorMessages.InvalidRenameFilePathValue, ex.Result.Message); - } - [Fact] - public void Missing_NewFileName_RenameFileException() - { - RenameFileRequest model = new RenameFileRequest - { - filePath = "test" - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.RenameFileAsync(model)); - Assert.Equal(ErrorMessages.InvalidRenameNewFileNameValue, ex.Result.Message); - } - - - - - [Fact] - public void GetFileVersions_Default() - { - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = restClient.GetFileVersionsAsync("abc").Result; - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - - - [Fact] - public void MISSING_FILE_ID_FileVersionsException() - { - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.GetFileVersionsAsync("")); - Assert.Equal(ErrorMessages.FileIdMissing, ex.Result.Message); - } - [Fact] - public void RestoreFileVersion_Default() - { - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = (Result)restClient.RestoreFileVersionAsync("abc", "1").Result; - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - - [Fact] - public void Missing_Restore_File_Exception() - { - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.RestoreFileVersionAsync("", "123")); - Assert.Equal(ErrorMessages.InvalidFieldIdDelVerValue, ex.Result.Message); - } - [Fact] - public void Missing_Restore_Version_Exception() - { - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.RestoreFileVersionAsync("123", "")); - Assert.Equal(ErrorMessages.InvalidversionIdDelVerValue, ex.Result.Message); - } - - [Fact] - public void Missing_Restore_File_Version_Exception() - { - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.RestoreFileVersionAsync("", "")); - Assert.Equal(ErrorMessages.InvalidDelVerValue, ex.Result.Message); - } - [Fact] - public void GetFileVersionDetails_Default() - { - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = restClient.GetFileVersionDetailsAsync("abc", "1").Result; - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - [Fact] - public void Missing_FileVersionDetailsException() - { - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.GetFileVersionDetailsAsync("", "")); - Assert.Equal(ErrorMessages.InvalidDelVerValue, ex.Result.Message); - } - [Fact] - public void Missing_FileDetails_Exception() - { - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.RestoreFileVersionAsync("", "123")); - Assert.Equal(ErrorMessages.InvalidFieldIdDelVerValue, ex.Result.Message); - } - [Fact] - public void Missing_VersionDetails_Exception() - { - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.RestoreFileVersionAsync("123", "")); - Assert.Equal(ErrorMessages.InvalidversionIdDelVerValue, ex.Result.Message); - } - } -} - - - - diff --git a/Imagekit.UnitTests/FileVersion/FileVersionTestNonAsync.cs b/Imagekit.UnitTests/FileVersion/FileVersionTestNonAsync.cs deleted file mode 100644 index 2e90db7c..00000000 --- a/Imagekit.UnitTests/FileVersion/FileVersionTestNonAsync.cs +++ /dev/null @@ -1,482 +0,0 @@ -using Imagekit.Constant; -using Imagekit.Models; -using Newtonsoft.Json; -using System; -using System.Net; -using System.Net.Http; -using Xunit; - -namespace Imagekit.UnitTests.FileVersion -{ - - public class FileVersionTestNonAsync - - { - private const string GOOD_PUBLICKEY = "abc"; - private const string GOOD_URLENDPOINT = "https://dasdsad.dad.io/"; - - - [Fact] - public void Missing_Object_FileVersionException_NonAsync() - { - DeleteFileVersionRequest model = null; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.DeleteFileVersion(model)); - Assert.Equal(ErrorMessages.InvalidDelVerValue, ex.Message); - } - [Fact] - public void Missing_fileId_FileVersionException_NonAsync() - { - DeleteFileVersionRequest model = new DeleteFileVersionRequest - { - versionId = "abc" - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.DeleteFileVersion(model)); - Assert.Equal(ErrorMessages.InvalidFieldIdDelVerValue, ex.Message); - } - - [Fact] - public void Missing_versionId_FileVersionException_NonAsync() - { - DeleteFileVersionRequest model = new DeleteFileVersionRequest - { - versionId = "", - fileId = "sas" - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.DeleteFileVersion(model)); - Assert.Equal(ErrorMessages.InvalidversionIdDelVerValue, ex.Message); - } - - [Fact] - public void CopyFile_Default_NonAsync() - { - CopyFileRequest model = new CopyFileRequest - { - sourceFilePath = "Tst3", - destinationPath = "Tst3", - includeFileVersions = true - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = restClient.CopyFile(model); - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - - [Fact] - public void Missing_Obj_CopyFileException_NonAsync() - { - CopyFileRequest model = null; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.CopyFile(model)); - Assert.Equal(ErrorMessages.InvalidCopyValue, ex.Message); - } - - - - [Fact] - public void Missing_Source_CopyFileException_NonAsync() - { - CopyFileRequest model = new CopyFileRequest - { - destinationPath = "abc" - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.CopyFile(model)); - Assert.Equal(ErrorMessages.InvalidSourceValue, ex.Message); - } - - [Fact] - public void Missing_Destination_CopyFileException_NonAsync() - { - CopyFileRequest model = new CopyFileRequest - { - sourceFilePath = "abc" - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.CopyFile(model)); - Assert.Equal(ErrorMessages.InvalidDestinationValue, ex.Message); - } - - [Fact] - public void MoveFile_Default_NonAsync() - { - MoveFileRequest model = new MoveFileRequest - { - sourceFilePath = "Tst3", - destinationPath = "Tst3" - }; - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = restClient.MoveFile(model); - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - - [Fact] - public void Missing_Obj_MoveFileException_NonAsync() - { - MoveFileRequest model = null; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.MoveFile(model)); - Assert.Equal(ErrorMessages.InvalidCopyValue, ex.Message); - } - - [Fact] - public void Missing_Source_MoveFileException_NonAsync() - { - MoveFileRequest model = new MoveFileRequest - { - destinationPath = "abc" - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.MoveFile(model)); - Assert.Equal(ErrorMessages.InvalidSourceValue, ex.Message); - } - - [Fact] - public void Missing_Destination_MoveFileException_NonAsync() - { - MoveFileRequest model = new MoveFileRequest - { - sourceFilePath = "abc" - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.MoveFile(model)); - Assert.Equal(ErrorMessages.InvalidDestinationValue, ex.Message); - } - - [Fact] - public void RenameFile_Default_NonAsync() - { - RenameFileRequest model = new RenameFileRequest - { - filePath = "Tst3", - newFileName = "Tst4", - purgeCache = false - }; - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = restClient.RenameFile(model); - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - - [Fact] - public void Missing_FilePath_RenameFileException_NonAsync() - { - RenameFileRequest model = new RenameFileRequest - { - newFileName = "test" - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.RenameFile(model)); - Assert.Equal(ErrorMessages.InvalidRenameFilePathValue, ex.Message); - } - [Fact] - public void Missing_NewFileName_RenameFileException_NonAsync() - { - RenameFileRequest model = new RenameFileRequest - { - filePath = "test" - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.RenameFile(model)); - Assert.Equal(ErrorMessages.InvalidRenameNewFileNameValue, ex.Message); - } - - - - - [Fact] - public void GetFileVersions_Default_NonAsync() - { - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = restClient.GetFileVersions("abc"); - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - - - [Fact] - public void MISSING_FILE_ID_FileVersionsException_NonAsync() - { - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.GetFileVersions("")); - Assert.Equal(ErrorMessages.FileIdMissing, ex.Message); - } - [Fact] - public void RestoreFileVersion_Default_NonAsync() - { - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = (Result)restClient.RestoreFileVersion("abc", "1"); - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - - [Fact] - public void Missing_Restore_File_Exception_NonAsync() - { - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.RestoreFileVersion("", "123")); - Assert.Equal(ErrorMessages.InvalidFieldIdDelVerValue, ex.Message); - } - [Fact] - public void Missing_Restore_Version_Exception_NonAsync() - { - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.RestoreFileVersion("123", "")); - Assert.Equal(ErrorMessages.InvalidversionIdDelVerValue, ex.Message); - } - - [Fact] - public void Missing_Restore_File_Version_Exception_NonAsync() - { - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.RestoreFileVersion("", "")); - Assert.Equal(ErrorMessages.InvalidDelVerValue, ex.Message); - } - [Fact] - public void GetFileVersionDetails_Default_NonAsync() - { - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = restClient.GetFileVersionDetails("abc", "1"); - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - [Fact] - public void Missing_FileVersionDetailsException_NonAsync() - { - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.GetFileVersionDetails("", "")); - Assert.Equal(ErrorMessages.InvalidDelVerValue, ex.Message); - } - [Fact] - public void Missing_FileDetails_Exception_NonAsync() - { - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.RestoreFileVersion("", "123")); - Assert.Equal(ErrorMessages.InvalidFieldIdDelVerValue, ex.Message); - } - [Fact] - public void Missing_VersionDetails_Exception_NonAsync() - { - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.RestoreFileVersion("123", "")); - Assert.Equal(ErrorMessages.InvalidversionIdDelVerValue, ex.Message); - } - - - - - } -} - - - - diff --git a/Imagekit.UnitTests/ImageKitRequestModelValidation.cs b/Imagekit.UnitTests/ImageKitRequestModelValidation.cs deleted file mode 100644 index 67028bcf..00000000 --- a/Imagekit.UnitTests/ImageKitRequestModelValidation.cs +++ /dev/null @@ -1,850 +0,0 @@ -using Imagekit.Constant; -using Imagekit.Models; -using System; -using System.Collections; -using System.Collections.Generic; -using System.Net.Http; -using Xunit; -using RichardSzalay.MockHttp; -using Imagekit.Helper; -using static Imagekit.Models.CustomMetaDataFieldSchemaObject; - -namespace Imagekit.UnitTests -{ - public class ImageKitRequestModelValidation - { - - private const string GOOD_PRIVATEKEY = "private_key"; - private const string GOOD_URLENDPOINT = "https://endpoint_url.io/"; - - [Fact] - public void UploadFileRequest_ModelValidation() - { - string json = "--ImageKit-dLV9Wyq26L\r\nContent-Type: text/plain; charset=utf-8\r\nContent-Disposition: form-data; name=fileName\r\n\r\ntest.jpg\r\n--ImageKit-dLV9Wyq26L\r\nContent-Type: text/plain; charset=utf-8\r\nContent-Disposition: form-data; name=file\r\n\r\nhttps://homepages.cae.wisc.edu/~ece533/images/cat.png\r\n--ImageKit-dLV9Wyq26L\r\nContent-Type: text/plain; charset=utf-8\r\nContent-Disposition: form-data; name=useUniqueFileName\r\n\r\ntrue\r\n--ImageKit-dLV9Wyq26L\r\nContent-Type: text/plain; charset=utf-8\r\nContent-Disposition: form-data; name=tags\r\n\r\nSoftware,Developer,Engineer\r\n--ImageKit-dLV9Wyq26L\r\nContent-Type: text/plain; charset=utf-8\r\nContent-Disposition: form-data; name=folder\r\n\r\ndummy-folder\r\n--ImageKit-dLV9Wyq26L\r\nContent-Type: text/plain; charset=utf-8\r\nContent-Disposition: form-data; name=customCoordinates\r\n\r\n10,10,20,20\r\n--ImageKit-dLV9Wyq26L\r\nContent-Type: text/plain; charset=utf-8\r\nContent-Disposition: form-data; name=overwriteFile\r\n\r\ntrue\r\n--ImageKit-dLV9Wyq26L\r\nContent-Type: text/plain; charset=utf-8\r\nContent-Disposition: form-data; name=overwriteAITags\r\n\r\ntrue\r\n--ImageKit-dLV9Wyq26L\r\nContent-Type: text/plain; charset=utf-8\r\nContent-Disposition: form-data; name=overwriteTags\r\n\r\ntrue\r\n--ImageKit-dLV9Wyq26L\r\nContent-Type: text/plain; charset=utf-8\r\nContent-Disposition: form-data; name=overwriteCustomMetadata\r\n\r\nfalse\r\n--ImageKit-dLV9Wyq26L\r\nContent-Type: text/plain; charset=utf-8\r\nContent-Disposition: form-data; name=extensions\r\n\r\n[{\"options\":{\"add_shadow\":true,\"semitransparency\":false,\"bg_image_url\":\"http://www.google.com/images/logos/ps_logo2.png\"},\"name\":\"remove-bg\"},{\"minConfidence\":95,\"maxTags\":5,\"name\":\"google-auto-tagging\"}]\r\n--ImageKit-dLV9Wyq26L\r\nContent-Type: text/plain; charset=utf-8\r\nContent-Disposition: form-data; name=webhookUrl\r\n\r\nhttps://webhook.site/c78d617f-33bc-40d9-9e61-608999721e2e\r\n--ImageKit-dLV9Wyq26L\r\nContent-Type: text/plain; charset=utf-8\r\nContent-Disposition: form-data; name=customMetadata\r\n\r\n{\"price\":2000}\r\n--ImageKit-dLV9Wyq26L--\r\n"; - string url = "https://upload.imagekit.io/api/v1/files/upload"; - FileCreateRequest ob = new FileCreateRequest - { - file = "https://homepages.cae.wisc.edu/~ece533/images/cat.png", - fileName = "test.jpg", - }; - List tags = new List - { - "Software", - "Developer", - "Engineer" - }; - ob.tags = tags; - - string customCoordinates = "10,10,20,20"; - ob.customCoordinates = customCoordinates; - List model1 = new List(); - BackGroundImage bck = new BackGroundImage - { - name = "remove-bg", - options = new options() { add_shadow = true, semitransparency = false, bg_image_url = "http://www.google.com/images/logos/ps_logo2.png" } - }; - AutoTags autoTags = new AutoTags - { - name = "google-auto-tagging", - maxTags = 5, - minConfidence = 95 - }; - model1.Add(bck); - model1.Add(autoTags); - ob.extensions = model1; - ob.webhookUrl = "https://webhook.site/c78d617f-33bc-40d9-9e61-608999721e2e"; - Hashtable model = new Hashtable - { - { "price", 2000 } - }; - ob.customMetadata = model; - ob.useUniqueFileName = true; - ob.folder = "dummy-folder"; - ob.isPrivateFile = false; - ob.overwriteFile = true; - ob.overwriteAITags = true; - ob.overwriteTags = true; - ob.overwriteCustomMetadata = true; - List responseFields = new List - { - "isPrivateFile", - "tags", - "customCoordinates" - }; - var mockHttp = new MockHttpMessageHandler(); - var request = mockHttp.Expect(url) - .With(a => a.Method.Equals(HttpMethod.Post)) - .WithHeaders("Authorization: Basic cHJpdmF0ZV9rZXk6") - .WithContent(json) - .Respond("application/json", "{'name' : 'ImageKit Response'}"); - var client = mockHttp.ToHttpClient(); - RestClient rs = new RestClient(GOOD_PRIVATEKEY, GOOD_URLENDPOINT, client); - var response = rs.Upload(ob); - mockHttp.VerifyNoOutstandingExpectation(); - } - - [Fact] - public void UpdateFileDetail_ModelValidation() - { - string url = string.Format("https://api.imagekit.io/v1/files/{0}/details", "file-Id"); - FileUpdateRequest ob = new FileUpdateRequest - { - fileId = "file-Id", - - }; - List tags = new List - { - "Software", - "Developer", - "Engineer" - }; - ob.tags = tags; - - string customCoordinates = "10,10,20,20"; - ob.customCoordinates = customCoordinates; - List modelExt = new List(); - BackGroundImage bck = new BackGroundImage - { - name = "remove-bg", - options = new options() { add_shadow = true, semitransparency = false, bg_color = "green", bg_image_url = "http://www.google.com/images/logos/ps_logo2.png" } - }; - AutoTags autoTags = new AutoTags - { - name = "google-auto-tagging", - maxTags = 5, - minConfidence = 95 - }; - modelExt.Add(autoTags); - modelExt.Add(bck); - ob.extensions = modelExt; - ob.webhookUrl = "https://webhook.site/c78d617f-33bc-40d9-9e61-608999721e2e"; - Hashtable model = new Hashtable - { - { "price", 2000 } - }; - ob.customMetadata = model; - string result = "{\"fileId\":\"file-Id\",\"webhookUrl\":\"https://webhook.site/c78d617f-33bc-40d9-9e61-608999721e2e\",\"extensions\":[{\"minConfidence\":95,\"maxTags\":5,\"name\":\"google-auto-tagging\"},{\"options\":{\"add_shadow\":true,\"semitransparency\":false,\"bg_color\":\"green\",\"bg_image_url\":\"http://www.google.com/images/logos/ps_logo2.png\"},\"name\":\"remove-bg\"}],\"tags\":[\"Software\",\"Developer\",\"Engineer\"],\"customCoordinates\":\"10,10,20,20\",\"customMetadata\":{\"price\":2000}}"; - var mockHttp = new MockHttpMessageHandler(); - var request = mockHttp.Expect(url) - .WithHeaders("Authorization: Basic cHJpdmF0ZV9rZXk6") - .WithContent(result) - .Respond("application/json", "{'name' : 'ImageKit Response'}"); - - var client = mockHttp.ToHttpClient(); - RestClient rs = new RestClient(GOOD_PRIVATEKEY, GOOD_URLENDPOINT, client); - var response = rs.UpdateFileDetail(ob); - mockHttp.VerifyNoOutstandingExpectation(); - } - - [Fact] - public void GetFileListRequest_ModelValidation() - { - GetFileListRequest ob = new GetFileListRequest - { - Name = "Test", - Limit = 10, - Skip = 20, - Type = "Test", - Path = "Test", - Sort = "Test", - SearchQuery = "Test", - FileType = "Test", - Tags = null - }; - string param = "sort=Test&path=Test&searchQuery=Test&fileType=Test&name=Test&limit=10&skip=20"; - string url = string.Format("https://api.imagekit.io/v1/files/?{0}", param); - - var mockHttp = new MockHttpMessageHandler(); - var request = mockHttp.Expect(url) - .With(a => a.Method.Equals(HttpMethod.Get)) - .WithHeaders("Authorization: Basic cHJpdmF0ZV9rZXk6") - .Respond("application/json", "{'name' : 'ImageKit Response'}"); - - var client = mockHttp.ToHttpClient(); - RestClient rs = new RestClient(GOOD_PRIVATEKEY, GOOD_URLENDPOINT, client); - var response = rs.GetFileListRequest(ob); - mockHttp.VerifyNoOutstandingExpectation(); - } - [Fact] - public void PurgeCache_ModelValidation() - { - string url = string.Format("https://api.imagekit.io/v1/files/purge"); - string reqJosn = "{\"url\":\"path\"}"; - var mockHttp = new MockHttpMessageHandler(); - var request = mockHttp.Expect(url) - .With(a => a.Method.Equals(HttpMethod.Post)) - .WithHeaders("Authorization: Basic cHJpdmF0ZV9rZXk6") - .WithContent(reqJosn) - .Respond("application/json", "{'name' : 'ImageKit Response'}"); - - var client = mockHttp.ToHttpClient(); - RestClient rs = new RestClient(GOOD_PRIVATEKEY, GOOD_URLENDPOINT, client); - var response = rs.PurgeCache("path"); - mockHttp.VerifyNoOutstandingExpectation(); - } - [Fact] - public void DeleteFileRequest_ModelValidation() - { - string url = string.Format("https://api.imagekit.io/v1/files/{0}/", "fileId"); - - var mockHttp = new MockHttpMessageHandler(); - var request = mockHttp.Expect(url) - .With(a => a.Method.Equals(HttpMethod.Delete)) - .WithHeaders("Authorization: Basic cHJpdmF0ZV9rZXk6") - .Respond("application/json", "{'name' : 'ImageKit Response'}"); - - var client = mockHttp.ToHttpClient(); - RestClient rs = new RestClient(GOOD_PRIVATEKEY, GOOD_URLENDPOINT, client); - var response = rs.DeleteFile("fileId"); - mockHttp.VerifyNoOutstandingExpectation(); - } - - [Fact] - public void PurgeStatusRequest_ModelValidation() - { - string url = string.Format("https://api.imagekit.io/v1/files/purge/{0}", "purgeRequestId"); - - var mockHttp = new MockHttpMessageHandler(); - var request = mockHttp.Expect(url) - .With(a => a.Method.Equals(HttpMethod.Get)) - .WithHeaders("Authorization: Basic cHJpdmF0ZV9rZXk6") - .Respond("application/json", "{'name' : 'ImageKit Response'}"); - - var client = mockHttp.ToHttpClient(); - RestClient rs = new RestClient(GOOD_PRIVATEKEY, GOOD_URLENDPOINT, client); - var response = rs.PurgeStatus("purgeRequestId"); - mockHttp.VerifyNoOutstandingExpectation(); - } - - [Fact] - public void GetFileDetailRequest_ModelValidation() - { - string url = string.Format("https://api.imagekit.io/v1/files/{0}/details", "fileId"); - var mockHttp = new MockHttpMessageHandler(); - var request = mockHttp.Expect(url) - .With(a => a.Method.Equals(HttpMethod.Get)) - .WithHeaders("Authorization: Basic cHJpdmF0ZV9rZXk6") - .Respond("application/json", "{'name' : 'ImageKit Response'}"); - - var client = mockHttp.ToHttpClient(); - RestClient rs = new RestClient(GOOD_PRIVATEKEY, GOOD_URLENDPOINT, client); - var response = rs.GetFileDetail("fileId"); - mockHttp.VerifyNoOutstandingExpectation(); - } - - [Fact] - public void BulkDeleteFilesRequest_ModelValidation() - { - string reqJosn = "{\"fileIds\":[\"fileId1\",\"fileId2\"]}"; - - List fileIds = new List - { - "fileId1", - "fileId2" - }; - string url = string.Format("https://api.imagekit.io/v1/files/batch/deleteByfileIds"); - var mockHttp = new MockHttpMessageHandler(); - var request = mockHttp.Expect(url) - .With(a => a.Method.Equals(HttpMethod.Post)) - .WithHeaders("Authorization: Basic cHJpdmF0ZV9rZXk6") - .WithContent(reqJosn) - .Respond("application/json", "{'name' : 'ImageKit Response'}"); - - var client = mockHttp.ToHttpClient(); - RestClient rs = new RestClient(GOOD_PRIVATEKEY, GOOD_URLENDPOINT, client); - var response = rs.BulkDeleteFiles(fileIds); - mockHttp.VerifyNoOutstandingExpectation(); - } - - [Fact] - public void GetFileMetaDataRequest_ModelValidation() - { - string url = string.Format("https://api.imagekit.io/v1/files/{0}/metadata", "fileId"); - var mockHttp = new MockHttpMessageHandler(); - var request = mockHttp.Expect(url) - .With(a => a.Method.Equals(HttpMethod.Get)) - .WithHeaders("Authorization: Basic cHJpdmF0ZV9rZXk6") - .Respond("application/json", "{'name' : 'ImageKit Response'}"); - - var client = mockHttp.ToHttpClient(); - RestClient rs = new RestClient(GOOD_PRIVATEKEY, GOOD_URLENDPOINT, client); - var response = rs.GetFileMetaData("fileId"); - mockHttp.VerifyNoOutstandingExpectation(); - } - - [Fact] - public void GetRemoteFileMetaDataRequest_ModelValidation() - { - string url = string.Format("https://api.imagekit.io/v1/metadata?url={0}", "url"); - var mockHttp = new MockHttpMessageHandler(); - var request = mockHttp.Expect(url) - .With(a => a.Method.Equals(HttpMethod.Get)) - .WithHeaders("Authorization: Basic cHJpdmF0ZV9rZXk6") - .Respond("application/json", "{'name' : 'ImageKit Response'}"); - - var client = mockHttp.ToHttpClient(); - RestClient rs = new RestClient(GOOD_PRIVATEKEY, GOOD_URLENDPOINT, client); - var response = rs.GetRemoteFileMetaData("url"); - mockHttp.VerifyNoOutstandingExpectation(); - } - - [Fact] - public void AddTagsRequest_ModelValidation() - { - string reqJosn = "{\"fileIds\":[\"abc\"],\"tags\":[\"abc\",\"abc\"]}"; - - TagsRequest tagsRequest = new TagsRequest - { - tags = new List - { - "abc", - "abc" - }, - fileIds = new List - { - "abc" - } - }; - string url = "https://api.imagekit.io/v1/files/addTags"; - var mockHttp = new MockHttpMessageHandler(); - var request = mockHttp.Expect(url) - .With(a => a.Method.Equals(HttpMethod.Post)) - .WithHeaders("Authorization: Basic cHJpdmF0ZV9rZXk6") - .WithContent(reqJosn) - .Respond("application/json", "{'name' : 'ImageKit Response'}"); - - var client = mockHttp.ToHttpClient(); - RestClient rs = new RestClient(GOOD_PRIVATEKEY, GOOD_URLENDPOINT, client); - var response = rs.ManageTags(tagsRequest, "addTags"); - mockHttp.VerifyNoOutstandingExpectation(); - } - [Fact] - public void RemoveTagsRequest_ModelValidation() - { - string reqJosn = "{\"fileIds\":[\"abc\"],\"tags\":[\"abc\",\"abc\"]}"; - - TagsRequest tagsRequest = new TagsRequest - { - tags = new List - { - "abc", - "abc" - }, - fileIds = new List - { - "abc" - } - }; - string url = string.Format("https://api.imagekit.io/" + UrlHandler.RemoveTags); - var mockHttp = new MockHttpMessageHandler(); - var request = mockHttp.Expect(url) - .With(a => a.Method.Equals(HttpMethod.Post)) - .WithHeaders("Authorization: Basic cHJpdmF0ZV9rZXk6") - .WithContent(reqJosn) - .Respond("application/json", "{'name' : 'ImageKit Response'}"); - - var client = mockHttp.ToHttpClient(); - RestClient rs = new RestClient(GOOD_PRIVATEKEY, GOOD_URLENDPOINT, client); - var response = rs.ManageTags(tagsRequest, "removeTags"); - mockHttp.VerifyNoOutstandingExpectation(); - } - - [Fact] - public void RemoveAITagsRequest_ModelValidation() - { - string reqJosn = "{\"fileIds\":[\"abc\"],\"AITags\":[\"abc\",\"abc\"]}"; - - AITagsRequest tagsRequest = new AITagsRequest - { - AITags = new List - { - "abc", - "abc" - }, - fileIds = new List - { - "abc" - } - }; - string url = string.Format("https://api.imagekit.io/" + UrlHandler.RemoveAITags); - var mockHttp = new MockHttpMessageHandler(); - var request = mockHttp.Expect(url) - .With(a => a.Method.Equals(HttpMethod.Post)) - .WithHeaders("Authorization: Basic cHJpdmF0ZV9rZXk6") - .WithContent(reqJosn) - .Respond("application/json", "{'name' : 'ImageKit Response'}"); - - var client = mockHttp.ToHttpClient(); - RestClient rs = new RestClient(GOOD_PRIVATEKEY, GOOD_URLENDPOINT, client); - var response = rs.RemoveAITags(tagsRequest); - mockHttp.VerifyNoOutstandingExpectation(); - } - [Fact] - public void GetCustomMetaDataFields_ModelValidation() - { - string url = string.Format("https://api.imagekit.io/v1/customMetadataFields?includeDeleted={0}", true); - var mockHttp = new MockHttpMessageHandler(); - var request = mockHttp.Expect(url) - .With(a => a.Method.Equals(HttpMethod.Get)) - .WithHeaders("Authorization: Basic cHJpdmF0ZV9rZXk6") - .Respond("application/json", "{'name' : 'ImageKit Response'}"); - - var client = mockHttp.ToHttpClient(); - RestClient rs = new RestClient(GOOD_PRIVATEKEY, GOOD_URLENDPOINT, client); - var response = rs.GetCustomMetaDataFields(true); - mockHttp.VerifyNoOutstandingExpectation(); - } - - [Fact] - public void GetCustomMetaDataFieldsEmpty_ModelValidation() - { - string url = string.Format("https://api.imagekit.io/v1/customMetadataFields?includeDeleted={0}", false); - var mockHttp = new MockHttpMessageHandler(); - var request = mockHttp.Expect(url) - .With(a => a.Method.Equals(HttpMethod.Get)) - .WithHeaders("Authorization: Basic cHJpdmF0ZV9rZXk6") - .Respond("application/json", "{'name' : 'ImageKit Response'}"); - - var client = mockHttp.ToHttpClient(); - RestClient rs = new RestClient(GOOD_PRIVATEKEY, GOOD_URLENDPOINT, client); - var response = rs.GetCustomMetaDataFields(); - mockHttp.VerifyNoOutstandingExpectation(); - } - - [Fact] - public void GetCustomMetaDataFieldsFalse_ModelValidation() - { - string url = string.Format("https://api.imagekit.io/v1/customMetadataFields?includeDeleted={0}", false); - var mockHttp = new MockHttpMessageHandler(); - var request = mockHttp.Expect(url) - .With(a => a.Method.Equals(HttpMethod.Get)) - .WithHeaders("Authorization: Basic cHJpdmF0ZV9rZXk6") - .Respond("application/json", "{'name' : 'ImageKit Response'}"); - - var client = mockHttp.ToHttpClient(); - RestClient rs = new RestClient(GOOD_PRIVATEKEY, GOOD_URLENDPOINT, client); - var response = rs.GetCustomMetaDataFields(false); - mockHttp.VerifyNoOutstandingExpectation(); - } - - [Fact] - public void CreateCustomMetaDataFields_ModelValidation() - { - string reqJosn = "{\n \"name\": \"Tst3\",\n \"label\": \"Test3\",\n \"schema\": {\n \"type\": \"Number\",\n \"minValue\": 1000,\n \"maxValue\": 3000,\n \"isValueRequired\": true,\n \"defaultValue\": 2500\n }\n}"; - CustomMetaDataFieldCreateRequest model = new CustomMetaDataFieldCreateRequest - { - name = "Tst3", - label = "Test3" - }; - CustomMetaDataFieldSchemaObject schema = new CustomMetaDataFieldSchemaObject - { - type = "Number", - minValue = 1000, - maxValue = 3000, - isValueRequired = true, - defaultValue = 2500 - - }; - model.schema = schema; - string url = "https://api.imagekit.io/v1/customMetadataFields"; - var mockHttp = new MockHttpMessageHandler(); - var request = mockHttp.Expect(url) - .With(a => a.Method.Equals(HttpMethod.Post)) - .WithHeaders("Authorization: Basic cHJpdmF0ZV9rZXk6") - .WithContent(reqJosn) - .Respond("application/json", "{'name' : 'ImageKit Response'}"); - - var client = mockHttp.ToHttpClient(); - RestClient rs = new RestClient(GOOD_PRIVATEKEY, GOOD_URLENDPOINT, client); - var response = rs.CreateCustomMetaDataFields(model); - mockHttp.VerifyNoOutstandingExpectation(); - } - - [Fact] - public void CreateCustomMetaDataFields2_ModelValidation() - { - string reqJosn = "{\n \"name\": \"Tst3\",\n \"label\": \"Test3\",\n \"schema\": {\n \"type\": \"Number\",\n \"minValue\": 1000,\n \"maxValue\": 3000,\n \"isValueRequired\": false\n }\n}"; - CustomMetaDataFieldCreateRequest model = new CustomMetaDataFieldCreateRequest - { - name = "Tst3", - label = "Test3" - }; - CustomMetaDataFieldSchemaObject schema = new CustomMetaDataFieldSchemaObject - { - type = "Number", - minValue = 1000, - maxValue = 3000 - - }; - model.schema = schema; - string url = "https://api.imagekit.io/v1/customMetadataFields"; - var mockHttp = new MockHttpMessageHandler(); - var request = mockHttp.Expect(url) - .With(a => a.Method.Equals(HttpMethod.Post)) - .WithHeaders("Authorization: Basic cHJpdmF0ZV9rZXk6") - .WithContent(reqJosn) - .Respond("application/json", "{'name' : 'ImageKit Response'}"); - - var client = mockHttp.ToHttpClient(); - RestClient rs = new RestClient(GOOD_PRIVATEKEY, GOOD_URLENDPOINT, client); - var response = rs.CreateCustomMetaDataFields(model); - mockHttp.VerifyNoOutstandingExpectation(); - } - - [Fact] - public void UpdateCustomMetaDataFields_ModelValidation() - { - string reqJosn = "{\n \"schema\": {\n \"type\": \"Number\",\n \"minValue\": 300,\n \"maxValue\": 500\n }\n}"; - CustomMetaDataFieldUpdateRequest requestUpdateModel = new CustomMetaDataFieldUpdateRequest - { - Id = "field_Id", - }; - CustomMetaDataFieldSchemaObject updateschema = new CustomMetaDataFieldSchemaObject - { - type = "Number", - minValue = 300, - maxValue = 500 - }; - requestUpdateModel.schema = updateschema; - - string url = "https://api.imagekit.io/v1/customMetadataFields/field_Id"; - var mockHttp = new MockHttpMessageHandler(); - var request = mockHttp.Expect(url) - .WithHeaders("Authorization: Basic cHJpdmF0ZV9rZXk6") - .WithContent(reqJosn) - .Respond("application/json", "{'name' : 'ImageKit Response'}"); - - var client = mockHttp.ToHttpClient(); - RestClient rs = new RestClient(GOOD_PRIVATEKEY, GOOD_URLENDPOINT, client); - var response = rs.UpdateCustomMetaDataFields(requestUpdateModel); - mockHttp.VerifyNoOutstandingExpectation(); - } - - [Fact] - public void DeleteCustomMetaDataField_ModelValidation() - { - string url = string.Format("https://api.imagekit.io/v1/customMetadataFields/{0}", "id"); - - var mockHttp = new MockHttpMessageHandler(); - var request = mockHttp.Expect(url) - .With(a => a.Method.Equals(HttpMethod.Delete)) - .WithHeaders("Authorization: Basic cHJpdmF0ZV9rZXk6") - .Respond("application/json", "{'name' : 'ImageKit Response'}"); - - var client = mockHttp.ToHttpClient(); - RestClient rs = new RestClient(GOOD_PRIVATEKEY, GOOD_URLENDPOINT, client); - var response = rs.DeleteCustomMetaDataField("id"); - mockHttp.VerifyNoOutstandingExpectation(); - } - - [Fact] - public void DeleteFileVersion_ModelValidation() - { - DeleteFileVersionRequest model = new DeleteFileVersionRequest - { - fileId = "Tst3", - versionId = "Tst3" - }; - string url = string.Format("https://api.imagekit.io/v1/files/{0}/versions/{1}", model.fileId, - model.versionId); - var mockHttp = new MockHttpMessageHandler(); - var request = mockHttp.Expect(url) - .With(a => a.Method.Equals(HttpMethod.Delete)) - .WithHeaders("Authorization: Basic cHJpdmF0ZV9rZXk6") - .Respond("application/json", "{'name' : 'ImageKit Response'}"); - - var client = mockHttp.ToHttpClient(); - RestClient rs = new RestClient(GOOD_PRIVATEKEY, GOOD_URLENDPOINT, client); - var response = rs.DeleteFileVersion(model); - mockHttp.VerifyNoOutstandingExpectation(); - } - - [Fact] - public void CopyFile_ModelValidation() - { - string reqJosn = "{\"sourceFilePath\":\"Tst3\",\"destinationPath\":\"Tst3\",\"includeFileVersions\":false}"; - - CopyFileRequest model = new CopyFileRequest - { - sourceFilePath = "Tst3", - destinationPath = "Tst3" - }; - string url = string.Empty; - url = string.Format("https://api.imagekit.io/v1/files/copy"); - var mockHttp = new MockHttpMessageHandler(); - var request = mockHttp.Expect(url) - .With(a => a.Method.Equals(HttpMethod.Post)) - .WithHeaders("Authorization: Basic cHJpdmF0ZV9rZXk6") - .WithContent(reqJosn) - .Respond("application/json", "{'name' : 'ImageKit Response'}"); - - var client = mockHttp.ToHttpClient(); - RestClient rs = new RestClient(GOOD_PRIVATEKEY, GOOD_URLENDPOINT, client); - var response = rs.CopyFile(model); - mockHttp.VerifyNoOutstandingExpectation(); - } - - [Fact] - public void CopyFile_includeFileVersions_ModelValidation() - { - string reqJosn = "{\"sourceFilePath\":\"Tst3\",\"destinationPath\":\"Tst3\",\"includeFileVersions\":true}"; - - CopyFileRequest model = new CopyFileRequest - { - sourceFilePath = "Tst3", - destinationPath = "Tst3", - includeFileVersions = true - }; - string url = string.Empty; - url = string.Format("https://api.imagekit.io/v1/files/copy"); - var mockHttp = new MockHttpMessageHandler(); - var request = mockHttp.Expect(url) - .With(a => a.Method.Equals(HttpMethod.Post)) - .WithHeaders("Authorization: Basic cHJpdmF0ZV9rZXk6") - .WithContent(reqJosn) - .Respond("application/json", "{'name' : 'ImageKit Response'}"); - - var client = mockHttp.ToHttpClient(); - RestClient rs = new RestClient(GOOD_PRIVATEKEY, GOOD_URLENDPOINT, client); - var response = rs.CopyFile(model); - mockHttp.VerifyNoOutstandingExpectation(); - } - - [Fact] - public void MoveFile_ModelValidation() - { - string reqJosn = "{\"sourceFilePath\":\"Tst3\",\"destinationPath\":\"Tst3\"}"; - MoveFileRequest model = new MoveFileRequest - { - sourceFilePath = "Tst3", - destinationPath = "Tst3" - }; - - string url = string.Empty; - url = string.Format("https://api.imagekit.io/v1/files/move"); - var mockHttp = new MockHttpMessageHandler(); - var request = mockHttp.Expect(url) - .With(a => a.Method.Equals(HttpMethod.Post)) - .WithHeaders("Authorization: Basic cHJpdmF0ZV9rZXk6") - .WithContent(reqJosn) - .Respond("application/json", "{'name' : 'ImageKit Response'}"); - - var client = mockHttp.ToHttpClient(); - RestClient rs = new RestClient(GOOD_PRIVATEKEY, GOOD_URLENDPOINT, client); - var response = rs.MoveFile(model); - mockHttp.VerifyNoOutstandingExpectation(); - } - - [Fact] - public void RenameFile_ModelValidation() - { - string reqJosn = "{\"filePath\":\"Tst3\",\"newFileName\":\"Tst4\",\"purgeCache\":false}"; - RenameFileRequest model = new RenameFileRequest - { - filePath = "Tst3", - newFileName = "Tst4", - purgeCache = false - }; - - string url = string.Empty; - url = string.Format("https://api.imagekit.io/v1/files/rename"); - var mockHttp = new MockHttpMessageHandler(); - var request = mockHttp.Expect(url) - .With(a => a.Method.Equals(HttpMethod.Put)) - .WithHeaders("Authorization: Basic cHJpdmF0ZV9rZXk6") - .WithContent(reqJosn) - .Respond("application/json", "{'name' : 'ImageKit Response'}"); - - var client = mockHttp.ToHttpClient(); - RestClient rs = new RestClient(GOOD_PRIVATEKEY, GOOD_URLENDPOINT, client); - var response = rs.RenameFile(model); - mockHttp.VerifyNoOutstandingExpectation(); - } - - [Fact] - public void RenameFileTrue_ModelValidation() - { - string reqJosn = "{\"filePath\":\"Tst3\",\"newFileName\":\"Tst4\",\"purgeCache\":true}"; - RenameFileRequest model = new RenameFileRequest - { - filePath = "Tst3", - newFileName = "Tst4", - purgeCache = true - }; - - string url = string.Empty; - url = string.Format("https://api.imagekit.io/v1/files/rename"); - var mockHttp = new MockHttpMessageHandler(); - var request = mockHttp.Expect(url) - .With(a => a.Method.Equals(HttpMethod.Put)) - .WithHeaders("Authorization: Basic cHJpdmF0ZV9rZXk6") - .WithContent(reqJosn) - .Respond("application/json", "{'name' : 'ImageKit Response'}"); - - var client = mockHttp.ToHttpClient(); - RestClient rs = new RestClient(GOOD_PRIVATEKEY, GOOD_URLENDPOINT, client); - var response = rs.RenameFile(model); - mockHttp.VerifyNoOutstandingExpectation(); - } - - [Fact] - public void RenameFileDefaultPurge_ModelValidation() - { - string reqJosn = "{\"filePath\":\"Tst3\",\"newFileName\":\"Tst4\",\"purgeCache\":false}"; - RenameFileRequest model = new RenameFileRequest - { - filePath = "Tst3", - newFileName = "Tst4" - }; - - string url = string.Empty; - url = string.Format("https://api.imagekit.io/v1/files/rename"); - var mockHttp = new MockHttpMessageHandler(); - var request = mockHttp.Expect(url) - .With(a => a.Method.Equals(HttpMethod.Put)) - .WithHeaders("Authorization: Basic cHJpdmF0ZV9rZXk6") - .WithContent(reqJosn) - .Respond("application/json", "{'name' : 'ImageKit Response'}"); - - var client = mockHttp.ToHttpClient(); - RestClient rs = new RestClient(GOOD_PRIVATEKEY, GOOD_URLENDPOINT, client); - var response = rs.RenameFile(model); - mockHttp.VerifyNoOutstandingExpectation(); - } - [Fact] - public void CopyFolder_ModelValidation() - { - string reqJosn = "{\"sourceFolderPath\":\"Tst3\",\"destinationPath\":\"Tst3\",\"includeFileVersions\":false}"; - CopyFolderRequest model = new CopyFolderRequest - { - sourceFolderPath = "Tst3", - destinationPath = "Tst3" - - }; - string url = string.Format("https://api.imagekit.io/v1/bulkJobs/copyFolder"); - var mockHttp = new MockHttpMessageHandler(); - var request = mockHttp.Expect(url) - .With(a => a.Method.Equals(HttpMethod.Post)) - .WithHeaders("Authorization: Basic cHJpdmF0ZV9rZXk6") - .WithContent(reqJosn) - .Respond("application/json", "{'name' : 'ImageKit Response'}"); - - var client = mockHttp.ToHttpClient(); - RestClient rs = new RestClient(GOOD_PRIVATEKEY, GOOD_URLENDPOINT, client); - var response = rs.CopyFolder(model); - mockHttp.VerifyNoOutstandingExpectation(); - } - - [Fact] - public void CopyFolder_includeFileVersions_ModelValidation() - { - string reqJosn = "{\"sourceFolderPath\":\"Tst3\",\"destinationPath\":\"Tst3\",\"includeFileVersions\":true}"; - CopyFolderRequest model = new CopyFolderRequest - { - sourceFolderPath = "Tst3", - destinationPath = "Tst3", - includeFileVersions = true - - }; - string url = string.Format("https://api.imagekit.io/v1/bulkJobs/copyFolder"); - var mockHttp = new MockHttpMessageHandler(); - var request = mockHttp.Expect(url) - .With(a => a.Method.Equals(HttpMethod.Post)) - .WithHeaders("Authorization: Basic cHJpdmF0ZV9rZXk6") - .WithContent(reqJosn) - .Respond("application/json", "{'name' : 'ImageKit Response'}"); - - var client = mockHttp.ToHttpClient(); - RestClient rs = new RestClient(GOOD_PRIVATEKEY, GOOD_URLENDPOINT, client); - var response = rs.CopyFolder(model); - mockHttp.VerifyNoOutstandingExpectation(); - } - - [Fact] - public void MoveFolder_ModelValidation() - { - string reqJosn = "{\"sourceFolderPath\":\"Tst3\",\"destinationPath\":\"Tst3\"}"; - MoveFolderRequest model = new MoveFolderRequest - { - sourceFolderPath = "Tst3", - destinationPath = "Tst3" - }; - string url = string.Format("https://api.imagekit.io/v1/bulkJobs/moveFolder"); - var mockHttp = new MockHttpMessageHandler(); - var request = mockHttp.Expect(url) - .With(a => a.Method.Equals(HttpMethod.Post)) - .WithHeaders("Authorization: Basic cHJpdmF0ZV9rZXk6") - .WithContent(reqJosn) - .Respond("application/json", "{'name' : 'ImageKit Response'}"); - - var client = mockHttp.ToHttpClient(); - RestClient rs = new RestClient(GOOD_PRIVATEKEY, GOOD_URLENDPOINT, client); - var response = rs.MoveFolder(model); - mockHttp.VerifyNoOutstandingExpectation(); - } - - - [Fact] - public void GetBulkJobStatus_ModelValidation() - { - string url = string.Format("https://api.imagekit.io/v1/bulkJobs/{0}", "jobId"); - var mockHttp = new MockHttpMessageHandler(); - var request = mockHttp.Expect(url) - .With(a => a.Method.Equals(HttpMethod.Get)) - .WithHeaders("Authorization: Basic cHJpdmF0ZV9rZXk6") - .Respond("application/json", "{'name' : 'ImageKit Response'}"); - - var client = mockHttp.ToHttpClient(); - RestClient rs = new RestClient(GOOD_PRIVATEKEY, GOOD_URLENDPOINT, client); - var response = rs.GetBulkJobStatus("jobId"); - mockHttp.VerifyNoOutstandingExpectation(); - } - [Fact] - public void GetFileVersions_ModelValidation() - { - string url = string.Format("https://api.imagekit.io/v1/files/{0}/versions", "fileId"); - var mockHttp = new MockHttpMessageHandler(); - var request = mockHttp.Expect(url) - .With(a => a.Method.Equals(HttpMethod.Get)) - .WithHeaders("Authorization: Basic cHJpdmF0ZV9rZXk6") - .Respond("application/json", "{'name' : 'ImageKit Response'}"); - - var client = mockHttp.ToHttpClient(); - RestClient rs = new RestClient(GOOD_PRIVATEKEY, GOOD_URLENDPOINT, client); - var response = rs.GetFileVersions("fileId"); - mockHttp.VerifyNoOutstandingExpectation(); - } - - [Fact] - public void GetFileVersionDetails_ModelValidation() - { - string url = string.Format("https://api.imagekit.io/v1/files/{0}/versions/{1}", "fileId", "versionId"); - var mockHttp = new MockHttpMessageHandler(); - var request = mockHttp.Expect(url) - .With(a => a.Method.Equals(HttpMethod.Get)) - .WithHeaders("Authorization: Basic cHJpdmF0ZV9rZXk6") - .Respond("application/json", "{'name' : 'ImageKit Response'}"); - - var client = mockHttp.ToHttpClient(); - RestClient rs = new RestClient(GOOD_PRIVATEKEY, GOOD_URLENDPOINT, client); - var response = rs.GetFileVersionDetails("fileId", "versionId"); - mockHttp.VerifyNoOutstandingExpectation(); - } - - [Fact] - public void RestoreFileVersion_ModelValidation() - { - string url = string.Format("https://api.imagekit.io/v1/files/{0}/versions/{1}/restore", "fileId", "versionId"); - var mockHttp = new MockHttpMessageHandler(); - var request = mockHttp.Expect(url) - .With(a => a.Method.Equals(HttpMethod.Put)) - .WithHeaders("Authorization: Basic cHJpdmF0ZV9rZXk6") - .Respond("application/json", "{'name' : 'ImageKit Response'}"); - - var client = mockHttp.ToHttpClient(); - RestClient rs = new RestClient(GOOD_PRIVATEKEY, GOOD_URLENDPOINT, client); - var response = rs.RestoreFileVersion("fileId", "versionId"); - mockHttp.VerifyNoOutstandingExpectation(); - } - } -} diff --git a/Imagekit.UnitTests/ImageKitTestCasesAsync.cs b/Imagekit.UnitTests/ImageKitTestCasesAsync.cs deleted file mode 100644 index e2722327..00000000 --- a/Imagekit.UnitTests/ImageKitTestCasesAsync.cs +++ /dev/null @@ -1,726 +0,0 @@ -using Imagekit.Constant; -using Imagekit.Sdk; -using Imagekit.Models; -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Net; -using System.Net.Http; -using Newtonsoft.Json.Linq; -using Xunit; - -namespace Imagekit.UnitTests -{ - - public class ImageKitTestCasesAsync - { - private const string GOOD_PUBLICKEY = "abc"; - private const string GOOD_PRIVATEKEY = "abc"; - private const string GOOD_URLENDPOINT = "https://dasdsad.dad.io/"; - - [Fact] - public void Missing_Key_Exception() - { - - Exception actualException = Assert.Throws(() => new RestClient("", "https://dasdsad.dad.io/", new HttpClient())); - Assert.Equal(ErrorMessages.InvalidKey, actualException.Message); - } - [Fact] - public void Missing_URL_Exception() - { - - Exception actualException = Assert.Throws(() => new RestClient("abc", "", new HttpClient())); - Assert.Equal(ErrorMessages.InvalidApiUrl, actualException.Message); - } - - [Fact] - public void Constructor_TransformationPosition_Default() - { - var imagekit = new ImagekitClient(GOOD_PUBLICKEY, GOOD_PRIVATEKEY, GOOD_URLENDPOINT); - Assert.NotNull(imagekit); - } - - [Fact] - public void GetFileRequest_Default() - { - GetFileListRequest ob = new GetFileListRequest - { - Type = "file", - Limit = 10, - Skip = 0, - Sort = "ASC_CREATED", - SearchQuery = "createdAt >= \"7d\"", - FileType = "image", - Path = "/" - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = (ResultList)restClient.GetFileListRequestAsync(ob).Result; - var responseObj1 = JsonConvert.SerializeObject(responseObj.Raw); - responseObj1 = JToken.Parse(responseObj1).ToString(); - - Assert.Equal(responseObj.Raw, responseObj1); - } - [Fact] - public async void GetFileRequestByNameWithoutSearchQuery() - { - GetFileListRequest ob = new GetFileListRequest - { - - Name = "file_name.jpg", - - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = await restClient.GetFileListRequestAsync(ob); - // Console.WriteLine("res",response); - var responseObj1 = JsonConvert.SerializeObject(responseObj.Raw); - responseObj1 = JToken.Parse(responseObj1).ToString(); - - Assert.Equal(responseObj.Raw, responseObj1); - Console.WriteLine(responseObj.Raw); - } - [Fact] - public void GetFileRequestByName() - { - GetFileListRequest ob = new GetFileListRequest - { - - SearchQuery = "name = \"file_name.jpg\"", - - - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = (ResultList)restClient.GetFileListRequestAsync(ob).Result; - var responseObj1 = JsonConvert.SerializeObject(responseObj.Raw); - responseObj1 = JToken.Parse(responseObj1).ToString(); - - Assert.Equal(responseObj.Raw, responseObj1); - } - [Fact] - public void GetFileRequestByTag() - { - GetFileListRequest ob = new GetFileListRequest - { - - SearchQuery = "tags = \"tag1,tag2\"", - - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = (ResultList)restClient.GetFileListRequestAsync(ob).Result; - var responseObj1 = JsonConvert.SerializeObject(responseObj.Raw); - responseObj1 = JToken.Parse(responseObj1).ToString(); - - Assert.Equal(responseObj.Raw, responseObj1); - } - [Fact] - public void GetFileRequestWithoutFilter_Default() - { - GetFileListRequest ob = new GetFileListRequest(); - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = (ResultList)restClient.GetFileListRequestAsync(ob).Result; - var responseObj1 = JsonConvert.SerializeObject(responseObj.Raw); - responseObj1 = JToken.Parse(responseObj1).ToString(); - - Assert.Equal(responseObj.Raw, responseObj1); - } - - [Fact] - public void GetFileDetail_Default() - { - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = (Result)restClient.GetFileDetailAsync("abc").Result; - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - [Fact] - public void GetFile_ID_Detail_Exception() - { - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.GetFileDetailAsync("")); - Assert.Equal(ErrorMessages.FileIdMissing, ex.Result.Message); - } - - [Fact] - public void PurgeCache_Default() - { - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = restClient.PurgeCacheAsync("abc").Result; - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - [Fact] - public void PurgeStatus_Default() - { - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = restClient.PurgeStatusAsync("abc").Result; - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - [Fact] - public void DeleteFile_Default() - { - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = (ResultDelete)restClient.DeleteFileAsync("abc").Result; - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - [Fact] - public void Delete_File_ID_Exception() - { - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.DeleteFileAsync("")); - Assert.Equal(ErrorMessages.FileIdMissing, ex.Result.Message); - } - - - [Fact] - public void BulkDeleteFiles_Default() - { - List ob = new List - { - "abc", - "abcd" - }; - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = (ResultFileDelete)restClient.BulkDeleteFilesAsync(ob).Result; - var responseObj1 = JsonConvert.SerializeObject(responseObj.Raw); - responseObj1=JToken.Parse(responseObj1).ToString(); - Assert.Equal(responseObj.Raw, responseObj1); - } - [Fact] - public void Bulk_Delete_Files_Input_Missing_Exception() - { - List ob = new List(); - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.BulkDeleteFilesAsync(ob)); - Assert.Equal(ErrorMessages.ListFilesInputMissing, ex.Result.Message); - } - - [Fact] - public void Missing_Filed_Null_Exception() - { - TagsRequest ob = new TagsRequest - { - tags = new List { "abc" }, - fileIds = null - }; - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.ManageTagsAsync(ob, "")); - Assert.Equal(ErrorMessages.InvalidFiledParamValue, ex.Result.Message); - } - - - - - [Fact] - public void Missing_Remove_Filed_Null_Exception() - { - TagsRequest ob = new TagsRequest - { - tags = new List { "abc" }, - fileIds = null - }; - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.ManageTagsAsync(ob, "")); - Assert.Equal(ErrorMessages.InvalidFiledParamValue, ex.Result.Message); - } - - - [Fact] - public void Missing_AI_Filed_Null_Exception() - { - AITagsRequest ob = new AITagsRequest - { - AITags = new List { "abc" }, - fileIds = null - }; - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.RemoveAITagsAsync(ob)); - Assert.Equal(ErrorMessages.InvalidFiledParamValue, ex.Result.Message); - } - - [Fact] - public void DeleteFileVersion_Default() - { - DeleteFileVersionRequest model = new DeleteFileVersionRequest - { - fileId = "Tst3", - versionId = "Tst3" - }; - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = restClient.DeleteFileVersionAsync(model).Result; - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - [Fact] - public void Missing_Object_FileVersionException() - { - DeleteFileVersionRequest model = null; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.DeleteFileVersionAsync(model)); - Assert.Equal(ErrorMessages.InvalidDelVerValue, ex.Result.Message); - } - [Fact] - public void Missing_fileId_FileVersionException() - { - DeleteFileVersionRequest model = new DeleteFileVersionRequest - { - versionId = "abc" - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.DeleteFileVersionAsync(model)); - Assert.Equal(ErrorMessages.InvalidFieldIdDelVerValue, ex.Result.Message); - } - - [Fact] - public void Missing_versionId_FileVersionException() - { - DeleteFileVersionRequest model = new DeleteFileVersionRequest - { - versionId = "", - fileId = "sas" - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.DeleteFileVersionAsync(model)); - Assert.Equal(ErrorMessages.InvalidversionIdDelVerValue, ex.Result.Message); - } - - [Fact] - public void CopyFile_Default() - { - CopyFileRequest model = new CopyFileRequest - { - sourceFilePath = "Tst3", - destinationPath = "Tst3", - includeFileVersions = true - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = restClient.CopyFileAsync(model).Result; - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - [Fact] - public void Missing_Obj_CopyFileException() - { - CopyFileRequest model = null; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.CopyFileAsync(model)); - Assert.Equal(ErrorMessages.InvalidCopyValue, ex.Result.Message); - } - - - - [Fact] - public void Missing_Source_CopyFileException() - { - CopyFileRequest model = new CopyFileRequest - { - destinationPath = "abc" - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.CopyFileAsync(model)); - Assert.Equal(ErrorMessages.InvalidSourceValue, ex.Result.Message); - } - - [Fact] - public void Missing_Destination_CopyFileException() - { - CopyFileRequest model = new CopyFileRequest - { - sourceFilePath = "abc" - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.CopyFileAsync(model)); - Assert.Equal(ErrorMessages.InvalidDestinationValue, ex.Result.Message); - } - - [Fact] - public void MoveFile_Default() - { - MoveFileRequest model = new MoveFileRequest - { - sourceFilePath = "Tst3", - destinationPath = "Tst3" - }; - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = restClient.MoveFileAsync(model).Result; - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - [Fact] - public void Missing_Obj_MoveFileException() - { - MoveFileRequest model = null; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.MoveFileAsync(model)); - Assert.Equal(ErrorMessages.InvalidCopyValue, ex.Result.Message); - } - - [Fact] - public void Missing_Source_MoveFileException() - { - MoveFileRequest model = new MoveFileRequest - { - destinationPath = "abc" - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.MoveFileAsync(model)); - Assert.Equal(ErrorMessages.InvalidSourceValue, ex.Result.Message); - } - - [Fact] - public void Missing_Destination_MoveFileException() - { - MoveFileRequest model = new MoveFileRequest - { - sourceFilePath = "abc" - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.MoveFileAsync(model)); - Assert.Equal(ErrorMessages.InvalidDestinationValue, ex.Result.Message); - } - - [Fact] - public void RenameFile_Default() - { - RenameFileRequest model = new RenameFileRequest - { - filePath = "Tst3", - newFileName = "Tst4", - purgeCache = false - }; - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = restClient.RenameFileAsync(model).Result; - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - [Fact] - public void Missing_FilePath_RenameFileException() - { - RenameFileRequest model = new RenameFileRequest - { - newFileName = "test" - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.RenameFileAsync(model)); - Assert.Equal(ErrorMessages.InvalidRenameFilePathValue, ex.Result.Message); - } - [Fact] - public void Missing_NewFileName_RenameFileException() - { - RenameFileRequest model = new RenameFileRequest - { - filePath = "test" - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.RenameFileAsync(model)); - Assert.Equal(ErrorMessages.InvalidRenameNewFileNameValue, ex.Result.Message); - } - - - [Fact] - public void GetBulkJobStatus_Default() - { - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = restClient.GetBulkJobStatusAsync("abc").Result; - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - [Fact] - public void Missing_Job_Id_BulkJobStatusException() - { - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.GetBulkJobStatusAsync("")); - Assert.Equal(ErrorMessages.InvalidJobValue, ex.Result.Message); - } - } -} - - - - diff --git a/Imagekit.UnitTests/ImageKitTestCasesNonAsync.cs b/Imagekit.UnitTests/ImageKitTestCasesNonAsync.cs deleted file mode 100644 index 4e57c7be..00000000 --- a/Imagekit.UnitTests/ImageKitTestCasesNonAsync.cs +++ /dev/null @@ -1,734 +0,0 @@ -using Imagekit.Constant; -using Imagekit.Sdk; -using Imagekit.Models; -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Net; -using System.Net.Http; -using Xunit; -using Newtonsoft.Json.Linq; - -namespace Imagekit.UnitTests.FileVersion -{ - public class ImageKitTestCasesNonAsync - { - private const string GOOD_PUBLICKEY = "public_key"; - private const string GOOD_PRIVATEKEY = "private_key_test"; - private const string GOOD_URLENDPOINT = "https://endpoint_url.io/"; - - - [Fact] - public void Missing_Key_ExceptionNonAsync() - { - - Exception actualException = Assert.Throws(() => new RestClient("", "https://endpoint_url.io/", new HttpClient())); - Assert.Equal(ErrorMessages.InvalidKey, actualException.Message); - } - [Fact] - public void Missing_URL_ExceptionNonAsync() - { - - Exception actualException = Assert.Throws(() => new RestClient("abc", "", new HttpClient())); - Assert.Equal(ErrorMessages.InvalidApiUrl, actualException.Message); - } - - [Fact] - public void Constructor_TransformationPosition_DefaultNonAsync() - { - var imagekit = new ImagekitClient(GOOD_PUBLICKEY, GOOD_PRIVATEKEY, GOOD_URLENDPOINT); - Assert.NotNull(imagekit); - } - [Fact] - public void UrlValidation() - { - var imagekit = new ImagekitClient(GOOD_PUBLICKEY, GOOD_PRIVATEKEY, GOOD_URLENDPOINT); - string path = "/default-image.jpg"; - Transformation trans = new Transformation() - .Width(400) - .Height(300) - .AspectRatio("4-3") - .Quality(40) - .Crop("force").CropMode("extract"). - Focus("left"). - Format("jpeg"). - Background("A94D34"). - Border("5-A94D34"). - Rotation(90). - Blur(10). - Named("some_name"). - Progressive(true). - Lossless(true). - Trim(5). - Metadata(true). - ColorProfile(true). - DefaultImage("folder/file.jpg/"). //trailing slash case - Dpr(3). - EffectSharpen(10). - EffectUsm("2-2-0.8-0.024"). - EffectContrast(true). - EffectGray(). - EffectShadow("bl-15"). - EffectGradient("from-lightskyblue_to-mintcream"). - Original(). - Raw("l-text,i-Imagekit,fs-50,l-end") - ; - - string imageURL = imagekit.Url(trans).Path(path).TransformationPosition("query").Generate(); - - Assert.Equal("https://endpoint_url.io/default-image.jpg?tr=w-400%2Ch-300%2Car-4-3%2Cq-40%2Cc-force%2Ccm-extract%2Cfo-left%2Cf-jpeg%2Cbg-A94D34%2Cb-5-A94D34%2Crt-90%2Cbl-10%2Cn-some_name%2Cpr-true%2Clo-true%2Ct-5%2Cmd-true%2Ccp-true%2Cdi-folder%40%40file.jpg%2Cdpr-3%2Ce-sharpen-10%2Ce-usm-2-2-0.8-0.024%2Ce-contrast-true%2Ce-grayscale-true%2Ce-shadow-bl-15%2Ce-gradient-from-lightskyblue_to-mintcream%2Corig-true%2Cl-text%2Ci-Imagekit%2Cfs-50%2Cl-end", imageURL); - } - - - [Fact] - public void UrlValidation1() - { - var imagekit = new ImagekitClient(GOOD_PUBLICKEY, GOOD_PRIVATEKEY, GOOD_URLENDPOINT); - var imgUrl1 = "https://ik.imagekit.io/demo/default-image.jpg"; - string[] queryParams = { "b=query", "a=value" }; - try - { - var signedUrl = imagekit.Url(new Transformation().Width(400).Height(300)) - .Src(imgUrl1) - .QueryParameters(queryParams) - .ExpireSeconds(600) - .Signed() - .Generate(); - Console.WriteLine("Signed Url for first image transformed with height: 300, width: 400: - {0}", signedUrl); - } - catch (Exception ex) - { - Console.WriteLine(ex.Message); - } - } - - [Fact] - public void GetFileRequest_DefaultNonAsync() - { - GetFileListRequest ob = new GetFileListRequest - { - Limit = 10, - Skip = 0 - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = (ResultList)restClient.GetFileListRequest(ob); - - Assert.Equal(response.Raw, response.Raw); - } - - [Fact] - public void GetFileDetail_DefaultNonAsync() - { - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var response = (Result)restClient.GetFileDetail("abc"); - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - [Fact] - public void GetFile_ID_Detail_ExceptionNonAsync() - { - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.GetFileDetail("")); - Assert.Equal(ErrorMessages.FileIdMissing, ex.Message); - } - - - - [Fact] - public void PurgeCache_DefaultNonAsync() - { - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = restClient.PurgeCache("abc"); - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - [Fact] - public void PurgeStatus_DefaultNonAsync() - { - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = restClient.PurgeStatus("abc"); - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - [Fact] - public void DeleteFile_DefaultNonAsync() - { - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = (ResultDelete)restClient.DeleteFile("abc"); - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - [Fact] - public void Delete_File_ID_ExceptionNonAsync() - { - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.DeleteFile("")); - Assert.Equal(ErrorMessages.FileIdMissing, ex.Message); - } - - - [Fact] - public void BulkDeleteFiles_DefaultNonAsync() - { - List ob = new List - { - "abc", - "abcd" - }; - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = (ResultFileDelete)restClient.BulkDeleteFiles(ob); - var responseObj1 = JsonConvert.SerializeObject(responseObj.Raw); - responseObj1 = JToken.Parse(responseObj1).ToString(); - - Assert.Equal(responseObj.Raw, responseObj1); - } - [Fact] - public void Bulk_Delete_Files_Input_Missing_ExceptionNonAsync() - { - List ob = new List(); - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.BulkDeleteFiles(ob)); - Assert.Equal(ErrorMessages.ListFilesInputMissing, ex.Message); - } - - - - - - - - [Fact] - public void Missing_Filed_Null_ExceptionNonAsync() - { - TagsRequest ob = new TagsRequest - { - tags = new List { "abc" }, - fileIds = null - }; - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.ManageTags(ob, "")); - Assert.Equal(ErrorMessages.InvalidFiledParamValue, ex.Message); - } - - - - - [Fact] - public void Missing_Remove_Filed_Null_ExceptionNonAsync() - { - TagsRequest ob = new TagsRequest - { - tags = new List { "abc" }, - fileIds = null - }; - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.ManageTags(ob, "")); - Assert.Equal(ErrorMessages.InvalidFiledParamValue, ex.Message); - } - - - [Fact] - public void Missing_AI_Filed_Null_ExceptionNonAsync() - { - AITagsRequest ob = new AITagsRequest - { - AITags = new List { "abc" }, - fileIds = null - }; - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.RemoveAITags(ob)); - Assert.Equal(ErrorMessages.InvalidFiledParamValue, ex.Message); - } - - [Fact] - public void DeleteFileVersion_DefaultNonAsync() - { - DeleteFileVersionRequest model = new DeleteFileVersionRequest - { - fileId = "Tst3", - versionId = "Tst3" - }; - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = restClient.DeleteFileVersion(model); - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - [Fact] - public void Missing_Object_FileVersionExceptionNonAsync() - { - DeleteFileVersionRequest model = null; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => (ResultNoContent)restClient.DeleteFileVersion(model)); - Assert.Equal(ErrorMessages.InvalidDelVerValue, ex.Message); - } - [Fact] - public void Missing_fileId_FileVersionExceptionNonAsync() - { - DeleteFileVersionRequest model = new DeleteFileVersionRequest - { - versionId = "abc" - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.DeleteFileVersion(model)); - Assert.Equal(ErrorMessages.InvalidFieldIdDelVerValue, ex.Message); - } - - [Fact] - public void Missing_versionId_FileVersionExceptionNonAsync() - { - DeleteFileVersionRequest model = new DeleteFileVersionRequest - { - versionId = "", - fileId = "sas" - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.DeleteFileVersion(model)); - Assert.Equal(ErrorMessages.InvalidversionIdDelVerValue, ex.Message); - } - - [Fact] - public void CopyFile_DefaultNonAsync() - { - CopyFileRequest model = new CopyFileRequest - { - sourceFilePath = "Tst3", - destinationPath = "Tst3", - includeFileVersions = true - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = restClient.CopyFile(model); - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - [Fact] - public void Missing_Obj_CopyFileExceptionNonAsync() - { - CopyFileRequest model = null; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.CopyFile(model)); - Assert.Equal(ErrorMessages.InvalidCopyValue, ex.Message); - } - - - - [Fact] - public void Missing_Source_CopyFileExceptionNonAsync() - { - CopyFileRequest model = new CopyFileRequest - { - destinationPath = "abc" - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.CopyFile(model)); - Assert.Equal(ErrorMessages.InvalidSourceValue, ex.Message); - } - - [Fact] - public void Missing_Destination_CopyFileExceptionNonAsync() - { - CopyFileRequest model = new CopyFileRequest - { - sourceFilePath = "abc" - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.CopyFile(model)); - Assert.Equal(ErrorMessages.InvalidDestinationValue, ex.Message); - } - - [Fact] - public void MoveFile_DefaultNonAsync() - { - MoveFileRequest model = new MoveFileRequest - { - sourceFilePath = "Tst3", - destinationPath = "Tst3" - }; - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = restClient.MoveFile(model); - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - [Fact] - public void Missing_Obj_MoveFileExceptionNonAsync() - { - MoveFileRequest model = null; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.MoveFile(model)); - Assert.Equal(ErrorMessages.InvalidCopyValue, ex.Message); - } - - [Fact] - public void Missing_Source_MoveFileExceptionNonAsync() - { - MoveFileRequest model = new MoveFileRequest - { - destinationPath = "abc" - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.MoveFile(model)); - Assert.Equal(ErrorMessages.InvalidSourceValue, ex.Message); - } - - [Fact] - public void Missing_Destination_MoveFileExceptionNonAsync() - { - MoveFileRequest model = new MoveFileRequest - { - sourceFilePath = "abc" - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.MoveFile(model)); - Assert.Equal(ErrorMessages.InvalidDestinationValue, ex.Message); - } - - [Fact] - public void RenameFile_DefaultNonAsync() - { - RenameFileRequest model = new RenameFileRequest - { - filePath = "Tst3", - newFileName = "Tst4", - purgeCache = false - }; - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = restClient.RenameFile(model); - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - [Fact] - public void Missing_FilePath_RenameFileExceptionNonAsync() - { - RenameFileRequest model = new RenameFileRequest - { - newFileName = "test" - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.RenameFile(model)); - Assert.Equal(ErrorMessages.InvalidRenameFilePathValue, ex.Message); - } - [Fact] - public void Missing_NewFileName_RenameFileExceptionNonAsync() - { - RenameFileRequest model = new RenameFileRequest - { - filePath = "test" - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.RenameFile(model)); - Assert.Equal(ErrorMessages.InvalidRenameNewFileNameValue, ex.Message); - } - - - [Fact] - public void GetBulkJobStatus_DefaultNonAsync() - { - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = restClient.GetBulkJobStatus("abc"); - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - [Fact] - public void Missing_Job_Id_BulkJobStatusExceptionNonAsync() - { - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.GetBulkJobStatus("")); - Assert.Equal(ErrorMessages.InvalidJobValue, ex.Message); - } - - - [Fact] - public void SameImage_getHammingDistance_expectedSuccessWith() - { - var imagekit = new ImagekitClient(GOOD_PUBLICKEY, GOOD_PRIVATEKEY, GOOD_URLENDPOINT); - int hammingDistance = imagekit.PHashDistance("f06830ca9f1e3e90", "f06830ca9f1e3e90"); - Assert.Equal(0, hammingDistance); - } - - - [Fact] - public void SimilarImage_getHammingDistance_expectedSuccessWith() - { - var imagekit = new ImagekitClient(GOOD_PUBLICKEY, GOOD_PRIVATEKEY, GOOD_URLENDPOINT); - int hammingDistance = imagekit.PHashDistance("33699c96619cc69e", "968e978414fe04ea"); - Assert.Equal(2, hammingDistance); - } - - [Fact] - public void AuthenticationParamCheck() - { - var imagekit = new ImagekitClient(GOOD_PUBLICKEY, GOOD_PRIVATEKEY, GOOD_URLENDPOINT); - string token = "your_token"; - string expire = "1582269249"; - AuthParamResponse authParams = imagekit.GetAuthenticationParameters(token, expire); - Assert.Equal(token, authParams.token); - Assert.Equal(expire, authParams.expire); - Assert.Equal("e71bcd6031016b060d349d212e23e85c791decdd", authParams.signature); - } - - [Fact] - public void AuthenticationParamNullCheck() - { - var imagekit = new ImagekitClient(GOOD_PUBLICKEY, GOOD_PRIVATEKEY, GOOD_URLENDPOINT); - string token = null; - string expire = "1582269249"; - AuthParamResponse authParams = imagekit.GetAuthenticationParameters(token, expire); - Assert.NotEmpty(authParams.token); - Assert.IsType(authParams.token); - Assert.Equal(expire, authParams.expire); - Assert.NotEmpty(authParams.signature); - Assert.IsType(authParams.signature); - } - } -} - - - - diff --git a/Imagekit.UnitTests/Imagekit.UnitTests.csproj b/Imagekit.UnitTests/Imagekit.UnitTests.csproj deleted file mode 100644 index 0c21e082..00000000 --- a/Imagekit.UnitTests/Imagekit.UnitTests.csproj +++ /dev/null @@ -1,77 +0,0 @@ - - - - net7.0;net5.0;net6.0;netcoreapp3.1 - 8 - true - false - - - - 1701;1702;NU5125;NU5048; - - - - 1701;1702;NU5125;NU5048; - - - - 1701;1702;NU5125;NU5048; - 5 - - - - 1701;1702;NU5125;NU5048; - 5 - - - - 1701;1702;NU5125;NU5048; - 5 - - - - 1701;1702;NU5125;NU5048; - 5 - - - - 1701;1702;NU5125;NU5048; - - - - 1701;1702;NU5125;NU5048; - - - - 1701;1702;NU5125;NU5048; - - - - 1701;1702;NU5125;NU5048; - - - - - - - - - - - - - - - - - - - - - - - Always - - - diff --git a/Imagekit.UnitTests/ManageFolder/ManageFolderTestAsync.cs b/Imagekit.UnitTests/ManageFolder/ManageFolderTestAsync.cs deleted file mode 100644 index 1d2e829f..00000000 --- a/Imagekit.UnitTests/ManageFolder/ManageFolderTestAsync.cs +++ /dev/null @@ -1,299 +0,0 @@ -using Imagekit.Constant; -using Imagekit.Models; -using Newtonsoft.Json; -using System; -using System.Net; -using System.Net.Http; -using Xunit; - - -namespace Imagekit.UnitTests -{ - - public class ManageFolderTestAsync - - { - private const string GOOD_PUBLICKEY = "abc"; - private const string GOOD_URLENDPOINT = "https://dasdsad.dad.io/"; - - - [Fact] - public void CreateFolder_Default() - { - CreateFolderRequest model = new CreateFolderRequest - { - folderName = "Tst3", - parentFolderPath = "Tst3" - }; - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = restClient.CreateFolderAsync(model).Result; - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - [Fact] - public void CreateFolderException() - { - CreateFolderRequest model = null; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.CreateFolderAsync(model)); - Assert.Equal(ErrorMessages.InvalidCreateFolderValue, ex.Result.Message); - } - - [Fact] - public void Missing_folderName_Exception() - { - CreateFolderRequest model = new CreateFolderRequest - { - parentFolderPath = "test" - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.CreateFolderAsync(model)); - Assert.Equal(ErrorMessages.InvalidfolderNameValue, ex.Result.Message); - } - [Fact] - public void Missing_parentFolderPath_FolderException() - { - CreateFolderRequest model = new CreateFolderRequest - { - folderName = "test" - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.CreateFolderAsync(model)); - Assert.Equal(ErrorMessages.InvalidFolderPathValue, ex.Result.Message); - } - [Fact] - public void DeleteFolder_Default() - { - DeleteFolderRequest model = new DeleteFolderRequest - { - folderPath = "Tst3" - }; - - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = restClient.DeleteFolderAsync(model).Result; - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - [Fact] - public void Missing_Folder_Path_Exception() - { - DeleteFolderRequest model = new DeleteFolderRequest(); - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.DeleteFolderAsync(model)); - Assert.Equal(ErrorMessages.InvalidDelFolderValue, ex.Result.Message); - } - - - [Fact] - public void CopyFolder_Default() - { - CopyFolderRequest model = new CopyFolderRequest - { - sourceFolderPath = "Tst3", - destinationPath = "Tst3", - includeFileVersions = true - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = restClient.CopyFolderAsync(model).Result; - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - [Fact] - public void Missing_Obj_FolderException() - { - CopyFolderRequest model = null; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.CopyFolderAsync(model)); - Assert.Equal(ErrorMessages.InvalidCopyFolderValue, ex.Result.Message); - } - [Fact] - public void Missing_sourceFolderPath_FolderException() - { - CopyFolderRequest model = new CopyFolderRequest - { - destinationPath = "abc" - }; - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.CopyFolderAsync(model)); - Assert.Equal(ErrorMessages.InvalidCopysourceFolderPathValue, ex.Result.Message); - } - [Fact] - public void Missing_Destination_FolderPath_FolderException() - { - CopyFolderRequest model = new CopyFolderRequest - { - sourceFolderPath = "abc" - }; - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.CopyFolderAsync(model)); - Assert.Equal(ErrorMessages.InvalidCopydestinationPathValue, ex.Result.Message); - } - - [Fact] - public void MoveFolder_Default() - { - MoveFolderRequest model = new MoveFolderRequest - { - sourceFolderPath = "Tst3", - destinationPath = "Tst3" - }; - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = restClient.MoveFolderAsync(model).Result; - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - [Fact] - public void Missing_Obj_Move_FolderException() - { - MoveFolderRequest model = null; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.MoveFolderAsync(model)); - Assert.Equal(ErrorMessages.InvalidCopyFolderValue, ex.Result.Message); - } - - [Fact] - public void Missing_sourceFolderPath_MoveFolderException() - { - MoveFolderRequest model = new MoveFolderRequest - { - destinationPath = "abc" - }; - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.MoveFolderAsync(model)); - Assert.Equal(ErrorMessages.InvalidCopysourceFolderPathValue, ex.Result.Message); - } - [Fact] - public void Missing_Destination_FolderPath_MoveFolderException() - { - MoveFolderRequest model = new MoveFolderRequest - { - sourceFolderPath = "abc" - }; - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.MoveFolderAsync(model)); - Assert.Equal(ErrorMessages.InvalidCopydestinationPathValue, ex.Result.Message); - } - - } -} - - - - diff --git a/Imagekit.UnitTests/ManageFolder/ManageFolderTestNonAsync.cs b/Imagekit.UnitTests/ManageFolder/ManageFolderTestNonAsync.cs deleted file mode 100644 index fb96b647..00000000 --- a/Imagekit.UnitTests/ManageFolder/ManageFolderTestNonAsync.cs +++ /dev/null @@ -1,296 +0,0 @@ -using Imagekit.Constant; -using Imagekit.Models; -using Newtonsoft.Json; -using System; -using System.Net; -using System.Net.Http; -using Xunit; - - -namespace Imagekit.UnitTests -{ - - public class ManageFolderTestNon - - { - private const string GoodPublickey = "abc"; - private const string GoodUrlendpoint = "https://dasdsad.dad.io/"; - - - [Fact] - public void CreateFolder_DefaultNonAsync() - { - CreateFolderRequest model = new CreateFolderRequest - { - folderName = "Tst3", - parentFolderPath = "Tst3" - }; - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GoodPublickey, GoodUrlendpoint, httpClient); - - var response = restClient.CreateFolder(model); - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - [Fact] - public void CreateFolderExceptionNonAsync() - { - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GoodPublickey, GoodUrlendpoint, httpClient); - var ex = Assert.Throws(() => restClient.CreateFolder(null)); - Assert.Equal(ErrorMessages.InvalidCreateFolderValue, ex.Message); - } - - [Fact] - public void Missing_folderName_ExceptionNonAsync() - { - CreateFolderRequest model = new CreateFolderRequest - { - parentFolderPath = "test" - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GoodPublickey, GoodUrlendpoint, httpClient); - var ex = Assert.Throws(() => restClient.CreateFolder(model)); - Assert.Equal(ErrorMessages.InvalidfolderNameValue, ex.Message); - } - [Fact] - public void Missing_parentFolderPath_FolderExceptionNonAsync() - { - CreateFolderRequest model = new CreateFolderRequest - { - folderName = "test" - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GoodPublickey, GoodUrlendpoint, httpClient); - var ex = Assert.Throws(() => restClient.CreateFolder(model)); - Assert.Equal(ErrorMessages.InvalidFolderPathValue, ex.Message); - } - [Fact] - public void DeleteFolder_DefaultNonAsync() - { - DeleteFolderRequest model = new DeleteFolderRequest - { - folderPath = "Tst3" - }; - - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GoodPublickey, GoodUrlendpoint, httpClient); - - var response = restClient.DeleteFolder(model); - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - [Fact] - public void Missing_Folder_Path_ExceptionNonAsync() - { - DeleteFolderRequest model = new DeleteFolderRequest(); - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GoodPublickey, GoodUrlendpoint, httpClient); - var ex = Assert.Throws(() => restClient.DeleteFolder(model)); - Assert.Equal(ErrorMessages.InvalidDelFolderValue, ex.Message); - } - - - [Fact] - public void CopyFolder_DefaultNonAsync() - { - CopyFolderRequest model = new CopyFolderRequest - { - sourceFolderPath = "Tst3", - destinationPath = "Tst3", - includeFileVersions = true - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GoodPublickey, GoodUrlendpoint, httpClient); - - var response = restClient.CopyFolder(model); - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - [Fact] - public void Missing_Obj_FolderExceptionNonAsync() - { - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GoodPublickey, GoodUrlendpoint, httpClient); - var ex = Assert.Throws(() => restClient.CopyFolder(null)); - Assert.Equal(ErrorMessages.InvalidCopyFolderValue, ex.Message); - } - [Fact] - public void Missing_sourceFolderPath_FolderExceptionNonAsync() - { - CopyFolderRequest model = new CopyFolderRequest - { - destinationPath = "abc" - }; - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GoodPublickey, GoodUrlendpoint, httpClient); - var ex = Assert.Throws(() => restClient.CopyFolder(model)); - Assert.Equal(ErrorMessages.InvalidCopysourceFolderPathValue, ex.Message); - } - [Fact] - public void Missing_Destination_FolderPath_FolderExceptionNonAsync() - { - CopyFolderRequest model = new CopyFolderRequest - { - sourceFolderPath = "abc" - }; - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GoodPublickey, GoodUrlendpoint, httpClient); - var ex = Assert.Throws(() => restClient.CopyFolder(model)); - Assert.Equal(ErrorMessages.InvalidCopydestinationPathValue, ex.Message); - } - - [Fact] - public void MoveFolder_DefaultNonAsync() - { - MoveFolderRequest model = new MoveFolderRequest - { - sourceFolderPath = "Tst3", - destinationPath = "Tst3" - }; - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GoodPublickey, GoodUrlendpoint, httpClient); - - var response = restClient.MoveFolder(model); - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - [Fact] - public void Missing_Obj_Move_FolderExceptionNonAsync() - { - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GoodPublickey, GoodUrlendpoint, httpClient); - var ex = Assert.Throws(() => restClient.MoveFolder(null)); - Assert.Equal(ErrorMessages.InvalidCopyFolderValue, ex.Message); - } - - [Fact] - public void Missing_sourceFolderPath_MoveFolderExceptionNonAsync() - { - MoveFolderRequest model = new MoveFolderRequest - { - destinationPath = "abc" - }; - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GoodPublickey, GoodUrlendpoint, httpClient); - var ex = Assert.Throws(() => restClient.MoveFolder(model)); - Assert.Equal(ErrorMessages.InvalidCopysourceFolderPathValue, ex.Message); - } - [Fact] - public void Missing_Destination_FolderPath_MoveFolderExceptionNonAsync() - { - MoveFolderRequest model = new MoveFolderRequest - { - sourceFolderPath = "abc" - }; - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GoodPublickey, GoodUrlendpoint, httpClient); - var ex = Assert.Throws(() => restClient.MoveFolder(model)); - Assert.Equal(ErrorMessages.InvalidCopydestinationPathValue, ex.Message); - } - - } -} - - - - diff --git a/Imagekit.UnitTests/MetaData/MetaDataTestAsync.cs b/Imagekit.UnitTests/MetaData/MetaDataTestAsync.cs deleted file mode 100644 index af0f8d52..00000000 --- a/Imagekit.UnitTests/MetaData/MetaDataTestAsync.cs +++ /dev/null @@ -1,557 +0,0 @@ -using Imagekit.Constant; -using Imagekit.Models; -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Net; -using System.Net.Http; -using Imagekit.Models.Response; -using Xunit; -using static Imagekit.Models.CustomMetaDataFieldSchemaObject; -using Newtonsoft.Json.Linq; - -namespace Imagekit.UnitTests.MetaData -{ - - public class MetaDataTestAsync - { - private const string GOOD_PUBLICKEY = "abc"; - private const string GOOD_URLENDPOINT = "https://dasdsad.dad.io/"; - - - - [Fact] - public void GetFileMetadata_Default() - { - - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = (ResultMetaData)restClient.GetFileMetaDataAsync("abc").Result; - var responseObj1 = JsonConvert.SerializeObject(responseObj.Raw); - responseObj1 = JToken.Parse(responseObj1).ToString(); - - Assert.Equal(responseObj.Raw, responseObj1); - } - [Fact] - public void GetFileMetadataException() - { - List ob = new List(); - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.GetFileMetaData("")); - Assert.Equal(ErrorMessages.FileIdMissing, ex.Message); - } - - - [Fact] - public void GetRemoteFileMetadata_Default() - { - - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = (ResultMetaData)restClient.GetRemoteFileMetaDataAsync("abc").Result; - var responseObj1 = JsonConvert.SerializeObject(responseObj.Raw); - responseObj1 = JToken.Parse(responseObj1).ToString(); - - Assert.Equal(responseObj.Raw, responseObj1); - } - [Fact] - public void GetRemoteFileMetadataException() - { - List ob = new List(); - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.GetRemoteFileMetaDataAsync("")); - Assert.Equal(ErrorMessages.InvalidUrlValue, ex.Result.Message); - } - - - [Fact] - public void GetCustomMetaDataFields_Default() - { - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = restClient.GetCustomMetaDataFieldsAsync(true).Result; - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - [Fact] - public void CreateCustomMetaDataFields_Default() - { - CustomMetaDataFieldCreateRequest model = new CustomMetaDataFieldCreateRequest - { - name = "Tst3", - label = "Test3" - }; - CustomMetaDataFieldSchemaObject schema = new CustomMetaDataFieldSchemaObject - { - type = "Number", - minValue = 1000, - maxValue = 3000, - minLength = 500, - maxLength = 600, - isValueRequired = false - }; - - model.schema = schema; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = restClient.CreateCustomMetaDataFieldsAsync(model).Result; - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - [Fact] - public void CreateCustomMetaDataFields_Type_Date() - { - CustomMetaDataFieldCreateRequest model = new CustomMetaDataFieldCreateRequest - { - name = "Tst3", - label = "Test3" - }; - CustomMetaDataFieldSchemaObject schema = new CustomMetaDataFieldSchemaObject - { - type = "Number", - minValue = 1000, - maxValue = 3000, - minLength = 500, - maxLength = 600, - isValueRequired = false - }; - - model.schema = schema; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = restClient.CreateCustomMetaDataFieldsAsync(model).Result; - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - [Fact] - public void CreateCustomMetaDataFields_Type_Text() - { - CustomMetaDataFieldCreateRequest model = new CustomMetaDataFieldCreateRequest - { - name = "Tst3", - label = "Test3" - }; - CustomMetaDataFieldSchemaObject schema = new CustomMetaDataFieldSchemaObject - { - type = "Number", - minValue = 1000, - maxValue = 3000 - - }; - - model.schema = schema; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = restClient.CreateCustomMetaDataFieldsAsync(model).Result; - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - [Fact] - public void CreateCustomMetaDataFields_Type_TextArea() - { - - CustomMetaDataFieldCreateRequest model = new CustomMetaDataFieldCreateRequest - { - name = "Tst3", - label = "Test3" - }; - CustomMetaDataFieldSchemaObject schema = new CustomMetaDataFieldSchemaObject - { - type = "Number", - minValue = 1000, - maxValue = 3000 - - }; - - model.schema = schema; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = restClient.CreateCustomMetaDataFieldsAsync(model).Result; - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - [Fact] - public void CreateCustomMetaDataFields_successExpected_type_SingleSelect() - { - - List objectList = new List - { - "small", - "medium", - "large", - 30, - 40, - true - }; - - CustomMetaDataFieldCreateRequest model = new CustomMetaDataFieldCreateRequest - { - name = "Tst3", - label = "Test3" - }; - CustomMetaDataFieldSchemaObject schema = new CustomMetaDataFieldSchemaObject - { - type = "Number", - minValue = 1000, - maxValue = 3000 - }; - - model.schema = schema; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = restClient.CreateCustomMetaDataFieldsAsync(model).Result; - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - [Fact] - public void CreateCustomMetaDataFields_successExpected_type_MultiSelect() - { - CustomMetaDataFieldCreateRequest model = new CustomMetaDataFieldCreateRequest - { - name = "Tst3", - label = "Test3" - }; - List objectList = new List - { - "small", - "medium", - "large", - 30, - 40, - true - }; - - CustomMetaDataFieldCreateRequest customMetaDataFieldSchemaObject = new CustomMetaDataFieldCreateRequest - { - name = "Tst3", - label = "Test3" - }; - CustomMetaDataFieldSchemaObject schema = new CustomMetaDataFieldSchemaObject - { - type = "Number", - minValue = 1000, - maxValue = 3000 - }; - - model.schema = schema; - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = restClient.CreateCustomMetaDataFieldsAsync(model).Result; - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - [Fact] - public void CreateCustomMetaDataFieldsException() - { - CustomMetaDataFieldCreateRequest model = null; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.CreateCustomMetaDataFieldsAsync(model)); - Assert.Equal(ErrorMessages.InvalidMetaTagValue, ex.Result.Message); - } - [Fact] - public void Missing_Name_CustomMetaDataFieldsException() - { - CustomMetaDataFieldCreateRequest model = new CustomMetaDataFieldCreateRequest - { - name = string.Empty - }; - CustomMetaDataFieldSchemaObject ob = new CustomMetaDataFieldSchemaObject - { - maxValue = 1000 - }; - model.schema = ob; - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.CreateCustomMetaDataFieldsAsync(model)); - Assert.Equal(ErrorMessages.InvalidMetaTagNameValue, ex.Result.Message); - } - [Fact] - public void Missing_Label_CustomMetaDataFieldsException() - { - CustomMetaDataFieldCreateRequest model = new CustomMetaDataFieldCreateRequest - { - name = "abc", - label = string.Empty - }; - CustomMetaDataFieldSchemaObject ob = new CustomMetaDataFieldSchemaObject - { - maxValue = 1000 - }; - model.schema = ob; - - - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.CreateCustomMetaDataFieldsAsync(model)); - Assert.Equal(ErrorMessages.InvalidMetaTagLabelValue, ex.Result.Message); - } - [Fact] - public void Missing_Schema_CustomMetaDataFieldsException() - { - CustomMetaDataFieldCreateRequest model = new CustomMetaDataFieldCreateRequest - { - name = "abc", - label = "test", - schema = null - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.CreateCustomMetaDataFieldsAsync(model)); - Assert.Equal(ErrorMessages.InvalidMetaTagSchemaValue, ex.Result.Message); - } - - [Fact] - public void DeleteCustomMetaDataField_Default() - { - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = restClient.DeleteCustomMetaDataFieldAsync("abc").Result; - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - - [Fact] - public void Missing_fileId_CustomMetaDataFieldException() - { - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.DeleteCustomMetaDataFieldAsync("")); - Assert.Equal(ErrorMessages.InvalidfileIdsValue, ex.Result.Message); - } - - - - [Fact] - public void UpdateCustomMetaDataFields_Default() - { - CustomMetaDataFieldUpdateRequest model = new CustomMetaDataFieldUpdateRequest - { - Id = "Tst3" - }; - - CustomMetaDataFieldSchemaObject schema = new CustomMetaDataFieldSchemaObject - { - type = "Number", - minValue = 1000, - maxValue = 3000 - }; - model.schema = schema; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = restClient.UpdateCustomMetaDataFieldsAsync(model).Result; - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - [Fact] - public void Missing_Object_CustomMetaDataFieldsException() - { - CustomMetaDataFieldUpdateRequest model = null; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.UpdateCustomMetaDataFieldsAsync(model)); - Assert.Equal(ErrorMessages.InvalidMetaTagValue, ex.Result.Message); - } - - [Fact] - public void Missing_ID_CustomUpdateMetaDataFieldsException() - { - CustomMetaDataFieldUpdateRequest model = new CustomMetaDataFieldUpdateRequest - { - Id = "" - }; - CustomMetaDataFieldSchemaObject ob = new CustomMetaDataFieldSchemaObject - { - maxValue = 1000 - }; - model.schema = ob; - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.UpdateCustomMetaDataFieldsAsync(model)); - Assert.Equal(ErrorMessages.InvalidMetaTagIdValue, ex.Result.Message); - } - [Fact] - public void Missing_Schema_CustomUpdateMetaDataFieldsException() - { - CustomMetaDataFieldUpdateRequest model = new CustomMetaDataFieldUpdateRequest - { - Id = "abc", - schema = null - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.UpdateCustomMetaDataFieldsAsync(model)); - Assert.Equal(ErrorMessages.InvalidMetaTagSchemaValue, ex.Result.Message); - } - - } -} - - - - diff --git a/Imagekit.UnitTests/MetaData/MetaDataTestNonAsync.cs b/Imagekit.UnitTests/MetaData/MetaDataTestNonAsync.cs deleted file mode 100644 index b9d0ef24..00000000 --- a/Imagekit.UnitTests/MetaData/MetaDataTestNonAsync.cs +++ /dev/null @@ -1,546 +0,0 @@ -using Imagekit.Constant; -using Imagekit.Models; -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Net; -using System.Net.Http; -using Xunit; -using static Imagekit.Models.CustomMetaDataFieldSchemaObject; -using Imagekit.Models.Response; -using Newtonsoft.Json.Linq; - -namespace Imagekit.UnitTests.MetaData -{ - - public class MetaDataTestNonAsync - { - private const string GOOD_PUBLICKEY = "abc"; - private const string GOOD_URLENDPOINT = "https://dasdsad.dad.io/"; - - - - [Fact] - public void GetFileMetadata_DefaultNonAsync() - { - - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = (ResultMetaData)restClient.GetFileMetaData("abc"); - var responseObj1 = JsonConvert.SerializeObject(responseObj.Raw); - responseObj1 = JToken.Parse(responseObj1).ToString(); - - Assert.Equal(responseObj.Raw, responseObj1); - } - [Fact] - public void GetFileMetadataExceptionNonAsync() - { - List ob = new List(); - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.GetFileMetaData("")); - Assert.Equal(ErrorMessages.FileIdMissing, ex.Message); - } - - - [Fact] - public void GetRemoteFileMetadata_DefaultNonAsync() - { - - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = (ResultMetaData)restClient.GetRemoteFileMetaData("abc"); - var responseObj1 = JsonConvert.SerializeObject(responseObj.Raw); - responseObj1 = JToken.Parse(responseObj1).ToString(); - - Assert.Equal(responseObj.Raw, responseObj1); - } - [Fact] - public void GetRemoteFileMetadataExceptionNonAsync() - { - List ob = new List(); - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.GetRemoteFileMetaData("")); - Assert.Equal(ErrorMessages.InvalidUrlValue, ex.Message); - } - - - [Fact] - public void GetCustomMetaDataFields_DefaultNonAsync() - { - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = restClient.GetCustomMetaDataFields(true); - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - [Fact] - public void CreateCustomMetaDataFields_DefaultNonAsync() - { - CustomMetaDataFieldCreateRequest model = new CustomMetaDataFieldCreateRequest - { - name = "Tst3", - label = "Test3" - }; - CustomMetaDataFieldSchemaObject schema = new CustomMetaDataFieldSchemaObject - { - type = "Number", - minValue = 1000, - maxValue = 3000, - minLength = 500, - maxLength = 600, - isValueRequired = false - }; - - model.schema = schema; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = restClient.CreateCustomMetaDataFields(model); - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - [Fact] - public void CreateCustomMetaDataFields_Type_Date() - { - CustomMetaDataFieldCreateRequest model = new CustomMetaDataFieldCreateRequest - { - name = "Tst3", - label = "Test3" - }; - CustomMetaDataFieldSchemaObject schema = new CustomMetaDataFieldSchemaObject - { - type = "Number", - minValue = 1000, - maxValue = 3000, - minLength = 500, - maxLength = 600, - isValueRequired = false - }; - - model.schema = schema; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = restClient.CreateCustomMetaDataFields(model); - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - [Fact] - public void CreateCustomMetaDataFields_Type_Text() - { - CustomMetaDataFieldCreateRequest model = new CustomMetaDataFieldCreateRequest - { - name = "Tst3", - label = "Test3" - }; - CustomMetaDataFieldSchemaObject schema = new CustomMetaDataFieldSchemaObject - { - type = "Number", - minValue = 1000, - maxValue = 3000, - minLength = 500, - maxLength = 600, - isValueRequired = false - }; - - model.schema = schema; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = restClient.CreateCustomMetaDataFields(model); - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - [Fact] - public void CreateCustomMetaDataFields_Type_TextArea() - { - CustomMetaDataFieldCreateRequest model = new CustomMetaDataFieldCreateRequest - { - name = "Tst3", - label = "Test3" - }; - CustomMetaDataFieldSchemaObject schema = new CustomMetaDataFieldSchemaObject - { - type = "Number", - minValue = 1000, - maxValue = 3000, - minLength = 500, - maxLength = 600, - isValueRequired = false - }; - - model.schema = schema; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = restClient.CreateCustomMetaDataFields(model); - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - [Fact] - public void CreateCustomMetaDataFields_successExpected_type_SingleSelect() - { - CustomMetaDataFieldCreateRequest model = new CustomMetaDataFieldCreateRequest - { - name = "Tst3", - label = "Test3" - }; - CustomMetaDataFieldSchemaObject schema = new CustomMetaDataFieldSchemaObject - { - type = "Number", - minValue = 1000, - maxValue = 3000, - minLength = 500, - maxLength = 600, - isValueRequired = false - }; - - model.schema = schema; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = (ResultCustomMetaDataField)restClient.CreateCustomMetaDataFields(model); - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - [Fact] - public void CreateCustomMetaDataFields_successExpected_type_MultiSelect() - { - CustomMetaDataFieldCreateRequest model = new CustomMetaDataFieldCreateRequest - { - name = "Tst3", - label = "Test3" - }; - - CustomMetaDataFieldSchemaObject customMetaDataFieldSchemaObject = new CustomMetaDataFieldSchemaObject - { - type = "MultiSelect", - selectOptions = new string[] { "small", "medium", "large" } - }; - - CustomMetaDataFieldSchemaObject schema = new CustomMetaDataFieldSchemaObject - { - type = "Number", - minValue = 1000, - maxValue = 3000, - minLength = 500, - maxLength = 600, - isValueRequired = false - }; - - model.schema = schema; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = (ResultCustomMetaDataField)restClient.CreateCustomMetaDataFields(model); - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - [Fact] - public void CreateCustomMetaDataFieldsExceptionNonAsync() - { - CustomMetaDataFieldCreateRequest model = null; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.CreateCustomMetaDataFields(model)); - Assert.Equal(ErrorMessages.InvalidMetaTagValue, ex.Message); - } - [Fact] - public void Missing_Name_CustomMetaDataFieldsExceptionNonAsync() - { - CustomMetaDataFieldCreateRequest model = new CustomMetaDataFieldCreateRequest - { - name = string.Empty - }; - CustomMetaDataFieldSchemaObject ob = new CustomMetaDataFieldSchemaObject - { - maxValue = 1000 - }; - model.schema = ob; - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.CreateCustomMetaDataFields(model)); - Assert.Equal(ErrorMessages.InvalidMetaTagNameValue, ex.Message); - } - [Fact] - public void Missing_Label_CustomMetaDataFieldsExceptionNonAsync() - { - CustomMetaDataFieldCreateRequest model = new CustomMetaDataFieldCreateRequest - { - name = "abc", - label = string.Empty - }; - CustomMetaDataFieldSchemaObject ob = new CustomMetaDataFieldSchemaObject - { - maxValue = 1000 - }; - model.schema = ob; - - - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.CreateCustomMetaDataFields(model)); - Assert.Equal(ErrorMessages.InvalidMetaTagLabelValue, ex.Message); - } - [Fact] - public void Missing_Schema_CustomMetaDataFieldsExceptionNonAsync() - { - CustomMetaDataFieldCreateRequest model = new CustomMetaDataFieldCreateRequest - { - name = "abc", - label = "test", - schema = null - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.CreateCustomMetaDataFields(model)); - Assert.Equal(ErrorMessages.InvalidMetaTagSchemaValue, ex.Message); - } - - [Fact] - public void DeleteCustomMetaDataField_DefaultNonAsync() - { - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = restClient.DeleteCustomMetaDataField("abc"); - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - - [Fact] - public void Missing_fileId_CustomMetaDataFieldExceptionNonAsync() - { - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.DeleteCustomMetaDataField("")); - Assert.Equal(ErrorMessages.InvalidfileIdsValue, ex.Message); - } - - - - [Fact] - public void UpdateCustomMetaDataFields_DefaultNonAsync() - { - CustomMetaDataFieldUpdateRequest model = new CustomMetaDataFieldUpdateRequest - { - Id = "Tst3" - }; - - CustomMetaDataFieldSchemaObject schema = new CustomMetaDataFieldSchemaObject - { - type = "Number", - minValue = 1000, - maxValue = 3000 - }; - model.schema = schema; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = restClient.UpdateCustomMetaDataFields(model); - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - [Fact] - public void Missing_Object_CustomMetaDataFieldsExceptionNonAsync() - { - CustomMetaDataFieldUpdateRequest model = null; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.UpdateCustomMetaDataFields(model)); - Assert.Equal(ErrorMessages.InvalidMetaTagValue, ex.Message); - } - - [Fact] - public void Missing_ID_CustomUpdateMetaDataFieldsExceptionNonAsync() - { - CustomMetaDataFieldUpdateRequest model = new CustomMetaDataFieldUpdateRequest - { - Id = "" - }; - CustomMetaDataFieldSchemaObject ob = new CustomMetaDataFieldSchemaObject - { - maxValue = 1000 - }; - model.schema = ob; - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.UpdateCustomMetaDataFields(model)); - Assert.Equal(ErrorMessages.InvalidMetaTagIdValue, ex.Message); - } - [Fact] - public void Missing_Schema_CustomUpdateMetaDataFieldsExceptionNonAsync() - { - CustomMetaDataFieldUpdateRequest model = new CustomMetaDataFieldUpdateRequest - { - Id = "abc", - schema = null - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.UpdateCustomMetaDataFields(model)); - Assert.Equal(ErrorMessages.InvalidMetaTagSchemaValue, ex.Message); - } - - } -} - - - - diff --git a/Imagekit.UnitTests/Sample/test.jpg b/Imagekit.UnitTests/Sample/test.jpg deleted file mode 100644 index 79de088c43e2fa456ef4c476440236c69d0dc2ca..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 27405 zcmb4~1ydYf(C!y^cXxN!;O-t|arxtJ!Gpu%usA^$cX#*T5ZqZHgx~~+kjr~-y&vHA z)KpE)Id!^gs^(Pxx}WoJ{og(STSY-x0RRI71IYZi0ROfCvH(PQ1VjXQL_`EcBqT&+ zRBTjK6cki^Oe}P4B79MFh^2eweHUJg|79I`(;Ujz`WLP)=%*Txbk4wXYAgzsvM{DVUgwOjmm9DsH zXpulh=bDhu%CqEvUN*eBW%!1HQO+wO4YI_qD`1`eu^Ji7|MT^~p8m%*0OsS{AbkvS z;{aek3488egU^@x;pl7e^})YQ0Q$$Qj~O@s zNdOVrSTCcViA!)OYGX2XvjTaL2?2q*sPU|mmy=h;b<+fwU&@nugPEk}e+!IR);zV% zXvYA(Im+R4pY0zQ-nKgIB0B3E%`#hPzgV?0w(!FBh=)m}V+&qLyX^I&Z3H{m4Ez}u zaN2*?`D-xsAu>KKn=k8Gss|ROjh}J)&}ln;(OEyS2|HdWz%b?w7iv1z&u+5Q_o~ye z4SsTU zoT(KyG+_m8u8HQ-9y2T&=Su|1h0EH+o`v{WBcX;%;s8(P(nhQbh{Kf=Zch!gCh5)5 z%un=o;Dl&hcZS>b;WT7wvcm`eFm{bqG=I(05g?G|gqbGwaSi`;qyKX9+Zq86LE>sQ6%+_!}g* ziAOCcikho{&(k(%{OoOx!U*xK+%(PhX)`hf^A*j(ED%2b@E`X;rNuVntng5os{QzN zXdnAj=4nE4`UlN&&h;_m;hkWA-e3zj0kyR8L72Iu`JSmnzVeB|BqDd)sMv##=(&(B zQ)kB!tmHIq_?q2_vIhZ^xKvP7@=pXxIBO_jO`r*DZBs4+)N8cUsyN#S6s^BUdGg+3OC?~aY5az?05P-M`%BRZXW8B9wEfI; zP!l|!-UOBVzEcmfkmvS1UH=@2te-{u(psrGRg7+z$KOp-Ou=q>P5Xm>%tIa0Z|6iX zLS_u2;rhw$6%98*UD|0>n-}aJ5M({m&3^zNG5XtHRbtnl^e{5x?0{3n*~&$R-*>sr zc9Lk(s!Gq_wm8dM$Tbs{xxd54LVo-3SNX6(-3TrkL^aIuD3DL3H+Y~4YI}rZbGA0T zJmgWobM$(CiazUCkjixSgayf}EC!10oBbVC;KLsH)u}_K4H=-h-G1v{o$TjfRA#QR zJ8KG}dQe181R{*79;T}+%0Gt)l|PM2r}vVT-&>d+wGUTy)=SVUz(h^1I~kRpk07yV zrs~Fz(Mz@Dnarz9d3;+H@?sapMi>JXC{ES9DuZ%?vWnTU<0Ezdd5FqV3(?2Bva71+ zkwOC5iy&r$7>KQFh}p?#p46Zf??Zv)Pj`_0e3^snG?ZzhGll4Sen(r2O-g;!(UR`4 zT(1fm4_X${Q)Mgi-r4#HCoPi0a)#>q_8(=QutO`UlkTppHZd-3l_{L;N_Qp1<_A2m z{(lO{tVH!S@jX2vLouTKkbjcEsP?_n=&F%7Ys|AWG709c7z~+ZS#8XP-`QXPm~_QX zz7PyAh(N;?7&eXJQzM)b5YuCs-dEiDjDd3{ZaW|A%yP~=tSmc;^@$g=ZH4vbimCCdXPu?CQBLgKA=Y5=aR%*}>LSGtp)1Slu+ zW)~Y?-iZGIQ7TW!{&MugH6Z5pWqL+jj9QJ{cfHt&M@Lu+jWq!j58Uou1HmIquyAwA zQBu8Ui`jU8kP19%k&$0@lfYMMLh*~Dmt3qMr@dh+ zEA>^#?3e#6xNfUQQ_Eu08MB_08(&ZhpcX|KpB$flaQ4GxDZ7A&=+rUJzEWs}nS-nR zi^CmAV2^!%vZav}JJBB{C2+Eyt=Cv%?6UN5j8U>^UGk=vam0L6cv{rVE|)UGxU#!j zifTw({6lTzWiL%$bIK_-J;0jEO2+I&X;~BHMWG}pUJYt#s%e_pgsCX=4kx?d?`pf6 z1GV~^1+(J*Orzxp)W;{bl_SaB|3NNE2ug^YE4UqZ{hBoKj358>b*4jbX%|eNC?_9v zi4iLx=h5ogxNUEh#oBK0PI@*?2f}qRBm^JY@`xCahGWkKR-J8N}haWj2Iq-yGa)GJ%NOY0!_{hn@q6LI$loEf<|B7)sR zy(`fGXP%4;n!5L*1H}*<%i^AL24e54L+IrUvrw+v+XZ~+S{xx7`pV-im=`%jd zoSX9FCK6s@bUhYQ%+@L$8xjrAFUAn@#SyAa)duOl&)>&!@XN``zS$+pEu~8wk_!f@ zt;>xlelwz?CXagg%eK(iY|+Vt9)SQeV@=5pF%bX$yuxH7Yy!O&PH<&z;w5i#n$G#t zzelI*6OYtH>d2v^Q#LAhMptpp7Y|)ePz6)jQpx{yZ1=M&->&xTA_=jU>MCI)o;c{12bI2i5x-2c#LLkoO5UOO1zI;nFS;Rp%OZBdVM z{RhCTb*)t#S@=U`%$%CZi}JF}ARRr?-Ei;e|Md?c((UV6z52I9Pc|_VV$d7;*)|fB zs-uJJBXmv1O~3OC*>(XwuJY0j%NrxEBK4$7g9;KhscOsqST+I?V?GG}>gGvN!+RTh z3|o+pseqe8W}7s;O!BL^tbF(|SigmW(zzUosm`?&i{)o={g?bgmYdpqph=Yu+=&hr~k=iDfzQ zLMH9P)+}(TGtSeWZl%HNSWRgmjbzw^h1x($mCfw1_)Jw14{F0c>q9;_41u@)wB_l# z<52bAWd;I?Vu8sUg8qVY6$xSEAAS}O*j3W6k4x#ow!O2df-_&1%$|&1ds)fuVb2|z z1yzb?Lp zvvE_Vl=S!v1yMZfTR3B~TAXm}EArH?=H&A7tazC*SoAdsE*b?r^xvc>MQx^^ZBvzl zR8wGGLXkV3f23A#jk0S>coV@8F;hwo_rNqwx#eZHa@m5ch76d)B7%cXS0?nj2oAeXcKf z6w*IV?xd{butH;lgvWz1X6ohw!0^D9i{>)LA4$oFxo);D|bqcF;}vnKVv zF(0L5=dl^rX32O)HNA5koB z@{}~wLu7VS8tuO@oEm%8)QO!%WctA;&)JRe>6R`I35=Z1WHAZ(F+O7YDunPwr7rZN zP&k2g*7T_w{~D2@)+F`iaFpG|ksCHpBrmqheV=Tc;XYG;DaT(2l^?~*y1a&6$`W)P z#>ohSlEl!)0|-5hkZ;E@M8}>_mnEizki_2$@37`HjBV6 z6FWsFb+n6C9<^Eo#%T8wrJ9oMf9_cAD>|#;@h!8A1T!g!rFbsC4Y5yD8U|915*gDN+L+w^6P z2Gh9q8gnx5y|sRmc#B%IXxMpi-1|J&+KEQEhk6u2UuLv6=ztrV@$Es3hcYj@Y>bNA zBDXHv!K06DWTMMM`8p|N+`Ls&w)17VB$@U*$zq9B(HB>VLpLy*G^0`zsLy^rfzw@4 zyWz}uj!M+p-9xR&Xlx#An>(m*QaMoeX#=R)W5qD25-@j(KAuiq|SFvJOr$Br(iu9B^C)i=k&D#YPd<7ZUpLfq~P z(C!HS+BWg>>q-v*~!)yLXacXn=Vu&F0IV zQ-HoATSBc#LNjZ~NrL<+<1mi_Jw^3Zv_~xCR2q5mWI>JW_$yO1l;pKS$&Sq1ZK?Mp z{<_y3WsKiH!^W~wJki_Y<_l_O&ipq`x?#U<^><>BsUK2E>rB%5eqnSY5HG2pV2NBY z9@p<@TVLE8>}JHws@jun-1+HKzn*yZZL-a#&VhFa+Ygis2S+mk6J7164D299OQVh2 zq@pNOrvsnm-y*uSWQOhi-b78F3hl*mJrW=*%#*2pVG98Rn(k$NS+@XY=OWBJz3yM- zU;nco2g>|sR?<(b5ANBf1B(w*#g-3#7TK~8fX$$lPia+T^PGNODMzM_B9FU;;1#!h zE$XqgB4&~96J5{Vk+Di=dFNEfDnu#v$BLPXlT3>$o)E;sZiuofd8t~aGG3OAjfvf7 z;BlaV=cO12r+kN6NE4o|#_}+sg6PqQr3W4=D-bxt()yBo&7;3Dj7{d75!Wwav0eOW z&;Z{7BbW)2&+TZD-F0S4`O_sqP9V=3pdz*(l^yI^SJ{zEH=hQl4*OB&NN`Z~08Shs zbzb^ZYUXDr+zDf&(i=mEGbyD*oIK)5LjVkcdP2c**61imw^w6Y;2w1|zAmNiYN-%j z@=g&YD##5x2D9R`MbX_Kh`gv(=Qobx>ycdoDG}yH#Rb&H{mMr7cZShCXgF``Kfsr- zUC&tKmBL~+BW$L!6sHXiUy07Rgo`<%2dy)0w52UtmGmfQ_11i9eYV;1c9d`^S>#@^!xF4>RR81au^bk@IX zP?2G>iiJ-#{2^OBkfF0BUEo=0-R2-S=VzC`lbkFYueC|+^{Qt=!(aSeTl}?pmwi9d z;7@4}6Nm%OGW$(}{_aE$T3SydE11b-Y@*MKN4#8#oIVJ%83tqn>cKeBCV}yQ| zF_!^PDTz`! z!m$JAG_#mZJJZm$#lc$XQyz?!q*IzFB+8reBX;OIU_s}3kFh2f3PGXH?40#_TH(j( zdk9G_Is7kuxW;+r3xMl+S$LkTkW2(Q%6-bYQW8)9jaEk(Q$RmHhf%vDMG`Cr;>a1B z9SCTdZsHlw-_F(#ntI0#b835kiAh`=A<@^KTwmm4ZH67>q82RCWaqIj{Yi$fzJT6@ z?|_0XyAe{-l{|FNbd%jw$&e7PNLx|)$tg{(j)uVy@vQ8uX|7sdiCw(1uEL&0F|9nA z`GN`66))Mpg($99yRR*I0wTsP?k!QYvHddNeLJulhjI8EfKa zY=plTr-DdaCfYZoQ*_6x(Syv*e~$HHlOX_rRQ;s<&{CFPdz`MeC!fP-IaK1KKN5OM zVNP2C$WN`SIdQy=ONRy3xvWD_D+L`gbBT=VtYIM2ru>^^nIXP|&I{hM7VlALE2*C5 zdL5d2jGA8X5xm`c;pB?$CQDD39;}G>KLBgzHxgP83E~%!y`rql=m-^d1aE$Jq$sWc zrQ%c`NoWzeCgN;F$}CAYRUDF}2Dl7FSdO1M>8~+|1Qj8j$nv&JlG0!P-6uI!`=r1x zWs@X78x{DUjs)Inyn7$mpw-^Y{U*Hpunu6(@n}6?M#tKZGor9@eWGn0sEZAS&ooU| z(M=u{kP)}~U3roT*5ji6g@)^5+4uVd#2mzD0wq0@IbUXB!d0esZ<6A332fTBFCSZW zPF!&PA?2@VyM{tTaaX~YEctV#;Gk3xLEqp+^~d`{)6N6WXLnW*TrBs{P8ug9b+Z6@ zpyCw|CE)Z8^8t%+Bu*1XR4FHB`k6|lZ%Bp+Z`9qjBOz@{vRPp-(JD|W|?qw(^y?azr4TIFbPf?kVVjnlex5W$8epd2hNAJh`-}>EX9D@>-T)fWG{nOBIzlCnzaU+m zZK)eq1|;|q0$?4;WB#VL1L-r=aD%6_ryK5I;7WjIj4_L1i~-B@iqSMA%%B4!8Yn?Z zOb1|1{09)VjvvFCrvIe#hAz`Cy7{wO_#4YjcH78EsfwSdd6k5oD-Vd+f7Ef${;yvkm3_KD>w0fuskGME!Z%MP#4<1I&oORW=mkh3zUS6Y(|6Vr- ze!%gX&0T}d*f|f-S9+!u`OaqP4%5GEWNjT3NkqnFOv%#g2YcwWeEkCJ20cF3cWYkp z#;&1BRKCIS(vt7ZQRHhdX1@yh^!)}y(HOUB5}A_Y`{}VvJ;-#?muCWP$d1SI=jh}* zSeu*~_&cVe3=1vd0+TyN1CNrB@;^L|t~jVd#^?B8#`Zq zn71-opv_%k83=6Scj_pHN-)a4i8NzX4jk({?Ss-xcudk^`k;ku=|F~HR%D!%Y>oT8s%k-ck zX2p=Gt`(yHQ)VS&qFEpkF~!GMfMD&K1d{OoBYaz=ObkzHmt%l#v}WQ~zKqlZbU2og zLt;n_TV6~@9iQMPn6QZF3o=i{!=m2$P|8rhH-XEYZb2F zBXIr_B(M%=*Fqt9Ko#1RguR5e8j!H z)(3pj``;uWh1`yDHejRMgj#V9uQmtaw7_Vt0h8D~}wG~i!1}nnJyV|=|qj^+iNXZXqt-O@aQ+>9+-TSU4lwxi$DI;|74$Qc)@3=Kid8Ij0N2=AkVk6FDiz@} zb}#E#30l~70F?gTbg4uohT4wZCY{Lo6& zxK1-7jGlceg{y)Fx2Uie{EHmd`qfH^Nr9gGthlCr5j=D)H!{%%Mk@LTD6{o9$-YS) zU_hTZDqZ9<{r>tD9zsg6KL{0WeG2DK$n3}wHE0$@!Ru+)&ODhk@M>P%ig~Q~LY`O1 z!8+fnOWf%n=k1_mDjDhaIcr6N#(J6SsO&2Egou&R@ui*&bjh;wXC3L;|X6mh0&N4gadD|p=w?Ghz} z#q48gYx&fgq+Ilu?J%zgF`WD-;wGvqZE2W70rR)8WXM7Tc@>B9$MTGN{ z5A1^}a)&5gRI+Z_8O1AwTx$+tMv5Nx7p*@wz>oZUn^I3}@fcAu_O?tm;imwRN8em{ ziBy-?BydvTwoi(8Sfz<1Z1b@#=y`Lo#&|30SSLAJk+Yf4e5yvZd8a>xWm^nGFRiz| z#Bw>3NQmwdG9RS}Y+65^i$Lu*HD09WK<5={EW-h;^V7z}We&KXo)R{#O^{94bq6+vs+?yc6 z+=$P0ahUIVM1ZrtwCqmKS1+1fB=Qxej(eiu2<2K966~D+Mc1Ekx(+id5#HA zd~i-j+2LbGq12v>=6+7RsI1_QgoNGV);(!&aCtTI3nDSbj}D#CNF#JK)z_1x1)6#< z$9s5E&tSxzm}ZjC=XY$R-k|m{F=~jr`Jg0b!15EVFD-JMhYRXxt zBO_(A6MxrIV90WL1ISR13Y~bI09E?9cWtBZ2Ts`8YVt!K}&!e)XS z9T3X81cbDiPnBY|RVLwBsdIPk*n^-AF0~Wf`fz3sP&nfVe!k2f#W(u z>rmherfI|J7^g&;7qE)(2fk!eC{<1>99^7f&2R-q zxYT$iRSuu1o$3Zg35Y9MU=tAX_oksm>^9yKT*L3qY+c${niM*ar%hWr@^iwR$WDr8 zis_}Zn(I2Y*H&)&8d==9)>%lypQ{UTZG~%Oz37Wul4KbS=xVUP!;o<=n9QXzb1pWJ zZ|RM@FCru+q~R?jvUU28h>&60{3$LSA2I?J?!f=Z_9L2tuB~t0bs3)r;d`UAB)-Xk z$>0pM;K6VVeGU##KNCWD&r{v6sLc9pZ;32DvKdarnF%%nqNazc(J%2L>p#7Y0LAQT zwlEDTXCWCh95DXrqtEJf?p$-#9;o9Z7$l#yJts^I;xI`CKmBRQwALa%=WWY0T#4<^ z{{<23mT6|-Fj5a6h5`Xb;TYdH?=2&*HV-+sAIfvxUnXc%oqi#(#3X%Yf26;?aWObL z-f&m>gg)R8;nA)*RO%Pi_pC4ftEtj9GFCti3rti`B=8TMCQePsSj)U?qixo2xPG1zT+O}-u*j7U%P!MAxq61i9G#@Q}L7I+V(N4 zp7E%mlghz$Z8K78d;w?o_r&7{v2Iaj!~MZlE= zj|pEQs$f(#Vy_!!EkQhb4VEB}P z`1zXzRA{5FLiE@&=)!uny+s-=j{u?fcNS5&lzJ?@i?ueor>iU;L%y~=v1jy1$ z@M>N5X?Z`QiH>?;*0!Kp%MG#H^$ZY83&Y?cGIK=uCrd3`^`TtRwkk5yihA;)^da3a zwDj{m9!gDwf*<0s8Qly{A6+&A>xgRV;}2yY8s!#LQ}y+T$->dqr~I59dSn827Y~#7 z@0=kM*5Ny0R)Ti|U*qjp>YYN@4X_4dI6c_Bu-PTP=OJO&XX_$)} z`uZ3LGCt5U+isIAfQbo>iQpJ+Re2=8qpA}d9KwaF{`$;x0EATTl@2{bo4tad#ChRI zs5OaPaf6DTUyOC%hfg1y$~!^-eN#B8Z=z?wC!o@`k6C)b$w*J)akp&*Y z!juAN-XAU=S1gjw2Wa(iA$acHu08_H2dU|@<@X{ul;ba(cWR`tJ5FBSNsbd<>m=OA zdfT8=$0wFXz`C1eH=LDJ8!|PQs~)SY8UD90z>uc##d-r*nP4L!wc+Od+K4TJ{2c*s zVJu$X>XgP*MBB<;x!bJb@^Zwb+QYKBZF}>M^Ft!T%f<%8Mv4Jfy^-Zm9$_mrQi%Vu z5}p{DJkzkerK^iR43Im@T`b3TY7g`y9&}G4h!oxi8v0*X%ivlfvGhd`SC(90S=}=< z241?KhaT62IxX6sbMmp!{!x6tZh&XqF#P3HHiGN85rg)H&NmPkTyn1ELWNW~k2>;h z?CzV@bl{nwK)FMNdGc<2y*@}{6y0jSIUzk)H$-zbuKAjC5xOKX7S5*}Be-lg-1QHT z*>Cn~eMT03B!N!=WN2yVjPgziK1?c2j^1}#oig~`gtvjUOn1tCk?wkUVTtPu>#B$=5+WJMxVaRvQ_K!+0PsAx+J&#A)q&3 zx23yz8oB?-a?iXQ9KtaacWp(tcEADm4vtlT1rP(5-G2iSn1)fxI;@Fevw8&l^IZv| z4ks)ZyI^A6-rKYj@`zQ*1tqaU%xy+)jA5m`X~Ig7vn4)uMNi@;hRgqimv>5I(AXCb zjSgdpK20A}V`;HAG_G&^;a=F00z+7XWNEv!*)rR|g>scSdn}qnAMy+G2vfbPTL;4I zUkDPzI8Rgm1HedvUB)B~%OHqB`k5S`C`$>Ik^QKV)=ArjAF&m@s)dS|mpn2J!CI%q zokXy4xT1T*M(sj`wJ3`vs+rm2gg%d%&4{YMFz|5r6fosY)&H_cqpw==)_7J`rW%@} z{AnAivJkFm${2ghG2Z|B+WLE{pHLP`yD9*5uUE1$fvYU1PF(4=2;*>CWE@lBd0^Mt z&fmuksyV(wL#sX_uVsF+EMQ-S*9PdN4$(=gtIW(Unu{mR!8%ME*NhL23;GDrc{uju zW5ppxr{^05C8Cj`XrFX;{@rW+v=s{FJ}MMcIKK6|tDPVlA@_I~-_QmLi=YYr)XrjoJ2OgJq2{$D=V`K&thrXC~ z79pdw58wBcdKkOB$KRGF)&!rgcO9(%N`Z6W3~D8aa^l-I>x0`+K^(c!(x{#cF@DdG zFuUOiA*$fD8;0F$x^|5Wr?Yu}3Vq3yL`jk0!Xp+@OJ#Z9Tt*iqIOvRoPlDRHghrk{ z@x18l9DckYPKi9a=B@0q72BF|1A;d;gZW5U5;U%2C2c8op6wAP->T|~@aieV#$c6| zGc_5ly`DBRMirPQ_}#3dqZ(+CURKGNZ^;TjiRcp*7GO%2lA1 zb-51Ua$Jcgu;Zd*ZO!3!_B^Z4m?OANA$wG3p_pcN0v0%w#eq(rbm`fMrbxgoc^Dm4 zB{eQ>DB9u2ZQYy6=^4R^2VjuimnmOww|gswK6|>y5a-;+T4rPiaScC8Omocdw+9q#C3Mk)>bHX zzXB74ESow+krMs^ZkZeApV`|_&5QrmtUqAIayKneJ%P*%i4zf`W(AEGXRn14-zVwW zU(sBu%C*@cEGKoCBBYE>aHen7SCJDD!ssDf#EkaW8<vJ>8FX+#t@^SwVxitCP)5~#cmblu!oK)fN%!cxuT)fn7PU%ZUHj;P71ly+h-L?y-G&cPaVW$5)vb{$qUKLrkMN|{7rhlAiQqElKQ}eH1 z5#}C|?(RtD>5E!fA1Po|*dgsP%-ZBg4e$>fXt*Cy++AY+mmTdjbs+WQi1j4i-4!8h zqFU^Rc8o6^2eAE~0pui#QY5iw7&kB0TZ(pJDDJ#v38)GK;(d=!gd#*uHm(_q3ybKX z(ZE@I$VKfklZun3*Im(>+?Ke%DTv`E<5=l1BzMo13(^-zt?uiXM&9yk2$Q3=Z@~nJ z`x}v<5m0-d8IZs#RkzPB6gaGJNCWC7$+qJSD^lO^gA_5zqM;EO2Og&f0zdyok@Vfa}e6|9=3Rgbj+;d0l-S1;c3s zdOJ%`$6@5j*usdp<%U3Vb#HfN7l(Ipa~wQ7-IP2EC*E`M#Fdy4KLxJHG=9eXu+c+i zol;Dn$?!a51_jtbys7MHdaYT;ta5srj9SBkpZeY5dO(mKR51nfxvnf~eEG)2cG4M= zT8>M;SP+F9TakXGi$##ZO|+a0#<_mfEy5ozsS>PWLrYQm$)#vEynSV>IzCjZXQOm0VYvF+;k7M^?PDP@ppph1A-9kj!f5N*gO+l#S?poR7v@E6)&(g>>m2oCdi{;Ex{_ROy++z1%4#&z- z)hk^8*6AWR3-Oxb7y=UUWZF9~68`L7P5*t?E!Lt9MQUbTygge|m_B}d3`Gu3ryAUo zHJLA~8B09ET>ugY>qDm)F3UG68cfB@=e1$J3_7&RzT^VG?n#2fPAh@p^ghgR4{*s8 z@{+QG-Sv+HYuNGC6Boy7^z$;H*_M7OCGqg)g%K~SsQ*r6;wraFB6I4L$|V9D9E=5)E&K;kylxgndFFh`rcunlXVz_=_KnoQ_3g1(=c5=REj zpPCueiaWO?n-*i{Q5@Ds3ru%$SUFla3!PZD07S=QWg5fwE#g?3g@3Zf*AHQw zJ6{ZgT)T9P=oRi~2*>HKK+SOE8M)`U&TEYKemigyzd72(SHY*4k7k;B)ixu69TL4T zIV25odROELYY2T96OLThV2Vxhc8GwVlvQ*(D<+f(So&03f;NKUREy1) zh~$fPBB#b5ZR7fGJ5BGDQf+IYL>~2gU#5I(so+HJUmV0PO8|od39r?QsGtrN^|l-( z*Tr%Vee+vzx#2K8NZ`I9DYmLcK~Q-?`v;KFm!OG(i#rHoQWMX;c>OK|=^jNZeY~h!M_|Z0PH6fcgza|aYL^Z(LZuypwL~NzmB%8bbGKvUTPXU3n>B?e-sY;cmPJAu+l4oVH z-R#JglA|5Qp=|G%ovSPV3LXC8JOG-7F`pg+Gz=8OQgd}BzcnM zGZ$5fd4g5er=ghf}Mu1e*JbZ(UZ-lJLM~r->MMySuX4iKprY z5CFxB0jc+p*WRe;YA#diD1;4}#JLsIgz>+R*=uOjFO>ysM{Yh1r>Js^C$m;bmlCo!rN3d0kJEY;Jm7EpM`RF+ z$g^BkDlwqA%B-Nv(kD?&lAS7f^v^bZS5(h8tJxZ13n2e3%$#3Mavtd@l3*4LV~7Mde>^Am zOdO=FZ_xb%B~4wQGG=7+2yIe_M>r9Z`uofIv*0F<^xqreJ+LG-fh0}tvCS|AsgO7NZAKAuiQ3hT|aCBgie2hZw|jmve!B24I` zpH4^Jzx5;gzggldd~D3W%-DPkzV?$kGfM3%&mT2?Qs1l?oGA;RhQ(ZD5S;lpG5pZ0 z&lpEydy}iRs!QMFcD`-TnP?f-IAiAh@F;{Ww@_MIE#@UeXmM26M6!bq=W35!^+qo! zjvdPyRY`5nD&ckVrFJlt&IzLnxMXleNDPB0=>{_D{9;F%OK8{`_adXr2+RDC1YTb_ z(qQoUkM&ljBTO9GOlLb-$|Pg+`q!NTad<%;OKJXt;OJsE51kE1mS0T{IEOd3YX$mN zHmD(Nb!vRf%$xx_!pUgZic?k7(udJg_3ZmufI^jt8>=E*6vj5ss2?W*q=m0|C~E)ZDF^u?)3?cyir z9shwRnwBZ%Q{Nn4mw$Sc7Nm=o`1$hkDKf=uOz*<;iAH$2@mt*3kv9YzeX0V6}w$go26y;(wW5L?ymJtwn%`Kn@vjGN;# z4aJaESn=x53@}HFt{-DbHyxSrand)1DE29(-7K#EuF(?PDo4>IN^*vLN5$t$MRs?O zIIax*(dl($zp0lL@{P^tfE<$*ST3v<1elhAu*q1jA;$qZ|kZVt*RE1d?C&&?sDKR>cE^X4B-o4zgK>Cb9jfT^^9M#jV~agckB_1I1{+Ut zw%4M^TRQU9;vS?DLL)O4c9%?){mc$!dg8WIyF*&`{9UszTK*$^zUeV?xY~JGv5ZpU zV&hWxOI?ni3X=2|Cuf@BbsqXQ6Cgbbq@dtC<`M@wTsX@R>j1Gl8hAIOHCdZSshOp0 zsv=3_>!b<)9@XJzyBw!Ibl=F$%?nrkeTpQy7yaQ8`x2jzCRHuZ4^9pb??5QNFKadb zo+$z*5%R?WnS(YTKj&1D*@>kETfsG>JX#GJq1dY3q6&NC@Epl!)g*-ieT8<*U@j*I zJr5yI{`TG0bD$Crsvayqzen05fw)^M6?PbmYry8pj99&Efqj}vLRKeI854O}*A%DY zUI2oNb8AWj?)v(Y*N87h*Rf8tRwB4ovrfGfUDUgz2LULzZKLB-Rb8v=IzJCK;-000 z2~3^K7#s0Hm7fQ5lur!Z1oHVma{@>W4HVk81- z1t2h+bYHv)31lme19}e!NC=npQLIWoJE7h|=AW-#YVk|$mO2Zut3D;|IIXobi>oABR8=K?uNBkGPk5k<;A)7 z^oH3DG4>CRzs_s5+RKURx7Fe#%jt)t-c`e0Wlb+Vb zCtyu@r1YjW(PQf2+A3mIx3$s*1Q>cUY_1hg$`om7=!l#dl&0#AZ*39IkbUki>0Xby zH0Br5T}@bIQw+KG*~~J0Qz7zdGqwjpnD4~Cj+Ij((Q^>`i6$bb!r-SUnL=NM$j3y& zKg53|6fO&>t%W`Mjg1!VO~*=^as^yocI=oLr7uWP(IPlN@`^yx#(4DZGyv0O?UBy+ zED<+?hd$uJQ<%T&i;1lAcNC7?8{33d5gt7)q{=_VQ+4isCQft9Buz3(Z=wZJ8ptzM z;C$E-D;JgW9*RBr5Js9T-uw36vrc(iK}jDX!bpXOt*q6U2z3ydgJJ+D+j2#i5PB5qz0 zfhMn~#tENxQEbTSi8&)e+uH2@7IwUR#-(%f%rbw->?3PjXW1iz|GUx%Ws;>iTI(A? zwG;MAQ@~mdsO#P@n2c?-#hjWz~1-~5CCQtxLd|kEhDZFJiErcU!nwqD|yp=S%HOa};;3=DXVS*Hoo{>99%^S&`lSM*KMByESl2L=NA(cpnrz|C+ z2yrVJbYIq4O)z$Sf&ulSbrh}pK*uk<-{b_MW;=HKp~^mkQADp+(x>|YCm!dgRl4#) zN=8bgFxvLb`7B2UXNH~a9-Ud&zyR@qd@RKM{0OJR!5xh?S{kGp@%KPutfpzbkbyoqFbiXsIZd9` z<@!#N6<10XeX5iK=F~v#@3U?tI#-(%Yz1qborh+TfwDKFm8xx{cyA>aTFsO1seumf zIKMh#cf1)t78GvWXBQIZk#~NiFtnt#ksDhg;9eQ>SDklIA#xHX#JBpnz}n*IqK;@& z=N`$s2RC{)xY{EV5H85iE`D&NV3M#}p8plvwI-|6V9{f2<$PK&Z3mBq(Y-)1r(-q_ zJ*=a2=g4VijEa?Mif-DhDY~;0uI>ppysE3A8Kq;GJS_*eL#d5&oZb3nt^K>hmTa%X zQ4qiSx{WQK0G;u8{%ls-X>oZNV+y18w-t^713p_LZF&UVpIL~UYD;l>t(FF{qU;t` zfE`WAyUQJft8u+*gWfsL)X$%Cn!Z!IK)imty_i*XmhQ|^EOW&_bP+h6ub^D~p8#hn znAH>nwt^`M(&I%Z@~(9KSoU|J=*y$pP6@GCNHB_2TRAP$ZeKdf_QDCUos`8zIR2_- zI(dfuMS2GYjamUHC7I3h9e$OU_MZWM1BN2c5Q}#e@<*b8Ct%b_{Q-8pC7=gaB?W=}(wLWn~~6TGYS0_Yoz9$KON} zcssy!%VAmMt=cxl(xGg2h*tWMYtZ0ZDD;*%~$x|4BU=h>82_E8xpPjHwM>6}-KGAl$+?|D?u{jHe)0FQpG zpRqMEM)zP0WLBTE36}}SIyViP=l=k0XN(Tfc-UBStw(23R|m!I@iz;^Uf#It%4TYA74XWSxaC`SstDV|QdzOdt4$xN6>DT0gIzGf=zJHr z=4)zHak&Yn5|RP-(x4pdx2kT@_QM7^W+M!VCKY4JHsF;l|u}|$5M6sskx+emjxV}2ate3+=XLKcDa%sF$f~V zxd!9=%~k&Nvtlrjsm#j7z&!$xf8G_&lsL)6>&ATIr(KRZ3tOcSTPm`ReQSuf&3<%c zKqJ#}OGu58So4n+hmfz!{hnaGsKF9Q0~VtH0PO)^sbk;Lzb)Y)WbHgrASK2%R1YyA zt7}HT5&g&LC2X+n#BJ$JLzx}H^h zEo`4ti_uw!!<9e*uo}}c00{(o({MzGFe}dXzSO27H&?!{4eB*Wu3VS|QIXxoWKFsg zNK2jWSla&pbvTPJcPwfw0l5a2e7(~bED6{OUwRz0Q1K&_6*_rVH;oI1BK8{A!-xao z&40$Sd{Bappl&(PUd{Nlk2viC4Jq7oto+1ZLvkxa+C*fK`qp|tO|-7g549X$J$l%? z5=C|~n|%#@+BcO(7A8SjJ&t1UW`l~)B<+}=v%Y{N<2>H6y+x~-?&qpkQ3 zHpll<<*EH@?eH>VxHbh^UhJyI=G&4ss{a6JVOO)*wIl%H1^rkGM3#i(Yw9nXKRX~* z#IZIlb3w;lqy#DTu1T3OauH(J{ORxmua8qtZklGuu1TV^4h~|swHUDXZc zO{s-bbFIOumQ9BoI@wbZmM0CUCc7*ORZjQbo}Lq8M=dLfhBmReJujtKKXSf`T04P- z0t>JMtyvURiAr?mRdFsx%O$GM4=BnIk$+lT?(B4Qs9|GH=(bQ;)O)lmWmV9MluV?s zy@}geGDUo*#8BBNKf6Tn00{(h&CZjP3Z)ES+Slj3SmqE$Gng7rQH0fnb)Q#H^A0RtMmT=VH!O;4bjhhif|y^9i>3!gg8M{fX72`0B5&7Gy~AWbtEBm&>vrD5JkugR;-b%s^& zbJsC3WGLNmtJ(+ zW_m@S>LzBkan~x5hs>&`OjLI&^ z52fl^PLY>y=@%a2vdzXgW)p|RktA@e7_R>SKZ%PHO0BmR(x_V$W8<@N%wH6j z5KJ{-3KVx{CF*PB34wNJ(Ew8;vUce4jfZP~cON-a# z?jmHv_NrqNlIxBZ0ABw9YhR~{I}NMztGL5<^`wx0SHwXh%e<*4Mz0NDBiofpMK)0F zslK+QR#*E%9zz{8C&XYGt(T}pD5 z+dL{v7^x1Uo`o1w`3X>J&$8$fwEQ)Si zg4X3~$$LePLD}qk7R`}kVe)ZXath^DzlYtdaxX6(m=1le|s{ z1P)-)y{!v+do(X2P2D1;j%&9-0OkDkqa=O@?**;*&|#4svqhzbzO~t8J;}~=>quh| zgz^TO$OXprVTF;DEy9x4y;Q=4%ovV!af&KcN(}|BYNR=Id!Mt*Pwd7O31G{K7WI+q z!9%0vBd)dY{>&`i&hS70Kd%1(eXH|E7DlvYLvPI1tdMeqS~&hDMGVuNtu*#1z-2dnI{WwfGStoS`HaxBmdv)Vy$U z$sgIP%E+aHbp4s^g#a1_9+kmjy7H$Q4K79KebSMj7WJ;WRCy*Yx)b5jjTsrX(zs*S zMPHj5?n?j#ht8}LI6OIoyI8SveeYp?DZmZCT1F`hae(q>VSR5xpNdC^QqDz%LQ`e1 zxNt>=o7F#SoD41qGha3&0e|kbWcxwwUx4s7WyQ8Boq0tAH{WYkMlWn!FSZ?~;Jh1$ zVDXV>#FuHO%A-i%Kmk2zb81m(55)%=rz6mzTPf;m;}7&UIE1;QSAalqoZS!Z|{oshm~aTzjzI~4Qs{tqW=KjfFf(3eHJIL zc|nmi+BSHVa;AHGcw<1j5Goji%7wJC8&u(DY&2z-+E8&suvHr$x|aGC9?IC^k>t!x zlx@20i#LTr^~Rrjdkd141f@M(Hp|I=TITY7y8k$ zXyvlEhfr(j8JS8Qh|p0IGN^8U&Z5K(NVUZ&*hpRrd$2Y-ohqhPEi;Q|H`>*0B#{W1 zoe1TB%Bxml7&54{jKGoRXeH3-UA9%@NLb2*B#kR0#nDB}5In1C#pm!F6LYy0gyRwx z4Q($sd*Vtb`q_Q`#N5?^&6Sa@XF~*75$+m;8cGViFr4oe(A8 zk)cRz;`H1gNxqinTG`2hw@0Z&s#l)1XW6)k?Jo?|K`%c;NGMVPUtKBQ5g|^|aKW0_ zmv51-JX5pMLv3_W zew89@yoLEtS%a0=O6DR!pM@@mw@S`R%(`aW&|;2Pn&RzkcBx^b6Su{nJ5`u|=&EG^ z^P+Evy~|)boK8|y3-vqEVd3u0;sD>`H2h2$oZ8cpK*(b%;3(W$_cXU4=!6(yhg+_{ zI)s4S-9}T>T5vL|Uiw>lU0GNY^t~^zkefwubp$09Kdu6(hr7Z}n0C0PUw0K6F%%PGY4dS0;-80NK!hL5*yDtMgB2AuxMI#G)>v zh>WUq2J#yHQd3Q@UzvMt8$;~@nE7KDC&O|FI<=4^~5LL)G)EPDq1v> zW+a`o6yzaU7bv~-wd!i6LD**LSkx|!9QfS}_j$7h>$P!$fpt@Dg&d=0@ajcENZs|m z-6@su3Xmb4NMds?*6Bt<4X!!uT!uLX#jH&n;oPNwwE~M}xg;$h2QfwXcBd*K8{b;#F{{RfJS$F&&zV*~JqFaA zfkq@-TMc}v4Od2mCnvJIimXZi7q>%LPCOK5AoH!C7?8Pa!E;|jSe`JKQ@Oak>pSe| zcM`335+2?vbV$i-L#wRT&E zCza^gMwPGF<5u)~c|!~;6q8Nxe-~)@Gv*c;h0G~z<=4V24&sl%V$a%+6U=+cUf#9J zhi9Xo+RxCK0?mP3`-}eoKYda5-X%Sr#{-zCP;}pVyNDR$a1VrAN}}zH=IqZBk+UBF z_e{CGROZtiaPX&@gB(47d>l7Oq4UU4Ckp=otjFCd8I|UokQP^c~7Eulp$GJ6K zh86*>Ry5RRbr;?wYpN;8EoXTgbSM5P;im^)SxfISOd!3 z=n@r|bFDqXogvR1#%tW3W~-!K?7WsNAS(z(6S9H;Hnl1}}RhV1Q+w!LHs*Y|yz|V)b@4F!bTGpOlpNjYU>c~fxE=|~OPdcgg zJTmq+E1&i5e(_hQVhx4#uC5>Q(dPWUXPtbo5cm_sb=1_e7ADA?Rslo^#01Y|ao9;eBrl>4M5Ed*Ul#hXE@Ir0@A1W{cz-?1dEGoe{ zBIpUzQN1vur74ffxI*lm;-Oa{Xmns{#IWa9m@QF1l}sw0RSdw3-nt34l`NDI6b*$+ zxVvp#qD2HX`TMq*RiCtSO2fvO;=1(jO@4p|;=C8O1&3+zV&f>qk#F{iy=3zK)O3H1 z)Y+)SqXY^bK%-&EP|``-%4K2ZO<0vII*lvjjY$J22Dz>-^mJ6!bShqONM~|+8_^-2 zb|4uw8{BV9$}gtYJ5(cp2?k-U7pnUz(_H|3Ov=D0IvQ^Y-ZB=|NZ#g+kwCE*J!%~R zqNbkM4oRv=2sn)Gb8*VYdYFP%LEaI6E|g^iSo5xf;Wa;HU%;C}sdUc7a{$;-io&V^ zO?uN#w>p|n5W0?(wy0!Xl>AOLF`YE5cNUE@HG#jKZE>m!*jq}+ajPn|XPP=bJ3QaC zQJ}rfqoAx_DU`EV8rt@Od@L&&i2z?p=y=aUeDb1w{&dVXHYSCL1f|6n5AciD=h4EB zq;I6+0}mjML|{icwcr?#ymy5>ZJ3-)cehN!v$8_-NuFjP3tXOBbgMqjM1OB^r{QBX&bW~QZOugvPJ!B;fl$sosPeCBieAIv%Ex; zZ?Pi%D&@Ck2vk~Betwk7*qIJs(b!l4s5MuPbKhk)8F>wA;~uL5X3PclzcW-4kYp!Y zoynkv_H^f@SOF5k%-KO8a^8TrsSG{I3t%)h){~I1U>K6UDX0R-r}(I-34=|;n0^PLE=()2#Xm-seE!gqj`W8fWc z(xruxRDwt(C6%??uPTNBq*!)VU|#nE+i7Yflc>V7gO*lu03%>OTCZjWw4WwwBIq4(EYbEl&-LyF8rnCsM6No(7BNn|F*nkslo;E3{QKKUKkq*iIsllmSe`=X{Hxzo*XJ*269nx~Xd?sSn_s@N z`Cn=}KgRv<^m>ks2m^6yA}&x*Is|$twKBIU=UEoba?v87jYl0fxD;3%k;9+XbG<1Atv(9@!-Uhz4i^dz0YhTCC zV0~*Hjvz4um2UBtf%D#q$=LUHzd9@@OC6{akPrjC>Tr{reJgY5;6?h)?kYg&!549_ zTCm`lWIShvIvqwLA*sENaa8e08sJNi^RT^M_HtI2v^+gQ1Pn|^rTk*K)YgwhceCGc zOWl2)?k!dQpqW>Iac=VA1SB8Itew?lBb~2Q9j{>Bnc~AWtrhR)2qL2RFfFsfc*LRQ zY^L@)UaE|PJ7zhyrZG%+I)mj@xS3qL5C{a*al+Lab7teQ*KwBostbrQfw?DdDo!a# zjP;^MO97Z@DZD7p_3xn4O2n~leQ1hp5|F?ilnHMnVRgMmB`gZRDy}*&o8?DgW?4uY zoprTX;M*dubD%VyQxVJto^)gvIvwRYemIw&(R*p6b{QZ zw)dAJ-iuliKGc>VYHEYn`7PO*FK-SZhxk^s6Eq@LMv((t=vY@<$NvB>Cztad_2>Hm zAX}R)54!{rmd1-D_;{BzlSC7fXBMc*i^0aLB$$YmTV^f*KRRigf(fJ3O~*KLN!`9P46HiH zqw}wi7Qq8$#$njr))J{V`qV3B(Q&s*u1sKAU6xBEQ<&ve9}UIFFYPJmWAg!ziQ(l; z(a4TJvcT4F2iiUmc+Vc;*r|$4(}R#Jwq@>P7q}X9-<3{?k?0EHwrcpuRBu?X>1PhY zNF&5?5KhBB7DXr2fn&EpQvRKAbPCUjV;L8^;pM;6E$Z&d;LWI)F~3Uhedn!XW9`oa zl|wE!PFbUMKSC*l?SBZCGVx;)Lt;Q(+S-sW&&sH!6I2+M)U|$P_K}Or+x|AD;2A*I z(!Hk-+y2Z+8oA>*WXvuV*r^_%>MQeav>r2t#`{F$PlUurGzNbRh}o5_2FKR)jPY`b z(EdJ3IUW2Tqp;w~68YHPn~Z^bRd)|0;IPcBH9&9jt0at#dhc11G)a(lB!s>Z2?3REY9t2n8&}UFodLakMZl=hKOoyi z&}&O#wdOBOOQp>zHHwlqGz|w5pNKY8xX@NJk3Hcw<<8Zw;sj-2%s{L^Xe3QQVn>~2 zmuE-EN1b+#OBT7*n#SU!2LAw^YI{#8Alsc{@lAazq2ou=Wd27bIu(_!N39+pN;R}J zq>K$Qhja*T#5W<+33`o8C8I+3wzZ(_l&$?Bz%vk`aS@#c{vlaIbPl<++={;J z{O$WshbbX}#KZx=_QheGb)&tHBI%!_Fwfq|OA}%R>owb_E5LZFmLXkiHMX0d!qs-J zaL^GY*Ta9iL0F#FOwYnNjwV7`S~9AqnI^*Cds1N@O$(EyDIQbBZ;~*lL0~QT)l)D9 zgu2*ialJ`roX2AvrO6h|r)uKD&pp{B19D26R@DZ(GfO&_(r+t!Im&EDLra_)rWvBUU_>m^+V)U+ z?M_D$DvyTr6$PeHT}95Bw4%%1pg(9E(47S-+v!O(<=7G| z2|=5O8jBl!^jZR# z*_PKVK($6ZVuP-{^rU_2A)`CB`4u|(?MqE83noRJ20IRBqoUGfwl5VEEzBNAgPm(btvs%{~I#LO6&Rg{n8u>ERU3NaSqeZ5W^jUbOP+*;cI z05_~3ANJpmT*HV2UjZ@qeHzaIsy8i&y zfx8&uy^k~P4{rNM$BQmIisFndyh!Cz-7Gh%E*&p*h#L9VspI{PV=PV&6&QU6NeJBS ztzvsc*j~_fYY_*(U|qzGWN1%#3EtXswNBLlt};?TUT^?gg<#9r9_erEVOHogI{<4V z*^VfQz_?=0PkZjs87?eTl@|ncts3JYmOli^w=-Di+b4SuAqq!2UTK0SL+47*h>ffS zss;H}F&c|2ixIgr68r@Oy}?NGN)4~|puCbH_=yzkSVReNC}YnlptMF;3YNY0G!Gnx ztdTi|oZMX8)ueM~16x%dCK(ZnE~*WVU2JL0JWL{1Vo2Z4sy3YxX*FXQnL%~}l9Ab0 zP<7{BaM_uO89>(brXb0aLPGN8RUo2-IJ~)|V0qRXk0gEBU~OTjy=*v%v`v`b@~j7H zBr%~SyaQ52A+4LRx<{RMl3<~{&12?}v8%q)V!PQG0xf#ZlU;8f6%&i+<>iu*#v=77 zjh=;lYHCMH(d=`RH0tCl-7Z?%kyd@32lnR;$hm^zWBGW6T1(kZHl8HFAW^rEQhy)1 znc$tD<0-|kQoaK(b1FM{hlxWCfw%K&%;I$8l_#^_G0Pv?;-{0l!o#Lx&9gUIQGRD#O+eyKQX@qQ+7r@-5K%=>BaxJT z0R#>Kjz01B003>~XmfC^J{BCYSeaAdSRs~I zREja-(=p{%_{v?K4^lEr1>o zYWZg?W@0iOZfSuyAXsX83JNW@$*hhD4R9^%Oo_(9j@;=clHipbw9qsD^MZbsViePyGYTE zE=Xh~{pdcGZcy6Rq;Z&W-$d+f-N>zez92t3jfWA#8>@yJa|fM#V9vRaZ`XQyL`RFe z8arqY=R`RX~C6tov!DbzwQZDv4!$Xv$63F(hm# z(nOPtvP6zAav5$u`gF!a3oX>^d(n&p0z%%~RHDTO7B?WgD{-@PwMgL7Ti!A2YH}#e zn=*hrjT|d0cn!wKO0Fd2RY`%3Q!>NeumAyaDn|l@?XNIRS?ic7T`j4i7&B@II-F5X zY^TIv1d#okG8Q!a4n`~ zajDtPzkN38K4}1H?2os(8_VQbuY_Gb;k_>_(T&P5xAd zGX~(2B$#G5(Ye;ZVD%=)t$pr+m|S1wK=Gi~W_h+dh2mV^JXE6k5nyW_+78TPv9Y?O z@+&dijeRTKUxnuYfA4vkt5Q0_n)#dYHqRtnJ~5asygZG$v5@_^jC+A}AJSE5F}BlR0A?M4fy@Xa#98 zFhpVz$E=Lj7v)I91>_?xrHMXtGSEq(7Q-xSb^s~X=D7wKLnAw=YyR&#xk#_2u6DTO zX{e!2>{txPYtSU_%W|y=K#GlJ3{;VOtvByUm69dTl-p}-O{^mJ&8IIqmvlh@YP5Wq zy*42lO5`?0zS~pSXov#k5Oo(njeR7bDit0R&ZQH^M~GzuokT`O@`6IUH=iotjI$A7 zQq?)+PYh~E0Nh%q8B{k0^TaOfo&T7 z1x_^~Y<8$qbVV$_1s)$EQ(>6g=%myYOUvRVY<{%NQ7VfQubHTdbT97tvk>`wfZmnj zXcGr4k~O16R%W)qFemO6YZ3q~yIVjg9Arli2ggjv(kyU0G7Sp=3H*&+kuaHpVb$3Q zB!yoxbfO;#(|RuqLi|4q;#Ut6wa1{Y&4(e)vs*)Ywb@tfeV8@D9RRMFf$5ui`Zz)* z+cn9(5ypfm7w1uwnb_gVNjmiDQ$;KXD_3H;>toi5Ya3fi8ZO9%0^=Yn)})|Ymr+tc zMZwm(1=v^s2Rel8h)W)#)L;%x282{pFy)}vN}46j$+-tYIcZRb$eHbB@cGo017Az} zQGg(M)Gw4>N1YNtwnw@JG}hf~i50K479t6=D8F0R%p3ub3wiHXMOhO71d*Yxh?iY8 zH7k-xaBOO5H1n#WSTsO1AkpKEPWq8u3z%NoRI-KEtfCKxMk7mGO6%bjg^2ml6I;<# zk-b$S>`gG>UogK~8*uD2jB~`TeJ({=SRLzuKsTzQ`5s$_z%!{bHMyH;29((m_hB-h zkkX`OG7F}Qdsy?S0s{uH78~=V8bwS}7kLRz?!zDe=D$18gl@8fYhPZY(w%n~v*@fe z(*FQjUEOYe6V!vC`B2H&OGLy`2EH@1sdOf2&aA zrqyT`*r}361hgzj)Y)(Jrf%e@w}+j-W*5lx6sA+Vik9Nfbjd%0N;y zp)xBd9o?_6u@uq+WzS?b>s>cyv-p$}0qIhSY*nBm;6Ml(X;WyKRg^D^*S)G){A4R? zP5gyUHg51<#VxN=YSJmTCa@jkIv!*iIzkW=;s^&yV7Uc|)K}5DD#Va&sq+4GtE7sy z$YLb!Hj+V!q1tP@f$1&F+Aq048Q5g}Xi(0^M zO+$u*7Yvckd=mnNFKdfXqCo3w3hOs_m%Gq|Vs@*qf|?TGSfL*c!;}h<{qD z7G@yYqDL*Cj~$6MG`Ar*>OF+KL7v# diff --git a/Imagekit.UnitTests/Tags/ManageTagsTestAsync.cs b/Imagekit.UnitTests/Tags/ManageTagsTestAsync.cs deleted file mode 100644 index 87d4a1bb..00000000 --- a/Imagekit.UnitTests/Tags/ManageTagsTestAsync.cs +++ /dev/null @@ -1,240 +0,0 @@ -using Imagekit.Constant; -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Net; -using System.Net.Http; -using Xunit; - -namespace Imagekit.UnitTests.Tags -{ - - public class ManageTagsTestAsync - { - private const string GOOD_PUBLICKEY = "abc"; - private const string GOOD_URLENDPOINT = "https://dasdsad.dad.io/"; - - - [Fact] - public void AddTags_Default() - { - TagsRequest tagsRequest = new TagsRequest - { - tags = new List - { - "abc", - "abc" - }, - fileIds = new List - { - "abc" - } - }; - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = restClient.ManageTagsAsync(tagsRequest, "addTags").Result; - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - [Fact] - public void AddTags_Null_Exception() - { - TagsRequest ob = null; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.ManageTagsAsync(ob, "")); - Assert.Equal(ErrorMessages.InvalidTagValue, ex.Result.Message); - } - [Fact] - public void Missing_Tags_Null_Exception() - { - TagsRequest ob = new TagsRequest - { - tags = null, - fileIds = new List { "abc" } - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.ManageTagsAsync(ob, "")); - Assert.Equal(ErrorMessages.InvalidTagParamValue, ex.Result.Message); - } - - [Fact] - public void Missing_Filed_Null_Exception() - { - TagsRequest ob = new TagsRequest - { - tags = new List { "abc" }, - fileIds = null - }; - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.ManageTagsAsync(ob, "")); - Assert.Equal(ErrorMessages.InvalidFiledParamValue, ex.Result.Message); - } - - - [Fact] - public void RemoveTags_Default() - { - TagsRequest tagsRequest = new TagsRequest - { - tags = new List - { - "abc", - "abc" - }, - fileIds = new List - { - "abc" - } - }; - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = restClient.ManageTagsAsync(tagsRequest, "addTags").Result; - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - [Fact] - public void Remove_Tags_Object_Exception() - { - TagsRequest ob = null; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.ManageTagsAsync(ob, "")); - Assert.Equal(ErrorMessages.InvalidTagValue, ex.Result.Message); - } - [Fact] - public void Missing_Remove_Tags_Null_Exception() - { - TagsRequest ob = new TagsRequest - { - tags = null, - fileIds = new List { "abc" } - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.ManageTagsAsync(ob, "")); - Assert.Equal(ErrorMessages.InvalidTagParamValue, ex.Result.Message); - } - - - [Fact] - public void Remove_AITags_Null_Exception() - { - AITagsRequest ob = null; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.RemoveAITagsAsync(ob)); - Assert.Equal(ErrorMessages.InvalidTagValue, ex.Result.Message); - } - [Fact] - public void Missing_AI_Tags_Null_Exception() - { - AITagsRequest ob = new AITagsRequest - { - AITags = null, - fileIds = new List { "abc" } - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.RemoveAITagsAsync(ob)); - Assert.Equal(ErrorMessages.InvalidTagParamValue, ex.Result.Message); - } - - [Fact] - public void Missing_AI_Filed_Null_Exception() - { - AITagsRequest ob = new AITagsRequest - { - AITags = new List { "abc" }, - fileIds = null - }; - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.RemoveAITagsAsync(ob)); - Assert.Equal(ErrorMessages.InvalidFiledParamValue, ex.Result.Message); - } - - } -} - - - - diff --git a/Imagekit.UnitTests/Tags/ManageTagsTestNonAsync.cs b/Imagekit.UnitTests/Tags/ManageTagsTestNonAsync.cs deleted file mode 100644 index fca2fdea..00000000 --- a/Imagekit.UnitTests/Tags/ManageTagsTestNonAsync.cs +++ /dev/null @@ -1,240 +0,0 @@ -using Imagekit.Constant; -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Net; -using System.Net.Http; -using Xunit; - -namespace Imagekit.UnitTests.Tags -{ - - public class ManageTagsTestNonAsync - { - private const string GOOD_PUBLICKEY = "abc"; - private const string GOOD_URLENDPOINT = "https://dasdsad.dad.io/"; - - - [Fact] - public void AddTags_DefaultNonAsync() - { - TagsRequest tagsRequest = new TagsRequest - { - tags = new List - { - "abc", - "abc" - }, - fileIds = new List - { - "abc" - } - }; - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = restClient.ManageTags(tagsRequest, "addTags"); - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - [Fact] - public void AddTags_Null_ExceptionNonAsync() - { - TagsRequest ob = null; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.ManageTags(ob, "")); - Assert.Equal(ErrorMessages.InvalidTagValue, ex.Message); - } - [Fact] - public void Missing_Tags_Null_ExceptionNonAsync() - { - TagsRequest ob = new TagsRequest - { - tags = null, - fileIds = new List { "abc" } - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.ManageTags(ob, "")); - Assert.Equal(ErrorMessages.InvalidTagParamValue, ex.Message); - } - - [Fact] - public void Missing_Filed_Null_ExceptionNonAsync() - { - TagsRequest ob = new TagsRequest - { - tags = new List { "abc" }, - fileIds = null - }; - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.ManageTags(ob, "")); - Assert.Equal(ErrorMessages.InvalidFiledParamValue, ex.Message); - } - - - [Fact] - public void RemoveTags_DefaultNonAsync() - { - TagsRequest tagsRequest = new TagsRequest - { - tags = new List - { - "abc", - "abc" - }, - fileIds = new List - { - "abc" - } - }; - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = restClient.ManageTags(tagsRequest, "removeTags"); - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - [Fact] - public void Remove_Tags_Object_ExceptionNonAsync() - { - TagsRequest ob = null; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.ManageTags(ob, "")); - Assert.Equal(ErrorMessages.InvalidTagValue, ex.Message); - } - [Fact] - public void Missing_Remove_Tags_Null_ExceptionNonAsync() - { - TagsRequest ob = new TagsRequest - { - tags = null, - fileIds = new List { "abc" } - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.ManageTags(ob, "")); - Assert.Equal(ErrorMessages.InvalidTagParamValue, ex.Message); - } - - - [Fact] - public void Remove_AITags_Null_ExceptionNonAsync() - { - AITagsRequest ob = null; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.RemoveAITags(ob)); - Assert.Equal(ErrorMessages.InvalidTagValue, ex.Message); - } - [Fact] - public void Missing_AI_Tags_Null_ExceptionNonAsync() - { - AITagsRequest ob = new AITagsRequest - { - AITags = null, - fileIds = new List { "abc" } - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.RemoveAITags(ob)); - Assert.Equal(ErrorMessages.InvalidTagParamValue, ex.Message); - } - - [Fact] - public void Missing_AI_Filed_Null_ExceptionNonAsync() - { - AITagsRequest ob = new AITagsRequest - { - AITags = new List { "abc" }, - fileIds = null - }; - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.RemoveAITags(ob)); - Assert.Equal(ErrorMessages.InvalidFiledParamValue, ex.Message); - } - - } -} - - - - diff --git a/Imagekit.UnitTests/TestHelpers.cs b/Imagekit.UnitTests/TestHelpers.cs deleted file mode 100644 index 8a7aef75..00000000 --- a/Imagekit.UnitTests/TestHelpers.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq.Expressions; -using System.Net.Http; -using System.Threading; -using System.Threading.Tasks; -using Bogus; -using Moq; -using Moq.Protected; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using Xunit; - -namespace Imagekit.UnitTests -{ - public static class TestHelpers - { - static TestHelpers() - { - Faker.DefaultStrictMode = true; - } - - public static Faker ImagekitResponseFaker = new Faker() - .RuleFor(u => u.Raw, (f, u) => f.Random.Utf16String()) - .RuleFor(u => u.HttpStatusCode, (f, u) => 200); - - /// - /// Get a test http client that response to the specified request. - /// - /// An expression that matches the sent in the request. - /// The response to return from the request. - /// The function to call with the sent in the request. - /// - public static HttpClient GetTestHttpClient(Expression requestMatcher, HttpResponseMessage response, Action callback) - { - var handlerMock = new Mock(MockBehavior.Strict); - handlerMock - .Protected() - // Setup the PROTECTED method to mock - .Setup>( - "SendAsync", - requestMatcher, - ItExpr.IsAny() - ) - .Callback((msg, ct) => callback?.Invoke(msg)) - // prepare the expected response of the mocked http call - .ReturnsAsync(response) - .Verifiable(); - - // use real http client with mocked handler here - var httpClient = new HttpClient(handlerMock.Object); - return httpClient; - } - - - /// - /// Get a test http client that response to the specified request. - /// - /// The response to return from the request. - /// The function to call with the sent in the request. - /// - public static HttpClient GetTestHttpClient(HttpResponseMessage response) - { - return GetTestHttpClient(ItExpr.IsAny(), response, null); - } - - - public static Action GetUpdateFileDetailsMessageValidator( - string[] expectedTags, - string expectedCustomCoordinates - ) - { - return async (msg) => - { - var content = await msg.Content.ReadAsStringAsync(); - dynamic jobj = JObject.Parse(content); - string[] actualTags = jobj.tags == null ? null : JsonConvert.DeserializeObject(jobj.tags.ToString()); - string coords = jobj.customCoordinates; - Assert.Equal(expectedTags, actualTags); - Assert.Equal(expectedCustomCoordinates, coords); - }; - } - - } -} diff --git a/Imagekit.UnitTests/Upload/UploadTestCasesAsync.cs b/Imagekit.UnitTests/Upload/UploadTestCasesAsync.cs deleted file mode 100644 index 2a249062..00000000 --- a/Imagekit.UnitTests/Upload/UploadTestCasesAsync.cs +++ /dev/null @@ -1,431 +0,0 @@ -using Imagekit.Constant; -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Net; -using System.Net.Http; -using Xunit; -using Imagekit.Models; -using System.Collections; - -namespace Imagekit.UnitTests.Upload -{ - - public class UploadTestCasesAsync - { - private const string GOOD_PUBLICKEY = "abc"; - private const string GOOD_URLENDPOINT = "https://dasdsad.dad.io/"; - - - [Fact] - public void Upload_InvalidObject_Exception() - { - - FileCreateRequest ob = null; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.UploadAsync(ob)); - Assert.Equal(ErrorMessages.InvalidFileUploadObjValue, ex.Result.Message); - } - [Fact] - public void Upload_InvalidFileName_Exception() - { - FileCreateRequest ob = new FileCreateRequest - { - fileName = string.Empty - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.UploadAsync(ob)); - Assert.Equal(ErrorMessages.MissingUploadFilenameParameter, ex.Result.Message); - } - [Fact] - public void Upload_InvalidFileParam_Exception() - { - - FileCreateRequest ob = new FileCreateRequest - { - file = null, - fileName = Guid.NewGuid().ToString() - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.ThrowsAsync(async () => await restClient.UploadAsync(ob)); - Assert.Equal(ErrorMessages.InvalidFileValue, ex.Result.Message); - } - - [Fact] - public void UploadFileByURI_Default() - { - FileCreateRequest ob = new FileCreateRequest - { - file = "http://www.google.com/images/logos/ps_logo2.png", - fileName = Guid.NewGuid().ToString() - }; - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var response = (Result)restClient.Upload(ob); - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - [Fact] - public void UploadFileByBytes_Default() - { - - string base64 = "iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="; - byte[] bytes = Convert.FromBase64String(base64); - - FileCreateRequest ob = new FileCreateRequest - { - file = bytes, - fileName = Guid.NewGuid().ToString() - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - - - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = (Result)restClient.UploadAsync(ob).Result; - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - [Fact] - public void UploadFileByBase64_Default() - { - string base64 = "iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="; - FileCreateRequest ob = new FileCreateRequest - { - file = base64, - fileName = Guid.NewGuid().ToString() - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - - - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = (Result)restClient.UploadAsync(ob).Result; - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - [Fact] - public void UploadFile_Default() - { - string base64 = "iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="; - FileCreateRequest ob = new FileCreateRequest - { - file = base64, - fileName = Guid.NewGuid().ToString() - }; - List tags = new List - { - "Software", - "Developer", - "Engineer" - }; - ob.tags = tags; - - string customCoordinates = "10,10,20,20"; - ob.customCoordinates = customCoordinates; - List responseFields = new List - { - "isPrivateFile", - "tags", - "customCoordinates" - }; - - ob.responseFields = responseFields; - List model1 = new List(); - BackGroundImage bck = new BackGroundImage - { - name = "remove-bg", - options = new options() { add_shadow = true, bg_color = "green" } - }; - TransformationObject transformationObject = new TransformationObject - { - value = "w-100" - }; - List postTransformations = new List(); - postTransformations.Add(transformationObject); - UploadTransformation uploadTransformation = new UploadTransformation - { - pre = "l-text,i-Imagekit,fs-50,l-end", - post = postTransformations, - }; - model1.Add(bck); - ob.webhookUrl = "https://webhook.site/c78d617f-33bc-40d9-9e61-608999721e2e"; - ob.useUniqueFileName = true; - ob.folder = "dummy-folder"; - ob.isPrivateFile = false; - ob.overwriteFile = true; - ob.overwriteAITags = true; - ob.overwriteTags = true; - ob.overwriteCustomMetadata = true; - ob.transformation = uploadTransformation; - ob.checks = "'request.folder' : '/dummy-folder'"; - ob.isPublished = true; - Hashtable model = new Hashtable - { - { "price", 2000 } - }; - ob.customMetadata = model; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = (Result)restClient.UploadAsync(ob).Result; - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - [Fact] - public void UploadFile_Null_List() - { - string base64 = "iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="; - FileCreateRequest ob = new FileCreateRequest - { - file = base64, - fileName = Guid.NewGuid().ToString() - }; - List tags = null; - ob.tags = tags; - ob.folder = "demo1"; - string customCoordinates = "10,10,20,20"; - ob.customCoordinates = customCoordinates; - List responseFields = null; - ob.responseFields = responseFields; - List model1 = new List(); - BackGroundImage bck = new BackGroundImage - { - name = "remove-bg", - options = new options() { add_shadow = true, bg_color = "green", bg_image_url = "http://www.google.com/images/logos/ps_logo2.png" } - }; - model1.Add(bck); - ob.webhookUrl = "https://webhook.site/c78d617f-33bc-40d9-9e61-608999721e2e"; - ob.useUniqueFileName = false; - ob.isPrivateFile = false; - ob.overwriteFile = false; - ob.overwriteAITags = false; - ob.overwriteTags = false; - ob.overwriteCustomMetadata = true; - Hashtable model = new Hashtable - { - { "price", 2000 } - }; - ob.customMetadata = model; - - - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - - - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = (Result)restClient.UploadAsync(ob).Result; - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - - [Fact] - public void UploadFile_Null_Object_List() - { - string base64 = "iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="; - FileCreateRequest ob = new FileCreateRequest - { - file = base64, - fileName = Guid.NewGuid().ToString() - }; - List tags = null; - ob.tags = tags; - ob.folder = "demo1"; - string customCoordinates = "10,10,20,20"; - ob.customCoordinates = customCoordinates; - List responseFields = null; - ob.responseFields = responseFields; - Hashtable model = new Hashtable - { - { "price", 2000 } - }; - ob.customMetadata = model; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - - - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = (Result)restClient.UploadAsync(ob).Result; - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - [Fact] - public void UpdateFile_Missing_File_Id() - { - FileUpdateRequest ob = new FileUpdateRequest - { - fileId = "", - - }; - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var ex = Assert.ThrowsAsync(async () => await restClient.UpdateFileDetailAsync(ob)); - Assert.Equal(ErrorMessages.FileIdMissing, ex.Result.Message); - } - - [Fact] - public void UpdateFile_Default() - { - FileUpdateRequest ob = new FileUpdateRequest - { - fileId = "file-Id", - - }; - List tags = new List - { - "Software", - "Developer", - "Engineer" - }; - ob.tags = tags; - - string customCoordinates = "10,10,20,20"; - ob.customCoordinates = customCoordinates; - List responseFields = new List - { - "isPrivateFile", - "tags", - "customCoordinates" - }; - List model1 = new List(); - BackGroundImage bck = new BackGroundImage - { - name = "remove-bg", - options = new options() { add_shadow = true, bg_color = "green", bg_image_url = "http://www.google.com/images/logos/ps_logo2.png" } - }; - model1.Add(bck); - ob.webhookUrl = "https://webhook.site/c78d617f-33bc-40d9-9e61-608999721e2e"; - Hashtable model = new Hashtable - { - { "price", 2000 } - }; - ob.customMetadata = model; - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = (Result)restClient.UpdateFileDetailAsync(ob).Result; - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - [Fact] - public void UpdateFile_Publish_Status() - { - FileUpdateRequest ob = new FileUpdateRequest - { - fileId = "file-Id", - - }; - PublishStatus publishStatus = new PublishStatus - { - isPublished = false - }; - ob.publish = publishStatus; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = (Result)restClient.UpdateFileDetailAsync(ob).Result; - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - - } -} - - - - diff --git a/Imagekit.UnitTests/Upload/UploadTestCasesNonAsync.cs b/Imagekit.UnitTests/Upload/UploadTestCasesNonAsync.cs deleted file mode 100644 index 4ed8340f..00000000 --- a/Imagekit.UnitTests/Upload/UploadTestCasesNonAsync.cs +++ /dev/null @@ -1,421 +0,0 @@ -using Imagekit.Constant; -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Net; -using System.Net.Http; -using Xunit; -using Imagekit.Models; -using System.Collections; - -namespace Imagekit.UnitTests.Upload -{ - - public class UploadTestCasesNonAsync - { - private const string GOOD_PUBLICKEY = "abc"; - private const string GOOD_URLENDPOINT = "https://dasdsad.dad.io/"; - - - [Fact] - public void Upload_InvalidObject_ExceptionNonAsync() - { - - FileCreateRequest ob = null; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.Upload(ob)); - Assert.Equal(ErrorMessages.InvalidFileUploadObjValue, ex.Message); - } - [Fact] - public void Upload_InvalidFileName_ExceptionNonAsync() - { - FileCreateRequest ob = new FileCreateRequest - { - fileName = string.Empty - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.Upload(ob)); - Assert.Equal(ErrorMessages.MissingUploadFilenameParameter, ex.Message); - } - [Fact] - public void Upload_InvalidFileParam_ExceptionNonAsync() - { - - FileCreateRequest ob = new FileCreateRequest - { - file = null, - fileName = Guid.NewGuid().ToString() - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var ex = Assert.Throws(() => restClient.Upload(ob)); - Assert.Equal(ErrorMessages.InvalidFileValue, ex.Message); - } - - [Fact] - public void UploadFileByURI_DefaultNonAsync() - { - FileCreateRequest ob = new FileCreateRequest - { - file = "http://www.google.com/images/logos/ps_logo2.png", - fileName = Guid.NewGuid().ToString() - }; - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - var response = (Result)restClient.Upload(ob); - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - [Fact] - public void UploadFileByBytes_DefaultNonAsync() - { - - string base64 = "iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="; - byte[] bytes = Convert.FromBase64String(base64); - - FileCreateRequest ob = new FileCreateRequest - { - file = bytes, - fileName = Guid.NewGuid().ToString() - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - - - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = (Result)restClient.Upload(ob); - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - [Fact] - public void UploadFileByBase64_DefaultNonAsync() - { - string base64 = "iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="; - FileCreateRequest ob = new FileCreateRequest - { - file = base64, - fileName = Guid.NewGuid().ToString() - }; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - - - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = (Result)restClient.Upload(ob); - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - [Fact] - public void UploadFile_DefaultNonAsync() - { - string base64 = "iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="; - FileCreateRequest ob = new FileCreateRequest - { - file = base64, - fileName = Guid.NewGuid().ToString() - }; - List tags = new List - { - "Software", - "Developer", - "Engineer" - }; - ob.tags = tags; - ob.folder = "demo1"; - string customCoordinates = "10,10,20,20"; - ob.customCoordinates = customCoordinates; - List responseFields = new List - { - "isPrivateFile", - "tags", - "customCoordinates" - }; - - ob.responseFields = responseFields; - - List model1 = new List(); - BackGroundImage bck = new BackGroundImage - { - name = "remove-bg", - options = new options() { add_shadow = true, bg_image_url = "http://www.google.com/images/logos/ps_logo2.png" } - }; - model1.Add(bck); - ob.extensions = model1; - ob.webhookUrl = "https://webhook.site/c78d617f-33bc-40d9-9e61-608999721e2e"; - ob.useUniqueFileName = false; - ob.isPrivateFile = false; - ob.overwriteFile = false; - ob.overwriteAITags = false; - ob.overwriteTags = false; - ob.overwriteCustomMetadata = true; - ob.checks = "'request.folder' : '/dummy-folder'"; - ob.isPublished = true; - Hashtable model = new Hashtable - { - { "price", 2000 } - }; - ob.customMetadata = model; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - - - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = (Result)restClient.Upload(ob); - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - [Fact] - public void UploadFile_Null_List() - { - string base64 = "iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="; - FileCreateRequest ob = new FileCreateRequest - { - file = base64, - fileName = Guid.NewGuid().ToString() - }; - List tags = null; - ob.tags = tags; - ob.folder = "demo1"; - string customCoordinates = "10,10,20,20"; - ob.customCoordinates = customCoordinates; - List responseFields = null; - - ob.responseFields = responseFields; - List model1 = new List(); - BackGroundImage bck = new BackGroundImage - { - name = "remove-bg", - options = new options() { add_shadow = true, bg_image_url = "http://www.google.com/images/logos/ps_logo2.png" } - }; - model1.Add(bck); - ob.webhookUrl = "https://webhook.site/c78d617f-33bc-40d9-9e61-608999721e2e"; - ob.useUniqueFileName = false; - ob.isPrivateFile = false; - ob.overwriteFile = false; - ob.overwriteAITags = false; - ob.overwriteTags = false; - ob.overwriteCustomMetadata = true; - Hashtable model = new Hashtable - { - { "price", 2000 } - }; - ob.customMetadata = model; - - - - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - - - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = (Result)restClient.Upload(ob); - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - - [Fact] - public void UploadFile_Null_Object_List() - { - string base64 = "iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="; - FileCreateRequest ob = new FileCreateRequest - { - file = base64, - fileName = Guid.NewGuid().ToString() - }; - List tags = null; - ob.tags = tags; - ob.folder = "demo1"; - string customCoordinates = "10,10,20,20"; - ob.customCoordinates = customCoordinates; - List responseFields = null; - ob.responseFields = responseFields; - Hashtable model = new Hashtable - { - { "price", 2000 } - }; - ob.customMetadata = model; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - - - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = (Result)restClient.Upload(ob); - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - [Fact] - public void UpdateFile_Missing_File_Id() - { - FileUpdateRequest ob = new FileUpdateRequest - { - fileId = "", - - }; - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var ex = Assert.ThrowsAsync(async () => await restClient.UpdateFileDetailAsync(ob)); - Assert.Equal(ErrorMessages.FileIdMissing, ex.Result.Message); - } - [Fact] - public void UpdateFile_Default() - { - FileUpdateRequest ob = new FileUpdateRequest - { - fileId = "file-Id", - - }; - List tags = new List - { - "Software", - "Developer", - "Engineer" - }; - ob.tags = tags; - - string customCoordinates = "10,10,20,20"; - ob.customCoordinates = customCoordinates; - List responseFields = new List - { - "isPrivateFile", - "tags", - "customCoordinates" - }; - List model1 = new List(); - BackGroundImage bck = new BackGroundImage - { - name = "remove-bg", - options = new options() { add_shadow = true, bg_color = "green" } - }; - model1.Add(bck); - ob.webhookUrl = "https://webhook.site/c78d617f-33bc-40d9-9e61-608999721e2e"; - Hashtable model = new Hashtable - { - { "price", 2000 } - }; - ob.customMetadata = model; - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = (Result)restClient.UpdateFileDetail(ob); - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - [Fact] - public void UpdateFile_Publish_Status() - { - FileUpdateRequest ob = new FileUpdateRequest - { - fileId = "file-Id", - - }; - PublishStatus publishStatus = new PublishStatus - { - isPublished = false - }; - ob.publish = publishStatus; - - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); - var httpResponse = new HttpResponseMessage - { - StatusCode = HttpStatusCode.OK, - Content = new StringContent(JsonConvert.SerializeObject(responseObj)) - }; - var httpClient = TestHelpers.GetTestHttpClient(httpResponse); - - var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); - - var response = (Result)restClient.UpdateFileDetail(ob); - var responseObj1 = JsonConvert.SerializeObject(responseObj); - Assert.Equal(responseObj1, response.Raw); - } - - } -} - - - - diff --git a/Imagekit.crdata b/Imagekit.crdata deleted file mode 100644 index bb1963a8..00000000 --- a/Imagekit.crdata +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - AAEAAAD/////AQAAAAAAAAAMAgAAAFxTdWJNYWluLkNvZGVJdFJpZ2h0LlNkaywgVmVyc2lvbj0xLjEuMzYuMjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49MTNmODc4MmMwYzg4YjUxMAwDAAAAYFN1Yk1haW4uQ29kZUl0UmlnaHQuU2RrLkNvcmUsIFZlcnNpb249MS4xLjIyLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49NzliYzBkYjk3NDBhNWYwNAwEAAAAZlN1Yk1haW4uQ29kZUl0UmlnaHQuQ29kZU9iamVjdE1vZGVsLCBWZXJzaW9uPTIuMi4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49YmE5NjRiYzlhZGYxZTE4OQUBAAAALFN1Yk1haW4uQ29kZUl0UmlnaHQuU2RrLlJlZmxlY3Rpb24uQ2xhc3NJbmZvCAAAAAVfbmFtZQpfY2xhc3NUeXBlB19wYXJlbnQOX25hbWVzcGFjZUluZm8OX2Nhc2VTZW5zaXRpdmUKX21vZGlmaWVycwxfcHJvamVjdE5hbWUNX3Byb2plY3RGaWxlcwEEBAQABAEENVN1Yk1haW4uQ29kZUl0UmlnaHQuU2RrLkNvcmUuUmVmbGVjdGlvbi5DbGFzc0luZm9UeXBlAwAAADFTdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5Db3JlLlJlZmxlY3Rpb24uSVR5cGVJbmZvAwAAADBTdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5SZWZsZWN0aW9uLk5hbWVzcGFjZUluZm8CAAAAATJTdWJNYWluLkNvZGVPYmplY3RNb2RlbC5SZWZsZWN0aW9uLk1lbWJlck1vZGlmaWVycwQAAAA6U3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuQ29yZS5SZWZsZWN0aW9uLklQcm9qZWN0RmlsZUluZm9bXQMAAAACAAAABgUAAAAHUHJvZ3JhbQX6////NVN1Yk1haW4uQ29kZUl0UmlnaHQuU2RrLkNvcmUuUmVmbGVjdGlvbi5DbGFzc0luZm9UeXBlAQAAAAd2YWx1ZV9fAAgDAAAAAAAAAAoJBwAAAAEF+P///zJTdWJNYWluLkNvZGVPYmplY3RNb2RlbC5SZWZsZWN0aW9uLk1lbWJlck1vZGlmaWVycwEAAAAHdmFsdWVfXwAIBAAAAAgAAAAGCQAAAAtDb25zb2xlQXBwMQkKAAAABQcAAAAwU3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuUmVmbGVjdGlvbi5OYW1lc3BhY2VJbmZvAgAAABNfZnVsbHlRdWFsaWZpZWROYW1lCV9wcm9qZWN0cwEENlN1Yk1haW4uQ29kZUl0UmlnaHQuU2RrLkNvcmUuUmVmbGVjdGlvbi5JUHJvamVjdEluZm9bXQMAAAACAAAABgsAAAALQ29uc29sZUFwcDEJDAAAAAcKAAAAAAEAAAABAAAABDhTdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5Db3JlLlJlZmxlY3Rpb24uSVByb2plY3RGaWxlSW5mbwMAAAAJDQAAAAcMAAAAAAEAAAABAAAABDRTdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5Db3JlLlJlZmxlY3Rpb24uSVByb2plY3RJbmZvAwAAAAkOAAAABQ0AAAAyU3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuUmVmbGVjdGlvbi5Qcm9qZWN0RmlsZUluZm8CAAAADF9wcm9qZWN0TmFtZRFfcmVsYXRpdmVGaWxlTmFtZQEBAgAAAAkJAAAABhAAAAAMLlxQcm9ncmFtLmNzBQ4AAAAuU3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuUmVmbGVjdGlvbi5Qcm9qZWN0SW5mbwEAAAAFX25hbWUBAgAAAAkJAAAACwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= - - - - AAEAAAD/////AQAAAAAAAAAMAgAAAFxTdWJNYWluLkNvZGVJdFJpZ2h0LlNkaywgVmVyc2lvbj0xLjEuMzYuMjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49MTNmODc4MmMwYzg4YjUxMAwDAAAAZlN1Yk1haW4uQ29kZUl0UmlnaHQuQ29kZU9iamVjdE1vZGVsLCBWZXJzaW9uPTIuMi4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49YmE5NjRiYzlhZGYxZTE4OQUBAAAAMVN1Yk1haW4uQ29kZUl0UmlnaHQuU2RrLlJlZmxlY3Rpb24uRXhwcmVzc2lvbkluZm8EAAAAD19leHByZXNzaW9uVHlwZQdfcGFyZW50DF9wcm9qZWN0RmlsZQZfaW5kZXgEAgQAMVN1Yk1haW4uQ29kZU9iamVjdE1vZGVsLlJlZmxlY3Rpb24uRXhwcmVzc2lvblR5cGUDAAAAMlN1Yk1haW4uQ29kZUl0UmlnaHQuU2RrLlJlZmxlY3Rpb24uUHJvamVjdEZpbGVJbmZvAgAAAAgCAAAABfz///8xU3ViTWFpbi5Db2RlT2JqZWN0TW9kZWwuUmVmbGVjdGlvbi5FeHByZXNzaW9uVHlwZQEAAAAHdmFsdWVfXwAIAwAAAA8AAAAJBQAAAAkGAAAAAAAAAAEFAAAAAQAAAAH5/////P///wsAAAAJCAAAAAkJAAAAAAAAAAUGAAAAMlN1Yk1haW4uQ29kZUl0UmlnaHQuU2RrLlJlZmxlY3Rpb24uUHJvamVjdEZpbGVJbmZvAgAAAAxfcHJvamVjdE5hbWURX3JlbGF0aXZlRmlsZU5hbWUBAQIAAAAGCgAAAAhJbWFnZWtpdAYLAAAADy5cUmVzdENsaWVudC5jcwEIAAAAAQAAAAH0/////P///xgAAAAJDQAAAAkOAAAAAAAAAAEJAAAABgAAAAkKAAAABhAAAAAPLlxSZXN0Q2xpZW50LmNzAQ0AAAABAAAAAe/////8////IwAAAAkSAAAACRMAAAD/////AQ4AAAAGAAAACQoAAAAGFQAAAA8uXFJlc3RDbGllbnQuY3MFEgAAAC9TdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5SZWZsZWN0aW9uLlZhcmlhYmxlSW5mbwQAAAAFX25hbWUPX3JldHVyblR5cGVJbmZvB19wYXJlbnQKX3N0YXRlbWVudAEEBAQxU3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuUmVmbGVjdGlvbi5SZXR1cm5UeXBlSW5mbwIAAAAtU3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuUmVmbGVjdGlvbi5NZXRob2RJbmZvAgAAADBTdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5SZWZsZWN0aW9uLlN0YXRlbWVudEluZm8CAAAAAgAAAAYWAAAABmFwSXVybAkXAAAACRgAAAAJGQAAAAETAAAABgAAAAkKAAAABhsAAAAPLlxSZXN0Q2xpZW50LmNzDBwAAABgU3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuQ29yZSwgVmVyc2lvbj0xLjEuMjIuMCwgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj03OWJjMGRiOTc0MGE1ZjA0BRcAAAAxU3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuUmVmbGVjdGlvbi5SZXR1cm5UeXBlSW5mbwYAAAAFX3R5cGUUX3BvaW50ZXJOZXN0aW5nTGV2ZWwQX2FycmF5RGltZW5zaW9ucwxfcHJvamVjdEZpbGURX2dlbmVyaWNBcmd1bWVudHMTX2Z1bGx5UXVhbGlmaWVkTmFtZQQABwQEATFTdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5Db3JlLlJlZmxlY3Rpb24uSVR5cGVJbmZvHAAAAAgIMlN1Yk1haW4uQ29kZUl0UmlnaHQuU2RrLlJlZmxlY3Rpb24uUHJvamVjdEZpbGVJbmZvAgAAADlTdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5Db3JlLlJlZmxlY3Rpb24uSVJldHVyblR5cGVJbmZvW10cAAAAAgAAAAoAAAAACgkdAAAACR4AAAAGHwAAAA1TeXN0ZW0uU3RyaW5nBRgAAAAtU3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuUmVmbGVjdGlvbi5NZXRob2RJbmZvBwAAAAVfbmFtZQdfcGFyZW50C19yZXR1cm5UeXBlDF9wcm9qZWN0RmlsZQ5fY2FzZVNlbnNpdGl2ZQpfbW9kaWZpZXJzC19wYXJhbWV0ZXJzAQQEBAAEBCxTdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5SZWZsZWN0aW9uLkNsYXNzSW5mbwIAAAAxU3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuUmVmbGVjdGlvbi5SZXR1cm5UeXBlSW5mbwIAAAAyU3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuUmVmbGVjdGlvbi5Qcm9qZWN0RmlsZUluZm8CAAAAATtTdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5Db3JlLlJlZmxlY3Rpb24uTWVtYmVySW5mb01vZGlmaWVycxwAAAA4U3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuQ29yZS5SZWZsZWN0aW9uLklQYXJhbWV0ZXJJbmZvW10cAAAAAgAAAAYgAAAAFWdldFJlbW90ZUZpbGVNZXRhRGF0YQkhAAAACSIAAAAJIwAAAAEF3P///ztTdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5Db3JlLlJlZmxlY3Rpb24uTWVtYmVySW5mb01vZGlmaWVycwEAAAAHdmFsdWVfXwAIHAAAAAIAAAAJJQAAAAUZAAAAMFN1Yk1haW4uQ29kZUl0UmlnaHQuU2RrLlJlZmxlY3Rpb24uU3RhdGVtZW50SW5mbwQAAAAYQmxvY2tJbmZvK19zdGF0ZW1lbnRUeXBlFUJsb2NrSW5mbytfbWVtYmVySW5mbxFCbG9ja0luZm8rX3BhcmVudBBCbG9ja0luZm8rX2luZGV4BAQEADBTdWJNYWluLkNvZGVPYmplY3RNb2RlbC5SZWZsZWN0aW9uLlN0YXRlbWVudFR5cGUDAAAALVN1Yk1haW4uQ29kZUl0UmlnaHQuU2RrLlJlZmxlY3Rpb24uTWV0aG9kSW5mbwIAAAA2U3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuQ29yZS5SZWZsZWN0aW9uLklTdGF0ZW1lbnRJbmZvHAAAAAgCAAAABdr///8wU3ViTWFpbi5Db2RlT2JqZWN0TW9kZWwuUmVmbGVjdGlvbi5TdGF0ZW1lbnRUeXBlAQAAAAd2YWx1ZV9fAAgDAAAAAwAAAAknAAAACgEAAAABHQAAAAYAAAAJCgAAAAYpAAAADy5cUmVzdENsaWVudC5jcwceAAAAAAEAAAAAAAAABDdTdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5Db3JlLlJlZmxlY3Rpb24uSVJldHVyblR5cGVJbmZvHAAAAAUhAAAALFN1Yk1haW4uQ29kZUl0UmlnaHQuU2RrLlJlZmxlY3Rpb24uQ2xhc3NJbmZvCAAAAAVfbmFtZQpfY2xhc3NUeXBlB19wYXJlbnQOX25hbWVzcGFjZUluZm8OX2Nhc2VTZW5zaXRpdmUKX21vZGlmaWVycwxfcHJvamVjdE5hbWUNX3Byb2plY3RGaWxlcwEEBAQABAEENVN1Yk1haW4uQ29kZUl0UmlnaHQuU2RrLkNvcmUuUmVmbGVjdGlvbi5DbGFzc0luZm9UeXBlHAAAADFTdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5Db3JlLlJlZmxlY3Rpb24uSVR5cGVJbmZvHAAAADBTdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5SZWZsZWN0aW9uLk5hbWVzcGFjZUluZm8CAAAAATJTdWJNYWluLkNvZGVPYmplY3RNb2RlbC5SZWZsZWN0aW9uLk1lbWJlck1vZGlmaWVycwMAAAA6U3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuQ29yZS5SZWZsZWN0aW9uLklQcm9qZWN0RmlsZUluZm9bXRwAAAACAAAABioAAAAKUmVzdENsaWVudAXV////NVN1Yk1haW4uQ29kZUl0UmlnaHQuU2RrLkNvcmUuUmVmbGVjdGlvbi5DbGFzc0luZm9UeXBlAQAAAAd2YWx1ZV9fAAgcAAAAAAAAAAoJLAAAAAEF0////zJTdWJNYWluLkNvZGVPYmplY3RNb2RlbC5SZWZsZWN0aW9uLk1lbWJlck1vZGlmaWVycwEAAAAHdmFsdWVfXwAIAwAAAAIAAAAJCgAAAAkvAAAAASIAAAAXAAAACgAAAAAKCSMAAAAJMQAAAAYyAAAANXtBQzczREM2MS05OTkxLTRBMTUtQjg0NC0yNTMyREU0MkFCOER9LlJlc3VsdE1ldGFEYXRhASMAAAAGAAAACQoAAAAGNAAAAA8uXFJlc3RDbGllbnQuY3MHJQAAAAABAAAAAQAAAAQ2U3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuQ29yZS5SZWZsZWN0aW9uLklQYXJhbWV0ZXJJbmZvHAAAAAk1AAAAAScAAAAYAAAACSAAAAAJNwAAAAk4AAAACTkAAAABAcb////c////AgAAAAk7AAAABSwAAAAwU3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuUmVmbGVjdGlvbi5OYW1lc3BhY2VJbmZvAgAAABNfZnVsbHlRdWFsaWZpZWROYW1lCV9wcm9qZWN0cwEENlN1Yk1haW4uQ29kZUl0UmlnaHQuU2RrLkNvcmUuUmVmbGVjdGlvbi5JUHJvamVjdEluZm9bXRwAAAACAAAABjwAAAAISW1hZ2VraXQJPQAAAAcvAAAAAAEAAAABAAAABDhTdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5Db3JlLlJlZmxlY3Rpb24uSVByb2plY3RGaWxlSW5mbxwAAAAJPgAAAAcxAAAAAAEAAAAAAAAABDdTdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5Db3JlLlJlZmxlY3Rpb24uSVJldHVyblR5cGVJbmZvHAAAAAU1AAAAMFN1Yk1haW4uQ29kZUl0UmlnaHQuU2RrLlJlZmxlY3Rpb24uUGFyYW1ldGVySW5mbwMAAAAFX25hbWUPX3JldHVyblR5cGVJbmZvB19wYXJlbnQBBAQxU3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuUmVmbGVjdGlvbi5SZXR1cm5UeXBlSW5mbwIAAAAtU3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuUmVmbGVjdGlvbi5NZXRob2RJbmZvAgAAAAIAAAAGPwAAAAN1cmwJQAAAAAkYAAAAATcAAAAhAAAABkIAAAAKUmVzdENsaWVudAG9////1f///wAAAAAKCUQAAAABAbv////T////AgAAAAkKAAAACUcAAAABOAAAABcAAAAKAAAAAAoJOQAAAAlJAAAACTIAAAABOQAAAAYAAAAJCgAAAAZMAAAADy5cUmVzdENsaWVudC5jcwc7AAAAAAEAAAABAAAABDZTdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5Db3JlLlJlZmxlY3Rpb24uSVBhcmFtZXRlckluZm8cAAAACU0AAAAHPQAAAAABAAAAAQAAAAQ0U3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuQ29yZS5SZWZsZWN0aW9uLklQcm9qZWN0SW5mbxwAAAAJTgAAAAE+AAAABgAAAAkKAAAABlAAAAAPLlxSZXN0Q2xpZW50LmNzAUAAAAAXAAAACgAAAAAKCSMAAAAJUgAAAAkfAAAAAUQAAAAsAAAACTwAAAAJVQAAAAdHAAAAAAEAAAABAAAABDhTdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5Db3JlLlJlZmxlY3Rpb24uSVByb2plY3RGaWxlSW5mbxwAAAAJVgAAAAdJAAAAAAEAAAAAAAAABDdTdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5Db3JlLlJlZmxlY3Rpb24uSVJldHVyblR5cGVJbmZvHAAAAAFNAAAANQAAAAk/AAAACVgAAAAJJwAAAAVOAAAALlN1Yk1haW4uQ29kZUl0UmlnaHQuU2RrLlJlZmxlY3Rpb24uUHJvamVjdEluZm8BAAAABV9uYW1lAQIAAAAJCgAAAAdSAAAAAAEAAAAAAAAABDdTdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5Db3JlLlJlZmxlY3Rpb24uSVJldHVyblR5cGVJbmZvHAAAAAdVAAAAAAEAAAABAAAABDRTdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5Db3JlLlJlZmxlY3Rpb24uSVByb2plY3RJbmZvHAAAAAlbAAAAAVYAAAAGAAAACQoAAAAGXQAAAA8uXFJlc3RDbGllbnQuY3MBWAAAABcAAAAKAAAAAAoJOQAAAAlfAAAACR8AAAABWwAAAE4AAAAJCgAAAAdfAAAAAAEAAAAAAAAABDdTdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5Db3JlLlJlZmxlY3Rpb24uSVJldHVyblR5cGVJbmZvHAAAAAsAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= - - - - - AAEAAAD/////AQAAAAAAAAAMAgAAAGBTdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5Db3JlLCBWZXJzaW9uPTEuMS4yMi4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPTc5YmMwZGI5NzQwYTVmMDQFAQAAADhTdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5Db3JlLkNvbGxlY3Rpb25zLlJ1bGVzQ29sbGVjdGlvbgMAAAANX2NvbHVtblNvcnRlcgZfY291bnQKSW5uZXJBcnJheQQABD9TdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5Db3JlLkNvbGxlY3Rpb25zLlJ1bGVzQ29sbGVjdGlvbitTb3J0ZXICAAAACCpTdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5Db3JlLlJ1bGVzLklSdWxlW10CAAAAAgAAAAkDAAAABQAAAAkEAAAABQMAAAA/U3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuQ29yZS5Db2xsZWN0aW9ucy5SdWxlc0NvbGxlY3Rpb24rU29ydGVyAQAAAAxDb2x1bW5Ub1NvcnQBAgAAAAYFAAAAAAcEAAAAAAEAAABkAAAABChTdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5Db3JlLlJ1bGVzLklSdWxlAgAAAAkGAAAACQcAAAAJCAAAAAkJAAAACQoAAAANXwwLAAAAaVN1Yk1haW4uQ29kZUl0UmlnaHQuUnVsZXMuUGVyZm9ybWFuY2UsIFZlcnNpb249MS4wLjAuMTQsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49MTBjYmVjNTdjZjEwZWFjYgwMAAAAXFN1Yk1haW4uQ29kZUl0UmlnaHQuU2RrLCBWZXJzaW9uPTEuMS4zNi4yMCwgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj0xM2Y4NzgyYzBjODhiNTEwDA0AAABmU3ViTWFpbi5Db2RlSXRSaWdodC5Db2RlT2JqZWN0TW9kZWwsIFZlcnNpb249Mi4yLjAuMCwgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1iYTk2NGJjOWFkZjFlMTg5BQYAAAA4U3ViTWFpbi5Db2RlSXRSaWdodC5SdWxlcy5QZXJmb3JtYW5jZS5SZW1vdmVVbnVzZWRMb2NhbHMjAAAAFF91bnVzZWRMb2NhbFZhcmlhYmxlCF90YXJnZXRzCl9sYW5ndWFnZXMLX2NhbkNvcnJlY3QdX2RlZmF1bHRDb3JyZWN0aW9uT3B0aW9uSW5kZXgMX3Byb2plY3ROYW1lI1N1Yk1haW5QZXJmb3JtYW5jZVJ1bGVCYXNlK190YXJnZXRzJVN1Yk1haW5QZXJmb3JtYW5jZVJ1bGVCYXNlK19sYW5ndWFnZXMmU3ViTWFpblBlcmZvcm1hbmNlUnVsZUJhc2UrX2NhbkNvcnJlY3Q4U3ViTWFpblBlcmZvcm1hbmNlUnVsZUJhc2UrX2RlZmF1bHRDb3JyZWN0aW9uT3B0aW9uSW5kZXgnU3ViTWFpblBlcmZvcm1hbmNlUnVsZUJhc2UrX3Byb2plY3ROYW1lGFN1Yk1haW5SdWxlQmFzZStfdGFyZ2V0cxpTdWJNYWluUnVsZUJhc2UrX2xhbmd1YWdlcxtTdWJNYWluUnVsZUJhc2UrX2NhbkNvcnJlY3QtU3ViTWFpblJ1bGVCYXNlK19kZWZhdWx0Q29ycmVjdGlvbk9wdGlvbkluZGV4HFN1Yk1haW5SdWxlQmFzZStfcHJvamVjdE5hbWURUnVsZUJhc2UrX3RhcmdldHMTUnVsZUJhc2UrX2xhbmd1YWdlcxRSdWxlQmFzZStfY2FuQ29ycmVjdCZSdWxlQmFzZStfZGVmYXVsdENvcnJlY3Rpb25PcHRpb25JbmRleBVSdWxlQmFzZStfcHJvamVjdE5hbWUWQWJzdHJhY3RSdWxlQmFzZStfbmFtZRdBYnN0cmFjdFJ1bGVCYXNlK190aXRsZRpBYnN0cmFjdFJ1bGVCYXNlK19zZXZlcml0eRhBYnN0cmFjdFJ1bGVCYXNlK19zdGF0dXMYQWJzdHJhY3RSdWxlQmFzZStfc2NvcGVzGUFic3RyYWN0UnVsZUJhc2UrX2VsZW1lbnQZQWJzdHJhY3RSdWxlQmFzZStfdGFyZ2V0cxtBYnN0cmFjdFJ1bGVCYXNlK19sYW5ndWFnZXMcQWJzdHJhY3RSdWxlQmFzZStfY2FuQ29ycmVjdBZBYnN0cmFjdFJ1bGVCYXNlK19ub3RlLkFic3RyYWN0UnVsZUJhc2UrX2RlZmF1bHRDb3JyZWN0aW9uT3B0aW9uSW5kZXgdQWJzdHJhY3RSdWxlQmFzZStfcHJvamVjdE5hbWUeQWJzdHJhY3RSdWxlQmFzZStfcmVsYXRpdmVQYXRoIEFic3RyYWN0UnVsZUJhc2UrX2lzU3R5bGVDb3BSdWxlBAQEAAABBAQAAAEEBAAAAQQEAAABAQEEBAQEBAQABAABAQAvU3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuUmVmbGVjdGlvbi5WYXJpYWJsZUluZm8MAAAALlN1Yk1haW4uQ29kZUl0UmlnaHQuU2RrLkNvcmUuUnVsZXMuUnVsZVRhcmdldHMCAAAALFN1Yk1haW4uQ29kZU9iamVjdE1vZGVsLlJlZmxlY3Rpb24uTGFuZ3VhZ2VzDQAAAAEILlN1Yk1haW4uQ29kZUl0UmlnaHQuU2RrLkNvcmUuUnVsZXMuUnVsZVRhcmdldHMCAAAALFN1Yk1haW4uQ29kZU9iamVjdE1vZGVsLlJlZmxlY3Rpb24uTGFuZ3VhZ2VzDQAAAAEILlN1Yk1haW4uQ29kZUl0UmlnaHQuU2RrLkNvcmUuUnVsZXMuUnVsZVRhcmdldHMCAAAALFN1Yk1haW4uQ29kZU9iamVjdE1vZGVsLlJlZmxlY3Rpb24uTGFuZ3VhZ2VzDQAAAAEILlN1Yk1haW4uQ29kZUl0UmlnaHQuU2RrLkNvcmUuUnVsZXMuUnVsZVRhcmdldHMCAAAALFN1Yk1haW4uQ29kZU9iamVjdE1vZGVsLlJlZmxlY3Rpb24uTGFuZ3VhZ2VzDQAAAAEIMFN1Yk1haW4uQ29kZUl0UmlnaHQuU2RrLkNvcmUuUnVsZXMuU2V2ZXJpdHlMZXZlbAIAAAAvU3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuQ29yZS5SdWxlcy5BY3RpdmVTdGF0dXMCAAAALVN1Yk1haW4uQ29kZUl0UmlnaHQuU2RrLkNvcmUuUnVsZXMuUnVsZVNjb3BlcwIAAAAtU3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuUmVmbGVjdGlvbi5NZXRob2RJbmZvDAAAAC5TdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5Db3JlLlJ1bGVzLlJ1bGVUYXJnZXRzAgAAACxTdWJNYWluLkNvZGVPYmplY3RNb2RlbC5SZWZsZWN0aW9uLkxhbmd1YWdlcw0AAAABJ1N1Yk1haW4uQ29kZUl0UmlnaHQuU2RrLkNvcmUuUnVsZXMuTm90ZQIAAAAIDwsAAAAJDgAAAAXx////LlN1Yk1haW4uQ29kZUl0UmlnaHQuU2RrLkNvcmUuUnVsZXMuUnVsZVRhcmdldHMBAAAAB3ZhbHVlX18ACQIAAAAAYAAAAAAAAAXw////LFN1Yk1haW4uQ29kZU9iamVjdE1vZGVsLlJlZmxlY3Rpb24uTGFuZ3VhZ2VzAQAAAAd2YWx1ZV9fAAgNAAAAAwAAAAAAAAAABhEAAAALQ29uc29sZUFwcDEB7v////H///8AYAAAAAAAAAHt////8P///wMAAAAAAAAAAAkRAAAAAez////x////AGAAAAAAAAAB6/////D///8DAAAAAAAAAAAJEQAAAAHq////8f///wBgAAAAAAAAAen////w////AwAAAAAAAAAACREAAAAGGAAAAB5NZXRob2QgLT4gUmVtb3ZlIHVudXNlZCBsb2NhbHMGGQAAABRSZW1vdmUgdW51c2VkIGxvY2FscwXm////MFN1Yk1haW4uQ29kZUl0UmlnaHQuU2RrLkNvcmUuUnVsZXMuU2V2ZXJpdHlMZXZlbAEAAAAHdmFsdWVfXwAIAgAAAAIAAAAF5f///y9TdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5Db3JlLlJ1bGVzLkFjdGl2ZVN0YXR1cwEAAAAHdmFsdWVfXwAIAgAAAAEAAAAF5P///y1TdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5Db3JlLlJ1bGVzLlJ1bGVTY29wZXMBAAAAB3ZhbHVlX18ACAIAAAD/nxUACR0AAAAB4v////H///8AYAAAAAAAAAHh////8P///wMAAAAACgAAAAAJEQAAAAYhAAAADC5cUHJvZ3JhbS5jcwIAAAAMIgAAAGRTdWJNYWluLkNvZGVJdFJpZ2h0LlJ1bGVzLk5hbWluZywgVmVyc2lvbj0xLjAuMC4xMSwgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj0wYmVhNGY3YjdiOGVhZGI2DCMAAABJU3lzdGVtLCBWZXJzaW9uPTQuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjc3YTVjNTYxOTM0ZTA4OQUHAAAAQlN1Yk1haW4uQ29kZUl0UmlnaHQuUnVsZXMuTmFtaW5nLklkZW50aWZpZXJzU2hvdWxkQmVDYXNlZENvcnJlY3RseSkAAAAPX2lkZW50aWZpZXJDYXNlFV9wcm9jZXNzRXZlbnRIYW5kbGVycw5fZXhjbHVkZWRXb3JkcxVfY2FuQ29ycmVjdFdhc0NoYW5nZWQTX3VzZXJDb3JyZWN0T3B0aW9ucwhfdGFyZ2V0cwpfbGFuZ3VhZ2VzC19jYW5Db3JyZWN0HV9kZWZhdWx0Q29ycmVjdGlvbk9wdGlvbkluZGV4DF9wcm9qZWN0TmFtZSRTdWJNYWluTmFtaW5nUnVsZUJhc2UrX2V4Y2x1ZGVkV29yZHMrU3ViTWFpbk5hbWluZ1J1bGVCYXNlK19jYW5Db3JyZWN0V2FzQ2hhbmdlZClTdWJNYWluTmFtaW5nUnVsZUJhc2UrX3VzZXJDb3JyZWN0T3B0aW9ucx5TdWJNYWluTmFtaW5nUnVsZUJhc2UrX3RhcmdldHMgU3ViTWFpbk5hbWluZ1J1bGVCYXNlK19sYW5ndWFnZXMhU3ViTWFpbk5hbWluZ1J1bGVCYXNlK19jYW5Db3JyZWN0M1N1Yk1haW5OYW1pbmdSdWxlQmFzZStfZGVmYXVsdENvcnJlY3Rpb25PcHRpb25JbmRleCJTdWJNYWluTmFtaW5nUnVsZUJhc2UrX3Byb2plY3ROYW1lHU5hbWluZ1J1bGVCYXNlK19leGNsdWRlZFdvcmRzJE5hbWluZ1J1bGVCYXNlK19jYW5Db3JyZWN0V2FzQ2hhbmdlZBtOYW1pbmdSdWxlQmFzZStfZXhjbHVkZUxpc3QiTmFtaW5nUnVsZUJhc2UrX3VzZXJDb3JyZWN0T3B0aW9ucxdOYW1pbmdSdWxlQmFzZStfdGFyZ2V0cxlOYW1pbmdSdWxlQmFzZStfbGFuZ3VhZ2VzGk5hbWluZ1J1bGVCYXNlK19jYW5Db3JyZWN0LE5hbWluZ1J1bGVCYXNlK19kZWZhdWx0Q29ycmVjdGlvbk9wdGlvbkluZGV4G05hbWluZ1J1bGVCYXNlK19wcm9qZWN0TmFtZRZBYnN0cmFjdFJ1bGVCYXNlK19uYW1lF0Fic3RyYWN0UnVsZUJhc2UrX3RpdGxlGkFic3RyYWN0UnVsZUJhc2UrX3NldmVyaXR5GEFic3RyYWN0UnVsZUJhc2UrX3N0YXR1cxhBYnN0cmFjdFJ1bGVCYXNlK19zY29wZXMZQWJzdHJhY3RSdWxlQmFzZStfZWxlbWVudBlBYnN0cmFjdFJ1bGVCYXNlK190YXJnZXRzG0Fic3RyYWN0UnVsZUJhc2UrX2xhbmd1YWdlcxxBYnN0cmFjdFJ1bGVCYXNlK19jYW5Db3JyZWN0FkFic3RyYWN0UnVsZUJhc2UrX25vdGUuQWJzdHJhY3RSdWxlQmFzZStfZGVmYXVsdENvcnJlY3Rpb25PcHRpb25JbmRleB1BYnN0cmFjdFJ1bGVCYXNlK19wcm9qZWN0TmFtZR5BYnN0cmFjdFJ1bGVCYXNlK19yZWxhdGl2ZVBhdGggQWJzdHJhY3RSdWxlQmFzZStfaXNTdHlsZUNvcFJ1bGUEAAYABAQEAAABBgAEBAQAAAEGAAEEBAQAAAEBAQQEBAQEBAAEAAEBACtTdWJNYWluLkNvZGVJdFJpZ2h0LlJ1bGVzLk5hbWluZy5DYXNlT3B0aW9uIgAAAAEBL1N5c3RlbS5Db2xsZWN0aW9ucy5TcGVjaWFsaXplZC5TdHJpbmdDb2xsZWN0aW9uIwAAAC5TdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5Db3JlLlJ1bGVzLlJ1bGVUYXJnZXRzAgAAACxTdWJNYWluLkNvZGVPYmplY3RNb2RlbC5SZWZsZWN0aW9uLkxhbmd1YWdlcw0AAAABCAEvU3lzdGVtLkNvbGxlY3Rpb25zLlNwZWNpYWxpemVkLlN0cmluZ0NvbGxlY3Rpb24jAAAALlN1Yk1haW4uQ29kZUl0UmlnaHQuU2RrLkNvcmUuUnVsZXMuUnVsZVRhcmdldHMCAAAALFN1Yk1haW4uQ29kZU9iamVjdE1vZGVsLlJlZmxlY3Rpb24uTGFuZ3VhZ2VzDQAAAAEIAS9TeXN0ZW0uQ29sbGVjdGlvbnMuU3BlY2lhbGl6ZWQuU3RyaW5nQ29sbGVjdGlvbiMAAAAuU3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuQ29yZS5SdWxlcy5SdWxlVGFyZ2V0cwIAAAAsU3ViTWFpbi5Db2RlT2JqZWN0TW9kZWwuUmVmbGVjdGlvbi5MYW5ndWFnZXMNAAAAAQgwU3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuQ29yZS5SdWxlcy5TZXZlcml0eUxldmVsAgAAAC9TdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5Db3JlLlJ1bGVzLkFjdGl2ZVN0YXR1cwIAAAAtU3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuQ29yZS5SdWxlcy5SdWxlU2NvcGVzAgAAAC1TdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5SZWZsZWN0aW9uLk1ldGhvZEluZm8MAAAALlN1Yk1haW4uQ29kZUl0UmlnaHQuU2RrLkNvcmUuUnVsZXMuUnVsZVRhcmdldHMCAAAALFN1Yk1haW4uQ29kZU9iamVjdE1vZGVsLlJlZmxlY3Rpb24uTGFuZ3VhZ2VzDQAAAAEnU3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuQ29yZS5SdWxlcy5Ob3RlAgAAAAgPIgAAAAXc////K1N1Yk1haW4uQ29kZUl0UmlnaHQuUnVsZXMuTmFtaW5nLkNhc2VPcHRpb24BAAAAB3ZhbHVlX18ACCIAAAACAAAAAAoACSUAAAAB2v////H///8A4BcAAAAAAAHZ////8P///wMAAAABAAAAAAkRAAAACgAJJQAAAAHW////8f///wDgFwAAAAAAAdX////w////AwAAAAEAAAAACREAAAAKAAoJJQAAAAHS////8f///wDgFwAAAAAAAdH////w////AwAAAAEAAAAACREAAAAGMQAAABZNZW1iZXIgLT4gUGFzY2FsIENhc2VkBjIAAAAsTWVtYmVyIGlkZW50aWZpZXJzIHNob3VsZCBiZSBjYXNlZCBjb3JyZWN0bHkBzf///+b///8CAAAAAcz////l////AQAAAAHL////5P////63NQAJNgAAAAHJ////8f///wDgFwAAAAAAAcj////w////AwAAAAEKAAAAAAkRAAAABjoAAAAMLlxQcm9ncmFtLmNzAgAAAAEIAAAABgAAAAk7AAAAAcT////x////AGAAAAAAAAABw/////D///8DAAAAAAAAAAAJEQAAAAHB////8f///wBgAAAAAAAAAcD////w////AwAAAAAAAAAACREAAAABv/////H///8AYAAAAAAAAAG+////8P///wMAAAAAAAAAAAkRAAAAAb3////x////AGAAAAAAAAABvP////D///8DAAAAAAAAAAAJEQAAAAZFAAAAHk1ldGhvZCAtPiBSZW1vdmUgdW51c2VkIGxvY2FscwZGAAAAFFJlbW92ZSB1bnVzZWQgbG9jYWxzAbn////m////AgAAAAG4////5f///wEAAAABt////+T/////nxUACTYAAAABtf////H///8AYAAAAAAAAAG0////8P///wMAAAAACgAAAAAJEQAAAAZOAAAADC5cUHJvZ3JhbS5jcwIAAAABCQAAAAcAAAABsf///9z///8CAAAAAAoACVAAAAABr/////H///8A4BcAAAAAAAGu////8P///wMAAAABAAAAAAkRAAAACgAJUAAAAAGr////8f///wDgFwAAAAAAAar////w////AwAAAAEAAAAACREAAAAKAAoJUAAAAAGn////8f///wDgFwAAAAAAAab////w////AwAAAAEAAAAACREAAAAGXAAAABZNZW1iZXIgLT4gUGFzY2FsIENhc2VkBl0AAAAsTWVtYmVyIGlkZW50aWZpZXJzIHNob3VsZCBiZSBjYXNlZCBjb3JyZWN0bHkBov///+b///8CAAAAAaH////l////AQAAAAGg////5P////63NQAJYQAAAAGe////8f///wDgFwAAAAAAAZ3////w////AwAAAAEKAAAAAAkRAAAABmUAAAAMLlxQcm9ncmFtLmNzAgAAAAEKAAAABgAAAAlmAAAAAZn////x////AGAAAAAAAAABmP////D///8DAAAAAAAAAAAJEQAAAAGW////8f///wBgAAAAAAAAAZX////w////AwAAAAAAAAAACREAAAABlP////H///8AYAAAAAAAAAGT////8P///wMAAAAAAAAAAAkRAAAAAZL////x////AGAAAAAAAAABkf////D///8DAAAAAAAAAAAJEQAAAAZwAAAAHk1ldGhvZCAtPiBSZW1vdmUgdW51c2VkIGxvY2FscwZxAAAAFFJlbW92ZSB1bnVzZWQgbG9jYWxzAY7////m////AgAAAAGN////5f///wEAAAABjP///+T/////nxUACWEAAAABiv////H///8AYAAAAAAAAAGJ////8P///wMAAAAACgAAAAAJEQAAAAZ5AAAADC5cUHJvZ3JhbS5jcwIAAAAFDgAAAC9TdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5SZWZsZWN0aW9uLlZhcmlhYmxlSW5mbwQAAAAFX25hbWUPX3JldHVyblR5cGVJbmZvB19wYXJlbnQKX3N0YXRlbWVudAEEBAQxU3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuUmVmbGVjdGlvbi5SZXR1cm5UeXBlSW5mbwwAAAAtU3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuUmVmbGVjdGlvbi5NZXRob2RJbmZvDAAAADBTdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5SZWZsZWN0aW9uLlN0YXRlbWVudEluZm8MAAAADAAAAAZ6AAAABXRva2VuCXsAAAAJfAAAAAl9AAAABR0AAAAtU3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuUmVmbGVjdGlvbi5NZXRob2RJbmZvBwAAAAVfbmFtZQdfcGFyZW50C19yZXR1cm5UeXBlDF9wcm9qZWN0RmlsZQ5fY2FzZVNlbnNpdGl2ZQpfbW9kaWZpZXJzC19wYXJhbWV0ZXJzAQQEBAAEBCxTdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5SZWZsZWN0aW9uLkNsYXNzSW5mbwwAAAAxU3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuUmVmbGVjdGlvbi5SZXR1cm5UeXBlSW5mbwwAAAAyU3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuUmVmbGVjdGlvbi5Qcm9qZWN0RmlsZUluZm8MAAAAATtTdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5Db3JlLlJlZmxlY3Rpb24uTWVtYmVySW5mb01vZGlmaWVycwIAAAA4U3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuQ29yZS5SZWZsZWN0aW9uLklQYXJhbWV0ZXJJbmZvW10CAAAADAAAAAZ+AAAABE1haW4JfwAAAAmAAAAACYEAAAABBX7///87U3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuQ29yZS5SZWZsZWN0aW9uLk1lbWJlckluZm9Nb2RpZmllcnMBAAAAB3ZhbHVlX18ACAIAAACQAAAACYMAAAAFJQAAAC9TeXN0ZW0uQ29sbGVjdGlvbnMuU3BlY2lhbGl6ZWQuU3RyaW5nQ29sbGVjdGlvbgEAAAAEZGF0YQMcU3lzdGVtLkNvbGxlY3Rpb25zLkFycmF5TGlzdCMAAAAJhAAAAAE2AAAAHQAAAAaFAAAACWdldEJhc2U2NAmGAAAACYcAAAAJiAAAAAEBd////37///+QAAAACgE7AAAADgAAAAaKAAAAGWJhc2U2NEltYWdlUmVwcmVzZW50YXRpb24JiwAAAAmMAAAACY0AAAABUAAAACUAAAAJjgAAAAFhAAAAHQAAAAaPAAAADGdldEJhc2U2NFVSSQmQAAAACZEAAAAJkgAAAAEBbf///37///+QAAAACgFmAAAADgAAAAaUAAAACWNvbnZlcnRlZAmVAAAACZYAAAAJlwAAAAV7AAAAMVN1Yk1haW4uQ29kZUl0UmlnaHQuU2RrLlJlZmxlY3Rpb24uUmV0dXJuVHlwZUluZm8GAAAABV90eXBlFF9wb2ludGVyTmVzdGluZ0xldmVsEF9hcnJheURpbWVuc2lvbnMMX3Byb2plY3RGaWxlEV9nZW5lcmljQXJndW1lbnRzE19mdWxseVF1YWxpZmllZE5hbWUEAAcEBAExU3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuQ29yZS5SZWZsZWN0aW9uLklUeXBlSW5mbwIAAAAICDJTdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5SZWZsZWN0aW9uLlByb2plY3RGaWxlSW5mbwwAAAA5U3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuQ29yZS5SZWZsZWN0aW9uLklSZXR1cm5UeXBlSW5mb1tdAgAAAAwAAAAKAAAAAAoJmAAAAAmZAAAABpoAAAADdmFyAXwAAAAdAAAACX4AAAAJnAAAAAmdAAAACZ4AAAABAWH///9+////kAAAAAmgAAAABX0AAAAwU3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuUmVmbGVjdGlvbi5TdGF0ZW1lbnRJbmZvBAAAABhCbG9ja0luZm8rX3N0YXRlbWVudFR5cGUVQmxvY2tJbmZvK19tZW1iZXJJbmZvEUJsb2NrSW5mbytfcGFyZW50EEJsb2NrSW5mbytfaW5kZXgEBAQAMFN1Yk1haW4uQ29kZU9iamVjdE1vZGVsLlJlZmxlY3Rpb24uU3RhdGVtZW50VHlwZQ0AAAAtU3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuUmVmbGVjdGlvbi5NZXRob2RJbmZvDAAAADZTdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5Db3JlLlJlZmxlY3Rpb24uSVN0YXRlbWVudEluZm8CAAAACAwAAAAFX////zBTdWJNYWluLkNvZGVPYmplY3RNb2RlbC5SZWZsZWN0aW9uLlN0YXRlbWVudFR5cGUBAAAAB3ZhbHVlX18ACA0AAAADAAAACaIAAAAKAAAAAAV/AAAALFN1Yk1haW4uQ29kZUl0UmlnaHQuU2RrLlJlZmxlY3Rpb24uQ2xhc3NJbmZvCAAAAAVfbmFtZQpfY2xhc3NUeXBlB19wYXJlbnQOX25hbWVzcGFjZUluZm8OX2Nhc2VTZW5zaXRpdmUKX21vZGlmaWVycwxfcHJvamVjdE5hbWUNX3Byb2plY3RGaWxlcwEEBAQABAEENVN1Yk1haW4uQ29kZUl0UmlnaHQuU2RrLkNvcmUuUmVmbGVjdGlvbi5DbGFzc0luZm9UeXBlAgAAADFTdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5Db3JlLlJlZmxlY3Rpb24uSVR5cGVJbmZvAgAAADBTdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5SZWZsZWN0aW9uLk5hbWVzcGFjZUluZm8MAAAAATJTdWJNYWluLkNvZGVPYmplY3RNb2RlbC5SZWZsZWN0aW9uLk1lbWJlck1vZGlmaWVycw0AAAA6U3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuQ29yZS5SZWZsZWN0aW9uLklQcm9qZWN0RmlsZUluZm9bXQIAAAAMAAAABqMAAAAHUHJvZ3JhbQVc////NVN1Yk1haW4uQ29kZUl0UmlnaHQuU2RrLkNvcmUuUmVmbGVjdGlvbi5DbGFzc0luZm9UeXBlAQAAAAd2YWx1ZV9fAAgCAAAAAAAAAAoJpQAAAAEFWv///zJTdWJNYWluLkNvZGVPYmplY3RNb2RlbC5SZWZsZWN0aW9uLk1lbWJlck1vZGlmaWVycwEAAAAHdmFsdWVfXwAIDQAAAAgAAAAJEQAAAAmoAAAAAYAAAAB7AAAACgAAAAAKCYEAAAAJqgAAAAarAAAAC1N5c3RlbS5Wb2lkBYEAAAAyU3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuUmVmbGVjdGlvbi5Qcm9qZWN0RmlsZUluZm8CAAAADF9wcm9qZWN0TmFtZRFfcmVsYXRpdmVGaWxlTmFtZQEBDAAAAAkRAAAABq0AAAAMLlxQcm9ncmFtLmNzB4MAAAAAAQAAAAEAAAAENlN1Yk1haW4uQ29kZUl0UmlnaHQuU2RrLkNvcmUuUmVmbGVjdGlvbi5JUGFyYW1ldGVySW5mbwIAAAAJrgAAAASEAAAAHFN5c3RlbS5Db2xsZWN0aW9ucy5BcnJheUxpc3QDAAAABl9pdGVtcwVfc2l6ZQhfdmVyc2lvbgUAAAgICa8AAAABAAAAAQAAAAGGAAAAfwAAAAawAAAAB1Byb2dyYW0BT////1z///8AAAAACgmyAAAAAQFN////Wv///wgAAAAJEQAAAAm1AAAAAYcAAAB7AAAACgAAAAAJtgAAAAmIAAAACbgAAAAGuQAAAAtTeXN0ZW0uQnl0ZQGIAAAAgQAAAAkRAAAABrsAAAAMLlxQcm9ncmFtLmNzAYsAAAB7AAAACgAAAAAKCbwAAAAJvQAAAAa+AAAADVN5c3RlbS5TdHJpbmcBjAAAAB0AAAAJhQAAAAnAAAAACcEAAAAJwgAAAAEBPf///37///+QAAAACgGNAAAAfQAAAAE8////X////wMAAAAJxQAAAAoCAAAAAY4AAACEAAAACcYAAAABAAAAAQAAAAGQAAAAfwAAAAbHAAAAB1Byb2dyYW0BOP///1z///8AAAAACgnJAAAAAQE2////Wv///wgAAAAJEQAAAAnMAAAAAZEAAAB7AAAACgAAAAAKCZIAAAAJzgAAAAbPAAAAA1VyaQGSAAAAgQAAAAkRAAAABtEAAAAMLlxQcm9ncmFtLmNzAZUAAAB7AAAACgAAAAAKCdIAAAAJ0wAAAAbUAAAAA3ZhcgGWAAAAHQAAAAmPAAAACdYAAAAJ1wAAAAnYAAAAAQEn////fv///5AAAAAKAZcAAAB9AAAAASb///9f////AwAAAAnbAAAACgIAAAABmAAAAIEAAAAJEQAAAAbdAAAADC5cUHJvZ3JhbS5jcweZAAAAAAEAAAAAAAAABDdTdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5Db3JlLlJlZmxlY3Rpb24uSVJldHVyblR5cGVJbmZvAgAAAAGcAAAAfwAAAAbeAAAAB1Byb2dyYW0BIf///1z///8AAAAACgngAAAAAQEf////Wv///wgAAAAJEQAAAAnjAAAAAZ0AAAB7AAAACgAAAAAKCZ4AAAAJ5QAAAAmrAAAAAZ4AAACBAAAACREAAAAG6AAAAAwuXFByb2dyYW0uY3MHoAAAAAABAAAAAQAAAAQ2U3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuQ29yZS5SZWZsZWN0aW9uLklQYXJhbWV0ZXJJbmZvAgAAAAnpAAAAAaIAAAAdAAAACX4AAAAJ6wAAAAnsAAAACe0AAAABARL///9+////kAAAAAnvAAAABaUAAAAwU3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuUmVmbGVjdGlvbi5OYW1lc3BhY2VJbmZvAgAAABNfZnVsbHlRdWFsaWZpZWROYW1lCV9wcm9qZWN0cwEENlN1Yk1haW4uQ29kZUl0UmlnaHQuU2RrLkNvcmUuUmVmbGVjdGlvbi5JUHJvamVjdEluZm9bXQIAAAAMAAAABvAAAAALQ29uc29sZUFwcDEJ8QAAAAeoAAAAAAEAAAABAAAABDhTdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5Db3JlLlJlZmxlY3Rpb24uSVByb2plY3RGaWxlSW5mbwIAAAAJ8gAAAAeqAAAAAAEAAAAAAAAABDdTdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5Db3JlLlJlZmxlY3Rpb24uSVJldHVyblR5cGVJbmZvAgAAAAWuAAAAMFN1Yk1haW4uQ29kZUl0UmlnaHQuU2RrLlJlZmxlY3Rpb24uUGFyYW1ldGVySW5mbwMAAAAFX25hbWUPX3JldHVyblR5cGVJbmZvB19wYXJlbnQBBAQxU3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuUmVmbGVjdGlvbi5SZXR1cm5UeXBlSW5mbwwAAAAtU3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuUmVmbGVjdGlvbi5NZXRob2RJbmZvDAAAAAwAAAAG8wAAAARhcmdzCfQAAAAJHQAAABCvAAAABAAAAAb2AAAACUdldEJhc2U2NA0DAbIAAAClAAAACfAAAAAJ+AAAAAe1AAAAAAEAAAABAAAABDhTdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5Db3JlLlJlZmxlY3Rpb24uSVByb2plY3RGaWxlSW5mbwIAAAAJ+QAAAA+2AAAAAQAAAAgBAAAAB7gAAAAAAQAAAAAAAAAEN1N1Yk1haW4uQ29kZUl0UmlnaHQuU2RrLkNvcmUuUmVmbGVjdGlvbi5JUmV0dXJuVHlwZUluZm8CAAAAAbwAAACBAAAACREAAAAG+wAAAAwuXFByb2dyYW0uY3MHvQAAAAABAAAAAAAAAAQ3U3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuQ29yZS5SZWZsZWN0aW9uLklSZXR1cm5UeXBlSW5mbwIAAAABwAAAAH8AAAAG/AAAAAdQcm9ncmFtAQP///9c////AAAAAAoJ/gAAAAEBAf///1r///8IAAAACREAAAAJAQEAAAHBAAAAewAAAAoAAAAACbYAAAAJwgAAAAkEAQAACbkAAAABwgAAAIEAAAAJEQAAAAYHAQAADC5cUHJvZ3JhbS5jcwHFAAAAHQAAAAmFAAAACQkBAAAJCgEAAAkLAQAAAQH0/v//fv///5AAAAAKEMYAAAAEAAAABg0BAAAMR2V0QmFzZTY0VXJpDQMByQAAAKUAAAAJ8AAAAAkPAQAAB8wAAAAAAQAAAAEAAAAEOFN1Yk1haW4uQ29kZUl0UmlnaHQuU2RrLkNvcmUuUmVmbGVjdGlvbi5JUHJvamVjdEZpbGVJbmZvAgAAAAkQAQAAB84AAAAAAQAAAAAAAAAEN1N1Yk1haW4uQ29kZUl0UmlnaHQuU2RrLkNvcmUuUmVmbGVjdGlvbi5JUmV0dXJuVHlwZUluZm8CAAAAAdIAAACBAAAACREAAAAGEgEAAAwuXFByb2dyYW0uY3MH0wAAAAABAAAAAAAAAAQ3U3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuQ29yZS5SZWZsZWN0aW9uLklSZXR1cm5UeXBlSW5mbwIAAAAB1gAAAH8AAAAGEwEAAAdQcm9ncmFtAez+//9c////AAAAAAoJFQEAAAEB6v7//1r///8IAAAACREAAAAJGAEAAAHXAAAAewAAAAoAAAAACgnYAAAACRoBAAAJzwAAAAHYAAAAgQAAAAkRAAAABh0BAAAMLlxQcm9ncmFtLmNzAdsAAAAdAAAACY8AAAAJHwEAAAkgAQAACSEBAAABAd7+//9+////kAAAAAoB4AAAAKUAAAAJ8AAAAAkkAQAAB+MAAAAAAQAAAAEAAAAEOFN1Yk1haW4uQ29kZUl0UmlnaHQuU2RrLkNvcmUuUmVmbGVjdGlvbi5JUHJvamVjdEZpbGVJbmZvAgAAAAklAQAAB+UAAAAAAQAAAAAAAAAEN1N1Yk1haW4uQ29kZUl0UmlnaHQuU2RrLkNvcmUuUmVmbGVjdGlvbi5JUmV0dXJuVHlwZUluZm8CAAAAAekAAACuAAAACfMAAAAJJwEAAAl8AAAAAesAAAB/AAAABikBAAAHUHJvZ3JhbQHW/v//XP///wAAAAAKCSsBAAABAdT+//9a////CAAAAAkRAAAACS4BAAAB7AAAAHsAAAAKAAAAAAoJ7QAAAAkwAQAACasAAAAB7QAAAIEAAAAJEQAAAAYzAQAADC5cUHJvZ3JhbS5jcwfvAAAAAAEAAAABAAAABDZTdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5Db3JlLlJlZmxlY3Rpb24uSVBhcmFtZXRlckluZm8CAAAACTQBAAAH8QAAAAABAAAAAQAAAAQ0U3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuQ29yZS5SZWZsZWN0aW9uLklQcm9qZWN0SW5mbwIAAAAJNQEAAAHyAAAAgQAAAAkRAAAABjcBAAAMLlxQcm9ncmFtLmNzAfQAAAB7AAAACgAAAAAJOAEAAAmBAAAACToBAAAJvgAAAAf4AAAAAAEAAAABAAAABDRTdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5Db3JlLlJlZmxlY3Rpb24uSVByb2plY3RJbmZvAgAAAAk8AQAAAfkAAACBAAAACREAAAAGPgEAAAwuXFByb2dyYW0uY3MB/gAAAKUAAAAJ8AAAAAlAAQAABwEBAAAAAQAAAAEAAAAEOFN1Yk1haW4uQ29kZUl0UmlnaHQuU2RrLkNvcmUuUmVmbGVjdGlvbi5JUHJvamVjdEZpbGVJbmZvAgAAAAlBAQAABwQBAAAAAQAAAAAAAAAEN1N1Yk1haW4uQ29kZUl0UmlnaHQuU2RrLkNvcmUuUmVmbGVjdGlvbi5JUmV0dXJuVHlwZUluZm8CAAAAAQkBAAB/AAAABkIBAAAHUHJvZ3JhbQG9/v//XP///wAAAAAKCUQBAAABAbv+//9a////CAAAAAkRAAAACUcBAAABCgEAAHsAAAAKAAAAAAm2AAAACQsBAAAJSgEAAAm5AAAAAQsBAACBAAAACREAAAAGTQEAAAwuXFByb2dyYW0uY3MHDwEAAAABAAAAAQAAAAQ0U3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuQ29yZS5SZWZsZWN0aW9uLklQcm9qZWN0SW5mbwIAAAAJTgEAAAEQAQAAgQAAAAkRAAAABlABAAAMLlxQcm9ncmFtLmNzARUBAAClAAAACfAAAAAJUgEAAAcYAQAAAAEAAAABAAAABDhTdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5Db3JlLlJlZmxlY3Rpb24uSVByb2plY3RGaWxlSW5mbwIAAAAJUwEAAAcaAQAAAAEAAAAAAAAABDdTdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5Db3JlLlJlZmxlY3Rpb24uSVJldHVyblR5cGVJbmZvAgAAAAEfAQAAfwAAAAZUAQAAB1Byb2dyYW0Bq/7//1z///8AAAAACglWAQAAAQGp/v//Wv///wgAAAAJEQAAAAlZAQAAASABAAB7AAAACgAAAAAKCSEBAAAJWwEAAAnPAAAAASEBAACBAAAACREAAAAGXgEAAAwuXFByb2dyYW0uY3MHJAEAAAABAAAAAQAAAAQ0U3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuQ29yZS5SZWZsZWN0aW9uLklQcm9qZWN0SW5mbwIAAAAJXwEAAAElAQAAgQAAAAkRAAAABmEBAAAMLlxQcm9ncmFtLmNzAScBAAB7AAAACgAAAAAJOAEAAAmeAAAACWQBAAAJvgAAAAErAQAApQAAAAnwAAAACWcBAAAHLgEAAAABAAAAAQAAAAQ4U3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuQ29yZS5SZWZsZWN0aW9uLklQcm9qZWN0RmlsZUluZm8CAAAACWgBAAAHMAEAAAABAAAAAAAAAAQ3U3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuQ29yZS5SZWZsZWN0aW9uLklSZXR1cm5UeXBlSW5mbwIAAAABNAEAAK4AAAAJ8wAAAAlqAQAACaIAAAAFNQEAAC5TdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5SZWZsZWN0aW9uLlByb2plY3RJbmZvAQAAAAVfbmFtZQEMAAAACREAAAAPOAEAAAEAAAAIAQAAAAc6AQAAAAEAAAAAAAAABDdTdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5Db3JlLlJlZmxlY3Rpb24uSVJldHVyblR5cGVJbmZvAgAAAAE8AQAANQEAAAkRAAAAB0ABAAAAAQAAAAEAAAAENFN1Yk1haW4uQ29kZUl0UmlnaHQuU2RrLkNvcmUuUmVmbGVjdGlvbi5JUHJvamVjdEluZm8CAAAACW0BAAABQQEAAIEAAAAJEQAAAAZvAQAADC5cUHJvZ3JhbS5jcwFEAQAApQAAAAnwAAAACXEBAAAHRwEAAAABAAAAAQAAAAQ4U3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuQ29yZS5SZWZsZWN0aW9uLklQcm9qZWN0RmlsZUluZm8CAAAACXIBAAAHSgEAAAABAAAAAAAAAAQ3U3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuQ29yZS5SZWZsZWN0aW9uLklSZXR1cm5UeXBlSW5mbwIAAAABTgEAADUBAAAJEQAAAAdSAQAAAAEAAAABAAAABDRTdWJNYWluLkNvZGVJdFJpZ2h0LlNkay5Db3JlLlJlZmxlY3Rpb24uSVByb2plY3RJbmZvAgAAAAl0AQAAAVMBAACBAAAACREAAAAGdgEAAAwuXFByb2dyYW0uY3MBVgEAAKUAAAAJ8AAAAAl4AQAAB1kBAAAAAQAAAAEAAAAEOFN1Yk1haW4uQ29kZUl0UmlnaHQuU2RrLkNvcmUuUmVmbGVjdGlvbi5JUHJvamVjdEZpbGVJbmZvAgAAAAl5AQAAB1sBAAAAAQAAAAAAAAAEN1N1Yk1haW4uQ29kZUl0UmlnaHQuU2RrLkNvcmUuUmVmbGVjdGlvbi5JUmV0dXJuVHlwZUluZm8CAAAAAV8BAAA1AQAACREAAAAHZAEAAAABAAAAAAAAAAQ3U3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuQ29yZS5SZWZsZWN0aW9uLklSZXR1cm5UeXBlSW5mbwIAAAAHZwEAAAABAAAAAQAAAAQ0U3ViTWFpbi5Db2RlSXRSaWdodC5TZGsuQ29yZS5SZWZsZWN0aW9uLklQcm9qZWN0SW5mbwIAAAAJewEAAAFoAQAAgQAAAAkRAAAABn0BAAAMLlxQcm9ncmFtLmNzAWoBAAB7AAAACgAAAAAJOAEAAAntAAAACYABAAAJvgAAAAFtAQAANQEAAAkRAAAAB3EBAAAAAQAAAAEAAAAENFN1Yk1haW4uQ29kZUl0UmlnaHQuU2RrLkNvcmUuUmVmbGVjdGlvbi5JUHJvamVjdEluZm8CAAAACYMBAAABcgEAAIEAAAAJEQAAAAaFAQAADC5cUHJvZ3JhbS5jcwF0AQAANQEAAAkRAAAAB3gBAAAAAQAAAAEAAAAENFN1Yk1haW4uQ29kZUl0UmlnaHQuU2RrLkNvcmUuUmVmbGVjdGlvbi5JUHJvamVjdEluZm8CAAAACYcBAAABeQEAAIEAAAAJEQAAAAaJAQAADC5cUHJvZ3JhbS5jcwF7AQAANQEAAAkRAAAAB4ABAAAAAQAAAAAAAAAEN1N1Yk1haW4uQ29kZUl0UmlnaHQuU2RrLkNvcmUuUmVmbGVjdGlvbi5JUmV0dXJuVHlwZUluZm8CAAAAAYMBAAA1AQAACREAAAABhwEAADUBAAAJEQAAAAsAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA== - \ No newline at end of file diff --git a/Imagekit.sln b/Imagekit.sln index 84305571..2e968497 100644 --- a/Imagekit.sln +++ b/Imagekit.sln @@ -1,43 +1,27 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 +Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 -VisualStudioVersion = 17.2.32630.192 +VisualStudioVersion = 17.0.31903.59 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Imagekit", "Imagekit\Imagekit.csproj", "{D7929DCF-13EC-4677-9859-D55DA9D752E4}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Imagekit", "src\Imagekit\Imagekit.csproj", "{5816A0C1-3BA1-454E-8D08-85B23DEF309D}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C4C9DA70-E3C7-4848-AB58-E93762408560}" - ProjectSection(SolutionItems) = preProject - .editorconfig = .editorconfig - EndProjectSection -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Imagekit.UnitTests", "Imagekit.UnitTests\Imagekit.UnitTests.csproj", "{B459E977-A7C2-47CB-A743-2F0AAFCE8178}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Imagekit.Tests", "src\Imagekit.Tests\Imagekit.Tests.csproj", "{0732C8A6-7313-4C33-AE2E-FFAA82EFB481}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {D7929DCF-13EC-4677-9859-D55DA9D752E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D7929DCF-13EC-4677-9859-D55DA9D752E4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D7929DCF-13EC-4677-9859-D55DA9D752E4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D7929DCF-13EC-4677-9859-D55DA9D752E4}.Release|Any CPU.Build.0 = Release|Any CPU - {B459E977-A7C2-47CB-A743-2F0AAFCE8178}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B459E977-A7C2-47CB-A743-2F0AAFCE8178}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B459E977-A7C2-47CB-A743-2F0AAFCE8178}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B459E977-A7C2-47CB-A743-2F0AAFCE8178}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {CCE1EF90-4EA0-4458-90C1-7F408AE6E292} - EndGlobalSection - GlobalSection(MonoDevelopProperties) = preSolution - Policies = $0 - $0.DotNetNamingPolicy = $1 - $1.DirectoryNamespaceAssociation = PrefixedHierarchical - $0.StandardHeader = $2 - $0.VersionControlPolicy = $3 + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5816A0C1-3BA1-454E-8D08-85B23DEF309D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5816A0C1-3BA1-454E-8D08-85B23DEF309D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5816A0C1-3BA1-454E-8D08-85B23DEF309D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5816A0C1-3BA1-454E-8D08-85B23DEF309D}.Release|Any CPU.Build.0 = Release|Any CPU + {0732C8A6-7313-4C33-AE2E-FFAA82EFB481}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0732C8A6-7313-4C33-AE2E-FFAA82EFB481}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0732C8A6-7313-4C33-AE2E-FFAA82EFB481}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0732C8A6-7313-4C33-AE2E-FFAA82EFB481}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/Imagekit.sln.CodeItRight.xml b/Imagekit.sln.CodeItRight.xml deleted file mode 100644 index ee2ebdb7..00000000 --- a/Imagekit.sln.CodeItRight.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - *.min.js - jquery*.js - - diff --git a/Imagekit/Constant/UrlHandler.cs b/Imagekit/Constant/UrlHandler.cs deleted file mode 100644 index 07ef3c3b..00000000 --- a/Imagekit/Constant/UrlHandler.cs +++ /dev/null @@ -1,42 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - -namespace Imagekit.Constant -{ - public static class UrlHandler - { - public const string MediaAPIBaseUrl = "https://api.imagekit.io/"; - public const string UploadAPIBaseUrl = "https://upload.imagekit.io/"; - public const string UploadFile = @"api/v1/files/upload"; - public const string UpdateFileRequest = @"v1/files/{0}/details"; - public const string GetFileRequest = @"v1/files/?{0}"; - public const string GetPurge = @"v1/files/purge"; - public const string GetPurgeStatus = @"v1/files/purge/{0}"; - public const string GetFileDetails = @"v1/files/{0}/details"; - public const string DeleteFile = @"v1/files/{0}/"; - public const string BulkDelete = @"v1/files/batch/deleteByfileIds"; - public const string GetMetaData = @"v1/files/{0}/metadata"; - public const string GetRemoteData = @"v1/metadata?url={0}"; - public const string RemoveTags = @"v1/files/removeTags"; - public const string AddTags = @"v1/files/addTags"; - public const string RemoveAITags = @"v1/files/removeAITags"; - public const string CustomMetadataFields = @"v1/customMetadataFields?includeDeleted={0}"; - public const string CreareCustomMetaDataFields = @"v1/customMetadataFields"; - public const string DeleteCustomMetaDataFields = @"v1/customMetadataFields/{0}"; - public const string UpdateCustomMetadataFields = @"v1/customMetadataFields/{0}"; - public const string DeleteVesrion = @"v1/files/{0}/versions/{1}"; - public const string CopyFile = @"v1/files/copy"; - public const string MoveFile = @"v1/files/move"; - public const string RenameFile = @"v1/files/rename"; - public const string RestoreVesrion = @"v1/files/{0}/versions/{1}/restore"; - public const string CreateFolder = @"v1/folder/"; - public const string DeleteFolder = @"v1/folder/"; - public const string CopyFolder = @"v1/bulkJobs/copyFolder"; - public const string MoveFolder = @"v1/bulkJobs/moveFolder"; - public const string GetJobStatus = @"v1/bulkJobs/{0}"; - public const string GetFileVersion = @"v1/files/{0}/versions"; - public const string GetFileVersionDetail = @"v1/files/{0}/versions/{1}"; - public const string GetBoundaryString = "ImageKit-dLV9Wyq26L"; - } -} \ No newline at end of file diff --git a/Imagekit/Constant/errorMessages.cs b/Imagekit/Constant/errorMessages.cs deleted file mode 100644 index 3e24fa51..00000000 --- a/Imagekit/Constant/errorMessages.cs +++ /dev/null @@ -1,73 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - -namespace Imagekit.Constant -{ - public static class ErrorMessages - { - public const string MandatoryInitializationMissing = "{ \"message\": \"Missing publicKey or privateKey or urlEndpoint during Imagekit initialization\", \"help\": \"\" }"; - public const string MandatoryPublicKeyMissing = "{ \"message\": \"Missing publicKey during Imagekit initialization\", \"help\": \"\" }"; - public const string PrivateKeyMissing = "{ \"message\": \"Missing privateKey during Imagekit initialization\", \"help\": \"\" }"; - public const string MandatoryUrlEndpointKeyMissing = "{ \"message\": \"Missing urlEndpoint during Imagekit initialization\", \"help\": \"\" }"; - public const string InvalidTransformationPosition = "{ \"message\": \"Invalid transformationPosition parameter\", \"help\": \"\" }"; - public const string CachePurgeUrlMissing = "{ \"message\": \"Missing URL parameter for this request\", \"help\": \"\" }"; - public const string CachePurgeStatusIdMissing = "{ message: \"Missing Request ID parameter for this request\", \"help\": \"\" }"; - public const string FileIdMissing = "{ \"message\": \"Missing File ID parameter for this request\", \"help\": \"\" }"; - public const string InvalidUri = "{ \"message\": \"Invalid URI\", \"help\": \"Only HTTP or HTTPS Type Absolute URL are valid.\" }"; - public const string UpdateDataMissing = "{ \"message\": \"Missing file update data for this request\", \"help\": \"\" }"; - public const string UpdateDataTagsInvalid = "{ \"message\": \"Invalid tags parameter for this request\", \"help\": \"tags should be passed as 'null', a string like 'tag1,tag2', or an array like (new string[] { 'tag1', 'tag2' })\" }"; - public const string UpdateDataCoordsInvalid = "{ \"message\": \"Invalid customCoordinates parameter for this request\", \"help\": \"customCoordinates should be passed as null or a string like 'x,y,width,height'\" }"; - public const string ListFilesInputMissing = "{ \"message\": \"Missing options for list files\", \"help\": \"If you do not want to pass any parameter for listing, pass an empty object\" }"; - public const string MissingUploadData = "{ \"message\": \"Missing data for upload\", \"help\": \"\" }"; - public const string MissingUploadFileParameter = "{ \"message\": \"Missing file parameter for upload\", \"help\": \"\" }"; - public const string InvalidPhashValue = "{ \"message: \"Invalid pHash value\", \"help\": \"Both pHash strings must be valid hexadecimal numbers\" }"; - public const string MissingPhashValue = "{ \"message: \"Missing pHash value\", \"help\": \"Please pass two pHash values\" }"; - public const string UnequalStringLength = "{ \"message: \"Unequal pHash string length\", \"help\": \"For distance calucation, the two pHash strings must have equal length\" }"; - public const string InvalidfileIdsValue = "{ \"message: \"Invalid value for fileId\", \"help\": \"fileIds should be an string array of fileId of the files to delete. The array should have atleast one fileId.\" }"; - public const string InvalidUrlValue = "{ \"message: \"Missing URL parameter for this request\", \"help\": \"\" }"; - public const string InvalidCopyValue = "{ \"message: \"sourceFilePath and DestinationFilePath both parameter are required\", \"help\": \"\" }"; - public const string InvalidJobValue = "{ \"message: \"JobId parameter are required\", \"help\": \"\" }"; - public const string InvalidFolderValue = "{ \"message: \"FilePath and NewFileName both parameter are required\", \"help\": \"\" }"; - - public const string MissingUploadFilenameParameter = "{ \"message\": \"Missing fileName parameter for upload\", \"help\": \"\" }"; - public const string InvalidMetaTagValue = "{ \"message: \"Invalid MetaData parameter for this request\", \"help\": \"\" }"; - public const string InvalidMetaTagNameValue = "{ \"message: \"Invalid MetaData name parameter for this request\", \"help\": \"\" }"; - - public const string InvalidMetaTagLabelValue = "{ \"message: \"Invalid MetaData label parameter for this request\", \"help\": \"\" }"; - public const string InvalidMetaTagSchemaValue = "{ \"message: \"Invalid MetaData Schema parameter for this request\", \"help\": \"\" }"; - public const string InvalidDelVerValue = "{ \"message: \"FieldId and versionId both parameters are required\", \"help\": \"\" }"; - - public const string InvalidFileUploadObjValue = "{ \"message: \"Missing data for upload\", \"help\": \"\" }"; - - public const string InvalidFileValue = "{ \"message: \"Missing file parameter for upload\", \"help\": \"\" }"; - public const string InvalidTagValue = "{ \"message: \"Invalid parameter for this request\", \"help\": \"\" }"; - - public const string InvalidTagParamValue = "{ \"message: \"Invalid value for tags\", \"help\": \"tags should be a non empty array of string like ['tag1', 'tag2'].\" }"; - public const string InvalidFiledParamValue = "{ \"message: \"Invalid value for fileIds\", \"help\": \"fileIds should be an array of fileId of the files. The array should have atleast one fileId.\" }"; - - public const string InvalidMetaTagIdValue = "{ \"message: \"Invalid MetaData Id parameter for this request\", \"help\": \"\" }"; - - public const string InvalidFieldIdDelVerValue = "{ \"message: \"Missing fileId parameter for this request\", \"help\": \"\" }"; - public const string InvalidversionIdDelVerValue = "{ \"message: \"Missing versionId parameter for this request\", \"help\": \"\" }"; - public const string InvalidMoveValue = "{ \"message: \"sourceFilePath and DestinationFilePath both parameter are required\", \"help\": \"\" }"; - public const string InvalidSourceValue = "{ \"message: \"Missing sourceFilePath parameter for this request\", \"help\": \"\" }"; - public const string InvalidDestinationValue = "{ \"message: \"Missing DestinationFilePath parameter for this request\", \"help\": \"\" }"; - public const string InvalidDelFolderValue = "{ \"message: \"FolderPath parameter are required\", \"help\": \"\" }"; - - public const string InvalidCreateFolderValue = "{ \"message: \"Missing folderName and FolderPath parameters\", \"help\": \"\" }"; - public const string InvalidfolderNameValue = "{ \"message: \"Missing folderName parameters\", \"help\": \"\" }"; - public const string InvalidFolderPathValue = "{ \"message: \"Missing FolderPath parameters\", \"help\": \"\" }"; - - public const string InvalidCopyFolderValue = "{ \"message: \"Missing folderName and FolderPath parameters\", \"help\": \"\" }"; - public const string InvalidCopysourceFolderPathValue = "{ \"message: \"Missing sourceFolderPath parameters\", \"help\": \"\" }"; - public const string InvalidCopydestinationPathValue = "{ \"message: \"Missing destinationPath parameters\", \"help\": \"\" }"; - - public const string InvalidRenameValue = "{ \"message: \"FilePath and NewFileName both parameters are required\", \"help\": \"\" }"; - public const string InvalidRenameFilePathValue = "{ \"message: \"Missing FilePath parameters\", \"help\": \"\" }"; - public const string InvalidRenameNewFileNameValue = "{ \"message: \"Missing NewFileName parameters\", \"help\": \"\" }"; - public const string InvalidKey = "{ \"message: \"Missing API Key parameters\", \"help\": \"\" }"; - public const string InvalidApiUrl = "{ \"message: \"Missing API URL parameters\", \"help\": \"\" }"; - public const string InvalidPurgeUrl = "{ \"message: \"Missing Purge Request URL parameters\", \"help\": \"\" }"; - } -} diff --git a/Imagekit/GlobalSuppressions.cs b/Imagekit/GlobalSuppressions.cs deleted file mode 100644 index e8ce5786..00000000 --- a/Imagekit/GlobalSuppressions.cs +++ /dev/null @@ -1,49 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - -using System.Diagnostics.CodeAnalysis; - -[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "not needed", Scope = "member", Target = "~F:Imagekit.Models.DeleteFileVersionRequest.fileId")] -[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "not needed", Scope = "member", Target = "~M:Imagekit.Sdk.RestClient.MoveFile(MoveFileRequest)~ResponseMetaData")] -[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "not needed", Scope = "member", Target = "~M:Imagekit.Imagekit.#ctor(System.String,System.String,System.String,System.String)")] -[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1601:Partial elements should be documented", Justification = "not needed", Scope = "type", Target = "~T:Imagekit.BaseImagekit`1")] -[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "not needed", Scope = "type", Target = "~T:ImagekitSample.Program")] -[assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1117:Parameters should be on same line or separate lines", Justification = "not needed", Scope = "member", Target = "~M:Imagekit.Sdk.RestClient.PurgeCacheAsync(System.String)~System.Threading.Tasks.Task{ResponseMetaData}")] -[assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1117:Parameters should be on same line or separate lines", Justification = "not needed", Scope = "member", Target = "~M:Imagekit.Sdk.RestClient.DeleteFileVersion(Imagekit.Models.DeleteFileVersionRequest)~ResponseMetaData")] -[assembly: SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:File may only contain a single type", Justification = "not needed", Scope = "type", Target = "~T:Imagekit.Helper.QueryMaker")] -[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "not needed", Scope = "member", Target = "~M:Imagekit.Sdk.ImagekitClient.GetRemoteFileMetadata(System.String)~ResponseMetaData")] -[assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1117:Parameters should be on same line or separate lines", Justification = "not needed", Scope = "member", Target = "~M:Imagekit.Sdk.RestClient.DeleteFileVersionAsync(Imagekit.Models.DeleteFileVersionRequest)~System.Threading.Tasks.Task{ResponseMetaData}")] -[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "not needed", Scope = "member", Target = "~M:Imagekit.Sdk.RestClient.PurgeStatus(System.String)~ResponseMetaData")] -[assembly: SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:Fields should be private", Justification = "not needed", Scope = "member", Target = "~F:Imagekit.BaseImagekit`1.options")] -[assembly: SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:Fields should be private", Justification = "not needed", Scope = "member", Target = "~F:Transformation.nestedTransforms")] -[assembly: SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:Fields should be private", Justification = "not needed", Scope = "member", Target = "~F:Transformation.transformParams")] -[assembly: SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:Fields should be private", Justification = "not needed", Scope = "member", Target = "~F:Url.options")] -[assembly: SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1201:Elements should appear in the correct order", Justification = "not needed", Scope = "member", Target = "~F:Transformation.transformParams")] -[assembly: SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1201:Elements should appear in the correct order", Justification = "not needed", Scope = "member", Target = "~M:Imagekit.Sdk.ImagekitClient.#ctor(System.String,System.String,System.String)")] -[assembly: SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1201:Elements should appear in the correct order", Justification = "not needed", Scope = "member", Target = "~M:Transformation.#ctor")] -[assembly: SuppressMessage("Compiler", "CS0108:Member hides inherited member; missing new keyword", Justification = "not needed", Scope = "member", Target = "~P:Imagekit.Models.Response.ResultMetaData.Raw")] -[assembly: SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "not needed", Scope = "member", Target = "~P:ResultCache.Help")] -[assembly: SuppressMessage("Compiler", "CS0108:Member hides inherited member; missing new keyword", Justification = "not needed", Scope = "member", Target = "~P:ResultCache.Raw")] -[assembly: SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "not needed", Scope = "member", Target = "~P:ResultCache.Raw")] -[assembly: SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "not needed", Scope = "member", Target = "~P:ResultCache.RequestId")] -[assembly: SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "not needed", Scope = "member", Target = "~P:ResultCacheStatus.Help")] -[assembly: SuppressMessage("Compiler", "CS0108:Member hides inherited member; missing new keyword", Justification = "not needed", Scope = "member", Target = "~P:ResultCacheStatus.Raw")] -[assembly: SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "not needed", Scope = "member", Target = "~P:ResultCacheStatus.Raw")] -[assembly: SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "not needed", Scope = "member", Target = "~P:ResultCacheStatus.Status")] -[assembly: SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "not needed", Scope = "member", Target = "~P:ResultCustomMetaDataField.Id")] -[assembly: SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "not needed", Scope = "member", Target = "~P:ResultCustomMetaDataField.Label")] -[assembly: SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "not needed", Scope = "member", Target = "~P:ResultCustomMetaDataField.Message")] -[assembly: SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "not needed", Scope = "member", Target = "~P:ResultCustomMetaDataField.Name")] -[assembly: SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "not needed", Scope = "member", Target = "~P:ResultCustomMetaDataField.Schema")] -[assembly: SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "not needed", Scope = "member", Target = "~P:ResultException.Help")] -[assembly: SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "not needed", Scope = "member", Target = "~P:ResultException.Message")] -[assembly: SuppressMessage("Compiler", "CS0108:Member hides inherited member; missing new keyword", Justification = "not needed", Scope = "member", Target = "~P:ResultFileDelete.Raw")] -[assembly: SuppressMessage("Compiler", "CS0108:Member hides inherited member; missing new keyword", Justification = "not needed", Scope = "member", Target = "~P:ResultList.Raw")] -[assembly: SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "not needed", Scope = "member", Target = "~P:ResultNoContent.ResponseMetaData")] -[assembly: SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1202:Elements should be ordered by access", Justification = "not needed", Scope = "member", Target = "~M:Imagekit.Helper.GetJsonBody.GetBase64(System.Byte[])~System.String")] -[assembly: SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1202:Elements should be ordered by access", Justification = "not needed", Scope = "member", Target = "~M:Transformation.ToString~System.String")] -[assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1123:Do not place regions within elements", Justification = "not needed", Scope = "member", Target = "~M:ImagekitSample.Program.Main(System.String[])")] -[assembly: SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1400:Access modifier should be declared", Justification = "not needed", Scope = "member", Target = "~M:ImagekitSample.Program.Main(System.String[])")] -[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1649:File name should match first type name", Justification = "not needed", Scope = "type", Target = "~T:Imagekit.Sdk.ImagekitClient")] -[assembly: SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1204:Static elements should appear before instance elements", Justification = "not needed", Scope = "member", Target = "~M:Transformation.ToString(System.Object)~System.String")] diff --git a/Imagekit/Helper/GetJsonBody.cs b/Imagekit/Helper/GetJsonBody.cs deleted file mode 100644 index e7f4667e..00000000 --- a/Imagekit/Helper/GetJsonBody.cs +++ /dev/null @@ -1,423 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - -namespace Imagekit.Helper -{ - using System; - using System.Collections.Generic; - using System.Diagnostics.CodeAnalysis; - using System.IO; - using System.Runtime.Serialization.Formatters.Binary; - using global::Imagekit.Models; - - [ExcludeFromCodeCoverage] - public static class GetJsonBody - { - public static string CreateCustomMetaDataBody(CustomMetaDataFieldCreateRequest customMetaDataFieldCreateRequest) - { - string body = string.Empty; - if (customMetaDataFieldCreateRequest.schema.isValueRequired) - { - if (customMetaDataFieldCreateRequest.schema.type == "Text") - { - body = @"{" + "\n" + - @" ""name"": " + AddDoubleQuotes(customMetaDataFieldCreateRequest.name) + "," + "\n" + - @" ""label"": " + AddDoubleQuotes(customMetaDataFieldCreateRequest.label) + "," + "\n" + - @" ""schema"": {" + "\n" + - @" ""type"": " + - AddDoubleQuotes(customMetaDataFieldCreateRequest.schema.type.ToString()) + "," + "\n" + - @" ""minLength"": " + - customMetaDataFieldCreateRequest.schema.minLength.ToString() + "," + "\n" + - @" ""maxLength"": " + - customMetaDataFieldCreateRequest.schema.maxLength.ToString() + "," + "\n" + - @" ""isValueRequired"": " + - customMetaDataFieldCreateRequest.schema.isValueRequired.ToString().ToLower() + "," + "\n" + - @" ""defaultValue"": " + - AddDoubleQuotesObject(customMetaDataFieldCreateRequest.schema.defaultValue) + "\n" + - @" }" + "\n" + - @"}"; - } - - if (customMetaDataFieldCreateRequest.schema.type == "Textarea") - { - body = @"{" + "\n" + - @" ""name"": " + AddDoubleQuotes(customMetaDataFieldCreateRequest.name) + "," + "\n" + - @" ""label"": " + AddDoubleQuotes(customMetaDataFieldCreateRequest.label) + "," + "\n" + - @" ""schema"": {" + "\n" + - @" ""type"": " + - AddDoubleQuotes(customMetaDataFieldCreateRequest.schema.type.ToString()) + "," + "\n" + - @" ""minLength"": " + - customMetaDataFieldCreateRequest.schema.minLength.ToString() + "," + "\n" + - @" ""maxLength"": " + - customMetaDataFieldCreateRequest.schema.maxLength.ToString() + "," + "\n" + - @" ""isValueRequired"": " + - customMetaDataFieldCreateRequest.schema.isValueRequired.ToString().ToLower() + "," + "\n" + - @" ""defaultValue"": " + - AddDoubleQuotesObject(customMetaDataFieldCreateRequest.schema.defaultValue) + "\n" + - @" }" + "\n" + - @"}"; - } - - if (customMetaDataFieldCreateRequest.schema.type == "Number") - { - body = @"{" + "\n" + - @" ""name"": " + AddDoubleQuotes(customMetaDataFieldCreateRequest.name) + "," + "\n" + - @" ""label"": " + AddDoubleQuotes(customMetaDataFieldCreateRequest.label) + "," + "\n" + - @" ""schema"": {" + "\n" + - @" ""type"": " + - AddDoubleQuotes(customMetaDataFieldCreateRequest.schema.type.ToString()) + "," + "\n" + - @" ""minValue"": " + - customMetaDataFieldCreateRequest.schema.minValue.ToString() + "," + "\n" + - @" ""maxValue"": " + - customMetaDataFieldCreateRequest.schema.maxValue.ToString() + "," + "\n" + - @" ""isValueRequired"": " + - customMetaDataFieldCreateRequest.schema.isValueRequired.ToString().ToLower() + "," + "\n" + - @" ""defaultValue"": " + - customMetaDataFieldCreateRequest.schema.defaultValue + "\n" + - - @" }" + "\n" + - @"}"; - } - - if (customMetaDataFieldCreateRequest.schema.type == "Date") - { - body = @"{" + "\n" + - @" ""name"": " + AddDoubleQuotes(customMetaDataFieldCreateRequest.name) + "," + "\n" + - @" ""label"": " + AddDoubleQuotes(customMetaDataFieldCreateRequest.label) + "," + "\n" + - @" ""schema"": {" + "\n" + - @" ""type"": " + - AddDoubleQuotes(customMetaDataFieldCreateRequest.schema.type.ToString()) + "," + "\n" + - @" ""minValue"": " + - AddDoubleQuotes(customMetaDataFieldCreateRequest.schema.minValue.ToString()) + "," + "\n" + - @" ""maxValue"": " + - AddDoubleQuotes(customMetaDataFieldCreateRequest.schema.maxValue.ToString()) + "," + "\n" + - @" ""isValueRequired"": " + - customMetaDataFieldCreateRequest.schema.isValueRequired.ToString().ToLower() + "," + "\n" + - @" ""defaultValue"": " + - AddDoubleQuotesObject(customMetaDataFieldCreateRequest.schema.defaultValue) + "\n" + - @" }" + "\n" + - @"}"; - } - - if (customMetaDataFieldCreateRequest.schema.type == "SingleSelect") - { - body = @"{" + "\n" + - @" ""name"": " + AddDoubleQuotes(customMetaDataFieldCreateRequest.name) + "," + "\n" + - @" ""label"": " + AddDoubleQuotes(customMetaDataFieldCreateRequest.label) + "," + "\n" + - @" ""schema"": {" + "\n" + - @" ""type"": " + - AddDoubleQuotes(customMetaDataFieldCreateRequest.schema.type.ToString()) + "," + "\n" + - @" ""selectOptions"": " + - AddBigQuotes(customMetaDataFieldCreateRequest.schema.selectOptions) + "," + "\n" + - @" ""isValueRequired"": " + - customMetaDataFieldCreateRequest.schema.isValueRequired.ToString().ToLower() + "," + "\n" + - @" ""defaultValue"": " + - AddDoubleQuotesObject(customMetaDataFieldCreateRequest.schema.defaultValue) + "\n" + - - @" }" + "\n" + - @"}"; - } - - if (customMetaDataFieldCreateRequest.schema.type == "MultiSelect") - { - body = @"{" + "\n" + - @" ""name"": " + AddDoubleQuotes(customMetaDataFieldCreateRequest.name) + "," + "\n" + - @" ""label"": " + AddDoubleQuotes(customMetaDataFieldCreateRequest.label) + "," + "\n" + - @" ""schema"": {" + "\n" + - @" ""type"": " + - AddDoubleQuotes(customMetaDataFieldCreateRequest.schema.type.ToString()) + "," + "\n" + - @" ""selectOptions"": " + - AddBigQuotes(customMetaDataFieldCreateRequest.schema.selectOptions) + "," + "\n" + - @" ""isValueRequired"": " + - customMetaDataFieldCreateRequest.schema.isValueRequired.ToString().ToLower() + "," + "\n" + - @" ""defaultValue"": " + - customMetaDataFieldCreateRequest.schema.defaultValue + "\n" + - - @" }" + "\n" + - @"}"; - } - } - else - { - if (customMetaDataFieldCreateRequest.schema.type == "Text") - { - body = @"{" + "\n" + - @" ""name"": " + AddDoubleQuotes(customMetaDataFieldCreateRequest.name) + "," + "\n" + - @" ""label"": " + AddDoubleQuotes(customMetaDataFieldCreateRequest.label) + "," + "\n" + - @" ""schema"": {" + "\n" + - @" ""type"": " + - AddDoubleQuotes(customMetaDataFieldCreateRequest.schema.type.ToString()) + "," + "\n" + - @" ""minLength"": " + - customMetaDataFieldCreateRequest.schema.minLength.ToString() + "," + "\n" + - @" ""maxLength"": " + - customMetaDataFieldCreateRequest.schema.maxLength.ToString() + "," + "\n" + - @" ""isValueRequired"": " + - customMetaDataFieldCreateRequest.schema.isValueRequired.ToString().ToLower() + "\n" + - @" }" + "\n" + - @"}"; - } - - if (customMetaDataFieldCreateRequest.schema.type == "Textarea") - { - body = @"{" + "\n" + - @" ""name"": " + AddDoubleQuotes(customMetaDataFieldCreateRequest.name) + "," + "\n" + - @" ""label"": " + AddDoubleQuotes(customMetaDataFieldCreateRequest.label) + "," + "\n" + - @" ""schema"": {" + "\n" + - @" ""type"": " + - AddDoubleQuotes(customMetaDataFieldCreateRequest.schema.type.ToString()) + "," + "\n" + - @" ""minLength"": " + - customMetaDataFieldCreateRequest.schema.minLength.ToString() + "," + "\n" + - @" ""maxLength"": " + - customMetaDataFieldCreateRequest.schema.maxLength.ToString() + "," + "\n" + - @" ""isValueRequired"": " + - customMetaDataFieldCreateRequest.schema.isValueRequired.ToString().ToLower() + "\n" + - - @" }" + "\n" + - @"}"; - } - - if (customMetaDataFieldCreateRequest.schema.type == "Number") - { - body = @"{" + "\n" + - @" ""name"": " + AddDoubleQuotes(customMetaDataFieldCreateRequest.name) + "," + "\n" + - @" ""label"": " + AddDoubleQuotes(customMetaDataFieldCreateRequest.label) + "," + "\n" + - @" ""schema"": {" + "\n" + - @" ""type"": " + - AddDoubleQuotes(customMetaDataFieldCreateRequest.schema.type.ToString()) + "," + "\n" + - @" ""minValue"": " + - customMetaDataFieldCreateRequest.schema.minValue.ToString() + "," + "\n" + - @" ""maxValue"": " + - customMetaDataFieldCreateRequest.schema.maxValue.ToString() + "," + "\n" + - @" ""isValueRequired"": " + - customMetaDataFieldCreateRequest.schema.isValueRequired.ToString().ToLower() + "\n" + - @" }" + "\n" + - @"}"; - } - - if (customMetaDataFieldCreateRequest.schema.type == "Date") - { - body = @"{" + "\n" + - @" ""name"": " + AddDoubleQuotes(customMetaDataFieldCreateRequest.name) + "," + "\n" + - @" ""label"": " + AddDoubleQuotes(customMetaDataFieldCreateRequest.label) + "," + "\n" + - @" ""schema"": {" + "\n" + - @" ""type"": " + - AddDoubleQuotes(customMetaDataFieldCreateRequest.schema.type.ToString()) + "," + "\n" + - @" ""minValue"": " + - AddDoubleQuotes(customMetaDataFieldCreateRequest.schema.minValue.ToString()) + "," + "\n" + - @" ""maxValue"": " + - AddDoubleQuotes(customMetaDataFieldCreateRequest.schema.maxValue.ToString()) + "," + "\n" + - @" ""isValueRequired"": " + - customMetaDataFieldCreateRequest.schema.isValueRequired.ToString().ToLower() + "\n" + - @" }" + "\n" + - @"}"; - } - - if (customMetaDataFieldCreateRequest.schema.type == "SingleSelect" || - customMetaDataFieldCreateRequest.schema.type == "MultiSelect") - { - body = @"{" + "\n" + - @" ""name"": " + AddDoubleQuotes(customMetaDataFieldCreateRequest.name) + "," + "\n" + - @" ""label"": " + AddDoubleQuotes(customMetaDataFieldCreateRequest.label) + "," + "\n" + - @" ""schema"": {" + "\n" + - @" ""type"": " + - AddDoubleQuotes(customMetaDataFieldCreateRequest.schema.type.ToString()) + "," + "\n" + - @" ""selectOptions"": " + - AddBigQuotes(customMetaDataFieldCreateRequest.schema.selectOptions) + "," + "\n" + - @" ""isValueRequired"": " + - customMetaDataFieldCreateRequest.schema.isValueRequired.ToString().ToLower() + "\n" + - @" }" + "\n" + - @"}"; - } - } - - return body; - } - - public static string UpdateCustomMetaDataBody(CustomMetaDataFieldUpdateRequest customMetaDataFieldCreateRequest) - { - string body = string.Empty; - if (customMetaDataFieldCreateRequest.schema.type == "Text") - { - body = @"{" + "\n" + - @" ""schema"": {" + "\n" + - @" ""type"": " + - AddDoubleQuotes(customMetaDataFieldCreateRequest.schema.type.ToString()) + "," + "\n" + - @" ""minLength"": " + - customMetaDataFieldCreateRequest.schema.minLength.ToString() + "," + "\n" + - @" ""maxLength"": " + - customMetaDataFieldCreateRequest.schema.maxLength.ToString() + "\n" + - @" }" + "\n" + - @"}"; - } - - if (customMetaDataFieldCreateRequest.schema.type == "Textarea") - { - body = @"{" + "\n" + - @" ""schema"": {" + "\n" + - @" ""type"": " + - AddDoubleQuotes(customMetaDataFieldCreateRequest.schema.type.ToString()) + "," + "\n" + - @" ""minLength"": " + - customMetaDataFieldCreateRequest.schema.minLength.ToString() + "," + "\n" + - @" ""maxLength"": " + - customMetaDataFieldCreateRequest.schema.maxLength.ToString() + "\n" + - @" }" + "\n" + - @"}"; - } - - if (customMetaDataFieldCreateRequest.schema.type == "Number") - { - body = @"{" + "\n" + - @" ""schema"": {" + "\n" + - @" ""type"": " + - AddDoubleQuotes(customMetaDataFieldCreateRequest.schema.type.ToString()) + "," + "\n" + - @" ""minValue"": " + - customMetaDataFieldCreateRequest.schema.minValue.ToString() + "," + "\n" + - @" ""maxValue"": " + - customMetaDataFieldCreateRequest.schema.maxValue.ToString() + "\n" + - @" }" + "\n" + - @"}"; - } - - if (customMetaDataFieldCreateRequest.schema.type == "Date") - { - body = @"{" + "\n" + - @" ""schema"": {" + "\n" + - @" ""type"": " + - AddDoubleQuotes(customMetaDataFieldCreateRequest.schema.type.ToString()) + "," + "\n" + - @" ""minValue"": " + - customMetaDataFieldCreateRequest.schema.minValue.ToString() + "," + "\n" + - @" ""maxValue"": " + - customMetaDataFieldCreateRequest.schema.maxValue.ToString() + "\n" + - @" }" + "\n" + - @"}"; - } - - if (customMetaDataFieldCreateRequest.schema.type == "SingleSelect") - { - body = @"{" + "\n" + - @" ""schema"": {" + "\n" + - @" ""type"": " + - AddDoubleQuotes(customMetaDataFieldCreateRequest.schema.type.ToString()) + "," + "\n" + - @" ""selectOptions"": " + AddBigQuotes(customMetaDataFieldCreateRequest.schema.selectOptions) + "\n" + - - @" }" + "\n" + - @"}"; - } - - return body; - } - - public static string DeleteFolderBody(DeleteFolderRequest deleteFolderRequest) - { - var body = @"{" + "\n" + - @" ""folderPath"" : " + AddDoubleQuotes(deleteFolderRequest.folderPath) + "\n" + - @"}"; - - return body; - } - - private static string AddDoubleQuotes(this string value) - { - return "\"" + value + "\""; - } - - private static string AddDoubleQuotesObject(this object value) - { - return "\"" + value + "\""; - } - - private static string AddBigQuotes(this string[] value) - { - var joinedNames = "\"" + string.Join("\", \"", value) + "\""; - - return "[" + joinedNames + "]"; - } - - public static string GetBase64(object imageArray) - { - string base64ImageRepresentation = Convert.ToBase64String((byte[])imageArray); - return base64ImageRepresentation; - } - - public static string GetBase64Uri(string imagePath) - { - var uri = new System.Uri(imagePath); - byte[] imageArray = System.IO.File.ReadAllBytes(uri.AbsolutePath); - string base64ImageRepresentation = Convert.ToBase64String(imageArray); - return base64ImageRepresentation; - } - - public static string GetFileRequestBody(GetFileListRequest getFileListRequest) - { - QueryMaker queryMaker = new QueryMaker(); - Dictionary options = new Dictionary(); - - if (getFileListRequest.Sort != null) - { - options.Add("sort", getFileListRequest.Sort); - } - - if (getFileListRequest.Path != null) - { - options.Add("path", getFileListRequest.Path); - } - - if (getFileListRequest.SearchQuery != null) - { - options.Add("searchQuery", getFileListRequest.SearchQuery); - } - - if (getFileListRequest.FileType != null) - { - options.Add("fileType", getFileListRequest.FileType); - } - - if (getFileListRequest.Limit > 0) - { - options.Add("limit", getFileListRequest.Limit.ToString()); - } - - if (getFileListRequest.Skip > 0) - { - options.Add("skip", getFileListRequest.Skip.ToString()); - } - - if (getFileListRequest.Name != null) - { - options.Add("name", getFileListRequest.Name.ToString()); - } - - foreach (KeyValuePair entry in options) - { - queryMaker.Add(string.Format("{0}={1}", entry.Key, entry.Value)); - } - - return queryMaker.Get(); - } - } - - public class QueryMaker - { - private string query; - - public void Add(string q) - { - if (this.query != null) - { - this.query += "&"; - } - else - { - this.query = string.Empty; - } - - this.query += q; - } - - public string Get() - { - return this.query; - } - } -} diff --git a/Imagekit/Helper/ImageKitException.cs b/Imagekit/Helper/ImageKitException.cs deleted file mode 100644 index 48f1e504..00000000 --- a/Imagekit/Helper/ImageKitException.cs +++ /dev/null @@ -1,26 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - -namespace Imagekit.Helper -{ - using System; - - public class ImagekitException : Exception - { - public ImagekitException() - { - } - - public ImagekitException(string message) - : base(message) - { - throw new Exception(message); - } - - public ImagekitException(string message, Exception inner) - : base(message, inner) - { - } - } -} \ No newline at end of file diff --git a/Imagekit/Helper/ImagekitBase.cs b/Imagekit/Helper/ImagekitBase.cs deleted file mode 100644 index ef673522..00000000 --- a/Imagekit/Helper/ImagekitBase.cs +++ /dev/null @@ -1,83 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - -namespace Imagekit -{ - using System; - using System.Collections.Generic; - using System.Diagnostics.CodeAnalysis; - using System.Text.RegularExpressions; - - [ExcludeFromCodeCoverage] - public abstract partial class BaseImagekit - where T : BaseImagekit - { - public Dictionary options = new Dictionary(); - - public BaseImagekit(string publicKey, string urlEndpoint, string transformationPosition = "path") - { - if (string.IsNullOrEmpty(publicKey)) - { - throw new ArgumentNullException(nameof(publicKey)); - } - - if (string.IsNullOrEmpty(urlEndpoint)) - { - throw new ArgumentNullException(nameof(urlEndpoint)); - } - - Regex rgx = new Regex("^(path|query)$"); - if (transformationPosition == null || !rgx.IsMatch(transformationPosition)) - { - throw new Exception(Constant.ErrorMessages.InvalidTransformationPosition); - } - - this.Add("publicKey", publicKey); - this.Add("urlEndpoint", urlEndpoint); - this.Add("transformationPosition", transformationPosition); - } - - public string Generate() - { - Transformation transformation = (Transformation)this.options["transformation"]; - string tranformationString = transformation.Generate(); - return new Url(this.options).UrlBuilder(tranformationString); - } - } - - public class ServerImagekit : BaseImagekit - { - public ServerImagekit( - string publicKey, - string privateKey, - string urlEndpoint, - string transformationPosition = "path") - : base(publicKey, urlEndpoint, transformationPosition) - { - if (string.IsNullOrEmpty(privateKey)) - { - throw new ArgumentNullException(nameof(privateKey)); - } - - this.Add("privateKey", privateKey); - } - } - - // Leaving this for backwards compatibility. - // Renaming the class: - // a) solves the issue where Imagekit must always be fully qualified since the name is the same as the assembly - // b) allows for clarification between a server-side imagekit and a client-side imagekit - [Obsolete("Use ServerImagekit")] - public class Imagekit : ServerImagekit - { - public Imagekit( - string publicKey, - string privateKey, - string urlEndpoint, - string transformationPosition = "path") - : base(publicKey, privateKey, urlEndpoint, transformationPosition) - { - } - } -} diff --git a/Imagekit/Helper/ImagekitParams.cs b/Imagekit/Helper/ImagekitParams.cs deleted file mode 100644 index 38b6f937..00000000 --- a/Imagekit/Helper/ImagekitParams.cs +++ /dev/null @@ -1,73 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - -namespace Imagekit -{ - public partial class BaseImagekit - { - public T Path(string value) - { - return this.Add("path", value); - } - - public T Src(string value) - { - return this.Add("src", value); - } - - public T UrlEndpoint(string value) - { - return this.Add("urlEndpoint", value); - } - - public T Url(Transformation value) - { - return this.Add("transformation", value); - } - - public T QueryParameters(params string[] value) - { - return this.Add("queryParameters", value); - } - - public T TransformationPosition(string value) - { - return this.Add("transformationPosition", value); - } - - public T Signed(bool value = true) - { - return this.Add("signed", value); - } - - public T ExpireSeconds(int value) - { - return this.Add("expireSeconds", value); - } - - /// - /// Add transformation parameter. - /// - /// The name. - /// The value. - public T Add(string key, object value) - { - if (this.options.ContainsKey(key)) - { - this.options[key] = value; - if (key == "transformation") - { - this.options.Remove("path"); - this.options.Remove("src"); - } - } - else - { - this.options.Add(key, value); - } - - return (T)this; - } - } -} diff --git a/Imagekit/Helper/MultipartFormDataModel.cs b/Imagekit/Helper/MultipartFormDataModel.cs deleted file mode 100644 index cb670a75..00000000 --- a/Imagekit/Helper/MultipartFormDataModel.cs +++ /dev/null @@ -1,180 +0,0 @@ -namespace Imagekit.Helper -{ - using System; - using System.Net; - using System.Net.Http; - using System.Net.Http.Headers; - using global::Imagekit.Constant; - using global::Imagekit.Models; - using global::Imagekit.Util; - using Newtonsoft.Json; - using System.Collections.Generic; - - public static class MultipartFormDataModel - { - private static string boundary = UrlHandler.GetBoundaryString; - - public static MultipartFormDataContent Build(FileCreateRequest fileCreateRequest) - { - HttpContent content = new StringContent(string.Empty); - MultipartFormDataContent formdata = new MultipartFormDataContent(boundary); - formdata.Headers.Remove("Content-Type"); - formdata.Headers.TryAddWithoutValidation("Content-Type", "multipart/form-data; boundary=" + boundary); - formdata.Add(new StringContent(fileCreateRequest.fileName), "fileName"); - if (fileCreateRequest.file.GetType().Name == "Byte[]") - { - formdata.Add(new StringContent(GetJsonBody.GetBase64(fileCreateRequest.file)), "file"); - } - else - { - formdata.Add(new StringContent(fileCreateRequest.file.ToString()), "file"); - } - - if (fileCreateRequest.useUniqueFileName) - { - formdata.Add(new StringContent("true"), "useUniqueFileName"); - } - else - { - formdata.Add(new StringContent("false"), "useUniqueFileName"); - } - - if (fileCreateRequest.tags != null) - { - formdata.Add(new StringContent(Utils.ListToString(fileCreateRequest.tags)), "tags"); - } - - if (!string.IsNullOrEmpty(fileCreateRequest.folder)) - { - formdata.Add(new StringContent(fileCreateRequest.folder), "folder"); - } - - if (fileCreateRequest.isPrivateFile) - { - formdata.Add(new StringContent("true"), "isPrivateFile"); - } - - if (!string.IsNullOrEmpty(fileCreateRequest.customCoordinates)) - { - formdata.Add(new StringContent(fileCreateRequest.customCoordinates), "customCoordinates"); - } - - if (fileCreateRequest.responseFields != null) - { - formdata.Add(new StringContent(Utils.ListToString(fileCreateRequest.responseFields)), "responseFields"); - } - - if (fileCreateRequest.overwriteFile) - { - formdata.Add(new StringContent("true"), "overwriteFile"); - } - - if (fileCreateRequest.overwriteAITags) - { - formdata.Add(new StringContent("true"), "overwriteAITags"); - } - - if (fileCreateRequest.overwriteTags) - { - formdata.Add(new StringContent("true"), "overwriteTags"); - } - - if (fileCreateRequest.overwriteCustomMetadata) - { - formdata.Add(new StringContent("false"), "overwriteCustomMetadata"); - } - - if (fileCreateRequest.extensions != null) - { - var myContent = JsonConvert.SerializeObject( - fileCreateRequest.extensions, - new JsonSerializerSettings() - { - NullValueHandling = NullValueHandling.Ignore, - }); - formdata.Add(new StringContent(myContent), "extensions"); - } - - if (fileCreateRequest.webhookUrl != null) - { - formdata.Add(new StringContent(fileCreateRequest.webhookUrl), "webhookUrl"); - } - - if (fileCreateRequest.customMetadata != null) - { - string jsonResult = JsonConvert.SerializeObject(fileCreateRequest.customMetadata); - formdata.Add(new StringContent(jsonResult), "customMetadata"); - } - - if (fileCreateRequest.transformation != null) - { - string jsonResult = JsonConvert.SerializeObject(fileCreateRequest.transformation); - formdata.Add(new StringContent(jsonResult), "transformation"); - } - - if (fileCreateRequest.checks != null) - { - formdata.Add(new StringContent(fileCreateRequest.checks), "checks"); - } - - if (fileCreateRequest.isPublished.HasValue) - { - formdata.Add(new StringContent(fileCreateRequest.isPublished.Value.ToString().ToLower()), "isPublished"); - } - - return formdata; - } - - public static MultipartFormDataContent BuildUpdateFile(FileUpdateRequest fileCreateRequest) - { - MultipartFormDataContent formdata = new MultipartFormDataContent(boundary); - formdata.Headers.Remove("Content-Type"); - formdata.Headers.TryAddWithoutValidation("Content-Type", "multipart/form-data; boundary=" + boundary); - - if (fileCreateRequest.tags != null) - { - formdata.Add(new StringContent(Utils.ListToString(fileCreateRequest.tags)), "tags"); - } - - if (fileCreateRequest.removeAITags != null) - { - formdata.Add(new StringContent(Utils.ListToString(fileCreateRequest.removeAITags)), "removeAITags"); - } - - if (!string.IsNullOrEmpty(fileCreateRequest.customCoordinates)) - { - formdata.Add(new StringContent(fileCreateRequest.customCoordinates), "customCoordinates"); - } - - if (fileCreateRequest.extensions != null) - { - var myContent = JsonConvert.SerializeObject( - fileCreateRequest.extensions, - new JsonSerializerSettings() - { - NullValueHandling = NullValueHandling.Ignore, - }); - formdata.Add(new StringContent(myContent), "extensions"); - } - - if (fileCreateRequest.webhookUrl != null) - { - formdata.Add(new StringContent(fileCreateRequest.webhookUrl), "webhookUrl"); - } - - if (fileCreateRequest.customMetadata != null) - { - string jSONresult = JsonConvert.SerializeObject(fileCreateRequest.customMetadata); - formdata.Add(new StringContent(jSONresult), "customMetadata"); - } - - if (fileCreateRequest.publish != null) - { - string jSONresult = JsonConvert.SerializeObject(fileCreateRequest.publish); - formdata.Add(new StringContent(jSONresult), "publish"); - } - - return formdata; - } - } -} diff --git a/Imagekit/Helper/Transformation.cs b/Imagekit/Helper/Transformation.cs deleted file mode 100644 index cc5fa234..00000000 --- a/Imagekit/Helper/Transformation.cs +++ /dev/null @@ -1,281 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; - -public partial class Transformation -{ - public const string KeyNameRegex = "^\\$[a-zA-Z][a-zA-Z0-9]*$"; - public const string ChainTransformDelimiter = ":"; - public const string TransformDelimiter = ","; - public const string TransformKeyValueDelimiter = "-"; - - /// - /// Initializes a new instance of the class. - /// - /// - /// - public Transformation(Dictionary transformParams) - { - foreach (var key in transformParams.Keys) - { - transformParams.Add(key, transformParams[key]); - } - } - - /// - /// Initializes a new instance of the class. - /// Creates transformation object initialized with array of transformation parameters. - /// - /// List of transformation parameters represented as pairs 'name=value'. - public Transformation(params string[] transformParams) - { - foreach (var pair in transformParams) - { - string[] splittedPair = pair.Split('='); - if (splittedPair.Length != 2) - { - throw new Exception(string.Format("Couldn't parse '{0}'!", pair)); - } - - this.Add(splittedPair[0], splittedPair[1]); - } - } - - /// - /// Add transformation parameter. - /// - /// The name. - /// The value. - public Transformation Add(string key, object value) - { - if (this.transformParams.ContainsKey(key)) - { - this.transformParams[key] = value; - } - else - { - this.transformParams.Add(key, value); - } - - return this; - } - - /// - /// Initializes a new instance of the class. - /// Creates empty transformation object. - /// - public Transformation() - { - } - - /// - /// A dictionary of transformation parameters. - /// - protected Dictionary transformParams = new Dictionary(); - - /// - /// A list of nested transformations. - /// - protected List nestedTransforms = new List(); - - /// - /// Initializes a new instance of the class. - /// Creates transformation object chained with other transformations. - /// - /// List of transformations to chain with. - public Transformation(List transforms) - { - if (transforms != null) - { - this.nestedTransforms = transforms; - } - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// - public Transformation(Dictionary[] dictionary) - { - for (int i = 0; i < dictionary.Length; i++) - { - if (i == dictionary.Length - 1) - { - this.transformParams = dictionary[i]; - } - else - { - this.nestedTransforms.Add(new Transformation(dictionary[i])); - } - } - } - - /// - /// Get the transformation parameters dictionary. - /// - public Dictionary Params - { - get { return this.transformParams; } - } - - /// - /// Get list of nested transformations. - /// - public List NestedTransforms - { - get { return this.nestedTransforms; } - } - - /// - /// Chain transformation. - /// - public Transformation Chain() - { - Transformation nested = this.Clone(); - nested.nestedTransforms = null; - this.nestedTransforms.Add(nested); - this.transformParams = new Dictionary(); - Transformation transform = new Transformation(this.nestedTransforms); - return transform; - } - - /// - /// Get a deep cloned copy of this transformation. - /// - /// A deep cloned copy of this transformation. - public Transformation Clone() - { - Transformation t = (Transformation)this.MemberwiseClone(); - - t.transformParams = new Dictionary(); - - foreach (var key in this.transformParams.Keys) - { - var value = this.transformParams[key]; - - if (value is Array) - { - t.Add(key, ((Array)value).Clone()); - } - else if (value is string || value is ValueType) - { - t.Add(key, value); - } - else if (value is Dictionary) - { - t.Add(key, new Dictionary((Dictionary)value)); - } - else - { - throw new Exception(string.Format("Couldn't clone parameter '{0}'!", key)); - } - } - - if (this.nestedTransforms != null) - { - t.nestedTransforms = new List(); - foreach (var nestedTransform in this.nestedTransforms) - { - t.nestedTransforms.Add(nestedTransform.Clone()); - } - } - - return t; - } - - /// - /// Get this transformation represented as string. - /// - /// The transformation represented as string. - public string Generate() - { - List parts = new List(this.nestedTransforms.Select(t => t.GetTrans()).ToList()); - - var thisTransform = this.GetTrans(); - if (!string.IsNullOrEmpty(thisTransform)) - { - parts.Add(thisTransform); - } - - return string.Join(ChainTransformDelimiter, parts.ToArray()); - } - - public string GetTrans() - { - List transformations = new List(); - List varParams = new List(); - - foreach (var key in this.transformParams.Keys) - { - string val = this.GetString(this.transformParams, key); - if (string.IsNullOrEmpty(val)) - { - varParams.Add($"{key}"); - } - else - { - if (key == "oi" || key == "di") - { - val = val.TrimStart('/').TrimEnd('/'); - val = val.Replace("/", "@@"); - } - - varParams.Add($"{key}-{val}"); - } - } - - if (varParams.Count > 0) - { - transformations.Add(string.Join(TransformDelimiter, varParams)); - } - - return string.Join(ChainTransformDelimiter, transformations.ToArray()); - } - - private string GetString(Dictionary options, string key) - { - if (options.ContainsKey(key)) - { - return ToString(options[key]); - } - else - { - return null; - } - } - - private static string ToString(object obj) - { - if (obj == null) - { - return null; - } - - if (obj is string) - { - return obj.ToString(); - } - - if (obj is float || obj is double) - { - return string.Format(CultureInfo.InvariantCulture, "{0:0.0#}", obj); - } - - return string.Format(CultureInfo.InvariantCulture, "{0}", obj); - } - - /// - /// Get this transformation represented as string. - /// - /// The transformation represented as string. - public override string ToString() - { - return this.Generate(); - } -} diff --git a/Imagekit/Helper/TransformationTypes.cs b/Imagekit/Helper/TransformationTypes.cs deleted file mode 100644 index bd796928..00000000 --- a/Imagekit/Helper/TransformationTypes.cs +++ /dev/null @@ -1,268 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - -using System; -using System.Diagnostics.CodeAnalysis; - -[ExcludeFromCodeCoverage] -public partial class Transformation -{ - /// Width of a transformed image - /// - public Transformation Width(int value) - { - return this.Add("w", value); - } - - /// Height of a transformed image - /// - public Transformation Height(int value) - { - return this.Add("h", value); - } - - /// Aspect Ratio of a transformed image - /// - public Transformation AspectRatio(string value) - { - return this.Add("ar", value); - } - - /// - /// JPG compression quality. 1 is the lowest quality and 100 is the highest. The default is the - /// original image's quality or 80% if not available. - /// - /// - public Transformation Quality(int value) - { - return this.Add("q", value); - } - - /// Crop Transformation. - /// - public Transformation Crop(string value) - { - return this.Add("c", value); - } - - /// Crop Mode - /// - public Transformation CropMode(string value) - { - return this.Add("cm", value); - } - - /// - /// - public Transformation X(int value) - { - return this.Add("x", this.ConvertCoordinateParam(value)); - } - - /// - /// - public Transformation Y(int value) - { - return this.Add("y", this.ConvertCoordinateParam(value)); - } - - /// - /// - public Transformation Focus(string value) - { - return this.Add("fo", value); - } - - /// - /// - public Transformation Format(string value) - { - return this.Add("f", value); - } - - /// - /// - public Transformation Radius(object value) - { - return this.Add("r", value); - } - - /// - /// - public Transformation Background(string value) - { - return this.Add("bg", value); - } - - /// - /// - public Transformation Border(string value) - { - return this.Add("b", value); - } - - /// - /// - public Transformation Rotation(object value) - { - return this.Add("rt", value); - } - - /// - /// - public Transformation Rotate(object value) - { - return this.Add("rt", value); - } - - /// - /// - public Transformation Blur(int value) - { - return this.Add("bl", value); - } - - /// Add named transformation. - /// named transformation. - public Transformation Named(string value) - { - return this.Add("n", value); - } - - /// - /// - public Transformation Progressive(bool value) - { - return this.Add("pr", value.ToString().ToLower()); - } - - /// - /// - public Transformation Lossless(bool value) - { - return this.Add("lo", value.ToString().ToLower()); - } - - /// - /// - public Transformation Trim(int value) - { - return this.Add("t", value); - } - - /// - /// - public Transformation Metadata(bool value) - { - return this.Add("md", value.ToString().ToLower()); - } - - /// - /// - public Transformation ColorProfile(bool value) - { - return this.Add("cp", value.ToString().ToLower()); - } - - /// - /// - public Transformation DefaultImage(string value) - { - return this.Add("di", value); - } - - /// - /// - public Transformation Dpr(object value) - { - return this.Add("dpr", value); - } - - /// - public Transformation EffectSharpen() - { - return this.Add("e-sharpen", string.Empty); - } - - /// - /// - public Transformation EffectSharpen(int value) - { - return this.Add("e-sharpen", value); - } - - /// - /// - public Transformation EffectUsm(string value) - { - return this.Add("e-usm", value); - } - - /// - public Transformation EffectContrast() - { - return this.Add("e-contrast", string.Empty); - } - - /// - /// - public Transformation EffectContrast(object value) - { - return this.Add("e-contrast", value.ToString().ToLower()); - } - - /// - public Transformation EffectGray() - { - return this.Add("e-grayscale", "true"); - } - - /// - public Transformation EffectShadow() - { - return this.Add("e-shadow", string.Empty); - } - - /// - /// - public Transformation EffectShadow(string value) - { - return this.Add("e-shadow", value); - } - - /// - public Transformation EffectGradient() - { - return this.Add("e-gradient", string.Empty); - } - - /// - /// - public Transformation EffectGradient(string value) - { - return this.Add("e-gradient", value); - } - - /// - public Transformation Original() - { - return this.Add("orig", "true"); - } - - /// - /// Pass an raw transformation string (including chained transformations) - /// - /// A raw transformation string. - public Transformation Raw(string value) - { - return this.Add(value, string.Empty); - } - - private string ConvertCoordinateParam(int paramValue) - { - return paramValue < 0 - ? $"N{Math.Abs(paramValue)}" - : $"{paramValue}"; - } -} diff --git a/Imagekit/Helper/Url.cs b/Imagekit/Helper/Url.cs deleted file mode 100644 index fbf7b154..00000000 --- a/Imagekit/Helper/Url.cs +++ /dev/null @@ -1,184 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text; -using System.Text.RegularExpressions; -using global::Imagekit.Util; - -[ExcludeFromCodeCoverage] -public class Url -{ - public Dictionary options = new Dictionary(); - - private bool isSrcParameterUsedForUrl; - private Uri parsedUrl; - private Uri parsedHost; - - public Url(Dictionary client) - { - this.options = client; - } - - public string UrlBuilder(string transformationString) - { - Dictionary urlObject = new Dictionary(); - - if (this.options.ContainsKey("path") && this.options.ContainsKey("src")) - { - throw new Exception("Either path or src is required."); - } - else if (this.options.ContainsKey("path")) - { - string path = this.AddLeadingSlash((string)this.options["path"]); - this.parsedUrl = new Uri((string)this.options["urlEndpoint"] + path); - this.parsedHost = new Uri((string)this.options["urlEndpoint"]); - urlObject.Add("protocol", this.parsedHost.Scheme); - urlObject.Add("host", this.options["urlEndpoint"].ToString().Replace(this.parsedHost.Scheme + "://", string.Empty)); - urlObject.Add("pathname", path.Split('?')[0]); - } - else if (this.options.ContainsKey("src")) - { - this.parsedUrl = new Uri((string)this.options["src"]); - this.isSrcParameterUsedForUrl = true; - urlObject.Add("protocol", this.parsedUrl.Scheme); - urlObject.Add("host", this.parsedUrl.Host); - urlObject.Add("pathname", this.parsedUrl.AbsolutePath); - } - else - { - throw new Exception("Either path or src is required."); - } - - // Create correct query parameters - List queryParameters = new List(); - - // Parse query params which are part of the URL - if (this.parsedUrl.Query != null && this.parsedUrl.Query.Length > 1) - { - string[] queryList = this.parsedUrl.Query.Split(new char[] { '&', '?' }); - foreach (var param in queryList) - { - if (string.IsNullOrEmpty(param)) - { - continue; - } - - int index = param.IndexOf('='); - if (index < 0) - { - continue; - } - - queryParameters.Add(this.GetParam(param.Substring(0, index), param.Substring(index + 1))); - } - } - - // parse param passed as queryParameters list - if (this.options.ContainsKey("queryParameters")) - { - foreach (var param in (string[])this.options["queryParameters"]) - { - if (string.IsNullOrEmpty(param)) - { - continue; - } - - int index = param.IndexOf('='); - if (index < 0) - { - throw new Exception(string.Format("Couldn't parse '{0}'!", param)); - } - - queryParameters.Add(this.GetParam(param.Substring(0, index), param.Substring(index + 1))); - } - } - - if (!string.IsNullOrEmpty(transformationString)) - { - if (this.isSrcParameterUsedForUrl || this.AddAsQueryParameter()) - { - queryParameters.Add(this.GetParam(Constants.TransformationParameter, transformationString)); - } - else - { - urlObject["pathname"] = "/tr:" + transformationString + urlObject["pathname"]; - } - } - - urlObject["host"] = this.RemoveTrailingSlash(urlObject["host"]); - - if (queryParameters.Count > 0) - { - urlObject["query"] = string.Join("&", queryParameters); - } - - if (this.options.ContainsKey("signed") && this.options["signed"].Equals(true)) - { - string expiryTimestamp = this.options.ContainsKey("expireSeconds") ? Utils.GetSignatureTimestamp((int)this.options["expireSeconds"]) : Constants.DefaultTimestamp; - if (expiryTimestamp != Constants.DefaultTimestamp) - { - queryParameters.Add(this.GetParam(Constants.TimestampParameter, expiryTimestamp)); - } - - string intermediateUrl = this.GenrateUrl(urlObject); - queryParameters.Add(this.GetParam(Constants.SignatureParameter, this.GetSignature(intermediateUrl, expiryTimestamp))); - - if (queryParameters.Count > 0) - { - urlObject["query"] = string.Join("&", queryParameters); - } - } - - return this.GenrateUrl(urlObject); - } - - public string GenrateUrl(Dictionary urlObject) - { - if (urlObject.ContainsKey("query")) - { - return urlObject["protocol"] + "://" + urlObject["host"] + urlObject["pathname"] + "?" + urlObject["query"]; - } - else - { - return urlObject["protocol"] + "://" + urlObject["host"] + urlObject["pathname"]; - } - } - - public string RemoveTrailingSlash(string str) - { - return str.TrimEnd(new[] { '/' }); - } - - public string AddLeadingSlash(string str) - { - str = str.TrimStart('/'); - str = "/" + str; - return str; - } - - public string GetParam(string key, string param) - { - return $"{Uri.EscapeDataString(key)}={Uri.EscapeDataString(param)}"; - } - - public bool AddAsQueryParameter() - { - if (this.options["transformationPosition"].ToString() == "query") - { - return true; - } - - return false; - } - - public string GetSignature(string url, string expiryTimestamp) - { - var endPoint = this.RemoveTrailingSlash((string)this.options["urlEndpoint"]); - string str = Regex.Replace(url, endPoint + "/", string.Empty) + expiryTimestamp; - return Utils.CalculateSignature(str, Encoding.ASCII.GetBytes((string)this.options["privateKey"])); - } -} diff --git a/Imagekit/Helper/ValidateParamater.cs b/Imagekit/Helper/ValidateParamater.cs deleted file mode 100644 index bbd86776..00000000 --- a/Imagekit/Helper/ValidateParamater.cs +++ /dev/null @@ -1,397 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - -namespace Imagekit.Helper -{ - using System.Collections.Generic; - using global::Imagekit.Constant; - using global::Imagekit.Models; - - public static class ValidateParamater - { - public static string IsValidateUpload(FileCreateRequest obj) - { - string flag = ErrorMessages.InvalidFileValue; - if (obj == null) - { - flag = ErrorMessages.InvalidFileUploadObjValue; - return flag; - } - - if (string.IsNullOrEmpty(obj.fileName)) - { - flag = ErrorMessages.MissingUploadFilenameParameter; - return flag; - } - - if (obj.file != null) - { - flag = string.Empty; - return flag; - } - - return flag; - } - - public static bool IsValidateParam(string input) - { - bool flag = false; - - if (!string.IsNullOrEmpty(input)) - { - flag = true; - return flag; - } - - return flag; - } - - public static bool IsListCheck(List input) - { - bool flag = false; - - if (input.Count > 0) - { - flag = true; - return flag; - } - - return flag; - } - - public static string IsValidateTagRequest(TagsRequest obj) - { - string flag = string.Empty; - if (obj == null) - { - flag = ErrorMessages.InvalidTagValue; - return flag; - } - - if (obj.tags == null) - { - flag = ErrorMessages.InvalidTagParamValue; - return flag; - } - - if (obj.fileIds == null) - { - flag = ErrorMessages.InvalidFiledParamValue; - return flag; - } - - return flag; - } - - public static string IsValidateAiTagRequest(AITagsRequest obj) - { - string flag = string.Empty; - if (obj == null) - { - flag = ErrorMessages.InvalidTagValue; - return flag; - } - - if (obj.AITags == null) - { - flag = ErrorMessages.InvalidTagParamValue; - return flag; - } - - if (obj.fileIds == null) - { - flag = ErrorMessages.InvalidFiledParamValue; - return flag; - } - - return flag; - } - - public static string IsValidateCustomMetaDataFieldCreateRequest(CustomMetaDataFieldCreateRequest obj) - { - string flag = string.Empty; - if (obj == null) - { - flag = ErrorMessages.InvalidMetaTagValue; - return flag; - } - - if (obj.schema == null) - { - flag = ErrorMessages.InvalidMetaTagSchemaValue; - return flag; - } - - if (string.IsNullOrEmpty(obj.name)) - { - flag = ErrorMessages.InvalidMetaTagNameValue; - return flag; - } - - if (string.IsNullOrEmpty(obj.label)) - { - flag = ErrorMessages.InvalidMetaTagLabelValue; - return flag; - } - - return flag; - } - - public static string IsValidateCustomMetaDataFieldUpdateRequest(CustomMetaDataFieldUpdateRequest obj) - { - string flag = string.Empty; - if (obj == null) - { - flag = ErrorMessages.InvalidMetaTagValue; - return flag; - } - - if (obj.schema == null) - { - flag = ErrorMessages.InvalidMetaTagSchemaValue; - return flag; - } - - if (string.IsNullOrEmpty(obj.Id)) - { - flag = ErrorMessages.InvalidMetaTagIdValue; - return flag; - } - - return flag; - } - - public static string IsValidateDeleteFileVersionRequest(DeleteFileVersionRequest obj) - { - string flag = string.Empty; - if (obj == null) - { - flag = ErrorMessages.InvalidDelVerValue; - return flag; - } - - if (string.IsNullOrEmpty(obj.fileId)) - { - flag = ErrorMessages.InvalidFieldIdDelVerValue; - return flag; - } - - if (string.IsNullOrEmpty(obj.versionId)) - { - flag = ErrorMessages.InvalidversionIdDelVerValue; - return flag; - } - - return flag; - } - - public static string IsValidateCopyRequest(CopyFileRequest obj) - { - string flag = string.Empty; - if (obj == null) - { - flag = ErrorMessages.InvalidMoveValue; - return flag; - } - - if (string.IsNullOrEmpty(obj.sourceFilePath)) - { - flag = ErrorMessages.InvalidSourceValue; - return flag; - } - - if (string.IsNullOrEmpty(obj.destinationPath)) - { - flag = ErrorMessages.InvalidDestinationValue; - return flag; - } - - return flag; - } - - public static string IsValidateMoveRequest(MoveFileRequest obj) - { - string flag = string.Empty; - if (obj == null) - { - flag = ErrorMessages.InvalidMoveValue; - return flag; - } - - if (string.IsNullOrEmpty(obj.sourceFilePath)) - { - flag = ErrorMessages.InvalidSourceValue; - return flag; - } - - if (string.IsNullOrEmpty(obj.destinationPath)) - { - flag = ErrorMessages.InvalidDestinationValue; - return flag; - } - - return flag; - } - - public static string IsValidateRenameRequest(RenameFileRequest obj) - { - string flag = string.Empty; - if (obj == null) - { - flag = ErrorMessages.InvalidRenameValue; - return flag; - } - - if (string.IsNullOrEmpty(obj.filePath)) - { - flag = ErrorMessages.InvalidRenameFilePathValue; - return flag; - } - - if (string.IsNullOrEmpty(obj.newFileName)) - { - flag = ErrorMessages.InvalidRenameNewFileNameValue; - return flag; - } - - return flag; - } - - public static string IsValidateParam(string input, string versonid) - { - string flag = string.Empty; - - if (string.IsNullOrEmpty(input) && string.IsNullOrEmpty(versonid)) - { - flag = ErrorMessages.InvalidDelVerValue; - return flag; - } - - if (string.IsNullOrEmpty(input)) - { - flag = ErrorMessages.InvalidFieldIdDelVerValue; - return flag; - } - - if (string.IsNullOrEmpty(versonid)) - { - flag = ErrorMessages.InvalidversionIdDelVerValue; - return flag; - } - - return flag; - } - - public static string IsValidateFolder(CreateFolderRequest createFolderRequest) - { - string flag = string.Empty; - - if (createFolderRequest == null) - { - flag = ErrorMessages.InvalidCreateFolderValue; - return flag; - } - - if (string.IsNullOrEmpty(createFolderRequest.folderName)) - { - flag = ErrorMessages.InvalidfolderNameValue; - return flag; - } - - if (string.IsNullOrEmpty(createFolderRequest.parentFolderPath)) - { - flag = ErrorMessages.InvalidFolderPathValue; - return flag; - } - - return flag; - } - - public static bool IsValidateDeleteFolder(DeleteFolderRequest createFolderRequest) - { - bool flag = false; - - if (createFolderRequest == null) - { - return flag; - } - - if (!string.IsNullOrEmpty(createFolderRequest.folderPath)) - { - flag = true; - return flag; - } - - return flag; - } - - public static string IsValidateCopyFolder(CopyFolderRequest createFolderRequest) - { - string flag = string.Empty; - - if (createFolderRequest == null) - { - flag = ErrorMessages.InvalidCopyFolderValue; - return flag; - } - - if (string.IsNullOrEmpty(createFolderRequest.sourceFolderPath)) - { - flag = ErrorMessages.InvalidCopysourceFolderPathValue; - return flag; - } - - if (string.IsNullOrEmpty(createFolderRequest.destinationPath)) - { - flag = ErrorMessages.InvalidCopydestinationPathValue; - return flag; - } - - return flag; - } - - public static string IsValidateMoveFolder(MoveFolderRequest createFolderRequest) - { - string flag = string.Empty; - - if (createFolderRequest == null) - { - flag = ErrorMessages.InvalidCopyFolderValue; - return flag; - } - - if (string.IsNullOrEmpty(createFolderRequest.sourceFolderPath)) - { - flag = ErrorMessages.InvalidCopysourceFolderPathValue; - return flag; - } - - if (string.IsNullOrEmpty(createFolderRequest.destinationPath)) - { - flag = ErrorMessages.InvalidCopydestinationPathValue; - return flag; - } - - return flag; - } - - public static string IsValidateUpdateFile(FileUpdateRequest obj) - { - string flag = string.Empty; - if (obj == null) - { - flag = ErrorMessages.FileIdMissing; - return flag; - } - - if (string.IsNullOrEmpty(obj.fileId)) - { - flag = ErrorMessages.FileIdMissing; - return flag; - } - - return flag; - } - } -} diff --git a/Imagekit/IImageKit.cs b/Imagekit/IImageKit.cs deleted file mode 100644 index 9ef4ed94..00000000 --- a/Imagekit/IImageKit.cs +++ /dev/null @@ -1,62 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - -namespace Imagekit.Sdk -{ - using System.Collections.Generic; - using global::Imagekit.Models; - - public interface IImagekit - { - ResponseMetaData AddTags(TagsRequest tagsRequest); - - ResponseMetaData BulkDeleteFiles(List fileIds); - - ResponseMetaData CopyFile(CopyFileRequest copyFileRequest); - - ResponseMetaData CopyFolder(CopyFolderRequest copyFolderRequest); - - ResponseMetaData CreateCustomMetaDataFields(CustomMetaDataFieldCreateRequest customMetaDataFieldCreateRequest); - - ResponseMetaData CreateFolder(CreateFolderRequest createFolderRequest); - - ResponseMetaData DeleteCustomMetaDataField(string id); - - ResponseMetaData DeleteFile(string fileId); - - ResponseMetaData DeleteFileVersion(DeleteFileVersionRequest deleteFileVersionRequest); - - ResponseMetaData DeleteFolder(DeleteFolderRequest deleteFolderRequest); - - ResponseMetaData GetBulkJobStatus(string jobId); - - ResponseMetaData GetCustomMetaDataFields(bool includeDeleted); - - ResponseMetaData GetFileDetail(string fileId); - - ResponseMetaData GetFileMetadata(string fileId); - - ResponseMetaData GetFileVersionDetails(string fileId, string versionId); - - ResponseMetaData GetFileVersions(string fileId); - - ResponseMetaData GetRemoteFileMetadata(string url); - - ResponseMetaData MoveFile(MoveFileRequest moveFileRequest); - - ResponseMetaData MoveFolder(MoveFolderRequest moveFolderRequest); - - ResponseMetaData RemoveAITags(AITagsRequest aITagsRequest); - - ResponseMetaData RemoveTags(TagsRequest tagsRequest); - - ResponseMetaData RenameFile(RenameFileRequest renameFileRequest); - - ResponseMetaData RestoreFileVersion(string fileId, string versionId); - - ResponseMetaData UpdateCustomMetaDataFields(CustomMetaDataFieldUpdateRequest customMetaDataFieldUpdateRequest); - - ResponseMetaData Upload(FileCreateRequest fileCreateRequest); - } -} \ No newline at end of file diff --git a/Imagekit/Imagekit.cs b/Imagekit/Imagekit.cs deleted file mode 100644 index e877c1f6..00000000 --- a/Imagekit/Imagekit.cs +++ /dev/null @@ -1,367 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - -namespace Imagekit.Sdk -{ - using System; - using System.Collections.Generic; - using System.Text; - using System.Threading.Tasks; - using global::Imagekit.Models; - using global::Imagekit.Models.Response; - using global::Imagekit.Util; - - public class ImagekitClient : BaseImagekit - { - private readonly RestClient restClient; - private readonly string privateKey; - - public ImagekitClient(string publicKey, string privateKey, string urlEndPoint) - : base(privateKey, urlEndPoint, "path") - { - this.restClient = new RestClient(privateKey, urlEndPoint, new System.Net.Http.HttpClient()); - this.Add("privateKey", privateKey); - this.Add("publicKey", publicKey); - this.privateKey = privateKey; - } - - public Result Upload(FileCreateRequest fileCreateRequest) - { - return (Result)this.restClient.Upload(fileCreateRequest); - } - - public Result UpdateFileDetail(FileUpdateRequest fileUpdateRequest) - { - return (Result)this.restClient.UpdateFileDetail(fileUpdateRequest); - } - - public async Task UpdateFileDetailAsync(FileUpdateRequest fileUpdateRequest) - { - return (Result)await this.restClient.UpdateFileDetailAsync(fileUpdateRequest); - } - - public ResultCache PurgeCache(string url) - { - return (ResultCache)this.restClient.PurgeCache(url); - } - - public async Task PurgeCacheAsync(string url) - { - return (ResultCache)await this.restClient.PurgeCacheAsync(url); - } - - public ResultCacheStatus PurgeStatus(string purgeRequestId) - { - return (ResultCacheStatus)this.restClient.PurgeStatus(purgeRequestId); - } - - public async Task PurgeStatusAsync(string url) - { - return (ResultCacheStatus)await this.restClient.PurgeStatusAsync(url); - } - - public Result GetFileDetail(string url) - { - return (Result)this.restClient.GetFileDetail(url); - } - - public ResultList GetFileListRequest(GetFileListRequest getFileListRequest) - { - return (ResultList)this.restClient.GetFileListRequest(getFileListRequest); - } - - public ResultMetaData GetFileMetadata(string fileId) - { - return (ResultMetaData)this.restClient.GetFileMetaData(fileId); - } - - public ResultMetaData GetRemoteFileMetadata(string url) - { - return (ResultMetaData)this.restClient.GetRemoteFileMetaData(url); - } - - public ResultDelete DeleteFile(string fileId) - { - return (ResultDelete)this.restClient.DeleteFile(fileId); - } - - public ResultFileDelete BulkDeleteFiles(List fileIds) - { - return (ResultFileDelete)this.restClient.BulkDeleteFiles(fileIds); - } - - public ResultTags AddTags(TagsRequest tagsRequest) - { - return (ResultTags)this.restClient.ManageTags(tagsRequest, "addTags"); - } - - public void Clear() - { - throw new NotImplementedException(); - } - - public ResultTags RemoveAITags(AITagsRequest aITagsRequest) - { - return (ResultTags)this.restClient.RemoveAITags(aITagsRequest); - } - - public ResultTags RemoveTags(TagsRequest tagsRequest) - { - return (ResultTags)this.restClient.ManageTags(tagsRequest, "removeTags"); - } - - public ResultCustomMetaDataFieldList GetCustomMetaDataFields(bool includeDeleted) - { - return (ResultCustomMetaDataFieldList)this.restClient.GetCustomMetaDataFields(includeDeleted); - } - - public ResultCustomMetaDataField CreateCustomMetaDataFields( - CustomMetaDataFieldCreateRequest customMetaDataFieldCreateRequest) - { - return (ResultCustomMetaDataField)this.restClient.CreateCustomMetaDataFields(customMetaDataFieldCreateRequest); - } - - public ResultNoContent DeleteCustomMetaDataField(string id) - { - return (ResultNoContent)this.restClient.DeleteCustomMetaDataField(id); - } - - public ResultCustomMetaDataField UpdateCustomMetaDataFields( - CustomMetaDataFieldUpdateRequest customMetaDataFieldUpdateRequest) - { - return (ResultCustomMetaDataField)this.restClient.UpdateCustomMetaDataFields(customMetaDataFieldUpdateRequest); - } - - public ResultNoContent DeleteFileVersion(DeleteFileVersionRequest deleteFileVersionRequest) - { - return (ResultNoContent)this.restClient.DeleteFileVersion(deleteFileVersionRequest); - } - - public ResultNoContent CopyFile(CopyFileRequest copyFileRequest) - { - return (ResultNoContent)this.restClient.CopyFile(copyFileRequest); - } - - public ResultNoContent MoveFile(MoveFileRequest moveFileRequest) - { - return (ResultNoContent)this.restClient.MoveFile(moveFileRequest); - } - - public ResultRenameFile RenameFile(RenameFileRequest renameFileRequest) - { - return (ResultRenameFile)this.restClient.RenameFile(renameFileRequest); - } - - public Result RestoreFileVersion(string fileId, string versionId) - { - return (Result)this.restClient.RestoreFileVersion(fileId, versionId); - } - - public ResultEmptyBlock CreateFolder(CreateFolderRequest createFolderRequest) - { - return (ResultEmptyBlock)this.restClient.CreateFolder(createFolderRequest); - } - - public ResultNoContent DeleteFolder(DeleteFolderRequest deleteFolderRequest) - { - return (ResultNoContent)this.restClient.DeleteFolder(deleteFolderRequest); - } - - public ResultOfFolderActions CopyFolder(CopyFolderRequest copyFolderRequest) - { - return (ResultOfFolderActions)this.restClient.CopyFolder(copyFolderRequest); - } - - public ResultOfFolderActions MoveFolder(MoveFolderRequest moveFolderRequest) - { - return (ResultOfFolderActions)this.restClient.MoveFolder(moveFolderRequest); - } - - public ResultBulkJobStatus GetBulkJobStatus(string jobId) - { - return (ResultBulkJobStatus)this.restClient.GetBulkJobStatus(jobId); - } - - public ResultFileVersions GetFileVersions(string fileId) - { - return (ResultFileVersions)this.restClient.GetFileVersions(fileId); - } - - public ResultFileVersionDetails GetFileVersionDetails(string fileId, string versionId) - { - return (ResultFileVersionDetails)this.restClient.GetFileVersionDetails(fileId, versionId); - } - - public async Task UploadAsync(FileCreateRequest fileCreateRequest) - { - return (Result)await this.restClient.UploadAsync(fileCreateRequest); - } - - public async Task GetFileDetailAsync(string fileId) - { - return await this.restClient.GetFileDetailAsync(fileId); - } - - public async Task GetFileMetadataAsync(string fileId) - { - return (Result)await this.restClient.GetFileMetaDataAsync(fileId); - } - - public async Task GetRemoteFileMetadataAsync(string url) - { - return (ResultMetaData)await this.restClient.GetRemoteFileMetaDataAsync(url); - } - - public async Task DeleteFileAsync(string fileId) - { - return (ResultDelete)await this.restClient.DeleteFileAsync(fileId); - } - - public async Task BulkDeleteFilesAsync(List fileIds) - { - return (ResultFileDelete)await this.restClient.BulkDeleteFilesAsync(fileIds); - } - - public async Task AddTagsAsync(TagsRequest tagsRequest) - { - return (ResultTags)await this.restClient.ManageTagsAsync(tagsRequest, "addTags"); - } - - public async Task RemoveAITagsAsync(AITagsRequest aITagsRequest) - { - return (ResultTags)await this.restClient.RemoveAITagsAsync(aITagsRequest); - } - - public async Task RemoveTagsAsync(TagsRequest tagsRequest) - { - return (ResultTags)await this.restClient.ManageTagsAsync(tagsRequest, "removeTags"); - } - - public async Task GetCustomMetaDataFieldsAsync(bool includeDeleted) - { - return (ResultCustomMetaDataFieldList)await this.restClient.GetCustomMetaDataFieldsAsync(includeDeleted); - } - - public async Task CreateCustomMetaDataFieldsAsync( - CustomMetaDataFieldCreateRequest customMetaDataFieldCreateRequest) - { - return (ResultCustomMetaDataField)await this.restClient.CreateCustomMetaDataFieldsAsync(customMetaDataFieldCreateRequest); - } - - public async Task DeleteCustomMetaDataFieldAsync(string id) - { - return (ResultNoContent)await this.restClient.DeleteCustomMetaDataFieldAsync(id); - } - - public async Task UpdateCustomMetaDataFieldsAsync( - CustomMetaDataFieldUpdateRequest customMetaDataFieldUpdateRequest) - { - return (ResultCustomMetaDataField)await this.restClient.UpdateCustomMetaDataFieldsAsync(customMetaDataFieldUpdateRequest); - } - - public async Task DeleteFileVersionAsync(DeleteFileVersionRequest deleteFileVersionRequest) - { - return (ResultNoContent)await this.restClient.DeleteFileVersionAsync(deleteFileVersionRequest); - } - - public async Task CopyFileAsync(CopyFileRequest copyFileRequest) - { - return (ResultNoContent)await this.restClient.CopyFileAsync(copyFileRequest); - } - - public async Task MoveFileAsync(MoveFileRequest moveFileRequest) - { - return (ResultNoContent)await this.restClient.MoveFileAsync(moveFileRequest); - } - - public async Task RenameFileAsync(RenameFileRequest renameFileRequest) - { - return await this.restClient.RenameFileAsync(renameFileRequest); - } - - public async Task RestoreFileVersionAsync(string fileId, string versionId) - { - return (ResultRenameFile)await this.restClient.RestoreFileVersionAsync(fileId, versionId); - } - - public async Task CreateFolderAsync(CreateFolderRequest createFolderRequest) - { - return (ResultEmptyBlock)await this.restClient.CreateFolderAsync(createFolderRequest); - } - - public async Task DeleteFolderAsync(DeleteFolderRequest deleteFolderRequest) - { - return (ResultNoContent)await this.restClient.DeleteFolderAsync(deleteFolderRequest); - } - - public async Task CopyFolderAsync(CopyFolderRequest copyFolderRequest) - { - return (ResultOfFolderActions)await this.restClient.CopyFolderAsync(copyFolderRequest); - } - - public async Task MoveFolderAsync(MoveFolderRequest moveFolderRequest) - { - return await this.restClient.MoveFolderAsync(moveFolderRequest); - } - - public async Task GetBulkJobStatusAsync(string jobId) - { - return (ResultOfFolderActions)await this.restClient.GetBulkJobStatusAsync(jobId); - } - - public async Task GetFileVersionsAsync(string fileId) - { - return (ResultFileVersions)await this.restClient.GetFileVersionsAsync(fileId); - } - - public async Task GetFileVersionDetailsAsync(string fileId, string versionId) - { - return (ResultFileVersionDetails)await this.restClient.GetFileVersionDetailsAsync(fileId, versionId); - } - - public async Task GetFileListRequestAsync(GetFileListRequest getFileListRequest) - { - return (ResultList)await this.restClient.GetFileListRequestAsync(getFileListRequest); - } - - public int PHashDistance(string firstHex, string secondHex) - { - return Calculation.GetHammingDistance(firstHex, secondHex); - } - - /// - /// Generate Auth params for client-side upload - /// - /// Random Token String - /// Expire time for the token - /// Returns Authparams including token, expiry time and signature. - public AuthParamResponse GetAuthenticationParameters(string token = null, string expire = null) - { - var dEFAULT_TIME_DIFF = 60 * 30; - - AuthParamResponse authParameters = new AuthParamResponse(); - authParameters.token = token; - authParameters.expire = expire; - authParameters.signature = string.Empty; - string defaultExpire = Utils.GetSignatureTimestamp(dEFAULT_TIME_DIFF); - - if (string.IsNullOrEmpty(expire)) - { - expire = defaultExpire; - } - - if (string.IsNullOrEmpty(token)) - { - token = Guid.NewGuid().ToString(); - } - - string signature = Utils.CalculateSignature(token + expire, Encoding.ASCII.GetBytes((string)this.privateKey)); - authParameters.token = token; - authParameters.expire = expire; - authParameters.signature = signature; - - return authParameters; - } - } -} \ No newline at end of file diff --git a/Imagekit/Imagekit.csproj b/Imagekit/Imagekit.csproj deleted file mode 100644 index 013cc8ba..00000000 --- a/Imagekit/Imagekit.csproj +++ /dev/null @@ -1,124 +0,0 @@ - - - - Library - Imagekit - Imagekit - net7.0;net5.0;net6.0;netcoreapp3.1;netstandard2.0 - 8 - © Imagekit Private Limited 2019 - false - - https://github.com/imagekit-developer/imagekit-dotnet/blob/v2.x/LICENSE - Imagekit - https://imagekit.io - Image Resize Crop SmartCrop Rotate Quality Watermark Gif Jpg Jpeg Bitmap PNG Tiff Webp Webm Svg Optimization - Imagekit.io DotNet Library - Library to Integrate Imagekit.io Service. - Imagekit - true - 5.0.0 - true - false - 5.0.0 - git@github.com:imagekit-developer/imagekit-dotnet.git - true - -Fixes - false - - - - - 1701;1702;1591;NU5125;NU5048;NU1504;NU5125;SYSLIB0014; - $(WarningsAsErrors); - - - - 1701;1702;1591;NU5125;NU5048;NU1504;NU5125;SYSLIB0014; - $(WarningsAsErrors); - - - - 1701;1702;1591;NU5125;NU5048;NU1504;NU5125;SYSLIB0014; - $(WarningsAsErrors); - 4 - - - - 1701;1702;1591;NU5125;NU5048;NU1504;NU5125;SYSLIB0014; - $(WarningsAsErrors); - 4 - - - - 1701;1702;1591;NU5125;NU5048;NU1504;NU5125;SYSLIB0014; - $(WarningsAsErrors); - 4 - - - - 1701;1702;1591;NU5125;NU5048;NU1504;NU5125;SYSLIB0014; - $(WarningsAsErrors); - 4 - - - - 1701;1702;1591;NU5125;NU5048;NU1504;NU5125;SYSLIB0014; - $(WarningsAsErrors); - - - - 1701;1702;1591;NU5125;NU5048;NU1504;NU5125;SYSLIB0014; - $(WarningsAsErrors); - - - - 1701;1702;1591;NU5125;NU5048;NU1504;NU5125;SYSLIB0014; - $(WarningsAsErrors); - - - - 1701;1702;1591;NU5125;NU5048;NU1504;NU5125;SYSLIB0014; - $(WarningsAsErrors); - - - - - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Imagekit/Models/AITagsRequest.cs b/Imagekit/Models/AITagsRequest.cs deleted file mode 100644 index 4d1db13d..00000000 --- a/Imagekit/Models/AITagsRequest.cs +++ /dev/null @@ -1,23 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - -namespace Imagekit -{ - using System.Collections.Generic; - - public class AITagsRequest - { - public List fileIds - { - get; - set; - } - - public List AITags - { - get; - set; - } - } -} \ No newline at end of file diff --git a/Imagekit/Models/AuthParamResponse.cs b/Imagekit/Models/AuthParamResponse.cs deleted file mode 100644 index 67e8f446..00000000 --- a/Imagekit/Models/AuthParamResponse.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace Imagekit.Models -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Text; - using System.Threading.Tasks; - using Newtonsoft.Json; - - public class AuthParamResponse - { - public string token { get; set; } - - public string expire { get; set; } - - public string signature { get; set; } - } -} diff --git a/Imagekit/Models/CopyFileRequest.cs b/Imagekit/Models/CopyFileRequest.cs deleted file mode 100644 index 6dfb8bcf..00000000 --- a/Imagekit/Models/CopyFileRequest.cs +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - -namespace Imagekit.Models -{ - public class CopyFileRequest - { - public string sourceFilePath { get; set; } - - public string destinationPath { get; set; } - - public bool includeFileVersions { get; set; } - } -} \ No newline at end of file diff --git a/Imagekit/Models/CopyFolderRequest.cs b/Imagekit/Models/CopyFolderRequest.cs deleted file mode 100644 index 1e4b452c..00000000 --- a/Imagekit/Models/CopyFolderRequest.cs +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - -namespace Imagekit.Models -{ - public class CopyFolderRequest - { - public string sourceFolderPath { get; set; } - - public string destinationPath { get; set; } - - public bool includeFileVersions { get; set; } - } -} \ No newline at end of file diff --git a/Imagekit/Models/CreateFolderRequest.cs b/Imagekit/Models/CreateFolderRequest.cs deleted file mode 100644 index b308c51f..00000000 --- a/Imagekit/Models/CreateFolderRequest.cs +++ /dev/null @@ -1,13 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - -namespace Imagekit.Models -{ - public class CreateFolderRequest - { - public string folderName { get; set; } - - public string parentFolderPath { get; set; } - } -} \ No newline at end of file diff --git a/Imagekit/Models/CustomMetaDataFieldCreateRequest.cs b/Imagekit/Models/CustomMetaDataFieldCreateRequest.cs deleted file mode 100644 index 7286fe48..00000000 --- a/Imagekit/Models/CustomMetaDataFieldCreateRequest.cs +++ /dev/null @@ -1,22 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - -namespace Imagekit.Models -{ - public class CustomMetaDataFieldCreateRequest - { - public string name { get; set; } - - public string label { get; set; } - - public CustomMetaDataFieldSchemaObject schema { get; set; } - } - - public class CustomMetaDataFieldUploadRequest - { - public string name { get; set; } - - public CustomMetaDataFieldSchemaObject schema { get; set; } - } -} \ No newline at end of file diff --git a/Imagekit/Models/CustomMetaDataFieldSchemaObject.cs b/Imagekit/Models/CustomMetaDataFieldSchemaObject.cs deleted file mode 100644 index 385a7a02..00000000 --- a/Imagekit/Models/CustomMetaDataFieldSchemaObject.cs +++ /dev/null @@ -1,51 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - -namespace Imagekit.Models -{ - using System.ComponentModel; - - public class CustomMetaDataFieldSchemaObject - { - public string type { get; set; } - - public string[] selectOptions { get; set; } - - public object defaultValue { get; set; } - - private bool IsValueRequired; - - [DefaultValue(false)] - public bool isValueRequired - { - get - { - return this.IsValueRequired; - } - - set - { - this.IsValueRequired = value; - } - } - - public object minValue { get; set; } - - public object maxValue { get; set; } - - public int minLength { get; set; } - - public int maxLength { get; set; } - - public enum CustomMetaDataTypeEnum - { - Text, - Textarea, - Number, - Date, - SingleSelect, - MultiSelect, - } - } -} \ No newline at end of file diff --git a/Imagekit/Models/CustomMetaDataFieldUpdateRequest.cs b/Imagekit/Models/CustomMetaDataFieldUpdateRequest.cs deleted file mode 100644 index 9d920e1b..00000000 --- a/Imagekit/Models/CustomMetaDataFieldUpdateRequest.cs +++ /dev/null @@ -1,13 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - -namespace Imagekit.Models -{ - public class CustomMetaDataFieldUpdateRequest - { - public string Id { get; set; } - - public CustomMetaDataFieldSchemaObject schema { get; set; } - } -} \ No newline at end of file diff --git a/Imagekit/Models/DeleteFileVersionRequest.cs b/Imagekit/Models/DeleteFileVersionRequest.cs deleted file mode 100644 index c0aa7d78..00000000 --- a/Imagekit/Models/DeleteFileVersionRequest.cs +++ /dev/null @@ -1,13 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - -namespace Imagekit.Models -{ - public class DeleteFileVersionRequest - { - public string fileId { get; set; } - - public string versionId { get; set; } - } -} \ No newline at end of file diff --git a/Imagekit/Models/DeleteFolderRequest.cs b/Imagekit/Models/DeleteFolderRequest.cs deleted file mode 100644 index dcfe9cff..00000000 --- a/Imagekit/Models/DeleteFolderRequest.cs +++ /dev/null @@ -1,11 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - -namespace Imagekit.Models -{ - public class DeleteFolderRequest - { - public string folderPath { get; set; } - } -} \ No newline at end of file diff --git a/Imagekit/Models/ExtensionModel.cs b/Imagekit/Models/ExtensionModel.cs deleted file mode 100644 index 32b5f270..00000000 --- a/Imagekit/Models/ExtensionModel.cs +++ /dev/null @@ -1,32 +0,0 @@ -namespace Imagekit.Models -{ - using System.Collections.Generic; - - public class Extension - { - public string name { get; set; } - } - - public class options - { - public bool add_shadow { get; set; } - - public bool? semitransparency { get; set; } - - public string? bg_color { get; set; } - - public string? bg_image_url { get; set; } - } - - public class BackGroundImage : Extension - { - public options options { get; set; } - } - - public class AutoTags : Extension - { - public int? minConfidence { get; set; } - - public int? maxTags { get; set; } - } -} diff --git a/Imagekit/Models/FileCreateRequest.cs b/Imagekit/Models/FileCreateRequest.cs deleted file mode 100644 index 9787a6bc..00000000 --- a/Imagekit/Models/FileCreateRequest.cs +++ /dev/null @@ -1,47 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - -using System; -using System.Collections; -using System.Collections.Generic; -using Imagekit.Models; - -public class FileCreateRequest -{ - public string fileName { get; set; } - - public bool useUniqueFileName { get; set; } - - public List tags { get; set; } - - public string folder { get; set; } - - public string customCoordinates { get; set; } - - public List responseFields { get; set; } - - public List extensions { get; set; } - - public string webhookUrl { get; set; } - - public bool overwriteFile { get; set; } - - public bool overwriteAITags { get; set; } - - public bool overwriteTags { get; set; } - - public bool overwriteCustomMetadata { get; set; } - - public Hashtable customMetadata { get; set; } - - public object file { get; set; } - - public bool isPrivateFile { get; set; } - - public UploadTransformation transformation { get; set; } - - public string checks { get; set; } - - public bool? isPublished { get; set; } -} \ No newline at end of file diff --git a/Imagekit/Models/FileUpdateRequest.cs b/Imagekit/Models/FileUpdateRequest.cs deleted file mode 100644 index 9d1bd552..00000000 --- a/Imagekit/Models/FileUpdateRequest.cs +++ /dev/null @@ -1,24 +0,0 @@ -namespace Imagekit.Models -{ - using System.Collections; - using System.Collections.Generic; - - public class FileUpdateRequest - { - public string fileId { get; set; } - - public List removeAITags { get; set; } - - public string webhookUrl { get; set; } - - public List extensions { get; set; } - - public List tags { get; set; } - - public string customCoordinates { get; set; } - - public Hashtable customMetadata { get; set; } - - public PublishStatus publish { get; set; } - } -} diff --git a/Imagekit/Models/GetFileListRequest.cs b/Imagekit/Models/GetFileListRequest.cs deleted file mode 100644 index 67da7164..00000000 --- a/Imagekit/Models/GetFileListRequest.cs +++ /dev/null @@ -1,27 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - -namespace Imagekit.Models -{ - public class GetFileListRequest - { - public string Name { get; set; } - - public string Type { get; set; } - - public string Sort { get; set; } - - public string Path { get; set; } - - public string SearchQuery { get; set; } - - public string FileType { get; set; } - - public int Limit { get; set; } - - public int Skip { get; set; } - - public string[] Tags { get; set; } - } -} diff --git a/Imagekit/Models/MoveFileRequest.cs b/Imagekit/Models/MoveFileRequest.cs deleted file mode 100644 index 0b247186..00000000 --- a/Imagekit/Models/MoveFileRequest.cs +++ /dev/null @@ -1,10 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - -public class MoveFileRequest -{ - public string sourceFilePath { get; set; } - - public string destinationPath { get; set; } -} \ No newline at end of file diff --git a/Imagekit/Models/MoveFolderRequest.cs b/Imagekit/Models/MoveFolderRequest.cs deleted file mode 100644 index 8cc3818c..00000000 --- a/Imagekit/Models/MoveFolderRequest.cs +++ /dev/null @@ -1,10 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - -public class MoveFolderRequest -{ - public string sourceFolderPath { get; set; } - - public string destinationPath { get; set; } -} \ No newline at end of file diff --git a/Imagekit/Models/PublishStatus.cs b/Imagekit/Models/PublishStatus.cs deleted file mode 100644 index be11998e..00000000 --- a/Imagekit/Models/PublishStatus.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Imagekit.Models -{ - using System.Collections.Generic; - - public class PublishStatus - { - public bool isPublished { get; set; } - public bool? includeFileVersions { get; set; } - } - -} diff --git a/Imagekit/Models/RenameFileRequest.cs b/Imagekit/Models/RenameFileRequest.cs deleted file mode 100644 index 6585492c..00000000 --- a/Imagekit/Models/RenameFileRequest.cs +++ /dev/null @@ -1,28 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - -using System.ComponentModel; - -public class RenameFileRequest -{ - public string filePath { get; set; } - - public string newFileName { get; set; } - - private bool IspurgeCache; - - [DefaultValue(false)] - public bool purgeCache - { - get - { - return this.IspurgeCache; - } - - set - { - this.IspurgeCache = value; - } - } -} \ No newline at end of file diff --git a/Imagekit/Models/Response/MetaData.cs b/Imagekit/Models/Response/MetaData.cs deleted file mode 100644 index 2cf6288d..00000000 --- a/Imagekit/Models/Response/MetaData.cs +++ /dev/null @@ -1,30 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - -namespace Imagekit.Models.Response -{ - using System.Diagnostics.CodeAnalysis; - - [ExcludeFromCodeCoverage] - public class MetaData - { - public float Height { get; set; } - - public float Width { get; set; } - - public float Size { get; set; } - - public string Format { get; set; } - - public bool HasColorProfile { get; set; } - - public float Quality { get; set; } - - public float Density { get; set; } - - public bool HasTransparency { get; set; } - - public string PHash { get; set; } - } -} diff --git a/Imagekit/Models/Response/Result.cs b/Imagekit/Models/Response/Result.cs deleted file mode 100644 index 42d86dac..00000000 --- a/Imagekit/Models/Response/Result.cs +++ /dev/null @@ -1,109 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using Newtonsoft.Json; - -[ExcludeFromCodeCoverage] - -// Root myDeserializedClass = JsonConvert.DeserializeObject(myJsonResponse); -public class Exif -{ -} - -public class ExtensionStatus -{ - [JsonProperty("remove-bg")] - public string RemoveBg { get; set; } - - [JsonProperty("google-auto-tagging")] - public string GoogleAutoTagging { get; set; } -} - -public class Metadata -{ - public int height { get; set; } - - public int width { get; set; } - - public int size { get; set; } - - public string format { get; set; } - - public bool hasColorProfile { get; set; } - - public int quality { get; set; } - - public int density { get; set; } - - public bool hasTransparency { get; set; } - - public Exif exif { get; set; } - - public string pHash { get; set; } -} - -public class Result : ResponseMetaData -{ - public string fileId { get; set; } - - public string name { get; set; } - - public int size { get; set; } - - public VersionInfo versionInfo { get; set; } - - public string filePath { get; set; } - - public string url { get; set; } - - public string fileType { get; set; } - - public int height { get; set; } - - public int width { get; set; } - - public string thumbnailUrl { get; set; } - - public List tags { get; set; } - - public object AITags { get; set; } - - public bool isPrivateFile { get; set; } - - public string customCoordinates { get; set; } - - public Metadata metadata { get; set; } - - public ExtensionStatus extensionStatus { get; set; } -} - -public class VersionInfo -{ - public string id { get; set; } - - public string name { get; set; } -} - -public class CustomMetadata -{ -} - -public class EmbeddedMetadata -{ - public int XResolution { get; set; } - - public int YResolution { get; set; } - - public DateTime DateCreated { get; set; } - - public DateTime DateTimeCreated { get; set; } -} - -public class ResultDelete : ResponseMetaData -{ - public string fileId { get; set; } -} \ No newline at end of file diff --git a/Imagekit/Models/Response/ResultBulkJobStatus.cs b/Imagekit/Models/Response/ResultBulkJobStatus.cs deleted file mode 100644 index f2b34ca2..00000000 --- a/Imagekit/Models/Response/ResultBulkJobStatus.cs +++ /dev/null @@ -1,14 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// -using System.Diagnostics.CodeAnalysis; - -[ExcludeFromCodeCoverage] -public class ResultBulkJobStatus : ResponseMetaData -{ - public string JobId { get; set; } - - public string Type { get; set; } - - public string Status { get; set; } -} \ No newline at end of file diff --git a/Imagekit/Models/Response/ResultCache.cs b/Imagekit/Models/Response/ResultCache.cs deleted file mode 100644 index 23ce9589..00000000 --- a/Imagekit/Models/Response/ResultCache.cs +++ /dev/null @@ -1,13 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - -using System.Diagnostics.CodeAnalysis; - -[ExcludeFromCodeCoverage] -public class ResultCache : ResponseMetaData -{ - public string Help { get; set; } - - public string RequestId { get; set; } -} \ No newline at end of file diff --git a/Imagekit/Models/Response/ResultCacheStatus.cs b/Imagekit/Models/Response/ResultCacheStatus.cs deleted file mode 100644 index db95f5b9..00000000 --- a/Imagekit/Models/Response/ResultCacheStatus.cs +++ /dev/null @@ -1,13 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - -using System.Diagnostics.CodeAnalysis; - -[ExcludeFromCodeCoverage] -public class ResultCacheStatus : ResponseMetaData -{ - public string Help { get; set; } - - public string Status { get; set; } -} \ No newline at end of file diff --git a/Imagekit/Models/Response/ResultCustomMetaDataField.cs b/Imagekit/Models/Response/ResultCustomMetaDataField.cs deleted file mode 100644 index 12b807b5..00000000 --- a/Imagekit/Models/Response/ResultCustomMetaDataField.cs +++ /dev/null @@ -1,18 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - -using System.Diagnostics.CodeAnalysis; -using Imagekit.Models; - -[ExcludeFromCodeCoverage] -public class ResultCustomMetaDataField : ResponseMetaData -{ - public string id { get; set; } - - public string name { get; set; } - - public string label { get; set; } - - public CustomMetaDataFieldSchemaObject Schema { get; set; } -} \ No newline at end of file diff --git a/Imagekit/Models/Response/ResultCustomMetaDataFieldList.cs b/Imagekit/Models/Response/ResultCustomMetaDataFieldList.cs deleted file mode 100644 index 6ad9b067..00000000 --- a/Imagekit/Models/Response/ResultCustomMetaDataFieldList.cs +++ /dev/null @@ -1,12 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; - -[ExcludeFromCodeCoverage] -public class ResultCustomMetaDataFieldList : ResponseMetaData -{ - public List ResultCustomMetaDataFieldList1 { get; set; } = new List(); -} \ No newline at end of file diff --git a/Imagekit/Models/Response/ResultEmptyBlock.cs b/Imagekit/Models/Response/ResultEmptyBlock.cs deleted file mode 100644 index c3e53d5f..00000000 --- a/Imagekit/Models/Response/ResultEmptyBlock.cs +++ /dev/null @@ -1,9 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// -using System.Diagnostics.CodeAnalysis; - -[ExcludeFromCodeCoverage] -public class ResultEmptyBlock : ResponseMetaData -{ -} \ No newline at end of file diff --git a/Imagekit/Models/Response/ResultException.cs b/Imagekit/Models/Response/ResultException.cs deleted file mode 100644 index cd84c4d2..00000000 --- a/Imagekit/Models/Response/ResultException.cs +++ /dev/null @@ -1,12 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// -using System.Diagnostics.CodeAnalysis; - -[ExcludeFromCodeCoverage] -public class ResultException : ResponseMetaData -{ - private string Message { get; set; } - - private string Help { get; set; } -} \ No newline at end of file diff --git a/Imagekit/Models/Response/ResultFileDelete.cs b/Imagekit/Models/Response/ResultFileDelete.cs deleted file mode 100644 index 06da1f29..00000000 --- a/Imagekit/Models/Response/ResultFileDelete.cs +++ /dev/null @@ -1,16 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; - -[ExcludeFromCodeCoverage] -public class ResultFileDelete : ResponseMetaData -{ - public string Help { get; set; } - - public List SuccessfullyDeletedfileIds { get; set; } - - public List MissingfileIds { get; set; } -} \ No newline at end of file diff --git a/Imagekit/Models/Response/ResultFileVersionDetails.cs b/Imagekit/Models/Response/ResultFileVersionDetails.cs deleted file mode 100644 index 4e2108fc..00000000 --- a/Imagekit/Models/Response/ResultFileVersionDetails.cs +++ /dev/null @@ -1,54 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using Newtonsoft.Json.Linq; - -[ExcludeFromCodeCoverage] -public class ResultFileVersionDetails : ResponseMetaData -{ - public string type { get; set; } - - public string name { get; set; } - - public DateTime createdAt { get; set; } - - public DateTime updatedAt { get; set; } - - public string fileId { get; set; } - - public object tags { get; set; } - - public object AITags { get; set; } - - public VersionInfo versionInfo { get; set; } - - public EmbeddedMetadata embeddedMetadata { get; set; } - - public object customCoordinates { get; set; } - - public CustomMetadata customMetadata { get; set; } - - public bool isPrivateFile { get; set; } - - public string url { get; set; } - - public string thumbnail { get; set; } - - public string fileType { get; set; } - - public string filePath { get; set; } - - public int height { get; set; } - - public int width { get; set; } - - public int size { get; set; } - - public bool hasAlpha { get; set; } - - public string mime { get; set; } -} \ No newline at end of file diff --git a/Imagekit/Models/Response/ResultFileVersions.cs b/Imagekit/Models/Response/ResultFileVersions.cs deleted file mode 100644 index 14120fd3..00000000 --- a/Imagekit/Models/Response/ResultFileVersions.cs +++ /dev/null @@ -1,12 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; - -[ExcludeFromCodeCoverage] -public class ResultFileVersions : ResponseMetaData -{ - public List ResultFileVersionDetailsList { get; set; } = new List(); -} \ No newline at end of file diff --git a/Imagekit/Models/Response/ResultList.cs b/Imagekit/Models/Response/ResultList.cs deleted file mode 100644 index 34aeb73c..00000000 --- a/Imagekit/Models/Response/ResultList.cs +++ /dev/null @@ -1,60 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; - -[ExcludeFromCodeCoverage] -public class ResultList : ResponseMetaData -{ - public string Help { get; set; } - - public List FileList { get; set; } -} - -public class Root -{ - public string type { get; set; } - - public string name { get; set; } - - public DateTime createdAt { get; set; } - - public DateTime updatedAt { get; set; } - - public string fileId { get; set; } - - public List tags { get; set; } - - public object AITags { get; set; } - - public VersionInfo versionInfo { get; set; } - - public EmbeddedMetadata embeddedMetadata { get; set; } - - public string customCoordinates { get; set; } - - public CustomMetadata customMetadata { get; set; } - - public bool isPrivateFile { get; set; } - - public string url { get; set; } - - public string thumbnail { get; set; } - - public string fileType { get; set; } - - public string filePath { get; set; } - - public int height { get; set; } - - public int width { get; set; } - - public int size { get; set; } - - public bool hasAlpha { get; set; } - - public string mime { get; set; } -} diff --git a/Imagekit/Models/Response/ResultMetaData.cs b/Imagekit/Models/Response/ResultMetaData.cs deleted file mode 100644 index a2310f72..00000000 --- a/Imagekit/Models/Response/ResultMetaData.cs +++ /dev/null @@ -1,16 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - -namespace Imagekit.Models.Response -{ - using System.Diagnostics.CodeAnalysis; - - [ExcludeFromCodeCoverage] - public class ResultMetaData : ResponseMetaData - { - public string Help { get; set; } - - public MetaData Results { get; set; } - } -} diff --git a/Imagekit/Models/Response/ResultNoContent.cs b/Imagekit/Models/Response/ResultNoContent.cs deleted file mode 100644 index 7c5b2a4e..00000000 --- a/Imagekit/Models/Response/ResultNoContent.cs +++ /dev/null @@ -1,10 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// -using System.Diagnostics.CodeAnalysis; - -[ExcludeFromCodeCoverage] -public class ResultNoContent : ResponseMetaData -{ - private ResponseMetaData ResponseMetaData { get; set; } = new ResponseMetaData(); -} \ No newline at end of file diff --git a/Imagekit/Models/Response/ResultOfFolderActions.cs b/Imagekit/Models/Response/ResultOfFolderActions.cs deleted file mode 100644 index be320ce0..00000000 --- a/Imagekit/Models/Response/ResultOfFolderActions.cs +++ /dev/null @@ -1,11 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - -using System.Diagnostics.CodeAnalysis; - -[ExcludeFromCodeCoverage] -public class ResultOfFolderActions : ResponseMetaData -{ - public string JobId { get; set; } -} \ No newline at end of file diff --git a/Imagekit/Models/Response/ResultRenameFile.cs b/Imagekit/Models/Response/ResultRenameFile.cs deleted file mode 100644 index 4fc88224..00000000 --- a/Imagekit/Models/Response/ResultRenameFile.cs +++ /dev/null @@ -1,10 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// -using System.Diagnostics.CodeAnalysis; - -[ExcludeFromCodeCoverage] -public class ResultRenameFile : ResponseMetaData -{ - public string PurgeRequestId { get; set; } -} \ No newline at end of file diff --git a/Imagekit/Models/Response/ResultTags.cs b/Imagekit/Models/Response/ResultTags.cs deleted file mode 100644 index ef73cdb3..00000000 --- a/Imagekit/Models/Response/ResultTags.cs +++ /dev/null @@ -1,12 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; - -[ExcludeFromCodeCoverage] -public class ResultTags : ResponseMetaData -{ - public List SuccessfullyUpDateTimeTimedfileIds { get; set; } -} \ No newline at end of file diff --git a/Imagekit/Models/ResponseMetaData.cs b/Imagekit/Models/ResponseMetaData.cs deleted file mode 100644 index 7e0f6e31..00000000 --- a/Imagekit/Models/ResponseMetaData.cs +++ /dev/null @@ -1,10 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - -public class ResponseMetaData -{ - public string Raw { get; set; } - - public int HttpStatusCode { get; set; } -} \ No newline at end of file diff --git a/Imagekit/Models/TagsRequest.cs b/Imagekit/Models/TagsRequest.cs deleted file mode 100644 index 43622ea5..00000000 --- a/Imagekit/Models/TagsRequest.cs +++ /dev/null @@ -1,12 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - -using System.Collections.Generic; - -public class TagsRequest -{ - public List fileIds { get; set; } - - public List tags { get; set; } -} diff --git a/Imagekit/Models/UploadTransformation.cs b/Imagekit/Models/UploadTransformation.cs deleted file mode 100644 index dadc45ec..00000000 --- a/Imagekit/Models/UploadTransformation.cs +++ /dev/null @@ -1,47 +0,0 @@ -namespace Imagekit.Models -{ - using System.Collections.Generic; - - public class PostTransformation - { - public string type { get; set; } - public string value { get; set; } - } - - public enum Protocol - { - hls, - dash - } - - public class TransformationObject : PostTransformation - { - public string type { get; } = "transformation"; - public string value { get; set; } - } - - public class GifToVideoObject : PostTransformation - { - public string type { get; } = "gif-to-video"; - public string? value { get; set; } - } - public class ThumbnailObject : PostTransformation - { - public string type { get; } = "thumbnail"; - public string? value { get; set; } - } - - public class AbsObject : PostTransformation - { - public string type { get; } = "abs"; - public string value { get; set; } - public Protocol protocol { get; set; } - } - - public class UploadTransformation - { - public string? pre { get; set; } - public List? post { get; set; } - } - -} diff --git a/Imagekit/Properties/AssemblyProperties.cs b/Imagekit/Properties/AssemblyProperties.cs deleted file mode 100644 index 7784aa5c..00000000 --- a/Imagekit/Properties/AssemblyProperties.cs +++ /dev/null @@ -1,5 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - -[assembly: System.Runtime.CompilerServices.InternalsVisibleToAttribute("Imagekit.UnitTests")] \ No newline at end of file diff --git a/Imagekit/RestClient.cs b/Imagekit/RestClient.cs deleted file mode 100644 index ddced72b..00000000 --- a/Imagekit/RestClient.cs +++ /dev/null @@ -1,1876 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - -using System; -using System.Collections.Generic; -using System.Net.Http; -using System.Text; -using System.Threading.Tasks; -using global::Imagekit.Constant; -using global::Imagekit.Helper; -using global::Imagekit.Models; -using global::Imagekit.Models.Response; -using global::Imagekit.Util; -using Imagekit; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; - -internal class RestClient -{ - private readonly string mediaAPIBaseUrl = UrlHandler.MediaAPIBaseUrl; - private readonly string uploadAPIBaseUrl = UrlHandler.UploadAPIBaseUrl; - private readonly HttpClient client; - - public RestClient(string privateKey, string mediaAPIBaseUrl, HttpClient httpClient) - { - if (string.IsNullOrEmpty(privateKey)) - { - throw new Exception(ErrorMessages.InvalidKey); - } - - if (string.IsNullOrEmpty(mediaAPIBaseUrl)) - { - throw new Exception(ErrorMessages.InvalidApiUrl); - } - - this.client = httpClient; - this.client.DefaultRequestHeaders.Add("Authorization", "Basic " + Utils.EncodeTo64(privateKey)); - } - - public ResponseMetaData GetFileListRequest(GetFileListRequest getFileListRequest) - { - try - { - ResultList model = new ResultList(); - string param = GetJsonBody.GetFileRequestBody(getFileListRequest); - string url = string.Format(this.mediaAPIBaseUrl + UrlHandler.GetFileRequest, param); - HttpResponseMessage response = this.client.GetAsync(url).Result; - string res = response.Content.ReadAsStringAsync().Result; - - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public async Task GetFileListRequestAsync(GetFileListRequest getFileListRequest) - { - try - { - ResultList model = new ResultList(); - string param = GetJsonBody.GetFileRequestBody(getFileListRequest); - string url = string.Format(this.mediaAPIBaseUrl + UrlHandler.GetFileRequest, param); - - HttpResponseMessage response = await this.client.GetAsync(url); - string res = response.Content.ReadAsStringAsync().Result; - - if (res.Length > 2) - { - var token = JToken.Parse(res); - if (token is JArray) - { - model.FileList = JsonConvert.DeserializeObject>(res); - } - else - { - model = JsonConvert.DeserializeObject(res); - } - } - - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public ResponseMetaData PurgeCache(string path) - { - try - { - ResultCache model = new ResultCache(); - if (!ValidateParamater.IsValidateParam(path)) - { - throw new Exception(ErrorMessages.InvalidUrlValue); - } - - string url = string.Format(this.mediaAPIBaseUrl + UrlHandler.GetPurge); - - object data = new - { - url = path, - }; - var content = JsonConvert.SerializeObject(data); - var stringContent = - new StringContent(content, Encoding.UTF8, - "application/json"); // use MediaTypeNames.Application.Json in Core 3.0+ and Standard 2.1+ - - HttpResponseMessage response = this.client.PostAsync(url, stringContent).Result; - string res = response.Content.ReadAsStringAsync().Result; - model = JsonConvert.DeserializeObject(res); - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public async Task PurgeCacheAsync(string path) - { - try - { - ResultCache model = new ResultCache(); - if (!ValidateParamater.IsValidateParam(path)) - { - throw new Exception(ErrorMessages.InvalidUrlValue); - } - - string url = string.Format(this.mediaAPIBaseUrl + UrlHandler.GetPurge); - object data = new - { - url = path, - }; - var content = JsonConvert.SerializeObject(data); - var stringContent = - new StringContent(content: content, encoding: Encoding.UTF8, - mediaType: "application/json"); // use MediaTypeNames.Application.Json in Core 3.0+ and Standard 2.1+ - - HttpResponseMessage response = await this.client.PostAsync(url, stringContent); - string res = response.Content.ReadAsStringAsync().Result; - model = JsonConvert.DeserializeObject(res); - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public ResponseMetaData PurgeStatus(string purgeRequestId) - { - try - { - ResultCacheStatus model = new ResultCacheStatus(); - if (!ValidateParamater.IsValidateParam(purgeRequestId)) - { - throw new Exception(ErrorMessages.InvalidPurgeUrl); - } - - string url = string.Format(this.mediaAPIBaseUrl + UrlHandler.GetPurgeStatus, purgeRequestId); - - HttpResponseMessage response = this.client.GetAsync(url).Result; - string res = response.Content.ReadAsStringAsync().Result; - model = JsonConvert.DeserializeObject(res); - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public async Task PurgeStatusAsync(string purgeRequestId) - { - try - { - ResultCacheStatus model = new ResultCacheStatus(); - if (!ValidateParamater.IsValidateParam(purgeRequestId)) - { - throw new Exception(ErrorMessages.InvalidPurgeUrl); - } - - string url = string.Format(this.mediaAPIBaseUrl + UrlHandler.GetPurgeStatus, purgeRequestId); - - HttpResponseMessage response = await this.client.GetAsync(url); - string res = response.Content.ReadAsStringAsync().Result; - model = JsonConvert.DeserializeObject(res); - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public ResponseMetaData GetFileDetail(string fileId) - { - try - { - Result model = new Result(); - if (!ValidateParamater.IsValidateParam(fileId)) - { - throw new Exception(ErrorMessages.FileIdMissing); - } - - string url = string.Format(this.mediaAPIBaseUrl + UrlHandler.GetFileDetails, fileId); - - HttpResponseMessage response = this.client.GetAsync(url).Result; - string res = response.Content.ReadAsStringAsync().Result; - model = JsonConvert.DeserializeObject(res); - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public async Task GetFileDetailAsync(string fileId) - { - try - { - Result model = new Result(); - if (!ValidateParamater.IsValidateParam(fileId)) - { - throw new Exception(ErrorMessages.FileIdMissing); - } - - Dictionary headers = Utils.GetHeaders(); - string url = string.Format(this.mediaAPIBaseUrl + UrlHandler.GetFileDetails, fileId); - - HttpResponseMessage response = await this.client.GetAsync(url); - string res = response.Content.ReadAsStringAsync().Result; - - model = JsonConvert.DeserializeObject(res); - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public ResponseMetaData Upload(FileCreateRequest fileCreateRequest) - { - try - { - Result model = new Result(); - string validate = ValidateParamater.IsValidateUpload(fileCreateRequest); - if (!string.IsNullOrEmpty(validate)) - { - throw new Exception(validate); - } - - string url = this.uploadAPIBaseUrl + UrlHandler.UploadFile; - Dictionary headers = Utils.GetHeaders(); - var formdata = MultipartFormDataModel.Build(fileCreateRequest); - HttpResponseMessage response = this.client.PostAsync(url, formdata).Result; - string res = response.Content.ReadAsStringAsync().Result; - model = JsonConvert.DeserializeObject(res); - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - /// - /// - /// - /// - /// A representing the result of the asynchronous operation. - public async Task UploadAsync(FileCreateRequest fileCreateRequest) - { - try - { - Result model = new Result(); - string validate = ValidateParamater.IsValidateUpload(fileCreateRequest); - if (!string.IsNullOrEmpty(validate)) - { - throw new Exception(validate); - } - - string url = this.uploadAPIBaseUrl + UrlHandler.UploadFile; - Dictionary headers = Utils.GetHeaders(); - var formdata = MultipartFormDataModel.Build(fileCreateRequest); - - HttpResponseMessage response = await this.client.PostAsync(url, formdata); - string res = response.Content.ReadAsStringAsync().Result; - - model = JsonConvert.DeserializeObject(res); - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public ResponseMetaData UpdateFileDetail(FileUpdateRequest fileUpdateRequest) - { - try - { - Result model = new Result(); - string validate = ValidateParamater.IsValidateUpdateFile(fileUpdateRequest); - if (!string.IsNullOrEmpty(validate)) - { - throw new Exception(validate); - } - - string url = string.Format(this.mediaAPIBaseUrl + UrlHandler.UpdateFileRequest, fileUpdateRequest.fileId); - Dictionary headers = Utils.GetHeaders(); - - var content = JsonConvert.SerializeObject(fileUpdateRequest, - new JsonSerializerSettings() - { - NullValueHandling = NullValueHandling.Ignore, - }); - var stringContent = - new StringContent(content, Encoding.UTF8, - mediaType: "application/json"); - var request = new HttpRequestMessage - { - Method = new HttpMethod("PATCH"), - RequestUri = new Uri(url), - Content = stringContent, - }; - - HttpResponseMessage response = this.client.SendAsync(request).Result; - - string res = response.Content.ReadAsStringAsync().Result; - model = JsonConvert.DeserializeObject(res); - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public async Task UpdateFileDetailAsync(FileUpdateRequest fileUpdateRequest) - { - try - { - Result model = new Result(); - string validate = ValidateParamater.IsValidateUpdateFile(fileUpdateRequest); - if (!string.IsNullOrEmpty(validate)) - { - throw new Exception(validate); - } - - string url = string.Format(this.mediaAPIBaseUrl + UrlHandler.UpdateFileRequest, fileUpdateRequest.fileId); - var content = JsonConvert.SerializeObject(fileUpdateRequest, - new JsonSerializerSettings() - { - NullValueHandling = NullValueHandling.Ignore, - }); - var stringContent = - new StringContent(content, Encoding.UTF8, - mediaType: "application/json"); - var request = new HttpRequestMessage - { - Method = new HttpMethod("PATCH"), - RequestUri = new Uri(url), - Content = stringContent, - }; - - HttpResponseMessage response = await this.client.SendAsync(request); - string res = response.Content.ReadAsStringAsync().Result; - model = JsonConvert.DeserializeObject(res); - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public ResponseMetaData DeleteFile(string fileId) - { - try - { - ResultDelete model = new ResultDelete(); - if (!ValidateParamater.IsValidateParam(fileId)) - { - throw new Exception(ErrorMessages.FileIdMissing); - } - - string url = string.Format(this.mediaAPIBaseUrl + UrlHandler.DeleteFile, fileId); - - HttpResponseMessage response = this.client.DeleteAsync(url).Result; - string res = response.Content.ReadAsStringAsync().Result; - model.Raw = res; - model.fileId = fileId; - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - /// - /// - /// - /// - /// A representing the result of the asynchronous operation. - public async Task DeleteFileAsync(string fileId) - { - try - { - ResultDelete model = new ResultDelete(); - if (!ValidateParamater.IsValidateParam(fileId)) - { - throw new Exception(ErrorMessages.FileIdMissing); - } - - string url = string.Format(this.mediaAPIBaseUrl + UrlHandler.DeleteFile, fileId); - - HttpResponseMessage response = await this.client.DeleteAsync(url); - string res = response.Content.ReadAsStringAsync().Result; - model.Raw = res; - model.fileId = fileId; - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public ResponseMetaData BulkDeleteFiles(List fileIds) - { - try - { - ResultFileDelete model = new ResultFileDelete(); - if (!ValidateParamater.IsListCheck(fileIds)) - { - throw new Exception(ErrorMessages.ListFilesInputMissing); - } - - string url = string.Format(this.mediaAPIBaseUrl + UrlHandler.BulkDelete); - - object data = new - { - fileIds = fileIds, - }; - var content = JsonConvert.SerializeObject(data); - var stringContent = - new StringContent(content, Encoding.UTF8, - "application/json"); // use MediaTypeNames.Application.Json in Core 3.0+ and Standard 2.1+ - - HttpResponseMessage response = this.client.PostAsync(url, stringContent).Result; - string res = response.Content.ReadAsStringAsync().Result; - model = JsonConvert.DeserializeObject(res); - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - /// - /// - /// - /// - /// A representing the result of the asynchronous operation. - public async Task BulkDeleteFilesAsync(List fileIds) - { - try - { - ResultFileDelete model = new ResultFileDelete(); - if (!ValidateParamater.IsListCheck(fileIds)) - { - throw new Exception(ErrorMessages.ListFilesInputMissing); - } - - string url = string.Format(this.mediaAPIBaseUrl + UrlHandler.BulkDelete); - - object data = new - { - fileIds = fileIds, - }; - var content = JsonConvert.SerializeObject(data); - var stringContent = - new StringContent(content, Encoding.UTF8, - mediaType: "application/json"); // use MediaTypeNames.Application.Json in Core 3.0+ and Standard 2.1+ - - HttpResponseMessage response = await this.client.PostAsync(url, stringContent); - string res = response.Content.ReadAsStringAsync().Result; - - model = JsonConvert.DeserializeObject(res); - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public ResponseMetaData GetFileMetaData(string fileId) - { - try - { - ResultMetaData model = new ResultMetaData(); - if (!ValidateParamater.IsValidateParam(fileId)) - { - throw new Exception(ErrorMessages.FileIdMissing); - } - - string url = string.Format(this.mediaAPIBaseUrl + UrlHandler.GetMetaData, fileId); - - HttpResponseMessage response = this.client.GetAsync(url).Result; - string res = response.Content.ReadAsStringAsync().Result; - model = JsonConvert.DeserializeObject(res); - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public async Task GetFileMetaDataAsync(string fileId) - { - try - { - ResultMetaData model = new ResultMetaData(); - if (!ValidateParamater.IsValidateParam(fileId)) - { - throw new Exception(ErrorMessages.FileIdMissing); - } - - string url = string.Format(this.mediaAPIBaseUrl + UrlHandler.GetMetaData, fileId); - - HttpResponseMessage response = await this.client.GetAsync(url); - string res = response.Content.ReadAsStringAsync().Result; - - model = JsonConvert.DeserializeObject(res); - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public ResponseMetaData GetRemoteFileMetaData(string url) - { - try - { - ResultMetaData model = new ResultMetaData(); - if (!ValidateParamater.IsValidateParam(url)) - { - throw new Exception(ErrorMessages.InvalidUrlValue); - } - - string apIurl = string.Format(this.mediaAPIBaseUrl + UrlHandler.GetRemoteData, url); - - HttpResponseMessage response = this.client.GetAsync(apIurl).Result; - string res = response.Content.ReadAsStringAsync().Result; - model = JsonConvert.DeserializeObject(res); - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public async Task GetRemoteFileMetaDataAsync(string url) - { - try - { - ResultMetaData model = new ResultMetaData(); - if (!ValidateParamater.IsValidateParam(url)) - { - throw new Exception(ErrorMessages.InvalidUrlValue); - } - - string apIurl = string.Format(this.mediaAPIBaseUrl + UrlHandler.GetRemoteData, url); - - HttpResponseMessage response = await this.client.GetAsync(apIurl); - string res = response.Content.ReadAsStringAsync().Result; - model = JsonConvert.DeserializeObject(res); - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public ResponseMetaData ManageTags(TagsRequest tagsRequest, string action) - { - try - { - ResultTags model = new ResultTags(); - var validate = ValidateParamater.IsValidateTagRequest(tagsRequest); - if (!string.IsNullOrEmpty(validate)) - { - throw new Exception(validate); - } - - string url = string.Empty; - - if (action == "addTags") - { - url = this.mediaAPIBaseUrl + UrlHandler.AddTags; - } - else if (action == "removeTags") - { - url = this.mediaAPIBaseUrl + UrlHandler.RemoveTags; - } - - var content = JsonConvert.SerializeObject(tagsRequest); - var stringContent = new StringContent(content, Encoding.UTF8, "application/json"); - HttpResponseMessage response = this.client.PostAsync(url, stringContent).Result; - string res = response.Content.ReadAsStringAsync().Result; - model = JsonConvert.DeserializeObject(res); - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public async Task ManageTagsAsync(TagsRequest tagsRequest, string action) - { - try - { - ResultTags model = new ResultTags(); - var validate = ValidateParamater.IsValidateTagRequest(tagsRequest); - if (!string.IsNullOrEmpty(validate)) - { - throw new Exception(validate); - } - - string url = string.Empty; - - if (action == "addTags") - { - url = this.uploadAPIBaseUrl + UrlHandler.AddTags; - } - else if (action == "removeTags") - { - url = this.uploadAPIBaseUrl + UrlHandler.RemoveTags; - } - - var content = JsonConvert.SerializeObject(tagsRequest); - var stringContent = new StringContent(content, Encoding.UTF8, "application/json"); - HttpResponseMessage response = await this.client.PostAsync(url, stringContent); - string res = response.Content.ReadAsStringAsync().Result; - model = JsonConvert.DeserializeObject(res); - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public ResponseMetaData RemoveAITags(AITagsRequest aITagsRequest) - { - try - { - ResultTags model = new ResultTags(); - var validate = ValidateParamater.IsValidateAiTagRequest(aITagsRequest); - if (!string.IsNullOrEmpty(validate)) - { - throw new Exception(validate); - } - - // removeAITags - string url = string.Empty; - - url = this.mediaAPIBaseUrl + UrlHandler.RemoveAITags; - - var content = JsonConvert.SerializeObject(aITagsRequest); - var stringContent = new StringContent(content, Encoding.UTF8, "application/json"); - HttpResponseMessage response = this.client.PostAsync(url, stringContent).Result; - string res = response.Content.ReadAsStringAsync().Result; - - model = JsonConvert.DeserializeObject(res); - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public async Task RemoveAITagsAsync(AITagsRequest aITagsRequest) - { - try - { - ResultTags model = new ResultTags(); - var validate = ValidateParamater.IsValidateAiTagRequest(aITagsRequest); - if (!string.IsNullOrEmpty(validate)) - { - throw new Exception(validate); - } - - // removeAITags - string url = string.Empty; - - url = this.uploadAPIBaseUrl + UrlHandler.RemoveAITags; - - var content = JsonConvert.SerializeObject(aITagsRequest); - var stringContent = new StringContent(content, Encoding.UTF8, "application/json"); - HttpResponseMessage response = await this.client.PostAsync(url, stringContent); - string res = response.Content.ReadAsStringAsync().Result; - - model = JsonConvert.DeserializeObject(res); - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public ResponseMetaData GetCustomMetaDataFields(bool? includeDeleted = false) - { - try - { - ResultCustomMetaDataFieldList model = new ResultCustomMetaDataFieldList(); - string url = string.Format(this.mediaAPIBaseUrl + UrlHandler.CustomMetadataFields, includeDeleted); - - HttpResponseMessage response = this.client.GetAsync(url).Result; - string res = response.Content.ReadAsStringAsync().Result; - if (res.Length > 2) - { - var token = JToken.Parse(res); - if (token is JArray) - { - model.ResultCustomMetaDataFieldList1 = JsonConvert.DeserializeObject>(res); - } - else - { - model = JsonConvert.DeserializeObject(res); - } - } - - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public async Task GetCustomMetaDataFieldsAsync(bool includeDeleted) - { - try - { - ResultCustomMetaDataFieldList model = new ResultCustomMetaDataFieldList(); - string url = string.Format(this.mediaAPIBaseUrl + UrlHandler.CustomMetadataFields, includeDeleted); - - HttpResponseMessage response = await this.client.GetAsync(url); - string res = response.Content.ReadAsStringAsync().Result; - - model = JsonConvert.DeserializeObject(res); - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public ResponseMetaData CreateCustomMetaDataFields( - CustomMetaDataFieldCreateRequest customMetaDataFieldCreateRequest) - { - try - { - ResultCustomMetaDataField model = new ResultCustomMetaDataField(); - var validate = - ValidateParamater.IsValidateCustomMetaDataFieldCreateRequest(customMetaDataFieldCreateRequest); - if (!string.IsNullOrEmpty(validate)) - { - throw new Exception(validate); - } - - string url = string.Empty; - url = this.mediaAPIBaseUrl + UrlHandler.CreareCustomMetaDataFields; - - string body = GetJsonBody.CreateCustomMetaDataBody(customMetaDataFieldCreateRequest); - var stringContent = new StringContent(body, Encoding.UTF8, "application/json"); - HttpResponseMessage response = this.client.PostAsync(url, stringContent).Result; - string res = response.Content.ReadAsStringAsync().Result; - model = JsonConvert.DeserializeObject(res); - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public async Task CreateCustomMetaDataFieldsAsync( - CustomMetaDataFieldCreateRequest customMetaDataFieldCreateRequest) - { - try - { - ResultCustomMetaDataField model = new ResultCustomMetaDataField(); - var validate = - ValidateParamater.IsValidateCustomMetaDataFieldCreateRequest(customMetaDataFieldCreateRequest); - if (!string.IsNullOrEmpty(validate)) - { - throw new Exception(validate); - } - - string url = string.Empty; - url = this.mediaAPIBaseUrl + UrlHandler.CreareCustomMetaDataFields; - - string body = GetJsonBody.CreateCustomMetaDataBody(customMetaDataFieldCreateRequest); - var stringContent = new StringContent(body, Encoding.UTF8, "application/json"); - HttpResponseMessage response = await this.client.PostAsync(url, stringContent); - string res = response.Content.ReadAsStringAsync().Result; - - model = JsonConvert.DeserializeObject(res); - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public ResponseMetaData DeleteCustomMetaDataField(string id) - { - try - { - ResultNoContent model = new ResultNoContent(); - if (!ValidateParamater.IsValidateParam(id)) - { - throw new Exception(ErrorMessages.InvalidfileIdsValue); - } - - string url = string.Format(this.mediaAPIBaseUrl + UrlHandler.DeleteCustomMetaDataFields, id); - - HttpResponseMessage response = this.client.DeleteAsync(url).Result; - string res = response.Content.ReadAsStringAsync().Result; - model = JsonConvert.DeserializeObject(res); - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public async Task DeleteCustomMetaDataFieldAsync(string id) - { - try - { - ResultNoContent model = new ResultNoContent(); - if (!ValidateParamater.IsValidateParam(id)) - { - throw new Exception(ErrorMessages.InvalidfileIdsValue); - } - - string url = string.Format(this.mediaAPIBaseUrl + UrlHandler.DeleteCustomMetaDataFields, id); - - HttpResponseMessage response = await this.client.DeleteAsync(url); - string res = response.Content.ReadAsStringAsync().Result; - model = JsonConvert.DeserializeObject(res); - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public ResponseMetaData UpdateCustomMetaDataFields( - CustomMetaDataFieldUpdateRequest customMetaDataFieldUpdateRequest) - { - try - { - ResultCustomMetaDataField model = new ResultCustomMetaDataField(); - var validate = - ValidateParamater.IsValidateCustomMetaDataFieldUpdateRequest(customMetaDataFieldUpdateRequest); - if (!string.IsNullOrEmpty(validate)) - { - throw new Exception(validate); - } - - string url = string.Empty; - url = string.Format( - this.mediaAPIBaseUrl + UrlHandler.UpdateCustomMetadataFields, - customMetaDataFieldUpdateRequest.Id); - string body = GetJsonBody.UpdateCustomMetaDataBody(customMetaDataFieldUpdateRequest); - - var stringContent = - new StringContent(body, Encoding.UTF8, - mediaType: "application/json"); - var request = new HttpRequestMessage - { - Method = new HttpMethod("PATCH"), - RequestUri = new Uri(url), - Content = stringContent, - }; - HttpResponseMessage response = this.client.SendAsync(request).Result; - string res = response.Content.ReadAsStringAsync().Result; - model = JsonConvert.DeserializeObject(res); - Utils.PopulateResponseMetadata( - res, model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public async Task UpdateCustomMetaDataFieldsAsync( - CustomMetaDataFieldUpdateRequest customMetaDataFieldUpdateRequest) - { - try - { - ResultCustomMetaDataField model = new ResultCustomMetaDataField(); - var validate = - ValidateParamater.IsValidateCustomMetaDataFieldUpdateRequest(customMetaDataFieldUpdateRequest); - if (!string.IsNullOrEmpty(validate)) - { - throw new Exception(validate); - } - - string url = string.Empty; - url = string.Format( - this.mediaAPIBaseUrl + UrlHandler.UpdateCustomMetadataFields, - customMetaDataFieldUpdateRequest.Id); - string body = GetJsonBody.UpdateCustomMetaDataBody(customMetaDataFieldUpdateRequest); - - var stringContent = - new StringContent(body, Encoding.UTF8, - mediaType: "application/json"); - var request = new HttpRequestMessage - { - Method = new HttpMethod("PATCH"), - RequestUri = new Uri(url), - Content = stringContent, - }; - HttpResponseMessage response = await this.client.SendAsync(request); - string res = response.Content.ReadAsStringAsync().Result; - model = JsonConvert.DeserializeObject(res); - Utils.PopulateResponseMetadata( - res, model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public ResponseMetaData DeleteFileVersion(DeleteFileVersionRequest deleteFileVersionRequest) - { - try - { - ResultNoContent model = new ResultNoContent(); - var validate = ValidateParamater.IsValidateDeleteFileVersionRequest(deleteFileVersionRequest); - if (!string.IsNullOrEmpty(validate)) - { - throw new Exception(validate); - } - - string url = string.Format(this.mediaAPIBaseUrl + UrlHandler.DeleteVesrion, deleteFileVersionRequest.fileId, - deleteFileVersionRequest.versionId); - - HttpResponseMessage response = this.client.DeleteAsync(url).Result; - string res = response.Content.ReadAsStringAsync().Result; - model = JsonConvert.DeserializeObject(res); - - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public async Task DeleteFileVersionAsync(DeleteFileVersionRequest deleteFileVersionRequest) - { - try - { - ResultNoContent model = new ResultNoContent(); - var validate = ValidateParamater.IsValidateDeleteFileVersionRequest(deleteFileVersionRequest); - if (!string.IsNullOrEmpty(validate)) - { - throw new Exception(validate); - } - - string url = string.Format(this.mediaAPIBaseUrl + UrlHandler.DeleteVesrion, deleteFileVersionRequest.fileId, - deleteFileVersionRequest.versionId); - - HttpResponseMessage response = await this.client.DeleteAsync(url); - string res = response.Content.ReadAsStringAsync().Result; - model = JsonConvert.DeserializeObject(res); - - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public ResponseMetaData CopyFile(CopyFileRequest copyFileRequest) - { - try - { - ResultNoContent model = new ResultNoContent(); - string validate = ValidateParamater.IsValidateCopyRequest(copyFileRequest); - if (!string.IsNullOrEmpty(validate)) - { - throw new Exception(validate); - } - - string url = string.Empty; - url = string.Format(this.mediaAPIBaseUrl + UrlHandler.CopyFile); - var content = JsonConvert.SerializeObject(copyFileRequest); - var stringContent = new StringContent(content, Encoding.UTF8, "application/json"); - HttpResponseMessage response = this.client.PostAsync(url, stringContent).Result; - string res = response.Content.ReadAsStringAsync().Result; - - model = JsonConvert.DeserializeObject(res); - - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public async Task CopyFileAsync(CopyFileRequest copyFileRequest) - { - try - { - ResultNoContent model = new ResultNoContent(); - string validate = ValidateParamater.IsValidateCopyRequest(copyFileRequest); - if (!string.IsNullOrEmpty(validate)) - { - throw new Exception(validate); - } - - string url = string.Empty; - url = string.Format(this.mediaAPIBaseUrl + UrlHandler.CopyFile); - var content = JsonConvert.SerializeObject(copyFileRequest); - var stringContent = new StringContent(content, Encoding.UTF8, "application/json"); - HttpResponseMessage response = await this.client.PostAsync(url, stringContent); - string res = response.Content.ReadAsStringAsync().Result; - - model = JsonConvert.DeserializeObject(res); - - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public ResponseMetaData MoveFile(MoveFileRequest moveFileRequest) - { - try - { - ResultNoContent model = new ResultNoContent(); - string validate = ValidateParamater.IsValidateMoveRequest(moveFileRequest); - if (!string.IsNullOrEmpty(validate)) - { - throw new Exception(validate); - } - - string url = string.Empty; - url = string.Format(this.mediaAPIBaseUrl + UrlHandler.MoveFile); - var content = JsonConvert.SerializeObject(moveFileRequest); - var stringContent = new StringContent(content, Encoding.UTF8, "application/json"); - HttpResponseMessage response = this.client.PostAsync(url, stringContent).Result; - string res = response.Content.ReadAsStringAsync().Result; - model = JsonConvert.DeserializeObject(res); - - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public async Task MoveFileAsync(MoveFileRequest moveFileRequest) - { - try - { - ResultNoContent model = new ResultNoContent(); - string validate = ValidateParamater.IsValidateMoveRequest(moveFileRequest); - if (!string.IsNullOrEmpty(validate)) - { - throw new Exception(validate); - } - - string url = string.Empty; - url = string.Format(this.mediaAPIBaseUrl + UrlHandler.MoveFile); - var content = JsonConvert.SerializeObject(moveFileRequest); - var stringContent = new StringContent(content, Encoding.UTF8, "application/json"); - HttpResponseMessage response = await this.client.PostAsync(url, stringContent); - string res = response.Content.ReadAsStringAsync().Result; - model = JsonConvert.DeserializeObject(res); - - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public ResponseMetaData RenameFile(RenameFileRequest renameFileRequest) - { - try - { - ResultRenameFile model = new ResultRenameFile(); - var validate = ValidateParamater.IsValidateRenameRequest(renameFileRequest); - if (!string.IsNullOrEmpty(validate)) - { - throw new Exception(validate); - } - - string url = string.Empty; - url = string.Format(this.mediaAPIBaseUrl + UrlHandler.RenameFile); - var content = JsonConvert.SerializeObject(renameFileRequest); - var stringContent = new StringContent(content, Encoding.UTF8, "application/json"); - HttpResponseMessage response = this.client.PutAsync(url, stringContent).Result; - string res = response.Content.ReadAsStringAsync().Result; - model = JsonConvert.DeserializeObject(res); - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public async Task RenameFileAsync(RenameFileRequest renameFileRequest) - { - try - { - ResultRenameFile model = new ResultRenameFile(); - var validate = ValidateParamater.IsValidateRenameRequest(renameFileRequest); - if (!string.IsNullOrEmpty(validate)) - { - throw new Exception(validate); - } - - string url = string.Empty; - url = string.Format(this.mediaAPIBaseUrl + UrlHandler.RenameFile); - var content = JsonConvert.SerializeObject(renameFileRequest); - var stringContent = new StringContent(content, Encoding.UTF8, "application/json"); - HttpResponseMessage response = await this.client.PutAsync(url, stringContent); - string res = response.Content.ReadAsStringAsync().Result; - model = JsonConvert.DeserializeObject(res); - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public ResponseMetaData CreateFolder(CreateFolderRequest createFolderRequest) - { - try - { - ResultEmptyBlock model = new ResultEmptyBlock(); - var isValidateFolder = ValidateParamater.IsValidateFolder(createFolderRequest); - if (!string.IsNullOrEmpty(isValidateFolder)) - { - throw new Exception(isValidateFolder); - } - - string url = string.Empty; - url = string.Format(this.mediaAPIBaseUrl + UrlHandler.CreateFolder); - var content = JsonConvert.SerializeObject(createFolderRequest); - Console.WriteLine(content); - var stringContent = new StringContent(content, Encoding.UTF8, "application/json"); - HttpResponseMessage response = this.client.PostAsync(url, stringContent).Result; - string res = response.Content.ReadAsStringAsync().Result; - model = JsonConvert.DeserializeObject(res); - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public async Task CreateFolderAsync(CreateFolderRequest createFolderRequest) - { - try - { - ResultEmptyBlock model = new ResultEmptyBlock(); - var isValidateFolder = ValidateParamater.IsValidateFolder(createFolderRequest); - if (!string.IsNullOrEmpty(isValidateFolder)) - { - throw new Exception(isValidateFolder); - } - - string url = string.Empty; - url = string.Format(this.mediaAPIBaseUrl + UrlHandler.CreateFolder); - var content = JsonConvert.SerializeObject(createFolderRequest); - var stringContent = new StringContent(content, Encoding.UTF8, "application/json"); - HttpResponseMessage response = await this.client.PostAsync(url, stringContent); - string res = response.Content.ReadAsStringAsync().Result; - model = JsonConvert.DeserializeObject(res); - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public ResponseMetaData DeleteFolder(DeleteFolderRequest deleteFolderRequest) - { - try - { - ResultNoContent model = new ResultNoContent(); - if (!ValidateParamater.IsValidateDeleteFolder(deleteFolderRequest)) - { - throw new Exception(ErrorMessages.InvalidDelFolderValue); - } - - var body = GetJsonBody.DeleteFolderBody(deleteFolderRequest); - - string url = string.Format(this.mediaAPIBaseUrl + UrlHandler.DeleteFolder); - var request = new HttpRequestMessage - { - Method = HttpMethod.Delete, - RequestUri = new Uri(url), - Content = new StringContent(body, Encoding.UTF8, "application/json"), - }; - - HttpResponseMessage response = this.client.SendAsync(request).Result; - string res = response.Content.ReadAsStringAsync().Result; - model = JsonConvert.DeserializeObject(res); - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public async Task DeleteFolderAsync(DeleteFolderRequest deleteFolderRequest) - { - try - { - ResultNoContent model = new ResultNoContent(); - if (!ValidateParamater.IsValidateDeleteFolder(deleteFolderRequest)) - { - throw new Exception(ErrorMessages.InvalidDelFolderValue); - } - - var body = GetJsonBody.DeleteFolderBody(deleteFolderRequest); - - string url = string.Format(this.mediaAPIBaseUrl + UrlHandler.DeleteFolder); - var request = new HttpRequestMessage - { - Method = HttpMethod.Delete, - RequestUri = new Uri(url), - Content = new StringContent(body, Encoding.UTF8, "application/json"), - }; - - HttpResponseMessage response = await this.client.SendAsync(request); - string res = response.Content.ReadAsStringAsync().Result; - model = JsonConvert.DeserializeObject(res); - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public ResponseMetaData CopyFolder(CopyFolderRequest copyFolderRequest) - { - try - { - ResultOfFolderActions model = new ResultOfFolderActions(); - var validate = ValidateParamater.IsValidateCopyFolder(copyFolderRequest); - if (!string.IsNullOrEmpty(validate)) - { - throw new Exception(validate); - } - - string url = string.Format(this.mediaAPIBaseUrl + UrlHandler.CopyFolder); - var content = JsonConvert.SerializeObject(copyFolderRequest); - var stringContent = - new StringContent(content, Encoding.UTF8, - "application/json"); // use MediaTypeNames.Application.Json in Core 3.0+ and Standard 2.1+ - - HttpResponseMessage response = this.client.PostAsync(url, stringContent).Result; - string res = response.Content.ReadAsStringAsync().Result; - model = JsonConvert.DeserializeObject(res); - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public async Task CopyFolderAsync(CopyFolderRequest copyFolderRequest) - { - try - { - ResultOfFolderActions model = new ResultOfFolderActions(); - var validate = ValidateParamater.IsValidateCopyFolder(copyFolderRequest); - if (!string.IsNullOrEmpty(validate)) - { - throw new Exception(validate); - } - - string url = string.Format(this.mediaAPIBaseUrl + UrlHandler.CopyFolder); - var content = JsonConvert.SerializeObject(copyFolderRequest); - var stringContent = - new StringContent(content, Encoding.UTF8, - "application/json"); // use MediaTypeNames.Application.Json in Core 3.0+ and Standard 2.1+ - - HttpResponseMessage response = await this.client.PostAsync(url, stringContent); - string res = response.Content.ReadAsStringAsync().Result; - - model = JsonConvert.DeserializeObject(res); - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public ResponseMetaData MoveFolder(MoveFolderRequest moveFolderRequest) - { - try - { - ResultOfFolderActions model = new ResultOfFolderActions(); - var validate = ValidateParamater.IsValidateMoveFolder(moveFolderRequest); - if (!string.IsNullOrEmpty(validate)) - { - throw new Exception(validate); - } - - string url = string.Format(this.mediaAPIBaseUrl + UrlHandler.MoveFolder); - var content = JsonConvert.SerializeObject(moveFolderRequest); - var stringContent = - new StringContent(content, Encoding.UTF8, - "application/json"); // use MediaTypeNames.Application.Json in Core 3.0+ and Standard 2.1+ - - HttpResponseMessage response = this.client.PostAsync(url, stringContent).Result; - string res = response.Content.ReadAsStringAsync().Result; - - model = JsonConvert.DeserializeObject(res); - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public async Task MoveFolderAsync(MoveFolderRequest moveFolderRequest) - { - try - { - ResultOfFolderActions model = new ResultOfFolderActions(); - - var validate = ValidateParamater.IsValidateMoveFolder(moveFolderRequest); - if (!string.IsNullOrEmpty(validate)) - { - throw new Exception(validate); - } - - string url = string.Format(this.mediaAPIBaseUrl + UrlHandler.MoveFolder); - var content = JsonConvert.SerializeObject(moveFolderRequest); - var stringContent = - new StringContent(content, Encoding.UTF8, - "application/json"); // use MediaTypeNames.Application.Json in Core 3.0+ and Standard 2.1+ - - HttpResponseMessage response = await this.client.PostAsync(url, stringContent); - string res = response.Content.ReadAsStringAsync().Result; - model = JsonConvert.DeserializeObject(res); - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public ResponseMetaData GetBulkJobStatus(string jobId) - { - try - { - ResultBulkJobStatus model = new ResultBulkJobStatus(); - if (!ValidateParamater.IsValidateParam(jobId)) - { - throw new Exception(ErrorMessages.InvalidJobValue); - } - - string url = string.Format(this.mediaAPIBaseUrl + UrlHandler.GetJobStatus, jobId); - - HttpResponseMessage response = this.client.GetAsync(url).Result; - string res = response.Content.ReadAsStringAsync().Result; - model = JsonConvert.DeserializeObject(res); - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public async Task GetBulkJobStatusAsync(string jobId) - { - try - { - ResultBulkJobStatus model = new ResultBulkJobStatus(); - if (!ValidateParamater.IsValidateParam(jobId)) - { - throw new Exception(ErrorMessages.InvalidJobValue); - } - - string url = string.Format(this.mediaAPIBaseUrl + UrlHandler.GetJobStatus, jobId); - - HttpResponseMessage response = await this.client.GetAsync(url); - string res = response.Content.ReadAsStringAsync().Result; - - model = JsonConvert.DeserializeObject(res); - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public ResponseMetaData GetFileVersions(string fileId) - { - try - { - ResultFileVersions model = new ResultFileVersions(); - if (!ValidateParamater.IsValidateParam(fileId)) - { - throw new Exception(ErrorMessages.FileIdMissing); - } - - string url = string.Format(this.mediaAPIBaseUrl + UrlHandler.GetFileVersion, fileId); - HttpResponseMessage response = this.client.GetAsync(url).Result; - string res = response.Content.ReadAsStringAsync().Result; - var token = JToken.Parse(res); - if (token is JArray) - { - model.ResultFileVersionDetailsList = JsonConvert.DeserializeObject>(res); - } - - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public async Task GetFileVersionsAsync(string fileId) - { - try - { - ResultFileVersions model = new ResultFileVersions(); - if (!ValidateParamater.IsValidateParam(fileId)) - { - throw new Exception(ErrorMessages.FileIdMissing); - } - - string url = string.Format(this.mediaAPIBaseUrl + UrlHandler.GetFileVersion, fileId); - HttpResponseMessage response = this.client.GetAsync(url).Result; - string res = await response.Content.ReadAsStringAsync(); - var token = JToken.Parse(res); - if (token is JArray) - { - model.ResultFileVersionDetailsList = JsonConvert.DeserializeObject>(res); - } - - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public ResponseMetaData GetFileVersionDetails(string fileId, string versionId) - { - try - { - ResultFileVersionDetails model = new ResultFileVersionDetails(); - var validate = ValidateParamater.IsValidateParam(fileId, versionId); - if (!string.IsNullOrEmpty(validate)) - { - throw new Exception(validate); - } - - string url = string.Format(this.mediaAPIBaseUrl + UrlHandler.GetFileVersionDetail, fileId, versionId); - HttpResponseMessage response = this.client.GetAsync(url).Result; - string res = response.Content.ReadAsStringAsync().Result; - model = JsonConvert.DeserializeObject(res); - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public async Task GetFileVersionDetailsAsync(string fileId, string versionId) - { - try - { - ResultFileVersionDetails model = new ResultFileVersionDetails(); - var validate = ValidateParamater.IsValidateParam(fileId, versionId); - if (!string.IsNullOrEmpty(validate)) - { - throw new Exception(validate); - } - - string url = string.Format(this.mediaAPIBaseUrl + UrlHandler.GetFileVersionDetail, fileId, versionId); - HttpResponseMessage response = await this.client.GetAsync(url); - string res = response.Content.ReadAsStringAsync().Result; - model = JsonConvert.DeserializeObject(res); - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public ResponseMetaData RestoreFileVersion(string fileId, string versionId) - { - try - { - Result model = new Result(); - var validate = ValidateParamater.IsValidateParam(fileId, versionId); - if (!string.IsNullOrEmpty(validate)) - { - throw new Exception(validate); - } - - string url = string.Format(this.mediaAPIBaseUrl + UrlHandler.RestoreVesrion, fileId, versionId); - HttpResponseMessage response = this.client.PutAsync(url, null).Result; - string res = response.Content.ReadAsStringAsync().Result; - model = JsonConvert.DeserializeObject(res); - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } - - public async Task RestoreFileVersionAsync(string fileId, string versionId) - { - try - { - Result model = new Result(); - var validate = ValidateParamater.IsValidateParam(fileId, versionId); - if (!string.IsNullOrEmpty(validate)) - { - throw new Exception(validate); - } - - string url = string.Format(this.mediaAPIBaseUrl + UrlHandler.RestoreVesrion, fileId, versionId); - HttpResponseMessage response = await this.client.PutAsync(url, null); - string res = response.Content.ReadAsStringAsync().Result; - model = JsonConvert.DeserializeObject(res); - Utils.PopulateResponseMetadata( - res, - model, - Convert.ToInt32(response.StatusCode), - responseHeaders: null); - return model; - } - catch (Exception ex) - { - throw new ImagekitException(ex.Message); - } - } -} \ No newline at end of file diff --git a/Imagekit/Util/Calculation.cs b/Imagekit/Util/Calculation.cs deleted file mode 100644 index 03a86129..00000000 --- a/Imagekit/Util/Calculation.cs +++ /dev/null @@ -1,47 +0,0 @@ -namespace Imagekit.Util -{ - using System; - using System.Collections.Generic; - using System.Globalization; - using System.Linq; - using System.Numerics; - using System.Text; - using System.Text.RegularExpressions; - using System.Threading.Tasks; - - public class Calculation - { - public static int GetHammingDistance(string firstHex, string secondHex) - { - if (!(IsValidHex(firstHex) && IsValidHex(secondHex))) - { - throw new Exception("Both argument should be hexadecimal."); - } - - if (firstHex.Length != secondHex.Length) - { - throw new Exception("Both argument are not equal in length."); - } - - BigInteger b1 = BigInteger.Parse(firstHex, NumberStyles.HexNumber); - BigInteger b2 = BigInteger.Parse(secondHex, NumberStyles.HexNumber); - BigInteger xor = b1 ^ b2; - - int count = 0; - for (int i = 0; i < xor.ToString().Length; i++) - { - if (xor.ToString()[i] == '1') - { - count += 1; - } - } - - return count; - } - - private static bool IsValidHex(string hex) - { - return System.Text.RegularExpressions.Regex.IsMatch(hex, @"^[0-9a-fA-F]+$"); - } - } -} diff --git a/Imagekit/Util/Constants.cs b/Imagekit/Util/Constants.cs deleted file mode 100644 index 07007431..00000000 --- a/Imagekit/Util/Constants.cs +++ /dev/null @@ -1,26 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - -namespace Imagekit.Util -{ - public static class Constants - { - public const string TransformationParameter = "tr"; - public const string SignatureParameter = "ik-s"; - public const string TimestampParameter = "ik-t"; - public const string ChainTransformDelimiter = ":"; - public const string TransformDelimiter = ","; - public const string TransformKeyValueDelimiter = "-"; - public const string DefaultTimestamp = "9999999999"; - public const string ProtocolQuery = @"/http[s]?\:\/\//"; - - public const string HttpsProtocol = "https://"; - public const string HttpProtocol = "http://"; - public const string ApiHost = "api.imagekit.io"; - public const string UploadApiHost = "dasdasd.sadsdasd.io"; - public const string FileApi = "/v1/files"; - public const string UploadApi = "/api/v1/files/upload"; - public const string SdkVersion = "5.0.0"; - } -} \ No newline at end of file diff --git a/Imagekit/Util/Utils.cs b/Imagekit/Util/Utils.cs deleted file mode 100644 index 321c510b..00000000 --- a/Imagekit/Util/Utils.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - -namespace Imagekit.Util -{ - using System; - using System.Collections.Generic; - using System.Diagnostics.CodeAnalysis; - using System.IO; - using System.Linq; - using System.Security.Cryptography; - using System.Text; - - [ExcludeFromCodeCoverage] - public static class Utils - { - public static string ListToString(List list) - { - return string.Join(",", list); - } - - public static string ListToString(string[] list) - { - return string.Join(",", list); - } - - public static Dictionary GetHeaders() - { - Dictionary headers = new Dictionary - { - { "Accept-Encoding", "application/json" }, - { "Content-Type", "application/json" }, - { "Authorization", "Basic " + "private_FguYxKgB8/Jm9Xs5ZyyLfwIBSFU=" }, - }; - return headers; - } - - public static ResponseMetaData PopulateResponseMetadata( - string respBody, - ResponseMetaData responseMetadata, - int responseCode, - Dictionary> responseHeaders) - { - if (responseMetadata == null) - { - responseMetadata = new ResponseMetaData(); - } - - responseMetadata.Raw = respBody; - responseMetadata.HttpStatusCode = responseCode; - return responseMetadata; - } - - public static long ToUnixTime(DateTime dateTime) - { - return (int)dateTime.ToUniversalTime().Subtract(new DateTime(1970, 1, 1)).TotalSeconds; - } - - public static string EncodeTo64(string toEncode) - { - var plainTextBytes = Encoding.UTF8.GetBytes(toEncode + ":"); - string returnValue = Convert.ToBase64String(plainTextBytes); - return returnValue; - } - - public static string GetSignatureTimestamp(int seconds) - { - if (seconds <= 0) - { - return Constants.DefaultTimestamp; - } - - var timeStamp = ToUnixTime(DateTime.UtcNow); - return (timeStamp + seconds).ToString(); - } - - public static string CalculateSignature(string input, byte[] key) - { - HMACSHA1 myhmacsha1 = new HMACSHA1(key); - byte[] byteArray = Encoding.ASCII.GetBytes(input); - MemoryStream stream = new MemoryStream(byteArray); - return myhmacsha1.ComputeHash(stream).Aggregate(string.Empty, (s, e) => s + string.Format("{0:x2}", e), s => s); - } - } -} \ No newline at end of file diff --git a/Imagekit/stylecop.json b/Imagekit/stylecop.json deleted file mode 100644 index 2bb8814b..00000000 --- a/Imagekit/stylecop.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - // ACTION REQUIRED: This file was automatically added to your project, but it - // will not take effect until additional steps are taken to enable it. See the - // following page for additional informations: - // - // https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/EnableConfiguration.md - - "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json", - "settings": { - "documentationRules": { - "companyName": "Imagekit" - } - } -} \ No newline at end of file diff --git a/LICENSE b/LICENSE index 1247a613..e7a4d160 100644 --- a/LICENSE +++ b/LICENSE @@ -1,22 +1,201 @@ -MIT License + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ -Copyright (c) 2017 Imagekit + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: + 1. Definitions. -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2025 Image Kit + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md index 7442f66c..cc346a5a 100644 --- a/README.md +++ b/README.md @@ -1,962 +1,102 @@ -[ImageKit.io](https://imagekit.io) +# Image Kit C# API Library -## DotNET (NET45/Standard/Core) SDK for ImageKit +> [!NOTE] +> The Image Kit C# API Library is currently in **beta** and we're excited for you to experiment with it! +> +> This library has not yet been exhaustively tested in production environments and may be missing some features you'd expect in a stable release. As we continue development, there may be breaking changes that require updates to your code. +> +> **We'd love your feedback!** Please share any suggestions, bug reports, feature requests, or general thoughts by [filing an issue](https://www.github.com/stainless-sdks/imagekit-csharp/issues/new). -[![CI Pipeline](https://github.com/imagekit-developer/imagekit-dotnet/workflows/CI%20Pipeline/badge.svg?branch=master)](https://github.com/imagekit-developer/imagekit-dotnet) [![NuGet](https://img.shields.io/nuget/v/imagekit.svg)](https://www.nuget.org/packages/Imagekit) [![codecov](https://codecov.io/gh/imagekit-developer/imagekit-dotnet/branch/master/graph/badge.svg)](https://codecov.io/gh/imagekit-developer/imagekit-dotnet) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Twitter Follow](https://img.shields.io/twitter/follow/imagekitio?label=Follow&style=social)](https://twitter.com/ImagekitIo) +The Image Kit C# SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs) from applications written in C#. -ImageKit DotNET SDK allows you to use [image resizing](https://docs.imagekit.io/features/image-transformations), [optimization](https://docs.imagekit.io/features/image-optimization), [file uploading](https://docs.imagekit.io/api-reference/upload-file-api) and other [ImageKit APIs](https://docs.imagekit.io/api-reference/api-introduction) from applications written in server-side C#. +It is generated with [Stainless](https://www.stainless.com/). -##### Table of contents - -* [Installation](#installation) -* [Initialization](#initialization) -* [URL generation](#url-generation) -* [File Upload](#file-upload) -* [File Management](#file-management) -* [Tags](#tags-management) -* [Manage Folder](#folder-management) -* [Bulk Job Status](#job-management) -* [Purge](#purge) -* [Meta Data](#metadata) -* [Utility functions](#utility-functions) -* [Support](#support) -* [Links](#links) +The REST API documentation can be found on [imagekit.io](https://imagekit.io/docs). ## Installation -Package Manager - -```cs -Install-Package Imagekit -``` - -PackageReference - -```html - - +```bash +git clone git@github.com:stainless-sdks/imagekit-csharp.git +dotnet add reference imagekit-csharp/src/Imagekit ``` -.Net CLI +## Requirements -```cs -dotnet add package Imagekit --version 4.0.1 -``` - -Open up your project, navigate to the Nuget package manager console, and add the Imagekit package. -Also, you can search for [Imagekit](https://www.nuget.org/packages/Imagekit) in Nuget GUI. - -## Initialization +This library requires .NET 8 or later. -Add this reference where you want to use imagekit.io services: - -```cs -using Imagekit; - -ImageKitClient imagekit = new ImageKitClient(publicKey, privateKey, urlEndPoint); -``` - -**Note**: You can get the `apiKey`, `apiSecret`, and ImagekitId from your [Imagekit.io dashboard](https://imagekit.io/dashboard). - -## Demo application - -The fastest way to get started is by running the demo application in the [ImageKitSample](/ImageKitSample) folder. +> [!NOTE] +> The library is currently in **beta**. The requirements will be lowered in the future. ## Usage -You can use this DotNET SDK for three different functions: URL generation, file uploads, and file management. The usage of the SDK has been explained below. - -### URL Generation - -**1\. Using image path and image hostname or endpoint** - -This method allows you to create a URL using the `path` where the image exists and the URL endpoint (`urlEndpoint`) you want to use to access the image. You can refer to the documentation [here](https://docs.imagekit.io/integration/url-endpoints) to read more about URL endpoints in ImageKit and the section about [image origins](https://docs.imagekit.io/integration/configure-origin) to understand paths with different kinds of origins. - -```cs -string path = "/default_image.jpg"; -Transformation trans = new Transformation() -.Width(400) -.Height(300) -.AspectRatio("4-3") -.Quality(40) -.Crop("force") -.CropMode("extract") -.Focus("left") -.Format("jpeg") -.Raw("l-text,i-Imagekit,fs-50,l-end"); - -string imageURL = imagekit.Url(trans).Path(path).TransformationPosition("query").Generate(); -``` - -This results in a URL like - -```plaintext -https://ik.imagekit.io/your_imagekit_id/default_image.jpg?tr=w-400%2Ch-300%2Car-4-3%2Cq-40%2Cc-force%2Ccm-extract%2Cfo-left%2Cf-jpeg%2Cl-text%2Ci-Imagekit%2Cfs-50%2Cl-end -``` - -**2\. Using full image URL** - -This method allows you to add transformation parameters to an existing, complete URL that is already mapped to ImageKit using the `src` parameter. This method should be used if you have the complete URL mapped to ImageKit stored in your database. - -```cs -string imageURL = imagekit.Url(new Transformation().Width(400).Height(300)) - .Src("https://ik.imagekit.io/your_imagekit_id/endpoint/default_image.jpg") - .Generate(); -``` - -This results in a URL like - -```plaintext -https://ik.imagekit.io/your_imagekit_id/endpoint/default_image.jpg?tr=h-300,w-400 -``` - -The `.Url()` method accepts the following parameters. - -| Option | Description | -| --- | --- | -| urlEndpoint | Optional. The base URL has to be appended before the path of the image. If not specified, the URL Endpoint specified at the time of SDK initialization is used. For example, `https://ik.imagekit.io/your_imagekit_id/endpoint/` | -| path | Conditional. This is the path on which the image exists. For example, `/path/to/image.jpg`. Either the `path` or `src` parameter needs to be specified for URL generation. | -| src | Conditional. This is the complete URL of an image already mapped to ImageKit. For example, `https://ik.imagekit.io/your_imagekit_id/endpoint/path/to/image.jpg`. Either the `path` or `src` parameter needs to be specified for URL generation. | -| transformation | Optional. An array of objects specifying the transformation to be applied in the URL. The transformation name and the value should be specified as a key-value pair in the object. Different steps of a [chained transformation](https://docs.imagekit.io/features/image-transformations/chained-transformations) can be specified as the array's different objects. The complete list of supported transformations in the SDK and some examples of using them are given later. If you use a transformation name that is not specified in the SDK, it gets applied as it is in the URL. | -| transformationPosition | Optional. The default value is `path` that places the transformation string as a URL path parameter. It can also be specified as `query`, which adds the transformation string as the URL's query parameter `tr`. If you use the `src` parameter to create the URL, then the transformation string is always added as a query parameter. | -| queryParameters | Optional. These are the other query parameters that you want to add to the final URL. These can be any query parameters and not necessarily related to ImageKit. Especially useful if you want to add some versioning parameters to your URLs. | -| signed | Optional. Boolean. Default is `false`. If set to `false`, the SDK generates a signed image URL by adding the image signature to the image URL. This can only be used if you create the URL with the `urlEndpoint` and `path` parameters, not with the `src` parameter. | -| expireSeconds | Optional. Integer. It is meant to be used along with the `signed` parameter to specify the time in seconds from now when the URL should expire. If specified, the URL contains the expiry timestamp in the URL, and the image signature is modified accordingly. | - -#### Examples of generating URLs - -**1\. Chained Transformations as a query parameter** - -```cs -Transformation transformation = new Transformation() - .Width(400).Height(300) - .Chain() - .Rotation(90); - -string imageURL = imagekit.Url(transformation) - .Path("/default_image.jpg") - .UrlEndpoint("https://ik.imagekit.io/your_imagekit_id/endpoint") - .TransformationPosition("query") - .Generate(); -``` - -```plaintext -https://ik.imagekit.io/your_imagekit_id/endpoint/default_image.jpg?tr=h-300,w-400:rt-90 -``` - -**2\. Sharpening, contrast adjustment, shadow and gradient transformations, along with a progressive JPEG format image.** - -There are some transforms like [Sharpening](https://docs.imagekit.io/features/image-transformations/image-enhancement-and-color-manipulation) that can be added to the URL with or without any other value. - -```cs -string src = "https://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg"; - -Transformation trans = new Transformation() - .Format("jpg") - .Progressive(false) - .EffectSharpen() - .EffectContrast(1) - .EffectShadow() - .EffectGradient(); - -string imageURL = imagekit.Url(trans) - .Src(src) - .Generate(); -``` - -**Note**: Because `src` parameter was used, the transformation string gets added as a query parameter `tr`. - -```plaintext -https://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg?tr=f-jpg%2Cpr-false%2Ce-sharpen%2Ce-contrast-1%2Ce-shadow%2Ce-gradient -``` - -**3\. Signed URL that expires in 600 seconds with the default URL endpoint and other query parameters** - -```cs -Transformation trans = new Transformation() - .Height(300).Width(400); -string[] queryParams = { "v = 123" }; - -string imageURL = imagekit.Url(trans) - .Path("/default-image.jpg") - .QueryParameters(queryParams) - .Signed(false).ExpireSeconds(600) - .Generate(); -``` - -```plaintext -https://ik.imagekit.io/your_imagekit_id/tr:h-300,w-400/default-image.jpg?v=123&ik-t=1567358667&ik-s=f2c7cdacbe7707b71a83d49cf1c6110e3d701054 -``` - -**4. Adding overlays** - -ImageKit.io enables you to apply overlays to [images](https://docs.imagekit.io/features/image-transformations/overlay-using-layers) and [videos](https://docs.imagekit.io/features/video-transformation/overlay) using the raw parameter with the concept of [layers](https://docs.imagekit.io/features/image-transformations/overlay-using-layers#layers). The raw parameter facilitates incorporating transformations directly in the URL. A layer is a distinct type of transformation that allows you to define an asset to serve as an overlay, along with its positioning and additional transformations. - -**Text as overlays** - -You can add any text string over a base video or image using a text layer (l-text). - -For example: - -```cs -string path = "/default_image.jpg"; -Transformation trans = new Transformation() -.Width(400) -.Height(300) -.Raw("l-text,i-Imagekit,fs-50,l-end"); - -string imageURL = imagekit.Url(trans).Path(path).TransformationPosition("query").Generate(); -``` -**Sample Result URL** -``` -https://ik.imagekit.io/your_imagekit_id/default-image.jpg?tr=h-300,w-400,l-text,i-Imagekit,fs-50,l-end -``` - -**Image as overlays** - -You can add an image over a base video or image using an image layer (l-image). - -For example: - -```cs -string path = "/default_image.jpg"; -Transformation trans = new Transformation() -.Width(400) -.Height(300) -.Raw("l-image,i-default-image.jpg,w-100,b-10_CDDC39,l-end"); - -string imageURL = imagekit.Url(trans).Path(path).TransformationPosition("query").Generate(); -``` -**Sample Result URL** -``` -https://ik.imagekit.io/your_imagekit_id/default-image.jpg?tr=h-300,w-400,l-image,i-default-image.jpg,w-100,b-10_CDDC39,l-end -``` - -**Solid color blocks as overlays** - -You can add solid color blocks over a base video or image using an image layer (l-image). - -For example: - -```cs -string path = "/img/sample-video.mp4"; -Transformation trans = new Transformation() -.Width(400) -.Height(300) -.Raw("l-image,i-ik_canvas,bg-FF0000,w-300,h-100,l-end"); - -string imageURL = imagekit.Url(trans).Path(path).TransformationPosition("query").Generate(); -``` -**Sample Result URL** -``` -https://ik.imagekit.io/your_imagekit_id/img/sample-video.mp4?tr=h-300,w-400,l-image,i-ik_canvas,bg-FF0000,w-300,h-100,l-end -``` - -#### List of supported transformations - -The complete list of transformations supported and their usage in ImageKit can be found [here](https://docs.imagekit.io/features/image-transformations). The SDK gives a name to each transformation parameter, making the code simpler and more readable. If a transformation is supported in ImageKit, but a name for it cannot be found in the table below, then use the transformation code from ImageKit docs as the name when using the `url` function. - -| Supported Transformation Name | Translates to parameters | -| --- | --- | -| Height | h | -| Width | w | -| AspectRatio | ar | -| Quality | q | -| Crop | c | -| CropMode | cm | -| X | x | -| Y | y | -| Focus | fo | -| Format | f | -| Radius | r | -| Background | bg | -| Border | b | -| Rotation | rt | -| Blur | bl | -| Named | n | -| Progressive | pr | -| Lossless | lo | -| Trim | t | -| Metadata | md | -| ColorProfile | cp | -| DefaultImage | di | -| Dpr | dpr | -| EffectSharpen | e-sharpen | -| EffectUSM | e-usm | -| EffectContrast | e-contrast | -| EffectGray | e-grayscale | -| EffectShadow | e-shadow | -| EffectGradient | e-gradient | -| Original | orig | -| Raw | `replaced by the parameter value` | - -### File Upload - -The SDK provides a simple interface using the `.upload()` method to upload files to the ImageKit Media Library. It accepts all the parameters supported by the [ImageKit Upload API](https://docs.imagekit.io/api-reference/upload-file-api/server-side-file-upload). - -The `upload()` method requires at least the `file` and the `fileName` parameter to upload a file. You can pass other parameters supported by the ImageKit upload API using the same parameter name as specified in the upload API documentation. For example, to specify tags for a file at the time of upload, use the `tags` parameter as specified in the [documentation here](https://docs.imagekit.io/api-reference/upload-file-api/server-side-file-upload). - -Sample usage - -```cs - // Upload By URI -FileCreateRequest request = new FileCreateRequest -{ - file = "http://www.google.com/images/logos/ps_logo2.png", - fileName = "file_name.jpg", -}; -Result resp1 = imagekit.Upload(request); - -// Upload by bytes -byte[] bytes = System.IO.File.ReadAllBytes(@"image file path"); - -FileCreateRequest ob = new FileCreateRequest -{ - file = bytes, - fileName = Guid.NewGuid().ToString() -}; -List tags = new List -{ - "Software", - "Developer", - "Engineer" -}; -ob.tags = tags; - -string customCoordinates = "10,10,20,20"; -ob.customCoordinates = customCoordinates; -List responseFields = new List -{ - "isPrivateFile", - "tags", - "customCoordinates" -}; -ob.responseFields = responseFields; -List ext = new List(); -BackGroundImage bck1 = new BackGroundImage -{ - name = "remove-bg", - options = new options() - { add_shadow = true, semitransparency = false, bg_image_url = "http://www.google.com/images/logos/ps_logo2.png" } -}; -AutoTags autoTags = new AutoTags -{ - name = "google-auto-tagging", - maxTags = 5, - minConfidence = 95 -}; -ext.Add(bck1); -ext.Add(autoTags); -TransformationObject transformationObject = new TransformationObject -{ - value = "w-100" -}; -List postTransformations = new List(); -postTransformations.Add(transformationObject); -UploadTransformation uploadTransformation = new UploadTransformation -{ - pre = "l-text,i-Imagekit,fs-50,l-end", - post = postTransformations, -}; -ob.extensions = ext; -ob.webhookUrl = "https://webhook.site/c78d617f_33bc_40d9_9e61_608999721e2e"; -ob.useUniqueFileName = true; -ob.folder = "dummy_folder"; -ob.isPrivateFile = false; -ob.overwriteFile = true; -ob.overwriteAITags = true; -ob.overwriteTags = true; -ob.overwriteCustomMetadata = true; -ob.checks = "'file.size' < '1mb'" // To run server side checks before uploading files. Notice the quotes around file.size and 1mb. -ob.isPublished = true; -Result resp2 = imagekit.Upload(ob); - -//Get Base64 -byte[] imageArray = System.IO.File.ReadAllBytes(@"image file path"); -string base64ImageRepresentation = Convert.ToBase64String(imageArray); -// Upload by Base64 -FileCreateRequest ob2 = new FileCreateRequest -{ - file=base64ImageRepresentation, - fileName = Guid.NewGuid().ToString() -}; -Result resp = imagekit.Upload(ob2); -``` - -### File Management - -The SDK provides a simple interface for all the [media APIs mentioned here](https://docs.imagekit.io/api-reference/media-afile-uploadpi) to manage your files. - -**1 . List & Search Files** - -Accepts an object specifying the parameters to be used to list and search files. All parameters specified in the [documentation here](https://docs.imagekit.io/api-reference/media-api/list-and-search-files) can be passed as it is with the correct values to get the results. - -#### Applying Filters -Filter out the files by specifying the parameters. - -```cs -GetFileListRequest model = new GetFileListRequest -{ - Name = "file_name.jpg", - Type = "file", - Limit = 10, - Skip = 0, - Sort = "ASC_CREATED", - FileType = "image", - Tags = new string[] { "tag1", "tag2" } -}; -ResultList res = await imagekit.GetFileListRequestAsync(model); -``` - -#### Advance Search -In addition, you can fine-tune your query by specifying various filters by generating a query string in a Lucene-like syntax and providing this generated string as the value of the `SearchQuery`. - -```cs -GetFileListRequest model = new GetFileListRequest -{ - SearchQuery = "createdAt >= '2d' OR size < '2mb' OR format='png'", -}; -ResultList res = await imagekit.GetFileListRequestAsync(model); -``` - -Detailed documentation can be found here for [advance search queries](https://docs.imagekit.io/api-reference/media-api/list-and-search-files#advanced-search-queries). - -**2\. Get File Details** - -Accepts the file ID and fetches the details as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/get-file-details). - -```cs -Result resp = await imagekit.GetFileDetail(file_Id); -``` - -**3\. File Update** - -Accepts an object of class `FileUpdateRequest` specifying the parameters to be used to update file details. All parameters specified in the \[documentation here\] (https://docs.imagekit.io/api-reference/media-api/update-file-details) can be passed via their setter functions to get the results. - -```cs -FileUpdateRequest updateob = new FileUpdateRequest -{ - fileId = "fileId", -}; -List updatetags = new List -{ - "Software", - "Developer", - "Engineer" -}; -updateob.tags = updatetags; -string updatecustomCoordinates = "10,10,20,20"; -updateob.customCoordinates = updatecustomCoordinates; -List updateresponseFields = new List -{ - "isPrivateFile", - "tags", - "customCoordinates" -}; - -List extModel = new List(); -BackGroundImage bck = new BackGroundImage -{ - name = "remove-bg", - options = new options() { add_shadow = true, semitransparency = false, bg_color = "green" } -}; -extModel.Add(bck); -updateob.extensions = extModel; -updateob.webhookUrl = "https://webhook.site/c78d617f_33bc_40d9_9e61_608999721e2e"; -Result updateresp = imagekit.UpdateFileDetail(updateob); -``` - -**Update publish status** - -If `publish` is included in the update options, no other parameters are allowed. - -```cs -FileUpdateRequest updateob = new FileUpdateRequest -{ - fileId = "fileId", -}; -PublishStatus publishStatus = new PublishStatus -{ - isPublished = false -}; -updateob.publish = publishStatus; -Result updateresp = imagekit.UpdateFileDetail(updateob); -``` - -**4\. Delete File** - -Accept the file ID and delete a file as per the [API documentation here](https://docs.imageKit.io/api-reference/media-api/delete-file). - -```cs -String fileId = "file_Id"; -ResultDelete result = imageKit.deleteFile(fileId); -``` - -**5\. Delete files (bulk)** - -Accepts the file IDs to delete files as per the [API documentation here](https://docs.imageKit.io/api-reference/media-api/delete-files-bulk). - -```cs -List ob3 = new List(); -ob3.Add("fileId_1"); -ob3.Add("fileId_2"); -ResultFileDelete resultFileDelete = imagekit.BulkDeleteFiles(ob3); -``` - -**6\. Copy file** - -Accepts an object of class `CopyFileRequest` specifying the parameters to be used to copy a file. All parameters specified in the [documentation here](https://docs.imageKit.io/api-reference/media-api/copy-file) can be passed via their setter functions to get the results. - -```cs -CopyFileRequest cpyRequest = new CopyFileRequest -{ - sourceFilePath = "path_1", - destinationPath = "path_2", - includeFileVersions = true -}; -ResultNoContent resultNoContent = imagekit.CopyFile(cpyRequest); -``` - -**7\. Move file** - -Accepts an object of class `MoveFileRequest` specifying the parameters to be used to move a file. All parameters specified in the [documentation here](https://docs.imageKit.io/api-reference/media-api/move-file) can be passed via their setter functions to get the results. - -```cs -MoveFileRequest moveFile = new MoveFileRequest -{ - sourceFilePath = "path_1", - destinationPath = "path_2" -}; -ResultNoContent resultNoContentMoveFile = imagekit.MoveFile(moveFile); -``` - -**8\. Rename file** - -Accepts an object of class `RenameFileRequest` specifying the parameters to be used to rename a file. All parameters specified in the [documentation here](https://docs.imageKit.io/api-reference/media-api/rename-file) can be passed via their setter functions to get the results. - -```cs -RenameFileRequest renameFileRequest = new RenameFileRequest -{ - filePath = "path_1", - newFileName = "file_name", - purgeCache = false -}; -ResultRenameFile resultRenameFile = imagekit.RenameFile(renameFileRequest); -``` - -### Tags Management - -The SDK provides a simple interface to manage your tags. - -**9\. Add tags** - -Accepts an object of class `TagsRequest` specifying the parameters to be used to add tags. All parameters specified in the [documentation here](https://docs.imageKit.io/api-reference/media-api/add-tags-bulk) can be passed via their setter functions to get the results. - -```cs -TagsRequest tagsRequest = new TagsRequest -{ - tags = new List - { - "tag_1", - "tag_2" - }, - fileIds = new List - { - "fileId_1", - }, -}; -ResultTags resultTags = imagekit.AddTags(tagsRequest); -``` - -**10\. Remove tags** - -Accepts an object of class `TagsRequest` specifying the parameters to be used to remove tags. All parameters specified in the [documentation here](https://docs.imageKit.io/api-reference/media-api/remove-tags-bulk) can be passed via their setter functions to get the results. - -```cs -TagsRequest removeTagsRequest = new TagsRequest -{ - tags = new List - { - "tag_1", - "tag_2" - }, - fileIds = new List - { - "fileId_1", - }, -}; -ResultTags removeTags = imagekit.RemoveTags(removeTagsRequest); -``` - -**11\. Remove AI tags** - -Accepts an object of class `AITagsRequest` specifying the parameters to be used to remove AI tags. All parameters specified in the [documentation here](https://docs.imageKit.io/api-reference/media-api/remove-aitags-bulk) can be passed via their setter functions to get the results. - -```cs -AITagsRequest removeAITagsRequest = new AITagsRequest -{ - AITags = new List - { - "tag_1", - "tag_2" - }, - fileIds = new List - { - "fileId_1", - } -}; -ResultTags removeAITags = imagekit.RemoveAITags(removeAITagsRequest); -``` - -**12\. Get File Versions** - -Accepts the file ID and fetches the details as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/get-file-versions). - -```cs -String fileId = "file_id_1"; -ResultFileVersions resultFileVersions = imageKit.getFileVersions(fileId); -``` - -**13\. Get File Version details** +See the [`examples`](examples) directory for complete and runnable examples. -Accepts the file ID and version ID and fetches the details as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/get-file-version-details). - -```cs -String fileId = "file_Id"; -String versionId = "version_Id"; -ResultFileVersionDetails resultFileVersionDetails = imageKit.getFileVersionDetails(fileId, versionId); -``` - -**14\. Delete FileVersion** - -Accepts an object of class `DeleteFileVersionRequest` specifying the parameters to be used to delete the file version. All parameters specified in the [documentation here](https://docs.imageKit.io/api-reference/media-api/delete-file-version) can be passed via their setter functions to get the results. - -```cs -DeleteFileVersionRequest delRequest = new DeleteFileVersionRequest -{ - fileId = "file_Id", - versionId = "version_Id" -}; -ResultNoContent resultNoContent1 = imagekit.DeleteFileVersion(delRequest); -``` - -**15\. Restore file Version** - -Accepts the fileId and versionId to restore the file version as per the [API documentation here](https://docs.imageKit.io/api-reference/media-api/restore-file-version). - -```cs -Result result = imagekit.RestoreFileVersion("file_Id", "version_Id"); -``` - -### Folder Management - -**16\. Create Folder** - -Accepts an object of class `CreateFolderRequest` specifying the parameters to be used to create a folder. All parameters specified in the [documentation here](https://docs.imageKit.io/api-reference/media-api/create-folder) can be passed via their setter functions to get the results. - -```cs -CreateFolderRequest createFolderRequest = new CreateFolderRequest -{ - folderName = "folder_name", - parentFolderPath = "source/folder/path" -}; -ResultEmptyBlock resultEmptyBlock = imagekit.CreateFolder(createFolderRequest); -``` - -**17\. Copy Folder** - -Accepts an object of class `CopyFolderRequest` specifying the parameters to be used to copy a folder. All parameters specified in the [documentation here](https://docs.imageKit.io/api-reference/media-api/copy-folder) can be passed via their setter functions to get the results. - -```cs -CopyFolderRequest cpyFolderRequest = new CopyFolderRequest -{ - sourceFolderPath = "path_1", - destinationPath = "path_2", - includeFileVersions = true -}; - -ResultOfFolderActions resultOfFolderActions = imagekit.CopyFolder(cpyFolderRequest); -``` - -**18\. Move Folder** - -Accepts an object of class `MoveFolderRequest` specifying the parameters to be used to move a folder. All parameters specified in the [documentation here](https://docs.imageKit.io/api-reference/media-api/move-folder) can be passed via their setter functions to get the results. - -```cs -MoveFolderRequest moveFolderRequest = new MoveFolderRequest -{ - sourceFolderPath="path_1", - destinationPath="path_2" -}; - -ResultOfFolderActions resultOfFolderActions1 = imagekit.MoveFolder(moveFolderRequest); -``` - -**19\. Delete Folder** +```csharp +using System; +using Imagekit; +using Imagekit.Models.Files; -Accepts an object of class `DeleteFolderRequest` specifying the parameters to be used to delete a folder. All parameters specified in the [documentation here](https://docs.imageKit.io/api-reference/media-api/delete-folder) can be passed via their setter functions to get the results. +// Configured using the IMAGEKIT_PRIVATE_API_KEY, OPTIONAL_IMAGEKIT_IGNORES_THIS, IMAGEKIT_WEBHOOK_SECRET and IMAGE_KIT_BASE_URL environment variables +ImageKitClient client = new(); -```cs -DeleteFolderRequest deleteFolderRequest = new DeleteFolderRequest +FileUploadParams parameters = new() { - folderPath="source/folder/path/folder_name", + File = "a value", + FileName = "file-name.jpg", }; -ResultNoContent resultNoContent2 = imagekit.DeleteFolder(deleteFolderRequest); -``` - -### Job Management - -**20\. Get Bulk Job Status** -Accepts the jobId to get bulk job status as per the [API documentation here](https://docs.imageKit.io/api-reference/media-api/copy-move-folder-status). +var response = await client.Files.Upload(parameters); -```cs -String jobId = "job_Id"; -ResultBulkJobStatus resultBulkJobStatus = imageKit.getBulkJobStatus(jobId); +Console.WriteLine(response); ``` -### Purge +## Client Configuration -**21\. Purge Cache** +Configure the client using environment variables: -Accepts a full URL of the file for which the cache has to be cleared as per the [API documentation here](https://docs.imageKit.io/api-reference/media-api/purge-cache). - -```cs -ResultCache result = imageKit.purgeCache("https://ik.imageKit.io/imagekit-id/default-image.jpg"); -``` - -**22\. Purge Cache Status** - -Accepts a request ID and fetch purge cache status as per the [API documentation here](https://docs.imageKit.io/api-reference/media-api/purge-cache-status) - -```cs -String requestId = "cache_request_Id"; -ResultCacheStatus result = imageKit.getPurgeCacheStatus(requestId); -``` - -### Metadata - -Accepts the file ID and fetches the metadata as per the [API documentation here](https://docs.imageKit.io/api-reference/metadata-api/get-image-metadata-for-uploaded-media-files) - -**23\. Get File Metadata** - -```cs -String fileId = "file_id"; -ResultMetaData result = imageKit.getFileMetadata(fileId); -``` - -Another way to get metadata from a remote file URL as per the [API documentation here](https://docs.imageKit.io/api-reference/metadata-api/get-image-metadata-from-remote-url). This file should be accessible over the imageKit.io URL-endpoint. - -```cs -String url = "Remote File URL"; -ResultMetaData result = imageKit.getRemoteFileMetadata(url); -``` - -**24\. Create Custom MetaData Fields** - -Accepts an object of class `CustomMetaDataFieldCreateRequest` specifying the parameters to be used to create cusomMetaDataFields. All parameters specified in the [documentation here](https://docs.imageKit.io/api-reference/custom-metadata-fields-api/create-custom-metadata-field) can be passed as-is with the correct values to get the results. - -Check for the [Allowed Values In The Schema](https://docs.imageKit.io/api-reference/custom-metadata-fields-api/create-custom-metadata-field#allowed-values-in-the-schema-object). - -#### Examples: - -```cs -CustomMetaDataFieldCreateRequest requestModel = new CustomMetaDataFieldCreateRequest -{ - name = "custom-meta-1", - label = "Testmeta" -}; -CustomMetaDataFieldSchemaObject schema = new CustomMetaDataFieldSchemaObject -{ - type = "Number", - minValue = 2000, - maxValue = 3000, - isValueRequired = true, - defaultValue = "2500" -}; - -requestModel.schema = schema; -ResultCustomMetaDataField resultCustomMetaDataField1 = imagekit.CreateCustomMetaDataFields(requestModel); -``` - -* Date type Example: - -```cs -CustomMetaDataFieldCreateRequest requestModelDate = new CustomMetaDataFieldCreateRequest -{ - name = "custom_meta_Date", - label = "TestmetaDate" -}; -CustomMetaDataFieldSchemaObject schemaDate = new CustomMetaDataFieldSchemaObject -{ - type = "Date", - minValue = "2022-11-30T10:11:10+00:00", - maxValue = "2022-12-30T10:11:10+00:00" -}; -requestModelDate.schema = schemaDate; -ResultCustomMetaDataField resultCustomMetaDataFieldDate = imagekit.CreateCustomMetaDataFields(requestModelDate); -``` - -**25\. Get CustomMetaDataFields** - -Accepts the includeDeleted boolean and fetches the metadata as per the [API documentation here](https://docs.imageKit.io/api-reference/custom-metadata-fields-api/get-custom-metadata-field) +```csharp +using Imagekit; -```cs -bool includeDeleted = true; -ResultCustomMetaDataFieldList resultCustomMetaDataFieldList = imageKit.getCustomMetaDataFields(includeDeleted); +// Configured using the IMAGEKIT_PRIVATE_API_KEY, OPTIONAL_IMAGEKIT_IGNORES_THIS, IMAGEKIT_WEBHOOK_SECRET and IMAGE_KIT_BASE_URL environment variables +ImageKitClient client = new(); ``` -**26\. Edit Custom MetaData Fields** +Or manually: -Accepts an ID of customMetaDataField and an object of class `CustomMetaDataFieldUpdateRequest` specifying the parameters to be used to edit cusomMetaDataFields as per the [API documentation here](https://docs.imageKit.io/api-reference/custom-metadata-fields-api/update-custom-metadata-field). +```csharp +using Imagekit; -```cs -CustomMetaDataFieldUpdateRequest requestUpdateModel = new CustomMetaDataFieldUpdateRequest -{ - Id = "field_id", -}; -CustomMetaDataFieldSchemaObject updateschema = new CustomMetaDataFieldSchemaObject +ImageKitClient client = new() { - type = "Number", - minValue = 8000, - maxValue = 3000 + PrivateAPIKey = "My Private API Key", + Password = "My Password", }; - -requestUpdateModel.schema = updateschema; -ResultCustomMetaDataField resultCustomMetaDataFieldUpdate = imagekit.UpdateCustomMetaDataFields(requestUpdateModel); -``` - -**27\. Delete Custom MetaData Fields** - -Accepts the id to delete the customMetaDataFields as per the [API documentation here](https://docs.imageKit.io/api-reference/custom-metadata-fields-api/delete-custom-metadata-field). - -```cs -ResultNoContent resultNoContent = imageKit.DeleteCustomMetaDataField("field_id"); -``` - -## Utility functions - -We have included the following commonly used utility functions in this library. - -### Authentication Parameter Generation - -If you are looking to implement client-side file upload, you will need a token, expiry timestamp, and a valid signature for that upload. The SDK provides a simple method that you can use in your code to generate these authentication parameters for you. - -_Note: The Private API Key should never be exposed in any client-side code. You must always generate these authentication parameters on the server-side_ - -```cs -AuthParamResponse resp = imageKit.GetAuthenticationParameters(); -``` - -Returns - -```javascript -{ - "token" : "unique_token", - "expire" : "valid_expiry_timestamp", - "signature" : "generated_signature" -} -``` - -Both the `token` and `expire` parameters are optional. If not specified, the SDK uses the [uuid](https://www.npmjs.com/package/uuid) package to generate a random token and also generates a valid expiry timestamp internally. The value of the `token` and `expire` used to generate the signature is always returned in the response, no matter if they are provided as an input to this method or not. - -### Distance calculation between two pHash values - -Perceptual hashing allows you to construct a hash value that uniquely identifies an input image based on an image's contents. [imageKit.io metadata API](https://docs.imageKit.io/api-reference/metadata-api) returns the pHash value of an image in the response. You can use this value to [find a duplicate (or similar) image](https://docs.imageKit.io/api-reference/metadata-api#using-phash-to-find-similar-or-duplicate-images) by calculating the distance between the two images' pHash value. - -This SDK exposes `PHashDistance` function to calculate the distance between two pHash values. It accepts two pHash hexadecimal strings and returns a numeric value indicative of the level of difference between the two images. - -```cs -public static int CalculateDistance() { - // asynchronously fetch metadata of two uploaded image files - // ... - // Extract pHash strings from both: say 'firstHash' and 'secondHash' - // ... - // Calculate the distance between them: - int distance = imageKit.PHashDistance(firstHash, secondHash); - return distance; -} -``` - -#### Distance calculation examples - -```cs -imageKit.PHashDistance('firstHash', 'secondHash'); -// output: 0 (same image) - -imageKit.PHashDistance('firstHash', 'secondHash'); -// output: 17 (similar images) - -imageKit.PHashDistance('firstHash', 'secondHash'); -// output: 37 (dissimilar images) ``` -## Handling errors +Or using a combination of the two approaches. -Catch and respond to invalid data, internal problems, and more. +See this table for the available options: -Imagekit .Net SDK raises exceptions for many reasons, such as being not found, invalid parameters, authentication errors, and internal server errors. We recommend writing code that gracefully handles all possible API exceptions. +| Property | Environment variable | Required | Default value | +| --------------- | -------------------------------- | -------- | --------------------------- | +| `PrivateAPIKey` | `IMAGEKIT_PRIVATE_API_KEY` | true | - | +| `Password` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` | +| `WebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - | +| `BaseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` | -#### Example: +## Requests and responses -```cs -try -{ - // Use ImageKit's SDK to make requests... -} -catch (InvalidOperationException ex) -{ - Console.Write("Invalid operation. Please try again."); -} -catch (FormatException ex) -{ - Console.Write("Not a valid format. Please try again."); -} -catch (WebServiceException webEx) -{ - /* - webEx.StatusCode = 400 - webEx.StatusDescription = ArgumentNullException - webEx.ErrorCode = ArgumentNullException - webEx.ErrorMessage = Value cannot be null. Parameter name: Name - webEx.StackTrace = (your Server Exception StackTrace - in DebugMode) - webEx.ResponseDto = (your populated Response DTO) - webEx.ResponseStatus = (your populated Response Status DTO) - webEx.GetFieldErrors() = (individual errors for each field if any) - */ -} -``` - -## Access request-id, other response headers and HTTP status code - -You can access success or error object to access the HTTP status code and response headers. - -```cs -// Success -var response = await imagekit.PurgeStatus(requestId); -console.Write(response.statusCode); // 200 -// {'content-type': 'application/json', 'x-request-id': 'ee560df4-d44f-455e-a48e-29dfda49aec5'} -console.Write(response.Raw); -try -{ - await imagekit.PurgeStatus(requestId); -} -catch (Exception ex) -{ - console.Write(ex.Message); - // {'content-type': 'application/json', 'x-request-id': 'ee560df4-d44f-455e-a48e-29dfda49aec5'} -} -``` +To send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a C# class. -## Support +For example, `client.Files.Upload` should be called with an instance of `FileUploadParams`, and it will return an instance of `Task`. -For any feedback or to report any issues or general implementation support, please reach out to [support@imageKit.io](mailto:support@imageKit.io) +## Semantic versioning -## Links +This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions: -* [Documentation](https://docs.imageKit.io) -* [Main website](https://imageKit.io) +1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_ +2. Changes that we do not expect to impact the vast majority of users in practice. -## License +We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience. -This project is licensed under the MIT License - see the [LICENSE](LICENSE) File for details \ No newline at end of file +We are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/imagekit-csharp/issues) with questions, bugs, or suggestions. diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 00000000..8e64327a --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,27 @@ +# Security Policy + +## Reporting Security Issues + +This SDK is generated by [Stainless Software Inc](http://stainless.com). Stainless takes security seriously, and encourages you to report any security vulnerability promptly so that appropriate action can be taken. + +To report a security issue, please contact the Stainless team at security@stainless.com. + +## Responsible Disclosure + +We appreciate the efforts of security researchers and individuals who help us maintain the security of +SDKs we generate. If you believe you have found a security vulnerability, please adhere to responsible +disclosure practices by allowing us a reasonable amount of time to investigate and address the issue +before making any information public. + +## Reporting Non-SDK Related Security Issues + +If you encounter security issues that are not directly related to SDKs but pertain to the services +or products provided by Image Kit, please follow the respective company's security reporting guidelines. + +### Image Kit Terms and Policies + +Please contact developer@imagekit.io for any questions or concerns regarding the security of our services. + +--- + +Thank you for helping us keep the SDKs and systems they interact with secure. diff --git a/codecov.yml b/codecov.yml deleted file mode 100644 index 52dd98c0..00000000 --- a/codecov.yml +++ /dev/null @@ -1,15 +0,0 @@ -# Team Yaml -coverage: - round: down - precision: 5 - -# Repository Yaml -coverage: - round: up - range: 0..10 - -# Used in Codecov after updating -coverage: - round: up - range: 0..10 - precision: 5 diff --git a/examples/ImagekitExample/ImagekitExample.csproj b/examples/ImagekitExample/ImagekitExample.csproj new file mode 100644 index 00000000..00114bda --- /dev/null +++ b/examples/ImagekitExample/ImagekitExample.csproj @@ -0,0 +1,12 @@ + + + + + + Exe + net8.0 + ImagekitExample + enable + disable + + diff --git a/scripts/bootstrap b/scripts/bootstrap new file mode 100755 index 00000000..2527407d --- /dev/null +++ b/scripts/bootstrap @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +echo "==> Running dotnet tool restore" +dotnet tool restore diff --git a/scripts/build b/scripts/build new file mode 100755 index 00000000..3ce1e776 --- /dev/null +++ b/scripts/build @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +echo "==> Running dotnet build" +dotnet build diff --git a/scripts/format b/scripts/format new file mode 100755 index 00000000..52057e25 --- /dev/null +++ b/scripts/format @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +echo "==> Running dotnet csharpier format" +dotnet csharpier format . diff --git a/scripts/lint b/scripts/lint new file mode 100755 index 00000000..c7ef3cb9 --- /dev/null +++ b/scripts/lint @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +echo "==> Running dotnet format" +dotnet format style --severity info --verify-no-changes +dotnet format analyzers --severity info --verify-no-changes diff --git a/scripts/mock b/scripts/mock new file mode 100755 index 00000000..0b28f6ea --- /dev/null +++ b/scripts/mock @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +if [[ -n "$1" && "$1" != '--'* ]]; then + URL="$1" + shift +else + URL="$(grep 'openapi_spec_url' .stats.yml | cut -d' ' -f2)" +fi + +# Check if the URL is empty +if [ -z "$URL" ]; then + echo "Error: No OpenAPI spec path/url provided or found in .stats.yml" + exit 1 +fi + +echo "==> Starting mock server with URL ${URL}" + +# Run prism mock on the given spec +if [ "$1" == "--daemon" ]; then + npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" &> .prism.log & + + # Wait for server to come online + echo -n "Waiting for server" + while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do + echo -n "." + sleep 0.1 + done + + if grep -q "✖ fatal" ".prism.log"; then + cat .prism.log + exit 1 + fi + + echo +else + npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" +fi diff --git a/scripts/test b/scripts/test new file mode 100755 index 00000000..a562fa22 --- /dev/null +++ b/scripts/test @@ -0,0 +1,56 @@ +#!/usr/bin/env bash + +set -e + +cd -- "$(dirname -- "$0")/.." + +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[0;33m' +NC='\033[0m' # No Color + +function prism_is_running() { + curl --silent "http://localhost:4010" >/dev/null 2>&1 +} + +kill_server_on_port() { + pids=$(lsof -t -i tcp:"$1" || echo "") + if [ "$pids" != "" ]; then + kill "$pids" + echo "Stopped $pids." + fi +} + +function is_overriding_api_base_url() { + [ -n "$TEST_API_BASE_URL" ] +} + +if ! is_overriding_api_base_url && ! prism_is_running ; then + # When we exit this script, make sure to kill the background mock server process + trap 'kill_server_on_port 4010' EXIT + + # Start the dev server + ./scripts/mock --daemon +fi + +if is_overriding_api_base_url ; then + echo -e "${GREEN}✔ Running tests against ${TEST_API_BASE_URL}${NC}" + echo +elif ! prism_is_running ; then + echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Prism server" + echo -e "running against your OpenAPI spec." + echo + echo -e "To run the server, pass in the path or url of your OpenAPI" + echo -e "spec to the prism command:" + echo + echo -e " \$ ${YELLOW}npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock path/to/your.openapi.yml${NC}" + echo + + exit 1 +else + echo -e "${GREEN}✔ Mock prism server is running with your OpenAPI spec${NC}" + echo +fi + +echo "==> Running tests" +dotnet test diff --git a/src/Imagekit.Tests/Imagekit.Tests.csproj b/src/Imagekit.Tests/Imagekit.Tests.csproj new file mode 100644 index 00000000..cc370ddc --- /dev/null +++ b/src/Imagekit.Tests/Imagekit.Tests.csproj @@ -0,0 +1,20 @@ + + + net8.0 + false + true + disable + + $(NoWarn),xUnit1004 + + + + + + + + + + + + diff --git a/src/Imagekit.Tests/Services/Accounts/AccountServiceTest.cs b/src/Imagekit.Tests/Services/Accounts/AccountServiceTest.cs new file mode 100644 index 00000000..7be4ff92 --- /dev/null +++ b/src/Imagekit.Tests/Services/Accounts/AccountServiceTest.cs @@ -0,0 +1,3 @@ +namespace Imagekit.Tests.Services.Accounts; + +public class AccountServiceTest : TestBase { } diff --git a/src/Imagekit.Tests/Services/Accounts/Origins/OriginServiceTest.cs b/src/Imagekit.Tests/Services/Accounts/Origins/OriginServiceTest.cs new file mode 100644 index 00000000..596ba623 --- /dev/null +++ b/src/Imagekit.Tests/Services/Accounts/Origins/OriginServiceTest.cs @@ -0,0 +1,73 @@ +using System.Threading.Tasks; +using Imagekit.Models.Accounts.Origins.OriginRequestProperties; + +namespace Imagekit.Tests.Services.Accounts.Origins; + +public class OriginServiceTest : TestBase +{ + [Fact(Skip = "Prism tests are disabled")] + public async Task Create_Works() + { + var originResponse = await this.client.Accounts.Origins.Create( + new() + { + Origin = new S3() + { + AccessKey = "AKIATEST123", + Bucket = "test-bucket", + Name = "My S3 Origin", + SecretKey = "secrettest123", + BaseURLForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + Prefix = "images", + }, + } + ); + originResponse.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Update_Works() + { + var originResponse = await this.client.Accounts.Origins.Update( + new() + { + ID = "id", + Origin = new S3() + { + AccessKey = "AKIATEST123", + Bucket = "test-bucket", + Name = "My S3 Origin", + SecretKey = "secrettest123", + BaseURLForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + Prefix = "images", + }, + } + ); + originResponse.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task List_Works() + { + var originResponses = await this.client.Accounts.Origins.List(); + foreach (var item in originResponses) + { + item.Validate(); + } + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Delete_Works() + { + await this.client.Accounts.Origins.Delete(new() { ID = "id" }); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Get_Works() + { + var originResponse = await this.client.Accounts.Origins.Get(new() { ID = "id" }); + originResponse.Validate(); + } +} diff --git a/src/Imagekit.Tests/Services/Accounts/URLEndpoints/URLEndpointServiceTest.cs b/src/Imagekit.Tests/Services/Accounts/URLEndpoints/URLEndpointServiceTest.cs new file mode 100644 index 00000000..e02ba52f --- /dev/null +++ b/src/Imagekit.Tests/Services/Accounts/URLEndpoints/URLEndpointServiceTest.cs @@ -0,0 +1,47 @@ +using System.Threading.Tasks; + +namespace Imagekit.Tests.Services.Accounts.URLEndpoints; + +public class URLEndpointServiceTest : TestBase +{ + [Fact(Skip = "Prism tests are disabled")] + public async Task Create_Works() + { + var urlEndpointResponse = await this.client.Accounts.URLEndpoints.Create( + new() { Description = "My custom URL endpoint" } + ); + urlEndpointResponse.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Update_Works() + { + var urlEndpointResponse = await this.client.Accounts.URLEndpoints.Update( + new() { ID = "id", Description = "My custom URL endpoint" } + ); + urlEndpointResponse.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task List_Works() + { + var urlEndpointResponses = await this.client.Accounts.URLEndpoints.List(); + foreach (var item in urlEndpointResponses) + { + item.Validate(); + } + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Delete_Works() + { + await this.client.Accounts.URLEndpoints.Delete(new() { ID = "id" }); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Get_Works() + { + var urlEndpointResponse = await this.client.Accounts.URLEndpoints.Get(new() { ID = "id" }); + urlEndpointResponse.Validate(); + } +} diff --git a/src/Imagekit.Tests/Services/Accounts/Usage/UsageServiceTest.cs b/src/Imagekit.Tests/Services/Accounts/Usage/UsageServiceTest.cs new file mode 100644 index 00000000..5c9fec8f --- /dev/null +++ b/src/Imagekit.Tests/Services/Accounts/Usage/UsageServiceTest.cs @@ -0,0 +1,20 @@ +using System; +using System.Threading.Tasks; + +namespace Imagekit.Tests.Services.Accounts.Usage; + +public class UsageServiceTest : TestBase +{ + [Fact(Skip = "Prism tests are disabled")] + public async Task Get_Works() + { + var usage = await this.client.Accounts.Usage.Get( + new() + { + EndDate = DateOnly.Parse("2019-12-27"), + StartDate = DateOnly.Parse("2019-12-27"), + } + ); + usage.Validate(); + } +} diff --git a/src/Imagekit.Tests/Services/Assets/AssetServiceTest.cs b/src/Imagekit.Tests/Services/Assets/AssetServiceTest.cs new file mode 100644 index 00000000..c069b40c --- /dev/null +++ b/src/Imagekit.Tests/Services/Assets/AssetServiceTest.cs @@ -0,0 +1,16 @@ +using System.Threading.Tasks; + +namespace Imagekit.Tests.Services.Assets; + +public class AssetServiceTest : TestBase +{ + [Fact(Skip = "Prism tests are disabled")] + public async Task List_Works() + { + var assets = await this.client.Assets.List(); + foreach (var item in assets) + { + item.Validate(); + } + } +} diff --git a/src/Imagekit.Tests/Services/Beta/BetaServiceTest.cs b/src/Imagekit.Tests/Services/Beta/BetaServiceTest.cs new file mode 100644 index 00000000..df0194f8 --- /dev/null +++ b/src/Imagekit.Tests/Services/Beta/BetaServiceTest.cs @@ -0,0 +1,3 @@ +namespace Imagekit.Tests.Services.Beta; + +public class BetaServiceTest : TestBase { } diff --git a/src/Imagekit.Tests/Services/Beta/V2/Files/FileServiceTest.cs b/src/Imagekit.Tests/Services/Beta/V2/Files/FileServiceTest.cs new file mode 100644 index 00000000..e37025dd --- /dev/null +++ b/src/Imagekit.Tests/Services/Beta/V2/Files/FileServiceTest.cs @@ -0,0 +1,15 @@ +using System.Threading.Tasks; + +namespace Imagekit.Tests.Services.Beta.V2.Files; + +public class FileServiceTest : TestBase +{ + [Fact(Skip = "Prism tests are disabled")] + public async Task Upload_Works() + { + var response = await this.client.Beta.V2.Files.Upload( + new() { File = "a value", FileName = "fileName" } + ); + response.Validate(); + } +} diff --git a/src/Imagekit.Tests/Services/Beta/V2/V2ServiceTest.cs b/src/Imagekit.Tests/Services/Beta/V2/V2ServiceTest.cs new file mode 100644 index 00000000..1b31bb9d --- /dev/null +++ b/src/Imagekit.Tests/Services/Beta/V2/V2ServiceTest.cs @@ -0,0 +1,3 @@ +namespace Imagekit.Tests.Services.Beta.V2; + +public class V2ServiceTest : TestBase { } diff --git a/src/Imagekit.Tests/Services/Cache/CacheServiceTest.cs b/src/Imagekit.Tests/Services/Cache/CacheServiceTest.cs new file mode 100644 index 00000000..879b9a6b --- /dev/null +++ b/src/Imagekit.Tests/Services/Cache/CacheServiceTest.cs @@ -0,0 +1,3 @@ +namespace Imagekit.Tests.Services.Cache; + +public class CacheServiceTest : TestBase { } diff --git a/src/Imagekit.Tests/Services/Cache/Invalidation/InvalidationServiceTest.cs b/src/Imagekit.Tests/Services/Cache/Invalidation/InvalidationServiceTest.cs new file mode 100644 index 00000000..ef5f184f --- /dev/null +++ b/src/Imagekit.Tests/Services/Cache/Invalidation/InvalidationServiceTest.cs @@ -0,0 +1,24 @@ +using System.Threading.Tasks; + +namespace Imagekit.Tests.Services.Cache.Invalidation; + +public class InvalidationServiceTest : TestBase +{ + [Fact(Skip = "Prism tests are disabled")] + public async Task Create_Works() + { + var invalidation = await this.client.Cache.Invalidation.Create( + new() { URL = "https://ik.imagekit.io/your_imagekit_id/default-image.jpg" } + ); + invalidation.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Get_Works() + { + var invalidation = await this.client.Cache.Invalidation.Get( + new() { RequestID = "requestId" } + ); + invalidation.Validate(); + } +} diff --git a/src/Imagekit.Tests/Services/CustomMetadataFields/CustomMetadataFieldServiceTest.cs b/src/Imagekit.Tests/Services/CustomMetadataFields/CustomMetadataFieldServiceTest.cs new file mode 100644 index 00000000..645b10df --- /dev/null +++ b/src/Imagekit.Tests/Services/CustomMetadataFields/CustomMetadataFieldServiceTest.cs @@ -0,0 +1,59 @@ +using System.Threading.Tasks; +using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties; + +namespace Imagekit.Tests.Services.CustomMetadataFields; + +public class CustomMetadataFieldServiceTest : TestBase +{ + [Fact(Skip = "Prism tests are disabled")] + public async Task Create_Works() + { + var customMetadataField = await this.client.CustomMetadataFields.Create( + new() + { + Label = "label", + Name = "name", + Schema = new() + { + Type = Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + SelectOptions = ["small", "medium", "large", 30, 40, true], + }, + } + ); + customMetadataField.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Update_Works() + { + var customMetadataField = await this.client.CustomMetadataFields.Update( + new() { ID = "id" } + ); + customMetadataField.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task List_Works() + { + var customMetadataFields = await this.client.CustomMetadataFields.List(); + foreach (var item in customMetadataFields) + { + item.Validate(); + } + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Delete_Works() + { + var customMetadataField = await this.client.CustomMetadataFields.Delete( + new() { ID = "id" } + ); + customMetadataField.Validate(); + } +} diff --git a/src/Imagekit.Tests/Services/Files/Bulk/BulkServiceTest.cs b/src/Imagekit.Tests/Services/Files/Bulk/BulkServiceTest.cs new file mode 100644 index 00000000..76a30ceb --- /dev/null +++ b/src/Imagekit.Tests/Services/Files/Bulk/BulkServiceTest.cs @@ -0,0 +1,40 @@ +using System.Threading.Tasks; + +namespace Imagekit.Tests.Services.Files.Bulk; + +public class BulkServiceTest : TestBase +{ + [Fact(Skip = "Prism tests are disabled")] + public async Task Delete_Works() + { + var bulk = await this.client.Files.Bulk.Delete(new() { FileIDs = ["string"] }); + bulk.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task AddTags_Works() + { + var response = await this.client.Files.Bulk.AddTags( + new() { FileIDs = ["string"], Tags = ["string"] } + ); + response.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task RemoveAITags_Works() + { + var response = await this.client.Files.Bulk.RemoveAITags( + new() { AITags = ["string"], FileIDs = ["string"] } + ); + response.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task RemoveTags_Works() + { + var response = await this.client.Files.Bulk.RemoveTags( + new() { FileIDs = ["string"], Tags = ["string"] } + ); + response.Validate(); + } +} diff --git a/src/Imagekit.Tests/Services/Files/FileServiceTest.cs b/src/Imagekit.Tests/Services/Files/FileServiceTest.cs new file mode 100644 index 00000000..9241f04d --- /dev/null +++ b/src/Imagekit.Tests/Services/Files/FileServiceTest.cs @@ -0,0 +1,70 @@ +using System.Threading.Tasks; + +namespace Imagekit.Tests.Services.Files; + +public class FileServiceTest : TestBase +{ + [Fact(Skip = "Prism tests are disabled")] + public async Task Update_Works() + { + var file = await this.client.Files.Update(new() { FileID = "fileId" }); + file.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Delete_Works() + { + await this.client.Files.Delete(new() { FileID = "fileId" }); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Copy_Works() + { + var response = await this.client.Files.Copy( + new() + { + DestinationPath = "/folder/to/copy/into/", + SourceFilePath = "/path/to/file.jpg", + } + ); + response.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Get_Works() + { + var file = await this.client.Files.Get(new() { FileID = "fileId" }); + file.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Move_Works() + { + var response = await this.client.Files.Move( + new() + { + DestinationPath = "/folder/to/move/into/", + SourceFilePath = "/path/to/file.jpg", + } + ); + response.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Rename_Works() + { + var response = await this.client.Files.Rename( + new() { FilePath = "/path/to/file.jpg", NewFileName = "newFileName.jpg" } + ); + response.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Upload_Works() + { + var response = await this.client.Files.Upload( + new() { File = "a value", FileName = "fileName" } + ); + response.Validate(); + } +} diff --git a/src/Imagekit.Tests/Services/Files/Metadata/MetadataServiceTest.cs b/src/Imagekit.Tests/Services/Files/Metadata/MetadataServiceTest.cs new file mode 100644 index 00000000..ae2f33d1 --- /dev/null +++ b/src/Imagekit.Tests/Services/Files/Metadata/MetadataServiceTest.cs @@ -0,0 +1,22 @@ +using System.Threading.Tasks; + +namespace Imagekit.Tests.Services.Files.Metadata; + +public class MetadataServiceTest : TestBase +{ + [Fact(Skip = "Prism tests are disabled")] + public async Task Get_Works() + { + var metadata = await this.client.Files.Metadata.Get(new() { FileID = "fileId" }); + metadata.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task GetFromURL_Works() + { + var metadata = await this.client.Files.Metadata.GetFromURL( + new() { URL = "https://example.com" } + ); + metadata.Validate(); + } +} diff --git a/src/Imagekit.Tests/Services/Files/Versions/VersionServiceTest.cs b/src/Imagekit.Tests/Services/Files/Versions/VersionServiceTest.cs new file mode 100644 index 00000000..a4ddfcdd --- /dev/null +++ b/src/Imagekit.Tests/Services/Files/Versions/VersionServiceTest.cs @@ -0,0 +1,43 @@ +using System.Threading.Tasks; + +namespace Imagekit.Tests.Services.Files.Versions; + +public class VersionServiceTest : TestBase +{ + [Fact(Skip = "Prism tests are disabled")] + public async Task List_Works() + { + var files = await this.client.Files.Versions.List(new() { FileID = "fileId" }); + foreach (var item in files) + { + item.Validate(); + } + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Delete_Works() + { + var version = await this.client.Files.Versions.Delete( + new() { FileID = "fileId", VersionID = "versionId" } + ); + version.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Get_Works() + { + var file = await this.client.Files.Versions.Get( + new() { FileID = "fileId", VersionID = "versionId" } + ); + file.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Restore_Works() + { + var file = await this.client.Files.Versions.Restore( + new() { FileID = "fileId", VersionID = "versionId" } + ); + file.Validate(); + } +} diff --git a/src/Imagekit.Tests/Services/Folders/FolderServiceTest.cs b/src/Imagekit.Tests/Services/Folders/FolderServiceTest.cs new file mode 100644 index 00000000..21dcc7f5 --- /dev/null +++ b/src/Imagekit.Tests/Services/Folders/FolderServiceTest.cs @@ -0,0 +1,57 @@ +using System.Threading.Tasks; + +namespace Imagekit.Tests.Services.Folders; + +public class FolderServiceTest : TestBase +{ + [Fact(Skip = "Prism tests are disabled")] + public async Task Create_Works() + { + var folder = await this.client.Folders.Create( + new() { FolderName = "folderName", ParentFolderPath = "parentFolderPath" } + ); + folder.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Delete_Works() + { + var folder = await this.client.Folders.Delete(new() { FolderPath = "folderPath" }); + folder.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Copy_Works() + { + var response = await this.client.Folders.Copy( + new() + { + DestinationPath = "/path/of/destination/folder", + SourceFolderPath = "/path/of/source/folder", + } + ); + response.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Move_Works() + { + var response = await this.client.Folders.Move( + new() + { + DestinationPath = "/path/of/destination/folder", + SourceFolderPath = "/path/of/source/folder", + } + ); + response.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Rename_Works() + { + var response = await this.client.Folders.Rename( + new() { FolderPath = "/path/of/folder", NewFolderName = "new-folder-name" } + ); + response.Validate(); + } +} diff --git a/src/Imagekit.Tests/Services/Folders/Job/JobServiceTest.cs b/src/Imagekit.Tests/Services/Folders/Job/JobServiceTest.cs new file mode 100644 index 00000000..9ec1497d --- /dev/null +++ b/src/Imagekit.Tests/Services/Folders/Job/JobServiceTest.cs @@ -0,0 +1,13 @@ +using System.Threading.Tasks; + +namespace Imagekit.Tests.Services.Folders.Job; + +public class JobServiceTest : TestBase +{ + [Fact(Skip = "Prism tests are disabled")] + public async Task Get_Works() + { + var job = await this.client.Folders.Job.Get(new() { JobID = "jobId" }); + job.Validate(); + } +} diff --git a/src/Imagekit.Tests/Services/Webhooks/WebhookServiceTest.cs b/src/Imagekit.Tests/Services/Webhooks/WebhookServiceTest.cs new file mode 100644 index 00000000..88914250 --- /dev/null +++ b/src/Imagekit.Tests/Services/Webhooks/WebhookServiceTest.cs @@ -0,0 +1,3 @@ +namespace Imagekit.Tests.Services.Webhooks; + +public class WebhookServiceTest : TestBase { } diff --git a/src/Imagekit.Tests/TestBase.cs b/src/Imagekit.Tests/TestBase.cs new file mode 100644 index 00000000..a045d668 --- /dev/null +++ b/src/Imagekit.Tests/TestBase.cs @@ -0,0 +1,21 @@ +using System; +using Imagekit; + +namespace Imagekit.Tests; + +public class TestBase +{ + protected IImageKitClient client; + + public TestBase() + { + client = new ImageKitClient() + { + BaseUrl = new Uri( + Environment.GetEnvironmentVariable("TEST_API_BASE_URL") ?? "http://localhost:4010" + ), + PrivateAPIKey = "My Private API Key", + Password = "My Password", + }; + } +} diff --git a/src/Imagekit/ApiEnum.cs b/src/Imagekit/ApiEnum.cs new file mode 100644 index 00000000..29b6a839 --- /dev/null +++ b/src/Imagekit/ApiEnum.cs @@ -0,0 +1,56 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit; + +public record struct ApiEnum(JsonElement Json) + where TEnum : struct, Enum +{ + public readonly TRaw Raw() => + JsonSerializer.Deserialize(this.Json, ModelBase.SerializerOptions) + ?? throw new NullReferenceException(nameof(this.Json)); + + public readonly TEnum Value() => + JsonSerializer.Deserialize(this.Json, ModelBase.SerializerOptions); + + public readonly void Validate() + { + if (!Enum.IsDefined(Value())) + { + throw new Exception(); + } + } + + public static implicit operator TRaw(ApiEnum value) => value.Raw(); + + public static implicit operator TEnum(ApiEnum value) => value.Value(); + + public static implicit operator ApiEnum(TRaw value) => + new(JsonSerializer.SerializeToElement(value, ModelBase.SerializerOptions)); + + public static implicit operator ApiEnum(TEnum value) => + new(JsonSerializer.SerializeToElement(value, ModelBase.SerializerOptions)); +} + +sealed class ApiEnumConverter : JsonConverter> + where TEnum : struct, Enum +{ + public override ApiEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write( + Utf8JsonWriter writer, + ApiEnum value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} diff --git a/src/Imagekit/HttpException.cs b/src/Imagekit/HttpException.cs new file mode 100644 index 00000000..2986ea2c --- /dev/null +++ b/src/Imagekit/HttpException.cs @@ -0,0 +1,29 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Net; + +namespace Imagekit; + +public sealed class HttpException : Exception +{ + public required HttpStatusCode? StatusCode { get; set; } + public required string ResponseBody { get; set; } + public override string Message + { + get + { + return string.Format( + "Status Code: {0}\n{1}", + this.StatusCode?.ToString() ?? "Unknown", + this.ResponseBody + ); + } + } + + [SetsRequiredMembers] + public HttpException(HttpStatusCode? statusCode, string responseBody) + { + this.StatusCode = statusCode; + this.ResponseBody = responseBody; + } +} diff --git a/src/Imagekit/IImageKitClient.cs b/src/Imagekit/IImageKitClient.cs new file mode 100644 index 00000000..784f4b94 --- /dev/null +++ b/src/Imagekit/IImageKitClient.cs @@ -0,0 +1,56 @@ +using System; +using System.Net.Http; +using Imagekit.Services.Accounts; +using Imagekit.Services.Assets; +using Imagekit.Services.Beta; +using Imagekit.Services.Cache; +using Imagekit.Services.CustomMetadataFields; +using Imagekit.Services.Files; +using Imagekit.Services.Folders; +using Imagekit.Services.Webhooks; + +namespace Imagekit; + +public interface IImageKitClient +{ + HttpClient HttpClient { get; init; } + + Uri BaseUrl { get; init; } + + /// + /// Your ImageKit private API key (it starts with `private_`). You can view and + /// manage API keys in the [dashboard](https://imagekit.io/dashboard/developer/api-keys). + /// + string PrivateAPIKey { get; init; } + + /// + /// ImageKit Basic Auth only uses the username field and ignores the password. + /// This field is unused. + /// + string? Password { get; init; } + + /// + /// Your ImageKit webhook secret. This is used by the SDK to verify webhook signatures. + /// It starts with a `whsec_` prefix. You can view and manage your webhook secret + /// in the [dashboard](https://imagekit.io/dashboard/developer/webhooks). Treat + /// the secret like a password, keep it private and do not expose it publicly. + /// Learn more about [webhook verification](https://imagekit.io/docs/webhooks#verify-webhook-signature). + /// + string? WebhookSecret { get; init; } + + ICustomMetadataFieldService CustomMetadataFields { get; } + + IFileService Files { get; } + + IAssetService Assets { get; } + + ICacheService Cache { get; } + + IFolderService Folders { get; } + + IAccountService Accounts { get; } + + IBetaService Beta { get; } + + IWebhookService Webhooks { get; } +} diff --git a/src/Imagekit/IVariant.cs b/src/Imagekit/IVariant.cs new file mode 100644 index 00000000..1aebab56 --- /dev/null +++ b/src/Imagekit/IVariant.cs @@ -0,0 +1,8 @@ +namespace Imagekit; + +interface IVariant + where TVariant : IVariant +{ + static abstract TVariant From(TValue value); + TValue Value { get; } +} diff --git a/src/Imagekit/ImageKitClient.cs b/src/Imagekit/ImageKitClient.cs new file mode 100644 index 00000000..73466d00 --- /dev/null +++ b/src/Imagekit/ImageKitClient.cs @@ -0,0 +1,116 @@ +using System; +using System.Net.Http; +using Imagekit.Services.Accounts; +using Imagekit.Services.Assets; +using Imagekit.Services.Beta; +using Imagekit.Services.Cache; +using Imagekit.Services.CustomMetadataFields; +using Imagekit.Services.Files; +using Imagekit.Services.Folders; +using Imagekit.Services.Webhooks; + +namespace Imagekit; + +public sealed class ImageKitClient : IImageKitClient +{ + public HttpClient HttpClient { get; init; } = new(); + + Lazy _baseUrl = new(() => + new Uri( + Environment.GetEnvironmentVariable("IMAGE_KIT_BASE_URL") ?? "https://api.imagekit.io" + ) + ); + public Uri BaseUrl + { + get { return _baseUrl.Value; } + init { _baseUrl = new(() => value); } + } + + Lazy _privateAPIKey = new(() => + Environment.GetEnvironmentVariable("IMAGEKIT_PRIVATE_API_KEY") + ?? throw new ArgumentNullException(nameof(PrivateAPIKey)) + ); + public string PrivateAPIKey + { + get { return _privateAPIKey.Value; } + init { _privateAPIKey = new(() => value); } + } + + Lazy _password = new(() => + Environment.GetEnvironmentVariable("OPTIONAL_IMAGEKIT_IGNORES_THIS") ?? "do_not_set" + ); + public string? Password + { + get { return _password.Value; } + init { _password = new(() => value); } + } + + Lazy _webhookSecret = new(() => + Environment.GetEnvironmentVariable("IMAGEKIT_WEBHOOK_SECRET") + ); + public string? WebhookSecret + { + get { return _webhookSecret.Value; } + init { _webhookSecret = new(() => value); } + } + + readonly Lazy _customMetadataFields; + public ICustomMetadataFieldService CustomMetadataFields + { + get { return _customMetadataFields.Value; } + } + + readonly Lazy _files; + public IFileService Files + { + get { return _files.Value; } + } + + readonly Lazy _assets; + public IAssetService Assets + { + get { return _assets.Value; } + } + + readonly Lazy _cache; + public ICacheService Cache + { + get { return _cache.Value; } + } + + readonly Lazy _folders; + public IFolderService Folders + { + get { return _folders.Value; } + } + + readonly Lazy _accounts; + public IAccountService Accounts + { + get { return _accounts.Value; } + } + + readonly Lazy _beta; + public IBetaService Beta + { + get { return _beta.Value; } + } + + readonly Lazy _webhooks; + public IWebhookService Webhooks + { + get { return _webhooks.Value; } + } + + public ImageKitClient() + { + _customMetadataFields = new(() => new CustomMetadataFieldService(this)); + _files = new(() => new FileService(this)); + _assets = new(() => new AssetService(this)); + _cache = new(() => new CacheService(this)); + _folders = new(() => new FolderService(this)); + _accounts = new(() => new AccountService(this)); + _beta = new(() => new BetaService(this)); + _webhooks = new(() => new WebhookService(this)); + } +} diff --git a/src/Imagekit/Imagekit.csproj b/src/Imagekit/Imagekit.csproj new file mode 100644 index 00000000..042a3402 --- /dev/null +++ b/src/Imagekit/Imagekit.csproj @@ -0,0 +1,38 @@ + + + + The official .NET library for the Image Kit C# service API. + + SDK Code Generation Image Kit C# + Apache-2.0 + enable + 0.0.1 + net8.0 + latest + + true + README.md + https://www.github.com/stainless-sdks/imagekit-csharp + git + + true + true + + $(NoWarn),1570,1573,1574,1591 + + $(NoWarn),IL2026,IL3050 + Debug;Release + true + true + disable + + + + + diff --git a/src/Imagekit/ModelBase.cs b/src/Imagekit/ModelBase.cs new file mode 100644 index 00000000..7e43b00e --- /dev/null +++ b/src/Imagekit/ModelBase.cs @@ -0,0 +1,202 @@ +using System.Collections.Generic; +using System.Text.Json; +using Imagekit.Models; +using Imagekit.Models.Cache.Invalidation.InvalidationGetResponseProperties; +using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties; +using Imagekit.Models.Files.FileUpdateParamsProperties.UpdateProperties.UpdateFileDetailsProperties.ExtensionProperties.AutoTaggingExtensionProperties; +using Imagekit.Models.Files.FileUpdateResponseProperties.IntersectionMember1Properties.ExtensionStatusProperties; +using Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.AbsProperties; +using Imagekit.Models.ImageOverlayProperties.IntersectionMember1Properties; +using Imagekit.Models.OverlayPositionProperties; +using Imagekit.Models.SubtitleOverlayTransformationProperties; +using Imagekit.Models.TextOverlayTransformationProperties; +using Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.DataProperties.TransformationProperties.OptionsProperties; +using Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.DataProperties.TransformationProperties.ErrorProperties; +using AbsProperties = Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.AbsProperties; +using AssetListParamsProperties = Imagekit.Models.Assets.AssetListParamsProperties; +using AutoTaggingExtensionProperties = Imagekit.Models.Files.FileUploadParamsProperties.ExtensionProperties.AutoTaggingExtensionProperties; +using ExtensionStatusProperties = Imagekit.Models.Files.FileUploadResponseProperties.ExtensionStatusProperties; +using FileProperties = Imagekit.Models.Files.FileProperties; +using FileUploadParamsProperties = Imagekit.Models.Files.FileUploadParamsProperties; +using FolderProperties = Imagekit.Models.Files.FolderProperties; +using IntersectionMember1Properties = Imagekit.Models.SubtitleOverlayProperties.IntersectionMember1Properties; +using JobGetResponseProperties = Imagekit.Models.Folders.Job.JobGetResponseProperties; +using OptionsProperties = Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.DataProperties.TransformationProperties.OptionsProperties; +using SchemaProperties = Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties; +using TransformationProperties = Imagekit.Models.TransformationProperties; + +namespace Imagekit; + +public abstract record class ModelBase +{ + public Dictionary Properties { get; set; } = []; + + internal static readonly JsonSerializerOptions SerializerOptions = new() + { + Converters = + { + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter< + string, + global::Imagekit.Models.TextOverlayProperties.IntersectionMember1Properties.Encoding + >(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter< + string, + global::Imagekit.Models.VideoOverlayProperties.IntersectionMember1Properties.Encoding + >(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter< + string, + global::Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.ExtensionStatusProperties.AIAutoDescription + >(), + new ApiEnumConverter< + string, + global::Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.ExtensionStatusProperties.AwsAutoTagging + >(), + new ApiEnumConverter< + string, + global::Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.ExtensionStatusProperties.GoogleAutoTagging + >(), + new ApiEnumConverter< + string, + global::Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.ExtensionStatusProperties.RemoveBg + >(), + new ApiEnumConverter< + string, + global::Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.ExtensionProperties.AutoTaggingExtensionProperties.Name + >(), + new ApiEnumConverter< + string, + global::Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.ResponseField + >(), + new ApiEnumConverter(), + new ApiEnumConverter< + string, + global::Imagekit.Models.Webhooks.UploadPostTransformErrorEventProperties.RequestProperties.TransformationProperties.Type + >(), + new ApiEnumConverter< + string, + global::Imagekit.Models.Webhooks.UploadPostTransformErrorEventProperties.RequestProperties.TransformationProperties.Protocol + >(), + new ApiEnumConverter< + string, + global::Imagekit.Models.Webhooks.UploadPostTransformSuccessEventProperties.RequestProperties.TransformationProperties.Type + >(), + new ApiEnumConverter< + string, + global::Imagekit.Models.Webhooks.UploadPostTransformSuccessEventProperties.RequestProperties.TransformationProperties.Protocol + >(), + new ApiEnumConverter< + string, + global::Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.DataProperties.ExtensionStatusProperties.AIAutoDescription + >(), + new ApiEnumConverter< + string, + global::Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.DataProperties.ExtensionStatusProperties.AwsAutoTagging + >(), + new ApiEnumConverter< + string, + global::Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.DataProperties.ExtensionStatusProperties.GoogleAutoTagging + >(), + new ApiEnumConverter< + string, + global::Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.DataProperties.ExtensionStatusProperties.RemoveBg + >(), + new ApiEnumConverter< + string, + global::Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.DataProperties.TransformationProperties.Type + >(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter< + string, + global::Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.DataProperties.TransformationProperties.Type + >(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter< + string, + global::Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties.TransformationProperties.Type + >(), + new ApiEnumConverter< + string, + global::Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties.TransformationProperties.OptionsProperties.AudioCodec + >(), + new ApiEnumConverter< + string, + global::Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties.TransformationProperties.OptionsProperties.Format + >(), + new ApiEnumConverter< + string, + global::Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties.TransformationProperties.OptionsProperties.StreamProtocol + >(), + new ApiEnumConverter< + string, + global::Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties.TransformationProperties.OptionsProperties.VideoCodec + >(), + }, + }; + + static readonly JsonSerializerOptions _toStringSerializerOptions = new(SerializerOptions) + { + WriteIndented = true, + }; + + public sealed override string? ToString() + { + return JsonSerializer.Serialize(this.Properties, _toStringSerializerOptions); + } + + public abstract void Validate(); +} + +interface IFromRaw +{ + static abstract T FromRawUnchecked(Dictionary properties); +} diff --git a/src/Imagekit/ModelConverter.cs b/src/Imagekit/ModelConverter.cs new file mode 100644 index 00000000..0c40a8ef --- /dev/null +++ b/src/Imagekit/ModelConverter.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit; + +sealed class ModelConverter : JsonConverter + where TModel : ModelBase, IFromRaw +{ + public override TModel? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + Dictionary? properties = JsonSerializer.Deserialize< + Dictionary + >(ref reader, options); + if (properties == null) + return null; + + return TModel.FromRawUnchecked(properties); + } + + public override void Write(Utf8JsonWriter writer, TModel value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Properties, options); + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginCreateParams.cs b/src/Imagekit/Models/Accounts/Origins/OriginCreateParams.cs new file mode 100644 index 00000000..b485becb --- /dev/null +++ b/src/Imagekit/Models/Accounts/Origins/OriginCreateParams.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Text; +using System.Text.Json; + +namespace Imagekit.Models.Accounts.Origins; + +/// +/// **Note:** This API is currently in beta. Creates a new origin and returns the +/// origin object. +/// +public sealed record class OriginCreateParams : ParamsBase +{ + public Dictionary BodyProperties { get; set; } = []; + + /// + /// Schema for origin request resources. + /// + public required OriginRequest Origin + { + get + { + if (!this.BodyProperties.TryGetValue("origin", out JsonElement element)) + throw new ArgumentOutOfRangeException("origin", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("origin"); + } + set + { + this.BodyProperties["origin"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override Uri Url(IImageKitClient client) + { + return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/accounts/origins") + { + Query = this.QueryString(client), + }.Uri; + } + + public StringContent BodyContent() + { + return new( + JsonSerializer.Serialize(this.BodyProperties), + Encoding.UTF8, + "application/json" + ); + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginDeleteParams.cs b/src/Imagekit/Models/Accounts/Origins/OriginDeleteParams.cs new file mode 100644 index 00000000..826a127b --- /dev/null +++ b/src/Imagekit/Models/Accounts/Origins/OriginDeleteParams.cs @@ -0,0 +1,34 @@ +using System; +using System.Net.Http; + +namespace Imagekit.Models.Accounts.Origins; + +/// +/// **Note:** This API is currently in beta. Permanently removes the origin identified +/// by `id`. If the origin is in use by any URL‑endpoints, the API will return an +/// error. +/// +public sealed record class OriginDeleteParams : ParamsBase +{ + public required string ID; + + public override Uri Url(IImageKitClient client) + { + return new UriBuilder( + client.BaseUrl.ToString().TrimEnd('/') + + string.Format("/v1/accounts/origins/{0}", this.ID) + ) + { + Query = this.QueryString(client), + }.Uri; + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginGetParams.cs b/src/Imagekit/Models/Accounts/Origins/OriginGetParams.cs new file mode 100644 index 00000000..1387a2da --- /dev/null +++ b/src/Imagekit/Models/Accounts/Origins/OriginGetParams.cs @@ -0,0 +1,33 @@ +using System; +using System.Net.Http; + +namespace Imagekit.Models.Accounts.Origins; + +/// +/// **Note:** This API is currently in beta. Retrieves the origin identified by +/// `id`. +/// +public sealed record class OriginGetParams : ParamsBase +{ + public required string ID; + + public override Uri Url(IImageKitClient client) + { + return new UriBuilder( + client.BaseUrl.ToString().TrimEnd('/') + + string.Format("/v1/accounts/origins/{0}", this.ID) + ) + { + Query = this.QueryString(client), + }.Uri; + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginListParams.cs b/src/Imagekit/Models/Accounts/Origins/OriginListParams.cs new file mode 100644 index 00000000..29897449 --- /dev/null +++ b/src/Imagekit/Models/Accounts/Origins/OriginListParams.cs @@ -0,0 +1,28 @@ +using System; +using System.Net.Http; + +namespace Imagekit.Models.Accounts.Origins; + +/// +/// **Note:** This API is currently in beta. Returns an array of all configured +/// origins for the current account. +/// +public sealed record class OriginListParams : ParamsBase +{ + public override Uri Url(IImageKitClient client) + { + return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/accounts/origins") + { + Query = this.QueryString(client), + }.Uri; + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequest.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequest.cs new file mode 100644 index 00000000..be08db0e --- /dev/null +++ b/src/Imagekit/Models/Accounts/Origins/OriginRequest.cs @@ -0,0 +1,360 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Accounts.Origins.OriginRequestProperties; +using OriginRequestVariants = Imagekit.Models.Accounts.Origins.OriginRequestVariants; + +namespace Imagekit.Models.Accounts.Origins; + +/// +/// Schema for origin request resources. +/// +[JsonConverter(typeof(OriginRequestConverter))] +public abstract record class OriginRequest +{ + internal OriginRequest() { } + + public static implicit operator OriginRequest(S3 value) => new OriginRequestVariants::S3(value); + + public static implicit operator OriginRequest(S3Compatible value) => + new OriginRequestVariants::S3Compatible(value); + + public static implicit operator OriginRequest(CloudinaryBackup value) => + new OriginRequestVariants::CloudinaryBackup(value); + + public static implicit operator OriginRequest(WebFolder value) => + new OriginRequestVariants::WebFolder(value); + + public static implicit operator OriginRequest(WebProxy value) => + new OriginRequestVariants::WebProxy(value); + + public static implicit operator OriginRequest(Gcs value) => + new OriginRequestVariants::Gcs(value); + + public static implicit operator OriginRequest(AzureBlob value) => + new OriginRequestVariants::AzureBlob(value); + + public static implicit operator OriginRequest(AkeneoPim value) => + new OriginRequestVariants::AkeneoPim(value); + + public bool TryPickS3([NotNullWhen(true)] out S3? value) + { + value = (this as OriginRequestVariants::S3)?.Value; + return value != null; + } + + public bool TryPickS3Compatible([NotNullWhen(true)] out S3Compatible? value) + { + value = (this as OriginRequestVariants::S3Compatible)?.Value; + return value != null; + } + + public bool TryPickCloudinaryBackup([NotNullWhen(true)] out CloudinaryBackup? value) + { + value = (this as OriginRequestVariants::CloudinaryBackup)?.Value; + return value != null; + } + + public bool TryPickWebFolder([NotNullWhen(true)] out WebFolder? value) + { + value = (this as OriginRequestVariants::WebFolder)?.Value; + return value != null; + } + + public bool TryPickWebProxy([NotNullWhen(true)] out WebProxy? value) + { + value = (this as OriginRequestVariants::WebProxy)?.Value; + return value != null; + } + + public bool TryPickGcs([NotNullWhen(true)] out Gcs? value) + { + value = (this as OriginRequestVariants::Gcs)?.Value; + return value != null; + } + + public bool TryPickAzureBlob([NotNullWhen(true)] out AzureBlob? value) + { + value = (this as OriginRequestVariants::AzureBlob)?.Value; + return value != null; + } + + public bool TryPickAkeneoPim([NotNullWhen(true)] out AkeneoPim? value) + { + value = (this as OriginRequestVariants::AkeneoPim)?.Value; + return value != null; + } + + public void Switch( + Action s3, + Action s3Compatible, + Action cloudinaryBackup, + Action webFolder, + Action webProxy, + Action gcs, + Action azureBlob, + Action akeneoPim + ) + { + switch (this) + { + case OriginRequestVariants::S3 inner: + s3(inner); + break; + case OriginRequestVariants::S3Compatible inner: + s3Compatible(inner); + break; + case OriginRequestVariants::CloudinaryBackup inner: + cloudinaryBackup(inner); + break; + case OriginRequestVariants::WebFolder inner: + webFolder(inner); + break; + case OriginRequestVariants::WebProxy inner: + webProxy(inner); + break; + case OriginRequestVariants::Gcs inner: + gcs(inner); + break; + case OriginRequestVariants::AzureBlob inner: + azureBlob(inner); + break; + case OriginRequestVariants::AkeneoPim inner: + akeneoPim(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func s3, + Func s3Compatible, + Func cloudinaryBackup, + Func webFolder, + Func webProxy, + Func gcs, + Func azureBlob, + Func akeneoPim + ) + { + return this switch + { + OriginRequestVariants::S3 inner => s3(inner), + OriginRequestVariants::S3Compatible inner => s3Compatible(inner), + OriginRequestVariants::CloudinaryBackup inner => cloudinaryBackup(inner), + OriginRequestVariants::WebFolder inner => webFolder(inner), + OriginRequestVariants::WebProxy inner => webProxy(inner), + OriginRequestVariants::Gcs inner => gcs(inner), + OriginRequestVariants::AzureBlob inner => azureBlob(inner), + OriginRequestVariants::AkeneoPim inner => akeneoPim(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class OriginRequestConverter : JsonConverter +{ + public override OriginRequest? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var json = JsonSerializer.Deserialize(ref reader, options); + string? type; + try + { + type = json.GetProperty("type").GetString(); + } + catch + { + type = null; + } + + switch (type) + { + case "S3": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new OriginRequestVariants::S3(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "S3_COMPATIBLE": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new OriginRequestVariants::S3Compatible(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "CLOUDINARY_BACKUP": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new OriginRequestVariants::CloudinaryBackup(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "WEB_FOLDER": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new OriginRequestVariants::WebFolder(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "WEB_PROXY": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new OriginRequestVariants::WebProxy(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "GCS": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new OriginRequestVariants::Gcs(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "AZURE_BLOB": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new OriginRequestVariants::AzureBlob(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "AKENEO_PIM": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new OriginRequestVariants::AkeneoPim(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + default: + { + throw new Exception(); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + OriginRequest value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + OriginRequestVariants::S3(var s3) => s3, + OriginRequestVariants::S3Compatible(var s3Compatible) => s3Compatible, + OriginRequestVariants::CloudinaryBackup(var cloudinaryBackup) => cloudinaryBackup, + OriginRequestVariants::WebFolder(var webFolder) => webFolder, + OriginRequestVariants::WebProxy(var webProxy) => webProxy, + OriginRequestVariants::Gcs(var gcs) => gcs, + OriginRequestVariants::AzureBlob(var azureBlob) => azureBlob, + OriginRequestVariants::AkeneoPim(var akeneoPim) => akeneoPim, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AkeneoPim.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AkeneoPim.cs new file mode 100644 index 00000000..e3bb4329 --- /dev/null +++ b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AkeneoPim.cs @@ -0,0 +1,233 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Accounts.Origins.OriginRequestProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class AkeneoPim : ModelBase, IFromRaw +{ + /// + /// Akeneo instance base URL. + /// + public required string BaseURL + { + get + { + if (!this.Properties.TryGetValue("baseUrl", out JsonElement element)) + throw new ArgumentOutOfRangeException("baseUrl", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("baseUrl"); + } + set + { + this.Properties["baseUrl"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Akeneo API client ID. + /// + public required string ClientID + { + get + { + if (!this.Properties.TryGetValue("clientId", out JsonElement element)) + throw new ArgumentOutOfRangeException("clientId", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("clientId"); + } + set + { + this.Properties["clientId"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Akeneo API client secret. + /// + public required string ClientSecret + { + get + { + if (!this.Properties.TryGetValue("clientSecret", out JsonElement element)) + throw new ArgumentOutOfRangeException("clientSecret", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("clientSecret"); + } + set + { + this.Properties["clientSecret"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Display name of the origin. + /// + public required string Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + throw new ArgumentOutOfRangeException("name", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("name"); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Akeneo API password. + /// + public required string Password + { + get + { + if (!this.Properties.TryGetValue("password", out JsonElement element)) + throw new ArgumentOutOfRangeException("password", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("password"); + } + set + { + this.Properties["password"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Akeneo API username. + /// + public required string Username + { + get + { + if (!this.Properties.TryGetValue("username", out JsonElement element)) + throw new ArgumentOutOfRangeException("username", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("username"); + } + set + { + this.Properties["username"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// URL used in the Canonical header (if enabled). + /// + public string? BaseURLForCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to send a Canonical header. + /// + public bool? IncludeCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.BaseURL; + _ = this.ClientID; + _ = this.ClientSecret; + _ = this.Name; + _ = this.Password; + _ = this.Username; + _ = this.BaseURLForCanonicalHeader; + _ = this.IncludeCanonicalHeader; + } + + public AkeneoPim() + { + this.Type = JsonSerializer.Deserialize("\"AKENEO_PIM\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + AkeneoPim(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static AkeneoPim FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AzureBlob.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AzureBlob.cs new file mode 100644 index 00000000..130af741 --- /dev/null +++ b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AzureBlob.cs @@ -0,0 +1,197 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Accounts.Origins.OriginRequestProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class AzureBlob : ModelBase, IFromRaw +{ + public required string AccountName + { + get + { + if (!this.Properties.TryGetValue("accountName", out JsonElement element)) + throw new ArgumentOutOfRangeException("accountName", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("accountName"); + } + set + { + this.Properties["accountName"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required string Container + { + get + { + if (!this.Properties.TryGetValue("container", out JsonElement element)) + throw new ArgumentOutOfRangeException("container", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("container"); + } + set + { + this.Properties["container"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Display name of the origin. + /// + public required string Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + throw new ArgumentOutOfRangeException("name", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("name"); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required string SasToken + { + get + { + if (!this.Properties.TryGetValue("sasToken", out JsonElement element)) + throw new ArgumentOutOfRangeException("sasToken", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("sasToken"); + } + set + { + this.Properties["sasToken"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// URL used in the Canonical header (if enabled). + /// + public string? BaseURLForCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to send a Canonical header. + /// + public bool? IncludeCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public string? Prefix + { + get + { + if (!this.Properties.TryGetValue("prefix", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["prefix"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.AccountName; + _ = this.Container; + _ = this.Name; + _ = this.SasToken; + _ = this.BaseURLForCanonicalHeader; + _ = this.IncludeCanonicalHeader; + _ = this.Prefix; + } + + public AzureBlob() + { + this.Type = JsonSerializer.Deserialize("\"AZURE_BLOB\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + AzureBlob(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static AzureBlob FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/CloudinaryBackup.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/CloudinaryBackup.cs new file mode 100644 index 00000000..a4b9bb4f --- /dev/null +++ b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/CloudinaryBackup.cs @@ -0,0 +1,209 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Accounts.Origins.OriginRequestProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class CloudinaryBackup : ModelBase, IFromRaw +{ + /// + /// Access key for the bucket. + /// + public required string AccessKey + { + get + { + if (!this.Properties.TryGetValue("accessKey", out JsonElement element)) + throw new ArgumentOutOfRangeException("accessKey", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("accessKey"); + } + set + { + this.Properties["accessKey"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// S3 bucket name. + /// + public required string Bucket + { + get + { + if (!this.Properties.TryGetValue("bucket", out JsonElement element)) + throw new ArgumentOutOfRangeException("bucket", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("bucket"); + } + set + { + this.Properties["bucket"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Display name of the origin. + /// + public required string Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + throw new ArgumentOutOfRangeException("name", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("name"); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Secret key for the bucket. + /// + public required string SecretKey + { + get + { + if (!this.Properties.TryGetValue("secretKey", out JsonElement element)) + throw new ArgumentOutOfRangeException("secretKey", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("secretKey"); + } + set + { + this.Properties["secretKey"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// URL used in the Canonical header (if enabled). + /// + public string? BaseURLForCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to send a Canonical header. + /// + public bool? IncludeCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Path prefix inside the bucket. + /// + public string? Prefix + { + get + { + if (!this.Properties.TryGetValue("prefix", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["prefix"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.AccessKey; + _ = this.Bucket; + _ = this.Name; + _ = this.SecretKey; + _ = this.BaseURLForCanonicalHeader; + _ = this.IncludeCanonicalHeader; + _ = this.Prefix; + } + + public CloudinaryBackup() + { + this.Type = JsonSerializer.Deserialize("\"CLOUDINARY_BACKUP\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + CloudinaryBackup(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static CloudinaryBackup FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/Gcs.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/Gcs.cs new file mode 100644 index 00000000..ad22fac8 --- /dev/null +++ b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/Gcs.cs @@ -0,0 +1,197 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Accounts.Origins.OriginRequestProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Gcs : ModelBase, IFromRaw +{ + public required string Bucket + { + get + { + if (!this.Properties.TryGetValue("bucket", out JsonElement element)) + throw new ArgumentOutOfRangeException("bucket", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("bucket"); + } + set + { + this.Properties["bucket"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required string ClientEmail + { + get + { + if (!this.Properties.TryGetValue("clientEmail", out JsonElement element)) + throw new ArgumentOutOfRangeException("clientEmail", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("clientEmail"); + } + set + { + this.Properties["clientEmail"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Display name of the origin. + /// + public required string Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + throw new ArgumentOutOfRangeException("name", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("name"); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required string PrivateKey + { + get + { + if (!this.Properties.TryGetValue("privateKey", out JsonElement element)) + throw new ArgumentOutOfRangeException("privateKey", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("privateKey"); + } + set + { + this.Properties["privateKey"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// URL used in the Canonical header (if enabled). + /// + public string? BaseURLForCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to send a Canonical header. + /// + public bool? IncludeCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public string? Prefix + { + get + { + if (!this.Properties.TryGetValue("prefix", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["prefix"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.Bucket; + _ = this.ClientEmail; + _ = this.Name; + _ = this.PrivateKey; + _ = this.BaseURLForCanonicalHeader; + _ = this.IncludeCanonicalHeader; + _ = this.Prefix; + } + + public Gcs() + { + this.Type = JsonSerializer.Deserialize("\"GCS\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Gcs(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Gcs FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3.cs new file mode 100644 index 00000000..f9d0d5f1 --- /dev/null +++ b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3.cs @@ -0,0 +1,209 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Accounts.Origins.OriginRequestProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class S3 : ModelBase, IFromRaw +{ + /// + /// Access key for the bucket. + /// + public required string AccessKey + { + get + { + if (!this.Properties.TryGetValue("accessKey", out JsonElement element)) + throw new ArgumentOutOfRangeException("accessKey", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("accessKey"); + } + set + { + this.Properties["accessKey"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// S3 bucket name. + /// + public required string Bucket + { + get + { + if (!this.Properties.TryGetValue("bucket", out JsonElement element)) + throw new ArgumentOutOfRangeException("bucket", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("bucket"); + } + set + { + this.Properties["bucket"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Display name of the origin. + /// + public required string Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + throw new ArgumentOutOfRangeException("name", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("name"); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Secret key for the bucket. + /// + public required string SecretKey + { + get + { + if (!this.Properties.TryGetValue("secretKey", out JsonElement element)) + throw new ArgumentOutOfRangeException("secretKey", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("secretKey"); + } + set + { + this.Properties["secretKey"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// URL used in the Canonical header (if enabled). + /// + public string? BaseURLForCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to send a Canonical header. + /// + public bool? IncludeCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Path prefix inside the bucket. + /// + public string? Prefix + { + get + { + if (!this.Properties.TryGetValue("prefix", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["prefix"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.AccessKey; + _ = this.Bucket; + _ = this.Name; + _ = this.SecretKey; + _ = this.BaseURLForCanonicalHeader; + _ = this.IncludeCanonicalHeader; + _ = this.Prefix; + } + + public S3() + { + this.Type = JsonSerializer.Deserialize("\"S3\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + S3(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static S3 FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3Compatible.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3Compatible.cs new file mode 100644 index 00000000..500d31b5 --- /dev/null +++ b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3Compatible.cs @@ -0,0 +1,254 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Accounts.Origins.OriginRequestProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class S3Compatible : ModelBase, IFromRaw +{ + /// + /// Access key for the bucket. + /// + public required string AccessKey + { + get + { + if (!this.Properties.TryGetValue("accessKey", out JsonElement element)) + throw new ArgumentOutOfRangeException("accessKey", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("accessKey"); + } + set + { + this.Properties["accessKey"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// S3 bucket name. + /// + public required string Bucket + { + get + { + if (!this.Properties.TryGetValue("bucket", out JsonElement element)) + throw new ArgumentOutOfRangeException("bucket", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("bucket"); + } + set + { + this.Properties["bucket"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Custom S3-compatible endpoint. + /// + public required string Endpoint + { + get + { + if (!this.Properties.TryGetValue("endpoint", out JsonElement element)) + throw new ArgumentOutOfRangeException("endpoint", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("endpoint"); + } + set + { + this.Properties["endpoint"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Display name of the origin. + /// + public required string Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + throw new ArgumentOutOfRangeException("name", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("name"); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Secret key for the bucket. + /// + public required string SecretKey + { + get + { + if (!this.Properties.TryGetValue("secretKey", out JsonElement element)) + throw new ArgumentOutOfRangeException("secretKey", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("secretKey"); + } + set + { + this.Properties["secretKey"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// URL used in the Canonical header (if enabled). + /// + public string? BaseURLForCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to send a Canonical header. + /// + public bool? IncludeCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Path prefix inside the bucket. + /// + public string? Prefix + { + get + { + if (!this.Properties.TryGetValue("prefix", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["prefix"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Use path-style S3 URLs? + /// + public bool? S3ForcePathStyle + { + get + { + if (!this.Properties.TryGetValue("s3ForcePathStyle", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["s3ForcePathStyle"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.AccessKey; + _ = this.Bucket; + _ = this.Endpoint; + _ = this.Name; + _ = this.SecretKey; + _ = this.BaseURLForCanonicalHeader; + _ = this.IncludeCanonicalHeader; + _ = this.Prefix; + _ = this.S3ForcePathStyle; + } + + public S3Compatible() + { + this.Type = JsonSerializer.Deserialize("\"S3_COMPATIBLE\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + S3Compatible(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static S3Compatible FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebFolder.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebFolder.cs new file mode 100644 index 00000000..09bf8765 --- /dev/null +++ b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebFolder.cs @@ -0,0 +1,163 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Accounts.Origins.OriginRequestProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class WebFolder : ModelBase, IFromRaw +{ + /// + /// Root URL for the web folder origin. + /// + public required string BaseURL + { + get + { + if (!this.Properties.TryGetValue("baseUrl", out JsonElement element)) + throw new ArgumentOutOfRangeException("baseUrl", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("baseUrl"); + } + set + { + this.Properties["baseUrl"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Display name of the origin. + /// + public required string Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + throw new ArgumentOutOfRangeException("name", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("name"); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// URL used in the Canonical header (if enabled). + /// + public string? BaseURLForCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Forward the Host header to origin? + /// + public bool? ForwardHostHeaderToOrigin + { + get + { + if (!this.Properties.TryGetValue("forwardHostHeaderToOrigin", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["forwardHostHeaderToOrigin"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to send a Canonical header. + /// + public bool? IncludeCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.BaseURL; + _ = this.Name; + _ = this.BaseURLForCanonicalHeader; + _ = this.ForwardHostHeaderToOrigin; + _ = this.IncludeCanonicalHeader; + } + + public WebFolder() + { + this.Type = JsonSerializer.Deserialize("\"WEB_FOLDER\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + WebFolder(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static WebFolder FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebProxy.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebProxy.cs new file mode 100644 index 00000000..bf88baa9 --- /dev/null +++ b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebProxy.cs @@ -0,0 +1,125 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Accounts.Origins.OriginRequestProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class WebProxy : ModelBase, IFromRaw +{ + /// + /// Display name of the origin. + /// + public required string Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + throw new ArgumentOutOfRangeException("name", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("name"); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// URL used in the Canonical header (if enabled). + /// + public string? BaseURLForCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to send a Canonical header. + /// + public bool? IncludeCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.Name; + _ = this.BaseURLForCanonicalHeader; + _ = this.IncludeCanonicalHeader; + } + + public WebProxy() + { + this.Type = JsonSerializer.Deserialize("\"WEB_PROXY\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + WebProxy(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static WebProxy FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public WebProxy(string name) + : this() + { + this.Name = name; + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestVariants/All.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestVariants/All.cs new file mode 100644 index 00000000..bfaed1ab --- /dev/null +++ b/src/Imagekit/Models/Accounts/Origins/OriginRequestVariants/All.cs @@ -0,0 +1,123 @@ +using OriginRequestProperties = Imagekit.Models.Accounts.Origins.OriginRequestProperties; + +namespace Imagekit.Models.Accounts.Origins.OriginRequestVariants; + +public sealed record class S3(OriginRequestProperties::S3 Value) + : OriginRequest, + IVariant +{ + public static S3 From(OriginRequestProperties::S3 value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class S3Compatible(OriginRequestProperties::S3Compatible Value) + : OriginRequest, + IVariant +{ + public static S3Compatible From(OriginRequestProperties::S3Compatible value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class CloudinaryBackup(OriginRequestProperties::CloudinaryBackup Value) + : OriginRequest, + IVariant +{ + public static CloudinaryBackup From(OriginRequestProperties::CloudinaryBackup value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class WebFolder(OriginRequestProperties::WebFolder Value) + : OriginRequest, + IVariant +{ + public static WebFolder From(OriginRequestProperties::WebFolder value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class WebProxy(OriginRequestProperties::WebProxy Value) + : OriginRequest, + IVariant +{ + public static WebProxy From(OriginRequestProperties::WebProxy value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class Gcs(OriginRequestProperties::Gcs Value) + : OriginRequest, + IVariant +{ + public static Gcs From(OriginRequestProperties::Gcs value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class AzureBlob(OriginRequestProperties::AzureBlob Value) + : OriginRequest, + IVariant +{ + public static AzureBlob From(OriginRequestProperties::AzureBlob value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class AkeneoPim(OriginRequestProperties::AkeneoPim Value) + : OriginRequest, + IVariant +{ + public static AkeneoPim From(OriginRequestProperties::AkeneoPim value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponse.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponse.cs new file mode 100644 index 00000000..9fd7dadf --- /dev/null +++ b/src/Imagekit/Models/Accounts/Origins/OriginResponse.cs @@ -0,0 +1,361 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Accounts.Origins.OriginResponseProperties; +using OriginResponseVariants = Imagekit.Models.Accounts.Origins.OriginResponseVariants; + +namespace Imagekit.Models.Accounts.Origins; + +/// +/// Origin object as returned by the API (sensitive fields removed). +/// +[JsonConverter(typeof(OriginResponseConverter))] +public abstract record class OriginResponse +{ + internal OriginResponse() { } + + public static implicit operator OriginResponse(S3 value) => + new OriginResponseVariants::S3(value); + + public static implicit operator OriginResponse(S3Compatible value) => + new OriginResponseVariants::S3Compatible(value); + + public static implicit operator OriginResponse(CloudinaryBackup value) => + new OriginResponseVariants::CloudinaryBackup(value); + + public static implicit operator OriginResponse(WebFolder value) => + new OriginResponseVariants::WebFolder(value); + + public static implicit operator OriginResponse(WebProxy value) => + new OriginResponseVariants::WebProxy(value); + + public static implicit operator OriginResponse(Gcs value) => + new OriginResponseVariants::Gcs(value); + + public static implicit operator OriginResponse(AzureBlob value) => + new OriginResponseVariants::AzureBlob(value); + + public static implicit operator OriginResponse(AkeneoPim value) => + new OriginResponseVariants::AkeneoPim(value); + + public bool TryPickS3([NotNullWhen(true)] out S3? value) + { + value = (this as OriginResponseVariants::S3)?.Value; + return value != null; + } + + public bool TryPickS3Compatible([NotNullWhen(true)] out S3Compatible? value) + { + value = (this as OriginResponseVariants::S3Compatible)?.Value; + return value != null; + } + + public bool TryPickCloudinaryBackup([NotNullWhen(true)] out CloudinaryBackup? value) + { + value = (this as OriginResponseVariants::CloudinaryBackup)?.Value; + return value != null; + } + + public bool TryPickWebFolder([NotNullWhen(true)] out WebFolder? value) + { + value = (this as OriginResponseVariants::WebFolder)?.Value; + return value != null; + } + + public bool TryPickWebProxy([NotNullWhen(true)] out WebProxy? value) + { + value = (this as OriginResponseVariants::WebProxy)?.Value; + return value != null; + } + + public bool TryPickGcs([NotNullWhen(true)] out Gcs? value) + { + value = (this as OriginResponseVariants::Gcs)?.Value; + return value != null; + } + + public bool TryPickAzureBlob([NotNullWhen(true)] out AzureBlob? value) + { + value = (this as OriginResponseVariants::AzureBlob)?.Value; + return value != null; + } + + public bool TryPickAkeneoPim([NotNullWhen(true)] out AkeneoPim? value) + { + value = (this as OriginResponseVariants::AkeneoPim)?.Value; + return value != null; + } + + public void Switch( + Action s3, + Action s3Compatible, + Action cloudinaryBackup, + Action webFolder, + Action webProxy, + Action gcs, + Action azureBlob, + Action akeneoPim + ) + { + switch (this) + { + case OriginResponseVariants::S3 inner: + s3(inner); + break; + case OriginResponseVariants::S3Compatible inner: + s3Compatible(inner); + break; + case OriginResponseVariants::CloudinaryBackup inner: + cloudinaryBackup(inner); + break; + case OriginResponseVariants::WebFolder inner: + webFolder(inner); + break; + case OriginResponseVariants::WebProxy inner: + webProxy(inner); + break; + case OriginResponseVariants::Gcs inner: + gcs(inner); + break; + case OriginResponseVariants::AzureBlob inner: + azureBlob(inner); + break; + case OriginResponseVariants::AkeneoPim inner: + akeneoPim(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func s3, + Func s3Compatible, + Func cloudinaryBackup, + Func webFolder, + Func webProxy, + Func gcs, + Func azureBlob, + Func akeneoPim + ) + { + return this switch + { + OriginResponseVariants::S3 inner => s3(inner), + OriginResponseVariants::S3Compatible inner => s3Compatible(inner), + OriginResponseVariants::CloudinaryBackup inner => cloudinaryBackup(inner), + OriginResponseVariants::WebFolder inner => webFolder(inner), + OriginResponseVariants::WebProxy inner => webProxy(inner), + OriginResponseVariants::Gcs inner => gcs(inner), + OriginResponseVariants::AzureBlob inner => azureBlob(inner), + OriginResponseVariants::AkeneoPim inner => akeneoPim(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class OriginResponseConverter : JsonConverter +{ + public override OriginResponse? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var json = JsonSerializer.Deserialize(ref reader, options); + string? type; + try + { + type = json.GetProperty("type").GetString(); + } + catch + { + type = null; + } + + switch (type) + { + case "S3": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new OriginResponseVariants::S3(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "S3_COMPATIBLE": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new OriginResponseVariants::S3Compatible(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "CLOUDINARY_BACKUP": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new OriginResponseVariants::CloudinaryBackup(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "WEB_FOLDER": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new OriginResponseVariants::WebFolder(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "WEB_PROXY": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new OriginResponseVariants::WebProxy(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "GCS": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new OriginResponseVariants::Gcs(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "AZURE_BLOB": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new OriginResponseVariants::AzureBlob(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "AKENEO_PIM": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new OriginResponseVariants::AkeneoPim(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + default: + { + throw new Exception(); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + OriginResponse value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + OriginResponseVariants::S3(var s3) => s3, + OriginResponseVariants::S3Compatible(var s3Compatible) => s3Compatible, + OriginResponseVariants::CloudinaryBackup(var cloudinaryBackup) => cloudinaryBackup, + OriginResponseVariants::WebFolder(var webFolder) => webFolder, + OriginResponseVariants::WebProxy(var webProxy) => webProxy, + OriginResponseVariants::Gcs(var gcs) => gcs, + OriginResponseVariants::AzureBlob(var azureBlob) => azureBlob, + OriginResponseVariants::AkeneoPim(var akeneoPim) => akeneoPim, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AkeneoPim.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AkeneoPim.cs new file mode 100644 index 00000000..9860c44c --- /dev/null +++ b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AkeneoPim.cs @@ -0,0 +1,168 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Accounts.Origins.OriginResponseProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class AkeneoPim : ModelBase, IFromRaw +{ + /// + /// Unique identifier for the origin. This is generated by ImageKit when you create + /// a new origin. + /// + public required string ID + { + get + { + if (!this.Properties.TryGetValue("id", out JsonElement element)) + throw new ArgumentOutOfRangeException("id", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("id"); + } + set + { + this.Properties["id"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Akeneo instance base URL. + /// + public required string BaseURL + { + get + { + if (!this.Properties.TryGetValue("baseUrl", out JsonElement element)) + throw new ArgumentOutOfRangeException("baseUrl", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("baseUrl"); + } + set + { + this.Properties["baseUrl"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to send a Canonical header. + /// + public required bool IncludeCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) + throw new ArgumentOutOfRangeException( + "includeCanonicalHeader", + "Missing required argument" + ); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Display name of the origin. + /// + public required string Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + throw new ArgumentOutOfRangeException("name", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("name"); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// URL used in the Canonical header (if enabled). + /// + public string? BaseURLForCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.ID; + _ = this.BaseURL; + _ = this.IncludeCanonicalHeader; + _ = this.Name; + _ = this.BaseURLForCanonicalHeader; + } + + public AkeneoPim() + { + this.Type = JsonSerializer.Deserialize("\"AKENEO_PIM\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + AkeneoPim(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static AkeneoPim FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AzureBlob.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AzureBlob.cs new file mode 100644 index 00000000..afd047bd --- /dev/null +++ b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AzureBlob.cs @@ -0,0 +1,205 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Accounts.Origins.OriginResponseProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class AzureBlob : ModelBase, IFromRaw +{ + /// + /// Unique identifier for the origin. This is generated by ImageKit when you create + /// a new origin. + /// + public required string ID + { + get + { + if (!this.Properties.TryGetValue("id", out JsonElement element)) + throw new ArgumentOutOfRangeException("id", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("id"); + } + set + { + this.Properties["id"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required string AccountName + { + get + { + if (!this.Properties.TryGetValue("accountName", out JsonElement element)) + throw new ArgumentOutOfRangeException("accountName", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("accountName"); + } + set + { + this.Properties["accountName"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required string Container + { + get + { + if (!this.Properties.TryGetValue("container", out JsonElement element)) + throw new ArgumentOutOfRangeException("container", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("container"); + } + set + { + this.Properties["container"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to send a Canonical header. + /// + public required bool IncludeCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) + throw new ArgumentOutOfRangeException( + "includeCanonicalHeader", + "Missing required argument" + ); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Display name of the origin. + /// + public required string Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + throw new ArgumentOutOfRangeException("name", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("name"); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required string Prefix + { + get + { + if (!this.Properties.TryGetValue("prefix", out JsonElement element)) + throw new ArgumentOutOfRangeException("prefix", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("prefix"); + } + set + { + this.Properties["prefix"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// URL used in the Canonical header (if enabled). + /// + public string? BaseURLForCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.ID; + _ = this.AccountName; + _ = this.Container; + _ = this.IncludeCanonicalHeader; + _ = this.Name; + _ = this.Prefix; + _ = this.BaseURLForCanonicalHeader; + } + + public AzureBlob() + { + this.Type = JsonSerializer.Deserialize("\"AZURE_BLOB\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + AzureBlob(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static AzureBlob FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/CloudinaryBackup.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/CloudinaryBackup.cs new file mode 100644 index 00000000..288553c5 --- /dev/null +++ b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/CloudinaryBackup.cs @@ -0,0 +1,191 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Accounts.Origins.OriginResponseProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class CloudinaryBackup : ModelBase, IFromRaw +{ + /// + /// Unique identifier for the origin. This is generated by ImageKit when you create + /// a new origin. + /// + public required string ID + { + get + { + if (!this.Properties.TryGetValue("id", out JsonElement element)) + throw new ArgumentOutOfRangeException("id", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("id"); + } + set + { + this.Properties["id"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// S3 bucket name. + /// + public required string Bucket + { + get + { + if (!this.Properties.TryGetValue("bucket", out JsonElement element)) + throw new ArgumentOutOfRangeException("bucket", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("bucket"); + } + set + { + this.Properties["bucket"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to send a Canonical header. + /// + public required bool IncludeCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) + throw new ArgumentOutOfRangeException( + "includeCanonicalHeader", + "Missing required argument" + ); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Display name of the origin. + /// + public required string Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + throw new ArgumentOutOfRangeException("name", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("name"); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Path prefix inside the bucket. + /// + public required string Prefix + { + get + { + if (!this.Properties.TryGetValue("prefix", out JsonElement element)) + throw new ArgumentOutOfRangeException("prefix", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("prefix"); + } + set + { + this.Properties["prefix"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// URL used in the Canonical header (if enabled). + /// + public string? BaseURLForCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.ID; + _ = this.Bucket; + _ = this.IncludeCanonicalHeader; + _ = this.Name; + _ = this.Prefix; + _ = this.BaseURLForCanonicalHeader; + } + + public CloudinaryBackup() + { + this.Type = JsonSerializer.Deserialize("\"CLOUDINARY_BACKUP\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + CloudinaryBackup(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static CloudinaryBackup FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/Gcs.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/Gcs.cs new file mode 100644 index 00000000..17a6daac --- /dev/null +++ b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/Gcs.cs @@ -0,0 +1,205 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Accounts.Origins.OriginResponseProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Gcs : ModelBase, IFromRaw +{ + /// + /// Unique identifier for the origin. This is generated by ImageKit when you create + /// a new origin. + /// + public required string ID + { + get + { + if (!this.Properties.TryGetValue("id", out JsonElement element)) + throw new ArgumentOutOfRangeException("id", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("id"); + } + set + { + this.Properties["id"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required string Bucket + { + get + { + if (!this.Properties.TryGetValue("bucket", out JsonElement element)) + throw new ArgumentOutOfRangeException("bucket", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("bucket"); + } + set + { + this.Properties["bucket"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required string ClientEmail + { + get + { + if (!this.Properties.TryGetValue("clientEmail", out JsonElement element)) + throw new ArgumentOutOfRangeException("clientEmail", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("clientEmail"); + } + set + { + this.Properties["clientEmail"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to send a Canonical header. + /// + public required bool IncludeCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) + throw new ArgumentOutOfRangeException( + "includeCanonicalHeader", + "Missing required argument" + ); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Display name of the origin. + /// + public required string Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + throw new ArgumentOutOfRangeException("name", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("name"); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required string Prefix + { + get + { + if (!this.Properties.TryGetValue("prefix", out JsonElement element)) + throw new ArgumentOutOfRangeException("prefix", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("prefix"); + } + set + { + this.Properties["prefix"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// URL used in the Canonical header (if enabled). + /// + public string? BaseURLForCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.ID; + _ = this.Bucket; + _ = this.ClientEmail; + _ = this.IncludeCanonicalHeader; + _ = this.Name; + _ = this.Prefix; + _ = this.BaseURLForCanonicalHeader; + } + + public Gcs() + { + this.Type = JsonSerializer.Deserialize("\"GCS\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Gcs(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Gcs FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3.cs new file mode 100644 index 00000000..b2046890 --- /dev/null +++ b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3.cs @@ -0,0 +1,191 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Accounts.Origins.OriginResponseProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class S3 : ModelBase, IFromRaw +{ + /// + /// Unique identifier for the origin. This is generated by ImageKit when you create + /// a new origin. + /// + public required string ID + { + get + { + if (!this.Properties.TryGetValue("id", out JsonElement element)) + throw new ArgumentOutOfRangeException("id", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("id"); + } + set + { + this.Properties["id"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// S3 bucket name. + /// + public required string Bucket + { + get + { + if (!this.Properties.TryGetValue("bucket", out JsonElement element)) + throw new ArgumentOutOfRangeException("bucket", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("bucket"); + } + set + { + this.Properties["bucket"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to send a Canonical header. + /// + public required bool IncludeCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) + throw new ArgumentOutOfRangeException( + "includeCanonicalHeader", + "Missing required argument" + ); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Display name of the origin. + /// + public required string Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + throw new ArgumentOutOfRangeException("name", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("name"); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Path prefix inside the bucket. + /// + public required string Prefix + { + get + { + if (!this.Properties.TryGetValue("prefix", out JsonElement element)) + throw new ArgumentOutOfRangeException("prefix", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("prefix"); + } + set + { + this.Properties["prefix"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// URL used in the Canonical header (if enabled). + /// + public string? BaseURLForCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.ID; + _ = this.Bucket; + _ = this.IncludeCanonicalHeader; + _ = this.Name; + _ = this.Prefix; + _ = this.BaseURLForCanonicalHeader; + } + + public S3() + { + this.Type = JsonSerializer.Deserialize("\"S3\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + S3(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static S3 FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3Compatible.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3Compatible.cs new file mode 100644 index 00000000..8d36f4a9 --- /dev/null +++ b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3Compatible.cs @@ -0,0 +1,239 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Accounts.Origins.OriginResponseProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class S3Compatible : ModelBase, IFromRaw +{ + /// + /// Unique identifier for the origin. This is generated by ImageKit when you create + /// a new origin. + /// + public required string ID + { + get + { + if (!this.Properties.TryGetValue("id", out JsonElement element)) + throw new ArgumentOutOfRangeException("id", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("id"); + } + set + { + this.Properties["id"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// S3 bucket name. + /// + public required string Bucket + { + get + { + if (!this.Properties.TryGetValue("bucket", out JsonElement element)) + throw new ArgumentOutOfRangeException("bucket", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("bucket"); + } + set + { + this.Properties["bucket"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Custom S3-compatible endpoint. + /// + public required string Endpoint + { + get + { + if (!this.Properties.TryGetValue("endpoint", out JsonElement element)) + throw new ArgumentOutOfRangeException("endpoint", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("endpoint"); + } + set + { + this.Properties["endpoint"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to send a Canonical header. + /// + public required bool IncludeCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) + throw new ArgumentOutOfRangeException( + "includeCanonicalHeader", + "Missing required argument" + ); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Display name of the origin. + /// + public required string Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + throw new ArgumentOutOfRangeException("name", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("name"); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Path prefix inside the bucket. + /// + public required string Prefix + { + get + { + if (!this.Properties.TryGetValue("prefix", out JsonElement element)) + throw new ArgumentOutOfRangeException("prefix", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("prefix"); + } + set + { + this.Properties["prefix"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Use path-style S3 URLs? + /// + public required bool S3ForcePathStyle + { + get + { + if (!this.Properties.TryGetValue("s3ForcePathStyle", out JsonElement element)) + throw new ArgumentOutOfRangeException( + "s3ForcePathStyle", + "Missing required argument" + ); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["s3ForcePathStyle"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// URL used in the Canonical header (if enabled). + /// + public string? BaseURLForCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.ID; + _ = this.Bucket; + _ = this.Endpoint; + _ = this.IncludeCanonicalHeader; + _ = this.Name; + _ = this.Prefix; + _ = this.S3ForcePathStyle; + _ = this.BaseURLForCanonicalHeader; + } + + public S3Compatible() + { + this.Type = JsonSerializer.Deserialize("\"S3_COMPATIBLE\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + S3Compatible(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static S3Compatible FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebFolder.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebFolder.cs new file mode 100644 index 00000000..8313749f --- /dev/null +++ b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebFolder.cs @@ -0,0 +1,193 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Accounts.Origins.OriginResponseProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class WebFolder : ModelBase, IFromRaw +{ + /// + /// Unique identifier for the origin. This is generated by ImageKit when you create + /// a new origin. + /// + public required string ID + { + get + { + if (!this.Properties.TryGetValue("id", out JsonElement element)) + throw new ArgumentOutOfRangeException("id", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("id"); + } + set + { + this.Properties["id"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Root URL for the web folder origin. + /// + public required string BaseURL + { + get + { + if (!this.Properties.TryGetValue("baseUrl", out JsonElement element)) + throw new ArgumentOutOfRangeException("baseUrl", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("baseUrl"); + } + set + { + this.Properties["baseUrl"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Forward the Host header to origin? + /// + public required bool ForwardHostHeaderToOrigin + { + get + { + if (!this.Properties.TryGetValue("forwardHostHeaderToOrigin", out JsonElement element)) + throw new ArgumentOutOfRangeException( + "forwardHostHeaderToOrigin", + "Missing required argument" + ); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["forwardHostHeaderToOrigin"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to send a Canonical header. + /// + public required bool IncludeCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) + throw new ArgumentOutOfRangeException( + "includeCanonicalHeader", + "Missing required argument" + ); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Display name of the origin. + /// + public required string Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + throw new ArgumentOutOfRangeException("name", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("name"); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// URL used in the Canonical header (if enabled). + /// + public string? BaseURLForCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.ID; + _ = this.BaseURL; + _ = this.ForwardHostHeaderToOrigin; + _ = this.IncludeCanonicalHeader; + _ = this.Name; + _ = this.BaseURLForCanonicalHeader; + } + + public WebFolder() + { + this.Type = JsonSerializer.Deserialize("\"WEB_FOLDER\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + WebFolder(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static WebFolder FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebProxy.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebProxy.cs new file mode 100644 index 00000000..150c5901 --- /dev/null +++ b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebProxy.cs @@ -0,0 +1,145 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Accounts.Origins.OriginResponseProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class WebProxy : ModelBase, IFromRaw +{ + /// + /// Unique identifier for the origin. This is generated by ImageKit when you create + /// a new origin. + /// + public required string ID + { + get + { + if (!this.Properties.TryGetValue("id", out JsonElement element)) + throw new ArgumentOutOfRangeException("id", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("id"); + } + set + { + this.Properties["id"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to send a Canonical header. + /// + public required bool IncludeCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) + throw new ArgumentOutOfRangeException( + "includeCanonicalHeader", + "Missing required argument" + ); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Display name of the origin. + /// + public required string Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + throw new ArgumentOutOfRangeException("name", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("name"); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// URL used in the Canonical header (if enabled). + /// + public string? BaseURLForCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.ID; + _ = this.IncludeCanonicalHeader; + _ = this.Name; + _ = this.BaseURLForCanonicalHeader; + } + + public WebProxy() + { + this.Type = JsonSerializer.Deserialize("\"WEB_PROXY\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + WebProxy(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static WebProxy FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseVariants/All.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseVariants/All.cs new file mode 100644 index 00000000..cb69f75d --- /dev/null +++ b/src/Imagekit/Models/Accounts/Origins/OriginResponseVariants/All.cs @@ -0,0 +1,123 @@ +using OriginResponseProperties = Imagekit.Models.Accounts.Origins.OriginResponseProperties; + +namespace Imagekit.Models.Accounts.Origins.OriginResponseVariants; + +public sealed record class S3(OriginResponseProperties::S3 Value) + : OriginResponse, + IVariant +{ + public static S3 From(OriginResponseProperties::S3 value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class S3Compatible(OriginResponseProperties::S3Compatible Value) + : OriginResponse, + IVariant +{ + public static S3Compatible From(OriginResponseProperties::S3Compatible value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class CloudinaryBackup(OriginResponseProperties::CloudinaryBackup Value) + : OriginResponse, + IVariant +{ + public static CloudinaryBackup From(OriginResponseProperties::CloudinaryBackup value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class WebFolder(OriginResponseProperties::WebFolder Value) + : OriginResponse, + IVariant +{ + public static WebFolder From(OriginResponseProperties::WebFolder value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class WebProxy(OriginResponseProperties::WebProxy Value) + : OriginResponse, + IVariant +{ + public static WebProxy From(OriginResponseProperties::WebProxy value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class Gcs(OriginResponseProperties::Gcs Value) + : OriginResponse, + IVariant +{ + public static Gcs From(OriginResponseProperties::Gcs value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class AzureBlob(OriginResponseProperties::AzureBlob Value) + : OriginResponse, + IVariant +{ + public static AzureBlob From(OriginResponseProperties::AzureBlob value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class AkeneoPim(OriginResponseProperties::AkeneoPim Value) + : OriginResponse, + IVariant +{ + public static AkeneoPim From(OriginResponseProperties::AkeneoPim value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginUpdateParams.cs b/src/Imagekit/Models/Accounts/Origins/OriginUpdateParams.cs new file mode 100644 index 00000000..e2b40c56 --- /dev/null +++ b/src/Imagekit/Models/Accounts/Origins/OriginUpdateParams.cs @@ -0,0 +1,69 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Text; +using System.Text.Json; + +namespace Imagekit.Models.Accounts.Origins; + +/// +/// **Note:** This API is currently in beta. Updates the origin identified by `id` +/// and returns the updated origin object. +/// +public sealed record class OriginUpdateParams : ParamsBase +{ + public Dictionary BodyProperties { get; set; } = []; + + public required string ID; + + /// + /// Schema for origin request resources. + /// + public required OriginRequest Origin + { + get + { + if (!this.BodyProperties.TryGetValue("origin", out JsonElement element)) + throw new ArgumentOutOfRangeException("origin", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("origin"); + } + set + { + this.BodyProperties["origin"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override Uri Url(IImageKitClient client) + { + return new UriBuilder( + client.BaseUrl.ToString().TrimEnd('/') + + string.Format("/v1/accounts/origins/{0}", this.ID) + ) + { + Query = this.QueryString(client), + }.Uri; + } + + public StringContent BodyContent() + { + return new( + JsonSerializer.Serialize(this.BodyProperties), + Encoding.UTF8, + "application/json" + ); + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParams.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParams.cs new file mode 100644 index 00000000..246f09e9 --- /dev/null +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParams.cs @@ -0,0 +1,131 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Text; +using System.Text.Json; +using Imagekit.Models.Accounts.URLEndpoints.URLEndpointCreateParamsProperties; + +namespace Imagekit.Models.Accounts.URLEndpoints; + +/// +/// **Note:** This API is currently in beta. Creates a new URL‑endpoint and returns +/// the resulting object. +/// +public sealed record class URLEndpointCreateParams : ParamsBase +{ + public Dictionary BodyProperties { get; set; } = []; + + /// + /// Description of the URL endpoint. + /// + public required string Description + { + get + { + if (!this.BodyProperties.TryGetValue("description", out JsonElement element)) + throw new ArgumentOutOfRangeException("description", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("description"); + } + set + { + this.BodyProperties["description"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Ordered list of origin IDs to try when the file isn’t in the Media Library; + /// ImageKit checks them in the sequence provided. Origin must be created before + /// it can be used in a URL endpoint. + /// + public List? Origins + { + get + { + if (!this.BodyProperties.TryGetValue("origins", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["origins"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Path segment appended to your base URL to form the endpoint (letters, digits, + /// and hyphens only — or empty for the default endpoint). + /// + public string? URLPrefix + { + get + { + if (!this.BodyProperties.TryGetValue("urlPrefix", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["urlPrefix"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Configuration for third-party URL rewriting. + /// + public URLRewriter? URLRewriter + { + get + { + if (!this.BodyProperties.TryGetValue("urlRewriter", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["urlRewriter"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override Uri Url(IImageKitClient client) + { + return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/accounts/url-endpoints") + { + Query = this.QueryString(client), + }.Uri; + } + + public StringContent BodyContent() + { + return new( + JsonSerializer.Serialize(this.BodyProperties), + Encoding.UTF8, + "application/json" + ); + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriter.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriter.cs new file mode 100644 index 00000000..5d26268a --- /dev/null +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriter.cs @@ -0,0 +1,176 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Accounts.URLEndpoints.URLEndpointCreateParamsProperties.URLRewriterProperties; +using URLRewriterVariants = Imagekit.Models.Accounts.URLEndpoints.URLEndpointCreateParamsProperties.URLRewriterVariants; + +namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointCreateParamsProperties; + +/// +/// Configuration for third-party URL rewriting. +/// +[JsonConverter(typeof(URLRewriterConverter))] +public abstract record class URLRewriter +{ + internal URLRewriter() { } + + public static implicit operator URLRewriter(Cloudinary value) => + new URLRewriterVariants::Cloudinary(value); + + public bool TryPickCloudinary([NotNullWhen(true)] out Cloudinary? value) + { + value = (this as URLRewriterVariants::Cloudinary)?.Value; + return value != null; + } + + public bool TryPickImgix([NotNullWhen(true)] out JsonElement? value) + { + value = (this as URLRewriterVariants::Imgix)?.Value; + return value != null; + } + + public bool TryPickAkamai([NotNullWhen(true)] out JsonElement? value) + { + value = (this as URLRewriterVariants::Akamai)?.Value; + return value != null; + } + + public void Switch( + Action cloudinary, + Action imgix, + Action akamai + ) + { + switch (this) + { + case URLRewriterVariants::Cloudinary inner: + cloudinary(inner); + break; + case URLRewriterVariants::Imgix inner: + imgix(inner); + break; + case URLRewriterVariants::Akamai inner: + akamai(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func cloudinary, + Func imgix, + Func akamai + ) + { + return this switch + { + URLRewriterVariants::Cloudinary inner => cloudinary(inner), + URLRewriterVariants::Imgix inner => imgix(inner), + URLRewriterVariants::Akamai inner => akamai(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class URLRewriterConverter : JsonConverter +{ + public override URLRewriter? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var json = JsonSerializer.Deserialize(ref reader, options); + string? type; + try + { + type = json.GetProperty("type").GetString(); + } + catch + { + type = null; + } + + switch (type) + { + case "CLOUDINARY": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new URLRewriterVariants::Cloudinary(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "IMGIX": + { + List exceptions = []; + + try + { + return new URLRewriterVariants::Imgix( + JsonSerializer.Deserialize(json, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "AKAMAI": + { + List exceptions = []; + + try + { + return new URLRewriterVariants::Akamai( + JsonSerializer.Deserialize(json, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + default: + { + throw new Exception(); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + URLRewriter value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + URLRewriterVariants::Cloudinary(var cloudinary) => cloudinary, + URLRewriterVariants::Imgix(var imgix) => imgix, + URLRewriterVariants::Akamai(var akamai) => akamai, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/Cloudinary.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/Cloudinary.cs new file mode 100644 index 00000000..e1342282 --- /dev/null +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/Cloudinary.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointCreateParamsProperties.URLRewriterProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Cloudinary : ModelBase, IFromRaw +{ + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to preserve `/` in the rewritten URL. + /// + public bool? PreserveAssetDeliveryTypes + { + get + { + if (!this.Properties.TryGetValue("preserveAssetDeliveryTypes", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["preserveAssetDeliveryTypes"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.PreserveAssetDeliveryTypes; + } + + public Cloudinary() + { + this.Type = JsonSerializer.Deserialize("\"CLOUDINARY\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Cloudinary(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Cloudinary FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterVariants/All.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterVariants/All.cs new file mode 100644 index 00000000..bbef6b5d --- /dev/null +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterVariants/All.cs @@ -0,0 +1,39 @@ +using System.Text.Json; +using URLRewriterProperties = Imagekit.Models.Accounts.URLEndpoints.URLEndpointCreateParamsProperties.URLRewriterProperties; + +namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointCreateParamsProperties.URLRewriterVariants; + +public sealed record class Cloudinary(URLRewriterProperties::Cloudinary Value) + : URLRewriter, + IVariant +{ + public static Cloudinary From(URLRewriterProperties::Cloudinary value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class Imgix(JsonElement Value) : URLRewriter, IVariant +{ + public static Imgix From(JsonElement value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Akamai(JsonElement Value) : URLRewriter, IVariant +{ + public static Akamai From(JsonElement value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointDeleteParams.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointDeleteParams.cs new file mode 100644 index 00000000..7c5510bf --- /dev/null +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointDeleteParams.cs @@ -0,0 +1,34 @@ +using System; +using System.Net.Http; + +namespace Imagekit.Models.Accounts.URLEndpoints; + +/// +/// **Note:** This API is currently in beta. Deletes the URL‑endpoint identified +/// by `id`. You cannot delete the default URL‑endpoint created by ImageKit during +/// account creation. +/// +public sealed record class URLEndpointDeleteParams : ParamsBase +{ + public required string ID; + + public override Uri Url(IImageKitClient client) + { + return new UriBuilder( + client.BaseUrl.ToString().TrimEnd('/') + + string.Format("/v1/accounts/url-endpoints/{0}", this.ID) + ) + { + Query = this.QueryString(client), + }.Uri; + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointGetParams.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointGetParams.cs new file mode 100644 index 00000000..785de18a --- /dev/null +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointGetParams.cs @@ -0,0 +1,33 @@ +using System; +using System.Net.Http; + +namespace Imagekit.Models.Accounts.URLEndpoints; + +/// +/// **Note:** This API is currently in beta. Retrieves the URL‑endpoint identified +/// by `id`. +/// +public sealed record class URLEndpointGetParams : ParamsBase +{ + public required string ID; + + public override Uri Url(IImageKitClient client) + { + return new UriBuilder( + client.BaseUrl.ToString().TrimEnd('/') + + string.Format("/v1/accounts/url-endpoints/{0}", this.ID) + ) + { + Query = this.QueryString(client), + }.Uri; + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointListParams.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointListParams.cs new file mode 100644 index 00000000..86dcc613 --- /dev/null +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointListParams.cs @@ -0,0 +1,29 @@ +using System; +using System.Net.Http; + +namespace Imagekit.Models.Accounts.URLEndpoints; + +/// +/// **Note:** This API is currently in beta. Returns an array of all URL‑endpoints +/// configured including the default URL-endpoint generated by ImageKit during account +/// creation. +/// +public sealed record class URLEndpointListParams : ParamsBase +{ + public override Uri Url(IImageKitClient client) + { + return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/accounts/url-endpoints") + { + Query = this.QueryString(client), + }.Uri; + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequest.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequest.cs new file mode 100644 index 00000000..69d87d20 --- /dev/null +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequest.cs @@ -0,0 +1,136 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Accounts.URLEndpoints.URLEndpointRequestProperties; + +namespace Imagekit.Models.Accounts.URLEndpoints; + +/// +/// Schema for URL endpoint resource. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class URLEndpointRequest : ModelBase, IFromRaw +{ + /// + /// Description of the URL endpoint. + /// + public required string Description + { + get + { + if (!this.Properties.TryGetValue("description", out JsonElement element)) + throw new ArgumentOutOfRangeException("description", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("description"); + } + set + { + this.Properties["description"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Ordered list of origin IDs to try when the file isn’t in the Media Library; + /// ImageKit checks them in the sequence provided. Origin must be created before + /// it can be used in a URL endpoint. + /// + public List? Origins + { + get + { + if (!this.Properties.TryGetValue("origins", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["origins"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Path segment appended to your base URL to form the endpoint (letters, digits, + /// and hyphens only — or empty for the default endpoint). + /// + public string? URLPrefix + { + get + { + if (!this.Properties.TryGetValue("urlPrefix", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["urlPrefix"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Configuration for third-party URL rewriting. + /// + public URLRewriter? URLRewriter + { + get + { + if (!this.Properties.TryGetValue("urlRewriter", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["urlRewriter"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.Description; + foreach (var item in this.Origins ?? []) + { + _ = item; + } + _ = this.URLPrefix; + this.URLRewriter?.Validate(); + } + + public URLEndpointRequest() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + URLEndpointRequest(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static URLEndpointRequest FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public URLEndpointRequest(string description) + : this() + { + this.Description = description; + } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriter.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriter.cs new file mode 100644 index 00000000..9ee41202 --- /dev/null +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriter.cs @@ -0,0 +1,176 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Accounts.URLEndpoints.URLEndpointRequestProperties.URLRewriterProperties; +using URLRewriterVariants = Imagekit.Models.Accounts.URLEndpoints.URLEndpointRequestProperties.URLRewriterVariants; + +namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointRequestProperties; + +/// +/// Configuration for third-party URL rewriting. +/// +[JsonConverter(typeof(URLRewriterConverter))] +public abstract record class URLRewriter +{ + internal URLRewriter() { } + + public static implicit operator URLRewriter(Cloudinary value) => + new URLRewriterVariants::Cloudinary(value); + + public bool TryPickCloudinary([NotNullWhen(true)] out Cloudinary? value) + { + value = (this as URLRewriterVariants::Cloudinary)?.Value; + return value != null; + } + + public bool TryPickImgix([NotNullWhen(true)] out JsonElement? value) + { + value = (this as URLRewriterVariants::Imgix)?.Value; + return value != null; + } + + public bool TryPickAkamai([NotNullWhen(true)] out JsonElement? value) + { + value = (this as URLRewriterVariants::Akamai)?.Value; + return value != null; + } + + public void Switch( + Action cloudinary, + Action imgix, + Action akamai + ) + { + switch (this) + { + case URLRewriterVariants::Cloudinary inner: + cloudinary(inner); + break; + case URLRewriterVariants::Imgix inner: + imgix(inner); + break; + case URLRewriterVariants::Akamai inner: + akamai(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func cloudinary, + Func imgix, + Func akamai + ) + { + return this switch + { + URLRewriterVariants::Cloudinary inner => cloudinary(inner), + URLRewriterVariants::Imgix inner => imgix(inner), + URLRewriterVariants::Akamai inner => akamai(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class URLRewriterConverter : JsonConverter +{ + public override URLRewriter? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var json = JsonSerializer.Deserialize(ref reader, options); + string? type; + try + { + type = json.GetProperty("type").GetString(); + } + catch + { + type = null; + } + + switch (type) + { + case "CLOUDINARY": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new URLRewriterVariants::Cloudinary(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "IMGIX": + { + List exceptions = []; + + try + { + return new URLRewriterVariants::Imgix( + JsonSerializer.Deserialize(json, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "AKAMAI": + { + List exceptions = []; + + try + { + return new URLRewriterVariants::Akamai( + JsonSerializer.Deserialize(json, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + default: + { + throw new Exception(); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + URLRewriter value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + URLRewriterVariants::Cloudinary(var cloudinary) => cloudinary, + URLRewriterVariants::Imgix(var imgix) => imgix, + URLRewriterVariants::Akamai(var akamai) => akamai, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/Cloudinary.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/Cloudinary.cs new file mode 100644 index 00000000..67997088 --- /dev/null +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/Cloudinary.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointRequestProperties.URLRewriterProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Cloudinary : ModelBase, IFromRaw +{ + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to preserve `/` in the rewritten URL. + /// + public bool? PreserveAssetDeliveryTypes + { + get + { + if (!this.Properties.TryGetValue("preserveAssetDeliveryTypes", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["preserveAssetDeliveryTypes"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.PreserveAssetDeliveryTypes; + } + + public Cloudinary() + { + this.Type = JsonSerializer.Deserialize("\"CLOUDINARY\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Cloudinary(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Cloudinary FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterVariants/All.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterVariants/All.cs new file mode 100644 index 00000000..fcad34a1 --- /dev/null +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterVariants/All.cs @@ -0,0 +1,39 @@ +using System.Text.Json; +using URLRewriterProperties = Imagekit.Models.Accounts.URLEndpoints.URLEndpointRequestProperties.URLRewriterProperties; + +namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointRequestProperties.URLRewriterVariants; + +public sealed record class Cloudinary(URLRewriterProperties::Cloudinary Value) + : URLRewriter, + IVariant +{ + public static Cloudinary From(URLRewriterProperties::Cloudinary value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class Imgix(JsonElement Value) : URLRewriter, IVariant +{ + public static Imgix From(JsonElement value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Akamai(JsonElement Value) : URLRewriter, IVariant +{ + public static Akamai From(JsonElement value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponse.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponse.cs new file mode 100644 index 00000000..478785dc --- /dev/null +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponse.cs @@ -0,0 +1,155 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Accounts.URLEndpoints.URLEndpointResponseProperties; + +namespace Imagekit.Models.Accounts.URLEndpoints; + +/// +/// URL‑endpoint object as returned by the API. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class URLEndpointResponse : ModelBase, IFromRaw +{ + /// + /// Unique identifier for the URL-endpoint. This is generated by ImageKit when + /// you create a new URL-endpoint. For the default URL-endpoint, this is always `default`. + /// + public required string ID + { + get + { + if (!this.Properties.TryGetValue("id", out JsonElement element)) + throw new ArgumentOutOfRangeException("id", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("id"); + } + set + { + this.Properties["id"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Description of the URL endpoint. + /// + public required string Description + { + get + { + if (!this.Properties.TryGetValue("description", out JsonElement element)) + throw new ArgumentOutOfRangeException("description", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("description"); + } + set + { + this.Properties["description"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Ordered list of origin IDs to try when the file isn’t in the Media Library; + /// ImageKit checks them in the sequence provided. Origin must be created before + /// it can be used in a URL endpoint. + /// + public required List Origins + { + get + { + if (!this.Properties.TryGetValue("origins", out JsonElement element)) + throw new ArgumentOutOfRangeException("origins", "Missing required argument"); + + return JsonSerializer.Deserialize>(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("origins"); + } + set + { + this.Properties["origins"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Path segment appended to your base URL to form the endpoint (letters, digits, + /// and hyphens only — or empty for the default endpoint). + /// + public required string URLPrefix + { + get + { + if (!this.Properties.TryGetValue("urlPrefix", out JsonElement element)) + throw new ArgumentOutOfRangeException("urlPrefix", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("urlPrefix"); + } + set + { + this.Properties["urlPrefix"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Configuration for third-party URL rewriting. + /// + public URLRewriter? URLRewriter + { + get + { + if (!this.Properties.TryGetValue("urlRewriter", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["urlRewriter"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.ID; + _ = this.Description; + foreach (var item in this.Origins) + { + _ = item; + } + _ = this.URLPrefix; + this.URLRewriter?.Validate(); + } + + public URLEndpointResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + URLEndpointResponse(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static URLEndpointResponse FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriter.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriter.cs new file mode 100644 index 00000000..26256e1c --- /dev/null +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriter.cs @@ -0,0 +1,176 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Accounts.URLEndpoints.URLEndpointResponseProperties.URLRewriterProperties; +using URLRewriterVariants = Imagekit.Models.Accounts.URLEndpoints.URLEndpointResponseProperties.URLRewriterVariants; + +namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointResponseProperties; + +/// +/// Configuration for third-party URL rewriting. +/// +[JsonConverter(typeof(URLRewriterConverter))] +public abstract record class URLRewriter +{ + internal URLRewriter() { } + + public static implicit operator URLRewriter(Cloudinary value) => + new URLRewriterVariants::Cloudinary(value); + + public bool TryPickCloudinary([NotNullWhen(true)] out Cloudinary? value) + { + value = (this as URLRewriterVariants::Cloudinary)?.Value; + return value != null; + } + + public bool TryPickImgix([NotNullWhen(true)] out JsonElement? value) + { + value = (this as URLRewriterVariants::Imgix)?.Value; + return value != null; + } + + public bool TryPickAkamai([NotNullWhen(true)] out JsonElement? value) + { + value = (this as URLRewriterVariants::Akamai)?.Value; + return value != null; + } + + public void Switch( + Action cloudinary, + Action imgix, + Action akamai + ) + { + switch (this) + { + case URLRewriterVariants::Cloudinary inner: + cloudinary(inner); + break; + case URLRewriterVariants::Imgix inner: + imgix(inner); + break; + case URLRewriterVariants::Akamai inner: + akamai(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func cloudinary, + Func imgix, + Func akamai + ) + { + return this switch + { + URLRewriterVariants::Cloudinary inner => cloudinary(inner), + URLRewriterVariants::Imgix inner => imgix(inner), + URLRewriterVariants::Akamai inner => akamai(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class URLRewriterConverter : JsonConverter +{ + public override URLRewriter? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var json = JsonSerializer.Deserialize(ref reader, options); + string? type; + try + { + type = json.GetProperty("type").GetString(); + } + catch + { + type = null; + } + + switch (type) + { + case "CLOUDINARY": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new URLRewriterVariants::Cloudinary(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "IMGIX": + { + List exceptions = []; + + try + { + return new URLRewriterVariants::Imgix( + JsonSerializer.Deserialize(json, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "AKAMAI": + { + List exceptions = []; + + try + { + return new URLRewriterVariants::Akamai( + JsonSerializer.Deserialize(json, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + default: + { + throw new Exception(); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + URLRewriter value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + URLRewriterVariants::Cloudinary(var cloudinary) => cloudinary, + URLRewriterVariants::Imgix(var imgix) => imgix, + URLRewriterVariants::Akamai(var akamai) => akamai, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/Cloudinary.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/Cloudinary.cs new file mode 100644 index 00000000..e2ebff1d --- /dev/null +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/Cloudinary.cs @@ -0,0 +1,83 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointResponseProperties.URLRewriterProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Cloudinary : ModelBase, IFromRaw +{ + /// + /// Whether to preserve `/` in the rewritten URL. + /// + public required bool PreserveAssetDeliveryTypes + { + get + { + if (!this.Properties.TryGetValue("preserveAssetDeliveryTypes", out JsonElement element)) + throw new ArgumentOutOfRangeException( + "preserveAssetDeliveryTypes", + "Missing required argument" + ); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["preserveAssetDeliveryTypes"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.PreserveAssetDeliveryTypes; + } + + public Cloudinary() + { + this.Type = JsonSerializer.Deserialize("\"CLOUDINARY\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Cloudinary(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Cloudinary FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public Cloudinary(bool preserveAssetDeliveryTypes) + : this() + { + this.PreserveAssetDeliveryTypes = preserveAssetDeliveryTypes; + } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterVariants/All.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterVariants/All.cs new file mode 100644 index 00000000..7e77ed0a --- /dev/null +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterVariants/All.cs @@ -0,0 +1,39 @@ +using System.Text.Json; +using URLRewriterProperties = Imagekit.Models.Accounts.URLEndpoints.URLEndpointResponseProperties.URLRewriterProperties; + +namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointResponseProperties.URLRewriterVariants; + +public sealed record class Cloudinary(URLRewriterProperties::Cloudinary Value) + : URLRewriter, + IVariant +{ + public static Cloudinary From(URLRewriterProperties::Cloudinary value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class Imgix(JsonElement Value) : URLRewriter, IVariant +{ + public static Imgix From(JsonElement value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Akamai(JsonElement Value) : URLRewriter, IVariant +{ + public static Akamai From(JsonElement value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParams.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParams.cs new file mode 100644 index 00000000..8a2aac55 --- /dev/null +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParams.cs @@ -0,0 +1,136 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Text; +using System.Text.Json; +using Imagekit.Models.Accounts.URLEndpoints.URLEndpointUpdateParamsProperties; + +namespace Imagekit.Models.Accounts.URLEndpoints; + +/// +/// **Note:** This API is currently in beta. Updates the URL‑endpoint identified +/// by `id` and returns the updated object. +/// +public sealed record class URLEndpointUpdateParams : ParamsBase +{ + public Dictionary BodyProperties { get; set; } = []; + + public required string ID; + + /// + /// Description of the URL endpoint. + /// + public required string Description + { + get + { + if (!this.BodyProperties.TryGetValue("description", out JsonElement element)) + throw new ArgumentOutOfRangeException("description", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("description"); + } + set + { + this.BodyProperties["description"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Ordered list of origin IDs to try when the file isn’t in the Media Library; + /// ImageKit checks them in the sequence provided. Origin must be created before + /// it can be used in a URL endpoint. + /// + public List? Origins + { + get + { + if (!this.BodyProperties.TryGetValue("origins", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["origins"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Path segment appended to your base URL to form the endpoint (letters, digits, + /// and hyphens only — or empty for the default endpoint). + /// + public string? URLPrefix + { + get + { + if (!this.BodyProperties.TryGetValue("urlPrefix", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["urlPrefix"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Configuration for third-party URL rewriting. + /// + public URLRewriter? URLRewriter + { + get + { + if (!this.BodyProperties.TryGetValue("urlRewriter", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["urlRewriter"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override Uri Url(IImageKitClient client) + { + return new UriBuilder( + client.BaseUrl.ToString().TrimEnd('/') + + string.Format("/v1/accounts/url-endpoints/{0}", this.ID) + ) + { + Query = this.QueryString(client), + }.Uri; + } + + public StringContent BodyContent() + { + return new( + JsonSerializer.Serialize(this.BodyProperties), + Encoding.UTF8, + "application/json" + ); + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriter.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriter.cs new file mode 100644 index 00000000..a33a02b3 --- /dev/null +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriter.cs @@ -0,0 +1,176 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Accounts.URLEndpoints.URLEndpointUpdateParamsProperties.URLRewriterProperties; +using URLRewriterVariants = Imagekit.Models.Accounts.URLEndpoints.URLEndpointUpdateParamsProperties.URLRewriterVariants; + +namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointUpdateParamsProperties; + +/// +/// Configuration for third-party URL rewriting. +/// +[JsonConverter(typeof(URLRewriterConverter))] +public abstract record class URLRewriter +{ + internal URLRewriter() { } + + public static implicit operator URLRewriter(Cloudinary value) => + new URLRewriterVariants::Cloudinary(value); + + public bool TryPickCloudinary([NotNullWhen(true)] out Cloudinary? value) + { + value = (this as URLRewriterVariants::Cloudinary)?.Value; + return value != null; + } + + public bool TryPickImgix([NotNullWhen(true)] out JsonElement? value) + { + value = (this as URLRewriterVariants::Imgix)?.Value; + return value != null; + } + + public bool TryPickAkamai([NotNullWhen(true)] out JsonElement? value) + { + value = (this as URLRewriterVariants::Akamai)?.Value; + return value != null; + } + + public void Switch( + Action cloudinary, + Action imgix, + Action akamai + ) + { + switch (this) + { + case URLRewriterVariants::Cloudinary inner: + cloudinary(inner); + break; + case URLRewriterVariants::Imgix inner: + imgix(inner); + break; + case URLRewriterVariants::Akamai inner: + akamai(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func cloudinary, + Func imgix, + Func akamai + ) + { + return this switch + { + URLRewriterVariants::Cloudinary inner => cloudinary(inner), + URLRewriterVariants::Imgix inner => imgix(inner), + URLRewriterVariants::Akamai inner => akamai(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class URLRewriterConverter : JsonConverter +{ + public override URLRewriter? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var json = JsonSerializer.Deserialize(ref reader, options); + string? type; + try + { + type = json.GetProperty("type").GetString(); + } + catch + { + type = null; + } + + switch (type) + { + case "CLOUDINARY": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new URLRewriterVariants::Cloudinary(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "IMGIX": + { + List exceptions = []; + + try + { + return new URLRewriterVariants::Imgix( + JsonSerializer.Deserialize(json, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "AKAMAI": + { + List exceptions = []; + + try + { + return new URLRewriterVariants::Akamai( + JsonSerializer.Deserialize(json, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + default: + { + throw new Exception(); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + URLRewriter value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + URLRewriterVariants::Cloudinary(var cloudinary) => cloudinary, + URLRewriterVariants::Imgix(var imgix) => imgix, + URLRewriterVariants::Akamai(var akamai) => akamai, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/Cloudinary.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/Cloudinary.cs new file mode 100644 index 00000000..169c202f --- /dev/null +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/Cloudinary.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointUpdateParamsProperties.URLRewriterProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Cloudinary : ModelBase, IFromRaw +{ + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to preserve `/` in the rewritten URL. + /// + public bool? PreserveAssetDeliveryTypes + { + get + { + if (!this.Properties.TryGetValue("preserveAssetDeliveryTypes", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["preserveAssetDeliveryTypes"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.PreserveAssetDeliveryTypes; + } + + public Cloudinary() + { + this.Type = JsonSerializer.Deserialize("\"CLOUDINARY\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Cloudinary(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Cloudinary FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterVariants/All.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterVariants/All.cs new file mode 100644 index 00000000..bab987b0 --- /dev/null +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterVariants/All.cs @@ -0,0 +1,39 @@ +using System.Text.Json; +using URLRewriterProperties = Imagekit.Models.Accounts.URLEndpoints.URLEndpointUpdateParamsProperties.URLRewriterProperties; + +namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointUpdateParamsProperties.URLRewriterVariants; + +public sealed record class Cloudinary(URLRewriterProperties::Cloudinary Value) + : URLRewriter, + IVariant +{ + public static Cloudinary From(URLRewriterProperties::Cloudinary value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class Imgix(JsonElement Value) : URLRewriter, IVariant +{ + public static Imgix From(JsonElement value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Akamai(JsonElement Value) : URLRewriter, IVariant +{ + public static Akamai From(JsonElement value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/Accounts/Usage/UsageGetParams.cs b/src/Imagekit/Models/Accounts/Usage/UsageGetParams.cs new file mode 100644 index 00000000..fe843155 --- /dev/null +++ b/src/Imagekit/Models/Accounts/Usage/UsageGetParams.cs @@ -0,0 +1,75 @@ +using System; +using System.Net.Http; +using System.Text.Json; + +namespace Imagekit.Models.Accounts.Usage; + +/// +/// Get the account usage information between two dates. Note that the API response +/// includes data from the start date while excluding data from the end date. In +/// other words, the data covers the period starting from the specified start date +/// up to, but not including, the end date. +/// +public sealed record class UsageGetParams : ParamsBase +{ + /// + /// Specify a `endDate` in `YYYY-MM-DD` format. It should be after the `startDate`. + /// The difference between `startDate` and `endDate` should be less than 90 days. + /// + public required DateOnly EndDate + { + get + { + if (!this.QueryProperties.TryGetValue("endDate", out JsonElement element)) + throw new ArgumentOutOfRangeException("endDate", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.QueryProperties["endDate"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specify a `startDate` in `YYYY-MM-DD` format. It should be before the `endDate`. + /// The difference between `startDate` and `endDate` should be less than 90 days. + /// + public required DateOnly StartDate + { + get + { + if (!this.QueryProperties.TryGetValue("startDate", out JsonElement element)) + throw new ArgumentOutOfRangeException("startDate", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.QueryProperties["startDate"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override Uri Url(IImageKitClient client) + { + return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/accounts/usage") + { + Query = this.QueryString(client), + }.Uri; + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/Accounts/Usage/UsageGetResponse.cs b/src/Imagekit/Models/Accounts/Usage/UsageGetResponse.cs new file mode 100644 index 00000000..d540bab5 --- /dev/null +++ b/src/Imagekit/Models/Accounts/Usage/UsageGetResponse.cs @@ -0,0 +1,139 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Accounts.Usage; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class UsageGetResponse : ModelBase, IFromRaw +{ + /// + /// Amount of bandwidth used in bytes. + /// + public long? BandwidthBytes + { + get + { + if (!this.Properties.TryGetValue("bandwidthBytes", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["bandwidthBytes"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Number of extension units used. + /// + public long? ExtensionUnitsCount + { + get + { + if (!this.Properties.TryGetValue("extensionUnitsCount", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["extensionUnitsCount"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Storage used by media library in bytes. + /// + public long? MediaLibraryStorageBytes + { + get + { + if (!this.Properties.TryGetValue("mediaLibraryStorageBytes", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["mediaLibraryStorageBytes"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Storage used by the original cache in bytes. + /// + public long? OriginalCacheStorageBytes + { + get + { + if (!this.Properties.TryGetValue("originalCacheStorageBytes", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["originalCacheStorageBytes"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Number of video processing units used. + /// + public long? VideoProcessingUnitsCount + { + get + { + if (!this.Properties.TryGetValue("videoProcessingUnitsCount", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["videoProcessingUnitsCount"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.BandwidthBytes; + _ = this.ExtensionUnitsCount; + _ = this.MediaLibraryStorageBytes; + _ = this.OriginalCacheStorageBytes; + _ = this.VideoProcessingUnitsCount; + } + + public UsageGetResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UsageGetResponse(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static UsageGetResponse FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Assets/AssetListParams.cs b/src/Imagekit/Models/Assets/AssetListParams.cs new file mode 100644 index 00000000..0e5fb2b3 --- /dev/null +++ b/src/Imagekit/Models/Assets/AssetListParams.cs @@ -0,0 +1,210 @@ +using System; +using System.Net.Http; +using System.Text.Json; +using AssetListParamsProperties = Imagekit.Models.Assets.AssetListParamsProperties; + +namespace Imagekit.Models.Assets; + +/// +/// This API can list all the uploaded files and folders in your ImageKit.io media +/// library. In addition, you can fine-tune your query by specifying various filters +/// by generating a query string in a Lucene-like syntax and provide this generated +/// string as the value of the `searchQuery`. +/// +public sealed record class AssetListParams : ParamsBase +{ + /// + /// Filter results by file type. + /// + /// - `all` — include all file types - `image` — include only image files + /// - `non-image` — include only non-image files (e.g., JS, CSS, video) + /// + public ApiEnum? FileType + { + get + { + if (!this.QueryProperties.TryGetValue("fileType", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.QueryProperties["fileType"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The maximum number of results to return in response. + /// + public long? Limit + { + get + { + if (!this.QueryProperties.TryGetValue("limit", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.QueryProperties["limit"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Folder path if you want to limit the search within a specific folder. For + /// example, `/sales-banner/` will only search in folder sales-banner. + /// + /// Note : If your use case involves searching within a folder as well as its + /// subfolders, you can use `path` parameter in `searchQuery` with appropriate + /// operator. Checkout [Supported parameters](/docs/api-reference/digital-asset-management-dam/list-and-search-assets#supported-parameters) + /// for more information. + /// + public string? Path + { + get + { + if (!this.QueryProperties.TryGetValue("path", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.QueryProperties["path"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Query string in a Lucene-like query language e.g. `createdAt > "7d"`. + /// + /// Note : When the searchQuery parameter is present, the following query parameters + /// will have no effect on the result: + /// + /// 1. `tags` 2. `type` 3. `name` + /// + /// [Learn more](/docs/api-reference/digital-asset-management-dam/list-and-search-assets#advanced-search-queries) + /// from examples. + /// + public string? SearchQuery + { + get + { + if (!this.QueryProperties.TryGetValue("searchQuery", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.QueryProperties["searchQuery"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The number of results to skip before returning results. + /// + public long? Skip + { + get + { + if (!this.QueryProperties.TryGetValue("skip", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.QueryProperties["skip"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Sort the results by one of the supported fields in ascending or descending + /// order. + /// + public ApiEnum? Sort + { + get + { + if (!this.QueryProperties.TryGetValue("sort", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.QueryProperties["sort"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Filter results by asset type. + /// + /// - `file` — returns only files - `file-version` — returns specific file versions + /// - `folder` — returns only folders - `all` — returns both files and folders + /// (excludes `file-version`) + /// + public ApiEnum? Type + { + get + { + if (!this.QueryProperties.TryGetValue("type", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.QueryProperties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override Uri Url(IImageKitClient client) + { + return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/files") + { + Query = this.QueryString(client), + }.Uri; + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/Assets/AssetListParamsProperties/FileType.cs b/src/Imagekit/Models/Assets/AssetListParamsProperties/FileType.cs new file mode 100644 index 00000000..620809fb --- /dev/null +++ b/src/Imagekit/Models/Assets/AssetListParamsProperties/FileType.cs @@ -0,0 +1,52 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using System = System; + +namespace Imagekit.Models.Assets.AssetListParamsProperties; + +/// +/// Filter results by file type. +/// +/// - `all` — include all file types - `image` — include only image files - `non-image` +/// — include only non-image files (e.g., JS, CSS, video) +/// +[JsonConverter(typeof(FileTypeConverter))] +public enum FileType +{ + All, + Image, + NonImage, +} + +sealed class FileTypeConverter : JsonConverter +{ + public override FileType Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "all" => FileType.All, + "image" => FileType.Image, + "non-image" => FileType.NonImage, + _ => (FileType)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, FileType value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + FileType.All => "all", + FileType.Image => "image", + FileType.NonImage => "non-image", + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Assets/AssetListParamsProperties/Sort.cs b/src/Imagekit/Models/Assets/AssetListParamsProperties/Sort.cs new file mode 100644 index 00000000..a932d642 --- /dev/null +++ b/src/Imagekit/Models/Assets/AssetListParamsProperties/Sort.cs @@ -0,0 +1,82 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using System = System; + +namespace Imagekit.Models.Assets.AssetListParamsProperties; + +/// +/// Sort the results by one of the supported fields in ascending or descending order. +/// +[JsonConverter(typeof(SortConverter))] +public enum Sort +{ + AscName, + DescName, + AscCreated, + DescCreated, + AscUpdated, + DescUpdated, + AscHeight, + DescHeight, + AscWidth, + DescWidth, + AscSize, + DescSize, + AscRelevance, + DescRelevance, +} + +sealed class SortConverter : JsonConverter +{ + public override Sort Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "ASC_NAME" => Sort.AscName, + "DESC_NAME" => Sort.DescName, + "ASC_CREATED" => Sort.AscCreated, + "DESC_CREATED" => Sort.DescCreated, + "ASC_UPDATED" => Sort.AscUpdated, + "DESC_UPDATED" => Sort.DescUpdated, + "ASC_HEIGHT" => Sort.AscHeight, + "DESC_HEIGHT" => Sort.DescHeight, + "ASC_WIDTH" => Sort.AscWidth, + "DESC_WIDTH" => Sort.DescWidth, + "ASC_SIZE" => Sort.AscSize, + "DESC_SIZE" => Sort.DescSize, + "ASC_RELEVANCE" => Sort.AscRelevance, + "DESC_RELEVANCE" => Sort.DescRelevance, + _ => (Sort)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Sort value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + Sort.AscName => "ASC_NAME", + Sort.DescName => "DESC_NAME", + Sort.AscCreated => "ASC_CREATED", + Sort.DescCreated => "DESC_CREATED", + Sort.AscUpdated => "ASC_UPDATED", + Sort.DescUpdated => "DESC_UPDATED", + Sort.AscHeight => "ASC_HEIGHT", + Sort.DescHeight => "DESC_HEIGHT", + Sort.AscWidth => "ASC_WIDTH", + Sort.DescWidth => "DESC_WIDTH", + Sort.AscSize => "ASC_SIZE", + Sort.DescSize => "DESC_SIZE", + Sort.AscRelevance => "ASC_RELEVANCE", + Sort.DescRelevance => "DESC_RELEVANCE", + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Assets/AssetListParamsProperties/Type.cs b/src/Imagekit/Models/Assets/AssetListParamsProperties/Type.cs new file mode 100644 index 00000000..e3141966 --- /dev/null +++ b/src/Imagekit/Models/Assets/AssetListParamsProperties/Type.cs @@ -0,0 +1,56 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using System = System; + +namespace Imagekit.Models.Assets.AssetListParamsProperties; + +/// +/// Filter results by asset type. +/// +/// - `file` — returns only files - `file-version` — returns specific file versions +/// - `folder` — returns only folders - `all` — returns both files and folders +/// (excludes `file-version`) +/// +[JsonConverter(typeof(TypeConverter))] +public enum Type +{ + File, + FileVersion, + Folder, + All, +} + +sealed class TypeConverter : JsonConverter +{ + public override Type Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "file" => AssetListParamsProperties.Type.File, + "file-version" => AssetListParamsProperties.Type.FileVersion, + "folder" => AssetListParamsProperties.Type.Folder, + "all" => AssetListParamsProperties.Type.All, + _ => (Type)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + AssetListParamsProperties.Type.File => "file", + AssetListParamsProperties.Type.FileVersion => "file-version", + AssetListParamsProperties.Type.Folder => "folder", + AssetListParamsProperties.Type.All => "all", + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Assets/AssetListResponse.cs b/src/Imagekit/Models/Assets/AssetListResponse.cs new file mode 100644 index 00000000..4fb2cf1b --- /dev/null +++ b/src/Imagekit/Models/Assets/AssetListResponse.cs @@ -0,0 +1,147 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files; +using AssetListResponseVariants = Imagekit.Models.Assets.AssetListResponseVariants; + +namespace Imagekit.Models.Assets; + +/// +/// Object containing details of a file or file version. +/// +[JsonConverter(typeof(AssetListResponseConverter))] +public abstract record class AssetListResponse +{ + internal AssetListResponse() { } + + public static implicit operator AssetListResponse(File value) => + new AssetListResponseVariants::File(value); + + public static implicit operator AssetListResponse(Folder value) => + new AssetListResponseVariants::Folder(value); + + public bool TryPickFile([NotNullWhen(true)] out File? value) + { + value = (this as AssetListResponseVariants::File)?.Value; + return value != null; + } + + public bool TryPickFolder([NotNullWhen(true)] out Folder? value) + { + value = (this as AssetListResponseVariants::Folder)?.Value; + return value != null; + } + + public void Switch( + Action file, + Action folder + ) + { + switch (this) + { + case AssetListResponseVariants::File inner: + file(inner); + break; + case AssetListResponseVariants::Folder inner: + folder(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func file, + Func folder + ) + { + return this switch + { + AssetListResponseVariants::File inner => file(inner), + AssetListResponseVariants::Folder inner => folder(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class AssetListResponseConverter : JsonConverter +{ + public override AssetListResponse? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var json = JsonSerializer.Deserialize(ref reader, options); + string? type; + try + { + type = json.GetProperty("type").GetString(); + } + catch + { + type = null; + } + + switch (type) + { + case "folder": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new AssetListResponseVariants::Folder(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + default: + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new AssetListResponseVariants::File(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + AssetListResponse value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + AssetListResponseVariants::File(var file) => file, + AssetListResponseVariants::Folder(var folder) => folder, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Assets/AssetListResponseVariants/All.cs b/src/Imagekit/Models/Assets/AssetListResponseVariants/All.cs new file mode 100644 index 00000000..5bd62993 --- /dev/null +++ b/src/Imagekit/Models/Assets/AssetListResponseVariants/All.cs @@ -0,0 +1,34 @@ +using Files = Imagekit.Models.Files; + +namespace Imagekit.Models.Assets.AssetListResponseVariants; + +/// +/// Object containing details of a file or file version. +/// +public sealed record class File(Files::File Value) : AssetListResponse, IVariant +{ + public static File From(Files::File value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class Folder(Files::Folder Value) + : AssetListResponse, + IVariant +{ + public static Folder From(Files::Folder value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} diff --git a/src/Imagekit/Models/BaseOverlay.cs b/src/Imagekit/Models/BaseOverlay.cs new file mode 100644 index 00000000..b1a9d463 --- /dev/null +++ b/src/Imagekit/Models/BaseOverlay.cs @@ -0,0 +1,70 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class BaseOverlay : ModelBase, IFromRaw +{ + public OverlayPosition? Position + { + get + { + if (!this.Properties.TryGetValue("position", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["position"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public OverlayTiming? Timing + { + get + { + if (!this.Properties.TryGetValue("timing", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["timing"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.Position?.Validate(); + this.Timing?.Validate(); + } + + public BaseOverlay() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + BaseOverlay(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static BaseOverlay FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParams.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParams.cs new file mode 100644 index 00000000..69983989 --- /dev/null +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParams.cs @@ -0,0 +1,561 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Text; +using System.Text.Json; +using FileUploadParamsProperties = Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties; + +namespace Imagekit.Models.Beta.V2.Files; + +/// +/// The V2 API enhances security by verifying the entire payload using JWT. This +/// API is in beta. +/// +/// ImageKit.io allows you to upload files directly from both the server and client +/// sides. For server-side uploads, private API key authentication is used. For client-side +/// uploads, generate a one-time `token` from your secure backend using private API. +/// [Learn more](/docs/api-reference/upload-file/upload-file-v2#how-to-implement-secure-client-side-file-upload) +/// about how to implement secure client-side file upload. +/// +/// **File size limit** \ On the free plan, the maximum upload file sizes are 20MB +/// for images, audio, and raw files, and 100MB for videos. On the paid plan, these +/// limits increase to 40MB for images, audio, and raw files, and 2GB for videos. +/// These limits can be further increased with higher-tier plans. +/// +/// **Version limit** \ A file can have a maximum of 100 versions. +/// +/// **Demo applications** +/// +/// - A full-fledged [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), +/// supporting file selections from local storage, URL, Dropbox, Google Drive, Instagram, +/// and more. - [Quick start guides](/docs/quick-start-guides) for various frameworks +/// and technologies. +/// +public sealed record class FileUploadParams : ParamsBase +{ + public Dictionary BodyProperties { get; set; } = []; + + /// + /// The API accepts any of the following: + /// + /// - **Binary data** – send the raw bytes as `multipart/form-data`. - **HTTP + /// / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + /// - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + /// + /// When supplying a URL, the server must receive the response headers within + /// 8 seconds; otherwise the request fails with 400 Bad Request. + /// + public required string File + { + get + { + if (!this.BodyProperties.TryGetValue("file", out JsonElement element)) + throw new ArgumentOutOfRangeException("file", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("file"); + } + set + { + this.BodyProperties["file"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The name with which the file has to be uploaded. + /// + public required string FileName + { + get + { + if (!this.BodyProperties.TryGetValue("fileName", out JsonElement element)) + throw new ArgumentOutOfRangeException("fileName", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("fileName"); + } + set + { + this.BodyProperties["fileName"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// This is the client-generated JSON Web Token (JWT). The ImageKit.io server + /// uses it to authenticate and check that the upload request parameters have + /// not been tampered with after the token has been generated. Learn how to create + /// the token on the page below. This field is only required for authentication + /// when uploading a file from the client side. + /// + /// **Note**: Sending a JWT that has been used in the past will result in a validation + /// error. Even if your previous request resulted in an error, you should always + /// send a new token. + /// + /// **⚠️Warning**: JWT must be generated on the server-side because it is generated + /// using your account's private API key. This field is required for authentication + /// when uploading a file from the client-side. + /// + public string? Token + { + get + { + if (!this.BodyProperties.TryGetValue("token", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["token"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Server-side checks to run on the asset. Read more about [Upload API checks](/docs/api-reference/upload-file/upload-file-v2#upload-api-checks). + /// + public string? Checks + { + get + { + if (!this.BodyProperties.TryGetValue("checks", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["checks"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Define an important area in the image. This is only relevant for image type files. + /// + /// - To be passed as a string with the x and y coordinates of the top-left + /// corner, and width and height of the area of interest in the format `x,y,width,height`. + /// For example - `10,10,100,100` - Can be used with fo-customtransformation. + /// - If this field is not specified and the file is overwritten, then customCoordinates + /// will be removed. + /// + public string? CustomCoordinates + { + get + { + if (!this.BodyProperties.TryGetValue("customCoordinates", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["customCoordinates"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// JSON key-value pairs to associate with the asset. Create the custom metadata + /// fields before setting these values. + /// + public Dictionary? CustomMetadata + { + get + { + if (!this.BodyProperties.TryGetValue("customMetadata", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.BodyProperties["customMetadata"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Optional text to describe the contents of the file. + /// + public string? Description + { + get + { + if (!this.BodyProperties.TryGetValue("description", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["description"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Array of extensions to be applied to the image. Each extension can be configured + /// with specific parameters based on the extension type. + /// + public List? Extensions + { + get + { + if (!this.BodyProperties.TryGetValue("extensions", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.BodyProperties["extensions"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The folder path in which the image has to be uploaded. If the folder(s) didn't + /// exist before, a new folder(s) is created. Using multiple `/` creates a nested + /// folder. + /// + public string? Folder + { + get + { + if (!this.BodyProperties.TryGetValue("folder", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["folder"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to mark the file as private or not. + /// + /// If `true`, the file is marked as private and is accessible only using named + /// transformation or signed URL. + /// + public bool? IsPrivateFile + { + get + { + if (!this.BodyProperties.TryGetValue("isPrivateFile", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["isPrivateFile"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to upload file as published or not. + /// + /// If `false`, the file is marked as unpublished, which restricts access to the + /// file only via the media library. Files in draft or unpublished state can only + /// be publicly accessed after being published. + /// + /// The option to upload in draft state is only available in custom enterprise + /// pricing plans. + /// + public bool? IsPublished + { + get + { + if (!this.BodyProperties.TryGetValue("isPublished", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["isPublished"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// If set to `true` and a file already exists at the exact location, its AITags + /// will be removed. Set `overwriteAITags` to `false` to preserve AITags. + /// + public bool? OverwriteAITags + { + get + { + if (!this.BodyProperties.TryGetValue("overwriteAITags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["overwriteAITags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// If the request does not have `customMetadata`, and a file already exists at + /// the exact location, existing customMetadata will be removed. + /// + public bool? OverwriteCustomMetadata + { + get + { + if ( + !this.BodyProperties.TryGetValue("overwriteCustomMetadata", out JsonElement element) + ) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["overwriteCustomMetadata"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// If `false` and `useUniqueFileName` is also `false`, and a file already exists + /// at the exact location, upload API will return an error immediately. + /// + public bool? OverwriteFile + { + get + { + if (!this.BodyProperties.TryGetValue("overwriteFile", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["overwriteFile"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// If the request does not have `tags`, and a file already exists at the exact + /// location, existing tags will be removed. + /// + public bool? OverwriteTags + { + get + { + if (!this.BodyProperties.TryGetValue("overwriteTags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["overwriteTags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Array of response field keys to include in the API response body. + /// + public List>? ResponseFields + { + get + { + if (!this.BodyProperties.TryGetValue("responseFields", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize + >?>(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["responseFields"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Set the tags while uploading the file. Provide an array of tag strings (e.g. + /// `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must + /// not exceed 500, and the `%` character is not allowed. If this field is not + /// specified and the file is overwritten, the existing tags will be removed. + /// + public List? Tags + { + get + { + if (!this.BodyProperties.TryGetValue("tags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["tags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Configure pre-processing (`pre`) and post-processing (`post`) transformations. + /// + /// - `pre` — applied before the file is uploaded to the Media Library. Useful + /// for reducing file size or applying basic optimizations upfront (e.g., resize, compress). + /// + /// - `post` — applied immediately after upload. Ideal for generating transformed + /// versions (like video encodes or thumbnails) in advance, so they're ready for + /// delivery without delay. + /// + /// You can mix and match any combination of post-processing types. + /// + public FileUploadParamsProperties::Transformation? Transformation + { + get + { + if (!this.BodyProperties.TryGetValue("transformation", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.BodyProperties["transformation"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to use a unique filename for this file or not. + /// + /// If `true`, ImageKit.io will add a unique suffix to the filename parameter + /// to get a unique filename. + /// + /// If `false`, then the image is uploaded with the provided filename parameter, + /// and any existing file with the same name is replaced. + /// + public bool? UseUniqueFileName + { + get + { + if (!this.BodyProperties.TryGetValue("useUniqueFileName", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["useUniqueFileName"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The final status of extensions after they have completed execution will be + /// delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + /// about the webhook payload structure. + /// + public string? WebhookURL + { + get + { + if (!this.BodyProperties.TryGetValue("webhookUrl", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["webhookUrl"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override Uri Url(IImageKitClient client) + { + return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/api/v2/files/upload") + { + Query = this.QueryString(client), + }.Uri; + } + + public StringContent BodyContent() + { + return new( + JsonSerializer.Serialize(this.BodyProperties), + Encoding.UTF8, + "application/json" + ); + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/Extension.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/Extension.cs new file mode 100644 index 00000000..643fb77a --- /dev/null +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/Extension.cs @@ -0,0 +1,177 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.ExtensionProperties; +using ExtensionVariants = Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.ExtensionVariants; + +namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties; + +[JsonConverter(typeof(ExtensionConverter))] +public abstract record class Extension +{ + internal Extension() { } + + public static implicit operator Extension(RemoveBg value) => + new ExtensionVariants::RemoveBg(value); + + public static implicit operator Extension(AutoTaggingExtension value) => + new ExtensionVariants::AutoTaggingExtension(value); + + public bool TryPickRemoveBg([NotNullWhen(true)] out RemoveBg? value) + { + value = (this as ExtensionVariants::RemoveBg)?.Value; + return value != null; + } + + public bool TryPickAutoTagging([NotNullWhen(true)] out AutoTaggingExtension? value) + { + value = (this as ExtensionVariants::AutoTaggingExtension)?.Value; + return value != null; + } + + public bool TryPickAIAutoDescription([NotNullWhen(true)] out JsonElement? value) + { + value = (this as ExtensionVariants::AIAutoDescription)?.Value; + return value != null; + } + + public void Switch( + Action removeBg, + Action autoTagging, + Action aiAutoDescription + ) + { + switch (this) + { + case ExtensionVariants::RemoveBg inner: + removeBg(inner); + break; + case ExtensionVariants::AutoTaggingExtension inner: + autoTagging(inner); + break; + case ExtensionVariants::AIAutoDescription inner: + aiAutoDescription(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func removeBg, + Func autoTagging, + Func aiAutoDescription + ) + { + return this switch + { + ExtensionVariants::RemoveBg inner => removeBg(inner), + ExtensionVariants::AutoTaggingExtension inner => autoTagging(inner), + ExtensionVariants::AIAutoDescription inner => aiAutoDescription(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class ExtensionConverter : JsonConverter +{ + public override Extension? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var json = JsonSerializer.Deserialize(ref reader, options); + string? name; + try + { + name = json.GetProperty("name").GetString(); + } + catch + { + name = null; + } + + switch (name) + { + case "remove-bg": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new ExtensionVariants::RemoveBg(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "ai-auto-description": + { + List exceptions = []; + + try + { + return new ExtensionVariants::AIAutoDescription( + JsonSerializer.Deserialize(json, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + default: + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize( + json, + options + ); + if (deserialized != null) + { + return new ExtensionVariants::AutoTaggingExtension(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + Extension value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + ExtensionVariants::RemoveBg(var removeBg) => removeBg, + ExtensionVariants::AutoTaggingExtension(var autoTagging) => autoTagging, + ExtensionVariants::AIAutoDescription(var aiAutoDescription) => aiAutoDescription, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ExtensionProperties/AutoTaggingExtension.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ExtensionProperties/AutoTaggingExtension.cs new file mode 100644 index 00000000..0d372e84 --- /dev/null +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ExtensionProperties/AutoTaggingExtension.cs @@ -0,0 +1,100 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.ExtensionProperties.AutoTaggingExtensionProperties; + +namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.ExtensionProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class AutoTaggingExtension : ModelBase, IFromRaw +{ + /// + /// Maximum number of tags to attach to the asset. + /// + public required long MaxTags + { + get + { + if (!this.Properties.TryGetValue("maxTags", out JsonElement element)) + throw new ArgumentOutOfRangeException("maxTags", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["maxTags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Minimum confidence level for tags to be considered valid. + /// + public required long MinConfidence + { + get + { + if (!this.Properties.TryGetValue("minConfidence", out JsonElement element)) + throw new ArgumentOutOfRangeException("minConfidence", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["minConfidence"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies the auto-tagging extension used. + /// + public required ApiEnum Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + throw new ArgumentOutOfRangeException("name", "Missing required argument"); + + return JsonSerializer.Deserialize>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.MaxTags; + _ = this.MinConfidence; + this.Name.Validate(); + } + + public AutoTaggingExtension() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + AutoTaggingExtension(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static AutoTaggingExtension FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs new file mode 100644 index 00000000..d6d37376 --- /dev/null +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs @@ -0,0 +1,46 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.ExtensionProperties.AutoTaggingExtensionProperties; + +/// +/// Specifies the auto-tagging extension used. +/// +[JsonConverter(typeof(NameConverter))] +public enum Name +{ + GoogleAutoTagging, + AwsAutoTagging, +} + +sealed class NameConverter : JsonConverter +{ + public override Name Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "google-auto-tagging" => Name.GoogleAutoTagging, + "aws-auto-tagging" => Name.AwsAutoTagging, + _ => (Name)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Name value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + Name.GoogleAutoTagging => "google-auto-tagging", + Name.AwsAutoTagging => "aws-auto-tagging", + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ExtensionProperties/RemoveBg.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ExtensionProperties/RemoveBg.cs new file mode 100644 index 00000000..fde15cdf --- /dev/null +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ExtensionProperties/RemoveBg.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.ExtensionProperties.RemoveBgProperties; + +namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.ExtensionProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class RemoveBg : ModelBase, IFromRaw +{ + /// + /// Specifies the background removal extension. + /// + public JsonElement Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + throw new ArgumentOutOfRangeException("name", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public Options? Options + { + get + { + if (!this.Properties.TryGetValue("options", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["options"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.Options?.Validate(); + } + + public RemoveBg() + { + this.Name = JsonSerializer.Deserialize("\"remove-bg\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + RemoveBg(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static RemoveBg FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ExtensionProperties/RemoveBgProperties/Options.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ExtensionProperties/RemoveBgProperties/Options.cs new file mode 100644 index 00000000..5b7de9ca --- /dev/null +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ExtensionProperties/RemoveBgProperties/Options.cs @@ -0,0 +1,122 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.ExtensionProperties.RemoveBgProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Options : ModelBase, IFromRaw +{ + /// + /// Whether to add an artificial shadow to the result. Default is false. Note: + /// Adding shadows is currently only supported for car photos. + /// + public bool? AddShadow + { + get + { + if (!this.Properties.TryGetValue("add_shadow", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["add_shadow"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies a solid color background using hex code (e.g., "81d4fa", "fff") + /// or color name (e.g., "green"). If this parameter is set, `bg_image_url` must + /// be empty. + /// + public string? BgColor + { + get + { + if (!this.Properties.TryGetValue("bg_color", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["bg_color"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Sets a background image from a URL. If this parameter is set, `bg_color` + /// must be empty. + /// + public string? BgImageURL + { + get + { + if (!this.Properties.TryGetValue("bg_image_url", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["bg_image_url"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Allows semi-transparent regions in the result. Default is true. Note: Semitransparency + /// is currently only supported for car windows. + /// + public bool? Semitransparency + { + get + { + if (!this.Properties.TryGetValue("semitransparency", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["semitransparency"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.AddShadow; + _ = this.BgColor; + _ = this.BgImageURL; + _ = this.Semitransparency; + } + + public Options() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Options(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Options FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ExtensionVariants/All.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ExtensionVariants/All.cs new file mode 100644 index 00000000..8806e3a7 --- /dev/null +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ExtensionVariants/All.cs @@ -0,0 +1,46 @@ +using System.Text.Json; +using ExtensionProperties = Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.ExtensionProperties; + +namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.ExtensionVariants; + +public sealed record class RemoveBg(ExtensionProperties::RemoveBg Value) + : Extension, + IVariant +{ + public static RemoveBg From(ExtensionProperties::RemoveBg value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class AutoTaggingExtension(ExtensionProperties::AutoTaggingExtension Value) + : Extension, + IVariant +{ + public static AutoTaggingExtension From(ExtensionProperties::AutoTaggingExtension value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class AIAutoDescription(JsonElement Value) + : Extension, + IVariant +{ + public static AIAutoDescription From(JsonElement value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ResponseField.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ResponseField.cs new file mode 100644 index 00000000..91a2f19c --- /dev/null +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ResponseField.cs @@ -0,0 +1,62 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties; + +[JsonConverter(typeof(ResponseFieldConverter))] +public enum ResponseField +{ + Tags, + CustomCoordinates, + IsPrivateFile, + EmbeddedMetadata, + IsPublished, + CustomMetadata, + Metadata, +} + +sealed class ResponseFieldConverter : JsonConverter +{ + public override ResponseField Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "tags" => ResponseField.Tags, + "customCoordinates" => ResponseField.CustomCoordinates, + "isPrivateFile" => ResponseField.IsPrivateFile, + "embeddedMetadata" => ResponseField.EmbeddedMetadata, + "isPublished" => ResponseField.IsPublished, + "customMetadata" => ResponseField.CustomMetadata, + "metadata" => ResponseField.Metadata, + _ => (ResponseField)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ResponseField value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ResponseField.Tags => "tags", + ResponseField.CustomCoordinates => "customCoordinates", + ResponseField.IsPrivateFile => "isPrivateFile", + ResponseField.EmbeddedMetadata => "embeddedMetadata", + ResponseField.IsPublished => "isPublished", + ResponseField.CustomMetadata => "customMetadata", + ResponseField.Metadata => "metadata", + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/Transformation.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/Transformation.cs new file mode 100644 index 00000000..928b8185 --- /dev/null +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/Transformation.cs @@ -0,0 +1,92 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties; + +namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties; + +/// +/// Configure pre-processing (`pre`) and post-processing (`post`) transformations. +/// +/// - `pre` — applied before the file is uploaded to the Media Library. Useful +/// for reducing file size or applying basic optimizations upfront (e.g., resize, compress). +/// +/// - `post` — applied immediately after upload. Ideal for generating transformed +/// versions (like video encodes or thumbnails) in advance, so they're ready for +/// delivery without delay. +/// +/// You can mix and match any combination of post-processing types. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class Transformation : ModelBase, IFromRaw +{ + /// + /// List of transformations to apply *after* the file is uploaded. Each item + /// must match one of the following types: `transformation`, `gif-to-video`, + /// `thumbnail`, `abs`. + /// + public List? Post + { + get + { + if (!this.Properties.TryGetValue("post", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["post"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Transformation string to apply before uploading the file to the Media Library. + /// Useful for optimizing files at ingestion. + /// + public string? Pre + { + get + { + if (!this.Properties.TryGetValue("pre", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["pre"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + foreach (var item in this.Post ?? []) + { + item.Validate(); + } + _ = this.Pre; + } + + public Transformation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Transformation(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Transformation FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/Post.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/Post.cs new file mode 100644 index 00000000..80ec39d5 --- /dev/null +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/Post.cs @@ -0,0 +1,225 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using PostProperties = Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; +using PostVariants = Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostVariants; + +namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties; + +[JsonConverter(typeof(PostConverter))] +public abstract record class Post +{ + internal Post() { } + + public static implicit operator Post(PostProperties::Transformation value) => + new PostVariants::Transformation(value); + + public static implicit operator Post(PostProperties::GifToVideo value) => + new PostVariants::GifToVideo(value); + + public static implicit operator Post(PostProperties::Thumbnail value) => + new PostVariants::Thumbnail(value); + + public static implicit operator Post(PostProperties::Abs value) => new PostVariants::Abs(value); + + public bool TryPickTransformation([NotNullWhen(true)] out PostProperties::Transformation? value) + { + value = (this as PostVariants::Transformation)?.Value; + return value != null; + } + + public bool TryPickGifToVideo([NotNullWhen(true)] out PostProperties::GifToVideo? value) + { + value = (this as PostVariants::GifToVideo)?.Value; + return value != null; + } + + public bool TryPickThumbnail([NotNullWhen(true)] out PostProperties::Thumbnail? value) + { + value = (this as PostVariants::Thumbnail)?.Value; + return value != null; + } + + public bool TryPickAbs([NotNullWhen(true)] out PostProperties::Abs? value) + { + value = (this as PostVariants::Abs)?.Value; + return value != null; + } + + public void Switch( + Action transformation, + Action gifToVideo, + Action thumbnail, + Action abs + ) + { + switch (this) + { + case PostVariants::Transformation inner: + transformation(inner); + break; + case PostVariants::GifToVideo inner: + gifToVideo(inner); + break; + case PostVariants::Thumbnail inner: + thumbnail(inner); + break; + case PostVariants::Abs inner: + abs(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func transformation, + Func gifToVideo, + Func thumbnail, + Func abs + ) + { + return this switch + { + PostVariants::Transformation inner => transformation(inner), + PostVariants::GifToVideo inner => gifToVideo(inner), + PostVariants::Thumbnail inner => thumbnail(inner), + PostVariants::Abs inner => abs(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class PostConverter : JsonConverter +{ + public override Post? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var json = JsonSerializer.Deserialize(ref reader, options); + string? type; + try + { + type = json.GetProperty("type").GetString(); + } + catch + { + type = null; + } + + switch (type) + { + case "transformation": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize( + json, + options + ); + if (deserialized != null) + { + return new PostVariants::Transformation(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "gif-to-video": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize( + json, + options + ); + if (deserialized != null) + { + return new PostVariants::GifToVideo(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "thumbnail": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize( + json, + options + ); + if (deserialized != null) + { + return new PostVariants::Thumbnail(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "abs": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize( + json, + options + ); + if (deserialized != null) + { + return new PostVariants::Abs(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + default: + { + throw new Exception(); + } + } + } + + public override void Write(Utf8JsonWriter writer, Post value, JsonSerializerOptions options) + { + object variant = value switch + { + PostVariants::Transformation(var transformation) => transformation, + PostVariants::GifToVideo(var gifToVideo) => gifToVideo, + PostVariants::Thumbnail(var thumbnail) => thumbnail, + PostVariants::Abs(var abs) => abs, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Abs.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Abs.cs new file mode 100644 index 00000000..f6369541 --- /dev/null +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Abs.cs @@ -0,0 +1,103 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.AbsProperties; + +namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Abs : ModelBase, IFromRaw +{ + /// + /// Streaming protocol to use (`hls` or `dash`). + /// + public required ApiEnum Protocol + { + get + { + if (!this.Properties.TryGetValue("protocol", out JsonElement element)) + throw new ArgumentOutOfRangeException("protocol", "Missing required argument"); + + return JsonSerializer.Deserialize>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["protocol"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Adaptive Bitrate Streaming (ABS) setup. + /// + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// List of different representations you want to create separated by an underscore. + /// + public required string Value + { + get + { + if (!this.Properties.TryGetValue("value", out JsonElement element)) + throw new ArgumentOutOfRangeException("value", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("value"); + } + set + { + this.Properties["value"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.Protocol.Validate(); + _ = this.Value; + } + + public Abs() + { + this.Type = JsonSerializer.Deserialize("\"abs\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Abs(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Abs FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs new file mode 100644 index 00000000..fb83079d --- /dev/null +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs @@ -0,0 +1,46 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.AbsProperties; + +/// +/// Streaming protocol to use (`hls` or `dash`). +/// +[JsonConverter(typeof(ProtocolConverter))] +public enum Protocol +{ + Hls, + Dash, +} + +sealed class ProtocolConverter : JsonConverter +{ + public override Protocol Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "hls" => Protocol.Hls, + "dash" => Protocol.Dash, + _ => (Protocol)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Protocol value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + Protocol.Hls => "hls", + Protocol.Dash => "dash", + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideo.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideo.cs new file mode 100644 index 00000000..6f180d0b --- /dev/null +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideo.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class GifToVideo : ModelBase, IFromRaw +{ + /// + /// Converts an animated GIF into an MP4. + /// + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Optional transformation string to apply to the output video. **Example**: + /// `q-80` + /// + public string? Value + { + get + { + if (!this.Properties.TryGetValue("value", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["value"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.Value; + } + + public GifToVideo() + { + this.Type = JsonSerializer.Deserialize("\"gif-to-video\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GifToVideo(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static GifToVideo FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Thumbnail.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Thumbnail.cs new file mode 100644 index 00000000..b2ee20f1 --- /dev/null +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Thumbnail.cs @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Thumbnail : ModelBase, IFromRaw +{ + /// + /// Generates a thumbnail image. + /// + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Optional transformation string. **Example**: `w-150,h-150` + /// + public string? Value + { + get + { + if (!this.Properties.TryGetValue("value", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["value"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.Value; + } + + public Thumbnail() + { + this.Type = JsonSerializer.Deserialize("\"thumbnail\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Thumbnail(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Thumbnail FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Transformation.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Transformation.cs new file mode 100644 index 00000000..4fdd2185 --- /dev/null +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Transformation.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Transformation : ModelBase, IFromRaw +{ + /// + /// Transformation type. + /// + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Transformation string (e.g. `w-200,h-200`). Same syntax as ImageKit URL-based + /// transformations. + /// + public required string Value + { + get + { + if (!this.Properties.TryGetValue("value", out JsonElement element)) + throw new ArgumentOutOfRangeException("value", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("value"); + } + set + { + this.Properties["value"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.Value; + } + + public Transformation() + { + this.Type = JsonSerializer.Deserialize("\"transformation\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Transformation(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Transformation FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public Transformation(string value) + : this() + { + this.Value = value; + } +} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostVariants/All.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostVariants/All.cs new file mode 100644 index 00000000..4530dadc --- /dev/null +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostVariants/All.cs @@ -0,0 +1,61 @@ +using PostProperties = Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; + +namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostVariants; + +public sealed record class Transformation(PostProperties::Transformation Value) + : Post, + IVariant +{ + public static Transformation From(PostProperties::Transformation value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class GifToVideo(PostProperties::GifToVideo Value) + : Post, + IVariant +{ + public static GifToVideo From(PostProperties::GifToVideo value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class Thumbnail(PostProperties::Thumbnail Value) + : Post, + IVariant +{ + public static Thumbnail From(PostProperties::Thumbnail value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class Abs(PostProperties::Abs Value) : Post, IVariant +{ + public static Abs From(PostProperties::Abs value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponse.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponse.cs new file mode 100644 index 00000000..723b749b --- /dev/null +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponse.cs @@ -0,0 +1,616 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties; +using Files = Imagekit.Models.Files; + +namespace Imagekit.Models.Beta.V2.Files; + +/// +/// Object containing details of a successful upload. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class FileUploadResponse : ModelBase, IFromRaw +{ + /// + /// An array of tags assigned to the uploaded file by auto tagging. + /// + public List? AITags + { + get + { + if (!this.Properties.TryGetValue("AITags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["AITags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The audio codec used in the video (only for video). + /// + public string? AudioCodec + { + get + { + if (!this.Properties.TryGetValue("audioCodec", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["audioCodec"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The bit rate of the video in kbps (only for video). + /// + public long? BitRate + { + get + { + if (!this.Properties.TryGetValue("bitRate", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["bitRate"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Value of custom coordinates associated with the image in the format `x,y,width,height`. + /// If `customCoordinates` are not defined, then it is `null`. Send `customCoordinates` + /// in `responseFields` in API request to get the value of this field. + /// + public string? CustomCoordinates + { + get + { + if (!this.Properties.TryGetValue("customCoordinates", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["customCoordinates"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// A key-value data associated with the asset. Use `responseField` in API request + /// to get `customMetadata` in the upload API response. Before setting any custom + /// metadata on an asset, you have to create the field using custom metadata + /// fields API. Send `customMetadata` in `responseFields` in API request to get + /// the value of this field. + /// + public Dictionary? CustomMetadata + { + get + { + if (!this.Properties.TryGetValue("customMetadata", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["customMetadata"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Optional text to describe the contents of the file. Can be set by the user + /// or the ai-auto-description extension. + /// + public string? Description + { + get + { + if (!this.Properties.TryGetValue("description", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["description"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The duration of the video in seconds (only for video). + /// + public long? Duration + { + get + { + if (!this.Properties.TryGetValue("duration", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["duration"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Consolidated embedded metadata associated with the file. It includes exif, + /// iptc, and xmp data. Send `embeddedMetadata` in `responseFields` in API request + /// to get embeddedMetadata in the upload API response. + /// + public Dictionary? EmbeddedMetadata + { + get + { + if (!this.Properties.TryGetValue("embeddedMetadata", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["embeddedMetadata"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Extension names with their processing status at the time of completion of + /// the request. It could have one of the following status values: + /// + /// `success`: The extension has been successfully applied. `failed`: The extension + /// has failed and will not be retried. `pending`: The extension will finish processing + /// in some time. On completion, the final status (success / failed) will be sent + /// to the `webhookUrl` provided. + /// + /// If no extension was requested, then this parameter is not returned. + /// + public ExtensionStatus? ExtensionStatus + { + get + { + if (!this.Properties.TryGetValue("extensionStatus", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["extensionStatus"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Unique fileId. Store this fileld in your database, as this will be used to + /// perform update action on this file. + /// + public string? FileID + { + get + { + if (!this.Properties.TryGetValue("fileId", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["fileId"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The relative path of the file in the media library e.g. `/marketing-assets/new-banner.jpg`. + /// + public string? FilePath + { + get + { + if (!this.Properties.TryGetValue("filePath", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["filePath"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Type of the uploaded file. Possible values are `image`, `non-image`. + /// + public string? FileType + { + get + { + if (!this.Properties.TryGetValue("fileType", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["fileType"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Height of the image in pixels (Only for images) + /// + public double? Height + { + get + { + if (!this.Properties.TryGetValue("height", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["height"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Is the file marked as private. It can be either `true` or `false`. Send `isPrivateFile` + /// in `responseFields` in API request to get the value of this field. + /// + public bool? IsPrivateFile + { + get + { + if (!this.Properties.TryGetValue("isPrivateFile", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["isPrivateFile"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Is the file published or in draft state. It can be either `true` or `false`. + /// Send `isPublished` in `responseFields` in API request to get the value of + /// this field. + /// + public bool? IsPublished + { + get + { + if (!this.Properties.TryGetValue("isPublished", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["isPublished"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Legacy metadata. Send `metadata` in `responseFields` in API request to get + /// metadata in the upload API response. + /// + public Files::Metadata? Metadata + { + get + { + if (!this.Properties.TryGetValue("metadata", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["metadata"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Name of the asset. + /// + public string? Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Size of the image file in Bytes. + /// + public double? Size + { + get + { + if (!this.Properties.TryGetValue("size", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["size"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The array of tags associated with the asset. If no tags are set, it will + /// be `null`. Send `tags` in `responseFields` in API request to get the value + /// of this field. + /// + public List? Tags + { + get + { + if (!this.Properties.TryGetValue("tags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["tags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// In the case of an image, a small thumbnail URL. + /// + public string? ThumbnailURL + { + get + { + if (!this.Properties.TryGetValue("thumbnailUrl", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["thumbnailUrl"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// A publicly accessible URL of the file. + /// + public string? URL + { + get + { + if (!this.Properties.TryGetValue("url", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["url"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// An object containing the file or file version's `id` (versionId) and `name`. + /// + public VersionInfo? VersionInfo + { + get + { + if (!this.Properties.TryGetValue("versionInfo", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["versionInfo"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The video codec used in the video (only for video). + /// + public string? VideoCodec + { + get + { + if (!this.Properties.TryGetValue("videoCodec", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["videoCodec"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Width of the image in pixels (Only for Images) + /// + public double? Width + { + get + { + if (!this.Properties.TryGetValue("width", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["width"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + foreach (var item in this.AITags ?? []) + { + item.Validate(); + } + _ = this.AudioCodec; + _ = this.BitRate; + _ = this.CustomCoordinates; + if (this.CustomMetadata != null) + { + foreach (var item in this.CustomMetadata.Values) + { + _ = item; + } + } + _ = this.Description; + _ = this.Duration; + if (this.EmbeddedMetadata != null) + { + foreach (var item in this.EmbeddedMetadata.Values) + { + _ = item; + } + } + this.ExtensionStatus?.Validate(); + _ = this.FileID; + _ = this.FilePath; + _ = this.FileType; + _ = this.Height; + _ = this.IsPrivateFile; + _ = this.IsPublished; + this.Metadata?.Validate(); + _ = this.Name; + _ = this.Size; + foreach (var item in this.Tags ?? []) + { + _ = item; + } + _ = this.ThumbnailURL; + _ = this.URL; + this.VersionInfo?.Validate(); + _ = this.VideoCodec; + _ = this.Width; + } + + public FileUploadResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FileUploadResponse(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static FileUploadResponse FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/AITag.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/AITag.cs new file mode 100644 index 00000000..a6c52d08 --- /dev/null +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/AITag.cs @@ -0,0 +1,96 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class AITag : ModelBase, IFromRaw +{ + /// + /// Confidence score of the tag. + /// + public double? Confidence + { + get + { + if (!this.Properties.TryGetValue("confidence", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["confidence"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Name of the tag. + /// + public string? Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Array of `AITags` associated with the image. If no `AITags` are set, it will + /// be null. These tags can be added using the `google-auto-tagging` or `aws-auto-tagging` extensions. + /// + public string? Source + { + get + { + if (!this.Properties.TryGetValue("source", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["source"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.Confidence; + _ = this.Name; + _ = this.Source; + } + + public AITag() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + AITag(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static AITag FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/ExtensionStatus.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/ExtensionStatus.cs new file mode 100644 index 00000000..aeff7b7b --- /dev/null +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/ExtensionStatus.cs @@ -0,0 +1,129 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.ExtensionStatusProperties; + +namespace Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties; + +/// +/// Extension names with their processing status at the time of completion of the +/// request. It could have one of the following status values: +/// +/// `success`: The extension has been successfully applied. `failed`: The extension +/// has failed and will not be retried. `pending`: The extension will finish processing +/// in some time. On completion, the final status (success / failed) will be sent +/// to the `webhookUrl` provided. +/// +/// If no extension was requested, then this parameter is not returned. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class ExtensionStatus : ModelBase, IFromRaw +{ + public ApiEnum? AIAutoDescription + { + get + { + if (!this.Properties.TryGetValue("ai-auto-description", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["ai-auto-description"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public ApiEnum? AwsAutoTagging + { + get + { + if (!this.Properties.TryGetValue("aws-auto-tagging", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["aws-auto-tagging"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public ApiEnum? GoogleAutoTagging + { + get + { + if (!this.Properties.TryGetValue("google-auto-tagging", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["google-auto-tagging"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public ApiEnum? RemoveBg + { + get + { + if (!this.Properties.TryGetValue("remove-bg", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["remove-bg"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.AIAutoDescription?.Validate(); + this.AwsAutoTagging?.Validate(); + this.GoogleAutoTagging?.Validate(); + this.RemoveBg?.Validate(); + } + + public ExtensionStatus() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ExtensionStatus(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static ExtensionStatus FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/ExtensionStatusProperties/AIAutoDescription.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/ExtensionStatusProperties/AIAutoDescription.cs new file mode 100644 index 00000000..e9577c37 --- /dev/null +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/ExtensionStatusProperties/AIAutoDescription.cs @@ -0,0 +1,50 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.ExtensionStatusProperties; + +[JsonConverter(typeof(AIAutoDescriptionConverter))] +public enum AIAutoDescription +{ + Success, + Pending, + Failed, +} + +sealed class AIAutoDescriptionConverter : JsonConverter +{ + public override AIAutoDescription Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "success" => AIAutoDescription.Success, + "pending" => AIAutoDescription.Pending, + "failed" => AIAutoDescription.Failed, + _ => (AIAutoDescription)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + AIAutoDescription value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + AIAutoDescription.Success => "success", + AIAutoDescription.Pending => "pending", + AIAutoDescription.Failed => "failed", + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/ExtensionStatusProperties/AwsAutoTagging.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/ExtensionStatusProperties/AwsAutoTagging.cs new file mode 100644 index 00000000..43ece216 --- /dev/null +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/ExtensionStatusProperties/AwsAutoTagging.cs @@ -0,0 +1,50 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.ExtensionStatusProperties; + +[JsonConverter(typeof(AwsAutoTaggingConverter))] +public enum AwsAutoTagging +{ + Success, + Pending, + Failed, +} + +sealed class AwsAutoTaggingConverter : JsonConverter +{ + public override AwsAutoTagging Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "success" => AwsAutoTagging.Success, + "pending" => AwsAutoTagging.Pending, + "failed" => AwsAutoTagging.Failed, + _ => (AwsAutoTagging)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + AwsAutoTagging value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + AwsAutoTagging.Success => "success", + AwsAutoTagging.Pending => "pending", + AwsAutoTagging.Failed => "failed", + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/ExtensionStatusProperties/GoogleAutoTagging.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/ExtensionStatusProperties/GoogleAutoTagging.cs new file mode 100644 index 00000000..15da92d3 --- /dev/null +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/ExtensionStatusProperties/GoogleAutoTagging.cs @@ -0,0 +1,50 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.ExtensionStatusProperties; + +[JsonConverter(typeof(GoogleAutoTaggingConverter))] +public enum GoogleAutoTagging +{ + Success, + Pending, + Failed, +} + +sealed class GoogleAutoTaggingConverter : JsonConverter +{ + public override GoogleAutoTagging Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "success" => GoogleAutoTagging.Success, + "pending" => GoogleAutoTagging.Pending, + "failed" => GoogleAutoTagging.Failed, + _ => (GoogleAutoTagging)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + GoogleAutoTagging value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + GoogleAutoTagging.Success => "success", + GoogleAutoTagging.Pending => "pending", + GoogleAutoTagging.Failed => "failed", + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/ExtensionStatusProperties/RemoveBg.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/ExtensionStatusProperties/RemoveBg.cs new file mode 100644 index 00000000..9094a0e5 --- /dev/null +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/ExtensionStatusProperties/RemoveBg.cs @@ -0,0 +1,46 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.ExtensionStatusProperties; + +[JsonConverter(typeof(RemoveBgConverter))] +public enum RemoveBg +{ + Success, + Pending, + Failed, +} + +sealed class RemoveBgConverter : JsonConverter +{ + public override RemoveBg Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "success" => RemoveBg.Success, + "pending" => RemoveBg.Pending, + "failed" => RemoveBg.Failed, + _ => (RemoveBg)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, RemoveBg value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + RemoveBg.Success => "success", + RemoveBg.Pending => "pending", + RemoveBg.Failed => "failed", + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/VersionInfo.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/VersionInfo.cs new file mode 100644 index 00000000..ee7f3784 --- /dev/null +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/VersionInfo.cs @@ -0,0 +1,76 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties; + +/// +/// An object containing the file or file version's `id` (versionId) and `name`. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class VersionInfo : ModelBase, IFromRaw +{ + /// + /// Unique identifier of the file version. + /// + public string? ID + { + get + { + if (!this.Properties.TryGetValue("id", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["id"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Name of the file version. + /// + public string? Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.ID; + _ = this.Name; + } + + public VersionInfo() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + VersionInfo(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static VersionInfo FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Cache/Invalidation/InvalidationCreateParams.cs b/src/Imagekit/Models/Cache/Invalidation/InvalidationCreateParams.cs new file mode 100644 index 00000000..2d4a3cd1 --- /dev/null +++ b/src/Imagekit/Models/Cache/Invalidation/InvalidationCreateParams.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Text; +using System.Text.Json; + +namespace Imagekit.Models.Cache.Invalidation; + +/// +/// This API will purge CDN cache and ImageKit.io's internal cache for a file. Note: +/// Purge cache is an asynchronous process and it may take some time to reflect the +/// changes. +/// +public sealed record class InvalidationCreateParams : ParamsBase +{ + public Dictionary BodyProperties { get; set; } = []; + + /// + /// The full URL of the file to be purged. + /// + public required string URL + { + get + { + if (!this.BodyProperties.TryGetValue("url", out JsonElement element)) + throw new ArgumentOutOfRangeException("url", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("url"); + } + set + { + this.BodyProperties["url"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override Uri Url(IImageKitClient client) + { + return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/files/purge") + { + Query = this.QueryString(client), + }.Uri; + } + + public StringContent BodyContent() + { + return new( + JsonSerializer.Serialize(this.BodyProperties), + Encoding.UTF8, + "application/json" + ); + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/Cache/Invalidation/InvalidationCreateResponse.cs b/src/Imagekit/Models/Cache/Invalidation/InvalidationCreateResponse.cs new file mode 100644 index 00000000..3fa13c55 --- /dev/null +++ b/src/Imagekit/Models/Cache/Invalidation/InvalidationCreateResponse.cs @@ -0,0 +1,56 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Cache.Invalidation; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class InvalidationCreateResponse + : ModelBase, + IFromRaw +{ + /// + /// Unique identifier of the purge request. This can be used to check the status + /// of the purge request. + /// + public string? RequestID + { + get + { + if (!this.Properties.TryGetValue("requestId", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["requestId"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.RequestID; + } + + public InvalidationCreateResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + InvalidationCreateResponse(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static InvalidationCreateResponse FromRawUnchecked( + Dictionary properties + ) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Cache/Invalidation/InvalidationGetParams.cs b/src/Imagekit/Models/Cache/Invalidation/InvalidationGetParams.cs new file mode 100644 index 00000000..b856615c --- /dev/null +++ b/src/Imagekit/Models/Cache/Invalidation/InvalidationGetParams.cs @@ -0,0 +1,32 @@ +using System; +using System.Net.Http; + +namespace Imagekit.Models.Cache.Invalidation; + +/// +/// This API returns the status of a purge cache request. +/// +public sealed record class InvalidationGetParams : ParamsBase +{ + public required string RequestID; + + public override Uri Url(IImageKitClient client) + { + return new UriBuilder( + client.BaseUrl.ToString().TrimEnd('/') + + string.Format("/v1/files/purge/{0}", this.RequestID) + ) + { + Query = this.QueryString(client), + }.Uri; + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/Cache/Invalidation/InvalidationGetResponse.cs b/src/Imagekit/Models/Cache/Invalidation/InvalidationGetResponse.cs new file mode 100644 index 00000000..a61b3779 --- /dev/null +++ b/src/Imagekit/Models/Cache/Invalidation/InvalidationGetResponse.cs @@ -0,0 +1,57 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Cache.Invalidation.InvalidationGetResponseProperties; + +namespace Imagekit.Models.Cache.Invalidation; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class InvalidationGetResponse : ModelBase, IFromRaw +{ + /// + /// Status of the purge request. + /// + public ApiEnum? Status + { + get + { + if (!this.Properties.TryGetValue("status", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["status"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.Status?.Validate(); + } + + public InvalidationGetResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + InvalidationGetResponse(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static InvalidationGetResponse FromRawUnchecked( + Dictionary properties + ) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Cache/Invalidation/InvalidationGetResponseProperties/Status.cs b/src/Imagekit/Models/Cache/Invalidation/InvalidationGetResponseProperties/Status.cs new file mode 100644 index 00000000..1760eb98 --- /dev/null +++ b/src/Imagekit/Models/Cache/Invalidation/InvalidationGetResponseProperties/Status.cs @@ -0,0 +1,46 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Cache.Invalidation.InvalidationGetResponseProperties; + +/// +/// Status of the purge request. +/// +[JsonConverter(typeof(StatusConverter))] +public enum Status +{ + Pending, + Completed, +} + +sealed class StatusConverter : JsonConverter +{ + public override Status Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "Pending" => Status.Pending, + "Completed" => Status.Completed, + _ => (Status)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Status value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + Status.Pending => "Pending", + Status.Completed => "Completed", + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataField.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataField.cs new file mode 100644 index 00000000..a270845e --- /dev/null +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataField.cs @@ -0,0 +1,129 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties; + +namespace Imagekit.Models.CustomMetadataFields; + +/// +/// Object containing details of a custom metadata field. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class CustomMetadataField : ModelBase, IFromRaw +{ + /// + /// Unique identifier for the custom metadata field. Use this to update the field. + /// + public required string ID + { + get + { + if (!this.Properties.TryGetValue("id", out JsonElement element)) + throw new ArgumentOutOfRangeException("id", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("id"); + } + set + { + this.Properties["id"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Human readable name of the custom metadata field. This name is displayed as + /// form field label to the users while setting field value on the asset in the + /// media library UI. + /// + public required string Label + { + get + { + if (!this.Properties.TryGetValue("label", out JsonElement element)) + throw new ArgumentOutOfRangeException("label", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("label"); + } + set + { + this.Properties["label"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// API name of the custom metadata field. This becomes the key while setting + /// `customMetadata` (key-value object) for an asset using upload or update API. + /// + public required string Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + throw new ArgumentOutOfRangeException("name", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("name"); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// An object that describes the rules for the custom metadata field value. + /// + public required Schema Schema + { + get + { + if (!this.Properties.TryGetValue("schema", out JsonElement element)) + throw new ArgumentOutOfRangeException("schema", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("schema"); + } + set + { + this.Properties["schema"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.ID; + _ = this.Label; + _ = this.Name; + this.Schema.Validate(); + } + + public CustomMetadataField() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + CustomMetadataField(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static CustomMetadataField FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParams.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParams.cs new file mode 100644 index 00000000..3b0d94e6 --- /dev/null +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParams.cs @@ -0,0 +1,111 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Text; +using System.Text.Json; +using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties; + +namespace Imagekit.Models.CustomMetadataFields; + +/// +/// This API creates a new custom metadata field. Once a custom metadata field is +/// created either through this API or using the dashboard UI, its value can be set +/// on the assets. The value of a field for an asset can be set using the media library +/// UI or programmatically through upload or update assets API. +/// +public sealed record class CustomMetadataFieldCreateParams : ParamsBase +{ + public Dictionary BodyProperties { get; set; } = []; + + /// + /// Human readable name of the custom metadata field. This should be unique across + /// all non deleted custom metadata fields. This name is displayed as form field + /// label to the users while setting field value on an asset in the media library UI. + /// + public required string Label + { + get + { + if (!this.BodyProperties.TryGetValue("label", out JsonElement element)) + throw new ArgumentOutOfRangeException("label", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("label"); + } + set + { + this.BodyProperties["label"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// API name of the custom metadata field. This should be unique across all (including + /// deleted) custom metadata fields. + /// + public required string Name + { + get + { + if (!this.BodyProperties.TryGetValue("name", out JsonElement element)) + throw new ArgumentOutOfRangeException("name", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("name"); + } + set + { + this.BodyProperties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required Schema Schema + { + get + { + if (!this.BodyProperties.TryGetValue("schema", out JsonElement element)) + throw new ArgumentOutOfRangeException("schema", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("schema"); + } + set + { + this.BodyProperties["schema"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override Uri Url(IImageKitClient client) + { + return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/customMetadataFields") + { + Query = this.QueryString(client), + }.Uri; + } + + public StringContent BodyContent() + { + return new( + JsonSerializer.Serialize(this.BodyProperties), + Encoding.UTF8, + "application/json" + ); + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/Schema.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/Schema.cs new file mode 100644 index 00000000..04cbce16 --- /dev/null +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/Schema.cs @@ -0,0 +1,243 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using SchemaProperties = Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties; + +namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Schema : ModelBase, IFromRaw +{ + /// + /// Type of the custom metadata field. + /// + public required ApiEnum Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The default value for this custom metadata field. This property is only required + /// if `isValueRequired` property is set to `true`. The value should match the + /// `type` of custom metadata field. + /// + public SchemaProperties::DefaultValue? DefaultValue + { + get + { + if (!this.Properties.TryGetValue("defaultValue", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["defaultValue"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Sets this custom metadata field as required. Setting custom metadata fields + /// on an asset will throw error if the value for all required fields are not + /// present in upload or update asset API request body. + /// + public bool? IsValueRequired + { + get + { + if (!this.Properties.TryGetValue("isValueRequired", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["isValueRequired"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Maximum length of string. Only set this property if `type` is set to `Text` + /// or `Textarea`. + /// + public double? MaxLength + { + get + { + if (!this.Properties.TryGetValue("maxLength", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["maxLength"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Maximum value of the field. Only set this property if field type is `Date` + /// or `Number`. For `Date` type field, set the minimum date in ISO8601 string + /// format. For `Number` type field, set the minimum numeric value. + /// + public SchemaProperties::MaxValue? MaxValue + { + get + { + if (!this.Properties.TryGetValue("maxValue", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["maxValue"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Minimum length of string. Only set this property if `type` is set to `Text` + /// or `Textarea`. + /// + public double? MinLength + { + get + { + if (!this.Properties.TryGetValue("minLength", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["minLength"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Minimum value of the field. Only set this property if field type is `Date` + /// or `Number`. For `Date` type field, set the minimum date in ISO8601 string + /// format. For `Number` type field, set the minimum numeric value. + /// + public SchemaProperties::MinValue? MinValue + { + get + { + if (!this.Properties.TryGetValue("minValue", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["minValue"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// An array of allowed values. This property is only required if `type` property + /// is set to `SingleSelect` or `MultiSelect`. + /// + public List? SelectOptions + { + get + { + if (!this.Properties.TryGetValue("selectOptions", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["selectOptions"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.Type.Validate(); + this.DefaultValue?.Validate(); + _ = this.IsValueRequired; + _ = this.MaxLength; + this.MaxValue?.Validate(); + _ = this.MinLength; + this.MinValue?.Validate(); + foreach (var item in this.SelectOptions ?? []) + { + item.Validate(); + } + } + + public Schema() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Schema(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Schema FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public Schema(ApiEnum type) + : this() + { + this.Type = type; + } +} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValue.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValue.cs new file mode 100644 index 00000000..d18ab6d2 --- /dev/null +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValue.cs @@ -0,0 +1,176 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties.DefaultValueProperties; +using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties.DefaultValueVariants; +using System = System; + +namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties; + +/// +/// The default value for this custom metadata field. This property is only required +/// if `isValueRequired` property is set to `true`. The value should match the `type` +/// of custom metadata field. +/// +[JsonConverter(typeof(DefaultValueConverter))] +public abstract record class DefaultValue +{ + internal DefaultValue() { } + + public static implicit operator DefaultValue(string value) => new String(value); + + public static implicit operator DefaultValue(double value) => new Double(value); + + public static implicit operator DefaultValue(bool value) => new Bool(value); + + public static implicit operator DefaultValue(List value) => + new Mixed(value); + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as String)?.Value; + return value != null; + } + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as Double)?.Value; + return value != null; + } + + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = (this as Bool)?.Value; + return value != null; + } + + public bool TryPickMixed([NotNullWhen(true)] out List? value) + { + value = (this as Mixed)?.Value; + return value != null; + } + + public void Switch( + System::Action @string, + System::Action @double, + System::Action @bool, + System::Action mixed + ) + { + switch (this) + { + case String inner: + @string(inner); + break; + case Double inner: + @double(inner); + break; + case Bool inner: + @bool(inner); + break; + case Mixed inner: + mixed(inner); + break; + default: + throw new System::InvalidOperationException(); + } + } + + public T Match( + System::Func @string, + System::Func @double, + System::Func @bool, + System::Func mixed + ) + { + return this switch + { + String inner => @string(inner), + Double inner => @double(inner), + Bool inner => @bool(inner), + Mixed inner => mixed(inner), + _ => throw new System::InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class DefaultValueConverter : JsonConverter +{ + public override DefaultValue? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new Double(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new Bool(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize>( + ref reader, + options + ); + if (deserialized != null) + { + return new Mixed(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new System::AggregateException(exceptions); + } + + public override void Write( + Utf8JsonWriter writer, + DefaultValue value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + String(var @string) => @string, + Double(var @double) => @double, + Bool(var @bool) => @bool, + Mixed(var mixed) => mixed, + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent1.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent1.cs new file mode 100644 index 00000000..aa9e002a --- /dev/null +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent1.cs @@ -0,0 +1,140 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties.DefaultValueProperties.UnnamedSchemaWithArrayParent1Variants; +using System = System; + +namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties.DefaultValueProperties; + +[JsonConverter(typeof(UnnamedSchemaWithArrayParent1Converter))] +public abstract record class UnnamedSchemaWithArrayParent1 +{ + internal UnnamedSchemaWithArrayParent1() { } + + public static implicit operator UnnamedSchemaWithArrayParent1(string value) => + new String(value); + + public static implicit operator UnnamedSchemaWithArrayParent1(double value) => + new Double(value); + + public static implicit operator UnnamedSchemaWithArrayParent1(bool value) => new Bool(value); + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as String)?.Value; + return value != null; + } + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as Double)?.Value; + return value != null; + } + + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = (this as Bool)?.Value; + return value != null; + } + + public void Switch( + System::Action @string, + System::Action @double, + System::Action @bool + ) + { + switch (this) + { + case String inner: + @string(inner); + break; + case Double inner: + @double(inner); + break; + case Bool inner: + @bool(inner); + break; + default: + throw new System::InvalidOperationException(); + } + } + + public T Match( + System::Func @string, + System::Func @double, + System::Func @bool + ) + { + return this switch + { + String inner => @string(inner), + Double inner => @double(inner), + Bool inner => @bool(inner), + _ => throw new System::InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class UnnamedSchemaWithArrayParent1Converter : JsonConverter +{ + public override UnnamedSchemaWithArrayParent1? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new Double(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new Bool(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new System::AggregateException(exceptions); + } + + public override void Write( + Utf8JsonWriter writer, + UnnamedSchemaWithArrayParent1 value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + String(var @string) => @string, + Double(var @double) => @double, + Bool(var @bool) => @bool, + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent1Variants/All.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent1Variants/All.cs new file mode 100644 index 00000000..9bde8ea7 --- /dev/null +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent1Variants/All.cs @@ -0,0 +1,35 @@ +namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties.DefaultValueProperties.UnnamedSchemaWithArrayParent1Variants; + +public sealed record class String(string Value) + : UnnamedSchemaWithArrayParent1, + IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Double(double Value) + : UnnamedSchemaWithArrayParent1, + IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Bool(bool Value) : UnnamedSchemaWithArrayParent1, IVariant +{ + public static Bool From(bool value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValueVariants/All.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValueVariants/All.cs new file mode 100644 index 00000000..43c33479 --- /dev/null +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValueVariants/All.cs @@ -0,0 +1,50 @@ +using System.Collections.Generic; +using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties.DefaultValueProperties; + +namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties.DefaultValueVariants; + +public sealed record class String(string Value) : DefaultValue, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Double(double Value) : DefaultValue, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Bool(bool Value) : DefaultValue, IVariant +{ + public static Bool From(bool value) + { + return new(value); + } + + public override void Validate() { } +} + +/// +/// Default value should be of type array when custom metadata field type is set to +/// `MultiSelect`. +/// +public sealed record class Mixed(List Value) + : DefaultValue, + IVariant> +{ + public static Mixed From(List value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MaxValue.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MaxValue.cs new file mode 100644 index 00000000..0928aece --- /dev/null +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MaxValue.cs @@ -0,0 +1,109 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties.MaxValueVariants; +using System = System; + +namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties; + +/// +/// Maximum value of the field. Only set this property if field type is `Date` or +/// `Number`. For `Date` type field, set the minimum date in ISO8601 string format. +/// For `Number` type field, set the minimum numeric value. +/// +[JsonConverter(typeof(MaxValueConverter))] +public abstract record class MaxValue +{ + internal MaxValue() { } + + public static implicit operator MaxValue(string value) => new String(value); + + public static implicit operator MaxValue(double value) => new Double(value); + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as String)?.Value; + return value != null; + } + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as Double)?.Value; + return value != null; + } + + public void Switch(System::Action @string, System::Action @double) + { + switch (this) + { + case String inner: + @string(inner); + break; + case Double inner: + @double(inner); + break; + default: + throw new System::InvalidOperationException(); + } + } + + public T Match(System::Func @string, System::Func @double) + { + return this switch + { + String inner => @string(inner), + Double inner => @double(inner), + _ => throw new System::InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class MaxValueConverter : JsonConverter +{ + public override MaxValue? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new Double(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new System::AggregateException(exceptions); + } + + public override void Write(Utf8JsonWriter writer, MaxValue value, JsonSerializerOptions options) + { + object variant = value switch + { + String(var @string) => @string, + Double(var @double) => @double, + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MaxValueVariants/All.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MaxValueVariants/All.cs new file mode 100644 index 00000000..0702732b --- /dev/null +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MaxValueVariants/All.cs @@ -0,0 +1,21 @@ +namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties.MaxValueVariants; + +public sealed record class String(string Value) : MaxValue, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Double(double Value) : MaxValue, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MinValue.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MinValue.cs new file mode 100644 index 00000000..ccce54d0 --- /dev/null +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MinValue.cs @@ -0,0 +1,109 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties.MinValueVariants; +using System = System; + +namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties; + +/// +/// Minimum value of the field. Only set this property if field type is `Date` or +/// `Number`. For `Date` type field, set the minimum date in ISO8601 string format. +/// For `Number` type field, set the minimum numeric value. +/// +[JsonConverter(typeof(MinValueConverter))] +public abstract record class MinValue +{ + internal MinValue() { } + + public static implicit operator MinValue(string value) => new String(value); + + public static implicit operator MinValue(double value) => new Double(value); + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as String)?.Value; + return value != null; + } + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as Double)?.Value; + return value != null; + } + + public void Switch(System::Action @string, System::Action @double) + { + switch (this) + { + case String inner: + @string(inner); + break; + case Double inner: + @double(inner); + break; + default: + throw new System::InvalidOperationException(); + } + } + + public T Match(System::Func @string, System::Func @double) + { + return this switch + { + String inner => @string(inner), + Double inner => @double(inner), + _ => throw new System::InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class MinValueConverter : JsonConverter +{ + public override MinValue? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new Double(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new System::AggregateException(exceptions); + } + + public override void Write(Utf8JsonWriter writer, MinValue value, JsonSerializerOptions options) + { + object variant = value switch + { + String(var @string) => @string, + Double(var @double) => @double, + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MinValueVariants/All.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MinValueVariants/All.cs new file mode 100644 index 00000000..94c0c48b --- /dev/null +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MinValueVariants/All.cs @@ -0,0 +1,21 @@ +namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties.MinValueVariants; + +public sealed record class String(string Value) : MinValue, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Double(double Value) : MinValue, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/SelectOption.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/SelectOption.cs new file mode 100644 index 00000000..b217c981 --- /dev/null +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/SelectOption.cs @@ -0,0 +1,138 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties.SelectOptionVariants; +using System = System; + +namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties; + +[JsonConverter(typeof(SelectOptionConverter))] +public abstract record class SelectOption +{ + internal SelectOption() { } + + public static implicit operator SelectOption(string value) => new String(value); + + public static implicit operator SelectOption(double value) => new Double(value); + + public static implicit operator SelectOption(bool value) => new Bool(value); + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as String)?.Value; + return value != null; + } + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as Double)?.Value; + return value != null; + } + + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = (this as Bool)?.Value; + return value != null; + } + + public void Switch( + System::Action @string, + System::Action @double, + System::Action @bool + ) + { + switch (this) + { + case String inner: + @string(inner); + break; + case Double inner: + @double(inner); + break; + case Bool inner: + @bool(inner); + break; + default: + throw new System::InvalidOperationException(); + } + } + + public T Match( + System::Func @string, + System::Func @double, + System::Func @bool + ) + { + return this switch + { + String inner => @string(inner), + Double inner => @double(inner), + Bool inner => @bool(inner), + _ => throw new System::InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class SelectOptionConverter : JsonConverter +{ + public override SelectOption? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new Double(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new Bool(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new System::AggregateException(exceptions); + } + + public override void Write( + Utf8JsonWriter writer, + SelectOption value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + String(var @string) => @string, + Double(var @double) => @double, + Bool(var @bool) => @bool, + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/SelectOptionVariants/All.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/SelectOptionVariants/All.cs new file mode 100644 index 00000000..2e894cad --- /dev/null +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/SelectOptionVariants/All.cs @@ -0,0 +1,31 @@ +namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties.SelectOptionVariants; + +public sealed record class String(string Value) : SelectOption, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Double(double Value) : SelectOption, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Bool(bool Value) : SelectOption, IVariant +{ + public static Bool From(bool value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/Type.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/Type.cs new file mode 100644 index 00000000..d1008752 --- /dev/null +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/Type.cs @@ -0,0 +1,61 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using System = System; + +namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties; + +/// +/// Type of the custom metadata field. +/// +[JsonConverter(typeof(TypeConverter))] +public enum Type +{ + Text, + Textarea, + Number, + Date, + Boolean, + SingleSelect, + MultiSelect, +} + +sealed class TypeConverter : JsonConverter +{ + public override Type Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "Text" => SchemaProperties.Type.Text, + "Textarea" => SchemaProperties.Type.Textarea, + "Number" => SchemaProperties.Type.Number, + "Date" => SchemaProperties.Type.Date, + "Boolean" => SchemaProperties.Type.Boolean, + "SingleSelect" => SchemaProperties.Type.SingleSelect, + "MultiSelect" => SchemaProperties.Type.MultiSelect, + _ => (Type)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + SchemaProperties.Type.Text => "Text", + SchemaProperties.Type.Textarea => "Textarea", + SchemaProperties.Type.Number => "Number", + SchemaProperties.Type.Date => "Date", + SchemaProperties.Type.Boolean => "Boolean", + SchemaProperties.Type.SingleSelect => "SingleSelect", + SchemaProperties.Type.MultiSelect => "MultiSelect", + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldDeleteParams.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldDeleteParams.cs new file mode 100644 index 00000000..ccf4ec98 --- /dev/null +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldDeleteParams.cs @@ -0,0 +1,33 @@ +using System; +using System.Net.Http; + +namespace Imagekit.Models.CustomMetadataFields; + +/// +/// This API deletes a custom metadata field. Even after deleting a custom metadata +/// field, you cannot create any new custom metadata field with the same name. +/// +public sealed record class CustomMetadataFieldDeleteParams : ParamsBase +{ + public required string ID; + + public override Uri Url(IImageKitClient client) + { + return new UriBuilder( + client.BaseUrl.ToString().TrimEnd('/') + + string.Format("/v1/customMetadataFields/{0}", this.ID) + ) + { + Query = this.QueryString(client), + }.Uri; + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldDeleteResponse.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldDeleteResponse.cs new file mode 100644 index 00000000..47473126 --- /dev/null +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldDeleteResponse.cs @@ -0,0 +1,31 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.CustomMetadataFields; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class CustomMetadataFieldDeleteResponse + : ModelBase, + IFromRaw +{ + public override void Validate() { } + + public CustomMetadataFieldDeleteResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + CustomMetadataFieldDeleteResponse(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static CustomMetadataFieldDeleteResponse FromRawUnchecked( + Dictionary properties + ) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldListParams.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldListParams.cs new file mode 100644 index 00000000..72aeee66 --- /dev/null +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldListParams.cs @@ -0,0 +1,51 @@ +using System; +using System.Net.Http; +using System.Text.Json; + +namespace Imagekit.Models.CustomMetadataFields; + +/// +/// This API returns the array of created custom metadata field objects. By default +/// the API returns only non deleted field objects, but you can include deleted fields +/// in the API response. +/// +public sealed record class CustomMetadataFieldListParams : ParamsBase +{ + /// + /// Set it to `true` to include deleted field objects in the API response. + /// + public bool? IncludeDeleted + { + get + { + if (!this.QueryProperties.TryGetValue("includeDeleted", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.QueryProperties["includeDeleted"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override Uri Url(IImageKitClient client) + { + return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/customMetadataFields") + { + Query = this.QueryString(client), + }.Uri; + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/Schema.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/Schema.cs new file mode 100644 index 00000000..c650c1cf --- /dev/null +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/Schema.cs @@ -0,0 +1,240 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using SchemaProperties = Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties; + +namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties; + +/// +/// An object that describes the rules for the custom metadata field value. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class Schema : ModelBase, IFromRaw +{ + /// + /// Type of the custom metadata field. + /// + public required ApiEnum Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The default value for this custom metadata field. Date type of default value + /// depends on the field type. + /// + public SchemaProperties::DefaultValue? DefaultValue + { + get + { + if (!this.Properties.TryGetValue("defaultValue", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["defaultValue"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies if the this custom metadata field is required or not. + /// + public bool? IsValueRequired + { + get + { + if (!this.Properties.TryGetValue("isValueRequired", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["isValueRequired"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. + /// + public double? MaxLength + { + get + { + if (!this.Properties.TryGetValue("maxLength", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["maxLength"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Maximum value of the field. Only set if field type is `Date` or `Number`. + /// For `Date` type field, the value will be in ISO8601 string format. For `Number` + /// type field, it will be a numeric value. + /// + public SchemaProperties::MaxValue? MaxValue + { + get + { + if (!this.Properties.TryGetValue("maxValue", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["maxValue"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. + /// + public double? MinLength + { + get + { + if (!this.Properties.TryGetValue("minLength", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["minLength"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Minimum value of the field. Only set if field type is `Date` or `Number`. + /// For `Date` type field, the value will be in ISO8601 string format. For `Number` + /// type field, it will be a numeric value. + /// + public SchemaProperties::MinValue? MinValue + { + get + { + if (!this.Properties.TryGetValue("minValue", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["minValue"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// An array of allowed values when field type is `SingleSelect` or `MultiSelect`. + /// + public List? SelectOptions + { + get + { + if (!this.Properties.TryGetValue("selectOptions", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["selectOptions"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.Type.Validate(); + this.DefaultValue?.Validate(); + _ = this.IsValueRequired; + _ = this.MaxLength; + this.MaxValue?.Validate(); + _ = this.MinLength; + this.MinValue?.Validate(); + foreach (var item in this.SelectOptions ?? []) + { + item.Validate(); + } + } + + public Schema() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Schema(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Schema FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public Schema(ApiEnum type) + : this() + { + this.Type = type; + } +} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValue.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValue.cs new file mode 100644 index 00000000..d825c283 --- /dev/null +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValue.cs @@ -0,0 +1,175 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties.DefaultValueProperties; +using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties.DefaultValueVariants; +using System = System; + +namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties; + +/// +/// The default value for this custom metadata field. Date type of default value +/// depends on the field type. +/// +[JsonConverter(typeof(DefaultValueConverter))] +public abstract record class DefaultValue +{ + internal DefaultValue() { } + + public static implicit operator DefaultValue(string value) => new String(value); + + public static implicit operator DefaultValue(double value) => new Double(value); + + public static implicit operator DefaultValue(bool value) => new Bool(value); + + public static implicit operator DefaultValue(List value) => + new Mixed(value); + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as String)?.Value; + return value != null; + } + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as Double)?.Value; + return value != null; + } + + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = (this as Bool)?.Value; + return value != null; + } + + public bool TryPickMixed([NotNullWhen(true)] out List? value) + { + value = (this as Mixed)?.Value; + return value != null; + } + + public void Switch( + System::Action @string, + System::Action @double, + System::Action @bool, + System::Action mixed + ) + { + switch (this) + { + case String inner: + @string(inner); + break; + case Double inner: + @double(inner); + break; + case Bool inner: + @bool(inner); + break; + case Mixed inner: + mixed(inner); + break; + default: + throw new System::InvalidOperationException(); + } + } + + public T Match( + System::Func @string, + System::Func @double, + System::Func @bool, + System::Func mixed + ) + { + return this switch + { + String inner => @string(inner), + Double inner => @double(inner), + Bool inner => @bool(inner), + Mixed inner => mixed(inner), + _ => throw new System::InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class DefaultValueConverter : JsonConverter +{ + public override DefaultValue? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new Double(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new Bool(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize>( + ref reader, + options + ); + if (deserialized != null) + { + return new Mixed(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new System::AggregateException(exceptions); + } + + public override void Write( + Utf8JsonWriter writer, + DefaultValue value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + String(var @string) => @string, + Double(var @double) => @double, + Bool(var @bool) => @bool, + Mixed(var mixed) => mixed, + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent0.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent0.cs new file mode 100644 index 00000000..2aa86446 --- /dev/null +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent0.cs @@ -0,0 +1,140 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties.DefaultValueProperties.UnnamedSchemaWithArrayParent0Variants; +using System = System; + +namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties.DefaultValueProperties; + +[JsonConverter(typeof(UnnamedSchemaWithArrayParent0Converter))] +public abstract record class UnnamedSchemaWithArrayParent0 +{ + internal UnnamedSchemaWithArrayParent0() { } + + public static implicit operator UnnamedSchemaWithArrayParent0(string value) => + new String(value); + + public static implicit operator UnnamedSchemaWithArrayParent0(double value) => + new Double(value); + + public static implicit operator UnnamedSchemaWithArrayParent0(bool value) => new Bool(value); + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as String)?.Value; + return value != null; + } + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as Double)?.Value; + return value != null; + } + + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = (this as Bool)?.Value; + return value != null; + } + + public void Switch( + System::Action @string, + System::Action @double, + System::Action @bool + ) + { + switch (this) + { + case String inner: + @string(inner); + break; + case Double inner: + @double(inner); + break; + case Bool inner: + @bool(inner); + break; + default: + throw new System::InvalidOperationException(); + } + } + + public T Match( + System::Func @string, + System::Func @double, + System::Func @bool + ) + { + return this switch + { + String inner => @string(inner), + Double inner => @double(inner), + Bool inner => @bool(inner), + _ => throw new System::InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class UnnamedSchemaWithArrayParent0Converter : JsonConverter +{ + public override UnnamedSchemaWithArrayParent0? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new Double(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new Bool(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new System::AggregateException(exceptions); + } + + public override void Write( + Utf8JsonWriter writer, + UnnamedSchemaWithArrayParent0 value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + String(var @string) => @string, + Double(var @double) => @double, + Bool(var @bool) => @bool, + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent0Variants/All.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent0Variants/All.cs new file mode 100644 index 00000000..30c9b6cb --- /dev/null +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent0Variants/All.cs @@ -0,0 +1,35 @@ +namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties.DefaultValueProperties.UnnamedSchemaWithArrayParent0Variants; + +public sealed record class String(string Value) + : UnnamedSchemaWithArrayParent0, + IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Double(double Value) + : UnnamedSchemaWithArrayParent0, + IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Bool(bool Value) : UnnamedSchemaWithArrayParent0, IVariant +{ + public static Bool From(bool value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValueVariants/All.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValueVariants/All.cs new file mode 100644 index 00000000..2d59b456 --- /dev/null +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValueVariants/All.cs @@ -0,0 +1,50 @@ +using System.Collections.Generic; +using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties.DefaultValueProperties; + +namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties.DefaultValueVariants; + +public sealed record class String(string Value) : DefaultValue, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Double(double Value) : DefaultValue, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Bool(bool Value) : DefaultValue, IVariant +{ + public static Bool From(bool value) + { + return new(value); + } + + public override void Validate() { } +} + +/// +/// Default value should be of type array when custom metadata field type is set to +/// `MultiSelect`. +/// +public sealed record class Mixed(List Value) + : DefaultValue, + IVariant> +{ + public static Mixed From(List value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MaxValue.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MaxValue.cs new file mode 100644 index 00000000..fb8cbefe --- /dev/null +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MaxValue.cs @@ -0,0 +1,109 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties.MaxValueVariants; +using System = System; + +namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties; + +/// +/// Maximum value of the field. Only set if field type is `Date` or `Number`. For +/// `Date` type field, the value will be in ISO8601 string format. For `Number` type +/// field, it will be a numeric value. +/// +[JsonConverter(typeof(MaxValueConverter))] +public abstract record class MaxValue +{ + internal MaxValue() { } + + public static implicit operator MaxValue(string value) => new String(value); + + public static implicit operator MaxValue(double value) => new Double(value); + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as String)?.Value; + return value != null; + } + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as Double)?.Value; + return value != null; + } + + public void Switch(System::Action @string, System::Action @double) + { + switch (this) + { + case String inner: + @string(inner); + break; + case Double inner: + @double(inner); + break; + default: + throw new System::InvalidOperationException(); + } + } + + public T Match(System::Func @string, System::Func @double) + { + return this switch + { + String inner => @string(inner), + Double inner => @double(inner), + _ => throw new System::InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class MaxValueConverter : JsonConverter +{ + public override MaxValue? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new Double(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new System::AggregateException(exceptions); + } + + public override void Write(Utf8JsonWriter writer, MaxValue value, JsonSerializerOptions options) + { + object variant = value switch + { + String(var @string) => @string, + Double(var @double) => @double, + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MaxValueVariants/All.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MaxValueVariants/All.cs new file mode 100644 index 00000000..40dbd110 --- /dev/null +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MaxValueVariants/All.cs @@ -0,0 +1,21 @@ +namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties.MaxValueVariants; + +public sealed record class String(string Value) : MaxValue, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Double(double Value) : MaxValue, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MinValue.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MinValue.cs new file mode 100644 index 00000000..21b6c8a5 --- /dev/null +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MinValue.cs @@ -0,0 +1,109 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties.MinValueVariants; +using System = System; + +namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties; + +/// +/// Minimum value of the field. Only set if field type is `Date` or `Number`. For +/// `Date` type field, the value will be in ISO8601 string format. For `Number` type +/// field, it will be a numeric value. +/// +[JsonConverter(typeof(MinValueConverter))] +public abstract record class MinValue +{ + internal MinValue() { } + + public static implicit operator MinValue(string value) => new String(value); + + public static implicit operator MinValue(double value) => new Double(value); + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as String)?.Value; + return value != null; + } + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as Double)?.Value; + return value != null; + } + + public void Switch(System::Action @string, System::Action @double) + { + switch (this) + { + case String inner: + @string(inner); + break; + case Double inner: + @double(inner); + break; + default: + throw new System::InvalidOperationException(); + } + } + + public T Match(System::Func @string, System::Func @double) + { + return this switch + { + String inner => @string(inner), + Double inner => @double(inner), + _ => throw new System::InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class MinValueConverter : JsonConverter +{ + public override MinValue? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new Double(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new System::AggregateException(exceptions); + } + + public override void Write(Utf8JsonWriter writer, MinValue value, JsonSerializerOptions options) + { + object variant = value switch + { + String(var @string) => @string, + Double(var @double) => @double, + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MinValueVariants/All.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MinValueVariants/All.cs new file mode 100644 index 00000000..6ed3faa4 --- /dev/null +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MinValueVariants/All.cs @@ -0,0 +1,21 @@ +namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties.MinValueVariants; + +public sealed record class String(string Value) : MinValue, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Double(double Value) : MinValue, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/SelectOption.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/SelectOption.cs new file mode 100644 index 00000000..df5e0640 --- /dev/null +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/SelectOption.cs @@ -0,0 +1,138 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties.SelectOptionVariants; +using System = System; + +namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties; + +[JsonConverter(typeof(SelectOptionConverter))] +public abstract record class SelectOption +{ + internal SelectOption() { } + + public static implicit operator SelectOption(string value) => new String(value); + + public static implicit operator SelectOption(double value) => new Double(value); + + public static implicit operator SelectOption(bool value) => new Bool(value); + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as String)?.Value; + return value != null; + } + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as Double)?.Value; + return value != null; + } + + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = (this as Bool)?.Value; + return value != null; + } + + public void Switch( + System::Action @string, + System::Action @double, + System::Action @bool + ) + { + switch (this) + { + case String inner: + @string(inner); + break; + case Double inner: + @double(inner); + break; + case Bool inner: + @bool(inner); + break; + default: + throw new System::InvalidOperationException(); + } + } + + public T Match( + System::Func @string, + System::Func @double, + System::Func @bool + ) + { + return this switch + { + String inner => @string(inner), + Double inner => @double(inner), + Bool inner => @bool(inner), + _ => throw new System::InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class SelectOptionConverter : JsonConverter +{ + public override SelectOption? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new Double(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new Bool(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new System::AggregateException(exceptions); + } + + public override void Write( + Utf8JsonWriter writer, + SelectOption value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + String(var @string) => @string, + Double(var @double) => @double, + Bool(var @bool) => @bool, + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/SelectOptionVariants/All.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/SelectOptionVariants/All.cs new file mode 100644 index 00000000..7127cf34 --- /dev/null +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/SelectOptionVariants/All.cs @@ -0,0 +1,31 @@ +namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties.SelectOptionVariants; + +public sealed record class String(string Value) : SelectOption, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Double(double Value) : SelectOption, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Bool(bool Value) : SelectOption, IVariant +{ + public static Bool From(bool value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/Type.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/Type.cs new file mode 100644 index 00000000..de0b7408 --- /dev/null +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/Type.cs @@ -0,0 +1,61 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using System = System; + +namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties; + +/// +/// Type of the custom metadata field. +/// +[JsonConverter(typeof(TypeConverter))] +public enum Type +{ + Text, + Textarea, + Number, + Date, + Boolean, + SingleSelect, + MultiSelect, +} + +sealed class TypeConverter : JsonConverter +{ + public override Type Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "Text" => SchemaProperties.Type.Text, + "Textarea" => SchemaProperties.Type.Textarea, + "Number" => SchemaProperties.Type.Number, + "Date" => SchemaProperties.Type.Date, + "Boolean" => SchemaProperties.Type.Boolean, + "SingleSelect" => SchemaProperties.Type.SingleSelect, + "MultiSelect" => SchemaProperties.Type.MultiSelect, + _ => (Type)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + SchemaProperties.Type.Text => "Text", + SchemaProperties.Type.Textarea => "Textarea", + SchemaProperties.Type.Number => "Number", + SchemaProperties.Type.Date => "Date", + SchemaProperties.Type.Boolean => "Boolean", + SchemaProperties.Type.SingleSelect => "SingleSelect", + SchemaProperties.Type.MultiSelect => "MultiSelect", + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParams.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParams.cs new file mode 100644 index 00000000..3bfb3f73 --- /dev/null +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParams.cs @@ -0,0 +1,95 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Text; +using System.Text.Json; +using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldUpdateParamsProperties; + +namespace Imagekit.Models.CustomMetadataFields; + +/// +/// This API updates the label or schema of an existing custom metadata field. +/// +public sealed record class CustomMetadataFieldUpdateParams : ParamsBase +{ + public Dictionary BodyProperties { get; set; } = []; + + public required string ID; + + /// + /// Human readable name of the custom metadata field. This should be unique across + /// all non deleted custom metadata fields. This name is displayed as form field + /// label to the users while setting field value on an asset in the media library + /// UI. This parameter is required if `schema` is not provided. + /// + public string? Label + { + get + { + if (!this.BodyProperties.TryGetValue("label", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["label"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// An object that describes the rules for the custom metadata key. This parameter + /// is required if `label` is not provided. Note: `type` cannot be updated and + /// will be ignored if sent with the `schema`. The schema will be validated as + /// per the existing `type`. + /// + public Schema? Schema + { + get + { + if (!this.BodyProperties.TryGetValue("schema", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["schema"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override Uri Url(IImageKitClient client) + { + return new UriBuilder( + client.BaseUrl.ToString().TrimEnd('/') + + string.Format("/v1/customMetadataFields/{0}", this.ID) + ) + { + Query = this.QueryString(client), + }.Uri; + } + + public StringContent BodyContent() + { + return new( + JsonSerializer.Serialize(this.BodyProperties), + Encoding.UTF8, + "application/json" + ); + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/Schema.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/Schema.cs new file mode 100644 index 00000000..634ff465 --- /dev/null +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/Schema.cs @@ -0,0 +1,207 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldUpdateParamsProperties.SchemaProperties; + +namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldUpdateParamsProperties; + +/// +/// An object that describes the rules for the custom metadata key. This parameter +/// is required if `label` is not provided. Note: `type` cannot be updated and will +/// be ignored if sent with the `schema`. The schema will be validated as per the +/// existing `type`. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class Schema : ModelBase, IFromRaw +{ + /// + /// The default value for this custom metadata field. This property is only required + /// if `isValueRequired` property is set to `true`. The value should match the + /// `type` of custom metadata field. + /// + public DefaultValue? DefaultValue + { + get + { + if (!this.Properties.TryGetValue("defaultValue", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["defaultValue"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Sets this custom metadata field as required. Setting custom metadata fields + /// on an asset will throw error if the value for all required fields are not + /// present in upload or update asset API request body. + /// + public bool? IsValueRequired + { + get + { + if (!this.Properties.TryGetValue("isValueRequired", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["isValueRequired"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Maximum length of string. Only set this property if `type` is set to `Text` + /// or `Textarea`. + /// + public double? MaxLength + { + get + { + if (!this.Properties.TryGetValue("maxLength", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["maxLength"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Maximum value of the field. Only set this property if field type is `Date` + /// or `Number`. For `Date` type field, set the minimum date in ISO8601 string + /// format. For `Number` type field, set the minimum numeric value. + /// + public MaxValue? MaxValue + { + get + { + if (!this.Properties.TryGetValue("maxValue", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["maxValue"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Minimum length of string. Only set this property if `type` is set to `Text` + /// or `Textarea`. + /// + public double? MinLength + { + get + { + if (!this.Properties.TryGetValue("minLength", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["minLength"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Minimum value of the field. Only set this property if field type is `Date` + /// or `Number`. For `Date` type field, set the minimum date in ISO8601 string + /// format. For `Number` type field, set the minimum numeric value. + /// + public MinValue? MinValue + { + get + { + if (!this.Properties.TryGetValue("minValue", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["minValue"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// An array of allowed values. This property is only required if `type` property + /// is set to `SingleSelect` or `MultiSelect`. + /// + public List? SelectOptions + { + get + { + if (!this.Properties.TryGetValue("selectOptions", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["selectOptions"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.DefaultValue?.Validate(); + _ = this.IsValueRequired; + _ = this.MaxLength; + this.MaxValue?.Validate(); + _ = this.MinLength; + this.MinValue?.Validate(); + foreach (var item in this.SelectOptions ?? []) + { + item.Validate(); + } + } + + public Schema() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Schema(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Schema FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValue.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValue.cs new file mode 100644 index 00000000..d806401a --- /dev/null +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValue.cs @@ -0,0 +1,183 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldUpdateParamsProperties.SchemaProperties.DefaultValueProperties; +using DefaultValueVariants = Imagekit.Models.CustomMetadataFields.CustomMetadataFieldUpdateParamsProperties.SchemaProperties.DefaultValueVariants; + +namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldUpdateParamsProperties.SchemaProperties; + +/// +/// The default value for this custom metadata field. This property is only required +/// if `isValueRequired` property is set to `true`. The value should match the `type` +/// of custom metadata field. +/// +[JsonConverter(typeof(DefaultValueConverter))] +public abstract record class DefaultValue +{ + internal DefaultValue() { } + + public static implicit operator DefaultValue(string value) => + new DefaultValueVariants::String(value); + + public static implicit operator DefaultValue(double value) => + new DefaultValueVariants::Double(value); + + public static implicit operator DefaultValue(bool value) => + new DefaultValueVariants::Bool(value); + + public static implicit operator DefaultValue(List value) => + new DefaultValueVariants::Mixed(value); + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as DefaultValueVariants::String)?.Value; + return value != null; + } + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as DefaultValueVariants::Double)?.Value; + return value != null; + } + + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = (this as DefaultValueVariants::Bool)?.Value; + return value != null; + } + + public bool TryPickMixed([NotNullWhen(true)] out List? value) + { + value = (this as DefaultValueVariants::Mixed)?.Value; + return value != null; + } + + public void Switch( + Action @string, + Action @double, + Action @bool, + Action mixed + ) + { + switch (this) + { + case DefaultValueVariants::String inner: + @string(inner); + break; + case DefaultValueVariants::Double inner: + @double(inner); + break; + case DefaultValueVariants::Bool inner: + @bool(inner); + break; + case DefaultValueVariants::Mixed inner: + mixed(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func @string, + Func @double, + Func @bool, + Func mixed + ) + { + return this switch + { + DefaultValueVariants::String inner => @string(inner), + DefaultValueVariants::Double inner => @double(inner), + DefaultValueVariants::Bool inner => @bool(inner), + DefaultValueVariants::Mixed inner => mixed(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class DefaultValueConverter : JsonConverter +{ + public override DefaultValue? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new DefaultValueVariants::String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new DefaultValueVariants::Double( + JsonSerializer.Deserialize(ref reader, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new DefaultValueVariants::Bool( + JsonSerializer.Deserialize(ref reader, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize>( + ref reader, + options + ); + if (deserialized != null) + { + return new DefaultValueVariants::Mixed(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + + public override void Write( + Utf8JsonWriter writer, + DefaultValue value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + DefaultValueVariants::String(var @string) => @string, + DefaultValueVariants::Double(var @double) => @double, + DefaultValueVariants::Bool(var @bool) => @bool, + DefaultValueVariants::Mixed(var mixed) => mixed, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent2.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent2.cs new file mode 100644 index 00000000..2534e6a3 --- /dev/null +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent2.cs @@ -0,0 +1,145 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using UnnamedSchemaWithArrayParent2Variants = Imagekit.Models.CustomMetadataFields.CustomMetadataFieldUpdateParamsProperties.SchemaProperties.DefaultValueProperties.UnnamedSchemaWithArrayParent2Variants; + +namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldUpdateParamsProperties.SchemaProperties.DefaultValueProperties; + +[JsonConverter(typeof(UnnamedSchemaWithArrayParent2Converter))] +public abstract record class UnnamedSchemaWithArrayParent2 +{ + internal UnnamedSchemaWithArrayParent2() { } + + public static implicit operator UnnamedSchemaWithArrayParent2(string value) => + new UnnamedSchemaWithArrayParent2Variants::String(value); + + public static implicit operator UnnamedSchemaWithArrayParent2(double value) => + new UnnamedSchemaWithArrayParent2Variants::Double(value); + + public static implicit operator UnnamedSchemaWithArrayParent2(bool value) => + new UnnamedSchemaWithArrayParent2Variants::Bool(value); + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as UnnamedSchemaWithArrayParent2Variants::String)?.Value; + return value != null; + } + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as UnnamedSchemaWithArrayParent2Variants::Double)?.Value; + return value != null; + } + + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = (this as UnnamedSchemaWithArrayParent2Variants::Bool)?.Value; + return value != null; + } + + public void Switch( + Action @string, + Action @double, + Action @bool + ) + { + switch (this) + { + case UnnamedSchemaWithArrayParent2Variants::String inner: + @string(inner); + break; + case UnnamedSchemaWithArrayParent2Variants::Double inner: + @double(inner); + break; + case UnnamedSchemaWithArrayParent2Variants::Bool inner: + @bool(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func @string, + Func @double, + Func @bool + ) + { + return this switch + { + UnnamedSchemaWithArrayParent2Variants::String inner => @string(inner), + UnnamedSchemaWithArrayParent2Variants::Double inner => @double(inner), + UnnamedSchemaWithArrayParent2Variants::Bool inner => @bool(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class UnnamedSchemaWithArrayParent2Converter : JsonConverter +{ + public override UnnamedSchemaWithArrayParent2? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new UnnamedSchemaWithArrayParent2Variants::String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new UnnamedSchemaWithArrayParent2Variants::Double( + JsonSerializer.Deserialize(ref reader, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new UnnamedSchemaWithArrayParent2Variants::Bool( + JsonSerializer.Deserialize(ref reader, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + + public override void Write( + Utf8JsonWriter writer, + UnnamedSchemaWithArrayParent2 value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + UnnamedSchemaWithArrayParent2Variants::String(var @string) => @string, + UnnamedSchemaWithArrayParent2Variants::Double(var @double) => @double, + UnnamedSchemaWithArrayParent2Variants::Bool(var @bool) => @bool, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent2Variants/All.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent2Variants/All.cs new file mode 100644 index 00000000..9907932a --- /dev/null +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent2Variants/All.cs @@ -0,0 +1,35 @@ +namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldUpdateParamsProperties.SchemaProperties.DefaultValueProperties.UnnamedSchemaWithArrayParent2Variants; + +public sealed record class String(string Value) + : UnnamedSchemaWithArrayParent2, + IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Double(double Value) + : UnnamedSchemaWithArrayParent2, + IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Bool(bool Value) : UnnamedSchemaWithArrayParent2, IVariant +{ + public static Bool From(bool value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValueVariants/All.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValueVariants/All.cs new file mode 100644 index 00000000..0dec8fad --- /dev/null +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValueVariants/All.cs @@ -0,0 +1,50 @@ +using System.Collections.Generic; +using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldUpdateParamsProperties.SchemaProperties.DefaultValueProperties; + +namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldUpdateParamsProperties.SchemaProperties.DefaultValueVariants; + +public sealed record class String(string Value) : DefaultValue, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Double(double Value) : DefaultValue, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Bool(bool Value) : DefaultValue, IVariant +{ + public static Bool From(bool value) + { + return new(value); + } + + public override void Validate() { } +} + +/// +/// Default value should be of type array when custom metadata field type is set to +/// `MultiSelect`. +/// +public sealed record class Mixed(List Value) + : DefaultValue, + IVariant> +{ + public static Mixed From(List value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MaxValue.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MaxValue.cs new file mode 100644 index 00000000..362c3574 --- /dev/null +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MaxValue.cs @@ -0,0 +1,117 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using MaxValueVariants = Imagekit.Models.CustomMetadataFields.CustomMetadataFieldUpdateParamsProperties.SchemaProperties.MaxValueVariants; + +namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldUpdateParamsProperties.SchemaProperties; + +/// +/// Maximum value of the field. Only set this property if field type is `Date` or +/// `Number`. For `Date` type field, set the minimum date in ISO8601 string format. +/// For `Number` type field, set the minimum numeric value. +/// +[JsonConverter(typeof(MaxValueConverter))] +public abstract record class MaxValue +{ + internal MaxValue() { } + + public static implicit operator MaxValue(string value) => new MaxValueVariants::String(value); + + public static implicit operator MaxValue(double value) => new MaxValueVariants::Double(value); + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as MaxValueVariants::String)?.Value; + return value != null; + } + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as MaxValueVariants::Double)?.Value; + return value != null; + } + + public void Switch( + Action @string, + Action @double + ) + { + switch (this) + { + case MaxValueVariants::String inner: + @string(inner); + break; + case MaxValueVariants::Double inner: + @double(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func @string, + Func @double + ) + { + return this switch + { + MaxValueVariants::String inner => @string(inner), + MaxValueVariants::Double inner => @double(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class MaxValueConverter : JsonConverter +{ + public override MaxValue? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new MaxValueVariants::String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new MaxValueVariants::Double( + JsonSerializer.Deserialize(ref reader, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + + public override void Write(Utf8JsonWriter writer, MaxValue value, JsonSerializerOptions options) + { + object variant = value switch + { + MaxValueVariants::String(var @string) => @string, + MaxValueVariants::Double(var @double) => @double, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MaxValueVariants/All.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MaxValueVariants/All.cs new file mode 100644 index 00000000..77dc33f7 --- /dev/null +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MaxValueVariants/All.cs @@ -0,0 +1,21 @@ +namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldUpdateParamsProperties.SchemaProperties.MaxValueVariants; + +public sealed record class String(string Value) : MaxValue, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Double(double Value) : MaxValue, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MinValue.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MinValue.cs new file mode 100644 index 00000000..7ab361fc --- /dev/null +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MinValue.cs @@ -0,0 +1,117 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using MinValueVariants = Imagekit.Models.CustomMetadataFields.CustomMetadataFieldUpdateParamsProperties.SchemaProperties.MinValueVariants; + +namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldUpdateParamsProperties.SchemaProperties; + +/// +/// Minimum value of the field. Only set this property if field type is `Date` or +/// `Number`. For `Date` type field, set the minimum date in ISO8601 string format. +/// For `Number` type field, set the minimum numeric value. +/// +[JsonConverter(typeof(MinValueConverter))] +public abstract record class MinValue +{ + internal MinValue() { } + + public static implicit operator MinValue(string value) => new MinValueVariants::String(value); + + public static implicit operator MinValue(double value) => new MinValueVariants::Double(value); + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as MinValueVariants::String)?.Value; + return value != null; + } + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as MinValueVariants::Double)?.Value; + return value != null; + } + + public void Switch( + Action @string, + Action @double + ) + { + switch (this) + { + case MinValueVariants::String inner: + @string(inner); + break; + case MinValueVariants::Double inner: + @double(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func @string, + Func @double + ) + { + return this switch + { + MinValueVariants::String inner => @string(inner), + MinValueVariants::Double inner => @double(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class MinValueConverter : JsonConverter +{ + public override MinValue? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new MinValueVariants::String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new MinValueVariants::Double( + JsonSerializer.Deserialize(ref reader, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + + public override void Write(Utf8JsonWriter writer, MinValue value, JsonSerializerOptions options) + { + object variant = value switch + { + MinValueVariants::String(var @string) => @string, + MinValueVariants::Double(var @double) => @double, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MinValueVariants/All.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MinValueVariants/All.cs new file mode 100644 index 00000000..c0acd9c9 --- /dev/null +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MinValueVariants/All.cs @@ -0,0 +1,21 @@ +namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldUpdateParamsProperties.SchemaProperties.MinValueVariants; + +public sealed record class String(string Value) : MinValue, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Double(double Value) : MinValue, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/SelectOption.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/SelectOption.cs new file mode 100644 index 00000000..172d2d2f --- /dev/null +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/SelectOption.cs @@ -0,0 +1,145 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using SelectOptionVariants = Imagekit.Models.CustomMetadataFields.CustomMetadataFieldUpdateParamsProperties.SchemaProperties.SelectOptionVariants; + +namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldUpdateParamsProperties.SchemaProperties; + +[JsonConverter(typeof(SelectOptionConverter))] +public abstract record class SelectOption +{ + internal SelectOption() { } + + public static implicit operator SelectOption(string value) => + new SelectOptionVariants::String(value); + + public static implicit operator SelectOption(double value) => + new SelectOptionVariants::Double(value); + + public static implicit operator SelectOption(bool value) => + new SelectOptionVariants::Bool(value); + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as SelectOptionVariants::String)?.Value; + return value != null; + } + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as SelectOptionVariants::Double)?.Value; + return value != null; + } + + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = (this as SelectOptionVariants::Bool)?.Value; + return value != null; + } + + public void Switch( + Action @string, + Action @double, + Action @bool + ) + { + switch (this) + { + case SelectOptionVariants::String inner: + @string(inner); + break; + case SelectOptionVariants::Double inner: + @double(inner); + break; + case SelectOptionVariants::Bool inner: + @bool(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func @string, + Func @double, + Func @bool + ) + { + return this switch + { + SelectOptionVariants::String inner => @string(inner), + SelectOptionVariants::Double inner => @double(inner), + SelectOptionVariants::Bool inner => @bool(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class SelectOptionConverter : JsonConverter +{ + public override SelectOption? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new SelectOptionVariants::String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new SelectOptionVariants::Double( + JsonSerializer.Deserialize(ref reader, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new SelectOptionVariants::Bool( + JsonSerializer.Deserialize(ref reader, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + + public override void Write( + Utf8JsonWriter writer, + SelectOption value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + SelectOptionVariants::String(var @string) => @string, + SelectOptionVariants::Double(var @double) => @double, + SelectOptionVariants::Bool(var @bool) => @bool, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/SelectOptionVariants/All.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/SelectOptionVariants/All.cs new file mode 100644 index 00000000..419bfb5c --- /dev/null +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/SelectOptionVariants/All.cs @@ -0,0 +1,31 @@ +namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldUpdateParamsProperties.SchemaProperties.SelectOptionVariants; + +public sealed record class String(string Value) : SelectOption, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Double(double Value) : SelectOption, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Bool(bool Value) : SelectOption, IVariant +{ + public static Bool From(bool value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/Files/Bulk/BulkAddTagsParams.cs b/src/Imagekit/Models/Files/Bulk/BulkAddTagsParams.cs new file mode 100644 index 00000000..6cd055a9 --- /dev/null +++ b/src/Imagekit/Models/Files/Bulk/BulkAddTagsParams.cs @@ -0,0 +1,86 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Text; +using System.Text.Json; + +namespace Imagekit.Models.Files.Bulk; + +/// +/// This API adds tags to multiple files in bulk. A maximum of 50 files can be specified +/// at a time. +/// +public sealed record class BulkAddTagsParams : ParamsBase +{ + public Dictionary BodyProperties { get; set; } = []; + + /// + /// An array of fileIds to which you want to add tags. + /// + public required List FileIDs + { + get + { + if (!this.BodyProperties.TryGetValue("fileIds", out JsonElement element)) + throw new ArgumentOutOfRangeException("fileIds", "Missing required argument"); + + return JsonSerializer.Deserialize>(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("fileIds"); + } + set + { + this.BodyProperties["fileIds"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// An array of tags that you want to add to the files. + /// + public required List Tags + { + get + { + if (!this.BodyProperties.TryGetValue("tags", out JsonElement element)) + throw new ArgumentOutOfRangeException("tags", "Missing required argument"); + + return JsonSerializer.Deserialize>(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("tags"); + } + set + { + this.BodyProperties["tags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override Uri Url(IImageKitClient client) + { + return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/files/addTags") + { + Query = this.QueryString(client), + }.Uri; + } + + public StringContent BodyContent() + { + return new( + JsonSerializer.Serialize(this.BodyProperties), + Encoding.UTF8, + "application/json" + ); + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/Files/Bulk/BulkAddTagsResponse.cs b/src/Imagekit/Models/Files/Bulk/BulkAddTagsResponse.cs new file mode 100644 index 00000000..c346fd8b --- /dev/null +++ b/src/Imagekit/Models/Files/Bulk/BulkAddTagsResponse.cs @@ -0,0 +1,54 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.Bulk; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class BulkAddTagsResponse : ModelBase, IFromRaw +{ + /// + /// An array of fileIds that in which tags were successfully added. + /// + public List? SuccessfullyUpdatedFileIDs + { + get + { + if (!this.Properties.TryGetValue("successfullyUpdatedFileIds", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["successfullyUpdatedFileIds"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + foreach (var item in this.SuccessfullyUpdatedFileIDs ?? []) + { + _ = item; + } + } + + public BulkAddTagsResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + BulkAddTagsResponse(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static BulkAddTagsResponse FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/Bulk/BulkDeleteParams.cs b/src/Imagekit/Models/Files/Bulk/BulkDeleteParams.cs new file mode 100644 index 00000000..abca4e63 --- /dev/null +++ b/src/Imagekit/Models/Files/Bulk/BulkDeleteParams.cs @@ -0,0 +1,71 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Text; +using System.Text.Json; + +namespace Imagekit.Models.Files.Bulk; + +/// +/// This API deletes multiple files and all their file versions permanently. +/// +/// Note: If a file or specific transformation has been requested in the past, then +/// the response is cached. Deleting a file does not purge the cache. You can purge +/// the cache using purge cache API. +/// +/// A maximum of 100 files can be deleted at a time. +/// +public sealed record class BulkDeleteParams : ParamsBase +{ + public Dictionary BodyProperties { get; set; } = []; + + /// + /// An array of fileIds which you want to delete. + /// + public required List FileIDs + { + get + { + if (!this.BodyProperties.TryGetValue("fileIds", out JsonElement element)) + throw new ArgumentOutOfRangeException("fileIds", "Missing required argument"); + + return JsonSerializer.Deserialize>(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("fileIds"); + } + set + { + this.BodyProperties["fileIds"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override Uri Url(IImageKitClient client) + { + return new UriBuilder( + client.BaseUrl.ToString().TrimEnd('/') + "/v1/files/batch/deleteByFileIds" + ) + { + Query = this.QueryString(client), + }.Uri; + } + + public StringContent BodyContent() + { + return new( + JsonSerializer.Serialize(this.BodyProperties), + Encoding.UTF8, + "application/json" + ); + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/Files/Bulk/BulkDeleteResponse.cs b/src/Imagekit/Models/Files/Bulk/BulkDeleteResponse.cs new file mode 100644 index 00000000..e62d675a --- /dev/null +++ b/src/Imagekit/Models/Files/Bulk/BulkDeleteResponse.cs @@ -0,0 +1,54 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.Bulk; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class BulkDeleteResponse : ModelBase, IFromRaw +{ + /// + /// An array of fileIds that were successfully deleted. + /// + public List? SuccessfullyDeletedFileIDs + { + get + { + if (!this.Properties.TryGetValue("successfullyDeletedFileIds", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["successfullyDeletedFileIds"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + foreach (var item in this.SuccessfullyDeletedFileIDs ?? []) + { + _ = item; + } + } + + public BulkDeleteResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + BulkDeleteResponse(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static BulkDeleteResponse FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/Bulk/BulkRemoveAITagsParams.cs b/src/Imagekit/Models/Files/Bulk/BulkRemoveAITagsParams.cs new file mode 100644 index 00000000..358f851d --- /dev/null +++ b/src/Imagekit/Models/Files/Bulk/BulkRemoveAITagsParams.cs @@ -0,0 +1,86 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Text; +using System.Text.Json; + +namespace Imagekit.Models.Files.Bulk; + +/// +/// This API removes AITags from multiple files in bulk. A maximum of 50 files can +/// be specified at a time. +/// +public sealed record class BulkRemoveAITagsParams : ParamsBase +{ + public Dictionary BodyProperties { get; set; } = []; + + /// + /// An array of AITags that you want to remove from the files. + /// + public required List AITags + { + get + { + if (!this.BodyProperties.TryGetValue("AITags", out JsonElement element)) + throw new ArgumentOutOfRangeException("AITags", "Missing required argument"); + + return JsonSerializer.Deserialize>(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("AITags"); + } + set + { + this.BodyProperties["AITags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// An array of fileIds from which you want to remove AITags. + /// + public required List FileIDs + { + get + { + if (!this.BodyProperties.TryGetValue("fileIds", out JsonElement element)) + throw new ArgumentOutOfRangeException("fileIds", "Missing required argument"); + + return JsonSerializer.Deserialize>(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("fileIds"); + } + set + { + this.BodyProperties["fileIds"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override Uri Url(IImageKitClient client) + { + return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/files/removeAITags") + { + Query = this.QueryString(client), + }.Uri; + } + + public StringContent BodyContent() + { + return new( + JsonSerializer.Serialize(this.BodyProperties), + Encoding.UTF8, + "application/json" + ); + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/Files/Bulk/BulkRemoveAITagsResponse.cs b/src/Imagekit/Models/Files/Bulk/BulkRemoveAITagsResponse.cs new file mode 100644 index 00000000..8eb52d35 --- /dev/null +++ b/src/Imagekit/Models/Files/Bulk/BulkRemoveAITagsResponse.cs @@ -0,0 +1,56 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.Bulk; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class BulkRemoveAITagsResponse : ModelBase, IFromRaw +{ + /// + /// An array of fileIds that in which AITags were successfully removed. + /// + public List? SuccessfullyUpdatedFileIDs + { + get + { + if (!this.Properties.TryGetValue("successfullyUpdatedFileIds", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["successfullyUpdatedFileIds"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + foreach (var item in this.SuccessfullyUpdatedFileIDs ?? []) + { + _ = item; + } + } + + public BulkRemoveAITagsResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + BulkRemoveAITagsResponse(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static BulkRemoveAITagsResponse FromRawUnchecked( + Dictionary properties + ) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/Bulk/BulkRemoveTagsParams.cs b/src/Imagekit/Models/Files/Bulk/BulkRemoveTagsParams.cs new file mode 100644 index 00000000..db0b9eff --- /dev/null +++ b/src/Imagekit/Models/Files/Bulk/BulkRemoveTagsParams.cs @@ -0,0 +1,86 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Text; +using System.Text.Json; + +namespace Imagekit.Models.Files.Bulk; + +/// +/// This API removes tags from multiple files in bulk. A maximum of 50 files can +/// be specified at a time. +/// +public sealed record class BulkRemoveTagsParams : ParamsBase +{ + public Dictionary BodyProperties { get; set; } = []; + + /// + /// An array of fileIds from which you want to remove tags. + /// + public required List FileIDs + { + get + { + if (!this.BodyProperties.TryGetValue("fileIds", out JsonElement element)) + throw new ArgumentOutOfRangeException("fileIds", "Missing required argument"); + + return JsonSerializer.Deserialize>(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("fileIds"); + } + set + { + this.BodyProperties["fileIds"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// An array of tags that you want to remove from the files. + /// + public required List Tags + { + get + { + if (!this.BodyProperties.TryGetValue("tags", out JsonElement element)) + throw new ArgumentOutOfRangeException("tags", "Missing required argument"); + + return JsonSerializer.Deserialize>(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("tags"); + } + set + { + this.BodyProperties["tags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override Uri Url(IImageKitClient client) + { + return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/files/removeTags") + { + Query = this.QueryString(client), + }.Uri; + } + + public StringContent BodyContent() + { + return new( + JsonSerializer.Serialize(this.BodyProperties), + Encoding.UTF8, + "application/json" + ); + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/Files/Bulk/BulkRemoveTagsResponse.cs b/src/Imagekit/Models/Files/Bulk/BulkRemoveTagsResponse.cs new file mode 100644 index 00000000..453899cb --- /dev/null +++ b/src/Imagekit/Models/Files/Bulk/BulkRemoveTagsResponse.cs @@ -0,0 +1,56 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.Bulk; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class BulkRemoveTagsResponse : ModelBase, IFromRaw +{ + /// + /// An array of fileIds that in which tags were successfully removed. + /// + public List? SuccessfullyUpdatedFileIDs + { + get + { + if (!this.Properties.TryGetValue("successfullyUpdatedFileIds", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["successfullyUpdatedFileIds"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + foreach (var item in this.SuccessfullyUpdatedFileIDs ?? []) + { + _ = item; + } + } + + public BulkRemoveTagsResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + BulkRemoveTagsResponse(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static BulkRemoveTagsResponse FromRawUnchecked( + Dictionary properties + ) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/File.cs b/src/Imagekit/Models/Files/File.cs new file mode 100644 index 00000000..0840cb97 --- /dev/null +++ b/src/Imagekit/Models/Files/File.cs @@ -0,0 +1,550 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using FileProperties = Imagekit.Models.Files.FileProperties; + +namespace Imagekit.Models.Files; + +/// +/// Object containing details of a file or file version. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class File : ModelBase, IFromRaw +{ + /// + /// An array of tags assigned to the file by auto tagging. + /// + public List? AITags + { + get + { + if (!this.Properties.TryGetValue("AITags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["AITags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Date and time when the file was uploaded. The date and time is in ISO8601 + /// format. + /// + public DateTime? CreatedAt + { + get + { + if (!this.Properties.TryGetValue("createdAt", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["createdAt"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// An string with custom coordinates of the file. + /// + public string? CustomCoordinates + { + get + { + if (!this.Properties.TryGetValue("customCoordinates", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["customCoordinates"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// An object with custom metadata for the file. + /// + public Dictionary? CustomMetadata + { + get + { + if (!this.Properties.TryGetValue("customMetadata", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["customMetadata"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Optional text to describe the contents of the file. Can be set by the user + /// or the ai-auto-description extension. + /// + public string? Description + { + get + { + if (!this.Properties.TryGetValue("description", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["description"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Unique identifier of the asset. + /// + public string? FileID + { + get + { + if (!this.Properties.TryGetValue("fileId", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["fileId"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Path of the file. This is the path you would use in the URL to access the + /// file. For example, if the file is at the root of the media library, the path + /// will be `/file.jpg`. If the file is inside a folder named `images`, the path + /// will be `/images/file.jpg`. + /// + public string? FilePath + { + get + { + if (!this.Properties.TryGetValue("filePath", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["filePath"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Type of the file. Possible values are `image`, `non-image`. + /// + public string? FileType + { + get + { + if (!this.Properties.TryGetValue("fileType", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["fileType"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies if the image has an alpha channel. + /// + public bool? HasAlpha + { + get + { + if (!this.Properties.TryGetValue("hasAlpha", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["hasAlpha"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Height of the file. + /// + public double? Height + { + get + { + if (!this.Properties.TryGetValue("height", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["height"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies if the file is private or not. + /// + public bool? IsPrivateFile + { + get + { + if (!this.Properties.TryGetValue("isPrivateFile", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["isPrivateFile"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies if the file is published or not. + /// + public bool? IsPublished + { + get + { + if (!this.Properties.TryGetValue("isPublished", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["isPublished"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// MIME type of the file. + /// + public string? Mime + { + get + { + if (!this.Properties.TryGetValue("mime", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["mime"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Name of the asset. + /// + public string? Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Size of the file in bytes. + /// + public double? Size + { + get + { + if (!this.Properties.TryGetValue("size", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["size"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// An array of tags assigned to the file. Tags are used to search files in the + /// media library. + /// + public List? Tags + { + get + { + if (!this.Properties.TryGetValue("tags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["tags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// URL of the thumbnail image. This URL is used to access the thumbnail image + /// of the file in the media library. + /// + public string? Thumbnail + { + get + { + if (!this.Properties.TryGetValue("thumbnail", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["thumbnail"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Type of the asset. + /// + public ApiEnum? Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Date and time when the file was last updated. The date and time is in ISO8601 + /// format. + /// + public DateTime? UpdatedAt + { + get + { + if (!this.Properties.TryGetValue("updatedAt", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["updatedAt"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// URL of the file. + /// + public string? URL + { + get + { + if (!this.Properties.TryGetValue("url", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["url"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// An object with details of the file version. + /// + public FileProperties::VersionInfo? VersionInfo + { + get + { + if (!this.Properties.TryGetValue("versionInfo", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["versionInfo"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Width of the file. + /// + public double? Width + { + get + { + if (!this.Properties.TryGetValue("width", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["width"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + foreach (var item in this.AITags ?? []) + { + item.Validate(); + } + _ = this.CreatedAt; + _ = this.CustomCoordinates; + if (this.CustomMetadata != null) + { + foreach (var item in this.CustomMetadata.Values) + { + _ = item; + } + } + _ = this.Description; + _ = this.FileID; + _ = this.FilePath; + _ = this.FileType; + _ = this.HasAlpha; + _ = this.Height; + _ = this.IsPrivateFile; + _ = this.IsPublished; + _ = this.Mime; + _ = this.Name; + _ = this.Size; + foreach (var item in this.Tags ?? []) + { + _ = item; + } + _ = this.Thumbnail; + this.Type?.Validate(); + _ = this.UpdatedAt; + _ = this.URL; + this.VersionInfo?.Validate(); + _ = this.Width; + } + + public File() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + File(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static File FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/FileCopyParams.cs b/src/Imagekit/Models/Files/FileCopyParams.cs new file mode 100644 index 00000000..0dc5ca78 --- /dev/null +++ b/src/Imagekit/Models/Files/FileCopyParams.cs @@ -0,0 +1,118 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Text; +using System.Text.Json; + +namespace Imagekit.Models.Files; + +/// +/// This will copy a file from one folder to another. +/// +/// Note: If any file at the destination has the same name as the source file, then +/// the source file and its versions (if `includeFileVersions` is set to true) will +/// be appended to the destination file version history. +/// +public sealed record class FileCopyParams : ParamsBase +{ + public Dictionary BodyProperties { get; set; } = []; + + /// + /// Full path to the folder you want to copy the above file into. + /// + public required string DestinationPath + { + get + { + if (!this.BodyProperties.TryGetValue("destinationPath", out JsonElement element)) + throw new ArgumentOutOfRangeException( + "destinationPath", + "Missing required argument" + ); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("destinationPath"); + } + set + { + this.BodyProperties["destinationPath"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The full path of the file you want to copy. + /// + public required string SourceFilePath + { + get + { + if (!this.BodyProperties.TryGetValue("sourceFilePath", out JsonElement element)) + throw new ArgumentOutOfRangeException( + "sourceFilePath", + "Missing required argument" + ); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("sourceFilePath"); + } + set + { + this.BodyProperties["sourceFilePath"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Option to copy all versions of a file. By default, only the current version + /// of the file is copied. When set to true, all versions of the file will be + /// copied. Default value - `false`. + /// + public bool? IncludeFileVersions + { + get + { + if (!this.BodyProperties.TryGetValue("includeFileVersions", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["includeFileVersions"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override Uri Url(IImageKitClient client) + { + return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/files/copy") + { + Query = this.QueryString(client), + }.Uri; + } + + public StringContent BodyContent() + { + return new( + JsonSerializer.Serialize(this.BodyProperties), + Encoding.UTF8, + "application/json" + ); + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/Files/FileCopyResponse.cs b/src/Imagekit/Models/Files/FileCopyResponse.cs new file mode 100644 index 00000000..bac4ecbb --- /dev/null +++ b/src/Imagekit/Models/Files/FileCopyResponse.cs @@ -0,0 +1,27 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class FileCopyResponse : ModelBase, IFromRaw +{ + public override void Validate() { } + + public FileCopyResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FileCopyResponse(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static FileCopyResponse FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/FileDeleteParams.cs b/src/Imagekit/Models/Files/FileDeleteParams.cs new file mode 100644 index 00000000..aac0dab1 --- /dev/null +++ b/src/Imagekit/Models/Files/FileDeleteParams.cs @@ -0,0 +1,35 @@ +using System; +using System.Net.Http; + +namespace Imagekit.Models.Files; + +/// +/// This API deletes the file and all its file versions permanently. +/// +/// Note: If a file or specific transformation has been requested in the past, then +/// the response is cached. Deleting a file does not purge the cache. You can purge +/// the cache using purge cache API. +/// +public sealed record class FileDeleteParams : ParamsBase +{ + public required string FileID; + + public override Uri Url(IImageKitClient client) + { + return new UriBuilder( + client.BaseUrl.ToString().TrimEnd('/') + string.Format("/v1/files/{0}", this.FileID) + ) + { + Query = this.QueryString(client), + }.Uri; + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/Files/FileGetParams.cs b/src/Imagekit/Models/Files/FileGetParams.cs new file mode 100644 index 00000000..5f8dbc1a --- /dev/null +++ b/src/Imagekit/Models/Files/FileGetParams.cs @@ -0,0 +1,33 @@ +using System; +using System.Net.Http; + +namespace Imagekit.Models.Files; + +/// +/// This API returns an object with details or attributes about the current version +/// of the file. +/// +public sealed record class FileGetParams : ParamsBase +{ + public required string FileID; + + public override Uri Url(IImageKitClient client) + { + return new UriBuilder( + client.BaseUrl.ToString().TrimEnd('/') + + string.Format("/v1/files/{0}/details", this.FileID) + ) + { + Query = this.QueryString(client), + }.Uri; + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/Files/FileMoveParams.cs b/src/Imagekit/Models/Files/FileMoveParams.cs new file mode 100644 index 00000000..66cc32b5 --- /dev/null +++ b/src/Imagekit/Models/Files/FileMoveParams.cs @@ -0,0 +1,94 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Text; +using System.Text.Json; + +namespace Imagekit.Models.Files; + +/// +/// This will move a file and all its versions from one folder to another. +/// +/// Note: If any file at the destination has the same name as the source file, then +/// the source file and its versions will be appended to the destination file. +/// +public sealed record class FileMoveParams : ParamsBase +{ + public Dictionary BodyProperties { get; set; } = []; + + /// + /// Full path to the folder you want to move the above file into. + /// + public required string DestinationPath + { + get + { + if (!this.BodyProperties.TryGetValue("destinationPath", out JsonElement element)) + throw new ArgumentOutOfRangeException( + "destinationPath", + "Missing required argument" + ); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("destinationPath"); + } + set + { + this.BodyProperties["destinationPath"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The full path of the file you want to move. + /// + public required string SourceFilePath + { + get + { + if (!this.BodyProperties.TryGetValue("sourceFilePath", out JsonElement element)) + throw new ArgumentOutOfRangeException( + "sourceFilePath", + "Missing required argument" + ); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("sourceFilePath"); + } + set + { + this.BodyProperties["sourceFilePath"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override Uri Url(IImageKitClient client) + { + return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/files/move") + { + Query = this.QueryString(client), + }.Uri; + } + + public StringContent BodyContent() + { + return new( + JsonSerializer.Serialize(this.BodyProperties), + Encoding.UTF8, + "application/json" + ); + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/Files/FileMoveResponse.cs b/src/Imagekit/Models/Files/FileMoveResponse.cs new file mode 100644 index 00000000..ebcffab9 --- /dev/null +++ b/src/Imagekit/Models/Files/FileMoveResponse.cs @@ -0,0 +1,27 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class FileMoveResponse : ModelBase, IFromRaw +{ + public override void Validate() { } + + public FileMoveResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FileMoveResponse(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static FileMoveResponse FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/FileProperties/AITag.cs b/src/Imagekit/Models/Files/FileProperties/AITag.cs new file mode 100644 index 00000000..f5bacb0e --- /dev/null +++ b/src/Imagekit/Models/Files/FileProperties/AITag.cs @@ -0,0 +1,95 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.FileProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class AITag : ModelBase, IFromRaw +{ + /// + /// Confidence score of the tag. + /// + public double? Confidence + { + get + { + if (!this.Properties.TryGetValue("confidence", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["confidence"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Name of the tag. + /// + public string? Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Source of the tag. Possible values are `google-auto-tagging` and `aws-auto-tagging`. + /// + public string? Source + { + get + { + if (!this.Properties.TryGetValue("source", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["source"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.Confidence; + _ = this.Name; + _ = this.Source; + } + + public AITag() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + AITag(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static AITag FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/FileProperties/Type.cs b/src/Imagekit/Models/Files/FileProperties/Type.cs new file mode 100644 index 00000000..6062c976 --- /dev/null +++ b/src/Imagekit/Models/Files/FileProperties/Type.cs @@ -0,0 +1,46 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using System = System; + +namespace Imagekit.Models.Files.FileProperties; + +/// +/// Type of the asset. +/// +[JsonConverter(typeof(TypeConverter))] +public enum Type +{ + File, + FileVersion, +} + +sealed class TypeConverter : JsonConverter +{ + public override Type Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "file" => FileProperties.Type.File, + "file-version" => FileProperties.Type.FileVersion, + _ => (Type)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + FileProperties.Type.File => "file", + FileProperties.Type.FileVersion => "file-version", + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Files/FileProperties/VersionInfo.cs b/src/Imagekit/Models/Files/FileProperties/VersionInfo.cs new file mode 100644 index 00000000..48e2faf5 --- /dev/null +++ b/src/Imagekit/Models/Files/FileProperties/VersionInfo.cs @@ -0,0 +1,76 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.FileProperties; + +/// +/// An object with details of the file version. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class VersionInfo : ModelBase, IFromRaw +{ + /// + /// Unique identifier of the file version. + /// + public string? ID + { + get + { + if (!this.Properties.TryGetValue("id", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["id"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Name of the file version. + /// + public string? Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.ID; + _ = this.Name; + } + + public VersionInfo() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + VersionInfo(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static VersionInfo FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/FileRenameParams.cs b/src/Imagekit/Models/Files/FileRenameParams.cs new file mode 100644 index 00000000..8c378757 --- /dev/null +++ b/src/Imagekit/Models/Files/FileRenameParams.cs @@ -0,0 +1,129 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Text; +using System.Text.Json; + +namespace Imagekit.Models.Files; + +/// +/// You can rename an already existing file in the media library using rename file +/// API. This operation would rename all file versions of the file. +/// +/// Note: The old URLs will stop working. The file/file version URLs cached on CDN +/// will continue to work unless a purge is requested. +/// +public sealed record class FileRenameParams : ParamsBase +{ + public Dictionary BodyProperties { get; set; } = []; + + /// + /// The full path of the file you want to rename. + /// + public required string FilePath + { + get + { + if (!this.BodyProperties.TryGetValue("filePath", out JsonElement element)) + throw new ArgumentOutOfRangeException("filePath", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("filePath"); + } + set + { + this.BodyProperties["filePath"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The new name of the file. A filename can contain: + /// + /// Alphanumeric Characters: `a-z`, `A-Z`, `0-9` (including Unicode letters, marks, + /// and numerals in other languages). Special Characters: `.`, `_`, and `-`. + /// + /// Any other character, including space, will be replaced by `_`. + /// + public required string NewFileName + { + get + { + if (!this.BodyProperties.TryGetValue("newFileName", out JsonElement element)) + throw new ArgumentOutOfRangeException("newFileName", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("newFileName"); + } + set + { + this.BodyProperties["newFileName"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Option to purge cache for the old file and its versions' URLs. + /// + /// When set to true, it will internally issue a purge cache request on CDN to + /// remove cached content of old file and its versions. This purge request is + /// counted against your monthly purge quota. + /// + /// Note: If the old file were accessible at `https://ik.imagekit.io/demo/old-filename.jpg`, + /// a purge cache request would be issued against `https://ik.imagekit.io/demo/old-filename.jpg*` + /// (with a wildcard at the end). It will remove the file and its versions' URLs + /// and any transformations made using query parameters on this file or its versions. + /// However, the cache for file transformations made using path parameters will + /// persist. You can purge them using the purge API. For more details, refer to + /// the purge API documentation. + /// + /// Default value - `false` + /// + public bool? PurgeCache + { + get + { + if (!this.BodyProperties.TryGetValue("purgeCache", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["purgeCache"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override Uri Url(IImageKitClient client) + { + return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/files/rename") + { + Query = this.QueryString(client), + }.Uri; + } + + public StringContent BodyContent() + { + return new( + JsonSerializer.Serialize(this.BodyProperties), + Encoding.UTF8, + "application/json" + ); + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/Files/FileRenameResponse.cs b/src/Imagekit/Models/Files/FileRenameResponse.cs new file mode 100644 index 00000000..29001165 --- /dev/null +++ b/src/Imagekit/Models/Files/FileRenameResponse.cs @@ -0,0 +1,52 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class FileRenameResponse : ModelBase, IFromRaw +{ + /// + /// Unique identifier of the purge request. This can be used to check the status + /// of the purge request. + /// + public string? PurgeRequestID + { + get + { + if (!this.Properties.TryGetValue("purgeRequestId", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["purgeRequestId"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.PurgeRequestID; + } + + public FileRenameResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FileRenameResponse(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static FileRenameResponse FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/FileUpdateParams.cs b/src/Imagekit/Models/Files/FileUpdateParams.cs new file mode 100644 index 00000000..100f51ab --- /dev/null +++ b/src/Imagekit/Models/Files/FileUpdateParams.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Text; +using System.Text.Json; +using Imagekit.Models.Files.FileUpdateParamsProperties; + +namespace Imagekit.Models.Files; + +/// +/// This API updates the details or attributes of the current version of the file. +/// You can update `tags`, `customCoordinates`, `customMetadata`, publication status, +/// remove existing `AITags` and apply extensions using this API. +/// +public sealed record class FileUpdateParams : ParamsBase +{ + public Dictionary BodyProperties { get; set; } = []; + + public required string FileID; + + public Update? Update + { + get + { + if (!this.BodyProperties.TryGetValue("update", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["update"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override Uri Url(IImageKitClient client) + { + return new UriBuilder( + client.BaseUrl.ToString().TrimEnd('/') + + string.Format("/v1/files/{0}/details", this.FileID) + ) + { + Query = this.QueryString(client), + }.Uri; + } + + public StringContent BodyContent() + { + return new( + JsonSerializer.Serialize(this.BodyProperties), + Encoding.UTF8, + "application/json" + ); + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/Files/FileUpdateParamsProperties/Update.cs b/src/Imagekit/Models/Files/FileUpdateParamsProperties/Update.cs new file mode 100644 index 00000000..2e507646 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUpdateParamsProperties/Update.cs @@ -0,0 +1,123 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files.FileUpdateParamsProperties.UpdateProperties; +using UpdateVariants = Imagekit.Models.Files.FileUpdateParamsProperties.UpdateVariants; + +namespace Imagekit.Models.Files.FileUpdateParamsProperties; + +[JsonConverter(typeof(UpdateConverter))] +public abstract record class Update +{ + internal Update() { } + + public static implicit operator Update(UpdateFileDetails value) => + new UpdateVariants::UpdateFileDetails(value); + + public static implicit operator Update(ChangePublicationStatus value) => + new UpdateVariants::ChangePublicationStatus(value); + + public bool TryPickFileDetails([NotNullWhen(true)] out UpdateFileDetails? value) + { + value = (this as UpdateVariants::UpdateFileDetails)?.Value; + return value != null; + } + + public bool TryPickChangePublicationStatus( + [NotNullWhen(true)] out ChangePublicationStatus? value + ) + { + value = (this as UpdateVariants::ChangePublicationStatus)?.Value; + return value != null; + } + + public void Switch( + Action fileDetails, + Action changePublicationStatus + ) + { + switch (this) + { + case UpdateVariants::UpdateFileDetails inner: + fileDetails(inner); + break; + case UpdateVariants::ChangePublicationStatus inner: + changePublicationStatus(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func fileDetails, + Func changePublicationStatus + ) + { + return this switch + { + UpdateVariants::UpdateFileDetails inner => fileDetails(inner), + UpdateVariants::ChangePublicationStatus inner => changePublicationStatus(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class UpdateConverter : JsonConverter +{ + public override Update? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new UpdateVariants::UpdateFileDetails(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize( + ref reader, + options + ); + if (deserialized != null) + { + return new UpdateVariants::ChangePublicationStatus(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + + public override void Write(Utf8JsonWriter writer, Update value, JsonSerializerOptions options) + { + object variant = value switch + { + UpdateVariants::UpdateFileDetails(var fileDetails) => fileDetails, + UpdateVariants::ChangePublicationStatus(var changePublicationStatus) => + changePublicationStatus, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/ChangePublicationStatus.cs b/src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/ChangePublicationStatus.cs new file mode 100644 index 00000000..7de8ec8b --- /dev/null +++ b/src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/ChangePublicationStatus.cs @@ -0,0 +1,54 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files.FileUpdateParamsProperties.UpdateProperties.ChangePublicationStatusProperties; + +namespace Imagekit.Models.Files.FileUpdateParamsProperties.UpdateProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class ChangePublicationStatus : ModelBase, IFromRaw +{ + /// + /// Configure the publication status of a file and its versions. + /// + public Publish? Publish + { + get + { + if (!this.Properties.TryGetValue("publish", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["publish"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.Publish?.Validate(); + } + + public ChangePublicationStatus() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ChangePublicationStatus(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static ChangePublicationStatus FromRawUnchecked( + Dictionary properties + ) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/ChangePublicationStatusProperties/Publish.cs b/src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/ChangePublicationStatusProperties/Publish.cs new file mode 100644 index 00000000..acd8feb0 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/ChangePublicationStatusProperties/Publish.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.FileUpdateParamsProperties.UpdateProperties.ChangePublicationStatusProperties; + +/// +/// Configure the publication status of a file and its versions. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class Publish : ModelBase, IFromRaw +{ + /// + /// Set to `true` to publish the file. Set to `false` to unpublish the file. + /// + public required bool IsPublished + { + get + { + if (!this.Properties.TryGetValue("isPublished", out JsonElement element)) + throw new ArgumentOutOfRangeException("isPublished", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["isPublished"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Set to `true` to publish/unpublish all versions of the file. Set to `false` + /// to publish/unpublish only the current version of the file. + /// + public bool? IncludeFileVersions + { + get + { + if (!this.Properties.TryGetValue("includeFileVersions", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["includeFileVersions"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.IsPublished; + _ = this.IncludeFileVersions; + } + + public Publish() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Publish(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Publish FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public Publish(bool isPublished) + : this() + { + this.IsPublished = isPublished; + } +} diff --git a/src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetails.cs b/src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetails.cs new file mode 100644 index 00000000..54fbecbe --- /dev/null +++ b/src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetails.cs @@ -0,0 +1,215 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files.FileUpdateParamsProperties.UpdateProperties.UpdateFileDetailsProperties; + +namespace Imagekit.Models.Files.FileUpdateParamsProperties.UpdateProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class UpdateFileDetails : ModelBase, IFromRaw +{ + /// + /// Define an important area in the image in the format `x,y,width,height` e.g. + /// `10,10,100,100`. Send `null` to unset this value. + /// + public string? CustomCoordinates + { + get + { + if (!this.Properties.TryGetValue("customCoordinates", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["customCoordinates"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// A key-value data to be associated with the asset. To unset a key, send `null` + /// value for that key. Before setting any custom metadata on an asset you have + /// to create the field using custom metadata fields API. + /// + public Dictionary? CustomMetadata + { + get + { + if (!this.Properties.TryGetValue("customMetadata", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["customMetadata"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Optional text to describe the contents of the file. + /// + public string? Description + { + get + { + if (!this.Properties.TryGetValue("description", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["description"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Array of extensions to be applied to the asset. Each extension can be configured + /// with specific parameters based on the extension type. + /// + public List? Extensions + { + get + { + if (!this.Properties.TryGetValue("extensions", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["extensions"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// An array of AITags associated with the file that you want to remove, e.g. + /// `["car", "vehicle", "motorsports"]`. + /// + /// If you want to remove all AITags associated with the file, send a string - "all". + /// + /// Note: The remove operation for `AITags` executes before any of the `extensions` + /// are processed. + /// + public RemoveAITags? RemoveAITags + { + get + { + if (!this.Properties.TryGetValue("removeAITags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["removeAITags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// An array of tags associated with the file, such as `["tag1", "tag2"]`. Send + /// `null` to unset all tags associated with the file. + /// + public List? Tags + { + get + { + if (!this.Properties.TryGetValue("tags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["tags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The final status of extensions after they have completed execution will be + /// delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + /// about the webhook payload structure. + /// + public string? WebhookURL + { + get + { + if (!this.Properties.TryGetValue("webhookUrl", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["webhookUrl"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.CustomCoordinates; + if (this.CustomMetadata != null) + { + foreach (var item in this.CustomMetadata.Values) + { + _ = item; + } + } + _ = this.Description; + foreach (var item in this.Extensions ?? []) + { + item.Validate(); + } + this.RemoveAITags?.Validate(); + foreach (var item in this.Tags ?? []) + { + _ = item; + } + _ = this.WebhookURL; + } + + public UpdateFileDetails() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UpdateFileDetails(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static UpdateFileDetails FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetailsProperties/Extension.cs b/src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetailsProperties/Extension.cs new file mode 100644 index 00000000..4eaae50d --- /dev/null +++ b/src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetailsProperties/Extension.cs @@ -0,0 +1,177 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files.FileUpdateParamsProperties.UpdateProperties.UpdateFileDetailsProperties.ExtensionProperties; +using ExtensionVariants = Imagekit.Models.Files.FileUpdateParamsProperties.UpdateProperties.UpdateFileDetailsProperties.ExtensionVariants; + +namespace Imagekit.Models.Files.FileUpdateParamsProperties.UpdateProperties.UpdateFileDetailsProperties; + +[JsonConverter(typeof(ExtensionConverter))] +public abstract record class Extension +{ + internal Extension() { } + + public static implicit operator Extension(RemoveBg value) => + new ExtensionVariants::RemoveBg(value); + + public static implicit operator Extension(AutoTaggingExtension value) => + new ExtensionVariants::AutoTaggingExtension(value); + + public bool TryPickRemoveBg([NotNullWhen(true)] out RemoveBg? value) + { + value = (this as ExtensionVariants::RemoveBg)?.Value; + return value != null; + } + + public bool TryPickAutoTagging([NotNullWhen(true)] out AutoTaggingExtension? value) + { + value = (this as ExtensionVariants::AutoTaggingExtension)?.Value; + return value != null; + } + + public bool TryPickAIAutoDescription([NotNullWhen(true)] out JsonElement? value) + { + value = (this as ExtensionVariants::AIAutoDescription)?.Value; + return value != null; + } + + public void Switch( + Action removeBg, + Action autoTagging, + Action aiAutoDescription + ) + { + switch (this) + { + case ExtensionVariants::RemoveBg inner: + removeBg(inner); + break; + case ExtensionVariants::AutoTaggingExtension inner: + autoTagging(inner); + break; + case ExtensionVariants::AIAutoDescription inner: + aiAutoDescription(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func removeBg, + Func autoTagging, + Func aiAutoDescription + ) + { + return this switch + { + ExtensionVariants::RemoveBg inner => removeBg(inner), + ExtensionVariants::AutoTaggingExtension inner => autoTagging(inner), + ExtensionVariants::AIAutoDescription inner => aiAutoDescription(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class ExtensionConverter : JsonConverter +{ + public override Extension? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var json = JsonSerializer.Deserialize(ref reader, options); + string? name; + try + { + name = json.GetProperty("name").GetString(); + } + catch + { + name = null; + } + + switch (name) + { + case "remove-bg": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new ExtensionVariants::RemoveBg(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "ai-auto-description": + { + List exceptions = []; + + try + { + return new ExtensionVariants::AIAutoDescription( + JsonSerializer.Deserialize(json, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + default: + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize( + json, + options + ); + if (deserialized != null) + { + return new ExtensionVariants::AutoTaggingExtension(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + Extension value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + ExtensionVariants::RemoveBg(var removeBg) => removeBg, + ExtensionVariants::AutoTaggingExtension(var autoTagging) => autoTagging, + ExtensionVariants::AIAutoDescription(var aiAutoDescription) => aiAutoDescription, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetailsProperties/ExtensionProperties/AutoTaggingExtension.cs b/src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetailsProperties/ExtensionProperties/AutoTaggingExtension.cs new file mode 100644 index 00000000..61e0caf0 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetailsProperties/ExtensionProperties/AutoTaggingExtension.cs @@ -0,0 +1,100 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files.FileUpdateParamsProperties.UpdateProperties.UpdateFileDetailsProperties.ExtensionProperties.AutoTaggingExtensionProperties; + +namespace Imagekit.Models.Files.FileUpdateParamsProperties.UpdateProperties.UpdateFileDetailsProperties.ExtensionProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class AutoTaggingExtension : ModelBase, IFromRaw +{ + /// + /// Maximum number of tags to attach to the asset. + /// + public required long MaxTags + { + get + { + if (!this.Properties.TryGetValue("maxTags", out JsonElement element)) + throw new ArgumentOutOfRangeException("maxTags", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["maxTags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Minimum confidence level for tags to be considered valid. + /// + public required long MinConfidence + { + get + { + if (!this.Properties.TryGetValue("minConfidence", out JsonElement element)) + throw new ArgumentOutOfRangeException("minConfidence", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["minConfidence"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies the auto-tagging extension used. + /// + public required ApiEnum Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + throw new ArgumentOutOfRangeException("name", "Missing required argument"); + + return JsonSerializer.Deserialize>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.MaxTags; + _ = this.MinConfidence; + this.Name.Validate(); + } + + public AutoTaggingExtension() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + AutoTaggingExtension(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static AutoTaggingExtension FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetailsProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs b/src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetailsProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs new file mode 100644 index 00000000..2f988a2d --- /dev/null +++ b/src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetailsProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs @@ -0,0 +1,46 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.FileUpdateParamsProperties.UpdateProperties.UpdateFileDetailsProperties.ExtensionProperties.AutoTaggingExtensionProperties; + +/// +/// Specifies the auto-tagging extension used. +/// +[JsonConverter(typeof(NameConverter))] +public enum Name +{ + GoogleAutoTagging, + AwsAutoTagging, +} + +sealed class NameConverter : JsonConverter +{ + public override Name Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "google-auto-tagging" => Name.GoogleAutoTagging, + "aws-auto-tagging" => Name.AwsAutoTagging, + _ => (Name)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Name value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + Name.GoogleAutoTagging => "google-auto-tagging", + Name.AwsAutoTagging => "aws-auto-tagging", + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetailsProperties/ExtensionProperties/RemoveBg.cs b/src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetailsProperties/ExtensionProperties/RemoveBg.cs new file mode 100644 index 00000000..195549a9 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetailsProperties/ExtensionProperties/RemoveBg.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files.FileUpdateParamsProperties.UpdateProperties.UpdateFileDetailsProperties.ExtensionProperties.RemoveBgProperties; + +namespace Imagekit.Models.Files.FileUpdateParamsProperties.UpdateProperties.UpdateFileDetailsProperties.ExtensionProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class RemoveBg : ModelBase, IFromRaw +{ + /// + /// Specifies the background removal extension. + /// + public JsonElement Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + throw new ArgumentOutOfRangeException("name", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public Options? Options + { + get + { + if (!this.Properties.TryGetValue("options", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["options"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.Options?.Validate(); + } + + public RemoveBg() + { + this.Name = JsonSerializer.Deserialize("\"remove-bg\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + RemoveBg(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static RemoveBg FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetailsProperties/ExtensionProperties/RemoveBgProperties/Options.cs b/src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetailsProperties/ExtensionProperties/RemoveBgProperties/Options.cs new file mode 100644 index 00000000..b2051fb0 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetailsProperties/ExtensionProperties/RemoveBgProperties/Options.cs @@ -0,0 +1,122 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.FileUpdateParamsProperties.UpdateProperties.UpdateFileDetailsProperties.ExtensionProperties.RemoveBgProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Options : ModelBase, IFromRaw +{ + /// + /// Whether to add an artificial shadow to the result. Default is false. Note: + /// Adding shadows is currently only supported for car photos. + /// + public bool? AddShadow + { + get + { + if (!this.Properties.TryGetValue("add_shadow", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["add_shadow"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies a solid color background using hex code (e.g., "81d4fa", "fff") + /// or color name (e.g., "green"). If this parameter is set, `bg_image_url` must + /// be empty. + /// + public string? BgColor + { + get + { + if (!this.Properties.TryGetValue("bg_color", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["bg_color"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Sets a background image from a URL. If this parameter is set, `bg_color` + /// must be empty. + /// + public string? BgImageURL + { + get + { + if (!this.Properties.TryGetValue("bg_image_url", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["bg_image_url"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Allows semi-transparent regions in the result. Default is true. Note: Semitransparency + /// is currently only supported for car windows. + /// + public bool? Semitransparency + { + get + { + if (!this.Properties.TryGetValue("semitransparency", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["semitransparency"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.AddShadow; + _ = this.BgColor; + _ = this.BgImageURL; + _ = this.Semitransparency; + } + + public Options() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Options(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Options FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetailsProperties/ExtensionVariants/All.cs b/src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetailsProperties/ExtensionVariants/All.cs new file mode 100644 index 00000000..b1d2c160 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetailsProperties/ExtensionVariants/All.cs @@ -0,0 +1,46 @@ +using System.Text.Json; +using ExtensionProperties = Imagekit.Models.Files.FileUpdateParamsProperties.UpdateProperties.UpdateFileDetailsProperties.ExtensionProperties; + +namespace Imagekit.Models.Files.FileUpdateParamsProperties.UpdateProperties.UpdateFileDetailsProperties.ExtensionVariants; + +public sealed record class RemoveBg(ExtensionProperties::RemoveBg Value) + : Extension, + IVariant +{ + public static RemoveBg From(ExtensionProperties::RemoveBg value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class AutoTaggingExtension(ExtensionProperties::AutoTaggingExtension Value) + : Extension, + IVariant +{ + public static AutoTaggingExtension From(ExtensionProperties::AutoTaggingExtension value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class AIAutoDescription(JsonElement Value) + : Extension, + IVariant +{ + public static AIAutoDescription From(JsonElement value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetailsProperties/RemoveAITags.cs b/src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetailsProperties/RemoveAITags.cs new file mode 100644 index 00000000..f47a66cb --- /dev/null +++ b/src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetailsProperties/RemoveAITags.cs @@ -0,0 +1,115 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files.FileUpdateParamsProperties.UpdateProperties.UpdateFileDetailsProperties.RemoveAITagsVariants; + +namespace Imagekit.Models.Files.FileUpdateParamsProperties.UpdateProperties.UpdateFileDetailsProperties; + +/// +/// An array of AITags associated with the file that you want to remove, e.g. `["car", +/// "vehicle", "motorsports"]`. +/// +/// If you want to remove all AITags associated with the file, send a string - "all". +/// +/// Note: The remove operation for `AITags` executes before any of the `extensions` +/// are processed. +/// +[JsonConverter(typeof(RemoveAITagsConverter))] +public abstract record class RemoveAITags +{ + internal RemoveAITags() { } + + public static implicit operator RemoveAITags(List value) => new Strings(value); + + public bool TryPickStrings([NotNullWhen(true)] out List? value) + { + value = (this as Strings)?.Value; + return value != null; + } + + public bool TryPickAll([NotNullWhen(true)] out JsonElement? value) + { + value = (this as All)?.Value; + return value != null; + } + + public void Switch(Action strings, Action all) + { + switch (this) + { + case Strings inner: + strings(inner); + break; + case All inner: + all(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match(Func strings, Func all) + { + return this switch + { + Strings inner => strings(inner), + All inner => all(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class RemoveAITagsConverter : JsonConverter +{ + public override RemoveAITags? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + return new All(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize>(ref reader, options); + if (deserialized != null) + { + return new Strings(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + + public override void Write( + Utf8JsonWriter writer, + RemoveAITags value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + Strings(var strings) => strings, + All(var all) => all, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetailsProperties/RemoveAITagsVariants/All.cs b/src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetailsProperties/RemoveAITagsVariants/All.cs new file mode 100644 index 00000000..4fd3a772 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetailsProperties/RemoveAITagsVariants/All.cs @@ -0,0 +1,26 @@ +using System.Collections.Generic; +using System.Text.Json; + +namespace Imagekit.Models.Files.FileUpdateParamsProperties.UpdateProperties.UpdateFileDetailsProperties.RemoveAITagsVariants; + +public sealed record class Strings(List Value) + : RemoveAITags, + IVariant> +{ + public static Strings From(List value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class All(JsonElement Value) : RemoveAITags, IVariant +{ + public static All From(JsonElement value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateVariants/All.cs b/src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateVariants/All.cs new file mode 100644 index 00000000..aea0129a --- /dev/null +++ b/src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateVariants/All.cs @@ -0,0 +1,33 @@ +using UpdateProperties = Imagekit.Models.Files.FileUpdateParamsProperties.UpdateProperties; + +namespace Imagekit.Models.Files.FileUpdateParamsProperties.UpdateVariants; + +public sealed record class UpdateFileDetails(UpdateProperties::UpdateFileDetails Value) + : Update, + IVariant +{ + public static UpdateFileDetails From(UpdateProperties::UpdateFileDetails value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class ChangePublicationStatus(UpdateProperties::ChangePublicationStatus Value) + : Update, + IVariant +{ + public static ChangePublicationStatus From(UpdateProperties::ChangePublicationStatus value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} diff --git a/src/Imagekit/Models/Files/FileUpdateResponse.cs b/src/Imagekit/Models/Files/FileUpdateResponse.cs new file mode 100644 index 00000000..8f361123 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUpdateResponse.cs @@ -0,0 +1,600 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files.FileUpdateResponseProperties.IntersectionMember1Properties; +using FileProperties = Imagekit.Models.Files.FileProperties; + +namespace Imagekit.Models.Files; + +/// +/// Object containing details of a file or file version. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class FileUpdateResponse : ModelBase, IFromRaw +{ + /// + /// An array of tags assigned to the file by auto tagging. + /// + public List? AITags + { + get + { + if (!this.Properties.TryGetValue("AITags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["AITags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Date and time when the file was uploaded. The date and time is in ISO8601 + /// format. + /// + public DateTime? CreatedAt + { + get + { + if (!this.Properties.TryGetValue("createdAt", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["createdAt"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// An string with custom coordinates of the file. + /// + public string? CustomCoordinates + { + get + { + if (!this.Properties.TryGetValue("customCoordinates", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["customCoordinates"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// An object with custom metadata for the file. + /// + public Dictionary? CustomMetadata + { + get + { + if (!this.Properties.TryGetValue("customMetadata", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["customMetadata"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Optional text to describe the contents of the file. Can be set by the user + /// or the ai-auto-description extension. + /// + public string? Description + { + get + { + if (!this.Properties.TryGetValue("description", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["description"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Unique identifier of the asset. + /// + public string? FileID + { + get + { + if (!this.Properties.TryGetValue("fileId", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["fileId"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Path of the file. This is the path you would use in the URL to access the + /// file. For example, if the file is at the root of the media library, the path + /// will be `/file.jpg`. If the file is inside a folder named `images`, the path + /// will be `/images/file.jpg`. + /// + public string? FilePath + { + get + { + if (!this.Properties.TryGetValue("filePath", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["filePath"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Type of the file. Possible values are `image`, `non-image`. + /// + public string? FileType + { + get + { + if (!this.Properties.TryGetValue("fileType", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["fileType"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies if the image has an alpha channel. + /// + public bool? HasAlpha + { + get + { + if (!this.Properties.TryGetValue("hasAlpha", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["hasAlpha"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Height of the file. + /// + public double? Height + { + get + { + if (!this.Properties.TryGetValue("height", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["height"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies if the file is private or not. + /// + public bool? IsPrivateFile + { + get + { + if (!this.Properties.TryGetValue("isPrivateFile", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["isPrivateFile"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies if the file is published or not. + /// + public bool? IsPublished + { + get + { + if (!this.Properties.TryGetValue("isPublished", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["isPublished"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// MIME type of the file. + /// + public string? Mime + { + get + { + if (!this.Properties.TryGetValue("mime", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["mime"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Name of the asset. + /// + public string? Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Size of the file in bytes. + /// + public double? Size + { + get + { + if (!this.Properties.TryGetValue("size", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["size"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// An array of tags assigned to the file. Tags are used to search files in the + /// media library. + /// + public List? Tags + { + get + { + if (!this.Properties.TryGetValue("tags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["tags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// URL of the thumbnail image. This URL is used to access the thumbnail image + /// of the file in the media library. + /// + public string? Thumbnail + { + get + { + if (!this.Properties.TryGetValue("thumbnail", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["thumbnail"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Type of the asset. + /// + public ApiEnum? Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Date and time when the file was last updated. The date and time is in ISO8601 + /// format. + /// + public DateTime? UpdatedAt + { + get + { + if (!this.Properties.TryGetValue("updatedAt", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["updatedAt"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// URL of the file. + /// + public string? URL + { + get + { + if (!this.Properties.TryGetValue("url", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["url"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// An object with details of the file version. + /// + public FileProperties::VersionInfo? VersionInfo + { + get + { + if (!this.Properties.TryGetValue("versionInfo", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["versionInfo"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Width of the file. + /// + public double? Width + { + get + { + if (!this.Properties.TryGetValue("width", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["width"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public ExtensionStatus? ExtensionStatus + { + get + { + if (!this.Properties.TryGetValue("extensionStatus", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["extensionStatus"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public static implicit operator File(FileUpdateResponse fileUpdateResponse) => + new() + { + AITags = fileUpdateResponse.AITags, + CreatedAt = fileUpdateResponse.CreatedAt, + CustomCoordinates = fileUpdateResponse.CustomCoordinates, + CustomMetadata = fileUpdateResponse.CustomMetadata, + Description = fileUpdateResponse.Description, + FileID = fileUpdateResponse.FileID, + FilePath = fileUpdateResponse.FilePath, + FileType = fileUpdateResponse.FileType, + HasAlpha = fileUpdateResponse.HasAlpha, + Height = fileUpdateResponse.Height, + IsPrivateFile = fileUpdateResponse.IsPrivateFile, + IsPublished = fileUpdateResponse.IsPublished, + Mime = fileUpdateResponse.Mime, + Name = fileUpdateResponse.Name, + Size = fileUpdateResponse.Size, + Tags = fileUpdateResponse.Tags, + Thumbnail = fileUpdateResponse.Thumbnail, + Type = fileUpdateResponse.Type, + UpdatedAt = fileUpdateResponse.UpdatedAt, + URL = fileUpdateResponse.URL, + VersionInfo = fileUpdateResponse.VersionInfo, + Width = fileUpdateResponse.Width, + }; + + public override void Validate() + { + foreach (var item in this.AITags ?? []) + { + item.Validate(); + } + _ = this.CreatedAt; + _ = this.CustomCoordinates; + if (this.CustomMetadata != null) + { + foreach (var item in this.CustomMetadata.Values) + { + _ = item; + } + } + _ = this.Description; + _ = this.FileID; + _ = this.FilePath; + _ = this.FileType; + _ = this.HasAlpha; + _ = this.Height; + _ = this.IsPrivateFile; + _ = this.IsPublished; + _ = this.Mime; + _ = this.Name; + _ = this.Size; + foreach (var item in this.Tags ?? []) + { + _ = item; + } + _ = this.Thumbnail; + this.Type?.Validate(); + _ = this.UpdatedAt; + _ = this.URL; + this.VersionInfo?.Validate(); + _ = this.Width; + this.ExtensionStatus?.Validate(); + } + + public FileUpdateResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FileUpdateResponse(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static FileUpdateResponse FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/FileUpdateResponseProperties/IntersectionMember1.cs b/src/Imagekit/Models/Files/FileUpdateResponseProperties/IntersectionMember1.cs new file mode 100644 index 00000000..18f1f617 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUpdateResponseProperties/IntersectionMember1.cs @@ -0,0 +1,52 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files.FileUpdateResponseProperties.IntersectionMember1Properties; + +namespace Imagekit.Models.Files.FileUpdateResponseProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class IntersectionMember1 : ModelBase, IFromRaw +{ + public ExtensionStatus? ExtensionStatus + { + get + { + if (!this.Properties.TryGetValue("extensionStatus", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["extensionStatus"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.ExtensionStatus?.Validate(); + } + + public IntersectionMember1() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + IntersectionMember1(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static IntersectionMember1 FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/FileUpdateResponseProperties/IntersectionMember1Properties/ExtensionStatus.cs b/src/Imagekit/Models/Files/FileUpdateResponseProperties/IntersectionMember1Properties/ExtensionStatus.cs new file mode 100644 index 00000000..c540e9b8 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUpdateResponseProperties/IntersectionMember1Properties/ExtensionStatus.cs @@ -0,0 +1,118 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files.FileUpdateResponseProperties.IntersectionMember1Properties.ExtensionStatusProperties; + +namespace Imagekit.Models.Files.FileUpdateResponseProperties.IntersectionMember1Properties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class ExtensionStatus : ModelBase, IFromRaw +{ + public ApiEnum? AIAutoDescription + { + get + { + if (!this.Properties.TryGetValue("ai-auto-description", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["ai-auto-description"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public ApiEnum? AwsAutoTagging + { + get + { + if (!this.Properties.TryGetValue("aws-auto-tagging", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["aws-auto-tagging"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public ApiEnum? GoogleAutoTagging + { + get + { + if (!this.Properties.TryGetValue("google-auto-tagging", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["google-auto-tagging"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public ApiEnum? RemoveBg + { + get + { + if (!this.Properties.TryGetValue("remove-bg", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["remove-bg"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.AIAutoDescription?.Validate(); + this.AwsAutoTagging?.Validate(); + this.GoogleAutoTagging?.Validate(); + this.RemoveBg?.Validate(); + } + + public ExtensionStatus() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ExtensionStatus(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static ExtensionStatus FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/FileUpdateResponseProperties/IntersectionMember1Properties/ExtensionStatusProperties/AIAutoDescription.cs b/src/Imagekit/Models/Files/FileUpdateResponseProperties/IntersectionMember1Properties/ExtensionStatusProperties/AIAutoDescription.cs new file mode 100644 index 00000000..5411f57f --- /dev/null +++ b/src/Imagekit/Models/Files/FileUpdateResponseProperties/IntersectionMember1Properties/ExtensionStatusProperties/AIAutoDescription.cs @@ -0,0 +1,50 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.FileUpdateResponseProperties.IntersectionMember1Properties.ExtensionStatusProperties; + +[JsonConverter(typeof(AIAutoDescriptionConverter))] +public enum AIAutoDescription +{ + Success, + Pending, + Failed, +} + +sealed class AIAutoDescriptionConverter : JsonConverter +{ + public override AIAutoDescription Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "success" => AIAutoDescription.Success, + "pending" => AIAutoDescription.Pending, + "failed" => AIAutoDescription.Failed, + _ => (AIAutoDescription)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + AIAutoDescription value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + AIAutoDescription.Success => "success", + AIAutoDescription.Pending => "pending", + AIAutoDescription.Failed => "failed", + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Files/FileUpdateResponseProperties/IntersectionMember1Properties/ExtensionStatusProperties/AwsAutoTagging.cs b/src/Imagekit/Models/Files/FileUpdateResponseProperties/IntersectionMember1Properties/ExtensionStatusProperties/AwsAutoTagging.cs new file mode 100644 index 00000000..4e795b7b --- /dev/null +++ b/src/Imagekit/Models/Files/FileUpdateResponseProperties/IntersectionMember1Properties/ExtensionStatusProperties/AwsAutoTagging.cs @@ -0,0 +1,50 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.FileUpdateResponseProperties.IntersectionMember1Properties.ExtensionStatusProperties; + +[JsonConverter(typeof(AwsAutoTaggingConverter))] +public enum AwsAutoTagging +{ + Success, + Pending, + Failed, +} + +sealed class AwsAutoTaggingConverter : JsonConverter +{ + public override AwsAutoTagging Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "success" => AwsAutoTagging.Success, + "pending" => AwsAutoTagging.Pending, + "failed" => AwsAutoTagging.Failed, + _ => (AwsAutoTagging)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + AwsAutoTagging value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + AwsAutoTagging.Success => "success", + AwsAutoTagging.Pending => "pending", + AwsAutoTagging.Failed => "failed", + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Files/FileUpdateResponseProperties/IntersectionMember1Properties/ExtensionStatusProperties/GoogleAutoTagging.cs b/src/Imagekit/Models/Files/FileUpdateResponseProperties/IntersectionMember1Properties/ExtensionStatusProperties/GoogleAutoTagging.cs new file mode 100644 index 00000000..98e402cc --- /dev/null +++ b/src/Imagekit/Models/Files/FileUpdateResponseProperties/IntersectionMember1Properties/ExtensionStatusProperties/GoogleAutoTagging.cs @@ -0,0 +1,50 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.FileUpdateResponseProperties.IntersectionMember1Properties.ExtensionStatusProperties; + +[JsonConverter(typeof(GoogleAutoTaggingConverter))] +public enum GoogleAutoTagging +{ + Success, + Pending, + Failed, +} + +sealed class GoogleAutoTaggingConverter : JsonConverter +{ + public override GoogleAutoTagging Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "success" => GoogleAutoTagging.Success, + "pending" => GoogleAutoTagging.Pending, + "failed" => GoogleAutoTagging.Failed, + _ => (GoogleAutoTagging)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + GoogleAutoTagging value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + GoogleAutoTagging.Success => "success", + GoogleAutoTagging.Pending => "pending", + GoogleAutoTagging.Failed => "failed", + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Files/FileUpdateResponseProperties/IntersectionMember1Properties/ExtensionStatusProperties/RemoveBg.cs b/src/Imagekit/Models/Files/FileUpdateResponseProperties/IntersectionMember1Properties/ExtensionStatusProperties/RemoveBg.cs new file mode 100644 index 00000000..6f293e15 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUpdateResponseProperties/IntersectionMember1Properties/ExtensionStatusProperties/RemoveBg.cs @@ -0,0 +1,46 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.FileUpdateResponseProperties.IntersectionMember1Properties.ExtensionStatusProperties; + +[JsonConverter(typeof(RemoveBgConverter))] +public enum RemoveBg +{ + Success, + Pending, + Failed, +} + +sealed class RemoveBgConverter : JsonConverter +{ + public override RemoveBg Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "success" => RemoveBg.Success, + "pending" => RemoveBg.Pending, + "failed" => RemoveBg.Failed, + _ => (RemoveBg)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, RemoveBg value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + RemoveBg.Success => "success", + RemoveBg.Pending => "pending", + RemoveBg.Failed => "failed", + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParams.cs b/src/Imagekit/Models/Files/FileUploadParams.cs new file mode 100644 index 00000000..6d1d3bd2 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParams.cs @@ -0,0 +1,638 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Text; +using System.Text.Json; +using FileUploadParamsProperties = Imagekit.Models.Files.FileUploadParamsProperties; + +namespace Imagekit.Models.Files; + +/// +/// ImageKit.io allows you to upload files directly from both the server and client +/// sides. For server-side uploads, private API key authentication is used. For client-side +/// uploads, generate a one-time `token`, `signature`, and `expire` from your secure +/// backend using private API. [Learn more](/docs/api-reference/upload-file/upload-file#how-to-implement-client-side-file-upload) +/// about how to implement client-side file upload. +/// +/// The [V2 API](/docs/api-reference/upload-file/upload-file-v2) enhances security +/// by verifying the entire payload using JWT. +/// +/// **File size limit** \ On the free plan, the maximum upload file sizes are 20MB +/// for images, audio, and raw files and 100MB for videos. On the paid plan, these +/// limits increase to 40MB for images, audio, and raw files and 2GB for videos. These +/// limits can be further increased with higher-tier plans. +/// +/// **Version limit** \ A file can have a maximum of 100 versions. +/// +/// **Demo applications** +/// +/// - A full-fledged [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), +/// supporting file selections from local storage, URL, Dropbox, Google Drive, Instagram, +/// and more. - [Quick start guides](/docs/quick-start-guides) for various frameworks +/// and technologies. +/// +public sealed record class FileUploadParams : ParamsBase +{ + public Dictionary BodyProperties { get; set; } = []; + + /// + /// The API accepts any of the following: + /// + /// - **Binary data** – send the raw bytes as `multipart/form-data`. - **HTTP + /// / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + /// - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + /// + /// When supplying a URL, the server must receive the response headers within + /// 8 seconds; otherwise the request fails with 400 Bad Request. + /// + public required string File + { + get + { + if (!this.BodyProperties.TryGetValue("file", out JsonElement element)) + throw new ArgumentOutOfRangeException("file", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("file"); + } + set + { + this.BodyProperties["file"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The name with which the file has to be uploaded. The file name can contain: + /// + /// - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. - Special Characters: + /// `.`, `-` + /// + /// Any other character including space will be replaced by `_` + /// + public required string FileName + { + get + { + if (!this.BodyProperties.TryGetValue("fileName", out JsonElement element)) + throw new ArgumentOutOfRangeException("fileName", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("fileName"); + } + set + { + this.BodyProperties["fileName"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// A unique value that the ImageKit.io server will use to recognize and prevent + /// subsequent retries for the same request. We suggest using V4 UUIDs, or another + /// random string with enough entropy to avoid collisions. This field is only + /// required for authentication when uploading a file from the client side. + /// + /// **Note**: Sending a value that has been used in the past will result in a + /// validation error. Even if your previous request resulted in an error, you + /// should always send a new value for this field. + /// + public string? Token + { + get + { + if (!this.BodyProperties.TryGetValue("token", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["token"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Server-side checks to run on the asset. Read more about [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). + /// + public string? Checks + { + get + { + if (!this.BodyProperties.TryGetValue("checks", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["checks"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Define an important area in the image. This is only relevant for image type files. + /// + /// - To be passed as a string with the x and y coordinates of the top-left + /// corner, and width and height of the area of interest in the format `x,y,width,height`. + /// For example - `10,10,100,100` - Can be used with fo-customtransformation. + /// - If this field is not specified and the file is overwritten, then customCoordinates + /// will be removed. + /// + public string? CustomCoordinates + { + get + { + if (!this.BodyProperties.TryGetValue("customCoordinates", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["customCoordinates"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// JSON key-value pairs to associate with the asset. Create the custom metadata + /// fields before setting these values. + /// + public Dictionary? CustomMetadata + { + get + { + if (!this.BodyProperties.TryGetValue("customMetadata", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.BodyProperties["customMetadata"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Optional text to describe the contents of the file. + /// + public string? Description + { + get + { + if (!this.BodyProperties.TryGetValue("description", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["description"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The time until your signature is valid. It must be a [Unix time](https://en.wikipedia.org/wiki/Unix_time) + /// in less than 1 hour into the future. It should be in seconds. This field is + /// only required for authentication when uploading a file from the client side. + /// + public long? Expire + { + get + { + if (!this.BodyProperties.TryGetValue("expire", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["expire"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Array of extensions to be applied to the image. Each extension can be configured + /// with specific parameters based on the extension type. + /// + public List? Extensions + { + get + { + if (!this.BodyProperties.TryGetValue("extensions", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.BodyProperties["extensions"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The folder path in which the image has to be uploaded. If the folder(s) didn't + /// exist before, a new folder(s) is created. + /// + /// The folder name can contain: + /// + /// - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` - Special Characters: + /// `/` , `_` , `-` + /// + /// Using multiple `/` creates a nested folder. + /// + public string? Folder + { + get + { + if (!this.BodyProperties.TryGetValue("folder", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["folder"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to mark the file as private or not. + /// + /// If `true`, the file is marked as private and is accessible only using named + /// transformation or signed URL. + /// + public bool? IsPrivateFile + { + get + { + if (!this.BodyProperties.TryGetValue("isPrivateFile", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["isPrivateFile"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to upload file as published or not. + /// + /// If `false`, the file is marked as unpublished, which restricts access to the + /// file only via the media library. Files in draft or unpublished state can only + /// be publicly accessed after being published. + /// + /// The option to upload in draft state is only available in custom enterprise + /// pricing plans. + /// + public bool? IsPublished + { + get + { + if (!this.BodyProperties.TryGetValue("isPublished", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["isPublished"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// If set to `true` and a file already exists at the exact location, its AITags + /// will be removed. Set `overwriteAITags` to `false` to preserve AITags. + /// + public bool? OverwriteAITags + { + get + { + if (!this.BodyProperties.TryGetValue("overwriteAITags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["overwriteAITags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// If the request does not have `customMetadata`, and a file already exists at + /// the exact location, existing customMetadata will be removed. + /// + public bool? OverwriteCustomMetadata + { + get + { + if ( + !this.BodyProperties.TryGetValue("overwriteCustomMetadata", out JsonElement element) + ) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["overwriteCustomMetadata"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// If `false` and `useUniqueFileName` is also `false`, and a file already exists + /// at the exact location, upload API will return an error immediately. + /// + public bool? OverwriteFile + { + get + { + if (!this.BodyProperties.TryGetValue("overwriteFile", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["overwriteFile"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// If the request does not have `tags`, and a file already exists at the exact + /// location, existing tags will be removed. + /// + public bool? OverwriteTags + { + get + { + if (!this.BodyProperties.TryGetValue("overwriteTags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["overwriteTags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Your ImageKit.io public key. This field is only required for authentication + /// when uploading a file from the client side. + /// + public string? PublicKey + { + get + { + if (!this.BodyProperties.TryGetValue("publicKey", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["publicKey"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Array of response field keys to include in the API response body. + /// + public List>? ResponseFields + { + get + { + if (!this.BodyProperties.TryGetValue("responseFields", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize + >?>(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["responseFields"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key + /// as a key. Learn how to create a signature on the page below. This should be + /// in lowercase. + /// + /// Signature must be calculated on the server-side. This field is only required + /// for authentication when uploading a file from the client side. + /// + public string? Signature + { + get + { + if (!this.BodyProperties.TryGetValue("signature", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["signature"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Set the tags while uploading the file. Provide an array of tag strings (e.g. + /// `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must + /// not exceed 500, and the `%` character is not allowed. If this field is not + /// specified and the file is overwritten, the existing tags will be removed. + /// + public List? Tags + { + get + { + if (!this.BodyProperties.TryGetValue("tags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["tags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Configure pre-processing (`pre`) and post-processing (`post`) transformations. + /// + /// - `pre` — applied before the file is uploaded to the Media Library. Useful + /// for reducing file size or applying basic optimizations upfront (e.g., resize, compress). + /// + /// - `post` — applied immediately after upload. Ideal for generating transformed + /// versions (like video encodes or thumbnails) in advance, so they're ready for + /// delivery without delay. + /// + /// You can mix and match any combination of post-processing types. + /// + public FileUploadParamsProperties::Transformation? Transformation + { + get + { + if (!this.BodyProperties.TryGetValue("transformation", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.BodyProperties["transformation"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to use a unique filename for this file or not. + /// + /// If `true`, ImageKit.io will add a unique suffix to the filename parameter + /// to get a unique filename. + /// + /// If `false`, then the image is uploaded with the provided filename parameter, + /// and any existing file with the same name is replaced. + /// + public bool? UseUniqueFileName + { + get + { + if (!this.BodyProperties.TryGetValue("useUniqueFileName", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["useUniqueFileName"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The final status of extensions after they have completed execution will be + /// delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + /// about the webhook payload structure. + /// + public string? WebhookURL + { + get + { + if (!this.BodyProperties.TryGetValue("webhookUrl", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["webhookUrl"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override Uri Url(IImageKitClient client) + { + return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/api/v1/files/upload") + { + Query = this.QueryString(client), + }.Uri; + } + + public StringContent BodyContent() + { + return new( + JsonSerializer.Serialize(this.BodyProperties), + Encoding.UTF8, + "application/json" + ); + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/Extension.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/Extension.cs new file mode 100644 index 00000000..aca5f9b4 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/Extension.cs @@ -0,0 +1,177 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files.FileUploadParamsProperties.ExtensionProperties; +using ExtensionVariants = Imagekit.Models.Files.FileUploadParamsProperties.ExtensionVariants; + +namespace Imagekit.Models.Files.FileUploadParamsProperties; + +[JsonConverter(typeof(ExtensionConverter))] +public abstract record class Extension +{ + internal Extension() { } + + public static implicit operator Extension(RemoveBg value) => + new ExtensionVariants::RemoveBg(value); + + public static implicit operator Extension(AutoTaggingExtension value) => + new ExtensionVariants::AutoTaggingExtension(value); + + public bool TryPickRemoveBg([NotNullWhen(true)] out RemoveBg? value) + { + value = (this as ExtensionVariants::RemoveBg)?.Value; + return value != null; + } + + public bool TryPickAutoTagging([NotNullWhen(true)] out AutoTaggingExtension? value) + { + value = (this as ExtensionVariants::AutoTaggingExtension)?.Value; + return value != null; + } + + public bool TryPickAIAutoDescription([NotNullWhen(true)] out JsonElement? value) + { + value = (this as ExtensionVariants::AIAutoDescription)?.Value; + return value != null; + } + + public void Switch( + Action removeBg, + Action autoTagging, + Action aiAutoDescription + ) + { + switch (this) + { + case ExtensionVariants::RemoveBg inner: + removeBg(inner); + break; + case ExtensionVariants::AutoTaggingExtension inner: + autoTagging(inner); + break; + case ExtensionVariants::AIAutoDescription inner: + aiAutoDescription(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func removeBg, + Func autoTagging, + Func aiAutoDescription + ) + { + return this switch + { + ExtensionVariants::RemoveBg inner => removeBg(inner), + ExtensionVariants::AutoTaggingExtension inner => autoTagging(inner), + ExtensionVariants::AIAutoDescription inner => aiAutoDescription(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class ExtensionConverter : JsonConverter +{ + public override Extension? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var json = JsonSerializer.Deserialize(ref reader, options); + string? name; + try + { + name = json.GetProperty("name").GetString(); + } + catch + { + name = null; + } + + switch (name) + { + case "remove-bg": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new ExtensionVariants::RemoveBg(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "ai-auto-description": + { + List exceptions = []; + + try + { + return new ExtensionVariants::AIAutoDescription( + JsonSerializer.Deserialize(json, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + default: + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize( + json, + options + ); + if (deserialized != null) + { + return new ExtensionVariants::AutoTaggingExtension(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + Extension value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + ExtensionVariants::RemoveBg(var removeBg) => removeBg, + ExtensionVariants::AutoTaggingExtension(var autoTagging) => autoTagging, + ExtensionVariants::AIAutoDescription(var aiAutoDescription) => aiAutoDescription, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/AutoTaggingExtension.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/AutoTaggingExtension.cs new file mode 100644 index 00000000..11eab9ca --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/AutoTaggingExtension.cs @@ -0,0 +1,100 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files.FileUploadParamsProperties.ExtensionProperties.AutoTaggingExtensionProperties; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.ExtensionProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class AutoTaggingExtension : ModelBase, IFromRaw +{ + /// + /// Maximum number of tags to attach to the asset. + /// + public required long MaxTags + { + get + { + if (!this.Properties.TryGetValue("maxTags", out JsonElement element)) + throw new ArgumentOutOfRangeException("maxTags", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["maxTags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Minimum confidence level for tags to be considered valid. + /// + public required long MinConfidence + { + get + { + if (!this.Properties.TryGetValue("minConfidence", out JsonElement element)) + throw new ArgumentOutOfRangeException("minConfidence", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["minConfidence"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies the auto-tagging extension used. + /// + public required ApiEnum Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + throw new ArgumentOutOfRangeException("name", "Missing required argument"); + + return JsonSerializer.Deserialize>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.MaxTags; + _ = this.MinConfidence; + this.Name.Validate(); + } + + public AutoTaggingExtension() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + AutoTaggingExtension(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static AutoTaggingExtension FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs new file mode 100644 index 00000000..55796f3b --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs @@ -0,0 +1,46 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.ExtensionProperties.AutoTaggingExtensionProperties; + +/// +/// Specifies the auto-tagging extension used. +/// +[JsonConverter(typeof(NameConverter))] +public enum Name +{ + GoogleAutoTagging, + AwsAutoTagging, +} + +sealed class NameConverter : JsonConverter +{ + public override Name Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "google-auto-tagging" => Name.GoogleAutoTagging, + "aws-auto-tagging" => Name.AwsAutoTagging, + _ => (Name)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Name value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + Name.GoogleAutoTagging => "google-auto-tagging", + Name.AwsAutoTagging => "aws-auto-tagging", + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/RemoveBg.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/RemoveBg.cs new file mode 100644 index 00000000..68223612 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/RemoveBg.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files.FileUploadParamsProperties.ExtensionProperties.RemoveBgProperties; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.ExtensionProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class RemoveBg : ModelBase, IFromRaw +{ + /// + /// Specifies the background removal extension. + /// + public JsonElement Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + throw new ArgumentOutOfRangeException("name", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public Options? Options + { + get + { + if (!this.Properties.TryGetValue("options", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["options"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.Options?.Validate(); + } + + public RemoveBg() + { + this.Name = JsonSerializer.Deserialize("\"remove-bg\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + RemoveBg(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static RemoveBg FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/RemoveBgProperties/Options.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/RemoveBgProperties/Options.cs new file mode 100644 index 00000000..7f5799e6 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/RemoveBgProperties/Options.cs @@ -0,0 +1,122 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.ExtensionProperties.RemoveBgProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Options : ModelBase, IFromRaw +{ + /// + /// Whether to add an artificial shadow to the result. Default is false. Note: + /// Adding shadows is currently only supported for car photos. + /// + public bool? AddShadow + { + get + { + if (!this.Properties.TryGetValue("add_shadow", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["add_shadow"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies a solid color background using hex code (e.g., "81d4fa", "fff") + /// or color name (e.g., "green"). If this parameter is set, `bg_image_url` must + /// be empty. + /// + public string? BgColor + { + get + { + if (!this.Properties.TryGetValue("bg_color", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["bg_color"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Sets a background image from a URL. If this parameter is set, `bg_color` + /// must be empty. + /// + public string? BgImageURL + { + get + { + if (!this.Properties.TryGetValue("bg_image_url", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["bg_image_url"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Allows semi-transparent regions in the result. Default is true. Note: Semitransparency + /// is currently only supported for car windows. + /// + public bool? Semitransparency + { + get + { + if (!this.Properties.TryGetValue("semitransparency", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["semitransparency"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.AddShadow; + _ = this.BgColor; + _ = this.BgImageURL; + _ = this.Semitransparency; + } + + public Options() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Options(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Options FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionVariants/All.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionVariants/All.cs new file mode 100644 index 00000000..b312f63e --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionVariants/All.cs @@ -0,0 +1,46 @@ +using System.Text.Json; +using ExtensionProperties = Imagekit.Models.Files.FileUploadParamsProperties.ExtensionProperties; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.ExtensionVariants; + +public sealed record class RemoveBg(ExtensionProperties::RemoveBg Value) + : Extension, + IVariant +{ + public static RemoveBg From(ExtensionProperties::RemoveBg value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class AutoTaggingExtension(ExtensionProperties::AutoTaggingExtension Value) + : Extension, + IVariant +{ + public static AutoTaggingExtension From(ExtensionProperties::AutoTaggingExtension value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class AIAutoDescription(JsonElement Value) + : Extension, + IVariant +{ + public static AIAutoDescription From(JsonElement value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/ResponseField.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/ResponseField.cs new file mode 100644 index 00000000..c5b5b8f7 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/ResponseField.cs @@ -0,0 +1,62 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.FileUploadParamsProperties; + +[JsonConverter(typeof(ResponseFieldConverter))] +public enum ResponseField +{ + Tags, + CustomCoordinates, + IsPrivateFile, + EmbeddedMetadata, + IsPublished, + CustomMetadata, + Metadata, +} + +sealed class ResponseFieldConverter : JsonConverter +{ + public override ResponseField Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "tags" => ResponseField.Tags, + "customCoordinates" => ResponseField.CustomCoordinates, + "isPrivateFile" => ResponseField.IsPrivateFile, + "embeddedMetadata" => ResponseField.EmbeddedMetadata, + "isPublished" => ResponseField.IsPublished, + "customMetadata" => ResponseField.CustomMetadata, + "metadata" => ResponseField.Metadata, + _ => (ResponseField)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ResponseField value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ResponseField.Tags => "tags", + ResponseField.CustomCoordinates => "customCoordinates", + ResponseField.IsPrivateFile => "isPrivateFile", + ResponseField.EmbeddedMetadata => "embeddedMetadata", + ResponseField.IsPublished => "isPublished", + ResponseField.CustomMetadata => "customMetadata", + ResponseField.Metadata => "metadata", + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/Transformation.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/Transformation.cs new file mode 100644 index 00000000..e8cdd4c6 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/Transformation.cs @@ -0,0 +1,92 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties; + +namespace Imagekit.Models.Files.FileUploadParamsProperties; + +/// +/// Configure pre-processing (`pre`) and post-processing (`post`) transformations. +/// +/// - `pre` — applied before the file is uploaded to the Media Library. Useful +/// for reducing file size or applying basic optimizations upfront (e.g., resize, compress). +/// +/// - `post` — applied immediately after upload. Ideal for generating transformed +/// versions (like video encodes or thumbnails) in advance, so they're ready for +/// delivery without delay. +/// +/// You can mix and match any combination of post-processing types. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class Transformation : ModelBase, IFromRaw +{ + /// + /// List of transformations to apply *after* the file is uploaded. Each item + /// must match one of the following types: `transformation`, `gif-to-video`, + /// `thumbnail`, `abs`. + /// + public List? Post + { + get + { + if (!this.Properties.TryGetValue("post", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["post"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Transformation string to apply before uploading the file to the Media Library. + /// Useful for optimizing files at ingestion. + /// + public string? Pre + { + get + { + if (!this.Properties.TryGetValue("pre", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["pre"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + foreach (var item in this.Post ?? []) + { + item.Validate(); + } + _ = this.Pre; + } + + public Transformation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Transformation(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Transformation FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/Post.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/Post.cs new file mode 100644 index 00000000..9f7a1ec3 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/Post.cs @@ -0,0 +1,225 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using PostProperties = Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; +using PostVariants = Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostVariants; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties; + +[JsonConverter(typeof(PostConverter))] +public abstract record class Post +{ + internal Post() { } + + public static implicit operator Post(PostProperties::Transformation value) => + new PostVariants::Transformation(value); + + public static implicit operator Post(PostProperties::GifToVideo value) => + new PostVariants::GifToVideo(value); + + public static implicit operator Post(PostProperties::Thumbnail value) => + new PostVariants::Thumbnail(value); + + public static implicit operator Post(PostProperties::Abs value) => new PostVariants::Abs(value); + + public bool TryPickTransformation([NotNullWhen(true)] out PostProperties::Transformation? value) + { + value = (this as PostVariants::Transformation)?.Value; + return value != null; + } + + public bool TryPickGifToVideo([NotNullWhen(true)] out PostProperties::GifToVideo? value) + { + value = (this as PostVariants::GifToVideo)?.Value; + return value != null; + } + + public bool TryPickThumbnail([NotNullWhen(true)] out PostProperties::Thumbnail? value) + { + value = (this as PostVariants::Thumbnail)?.Value; + return value != null; + } + + public bool TryPickAbs([NotNullWhen(true)] out PostProperties::Abs? value) + { + value = (this as PostVariants::Abs)?.Value; + return value != null; + } + + public void Switch( + Action transformation, + Action gifToVideo, + Action thumbnail, + Action abs + ) + { + switch (this) + { + case PostVariants::Transformation inner: + transformation(inner); + break; + case PostVariants::GifToVideo inner: + gifToVideo(inner); + break; + case PostVariants::Thumbnail inner: + thumbnail(inner); + break; + case PostVariants::Abs inner: + abs(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func transformation, + Func gifToVideo, + Func thumbnail, + Func abs + ) + { + return this switch + { + PostVariants::Transformation inner => transformation(inner), + PostVariants::GifToVideo inner => gifToVideo(inner), + PostVariants::Thumbnail inner => thumbnail(inner), + PostVariants::Abs inner => abs(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class PostConverter : JsonConverter +{ + public override Post? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var json = JsonSerializer.Deserialize(ref reader, options); + string? type; + try + { + type = json.GetProperty("type").GetString(); + } + catch + { + type = null; + } + + switch (type) + { + case "transformation": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize( + json, + options + ); + if (deserialized != null) + { + return new PostVariants::Transformation(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "gif-to-video": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize( + json, + options + ); + if (deserialized != null) + { + return new PostVariants::GifToVideo(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "thumbnail": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize( + json, + options + ); + if (deserialized != null) + { + return new PostVariants::Thumbnail(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "abs": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize( + json, + options + ); + if (deserialized != null) + { + return new PostVariants::Abs(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + default: + { + throw new Exception(); + } + } + } + + public override void Write(Utf8JsonWriter writer, Post value, JsonSerializerOptions options) + { + object variant = value switch + { + PostVariants::Transformation(var transformation) => transformation, + PostVariants::GifToVideo(var gifToVideo) => gifToVideo, + PostVariants::Thumbnail(var thumbnail) => thumbnail, + PostVariants::Abs(var abs) => abs, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Abs.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Abs.cs new file mode 100644 index 00000000..10c95b3c --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Abs.cs @@ -0,0 +1,103 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.AbsProperties; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Abs : ModelBase, IFromRaw +{ + /// + /// Streaming protocol to use (`hls` or `dash`). + /// + public required ApiEnum Protocol + { + get + { + if (!this.Properties.TryGetValue("protocol", out JsonElement element)) + throw new ArgumentOutOfRangeException("protocol", "Missing required argument"); + + return JsonSerializer.Deserialize>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["protocol"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Adaptive Bitrate Streaming (ABS) setup. + /// + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// List of different representations you want to create separated by an underscore. + /// + public required string Value + { + get + { + if (!this.Properties.TryGetValue("value", out JsonElement element)) + throw new ArgumentOutOfRangeException("value", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("value"); + } + set + { + this.Properties["value"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.Protocol.Validate(); + _ = this.Value; + } + + public Abs() + { + this.Type = JsonSerializer.Deserialize("\"abs\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Abs(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Abs FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs new file mode 100644 index 00000000..56d80f9f --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs @@ -0,0 +1,46 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.AbsProperties; + +/// +/// Streaming protocol to use (`hls` or `dash`). +/// +[JsonConverter(typeof(ProtocolConverter))] +public enum Protocol +{ + Hls, + Dash, +} + +sealed class ProtocolConverter : JsonConverter +{ + public override Protocol Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "hls" => Protocol.Hls, + "dash" => Protocol.Dash, + _ => (Protocol)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Protocol value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + Protocol.Hls => "hls", + Protocol.Dash => "dash", + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideo.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideo.cs new file mode 100644 index 00000000..44e57f2a --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideo.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class GifToVideo : ModelBase, IFromRaw +{ + /// + /// Converts an animated GIF into an MP4. + /// + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Optional transformation string to apply to the output video. **Example**: + /// `q-80` + /// + public string? Value + { + get + { + if (!this.Properties.TryGetValue("value", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["value"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.Value; + } + + public GifToVideo() + { + this.Type = JsonSerializer.Deserialize("\"gif-to-video\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GifToVideo(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static GifToVideo FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Thumbnail.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Thumbnail.cs new file mode 100644 index 00000000..879f27c1 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Thumbnail.cs @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Thumbnail : ModelBase, IFromRaw +{ + /// + /// Generates a thumbnail image. + /// + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Optional transformation string. **Example**: `w-150,h-150` + /// + public string? Value + { + get + { + if (!this.Properties.TryGetValue("value", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["value"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.Value; + } + + public Thumbnail() + { + this.Type = JsonSerializer.Deserialize("\"thumbnail\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Thumbnail(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Thumbnail FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Transformation.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Transformation.cs new file mode 100644 index 00000000..b68c748b --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Transformation.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Transformation : ModelBase, IFromRaw +{ + /// + /// Transformation type. + /// + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Transformation string (e.g. `w-200,h-200`). Same syntax as ImageKit URL-based + /// transformations. + /// + public required string Value + { + get + { + if (!this.Properties.TryGetValue("value", out JsonElement element)) + throw new ArgumentOutOfRangeException("value", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("value"); + } + set + { + this.Properties["value"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.Value; + } + + public Transformation() + { + this.Type = JsonSerializer.Deserialize("\"transformation\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Transformation(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Transformation FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public Transformation(string value) + : this() + { + this.Value = value; + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostVariants/All.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostVariants/All.cs new file mode 100644 index 00000000..ae864596 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostVariants/All.cs @@ -0,0 +1,61 @@ +using PostProperties = Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostVariants; + +public sealed record class Transformation(PostProperties::Transformation Value) + : Post, + IVariant +{ + public static Transformation From(PostProperties::Transformation value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class GifToVideo(PostProperties::GifToVideo Value) + : Post, + IVariant +{ + public static GifToVideo From(PostProperties::GifToVideo value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class Thumbnail(PostProperties::Thumbnail Value) + : Post, + IVariant +{ + public static Thumbnail From(PostProperties::Thumbnail value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class Abs(PostProperties::Abs Value) : Post, IVariant +{ + public static Abs From(PostProperties::Abs value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadResponse.cs b/src/Imagekit/Models/Files/FileUploadResponse.cs new file mode 100644 index 00000000..1321dab1 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadResponse.cs @@ -0,0 +1,612 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files.FileUploadResponseProperties; + +namespace Imagekit.Models.Files; + +/// +/// Object containing details of a successful upload. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class FileUploadResponse : ModelBase, IFromRaw +{ + /// + /// An array of tags assigned to the uploaded file by auto tagging. + /// + public List? AITags + { + get + { + if (!this.Properties.TryGetValue("AITags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["AITags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The audio codec used in the video (only for video). + /// + public string? AudioCodec + { + get + { + if (!this.Properties.TryGetValue("audioCodec", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["audioCodec"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The bit rate of the video in kbps (only for video). + /// + public long? BitRate + { + get + { + if (!this.Properties.TryGetValue("bitRate", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["bitRate"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Value of custom coordinates associated with the image in the format `x,y,width,height`. + /// If `customCoordinates` are not defined, then it is `null`. Send `customCoordinates` + /// in `responseFields` in API request to get the value of this field. + /// + public string? CustomCoordinates + { + get + { + if (!this.Properties.TryGetValue("customCoordinates", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["customCoordinates"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// A key-value data associated with the asset. Use `responseField` in API request + /// to get `customMetadata` in the upload API response. Before setting any custom + /// metadata on an asset, you have to create the field using custom metadata + /// fields API. Send `customMetadata` in `responseFields` in API request to get + /// the value of this field. + /// + public Dictionary? CustomMetadata + { + get + { + if (!this.Properties.TryGetValue("customMetadata", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["customMetadata"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Optional text to describe the contents of the file. Can be set by the user + /// or the ai-auto-description extension. + /// + public string? Description + { + get + { + if (!this.Properties.TryGetValue("description", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["description"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The duration of the video in seconds (only for video). + /// + public long? Duration + { + get + { + if (!this.Properties.TryGetValue("duration", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["duration"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Consolidated embedded metadata associated with the file. It includes exif, + /// iptc, and xmp data. Send `embeddedMetadata` in `responseFields` in API request + /// to get embeddedMetadata in the upload API response. + /// + public Dictionary? EmbeddedMetadata + { + get + { + if (!this.Properties.TryGetValue("embeddedMetadata", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["embeddedMetadata"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Extension names with their processing status at the time of completion of + /// the request. It could have one of the following status values: + /// + /// `success`: The extension has been successfully applied. `failed`: The extension + /// has failed and will not be retried. `pending`: The extension will finish processing + /// in some time. On completion, the final status (success / failed) will be sent + /// to the `webhookUrl` provided. + /// + /// If no extension was requested, then this parameter is not returned. + /// + public ExtensionStatus? ExtensionStatus + { + get + { + if (!this.Properties.TryGetValue("extensionStatus", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["extensionStatus"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Unique fileId. Store this fileld in your database, as this will be used to + /// perform update action on this file. + /// + public string? FileID + { + get + { + if (!this.Properties.TryGetValue("fileId", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["fileId"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The relative path of the file in the media library e.g. `/marketing-assets/new-banner.jpg`. + /// + public string? FilePath + { + get + { + if (!this.Properties.TryGetValue("filePath", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["filePath"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Type of the uploaded file. Possible values are `image`, `non-image`. + /// + public string? FileType + { + get + { + if (!this.Properties.TryGetValue("fileType", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["fileType"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Height of the image in pixels (Only for images) + /// + public double? Height + { + get + { + if (!this.Properties.TryGetValue("height", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["height"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Is the file marked as private. It can be either `true` or `false`. Send `isPrivateFile` + /// in `responseFields` in API request to get the value of this field. + /// + public bool? IsPrivateFile + { + get + { + if (!this.Properties.TryGetValue("isPrivateFile", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["isPrivateFile"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Is the file published or in draft state. It can be either `true` or `false`. + /// Send `isPublished` in `responseFields` in API request to get the value of + /// this field. + /// + public bool? IsPublished + { + get + { + if (!this.Properties.TryGetValue("isPublished", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["isPublished"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Legacy metadata. Send `metadata` in `responseFields` in API request to get + /// metadata in the upload API response. + /// + public Metadata? Metadata + { + get + { + if (!this.Properties.TryGetValue("metadata", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["metadata"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Name of the asset. + /// + public string? Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Size of the image file in Bytes. + /// + public double? Size + { + get + { + if (!this.Properties.TryGetValue("size", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["size"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The array of tags associated with the asset. If no tags are set, it will + /// be `null`. Send `tags` in `responseFields` in API request to get the value + /// of this field. + /// + public List? Tags + { + get + { + if (!this.Properties.TryGetValue("tags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["tags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// In the case of an image, a small thumbnail URL. + /// + public string? ThumbnailURL + { + get + { + if (!this.Properties.TryGetValue("thumbnailUrl", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["thumbnailUrl"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// A publicly accessible URL of the file. + /// + public string? URL + { + get + { + if (!this.Properties.TryGetValue("url", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["url"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// An object containing the file or file version's `id` (versionId) and `name`. + /// + public VersionInfo? VersionInfo + { + get + { + if (!this.Properties.TryGetValue("versionInfo", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["versionInfo"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The video codec used in the video (only for video). + /// + public string? VideoCodec + { + get + { + if (!this.Properties.TryGetValue("videoCodec", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["videoCodec"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Width of the image in pixels (Only for Images) + /// + public double? Width + { + get + { + if (!this.Properties.TryGetValue("width", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["width"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + foreach (var item in this.AITags ?? []) + { + item.Validate(); + } + _ = this.AudioCodec; + _ = this.BitRate; + _ = this.CustomCoordinates; + if (this.CustomMetadata != null) + { + foreach (var item in this.CustomMetadata.Values) + { + _ = item; + } + } + _ = this.Description; + _ = this.Duration; + if (this.EmbeddedMetadata != null) + { + foreach (var item in this.EmbeddedMetadata.Values) + { + _ = item; + } + } + this.ExtensionStatus?.Validate(); + _ = this.FileID; + _ = this.FilePath; + _ = this.FileType; + _ = this.Height; + _ = this.IsPrivateFile; + _ = this.IsPublished; + this.Metadata?.Validate(); + _ = this.Name; + _ = this.Size; + foreach (var item in this.Tags ?? []) + { + _ = item; + } + _ = this.ThumbnailURL; + _ = this.URL; + this.VersionInfo?.Validate(); + _ = this.VideoCodec; + _ = this.Width; + } + + public FileUploadResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FileUploadResponse(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static FileUploadResponse FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadResponseProperties/AITag.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/AITag.cs new file mode 100644 index 00000000..bbe9e966 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadResponseProperties/AITag.cs @@ -0,0 +1,96 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.FileUploadResponseProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class AITag : ModelBase, IFromRaw +{ + /// + /// Confidence score of the tag. + /// + public double? Confidence + { + get + { + if (!this.Properties.TryGetValue("confidence", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["confidence"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Name of the tag. + /// + public string? Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Array of `AITags` associated with the image. If no `AITags` are set, it will + /// be null. These tags can be added using the `google-auto-tagging` or `aws-auto-tagging` extensions. + /// + public string? Source + { + get + { + if (!this.Properties.TryGetValue("source", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["source"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.Confidence; + _ = this.Name; + _ = this.Source; + } + + public AITag() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + AITag(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static AITag FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadResponseProperties/ExtensionStatus.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/ExtensionStatus.cs new file mode 100644 index 00000000..a742a8b7 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadResponseProperties/ExtensionStatus.cs @@ -0,0 +1,129 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files.FileUploadResponseProperties.ExtensionStatusProperties; + +namespace Imagekit.Models.Files.FileUploadResponseProperties; + +/// +/// Extension names with their processing status at the time of completion of the +/// request. It could have one of the following status values: +/// +/// `success`: The extension has been successfully applied. `failed`: The extension +/// has failed and will not be retried. `pending`: The extension will finish processing +/// in some time. On completion, the final status (success / failed) will be sent +/// to the `webhookUrl` provided. +/// +/// If no extension was requested, then this parameter is not returned. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class ExtensionStatus : ModelBase, IFromRaw +{ + public ApiEnum? AIAutoDescription + { + get + { + if (!this.Properties.TryGetValue("ai-auto-description", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["ai-auto-description"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public ApiEnum? AwsAutoTagging + { + get + { + if (!this.Properties.TryGetValue("aws-auto-tagging", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["aws-auto-tagging"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public ApiEnum? GoogleAutoTagging + { + get + { + if (!this.Properties.TryGetValue("google-auto-tagging", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["google-auto-tagging"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public ApiEnum? RemoveBg + { + get + { + if (!this.Properties.TryGetValue("remove-bg", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["remove-bg"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.AIAutoDescription?.Validate(); + this.AwsAutoTagging?.Validate(); + this.GoogleAutoTagging?.Validate(); + this.RemoveBg?.Validate(); + } + + public ExtensionStatus() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ExtensionStatus(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static ExtensionStatus FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadResponseProperties/ExtensionStatusProperties/AIAutoDescription.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/ExtensionStatusProperties/AIAutoDescription.cs new file mode 100644 index 00000000..6a9e6728 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadResponseProperties/ExtensionStatusProperties/AIAutoDescription.cs @@ -0,0 +1,50 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.FileUploadResponseProperties.ExtensionStatusProperties; + +[JsonConverter(typeof(AIAutoDescriptionConverter))] +public enum AIAutoDescription +{ + Success, + Pending, + Failed, +} + +sealed class AIAutoDescriptionConverter : JsonConverter +{ + public override AIAutoDescription Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "success" => AIAutoDescription.Success, + "pending" => AIAutoDescription.Pending, + "failed" => AIAutoDescription.Failed, + _ => (AIAutoDescription)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + AIAutoDescription value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + AIAutoDescription.Success => "success", + AIAutoDescription.Pending => "pending", + AIAutoDescription.Failed => "failed", + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadResponseProperties/ExtensionStatusProperties/AwsAutoTagging.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/ExtensionStatusProperties/AwsAutoTagging.cs new file mode 100644 index 00000000..b1faf17d --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadResponseProperties/ExtensionStatusProperties/AwsAutoTagging.cs @@ -0,0 +1,50 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.FileUploadResponseProperties.ExtensionStatusProperties; + +[JsonConverter(typeof(AwsAutoTaggingConverter))] +public enum AwsAutoTagging +{ + Success, + Pending, + Failed, +} + +sealed class AwsAutoTaggingConverter : JsonConverter +{ + public override AwsAutoTagging Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "success" => AwsAutoTagging.Success, + "pending" => AwsAutoTagging.Pending, + "failed" => AwsAutoTagging.Failed, + _ => (AwsAutoTagging)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + AwsAutoTagging value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + AwsAutoTagging.Success => "success", + AwsAutoTagging.Pending => "pending", + AwsAutoTagging.Failed => "failed", + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadResponseProperties/ExtensionStatusProperties/GoogleAutoTagging.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/ExtensionStatusProperties/GoogleAutoTagging.cs new file mode 100644 index 00000000..3de49b9f --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadResponseProperties/ExtensionStatusProperties/GoogleAutoTagging.cs @@ -0,0 +1,50 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.FileUploadResponseProperties.ExtensionStatusProperties; + +[JsonConverter(typeof(GoogleAutoTaggingConverter))] +public enum GoogleAutoTagging +{ + Success, + Pending, + Failed, +} + +sealed class GoogleAutoTaggingConverter : JsonConverter +{ + public override GoogleAutoTagging Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "success" => GoogleAutoTagging.Success, + "pending" => GoogleAutoTagging.Pending, + "failed" => GoogleAutoTagging.Failed, + _ => (GoogleAutoTagging)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + GoogleAutoTagging value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + GoogleAutoTagging.Success => "success", + GoogleAutoTagging.Pending => "pending", + GoogleAutoTagging.Failed => "failed", + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadResponseProperties/ExtensionStatusProperties/RemoveBg.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/ExtensionStatusProperties/RemoveBg.cs new file mode 100644 index 00000000..08d97e52 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadResponseProperties/ExtensionStatusProperties/RemoveBg.cs @@ -0,0 +1,46 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.FileUploadResponseProperties.ExtensionStatusProperties; + +[JsonConverter(typeof(RemoveBgConverter))] +public enum RemoveBg +{ + Success, + Pending, + Failed, +} + +sealed class RemoveBgConverter : JsonConverter +{ + public override RemoveBg Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "success" => RemoveBg.Success, + "pending" => RemoveBg.Pending, + "failed" => RemoveBg.Failed, + _ => (RemoveBg)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, RemoveBg value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + RemoveBg.Success => "success", + RemoveBg.Pending => "pending", + RemoveBg.Failed => "failed", + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadResponseProperties/VersionInfo.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/VersionInfo.cs new file mode 100644 index 00000000..a54f4050 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadResponseProperties/VersionInfo.cs @@ -0,0 +1,76 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.FileUploadResponseProperties; + +/// +/// An object containing the file or file version's `id` (versionId) and `name`. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class VersionInfo : ModelBase, IFromRaw +{ + /// + /// Unique identifier of the file version. + /// + public string? ID + { + get + { + if (!this.Properties.TryGetValue("id", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["id"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Name of the file version. + /// + public string? Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.ID; + _ = this.Name; + } + + public VersionInfo() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + VersionInfo(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static VersionInfo FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/Folder.cs b/src/Imagekit/Models/Files/Folder.cs new file mode 100644 index 00000000..5a3d957c --- /dev/null +++ b/src/Imagekit/Models/Files/Folder.cs @@ -0,0 +1,171 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using FolderProperties = Imagekit.Models.Files.FolderProperties; + +namespace Imagekit.Models.Files; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Folder : ModelBase, IFromRaw +{ + /// + /// Date and time when the folder was created. The date and time is in ISO8601 + /// format. + /// + public DateTime? CreatedAt + { + get + { + if (!this.Properties.TryGetValue("createdAt", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["createdAt"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Unique identifier of the asset. + /// + public string? FolderID + { + get + { + if (!this.Properties.TryGetValue("folderId", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["folderId"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Path of the folder. This is the path you would use in the URL to access the + /// folder. For example, if the folder is at the root of the media library, the + /// path will be /folder. If the folder is inside another folder named images, + /// the path will be /images/folder. + /// + public string? FolderPath + { + get + { + if (!this.Properties.TryGetValue("folderPath", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["folderPath"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Name of the asset. + /// + public string? Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Type of the asset. + /// + public ApiEnum? Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Date and time when the folder was last updated. The date and time is in ISO8601 + /// format. + /// + public DateTime? UpdatedAt + { + get + { + if (!this.Properties.TryGetValue("updatedAt", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["updatedAt"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.CreatedAt; + _ = this.FolderID; + _ = this.FolderPath; + _ = this.Name; + this.Type?.Validate(); + _ = this.UpdatedAt; + } + + public Folder() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Folder(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Folder FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/FolderProperties/Type.cs b/src/Imagekit/Models/Files/FolderProperties/Type.cs new file mode 100644 index 00000000..0d97363d --- /dev/null +++ b/src/Imagekit/Models/Files/FolderProperties/Type.cs @@ -0,0 +1,43 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using System = System; + +namespace Imagekit.Models.Files.FolderProperties; + +/// +/// Type of the asset. +/// +[JsonConverter(typeof(TypeConverter))] +public enum Type +{ + Folder, +} + +sealed class TypeConverter : JsonConverter +{ + public override Type Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "folder" => FolderProperties.Type.Folder, + _ => (Type)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + FolderProperties.Type.Folder => "folder", + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Files/Metadata.cs b/src/Imagekit/Models/Files/Metadata.cs new file mode 100644 index 00000000..8c59db4f --- /dev/null +++ b/src/Imagekit/Models/Files/Metadata.cs @@ -0,0 +1,338 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files.MetadataProperties; + +namespace Imagekit.Models.Files; + +/// +/// JSON object containing metadata. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class Metadata : ModelBase, IFromRaw +{ + /// + /// The audio codec used in the video (only for video). + /// + public string? AudioCodec + { + get + { + if (!this.Properties.TryGetValue("audioCodec", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["audioCodec"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The bit rate of the video in kbps (only for video). + /// + public long? BitRate + { + get + { + if (!this.Properties.TryGetValue("bitRate", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["bitRate"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The density of the image in DPI. + /// + public long? Density + { + get + { + if (!this.Properties.TryGetValue("density", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["density"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The duration of the video in seconds (only for video). + /// + public long? Duration + { + get + { + if (!this.Properties.TryGetValue("duration", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["duration"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public Exif? Exif + { + get + { + if (!this.Properties.TryGetValue("exif", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["exif"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The format of the file (e.g., 'jpg', 'mp4'). + /// + public string? Format + { + get + { + if (!this.Properties.TryGetValue("format", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["format"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Indicates if the image has a color profile. + /// + public bool? HasColorProfile + { + get + { + if (!this.Properties.TryGetValue("hasColorProfile", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["hasColorProfile"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Indicates if the image contains transparent areas. + /// + public bool? HasTransparency + { + get + { + if (!this.Properties.TryGetValue("hasTransparency", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["hasTransparency"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The height of the image or video in pixels. + /// + public long? Height + { + get + { + if (!this.Properties.TryGetValue("height", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["height"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Perceptual hash of the image. + /// + public string? PHash + { + get + { + if (!this.Properties.TryGetValue("pHash", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["pHash"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The quality indicator of the image. + /// + public long? Quality + { + get + { + if (!this.Properties.TryGetValue("quality", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["quality"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The file size in bytes. + /// + public long? Size + { + get + { + if (!this.Properties.TryGetValue("size", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["size"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The video codec used in the video (only for video). + /// + public string? VideoCodec + { + get + { + if (!this.Properties.TryGetValue("videoCodec", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["videoCodec"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The width of the image or video in pixels. + /// + public long? Width + { + get + { + if (!this.Properties.TryGetValue("width", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["width"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.AudioCodec; + _ = this.BitRate; + _ = this.Density; + _ = this.Duration; + this.Exif?.Validate(); + _ = this.Format; + _ = this.HasColorProfile; + _ = this.HasTransparency; + _ = this.Height; + _ = this.PHash; + _ = this.Quality; + _ = this.Size; + _ = this.VideoCodec; + _ = this.Width; + } + + public Metadata() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Metadata(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Metadata FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/Metadata/MetadataGetFromURLParams.cs b/src/Imagekit/Models/Files/Metadata/MetadataGetFromURLParams.cs new file mode 100644 index 00000000..45993ec0 --- /dev/null +++ b/src/Imagekit/Models/Files/Metadata/MetadataGetFromURLParams.cs @@ -0,0 +1,52 @@ +using System; +using System.Net.Http; +using System.Text.Json; + +namespace Imagekit.Models.Files.Metadata; + +/// +/// Get image EXIF, pHash, and other metadata from ImageKit.io powered remote URL +/// using this API. +/// +public sealed record class MetadataGetFromURLParams : ParamsBase +{ + /// + /// Should be a valid file URL. It should be accessible using your ImageKit.io + /// account. + /// + public required string URL + { + get + { + if (!this.QueryProperties.TryGetValue("url", out JsonElement element)) + throw new ArgumentOutOfRangeException("url", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("url"); + } + set + { + this.QueryProperties["url"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override Uri Url(IImageKitClient client) + { + return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/files/metadata") + { + Query = this.QueryString(client), + }.Uri; + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/Files/Metadata/MetadataGetParams.cs b/src/Imagekit/Models/Files/Metadata/MetadataGetParams.cs new file mode 100644 index 00000000..acd20a10 --- /dev/null +++ b/src/Imagekit/Models/Files/Metadata/MetadataGetParams.cs @@ -0,0 +1,36 @@ +using System; +using System.Net.Http; + +namespace Imagekit.Models.Files.Metadata; + +/// +/// You can programmatically get image EXIF, pHash, and other metadata for uploaded +/// files in the ImageKit.io media library using this API. +/// +/// You can also get the metadata in upload API response by passing `metadata` in +/// `responseFields` parameter. +/// +public sealed record class MetadataGetParams : ParamsBase +{ + public required string FileID; + + public override Uri Url(IImageKitClient client) + { + return new UriBuilder( + client.BaseUrl.ToString().TrimEnd('/') + + string.Format("/v1/files/{0}/metadata", this.FileID) + ) + { + Query = this.QueryString(client), + }.Uri; + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/Files/MetadataProperties/Exif.cs b/src/Imagekit/Models/Files/MetadataProperties/Exif.cs new file mode 100644 index 00000000..db2ed74c --- /dev/null +++ b/src/Imagekit/Models/Files/MetadataProperties/Exif.cs @@ -0,0 +1,183 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ExifProperties = Imagekit.Models.Files.MetadataProperties.ExifProperties; + +namespace Imagekit.Models.Files.MetadataProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Exif : ModelBase, IFromRaw +{ + /// + /// Object containing Exif details. + /// + public ExifProperties::Exif? Exif1 + { + get + { + if (!this.Properties.TryGetValue("exif", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["exif"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Object containing GPS information. + /// + public ExifProperties::Gps? Gps + { + get + { + if (!this.Properties.TryGetValue("gps", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["gps"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Object containing EXIF image information. + /// + public ExifProperties::Image? Image + { + get + { + if (!this.Properties.TryGetValue("image", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["image"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// JSON object. + /// + public ExifProperties::Interoperability? Interoperability + { + get + { + if (!this.Properties.TryGetValue("interoperability", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["interoperability"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public Dictionary? Makernote + { + get + { + if (!this.Properties.TryGetValue("makernote", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["makernote"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Object containing Thumbnail information. + /// + public ExifProperties::Thumbnail? Thumbnail + { + get + { + if (!this.Properties.TryGetValue("thumbnail", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["thumbnail"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.Exif1?.Validate(); + this.Gps?.Validate(); + this.Image?.Validate(); + this.Interoperability?.Validate(); + if (this.Makernote != null) + { + foreach (var item in this.Makernote.Values) + { + _ = item; + } + } + this.Thumbnail?.Validate(); + } + + public Exif() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Exif(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Exif FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/MetadataProperties/ExifProperties/Exif.cs b/src/Imagekit/Models/Files/MetadataProperties/ExifProperties/Exif.cs new file mode 100644 index 00000000..2f1827b7 --- /dev/null +++ b/src/Imagekit/Models/Files/MetadataProperties/ExifProperties/Exif.cs @@ -0,0 +1,526 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.MetadataProperties.ExifProperties; + +/// +/// Object containing Exif details. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class Exif : ModelBase, IFromRaw +{ + public double? ApertureValue + { + get + { + if (!this.Properties.TryGetValue("ApertureValue", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["ApertureValue"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public long? ColorSpace + { + get + { + if (!this.Properties.TryGetValue("ColorSpace", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["ColorSpace"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public string? CreateDate + { + get + { + if (!this.Properties.TryGetValue("CreateDate", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["CreateDate"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public long? CustomRendered + { + get + { + if (!this.Properties.TryGetValue("CustomRendered", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["CustomRendered"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public string? DateTimeOriginal + { + get + { + if (!this.Properties.TryGetValue("DateTimeOriginal", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["DateTimeOriginal"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public long? ExifImageHeight + { + get + { + if (!this.Properties.TryGetValue("ExifImageHeight", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["ExifImageHeight"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public long? ExifImageWidth + { + get + { + if (!this.Properties.TryGetValue("ExifImageWidth", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["ExifImageWidth"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public string? ExifVersion + { + get + { + if (!this.Properties.TryGetValue("ExifVersion", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["ExifVersion"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public double? ExposureCompensation + { + get + { + if (!this.Properties.TryGetValue("ExposureCompensation", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["ExposureCompensation"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public long? ExposureMode + { + get + { + if (!this.Properties.TryGetValue("ExposureMode", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["ExposureMode"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public long? ExposureProgram + { + get + { + if (!this.Properties.TryGetValue("ExposureProgram", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["ExposureProgram"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public double? ExposureTime + { + get + { + if (!this.Properties.TryGetValue("ExposureTime", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["ExposureTime"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public long? Flash + { + get + { + if (!this.Properties.TryGetValue("Flash", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["Flash"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public string? FlashpixVersion + { + get + { + if (!this.Properties.TryGetValue("FlashpixVersion", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["FlashpixVersion"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public double? FNumber + { + get + { + if (!this.Properties.TryGetValue("FNumber", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["FNumber"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public long? FocalLength + { + get + { + if (!this.Properties.TryGetValue("FocalLength", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["FocalLength"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public long? FocalPlaneResolutionUnit + { + get + { + if (!this.Properties.TryGetValue("FocalPlaneResolutionUnit", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["FocalPlaneResolutionUnit"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public double? FocalPlaneXResolution + { + get + { + if (!this.Properties.TryGetValue("FocalPlaneXResolution", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["FocalPlaneXResolution"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public double? FocalPlaneYResolution + { + get + { + if (!this.Properties.TryGetValue("FocalPlaneYResolution", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["FocalPlaneYResolution"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public long? InteropOffset + { + get + { + if (!this.Properties.TryGetValue("InteropOffset", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["InteropOffset"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public long? ISO + { + get + { + if (!this.Properties.TryGetValue("ISO", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["ISO"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public long? MeteringMode + { + get + { + if (!this.Properties.TryGetValue("MeteringMode", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["MeteringMode"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public long? SceneCaptureType + { + get + { + if (!this.Properties.TryGetValue("SceneCaptureType", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["SceneCaptureType"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public double? ShutterSpeedValue + { + get + { + if (!this.Properties.TryGetValue("ShutterSpeedValue", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["ShutterSpeedValue"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public string? SubSecTime + { + get + { + if (!this.Properties.TryGetValue("SubSecTime", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["SubSecTime"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public long? WhiteBalance + { + get + { + if (!this.Properties.TryGetValue("WhiteBalance", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["WhiteBalance"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.ApertureValue; + _ = this.ColorSpace; + _ = this.CreateDate; + _ = this.CustomRendered; + _ = this.DateTimeOriginal; + _ = this.ExifImageHeight; + _ = this.ExifImageWidth; + _ = this.ExifVersion; + _ = this.ExposureCompensation; + _ = this.ExposureMode; + _ = this.ExposureProgram; + _ = this.ExposureTime; + _ = this.Flash; + _ = this.FlashpixVersion; + _ = this.FNumber; + _ = this.FocalLength; + _ = this.FocalPlaneResolutionUnit; + _ = this.FocalPlaneXResolution; + _ = this.FocalPlaneYResolution; + _ = this.InteropOffset; + _ = this.ISO; + _ = this.MeteringMode; + _ = this.SceneCaptureType; + _ = this.ShutterSpeedValue; + _ = this.SubSecTime; + _ = this.WhiteBalance; + } + + public Exif() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Exif(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Exif FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/MetadataProperties/ExifProperties/Gps.cs b/src/Imagekit/Models/Files/MetadataProperties/ExifProperties/Gps.cs new file mode 100644 index 00000000..aa6d03c1 --- /dev/null +++ b/src/Imagekit/Models/Files/MetadataProperties/ExifProperties/Gps.cs @@ -0,0 +1,54 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.MetadataProperties.ExifProperties; + +/// +/// Object containing GPS information. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class Gps : ModelBase, IFromRaw +{ + public List? GpsVersionID + { + get + { + if (!this.Properties.TryGetValue("GPSVersionID", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["GPSVersionID"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + foreach (var item in this.GpsVersionID ?? []) + { + _ = item; + } + } + + public Gps() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Gps(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Gps FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/MetadataProperties/ExifProperties/Image.cs b/src/Imagekit/Models/Files/MetadataProperties/ExifProperties/Image.cs new file mode 100644 index 00000000..5c25d6a2 --- /dev/null +++ b/src/Imagekit/Models/Files/MetadataProperties/ExifProperties/Image.cs @@ -0,0 +1,241 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.MetadataProperties.ExifProperties; + +/// +/// Object containing EXIF image information. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class Image : ModelBase, IFromRaw +{ + public long? ExifOffset + { + get + { + if (!this.Properties.TryGetValue("ExifOffset", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["ExifOffset"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public long? GpsInfo + { + get + { + if (!this.Properties.TryGetValue("GPSInfo", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["GPSInfo"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public string? Make + { + get + { + if (!this.Properties.TryGetValue("Make", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["Make"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public string? Model + { + get + { + if (!this.Properties.TryGetValue("Model", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["Model"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public string? ModifyDate + { + get + { + if (!this.Properties.TryGetValue("ModifyDate", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["ModifyDate"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public long? Orientation + { + get + { + if (!this.Properties.TryGetValue("Orientation", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["Orientation"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public long? ResolutionUnit + { + get + { + if (!this.Properties.TryGetValue("ResolutionUnit", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["ResolutionUnit"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public string? Software + { + get + { + if (!this.Properties.TryGetValue("Software", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["Software"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public long? XResolution + { + get + { + if (!this.Properties.TryGetValue("XResolution", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["XResolution"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public long? YCbCrPositioning + { + get + { + if (!this.Properties.TryGetValue("YCbCrPositioning", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["YCbCrPositioning"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public long? YResolution + { + get + { + if (!this.Properties.TryGetValue("YResolution", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["YResolution"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.ExifOffset; + _ = this.GpsInfo; + _ = this.Make; + _ = this.Model; + _ = this.ModifyDate; + _ = this.Orientation; + _ = this.ResolutionUnit; + _ = this.Software; + _ = this.XResolution; + _ = this.YCbCrPositioning; + _ = this.YResolution; + } + + public Image() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Image(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Image FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/MetadataProperties/ExifProperties/Interoperability.cs b/src/Imagekit/Models/Files/MetadataProperties/ExifProperties/Interoperability.cs new file mode 100644 index 00000000..36225916 --- /dev/null +++ b/src/Imagekit/Models/Files/MetadataProperties/ExifProperties/Interoperability.cs @@ -0,0 +1,70 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.MetadataProperties.ExifProperties; + +/// +/// JSON object. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class Interoperability : ModelBase, IFromRaw +{ + public string? InteropIndex + { + get + { + if (!this.Properties.TryGetValue("InteropIndex", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["InteropIndex"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public string? InteropVersion + { + get + { + if (!this.Properties.TryGetValue("InteropVersion", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["InteropVersion"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.InteropIndex; + _ = this.InteropVersion; + } + + public Interoperability() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Interoperability(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Interoperability FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/MetadataProperties/ExifProperties/Thumbnail.cs b/src/Imagekit/Models/Files/MetadataProperties/ExifProperties/Thumbnail.cs new file mode 100644 index 00000000..9e01cf4c --- /dev/null +++ b/src/Imagekit/Models/Files/MetadataProperties/ExifProperties/Thumbnail.cs @@ -0,0 +1,146 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.MetadataProperties.ExifProperties; + +/// +/// Object containing Thumbnail information. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class Thumbnail : ModelBase, IFromRaw +{ + public long? Compression + { + get + { + if (!this.Properties.TryGetValue("Compression", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["Compression"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public long? ResolutionUnit + { + get + { + if (!this.Properties.TryGetValue("ResolutionUnit", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["ResolutionUnit"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public long? ThumbnailLength + { + get + { + if (!this.Properties.TryGetValue("ThumbnailLength", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["ThumbnailLength"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public long? ThumbnailOffset + { + get + { + if (!this.Properties.TryGetValue("ThumbnailOffset", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["ThumbnailOffset"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public long? XResolution + { + get + { + if (!this.Properties.TryGetValue("XResolution", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["XResolution"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public long? YResolution + { + get + { + if (!this.Properties.TryGetValue("YResolution", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["YResolution"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.Compression; + _ = this.ResolutionUnit; + _ = this.ThumbnailLength; + _ = this.ThumbnailOffset; + _ = this.XResolution; + _ = this.YResolution; + } + + public Thumbnail() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Thumbnail(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Thumbnail FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/Versions/VersionDeleteParams.cs b/src/Imagekit/Models/Files/Versions/VersionDeleteParams.cs new file mode 100644 index 00000000..7b43acb3 --- /dev/null +++ b/src/Imagekit/Models/Files/Versions/VersionDeleteParams.cs @@ -0,0 +1,36 @@ +using System; +using System.Net.Http; + +namespace Imagekit.Models.Files.Versions; + +/// +/// This API deletes a non-current file version permanently. The API returns an empty response. +/// +/// Note: If you want to delete all versions of a file, use the delete file API. +/// +public sealed record class VersionDeleteParams : ParamsBase +{ + public required string FileID; + + public required string VersionID; + + public override Uri Url(IImageKitClient client) + { + return new UriBuilder( + client.BaseUrl.ToString().TrimEnd('/') + + string.Format("/v1/files/{0}/versions/{1}", this.FileID, this.VersionID) + ) + { + Query = this.QueryString(client), + }.Uri; + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/Files/Versions/VersionDeleteResponse.cs b/src/Imagekit/Models/Files/Versions/VersionDeleteResponse.cs new file mode 100644 index 00000000..b5ca5287 --- /dev/null +++ b/src/Imagekit/Models/Files/Versions/VersionDeleteResponse.cs @@ -0,0 +1,27 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.Versions; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class VersionDeleteResponse : ModelBase, IFromRaw +{ + public override void Validate() { } + + public VersionDeleteResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + VersionDeleteResponse(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static VersionDeleteResponse FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/Versions/VersionGetParams.cs b/src/Imagekit/Models/Files/Versions/VersionGetParams.cs new file mode 100644 index 00000000..f1850a9a --- /dev/null +++ b/src/Imagekit/Models/Files/Versions/VersionGetParams.cs @@ -0,0 +1,34 @@ +using System; +using System.Net.Http; + +namespace Imagekit.Models.Files.Versions; + +/// +/// This API returns an object with details or attributes of a file version. +/// +public sealed record class VersionGetParams : ParamsBase +{ + public required string FileID; + + public required string VersionID; + + public override Uri Url(IImageKitClient client) + { + return new UriBuilder( + client.BaseUrl.ToString().TrimEnd('/') + + string.Format("/v1/files/{0}/versions/{1}", this.FileID, this.VersionID) + ) + { + Query = this.QueryString(client), + }.Uri; + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/Files/Versions/VersionListParams.cs b/src/Imagekit/Models/Files/Versions/VersionListParams.cs new file mode 100644 index 00000000..359cb066 --- /dev/null +++ b/src/Imagekit/Models/Files/Versions/VersionListParams.cs @@ -0,0 +1,32 @@ +using System; +using System.Net.Http; + +namespace Imagekit.Models.Files.Versions; + +/// +/// This API returns details of all versions of a file. +/// +public sealed record class VersionListParams : ParamsBase +{ + public required string FileID; + + public override Uri Url(IImageKitClient client) + { + return new UriBuilder( + client.BaseUrl.ToString().TrimEnd('/') + + string.Format("/v1/files/{0}/versions", this.FileID) + ) + { + Query = this.QueryString(client), + }.Uri; + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/Files/Versions/VersionRestoreParams.cs b/src/Imagekit/Models/Files/Versions/VersionRestoreParams.cs new file mode 100644 index 00000000..71a8ca90 --- /dev/null +++ b/src/Imagekit/Models/Files/Versions/VersionRestoreParams.cs @@ -0,0 +1,34 @@ +using System; +using System.Net.Http; + +namespace Imagekit.Models.Files.Versions; + +/// +/// This API restores a file version as the current file version. +/// +public sealed record class VersionRestoreParams : ParamsBase +{ + public required string FileID; + + public required string VersionID; + + public override Uri Url(IImageKitClient client) + { + return new UriBuilder( + client.BaseUrl.ToString().TrimEnd('/') + + string.Format("/v1/files/{0}/versions/{1}/restore", this.FileID, this.VersionID) + ) + { + Query = this.QueryString(client), + }.Uri; + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/Folders/FolderCopyParams.cs b/src/Imagekit/Models/Folders/FolderCopyParams.cs new file mode 100644 index 00000000..9f99e796 --- /dev/null +++ b/src/Imagekit/Models/Folders/FolderCopyParams.cs @@ -0,0 +1,120 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Text; +using System.Text.Json; + +namespace Imagekit.Models.Folders; + +/// +/// This will copy one folder into another. The selected folder, its nested folders, +/// files, and their versions (in `includeVersions` is set to true) are copied in +/// this operation. Note: If any file at the destination has the same name as the +/// source file, then the source file and its versions will be appended to the destination +/// file version history. +/// +public sealed record class FolderCopyParams : ParamsBase +{ + public Dictionary BodyProperties { get; set; } = []; + + /// + /// Full path to the destination folder where you want to copy the source folder + /// into. + /// + public required string DestinationPath + { + get + { + if (!this.BodyProperties.TryGetValue("destinationPath", out JsonElement element)) + throw new ArgumentOutOfRangeException( + "destinationPath", + "Missing required argument" + ); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("destinationPath"); + } + set + { + this.BodyProperties["destinationPath"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The full path to the source folder you want to copy. + /// + public required string SourceFolderPath + { + get + { + if (!this.BodyProperties.TryGetValue("sourceFolderPath", out JsonElement element)) + throw new ArgumentOutOfRangeException( + "sourceFolderPath", + "Missing required argument" + ); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("sourceFolderPath"); + } + set + { + this.BodyProperties["sourceFolderPath"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Option to copy all versions of files that are nested inside the selected + /// folder. By default, only the current version of each file will be copied. + /// When set to true, all versions of each file will be copied. Default value + /// - `false`. + /// + public bool? IncludeVersions + { + get + { + if (!this.BodyProperties.TryGetValue("includeVersions", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["includeVersions"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override Uri Url(IImageKitClient client) + { + return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/bulkJobs/copyFolder") + { + Query = this.QueryString(client), + }.Uri; + } + + public StringContent BodyContent() + { + return new( + JsonSerializer.Serialize(this.BodyProperties), + Encoding.UTF8, + "application/json" + ); + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/Folders/FolderCopyResponse.cs b/src/Imagekit/Models/Folders/FolderCopyResponse.cs new file mode 100644 index 00000000..546214a0 --- /dev/null +++ b/src/Imagekit/Models/Folders/FolderCopyResponse.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Folders; + +/// +/// Job submitted successfully. A `jobId` will be returned. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class FolderCopyResponse : ModelBase, IFromRaw +{ + /// + /// Unique identifier of the bulk job. This can be used to check the status of + /// the bulk job. + /// + public required string JobID + { + get + { + if (!this.Properties.TryGetValue("jobId", out JsonElement element)) + throw new ArgumentOutOfRangeException("jobId", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("jobId"); + } + set + { + this.Properties["jobId"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.JobID; + } + + public FolderCopyResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FolderCopyResponse(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static FolderCopyResponse FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public FolderCopyResponse(string jobID) + : this() + { + this.JobID = jobID; + } +} diff --git a/src/Imagekit/Models/Folders/FolderCreateParams.cs b/src/Imagekit/Models/Folders/FolderCreateParams.cs new file mode 100644 index 00000000..834ff0e7 --- /dev/null +++ b/src/Imagekit/Models/Folders/FolderCreateParams.cs @@ -0,0 +1,99 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Text; +using System.Text.Json; + +namespace Imagekit.Models.Folders; + +/// +/// This will create a new folder. You can specify the folder name and location of +/// the parent folder where this new folder should be created. +/// +public sealed record class FolderCreateParams : ParamsBase +{ + public Dictionary BodyProperties { get; set; } = []; + + /// + /// The folder will be created with this name. + /// + /// All characters except alphabets and numbers (inclusive of unicode letters, + /// marks, and numerals in other languages) will be replaced by an underscore + /// i.e. `_`. + /// + public required string FolderName + { + get + { + if (!this.BodyProperties.TryGetValue("folderName", out JsonElement element)) + throw new ArgumentOutOfRangeException("folderName", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("folderName"); + } + set + { + this.BodyProperties["folderName"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The folder where the new folder should be created, for root use `/` else the + /// path e.g. `containing/folder/`. + /// + /// Note: If any folder(s) is not present in the parentFolderPath parameter, + /// it will be automatically created. For example, if you pass `/product/images/summer`, + /// then `product`, `images`, and `summer` folders will be created if they don't + /// already exist. + /// + public required string ParentFolderPath + { + get + { + if (!this.BodyProperties.TryGetValue("parentFolderPath", out JsonElement element)) + throw new ArgumentOutOfRangeException( + "parentFolderPath", + "Missing required argument" + ); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("parentFolderPath"); + } + set + { + this.BodyProperties["parentFolderPath"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override Uri Url(IImageKitClient client) + { + return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/folder") + { + Query = this.QueryString(client), + }.Uri; + } + + public StringContent BodyContent() + { + return new( + JsonSerializer.Serialize(this.BodyProperties), + Encoding.UTF8, + "application/json" + ); + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/Folders/FolderCreateResponse.cs b/src/Imagekit/Models/Folders/FolderCreateResponse.cs new file mode 100644 index 00000000..c470a9e0 --- /dev/null +++ b/src/Imagekit/Models/Folders/FolderCreateResponse.cs @@ -0,0 +1,27 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Folders; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class FolderCreateResponse : ModelBase, IFromRaw +{ + public override void Validate() { } + + public FolderCreateResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FolderCreateResponse(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static FolderCreateResponse FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Folders/FolderDeleteParams.cs b/src/Imagekit/Models/Folders/FolderDeleteParams.cs new file mode 100644 index 00000000..ba1ac4fa --- /dev/null +++ b/src/Imagekit/Models/Folders/FolderDeleteParams.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Text; +using System.Text.Json; + +namespace Imagekit.Models.Folders; + +/// +/// This will delete a folder and all its contents permanently. The API returns an +/// empty response. +/// +public sealed record class FolderDeleteParams : ParamsBase +{ + public Dictionary BodyProperties { get; set; } = []; + + /// + /// Full path to the folder you want to delete. For example `/folder/to/delete/`. + /// + public required string FolderPath + { + get + { + if (!this.BodyProperties.TryGetValue("folderPath", out JsonElement element)) + throw new ArgumentOutOfRangeException("folderPath", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("folderPath"); + } + set + { + this.BodyProperties["folderPath"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override Uri Url(IImageKitClient client) + { + return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/folder") + { + Query = this.QueryString(client), + }.Uri; + } + + public StringContent BodyContent() + { + return new( + JsonSerializer.Serialize(this.BodyProperties), + Encoding.UTF8, + "application/json" + ); + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/Folders/FolderDeleteResponse.cs b/src/Imagekit/Models/Folders/FolderDeleteResponse.cs new file mode 100644 index 00000000..3ed1bc21 --- /dev/null +++ b/src/Imagekit/Models/Folders/FolderDeleteResponse.cs @@ -0,0 +1,27 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Folders; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class FolderDeleteResponse : ModelBase, IFromRaw +{ + public override void Validate() { } + + public FolderDeleteResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FolderDeleteResponse(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static FolderDeleteResponse FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Folders/FolderMoveParams.cs b/src/Imagekit/Models/Folders/FolderMoveParams.cs new file mode 100644 index 00000000..dccbc3b3 --- /dev/null +++ b/src/Imagekit/Models/Folders/FolderMoveParams.cs @@ -0,0 +1,95 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Text; +using System.Text.Json; + +namespace Imagekit.Models.Folders; + +/// +/// This will move one folder into another. The selected folder, its nested folders, +/// files, and their versions are moved in this operation. Note: If any file at the +/// destination has the same name as the source file, then the source file and its +/// versions will be appended to the destination file version history. +/// +public sealed record class FolderMoveParams : ParamsBase +{ + public Dictionary BodyProperties { get; set; } = []; + + /// + /// Full path to the destination folder where you want to move the source folder + /// into. + /// + public required string DestinationPath + { + get + { + if (!this.BodyProperties.TryGetValue("destinationPath", out JsonElement element)) + throw new ArgumentOutOfRangeException( + "destinationPath", + "Missing required argument" + ); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("destinationPath"); + } + set + { + this.BodyProperties["destinationPath"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The full path to the source folder you want to move. + /// + public required string SourceFolderPath + { + get + { + if (!this.BodyProperties.TryGetValue("sourceFolderPath", out JsonElement element)) + throw new ArgumentOutOfRangeException( + "sourceFolderPath", + "Missing required argument" + ); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("sourceFolderPath"); + } + set + { + this.BodyProperties["sourceFolderPath"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override Uri Url(IImageKitClient client) + { + return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/bulkJobs/moveFolder") + { + Query = this.QueryString(client), + }.Uri; + } + + public StringContent BodyContent() + { + return new( + JsonSerializer.Serialize(this.BodyProperties), + Encoding.UTF8, + "application/json" + ); + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/Folders/FolderMoveResponse.cs b/src/Imagekit/Models/Folders/FolderMoveResponse.cs new file mode 100644 index 00000000..6435065a --- /dev/null +++ b/src/Imagekit/Models/Folders/FolderMoveResponse.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Folders; + +/// +/// Job submitted successfully. A `jobId` will be returned. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class FolderMoveResponse : ModelBase, IFromRaw +{ + /// + /// Unique identifier of the bulk job. This can be used to check the status of + /// the bulk job. + /// + public required string JobID + { + get + { + if (!this.Properties.TryGetValue("jobId", out JsonElement element)) + throw new ArgumentOutOfRangeException("jobId", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("jobId"); + } + set + { + this.Properties["jobId"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.JobID; + } + + public FolderMoveResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FolderMoveResponse(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static FolderMoveResponse FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public FolderMoveResponse(string jobID) + : this() + { + this.JobID = jobID; + } +} diff --git a/src/Imagekit/Models/Folders/FolderRenameParams.cs b/src/Imagekit/Models/Folders/FolderRenameParams.cs new file mode 100644 index 00000000..b73112ce --- /dev/null +++ b/src/Imagekit/Models/Folders/FolderRenameParams.cs @@ -0,0 +1,126 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Text; +using System.Text.Json; + +namespace Imagekit.Models.Folders; + +/// +/// This API allows you to rename an existing folder. The folder and all its nested +/// assets and sub-folders will remain unchanged, but their paths will be updated +/// to reflect the new folder name. +/// +public sealed record class FolderRenameParams : ParamsBase +{ + public Dictionary BodyProperties { get; set; } = []; + + /// + /// The full path to the folder you want to rename. + /// + public required string FolderPath + { + get + { + if (!this.BodyProperties.TryGetValue("folderPath", out JsonElement element)) + throw new ArgumentOutOfRangeException("folderPath", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("folderPath"); + } + set + { + this.BodyProperties["folderPath"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The new name for the folder. + /// + /// All characters except alphabets and numbers (inclusive of unicode letters, + /// marks, and numerals in other languages) and `-` will be replaced by an underscore + /// i.e. `_`. + /// + public required string NewFolderName + { + get + { + if (!this.BodyProperties.TryGetValue("newFolderName", out JsonElement element)) + throw new ArgumentOutOfRangeException("newFolderName", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("newFolderName"); + } + set + { + this.BodyProperties["newFolderName"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Option to purge cache for the old nested files and their versions' URLs. + /// + /// When set to true, it will internally issue a purge cache request on CDN to + /// remove the cached content of the old nested files and their versions. There + /// will only be one purge request for all the nested files, which will be counted + /// against your monthly purge quota. + /// + /// Note: A purge cache request will be issued against `https://ik.imagekit.io/old/folder/path*` + /// (with a wildcard at the end). This will remove all nested files, their versions' + /// URLs, and any transformations made using query parameters on these files + /// or their versions. However, the cache for file transformations made using + /// path parameters will persist. You can purge them using the purge API. For + /// more details, refer to the purge API documentation. + /// + /// Default value - `false` + /// + public bool? PurgeCache + { + get + { + if (!this.BodyProperties.TryGetValue("purgeCache", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["purgeCache"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override Uri Url(IImageKitClient client) + { + return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/bulkJobs/renameFolder") + { + Query = this.QueryString(client), + }.Uri; + } + + public StringContent BodyContent() + { + return new( + JsonSerializer.Serialize(this.BodyProperties), + Encoding.UTF8, + "application/json" + ); + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/Folders/FolderRenameResponse.cs b/src/Imagekit/Models/Folders/FolderRenameResponse.cs new file mode 100644 index 00000000..8dd77536 --- /dev/null +++ b/src/Imagekit/Models/Folders/FolderRenameResponse.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Folders; + +/// +/// Job submitted successfully. A `jobId` will be returned. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class FolderRenameResponse : ModelBase, IFromRaw +{ + /// + /// Unique identifier of the bulk job. This can be used to check the status of + /// the bulk job. + /// + public required string JobID + { + get + { + if (!this.Properties.TryGetValue("jobId", out JsonElement element)) + throw new ArgumentOutOfRangeException("jobId", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("jobId"); + } + set + { + this.Properties["jobId"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.JobID; + } + + public FolderRenameResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FolderRenameResponse(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static FolderRenameResponse FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public FolderRenameResponse(string jobID) + : this() + { + this.JobID = jobID; + } +} diff --git a/src/Imagekit/Models/Folders/Job/JobGetParams.cs b/src/Imagekit/Models/Folders/Job/JobGetParams.cs new file mode 100644 index 00000000..cacc3f64 --- /dev/null +++ b/src/Imagekit/Models/Folders/Job/JobGetParams.cs @@ -0,0 +1,31 @@ +using System; +using System.Net.Http; + +namespace Imagekit.Models.Folders.Job; + +/// +/// This API returns the status of a bulk job like copy and move folder operations. +/// +public sealed record class JobGetParams : ParamsBase +{ + public required string JobID; + + public override Uri Url(IImageKitClient client) + { + return new UriBuilder( + client.BaseUrl.ToString().TrimEnd('/') + string.Format("/v1/bulkJobs/{0}", this.JobID) + ) + { + Query = this.QueryString(client), + }.Uri; + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/Folders/Job/JobGetResponse.cs b/src/Imagekit/Models/Folders/Job/JobGetResponse.cs new file mode 100644 index 00000000..5e20478b --- /dev/null +++ b/src/Imagekit/Models/Folders/Job/JobGetResponse.cs @@ -0,0 +1,125 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Folders.Job.JobGetResponseProperties; + +namespace Imagekit.Models.Folders.Job; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class JobGetResponse : ModelBase, IFromRaw +{ + /// + /// Unique identifier of the bulk job. + /// + public string? JobID + { + get + { + if (!this.Properties.TryGetValue("jobId", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["jobId"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Unique identifier of the purge request. This will be present only if `purgeCache` + /// is set to `true` in the rename folder API request. + /// + public string? PurgeRequestID + { + get + { + if (!this.Properties.TryGetValue("purgeRequestId", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["purgeRequestId"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Status of the bulk job. + /// + public ApiEnum? Status + { + get + { + if (!this.Properties.TryGetValue("status", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["status"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Type of the bulk job. + /// + public ApiEnum? Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.JobID; + _ = this.PurgeRequestID; + this.Status?.Validate(); + this.Type?.Validate(); + } + + public JobGetResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + JobGetResponse(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static JobGetResponse FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Folders/Job/JobGetResponseProperties/Status.cs b/src/Imagekit/Models/Folders/Job/JobGetResponseProperties/Status.cs new file mode 100644 index 00000000..21ceca11 --- /dev/null +++ b/src/Imagekit/Models/Folders/Job/JobGetResponseProperties/Status.cs @@ -0,0 +1,46 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using System = System; + +namespace Imagekit.Models.Folders.Job.JobGetResponseProperties; + +/// +/// Status of the bulk job. +/// +[JsonConverter(typeof(StatusConverter))] +public enum Status +{ + Pending, + Completed, +} + +sealed class StatusConverter : JsonConverter +{ + public override Status Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "Pending" => Status.Pending, + "Completed" => Status.Completed, + _ => (Status)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Status value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + Status.Pending => "Pending", + Status.Completed => "Completed", + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Folders/Job/JobGetResponseProperties/Type.cs b/src/Imagekit/Models/Folders/Job/JobGetResponseProperties/Type.cs new file mode 100644 index 00000000..d9f357b4 --- /dev/null +++ b/src/Imagekit/Models/Folders/Job/JobGetResponseProperties/Type.cs @@ -0,0 +1,49 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using System = System; + +namespace Imagekit.Models.Folders.Job.JobGetResponseProperties; + +/// +/// Type of the bulk job. +/// +[JsonConverter(typeof(TypeConverter))] +public enum Type +{ + CopyFolder, + MoveFolder, + RenameFolder, +} + +sealed class TypeConverter : JsonConverter +{ + public override Type Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "COPY_FOLDER" => JobGetResponseProperties.Type.CopyFolder, + "MOVE_FOLDER" => JobGetResponseProperties.Type.MoveFolder, + "RENAME_FOLDER" => JobGetResponseProperties.Type.RenameFolder, + _ => (Type)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + JobGetResponseProperties.Type.CopyFolder => "COPY_FOLDER", + JobGetResponseProperties.Type.MoveFolder => "MOVE_FOLDER", + JobGetResponseProperties.Type.RenameFolder => "RENAME_FOLDER", + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/ImageOverlay.cs b/src/Imagekit/Models/ImageOverlay.cs new file mode 100644 index 00000000..8a1ebd9f --- /dev/null +++ b/src/Imagekit/Models/ImageOverlay.cs @@ -0,0 +1,184 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.ImageOverlayProperties.IntersectionMember1Properties; + +namespace Imagekit.Models; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class ImageOverlay : ModelBase, IFromRaw +{ + public OverlayPosition? Position + { + get + { + if (!this.Properties.TryGetValue("position", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["position"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public OverlayTiming? Timing + { + get + { + if (!this.Properties.TryGetValue("timing", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["timing"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies the relative path to the image used as an overlay. + /// + public required string Input + { + get + { + if (!this.Properties.TryGetValue("input", out JsonElement element)) + throw new ArgumentOutOfRangeException("input", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("input"); + } + set + { + this.Properties["input"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The input path can be included in the layer as either `i-{input}` or `ie-{base64_encoded_input}`. + /// By default, the SDK determines the appropriate format automatically. To + /// always use base64 encoding (`ie-{base64}`), set this parameter to `base64`. + /// To always use plain text (`i-{input}`), set it to `plain`. + /// + public ApiEnum? Encoding + { + get + { + if (!this.Properties.TryGetValue("encoding", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["encoding"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Array of transformations to be applied to the overlay image. Supported transformations + /// depends on the base/parent asset. See overlays on [Images](https://imagekit.io/docs/add-overlays-on-images#list-of-supported-image-transformations-in-image-layers) + /// and [Videos](https://imagekit.io/docs/add-overlays-on-videos#list-of-transformations-supported-on-image-overlay). + /// + public List? Transformation + { + get + { + if (!this.Properties.TryGetValue("transformation", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["transformation"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public static implicit operator BaseOverlay(ImageOverlay imageOverlay) => + new() { Position = imageOverlay.Position, Timing = imageOverlay.Timing }; + + public override void Validate() + { + this.Position?.Validate(); + this.Timing?.Validate(); + _ = this.Input; + this.Encoding?.Validate(); + foreach (var item in this.Transformation ?? []) + { + item.Validate(); + } + } + + public ImageOverlay() + { + this.Type = JsonSerializer.Deserialize("\"image\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ImageOverlay(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static ImageOverlay FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public ImageOverlay(string input) + : this() + { + this.Input = input; + } +} diff --git a/src/Imagekit/Models/ImageOverlayProperties/IntersectionMember1.cs b/src/Imagekit/Models/ImageOverlayProperties/IntersectionMember1.cs new file mode 100644 index 00000000..9c13f738 --- /dev/null +++ b/src/Imagekit/Models/ImageOverlayProperties/IntersectionMember1.cs @@ -0,0 +1,140 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.ImageOverlayProperties.IntersectionMember1Properties; + +namespace Imagekit.Models.ImageOverlayProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class IntersectionMember1 : ModelBase, IFromRaw +{ + /// + /// Specifies the relative path to the image used as an overlay. + /// + public required string Input + { + get + { + if (!this.Properties.TryGetValue("input", out JsonElement element)) + throw new ArgumentOutOfRangeException("input", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("input"); + } + set + { + this.Properties["input"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The input path can be included in the layer as either `i-{input}` or `ie-{base64_encoded_input}`. + /// By default, the SDK determines the appropriate format automatically. To + /// always use base64 encoding (`ie-{base64}`), set this parameter to `base64`. + /// To always use plain text (`i-{input}`), set it to `plain`. + /// + public ApiEnum? Encoding + { + get + { + if (!this.Properties.TryGetValue("encoding", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["encoding"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Array of transformations to be applied to the overlay image. Supported transformations + /// depends on the base/parent asset. See overlays on [Images](https://imagekit.io/docs/add-overlays-on-images#list-of-supported-image-transformations-in-image-layers) + /// and [Videos](https://imagekit.io/docs/add-overlays-on-videos#list-of-transformations-supported-on-image-overlay). + /// + public List? Transformation + { + get + { + if (!this.Properties.TryGetValue("transformation", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["transformation"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.Input; + this.Encoding?.Validate(); + foreach (var item in this.Transformation ?? []) + { + item.Validate(); + } + } + + public IntersectionMember1() + { + this.Type = JsonSerializer.Deserialize("\"image\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + IntersectionMember1(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static IntersectionMember1 FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public IntersectionMember1(string input) + : this() + { + this.Input = input; + } +} diff --git a/src/Imagekit/Models/ImageOverlayProperties/IntersectionMember1Properties/Encoding.cs b/src/Imagekit/Models/ImageOverlayProperties/IntersectionMember1Properties/Encoding.cs new file mode 100644 index 00000000..c7efb752 --- /dev/null +++ b/src/Imagekit/Models/ImageOverlayProperties/IntersectionMember1Properties/Encoding.cs @@ -0,0 +1,52 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.ImageOverlayProperties.IntersectionMember1Properties; + +/// +/// The input path can be included in the layer as either `i-{input}` or `ie-{base64_encoded_input}`. +/// By default, the SDK determines the appropriate format automatically. To always +/// use base64 encoding (`ie-{base64}`), set this parameter to `base64`. To always +/// use plain text (`i-{input}`), set it to `plain`. +/// +[JsonConverter(typeof(EncodingConverter))] +public enum Encoding +{ + Auto, + Plain, + Base64, +} + +sealed class EncodingConverter : JsonConverter +{ + public override Encoding Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "auto" => Encoding.Auto, + "plain" => Encoding.Plain, + "base64" => Encoding.Base64, + _ => (Encoding)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Encoding value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + Encoding.Auto => "auto", + Encoding.Plain => "plain", + Encoding.Base64 => "base64", + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Overlay.cs b/src/Imagekit/Models/Overlay.cs new file mode 100644 index 00000000..abc2be63 --- /dev/null +++ b/src/Imagekit/Models/Overlay.cs @@ -0,0 +1,253 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using OverlayVariants = Imagekit.Models.OverlayVariants; + +namespace Imagekit.Models; + +/// +/// Specifies an overlay to be applied on the parent image or video. ImageKit supports +/// overlays including images, text, videos, subtitles, and solid colors. See [Overlay +/// using layers](https://imagekit.io/docs/transformations#overlay-using-layers). +/// +[JsonConverter(typeof(OverlayConverter))] +public abstract record class Overlay +{ + internal Overlay() { } + + public static implicit operator Overlay(TextOverlay value) => + new OverlayVariants::TextOverlay(value); + + public static implicit operator Overlay(ImageOverlay value) => + new OverlayVariants::ImageOverlay(value); + + public static implicit operator Overlay(VideoOverlay value) => + new OverlayVariants::VideoOverlay(value); + + public static implicit operator Overlay(SubtitleOverlay value) => + new OverlayVariants::SubtitleOverlay(value); + + public static implicit operator Overlay(SolidColorOverlay value) => + new OverlayVariants::SolidColorOverlay(value); + + public bool TryPickText([NotNullWhen(true)] out TextOverlay? value) + { + value = (this as OverlayVariants::TextOverlay)?.Value; + return value != null; + } + + public bool TryPickImage([NotNullWhen(true)] out ImageOverlay? value) + { + value = (this as OverlayVariants::ImageOverlay)?.Value; + return value != null; + } + + public bool TryPickVideo([NotNullWhen(true)] out VideoOverlay? value) + { + value = (this as OverlayVariants::VideoOverlay)?.Value; + return value != null; + } + + public bool TryPickSubtitle([NotNullWhen(true)] out SubtitleOverlay? value) + { + value = (this as OverlayVariants::SubtitleOverlay)?.Value; + return value != null; + } + + public bool TryPickSolidColor([NotNullWhen(true)] out SolidColorOverlay? value) + { + value = (this as OverlayVariants::SolidColorOverlay)?.Value; + return value != null; + } + + public void Switch( + Action text, + Action image, + Action video, + Action subtitle, + Action solidColor + ) + { + switch (this) + { + case OverlayVariants::TextOverlay inner: + text(inner); + break; + case OverlayVariants::ImageOverlay inner: + image(inner); + break; + case OverlayVariants::VideoOverlay inner: + video(inner); + break; + case OverlayVariants::SubtitleOverlay inner: + subtitle(inner); + break; + case OverlayVariants::SolidColorOverlay inner: + solidColor(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func text, + Func image, + Func video, + Func subtitle, + Func solidColor + ) + { + return this switch + { + OverlayVariants::TextOverlay inner => text(inner), + OverlayVariants::ImageOverlay inner => image(inner), + OverlayVariants::VideoOverlay inner => video(inner), + OverlayVariants::SubtitleOverlay inner => subtitle(inner), + OverlayVariants::SolidColorOverlay inner => solidColor(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class OverlayConverter : JsonConverter +{ + public override Overlay? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var json = JsonSerializer.Deserialize(ref reader, options); + string? type; + try + { + type = json.GetProperty("type").GetString(); + } + catch + { + type = null; + } + + switch (type) + { + case "text": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new OverlayVariants::TextOverlay(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "image": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new OverlayVariants::ImageOverlay(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "video": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new OverlayVariants::VideoOverlay(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "subtitle": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new OverlayVariants::SubtitleOverlay(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "solidColor": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new OverlayVariants::SolidColorOverlay(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + default: + { + throw new Exception(); + } + } + } + + public override void Write(Utf8JsonWriter writer, Overlay value, JsonSerializerOptions options) + { + object variant = value switch + { + OverlayVariants::TextOverlay(var text) => text, + OverlayVariants::ImageOverlay(var image) => image, + OverlayVariants::VideoOverlay(var video) => video, + OverlayVariants::SubtitleOverlay(var subtitle) => subtitle, + OverlayVariants::SolidColorOverlay(var solidColor) => solidColor, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/OverlayPosition.cs b/src/Imagekit/Models/OverlayPosition.cs new file mode 100644 index 00000000..84ba3398 --- /dev/null +++ b/src/Imagekit/Models/OverlayPosition.cs @@ -0,0 +1,106 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.OverlayPositionProperties; + +namespace Imagekit.Models; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class OverlayPosition : ModelBase, IFromRaw +{ + /// + /// Specifies the position of the overlay relative to the parent image or video. + /// Maps to `lfo` in the URL. + /// + public ApiEnum? Focus + { + get + { + if (!this.Properties.TryGetValue("focus", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["focus"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies the x-coordinate of the top-left corner of the base asset where + /// the overlay's top-left corner will be positioned. It also accepts arithmetic + /// expressions such as `bw_mul_0.4` or `bw_sub_cw`. Maps to `lx` in the URL. + /// Learn about [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + /// + public X? X + { + get + { + if (!this.Properties.TryGetValue("x", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["x"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies the y-coordinate of the top-left corner of the base asset where + /// the overlay's top-left corner will be positioned. It also accepts arithmetic + /// expressions such as `bh_mul_0.4` or `bh_sub_ch`. Maps to `ly` in the URL. + /// Learn about [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + /// + public Y? Y + { + get + { + if (!this.Properties.TryGetValue("y", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["y"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.Focus?.Validate(); + this.X?.Validate(); + this.Y?.Validate(); + } + + public OverlayPosition() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + OverlayPosition(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static OverlayPosition FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/OverlayPositionProperties/Focus.cs b/src/Imagekit/Models/OverlayPositionProperties/Focus.cs new file mode 100644 index 00000000..9c9b013e --- /dev/null +++ b/src/Imagekit/Models/OverlayPositionProperties/Focus.cs @@ -0,0 +1,68 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.OverlayPositionProperties; + +/// +/// Specifies the position of the overlay relative to the parent image or video. +/// Maps to `lfo` in the URL. +/// +[JsonConverter(typeof(FocusConverter))] +public enum Focus +{ + Center, + Top, + Left, + Bottom, + Right, + TopLeft, + TopRight, + BottomLeft, + BottomRight, +} + +sealed class FocusConverter : JsonConverter +{ + public override Focus Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "center" => Focus.Center, + "top" => Focus.Top, + "left" => Focus.Left, + "bottom" => Focus.Bottom, + "right" => Focus.Right, + "top_left" => Focus.TopLeft, + "top_right" => Focus.TopRight, + "bottom_left" => Focus.BottomLeft, + "bottom_right" => Focus.BottomRight, + _ => (Focus)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Focus value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + Focus.Center => "center", + Focus.Top => "top", + Focus.Left => "left", + Focus.Bottom => "bottom", + Focus.Right => "right", + Focus.TopLeft => "top_left", + Focus.TopRight => "top_right", + Focus.BottomLeft => "bottom_left", + Focus.BottomRight => "bottom_right", + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/OverlayPositionProperties/X.cs b/src/Imagekit/Models/OverlayPositionProperties/X.cs new file mode 100644 index 00000000..72a6341a --- /dev/null +++ b/src/Imagekit/Models/OverlayPositionProperties/X.cs @@ -0,0 +1,110 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using XVariants = Imagekit.Models.OverlayPositionProperties.XVariants; + +namespace Imagekit.Models.OverlayPositionProperties; + +/// +/// Specifies the x-coordinate of the top-left corner of the base asset where the +/// overlay's top-left corner will be positioned. It also accepts arithmetic expressions +/// such as `bw_mul_0.4` or `bw_sub_cw`. Maps to `lx` in the URL. Learn about [Arithmetic +/// expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). +/// +[JsonConverter(typeof(XConverter))] +public abstract record class X +{ + internal X() { } + + public static implicit operator X(double value) => new XVariants::Double(value); + + public static implicit operator X(string value) => new XVariants::String(value); + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as XVariants::Double)?.Value; + return value != null; + } + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as XVariants::String)?.Value; + return value != null; + } + + public void Switch(Action @double, Action @string) + { + switch (this) + { + case XVariants::Double inner: + @double(inner); + break; + case XVariants::String inner: + @string(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match(Func @double, Func @string) + { + return this switch + { + XVariants::Double inner => @double(inner), + XVariants::String inner => @string(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class XConverter : JsonConverter +{ + public override X? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + return new XVariants::Double(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new XVariants::String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + + public override void Write(Utf8JsonWriter writer, X value, JsonSerializerOptions options) + { + object variant = value switch + { + XVariants::Double(var @double) => @double, + XVariants::String(var @string) => @string, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/OverlayPositionProperties/XVariants/All.cs b/src/Imagekit/Models/OverlayPositionProperties/XVariants/All.cs new file mode 100644 index 00000000..83d285fc --- /dev/null +++ b/src/Imagekit/Models/OverlayPositionProperties/XVariants/All.cs @@ -0,0 +1,21 @@ +namespace Imagekit.Models.OverlayPositionProperties.XVariants; + +public sealed record class Double(double Value) : X, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class String(string Value) : X, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/OverlayPositionProperties/Y.cs b/src/Imagekit/Models/OverlayPositionProperties/Y.cs new file mode 100644 index 00000000..bde27831 --- /dev/null +++ b/src/Imagekit/Models/OverlayPositionProperties/Y.cs @@ -0,0 +1,110 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using YVariants = Imagekit.Models.OverlayPositionProperties.YVariants; + +namespace Imagekit.Models.OverlayPositionProperties; + +/// +/// Specifies the y-coordinate of the top-left corner of the base asset where the +/// overlay's top-left corner will be positioned. It also accepts arithmetic expressions +/// such as `bh_mul_0.4` or `bh_sub_ch`. Maps to `ly` in the URL. Learn about [Arithmetic +/// expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). +/// +[JsonConverter(typeof(YConverter))] +public abstract record class Y +{ + internal Y() { } + + public static implicit operator Y(double value) => new YVariants::Double(value); + + public static implicit operator Y(string value) => new YVariants::String(value); + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as YVariants::Double)?.Value; + return value != null; + } + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as YVariants::String)?.Value; + return value != null; + } + + public void Switch(Action @double, Action @string) + { + switch (this) + { + case YVariants::Double inner: + @double(inner); + break; + case YVariants::String inner: + @string(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match(Func @double, Func @string) + { + return this switch + { + YVariants::Double inner => @double(inner), + YVariants::String inner => @string(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class YConverter : JsonConverter +{ + public override Y? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + return new YVariants::Double(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new YVariants::String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + + public override void Write(Utf8JsonWriter writer, Y value, JsonSerializerOptions options) + { + object variant = value switch + { + YVariants::Double(var @double) => @double, + YVariants::String(var @string) => @string, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/OverlayPositionProperties/YVariants/All.cs b/src/Imagekit/Models/OverlayPositionProperties/YVariants/All.cs new file mode 100644 index 00000000..b123e666 --- /dev/null +++ b/src/Imagekit/Models/OverlayPositionProperties/YVariants/All.cs @@ -0,0 +1,21 @@ +namespace Imagekit.Models.OverlayPositionProperties.YVariants; + +public sealed record class Double(double Value) : Y, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class String(string Value) : Y, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/OverlayTiming.cs b/src/Imagekit/Models/OverlayTiming.cs new file mode 100644 index 00000000..c559ab9d --- /dev/null +++ b/src/Imagekit/Models/OverlayTiming.cs @@ -0,0 +1,106 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.OverlayTimingProperties; + +namespace Imagekit.Models; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class OverlayTiming : ModelBase, IFromRaw +{ + /// + /// Specifies the duration (in seconds) during which the overlay should appear + /// on the base video. Accepts a positive number up to two decimal places (e.g., + /// `20` or `20.50`) and arithmetic expressions such as `bdu_mul_0.4` or `bdu_sub_idu`. + /// Applies only if the base asset is a video. Maps to `ldu` in the URL. + /// + public Duration? Duration + { + get + { + if (!this.Properties.TryGetValue("duration", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["duration"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies the end time (in seconds) for when the overlay should disappear + /// from the base video. If both end and duration are provided, duration is ignored. + /// Accepts a positive number up to two decimal places (e.g., `20` or `20.50`) + /// and arithmetic expressions such as `bdu_mul_0.4` or `bdu_sub_idu`. Applies + /// only if the base asset is a video. Maps to `leo` in the URL. + /// + public End? End + { + get + { + if (!this.Properties.TryGetValue("end", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["end"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies the start time (in seconds) for when the overlay should appear on + /// the base video. Accepts a positive number up to two decimal places (e.g., + /// `20` or `20.50`) and arithmetic expressions such as `bdu_mul_0.4` or `bdu_sub_idu`. + /// Applies only if the base asset is a video. Maps to `lso` in the URL. + /// + public Start? Start + { + get + { + if (!this.Properties.TryGetValue("start", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["start"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.Duration?.Validate(); + this.End?.Validate(); + this.Start?.Validate(); + } + + public OverlayTiming() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + OverlayTiming(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static OverlayTiming FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/OverlayTimingProperties/Duration.cs b/src/Imagekit/Models/OverlayTimingProperties/Duration.cs new file mode 100644 index 00000000..c835f546 --- /dev/null +++ b/src/Imagekit/Models/OverlayTimingProperties/Duration.cs @@ -0,0 +1,118 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using DurationVariants = Imagekit.Models.OverlayTimingProperties.DurationVariants; + +namespace Imagekit.Models.OverlayTimingProperties; + +/// +/// Specifies the duration (in seconds) during which the overlay should appear on +/// the base video. Accepts a positive number up to two decimal places (e.g., `20` +/// or `20.50`) and arithmetic expressions such as `bdu_mul_0.4` or `bdu_sub_idu`. +/// Applies only if the base asset is a video. Maps to `ldu` in the URL. +/// +[JsonConverter(typeof(DurationConverter))] +public abstract record class Duration +{ + internal Duration() { } + + public static implicit operator Duration(double value) => new DurationVariants::Double(value); + + public static implicit operator Duration(string value) => new DurationVariants::String(value); + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as DurationVariants::Double)?.Value; + return value != null; + } + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as DurationVariants::String)?.Value; + return value != null; + } + + public void Switch( + Action @double, + Action @string + ) + { + switch (this) + { + case DurationVariants::Double inner: + @double(inner); + break; + case DurationVariants::String inner: + @string(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func @double, + Func @string + ) + { + return this switch + { + DurationVariants::Double inner => @double(inner), + DurationVariants::String inner => @string(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class DurationConverter : JsonConverter +{ + public override Duration? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + return new DurationVariants::Double( + JsonSerializer.Deserialize(ref reader, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new DurationVariants::String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + + public override void Write(Utf8JsonWriter writer, Duration value, JsonSerializerOptions options) + { + object variant = value switch + { + DurationVariants::Double(var @double) => @double, + DurationVariants::String(var @string) => @string, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/OverlayTimingProperties/DurationVariants/All.cs b/src/Imagekit/Models/OverlayTimingProperties/DurationVariants/All.cs new file mode 100644 index 00000000..c4645813 --- /dev/null +++ b/src/Imagekit/Models/OverlayTimingProperties/DurationVariants/All.cs @@ -0,0 +1,21 @@ +namespace Imagekit.Models.OverlayTimingProperties.DurationVariants; + +public sealed record class Double(double Value) : Duration, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class String(string Value) : Duration, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/OverlayTimingProperties/End.cs b/src/Imagekit/Models/OverlayTimingProperties/End.cs new file mode 100644 index 00000000..00434c3d --- /dev/null +++ b/src/Imagekit/Models/OverlayTimingProperties/End.cs @@ -0,0 +1,111 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using EndVariants = Imagekit.Models.OverlayTimingProperties.EndVariants; + +namespace Imagekit.Models.OverlayTimingProperties; + +/// +/// Specifies the end time (in seconds) for when the overlay should disappear from +/// the base video. If both end and duration are provided, duration is ignored. Accepts +/// a positive number up to two decimal places (e.g., `20` or `20.50`) and arithmetic +/// expressions such as `bdu_mul_0.4` or `bdu_sub_idu`. Applies only if the base asset +/// is a video. Maps to `leo` in the URL. +/// +[JsonConverter(typeof(EndConverter))] +public abstract record class End +{ + internal End() { } + + public static implicit operator End(double value) => new EndVariants::Double(value); + + public static implicit operator End(string value) => new EndVariants::String(value); + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as EndVariants::Double)?.Value; + return value != null; + } + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as EndVariants::String)?.Value; + return value != null; + } + + public void Switch(Action @double, Action @string) + { + switch (this) + { + case EndVariants::Double inner: + @double(inner); + break; + case EndVariants::String inner: + @string(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match(Func @double, Func @string) + { + return this switch + { + EndVariants::Double inner => @double(inner), + EndVariants::String inner => @string(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class EndConverter : JsonConverter +{ + public override End? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + return new EndVariants::Double(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new EndVariants::String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + + public override void Write(Utf8JsonWriter writer, End value, JsonSerializerOptions options) + { + object variant = value switch + { + EndVariants::Double(var @double) => @double, + EndVariants::String(var @string) => @string, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/OverlayTimingProperties/EndVariants/All.cs b/src/Imagekit/Models/OverlayTimingProperties/EndVariants/All.cs new file mode 100644 index 00000000..58912819 --- /dev/null +++ b/src/Imagekit/Models/OverlayTimingProperties/EndVariants/All.cs @@ -0,0 +1,21 @@ +namespace Imagekit.Models.OverlayTimingProperties.EndVariants; + +public sealed record class Double(double Value) : End, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class String(string Value) : End, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/OverlayTimingProperties/Start.cs b/src/Imagekit/Models/OverlayTimingProperties/Start.cs new file mode 100644 index 00000000..dd7eeacc --- /dev/null +++ b/src/Imagekit/Models/OverlayTimingProperties/Start.cs @@ -0,0 +1,115 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using StartVariants = Imagekit.Models.OverlayTimingProperties.StartVariants; + +namespace Imagekit.Models.OverlayTimingProperties; + +/// +/// Specifies the start time (in seconds) for when the overlay should appear on the +/// base video. Accepts a positive number up to two decimal places (e.g., `20` or +/// `20.50`) and arithmetic expressions such as `bdu_mul_0.4` or `bdu_sub_idu`. Applies +/// only if the base asset is a video. Maps to `lso` in the URL. +/// +[JsonConverter(typeof(StartConverter))] +public abstract record class Start +{ + internal Start() { } + + public static implicit operator Start(double value) => new StartVariants::Double(value); + + public static implicit operator Start(string value) => new StartVariants::String(value); + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as StartVariants::Double)?.Value; + return value != null; + } + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as StartVariants::String)?.Value; + return value != null; + } + + public void Switch(Action @double, Action @string) + { + switch (this) + { + case StartVariants::Double inner: + @double(inner); + break; + case StartVariants::String inner: + @string(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func @double, + Func @string + ) + { + return this switch + { + StartVariants::Double inner => @double(inner), + StartVariants::String inner => @string(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class StartConverter : JsonConverter +{ + public override Start? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + return new StartVariants::Double( + JsonSerializer.Deserialize(ref reader, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new StartVariants::String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + + public override void Write(Utf8JsonWriter writer, Start value, JsonSerializerOptions options) + { + object variant = value switch + { + StartVariants::Double(var @double) => @double, + StartVariants::String(var @string) => @string, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/OverlayTimingProperties/StartVariants/All.cs b/src/Imagekit/Models/OverlayTimingProperties/StartVariants/All.cs new file mode 100644 index 00000000..6554819a --- /dev/null +++ b/src/Imagekit/Models/OverlayTimingProperties/StartVariants/All.cs @@ -0,0 +1,21 @@ +namespace Imagekit.Models.OverlayTimingProperties.StartVariants; + +public sealed record class Double(double Value) : Start, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class String(string Value) : Start, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/OverlayVariants/All.cs b/src/Imagekit/Models/OverlayVariants/All.cs new file mode 100644 index 00000000..3ff187c8 --- /dev/null +++ b/src/Imagekit/Models/OverlayVariants/All.cs @@ -0,0 +1,78 @@ +using Models = Imagekit.Models; + +namespace Imagekit.Models.OverlayVariants; + +public sealed record class TextOverlay(Models::TextOverlay Value) + : Models::Overlay, + IVariant +{ + public static TextOverlay From(Models::TextOverlay value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class ImageOverlay(Models::ImageOverlay Value) + : Models::Overlay, + IVariant +{ + public static ImageOverlay From(Models::ImageOverlay value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class VideoOverlay(Models::VideoOverlay Value) + : Models::Overlay, + IVariant +{ + public static VideoOverlay From(Models::VideoOverlay value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class SubtitleOverlay(Models::SubtitleOverlay Value) + : Models::Overlay, + IVariant +{ + public static SubtitleOverlay From(Models::SubtitleOverlay value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class SolidColorOverlay(Models::SolidColorOverlay Value) + : Models::Overlay, + IVariant +{ + public static SolidColorOverlay From(Models::SolidColorOverlay value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} diff --git a/src/Imagekit/Models/SolidColorOverlay.cs b/src/Imagekit/Models/SolidColorOverlay.cs new file mode 100644 index 00000000..7bd01c08 --- /dev/null +++ b/src/Imagekit/Models/SolidColorOverlay.cs @@ -0,0 +1,158 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class SolidColorOverlay : ModelBase, IFromRaw +{ + public OverlayPosition? Position + { + get + { + if (!this.Properties.TryGetValue("position", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["position"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public OverlayTiming? Timing + { + get + { + if (!this.Properties.TryGetValue("timing", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["timing"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies the color of the block using an RGB hex code (e.g., `FF0000`), + /// an RGBA code (e.g., `FFAABB50`), or a color name (e.g., `red`). If an 8-character + /// value is provided, the last two characters represent the opacity level (from + /// `00` for 0.00 to `99` for 0.99). + /// + public required string Color + { + get + { + if (!this.Properties.TryGetValue("color", out JsonElement element)) + throw new ArgumentOutOfRangeException("color", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("color"); + } + set + { + this.Properties["color"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Control width and height of the solid color overlay. Supported transformations + /// depend on the base/parent asset. See overlays on [Images](https://imagekit.io/docs/add-overlays-on-images#apply-transformation-on-solid-color-overlay) + /// and [Videos](https://imagekit.io/docs/add-overlays-on-videos#apply-transformations-on-solid-color-block-overlay). + /// + public List? Transformation + { + get + { + if (!this.Properties.TryGetValue("transformation", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["transformation"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public static implicit operator BaseOverlay(SolidColorOverlay solidColorOverlay) => + new() { Position = solidColorOverlay.Position, Timing = solidColorOverlay.Timing }; + + public override void Validate() + { + this.Position?.Validate(); + this.Timing?.Validate(); + _ = this.Color; + foreach (var item in this.Transformation ?? []) + { + item.Validate(); + } + } + + public SolidColorOverlay() + { + this.Type = JsonSerializer.Deserialize("\"solidColor\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + SolidColorOverlay(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static SolidColorOverlay FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public SolidColorOverlay(string color) + : this() + { + this.Color = color; + } +} diff --git a/src/Imagekit/Models/SolidColorOverlayProperties/IntersectionMember1.cs b/src/Imagekit/Models/SolidColorOverlayProperties/IntersectionMember1.cs new file mode 100644 index 00000000..57ddef26 --- /dev/null +++ b/src/Imagekit/Models/SolidColorOverlayProperties/IntersectionMember1.cs @@ -0,0 +1,114 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.SolidColorOverlayProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class IntersectionMember1 : ModelBase, IFromRaw +{ + /// + /// Specifies the color of the block using an RGB hex code (e.g., `FF0000`), + /// an RGBA code (e.g., `FFAABB50`), or a color name (e.g., `red`). If an 8-character + /// value is provided, the last two characters represent the opacity level (from + /// `00` for 0.00 to `99` for 0.99). + /// + public required string Color + { + get + { + if (!this.Properties.TryGetValue("color", out JsonElement element)) + throw new ArgumentOutOfRangeException("color", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("color"); + } + set + { + this.Properties["color"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Control width and height of the solid color overlay. Supported transformations + /// depend on the base/parent asset. See overlays on [Images](https://imagekit.io/docs/add-overlays-on-images#apply-transformation-on-solid-color-overlay) + /// and [Videos](https://imagekit.io/docs/add-overlays-on-videos#apply-transformations-on-solid-color-block-overlay). + /// + public List? Transformation + { + get + { + if (!this.Properties.TryGetValue("transformation", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["transformation"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.Color; + foreach (var item in this.Transformation ?? []) + { + item.Validate(); + } + } + + public IntersectionMember1() + { + this.Type = JsonSerializer.Deserialize("\"solidColor\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + IntersectionMember1(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static IntersectionMember1 FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public IntersectionMember1(string color) + : this() + { + this.Color = color; + } +} diff --git a/src/Imagekit/Models/SolidColorOverlayTransformation.cs b/src/Imagekit/Models/SolidColorOverlayTransformation.cs new file mode 100644 index 00000000..68937764 --- /dev/null +++ b/src/Imagekit/Models/SolidColorOverlayTransformation.cs @@ -0,0 +1,174 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.SolidColorOverlayTransformationProperties; + +namespace Imagekit.Models; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class SolidColorOverlayTransformation + : ModelBase, + IFromRaw +{ + /// + /// Specifies the transparency level of the solid color overlay. Accepts integers + /// from `1` to `9`. + /// + public double? Alpha + { + get + { + if (!this.Properties.TryGetValue("alpha", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["alpha"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies the background color of the solid color overlay. Accepts an RGB + /// hex code (e.g., `FF0000`), an RGBA code (e.g., `FFAABB50`), or a color name. + /// + public string? Background + { + get + { + if (!this.Properties.TryGetValue("background", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["background"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Creates a linear gradient with two colors. Pass `true` for a default gradient, + /// or provide a string for a custom gradient. Only works if the base asset is + /// an image. See [gradient](https://imagekit.io/docs/effects-and-enhancements#gradient---e-gradient). + /// + public Gradient? Gradient + { + get + { + if (!this.Properties.TryGetValue("gradient", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["gradient"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Controls the height of the solid color overlay. Accepts a numeric value or + /// an arithmetic expression. Learn about [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + /// + public Height? Height + { + get + { + if (!this.Properties.TryGetValue("height", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["height"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies the corner radius of the solid color overlay. Set to `max` for + /// circular or oval shape. See [radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). + /// + public Radius? Radius + { + get + { + if (!this.Properties.TryGetValue("radius", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["radius"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Controls the width of the solid color overlay. Accepts a numeric value or + /// an arithmetic expression (e.g., `bw_mul_0.2` or `bh_div_2`). Learn about [arithmetic + /// expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + /// + public Width? Width + { + get + { + if (!this.Properties.TryGetValue("width", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["width"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.Alpha; + _ = this.Background; + this.Gradient?.Validate(); + this.Height?.Validate(); + this.Radius?.Validate(); + this.Width?.Validate(); + } + + public SolidColorOverlayTransformation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + SolidColorOverlayTransformation(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static SolidColorOverlayTransformation FromRawUnchecked( + Dictionary properties + ) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Gradient.cs b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Gradient.cs new file mode 100644 index 00000000..d54f5053 --- /dev/null +++ b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Gradient.cs @@ -0,0 +1,115 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using GradientVariants = Imagekit.Models.SolidColorOverlayTransformationProperties.GradientVariants; + +namespace Imagekit.Models.SolidColorOverlayTransformationProperties; + +/// +/// Creates a linear gradient with two colors. Pass `true` for a default gradient, +/// or provide a string for a custom gradient. Only works if the base asset is an +/// image. See [gradient](https://imagekit.io/docs/effects-and-enhancements#gradient---e-gradient). +/// +[JsonConverter(typeof(GradientConverter))] +public abstract record class Gradient +{ + internal Gradient() { } + + public static implicit operator Gradient(string value) => new GradientVariants::String(value); + + public bool TryPickTrue([NotNullWhen(true)] out JsonElement? value) + { + value = (this as GradientVariants::True)?.Value; + return value != null; + } + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as GradientVariants::String)?.Value; + return value != null; + } + + public void Switch( + Action true1, + Action @string + ) + { + switch (this) + { + case GradientVariants::True inner: + true1(inner); + break; + case GradientVariants::String inner: + @string(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func true1, + Func @string + ) + { + return this switch + { + GradientVariants::True inner => true1(inner), + GradientVariants::String inner => @string(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class GradientConverter : JsonConverter +{ + public override Gradient? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + return new GradientVariants::True( + JsonSerializer.Deserialize(ref reader, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new GradientVariants::String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + + public override void Write(Utf8JsonWriter writer, Gradient value, JsonSerializerOptions options) + { + object variant = value switch + { + GradientVariants::True(var true1) => true1, + GradientVariants::String(var @string) => @string, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/GradientVariants/All.cs b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/GradientVariants/All.cs new file mode 100644 index 00000000..4f3289f0 --- /dev/null +++ b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/GradientVariants/All.cs @@ -0,0 +1,23 @@ +using System.Text.Json; + +namespace Imagekit.Models.SolidColorOverlayTransformationProperties.GradientVariants; + +public sealed record class True(JsonElement Value) : Gradient, IVariant +{ + public static True From(JsonElement value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class String(string Value) : Gradient, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Height.cs b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Height.cs new file mode 100644 index 00000000..a1edb6a4 --- /dev/null +++ b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Height.cs @@ -0,0 +1,116 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using HeightVariants = Imagekit.Models.SolidColorOverlayTransformationProperties.HeightVariants; + +namespace Imagekit.Models.SolidColorOverlayTransformationProperties; + +/// +/// Controls the height of the solid color overlay. Accepts a numeric value or an +/// arithmetic expression. Learn about [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). +/// +[JsonConverter(typeof(HeightConverter))] +public abstract record class Height +{ + internal Height() { } + + public static implicit operator Height(double value) => new HeightVariants::Double(value); + + public static implicit operator Height(string value) => new HeightVariants::String(value); + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as HeightVariants::Double)?.Value; + return value != null; + } + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as HeightVariants::String)?.Value; + return value != null; + } + + public void Switch( + Action @double, + Action @string + ) + { + switch (this) + { + case HeightVariants::Double inner: + @double(inner); + break; + case HeightVariants::String inner: + @string(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func @double, + Func @string + ) + { + return this switch + { + HeightVariants::Double inner => @double(inner), + HeightVariants::String inner => @string(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class HeightConverter : JsonConverter +{ + public override Height? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + return new HeightVariants::Double( + JsonSerializer.Deserialize(ref reader, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new HeightVariants::String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + + public override void Write(Utf8JsonWriter writer, Height value, JsonSerializerOptions options) + { + object variant = value switch + { + HeightVariants::Double(var @double) => @double, + HeightVariants::String(var @string) => @string, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/HeightVariants/All.cs b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/HeightVariants/All.cs new file mode 100644 index 00000000..7964bb15 --- /dev/null +++ b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/HeightVariants/All.cs @@ -0,0 +1,21 @@ +namespace Imagekit.Models.SolidColorOverlayTransformationProperties.HeightVariants; + +public sealed record class Double(double Value) : Height, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class String(string Value) : Height, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Radius.cs b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Radius.cs new file mode 100644 index 00000000..fd7074ff --- /dev/null +++ b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Radius.cs @@ -0,0 +1,106 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using RadiusVariants = Imagekit.Models.SolidColorOverlayTransformationProperties.RadiusVariants; + +namespace Imagekit.Models.SolidColorOverlayTransformationProperties; + +/// +/// Specifies the corner radius of the solid color overlay. Set to `max` for circular +/// or oval shape. See [radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). +/// +[JsonConverter(typeof(RadiusConverter))] +public abstract record class Radius +{ + internal Radius() { } + + public static implicit operator Radius(double value) => new RadiusVariants::Double(value); + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as RadiusVariants::Double)?.Value; + return value != null; + } + + public bool TryPickMax([NotNullWhen(true)] out JsonElement? value) + { + value = (this as RadiusVariants::Max)?.Value; + return value != null; + } + + public void Switch(Action @double, Action max) + { + switch (this) + { + case RadiusVariants::Double inner: + @double(inner); + break; + case RadiusVariants::Max inner: + max(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match(Func @double, Func max) + { + return this switch + { + RadiusVariants::Double inner => @double(inner), + RadiusVariants::Max inner => max(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class RadiusConverter : JsonConverter +{ + public override Radius? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + return new RadiusVariants::Max( + JsonSerializer.Deserialize(ref reader, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new RadiusVariants::Double( + JsonSerializer.Deserialize(ref reader, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + + public override void Write(Utf8JsonWriter writer, Radius value, JsonSerializerOptions options) + { + object variant = value switch + { + RadiusVariants::Double(var @double) => @double, + RadiusVariants::Max(var max) => max, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/RadiusVariants/All.cs b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/RadiusVariants/All.cs new file mode 100644 index 00000000..027d6797 --- /dev/null +++ b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/RadiusVariants/All.cs @@ -0,0 +1,23 @@ +using System.Text.Json; + +namespace Imagekit.Models.SolidColorOverlayTransformationProperties.RadiusVariants; + +public sealed record class Double(double Value) : Radius, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Max(JsonElement Value) : Radius, IVariant +{ + public static Max From(JsonElement value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Width.cs b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Width.cs new file mode 100644 index 00000000..689da93c --- /dev/null +++ b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Width.cs @@ -0,0 +1,113 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using WidthVariants = Imagekit.Models.SolidColorOverlayTransformationProperties.WidthVariants; + +namespace Imagekit.Models.SolidColorOverlayTransformationProperties; + +/// +/// Controls the width of the solid color overlay. Accepts a numeric value or an arithmetic +/// expression (e.g., `bw_mul_0.2` or `bh_div_2`). Learn about [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). +/// +[JsonConverter(typeof(WidthConverter))] +public abstract record class Width +{ + internal Width() { } + + public static implicit operator Width(double value) => new WidthVariants::Double(value); + + public static implicit operator Width(string value) => new WidthVariants::String(value); + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as WidthVariants::Double)?.Value; + return value != null; + } + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as WidthVariants::String)?.Value; + return value != null; + } + + public void Switch(Action @double, Action @string) + { + switch (this) + { + case WidthVariants::Double inner: + @double(inner); + break; + case WidthVariants::String inner: + @string(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func @double, + Func @string + ) + { + return this switch + { + WidthVariants::Double inner => @double(inner), + WidthVariants::String inner => @string(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class WidthConverter : JsonConverter +{ + public override Width? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + return new WidthVariants::Double( + JsonSerializer.Deserialize(ref reader, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new WidthVariants::String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + + public override void Write(Utf8JsonWriter writer, Width value, JsonSerializerOptions options) + { + object variant = value switch + { + WidthVariants::Double(var @double) => @double, + WidthVariants::String(var @string) => @string, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/WidthVariants/All.cs b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/WidthVariants/All.cs new file mode 100644 index 00000000..6c5afda6 --- /dev/null +++ b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/WidthVariants/All.cs @@ -0,0 +1,21 @@ +namespace Imagekit.Models.SolidColorOverlayTransformationProperties.WidthVariants; + +public sealed record class Double(double Value) : Width, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class String(string Value) : Width, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/SrcOptions.cs b/src/Imagekit/Models/SrcOptions.cs new file mode 100644 index 00000000..d524abc3 --- /dev/null +++ b/src/Imagekit/Models/SrcOptions.cs @@ -0,0 +1,230 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models; + +/// +/// Options for generating ImageKit URLs with transformations. See the [Transformations guide](https://imagekit.io/docs/transformations). +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class SrcOptions : ModelBase, IFromRaw +{ + /// + /// Accepts a relative or absolute path of the resource. If a relative path is + /// provided, it is appended to the `urlEndpoint`. If an absolute path is provided, + /// `urlEndpoint` is ignored. + /// + public required string Src + { + get + { + if (!this.Properties.TryGetValue("src", out JsonElement element)) + throw new ArgumentOutOfRangeException("src", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("src"); + } + set + { + this.Properties["src"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Get your urlEndpoint from the [ImageKit dashboard](https://imagekit.io/dashboard/url-endpoints). + /// + public required string URLEndpoint + { + get + { + if (!this.Properties.TryGetValue("urlEndpoint", out JsonElement element)) + throw new ArgumentOutOfRangeException("urlEndpoint", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("urlEndpoint"); + } + set + { + this.Properties["urlEndpoint"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// When you want the signed URL to expire, specified in seconds. If `expiresIn` + /// is anything above 0, the URL will always be signed even if `signed` is set + /// to false. If not specified and `signed` is `true`, the signed URL will not + /// expire (valid indefinitely). + /// + /// Example: Setting `expiresIn: 3600` will make the URL expire 1 hour from generation + /// time. After the expiry time, the signed URL will no longer be valid and ImageKit + /// will return a 401 Unauthorized status code. + /// + /// [Learn more](https://imagekit.io/docs/media-delivery-basic-security#how-to-generate-signed-urls). + /// + public double? ExpiresIn + { + get + { + if (!this.Properties.TryGetValue("expiresIn", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["expiresIn"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// These are additional query parameters that you want to add to the final URL. + /// They can be any query parameters and not necessarily related to ImageKit. + /// This is especially useful if you want to add a versioning parameter to your + /// URLs. + /// + public Dictionary? QueryParameters + { + get + { + if (!this.Properties.TryGetValue("queryParameters", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["queryParameters"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to sign the URL or not. Set this to `true` if you want to generate + /// a signed URL. If `signed` is `true` and `expiresIn` is not specified, the + /// signed URL will not expire (valid indefinitely). Note: If `expiresIn` is set + /// to any value above 0, the URL will always be signed regardless of this setting. + /// [Learn more](https://imagekit.io/docs/media-delivery-basic-security#how-to-generate-signed-urls). + /// + public bool? Signed + { + get + { + if (!this.Properties.TryGetValue("signed", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["signed"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// An array of objects specifying the transformations to be applied in the URL. + /// If more than one transformation is specified, they are applied in the order + /// they are specified as chained transformations. See [Chained transformations](https://imagekit.io/docs/transformations#chained-transformations). + /// + public List? Transformation + { + get + { + if (!this.Properties.TryGetValue("transformation", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["transformation"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// By default, the transformation string is added as a query parameter in the + /// URL, e.g., `?tr=w-100,h-100`. If you want to add the transformation string + /// in the path of the URL, set this to `path`. Learn more in the [Transformations + /// guide](https://imagekit.io/docs/transformations). + /// + public ApiEnum? TransformationPosition + { + get + { + if (!this.Properties.TryGetValue("transformationPosition", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["transformationPosition"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.Src; + _ = this.URLEndpoint; + _ = this.ExpiresIn; + if (this.QueryParameters != null) + { + foreach (var item in this.QueryParameters.Values) + { + _ = item; + } + } + _ = this.Signed; + foreach (var item in this.Transformation ?? []) + { + item.Validate(); + } + this.TransformationPosition?.Validate(); + } + + public SrcOptions() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + SrcOptions(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static SrcOptions FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/StreamingResolution.cs b/src/Imagekit/Models/StreamingResolution.cs new file mode 100644 index 00000000..b6978e9e --- /dev/null +++ b/src/Imagekit/Models/StreamingResolution.cs @@ -0,0 +1,65 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models; + +/// +/// Available streaming resolutions for [adaptive bitrate streaming](https://imagekit.io/docs/adaptive-bitrate-streaming) +/// +[JsonConverter(typeof(StreamingResolutionConverter))] +public enum StreamingResolution +{ + v240, + v360, + v480, + v720, + v1080, + v1440, + v2160, +} + +sealed class StreamingResolutionConverter : JsonConverter +{ + public override StreamingResolution Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "240" => StreamingResolution.v240, + "360" => StreamingResolution.v360, + "480" => StreamingResolution.v480, + "720" => StreamingResolution.v720, + "1080" => StreamingResolution.v1080, + "1440" => StreamingResolution.v1440, + "2160" => StreamingResolution.v2160, + _ => (StreamingResolution)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + StreamingResolution value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + StreamingResolution.v240 => "240", + StreamingResolution.v360 => "360", + StreamingResolution.v480 => "480", + StreamingResolution.v720 => "720", + StreamingResolution.v1080 => "1080", + StreamingResolution.v1440 => "1440", + StreamingResolution.v2160 => "2160", + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/SubtitleOverlay.cs b/src/Imagekit/Models/SubtitleOverlay.cs new file mode 100644 index 00000000..eee00a3c --- /dev/null +++ b/src/Imagekit/Models/SubtitleOverlay.cs @@ -0,0 +1,182 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.SubtitleOverlayProperties.IntersectionMember1Properties; + +namespace Imagekit.Models; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class SubtitleOverlay : ModelBase, IFromRaw +{ + public OverlayPosition? Position + { + get + { + if (!this.Properties.TryGetValue("position", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["position"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public OverlayTiming? Timing + { + get + { + if (!this.Properties.TryGetValue("timing", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["timing"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies the relative path to the subtitle file used as an overlay. + /// + public required string Input + { + get + { + if (!this.Properties.TryGetValue("input", out JsonElement element)) + throw new ArgumentOutOfRangeException("input", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("input"); + } + set + { + this.Properties["input"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The input path can be included in the layer as either `i-{input}` or `ie-{base64_encoded_input}`. + /// By default, the SDK determines the appropriate format automatically. To + /// always use base64 encoding (`ie-{base64}`), set this parameter to `base64`. + /// To always use plain text (`i-{input}`), set it to `plain`. + /// + public ApiEnum? Encoding + { + get + { + if (!this.Properties.TryGetValue("encoding", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["encoding"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Control styling of the subtitle. See [Styling subtitles](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer). + /// + public List? Transformation + { + get + { + if (!this.Properties.TryGetValue("transformation", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["transformation"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public static implicit operator BaseOverlay(SubtitleOverlay subtitleOverlay) => + new() { Position = subtitleOverlay.Position, Timing = subtitleOverlay.Timing }; + + public override void Validate() + { + this.Position?.Validate(); + this.Timing?.Validate(); + _ = this.Input; + this.Encoding?.Validate(); + foreach (var item in this.Transformation ?? []) + { + item.Validate(); + } + } + + public SubtitleOverlay() + { + this.Type = JsonSerializer.Deserialize("\"subtitle\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + SubtitleOverlay(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static SubtitleOverlay FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public SubtitleOverlay(string input) + : this() + { + this.Input = input; + } +} diff --git a/src/Imagekit/Models/SubtitleOverlayProperties/IntersectionMember1.cs b/src/Imagekit/Models/SubtitleOverlayProperties/IntersectionMember1.cs new file mode 100644 index 00000000..87bc57c5 --- /dev/null +++ b/src/Imagekit/Models/SubtitleOverlayProperties/IntersectionMember1.cs @@ -0,0 +1,138 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.SubtitleOverlayProperties.IntersectionMember1Properties; + +namespace Imagekit.Models.SubtitleOverlayProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class IntersectionMember1 : ModelBase, IFromRaw +{ + /// + /// Specifies the relative path to the subtitle file used as an overlay. + /// + public required string Input + { + get + { + if (!this.Properties.TryGetValue("input", out JsonElement element)) + throw new ArgumentOutOfRangeException("input", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("input"); + } + set + { + this.Properties["input"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The input path can be included in the layer as either `i-{input}` or `ie-{base64_encoded_input}`. + /// By default, the SDK determines the appropriate format automatically. To + /// always use base64 encoding (`ie-{base64}`), set this parameter to `base64`. + /// To always use plain text (`i-{input}`), set it to `plain`. + /// + public ApiEnum? Encoding + { + get + { + if (!this.Properties.TryGetValue("encoding", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["encoding"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Control styling of the subtitle. See [Styling subtitles](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer). + /// + public List? Transformation + { + get + { + if (!this.Properties.TryGetValue("transformation", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["transformation"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.Input; + this.Encoding?.Validate(); + foreach (var item in this.Transformation ?? []) + { + item.Validate(); + } + } + + public IntersectionMember1() + { + this.Type = JsonSerializer.Deserialize("\"subtitle\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + IntersectionMember1(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static IntersectionMember1 FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public IntersectionMember1(string input) + : this() + { + this.Input = input; + } +} diff --git a/src/Imagekit/Models/SubtitleOverlayProperties/IntersectionMember1Properties/Encoding.cs b/src/Imagekit/Models/SubtitleOverlayProperties/IntersectionMember1Properties/Encoding.cs new file mode 100644 index 00000000..e1dda803 --- /dev/null +++ b/src/Imagekit/Models/SubtitleOverlayProperties/IntersectionMember1Properties/Encoding.cs @@ -0,0 +1,52 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.SubtitleOverlayProperties.IntersectionMember1Properties; + +/// +/// The input path can be included in the layer as either `i-{input}` or `ie-{base64_encoded_input}`. +/// By default, the SDK determines the appropriate format automatically. To always +/// use base64 encoding (`ie-{base64}`), set this parameter to `base64`. To always +/// use plain text (`i-{input}`), set it to `plain`. +/// +[JsonConverter(typeof(EncodingConverter))] +public enum Encoding +{ + Auto, + Plain, + Base64, +} + +sealed class EncodingConverter : JsonConverter +{ + public override Encoding Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "auto" => Encoding.Auto, + "plain" => Encoding.Plain, + "base64" => Encoding.Base64, + _ => (Encoding)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Encoding value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + Encoding.Auto => "auto", + Encoding.Plain => "plain", + Encoding.Base64 => "base64", + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/SubtitleOverlayTransformation.cs b/src/Imagekit/Models/SubtitleOverlayTransformation.cs new file mode 100644 index 00000000..912ded35 --- /dev/null +++ b/src/Imagekit/Models/SubtitleOverlayTransformation.cs @@ -0,0 +1,220 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.SubtitleOverlayTransformationProperties; + +namespace Imagekit.Models; + +/// +/// Subtitle styling options. [Learn more](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) +/// from the docs. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class SubtitleOverlayTransformation + : ModelBase, + IFromRaw +{ + /// + /// Specifies the subtitle background color using a standard color name, an RGB + /// color code (e.g., FF0000), or an RGBA color code (e.g., FFAABB50). + /// + /// [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + /// + public string? Background + { + get + { + if (!this.Properties.TryGetValue("background", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["background"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Sets the font color of the subtitle text using a standard color name, an RGB + /// color code (e.g., FF0000), or an RGBA color code (e.g., FFAABB50). + /// + /// [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + /// + public string? Color + { + get + { + if (!this.Properties.TryGetValue("color", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["color"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Font family for subtitles. Refer to the [supported fonts](https://imagekit.io/docs/add-overlays-on-images#supported-text-font-list). + /// + public string? FontFamily + { + get + { + if (!this.Properties.TryGetValue("fontFamily", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["fontFamily"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Sets the font outline of the subtitle text. Requires the outline width (an + /// integer) and the outline color (as an RGB color code, RGBA color code, or + /// standard web color name) separated by an underscore. Example: `fol-2_blue` + /// (outline width of 2px and outline color blue), `fol-2_A1CCDD` (outline width + /// of 2px and outline color `#A1CCDD`) and `fol-2_A1CCDD50` (outline width of + /// 2px and outline color `#A1CCDD` at 50% opacity). + /// + /// [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + /// + public string? FontOutline + { + get + { + if (!this.Properties.TryGetValue("fontOutline", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["fontOutline"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Sets the font shadow for the subtitle text. Requires the shadow color (as + /// an RGB color code, RGBA color code, or standard web color name) and shadow + /// indent (an integer) separated by an underscore. Example: `fsh-blue_2` (shadow + /// color blue, indent of 2px), `fsh-A1CCDD_3` (shadow color `#A1CCDD`, indent + /// of 3px), `fsh-A1CCDD50_3` (shadow color `#A1CCDD` at 50% opacity, indent + /// of 3px). + /// + /// [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + /// + public string? FontShadow + { + get + { + if (!this.Properties.TryGetValue("fontShadow", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["fontShadow"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Sets the font size of subtitle text. + /// + /// [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + /// + public double? FontSize + { + get + { + if (!this.Properties.TryGetValue("fontSize", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["fontSize"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Sets the typography style of the subtitle text. Supports values are `b` for + /// bold, `i` for italics, and `b_i` for bold with italics. + /// + /// [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + /// + public ApiEnum? Typography + { + get + { + if (!this.Properties.TryGetValue("typography", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["typography"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.Background; + _ = this.Color; + _ = this.FontFamily; + _ = this.FontOutline; + _ = this.FontShadow; + _ = this.FontSize; + this.Typography?.Validate(); + } + + public SubtitleOverlayTransformation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + SubtitleOverlayTransformation(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static SubtitleOverlayTransformation FromRawUnchecked( + Dictionary properties + ) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/SubtitleOverlayTransformationProperties/Typography.cs b/src/Imagekit/Models/SubtitleOverlayTransformationProperties/Typography.cs new file mode 100644 index 00000000..4cef3c66 --- /dev/null +++ b/src/Imagekit/Models/SubtitleOverlayTransformationProperties/Typography.cs @@ -0,0 +1,56 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.SubtitleOverlayTransformationProperties; + +/// +/// Sets the typography style of the subtitle text. Supports values are `b` for bold, +/// `i` for italics, and `b_i` for bold with italics. +/// +/// [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) +/// +[JsonConverter(typeof(TypographyConverter))] +public enum Typography +{ + B, + I, + BI, +} + +sealed class TypographyConverter : JsonConverter +{ + public override Typography Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "b" => Typography.B, + "i" => Typography.I, + "b_i" => Typography.BI, + _ => (Typography)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + Typography value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + Typography.B => "b", + Typography.I => "i", + Typography.BI => "b_i", + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/TextOverlay.cs b/src/Imagekit/Models/TextOverlay.cs new file mode 100644 index 00000000..60fe68c8 --- /dev/null +++ b/src/Imagekit/Models/TextOverlay.cs @@ -0,0 +1,183 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.TextOverlayProperties.IntersectionMember1Properties; + +namespace Imagekit.Models; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class TextOverlay : ModelBase, IFromRaw +{ + public OverlayPosition? Position + { + get + { + if (!this.Properties.TryGetValue("position", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["position"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public OverlayTiming? Timing + { + get + { + if (!this.Properties.TryGetValue("timing", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["timing"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies the text to be displayed in the overlay. The SDK automatically handles + /// special characters and encoding. + /// + public required string Text + { + get + { + if (!this.Properties.TryGetValue("text", out JsonElement element)) + throw new ArgumentOutOfRangeException("text", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("text"); + } + set + { + this.Properties["text"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Text can be included in the layer as either `i-{input}` (plain text) or `ie-{base64_encoded_input}` + /// (base64). By default, the SDK selects the appropriate format based on the + /// input text. To always use base64 (`ie-{base64}`), set this parameter to + /// `base64`. To always use plain text (`i-{input}`), set it to `plain`. + /// + public ApiEnum? Encoding + { + get + { + if (!this.Properties.TryGetValue("encoding", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["encoding"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Control styling of the text overlay. See [Text overlays](https://imagekit.io/docs/add-overlays-on-images#text-overlay). + /// + public List? Transformation + { + get + { + if (!this.Properties.TryGetValue("transformation", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["transformation"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public static implicit operator BaseOverlay(TextOverlay textOverlay) => + new() { Position = textOverlay.Position, Timing = textOverlay.Timing }; + + public override void Validate() + { + this.Position?.Validate(); + this.Timing?.Validate(); + _ = this.Text; + this.Encoding?.Validate(); + foreach (var item in this.Transformation ?? []) + { + item.Validate(); + } + } + + public TextOverlay() + { + this.Type = JsonSerializer.Deserialize("\"text\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TextOverlay(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static TextOverlay FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public TextOverlay(string text) + : this() + { + this.Text = text; + } +} diff --git a/src/Imagekit/Models/TextOverlayProperties/IntersectionMember1.cs b/src/Imagekit/Models/TextOverlayProperties/IntersectionMember1.cs new file mode 100644 index 00000000..9af23151 --- /dev/null +++ b/src/Imagekit/Models/TextOverlayProperties/IntersectionMember1.cs @@ -0,0 +1,139 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.TextOverlayProperties.IntersectionMember1Properties; + +namespace Imagekit.Models.TextOverlayProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class IntersectionMember1 : ModelBase, IFromRaw +{ + /// + /// Specifies the text to be displayed in the overlay. The SDK automatically handles + /// special characters and encoding. + /// + public required string Text + { + get + { + if (!this.Properties.TryGetValue("text", out JsonElement element)) + throw new ArgumentOutOfRangeException("text", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("text"); + } + set + { + this.Properties["text"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Text can be included in the layer as either `i-{input}` (plain text) or `ie-{base64_encoded_input}` + /// (base64). By default, the SDK selects the appropriate format based on the + /// input text. To always use base64 (`ie-{base64}`), set this parameter to + /// `base64`. To always use plain text (`i-{input}`), set it to `plain`. + /// + public ApiEnum? Encoding + { + get + { + if (!this.Properties.TryGetValue("encoding", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["encoding"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Control styling of the text overlay. See [Text overlays](https://imagekit.io/docs/add-overlays-on-images#text-overlay). + /// + public List? Transformation + { + get + { + if (!this.Properties.TryGetValue("transformation", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["transformation"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.Text; + this.Encoding?.Validate(); + foreach (var item in this.Transformation ?? []) + { + item.Validate(); + } + } + + public IntersectionMember1() + { + this.Type = JsonSerializer.Deserialize("\"text\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + IntersectionMember1(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static IntersectionMember1 FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public IntersectionMember1(string text) + : this() + { + this.Text = text; + } +} diff --git a/src/Imagekit/Models/TextOverlayProperties/IntersectionMember1Properties/Encoding.cs b/src/Imagekit/Models/TextOverlayProperties/IntersectionMember1Properties/Encoding.cs new file mode 100644 index 00000000..74ed2a83 --- /dev/null +++ b/src/Imagekit/Models/TextOverlayProperties/IntersectionMember1Properties/Encoding.cs @@ -0,0 +1,52 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.TextOverlayProperties.IntersectionMember1Properties; + +/// +/// Text can be included in the layer as either `i-{input}` (plain text) or `ie-{base64_encoded_input}` +/// (base64). By default, the SDK selects the appropriate format based on the input +/// text. To always use base64 (`ie-{base64}`), set this parameter to `base64`. +/// To always use plain text (`i-{input}`), set it to `plain`. +/// +[JsonConverter(typeof(EncodingConverter))] +public enum Encoding +{ + Auto, + Plain, + Base64, +} + +sealed class EncodingConverter : JsonConverter +{ + public override Encoding Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "auto" => Encoding.Auto, + "plain" => Encoding.Plain, + "base64" => Encoding.Base64, + _ => (Encoding)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Encoding value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + Encoding.Auto => "auto", + Encoding.Plain => "plain", + Encoding.Base64 => "base64", + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/TextOverlayTransformation.cs b/src/Imagekit/Models/TextOverlayTransformation.cs new file mode 100644 index 00000000..0fd70a89 --- /dev/null +++ b/src/Imagekit/Models/TextOverlayTransformation.cs @@ -0,0 +1,345 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.TextOverlayTransformationProperties; + +namespace Imagekit.Models; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class TextOverlayTransformation + : ModelBase, + IFromRaw +{ + /// + /// Specifies the transparency level of the text overlay. Accepts integers from + /// `1` to `9`. + /// + public double? Alpha + { + get + { + if (!this.Properties.TryGetValue("alpha", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["alpha"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies the background color of the text overlay. Accepts an RGB hex code, + /// an RGBA code, or a color name. + /// + public string? Background + { + get + { + if (!this.Properties.TryGetValue("background", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["background"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Flip the text overlay horizontally, vertically, or both. + /// + public ApiEnum? Flip + { + get + { + if (!this.Properties.TryGetValue("flip", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["flip"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies the font color of the overlaid text. Accepts an RGB hex code (e.g., + /// `FF0000`), an RGBA code (e.g., `FFAABB50`), or a color name. + /// + public string? FontColor + { + get + { + if (!this.Properties.TryGetValue("fontColor", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["fontColor"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies the font family of the overlaid text. Choose from the supported + /// fonts list or use a custom font. See [Supported fonts](https://imagekit.io/docs/add-overlays-on-images#supported-text-font-list) + /// and [Custom font](https://imagekit.io/docs/add-overlays-on-images#change-font-family-in-text-overlay). + /// + public string? FontFamily + { + get + { + if (!this.Properties.TryGetValue("fontFamily", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["fontFamily"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies the font size of the overlaid text. Accepts a numeric value or + /// an arithmetic expression. + /// + public FontSize? FontSize + { + get + { + if (!this.Properties.TryGetValue("fontSize", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["fontSize"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies the inner alignment of the text when width is more than the text + /// length. + /// + public ApiEnum? InnerAlignment + { + get + { + if (!this.Properties.TryGetValue("innerAlignment", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["innerAlignment"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies the line height of the text overlay. Accepts integer values representing + /// line height in points. It can also accept [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations) + /// such as `bw_mul_0.2`, or `bh_div_20`. + /// + public LineHeight? LineHeight + { + get + { + if (!this.Properties.TryGetValue("lineHeight", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["lineHeight"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies the padding around the overlaid text. Can be provided as a single + /// positive integer or multiple values separated by underscores (following CSS + /// shorthand order). Arithmetic expressions are also accepted. + /// + public Padding? Padding + { + get + { + if (!this.Properties.TryGetValue("padding", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["padding"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies the corner radius of the text overlay. Set to `max` to achieve + /// a circular or oval shape. + /// + public Radius? Radius + { + get + { + if (!this.Properties.TryGetValue("radius", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["radius"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies the rotation angle of the text overlay. Accepts a numeric value + /// for clockwise rotation or a string prefixed with "N" for counter-clockwise + /// rotation. + /// + public Rotation? Rotation + { + get + { + if (!this.Properties.TryGetValue("rotation", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["rotation"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies the typography style of the text. Supported values: - Single + /// styles: `b` (bold), `i` (italic), `strikethrough`. - Combinations: Any combination + /// separated by underscores, e.g., `b_i`, `b_i_strikethrough`. + /// + public string? Typography + { + get + { + if (!this.Properties.TryGetValue("typography", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["typography"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies the maximum width (in pixels) of the overlaid text. The text wraps + /// automatically, and arithmetic expressions (e.g., `bw_mul_0.2` or `bh_div_2`) + /// are supported. Useful when used in conjunction with the `background`. Learn + /// about [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + /// + public Width? Width + { + get + { + if (!this.Properties.TryGetValue("width", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["width"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.Alpha; + _ = this.Background; + this.Flip?.Validate(); + _ = this.FontColor; + _ = this.FontFamily; + this.FontSize?.Validate(); + this.InnerAlignment?.Validate(); + this.LineHeight?.Validate(); + this.Padding?.Validate(); + this.Radius?.Validate(); + this.Rotation?.Validate(); + _ = this.Typography; + this.Width?.Validate(); + } + + public TextOverlayTransformation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TextOverlayTransformation(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static TextOverlayTransformation FromRawUnchecked( + Dictionary properties + ) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/TextOverlayTransformationProperties/Flip.cs b/src/Imagekit/Models/TextOverlayTransformationProperties/Flip.cs new file mode 100644 index 00000000..7eb76e22 --- /dev/null +++ b/src/Imagekit/Models/TextOverlayTransformationProperties/Flip.cs @@ -0,0 +1,52 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.TextOverlayTransformationProperties; + +/// +/// Flip the text overlay horizontally, vertically, or both. +/// +[JsonConverter(typeof(FlipConverter))] +public enum Flip +{ + H, + V, + HV, + VH, +} + +sealed class FlipConverter : JsonConverter +{ + public override Flip Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "h" => Flip.H, + "v" => Flip.V, + "h_v" => Flip.HV, + "v_h" => Flip.VH, + _ => (Flip)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Flip value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + Flip.H => "h", + Flip.V => "v", + Flip.HV => "h_v", + Flip.VH => "v_h", + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/TextOverlayTransformationProperties/FontSize.cs b/src/Imagekit/Models/TextOverlayTransformationProperties/FontSize.cs new file mode 100644 index 00000000..47f3d413 --- /dev/null +++ b/src/Imagekit/Models/TextOverlayTransformationProperties/FontSize.cs @@ -0,0 +1,115 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using FontSizeVariants = Imagekit.Models.TextOverlayTransformationProperties.FontSizeVariants; + +namespace Imagekit.Models.TextOverlayTransformationProperties; + +/// +/// Specifies the font size of the overlaid text. Accepts a numeric value or an arithmetic expression. +/// +[JsonConverter(typeof(FontSizeConverter))] +public abstract record class FontSize +{ + internal FontSize() { } + + public static implicit operator FontSize(double value) => new FontSizeVariants::Double(value); + + public static implicit operator FontSize(string value) => new FontSizeVariants::String(value); + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as FontSizeVariants::Double)?.Value; + return value != null; + } + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as FontSizeVariants::String)?.Value; + return value != null; + } + + public void Switch( + Action @double, + Action @string + ) + { + switch (this) + { + case FontSizeVariants::Double inner: + @double(inner); + break; + case FontSizeVariants::String inner: + @string(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func @double, + Func @string + ) + { + return this switch + { + FontSizeVariants::Double inner => @double(inner), + FontSizeVariants::String inner => @string(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class FontSizeConverter : JsonConverter +{ + public override FontSize? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + return new FontSizeVariants::Double( + JsonSerializer.Deserialize(ref reader, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new FontSizeVariants::String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + + public override void Write(Utf8JsonWriter writer, FontSize value, JsonSerializerOptions options) + { + object variant = value switch + { + FontSizeVariants::Double(var @double) => @double, + FontSizeVariants::String(var @string) => @string, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/TextOverlayTransformationProperties/FontSizeVariants/All.cs b/src/Imagekit/Models/TextOverlayTransformationProperties/FontSizeVariants/All.cs new file mode 100644 index 00000000..3bf4b3ae --- /dev/null +++ b/src/Imagekit/Models/TextOverlayTransformationProperties/FontSizeVariants/All.cs @@ -0,0 +1,21 @@ +namespace Imagekit.Models.TextOverlayTransformationProperties.FontSizeVariants; + +public sealed record class Double(double Value) : FontSize, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class String(string Value) : FontSize, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/TextOverlayTransformationProperties/InnerAlignment.cs b/src/Imagekit/Models/TextOverlayTransformationProperties/InnerAlignment.cs new file mode 100644 index 00000000..8dab9ed3 --- /dev/null +++ b/src/Imagekit/Models/TextOverlayTransformationProperties/InnerAlignment.cs @@ -0,0 +1,53 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.TextOverlayTransformationProperties; + +/// +/// Specifies the inner alignment of the text when width is more than the text length. +/// +[JsonConverter(typeof(InnerAlignmentConverter))] +public enum InnerAlignment +{ + Left, + Right, + Center, +} + +sealed class InnerAlignmentConverter : JsonConverter +{ + public override InnerAlignment Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "left" => InnerAlignment.Left, + "right" => InnerAlignment.Right, + "center" => InnerAlignment.Center, + _ => (InnerAlignment)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + InnerAlignment value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + InnerAlignment.Left => "left", + InnerAlignment.Right => "right", + InnerAlignment.Center => "center", + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/TextOverlayTransformationProperties/LineHeight.cs b/src/Imagekit/Models/TextOverlayTransformationProperties/LineHeight.cs new file mode 100644 index 00000000..4038cfb1 --- /dev/null +++ b/src/Imagekit/Models/TextOverlayTransformationProperties/LineHeight.cs @@ -0,0 +1,123 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using LineHeightVariants = Imagekit.Models.TextOverlayTransformationProperties.LineHeightVariants; + +namespace Imagekit.Models.TextOverlayTransformationProperties; + +/// +/// Specifies the line height of the text overlay. Accepts integer values representing +/// line height in points. It can also accept [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations) +/// such as `bw_mul_0.2`, or `bh_div_20`. +/// +[JsonConverter(typeof(LineHeightConverter))] +public abstract record class LineHeight +{ + internal LineHeight() { } + + public static implicit operator LineHeight(double value) => + new LineHeightVariants::Double(value); + + public static implicit operator LineHeight(string value) => + new LineHeightVariants::String(value); + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as LineHeightVariants::Double)?.Value; + return value != null; + } + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as LineHeightVariants::String)?.Value; + return value != null; + } + + public void Switch( + Action @double, + Action @string + ) + { + switch (this) + { + case LineHeightVariants::Double inner: + @double(inner); + break; + case LineHeightVariants::String inner: + @string(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func @double, + Func @string + ) + { + return this switch + { + LineHeightVariants::Double inner => @double(inner), + LineHeightVariants::String inner => @string(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class LineHeightConverter : JsonConverter +{ + public override LineHeight? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + return new LineHeightVariants::Double( + JsonSerializer.Deserialize(ref reader, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new LineHeightVariants::String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + + public override void Write( + Utf8JsonWriter writer, + LineHeight value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + LineHeightVariants::Double(var @double) => @double, + LineHeightVariants::String(var @string) => @string, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/TextOverlayTransformationProperties/LineHeightVariants/All.cs b/src/Imagekit/Models/TextOverlayTransformationProperties/LineHeightVariants/All.cs new file mode 100644 index 00000000..79caf949 --- /dev/null +++ b/src/Imagekit/Models/TextOverlayTransformationProperties/LineHeightVariants/All.cs @@ -0,0 +1,21 @@ +namespace Imagekit.Models.TextOverlayTransformationProperties.LineHeightVariants; + +public sealed record class Double(double Value) : LineHeight, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class String(string Value) : LineHeight, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/TextOverlayTransformationProperties/Padding.cs b/src/Imagekit/Models/TextOverlayTransformationProperties/Padding.cs new file mode 100644 index 00000000..09bec728 --- /dev/null +++ b/src/Imagekit/Models/TextOverlayTransformationProperties/Padding.cs @@ -0,0 +1,117 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using PaddingVariants = Imagekit.Models.TextOverlayTransformationProperties.PaddingVariants; + +namespace Imagekit.Models.TextOverlayTransformationProperties; + +/// +/// Specifies the padding around the overlaid text. Can be provided as a single positive +/// integer or multiple values separated by underscores (following CSS shorthand order). +/// Arithmetic expressions are also accepted. +/// +[JsonConverter(typeof(PaddingConverter))] +public abstract record class Padding +{ + internal Padding() { } + + public static implicit operator Padding(double value) => new PaddingVariants::Double(value); + + public static implicit operator Padding(string value) => new PaddingVariants::String(value); + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as PaddingVariants::Double)?.Value; + return value != null; + } + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as PaddingVariants::String)?.Value; + return value != null; + } + + public void Switch( + Action @double, + Action @string + ) + { + switch (this) + { + case PaddingVariants::Double inner: + @double(inner); + break; + case PaddingVariants::String inner: + @string(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func @double, + Func @string + ) + { + return this switch + { + PaddingVariants::Double inner => @double(inner), + PaddingVariants::String inner => @string(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class PaddingConverter : JsonConverter +{ + public override Padding? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + return new PaddingVariants::Double( + JsonSerializer.Deserialize(ref reader, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new PaddingVariants::String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + + public override void Write(Utf8JsonWriter writer, Padding value, JsonSerializerOptions options) + { + object variant = value switch + { + PaddingVariants::Double(var @double) => @double, + PaddingVariants::String(var @string) => @string, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/TextOverlayTransformationProperties/PaddingVariants/All.cs b/src/Imagekit/Models/TextOverlayTransformationProperties/PaddingVariants/All.cs new file mode 100644 index 00000000..4a679151 --- /dev/null +++ b/src/Imagekit/Models/TextOverlayTransformationProperties/PaddingVariants/All.cs @@ -0,0 +1,21 @@ +namespace Imagekit.Models.TextOverlayTransformationProperties.PaddingVariants; + +public sealed record class Double(double Value) : Padding, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class String(string Value) : Padding, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/TextOverlayTransformationProperties/Radius.cs b/src/Imagekit/Models/TextOverlayTransformationProperties/Radius.cs new file mode 100644 index 00000000..0c2f728c --- /dev/null +++ b/src/Imagekit/Models/TextOverlayTransformationProperties/Radius.cs @@ -0,0 +1,106 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using RadiusVariants = Imagekit.Models.TextOverlayTransformationProperties.RadiusVariants; + +namespace Imagekit.Models.TextOverlayTransformationProperties; + +/// +/// Specifies the corner radius of the text overlay. Set to `max` to achieve a circular +/// or oval shape. +/// +[JsonConverter(typeof(RadiusConverter))] +public abstract record class Radius +{ + internal Radius() { } + + public static implicit operator Radius(double value) => new RadiusVariants::Double(value); + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as RadiusVariants::Double)?.Value; + return value != null; + } + + public bool TryPickMax([NotNullWhen(true)] out JsonElement? value) + { + value = (this as RadiusVariants::Max)?.Value; + return value != null; + } + + public void Switch(Action @double, Action max) + { + switch (this) + { + case RadiusVariants::Double inner: + @double(inner); + break; + case RadiusVariants::Max inner: + max(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match(Func @double, Func max) + { + return this switch + { + RadiusVariants::Double inner => @double(inner), + RadiusVariants::Max inner => max(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class RadiusConverter : JsonConverter +{ + public override Radius? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + return new RadiusVariants::Max( + JsonSerializer.Deserialize(ref reader, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new RadiusVariants::Double( + JsonSerializer.Deserialize(ref reader, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + + public override void Write(Utf8JsonWriter writer, Radius value, JsonSerializerOptions options) + { + object variant = value switch + { + RadiusVariants::Double(var @double) => @double, + RadiusVariants::Max(var max) => max, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/TextOverlayTransformationProperties/RadiusVariants/All.cs b/src/Imagekit/Models/TextOverlayTransformationProperties/RadiusVariants/All.cs new file mode 100644 index 00000000..8f858903 --- /dev/null +++ b/src/Imagekit/Models/TextOverlayTransformationProperties/RadiusVariants/All.cs @@ -0,0 +1,23 @@ +using System.Text.Json; + +namespace Imagekit.Models.TextOverlayTransformationProperties.RadiusVariants; + +public sealed record class Double(double Value) : Radius, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Max(JsonElement Value) : Radius, IVariant +{ + public static Max From(JsonElement value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/TextOverlayTransformationProperties/Rotation.cs b/src/Imagekit/Models/TextOverlayTransformationProperties/Rotation.cs new file mode 100644 index 00000000..cb4ceeba --- /dev/null +++ b/src/Imagekit/Models/TextOverlayTransformationProperties/Rotation.cs @@ -0,0 +1,116 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using RotationVariants = Imagekit.Models.TextOverlayTransformationProperties.RotationVariants; + +namespace Imagekit.Models.TextOverlayTransformationProperties; + +/// +/// Specifies the rotation angle of the text overlay. Accepts a numeric value for +/// clockwise rotation or a string prefixed with "N" for counter-clockwise rotation. +/// +[JsonConverter(typeof(RotationConverter))] +public abstract record class Rotation +{ + internal Rotation() { } + + public static implicit operator Rotation(double value) => new RotationVariants::Double(value); + + public static implicit operator Rotation(string value) => new RotationVariants::String(value); + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as RotationVariants::Double)?.Value; + return value != null; + } + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as RotationVariants::String)?.Value; + return value != null; + } + + public void Switch( + Action @double, + Action @string + ) + { + switch (this) + { + case RotationVariants::Double inner: + @double(inner); + break; + case RotationVariants::String inner: + @string(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func @double, + Func @string + ) + { + return this switch + { + RotationVariants::Double inner => @double(inner), + RotationVariants::String inner => @string(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class RotationConverter : JsonConverter +{ + public override Rotation? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + return new RotationVariants::Double( + JsonSerializer.Deserialize(ref reader, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new RotationVariants::String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + + public override void Write(Utf8JsonWriter writer, Rotation value, JsonSerializerOptions options) + { + object variant = value switch + { + RotationVariants::Double(var @double) => @double, + RotationVariants::String(var @string) => @string, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/TextOverlayTransformationProperties/RotationVariants/All.cs b/src/Imagekit/Models/TextOverlayTransformationProperties/RotationVariants/All.cs new file mode 100644 index 00000000..b56a030f --- /dev/null +++ b/src/Imagekit/Models/TextOverlayTransformationProperties/RotationVariants/All.cs @@ -0,0 +1,21 @@ +namespace Imagekit.Models.TextOverlayTransformationProperties.RotationVariants; + +public sealed record class Double(double Value) : Rotation, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class String(string Value) : Rotation, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/TextOverlayTransformationProperties/Width.cs b/src/Imagekit/Models/TextOverlayTransformationProperties/Width.cs new file mode 100644 index 00000000..9a9f43b7 --- /dev/null +++ b/src/Imagekit/Models/TextOverlayTransformationProperties/Width.cs @@ -0,0 +1,115 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using WidthVariants = Imagekit.Models.TextOverlayTransformationProperties.WidthVariants; + +namespace Imagekit.Models.TextOverlayTransformationProperties; + +/// +/// Specifies the maximum width (in pixels) of the overlaid text. The text wraps +/// automatically, and arithmetic expressions (e.g., `bw_mul_0.2` or `bh_div_2`) +/// are supported. Useful when used in conjunction with the `background`. Learn about +/// [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). +/// +[JsonConverter(typeof(WidthConverter))] +public abstract record class Width +{ + internal Width() { } + + public static implicit operator Width(double value) => new WidthVariants::Double(value); + + public static implicit operator Width(string value) => new WidthVariants::String(value); + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as WidthVariants::Double)?.Value; + return value != null; + } + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as WidthVariants::String)?.Value; + return value != null; + } + + public void Switch(Action @double, Action @string) + { + switch (this) + { + case WidthVariants::Double inner: + @double(inner); + break; + case WidthVariants::String inner: + @string(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func @double, + Func @string + ) + { + return this switch + { + WidthVariants::Double inner => @double(inner), + WidthVariants::String inner => @string(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class WidthConverter : JsonConverter +{ + public override Width? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + return new WidthVariants::Double( + JsonSerializer.Deserialize(ref reader, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new WidthVariants::String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + + public override void Write(Utf8JsonWriter writer, Width value, JsonSerializerOptions options) + { + object variant = value switch + { + WidthVariants::Double(var @double) => @double, + WidthVariants::String(var @string) => @string, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/TextOverlayTransformationProperties/WidthVariants/All.cs b/src/Imagekit/Models/TextOverlayTransformationProperties/WidthVariants/All.cs new file mode 100644 index 00000000..e08d3a5e --- /dev/null +++ b/src/Imagekit/Models/TextOverlayTransformationProperties/WidthVariants/All.cs @@ -0,0 +1,21 @@ +namespace Imagekit.Models.TextOverlayTransformationProperties.WidthVariants; + +public sealed record class Double(double Value) : Width, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class String(string Value) : Width, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/Transformation.cs b/src/Imagekit/Models/Transformation.cs new file mode 100644 index 00000000..e1051a84 --- /dev/null +++ b/src/Imagekit/Models/Transformation.cs @@ -0,0 +1,1320 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.TransformationProperties; + +namespace Imagekit.Models; + +/// +/// The SDK provides easy-to-use names for transformations. These names are converted +/// to the corresponding transformation string before being added to the URL. SDKs +/// are updated regularly to support new transformations. If you want to use a transformation +/// that is not supported by the SDK, You can use the `raw` parameter to pass the +/// transformation string directly. See the [Transformations documentation](https://imagekit.io/docs/transformations). +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class Transformation : ModelBase, IFromRaw +{ + /// + /// Uses AI to change the background. Provide a text prompt or a base64-encoded + /// prompt, e.g., `prompt-snow road` or `prompte-[urlencoded_base64_encoded_text]`. + /// Not supported inside overlay. See [AI Change Background](https://imagekit.io/docs/ai-transformations#change-background-e-changebg). + /// + public string? AIChangeBackground + { + get + { + if (!this.Properties.TryGetValue("aiChangeBackground", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["aiChangeBackground"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Adds an AI-based drop shadow around a foreground object on a transparent or + /// removed background. Optionally, control the direction, elevation, and saturation + /// of the light source (e.g., `az-45` to change light direction). Pass `true` + /// for the default drop shadow, or provide a string for a custom drop shadow. + /// Supported inside overlay. See [AI Drop Shadow](https://imagekit.io/docs/ai-transformations#ai-drop-shadow-e-dropshadow). + /// + public AIDropShadow? AIDropShadow + { + get + { + if (!this.Properties.TryGetValue("aiDropShadow", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["aiDropShadow"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Uses AI to edit images based on a text prompt. Provide a text prompt or a + /// base64-encoded prompt, e.g., `prompt-snow road` or `prompte-[urlencoded_base64_encoded_text]`. + /// Not supported inside overlay. See [AI Edit](https://imagekit.io/docs/ai-transformations#edit-image-e-edit). + /// + public string? AIEdit + { + get + { + if (!this.Properties.TryGetValue("aiEdit", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["aiEdit"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Applies ImageKit's in-house background removal. Supported inside overlay. + /// See [AI Background Removal](https://imagekit.io/docs/ai-transformations#imagekit-background-removal-e-bgremove). + /// + public ApiEnum? AIRemoveBackground + { + get + { + if (!this.Properties.TryGetValue("aiRemoveBackground", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["aiRemoveBackground"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Uses third-party background removal. Note: It is recommended to use aiRemoveBackground, + /// ImageKit's in-house solution, which is more cost-effective. Supported inside + /// overlay. See [External Background Removal](https://imagekit.io/docs/ai-transformations#background-removal-e-removedotbg). + /// + public ApiEnum? AIRemoveBackgroundExternal + { + get + { + if (!this.Properties.TryGetValue("aiRemoveBackgroundExternal", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["aiRemoveBackgroundExternal"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Performs AI-based retouching to improve faces or product shots. Not supported + /// inside overlay. See [AI Retouch](https://imagekit.io/docs/ai-transformations#retouch-e-retouch). + /// + public ApiEnum? AIRetouch + { + get + { + if (!this.Properties.TryGetValue("aiRetouch", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["aiRetouch"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Upscales images beyond their original dimensions using AI. Not supported inside + /// overlay. See [AI Upscale](https://imagekit.io/docs/ai-transformations#upscale-e-upscale). + /// + public ApiEnum? AIUpscale + { + get + { + if (!this.Properties.TryGetValue("aiUpscale", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["aiUpscale"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Generates a variation of an image using AI. This produces a new image with + /// slight variations from the original, such as changes in color, texture, + /// and other visual elements, while preserving the structure and essence of the + /// original image. Not supported inside overlay. See [AI Generate Variations](https://imagekit.io/docs/ai-transformations#generate-variations-of-an-image-e-genvar). + /// + public ApiEnum? AIVariation + { + get + { + if (!this.Properties.TryGetValue("aiVariation", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["aiVariation"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies the aspect ratio for the output, e.g., "ar-4-3". Typically used + /// with either width or height (but not both). For example: aspectRatio = `4:3`, + /// `4_3`, or an expression like `iar_div_2`. See [Image resize and crop – Aspect + /// ratio](https://imagekit.io/docs/image-resize-and-crop#aspect-ratio---ar). + /// + public AspectRatio? AspectRatio + { + get + { + if (!this.Properties.TryGetValue("aspectRatio", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["aspectRatio"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies the audio codec, e.g., `aac`, `opus`, or `none`. See [Audio codec](https://imagekit.io/docs/video-optimization#audio-codec---ac). + /// + public ApiEnum? AudioCodec + { + get + { + if (!this.Properties.TryGetValue("audioCodec", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["audioCodec"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies the background to be used in conjunction with certain cropping + /// strategies when resizing an image. - A solid color: e.g., `red`, `F3F3F3`, + /// `AAFF0010`. See [Solid color background](https://imagekit.io/docs/effects-and-enhancements#solid-color-background). + /// - A blurred background: e.g., `blurred`, `blurred_25_N15`, etc. See [Blurred + /// background](https://imagekit.io/docs/effects-and-enhancements#blurred-background). + /// - Expand the image boundaries using generative fill: `genfill`. Not supported + /// inside overlay. Optionally, control the background scene by passing a text + /// prompt: `genfill[:-prompt-${text}]` or `genfill[:-prompte-${urlencoded_base64_encoded_text}]`. + /// See [Generative fill background](https://imagekit.io/docs/ai-transformations#generative-fill-bg-genfill). + /// + public string? Background + { + get + { + if (!this.Properties.TryGetValue("background", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["background"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies the Gaussian blur level. Accepts an integer value between 1 and + /// 100, or an expression like `bl-10`. See [Blur](https://imagekit.io/docs/effects-and-enhancements#blur---bl). + /// + public double? Blur + { + get + { + if (!this.Properties.TryGetValue("blur", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["blur"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Adds a border to the output media. Accepts a string in the format `_` + /// (e.g., `5_FFF000` for a 5px yellow border), or an expression like `ih_div_20_FF00FF`. + /// See [Border](https://imagekit.io/docs/effects-and-enhancements#border---b). + /// + public string? Border + { + get + { + if (!this.Properties.TryGetValue("border", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["border"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Indicates whether the output image should retain the original color profile. + /// See [Color profile](https://imagekit.io/docs/image-optimization#color-profile---cp). + /// + public bool? ColorProfile + { + get + { + if (!this.Properties.TryGetValue("colorProfile", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["colorProfile"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Automatically enhances the contrast of an image (contrast stretch). See [Contrast + /// Stretch](https://imagekit.io/docs/effects-and-enhancements#contrast-stretch---e-contrast). + /// + public ApiEnum? ContrastStretch + { + get + { + if (!this.Properties.TryGetValue("contrastStretch", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["contrastStretch"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Crop modes for image resizing. See [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). + /// + public ApiEnum? Crop + { + get + { + if (!this.Properties.TryGetValue("crop", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["crop"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Additional crop modes for image resizing. See [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). + /// + public ApiEnum? CropMode + { + get + { + if (!this.Properties.TryGetValue("cropMode", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["cropMode"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies a fallback image if the resource is not found, e.g., a URL or file + /// path. See [Default image](https://imagekit.io/docs/image-transformation#default-image---di). + /// + public string? DefaultImage + { + get + { + if (!this.Properties.TryGetValue("defaultImage", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["defaultImage"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Accepts values between 0.1 and 5, or `auto` for automatic device pixel ratio + /// (DPR) calculation. See [DPR](https://imagekit.io/docs/image-resize-and-crop#dpr---dpr). + /// + public double? Dpr + { + get + { + if (!this.Properties.TryGetValue("dpr", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["dpr"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies the duration (in seconds) for trimming videos, e.g., `5` or `10.5`. + /// Typically used with startOffset to indicate the length from the start offset. + /// Arithmetic expressions are supported. See [Trim videos – Duration](https://imagekit.io/docs/trim-videos#duration---du). + /// + public Duration? Duration + { + get + { + if (!this.Properties.TryGetValue("duration", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["duration"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies the end offset (in seconds) for trimming videos, e.g., `5` or `10.5`. + /// Typically used with startOffset to define a time window. Arithmetic expressions + /// are supported. See [Trim videos – End offset](https://imagekit.io/docs/trim-videos#end-offset---eo). + /// + public EndOffset? EndOffset + { + get + { + if (!this.Properties.TryGetValue("endOffset", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["endOffset"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Flips or mirrors an image either horizontally, vertically, or both. Acceptable + /// values: `h` (horizontal), `v` (vertical), `h_v` (horizontal and vertical), + /// or `v_h`. See [Flip](https://imagekit.io/docs/effects-and-enhancements#flip---fl). + /// + public ApiEnum? Flip + { + get + { + if (!this.Properties.TryGetValue("flip", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["flip"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Refines padding and cropping behavior for pad resize, maintain ratio, and + /// extract crop modes. Supports manual positions and coordinate-based focus. + /// With AI-based cropping, you can automatically keep key subjects in frame—such + /// as faces or detected objects (e.g., `fo-face`, `fo-person`, `fo-car`)— while + /// resizing. - See [Focus](https://imagekit.io/docs/image-resize-and-crop#focus---fo). + /// - [Object aware cropping](https://imagekit.io/docs/image-resize-and-crop#object-aware-cropping---fo-object-name) + /// + public string? Focus + { + get + { + if (!this.Properties.TryGetValue("focus", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["focus"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies the output format for images or videos, e.g., `jpg`, `png`, `webp`, + /// `mp4`, or `auto`. You can also pass `orig` for images to return the original + /// format. ImageKit automatically delivers images and videos in the optimal format + /// based on device support unless overridden by the dashboard settings or the + /// format parameter. See [Image format](https://imagekit.io/docs/image-optimization#format---f) + /// and [Video format](https://imagekit.io/docs/video-optimization#format---f). + /// + public ApiEnum? Format + { + get + { + if (!this.Properties.TryGetValue("format", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["format"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Creates a linear gradient with two colors. Pass `true` for a default gradient, + /// or provide a string for a custom gradient. See [Gradient](https://imagekit.io/docs/effects-and-enhancements#gradient---e-gradient). + /// + public Gradient? Gradient + { + get + { + if (!this.Properties.TryGetValue("gradient", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["gradient"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Enables a grayscale effect for images. See [Grayscale](https://imagekit.io/docs/effects-and-enhancements#grayscale---e-grayscale). + /// + public ApiEnum? Grayscale + { + get + { + if (!this.Properties.TryGetValue("grayscale", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["grayscale"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies the height of the output. If a value between 0 and 1 is provided, + /// it is treated as a percentage (e.g., `0.5` represents 50% of the original + /// height). You can also supply arithmetic expressions (e.g., `ih_mul_0.5`). + /// Height transformation – [Images](https://imagekit.io/docs/image-resize-and-crop#height---h) + /// · [Videos](https://imagekit.io/docs/video-resize-and-crop#height---h) + /// + public Height? Height + { + get + { + if (!this.Properties.TryGetValue("height", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["height"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies whether the output image (in JPEG or PNG) should be compressed losslessly. + /// See [Lossless compression](https://imagekit.io/docs/image-optimization#lossless-webp-and-png---lo). + /// + public bool? Lossless + { + get + { + if (!this.Properties.TryGetValue("lossless", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["lossless"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// By default, ImageKit removes all metadata during automatic image compression. + /// Set this to true to preserve metadata. See [Image metadata](https://imagekit.io/docs/image-optimization#image-metadata---md). + /// + public bool? Metadata + { + get + { + if (!this.Properties.TryGetValue("metadata", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["metadata"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Named transformation reference. See [Named transformations](https://imagekit.io/docs/transformations#named-transformations). + /// + public string? Named + { + get + { + if (!this.Properties.TryGetValue("named", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["named"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies the opacity level of the output image. See [Opacity](https://imagekit.io/docs/effects-and-enhancements#opacity---o). + /// + public double? Opacity + { + get + { + if (!this.Properties.TryGetValue("opacity", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["opacity"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// If set to true, serves the original file without applying any transformations. + /// See [Deliver original file as-is](https://imagekit.io/docs/core-delivery-features#deliver-original-file-as-is---orig-true). + /// + public bool? Original + { + get + { + if (!this.Properties.TryGetValue("original", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["original"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies an overlay to be applied on the parent image or video. ImageKit + /// supports overlays including images, text, videos, subtitles, and solid colors. + /// See [Overlay using layers](https://imagekit.io/docs/transformations#overlay-using-layers). + /// + public Overlay? Overlay + { + get + { + if (!this.Properties.TryGetValue("overlay", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["overlay"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Extracts a specific page or frame from multi-page or layered files (PDF, PSD, + /// AI). For example, specify by number (e.g., `2`), a range (e.g., `3-4` for + /// the 2nd and 3rd layers), or by name (e.g., `name-layer-4` for a PSD layer). + /// See [Thumbnail extraction](https://imagekit.io/docs/vector-and-animated-images#get-thumbnail-from-psd-pdf-ai-eps-and-animated-files). + /// + public Page? Page + { + get + { + if (!this.Properties.TryGetValue("page", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["page"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies whether the output JPEG image should be rendered progressively. + /// Progressive loading begins with a low-quality, pixelated version of the full + /// image, which gradually improves to provide a faster perceived load time. See + /// [Progressive images](https://imagekit.io/docs/image-optimization#progressive-image---pr). + /// + public bool? Progressive + { + get + { + if (!this.Properties.TryGetValue("progressive", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["progressive"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies the quality of the output image for lossy formats such as JPEG, + /// WebP, and AVIF. A higher quality value results in a larger file size with + /// better quality, while a lower value produces a smaller file size with reduced + /// quality. See [Quality](https://imagekit.io/docs/image-optimization#quality---q). + /// + public double? Quality + { + get + { + if (!this.Properties.TryGetValue("quality", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["quality"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies the corner radius for rounded corners (e.g., 20) or `max` for circular + /// or oval shape. See [Radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). + /// + public Radius? Radius + { + get + { + if (!this.Properties.TryGetValue("radius", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["radius"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Pass any transformation not directly supported by the SDK. This transformation + /// string is appended to the URL as provided. + /// + public string? Raw + { + get + { + if (!this.Properties.TryGetValue("raw", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["raw"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies the rotation angle in degrees. Positive values rotate the image + /// clockwise; you can also use, for example, `N40` for counterclockwise rotation + /// or `auto` to use the orientation specified in the image's EXIF data. For + /// videos, only the following values are supported: 0, 90, 180, 270, or 360. + /// See [Rotate](https://imagekit.io/docs/effects-and-enhancements#rotate---rt). + /// + public Rotation? Rotation + { + get + { + if (!this.Properties.TryGetValue("rotation", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["rotation"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Adds a shadow beneath solid objects in an image with a transparent background. + /// For AI-based drop shadows, refer to aiDropShadow. Pass `true` for a default + /// shadow, or provide a string for a custom shadow. See [Shadow](https://imagekit.io/docs/effects-and-enhancements#shadow---e-shadow). + /// + public Shadow? Shadow + { + get + { + if (!this.Properties.TryGetValue("shadow", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["shadow"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Sharpens the input image, highlighting edges and finer details. Pass `true` + /// for default sharpening, or provide a numeric value for custom sharpening. + /// See [Sharpen](https://imagekit.io/docs/effects-and-enhancements#sharpen---e-sharpen). + /// + public Sharpen? Sharpen + { + get + { + if (!this.Properties.TryGetValue("sharpen", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["sharpen"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies the start offset (in seconds) for trimming videos, e.g., `5` or + /// `10.5`. Arithmetic expressions are also supported. See [Trim videos – Start + /// offset](https://imagekit.io/docs/trim-videos#start-offset---so). + /// + public StartOffset? StartOffset + { + get + { + if (!this.Properties.TryGetValue("startOffset", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["startOffset"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// An array of resolutions for adaptive bitrate streaming, e.g., [`240`, `360`, + /// `480`, `720`, `1080`]. See [Adaptive Bitrate Streaming](https://imagekit.io/docs/adaptive-bitrate-streaming). + /// + public List>? StreamingResolutions + { + get + { + if (!this.Properties.TryGetValue("streamingResolutions", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize>?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["streamingResolutions"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Useful for images with a solid or nearly solid background and a central object. + /// This parameter trims the background, leaving only the central object in + /// the output image. See [Trim edges](https://imagekit.io/docs/effects-and-enhancements#trim-edges---t). + /// + public Trim? Trim + { + get + { + if (!this.Properties.TryGetValue("trim", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["trim"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Applies Unsharp Masking (USM), an image sharpening technique. Pass `true` + /// for a default unsharp mask, or provide a string for a custom unsharp mask. + /// See [Unsharp Mask](https://imagekit.io/docs/effects-and-enhancements#unsharp-mask---e-usm). + /// + public UnsharpMask? UnsharpMask + { + get + { + if (!this.Properties.TryGetValue("unsharpMask", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["unsharpMask"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies the video codec, e.g., `h264`, `vp9`, `av1`, or `none`. See [Video codec](https://imagekit.io/docs/video-optimization#video-codec---vc). + /// + public ApiEnum? VideoCodec + { + get + { + if (!this.Properties.TryGetValue("videoCodec", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["videoCodec"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies the width of the output. If a value between 0 and 1 is provided, + /// it is treated as a percentage (e.g., `0.4` represents 40% of the original + /// width). You can also supply arithmetic expressions (e.g., `iw_div_2`). Width + /// transformation – [Images](https://imagekit.io/docs/image-resize-and-crop#width---w) + /// · [Videos](https://imagekit.io/docs/video-resize-and-crop#width---w) + /// + public Width? Width + { + get + { + if (!this.Properties.TryGetValue("width", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["width"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Focus using cropped image coordinates - X coordinate. See [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). + /// + public X? X + { + get + { + if (!this.Properties.TryGetValue("x", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["x"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Focus using cropped image coordinates - X center coordinate. See [Focus using + /// cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). + /// + public XCenter? XCenter + { + get + { + if (!this.Properties.TryGetValue("xCenter", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["xCenter"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Focus using cropped image coordinates - Y coordinate. See [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). + /// + public Y? Y + { + get + { + if (!this.Properties.TryGetValue("y", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["y"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Focus using cropped image coordinates - Y center coordinate. See [Focus using + /// cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). + /// + public YCenter? YCenter + { + get + { + if (!this.Properties.TryGetValue("yCenter", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["yCenter"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Accepts a numeric value that determines how much to zoom in or out of the + /// cropped area. It should be used in conjunction with fo-face or fo-. + /// See [Zoom](https://imagekit.io/docs/image-resize-and-crop#zoom---z). + /// + public double? Zoom + { + get + { + if (!this.Properties.TryGetValue("zoom", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["zoom"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.AIChangeBackground; + this.AIDropShadow?.Validate(); + _ = this.AIEdit; + this.AIRemoveBackground?.Validate(); + this.AIRemoveBackgroundExternal?.Validate(); + this.AIRetouch?.Validate(); + this.AIUpscale?.Validate(); + this.AIVariation?.Validate(); + this.AspectRatio?.Validate(); + this.AudioCodec?.Validate(); + _ = this.Background; + _ = this.Blur; + _ = this.Border; + _ = this.ColorProfile; + this.ContrastStretch?.Validate(); + this.Crop?.Validate(); + this.CropMode?.Validate(); + _ = this.DefaultImage; + _ = this.Dpr; + this.Duration?.Validate(); + this.EndOffset?.Validate(); + this.Flip?.Validate(); + _ = this.Focus; + this.Format?.Validate(); + this.Gradient?.Validate(); + this.Grayscale?.Validate(); + this.Height?.Validate(); + _ = this.Lossless; + _ = this.Metadata; + _ = this.Named; + _ = this.Opacity; + _ = this.Original; + this.Overlay?.Validate(); + this.Page?.Validate(); + _ = this.Progressive; + _ = this.Quality; + this.Radius?.Validate(); + _ = this.Raw; + this.Rotation?.Validate(); + this.Shadow?.Validate(); + this.Sharpen?.Validate(); + this.StartOffset?.Validate(); + foreach (var item in this.StreamingResolutions ?? []) + { + item.Validate(); + } + this.Trim?.Validate(); + this.UnsharpMask?.Validate(); + this.VideoCodec?.Validate(); + this.Width?.Validate(); + this.X?.Validate(); + this.XCenter?.Validate(); + this.Y?.Validate(); + this.YCenter?.Validate(); + _ = this.Zoom; + } + + public Transformation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Transformation(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Transformation FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/TransformationPosition.cs b/src/Imagekit/Models/TransformationPosition.cs new file mode 100644 index 00000000..2f6aba22 --- /dev/null +++ b/src/Imagekit/Models/TransformationPosition.cs @@ -0,0 +1,52 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models; + +/// +/// By default, the transformation string is added as a query parameter in the URL, +/// e.g., `?tr=w-100,h-100`. If you want to add the transformation string in the +/// path of the URL, set this to `path`. Learn more in the [Transformations guide](https://imagekit.io/docs/transformations). +/// +[JsonConverter(typeof(TransformationPositionConverter))] +public enum TransformationPosition +{ + Path, + Query, +} + +sealed class TransformationPositionConverter : JsonConverter +{ + public override TransformationPosition Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "path" => TransformationPosition.Path, + "query" => TransformationPosition.Query, + _ => (TransformationPosition)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + TransformationPosition value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + TransformationPosition.Path => "path", + TransformationPosition.Query => "query", + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/TransformationProperties/AIDropShadow.cs b/src/Imagekit/Models/TransformationProperties/AIDropShadow.cs new file mode 100644 index 00000000..9298e807 --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/AIDropShadow.cs @@ -0,0 +1,122 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using AIDropShadowVariants = Imagekit.Models.TransformationProperties.AIDropShadowVariants; + +namespace Imagekit.Models.TransformationProperties; + +/// +/// Adds an AI-based drop shadow around a foreground object on a transparent or removed +/// background. Optionally, control the direction, elevation, and saturation of +/// the light source (e.g., `az-45` to change light direction). Pass `true` for the +/// default drop shadow, or provide a string for a custom drop shadow. Supported +/// inside overlay. See [AI Drop Shadow](https://imagekit.io/docs/ai-transformations#ai-drop-shadow-e-dropshadow). +/// +[JsonConverter(typeof(AIDropShadowConverter))] +public abstract record class AIDropShadow +{ + internal AIDropShadow() { } + + public static implicit operator AIDropShadow(string value) => + new AIDropShadowVariants::String(value); + + public bool TryPickTrue([NotNullWhen(true)] out JsonElement? value) + { + value = (this as AIDropShadowVariants::True)?.Value; + return value != null; + } + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as AIDropShadowVariants::String)?.Value; + return value != null; + } + + public void Switch( + Action true1, + Action @string + ) + { + switch (this) + { + case AIDropShadowVariants::True inner: + true1(inner); + break; + case AIDropShadowVariants::String inner: + @string(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func true1, + Func @string + ) + { + return this switch + { + AIDropShadowVariants::True inner => true1(inner), + AIDropShadowVariants::String inner => @string(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class AIDropShadowConverter : JsonConverter +{ + public override AIDropShadow? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + return new AIDropShadowVariants::True( + JsonSerializer.Deserialize(ref reader, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new AIDropShadowVariants::String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + + public override void Write( + Utf8JsonWriter writer, + AIDropShadow value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + AIDropShadowVariants::True(var true1) => true1, + AIDropShadowVariants::String(var @string) => @string, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/TransformationProperties/AIDropShadowVariants/All.cs b/src/Imagekit/Models/TransformationProperties/AIDropShadowVariants/All.cs new file mode 100644 index 00000000..8efb0f9e --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/AIDropShadowVariants/All.cs @@ -0,0 +1,23 @@ +using System.Text.Json; + +namespace Imagekit.Models.TransformationProperties.AIDropShadowVariants; + +public sealed record class True(JsonElement Value) : AIDropShadow, IVariant +{ + public static True From(JsonElement value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class String(string Value) : AIDropShadow, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/TransformationProperties/AIRemoveBackground.cs b/src/Imagekit/Models/TransformationProperties/AIRemoveBackground.cs new file mode 100644 index 00000000..dae6c3e7 --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/AIRemoveBackground.cs @@ -0,0 +1,48 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.TransformationProperties; + +/// +/// Applies ImageKit's in-house background removal. Supported inside overlay. See +/// [AI Background Removal](https://imagekit.io/docs/ai-transformations#imagekit-background-removal-e-bgremove). +/// +[JsonConverter(typeof(AIRemoveBackgroundConverter))] +public enum AIRemoveBackground +{ + True, +} + +sealed class AIRemoveBackgroundConverter : JsonConverter +{ + public override AIRemoveBackground Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + true => AIRemoveBackground.True, + _ => (AIRemoveBackground)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + AIRemoveBackground value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + AIRemoveBackground.True => true, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/TransformationProperties/AIRemoveBackgroundExternal.cs b/src/Imagekit/Models/TransformationProperties/AIRemoveBackgroundExternal.cs new file mode 100644 index 00000000..263eeab4 --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/AIRemoveBackgroundExternal.cs @@ -0,0 +1,49 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.TransformationProperties; + +/// +/// Uses third-party background removal. Note: It is recommended to use aiRemoveBackground, +/// ImageKit's in-house solution, which is more cost-effective. Supported inside overlay. +/// See [External Background Removal](https://imagekit.io/docs/ai-transformations#background-removal-e-removedotbg). +/// +[JsonConverter(typeof(AIRemoveBackgroundExternalConverter))] +public enum AIRemoveBackgroundExternal +{ + True, +} + +sealed class AIRemoveBackgroundExternalConverter : JsonConverter +{ + public override AIRemoveBackgroundExternal Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + true => AIRemoveBackgroundExternal.True, + _ => (AIRemoveBackgroundExternal)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + AIRemoveBackgroundExternal value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + AIRemoveBackgroundExternal.True => true, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/TransformationProperties/AIRetouch.cs b/src/Imagekit/Models/TransformationProperties/AIRetouch.cs new file mode 100644 index 00000000..19472a80 --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/AIRetouch.cs @@ -0,0 +1,48 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.TransformationProperties; + +/// +/// Performs AI-based retouching to improve faces or product shots. Not supported +/// inside overlay. See [AI Retouch](https://imagekit.io/docs/ai-transformations#retouch-e-retouch). +/// +[JsonConverter(typeof(AIRetouchConverter))] +public enum AIRetouch +{ + True, +} + +sealed class AIRetouchConverter : JsonConverter +{ + public override AIRetouch Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + true => AIRetouch.True, + _ => (AIRetouch)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + AIRetouch value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + AIRetouch.True => true, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/TransformationProperties/AIUpscale.cs b/src/Imagekit/Models/TransformationProperties/AIUpscale.cs new file mode 100644 index 00000000..0ff1ab45 --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/AIUpscale.cs @@ -0,0 +1,48 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.TransformationProperties; + +/// +/// Upscales images beyond their original dimensions using AI. Not supported inside +/// overlay. See [AI Upscale](https://imagekit.io/docs/ai-transformations#upscale-e-upscale). +/// +[JsonConverter(typeof(AIUpscaleConverter))] +public enum AIUpscale +{ + True, +} + +sealed class AIUpscaleConverter : JsonConverter +{ + public override AIUpscale Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + true => AIUpscale.True, + _ => (AIUpscale)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + AIUpscale value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + AIUpscale.True => true, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/TransformationProperties/AIVariation.cs b/src/Imagekit/Models/TransformationProperties/AIVariation.cs new file mode 100644 index 00000000..4f6d49e0 --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/AIVariation.cs @@ -0,0 +1,50 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.TransformationProperties; + +/// +/// Generates a variation of an image using AI. This produces a new image with slight +/// variations from the original, such as changes in color, texture, and other visual +/// elements, while preserving the structure and essence of the original image. Not +/// supported inside overlay. See [AI Generate Variations](https://imagekit.io/docs/ai-transformations#generate-variations-of-an-image-e-genvar). +/// +[JsonConverter(typeof(AIVariationConverter))] +public enum AIVariation +{ + True, +} + +sealed class AIVariationConverter : JsonConverter +{ + public override AIVariation Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + true => AIVariation.True, + _ => (AIVariation)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + AIVariation value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + AIVariation.True => true, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/TransformationProperties/AspectRatio.cs b/src/Imagekit/Models/TransformationProperties/AspectRatio.cs new file mode 100644 index 00000000..6ce169b1 --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/AspectRatio.cs @@ -0,0 +1,123 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using AspectRatioVariants = Imagekit.Models.TransformationProperties.AspectRatioVariants; + +namespace Imagekit.Models.TransformationProperties; + +/// +/// Specifies the aspect ratio for the output, e.g., "ar-4-3". Typically used with +/// either width or height (but not both). For example: aspectRatio = `4:3`, `4_3`, +/// or an expression like `iar_div_2`. See [Image resize and crop – Aspect ratio](https://imagekit.io/docs/image-resize-and-crop#aspect-ratio---ar). +/// +[JsonConverter(typeof(AspectRatioConverter))] +public abstract record class AspectRatio +{ + internal AspectRatio() { } + + public static implicit operator AspectRatio(double value) => + new AspectRatioVariants::Double(value); + + public static implicit operator AspectRatio(string value) => + new AspectRatioVariants::String(value); + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as AspectRatioVariants::Double)?.Value; + return value != null; + } + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as AspectRatioVariants::String)?.Value; + return value != null; + } + + public void Switch( + Action @double, + Action @string + ) + { + switch (this) + { + case AspectRatioVariants::Double inner: + @double(inner); + break; + case AspectRatioVariants::String inner: + @string(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func @double, + Func @string + ) + { + return this switch + { + AspectRatioVariants::Double inner => @double(inner), + AspectRatioVariants::String inner => @string(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class AspectRatioConverter : JsonConverter +{ + public override AspectRatio? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + return new AspectRatioVariants::Double( + JsonSerializer.Deserialize(ref reader, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new AspectRatioVariants::String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + + public override void Write( + Utf8JsonWriter writer, + AspectRatio value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + AspectRatioVariants::Double(var @double) => @double, + AspectRatioVariants::String(var @string) => @string, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/TransformationProperties/AspectRatioVariants/All.cs b/src/Imagekit/Models/TransformationProperties/AspectRatioVariants/All.cs new file mode 100644 index 00000000..d22b4b13 --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/AspectRatioVariants/All.cs @@ -0,0 +1,21 @@ +namespace Imagekit.Models.TransformationProperties.AspectRatioVariants; + +public sealed record class Double(double Value) : AspectRatio, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class String(string Value) : AspectRatio, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/TransformationProperties/AudioCodec.cs b/src/Imagekit/Models/TransformationProperties/AudioCodec.cs new file mode 100644 index 00000000..c5a861d3 --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/AudioCodec.cs @@ -0,0 +1,53 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.TransformationProperties; + +/// +/// Specifies the audio codec, e.g., `aac`, `opus`, or `none`. See [Audio codec](https://imagekit.io/docs/video-optimization#audio-codec---ac). +/// +[JsonConverter(typeof(AudioCodecConverter))] +public enum AudioCodec +{ + Aac, + Opus, + None, +} + +sealed class AudioCodecConverter : JsonConverter +{ + public override AudioCodec Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "aac" => AudioCodec.Aac, + "opus" => AudioCodec.Opus, + "none" => AudioCodec.None, + _ => (AudioCodec)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + AudioCodec value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + AudioCodec.Aac => "aac", + AudioCodec.Opus => "opus", + AudioCodec.None => "none", + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/TransformationProperties/ContrastStretch.cs b/src/Imagekit/Models/TransformationProperties/ContrastStretch.cs new file mode 100644 index 00000000..4ee3ec61 --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/ContrastStretch.cs @@ -0,0 +1,48 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.TransformationProperties; + +/// +/// Automatically enhances the contrast of an image (contrast stretch). See [Contrast +/// Stretch](https://imagekit.io/docs/effects-and-enhancements#contrast-stretch---e-contrast). +/// +[JsonConverter(typeof(ContrastStretchConverter))] +public enum ContrastStretch +{ + True, +} + +sealed class ContrastStretchConverter : JsonConverter +{ + public override ContrastStretch Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + true => ContrastStretch.True, + _ => (ContrastStretch)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ContrastStretch value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ContrastStretch.True => true, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/TransformationProperties/Crop.cs b/src/Imagekit/Models/TransformationProperties/Crop.cs new file mode 100644 index 00000000..eb549d7a --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/Crop.cs @@ -0,0 +1,55 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.TransformationProperties; + +/// +/// Crop modes for image resizing. See [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). +/// +[JsonConverter(typeof(CropConverter))] +public enum Crop +{ + Force, + AtMax, + AtMaxEnlarge, + AtLeast, + MaintainRatio, +} + +sealed class CropConverter : JsonConverter +{ + public override Crop Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "force" => Crop.Force, + "at_max" => Crop.AtMax, + "at_max_enlarge" => Crop.AtMaxEnlarge, + "at_least" => Crop.AtLeast, + "maintain_ratio" => Crop.MaintainRatio, + _ => (Crop)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Crop value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + Crop.Force => "force", + Crop.AtMax => "at_max", + Crop.AtMaxEnlarge => "at_max_enlarge", + Crop.AtLeast => "at_least", + Crop.MaintainRatio => "maintain_ratio", + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/TransformationProperties/CropMode.cs b/src/Imagekit/Models/TransformationProperties/CropMode.cs new file mode 100644 index 00000000..ec058dc1 --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/CropMode.cs @@ -0,0 +1,49 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.TransformationProperties; + +/// +/// Additional crop modes for image resizing. See [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). +/// +[JsonConverter(typeof(CropModeConverter))] +public enum CropMode +{ + PadResize, + Extract, + PadExtract, +} + +sealed class CropModeConverter : JsonConverter +{ + public override CropMode Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "pad_resize" => CropMode.PadResize, + "extract" => CropMode.Extract, + "pad_extract" => CropMode.PadExtract, + _ => (CropMode)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, CropMode value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + CropMode.PadResize => "pad_resize", + CropMode.Extract => "extract", + CropMode.PadExtract => "pad_extract", + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/TransformationProperties/Duration.cs b/src/Imagekit/Models/TransformationProperties/Duration.cs new file mode 100644 index 00000000..c1cd0a7b --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/Duration.cs @@ -0,0 +1,117 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using DurationVariants = Imagekit.Models.TransformationProperties.DurationVariants; + +namespace Imagekit.Models.TransformationProperties; + +/// +/// Specifies the duration (in seconds) for trimming videos, e.g., `5` or `10.5`. +/// Typically used with startOffset to indicate the length from the start offset. +/// Arithmetic expressions are supported. See [Trim videos – Duration](https://imagekit.io/docs/trim-videos#duration---du). +/// +[JsonConverter(typeof(DurationConverter))] +public abstract record class Duration +{ + internal Duration() { } + + public static implicit operator Duration(double value) => new DurationVariants::Double(value); + + public static implicit operator Duration(string value) => new DurationVariants::String(value); + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as DurationVariants::Double)?.Value; + return value != null; + } + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as DurationVariants::String)?.Value; + return value != null; + } + + public void Switch( + Action @double, + Action @string + ) + { + switch (this) + { + case DurationVariants::Double inner: + @double(inner); + break; + case DurationVariants::String inner: + @string(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func @double, + Func @string + ) + { + return this switch + { + DurationVariants::Double inner => @double(inner), + DurationVariants::String inner => @string(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class DurationConverter : JsonConverter +{ + public override Duration? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + return new DurationVariants::Double( + JsonSerializer.Deserialize(ref reader, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new DurationVariants::String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + + public override void Write(Utf8JsonWriter writer, Duration value, JsonSerializerOptions options) + { + object variant = value switch + { + DurationVariants::Double(var @double) => @double, + DurationVariants::String(var @string) => @string, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/TransformationProperties/DurationVariants/All.cs b/src/Imagekit/Models/TransformationProperties/DurationVariants/All.cs new file mode 100644 index 00000000..0aafb7f0 --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/DurationVariants/All.cs @@ -0,0 +1,21 @@ +namespace Imagekit.Models.TransformationProperties.DurationVariants; + +public sealed record class Double(double Value) : Duration, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class String(string Value) : Duration, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/TransformationProperties/EndOffset.cs b/src/Imagekit/Models/TransformationProperties/EndOffset.cs new file mode 100644 index 00000000..2badea7b --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/EndOffset.cs @@ -0,0 +1,121 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using EndOffsetVariants = Imagekit.Models.TransformationProperties.EndOffsetVariants; + +namespace Imagekit.Models.TransformationProperties; + +/// +/// Specifies the end offset (in seconds) for trimming videos, e.g., `5` or `10.5`. +/// Typically used with startOffset to define a time window. Arithmetic expressions +/// are supported. See [Trim videos – End offset](https://imagekit.io/docs/trim-videos#end-offset---eo). +/// +[JsonConverter(typeof(EndOffsetConverter))] +public abstract record class EndOffset +{ + internal EndOffset() { } + + public static implicit operator EndOffset(double value) => new EndOffsetVariants::Double(value); + + public static implicit operator EndOffset(string value) => new EndOffsetVariants::String(value); + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as EndOffsetVariants::Double)?.Value; + return value != null; + } + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as EndOffsetVariants::String)?.Value; + return value != null; + } + + public void Switch( + Action @double, + Action @string + ) + { + switch (this) + { + case EndOffsetVariants::Double inner: + @double(inner); + break; + case EndOffsetVariants::String inner: + @string(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func @double, + Func @string + ) + { + return this switch + { + EndOffsetVariants::Double inner => @double(inner), + EndOffsetVariants::String inner => @string(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class EndOffsetConverter : JsonConverter +{ + public override EndOffset? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + return new EndOffsetVariants::Double( + JsonSerializer.Deserialize(ref reader, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new EndOffsetVariants::String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + + public override void Write( + Utf8JsonWriter writer, + EndOffset value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + EndOffsetVariants::Double(var @double) => @double, + EndOffsetVariants::String(var @string) => @string, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/TransformationProperties/EndOffsetVariants/All.cs b/src/Imagekit/Models/TransformationProperties/EndOffsetVariants/All.cs new file mode 100644 index 00000000..062c3931 --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/EndOffsetVariants/All.cs @@ -0,0 +1,21 @@ +namespace Imagekit.Models.TransformationProperties.EndOffsetVariants; + +public sealed record class Double(double Value) : EndOffset, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class String(string Value) : EndOffset, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/TransformationProperties/Flip.cs b/src/Imagekit/Models/TransformationProperties/Flip.cs new file mode 100644 index 00000000..581d36a2 --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/Flip.cs @@ -0,0 +1,54 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.TransformationProperties; + +/// +/// Flips or mirrors an image either horizontally, vertically, or both. Acceptable +/// values: `h` (horizontal), `v` (vertical), `h_v` (horizontal and vertical), or +/// `v_h`. See [Flip](https://imagekit.io/docs/effects-and-enhancements#flip---fl). +/// +[JsonConverter(typeof(FlipConverter))] +public enum Flip +{ + H, + V, + HV, + VH, +} + +sealed class FlipConverter : JsonConverter +{ + public override Flip Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "h" => Flip.H, + "v" => Flip.V, + "h_v" => Flip.HV, + "v_h" => Flip.VH, + _ => (Flip)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Flip value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + Flip.H => "h", + Flip.V => "v", + Flip.HV => "h_v", + Flip.VH => "v_h", + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/TransformationProperties/Format.cs b/src/Imagekit/Models/TransformationProperties/Format.cs new file mode 100644 index 00000000..261f1417 --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/Format.cs @@ -0,0 +1,78 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.TransformationProperties; + +/// +/// Specifies the output format for images or videos, e.g., `jpg`, `png`, `webp`, +/// `mp4`, or `auto`. You can also pass `orig` for images to return the original +/// format. ImageKit automatically delivers images and videos in the optimal format +/// based on device support unless overridden by the dashboard settings or the format +/// parameter. See [Image format](https://imagekit.io/docs/image-optimization#format---f) +/// and [Video format](https://imagekit.io/docs/video-optimization#format---f). +/// +[JsonConverter(typeof(FormatConverter))] +public enum Format +{ + Auto, + Webp, + Jpg, + Jpeg, + Png, + Gif, + Svg, + MP4, + Webm, + Avif, + Orig, +} + +sealed class FormatConverter : JsonConverter +{ + public override Format Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "auto" => Format.Auto, + "webp" => Format.Webp, + "jpg" => Format.Jpg, + "jpeg" => Format.Jpeg, + "png" => Format.Png, + "gif" => Format.Gif, + "svg" => Format.Svg, + "mp4" => Format.MP4, + "webm" => Format.Webm, + "avif" => Format.Avif, + "orig" => Format.Orig, + _ => (Format)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Format value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + Format.Auto => "auto", + Format.Webp => "webp", + Format.Jpg => "jpg", + Format.Jpeg => "jpeg", + Format.Png => "png", + Format.Gif => "gif", + Format.Svg => "svg", + Format.MP4 => "mp4", + Format.Webm => "webm", + Format.Avif => "avif", + Format.Orig => "orig", + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/TransformationProperties/Gradient.cs b/src/Imagekit/Models/TransformationProperties/Gradient.cs new file mode 100644 index 00000000..b1bbef64 --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/Gradient.cs @@ -0,0 +1,114 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using GradientVariants = Imagekit.Models.TransformationProperties.GradientVariants; + +namespace Imagekit.Models.TransformationProperties; + +/// +/// Creates a linear gradient with two colors. Pass `true` for a default gradient, +/// or provide a string for a custom gradient. See [Gradient](https://imagekit.io/docs/effects-and-enhancements#gradient---e-gradient). +/// +[JsonConverter(typeof(GradientConverter))] +public abstract record class Gradient +{ + internal Gradient() { } + + public static implicit operator Gradient(string value) => new GradientVariants::String(value); + + public bool TryPickTrue([NotNullWhen(true)] out JsonElement? value) + { + value = (this as GradientVariants::True)?.Value; + return value != null; + } + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as GradientVariants::String)?.Value; + return value != null; + } + + public void Switch( + Action true1, + Action @string + ) + { + switch (this) + { + case GradientVariants::True inner: + true1(inner); + break; + case GradientVariants::String inner: + @string(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func true1, + Func @string + ) + { + return this switch + { + GradientVariants::True inner => true1(inner), + GradientVariants::String inner => @string(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class GradientConverter : JsonConverter +{ + public override Gradient? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + return new GradientVariants::True( + JsonSerializer.Deserialize(ref reader, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new GradientVariants::String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + + public override void Write(Utf8JsonWriter writer, Gradient value, JsonSerializerOptions options) + { + object variant = value switch + { + GradientVariants::True(var true1) => true1, + GradientVariants::String(var @string) => @string, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/TransformationProperties/GradientVariants/All.cs b/src/Imagekit/Models/TransformationProperties/GradientVariants/All.cs new file mode 100644 index 00000000..6fc6bc18 --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/GradientVariants/All.cs @@ -0,0 +1,23 @@ +using System.Text.Json; + +namespace Imagekit.Models.TransformationProperties.GradientVariants; + +public sealed record class True(JsonElement Value) : Gradient, IVariant +{ + public static True From(JsonElement value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class String(string Value) : Gradient, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/TransformationProperties/Grayscale.cs b/src/Imagekit/Models/TransformationProperties/Grayscale.cs new file mode 100644 index 00000000..4dac211d --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/Grayscale.cs @@ -0,0 +1,47 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.TransformationProperties; + +/// +/// Enables a grayscale effect for images. See [Grayscale](https://imagekit.io/docs/effects-and-enhancements#grayscale---e-grayscale). +/// +[JsonConverter(typeof(GrayscaleConverter))] +public enum Grayscale +{ + True, +} + +sealed class GrayscaleConverter : JsonConverter +{ + public override Grayscale Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + true => Grayscale.True, + _ => (Grayscale)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + Grayscale value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + Grayscale.True => true, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/TransformationProperties/Height.cs b/src/Imagekit/Models/TransformationProperties/Height.cs new file mode 100644 index 00000000..8c42abb6 --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/Height.cs @@ -0,0 +1,118 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using HeightVariants = Imagekit.Models.TransformationProperties.HeightVariants; + +namespace Imagekit.Models.TransformationProperties; + +/// +/// Specifies the height of the output. If a value between 0 and 1 is provided, it +/// is treated as a percentage (e.g., `0.5` represents 50% of the original height). +/// You can also supply arithmetic expressions (e.g., `ih_mul_0.5`). Height transformation +/// – [Images](https://imagekit.io/docs/image-resize-and-crop#height---h) · [Videos](https://imagekit.io/docs/video-resize-and-crop#height---h) +/// +[JsonConverter(typeof(HeightConverter))] +public abstract record class Height +{ + internal Height() { } + + public static implicit operator Height(double value) => new HeightVariants::Double(value); + + public static implicit operator Height(string value) => new HeightVariants::String(value); + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as HeightVariants::Double)?.Value; + return value != null; + } + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as HeightVariants::String)?.Value; + return value != null; + } + + public void Switch( + Action @double, + Action @string + ) + { + switch (this) + { + case HeightVariants::Double inner: + @double(inner); + break; + case HeightVariants::String inner: + @string(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func @double, + Func @string + ) + { + return this switch + { + HeightVariants::Double inner => @double(inner), + HeightVariants::String inner => @string(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class HeightConverter : JsonConverter +{ + public override Height? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + return new HeightVariants::Double( + JsonSerializer.Deserialize(ref reader, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new HeightVariants::String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + + public override void Write(Utf8JsonWriter writer, Height value, JsonSerializerOptions options) + { + object variant = value switch + { + HeightVariants::Double(var @double) => @double, + HeightVariants::String(var @string) => @string, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/TransformationProperties/HeightVariants/All.cs b/src/Imagekit/Models/TransformationProperties/HeightVariants/All.cs new file mode 100644 index 00000000..52dece91 --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/HeightVariants/All.cs @@ -0,0 +1,21 @@ +namespace Imagekit.Models.TransformationProperties.HeightVariants; + +public sealed record class Double(double Value) : Height, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class String(string Value) : Height, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/TransformationProperties/Page.cs b/src/Imagekit/Models/TransformationProperties/Page.cs new file mode 100644 index 00000000..8774faaa --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/Page.cs @@ -0,0 +1,112 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using PageVariants = Imagekit.Models.TransformationProperties.PageVariants; + +namespace Imagekit.Models.TransformationProperties; + +/// +/// Extracts a specific page or frame from multi-page or layered files (PDF, PSD, +/// AI). For example, specify by number (e.g., `2`), a range (e.g., `3-4` for the +/// 2nd and 3rd layers), or by name (e.g., `name-layer-4` for a PSD layer). See [Thumbnail +/// extraction](https://imagekit.io/docs/vector-and-animated-images#get-thumbnail-from-psd-pdf-ai-eps-and-animated-files). +/// +[JsonConverter(typeof(PageConverter))] +public abstract record class Page +{ + internal Page() { } + + public static implicit operator Page(double value) => new PageVariants::Double(value); + + public static implicit operator Page(string value) => new PageVariants::String(value); + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as PageVariants::Double)?.Value; + return value != null; + } + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as PageVariants::String)?.Value; + return value != null; + } + + public void Switch(Action @double, Action @string) + { + switch (this) + { + case PageVariants::Double inner: + @double(inner); + break; + case PageVariants::String inner: + @string(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match(Func @double, Func @string) + { + return this switch + { + PageVariants::Double inner => @double(inner), + PageVariants::String inner => @string(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class PageConverter : JsonConverter +{ + public override Page? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + return new PageVariants::Double( + JsonSerializer.Deserialize(ref reader, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new PageVariants::String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + + public override void Write(Utf8JsonWriter writer, Page value, JsonSerializerOptions options) + { + object variant = value switch + { + PageVariants::Double(var @double) => @double, + PageVariants::String(var @string) => @string, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/TransformationProperties/PageVariants/All.cs b/src/Imagekit/Models/TransformationProperties/PageVariants/All.cs new file mode 100644 index 00000000..ef065b2d --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/PageVariants/All.cs @@ -0,0 +1,21 @@ +namespace Imagekit.Models.TransformationProperties.PageVariants; + +public sealed record class Double(double Value) : Page, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class String(string Value) : Page, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/TransformationProperties/Radius.cs b/src/Imagekit/Models/TransformationProperties/Radius.cs new file mode 100644 index 00000000..af6dca7d --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/Radius.cs @@ -0,0 +1,106 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using RadiusVariants = Imagekit.Models.TransformationProperties.RadiusVariants; + +namespace Imagekit.Models.TransformationProperties; + +/// +/// Specifies the corner radius for rounded corners (e.g., 20) or `max` for circular +/// or oval shape. See [Radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). +/// +[JsonConverter(typeof(RadiusConverter))] +public abstract record class Radius +{ + internal Radius() { } + + public static implicit operator Radius(double value) => new RadiusVariants::Double(value); + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as RadiusVariants::Double)?.Value; + return value != null; + } + + public bool TryPickMax([NotNullWhen(true)] out JsonElement? value) + { + value = (this as RadiusVariants::Max)?.Value; + return value != null; + } + + public void Switch(Action @double, Action max) + { + switch (this) + { + case RadiusVariants::Double inner: + @double(inner); + break; + case RadiusVariants::Max inner: + max(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match(Func @double, Func max) + { + return this switch + { + RadiusVariants::Double inner => @double(inner), + RadiusVariants::Max inner => max(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class RadiusConverter : JsonConverter +{ + public override Radius? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + return new RadiusVariants::Max( + JsonSerializer.Deserialize(ref reader, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new RadiusVariants::Double( + JsonSerializer.Deserialize(ref reader, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + + public override void Write(Utf8JsonWriter writer, Radius value, JsonSerializerOptions options) + { + object variant = value switch + { + RadiusVariants::Double(var @double) => @double, + RadiusVariants::Max(var max) => max, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/TransformationProperties/RadiusVariants/All.cs b/src/Imagekit/Models/TransformationProperties/RadiusVariants/All.cs new file mode 100644 index 00000000..78448ae7 --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/RadiusVariants/All.cs @@ -0,0 +1,23 @@ +using System.Text.Json; + +namespace Imagekit.Models.TransformationProperties.RadiusVariants; + +public sealed record class Double(double Value) : Radius, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Max(JsonElement Value) : Radius, IVariant +{ + public static Max From(JsonElement value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/TransformationProperties/Rotation.cs b/src/Imagekit/Models/TransformationProperties/Rotation.cs new file mode 100644 index 00000000..60a011aa --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/Rotation.cs @@ -0,0 +1,118 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using RotationVariants = Imagekit.Models.TransformationProperties.RotationVariants; + +namespace Imagekit.Models.TransformationProperties; + +/// +/// Specifies the rotation angle in degrees. Positive values rotate the image clockwise; +/// you can also use, for example, `N40` for counterclockwise rotation or `auto` +/// to use the orientation specified in the image's EXIF data. For videos, only the +/// following values are supported: 0, 90, 180, 270, or 360. See [Rotate](https://imagekit.io/docs/effects-and-enhancements#rotate---rt). +/// +[JsonConverter(typeof(RotationConverter))] +public abstract record class Rotation +{ + internal Rotation() { } + + public static implicit operator Rotation(double value) => new RotationVariants::Double(value); + + public static implicit operator Rotation(string value) => new RotationVariants::String(value); + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as RotationVariants::Double)?.Value; + return value != null; + } + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as RotationVariants::String)?.Value; + return value != null; + } + + public void Switch( + Action @double, + Action @string + ) + { + switch (this) + { + case RotationVariants::Double inner: + @double(inner); + break; + case RotationVariants::String inner: + @string(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func @double, + Func @string + ) + { + return this switch + { + RotationVariants::Double inner => @double(inner), + RotationVariants::String inner => @string(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class RotationConverter : JsonConverter +{ + public override Rotation? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + return new RotationVariants::Double( + JsonSerializer.Deserialize(ref reader, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new RotationVariants::String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + + public override void Write(Utf8JsonWriter writer, Rotation value, JsonSerializerOptions options) + { + object variant = value switch + { + RotationVariants::Double(var @double) => @double, + RotationVariants::String(var @string) => @string, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/TransformationProperties/RotationVariants/All.cs b/src/Imagekit/Models/TransformationProperties/RotationVariants/All.cs new file mode 100644 index 00000000..2e7fac03 --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/RotationVariants/All.cs @@ -0,0 +1,21 @@ +namespace Imagekit.Models.TransformationProperties.RotationVariants; + +public sealed record class Double(double Value) : Rotation, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class String(string Value) : Rotation, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/TransformationProperties/Shadow.cs b/src/Imagekit/Models/TransformationProperties/Shadow.cs new file mode 100644 index 00000000..1a8f8e34 --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/Shadow.cs @@ -0,0 +1,109 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ShadowVariants = Imagekit.Models.TransformationProperties.ShadowVariants; + +namespace Imagekit.Models.TransformationProperties; + +/// +/// Adds a shadow beneath solid objects in an image with a transparent background. +/// For AI-based drop shadows, refer to aiDropShadow. Pass `true` for a default +/// shadow, or provide a string for a custom shadow. See [Shadow](https://imagekit.io/docs/effects-and-enhancements#shadow---e-shadow). +/// +[JsonConverter(typeof(ShadowConverter))] +public abstract record class Shadow +{ + internal Shadow() { } + + public static implicit operator Shadow(string value) => new ShadowVariants::String(value); + + public bool TryPickTrue([NotNullWhen(true)] out JsonElement? value) + { + value = (this as ShadowVariants::True)?.Value; + return value != null; + } + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as ShadowVariants::String)?.Value; + return value != null; + } + + public void Switch(Action true1, Action @string) + { + switch (this) + { + case ShadowVariants::True inner: + true1(inner); + break; + case ShadowVariants::String inner: + @string(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match(Func true1, Func @string) + { + return this switch + { + ShadowVariants::True inner => true1(inner), + ShadowVariants::String inner => @string(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class ShadowConverter : JsonConverter +{ + public override Shadow? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + return new ShadowVariants::True( + JsonSerializer.Deserialize(ref reader, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new ShadowVariants::String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + + public override void Write(Utf8JsonWriter writer, Shadow value, JsonSerializerOptions options) + { + object variant = value switch + { + ShadowVariants::True(var true1) => true1, + ShadowVariants::String(var @string) => @string, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/TransformationProperties/ShadowVariants/All.cs b/src/Imagekit/Models/TransformationProperties/ShadowVariants/All.cs new file mode 100644 index 00000000..94e02120 --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/ShadowVariants/All.cs @@ -0,0 +1,23 @@ +using System.Text.Json; + +namespace Imagekit.Models.TransformationProperties.ShadowVariants; + +public sealed record class True(JsonElement Value) : Shadow, IVariant +{ + public static True From(JsonElement value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class String(string Value) : Shadow, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/TransformationProperties/Sharpen.cs b/src/Imagekit/Models/TransformationProperties/Sharpen.cs new file mode 100644 index 00000000..27d65714 --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/Sharpen.cs @@ -0,0 +1,110 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using SharpenVariants = Imagekit.Models.TransformationProperties.SharpenVariants; + +namespace Imagekit.Models.TransformationProperties; + +/// +/// Sharpens the input image, highlighting edges and finer details. Pass `true` +/// for default sharpening, or provide a numeric value for custom sharpening. See +/// [Sharpen](https://imagekit.io/docs/effects-and-enhancements#sharpen---e-sharpen). +/// +[JsonConverter(typeof(SharpenConverter))] +public abstract record class Sharpen +{ + internal Sharpen() { } + + public static implicit operator Sharpen(double value) => new SharpenVariants::Double(value); + + public bool TryPickTrue([NotNullWhen(true)] out JsonElement? value) + { + value = (this as SharpenVariants::True)?.Value; + return value != null; + } + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as SharpenVariants::Double)?.Value; + return value != null; + } + + public void Switch(Action true1, Action @double) + { + switch (this) + { + case SharpenVariants::True inner: + true1(inner); + break; + case SharpenVariants::Double inner: + @double(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func true1, + Func @double + ) + { + return this switch + { + SharpenVariants::True inner => true1(inner), + SharpenVariants::Double inner => @double(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class SharpenConverter : JsonConverter +{ + public override Sharpen? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + return new SharpenVariants::True( + JsonSerializer.Deserialize(ref reader, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new SharpenVariants::Double( + JsonSerializer.Deserialize(ref reader, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + + public override void Write(Utf8JsonWriter writer, Sharpen value, JsonSerializerOptions options) + { + object variant = value switch + { + SharpenVariants::True(var true1) => true1, + SharpenVariants::Double(var @double) => @double, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/TransformationProperties/SharpenVariants/All.cs b/src/Imagekit/Models/TransformationProperties/SharpenVariants/All.cs new file mode 100644 index 00000000..aa226c35 --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/SharpenVariants/All.cs @@ -0,0 +1,23 @@ +using System.Text.Json; + +namespace Imagekit.Models.TransformationProperties.SharpenVariants; + +public sealed record class True(JsonElement Value) : Sharpen, IVariant +{ + public static True From(JsonElement value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Double(double Value) : Sharpen, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/TransformationProperties/StartOffset.cs b/src/Imagekit/Models/TransformationProperties/StartOffset.cs new file mode 100644 index 00000000..eb9f79bd --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/StartOffset.cs @@ -0,0 +1,122 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using StartOffsetVariants = Imagekit.Models.TransformationProperties.StartOffsetVariants; + +namespace Imagekit.Models.TransformationProperties; + +/// +/// Specifies the start offset (in seconds) for trimming videos, e.g., `5` or `10.5`. +/// Arithmetic expressions are also supported. See [Trim videos – Start offset](https://imagekit.io/docs/trim-videos#start-offset---so). +/// +[JsonConverter(typeof(StartOffsetConverter))] +public abstract record class StartOffset +{ + internal StartOffset() { } + + public static implicit operator StartOffset(double value) => + new StartOffsetVariants::Double(value); + + public static implicit operator StartOffset(string value) => + new StartOffsetVariants::String(value); + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as StartOffsetVariants::Double)?.Value; + return value != null; + } + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as StartOffsetVariants::String)?.Value; + return value != null; + } + + public void Switch( + Action @double, + Action @string + ) + { + switch (this) + { + case StartOffsetVariants::Double inner: + @double(inner); + break; + case StartOffsetVariants::String inner: + @string(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func @double, + Func @string + ) + { + return this switch + { + StartOffsetVariants::Double inner => @double(inner), + StartOffsetVariants::String inner => @string(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class StartOffsetConverter : JsonConverter +{ + public override StartOffset? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + return new StartOffsetVariants::Double( + JsonSerializer.Deserialize(ref reader, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new StartOffsetVariants::String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + + public override void Write( + Utf8JsonWriter writer, + StartOffset value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + StartOffsetVariants::Double(var @double) => @double, + StartOffsetVariants::String(var @string) => @string, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/TransformationProperties/StartOffsetVariants/All.cs b/src/Imagekit/Models/TransformationProperties/StartOffsetVariants/All.cs new file mode 100644 index 00000000..652e3912 --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/StartOffsetVariants/All.cs @@ -0,0 +1,21 @@ +namespace Imagekit.Models.TransformationProperties.StartOffsetVariants; + +public sealed record class Double(double Value) : StartOffset, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class String(string Value) : StartOffset, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/TransformationProperties/Trim.cs b/src/Imagekit/Models/TransformationProperties/Trim.cs new file mode 100644 index 00000000..ff235c78 --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/Trim.cs @@ -0,0 +1,107 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using TrimVariants = Imagekit.Models.TransformationProperties.TrimVariants; + +namespace Imagekit.Models.TransformationProperties; + +/// +/// Useful for images with a solid or nearly solid background and a central object. +/// This parameter trims the background, leaving only the central object in the output +/// image. See [Trim edges](https://imagekit.io/docs/effects-and-enhancements#trim-edges---t). +/// +[JsonConverter(typeof(TrimConverter))] +public abstract record class Trim +{ + internal Trim() { } + + public static implicit operator Trim(double value) => new TrimVariants::Double(value); + + public bool TryPickTrue([NotNullWhen(true)] out JsonElement? value) + { + value = (this as TrimVariants::True)?.Value; + return value != null; + } + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as TrimVariants::Double)?.Value; + return value != null; + } + + public void Switch(Action true1, Action @double) + { + switch (this) + { + case TrimVariants::True inner: + true1(inner); + break; + case TrimVariants::Double inner: + @double(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match(Func true1, Func @double) + { + return this switch + { + TrimVariants::True inner => true1(inner), + TrimVariants::Double inner => @double(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class TrimConverter : JsonConverter +{ + public override Trim? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + return new TrimVariants::True( + JsonSerializer.Deserialize(ref reader, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new TrimVariants::Double( + JsonSerializer.Deserialize(ref reader, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + + public override void Write(Utf8JsonWriter writer, Trim value, JsonSerializerOptions options) + { + object variant = value switch + { + TrimVariants::True(var true1) => true1, + TrimVariants::Double(var @double) => @double, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/TransformationProperties/TrimVariants/All.cs b/src/Imagekit/Models/TransformationProperties/TrimVariants/All.cs new file mode 100644 index 00000000..e26ab0d0 --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/TrimVariants/All.cs @@ -0,0 +1,23 @@ +using System.Text.Json; + +namespace Imagekit.Models.TransformationProperties.TrimVariants; + +public sealed record class True(JsonElement Value) : Trim, IVariant +{ + public static True From(JsonElement value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Double(double Value) : Trim, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/TransformationProperties/UnsharpMask.cs b/src/Imagekit/Models/TransformationProperties/UnsharpMask.cs new file mode 100644 index 00000000..c66dc5c7 --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/UnsharpMask.cs @@ -0,0 +1,120 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using UnsharpMaskVariants = Imagekit.Models.TransformationProperties.UnsharpMaskVariants; + +namespace Imagekit.Models.TransformationProperties; + +/// +/// Applies Unsharp Masking (USM), an image sharpening technique. Pass `true` for +/// a default unsharp mask, or provide a string for a custom unsharp mask. See [Unsharp +/// Mask](https://imagekit.io/docs/effects-and-enhancements#unsharp-mask---e-usm). +/// +[JsonConverter(typeof(UnsharpMaskConverter))] +public abstract record class UnsharpMask +{ + internal UnsharpMask() { } + + public static implicit operator UnsharpMask(string value) => + new UnsharpMaskVariants::String(value); + + public bool TryPickTrue([NotNullWhen(true)] out JsonElement? value) + { + value = (this as UnsharpMaskVariants::True)?.Value; + return value != null; + } + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as UnsharpMaskVariants::String)?.Value; + return value != null; + } + + public void Switch( + Action true1, + Action @string + ) + { + switch (this) + { + case UnsharpMaskVariants::True inner: + true1(inner); + break; + case UnsharpMaskVariants::String inner: + @string(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func true1, + Func @string + ) + { + return this switch + { + UnsharpMaskVariants::True inner => true1(inner), + UnsharpMaskVariants::String inner => @string(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class UnsharpMaskConverter : JsonConverter +{ + public override UnsharpMask? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + return new UnsharpMaskVariants::True( + JsonSerializer.Deserialize(ref reader, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new UnsharpMaskVariants::String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + + public override void Write( + Utf8JsonWriter writer, + UnsharpMask value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + UnsharpMaskVariants::True(var true1) => true1, + UnsharpMaskVariants::String(var @string) => @string, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/TransformationProperties/UnsharpMaskVariants/All.cs b/src/Imagekit/Models/TransformationProperties/UnsharpMaskVariants/All.cs new file mode 100644 index 00000000..6662a69b --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/UnsharpMaskVariants/All.cs @@ -0,0 +1,23 @@ +using System.Text.Json; + +namespace Imagekit.Models.TransformationProperties.UnsharpMaskVariants; + +public sealed record class True(JsonElement Value) : UnsharpMask, IVariant +{ + public static True From(JsonElement value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class String(string Value) : UnsharpMask, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/TransformationProperties/VideoCodec.cs b/src/Imagekit/Models/TransformationProperties/VideoCodec.cs new file mode 100644 index 00000000..c00b2b3b --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/VideoCodec.cs @@ -0,0 +1,56 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.TransformationProperties; + +/// +/// Specifies the video codec, e.g., `h264`, `vp9`, `av1`, or `none`. See [Video codec](https://imagekit.io/docs/video-optimization#video-codec---vc). +/// +[JsonConverter(typeof(VideoCodecConverter))] +public enum VideoCodec +{ + H264, + Vp9, + Av1, + None, +} + +sealed class VideoCodecConverter : JsonConverter +{ + public override VideoCodec Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "h264" => VideoCodec.H264, + "vp9" => VideoCodec.Vp9, + "av1" => VideoCodec.Av1, + "none" => VideoCodec.None, + _ => (VideoCodec)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + VideoCodec value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + VideoCodec.H264 => "h264", + VideoCodec.Vp9 => "vp9", + VideoCodec.Av1 => "av1", + VideoCodec.None => "none", + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/TransformationProperties/Width.cs b/src/Imagekit/Models/TransformationProperties/Width.cs new file mode 100644 index 00000000..f1dd1b24 --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/Width.cs @@ -0,0 +1,115 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using WidthVariants = Imagekit.Models.TransformationProperties.WidthVariants; + +namespace Imagekit.Models.TransformationProperties; + +/// +/// Specifies the width of the output. If a value between 0 and 1 is provided, it +/// is treated as a percentage (e.g., `0.4` represents 40% of the original width). +/// You can also supply arithmetic expressions (e.g., `iw_div_2`). Width transformation +/// – [Images](https://imagekit.io/docs/image-resize-and-crop#width---w) · [Videos](https://imagekit.io/docs/video-resize-and-crop#width---w) +/// +[JsonConverter(typeof(WidthConverter))] +public abstract record class Width +{ + internal Width() { } + + public static implicit operator Width(double value) => new WidthVariants::Double(value); + + public static implicit operator Width(string value) => new WidthVariants::String(value); + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as WidthVariants::Double)?.Value; + return value != null; + } + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as WidthVariants::String)?.Value; + return value != null; + } + + public void Switch(Action @double, Action @string) + { + switch (this) + { + case WidthVariants::Double inner: + @double(inner); + break; + case WidthVariants::String inner: + @string(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func @double, + Func @string + ) + { + return this switch + { + WidthVariants::Double inner => @double(inner), + WidthVariants::String inner => @string(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class WidthConverter : JsonConverter +{ + public override Width? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + return new WidthVariants::Double( + JsonSerializer.Deserialize(ref reader, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new WidthVariants::String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + + public override void Write(Utf8JsonWriter writer, Width value, JsonSerializerOptions options) + { + object variant = value switch + { + WidthVariants::Double(var @double) => @double, + WidthVariants::String(var @string) => @string, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/TransformationProperties/WidthVariants/All.cs b/src/Imagekit/Models/TransformationProperties/WidthVariants/All.cs new file mode 100644 index 00000000..3899be2b --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/WidthVariants/All.cs @@ -0,0 +1,21 @@ +namespace Imagekit.Models.TransformationProperties.WidthVariants; + +public sealed record class Double(double Value) : Width, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class String(string Value) : Width, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/TransformationProperties/X.cs b/src/Imagekit/Models/TransformationProperties/X.cs new file mode 100644 index 00000000..44c09b52 --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/X.cs @@ -0,0 +1,107 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using XVariants = Imagekit.Models.TransformationProperties.XVariants; + +namespace Imagekit.Models.TransformationProperties; + +/// +/// Focus using cropped image coordinates - X coordinate. See [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). +/// +[JsonConverter(typeof(XConverter))] +public abstract record class X +{ + internal X() { } + + public static implicit operator X(double value) => new XVariants::Double(value); + + public static implicit operator X(string value) => new XVariants::String(value); + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as XVariants::Double)?.Value; + return value != null; + } + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as XVariants::String)?.Value; + return value != null; + } + + public void Switch(Action @double, Action @string) + { + switch (this) + { + case XVariants::Double inner: + @double(inner); + break; + case XVariants::String inner: + @string(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match(Func @double, Func @string) + { + return this switch + { + XVariants::Double inner => @double(inner), + XVariants::String inner => @string(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class XConverter : JsonConverter +{ + public override X? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + return new XVariants::Double(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new XVariants::String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + + public override void Write(Utf8JsonWriter writer, X value, JsonSerializerOptions options) + { + object variant = value switch + { + XVariants::Double(var @double) => @double, + XVariants::String(var @string) => @string, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/TransformationProperties/XCenter.cs b/src/Imagekit/Models/TransformationProperties/XCenter.cs new file mode 100644 index 00000000..03db6407 --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/XCenter.cs @@ -0,0 +1,116 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using XCenterVariants = Imagekit.Models.TransformationProperties.XCenterVariants; + +namespace Imagekit.Models.TransformationProperties; + +/// +/// Focus using cropped image coordinates - X center coordinate. See [Focus using +/// cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). +/// +[JsonConverter(typeof(XCenterConverter))] +public abstract record class XCenter +{ + internal XCenter() { } + + public static implicit operator XCenter(double value) => new XCenterVariants::Double(value); + + public static implicit operator XCenter(string value) => new XCenterVariants::String(value); + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as XCenterVariants::Double)?.Value; + return value != null; + } + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as XCenterVariants::String)?.Value; + return value != null; + } + + public void Switch( + Action @double, + Action @string + ) + { + switch (this) + { + case XCenterVariants::Double inner: + @double(inner); + break; + case XCenterVariants::String inner: + @string(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func @double, + Func @string + ) + { + return this switch + { + XCenterVariants::Double inner => @double(inner), + XCenterVariants::String inner => @string(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class XCenterConverter : JsonConverter +{ + public override XCenter? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + return new XCenterVariants::Double( + JsonSerializer.Deserialize(ref reader, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new XCenterVariants::String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + + public override void Write(Utf8JsonWriter writer, XCenter value, JsonSerializerOptions options) + { + object variant = value switch + { + XCenterVariants::Double(var @double) => @double, + XCenterVariants::String(var @string) => @string, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/TransformationProperties/XCenterVariants/All.cs b/src/Imagekit/Models/TransformationProperties/XCenterVariants/All.cs new file mode 100644 index 00000000..af356397 --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/XCenterVariants/All.cs @@ -0,0 +1,21 @@ +namespace Imagekit.Models.TransformationProperties.XCenterVariants; + +public sealed record class Double(double Value) : XCenter, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class String(string Value) : XCenter, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/TransformationProperties/XVariants/All.cs b/src/Imagekit/Models/TransformationProperties/XVariants/All.cs new file mode 100644 index 00000000..f147a03c --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/XVariants/All.cs @@ -0,0 +1,21 @@ +namespace Imagekit.Models.TransformationProperties.XVariants; + +public sealed record class Double(double Value) : X, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class String(string Value) : X, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/TransformationProperties/Y.cs b/src/Imagekit/Models/TransformationProperties/Y.cs new file mode 100644 index 00000000..7fa77408 --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/Y.cs @@ -0,0 +1,107 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using YVariants = Imagekit.Models.TransformationProperties.YVariants; + +namespace Imagekit.Models.TransformationProperties; + +/// +/// Focus using cropped image coordinates - Y coordinate. See [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). +/// +[JsonConverter(typeof(YConverter))] +public abstract record class Y +{ + internal Y() { } + + public static implicit operator Y(double value) => new YVariants::Double(value); + + public static implicit operator Y(string value) => new YVariants::String(value); + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as YVariants::Double)?.Value; + return value != null; + } + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as YVariants::String)?.Value; + return value != null; + } + + public void Switch(Action @double, Action @string) + { + switch (this) + { + case YVariants::Double inner: + @double(inner); + break; + case YVariants::String inner: + @string(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match(Func @double, Func @string) + { + return this switch + { + YVariants::Double inner => @double(inner), + YVariants::String inner => @string(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class YConverter : JsonConverter +{ + public override Y? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + return new YVariants::Double(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new YVariants::String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + + public override void Write(Utf8JsonWriter writer, Y value, JsonSerializerOptions options) + { + object variant = value switch + { + YVariants::Double(var @double) => @double, + YVariants::String(var @string) => @string, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/TransformationProperties/YCenter.cs b/src/Imagekit/Models/TransformationProperties/YCenter.cs new file mode 100644 index 00000000..76038e88 --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/YCenter.cs @@ -0,0 +1,116 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using YCenterVariants = Imagekit.Models.TransformationProperties.YCenterVariants; + +namespace Imagekit.Models.TransformationProperties; + +/// +/// Focus using cropped image coordinates - Y center coordinate. See [Focus using +/// cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). +/// +[JsonConverter(typeof(YCenterConverter))] +public abstract record class YCenter +{ + internal YCenter() { } + + public static implicit operator YCenter(double value) => new YCenterVariants::Double(value); + + public static implicit operator YCenter(string value) => new YCenterVariants::String(value); + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as YCenterVariants::Double)?.Value; + return value != null; + } + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as YCenterVariants::String)?.Value; + return value != null; + } + + public void Switch( + Action @double, + Action @string + ) + { + switch (this) + { + case YCenterVariants::Double inner: + @double(inner); + break; + case YCenterVariants::String inner: + @string(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func @double, + Func @string + ) + { + return this switch + { + YCenterVariants::Double inner => @double(inner), + YCenterVariants::String inner => @string(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class YCenterConverter : JsonConverter +{ + public override YCenter? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + return new YCenterVariants::Double( + JsonSerializer.Deserialize(ref reader, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new YCenterVariants::String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + + public override void Write(Utf8JsonWriter writer, YCenter value, JsonSerializerOptions options) + { + object variant = value switch + { + YCenterVariants::Double(var @double) => @double, + YCenterVariants::String(var @string) => @string, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/TransformationProperties/YCenterVariants/All.cs b/src/Imagekit/Models/TransformationProperties/YCenterVariants/All.cs new file mode 100644 index 00000000..beec9696 --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/YCenterVariants/All.cs @@ -0,0 +1,21 @@ +namespace Imagekit.Models.TransformationProperties.YCenterVariants; + +public sealed record class Double(double Value) : YCenter, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class String(string Value) : YCenter, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/TransformationProperties/YVariants/All.cs b/src/Imagekit/Models/TransformationProperties/YVariants/All.cs new file mode 100644 index 00000000..eff97584 --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/YVariants/All.cs @@ -0,0 +1,21 @@ +namespace Imagekit.Models.TransformationProperties.YVariants; + +public sealed record class Double(double Value) : Y, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class String(string Value) : Y, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/VideoOverlay.cs b/src/Imagekit/Models/VideoOverlay.cs new file mode 100644 index 00000000..2ff8384f --- /dev/null +++ b/src/Imagekit/Models/VideoOverlay.cs @@ -0,0 +1,183 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.VideoOverlayProperties.IntersectionMember1Properties; + +namespace Imagekit.Models; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class VideoOverlay : ModelBase, IFromRaw +{ + public OverlayPosition? Position + { + get + { + if (!this.Properties.TryGetValue("position", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["position"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public OverlayTiming? Timing + { + get + { + if (!this.Properties.TryGetValue("timing", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["timing"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies the relative path to the video used as an overlay. + /// + public required string Input + { + get + { + if (!this.Properties.TryGetValue("input", out JsonElement element)) + throw new ArgumentOutOfRangeException("input", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("input"); + } + set + { + this.Properties["input"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The input path can be included in the layer as either `i-{input}` or `ie-{base64_encoded_input}`. + /// By default, the SDK determines the appropriate format automatically. To + /// always use base64 encoding (`ie-{base64}`), set this parameter to `base64`. + /// To always use plain text (`i-{input}`), set it to `plain`. + /// + public ApiEnum? Encoding + { + get + { + if (!this.Properties.TryGetValue("encoding", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["encoding"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Array of transformation to be applied to the overlay video. Except `streamingResolutions`, + /// all other video transformations are supported. See [Video transformations](https://imagekit.io/docs/video-transformation). + /// + public List? Transformation + { + get + { + if (!this.Properties.TryGetValue("transformation", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["transformation"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public static implicit operator BaseOverlay(VideoOverlay videoOverlay) => + new() { Position = videoOverlay.Position, Timing = videoOverlay.Timing }; + + public override void Validate() + { + this.Position?.Validate(); + this.Timing?.Validate(); + _ = this.Input; + this.Encoding?.Validate(); + foreach (var item in this.Transformation ?? []) + { + item.Validate(); + } + } + + public VideoOverlay() + { + this.Type = JsonSerializer.Deserialize("\"video\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + VideoOverlay(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static VideoOverlay FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public VideoOverlay(string input) + : this() + { + this.Input = input; + } +} diff --git a/src/Imagekit/Models/VideoOverlayProperties/IntersectionMember1.cs b/src/Imagekit/Models/VideoOverlayProperties/IntersectionMember1.cs new file mode 100644 index 00000000..8b13763d --- /dev/null +++ b/src/Imagekit/Models/VideoOverlayProperties/IntersectionMember1.cs @@ -0,0 +1,139 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.VideoOverlayProperties.IntersectionMember1Properties; + +namespace Imagekit.Models.VideoOverlayProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class IntersectionMember1 : ModelBase, IFromRaw +{ + /// + /// Specifies the relative path to the video used as an overlay. + /// + public required string Input + { + get + { + if (!this.Properties.TryGetValue("input", out JsonElement element)) + throw new ArgumentOutOfRangeException("input", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("input"); + } + set + { + this.Properties["input"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The input path can be included in the layer as either `i-{input}` or `ie-{base64_encoded_input}`. + /// By default, the SDK determines the appropriate format automatically. To + /// always use base64 encoding (`ie-{base64}`), set this parameter to `base64`. + /// To always use plain text (`i-{input}`), set it to `plain`. + /// + public ApiEnum? Encoding + { + get + { + if (!this.Properties.TryGetValue("encoding", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["encoding"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Array of transformation to be applied to the overlay video. Except `streamingResolutions`, + /// all other video transformations are supported. See [Video transformations](https://imagekit.io/docs/video-transformation). + /// + public List? Transformation + { + get + { + if (!this.Properties.TryGetValue("transformation", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["transformation"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.Input; + this.Encoding?.Validate(); + foreach (var item in this.Transformation ?? []) + { + item.Validate(); + } + } + + public IntersectionMember1() + { + this.Type = JsonSerializer.Deserialize("\"video\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + IntersectionMember1(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static IntersectionMember1 FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public IntersectionMember1(string input) + : this() + { + this.Input = input; + } +} diff --git a/src/Imagekit/Models/VideoOverlayProperties/IntersectionMember1Properties/Encoding.cs b/src/Imagekit/Models/VideoOverlayProperties/IntersectionMember1Properties/Encoding.cs new file mode 100644 index 00000000..8252c649 --- /dev/null +++ b/src/Imagekit/Models/VideoOverlayProperties/IntersectionMember1Properties/Encoding.cs @@ -0,0 +1,52 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.VideoOverlayProperties.IntersectionMember1Properties; + +/// +/// The input path can be included in the layer as either `i-{input}` or `ie-{base64_encoded_input}`. +/// By default, the SDK determines the appropriate format automatically. To always +/// use base64 encoding (`ie-{base64}`), set this parameter to `base64`. To always +/// use plain text (`i-{input}`), set it to `plain`. +/// +[JsonConverter(typeof(EncodingConverter))] +public enum Encoding +{ + Auto, + Plain, + Base64, +} + +sealed class EncodingConverter : JsonConverter +{ + public override Encoding Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "auto" => Encoding.Auto, + "plain" => Encoding.Plain, + "base64" => Encoding.Base64, + _ => (Encoding)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Encoding value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + Encoding.Auto => "auto", + Encoding.Plain => "plain", + Encoding.Base64 => "base64", + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs b/src/Imagekit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs new file mode 100644 index 00000000..a837e3d1 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs @@ -0,0 +1,364 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using UnsafeUnwrapWebhookEventVariants = Imagekit.Models.Webhooks.UnsafeUnwrapWebhookEventVariants; + +namespace Imagekit.Models.Webhooks; + +/// +/// Triggered when a new video transformation request is accepted for processing. +/// This event confirms that ImageKit has received and queued your transformation +/// request. Use this for debugging and tracking transformation lifecycle. +/// +[JsonConverter(typeof(UnsafeUnwrapWebhookEventConverter))] +public abstract record class UnsafeUnwrapWebhookEvent +{ + internal UnsafeUnwrapWebhookEvent() { } + + public static implicit operator UnsafeUnwrapWebhookEvent( + VideoTransformationAcceptedEvent value + ) => new UnsafeUnwrapWebhookEventVariants::VideoTransformationAcceptedEvent(value); + + public static implicit operator UnsafeUnwrapWebhookEvent(VideoTransformationReadyEvent value) => + new UnsafeUnwrapWebhookEventVariants::VideoTransformationReadyEvent(value); + + public static implicit operator UnsafeUnwrapWebhookEvent(VideoTransformationErrorEvent value) => + new UnsafeUnwrapWebhookEventVariants::VideoTransformationErrorEvent(value); + + public static implicit operator UnsafeUnwrapWebhookEvent( + UploadPreTransformSuccessEvent value + ) => new UnsafeUnwrapWebhookEventVariants::UploadPreTransformSuccessEvent(value); + + public static implicit operator UnsafeUnwrapWebhookEvent(UploadPreTransformErrorEvent value) => + new UnsafeUnwrapWebhookEventVariants::UploadPreTransformErrorEvent(value); + + public static implicit operator UnsafeUnwrapWebhookEvent( + UploadPostTransformSuccessEvent value + ) => new UnsafeUnwrapWebhookEventVariants::UploadPostTransformSuccessEvent(value); + + public static implicit operator UnsafeUnwrapWebhookEvent(UploadPostTransformErrorEvent value) => + new UnsafeUnwrapWebhookEventVariants::UploadPostTransformErrorEvent(value); + + public bool TryPickVideoTransformationAccepted( + [NotNullWhen(true)] out VideoTransformationAcceptedEvent? value + ) + { + value = (this as UnsafeUnwrapWebhookEventVariants::VideoTransformationAcceptedEvent)?.Value; + return value != null; + } + + public bool TryPickVideoTransformationReady( + [NotNullWhen(true)] out VideoTransformationReadyEvent? value + ) + { + value = (this as UnsafeUnwrapWebhookEventVariants::VideoTransformationReadyEvent)?.Value; + return value != null; + } + + public bool TryPickVideoTransformationError( + [NotNullWhen(true)] out VideoTransformationErrorEvent? value + ) + { + value = (this as UnsafeUnwrapWebhookEventVariants::VideoTransformationErrorEvent)?.Value; + return value != null; + } + + public bool TryPickUploadPreTransformSuccess( + [NotNullWhen(true)] out UploadPreTransformSuccessEvent? value + ) + { + value = (this as UnsafeUnwrapWebhookEventVariants::UploadPreTransformSuccessEvent)?.Value; + return value != null; + } + + public bool TryPickUploadPreTransformError( + [NotNullWhen(true)] out UploadPreTransformErrorEvent? value + ) + { + value = (this as UnsafeUnwrapWebhookEventVariants::UploadPreTransformErrorEvent)?.Value; + return value != null; + } + + public bool TryPickUploadPostTransformSuccess( + [NotNullWhen(true)] out UploadPostTransformSuccessEvent? value + ) + { + value = (this as UnsafeUnwrapWebhookEventVariants::UploadPostTransformSuccessEvent)?.Value; + return value != null; + } + + public bool TryPickUploadPostTransformError( + [NotNullWhen(true)] out UploadPostTransformErrorEvent? value + ) + { + value = (this as UnsafeUnwrapWebhookEventVariants::UploadPostTransformErrorEvent)?.Value; + return value != null; + } + + public void Switch( + Action videoTransformationAccepted, + Action videoTransformationReady, + Action videoTransformationError, + Action uploadPreTransformSuccess, + Action uploadPreTransformError, + Action uploadPostTransformSuccess, + Action uploadPostTransformError + ) + { + switch (this) + { + case UnsafeUnwrapWebhookEventVariants::VideoTransformationAcceptedEvent inner: + videoTransformationAccepted(inner); + break; + case UnsafeUnwrapWebhookEventVariants::VideoTransformationReadyEvent inner: + videoTransformationReady(inner); + break; + case UnsafeUnwrapWebhookEventVariants::VideoTransformationErrorEvent inner: + videoTransformationError(inner); + break; + case UnsafeUnwrapWebhookEventVariants::UploadPreTransformSuccessEvent inner: + uploadPreTransformSuccess(inner); + break; + case UnsafeUnwrapWebhookEventVariants::UploadPreTransformErrorEvent inner: + uploadPreTransformError(inner); + break; + case UnsafeUnwrapWebhookEventVariants::UploadPostTransformSuccessEvent inner: + uploadPostTransformSuccess(inner); + break; + case UnsafeUnwrapWebhookEventVariants::UploadPostTransformErrorEvent inner: + uploadPostTransformError(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func< + UnsafeUnwrapWebhookEventVariants::VideoTransformationAcceptedEvent, + T + > videoTransformationAccepted, + Func< + UnsafeUnwrapWebhookEventVariants::VideoTransformationReadyEvent, + T + > videoTransformationReady, + Func< + UnsafeUnwrapWebhookEventVariants::VideoTransformationErrorEvent, + T + > videoTransformationError, + Func< + UnsafeUnwrapWebhookEventVariants::UploadPreTransformSuccessEvent, + T + > uploadPreTransformSuccess, + Func< + UnsafeUnwrapWebhookEventVariants::UploadPreTransformErrorEvent, + T + > uploadPreTransformError, + Func< + UnsafeUnwrapWebhookEventVariants::UploadPostTransformSuccessEvent, + T + > uploadPostTransformSuccess, + Func< + UnsafeUnwrapWebhookEventVariants::UploadPostTransformErrorEvent, + T + > uploadPostTransformError + ) + { + return this switch + { + UnsafeUnwrapWebhookEventVariants::VideoTransformationAcceptedEvent inner => + videoTransformationAccepted(inner), + UnsafeUnwrapWebhookEventVariants::VideoTransformationReadyEvent inner => + videoTransformationReady(inner), + UnsafeUnwrapWebhookEventVariants::VideoTransformationErrorEvent inner => + videoTransformationError(inner), + UnsafeUnwrapWebhookEventVariants::UploadPreTransformSuccessEvent inner => + uploadPreTransformSuccess(inner), + UnsafeUnwrapWebhookEventVariants::UploadPreTransformErrorEvent inner => + uploadPreTransformError(inner), + UnsafeUnwrapWebhookEventVariants::UploadPostTransformSuccessEvent inner => + uploadPostTransformSuccess(inner), + UnsafeUnwrapWebhookEventVariants::UploadPostTransformErrorEvent inner => + uploadPostTransformError(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class UnsafeUnwrapWebhookEventConverter : JsonConverter +{ + public override UnsafeUnwrapWebhookEvent? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize( + ref reader, + options + ); + if (deserialized != null) + { + return new UnsafeUnwrapWebhookEventVariants::VideoTransformationAcceptedEvent( + deserialized + ); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize( + ref reader, + options + ); + if (deserialized != null) + { + return new UnsafeUnwrapWebhookEventVariants::VideoTransformationReadyEvent( + deserialized + ); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize( + ref reader, + options + ); + if (deserialized != null) + { + return new UnsafeUnwrapWebhookEventVariants::VideoTransformationErrorEvent( + deserialized + ); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize( + ref reader, + options + ); + if (deserialized != null) + { + return new UnsafeUnwrapWebhookEventVariants::UploadPreTransformSuccessEvent( + deserialized + ); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize( + ref reader, + options + ); + if (deserialized != null) + { + return new UnsafeUnwrapWebhookEventVariants::UploadPreTransformErrorEvent( + deserialized + ); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize( + ref reader, + options + ); + if (deserialized != null) + { + return new UnsafeUnwrapWebhookEventVariants::UploadPostTransformSuccessEvent( + deserialized + ); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize( + ref reader, + options + ); + if (deserialized != null) + { + return new UnsafeUnwrapWebhookEventVariants::UploadPostTransformErrorEvent( + deserialized + ); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + + public override void Write( + Utf8JsonWriter writer, + UnsafeUnwrapWebhookEvent value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + UnsafeUnwrapWebhookEventVariants::VideoTransformationAcceptedEvent( + var videoTransformationAccepted + ) => videoTransformationAccepted, + UnsafeUnwrapWebhookEventVariants::VideoTransformationReadyEvent( + var videoTransformationReady + ) => videoTransformationReady, + UnsafeUnwrapWebhookEventVariants::VideoTransformationErrorEvent( + var videoTransformationError + ) => videoTransformationError, + UnsafeUnwrapWebhookEventVariants::UploadPreTransformSuccessEvent( + var uploadPreTransformSuccess + ) => uploadPreTransformSuccess, + UnsafeUnwrapWebhookEventVariants::UploadPreTransformErrorEvent( + var uploadPreTransformError + ) => uploadPreTransformError, + UnsafeUnwrapWebhookEventVariants::UploadPostTransformSuccessEvent( + var uploadPostTransformSuccess + ) => uploadPostTransformSuccess, + UnsafeUnwrapWebhookEventVariants::UploadPostTransformErrorEvent( + var uploadPostTransformError + ) => uploadPostTransformError, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Webhooks/UnsafeUnwrapWebhookEventVariants/All.cs b/src/Imagekit/Models/Webhooks/UnsafeUnwrapWebhookEventVariants/All.cs new file mode 100644 index 00000000..b8e8a816 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/UnsafeUnwrapWebhookEventVariants/All.cs @@ -0,0 +1,163 @@ +using Webhooks = Imagekit.Models.Webhooks; + +namespace Imagekit.Models.Webhooks.UnsafeUnwrapWebhookEventVariants; + +/// +/// Triggered when a new video transformation request is accepted for processing. +/// This event confirms that ImageKit has received and queued your transformation +/// request. Use this for debugging and tracking transformation lifecycle. +/// +public sealed record class VideoTransformationAcceptedEvent( + Webhooks::VideoTransformationAcceptedEvent Value +) + : Webhooks::UnsafeUnwrapWebhookEvent, + IVariant +{ + public static VideoTransformationAcceptedEvent From( + Webhooks::VideoTransformationAcceptedEvent value + ) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +/// +/// Triggered when video encoding is finished and the transformed resource is ready +/// to be served. This is the key event to listen for - update your database or CMS +/// flags when you receive this so your application can start showing the transformed +/// video to users. +/// +public sealed record class VideoTransformationReadyEvent( + Webhooks::VideoTransformationReadyEvent Value +) + : Webhooks::UnsafeUnwrapWebhookEvent, + IVariant +{ + public static VideoTransformationReadyEvent From(Webhooks::VideoTransformationReadyEvent value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +/// +/// Triggered when an error occurs during video encoding. Listen to this webhook to +/// log error reasons and debug issues. Check your origin and URL endpoint settings +/// if the reason is related to download failure. For other errors, contact ImageKit +/// support. +/// +public sealed record class VideoTransformationErrorEvent( + Webhooks::VideoTransformationErrorEvent Value +) + : Webhooks::UnsafeUnwrapWebhookEvent, + IVariant +{ + public static VideoTransformationErrorEvent From(Webhooks::VideoTransformationErrorEvent value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +/// +/// Triggered when a pre-transformation completes successfully. The file has been +/// processed with the requested transformation and is now available in the Media +/// Library. +/// +public sealed record class UploadPreTransformSuccessEvent( + Webhooks::UploadPreTransformSuccessEvent Value +) + : Webhooks::UnsafeUnwrapWebhookEvent, + IVariant +{ + public static UploadPreTransformSuccessEvent From( + Webhooks::UploadPreTransformSuccessEvent value + ) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +/// +/// Triggered when a pre-transformation fails. The file upload may have been accepted, +/// but the requested transformation could not be applied. +/// +public sealed record class UploadPreTransformErrorEvent( + Webhooks::UploadPreTransformErrorEvent Value +) + : Webhooks::UnsafeUnwrapWebhookEvent, + IVariant +{ + public static UploadPreTransformErrorEvent From(Webhooks::UploadPreTransformErrorEvent value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +/// +/// Triggered when a post-transformation completes successfully. The transformed version +/// of the file is now ready and can be accessed via the provided URL. Note that +/// each post-transformation generates a separate webhook event. +/// +public sealed record class UploadPostTransformSuccessEvent( + Webhooks::UploadPostTransformSuccessEvent Value +) + : Webhooks::UnsafeUnwrapWebhookEvent, + IVariant +{ + public static UploadPostTransformSuccessEvent From( + Webhooks::UploadPostTransformSuccessEvent value + ) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +/// +/// Triggered when a post-transformation fails. The original file remains available, +/// but the requested transformation could not be generated. +/// +public sealed record class UploadPostTransformErrorEvent( + Webhooks::UploadPostTransformErrorEvent Value +) + : Webhooks::UnsafeUnwrapWebhookEvent, + IVariant +{ + public static UploadPostTransformErrorEvent From(Webhooks::UploadPostTransformErrorEvent value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} diff --git a/src/Imagekit/Models/Webhooks/UnwrapWebhookEvent.cs b/src/Imagekit/Models/Webhooks/UnwrapWebhookEvent.cs new file mode 100644 index 00000000..fbecd090 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/UnwrapWebhookEvent.cs @@ -0,0 +1,338 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using UnwrapWebhookEventVariants = Imagekit.Models.Webhooks.UnwrapWebhookEventVariants; + +namespace Imagekit.Models.Webhooks; + +/// +/// Triggered when a new video transformation request is accepted for processing. +/// This event confirms that ImageKit has received and queued your transformation +/// request. Use this for debugging and tracking transformation lifecycle. +/// +[JsonConverter(typeof(UnwrapWebhookEventConverter))] +public abstract record class UnwrapWebhookEvent +{ + internal UnwrapWebhookEvent() { } + + public static implicit operator UnwrapWebhookEvent(VideoTransformationAcceptedEvent value) => + new UnwrapWebhookEventVariants::VideoTransformationAcceptedEvent(value); + + public static implicit operator UnwrapWebhookEvent(VideoTransformationReadyEvent value) => + new UnwrapWebhookEventVariants::VideoTransformationReadyEvent(value); + + public static implicit operator UnwrapWebhookEvent(VideoTransformationErrorEvent value) => + new UnwrapWebhookEventVariants::VideoTransformationErrorEvent(value); + + public static implicit operator UnwrapWebhookEvent(UploadPreTransformSuccessEvent value) => + new UnwrapWebhookEventVariants::UploadPreTransformSuccessEvent(value); + + public static implicit operator UnwrapWebhookEvent(UploadPreTransformErrorEvent value) => + new UnwrapWebhookEventVariants::UploadPreTransformErrorEvent(value); + + public static implicit operator UnwrapWebhookEvent(UploadPostTransformSuccessEvent value) => + new UnwrapWebhookEventVariants::UploadPostTransformSuccessEvent(value); + + public static implicit operator UnwrapWebhookEvent(UploadPostTransformErrorEvent value) => + new UnwrapWebhookEventVariants::UploadPostTransformErrorEvent(value); + + public bool TryPickVideoTransformationAccepted( + [NotNullWhen(true)] out VideoTransformationAcceptedEvent? value + ) + { + value = (this as UnwrapWebhookEventVariants::VideoTransformationAcceptedEvent)?.Value; + return value != null; + } + + public bool TryPickVideoTransformationReady( + [NotNullWhen(true)] out VideoTransformationReadyEvent? value + ) + { + value = (this as UnwrapWebhookEventVariants::VideoTransformationReadyEvent)?.Value; + return value != null; + } + + public bool TryPickVideoTransformationError( + [NotNullWhen(true)] out VideoTransformationErrorEvent? value + ) + { + value = (this as UnwrapWebhookEventVariants::VideoTransformationErrorEvent)?.Value; + return value != null; + } + + public bool TryPickUploadPreTransformSuccess( + [NotNullWhen(true)] out UploadPreTransformSuccessEvent? value + ) + { + value = (this as UnwrapWebhookEventVariants::UploadPreTransformSuccessEvent)?.Value; + return value != null; + } + + public bool TryPickUploadPreTransformError( + [NotNullWhen(true)] out UploadPreTransformErrorEvent? value + ) + { + value = (this as UnwrapWebhookEventVariants::UploadPreTransformErrorEvent)?.Value; + return value != null; + } + + public bool TryPickUploadPostTransformSuccess( + [NotNullWhen(true)] out UploadPostTransformSuccessEvent? value + ) + { + value = (this as UnwrapWebhookEventVariants::UploadPostTransformSuccessEvent)?.Value; + return value != null; + } + + public bool TryPickUploadPostTransformError( + [NotNullWhen(true)] out UploadPostTransformErrorEvent? value + ) + { + value = (this as UnwrapWebhookEventVariants::UploadPostTransformErrorEvent)?.Value; + return value != null; + } + + public void Switch( + Action videoTransformationAccepted, + Action videoTransformationReady, + Action videoTransformationError, + Action uploadPreTransformSuccess, + Action uploadPreTransformError, + Action uploadPostTransformSuccess, + Action uploadPostTransformError + ) + { + switch (this) + { + case UnwrapWebhookEventVariants::VideoTransformationAcceptedEvent inner: + videoTransformationAccepted(inner); + break; + case UnwrapWebhookEventVariants::VideoTransformationReadyEvent inner: + videoTransformationReady(inner); + break; + case UnwrapWebhookEventVariants::VideoTransformationErrorEvent inner: + videoTransformationError(inner); + break; + case UnwrapWebhookEventVariants::UploadPreTransformSuccessEvent inner: + uploadPreTransformSuccess(inner); + break; + case UnwrapWebhookEventVariants::UploadPreTransformErrorEvent inner: + uploadPreTransformError(inner); + break; + case UnwrapWebhookEventVariants::UploadPostTransformSuccessEvent inner: + uploadPostTransformSuccess(inner); + break; + case UnwrapWebhookEventVariants::UploadPostTransformErrorEvent inner: + uploadPostTransformError(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func< + UnwrapWebhookEventVariants::VideoTransformationAcceptedEvent, + T + > videoTransformationAccepted, + Func videoTransformationReady, + Func videoTransformationError, + Func< + UnwrapWebhookEventVariants::UploadPreTransformSuccessEvent, + T + > uploadPreTransformSuccess, + Func uploadPreTransformError, + Func< + UnwrapWebhookEventVariants::UploadPostTransformSuccessEvent, + T + > uploadPostTransformSuccess, + Func uploadPostTransformError + ) + { + return this switch + { + UnwrapWebhookEventVariants::VideoTransformationAcceptedEvent inner => + videoTransformationAccepted(inner), + UnwrapWebhookEventVariants::VideoTransformationReadyEvent inner => + videoTransformationReady(inner), + UnwrapWebhookEventVariants::VideoTransformationErrorEvent inner => + videoTransformationError(inner), + UnwrapWebhookEventVariants::UploadPreTransformSuccessEvent inner => + uploadPreTransformSuccess(inner), + UnwrapWebhookEventVariants::UploadPreTransformErrorEvent inner => + uploadPreTransformError(inner), + UnwrapWebhookEventVariants::UploadPostTransformSuccessEvent inner => + uploadPostTransformSuccess(inner), + UnwrapWebhookEventVariants::UploadPostTransformErrorEvent inner => + uploadPostTransformError(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class UnwrapWebhookEventConverter : JsonConverter +{ + public override UnwrapWebhookEvent? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize( + ref reader, + options + ); + if (deserialized != null) + { + return new UnwrapWebhookEventVariants::VideoTransformationAcceptedEvent( + deserialized + ); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize( + ref reader, + options + ); + if (deserialized != null) + { + return new UnwrapWebhookEventVariants::VideoTransformationReadyEvent(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize( + ref reader, + options + ); + if (deserialized != null) + { + return new UnwrapWebhookEventVariants::VideoTransformationErrorEvent(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize( + ref reader, + options + ); + if (deserialized != null) + { + return new UnwrapWebhookEventVariants::UploadPreTransformSuccessEvent(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize( + ref reader, + options + ); + if (deserialized != null) + { + return new UnwrapWebhookEventVariants::UploadPreTransformErrorEvent(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize( + ref reader, + options + ); + if (deserialized != null) + { + return new UnwrapWebhookEventVariants::UploadPostTransformSuccessEvent( + deserialized + ); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize( + ref reader, + options + ); + if (deserialized != null) + { + return new UnwrapWebhookEventVariants::UploadPostTransformErrorEvent(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + + public override void Write( + Utf8JsonWriter writer, + UnwrapWebhookEvent value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + UnwrapWebhookEventVariants::VideoTransformationAcceptedEvent( + var videoTransformationAccepted + ) => videoTransformationAccepted, + UnwrapWebhookEventVariants::VideoTransformationReadyEvent( + var videoTransformationReady + ) => videoTransformationReady, + UnwrapWebhookEventVariants::VideoTransformationErrorEvent( + var videoTransformationError + ) => videoTransformationError, + UnwrapWebhookEventVariants::UploadPreTransformSuccessEvent( + var uploadPreTransformSuccess + ) => uploadPreTransformSuccess, + UnwrapWebhookEventVariants::UploadPreTransformErrorEvent(var uploadPreTransformError) => + uploadPreTransformError, + UnwrapWebhookEventVariants::UploadPostTransformSuccessEvent( + var uploadPostTransformSuccess + ) => uploadPostTransformSuccess, + UnwrapWebhookEventVariants::UploadPostTransformErrorEvent( + var uploadPostTransformError + ) => uploadPostTransformError, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Webhooks/UnwrapWebhookEventVariants/All.cs b/src/Imagekit/Models/Webhooks/UnwrapWebhookEventVariants/All.cs new file mode 100644 index 00000000..2f40319f --- /dev/null +++ b/src/Imagekit/Models/Webhooks/UnwrapWebhookEventVariants/All.cs @@ -0,0 +1,163 @@ +using Webhooks = Imagekit.Models.Webhooks; + +namespace Imagekit.Models.Webhooks.UnwrapWebhookEventVariants; + +/// +/// Triggered when a new video transformation request is accepted for processing. +/// This event confirms that ImageKit has received and queued your transformation +/// request. Use this for debugging and tracking transformation lifecycle. +/// +public sealed record class VideoTransformationAcceptedEvent( + Webhooks::VideoTransformationAcceptedEvent Value +) + : Webhooks::UnwrapWebhookEvent, + IVariant +{ + public static VideoTransformationAcceptedEvent From( + Webhooks::VideoTransformationAcceptedEvent value + ) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +/// +/// Triggered when video encoding is finished and the transformed resource is ready +/// to be served. This is the key event to listen for - update your database or CMS +/// flags when you receive this so your application can start showing the transformed +/// video to users. +/// +public sealed record class VideoTransformationReadyEvent( + Webhooks::VideoTransformationReadyEvent Value +) + : Webhooks::UnwrapWebhookEvent, + IVariant +{ + public static VideoTransformationReadyEvent From(Webhooks::VideoTransformationReadyEvent value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +/// +/// Triggered when an error occurs during video encoding. Listen to this webhook to +/// log error reasons and debug issues. Check your origin and URL endpoint settings +/// if the reason is related to download failure. For other errors, contact ImageKit +/// support. +/// +public sealed record class VideoTransformationErrorEvent( + Webhooks::VideoTransformationErrorEvent Value +) + : Webhooks::UnwrapWebhookEvent, + IVariant +{ + public static VideoTransformationErrorEvent From(Webhooks::VideoTransformationErrorEvent value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +/// +/// Triggered when a pre-transformation completes successfully. The file has been +/// processed with the requested transformation and is now available in the Media +/// Library. +/// +public sealed record class UploadPreTransformSuccessEvent( + Webhooks::UploadPreTransformSuccessEvent Value +) + : Webhooks::UnwrapWebhookEvent, + IVariant +{ + public static UploadPreTransformSuccessEvent From( + Webhooks::UploadPreTransformSuccessEvent value + ) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +/// +/// Triggered when a pre-transformation fails. The file upload may have been accepted, +/// but the requested transformation could not be applied. +/// +public sealed record class UploadPreTransformErrorEvent( + Webhooks::UploadPreTransformErrorEvent Value +) + : Webhooks::UnwrapWebhookEvent, + IVariant +{ + public static UploadPreTransformErrorEvent From(Webhooks::UploadPreTransformErrorEvent value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +/// +/// Triggered when a post-transformation completes successfully. The transformed version +/// of the file is now ready and can be accessed via the provided URL. Note that +/// each post-transformation generates a separate webhook event. +/// +public sealed record class UploadPostTransformSuccessEvent( + Webhooks::UploadPostTransformSuccessEvent Value +) + : Webhooks::UnwrapWebhookEvent, + IVariant +{ + public static UploadPostTransformSuccessEvent From( + Webhooks::UploadPostTransformSuccessEvent value + ) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +/// +/// Triggered when a post-transformation fails. The original file remains available, +/// but the requested transformation could not be generated. +/// +public sealed record class UploadPostTransformErrorEvent( + Webhooks::UploadPostTransformErrorEvent Value +) + : Webhooks::UnwrapWebhookEvent, + IVariant +{ + public static UploadPostTransformErrorEvent From(Webhooks::UploadPostTransformErrorEvent value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEvent.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEvent.cs new file mode 100644 index 00000000..b1b2422e --- /dev/null +++ b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEvent.cs @@ -0,0 +1,145 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Webhooks.UploadPostTransformErrorEventProperties; + +namespace Imagekit.Models.Webhooks; + +/// +/// Triggered when a post-transformation fails. The original file remains available, +/// but the requested transformation could not be generated. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class UploadPostTransformErrorEvent + : ModelBase, + IFromRaw +{ + /// + /// Unique identifier for the event. + /// + public required string ID + { + get + { + if (!this.Properties.TryGetValue("id", out JsonElement element)) + throw new ArgumentOutOfRangeException("id", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("id"); + } + set + { + this.Properties["id"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Timestamp of when the event occurred in ISO8601 format. + /// + public required DateTime CreatedAt + { + get + { + if (!this.Properties.TryGetValue("created_at", out JsonElement element)) + throw new ArgumentOutOfRangeException("created_at", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["created_at"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required Data Data + { + get + { + if (!this.Properties.TryGetValue("data", out JsonElement element)) + throw new ArgumentOutOfRangeException("data", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("data"); + } + set + { + this.Properties["data"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required Request Request + { + get + { + if (!this.Properties.TryGetValue("request", out JsonElement element)) + throw new ArgumentOutOfRangeException("request", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("request"); + } + set + { + this.Properties["request"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.ID; + _ = this.CreatedAt; + this.Data.Validate(); + this.Request.Validate(); + } + + public UploadPostTransformErrorEvent() + { + this.Type = JsonSerializer.Deserialize("\"upload.post-transform.error\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UploadPostTransformErrorEvent(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static UploadPostTransformErrorEvent FromRawUnchecked( + Dictionary properties + ) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/Data.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/Data.cs new file mode 100644 index 00000000..8783690a --- /dev/null +++ b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/Data.cs @@ -0,0 +1,148 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using DataProperties = Imagekit.Models.Webhooks.UploadPostTransformErrorEventProperties.DataProperties; + +namespace Imagekit.Models.Webhooks.UploadPostTransformErrorEventProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Data : ModelBase, IFromRaw +{ + /// + /// Unique identifier of the originally uploaded file. + /// + public required string FileID + { + get + { + if (!this.Properties.TryGetValue("fileId", out JsonElement element)) + throw new ArgumentOutOfRangeException("fileId", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("fileId"); + } + set + { + this.Properties["fileId"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Name of the file. + /// + public required string Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + throw new ArgumentOutOfRangeException("name", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("name"); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Path of the file. + /// + public required string Path + { + get + { + if (!this.Properties.TryGetValue("path", out JsonElement element)) + throw new ArgumentOutOfRangeException("path", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("path"); + } + set + { + this.Properties["path"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required DataProperties::Transformation Transformation + { + get + { + if (!this.Properties.TryGetValue("transformation", out JsonElement element)) + throw new ArgumentOutOfRangeException( + "transformation", + "Missing required argument" + ); + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ) ?? throw new ArgumentNullException("transformation"); + } + set + { + this.Properties["transformation"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// URL of the attempted post-transformation. + /// + public required string URL + { + get + { + if (!this.Properties.TryGetValue("url", out JsonElement element)) + throw new ArgumentOutOfRangeException("url", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("url"); + } + set + { + this.Properties["url"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.FileID; + _ = this.Name; + _ = this.Path; + this.Transformation.Validate(); + _ = this.URL; + } + + public Data() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Data(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Data FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/DataProperties/Transformation.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/DataProperties/Transformation.cs new file mode 100644 index 00000000..bba97cac --- /dev/null +++ b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/DataProperties/Transformation.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Webhooks.UploadPostTransformErrorEventProperties.DataProperties.TransformationProperties; + +namespace Imagekit.Models.Webhooks.UploadPostTransformErrorEventProperties.DataProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Transformation : ModelBase, IFromRaw +{ + public required Error Error + { + get + { + if (!this.Properties.TryGetValue("error", out JsonElement element)) + throw new ArgumentOutOfRangeException("error", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("error"); + } + set + { + this.Properties["error"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.Error.Validate(); + } + + public Transformation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Transformation(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Transformation FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public Transformation(Error error) + : this() + { + this.Error = error; + } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/DataProperties/TransformationProperties/Error.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/DataProperties/TransformationProperties/Error.cs new file mode 100644 index 00000000..27ceead4 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/DataProperties/TransformationProperties/Error.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Webhooks.UploadPostTransformErrorEventProperties.DataProperties.TransformationProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Error : ModelBase, IFromRaw +{ + /// + /// Reason for the post-transformation failure. + /// + public required string Reason + { + get + { + if (!this.Properties.TryGetValue("reason", out JsonElement element)) + throw new ArgumentOutOfRangeException("reason", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("reason"); + } + set + { + this.Properties["reason"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.Reason; + } + + public Error() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Error(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Error FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public Error(string reason) + : this() + { + this.Reason = reason; + } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/Request.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/Request.cs new file mode 100644 index 00000000..8ba13301 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/Request.cs @@ -0,0 +1,79 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using RequestProperties = Imagekit.Models.Webhooks.UploadPostTransformErrorEventProperties.RequestProperties; + +namespace Imagekit.Models.Webhooks.UploadPostTransformErrorEventProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Request : ModelBase, IFromRaw +{ + public required RequestProperties::Transformation Transformation + { + get + { + if (!this.Properties.TryGetValue("transformation", out JsonElement element)) + throw new ArgumentOutOfRangeException( + "transformation", + "Missing required argument" + ); + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ) ?? throw new ArgumentNullException("transformation"); + } + set + { + this.Properties["transformation"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Unique identifier for the originating request. + /// + public required string XRequestID + { + get + { + if (!this.Properties.TryGetValue("x_request_id", out JsonElement element)) + throw new ArgumentOutOfRangeException("x_request_id", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("x_request_id"); + } + set + { + this.Properties["x_request_id"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.Transformation.Validate(); + _ = this.XRequestID; + } + + public Request() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Request(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Request FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/RequestProperties/Transformation.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/RequestProperties/Transformation.cs new file mode 100644 index 00000000..d3569f92 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/RequestProperties/Transformation.cs @@ -0,0 +1,110 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using TransformationProperties = Imagekit.Models.Webhooks.UploadPostTransformErrorEventProperties.RequestProperties.TransformationProperties; + +namespace Imagekit.Models.Webhooks.UploadPostTransformErrorEventProperties.RequestProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Transformation : ModelBase, IFromRaw +{ + /// + /// Type of the requested post-transformation. + /// + public required ApiEnum Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Only applicable if transformation type is 'abs'. Streaming protocol used. + /// + public ApiEnum? Protocol + { + get + { + if (!this.Properties.TryGetValue("protocol", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["protocol"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Value for the requested transformation type. + /// + public string? Value + { + get + { + if (!this.Properties.TryGetValue("value", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["value"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.Type.Validate(); + this.Protocol?.Validate(); + _ = this.Value; + } + + public Transformation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Transformation(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Transformation FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public Transformation(ApiEnum type) + : this() + { + this.Type = type; + } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/RequestProperties/TransformationProperties/Protocol.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/RequestProperties/TransformationProperties/Protocol.cs new file mode 100644 index 00000000..734a713f --- /dev/null +++ b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/RequestProperties/TransformationProperties/Protocol.cs @@ -0,0 +1,46 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using System = System; + +namespace Imagekit.Models.Webhooks.UploadPostTransformErrorEventProperties.RequestProperties.TransformationProperties; + +/// +/// Only applicable if transformation type is 'abs'. Streaming protocol used. +/// +[JsonConverter(typeof(ProtocolConverter))] +public enum Protocol +{ + Hls, + Dash, +} + +sealed class ProtocolConverter : JsonConverter +{ + public override Protocol Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "hls" => Protocol.Hls, + "dash" => Protocol.Dash, + _ => (Protocol)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Protocol value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + Protocol.Hls => "hls", + Protocol.Dash => "dash", + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/RequestProperties/TransformationProperties/Type.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/RequestProperties/TransformationProperties/Type.cs new file mode 100644 index 00000000..aa052bf9 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/RequestProperties/TransformationProperties/Type.cs @@ -0,0 +1,52 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using System = System; + +namespace Imagekit.Models.Webhooks.UploadPostTransformErrorEventProperties.RequestProperties.TransformationProperties; + +/// +/// Type of the requested post-transformation. +/// +[JsonConverter(typeof(TypeConverter))] +public enum Type +{ + Transformation, + Abs, + GifToVideo, + Thumbnail, +} + +sealed class TypeConverter : JsonConverter +{ + public override Type Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "transformation" => TransformationProperties.Type.Transformation, + "abs" => TransformationProperties.Type.Abs, + "gif-to-video" => TransformationProperties.Type.GifToVideo, + "thumbnail" => TransformationProperties.Type.Thumbnail, + _ => (Type)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + TransformationProperties.Type.Transformation => "transformation", + TransformationProperties.Type.Abs => "abs", + TransformationProperties.Type.GifToVideo => "gif-to-video", + TransformationProperties.Type.Thumbnail => "thumbnail", + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEvent.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEvent.cs new file mode 100644 index 00000000..c4e0933c --- /dev/null +++ b/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEvent.cs @@ -0,0 +1,146 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Webhooks.UploadPostTransformSuccessEventProperties; + +namespace Imagekit.Models.Webhooks; + +/// +/// Triggered when a post-transformation completes successfully. The transformed version +/// of the file is now ready and can be accessed via the provided URL. Note that +/// each post-transformation generates a separate webhook event. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class UploadPostTransformSuccessEvent + : ModelBase, + IFromRaw +{ + /// + /// Unique identifier for the event. + /// + public required string ID + { + get + { + if (!this.Properties.TryGetValue("id", out JsonElement element)) + throw new ArgumentOutOfRangeException("id", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("id"); + } + set + { + this.Properties["id"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Timestamp of when the event occurred in ISO8601 format. + /// + public required DateTime CreatedAt + { + get + { + if (!this.Properties.TryGetValue("created_at", out JsonElement element)) + throw new ArgumentOutOfRangeException("created_at", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["created_at"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required Data Data + { + get + { + if (!this.Properties.TryGetValue("data", out JsonElement element)) + throw new ArgumentOutOfRangeException("data", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("data"); + } + set + { + this.Properties["data"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required Request Request + { + get + { + if (!this.Properties.TryGetValue("request", out JsonElement element)) + throw new ArgumentOutOfRangeException("request", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("request"); + } + set + { + this.Properties["request"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.ID; + _ = this.CreatedAt; + this.Data.Validate(); + this.Request.Validate(); + } + + public UploadPostTransformSuccessEvent() + { + this.Type = JsonSerializer.Deserialize("\"upload.post-transform.success\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UploadPostTransformSuccessEvent(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static UploadPostTransformSuccessEvent FromRawUnchecked( + Dictionary properties + ) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/Data.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/Data.cs new file mode 100644 index 00000000..e24a161d --- /dev/null +++ b/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/Data.cs @@ -0,0 +1,99 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Webhooks.UploadPostTransformSuccessEventProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Data : ModelBase, IFromRaw +{ + /// + /// Unique identifier of the originally uploaded file. + /// + public required string FileID + { + get + { + if (!this.Properties.TryGetValue("fileId", out JsonElement element)) + throw new ArgumentOutOfRangeException("fileId", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("fileId"); + } + set + { + this.Properties["fileId"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Name of the file. + /// + public required string Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + throw new ArgumentOutOfRangeException("name", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("name"); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// URL of the generated post-transformation. + /// + public required string URL + { + get + { + if (!this.Properties.TryGetValue("url", out JsonElement element)) + throw new ArgumentOutOfRangeException("url", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("url"); + } + set + { + this.Properties["url"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.FileID; + _ = this.Name; + _ = this.URL; + } + + public Data() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Data(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Data FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/Request.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/Request.cs new file mode 100644 index 00000000..2a643bb9 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/Request.cs @@ -0,0 +1,79 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using RequestProperties = Imagekit.Models.Webhooks.UploadPostTransformSuccessEventProperties.RequestProperties; + +namespace Imagekit.Models.Webhooks.UploadPostTransformSuccessEventProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Request : ModelBase, IFromRaw +{ + public required RequestProperties::Transformation Transformation + { + get + { + if (!this.Properties.TryGetValue("transformation", out JsonElement element)) + throw new ArgumentOutOfRangeException( + "transformation", + "Missing required argument" + ); + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ) ?? throw new ArgumentNullException("transformation"); + } + set + { + this.Properties["transformation"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Unique identifier for the originating request. + /// + public required string XRequestID + { + get + { + if (!this.Properties.TryGetValue("x_request_id", out JsonElement element)) + throw new ArgumentOutOfRangeException("x_request_id", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("x_request_id"); + } + set + { + this.Properties["x_request_id"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.Transformation.Validate(); + _ = this.XRequestID; + } + + public Request() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Request(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Request FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/RequestProperties/Transformation.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/RequestProperties/Transformation.cs new file mode 100644 index 00000000..cf8044dc --- /dev/null +++ b/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/RequestProperties/Transformation.cs @@ -0,0 +1,110 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using TransformationProperties = Imagekit.Models.Webhooks.UploadPostTransformSuccessEventProperties.RequestProperties.TransformationProperties; + +namespace Imagekit.Models.Webhooks.UploadPostTransformSuccessEventProperties.RequestProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Transformation : ModelBase, IFromRaw +{ + /// + /// Type of the requested post-transformation. + /// + public required ApiEnum Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Only applicable if transformation type is 'abs'. Streaming protocol used. + /// + public ApiEnum? Protocol + { + get + { + if (!this.Properties.TryGetValue("protocol", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["protocol"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Value for the requested transformation type. + /// + public string? Value + { + get + { + if (!this.Properties.TryGetValue("value", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["value"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.Type.Validate(); + this.Protocol?.Validate(); + _ = this.Value; + } + + public Transformation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Transformation(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Transformation FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public Transformation(ApiEnum type) + : this() + { + this.Type = type; + } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/RequestProperties/TransformationProperties/Protocol.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/RequestProperties/TransformationProperties/Protocol.cs new file mode 100644 index 00000000..745547da --- /dev/null +++ b/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/RequestProperties/TransformationProperties/Protocol.cs @@ -0,0 +1,46 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using System = System; + +namespace Imagekit.Models.Webhooks.UploadPostTransformSuccessEventProperties.RequestProperties.TransformationProperties; + +/// +/// Only applicable if transformation type is 'abs'. Streaming protocol used. +/// +[JsonConverter(typeof(ProtocolConverter))] +public enum Protocol +{ + Hls, + Dash, +} + +sealed class ProtocolConverter : JsonConverter +{ + public override Protocol Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "hls" => Protocol.Hls, + "dash" => Protocol.Dash, + _ => (Protocol)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Protocol value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + Protocol.Hls => "hls", + Protocol.Dash => "dash", + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/RequestProperties/TransformationProperties/Type.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/RequestProperties/TransformationProperties/Type.cs new file mode 100644 index 00000000..5ef8fe08 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/RequestProperties/TransformationProperties/Type.cs @@ -0,0 +1,52 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using System = System; + +namespace Imagekit.Models.Webhooks.UploadPostTransformSuccessEventProperties.RequestProperties.TransformationProperties; + +/// +/// Type of the requested post-transformation. +/// +[JsonConverter(typeof(TypeConverter))] +public enum Type +{ + Transformation, + Abs, + GifToVideo, + Thumbnail, +} + +sealed class TypeConverter : JsonConverter +{ + public override Type Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "transformation" => TransformationProperties.Type.Transformation, + "abs" => TransformationProperties.Type.Abs, + "gif-to-video" => TransformationProperties.Type.GifToVideo, + "thumbnail" => TransformationProperties.Type.Thumbnail, + _ => (Type)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + TransformationProperties.Type.Transformation => "transformation", + TransformationProperties.Type.Abs => "abs", + TransformationProperties.Type.GifToVideo => "gif-to-video", + TransformationProperties.Type.Thumbnail => "thumbnail", + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEvent.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEvent.cs new file mode 100644 index 00000000..c3d1ac50 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEvent.cs @@ -0,0 +1,145 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Webhooks.UploadPreTransformErrorEventProperties; + +namespace Imagekit.Models.Webhooks; + +/// +/// Triggered when a pre-transformation fails. The file upload may have been accepted, +/// but the requested transformation could not be applied. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class UploadPreTransformErrorEvent + : ModelBase, + IFromRaw +{ + /// + /// Unique identifier for the event. + /// + public required string ID + { + get + { + if (!this.Properties.TryGetValue("id", out JsonElement element)) + throw new ArgumentOutOfRangeException("id", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("id"); + } + set + { + this.Properties["id"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Timestamp of when the event occurred in ISO8601 format. + /// + public required DateTime CreatedAt + { + get + { + if (!this.Properties.TryGetValue("created_at", out JsonElement element)) + throw new ArgumentOutOfRangeException("created_at", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["created_at"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required Data Data + { + get + { + if (!this.Properties.TryGetValue("data", out JsonElement element)) + throw new ArgumentOutOfRangeException("data", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("data"); + } + set + { + this.Properties["data"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required Request Request + { + get + { + if (!this.Properties.TryGetValue("request", out JsonElement element)) + throw new ArgumentOutOfRangeException("request", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("request"); + } + set + { + this.Properties["request"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.ID; + _ = this.CreatedAt; + this.Data.Validate(); + this.Request.Validate(); + } + + public UploadPreTransformErrorEvent() + { + this.Type = JsonSerializer.Deserialize("\"upload.pre-transform.error\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UploadPreTransformErrorEvent(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static UploadPreTransformErrorEvent FromRawUnchecked( + Dictionary properties + ) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/Data.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/Data.cs new file mode 100644 index 00000000..76be65b6 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/Data.cs @@ -0,0 +1,102 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using DataProperties = Imagekit.Models.Webhooks.UploadPreTransformErrorEventProperties.DataProperties; + +namespace Imagekit.Models.Webhooks.UploadPreTransformErrorEventProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Data : ModelBase, IFromRaw +{ + /// + /// Name of the file. + /// + public required string Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + throw new ArgumentOutOfRangeException("name", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("name"); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Path of the file. + /// + public required string Path + { + get + { + if (!this.Properties.TryGetValue("path", out JsonElement element)) + throw new ArgumentOutOfRangeException("path", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("path"); + } + set + { + this.Properties["path"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required DataProperties::Transformation Transformation + { + get + { + if (!this.Properties.TryGetValue("transformation", out JsonElement element)) + throw new ArgumentOutOfRangeException( + "transformation", + "Missing required argument" + ); + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ) ?? throw new ArgumentNullException("transformation"); + } + set + { + this.Properties["transformation"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.Name; + _ = this.Path; + this.Transformation.Validate(); + } + + public Data() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Data(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Data FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/DataProperties/Transformation.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/DataProperties/Transformation.cs new file mode 100644 index 00000000..db92626f --- /dev/null +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/DataProperties/Transformation.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Webhooks.UploadPreTransformErrorEventProperties.DataProperties.TransformationProperties; + +namespace Imagekit.Models.Webhooks.UploadPreTransformErrorEventProperties.DataProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Transformation : ModelBase, IFromRaw +{ + public required Error Error + { + get + { + if (!this.Properties.TryGetValue("error", out JsonElement element)) + throw new ArgumentOutOfRangeException("error", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("error"); + } + set + { + this.Properties["error"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.Error.Validate(); + } + + public Transformation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Transformation(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Transformation FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public Transformation(Error error) + : this() + { + this.Error = error; + } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/DataProperties/TransformationProperties/Error.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/DataProperties/TransformationProperties/Error.cs new file mode 100644 index 00000000..1ff05383 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/DataProperties/TransformationProperties/Error.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Webhooks.UploadPreTransformErrorEventProperties.DataProperties.TransformationProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Error : ModelBase, IFromRaw +{ + /// + /// Reason for the pre-transformation failure. + /// + public required string Reason + { + get + { + if (!this.Properties.TryGetValue("reason", out JsonElement element)) + throw new ArgumentOutOfRangeException("reason", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("reason"); + } + set + { + this.Properties["reason"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.Reason; + } + + public Error() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Error(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Error FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public Error(string reason) + : this() + { + this.Reason = reason; + } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/Request.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/Request.cs new file mode 100644 index 00000000..78a656e2 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/Request.cs @@ -0,0 +1,79 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Webhooks.UploadPreTransformErrorEventProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Request : ModelBase, IFromRaw +{ + /// + /// The requested pre-transformation string. + /// + public required string Transformation + { + get + { + if (!this.Properties.TryGetValue("transformation", out JsonElement element)) + throw new ArgumentOutOfRangeException( + "transformation", + "Missing required argument" + ); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("transformation"); + } + set + { + this.Properties["transformation"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Unique identifier for the originating request. + /// + public required string XRequestID + { + get + { + if (!this.Properties.TryGetValue("x_request_id", out JsonElement element)) + throw new ArgumentOutOfRangeException("x_request_id", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("x_request_id"); + } + set + { + this.Properties["x_request_id"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.Transformation; + _ = this.XRequestID; + } + + public Request() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Request(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Request FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEvent.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEvent.cs new file mode 100644 index 00000000..11b65760 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEvent.cs @@ -0,0 +1,149 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties; + +namespace Imagekit.Models.Webhooks; + +/// +/// Triggered when a pre-transformation completes successfully. The file has been +/// processed with the requested transformation and is now available in the Media +/// Library. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class UploadPreTransformSuccessEvent + : ModelBase, + IFromRaw +{ + /// + /// Unique identifier for the event. + /// + public required string ID + { + get + { + if (!this.Properties.TryGetValue("id", out JsonElement element)) + throw new ArgumentOutOfRangeException("id", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("id"); + } + set + { + this.Properties["id"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Timestamp of when the event occurred in ISO8601 format. + /// + public required DateTime CreatedAt + { + get + { + if (!this.Properties.TryGetValue("created_at", out JsonElement element)) + throw new ArgumentOutOfRangeException("created_at", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["created_at"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Object containing details of a successful upload. + /// + public required Data Data + { + get + { + if (!this.Properties.TryGetValue("data", out JsonElement element)) + throw new ArgumentOutOfRangeException("data", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("data"); + } + set + { + this.Properties["data"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required Request Request + { + get + { + if (!this.Properties.TryGetValue("request", out JsonElement element)) + throw new ArgumentOutOfRangeException("request", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("request"); + } + set + { + this.Properties["request"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.ID; + _ = this.CreatedAt; + this.Data.Validate(); + this.Request.Validate(); + } + + public UploadPreTransformSuccessEvent() + { + this.Type = JsonSerializer.Deserialize("\"upload.pre-transform.success\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UploadPreTransformSuccessEvent(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static UploadPreTransformSuccessEvent FromRawUnchecked( + Dictionary properties + ) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/Data.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/Data.cs new file mode 100644 index 00000000..52c1dc77 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/Data.cs @@ -0,0 +1,613 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files; +using Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.DataProperties; + +namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties; + +/// +/// Object containing details of a successful upload. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class Data : ModelBase, IFromRaw +{ + /// + /// An array of tags assigned to the uploaded file by auto tagging. + /// + public List? AITags + { + get + { + if (!this.Properties.TryGetValue("AITags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["AITags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The audio codec used in the video (only for video). + /// + public string? AudioCodec + { + get + { + if (!this.Properties.TryGetValue("audioCodec", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["audioCodec"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The bit rate of the video in kbps (only for video). + /// + public long? BitRate + { + get + { + if (!this.Properties.TryGetValue("bitRate", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["bitRate"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Value of custom coordinates associated with the image in the format `x,y,width,height`. + /// If `customCoordinates` are not defined, then it is `null`. Send `customCoordinates` + /// in `responseFields` in API request to get the value of this field. + /// + public string? CustomCoordinates + { + get + { + if (!this.Properties.TryGetValue("customCoordinates", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["customCoordinates"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// A key-value data associated with the asset. Use `responseField` in API request + /// to get `customMetadata` in the upload API response. Before setting any custom + /// metadata on an asset, you have to create the field using custom metadata + /// fields API. Send `customMetadata` in `responseFields` in API request to get + /// the value of this field. + /// + public Dictionary? CustomMetadata + { + get + { + if (!this.Properties.TryGetValue("customMetadata", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["customMetadata"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Optional text to describe the contents of the file. Can be set by the user + /// or the ai-auto-description extension. + /// + public string? Description + { + get + { + if (!this.Properties.TryGetValue("description", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["description"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The duration of the video in seconds (only for video). + /// + public long? Duration + { + get + { + if (!this.Properties.TryGetValue("duration", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["duration"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Consolidated embedded metadata associated with the file. It includes exif, + /// iptc, and xmp data. Send `embeddedMetadata` in `responseFields` in API request + /// to get embeddedMetadata in the upload API response. + /// + public Dictionary? EmbeddedMetadata + { + get + { + if (!this.Properties.TryGetValue("embeddedMetadata", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["embeddedMetadata"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Extension names with their processing status at the time of completion of + /// the request. It could have one of the following status values: + /// + /// `success`: The extension has been successfully applied. `failed`: The extension + /// has failed and will not be retried. `pending`: The extension will finish processing + /// in some time. On completion, the final status (success / failed) will be sent + /// to the `webhookUrl` provided. + /// + /// If no extension was requested, then this parameter is not returned. + /// + public ExtensionStatus? ExtensionStatus + { + get + { + if (!this.Properties.TryGetValue("extensionStatus", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["extensionStatus"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Unique fileId. Store this fileld in your database, as this will be used to + /// perform update action on this file. + /// + public string? FileID + { + get + { + if (!this.Properties.TryGetValue("fileId", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["fileId"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The relative path of the file in the media library e.g. `/marketing-assets/new-banner.jpg`. + /// + public string? FilePath + { + get + { + if (!this.Properties.TryGetValue("filePath", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["filePath"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Type of the uploaded file. Possible values are `image`, `non-image`. + /// + public string? FileType + { + get + { + if (!this.Properties.TryGetValue("fileType", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["fileType"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Height of the image in pixels (Only for images) + /// + public double? Height + { + get + { + if (!this.Properties.TryGetValue("height", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["height"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Is the file marked as private. It can be either `true` or `false`. Send `isPrivateFile` + /// in `responseFields` in API request to get the value of this field. + /// + public bool? IsPrivateFile + { + get + { + if (!this.Properties.TryGetValue("isPrivateFile", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["isPrivateFile"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Is the file published or in draft state. It can be either `true` or `false`. + /// Send `isPublished` in `responseFields` in API request to get the value of + /// this field. + /// + public bool? IsPublished + { + get + { + if (!this.Properties.TryGetValue("isPublished", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["isPublished"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Legacy metadata. Send `metadata` in `responseFields` in API request to get + /// metadata in the upload API response. + /// + public Metadata? Metadata + { + get + { + if (!this.Properties.TryGetValue("metadata", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["metadata"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Name of the asset. + /// + public string? Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Size of the image file in Bytes. + /// + public double? Size + { + get + { + if (!this.Properties.TryGetValue("size", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["size"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The array of tags associated with the asset. If no tags are set, it will + /// be `null`. Send `tags` in `responseFields` in API request to get the value + /// of this field. + /// + public List? Tags + { + get + { + if (!this.Properties.TryGetValue("tags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["tags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// In the case of an image, a small thumbnail URL. + /// + public string? ThumbnailURL + { + get + { + if (!this.Properties.TryGetValue("thumbnailUrl", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["thumbnailUrl"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// A publicly accessible URL of the file. + /// + public string? URL + { + get + { + if (!this.Properties.TryGetValue("url", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["url"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// An object containing the file or file version's `id` (versionId) and `name`. + /// + public VersionInfo? VersionInfo + { + get + { + if (!this.Properties.TryGetValue("versionInfo", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["versionInfo"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The video codec used in the video (only for video). + /// + public string? VideoCodec + { + get + { + if (!this.Properties.TryGetValue("videoCodec", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["videoCodec"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Width of the image in pixels (Only for Images) + /// + public double? Width + { + get + { + if (!this.Properties.TryGetValue("width", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["width"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + foreach (var item in this.AITags ?? []) + { + item.Validate(); + } + _ = this.AudioCodec; + _ = this.BitRate; + _ = this.CustomCoordinates; + if (this.CustomMetadata != null) + { + foreach (var item in this.CustomMetadata.Values) + { + _ = item; + } + } + _ = this.Description; + _ = this.Duration; + if (this.EmbeddedMetadata != null) + { + foreach (var item in this.EmbeddedMetadata.Values) + { + _ = item; + } + } + this.ExtensionStatus?.Validate(); + _ = this.FileID; + _ = this.FilePath; + _ = this.FileType; + _ = this.Height; + _ = this.IsPrivateFile; + _ = this.IsPublished; + this.Metadata?.Validate(); + _ = this.Name; + _ = this.Size; + foreach (var item in this.Tags ?? []) + { + _ = item; + } + _ = this.ThumbnailURL; + _ = this.URL; + this.VersionInfo?.Validate(); + _ = this.VideoCodec; + _ = this.Width; + } + + public Data() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Data(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Data FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/DataProperties/AITag.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/DataProperties/AITag.cs new file mode 100644 index 00000000..3c5ac201 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/DataProperties/AITag.cs @@ -0,0 +1,96 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.DataProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class AITag : ModelBase, IFromRaw +{ + /// + /// Confidence score of the tag. + /// + public double? Confidence + { + get + { + if (!this.Properties.TryGetValue("confidence", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["confidence"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Name of the tag. + /// + public string? Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Array of `AITags` associated with the image. If no `AITags` are set, it will + /// be null. These tags can be added using the `google-auto-tagging` or `aws-auto-tagging` extensions. + /// + public string? Source + { + get + { + if (!this.Properties.TryGetValue("source", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["source"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.Confidence; + _ = this.Name; + _ = this.Source; + } + + public AITag() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + AITag(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static AITag FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/DataProperties/ExtensionStatus.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/DataProperties/ExtensionStatus.cs new file mode 100644 index 00000000..f144ed8f --- /dev/null +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/DataProperties/ExtensionStatus.cs @@ -0,0 +1,129 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.DataProperties.ExtensionStatusProperties; + +namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.DataProperties; + +/// +/// Extension names with their processing status at the time of completion of the +/// request. It could have one of the following status values: +/// +/// `success`: The extension has been successfully applied. `failed`: The extension +/// has failed and will not be retried. `pending`: The extension will finish processing +/// in some time. On completion, the final status (success / failed) will be sent +/// to the `webhookUrl` provided. +/// +/// If no extension was requested, then this parameter is not returned. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class ExtensionStatus : ModelBase, IFromRaw +{ + public ApiEnum? AIAutoDescription + { + get + { + if (!this.Properties.TryGetValue("ai-auto-description", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["ai-auto-description"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public ApiEnum? AwsAutoTagging + { + get + { + if (!this.Properties.TryGetValue("aws-auto-tagging", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["aws-auto-tagging"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public ApiEnum? GoogleAutoTagging + { + get + { + if (!this.Properties.TryGetValue("google-auto-tagging", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["google-auto-tagging"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public ApiEnum? RemoveBg + { + get + { + if (!this.Properties.TryGetValue("remove-bg", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["remove-bg"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.AIAutoDescription?.Validate(); + this.AwsAutoTagging?.Validate(); + this.GoogleAutoTagging?.Validate(); + this.RemoveBg?.Validate(); + } + + public ExtensionStatus() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ExtensionStatus(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static ExtensionStatus FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/DataProperties/ExtensionStatusProperties/AIAutoDescription.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/DataProperties/ExtensionStatusProperties/AIAutoDescription.cs new file mode 100644 index 00000000..9ea84518 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/DataProperties/ExtensionStatusProperties/AIAutoDescription.cs @@ -0,0 +1,50 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.DataProperties.ExtensionStatusProperties; + +[JsonConverter(typeof(AIAutoDescriptionConverter))] +public enum AIAutoDescription +{ + Success, + Pending, + Failed, +} + +sealed class AIAutoDescriptionConverter : JsonConverter +{ + public override AIAutoDescription Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "success" => AIAutoDescription.Success, + "pending" => AIAutoDescription.Pending, + "failed" => AIAutoDescription.Failed, + _ => (AIAutoDescription)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + AIAutoDescription value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + AIAutoDescription.Success => "success", + AIAutoDescription.Pending => "pending", + AIAutoDescription.Failed => "failed", + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/DataProperties/ExtensionStatusProperties/AwsAutoTagging.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/DataProperties/ExtensionStatusProperties/AwsAutoTagging.cs new file mode 100644 index 00000000..829c2741 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/DataProperties/ExtensionStatusProperties/AwsAutoTagging.cs @@ -0,0 +1,50 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.DataProperties.ExtensionStatusProperties; + +[JsonConverter(typeof(AwsAutoTaggingConverter))] +public enum AwsAutoTagging +{ + Success, + Pending, + Failed, +} + +sealed class AwsAutoTaggingConverter : JsonConverter +{ + public override AwsAutoTagging Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "success" => AwsAutoTagging.Success, + "pending" => AwsAutoTagging.Pending, + "failed" => AwsAutoTagging.Failed, + _ => (AwsAutoTagging)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + AwsAutoTagging value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + AwsAutoTagging.Success => "success", + AwsAutoTagging.Pending => "pending", + AwsAutoTagging.Failed => "failed", + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/DataProperties/ExtensionStatusProperties/GoogleAutoTagging.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/DataProperties/ExtensionStatusProperties/GoogleAutoTagging.cs new file mode 100644 index 00000000..ef9ecd16 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/DataProperties/ExtensionStatusProperties/GoogleAutoTagging.cs @@ -0,0 +1,50 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.DataProperties.ExtensionStatusProperties; + +[JsonConverter(typeof(GoogleAutoTaggingConverter))] +public enum GoogleAutoTagging +{ + Success, + Pending, + Failed, +} + +sealed class GoogleAutoTaggingConverter : JsonConverter +{ + public override GoogleAutoTagging Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "success" => GoogleAutoTagging.Success, + "pending" => GoogleAutoTagging.Pending, + "failed" => GoogleAutoTagging.Failed, + _ => (GoogleAutoTagging)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + GoogleAutoTagging value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + GoogleAutoTagging.Success => "success", + GoogleAutoTagging.Pending => "pending", + GoogleAutoTagging.Failed => "failed", + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/DataProperties/ExtensionStatusProperties/RemoveBg.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/DataProperties/ExtensionStatusProperties/RemoveBg.cs new file mode 100644 index 00000000..98156421 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/DataProperties/ExtensionStatusProperties/RemoveBg.cs @@ -0,0 +1,46 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.DataProperties.ExtensionStatusProperties; + +[JsonConverter(typeof(RemoveBgConverter))] +public enum RemoveBg +{ + Success, + Pending, + Failed, +} + +sealed class RemoveBgConverter : JsonConverter +{ + public override RemoveBg Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "success" => RemoveBg.Success, + "pending" => RemoveBg.Pending, + "failed" => RemoveBg.Failed, + _ => (RemoveBg)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, RemoveBg value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + RemoveBg.Success => "success", + RemoveBg.Pending => "pending", + RemoveBg.Failed => "failed", + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/DataProperties/VersionInfo.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/DataProperties/VersionInfo.cs new file mode 100644 index 00000000..ebc97415 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/DataProperties/VersionInfo.cs @@ -0,0 +1,76 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.DataProperties; + +/// +/// An object containing the file or file version's `id` (versionId) and `name`. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class VersionInfo : ModelBase, IFromRaw +{ + /// + /// Unique identifier of the file version. + /// + public string? ID + { + get + { + if (!this.Properties.TryGetValue("id", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["id"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Name of the file version. + /// + public string? Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.ID; + _ = this.Name; + } + + public VersionInfo() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + VersionInfo(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static VersionInfo FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/Request.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/Request.cs new file mode 100644 index 00000000..848061a5 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/Request.cs @@ -0,0 +1,79 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Request : ModelBase, IFromRaw +{ + /// + /// The requested pre-transformation string. + /// + public required string Transformation + { + get + { + if (!this.Properties.TryGetValue("transformation", out JsonElement element)) + throw new ArgumentOutOfRangeException( + "transformation", + "Missing required argument" + ); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("transformation"); + } + set + { + this.Properties["transformation"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Unique identifier for the originating request. + /// + public required string XRequestID + { + get + { + if (!this.Properties.TryGetValue("x_request_id", out JsonElement element)) + throw new ArgumentOutOfRangeException("x_request_id", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("x_request_id"); + } + set + { + this.Properties["x_request_id"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.Transformation; + _ = this.XRequestID; + } + + public Request() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Request(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Request FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEvent.cs b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEvent.cs new file mode 100644 index 00000000..e3dc0196 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEvent.cs @@ -0,0 +1,149 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties; + +namespace Imagekit.Models.Webhooks; + +/// +/// Triggered when a new video transformation request is accepted for processing. +/// This event confirms that ImageKit has received and queued your transformation +/// request. Use this for debugging and tracking transformation lifecycle. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class VideoTransformationAcceptedEvent + : ModelBase, + IFromRaw +{ + /// + /// Unique identifier for the event. + /// + public required string ID + { + get + { + if (!this.Properties.TryGetValue("id", out JsonElement element)) + throw new ArgumentOutOfRangeException("id", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("id"); + } + set + { + this.Properties["id"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Timestamp when the event was created in ISO8601 format. + /// + public required DateTime CreatedAt + { + get + { + if (!this.Properties.TryGetValue("created_at", out JsonElement element)) + throw new ArgumentOutOfRangeException("created_at", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["created_at"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required Data Data + { + get + { + if (!this.Properties.TryGetValue("data", out JsonElement element)) + throw new ArgumentOutOfRangeException("data", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("data"); + } + set + { + this.Properties["data"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Information about the original request that triggered the video transformation. + /// + public required Request Request + { + get + { + if (!this.Properties.TryGetValue("request", out JsonElement element)) + throw new ArgumentOutOfRangeException("request", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("request"); + } + set + { + this.Properties["request"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.ID; + _ = this.CreatedAt; + this.Data.Validate(); + this.Request.Validate(); + } + + public VideoTransformationAcceptedEvent() + { + this.Type = JsonSerializer.Deserialize("\"video.transformation.accepted\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + VideoTransformationAcceptedEvent(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static VideoTransformationAcceptedEvent FromRawUnchecked( + Dictionary properties + ) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/Data.cs b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/Data.cs new file mode 100644 index 00000000..d28eb91a --- /dev/null +++ b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/Data.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using DataProperties = Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.DataProperties; + +namespace Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Data : ModelBase, IFromRaw +{ + /// + /// Information about the source video asset being transformed. + /// + public required DataProperties::Asset Asset + { + get + { + if (!this.Properties.TryGetValue("asset", out JsonElement element)) + throw new ArgumentOutOfRangeException("asset", "Missing required argument"); + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ) ?? throw new ArgumentNullException("asset"); + } + set + { + this.Properties["asset"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Base information about a video transformation request. + /// + public required DataProperties::Transformation Transformation + { + get + { + if (!this.Properties.TryGetValue("transformation", out JsonElement element)) + throw new ArgumentOutOfRangeException( + "transformation", + "Missing required argument" + ); + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ) ?? throw new ArgumentNullException("transformation"); + } + set + { + this.Properties["transformation"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.Asset.Validate(); + this.Transformation.Validate(); + } + + public Data() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Data(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Data FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/DataProperties/Asset.cs b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/DataProperties/Asset.cs new file mode 100644 index 00000000..f54723b5 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/DataProperties/Asset.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.DataProperties; + +/// +/// Information about the source video asset being transformed. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class Asset : ModelBase, IFromRaw +{ + /// + /// URL to download or access the source video file. + /// + public required string URL + { + get + { + if (!this.Properties.TryGetValue("url", out JsonElement element)) + throw new ArgumentOutOfRangeException("url", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("url"); + } + set + { + this.Properties["url"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.URL; + } + + public Asset() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Asset(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Asset FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public Asset(string url) + : this() + { + this.URL = url; + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/DataProperties/Transformation.cs b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/DataProperties/Transformation.cs new file mode 100644 index 00000000..24e72bab --- /dev/null +++ b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/DataProperties/Transformation.cs @@ -0,0 +1,93 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using TransformationProperties = Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.DataProperties.TransformationProperties; + +namespace Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.DataProperties; + +/// +/// Base information about a video transformation request. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class Transformation : ModelBase, IFromRaw +{ + /// + /// Type of video transformation: - `video-transformation`: Standard video processing + /// (resize, format conversion, etc.) - `gif-to-video`: Convert animated GIF to + /// video format - `video-thumbnail`: Generate thumbnail image from video + /// + public required ApiEnum Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Configuration options for video transformations. + /// + public TransformationProperties::Options? Options + { + get + { + if (!this.Properties.TryGetValue("options", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["options"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.Type.Validate(); + this.Options?.Validate(); + } + + public Transformation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Transformation(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Transformation FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public Transformation(ApiEnum type) + : this() + { + this.Type = type; + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/DataProperties/TransformationProperties/Options.cs b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/DataProperties/TransformationProperties/Options.cs new file mode 100644 index 00000000..e841bd7a --- /dev/null +++ b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/DataProperties/TransformationProperties/Options.cs @@ -0,0 +1,202 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.DataProperties.TransformationProperties.OptionsProperties; + +namespace Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.DataProperties.TransformationProperties; + +/// +/// Configuration options for video transformations. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class Options : ModelBase, IFromRaw +{ + /// + /// Audio codec used for encoding (aac or opus). + /// + public ApiEnum? AudioCodec + { + get + { + if (!this.Properties.TryGetValue("audio_codec", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["audio_codec"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to automatically rotate the video based on metadata. + /// + public bool? AutoRotate + { + get + { + if (!this.Properties.TryGetValue("auto_rotate", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["auto_rotate"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Output format for the transformed video or thumbnail. + /// + public ApiEnum? Format + { + get + { + if (!this.Properties.TryGetValue("format", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["format"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Quality setting for the output video. + /// + public long? Quality + { + get + { + if (!this.Properties.TryGetValue("quality", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["quality"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Streaming protocol for adaptive bitrate streaming. + /// + public ApiEnum? StreamProtocol + { + get + { + if (!this.Properties.TryGetValue("stream_protocol", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["stream_protocol"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Array of quality representations for adaptive bitrate streaming. + /// + public List? Variants + { + get + { + if (!this.Properties.TryGetValue("variants", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["variants"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Video codec used for encoding (h264, vp9, or av1). + /// + public ApiEnum? VideoCodec + { + get + { + if (!this.Properties.TryGetValue("video_codec", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["video_codec"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.AudioCodec?.Validate(); + _ = this.AutoRotate; + this.Format?.Validate(); + _ = this.Quality; + this.StreamProtocol?.Validate(); + foreach (var item in this.Variants ?? []) + { + _ = item; + } + this.VideoCodec?.Validate(); + } + + public Options() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Options(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Options FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/DataProperties/TransformationProperties/OptionsProperties/AudioCodec.cs b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/DataProperties/TransformationProperties/OptionsProperties/AudioCodec.cs new file mode 100644 index 00000000..c448b18b --- /dev/null +++ b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/DataProperties/TransformationProperties/OptionsProperties/AudioCodec.cs @@ -0,0 +1,50 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using System = System; + +namespace Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.DataProperties.TransformationProperties.OptionsProperties; + +/// +/// Audio codec used for encoding (aac or opus). +/// +[JsonConverter(typeof(AudioCodecConverter))] +public enum AudioCodec +{ + Aac, + Opus, +} + +sealed class AudioCodecConverter : JsonConverter +{ + public override AudioCodec Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "aac" => AudioCodec.Aac, + "opus" => AudioCodec.Opus, + _ => (AudioCodec)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + AudioCodec value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + AudioCodec.Aac => "aac", + AudioCodec.Opus => "opus", + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/DataProperties/TransformationProperties/OptionsProperties/Format.cs b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/DataProperties/TransformationProperties/OptionsProperties/Format.cs new file mode 100644 index 00000000..48a62714 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/DataProperties/TransformationProperties/OptionsProperties/Format.cs @@ -0,0 +1,55 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using System = System; + +namespace Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.DataProperties.TransformationProperties.OptionsProperties; + +/// +/// Output format for the transformed video or thumbnail. +/// +[JsonConverter(typeof(FormatConverter))] +public enum Format +{ + MP4, + Webm, + Jpg, + Png, + Webp, +} + +sealed class FormatConverter : JsonConverter +{ + public override Format Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "mp4" => Format.MP4, + "webm" => Format.Webm, + "jpg" => Format.Jpg, + "png" => Format.Png, + "webp" => Format.Webp, + _ => (Format)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Format value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + Format.MP4 => "mp4", + Format.Webm => "webm", + Format.Jpg => "jpg", + Format.Png => "png", + Format.Webp => "webp", + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/DataProperties/TransformationProperties/OptionsProperties/StreamProtocol.cs b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/DataProperties/TransformationProperties/OptionsProperties/StreamProtocol.cs new file mode 100644 index 00000000..cee1bc53 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/DataProperties/TransformationProperties/OptionsProperties/StreamProtocol.cs @@ -0,0 +1,50 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using System = System; + +namespace Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.DataProperties.TransformationProperties.OptionsProperties; + +/// +/// Streaming protocol for adaptive bitrate streaming. +/// +[JsonConverter(typeof(StreamProtocolConverter))] +public enum StreamProtocol +{ + Hls, + Dash, +} + +sealed class StreamProtocolConverter : JsonConverter +{ + public override StreamProtocol Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "HLS" => StreamProtocol.Hls, + "DASH" => StreamProtocol.Dash, + _ => (StreamProtocol)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + StreamProtocol value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + StreamProtocol.Hls => "HLS", + StreamProtocol.Dash => "DASH", + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/DataProperties/TransformationProperties/OptionsProperties/VideoCodec.cs b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/DataProperties/TransformationProperties/OptionsProperties/VideoCodec.cs new file mode 100644 index 00000000..1016e491 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/DataProperties/TransformationProperties/OptionsProperties/VideoCodec.cs @@ -0,0 +1,53 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using System = System; + +namespace Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.DataProperties.TransformationProperties.OptionsProperties; + +/// +/// Video codec used for encoding (h264, vp9, or av1). +/// +[JsonConverter(typeof(VideoCodecConverter))] +public enum VideoCodec +{ + H264, + Vp9, + Av1, +} + +sealed class VideoCodecConverter : JsonConverter +{ + public override VideoCodec Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "h264" => VideoCodec.H264, + "vp9" => VideoCodec.Vp9, + "av1" => VideoCodec.Av1, + _ => (VideoCodec)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + VideoCodec value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + VideoCodec.H264 => "h264", + VideoCodec.Vp9 => "vp9", + VideoCodec.Av1 => "av1", + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/DataProperties/TransformationProperties/Type.cs b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/DataProperties/TransformationProperties/Type.cs new file mode 100644 index 00000000..90f9cee2 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/DataProperties/TransformationProperties/Type.cs @@ -0,0 +1,51 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using System = System; + +namespace Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.DataProperties.TransformationProperties; + +/// +/// Type of video transformation: - `video-transformation`: Standard video processing +/// (resize, format conversion, etc.) - `gif-to-video`: Convert animated GIF to video +/// format - `video-thumbnail`: Generate thumbnail image from video +/// +[JsonConverter(typeof(TypeConverter))] +public enum Type +{ + VideoTransformation, + GifToVideo, + VideoThumbnail, +} + +sealed class TypeConverter : JsonConverter +{ + public override Type Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "video-transformation" => TransformationProperties.Type.VideoTransformation, + "gif-to-video" => TransformationProperties.Type.GifToVideo, + "video-thumbnail" => TransformationProperties.Type.VideoThumbnail, + _ => (Type)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + TransformationProperties.Type.VideoTransformation => "video-transformation", + TransformationProperties.Type.GifToVideo => "gif-to-video", + TransformationProperties.Type.VideoThumbnail => "video-thumbnail", + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/Request.cs b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/Request.cs new file mode 100644 index 00000000..28c0f652 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/Request.cs @@ -0,0 +1,101 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties; + +/// +/// Information about the original request that triggered the video transformation. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class Request : ModelBase, IFromRaw +{ + /// + /// Full URL of the transformation request that was submitted. + /// + public required string URL + { + get + { + if (!this.Properties.TryGetValue("url", out JsonElement element)) + throw new ArgumentOutOfRangeException("url", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("url"); + } + set + { + this.Properties["url"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Unique identifier for the originating transformation request. + /// + public required string XRequestID + { + get + { + if (!this.Properties.TryGetValue("x_request_id", out JsonElement element)) + throw new ArgumentOutOfRangeException("x_request_id", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("x_request_id"); + } + set + { + this.Properties["x_request_id"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// User-Agent header from the original request that triggered the transformation. + /// + public string? UserAgent + { + get + { + if (!this.Properties.TryGetValue("user_agent", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["user_agent"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.URL; + _ = this.XRequestID; + _ = this.UserAgent; + } + + public Request() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Request(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Request FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEvent.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEvent.cs new file mode 100644 index 00000000..f8e5a29c --- /dev/null +++ b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEvent.cs @@ -0,0 +1,150 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties; + +namespace Imagekit.Models.Webhooks; + +/// +/// Triggered when an error occurs during video encoding. Listen to this webhook to +/// log error reasons and debug issues. Check your origin and URL endpoint settings +/// if the reason is related to download failure. For other errors, contact ImageKit +/// support. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class VideoTransformationErrorEvent + : ModelBase, + IFromRaw +{ + /// + /// Unique identifier for the event. + /// + public required string ID + { + get + { + if (!this.Properties.TryGetValue("id", out JsonElement element)) + throw new ArgumentOutOfRangeException("id", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("id"); + } + set + { + this.Properties["id"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Timestamp when the event was created in ISO8601 format. + /// + public required DateTime CreatedAt + { + get + { + if (!this.Properties.TryGetValue("created_at", out JsonElement element)) + throw new ArgumentOutOfRangeException("created_at", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["created_at"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required Data Data + { + get + { + if (!this.Properties.TryGetValue("data", out JsonElement element)) + throw new ArgumentOutOfRangeException("data", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("data"); + } + set + { + this.Properties["data"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Information about the original request that triggered the video transformation. + /// + public required Request Request + { + get + { + if (!this.Properties.TryGetValue("request", out JsonElement element)) + throw new ArgumentOutOfRangeException("request", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("request"); + } + set + { + this.Properties["request"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.ID; + _ = this.CreatedAt; + this.Data.Validate(); + this.Request.Validate(); + } + + public VideoTransformationErrorEvent() + { + this.Type = JsonSerializer.Deserialize("\"video.transformation.error\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + VideoTransformationErrorEvent(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static VideoTransformationErrorEvent FromRawUnchecked( + Dictionary properties + ) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/Data.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/Data.cs new file mode 100644 index 00000000..92ae506e --- /dev/null +++ b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/Data.cs @@ -0,0 +1,81 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using DataProperties = Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.DataProperties; + +namespace Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Data : ModelBase, IFromRaw +{ + /// + /// Information about the source video asset being transformed. + /// + public required DataProperties::Asset Asset + { + get + { + if (!this.Properties.TryGetValue("asset", out JsonElement element)) + throw new ArgumentOutOfRangeException("asset", "Missing required argument"); + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ) ?? throw new ArgumentNullException("asset"); + } + set + { + this.Properties["asset"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required DataProperties::Transformation Transformation + { + get + { + if (!this.Properties.TryGetValue("transformation", out JsonElement element)) + throw new ArgumentOutOfRangeException( + "transformation", + "Missing required argument" + ); + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ) ?? throw new ArgumentNullException("transformation"); + } + set + { + this.Properties["transformation"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.Asset.Validate(); + this.Transformation.Validate(); + } + + public Data() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Data(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Data FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/Asset.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/Asset.cs new file mode 100644 index 00000000..31f10dbe --- /dev/null +++ b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/Asset.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.DataProperties; + +/// +/// Information about the source video asset being transformed. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class Asset : ModelBase, IFromRaw +{ + /// + /// URL to download or access the source video file. + /// + public required string URL + { + get + { + if (!this.Properties.TryGetValue("url", out JsonElement element)) + throw new ArgumentOutOfRangeException("url", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("url"); + } + set + { + this.Properties["url"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.URL; + } + + public Asset() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Asset(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Asset FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public Asset(string url) + : this() + { + this.URL = url; + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/Transformation.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/Transformation.cs new file mode 100644 index 00000000..99f6feee --- /dev/null +++ b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/Transformation.cs @@ -0,0 +1,115 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using TransformationProperties = Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.DataProperties.TransformationProperties; + +namespace Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.DataProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Transformation : ModelBase, IFromRaw +{ + /// + /// Type of video transformation: - `video-transformation`: Standard video processing + /// (resize, format conversion, etc.) - `gif-to-video`: Convert animated GIF to + /// video format - `video-thumbnail`: Generate thumbnail image from video + /// + public required ApiEnum Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Details about the transformation error. + /// + public TransformationProperties::Error? Error + { + get + { + if (!this.Properties.TryGetValue("error", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["error"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Configuration options for video transformations. + /// + public TransformationProperties::Options? Options + { + get + { + if (!this.Properties.TryGetValue("options", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["options"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.Type.Validate(); + this.Error?.Validate(); + this.Options?.Validate(); + } + + public Transformation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Transformation(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Transformation FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public Transformation(ApiEnum type) + : this() + { + this.Type = type; + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/TransformationProperties/Error.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/TransformationProperties/Error.cs new file mode 100644 index 00000000..9b2dbb8d --- /dev/null +++ b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/TransformationProperties/Error.cs @@ -0,0 +1,71 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.DataProperties.TransformationProperties.ErrorProperties; +using System = System; + +namespace Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.DataProperties.TransformationProperties; + +/// +/// Details about the transformation error. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class Error : ModelBase, IFromRaw +{ + /// + /// Specific reason for the transformation failure: - `encoding_failed`: Error + /// during video encoding process - `download_failed`: Could not download source + /// video - `internal_server_error`: Unexpected server error + /// + public required ApiEnum Reason + { + get + { + if (!this.Properties.TryGetValue("reason", out JsonElement element)) + throw new System::ArgumentOutOfRangeException( + "reason", + "Missing required argument" + ); + + return JsonSerializer.Deserialize>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["reason"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.Reason.Validate(); + } + + public Error() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Error(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Error FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public Error(ApiEnum reason) + : this() + { + this.Reason = reason; + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/TransformationProperties/ErrorProperties/Reason.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/TransformationProperties/ErrorProperties/Reason.cs new file mode 100644 index 00000000..f0995426 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/TransformationProperties/ErrorProperties/Reason.cs @@ -0,0 +1,51 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using System = System; + +namespace Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.DataProperties.TransformationProperties.ErrorProperties; + +/// +/// Specific reason for the transformation failure: - `encoding_failed`: Error during +/// video encoding process - `download_failed`: Could not download source video - +/// `internal_server_error`: Unexpected server error +/// +[JsonConverter(typeof(ReasonConverter))] +public enum Reason +{ + EncodingFailed, + DownloadFailed, + InternalServerError, +} + +sealed class ReasonConverter : JsonConverter +{ + public override Reason Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "encoding_failed" => Reason.EncodingFailed, + "download_failed" => Reason.DownloadFailed, + "internal_server_error" => Reason.InternalServerError, + _ => (Reason)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Reason value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + Reason.EncodingFailed => "encoding_failed", + Reason.DownloadFailed => "download_failed", + Reason.InternalServerError => "internal_server_error", + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/TransformationProperties/Options.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/TransformationProperties/Options.cs new file mode 100644 index 00000000..7b11a0cb --- /dev/null +++ b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/TransformationProperties/Options.cs @@ -0,0 +1,202 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.DataProperties.TransformationProperties.OptionsProperties; + +namespace Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.DataProperties.TransformationProperties; + +/// +/// Configuration options for video transformations. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class Options : ModelBase, IFromRaw +{ + /// + /// Audio codec used for encoding (aac or opus). + /// + public ApiEnum? AudioCodec + { + get + { + if (!this.Properties.TryGetValue("audio_codec", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["audio_codec"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to automatically rotate the video based on metadata. + /// + public bool? AutoRotate + { + get + { + if (!this.Properties.TryGetValue("auto_rotate", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["auto_rotate"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Output format for the transformed video or thumbnail. + /// + public ApiEnum? Format + { + get + { + if (!this.Properties.TryGetValue("format", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["format"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Quality setting for the output video. + /// + public long? Quality + { + get + { + if (!this.Properties.TryGetValue("quality", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["quality"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Streaming protocol for adaptive bitrate streaming. + /// + public ApiEnum? StreamProtocol + { + get + { + if (!this.Properties.TryGetValue("stream_protocol", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["stream_protocol"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Array of quality representations for adaptive bitrate streaming. + /// + public List? Variants + { + get + { + if (!this.Properties.TryGetValue("variants", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["variants"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Video codec used for encoding (h264, vp9, or av1). + /// + public ApiEnum? VideoCodec + { + get + { + if (!this.Properties.TryGetValue("video_codec", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["video_codec"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.AudioCodec?.Validate(); + _ = this.AutoRotate; + this.Format?.Validate(); + _ = this.Quality; + this.StreamProtocol?.Validate(); + foreach (var item in this.Variants ?? []) + { + _ = item; + } + this.VideoCodec?.Validate(); + } + + public Options() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Options(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Options FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/TransformationProperties/OptionsProperties/AudioCodec.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/TransformationProperties/OptionsProperties/AudioCodec.cs new file mode 100644 index 00000000..03cfe515 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/TransformationProperties/OptionsProperties/AudioCodec.cs @@ -0,0 +1,50 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using System = System; + +namespace Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.DataProperties.TransformationProperties.OptionsProperties; + +/// +/// Audio codec used for encoding (aac or opus). +/// +[JsonConverter(typeof(AudioCodecConverter))] +public enum AudioCodec +{ + Aac, + Opus, +} + +sealed class AudioCodecConverter : JsonConverter +{ + public override AudioCodec Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "aac" => AudioCodec.Aac, + "opus" => AudioCodec.Opus, + _ => (AudioCodec)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + AudioCodec value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + AudioCodec.Aac => "aac", + AudioCodec.Opus => "opus", + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/TransformationProperties/OptionsProperties/Format.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/TransformationProperties/OptionsProperties/Format.cs new file mode 100644 index 00000000..0955e08d --- /dev/null +++ b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/TransformationProperties/OptionsProperties/Format.cs @@ -0,0 +1,55 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using System = System; + +namespace Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.DataProperties.TransformationProperties.OptionsProperties; + +/// +/// Output format for the transformed video or thumbnail. +/// +[JsonConverter(typeof(FormatConverter))] +public enum Format +{ + MP4, + Webm, + Jpg, + Png, + Webp, +} + +sealed class FormatConverter : JsonConverter +{ + public override Format Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "mp4" => Format.MP4, + "webm" => Format.Webm, + "jpg" => Format.Jpg, + "png" => Format.Png, + "webp" => Format.Webp, + _ => (Format)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Format value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + Format.MP4 => "mp4", + Format.Webm => "webm", + Format.Jpg => "jpg", + Format.Png => "png", + Format.Webp => "webp", + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/TransformationProperties/OptionsProperties/StreamProtocol.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/TransformationProperties/OptionsProperties/StreamProtocol.cs new file mode 100644 index 00000000..53822ce7 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/TransformationProperties/OptionsProperties/StreamProtocol.cs @@ -0,0 +1,50 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using System = System; + +namespace Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.DataProperties.TransformationProperties.OptionsProperties; + +/// +/// Streaming protocol for adaptive bitrate streaming. +/// +[JsonConverter(typeof(StreamProtocolConverter))] +public enum StreamProtocol +{ + Hls, + Dash, +} + +sealed class StreamProtocolConverter : JsonConverter +{ + public override StreamProtocol Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "HLS" => StreamProtocol.Hls, + "DASH" => StreamProtocol.Dash, + _ => (StreamProtocol)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + StreamProtocol value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + StreamProtocol.Hls => "HLS", + StreamProtocol.Dash => "DASH", + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/TransformationProperties/OptionsProperties/VideoCodec.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/TransformationProperties/OptionsProperties/VideoCodec.cs new file mode 100644 index 00000000..f6d33a3e --- /dev/null +++ b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/TransformationProperties/OptionsProperties/VideoCodec.cs @@ -0,0 +1,53 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using System = System; + +namespace Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.DataProperties.TransformationProperties.OptionsProperties; + +/// +/// Video codec used for encoding (h264, vp9, or av1). +/// +[JsonConverter(typeof(VideoCodecConverter))] +public enum VideoCodec +{ + H264, + Vp9, + Av1, +} + +sealed class VideoCodecConverter : JsonConverter +{ + public override VideoCodec Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "h264" => VideoCodec.H264, + "vp9" => VideoCodec.Vp9, + "av1" => VideoCodec.Av1, + _ => (VideoCodec)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + VideoCodec value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + VideoCodec.H264 => "h264", + VideoCodec.Vp9 => "vp9", + VideoCodec.Av1 => "av1", + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/TransformationProperties/Type.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/TransformationProperties/Type.cs new file mode 100644 index 00000000..8823f849 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/TransformationProperties/Type.cs @@ -0,0 +1,51 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using System = System; + +namespace Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.DataProperties.TransformationProperties; + +/// +/// Type of video transformation: - `video-transformation`: Standard video processing +/// (resize, format conversion, etc.) - `gif-to-video`: Convert animated GIF to video +/// format - `video-thumbnail`: Generate thumbnail image from video +/// +[JsonConverter(typeof(TypeConverter))] +public enum Type +{ + VideoTransformation, + GifToVideo, + VideoThumbnail, +} + +sealed class TypeConverter : JsonConverter +{ + public override Type Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "video-transformation" => TransformationProperties.Type.VideoTransformation, + "gif-to-video" => TransformationProperties.Type.GifToVideo, + "video-thumbnail" => TransformationProperties.Type.VideoThumbnail, + _ => (Type)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + TransformationProperties.Type.VideoTransformation => "video-transformation", + TransformationProperties.Type.GifToVideo => "gif-to-video", + TransformationProperties.Type.VideoThumbnail => "video-thumbnail", + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/Request.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/Request.cs new file mode 100644 index 00000000..74ac3484 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/Request.cs @@ -0,0 +1,101 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties; + +/// +/// Information about the original request that triggered the video transformation. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class Request : ModelBase, IFromRaw +{ + /// + /// Full URL of the transformation request that was submitted. + /// + public required string URL + { + get + { + if (!this.Properties.TryGetValue("url", out JsonElement element)) + throw new ArgumentOutOfRangeException("url", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("url"); + } + set + { + this.Properties["url"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Unique identifier for the originating transformation request. + /// + public required string XRequestID + { + get + { + if (!this.Properties.TryGetValue("x_request_id", out JsonElement element)) + throw new ArgumentOutOfRangeException("x_request_id", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("x_request_id"); + } + set + { + this.Properties["x_request_id"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// User-Agent header from the original request that triggered the transformation. + /// + public string? UserAgent + { + get + { + if (!this.Properties.TryGetValue("user_agent", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["user_agent"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.URL; + _ = this.XRequestID; + _ = this.UserAgent; + } + + public Request() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Request(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Request FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEvent.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEvent.cs new file mode 100644 index 00000000..ebd61c2f --- /dev/null +++ b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEvent.cs @@ -0,0 +1,172 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties; + +namespace Imagekit.Models.Webhooks; + +/// +/// Triggered when video encoding is finished and the transformed resource is ready +/// to be served. This is the key event to listen for - update your database or CMS +/// flags when you receive this so your application can start showing the transformed +/// video to users. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class VideoTransformationReadyEvent + : ModelBase, + IFromRaw +{ + /// + /// Unique identifier for the event. + /// + public required string ID + { + get + { + if (!this.Properties.TryGetValue("id", out JsonElement element)) + throw new ArgumentOutOfRangeException("id", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("id"); + } + set + { + this.Properties["id"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Timestamp when the event was created in ISO8601 format. + /// + public required DateTime CreatedAt + { + get + { + if (!this.Properties.TryGetValue("created_at", out JsonElement element)) + throw new ArgumentOutOfRangeException("created_at", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["created_at"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required Data Data + { + get + { + if (!this.Properties.TryGetValue("data", out JsonElement element)) + throw new ArgumentOutOfRangeException("data", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("data"); + } + set + { + this.Properties["data"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Information about the original request that triggered the video transformation. + /// + public required Request Request + { + get + { + if (!this.Properties.TryGetValue("request", out JsonElement element)) + throw new ArgumentOutOfRangeException("request", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("request"); + } + set + { + this.Properties["request"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Performance metrics for the transformation process. + /// + public Timings? Timings + { + get + { + if (!this.Properties.TryGetValue("timings", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["timings"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.ID; + _ = this.CreatedAt; + this.Data.Validate(); + this.Request.Validate(); + this.Timings?.Validate(); + } + + public VideoTransformationReadyEvent() + { + this.Type = JsonSerializer.Deserialize("\"video.transformation.ready\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + VideoTransformationReadyEvent(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static VideoTransformationReadyEvent FromRawUnchecked( + Dictionary properties + ) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/Data.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/Data.cs new file mode 100644 index 00000000..1dd96038 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/Data.cs @@ -0,0 +1,81 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using DataProperties = Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties; + +namespace Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Data : ModelBase, IFromRaw +{ + /// + /// Information about the source video asset being transformed. + /// + public required DataProperties::Asset Asset + { + get + { + if (!this.Properties.TryGetValue("asset", out JsonElement element)) + throw new ArgumentOutOfRangeException("asset", "Missing required argument"); + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ) ?? throw new ArgumentNullException("asset"); + } + set + { + this.Properties["asset"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required DataProperties::Transformation Transformation + { + get + { + if (!this.Properties.TryGetValue("transformation", out JsonElement element)) + throw new ArgumentOutOfRangeException( + "transformation", + "Missing required argument" + ); + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ) ?? throw new ArgumentNullException("transformation"); + } + set + { + this.Properties["transformation"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.Asset.Validate(); + this.Transformation.Validate(); + } + + public Data() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Data(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Data FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/Asset.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/Asset.cs new file mode 100644 index 00000000..0859135a --- /dev/null +++ b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/Asset.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties; + +/// +/// Information about the source video asset being transformed. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class Asset : ModelBase, IFromRaw +{ + /// + /// URL to download or access the source video file. + /// + public required string URL + { + get + { + if (!this.Properties.TryGetValue("url", out JsonElement element)) + throw new ArgumentOutOfRangeException("url", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("url"); + } + set + { + this.Properties["url"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.URL; + } + + public Asset() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Asset(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Asset FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public Asset(string url) + : this() + { + this.URL = url; + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/Transformation.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/Transformation.cs new file mode 100644 index 00000000..3c0c8315 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/Transformation.cs @@ -0,0 +1,115 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using TransformationProperties = Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties.TransformationProperties; + +namespace Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Transformation : ModelBase, IFromRaw +{ + /// + /// Type of video transformation: - `video-transformation`: Standard video processing + /// (resize, format conversion, etc.) - `gif-to-video`: Convert animated GIF to + /// video format - `video-thumbnail`: Generate thumbnail image from video + /// + public required ApiEnum Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Configuration options for video transformations. + /// + public TransformationProperties::Options? Options + { + get + { + if (!this.Properties.TryGetValue("options", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["options"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Information about the transformed output video. + /// + public TransformationProperties::Output? Output + { + get + { + if (!this.Properties.TryGetValue("output", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["output"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.Type.Validate(); + this.Options?.Validate(); + this.Output?.Validate(); + } + + public Transformation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Transformation(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Transformation FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public Transformation(ApiEnum type) + : this() + { + this.Type = type; + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/TransformationProperties/Options.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/TransformationProperties/Options.cs new file mode 100644 index 00000000..232195b8 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/TransformationProperties/Options.cs @@ -0,0 +1,202 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties.TransformationProperties.OptionsProperties; + +namespace Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties.TransformationProperties; + +/// +/// Configuration options for video transformations. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class Options : ModelBase, IFromRaw +{ + /// + /// Audio codec used for encoding (aac or opus). + /// + public ApiEnum? AudioCodec + { + get + { + if (!this.Properties.TryGetValue("audio_codec", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["audio_codec"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to automatically rotate the video based on metadata. + /// + public bool? AutoRotate + { + get + { + if (!this.Properties.TryGetValue("auto_rotate", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["auto_rotate"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Output format for the transformed video or thumbnail. + /// + public ApiEnum? Format + { + get + { + if (!this.Properties.TryGetValue("format", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["format"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Quality setting for the output video. + /// + public long? Quality + { + get + { + if (!this.Properties.TryGetValue("quality", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["quality"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Streaming protocol for adaptive bitrate streaming. + /// + public ApiEnum? StreamProtocol + { + get + { + if (!this.Properties.TryGetValue("stream_protocol", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["stream_protocol"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Array of quality representations for adaptive bitrate streaming. + /// + public List? Variants + { + get + { + if (!this.Properties.TryGetValue("variants", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["variants"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Video codec used for encoding (h264, vp9, or av1). + /// + public ApiEnum? VideoCodec + { + get + { + if (!this.Properties.TryGetValue("video_codec", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["video_codec"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.AudioCodec?.Validate(); + _ = this.AutoRotate; + this.Format?.Validate(); + _ = this.Quality; + this.StreamProtocol?.Validate(); + foreach (var item in this.Variants ?? []) + { + _ = item; + } + this.VideoCodec?.Validate(); + } + + public Options() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Options(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Options FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/TransformationProperties/OptionsProperties/AudioCodec.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/TransformationProperties/OptionsProperties/AudioCodec.cs new file mode 100644 index 00000000..b81c797b --- /dev/null +++ b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/TransformationProperties/OptionsProperties/AudioCodec.cs @@ -0,0 +1,50 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using System = System; + +namespace Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties.TransformationProperties.OptionsProperties; + +/// +/// Audio codec used for encoding (aac or opus). +/// +[JsonConverter(typeof(AudioCodecConverter))] +public enum AudioCodec +{ + Aac, + Opus, +} + +sealed class AudioCodecConverter : JsonConverter +{ + public override AudioCodec Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "aac" => AudioCodec.Aac, + "opus" => AudioCodec.Opus, + _ => (AudioCodec)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + AudioCodec value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + AudioCodec.Aac => "aac", + AudioCodec.Opus => "opus", + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/TransformationProperties/OptionsProperties/Format.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/TransformationProperties/OptionsProperties/Format.cs new file mode 100644 index 00000000..3bb8aace --- /dev/null +++ b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/TransformationProperties/OptionsProperties/Format.cs @@ -0,0 +1,55 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using System = System; + +namespace Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties.TransformationProperties.OptionsProperties; + +/// +/// Output format for the transformed video or thumbnail. +/// +[JsonConverter(typeof(FormatConverter))] +public enum Format +{ + MP4, + Webm, + Jpg, + Png, + Webp, +} + +sealed class FormatConverter : JsonConverter +{ + public override Format Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "mp4" => Format.MP4, + "webm" => Format.Webm, + "jpg" => Format.Jpg, + "png" => Format.Png, + "webp" => Format.Webp, + _ => (Format)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Format value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + Format.MP4 => "mp4", + Format.Webm => "webm", + Format.Jpg => "jpg", + Format.Png => "png", + Format.Webp => "webp", + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/TransformationProperties/OptionsProperties/StreamProtocol.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/TransformationProperties/OptionsProperties/StreamProtocol.cs new file mode 100644 index 00000000..e2492fe8 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/TransformationProperties/OptionsProperties/StreamProtocol.cs @@ -0,0 +1,50 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using System = System; + +namespace Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties.TransformationProperties.OptionsProperties; + +/// +/// Streaming protocol for adaptive bitrate streaming. +/// +[JsonConverter(typeof(StreamProtocolConverter))] +public enum StreamProtocol +{ + Hls, + Dash, +} + +sealed class StreamProtocolConverter : JsonConverter +{ + public override StreamProtocol Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "HLS" => StreamProtocol.Hls, + "DASH" => StreamProtocol.Dash, + _ => (StreamProtocol)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + StreamProtocol value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + StreamProtocol.Hls => "HLS", + StreamProtocol.Dash => "DASH", + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/TransformationProperties/OptionsProperties/VideoCodec.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/TransformationProperties/OptionsProperties/VideoCodec.cs new file mode 100644 index 00000000..0baacb16 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/TransformationProperties/OptionsProperties/VideoCodec.cs @@ -0,0 +1,53 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using System = System; + +namespace Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties.TransformationProperties.OptionsProperties; + +/// +/// Video codec used for encoding (h264, vp9, or av1). +/// +[JsonConverter(typeof(VideoCodecConverter))] +public enum VideoCodec +{ + H264, + Vp9, + Av1, +} + +sealed class VideoCodecConverter : JsonConverter +{ + public override VideoCodec Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "h264" => VideoCodec.H264, + "vp9" => VideoCodec.Vp9, + "av1" => VideoCodec.Av1, + _ => (VideoCodec)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + VideoCodec value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + VideoCodec.H264 => "h264", + VideoCodec.Vp9 => "vp9", + VideoCodec.Av1 => "av1", + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/TransformationProperties/Output.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/TransformationProperties/Output.cs new file mode 100644 index 00000000..ddcbfa27 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/TransformationProperties/Output.cs @@ -0,0 +1,86 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties.TransformationProperties.OutputProperties; +using System = System; + +namespace Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties.TransformationProperties; + +/// +/// Information about the transformed output video. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class Output : ModelBase, IFromRaw +{ + /// + /// URL to access the transformed video. + /// + public required string URL + { + get + { + if (!this.Properties.TryGetValue("url", out JsonElement element)) + throw new System::ArgumentOutOfRangeException("url", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new System::ArgumentNullException("url"); + } + set + { + this.Properties["url"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Metadata of the output video file. + /// + public VideoMetadata? VideoMetadata + { + get + { + if (!this.Properties.TryGetValue("video_metadata", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["video_metadata"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.URL; + this.VideoMetadata?.Validate(); + } + + public Output() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Output(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Output FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public Output(string url) + : this() + { + this.URL = url; + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/TransformationProperties/OutputProperties/VideoMetadata.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/TransformationProperties/OutputProperties/VideoMetadata.cs new file mode 100644 index 00000000..60f5f015 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/TransformationProperties/OutputProperties/VideoMetadata.cs @@ -0,0 +1,121 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties.TransformationProperties.OutputProperties; + +/// +/// Metadata of the output video file. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class VideoMetadata : ModelBase, IFromRaw +{ + /// + /// Bitrate of the output video in bits per second. + /// + public required long Bitrate + { + get + { + if (!this.Properties.TryGetValue("bitrate", out JsonElement element)) + throw new ArgumentOutOfRangeException("bitrate", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["bitrate"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Duration of the output video in seconds. + /// + public required double Duration + { + get + { + if (!this.Properties.TryGetValue("duration", out JsonElement element)) + throw new ArgumentOutOfRangeException("duration", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["duration"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Height of the output video in pixels. + /// + public required long Height + { + get + { + if (!this.Properties.TryGetValue("height", out JsonElement element)) + throw new ArgumentOutOfRangeException("height", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["height"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Width of the output video in pixels. + /// + public required long Width + { + get + { + if (!this.Properties.TryGetValue("width", out JsonElement element)) + throw new ArgumentOutOfRangeException("width", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["width"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.Bitrate; + _ = this.Duration; + _ = this.Height; + _ = this.Width; + } + + public VideoMetadata() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + VideoMetadata(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static VideoMetadata FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/TransformationProperties/Type.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/TransformationProperties/Type.cs new file mode 100644 index 00000000..dc9c5729 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/TransformationProperties/Type.cs @@ -0,0 +1,51 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using System = System; + +namespace Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties.TransformationProperties; + +/// +/// Type of video transformation: - `video-transformation`: Standard video processing +/// (resize, format conversion, etc.) - `gif-to-video`: Convert animated GIF to video +/// format - `video-thumbnail`: Generate thumbnail image from video +/// +[JsonConverter(typeof(TypeConverter))] +public enum Type +{ + VideoTransformation, + GifToVideo, + VideoThumbnail, +} + +sealed class TypeConverter : JsonConverter +{ + public override Type Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "video-transformation" => TransformationProperties.Type.VideoTransformation, + "gif-to-video" => TransformationProperties.Type.GifToVideo, + "video-thumbnail" => TransformationProperties.Type.VideoThumbnail, + _ => (Type)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + TransformationProperties.Type.VideoTransformation => "video-transformation", + TransformationProperties.Type.GifToVideo => "gif-to-video", + TransformationProperties.Type.VideoThumbnail => "video-thumbnail", + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/Request.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/Request.cs new file mode 100644 index 00000000..2de96a55 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/Request.cs @@ -0,0 +1,101 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties; + +/// +/// Information about the original request that triggered the video transformation. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class Request : ModelBase, IFromRaw +{ + /// + /// Full URL of the transformation request that was submitted. + /// + public required string URL + { + get + { + if (!this.Properties.TryGetValue("url", out JsonElement element)) + throw new ArgumentOutOfRangeException("url", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("url"); + } + set + { + this.Properties["url"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Unique identifier for the originating transformation request. + /// + public required string XRequestID + { + get + { + if (!this.Properties.TryGetValue("x_request_id", out JsonElement element)) + throw new ArgumentOutOfRangeException("x_request_id", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("x_request_id"); + } + set + { + this.Properties["x_request_id"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// User-Agent header from the original request that triggered the transformation. + /// + public string? UserAgent + { + get + { + if (!this.Properties.TryGetValue("user_agent", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["user_agent"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.URL; + _ = this.XRequestID; + _ = this.UserAgent; + } + + public Request() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Request(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Request FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/Timings.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/Timings.cs new file mode 100644 index 00000000..3f5cedd3 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/Timings.cs @@ -0,0 +1,77 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties; + +/// +/// Performance metrics for the transformation process. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class Timings : ModelBase, IFromRaw +{ + /// + /// Time spent downloading the source video from your origin or media library, + /// in milliseconds. + /// + public long? DownloadDuration + { + get + { + if (!this.Properties.TryGetValue("download_duration", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["download_duration"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Time spent encoding the video, in milliseconds. + /// + public long? EncodingDuration + { + get + { + if (!this.Properties.TryGetValue("encoding_duration", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["encoding_duration"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.DownloadDuration; + _ = this.EncodingDuration; + } + + public Timings() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Timings(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Timings FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/ParamsBase.cs b/src/Imagekit/ParamsBase.cs new file mode 100644 index 00000000..2f20430a --- /dev/null +++ b/src/Imagekit/ParamsBase.cs @@ -0,0 +1,164 @@ +using System; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.Linq; +using System.Net.Http; +using System.Text; +using System.Text.Json; +using Web = System.Web; + +namespace Imagekit; + +public abstract record class ParamsBase +{ + public Dictionary QueryProperties { get; set; } = []; + + public Dictionary HeaderProperties { get; set; } = []; + + public abstract Uri Url(IImageKitClient client); + + protected static void AddQueryElementToCollection( + NameValueCollection collection, + string key, + JsonElement element + ) + { + switch (element.ValueKind) + { + case JsonValueKind.Undefined: + case JsonValueKind.Null: + collection.Add(key, ""); + break; + case JsonValueKind.String: + case JsonValueKind.Number: + collection.Add(key, element.ToString()); + break; + case JsonValueKind.True: + collection.Add(key, "true"); + break; + case JsonValueKind.False: + collection.Add(key, "false"); + break; + case JsonValueKind.Object: + foreach (var item in element.EnumerateObject()) + { + AddQueryElementToCollection( + collection, + string.Format("{0}[{1}]", key, item.Name), + item.Value + ); + } + break; + case JsonValueKind.Array: + collection.Add( + key, + string.Join( + ",", + Enumerable.Select( + element.EnumerateArray(), + x => + x.ValueKind switch + { + JsonValueKind.Null => "", + JsonValueKind.True => "true", + JsonValueKind.False => "false", + _ => x.GetString(), + } + ) + ) + ); + break; + } + } + + protected static void AddHeaderElementToRequest( + HttpRequestMessage request, + string key, + JsonElement element + ) + { + switch (element.ValueKind) + { + case JsonValueKind.Undefined: + case JsonValueKind.Null: + request.Headers.Add(key, ""); + break; + case JsonValueKind.String: + case JsonValueKind.Number: + request.Headers.Add(key, element.ToString()); + break; + case JsonValueKind.True: + request.Headers.Add(key, "true"); + break; + case JsonValueKind.False: + request.Headers.Add(key, "false"); + break; + case JsonValueKind.Object: + foreach (var item in element.EnumerateObject()) + { + AddHeaderElementToRequest( + request, + string.Format("{0}.{1}", key, item.Name), + item.Value + ); + } + break; + case JsonValueKind.Array: + foreach (var item in element.EnumerateArray()) + { + request.Headers.Add( + key, + item.ValueKind switch + { + JsonValueKind.Null => "", + JsonValueKind.True => "true", + JsonValueKind.False => "false", + _ => item.GetString(), + } + ); + } + break; + } + } + + protected string QueryString(IImageKitClient client) + { + NameValueCollection collection = []; + foreach (var item in this.QueryProperties) + { + ParamsBase.AddQueryElementToCollection(collection, item.Key, item.Value); + } + StringBuilder sb = new(); + bool first = true; + foreach (var key in collection.AllKeys) + { + foreach (var value in collection.GetValues(key) ?? []) + { + if (!first) + { + sb.Append('&'); + } + first = false; + sb.Append(Web::HttpUtility.UrlEncode(key)); + sb.Append('='); + sb.Append(Web::HttpUtility.UrlEncode(value)); + } + } + return sb.ToString(); + } + + protected static void AddDefaultHeaders(HttpRequestMessage request, IImageKitClient client) + { + request.Headers.Add( + "Authorization", + string.Format( + "Basic {0}", + Convert.ToBase64String( + Encoding + .GetEncoding("ISO-8859-1") + .GetBytes(string.Format("{0}:{1}", client.PrivateAPIKey, client.Password)) + ) + ) + ); + } +} diff --git a/src/Imagekit/Services/Accounts/AccountService.cs b/src/Imagekit/Services/Accounts/AccountService.cs new file mode 100644 index 00000000..b50326fe --- /dev/null +++ b/src/Imagekit/Services/Accounts/AccountService.cs @@ -0,0 +1,34 @@ +using System; +using Imagekit.Services.Accounts.Origins; +using Imagekit.Services.Accounts.URLEndpoints; +using Imagekit.Services.Accounts.Usage; + +namespace Imagekit.Services.Accounts; + +public sealed class AccountService : IAccountService +{ + public AccountService(IImageKitClient client) + { + _usage = new(() => new UsageService(client)); + _origins = new(() => new OriginService(client)); + _urlEndpoints = new(() => new URLEndpointService(client)); + } + + readonly Lazy _usage; + public IUsageService Usage + { + get { return _usage.Value; } + } + + readonly Lazy _origins; + public IOriginService Origins + { + get { return _origins.Value; } + } + + readonly Lazy _urlEndpoints; + public IURLEndpointService URLEndpoints + { + get { return _urlEndpoints.Value; } + } +} diff --git a/src/Imagekit/Services/Accounts/IAccountService.cs b/src/Imagekit/Services/Accounts/IAccountService.cs new file mode 100644 index 00000000..918c2e42 --- /dev/null +++ b/src/Imagekit/Services/Accounts/IAccountService.cs @@ -0,0 +1,14 @@ +using Imagekit.Services.Accounts.Origins; +using Imagekit.Services.Accounts.URLEndpoints; +using Imagekit.Services.Accounts.Usage; + +namespace Imagekit.Services.Accounts; + +public interface IAccountService +{ + IUsageService Usage { get; } + + IOriginService Origins { get; } + + IURLEndpointService URLEndpoints { get; } +} diff --git a/src/Imagekit/Services/Accounts/Origins/IOriginService.cs b/src/Imagekit/Services/Accounts/Origins/IOriginService.cs new file mode 100644 index 00000000..4882a4b8 --- /dev/null +++ b/src/Imagekit/Services/Accounts/Origins/IOriginService.cs @@ -0,0 +1,39 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Imagekit.Models.Accounts.Origins; + +namespace Imagekit.Services.Accounts.Origins; + +public interface IOriginService +{ + /// + /// **Note:** This API is currently in beta. Creates a new origin and returns + /// the origin object. + /// + Task Create(OriginCreateParams parameters); + + /// + /// **Note:** This API is currently in beta. Updates the origin identified + /// by `id` and returns the updated origin object. + /// + Task Update(OriginUpdateParams parameters); + + /// + /// **Note:** This API is currently in beta. Returns an array of all configured + /// origins for the current account. + /// + Task> List(OriginListParams? parameters = null); + + /// + /// **Note:** This API is currently in beta. Permanently removes the origin + /// identified by `id`. If the origin is in use by any URL‑endpoints, the API + /// will return an error. + /// + Task Delete(OriginDeleteParams parameters); + + /// + /// **Note:** This API is currently in beta. Retrieves the origin identified + /// by `id`. + /// + Task Get(OriginGetParams parameters); +} diff --git a/src/Imagekit/Services/Accounts/Origins/OriginService.cs b/src/Imagekit/Services/Accounts/Origins/OriginService.cs new file mode 100644 index 00000000..336b1f97 --- /dev/null +++ b/src/Imagekit/Services/Accounts/Origins/OriginService.cs @@ -0,0 +1,126 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Text.Json; +using System.Threading.Tasks; +using Imagekit.Models.Accounts.Origins; + +namespace Imagekit.Services.Accounts.Origins; + +public sealed class OriginService : IOriginService +{ + readonly IImageKitClient _client; + + public OriginService(IImageKitClient client) + { + _client = client; + } + + public async Task Create(OriginCreateParams parameters) + { + using HttpRequestMessage request = new(HttpMethod.Post, parameters.Url(this._client)) + { + Content = parameters.BodyContent(), + }; + parameters.AddHeadersToRequest(request, this._client); + using HttpResponseMessage response = await this + ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) + .ConfigureAwait(false); + if (!response.IsSuccessStatusCode) + { + throw new HttpException( + response.StatusCode, + await response.Content.ReadAsStringAsync().ConfigureAwait(false) + ); + } + + return JsonSerializer.Deserialize( + await response.Content.ReadAsStreamAsync().ConfigureAwait(false), + ModelBase.SerializerOptions + ) ?? throw new NullReferenceException(); + } + + public async Task Update(OriginUpdateParams parameters) + { + using HttpRequestMessage request = new(HttpMethod.Put, parameters.Url(this._client)) + { + Content = parameters.BodyContent(), + }; + parameters.AddHeadersToRequest(request, this._client); + using HttpResponseMessage response = await this + ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) + .ConfigureAwait(false); + if (!response.IsSuccessStatusCode) + { + throw new HttpException( + response.StatusCode, + await response.Content.ReadAsStringAsync().ConfigureAwait(false) + ); + } + + return JsonSerializer.Deserialize( + await response.Content.ReadAsStreamAsync().ConfigureAwait(false), + ModelBase.SerializerOptions + ) ?? throw new NullReferenceException(); + } + + public async Task> List(OriginListParams? parameters = null) + { + parameters ??= new(); + + using HttpRequestMessage request = new(HttpMethod.Get, parameters.Url(this._client)); + parameters.AddHeadersToRequest(request, this._client); + using HttpResponseMessage response = await this + ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) + .ConfigureAwait(false); + if (!response.IsSuccessStatusCode) + { + throw new HttpException( + response.StatusCode, + await response.Content.ReadAsStringAsync().ConfigureAwait(false) + ); + } + + return JsonSerializer.Deserialize>( + await response.Content.ReadAsStreamAsync().ConfigureAwait(false), + ModelBase.SerializerOptions + ) ?? throw new NullReferenceException(); + } + + public async Task Delete(OriginDeleteParams parameters) + { + using HttpRequestMessage request = new(HttpMethod.Delete, parameters.Url(this._client)); + parameters.AddHeadersToRequest(request, this._client); + using HttpResponseMessage response = await this + ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) + .ConfigureAwait(false); + if (!response.IsSuccessStatusCode) + { + throw new HttpException( + response.StatusCode, + await response.Content.ReadAsStringAsync().ConfigureAwait(false) + ); + } + } + + public async Task Get(OriginGetParams parameters) + { + using HttpRequestMessage request = new(HttpMethod.Get, parameters.Url(this._client)); + parameters.AddHeadersToRequest(request, this._client); + using HttpResponseMessage response = await this + ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) + .ConfigureAwait(false); + if (!response.IsSuccessStatusCode) + { + throw new HttpException( + response.StatusCode, + await response.Content.ReadAsStringAsync().ConfigureAwait(false) + ); + } + + return JsonSerializer.Deserialize( + await response.Content.ReadAsStreamAsync().ConfigureAwait(false), + ModelBase.SerializerOptions + ) ?? throw new NullReferenceException(); + } +} diff --git a/src/Imagekit/Services/Accounts/URLEndpoints/IURLEndpointService.cs b/src/Imagekit/Services/Accounts/URLEndpoints/IURLEndpointService.cs new file mode 100644 index 00000000..dbf0dd4c --- /dev/null +++ b/src/Imagekit/Services/Accounts/URLEndpoints/IURLEndpointService.cs @@ -0,0 +1,40 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Imagekit.Models.Accounts.URLEndpoints; + +namespace Imagekit.Services.Accounts.URLEndpoints; + +public interface IURLEndpointService +{ + /// + /// **Note:** This API is currently in beta. Creates a new URL‑endpoint and + /// returns the resulting object. + /// + Task Create(URLEndpointCreateParams parameters); + + /// + /// **Note:** This API is currently in beta. Updates the URL‑endpoint identified + /// by `id` and returns the updated object. + /// + Task Update(URLEndpointUpdateParams parameters); + + /// + /// **Note:** This API is currently in beta. Returns an array of all URL‑endpoints + /// configured including the default URL-endpoint generated by ImageKit during + /// account creation. + /// + Task> List(URLEndpointListParams? parameters = null); + + /// + /// **Note:** This API is currently in beta. Deletes the URL‑endpoint identified + /// by `id`. You cannot delete the default URL‑endpoint created by ImageKit during + /// account creation. + /// + Task Delete(URLEndpointDeleteParams parameters); + + /// + /// **Note:** This API is currently in beta. Retrieves the URL‑endpoint identified + /// by `id`. + /// + Task Get(URLEndpointGetParams parameters); +} diff --git a/src/Imagekit/Services/Accounts/URLEndpoints/URLEndpointService.cs b/src/Imagekit/Services/Accounts/URLEndpoints/URLEndpointService.cs new file mode 100644 index 00000000..319410cb --- /dev/null +++ b/src/Imagekit/Services/Accounts/URLEndpoints/URLEndpointService.cs @@ -0,0 +1,126 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Text.Json; +using System.Threading.Tasks; +using Imagekit.Models.Accounts.URLEndpoints; + +namespace Imagekit.Services.Accounts.URLEndpoints; + +public sealed class URLEndpointService : IURLEndpointService +{ + readonly IImageKitClient _client; + + public URLEndpointService(IImageKitClient client) + { + _client = client; + } + + public async Task Create(URLEndpointCreateParams parameters) + { + using HttpRequestMessage request = new(HttpMethod.Post, parameters.Url(this._client)) + { + Content = parameters.BodyContent(), + }; + parameters.AddHeadersToRequest(request, this._client); + using HttpResponseMessage response = await this + ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) + .ConfigureAwait(false); + if (!response.IsSuccessStatusCode) + { + throw new HttpException( + response.StatusCode, + await response.Content.ReadAsStringAsync().ConfigureAwait(false) + ); + } + + return JsonSerializer.Deserialize( + await response.Content.ReadAsStreamAsync().ConfigureAwait(false), + ModelBase.SerializerOptions + ) ?? throw new NullReferenceException(); + } + + public async Task Update(URLEndpointUpdateParams parameters) + { + using HttpRequestMessage request = new(HttpMethod.Put, parameters.Url(this._client)) + { + Content = parameters.BodyContent(), + }; + parameters.AddHeadersToRequest(request, this._client); + using HttpResponseMessage response = await this + ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) + .ConfigureAwait(false); + if (!response.IsSuccessStatusCode) + { + throw new HttpException( + response.StatusCode, + await response.Content.ReadAsStringAsync().ConfigureAwait(false) + ); + } + + return JsonSerializer.Deserialize( + await response.Content.ReadAsStreamAsync().ConfigureAwait(false), + ModelBase.SerializerOptions + ) ?? throw new NullReferenceException(); + } + + public async Task> List(URLEndpointListParams? parameters = null) + { + parameters ??= new(); + + using HttpRequestMessage request = new(HttpMethod.Get, parameters.Url(this._client)); + parameters.AddHeadersToRequest(request, this._client); + using HttpResponseMessage response = await this + ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) + .ConfigureAwait(false); + if (!response.IsSuccessStatusCode) + { + throw new HttpException( + response.StatusCode, + await response.Content.ReadAsStringAsync().ConfigureAwait(false) + ); + } + + return JsonSerializer.Deserialize>( + await response.Content.ReadAsStreamAsync().ConfigureAwait(false), + ModelBase.SerializerOptions + ) ?? throw new NullReferenceException(); + } + + public async Task Delete(URLEndpointDeleteParams parameters) + { + using HttpRequestMessage request = new(HttpMethod.Delete, parameters.Url(this._client)); + parameters.AddHeadersToRequest(request, this._client); + using HttpResponseMessage response = await this + ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) + .ConfigureAwait(false); + if (!response.IsSuccessStatusCode) + { + throw new HttpException( + response.StatusCode, + await response.Content.ReadAsStringAsync().ConfigureAwait(false) + ); + } + } + + public async Task Get(URLEndpointGetParams parameters) + { + using HttpRequestMessage request = new(HttpMethod.Get, parameters.Url(this._client)); + parameters.AddHeadersToRequest(request, this._client); + using HttpResponseMessage response = await this + ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) + .ConfigureAwait(false); + if (!response.IsSuccessStatusCode) + { + throw new HttpException( + response.StatusCode, + await response.Content.ReadAsStringAsync().ConfigureAwait(false) + ); + } + + return JsonSerializer.Deserialize( + await response.Content.ReadAsStreamAsync().ConfigureAwait(false), + ModelBase.SerializerOptions + ) ?? throw new NullReferenceException(); + } +} diff --git a/src/Imagekit/Services/Accounts/Usage/IUsageService.cs b/src/Imagekit/Services/Accounts/Usage/IUsageService.cs new file mode 100644 index 00000000..ce3d7bec --- /dev/null +++ b/src/Imagekit/Services/Accounts/Usage/IUsageService.cs @@ -0,0 +1,15 @@ +using System.Threading.Tasks; +using Imagekit.Models.Accounts.Usage; + +namespace Imagekit.Services.Accounts.Usage; + +public interface IUsageService +{ + /// + /// Get the account usage information between two dates. Note that the API response + /// includes data from the start date while excluding data from the end date. + /// In other words, the data covers the period starting from the specified start + /// date up to, but not including, the end date. + /// + Task Get(UsageGetParams parameters); +} diff --git a/src/Imagekit/Services/Accounts/Usage/UsageService.cs b/src/Imagekit/Services/Accounts/Usage/UsageService.cs new file mode 100644 index 00000000..7e95271c --- /dev/null +++ b/src/Imagekit/Services/Accounts/Usage/UsageService.cs @@ -0,0 +1,38 @@ +using System; +using System.Net.Http; +using System.Text.Json; +using System.Threading.Tasks; +using Imagekit.Models.Accounts.Usage; + +namespace Imagekit.Services.Accounts.Usage; + +public sealed class UsageService : IUsageService +{ + readonly IImageKitClient _client; + + public UsageService(IImageKitClient client) + { + _client = client; + } + + public async Task Get(UsageGetParams parameters) + { + using HttpRequestMessage request = new(HttpMethod.Get, parameters.Url(this._client)); + parameters.AddHeadersToRequest(request, this._client); + using HttpResponseMessage response = await this + ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) + .ConfigureAwait(false); + if (!response.IsSuccessStatusCode) + { + throw new HttpException( + response.StatusCode, + await response.Content.ReadAsStringAsync().ConfigureAwait(false) + ); + } + + return JsonSerializer.Deserialize( + await response.Content.ReadAsStreamAsync().ConfigureAwait(false), + ModelBase.SerializerOptions + ) ?? throw new NullReferenceException(); + } +} diff --git a/src/Imagekit/Services/Assets/AssetService.cs b/src/Imagekit/Services/Assets/AssetService.cs new file mode 100644 index 00000000..7f54faac --- /dev/null +++ b/src/Imagekit/Services/Assets/AssetService.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Text.Json; +using System.Threading.Tasks; +using Imagekit.Models.Assets; + +namespace Imagekit.Services.Assets; + +public sealed class AssetService : IAssetService +{ + readonly IImageKitClient _client; + + public AssetService(IImageKitClient client) + { + _client = client; + } + + public async Task> List(AssetListParams? parameters = null) + { + parameters ??= new(); + + using HttpRequestMessage request = new(HttpMethod.Get, parameters.Url(this._client)); + parameters.AddHeadersToRequest(request, this._client); + using HttpResponseMessage response = await this + ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) + .ConfigureAwait(false); + if (!response.IsSuccessStatusCode) + { + throw new HttpException( + response.StatusCode, + await response.Content.ReadAsStringAsync().ConfigureAwait(false) + ); + } + + return JsonSerializer.Deserialize>( + await response.Content.ReadAsStreamAsync().ConfigureAwait(false), + ModelBase.SerializerOptions + ) ?? throw new NullReferenceException(); + } +} diff --git a/src/Imagekit/Services/Assets/IAssetService.cs b/src/Imagekit/Services/Assets/IAssetService.cs new file mode 100644 index 00000000..0ee9f37c --- /dev/null +++ b/src/Imagekit/Services/Assets/IAssetService.cs @@ -0,0 +1,16 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Imagekit.Models.Assets; + +namespace Imagekit.Services.Assets; + +public interface IAssetService +{ + /// + /// This API can list all the uploaded files and folders in your ImageKit.io + /// media library. In addition, you can fine-tune your query by specifying various + /// filters by generating a query string in a Lucene-like syntax and provide + /// this generated string as the value of the `searchQuery`. + /// + Task> List(AssetListParams? parameters = null); +} diff --git a/src/Imagekit/Services/Beta/BetaService.cs b/src/Imagekit/Services/Beta/BetaService.cs new file mode 100644 index 00000000..b6c9e2a1 --- /dev/null +++ b/src/Imagekit/Services/Beta/BetaService.cs @@ -0,0 +1,18 @@ +using System; +using Imagekit.Services.Beta.V2; + +namespace Imagekit.Services.Beta; + +public sealed class BetaService : IBetaService +{ + public BetaService(IImageKitClient client) + { + _v2 = new(() => new V2Service(client)); + } + + readonly Lazy _v2; + public IV2Service V2 + { + get { return _v2.Value; } + } +} diff --git a/src/Imagekit/Services/Beta/IBetaService.cs b/src/Imagekit/Services/Beta/IBetaService.cs new file mode 100644 index 00000000..65bd9f62 --- /dev/null +++ b/src/Imagekit/Services/Beta/IBetaService.cs @@ -0,0 +1,8 @@ +using Imagekit.Services.Beta.V2; + +namespace Imagekit.Services.Beta; + +public interface IBetaService +{ + IV2Service V2 { get; } +} diff --git a/src/Imagekit/Services/Beta/V2/Files/FileService.cs b/src/Imagekit/Services/Beta/V2/Files/FileService.cs new file mode 100644 index 00000000..cdc7fef3 --- /dev/null +++ b/src/Imagekit/Services/Beta/V2/Files/FileService.cs @@ -0,0 +1,41 @@ +using System; +using System.Net.Http; +using System.Text.Json; +using System.Threading.Tasks; +using Imagekit.Models.Beta.V2.Files; + +namespace Imagekit.Services.Beta.V2.Files; + +public sealed class FileService : IFileService +{ + readonly IImageKitClient _client; + + public FileService(IImageKitClient client) + { + _client = client; + } + + public async Task Upload(FileUploadParams parameters) + { + using HttpRequestMessage request = new(HttpMethod.Post, parameters.Url(this._client)) + { + Content = parameters.BodyContent(), + }; + parameters.AddHeadersToRequest(request, this._client); + using HttpResponseMessage response = await this + ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) + .ConfigureAwait(false); + if (!response.IsSuccessStatusCode) + { + throw new HttpException( + response.StatusCode, + await response.Content.ReadAsStringAsync().ConfigureAwait(false) + ); + } + + return JsonSerializer.Deserialize( + await response.Content.ReadAsStreamAsync().ConfigureAwait(false), + ModelBase.SerializerOptions + ) ?? throw new NullReferenceException(); + } +} diff --git a/src/Imagekit/Services/Beta/V2/Files/IFileService.cs b/src/Imagekit/Services/Beta/V2/Files/IFileService.cs new file mode 100644 index 00000000..7e4a65f2 --- /dev/null +++ b/src/Imagekit/Services/Beta/V2/Files/IFileService.cs @@ -0,0 +1,33 @@ +using System.Threading.Tasks; +using Imagekit.Models.Beta.V2.Files; + +namespace Imagekit.Services.Beta.V2.Files; + +public interface IFileService +{ + /// + /// The V2 API enhances security by verifying the entire payload using JWT. This + /// API is in beta. + /// + /// ImageKit.io allows you to upload files directly from both the server and client + /// sides. For server-side uploads, private API key authentication is used. For + /// client-side uploads, generate a one-time `token` from your secure backend + /// using private API. [Learn more](/docs/api-reference/upload-file/upload-file-v2#how-to-implement-secure-client-side-file-upload) + /// about how to implement secure client-side file upload. + /// + /// **File size limit** \ On the free plan, the maximum upload file sizes are + /// 20MB for images, audio, and raw files, and 100MB for videos. On the paid plan, + /// these limits increase to 40MB for images, audio, and raw files, and 2GB for + /// videos. These limits can be further increased with higher-tier plans. + /// + /// **Version limit** \ A file can have a maximum of 100 versions. + /// + /// **Demo applications** + /// + /// - A full-fledged [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), + /// supporting file selections from local storage, URL, Dropbox, Google Drive, + /// Instagram, and more. - [Quick start guides](/docs/quick-start-guides) for + /// various frameworks and technologies. + /// + Task Upload(FileUploadParams parameters); +} diff --git a/src/Imagekit/Services/Beta/V2/IV2Service.cs b/src/Imagekit/Services/Beta/V2/IV2Service.cs new file mode 100644 index 00000000..13609839 --- /dev/null +++ b/src/Imagekit/Services/Beta/V2/IV2Service.cs @@ -0,0 +1,8 @@ +using Imagekit.Services.Beta.V2.Files; + +namespace Imagekit.Services.Beta.V2; + +public interface IV2Service +{ + IFileService Files { get; } +} diff --git a/src/Imagekit/Services/Beta/V2/V2Service.cs b/src/Imagekit/Services/Beta/V2/V2Service.cs new file mode 100644 index 00000000..e966651e --- /dev/null +++ b/src/Imagekit/Services/Beta/V2/V2Service.cs @@ -0,0 +1,18 @@ +using System; +using Imagekit.Services.Beta.V2.Files; + +namespace Imagekit.Services.Beta.V2; + +public sealed class V2Service : IV2Service +{ + public V2Service(IImageKitClient client) + { + _files = new(() => new FileService(client)); + } + + readonly Lazy _files; + public IFileService Files + { + get { return _files.Value; } + } +} diff --git a/src/Imagekit/Services/Cache/CacheService.cs b/src/Imagekit/Services/Cache/CacheService.cs new file mode 100644 index 00000000..35ad5f64 --- /dev/null +++ b/src/Imagekit/Services/Cache/CacheService.cs @@ -0,0 +1,18 @@ +using System; +using Imagekit.Services.Cache.Invalidation; + +namespace Imagekit.Services.Cache; + +public sealed class CacheService : ICacheService +{ + public CacheService(IImageKitClient client) + { + _invalidation = new(() => new InvalidationService(client)); + } + + readonly Lazy _invalidation; + public IInvalidationService Invalidation + { + get { return _invalidation.Value; } + } +} diff --git a/src/Imagekit/Services/Cache/ICacheService.cs b/src/Imagekit/Services/Cache/ICacheService.cs new file mode 100644 index 00000000..91882a67 --- /dev/null +++ b/src/Imagekit/Services/Cache/ICacheService.cs @@ -0,0 +1,8 @@ +using Imagekit.Services.Cache.Invalidation; + +namespace Imagekit.Services.Cache; + +public interface ICacheService +{ + IInvalidationService Invalidation { get; } +} diff --git a/src/Imagekit/Services/Cache/Invalidation/IInvalidationService.cs b/src/Imagekit/Services/Cache/Invalidation/IInvalidationService.cs new file mode 100644 index 00000000..1c2a20a6 --- /dev/null +++ b/src/Imagekit/Services/Cache/Invalidation/IInvalidationService.cs @@ -0,0 +1,19 @@ +using System.Threading.Tasks; +using Imagekit.Models.Cache.Invalidation; + +namespace Imagekit.Services.Cache.Invalidation; + +public interface IInvalidationService +{ + /// + /// This API will purge CDN cache and ImageKit.io's internal cache for a file. + /// Note: Purge cache is an asynchronous process and it may take some time to + /// reflect the changes. + /// + Task Create(InvalidationCreateParams parameters); + + /// + /// This API returns the status of a purge cache request. + /// + Task Get(InvalidationGetParams parameters); +} diff --git a/src/Imagekit/Services/Cache/Invalidation/InvalidationService.cs b/src/Imagekit/Services/Cache/Invalidation/InvalidationService.cs new file mode 100644 index 00000000..2513605a --- /dev/null +++ b/src/Imagekit/Services/Cache/Invalidation/InvalidationService.cs @@ -0,0 +1,62 @@ +using System; +using System.Net.Http; +using System.Text.Json; +using System.Threading.Tasks; +using Imagekit.Models.Cache.Invalidation; + +namespace Imagekit.Services.Cache.Invalidation; + +public sealed class InvalidationService : IInvalidationService +{ + readonly IImageKitClient _client; + + public InvalidationService(IImageKitClient client) + { + _client = client; + } + + public async Task Create(InvalidationCreateParams parameters) + { + using HttpRequestMessage request = new(HttpMethod.Post, parameters.Url(this._client)) + { + Content = parameters.BodyContent(), + }; + parameters.AddHeadersToRequest(request, this._client); + using HttpResponseMessage response = await this + ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) + .ConfigureAwait(false); + if (!response.IsSuccessStatusCode) + { + throw new HttpException( + response.StatusCode, + await response.Content.ReadAsStringAsync().ConfigureAwait(false) + ); + } + + return JsonSerializer.Deserialize( + await response.Content.ReadAsStreamAsync().ConfigureAwait(false), + ModelBase.SerializerOptions + ) ?? throw new NullReferenceException(); + } + + public async Task Get(InvalidationGetParams parameters) + { + using HttpRequestMessage request = new(HttpMethod.Get, parameters.Url(this._client)); + parameters.AddHeadersToRequest(request, this._client); + using HttpResponseMessage response = await this + ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) + .ConfigureAwait(false); + if (!response.IsSuccessStatusCode) + { + throw new HttpException( + response.StatusCode, + await response.Content.ReadAsStringAsync().ConfigureAwait(false) + ); + } + + return JsonSerializer.Deserialize( + await response.Content.ReadAsStreamAsync().ConfigureAwait(false), + ModelBase.SerializerOptions + ) ?? throw new NullReferenceException(); + } +} diff --git a/src/Imagekit/Services/CustomMetadataFields/CustomMetadataFieldService.cs b/src/Imagekit/Services/CustomMetadataFields/CustomMetadataFieldService.cs new file mode 100644 index 00000000..b293386d --- /dev/null +++ b/src/Imagekit/Services/CustomMetadataFields/CustomMetadataFieldService.cs @@ -0,0 +1,114 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Text.Json; +using System.Threading.Tasks; +using Imagekit.Models.CustomMetadataFields; + +namespace Imagekit.Services.CustomMetadataFields; + +public sealed class CustomMetadataFieldService : ICustomMetadataFieldService +{ + readonly IImageKitClient _client; + + public CustomMetadataFieldService(IImageKitClient client) + { + _client = client; + } + + public async Task Create(CustomMetadataFieldCreateParams parameters) + { + using HttpRequestMessage request = new(HttpMethod.Post, parameters.Url(this._client)) + { + Content = parameters.BodyContent(), + }; + parameters.AddHeadersToRequest(request, this._client); + using HttpResponseMessage response = await this + ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) + .ConfigureAwait(false); + if (!response.IsSuccessStatusCode) + { + throw new HttpException( + response.StatusCode, + await response.Content.ReadAsStringAsync().ConfigureAwait(false) + ); + } + + return JsonSerializer.Deserialize( + await response.Content.ReadAsStreamAsync().ConfigureAwait(false), + ModelBase.SerializerOptions + ) ?? throw new NullReferenceException(); + } + + public async Task Update(CustomMetadataFieldUpdateParams parameters) + { + using HttpRequestMessage request = new(HttpMethod.Patch, parameters.Url(this._client)) + { + Content = parameters.BodyContent(), + }; + parameters.AddHeadersToRequest(request, this._client); + using HttpResponseMessage response = await this + ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) + .ConfigureAwait(false); + if (!response.IsSuccessStatusCode) + { + throw new HttpException( + response.StatusCode, + await response.Content.ReadAsStringAsync().ConfigureAwait(false) + ); + } + + return JsonSerializer.Deserialize( + await response.Content.ReadAsStreamAsync().ConfigureAwait(false), + ModelBase.SerializerOptions + ) ?? throw new NullReferenceException(); + } + + public async Task> List( + CustomMetadataFieldListParams? parameters = null + ) + { + parameters ??= new(); + + using HttpRequestMessage request = new(HttpMethod.Get, parameters.Url(this._client)); + parameters.AddHeadersToRequest(request, this._client); + using HttpResponseMessage response = await this + ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) + .ConfigureAwait(false); + if (!response.IsSuccessStatusCode) + { + throw new HttpException( + response.StatusCode, + await response.Content.ReadAsStringAsync().ConfigureAwait(false) + ); + } + + return JsonSerializer.Deserialize>( + await response.Content.ReadAsStreamAsync().ConfigureAwait(false), + ModelBase.SerializerOptions + ) ?? throw new NullReferenceException(); + } + + public async Task Delete( + CustomMetadataFieldDeleteParams parameters + ) + { + using HttpRequestMessage request = new(HttpMethod.Delete, parameters.Url(this._client)); + parameters.AddHeadersToRequest(request, this._client); + using HttpResponseMessage response = await this + ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) + .ConfigureAwait(false); + if (!response.IsSuccessStatusCode) + { + throw new HttpException( + response.StatusCode, + await response.Content.ReadAsStringAsync().ConfigureAwait(false) + ); + } + + return JsonSerializer.Deserialize( + await response.Content.ReadAsStreamAsync().ConfigureAwait(false), + ModelBase.SerializerOptions + ) ?? throw new NullReferenceException(); + } +} diff --git a/src/Imagekit/Services/CustomMetadataFields/ICustomMetadataFieldService.cs b/src/Imagekit/Services/CustomMetadataFields/ICustomMetadataFieldService.cs new file mode 100644 index 00000000..1661789f --- /dev/null +++ b/src/Imagekit/Services/CustomMetadataFields/ICustomMetadataFieldService.cs @@ -0,0 +1,34 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Imagekit.Models.CustomMetadataFields; + +namespace Imagekit.Services.CustomMetadataFields; + +public interface ICustomMetadataFieldService +{ + /// + /// This API creates a new custom metadata field. Once a custom metadata field + /// is created either through this API or using the dashboard UI, its value can + /// be set on the assets. The value of a field for an asset can be set using the + /// media library UI or programmatically through upload or update assets API. + /// + Task Create(CustomMetadataFieldCreateParams parameters); + + /// + /// This API updates the label or schema of an existing custom metadata field. + /// + Task Update(CustomMetadataFieldUpdateParams parameters); + + /// + /// This API returns the array of created custom metadata field objects. By default + /// the API returns only non deleted field objects, but you can include deleted + /// fields in the API response. + /// + Task> List(CustomMetadataFieldListParams? parameters = null); + + /// + /// This API deletes a custom metadata field. Even after deleting a custom metadata + /// field, you cannot create any new custom metadata field with the same name. + /// + Task Delete(CustomMetadataFieldDeleteParams parameters); +} diff --git a/src/Imagekit/Services/Files/Bulk/BulkService.cs b/src/Imagekit/Services/Files/Bulk/BulkService.cs new file mode 100644 index 00000000..a10d960d --- /dev/null +++ b/src/Imagekit/Services/Files/Bulk/BulkService.cs @@ -0,0 +1,113 @@ +using System; +using System.Net.Http; +using System.Text.Json; +using System.Threading.Tasks; +using Imagekit.Models.Files.Bulk; + +namespace Imagekit.Services.Files.Bulk; + +public sealed class BulkService : IBulkService +{ + readonly IImageKitClient _client; + + public BulkService(IImageKitClient client) + { + _client = client; + } + + public async Task Delete(BulkDeleteParams parameters) + { + using HttpRequestMessage request = new(HttpMethod.Post, parameters.Url(this._client)) + { + Content = parameters.BodyContent(), + }; + parameters.AddHeadersToRequest(request, this._client); + using HttpResponseMessage response = await this + ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) + .ConfigureAwait(false); + if (!response.IsSuccessStatusCode) + { + throw new HttpException( + response.StatusCode, + await response.Content.ReadAsStringAsync().ConfigureAwait(false) + ); + } + + return JsonSerializer.Deserialize( + await response.Content.ReadAsStreamAsync().ConfigureAwait(false), + ModelBase.SerializerOptions + ) ?? throw new NullReferenceException(); + } + + public async Task AddTags(BulkAddTagsParams parameters) + { + using HttpRequestMessage request = new(HttpMethod.Post, parameters.Url(this._client)) + { + Content = parameters.BodyContent(), + }; + parameters.AddHeadersToRequest(request, this._client); + using HttpResponseMessage response = await this + ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) + .ConfigureAwait(false); + if (!response.IsSuccessStatusCode) + { + throw new HttpException( + response.StatusCode, + await response.Content.ReadAsStringAsync().ConfigureAwait(false) + ); + } + + return JsonSerializer.Deserialize( + await response.Content.ReadAsStreamAsync().ConfigureAwait(false), + ModelBase.SerializerOptions + ) ?? throw new NullReferenceException(); + } + + public async Task RemoveAITags(BulkRemoveAITagsParams parameters) + { + using HttpRequestMessage request = new(HttpMethod.Post, parameters.Url(this._client)) + { + Content = parameters.BodyContent(), + }; + parameters.AddHeadersToRequest(request, this._client); + using HttpResponseMessage response = await this + ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) + .ConfigureAwait(false); + if (!response.IsSuccessStatusCode) + { + throw new HttpException( + response.StatusCode, + await response.Content.ReadAsStringAsync().ConfigureAwait(false) + ); + } + + return JsonSerializer.Deserialize( + await response.Content.ReadAsStreamAsync().ConfigureAwait(false), + ModelBase.SerializerOptions + ) ?? throw new NullReferenceException(); + } + + public async Task RemoveTags(BulkRemoveTagsParams parameters) + { + using HttpRequestMessage request = new(HttpMethod.Post, parameters.Url(this._client)) + { + Content = parameters.BodyContent(), + }; + parameters.AddHeadersToRequest(request, this._client); + using HttpResponseMessage response = await this + ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) + .ConfigureAwait(false); + if (!response.IsSuccessStatusCode) + { + throw new HttpException( + response.StatusCode, + await response.Content.ReadAsStringAsync().ConfigureAwait(false) + ); + } + + return JsonSerializer.Deserialize( + await response.Content.ReadAsStreamAsync().ConfigureAwait(false), + ModelBase.SerializerOptions + ) ?? throw new NullReferenceException(); + } +} diff --git a/src/Imagekit/Services/Files/Bulk/IBulkService.cs b/src/Imagekit/Services/Files/Bulk/IBulkService.cs new file mode 100644 index 00000000..da6626c9 --- /dev/null +++ b/src/Imagekit/Services/Files/Bulk/IBulkService.cs @@ -0,0 +1,36 @@ +using System.Threading.Tasks; +using Imagekit.Models.Files.Bulk; + +namespace Imagekit.Services.Files.Bulk; + +public interface IBulkService +{ + /// + /// This API deletes multiple files and all their file versions permanently. + /// + /// Note: If a file or specific transformation has been requested in the past, + /// then the response is cached. Deleting a file does not purge the cache. You + /// can purge the cache using purge cache API. + /// + /// A maximum of 100 files can be deleted at a time. + /// + Task Delete(BulkDeleteParams parameters); + + /// + /// This API adds tags to multiple files in bulk. A maximum of 50 files can be + /// specified at a time. + /// + Task AddTags(BulkAddTagsParams parameters); + + /// + /// This API removes AITags from multiple files in bulk. A maximum of 50 files + /// can be specified at a time. + /// + Task RemoveAITags(BulkRemoveAITagsParams parameters); + + /// + /// This API removes tags from multiple files in bulk. A maximum of 50 files can + /// be specified at a time. + /// + Task RemoveTags(BulkRemoveTagsParams parameters); +} diff --git a/src/Imagekit/Services/Files/FileService.cs b/src/Imagekit/Services/Files/FileService.cs new file mode 100644 index 00000000..7ec98b70 --- /dev/null +++ b/src/Imagekit/Services/Files/FileService.cs @@ -0,0 +1,198 @@ +using System; +using System.Net.Http; +using System.Text.Json; +using System.Threading.Tasks; +using Imagekit.Models.Files; +using Imagekit.Services.Files.Bulk; +using Imagekit.Services.Files.Metadata; +using Imagekit.Services.Files.Versions; + +namespace Imagekit.Services.Files; + +public sealed class FileService : IFileService +{ + readonly IImageKitClient _client; + + public FileService(IImageKitClient client) + { + _client = client; + _bulk = new(() => new BulkService(client)); + _versions = new(() => new VersionService(client)); + _metadata = new(() => new MetadataService(client)); + } + + readonly Lazy _bulk; + public IBulkService Bulk + { + get { return _bulk.Value; } + } + + readonly Lazy _versions; + public IVersionService Versions + { + get { return _versions.Value; } + } + + readonly Lazy _metadata; + public IMetadataService Metadata + { + get { return _metadata.Value; } + } + + public async Task Update(FileUpdateParams parameters) + { + using HttpRequestMessage request = new(HttpMethod.Patch, parameters.Url(this._client)) + { + Content = parameters.BodyContent(), + }; + parameters.AddHeadersToRequest(request, this._client); + using HttpResponseMessage response = await this + ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) + .ConfigureAwait(false); + if (!response.IsSuccessStatusCode) + { + throw new HttpException( + response.StatusCode, + await response.Content.ReadAsStringAsync().ConfigureAwait(false) + ); + } + + return JsonSerializer.Deserialize( + await response.Content.ReadAsStreamAsync().ConfigureAwait(false), + ModelBase.SerializerOptions + ) ?? throw new NullReferenceException(); + } + + public async Task Delete(FileDeleteParams parameters) + { + using HttpRequestMessage request = new(HttpMethod.Delete, parameters.Url(this._client)); + parameters.AddHeadersToRequest(request, this._client); + using HttpResponseMessage response = await this + ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) + .ConfigureAwait(false); + if (!response.IsSuccessStatusCode) + { + throw new HttpException( + response.StatusCode, + await response.Content.ReadAsStringAsync().ConfigureAwait(false) + ); + } + } + + public async Task Copy(FileCopyParams parameters) + { + using HttpRequestMessage request = new(HttpMethod.Post, parameters.Url(this._client)) + { + Content = parameters.BodyContent(), + }; + parameters.AddHeadersToRequest(request, this._client); + using HttpResponseMessage response = await this + ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) + .ConfigureAwait(false); + if (!response.IsSuccessStatusCode) + { + throw new HttpException( + response.StatusCode, + await response.Content.ReadAsStringAsync().ConfigureAwait(false) + ); + } + + return JsonSerializer.Deserialize( + await response.Content.ReadAsStreamAsync().ConfigureAwait(false), + ModelBase.SerializerOptions + ) ?? throw new NullReferenceException(); + } + + public async Task Get(FileGetParams parameters) + { + using HttpRequestMessage request = new(HttpMethod.Get, parameters.Url(this._client)); + parameters.AddHeadersToRequest(request, this._client); + using HttpResponseMessage response = await this + ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) + .ConfigureAwait(false); + if (!response.IsSuccessStatusCode) + { + throw new HttpException( + response.StatusCode, + await response.Content.ReadAsStringAsync().ConfigureAwait(false) + ); + } + + return JsonSerializer.Deserialize( + await response.Content.ReadAsStreamAsync().ConfigureAwait(false), + ModelBase.SerializerOptions + ) ?? throw new NullReferenceException(); + } + + public async Task Move(FileMoveParams parameters) + { + using HttpRequestMessage request = new(HttpMethod.Post, parameters.Url(this._client)) + { + Content = parameters.BodyContent(), + }; + parameters.AddHeadersToRequest(request, this._client); + using HttpResponseMessage response = await this + ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) + .ConfigureAwait(false); + if (!response.IsSuccessStatusCode) + { + throw new HttpException( + response.StatusCode, + await response.Content.ReadAsStringAsync().ConfigureAwait(false) + ); + } + + return JsonSerializer.Deserialize( + await response.Content.ReadAsStreamAsync().ConfigureAwait(false), + ModelBase.SerializerOptions + ) ?? throw new NullReferenceException(); + } + + public async Task Rename(FileRenameParams parameters) + { + using HttpRequestMessage request = new(HttpMethod.Put, parameters.Url(this._client)) + { + Content = parameters.BodyContent(), + }; + parameters.AddHeadersToRequest(request, this._client); + using HttpResponseMessage response = await this + ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) + .ConfigureAwait(false); + if (!response.IsSuccessStatusCode) + { + throw new HttpException( + response.StatusCode, + await response.Content.ReadAsStringAsync().ConfigureAwait(false) + ); + } + + return JsonSerializer.Deserialize( + await response.Content.ReadAsStreamAsync().ConfigureAwait(false), + ModelBase.SerializerOptions + ) ?? throw new NullReferenceException(); + } + + public async Task Upload(FileUploadParams parameters) + { + using HttpRequestMessage request = new(HttpMethod.Post, parameters.Url(this._client)) + { + Content = parameters.BodyContent(), + }; + parameters.AddHeadersToRequest(request, this._client); + using HttpResponseMessage response = await this + ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) + .ConfigureAwait(false); + if (!response.IsSuccessStatusCode) + { + throw new HttpException( + response.StatusCode, + await response.Content.ReadAsStringAsync().ConfigureAwait(false) + ); + } + + return JsonSerializer.Deserialize( + await response.Content.ReadAsStreamAsync().ConfigureAwait(false), + ModelBase.SerializerOptions + ) ?? throw new NullReferenceException(); + } +} diff --git a/src/Imagekit/Services/Files/IFileService.cs b/src/Imagekit/Services/Files/IFileService.cs new file mode 100644 index 00000000..183d998d --- /dev/null +++ b/src/Imagekit/Services/Files/IFileService.cs @@ -0,0 +1,91 @@ +using System.Threading.Tasks; +using Imagekit.Models.Files; +using Imagekit.Services.Files.Bulk; +using Imagekit.Services.Files.Metadata; +using Imagekit.Services.Files.Versions; + +namespace Imagekit.Services.Files; + +public interface IFileService +{ + IBulkService Bulk { get; } + + IVersionService Versions { get; } + + IMetadataService Metadata { get; } + + /// + /// This API updates the details or attributes of the current version of the + /// file. You can update `tags`, `customCoordinates`, `customMetadata`, publication + /// status, remove existing `AITags` and apply extensions using this API. + /// + Task Update(FileUpdateParams parameters); + + /// + /// This API deletes the file and all its file versions permanently. + /// + /// Note: If a file or specific transformation has been requested in the past, + /// then the response is cached. Deleting a file does not purge the cache. You + /// can purge the cache using purge cache API. + /// + Task Delete(FileDeleteParams parameters); + + /// + /// This will copy a file from one folder to another. + /// + /// Note: If any file at the destination has the same name as the source file, + /// then the source file and its versions (if `includeFileVersions` is set to + /// true) will be appended to the destination file version history. + /// + Task Copy(FileCopyParams parameters); + + /// + /// This API returns an object with details or attributes about the current version + /// of the file. + /// + Task Get(FileGetParams parameters); + + /// + /// This will move a file and all its versions from one folder to another. + /// + /// Note: If any file at the destination has the same name as the source file, + /// then the source file and its versions will be appended to the destination + /// file. + /// + Task Move(FileMoveParams parameters); + + /// + /// You can rename an already existing file in the media library using rename + /// file API. This operation would rename all file versions of the file. + /// + /// Note: The old URLs will stop working. The file/file version URLs cached on + /// CDN will continue to work unless a purge is requested. + /// + Task Rename(FileRenameParams parameters); + + /// + /// ImageKit.io allows you to upload files directly from both the server and client + /// sides. For server-side uploads, private API key authentication is used. For + /// client-side uploads, generate a one-time `token`, `signature`, and `expire` + /// from your secure backend using private API. [Learn more](/docs/api-reference/upload-file/upload-file#how-to-implement-client-side-file-upload) + /// about how to implement client-side file upload. + /// + /// The [V2 API](/docs/api-reference/upload-file/upload-file-v2) enhances security + /// by verifying the entire payload using JWT. + /// + /// **File size limit** \ On the free plan, the maximum upload file sizes are + /// 20MB for images, audio, and raw files and 100MB for videos. On the paid plan, + /// these limits increase to 40MB for images, audio, and raw files and 2GB for + /// videos. These limits can be further increased with higher-tier plans. + /// + /// **Version limit** \ A file can have a maximum of 100 versions. + /// + /// **Demo applications** + /// + /// - A full-fledged [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), + /// supporting file selections from local storage, URL, Dropbox, Google Drive, + /// Instagram, and more. - [Quick start guides](/docs/quick-start-guides) for + /// various frameworks and technologies. + /// + Task Upload(FileUploadParams parameters); +} diff --git a/src/Imagekit/Services/Files/Metadata/IMetadataService.cs b/src/Imagekit/Services/Files/Metadata/IMetadataService.cs new file mode 100644 index 00000000..2135c619 --- /dev/null +++ b/src/Imagekit/Services/Files/Metadata/IMetadataService.cs @@ -0,0 +1,23 @@ +using System.Threading.Tasks; +using Imagekit.Models.Files.Metadata; +using Files = Imagekit.Models.Files; + +namespace Imagekit.Services.Files.Metadata; + +public interface IMetadataService +{ + /// + /// You can programmatically get image EXIF, pHash, and other metadata for uploaded + /// files in the ImageKit.io media library using this API. + /// + /// You can also get the metadata in upload API response by passing `metadata` + /// in `responseFields` parameter. + /// + Task Get(MetadataGetParams parameters); + + /// + /// Get image EXIF, pHash, and other metadata from ImageKit.io powered remote + /// URL using this API. + /// + Task GetFromURL(MetadataGetFromURLParams parameters); +} diff --git a/src/Imagekit/Services/Files/Metadata/MetadataService.cs b/src/Imagekit/Services/Files/Metadata/MetadataService.cs new file mode 100644 index 00000000..46110365 --- /dev/null +++ b/src/Imagekit/Services/Files/Metadata/MetadataService.cs @@ -0,0 +1,60 @@ +using System; +using System.Net.Http; +using System.Text.Json; +using System.Threading.Tasks; +using Imagekit.Models.Files.Metadata; +using Files = Imagekit.Models.Files; + +namespace Imagekit.Services.Files.Metadata; + +public sealed class MetadataService : IMetadataService +{ + readonly IImageKitClient _client; + + public MetadataService(IImageKitClient client) + { + _client = client; + } + + public async Task Get(MetadataGetParams parameters) + { + using HttpRequestMessage request = new(HttpMethod.Get, parameters.Url(this._client)); + parameters.AddHeadersToRequest(request, this._client); + using HttpResponseMessage response = await this + ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) + .ConfigureAwait(false); + if (!response.IsSuccessStatusCode) + { + throw new HttpException( + response.StatusCode, + await response.Content.ReadAsStringAsync().ConfigureAwait(false) + ); + } + + return JsonSerializer.Deserialize( + await response.Content.ReadAsStreamAsync().ConfigureAwait(false), + ModelBase.SerializerOptions + ) ?? throw new NullReferenceException(); + } + + public async Task GetFromURL(MetadataGetFromURLParams parameters) + { + using HttpRequestMessage request = new(HttpMethod.Get, parameters.Url(this._client)); + parameters.AddHeadersToRequest(request, this._client); + using HttpResponseMessage response = await this + ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) + .ConfigureAwait(false); + if (!response.IsSuccessStatusCode) + { + throw new HttpException( + response.StatusCode, + await response.Content.ReadAsStringAsync().ConfigureAwait(false) + ); + } + + return JsonSerializer.Deserialize( + await response.Content.ReadAsStreamAsync().ConfigureAwait(false), + ModelBase.SerializerOptions + ) ?? throw new NullReferenceException(); + } +} diff --git a/src/Imagekit/Services/Files/Versions/IVersionService.cs b/src/Imagekit/Services/Files/Versions/IVersionService.cs new file mode 100644 index 00000000..8efbc71d --- /dev/null +++ b/src/Imagekit/Services/Files/Versions/IVersionService.cs @@ -0,0 +1,32 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Imagekit.Models.Files; +using Imagekit.Models.Files.Versions; + +namespace Imagekit.Services.Files.Versions; + +public interface IVersionService +{ + /// + /// This API returns details of all versions of a file. + /// + Task> List(VersionListParams parameters); + + /// + /// This API deletes a non-current file version permanently. The API returns + /// an empty response. + /// + /// Note: If you want to delete all versions of a file, use the delete file API. + /// + Task Delete(VersionDeleteParams parameters); + + /// + /// This API returns an object with details or attributes of a file version. + /// + Task Get(VersionGetParams parameters); + + /// + /// This API restores a file version as the current file version. + /// + Task Restore(VersionRestoreParams parameters); +} diff --git a/src/Imagekit/Services/Files/Versions/VersionService.cs b/src/Imagekit/Services/Files/Versions/VersionService.cs new file mode 100644 index 00000000..e47cc714 --- /dev/null +++ b/src/Imagekit/Services/Files/Versions/VersionService.cs @@ -0,0 +1,103 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Text.Json; +using System.Threading.Tasks; +using Imagekit.Models.Files; +using Imagekit.Models.Files.Versions; + +namespace Imagekit.Services.Files.Versions; + +public sealed class VersionService : IVersionService +{ + readonly IImageKitClient _client; + + public VersionService(IImageKitClient client) + { + _client = client; + } + + public async Task> List(VersionListParams parameters) + { + using HttpRequestMessage request = new(HttpMethod.Get, parameters.Url(this._client)); + parameters.AddHeadersToRequest(request, this._client); + using HttpResponseMessage response = await this + ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) + .ConfigureAwait(false); + if (!response.IsSuccessStatusCode) + { + throw new HttpException( + response.StatusCode, + await response.Content.ReadAsStringAsync().ConfigureAwait(false) + ); + } + + return JsonSerializer.Deserialize>( + await response.Content.ReadAsStreamAsync().ConfigureAwait(false), + ModelBase.SerializerOptions + ) ?? throw new NullReferenceException(); + } + + public async Task Delete(VersionDeleteParams parameters) + { + using HttpRequestMessage request = new(HttpMethod.Delete, parameters.Url(this._client)); + parameters.AddHeadersToRequest(request, this._client); + using HttpResponseMessage response = await this + ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) + .ConfigureAwait(false); + if (!response.IsSuccessStatusCode) + { + throw new HttpException( + response.StatusCode, + await response.Content.ReadAsStringAsync().ConfigureAwait(false) + ); + } + + return JsonSerializer.Deserialize( + await response.Content.ReadAsStreamAsync().ConfigureAwait(false), + ModelBase.SerializerOptions + ) ?? throw new NullReferenceException(); + } + + public async Task Get(VersionGetParams parameters) + { + using HttpRequestMessage request = new(HttpMethod.Get, parameters.Url(this._client)); + parameters.AddHeadersToRequest(request, this._client); + using HttpResponseMessage response = await this + ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) + .ConfigureAwait(false); + if (!response.IsSuccessStatusCode) + { + throw new HttpException( + response.StatusCode, + await response.Content.ReadAsStringAsync().ConfigureAwait(false) + ); + } + + return JsonSerializer.Deserialize( + await response.Content.ReadAsStreamAsync().ConfigureAwait(false), + ModelBase.SerializerOptions + ) ?? throw new NullReferenceException(); + } + + public async Task Restore(VersionRestoreParams parameters) + { + using HttpRequestMessage request = new(HttpMethod.Put, parameters.Url(this._client)); + parameters.AddHeadersToRequest(request, this._client); + using HttpResponseMessage response = await this + ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) + .ConfigureAwait(false); + if (!response.IsSuccessStatusCode) + { + throw new HttpException( + response.StatusCode, + await response.Content.ReadAsStringAsync().ConfigureAwait(false) + ); + } + + return JsonSerializer.Deserialize( + await response.Content.ReadAsStreamAsync().ConfigureAwait(false), + ModelBase.SerializerOptions + ) ?? throw new NullReferenceException(); + } +} diff --git a/src/Imagekit/Services/Folders/FolderService.cs b/src/Imagekit/Services/Folders/FolderService.cs new file mode 100644 index 00000000..23f3bc3d --- /dev/null +++ b/src/Imagekit/Services/Folders/FolderService.cs @@ -0,0 +1,145 @@ +using System; +using System.Net.Http; +using System.Text.Json; +using System.Threading.Tasks; +using Imagekit.Models.Folders; +using Imagekit.Services.Folders.Job; + +namespace Imagekit.Services.Folders; + +public sealed class FolderService : IFolderService +{ + readonly IImageKitClient _client; + + public FolderService(IImageKitClient client) + { + _client = client; + _job = new(() => new JobService(client)); + } + + readonly Lazy _job; + public IJobService Job + { + get { return _job.Value; } + } + + public async Task Create(FolderCreateParams parameters) + { + using HttpRequestMessage request = new(HttpMethod.Post, parameters.Url(this._client)) + { + Content = parameters.BodyContent(), + }; + parameters.AddHeadersToRequest(request, this._client); + using HttpResponseMessage response = await this + ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) + .ConfigureAwait(false); + if (!response.IsSuccessStatusCode) + { + throw new HttpException( + response.StatusCode, + await response.Content.ReadAsStringAsync().ConfigureAwait(false) + ); + } + + return JsonSerializer.Deserialize( + await response.Content.ReadAsStreamAsync().ConfigureAwait(false), + ModelBase.SerializerOptions + ) ?? throw new NullReferenceException(); + } + + public async Task Delete(FolderDeleteParams parameters) + { + using HttpRequestMessage request = new(HttpMethod.Delete, parameters.Url(this._client)) + { + Content = parameters.BodyContent(), + }; + parameters.AddHeadersToRequest(request, this._client); + using HttpResponseMessage response = await this + ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) + .ConfigureAwait(false); + if (!response.IsSuccessStatusCode) + { + throw new HttpException( + response.StatusCode, + await response.Content.ReadAsStringAsync().ConfigureAwait(false) + ); + } + + return JsonSerializer.Deserialize( + await response.Content.ReadAsStreamAsync().ConfigureAwait(false), + ModelBase.SerializerOptions + ) ?? throw new NullReferenceException(); + } + + public async Task Copy(FolderCopyParams parameters) + { + using HttpRequestMessage request = new(HttpMethod.Post, parameters.Url(this._client)) + { + Content = parameters.BodyContent(), + }; + parameters.AddHeadersToRequest(request, this._client); + using HttpResponseMessage response = await this + ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) + .ConfigureAwait(false); + if (!response.IsSuccessStatusCode) + { + throw new HttpException( + response.StatusCode, + await response.Content.ReadAsStringAsync().ConfigureAwait(false) + ); + } + + return JsonSerializer.Deserialize( + await response.Content.ReadAsStreamAsync().ConfigureAwait(false), + ModelBase.SerializerOptions + ) ?? throw new NullReferenceException(); + } + + public async Task Move(FolderMoveParams parameters) + { + using HttpRequestMessage request = new(HttpMethod.Post, parameters.Url(this._client)) + { + Content = parameters.BodyContent(), + }; + parameters.AddHeadersToRequest(request, this._client); + using HttpResponseMessage response = await this + ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) + .ConfigureAwait(false); + if (!response.IsSuccessStatusCode) + { + throw new HttpException( + response.StatusCode, + await response.Content.ReadAsStringAsync().ConfigureAwait(false) + ); + } + + return JsonSerializer.Deserialize( + await response.Content.ReadAsStreamAsync().ConfigureAwait(false), + ModelBase.SerializerOptions + ) ?? throw new NullReferenceException(); + } + + public async Task Rename(FolderRenameParams parameters) + { + using HttpRequestMessage request = new(HttpMethod.Post, parameters.Url(this._client)) + { + Content = parameters.BodyContent(), + }; + parameters.AddHeadersToRequest(request, this._client); + using HttpResponseMessage response = await this + ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) + .ConfigureAwait(false); + if (!response.IsSuccessStatusCode) + { + throw new HttpException( + response.StatusCode, + await response.Content.ReadAsStringAsync().ConfigureAwait(false) + ); + } + + return JsonSerializer.Deserialize( + await response.Content.ReadAsStreamAsync().ConfigureAwait(false), + ModelBase.SerializerOptions + ) ?? throw new NullReferenceException(); + } +} diff --git a/src/Imagekit/Services/Folders/IFolderService.cs b/src/Imagekit/Services/Folders/IFolderService.cs new file mode 100644 index 00000000..da6b7be6 --- /dev/null +++ b/src/Imagekit/Services/Folders/IFolderService.cs @@ -0,0 +1,46 @@ +using System.Threading.Tasks; +using Imagekit.Models.Folders; +using Imagekit.Services.Folders.Job; + +namespace Imagekit.Services.Folders; + +public interface IFolderService +{ + IJobService Job { get; } + + /// + /// This will create a new folder. You can specify the folder name and location + /// of the parent folder where this new folder should be created. + /// + Task Create(FolderCreateParams parameters); + + /// + /// This will delete a folder and all its contents permanently. The API returns + /// an empty response. + /// + Task Delete(FolderDeleteParams parameters); + + /// + /// This will copy one folder into another. The selected folder, its nested folders, + /// files, and their versions (in `includeVersions` is set to true) are copied + /// in this operation. Note: If any file at the destination has the same name + /// as the source file, then the source file and its versions will be appended + /// to the destination file version history. + /// + Task Copy(FolderCopyParams parameters); + + /// + /// This will move one folder into another. The selected folder, its nested folders, + /// files, and their versions are moved in this operation. Note: If any file at + /// the destination has the same name as the source file, then the source file + /// and its versions will be appended to the destination file version history. + /// + Task Move(FolderMoveParams parameters); + + /// + /// This API allows you to rename an existing folder. The folder and all its nested + /// assets and sub-folders will remain unchanged, but their paths will be updated + /// to reflect the new folder name. + /// + Task Rename(FolderRenameParams parameters); +} diff --git a/src/Imagekit/Services/Folders/Job/IJobService.cs b/src/Imagekit/Services/Folders/Job/IJobService.cs new file mode 100644 index 00000000..eb919607 --- /dev/null +++ b/src/Imagekit/Services/Folders/Job/IJobService.cs @@ -0,0 +1,12 @@ +using System.Threading.Tasks; +using Imagekit.Models.Folders.Job; + +namespace Imagekit.Services.Folders.Job; + +public interface IJobService +{ + /// + /// This API returns the status of a bulk job like copy and move folder operations. + /// + Task Get(JobGetParams parameters); +} diff --git a/src/Imagekit/Services/Folders/Job/JobService.cs b/src/Imagekit/Services/Folders/Job/JobService.cs new file mode 100644 index 00000000..3530816f --- /dev/null +++ b/src/Imagekit/Services/Folders/Job/JobService.cs @@ -0,0 +1,38 @@ +using System; +using System.Net.Http; +using System.Text.Json; +using System.Threading.Tasks; +using Imagekit.Models.Folders.Job; + +namespace Imagekit.Services.Folders.Job; + +public sealed class JobService : IJobService +{ + readonly IImageKitClient _client; + + public JobService(IImageKitClient client) + { + _client = client; + } + + public async Task Get(JobGetParams parameters) + { + using HttpRequestMessage request = new(HttpMethod.Get, parameters.Url(this._client)); + parameters.AddHeadersToRequest(request, this._client); + using HttpResponseMessage response = await this + ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) + .ConfigureAwait(false); + if (!response.IsSuccessStatusCode) + { + throw new HttpException( + response.StatusCode, + await response.Content.ReadAsStringAsync().ConfigureAwait(false) + ); + } + + return JsonSerializer.Deserialize( + await response.Content.ReadAsStreamAsync().ConfigureAwait(false), + ModelBase.SerializerOptions + ) ?? throw new NullReferenceException(); + } +} diff --git a/src/Imagekit/Services/Webhooks/IWebhookService.cs b/src/Imagekit/Services/Webhooks/IWebhookService.cs new file mode 100644 index 00000000..7529d7b5 --- /dev/null +++ b/src/Imagekit/Services/Webhooks/IWebhookService.cs @@ -0,0 +1,3 @@ +namespace Imagekit.Services.Webhooks; + +public interface IWebhookService { } diff --git a/src/Imagekit/Services/Webhooks/WebhookService.cs b/src/Imagekit/Services/Webhooks/WebhookService.cs new file mode 100644 index 00000000..79912020 --- /dev/null +++ b/src/Imagekit/Services/Webhooks/WebhookService.cs @@ -0,0 +1,6 @@ +namespace Imagekit.Services.Webhooks; + +public sealed class WebhookService : IWebhookService +{ + public WebhookService(IImageKitClient client) { } +} From 64c1feb98cc33c0ae56760cd9045b64c92269a16 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 1 Sep 2025 13:50:19 +0000 Subject: [PATCH 002/129] chore: update SDK settings --- .release-please-manifest.json | 3 ++ .stats.yml | 2 +- README.md | 8 ++-- release-please-config.json | 71 +++++++++++++++++++++++++++++++++++ src/Imagekit/Imagekit.csproj | 2 +- 5 files changed, 80 insertions(+), 6 deletions(-) create mode 100644 .release-please-manifest.json create mode 100644 release-please-config.json diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 00000000..1332969b --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "0.0.1" +} \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 85924bea..5d25590d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-3d7da4b8ef2ed30aa32c4fb3e98e498e67402e91aaa5fd4c628fc080bfe82ea1.yml openapi_spec_hash: aaa50fcbccec6f2cf1165f34bc6ac886 -config_hash: 9a8f470bf5b8ed9abcbefb7a7cb68979 +config_hash: 9f8a678d9d4d06daec522e8deb49e3ad diff --git a/README.md b/README.md index cc346a5a..22709ca0 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ > > This library has not yet been exhaustively tested in production environments and may be missing some features you'd expect in a stable release. As we continue development, there may be breaking changes that require updates to your code. > -> **We'd love your feedback!** Please share any suggestions, bug reports, feature requests, or general thoughts by [filing an issue](https://www.github.com/stainless-sdks/imagekit-csharp/issues/new). +> **We'd love your feedback!** Please share any suggestions, bug reports, feature requests, or general thoughts by [filing an issue](https://www.github.com/imagekit-developer/imagekit-dotnet/issues/new). The Image Kit C# SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs) from applications written in C#. @@ -16,8 +16,8 @@ The REST API documentation can be found on [imagekit.io](https://imagekit.io/doc ## Installation ```bash -git clone git@github.com:stainless-sdks/imagekit-csharp.git -dotnet add reference imagekit-csharp/src/Imagekit +git clone git@github.com:imagekit-developer/imagekit-dotnet.git +dotnet add reference imagekit-dotnet/src/Imagekit ``` ## Requirements @@ -99,4 +99,4 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience. -We are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/imagekit-csharp/issues) with questions, bugs, or suggestions. +We are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-dotnet/issues) with questions, bugs, or suggestions. diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 00000000..66eb8d5c --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,71 @@ +{ + "packages": { + ".": {} + }, + "$schema": "https://raw.githubusercontent.com/stainless-api/release-please/main/schemas/config.json", + "include-v-in-tag": true, + "include-component-in-tag": false, + "versioning": "prerelease", + "prerelease": true, + "bump-minor-pre-major": true, + "bump-patch-for-minor-pre-major": false, + "pull-request-header": "Automated Release PR", + "pull-request-title-pattern": "release: ${version}", + "changelog-sections": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "perf", + "section": "Performance Improvements" + }, + { + "type": "revert", + "section": "Reverts" + }, + { + "type": "chore", + "section": "Chores" + }, + { + "type": "docs", + "section": "Documentation" + }, + { + "type": "style", + "section": "Styles" + }, + { + "type": "refactor", + "section": "Refactors" + }, + { + "type": "test", + "section": "Tests", + "hidden": true + }, + { + "type": "build", + "section": "Build System" + }, + { + "type": "ci", + "section": "Continuous Integration", + "hidden": true + } + ], + "release-type": "simple", + "extra-files": [ + "README.md", + { + "type": "xml", + "path": "src/Imagekit/Imagekit.csproj", + "xpath": "//Project/PropertyGroup/VersionPrefix" + } + ] +} \ No newline at end of file diff --git a/src/Imagekit/Imagekit.csproj b/src/Imagekit/Imagekit.csproj index 042a3402..0d709b38 100644 --- a/src/Imagekit/Imagekit.csproj +++ b/src/Imagekit/Imagekit.csproj @@ -12,7 +12,7 @@ true README.md - https://www.github.com/stainless-sdks/imagekit-csharp + https://www.github.com/imagekit-developer/imagekit-dotnet git true From 4fd98595c03f4ba256e80d5c85ca7919c5d981f8 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 28 Jan 2026 16:03:56 +0000 Subject: [PATCH 003/129] feat(api): add BaseWebhookEvent --- .stats.yml | 6 +- .../Webhooks/UnsafeUnwrapWebhookEvent.cs | 728 +++++++++--------- .../UnsafeUnwrapWebhookEventVariants/All.cs | 326 ++++---- .../Models/Webhooks/UnwrapWebhookEvent.cs | 676 ++++++++-------- .../UnwrapWebhookEventVariants/All.cs | 326 ++++---- .../Webhooks/UploadPostTransformErrorEvent.cs | 290 +++---- .../UploadPostTransformSuccessEvent.cs | 292 +++---- .../Webhooks/UploadPreTransformErrorEvent.cs | 290 +++---- .../UploadPreTransformSuccessEvent.cs | 298 +++---- .../VideoTransformationAcceptedEvent.cs | 298 +++---- .../Webhooks/VideoTransformationErrorEvent.cs | 300 ++++---- .../Webhooks/VideoTransformationReadyEvent.cs | 344 ++++----- 12 files changed, 2087 insertions(+), 2087 deletions(-) diff --git a/.stats.yml b/.stats.yml index 5d25590d..08185446 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-3d7da4b8ef2ed30aa32c4fb3e98e498e67402e91aaa5fd4c628fc080bfe82ea1.yml -openapi_spec_hash: aaa50fcbccec6f2cf1165f34bc6ac886 -config_hash: 9f8a678d9d4d06daec522e8deb49e3ad +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-667f7f4988b44bc587d6eb9960ff5c8326e9f7e9b072f3f724f9f54166eff8b1.yml +openapi_spec_hash: f2081864a4abee0480e5ff991b4c936a +config_hash: 4e73c7e12a531edcd1366dab7eccc360 diff --git a/src/Imagekit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs b/src/Imagekit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs index a837e3d1..b354e2f8 100644 --- a/src/Imagekit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs +++ b/src/Imagekit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs @@ -1,364 +1,364 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using UnsafeUnwrapWebhookEventVariants = Imagekit.Models.Webhooks.UnsafeUnwrapWebhookEventVariants; - -namespace Imagekit.Models.Webhooks; - -/// -/// Triggered when a new video transformation request is accepted for processing. -/// This event confirms that ImageKit has received and queued your transformation -/// request. Use this for debugging and tracking transformation lifecycle. -/// -[JsonConverter(typeof(UnsafeUnwrapWebhookEventConverter))] -public abstract record class UnsafeUnwrapWebhookEvent -{ - internal UnsafeUnwrapWebhookEvent() { } - - public static implicit operator UnsafeUnwrapWebhookEvent( - VideoTransformationAcceptedEvent value - ) => new UnsafeUnwrapWebhookEventVariants::VideoTransformationAcceptedEvent(value); - - public static implicit operator UnsafeUnwrapWebhookEvent(VideoTransformationReadyEvent value) => - new UnsafeUnwrapWebhookEventVariants::VideoTransformationReadyEvent(value); - - public static implicit operator UnsafeUnwrapWebhookEvent(VideoTransformationErrorEvent value) => - new UnsafeUnwrapWebhookEventVariants::VideoTransformationErrorEvent(value); - - public static implicit operator UnsafeUnwrapWebhookEvent( - UploadPreTransformSuccessEvent value - ) => new UnsafeUnwrapWebhookEventVariants::UploadPreTransformSuccessEvent(value); - - public static implicit operator UnsafeUnwrapWebhookEvent(UploadPreTransformErrorEvent value) => - new UnsafeUnwrapWebhookEventVariants::UploadPreTransformErrorEvent(value); - - public static implicit operator UnsafeUnwrapWebhookEvent( - UploadPostTransformSuccessEvent value - ) => new UnsafeUnwrapWebhookEventVariants::UploadPostTransformSuccessEvent(value); - - public static implicit operator UnsafeUnwrapWebhookEvent(UploadPostTransformErrorEvent value) => - new UnsafeUnwrapWebhookEventVariants::UploadPostTransformErrorEvent(value); - - public bool TryPickVideoTransformationAccepted( - [NotNullWhen(true)] out VideoTransformationAcceptedEvent? value - ) - { - value = (this as UnsafeUnwrapWebhookEventVariants::VideoTransformationAcceptedEvent)?.Value; - return value != null; - } - - public bool TryPickVideoTransformationReady( - [NotNullWhen(true)] out VideoTransformationReadyEvent? value - ) - { - value = (this as UnsafeUnwrapWebhookEventVariants::VideoTransformationReadyEvent)?.Value; - return value != null; - } - - public bool TryPickVideoTransformationError( - [NotNullWhen(true)] out VideoTransformationErrorEvent? value - ) - { - value = (this as UnsafeUnwrapWebhookEventVariants::VideoTransformationErrorEvent)?.Value; - return value != null; - } - - public bool TryPickUploadPreTransformSuccess( - [NotNullWhen(true)] out UploadPreTransformSuccessEvent? value - ) - { - value = (this as UnsafeUnwrapWebhookEventVariants::UploadPreTransformSuccessEvent)?.Value; - return value != null; - } - - public bool TryPickUploadPreTransformError( - [NotNullWhen(true)] out UploadPreTransformErrorEvent? value - ) - { - value = (this as UnsafeUnwrapWebhookEventVariants::UploadPreTransformErrorEvent)?.Value; - return value != null; - } - - public bool TryPickUploadPostTransformSuccess( - [NotNullWhen(true)] out UploadPostTransformSuccessEvent? value - ) - { - value = (this as UnsafeUnwrapWebhookEventVariants::UploadPostTransformSuccessEvent)?.Value; - return value != null; - } - - public bool TryPickUploadPostTransformError( - [NotNullWhen(true)] out UploadPostTransformErrorEvent? value - ) - { - value = (this as UnsafeUnwrapWebhookEventVariants::UploadPostTransformErrorEvent)?.Value; - return value != null; - } - - public void Switch( - Action videoTransformationAccepted, - Action videoTransformationReady, - Action videoTransformationError, - Action uploadPreTransformSuccess, - Action uploadPreTransformError, - Action uploadPostTransformSuccess, - Action uploadPostTransformError - ) - { - switch (this) - { - case UnsafeUnwrapWebhookEventVariants::VideoTransformationAcceptedEvent inner: - videoTransformationAccepted(inner); - break; - case UnsafeUnwrapWebhookEventVariants::VideoTransformationReadyEvent inner: - videoTransformationReady(inner); - break; - case UnsafeUnwrapWebhookEventVariants::VideoTransformationErrorEvent inner: - videoTransformationError(inner); - break; - case UnsafeUnwrapWebhookEventVariants::UploadPreTransformSuccessEvent inner: - uploadPreTransformSuccess(inner); - break; - case UnsafeUnwrapWebhookEventVariants::UploadPreTransformErrorEvent inner: - uploadPreTransformError(inner); - break; - case UnsafeUnwrapWebhookEventVariants::UploadPostTransformSuccessEvent inner: - uploadPostTransformSuccess(inner); - break; - case UnsafeUnwrapWebhookEventVariants::UploadPostTransformErrorEvent inner: - uploadPostTransformError(inner); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match( - Func< - UnsafeUnwrapWebhookEventVariants::VideoTransformationAcceptedEvent, - T - > videoTransformationAccepted, - Func< - UnsafeUnwrapWebhookEventVariants::VideoTransformationReadyEvent, - T - > videoTransformationReady, - Func< - UnsafeUnwrapWebhookEventVariants::VideoTransformationErrorEvent, - T - > videoTransformationError, - Func< - UnsafeUnwrapWebhookEventVariants::UploadPreTransformSuccessEvent, - T - > uploadPreTransformSuccess, - Func< - UnsafeUnwrapWebhookEventVariants::UploadPreTransformErrorEvent, - T - > uploadPreTransformError, - Func< - UnsafeUnwrapWebhookEventVariants::UploadPostTransformSuccessEvent, - T - > uploadPostTransformSuccess, - Func< - UnsafeUnwrapWebhookEventVariants::UploadPostTransformErrorEvent, - T - > uploadPostTransformError - ) - { - return this switch - { - UnsafeUnwrapWebhookEventVariants::VideoTransformationAcceptedEvent inner => - videoTransformationAccepted(inner), - UnsafeUnwrapWebhookEventVariants::VideoTransformationReadyEvent inner => - videoTransformationReady(inner), - UnsafeUnwrapWebhookEventVariants::VideoTransformationErrorEvent inner => - videoTransformationError(inner), - UnsafeUnwrapWebhookEventVariants::UploadPreTransformSuccessEvent inner => - uploadPreTransformSuccess(inner), - UnsafeUnwrapWebhookEventVariants::UploadPreTransformErrorEvent inner => - uploadPreTransformError(inner), - UnsafeUnwrapWebhookEventVariants::UploadPostTransformSuccessEvent inner => - uploadPostTransformSuccess(inner), - UnsafeUnwrapWebhookEventVariants::UploadPostTransformErrorEvent inner => - uploadPostTransformError(inner), - _ => throw new InvalidOperationException(), - }; - } - - public abstract void Validate(); -} - -sealed class UnsafeUnwrapWebhookEventConverter : JsonConverter -{ - public override UnsafeUnwrapWebhookEvent? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize( - ref reader, - options - ); - if (deserialized != null) - { - return new UnsafeUnwrapWebhookEventVariants::VideoTransformationAcceptedEvent( - deserialized - ); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - try - { - var deserialized = JsonSerializer.Deserialize( - ref reader, - options - ); - if (deserialized != null) - { - return new UnsafeUnwrapWebhookEventVariants::VideoTransformationReadyEvent( - deserialized - ); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - try - { - var deserialized = JsonSerializer.Deserialize( - ref reader, - options - ); - if (deserialized != null) - { - return new UnsafeUnwrapWebhookEventVariants::VideoTransformationErrorEvent( - deserialized - ); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - try - { - var deserialized = JsonSerializer.Deserialize( - ref reader, - options - ); - if (deserialized != null) - { - return new UnsafeUnwrapWebhookEventVariants::UploadPreTransformSuccessEvent( - deserialized - ); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - try - { - var deserialized = JsonSerializer.Deserialize( - ref reader, - options - ); - if (deserialized != null) - { - return new UnsafeUnwrapWebhookEventVariants::UploadPreTransformErrorEvent( - deserialized - ); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - try - { - var deserialized = JsonSerializer.Deserialize( - ref reader, - options - ); - if (deserialized != null) - { - return new UnsafeUnwrapWebhookEventVariants::UploadPostTransformSuccessEvent( - deserialized - ); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - try - { - var deserialized = JsonSerializer.Deserialize( - ref reader, - options - ); - if (deserialized != null) - { - return new UnsafeUnwrapWebhookEventVariants::UploadPostTransformErrorEvent( - deserialized - ); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - - public override void Write( - Utf8JsonWriter writer, - UnsafeUnwrapWebhookEvent value, - JsonSerializerOptions options - ) - { - object variant = value switch - { - UnsafeUnwrapWebhookEventVariants::VideoTransformationAcceptedEvent( - var videoTransformationAccepted - ) => videoTransformationAccepted, - UnsafeUnwrapWebhookEventVariants::VideoTransformationReadyEvent( - var videoTransformationReady - ) => videoTransformationReady, - UnsafeUnwrapWebhookEventVariants::VideoTransformationErrorEvent( - var videoTransformationError - ) => videoTransformationError, - UnsafeUnwrapWebhookEventVariants::UploadPreTransformSuccessEvent( - var uploadPreTransformSuccess - ) => uploadPreTransformSuccess, - UnsafeUnwrapWebhookEventVariants::UploadPreTransformErrorEvent( - var uploadPreTransformError - ) => uploadPreTransformError, - UnsafeUnwrapWebhookEventVariants::UploadPostTransformSuccessEvent( - var uploadPostTransformSuccess - ) => uploadPostTransformSuccess, - UnsafeUnwrapWebhookEventVariants::UploadPostTransformErrorEvent( - var uploadPostTransformError - ) => uploadPostTransformError, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using UnsafeUnwrapWebhookEventVariants = Imagekit.Models.Webhooks.UnsafeUnwrapWebhookEventVariants; + +namespace Imagekit.Models.Webhooks; + +/// +/// Triggered when a new video transformation request is accepted for processing. +/// This event confirms that ImageKit has received and queued your transformation +/// request. Use this for debugging and tracking transformation lifecycle. +/// +[JsonConverter(typeof(UnsafeUnwrapWebhookEventConverter))] +public abstract record class UnsafeUnwrapWebhookEvent +{ + internal UnsafeUnwrapWebhookEvent() { } + + public static implicit operator UnsafeUnwrapWebhookEvent( + VideoTransformationAcceptedEvent value + ) => new UnsafeUnwrapWebhookEventVariants::VideoTransformationAcceptedEvent(value); + + public static implicit operator UnsafeUnwrapWebhookEvent(VideoTransformationReadyEvent value) => + new UnsafeUnwrapWebhookEventVariants::VideoTransformationReadyEvent(value); + + public static implicit operator UnsafeUnwrapWebhookEvent(VideoTransformationErrorEvent value) => + new UnsafeUnwrapWebhookEventVariants::VideoTransformationErrorEvent(value); + + public static implicit operator UnsafeUnwrapWebhookEvent( + UploadPreTransformSuccessEvent value + ) => new UnsafeUnwrapWebhookEventVariants::UploadPreTransformSuccessEvent(value); + + public static implicit operator UnsafeUnwrapWebhookEvent(UploadPreTransformErrorEvent value) => + new UnsafeUnwrapWebhookEventVariants::UploadPreTransformErrorEvent(value); + + public static implicit operator UnsafeUnwrapWebhookEvent( + UploadPostTransformSuccessEvent value + ) => new UnsafeUnwrapWebhookEventVariants::UploadPostTransformSuccessEvent(value); + + public static implicit operator UnsafeUnwrapWebhookEvent(UploadPostTransformErrorEvent value) => + new UnsafeUnwrapWebhookEventVariants::UploadPostTransformErrorEvent(value); + + public bool TryPickVideoTransformationAccepted( + [NotNullWhen(true)] out VideoTransformationAcceptedEvent? value + ) + { + value = (this as UnsafeUnwrapWebhookEventVariants::VideoTransformationAcceptedEvent)?.Value; + return value != null; + } + + public bool TryPickVideoTransformationReady( + [NotNullWhen(true)] out VideoTransformationReadyEvent? value + ) + { + value = (this as UnsafeUnwrapWebhookEventVariants::VideoTransformationReadyEvent)?.Value; + return value != null; + } + + public bool TryPickVideoTransformationError( + [NotNullWhen(true)] out VideoTransformationErrorEvent? value + ) + { + value = (this as UnsafeUnwrapWebhookEventVariants::VideoTransformationErrorEvent)?.Value; + return value != null; + } + + public bool TryPickUploadPreTransformSuccess( + [NotNullWhen(true)] out UploadPreTransformSuccessEvent? value + ) + { + value = (this as UnsafeUnwrapWebhookEventVariants::UploadPreTransformSuccessEvent)?.Value; + return value != null; + } + + public bool TryPickUploadPreTransformError( + [NotNullWhen(true)] out UploadPreTransformErrorEvent? value + ) + { + value = (this as UnsafeUnwrapWebhookEventVariants::UploadPreTransformErrorEvent)?.Value; + return value != null; + } + + public bool TryPickUploadPostTransformSuccess( + [NotNullWhen(true)] out UploadPostTransformSuccessEvent? value + ) + { + value = (this as UnsafeUnwrapWebhookEventVariants::UploadPostTransformSuccessEvent)?.Value; + return value != null; + } + + public bool TryPickUploadPostTransformError( + [NotNullWhen(true)] out UploadPostTransformErrorEvent? value + ) + { + value = (this as UnsafeUnwrapWebhookEventVariants::UploadPostTransformErrorEvent)?.Value; + return value != null; + } + + public void Switch( + Action videoTransformationAccepted, + Action videoTransformationReady, + Action videoTransformationError, + Action uploadPreTransformSuccess, + Action uploadPreTransformError, + Action uploadPostTransformSuccess, + Action uploadPostTransformError + ) + { + switch (this) + { + case UnsafeUnwrapWebhookEventVariants::VideoTransformationAcceptedEvent inner: + videoTransformationAccepted(inner); + break; + case UnsafeUnwrapWebhookEventVariants::VideoTransformationReadyEvent inner: + videoTransformationReady(inner); + break; + case UnsafeUnwrapWebhookEventVariants::VideoTransformationErrorEvent inner: + videoTransformationError(inner); + break; + case UnsafeUnwrapWebhookEventVariants::UploadPreTransformSuccessEvent inner: + uploadPreTransformSuccess(inner); + break; + case UnsafeUnwrapWebhookEventVariants::UploadPreTransformErrorEvent inner: + uploadPreTransformError(inner); + break; + case UnsafeUnwrapWebhookEventVariants::UploadPostTransformSuccessEvent inner: + uploadPostTransformSuccess(inner); + break; + case UnsafeUnwrapWebhookEventVariants::UploadPostTransformErrorEvent inner: + uploadPostTransformError(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func< + UnsafeUnwrapWebhookEventVariants::VideoTransformationAcceptedEvent, + T + > videoTransformationAccepted, + Func< + UnsafeUnwrapWebhookEventVariants::VideoTransformationReadyEvent, + T + > videoTransformationReady, + Func< + UnsafeUnwrapWebhookEventVariants::VideoTransformationErrorEvent, + T + > videoTransformationError, + Func< + UnsafeUnwrapWebhookEventVariants::UploadPreTransformSuccessEvent, + T + > uploadPreTransformSuccess, + Func< + UnsafeUnwrapWebhookEventVariants::UploadPreTransformErrorEvent, + T + > uploadPreTransformError, + Func< + UnsafeUnwrapWebhookEventVariants::UploadPostTransformSuccessEvent, + T + > uploadPostTransformSuccess, + Func< + UnsafeUnwrapWebhookEventVariants::UploadPostTransformErrorEvent, + T + > uploadPostTransformError + ) + { + return this switch + { + UnsafeUnwrapWebhookEventVariants::VideoTransformationAcceptedEvent inner => + videoTransformationAccepted(inner), + UnsafeUnwrapWebhookEventVariants::VideoTransformationReadyEvent inner => + videoTransformationReady(inner), + UnsafeUnwrapWebhookEventVariants::VideoTransformationErrorEvent inner => + videoTransformationError(inner), + UnsafeUnwrapWebhookEventVariants::UploadPreTransformSuccessEvent inner => + uploadPreTransformSuccess(inner), + UnsafeUnwrapWebhookEventVariants::UploadPreTransformErrorEvent inner => + uploadPreTransformError(inner), + UnsafeUnwrapWebhookEventVariants::UploadPostTransformSuccessEvent inner => + uploadPostTransformSuccess(inner), + UnsafeUnwrapWebhookEventVariants::UploadPostTransformErrorEvent inner => + uploadPostTransformError(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class UnsafeUnwrapWebhookEventConverter : JsonConverter +{ + public override UnsafeUnwrapWebhookEvent? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize( + ref reader, + options + ); + if (deserialized != null) + { + return new UnsafeUnwrapWebhookEventVariants::VideoTransformationAcceptedEvent( + deserialized + ); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize( + ref reader, + options + ); + if (deserialized != null) + { + return new UnsafeUnwrapWebhookEventVariants::VideoTransformationReadyEvent( + deserialized + ); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize( + ref reader, + options + ); + if (deserialized != null) + { + return new UnsafeUnwrapWebhookEventVariants::VideoTransformationErrorEvent( + deserialized + ); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize( + ref reader, + options + ); + if (deserialized != null) + { + return new UnsafeUnwrapWebhookEventVariants::UploadPreTransformSuccessEvent( + deserialized + ); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize( + ref reader, + options + ); + if (deserialized != null) + { + return new UnsafeUnwrapWebhookEventVariants::UploadPreTransformErrorEvent( + deserialized + ); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize( + ref reader, + options + ); + if (deserialized != null) + { + return new UnsafeUnwrapWebhookEventVariants::UploadPostTransformSuccessEvent( + deserialized + ); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize( + ref reader, + options + ); + if (deserialized != null) + { + return new UnsafeUnwrapWebhookEventVariants::UploadPostTransformErrorEvent( + deserialized + ); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + + public override void Write( + Utf8JsonWriter writer, + UnsafeUnwrapWebhookEvent value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + UnsafeUnwrapWebhookEventVariants::VideoTransformationAcceptedEvent( + var videoTransformationAccepted + ) => videoTransformationAccepted, + UnsafeUnwrapWebhookEventVariants::VideoTransformationReadyEvent( + var videoTransformationReady + ) => videoTransformationReady, + UnsafeUnwrapWebhookEventVariants::VideoTransformationErrorEvent( + var videoTransformationError + ) => videoTransformationError, + UnsafeUnwrapWebhookEventVariants::UploadPreTransformSuccessEvent( + var uploadPreTransformSuccess + ) => uploadPreTransformSuccess, + UnsafeUnwrapWebhookEventVariants::UploadPreTransformErrorEvent( + var uploadPreTransformError + ) => uploadPreTransformError, + UnsafeUnwrapWebhookEventVariants::UploadPostTransformSuccessEvent( + var uploadPostTransformSuccess + ) => uploadPostTransformSuccess, + UnsafeUnwrapWebhookEventVariants::UploadPostTransformErrorEvent( + var uploadPostTransformError + ) => uploadPostTransformError, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Webhooks/UnsafeUnwrapWebhookEventVariants/All.cs b/src/Imagekit/Models/Webhooks/UnsafeUnwrapWebhookEventVariants/All.cs index b8e8a816..e5062b4a 100644 --- a/src/Imagekit/Models/Webhooks/UnsafeUnwrapWebhookEventVariants/All.cs +++ b/src/Imagekit/Models/Webhooks/UnsafeUnwrapWebhookEventVariants/All.cs @@ -1,163 +1,163 @@ -using Webhooks = Imagekit.Models.Webhooks; - -namespace Imagekit.Models.Webhooks.UnsafeUnwrapWebhookEventVariants; - -/// -/// Triggered when a new video transformation request is accepted for processing. -/// This event confirms that ImageKit has received and queued your transformation -/// request. Use this for debugging and tracking transformation lifecycle. -/// -public sealed record class VideoTransformationAcceptedEvent( - Webhooks::VideoTransformationAcceptedEvent Value -) - : Webhooks::UnsafeUnwrapWebhookEvent, - IVariant -{ - public static VideoTransformationAcceptedEvent From( - Webhooks::VideoTransformationAcceptedEvent value - ) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -/// -/// Triggered when video encoding is finished and the transformed resource is ready -/// to be served. This is the key event to listen for - update your database or CMS -/// flags when you receive this so your application can start showing the transformed -/// video to users. -/// -public sealed record class VideoTransformationReadyEvent( - Webhooks::VideoTransformationReadyEvent Value -) - : Webhooks::UnsafeUnwrapWebhookEvent, - IVariant -{ - public static VideoTransformationReadyEvent From(Webhooks::VideoTransformationReadyEvent value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -/// -/// Triggered when an error occurs during video encoding. Listen to this webhook to -/// log error reasons and debug issues. Check your origin and URL endpoint settings -/// if the reason is related to download failure. For other errors, contact ImageKit -/// support. -/// -public sealed record class VideoTransformationErrorEvent( - Webhooks::VideoTransformationErrorEvent Value -) - : Webhooks::UnsafeUnwrapWebhookEvent, - IVariant -{ - public static VideoTransformationErrorEvent From(Webhooks::VideoTransformationErrorEvent value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -/// -/// Triggered when a pre-transformation completes successfully. The file has been -/// processed with the requested transformation and is now available in the Media -/// Library. -/// -public sealed record class UploadPreTransformSuccessEvent( - Webhooks::UploadPreTransformSuccessEvent Value -) - : Webhooks::UnsafeUnwrapWebhookEvent, - IVariant -{ - public static UploadPreTransformSuccessEvent From( - Webhooks::UploadPreTransformSuccessEvent value - ) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -/// -/// Triggered when a pre-transformation fails. The file upload may have been accepted, -/// but the requested transformation could not be applied. -/// -public sealed record class UploadPreTransformErrorEvent( - Webhooks::UploadPreTransformErrorEvent Value -) - : Webhooks::UnsafeUnwrapWebhookEvent, - IVariant -{ - public static UploadPreTransformErrorEvent From(Webhooks::UploadPreTransformErrorEvent value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -/// -/// Triggered when a post-transformation completes successfully. The transformed version -/// of the file is now ready and can be accessed via the provided URL. Note that -/// each post-transformation generates a separate webhook event. -/// -public sealed record class UploadPostTransformSuccessEvent( - Webhooks::UploadPostTransformSuccessEvent Value -) - : Webhooks::UnsafeUnwrapWebhookEvent, - IVariant -{ - public static UploadPostTransformSuccessEvent From( - Webhooks::UploadPostTransformSuccessEvent value - ) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -/// -/// Triggered when a post-transformation fails. The original file remains available, -/// but the requested transformation could not be generated. -/// -public sealed record class UploadPostTransformErrorEvent( - Webhooks::UploadPostTransformErrorEvent Value -) - : Webhooks::UnsafeUnwrapWebhookEvent, - IVariant -{ - public static UploadPostTransformErrorEvent From(Webhooks::UploadPostTransformErrorEvent value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} +using Webhooks = Imagekit.Models.Webhooks; + +namespace Imagekit.Models.Webhooks.UnsafeUnwrapWebhookEventVariants; + +/// +/// Triggered when a new video transformation request is accepted for processing. +/// This event confirms that ImageKit has received and queued your transformation +/// request. Use this for debugging and tracking transformation lifecycle. +/// +public sealed record class VideoTransformationAcceptedEvent( + Webhooks::VideoTransformationAcceptedEvent Value +) + : Webhooks::UnsafeUnwrapWebhookEvent, + IVariant +{ + public static VideoTransformationAcceptedEvent From( + Webhooks::VideoTransformationAcceptedEvent value + ) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +/// +/// Triggered when video encoding is finished and the transformed resource is ready +/// to be served. This is the key event to listen for - update your database or CMS +/// flags when you receive this so your application can start showing the transformed +/// video to users. +/// +public sealed record class VideoTransformationReadyEvent( + Webhooks::VideoTransformationReadyEvent Value +) + : Webhooks::UnsafeUnwrapWebhookEvent, + IVariant +{ + public static VideoTransformationReadyEvent From(Webhooks::VideoTransformationReadyEvent value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +/// +/// Triggered when an error occurs during video encoding. Listen to this webhook to +/// log error reasons and debug issues. Check your origin and URL endpoint settings +/// if the reason is related to download failure. For other errors, contact ImageKit +/// support. +/// +public sealed record class VideoTransformationErrorEvent( + Webhooks::VideoTransformationErrorEvent Value +) + : Webhooks::UnsafeUnwrapWebhookEvent, + IVariant +{ + public static VideoTransformationErrorEvent From(Webhooks::VideoTransformationErrorEvent value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +/// +/// Triggered when a pre-transformation completes successfully. The file has been +/// processed with the requested transformation and is now available in the Media +/// Library. +/// +public sealed record class UploadPreTransformSuccessEvent( + Webhooks::UploadPreTransformSuccessEvent Value +) + : Webhooks::UnsafeUnwrapWebhookEvent, + IVariant +{ + public static UploadPreTransformSuccessEvent From( + Webhooks::UploadPreTransformSuccessEvent value + ) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +/// +/// Triggered when a pre-transformation fails. The file upload may have been accepted, +/// but the requested transformation could not be applied. +/// +public sealed record class UploadPreTransformErrorEvent( + Webhooks::UploadPreTransformErrorEvent Value +) + : Webhooks::UnsafeUnwrapWebhookEvent, + IVariant +{ + public static UploadPreTransformErrorEvent From(Webhooks::UploadPreTransformErrorEvent value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +/// +/// Triggered when a post-transformation completes successfully. The transformed version +/// of the file is now ready and can be accessed via the provided URL. Note that +/// each post-transformation generates a separate webhook event. +/// +public sealed record class UploadPostTransformSuccessEvent( + Webhooks::UploadPostTransformSuccessEvent Value +) + : Webhooks::UnsafeUnwrapWebhookEvent, + IVariant +{ + public static UploadPostTransformSuccessEvent From( + Webhooks::UploadPostTransformSuccessEvent value + ) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +/// +/// Triggered when a post-transformation fails. The original file remains available, +/// but the requested transformation could not be generated. +/// +public sealed record class UploadPostTransformErrorEvent( + Webhooks::UploadPostTransformErrorEvent Value +) + : Webhooks::UnsafeUnwrapWebhookEvent, + IVariant +{ + public static UploadPostTransformErrorEvent From(Webhooks::UploadPostTransformErrorEvent value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} diff --git a/src/Imagekit/Models/Webhooks/UnwrapWebhookEvent.cs b/src/Imagekit/Models/Webhooks/UnwrapWebhookEvent.cs index fbecd090..c3c85e33 100644 --- a/src/Imagekit/Models/Webhooks/UnwrapWebhookEvent.cs +++ b/src/Imagekit/Models/Webhooks/UnwrapWebhookEvent.cs @@ -1,338 +1,338 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using UnwrapWebhookEventVariants = Imagekit.Models.Webhooks.UnwrapWebhookEventVariants; - -namespace Imagekit.Models.Webhooks; - -/// -/// Triggered when a new video transformation request is accepted for processing. -/// This event confirms that ImageKit has received and queued your transformation -/// request. Use this for debugging and tracking transformation lifecycle. -/// -[JsonConverter(typeof(UnwrapWebhookEventConverter))] -public abstract record class UnwrapWebhookEvent -{ - internal UnwrapWebhookEvent() { } - - public static implicit operator UnwrapWebhookEvent(VideoTransformationAcceptedEvent value) => - new UnwrapWebhookEventVariants::VideoTransformationAcceptedEvent(value); - - public static implicit operator UnwrapWebhookEvent(VideoTransformationReadyEvent value) => - new UnwrapWebhookEventVariants::VideoTransformationReadyEvent(value); - - public static implicit operator UnwrapWebhookEvent(VideoTransformationErrorEvent value) => - new UnwrapWebhookEventVariants::VideoTransformationErrorEvent(value); - - public static implicit operator UnwrapWebhookEvent(UploadPreTransformSuccessEvent value) => - new UnwrapWebhookEventVariants::UploadPreTransformSuccessEvent(value); - - public static implicit operator UnwrapWebhookEvent(UploadPreTransformErrorEvent value) => - new UnwrapWebhookEventVariants::UploadPreTransformErrorEvent(value); - - public static implicit operator UnwrapWebhookEvent(UploadPostTransformSuccessEvent value) => - new UnwrapWebhookEventVariants::UploadPostTransformSuccessEvent(value); - - public static implicit operator UnwrapWebhookEvent(UploadPostTransformErrorEvent value) => - new UnwrapWebhookEventVariants::UploadPostTransformErrorEvent(value); - - public bool TryPickVideoTransformationAccepted( - [NotNullWhen(true)] out VideoTransformationAcceptedEvent? value - ) - { - value = (this as UnwrapWebhookEventVariants::VideoTransformationAcceptedEvent)?.Value; - return value != null; - } - - public bool TryPickVideoTransformationReady( - [NotNullWhen(true)] out VideoTransformationReadyEvent? value - ) - { - value = (this as UnwrapWebhookEventVariants::VideoTransformationReadyEvent)?.Value; - return value != null; - } - - public bool TryPickVideoTransformationError( - [NotNullWhen(true)] out VideoTransformationErrorEvent? value - ) - { - value = (this as UnwrapWebhookEventVariants::VideoTransformationErrorEvent)?.Value; - return value != null; - } - - public bool TryPickUploadPreTransformSuccess( - [NotNullWhen(true)] out UploadPreTransformSuccessEvent? value - ) - { - value = (this as UnwrapWebhookEventVariants::UploadPreTransformSuccessEvent)?.Value; - return value != null; - } - - public bool TryPickUploadPreTransformError( - [NotNullWhen(true)] out UploadPreTransformErrorEvent? value - ) - { - value = (this as UnwrapWebhookEventVariants::UploadPreTransformErrorEvent)?.Value; - return value != null; - } - - public bool TryPickUploadPostTransformSuccess( - [NotNullWhen(true)] out UploadPostTransformSuccessEvent? value - ) - { - value = (this as UnwrapWebhookEventVariants::UploadPostTransformSuccessEvent)?.Value; - return value != null; - } - - public bool TryPickUploadPostTransformError( - [NotNullWhen(true)] out UploadPostTransformErrorEvent? value - ) - { - value = (this as UnwrapWebhookEventVariants::UploadPostTransformErrorEvent)?.Value; - return value != null; - } - - public void Switch( - Action videoTransformationAccepted, - Action videoTransformationReady, - Action videoTransformationError, - Action uploadPreTransformSuccess, - Action uploadPreTransformError, - Action uploadPostTransformSuccess, - Action uploadPostTransformError - ) - { - switch (this) - { - case UnwrapWebhookEventVariants::VideoTransformationAcceptedEvent inner: - videoTransformationAccepted(inner); - break; - case UnwrapWebhookEventVariants::VideoTransformationReadyEvent inner: - videoTransformationReady(inner); - break; - case UnwrapWebhookEventVariants::VideoTransformationErrorEvent inner: - videoTransformationError(inner); - break; - case UnwrapWebhookEventVariants::UploadPreTransformSuccessEvent inner: - uploadPreTransformSuccess(inner); - break; - case UnwrapWebhookEventVariants::UploadPreTransformErrorEvent inner: - uploadPreTransformError(inner); - break; - case UnwrapWebhookEventVariants::UploadPostTransformSuccessEvent inner: - uploadPostTransformSuccess(inner); - break; - case UnwrapWebhookEventVariants::UploadPostTransformErrorEvent inner: - uploadPostTransformError(inner); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match( - Func< - UnwrapWebhookEventVariants::VideoTransformationAcceptedEvent, - T - > videoTransformationAccepted, - Func videoTransformationReady, - Func videoTransformationError, - Func< - UnwrapWebhookEventVariants::UploadPreTransformSuccessEvent, - T - > uploadPreTransformSuccess, - Func uploadPreTransformError, - Func< - UnwrapWebhookEventVariants::UploadPostTransformSuccessEvent, - T - > uploadPostTransformSuccess, - Func uploadPostTransformError - ) - { - return this switch - { - UnwrapWebhookEventVariants::VideoTransformationAcceptedEvent inner => - videoTransformationAccepted(inner), - UnwrapWebhookEventVariants::VideoTransformationReadyEvent inner => - videoTransformationReady(inner), - UnwrapWebhookEventVariants::VideoTransformationErrorEvent inner => - videoTransformationError(inner), - UnwrapWebhookEventVariants::UploadPreTransformSuccessEvent inner => - uploadPreTransformSuccess(inner), - UnwrapWebhookEventVariants::UploadPreTransformErrorEvent inner => - uploadPreTransformError(inner), - UnwrapWebhookEventVariants::UploadPostTransformSuccessEvent inner => - uploadPostTransformSuccess(inner), - UnwrapWebhookEventVariants::UploadPostTransformErrorEvent inner => - uploadPostTransformError(inner), - _ => throw new InvalidOperationException(), - }; - } - - public abstract void Validate(); -} - -sealed class UnwrapWebhookEventConverter : JsonConverter -{ - public override UnwrapWebhookEvent? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize( - ref reader, - options - ); - if (deserialized != null) - { - return new UnwrapWebhookEventVariants::VideoTransformationAcceptedEvent( - deserialized - ); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - try - { - var deserialized = JsonSerializer.Deserialize( - ref reader, - options - ); - if (deserialized != null) - { - return new UnwrapWebhookEventVariants::VideoTransformationReadyEvent(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - try - { - var deserialized = JsonSerializer.Deserialize( - ref reader, - options - ); - if (deserialized != null) - { - return new UnwrapWebhookEventVariants::VideoTransformationErrorEvent(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - try - { - var deserialized = JsonSerializer.Deserialize( - ref reader, - options - ); - if (deserialized != null) - { - return new UnwrapWebhookEventVariants::UploadPreTransformSuccessEvent(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - try - { - var deserialized = JsonSerializer.Deserialize( - ref reader, - options - ); - if (deserialized != null) - { - return new UnwrapWebhookEventVariants::UploadPreTransformErrorEvent(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - try - { - var deserialized = JsonSerializer.Deserialize( - ref reader, - options - ); - if (deserialized != null) - { - return new UnwrapWebhookEventVariants::UploadPostTransformSuccessEvent( - deserialized - ); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - try - { - var deserialized = JsonSerializer.Deserialize( - ref reader, - options - ); - if (deserialized != null) - { - return new UnwrapWebhookEventVariants::UploadPostTransformErrorEvent(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - - public override void Write( - Utf8JsonWriter writer, - UnwrapWebhookEvent value, - JsonSerializerOptions options - ) - { - object variant = value switch - { - UnwrapWebhookEventVariants::VideoTransformationAcceptedEvent( - var videoTransformationAccepted - ) => videoTransformationAccepted, - UnwrapWebhookEventVariants::VideoTransformationReadyEvent( - var videoTransformationReady - ) => videoTransformationReady, - UnwrapWebhookEventVariants::VideoTransformationErrorEvent( - var videoTransformationError - ) => videoTransformationError, - UnwrapWebhookEventVariants::UploadPreTransformSuccessEvent( - var uploadPreTransformSuccess - ) => uploadPreTransformSuccess, - UnwrapWebhookEventVariants::UploadPreTransformErrorEvent(var uploadPreTransformError) => - uploadPreTransformError, - UnwrapWebhookEventVariants::UploadPostTransformSuccessEvent( - var uploadPostTransformSuccess - ) => uploadPostTransformSuccess, - UnwrapWebhookEventVariants::UploadPostTransformErrorEvent( - var uploadPostTransformError - ) => uploadPostTransformError, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using UnwrapWebhookEventVariants = Imagekit.Models.Webhooks.UnwrapWebhookEventVariants; + +namespace Imagekit.Models.Webhooks; + +/// +/// Triggered when a new video transformation request is accepted for processing. +/// This event confirms that ImageKit has received and queued your transformation +/// request. Use this for debugging and tracking transformation lifecycle. +/// +[JsonConverter(typeof(UnwrapWebhookEventConverter))] +public abstract record class UnwrapWebhookEvent +{ + internal UnwrapWebhookEvent() { } + + public static implicit operator UnwrapWebhookEvent(VideoTransformationAcceptedEvent value) => + new UnwrapWebhookEventVariants::VideoTransformationAcceptedEvent(value); + + public static implicit operator UnwrapWebhookEvent(VideoTransformationReadyEvent value) => + new UnwrapWebhookEventVariants::VideoTransformationReadyEvent(value); + + public static implicit operator UnwrapWebhookEvent(VideoTransformationErrorEvent value) => + new UnwrapWebhookEventVariants::VideoTransformationErrorEvent(value); + + public static implicit operator UnwrapWebhookEvent(UploadPreTransformSuccessEvent value) => + new UnwrapWebhookEventVariants::UploadPreTransformSuccessEvent(value); + + public static implicit operator UnwrapWebhookEvent(UploadPreTransformErrorEvent value) => + new UnwrapWebhookEventVariants::UploadPreTransformErrorEvent(value); + + public static implicit operator UnwrapWebhookEvent(UploadPostTransformSuccessEvent value) => + new UnwrapWebhookEventVariants::UploadPostTransformSuccessEvent(value); + + public static implicit operator UnwrapWebhookEvent(UploadPostTransformErrorEvent value) => + new UnwrapWebhookEventVariants::UploadPostTransformErrorEvent(value); + + public bool TryPickVideoTransformationAccepted( + [NotNullWhen(true)] out VideoTransformationAcceptedEvent? value + ) + { + value = (this as UnwrapWebhookEventVariants::VideoTransformationAcceptedEvent)?.Value; + return value != null; + } + + public bool TryPickVideoTransformationReady( + [NotNullWhen(true)] out VideoTransformationReadyEvent? value + ) + { + value = (this as UnwrapWebhookEventVariants::VideoTransformationReadyEvent)?.Value; + return value != null; + } + + public bool TryPickVideoTransformationError( + [NotNullWhen(true)] out VideoTransformationErrorEvent? value + ) + { + value = (this as UnwrapWebhookEventVariants::VideoTransformationErrorEvent)?.Value; + return value != null; + } + + public bool TryPickUploadPreTransformSuccess( + [NotNullWhen(true)] out UploadPreTransformSuccessEvent? value + ) + { + value = (this as UnwrapWebhookEventVariants::UploadPreTransformSuccessEvent)?.Value; + return value != null; + } + + public bool TryPickUploadPreTransformError( + [NotNullWhen(true)] out UploadPreTransformErrorEvent? value + ) + { + value = (this as UnwrapWebhookEventVariants::UploadPreTransformErrorEvent)?.Value; + return value != null; + } + + public bool TryPickUploadPostTransformSuccess( + [NotNullWhen(true)] out UploadPostTransformSuccessEvent? value + ) + { + value = (this as UnwrapWebhookEventVariants::UploadPostTransformSuccessEvent)?.Value; + return value != null; + } + + public bool TryPickUploadPostTransformError( + [NotNullWhen(true)] out UploadPostTransformErrorEvent? value + ) + { + value = (this as UnwrapWebhookEventVariants::UploadPostTransformErrorEvent)?.Value; + return value != null; + } + + public void Switch( + Action videoTransformationAccepted, + Action videoTransformationReady, + Action videoTransformationError, + Action uploadPreTransformSuccess, + Action uploadPreTransformError, + Action uploadPostTransformSuccess, + Action uploadPostTransformError + ) + { + switch (this) + { + case UnwrapWebhookEventVariants::VideoTransformationAcceptedEvent inner: + videoTransformationAccepted(inner); + break; + case UnwrapWebhookEventVariants::VideoTransformationReadyEvent inner: + videoTransformationReady(inner); + break; + case UnwrapWebhookEventVariants::VideoTransformationErrorEvent inner: + videoTransformationError(inner); + break; + case UnwrapWebhookEventVariants::UploadPreTransformSuccessEvent inner: + uploadPreTransformSuccess(inner); + break; + case UnwrapWebhookEventVariants::UploadPreTransformErrorEvent inner: + uploadPreTransformError(inner); + break; + case UnwrapWebhookEventVariants::UploadPostTransformSuccessEvent inner: + uploadPostTransformSuccess(inner); + break; + case UnwrapWebhookEventVariants::UploadPostTransformErrorEvent inner: + uploadPostTransformError(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func< + UnwrapWebhookEventVariants::VideoTransformationAcceptedEvent, + T + > videoTransformationAccepted, + Func videoTransformationReady, + Func videoTransformationError, + Func< + UnwrapWebhookEventVariants::UploadPreTransformSuccessEvent, + T + > uploadPreTransformSuccess, + Func uploadPreTransformError, + Func< + UnwrapWebhookEventVariants::UploadPostTransformSuccessEvent, + T + > uploadPostTransformSuccess, + Func uploadPostTransformError + ) + { + return this switch + { + UnwrapWebhookEventVariants::VideoTransformationAcceptedEvent inner => + videoTransformationAccepted(inner), + UnwrapWebhookEventVariants::VideoTransformationReadyEvent inner => + videoTransformationReady(inner), + UnwrapWebhookEventVariants::VideoTransformationErrorEvent inner => + videoTransformationError(inner), + UnwrapWebhookEventVariants::UploadPreTransformSuccessEvent inner => + uploadPreTransformSuccess(inner), + UnwrapWebhookEventVariants::UploadPreTransformErrorEvent inner => + uploadPreTransformError(inner), + UnwrapWebhookEventVariants::UploadPostTransformSuccessEvent inner => + uploadPostTransformSuccess(inner), + UnwrapWebhookEventVariants::UploadPostTransformErrorEvent inner => + uploadPostTransformError(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class UnwrapWebhookEventConverter : JsonConverter +{ + public override UnwrapWebhookEvent? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize( + ref reader, + options + ); + if (deserialized != null) + { + return new UnwrapWebhookEventVariants::VideoTransformationAcceptedEvent( + deserialized + ); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize( + ref reader, + options + ); + if (deserialized != null) + { + return new UnwrapWebhookEventVariants::VideoTransformationReadyEvent(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize( + ref reader, + options + ); + if (deserialized != null) + { + return new UnwrapWebhookEventVariants::VideoTransformationErrorEvent(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize( + ref reader, + options + ); + if (deserialized != null) + { + return new UnwrapWebhookEventVariants::UploadPreTransformSuccessEvent(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize( + ref reader, + options + ); + if (deserialized != null) + { + return new UnwrapWebhookEventVariants::UploadPreTransformErrorEvent(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize( + ref reader, + options + ); + if (deserialized != null) + { + return new UnwrapWebhookEventVariants::UploadPostTransformSuccessEvent( + deserialized + ); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize( + ref reader, + options + ); + if (deserialized != null) + { + return new UnwrapWebhookEventVariants::UploadPostTransformErrorEvent(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + + public override void Write( + Utf8JsonWriter writer, + UnwrapWebhookEvent value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + UnwrapWebhookEventVariants::VideoTransformationAcceptedEvent( + var videoTransformationAccepted + ) => videoTransformationAccepted, + UnwrapWebhookEventVariants::VideoTransformationReadyEvent( + var videoTransformationReady + ) => videoTransformationReady, + UnwrapWebhookEventVariants::VideoTransformationErrorEvent( + var videoTransformationError + ) => videoTransformationError, + UnwrapWebhookEventVariants::UploadPreTransformSuccessEvent( + var uploadPreTransformSuccess + ) => uploadPreTransformSuccess, + UnwrapWebhookEventVariants::UploadPreTransformErrorEvent(var uploadPreTransformError) => + uploadPreTransformError, + UnwrapWebhookEventVariants::UploadPostTransformSuccessEvent( + var uploadPostTransformSuccess + ) => uploadPostTransformSuccess, + UnwrapWebhookEventVariants::UploadPostTransformErrorEvent( + var uploadPostTransformError + ) => uploadPostTransformError, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Webhooks/UnwrapWebhookEventVariants/All.cs b/src/Imagekit/Models/Webhooks/UnwrapWebhookEventVariants/All.cs index 2f40319f..5b97daed 100644 --- a/src/Imagekit/Models/Webhooks/UnwrapWebhookEventVariants/All.cs +++ b/src/Imagekit/Models/Webhooks/UnwrapWebhookEventVariants/All.cs @@ -1,163 +1,163 @@ -using Webhooks = Imagekit.Models.Webhooks; - -namespace Imagekit.Models.Webhooks.UnwrapWebhookEventVariants; - -/// -/// Triggered when a new video transformation request is accepted for processing. -/// This event confirms that ImageKit has received and queued your transformation -/// request. Use this for debugging and tracking transformation lifecycle. -/// -public sealed record class VideoTransformationAcceptedEvent( - Webhooks::VideoTransformationAcceptedEvent Value -) - : Webhooks::UnwrapWebhookEvent, - IVariant -{ - public static VideoTransformationAcceptedEvent From( - Webhooks::VideoTransformationAcceptedEvent value - ) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -/// -/// Triggered when video encoding is finished and the transformed resource is ready -/// to be served. This is the key event to listen for - update your database or CMS -/// flags when you receive this so your application can start showing the transformed -/// video to users. -/// -public sealed record class VideoTransformationReadyEvent( - Webhooks::VideoTransformationReadyEvent Value -) - : Webhooks::UnwrapWebhookEvent, - IVariant -{ - public static VideoTransformationReadyEvent From(Webhooks::VideoTransformationReadyEvent value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -/// -/// Triggered when an error occurs during video encoding. Listen to this webhook to -/// log error reasons and debug issues. Check your origin and URL endpoint settings -/// if the reason is related to download failure. For other errors, contact ImageKit -/// support. -/// -public sealed record class VideoTransformationErrorEvent( - Webhooks::VideoTransformationErrorEvent Value -) - : Webhooks::UnwrapWebhookEvent, - IVariant -{ - public static VideoTransformationErrorEvent From(Webhooks::VideoTransformationErrorEvent value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -/// -/// Triggered when a pre-transformation completes successfully. The file has been -/// processed with the requested transformation and is now available in the Media -/// Library. -/// -public sealed record class UploadPreTransformSuccessEvent( - Webhooks::UploadPreTransformSuccessEvent Value -) - : Webhooks::UnwrapWebhookEvent, - IVariant -{ - public static UploadPreTransformSuccessEvent From( - Webhooks::UploadPreTransformSuccessEvent value - ) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -/// -/// Triggered when a pre-transformation fails. The file upload may have been accepted, -/// but the requested transformation could not be applied. -/// -public sealed record class UploadPreTransformErrorEvent( - Webhooks::UploadPreTransformErrorEvent Value -) - : Webhooks::UnwrapWebhookEvent, - IVariant -{ - public static UploadPreTransformErrorEvent From(Webhooks::UploadPreTransformErrorEvent value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -/// -/// Triggered when a post-transformation completes successfully. The transformed version -/// of the file is now ready and can be accessed via the provided URL. Note that -/// each post-transformation generates a separate webhook event. -/// -public sealed record class UploadPostTransformSuccessEvent( - Webhooks::UploadPostTransformSuccessEvent Value -) - : Webhooks::UnwrapWebhookEvent, - IVariant -{ - public static UploadPostTransformSuccessEvent From( - Webhooks::UploadPostTransformSuccessEvent value - ) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -/// -/// Triggered when a post-transformation fails. The original file remains available, -/// but the requested transformation could not be generated. -/// -public sealed record class UploadPostTransformErrorEvent( - Webhooks::UploadPostTransformErrorEvent Value -) - : Webhooks::UnwrapWebhookEvent, - IVariant -{ - public static UploadPostTransformErrorEvent From(Webhooks::UploadPostTransformErrorEvent value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} +using Webhooks = Imagekit.Models.Webhooks; + +namespace Imagekit.Models.Webhooks.UnwrapWebhookEventVariants; + +/// +/// Triggered when a new video transformation request is accepted for processing. +/// This event confirms that ImageKit has received and queued your transformation +/// request. Use this for debugging and tracking transformation lifecycle. +/// +public sealed record class VideoTransformationAcceptedEvent( + Webhooks::VideoTransformationAcceptedEvent Value +) + : Webhooks::UnwrapWebhookEvent, + IVariant +{ + public static VideoTransformationAcceptedEvent From( + Webhooks::VideoTransformationAcceptedEvent value + ) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +/// +/// Triggered when video encoding is finished and the transformed resource is ready +/// to be served. This is the key event to listen for - update your database or CMS +/// flags when you receive this so your application can start showing the transformed +/// video to users. +/// +public sealed record class VideoTransformationReadyEvent( + Webhooks::VideoTransformationReadyEvent Value +) + : Webhooks::UnwrapWebhookEvent, + IVariant +{ + public static VideoTransformationReadyEvent From(Webhooks::VideoTransformationReadyEvent value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +/// +/// Triggered when an error occurs during video encoding. Listen to this webhook to +/// log error reasons and debug issues. Check your origin and URL endpoint settings +/// if the reason is related to download failure. For other errors, contact ImageKit +/// support. +/// +public sealed record class VideoTransformationErrorEvent( + Webhooks::VideoTransformationErrorEvent Value +) + : Webhooks::UnwrapWebhookEvent, + IVariant +{ + public static VideoTransformationErrorEvent From(Webhooks::VideoTransformationErrorEvent value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +/// +/// Triggered when a pre-transformation completes successfully. The file has been +/// processed with the requested transformation and is now available in the Media +/// Library. +/// +public sealed record class UploadPreTransformSuccessEvent( + Webhooks::UploadPreTransformSuccessEvent Value +) + : Webhooks::UnwrapWebhookEvent, + IVariant +{ + public static UploadPreTransformSuccessEvent From( + Webhooks::UploadPreTransformSuccessEvent value + ) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +/// +/// Triggered when a pre-transformation fails. The file upload may have been accepted, +/// but the requested transformation could not be applied. +/// +public sealed record class UploadPreTransformErrorEvent( + Webhooks::UploadPreTransformErrorEvent Value +) + : Webhooks::UnwrapWebhookEvent, + IVariant +{ + public static UploadPreTransformErrorEvent From(Webhooks::UploadPreTransformErrorEvent value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +/// +/// Triggered when a post-transformation completes successfully. The transformed version +/// of the file is now ready and can be accessed via the provided URL. Note that +/// each post-transformation generates a separate webhook event. +/// +public sealed record class UploadPostTransformSuccessEvent( + Webhooks::UploadPostTransformSuccessEvent Value +) + : Webhooks::UnwrapWebhookEvent, + IVariant +{ + public static UploadPostTransformSuccessEvent From( + Webhooks::UploadPostTransformSuccessEvent value + ) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +/// +/// Triggered when a post-transformation fails. The original file remains available, +/// but the requested transformation could not be generated. +/// +public sealed record class UploadPostTransformErrorEvent( + Webhooks::UploadPostTransformErrorEvent Value +) + : Webhooks::UnwrapWebhookEvent, + IVariant +{ + public static UploadPostTransformErrorEvent From(Webhooks::UploadPostTransformErrorEvent value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEvent.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEvent.cs index b1b2422e..3dea0812 100644 --- a/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEvent.cs +++ b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEvent.cs @@ -1,145 +1,145 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Webhooks.UploadPostTransformErrorEventProperties; - -namespace Imagekit.Models.Webhooks; - -/// -/// Triggered when a post-transformation fails. The original file remains available, -/// but the requested transformation could not be generated. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class UploadPostTransformErrorEvent - : ModelBase, - IFromRaw -{ - /// - /// Unique identifier for the event. - /// - public required string ID - { - get - { - if (!this.Properties.TryGetValue("id", out JsonElement element)) - throw new ArgumentOutOfRangeException("id", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("id"); - } - set - { - this.Properties["id"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Timestamp of when the event occurred in ISO8601 format. - /// - public required DateTime CreatedAt - { - get - { - if (!this.Properties.TryGetValue("created_at", out JsonElement element)) - throw new ArgumentOutOfRangeException("created_at", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["created_at"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required Data Data - { - get - { - if (!this.Properties.TryGetValue("data", out JsonElement element)) - throw new ArgumentOutOfRangeException("data", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("data"); - } - set - { - this.Properties["data"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required Request Request - { - get - { - if (!this.Properties.TryGetValue("request", out JsonElement element)) - throw new ArgumentOutOfRangeException("request", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("request"); - } - set - { - this.Properties["request"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.ID; - _ = this.CreatedAt; - this.Data.Validate(); - this.Request.Validate(); - } - - public UploadPostTransformErrorEvent() - { - this.Type = JsonSerializer.Deserialize("\"upload.post-transform.error\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - UploadPostTransformErrorEvent(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static UploadPostTransformErrorEvent FromRawUnchecked( - Dictionary properties - ) - { - return new(properties); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Webhooks.UploadPostTransformErrorEventProperties; + +namespace Imagekit.Models.Webhooks; + +/// +/// Triggered when a post-transformation fails. The original file remains available, +/// but the requested transformation could not be generated. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class UploadPostTransformErrorEvent + : ModelBase, + IFromRaw +{ + /// + /// Unique identifier for the event. + /// + public required string ID + { + get + { + if (!this.Properties.TryGetValue("id", out JsonElement element)) + throw new ArgumentOutOfRangeException("id", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("id"); + } + set + { + this.Properties["id"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Timestamp of when the event occurred in ISO8601 format. + /// + public required DateTime CreatedAt + { + get + { + if (!this.Properties.TryGetValue("created_at", out JsonElement element)) + throw new ArgumentOutOfRangeException("created_at", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["created_at"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required Data Data + { + get + { + if (!this.Properties.TryGetValue("data", out JsonElement element)) + throw new ArgumentOutOfRangeException("data", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("data"); + } + set + { + this.Properties["data"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required Request Request + { + get + { + if (!this.Properties.TryGetValue("request", out JsonElement element)) + throw new ArgumentOutOfRangeException("request", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("request"); + } + set + { + this.Properties["request"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.ID; + _ = this.CreatedAt; + this.Data.Validate(); + this.Request.Validate(); + } + + public UploadPostTransformErrorEvent() + { + this.Type = JsonSerializer.Deserialize("\"upload.post-transform.error\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UploadPostTransformErrorEvent(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static UploadPostTransformErrorEvent FromRawUnchecked( + Dictionary properties + ) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEvent.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEvent.cs index c4e0933c..6a64eb24 100644 --- a/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEvent.cs +++ b/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEvent.cs @@ -1,146 +1,146 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Webhooks.UploadPostTransformSuccessEventProperties; - -namespace Imagekit.Models.Webhooks; - -/// -/// Triggered when a post-transformation completes successfully. The transformed version -/// of the file is now ready and can be accessed via the provided URL. Note that -/// each post-transformation generates a separate webhook event. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class UploadPostTransformSuccessEvent - : ModelBase, - IFromRaw -{ - /// - /// Unique identifier for the event. - /// - public required string ID - { - get - { - if (!this.Properties.TryGetValue("id", out JsonElement element)) - throw new ArgumentOutOfRangeException("id", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("id"); - } - set - { - this.Properties["id"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Timestamp of when the event occurred in ISO8601 format. - /// - public required DateTime CreatedAt - { - get - { - if (!this.Properties.TryGetValue("created_at", out JsonElement element)) - throw new ArgumentOutOfRangeException("created_at", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["created_at"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required Data Data - { - get - { - if (!this.Properties.TryGetValue("data", out JsonElement element)) - throw new ArgumentOutOfRangeException("data", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("data"); - } - set - { - this.Properties["data"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required Request Request - { - get - { - if (!this.Properties.TryGetValue("request", out JsonElement element)) - throw new ArgumentOutOfRangeException("request", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("request"); - } - set - { - this.Properties["request"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.ID; - _ = this.CreatedAt; - this.Data.Validate(); - this.Request.Validate(); - } - - public UploadPostTransformSuccessEvent() - { - this.Type = JsonSerializer.Deserialize("\"upload.post-transform.success\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - UploadPostTransformSuccessEvent(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static UploadPostTransformSuccessEvent FromRawUnchecked( - Dictionary properties - ) - { - return new(properties); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Webhooks.UploadPostTransformSuccessEventProperties; + +namespace Imagekit.Models.Webhooks; + +/// +/// Triggered when a post-transformation completes successfully. The transformed version +/// of the file is now ready and can be accessed via the provided URL. Note that +/// each post-transformation generates a separate webhook event. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class UploadPostTransformSuccessEvent + : ModelBase, + IFromRaw +{ + /// + /// Unique identifier for the event. + /// + public required string ID + { + get + { + if (!this.Properties.TryGetValue("id", out JsonElement element)) + throw new ArgumentOutOfRangeException("id", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("id"); + } + set + { + this.Properties["id"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Timestamp of when the event occurred in ISO8601 format. + /// + public required DateTime CreatedAt + { + get + { + if (!this.Properties.TryGetValue("created_at", out JsonElement element)) + throw new ArgumentOutOfRangeException("created_at", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["created_at"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required Data Data + { + get + { + if (!this.Properties.TryGetValue("data", out JsonElement element)) + throw new ArgumentOutOfRangeException("data", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("data"); + } + set + { + this.Properties["data"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required Request Request + { + get + { + if (!this.Properties.TryGetValue("request", out JsonElement element)) + throw new ArgumentOutOfRangeException("request", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("request"); + } + set + { + this.Properties["request"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.ID; + _ = this.CreatedAt; + this.Data.Validate(); + this.Request.Validate(); + } + + public UploadPostTransformSuccessEvent() + { + this.Type = JsonSerializer.Deserialize("\"upload.post-transform.success\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UploadPostTransformSuccessEvent(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static UploadPostTransformSuccessEvent FromRawUnchecked( + Dictionary properties + ) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEvent.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEvent.cs index c3d1ac50..f31c21d5 100644 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEvent.cs +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEvent.cs @@ -1,145 +1,145 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Webhooks.UploadPreTransformErrorEventProperties; - -namespace Imagekit.Models.Webhooks; - -/// -/// Triggered when a pre-transformation fails. The file upload may have been accepted, -/// but the requested transformation could not be applied. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class UploadPreTransformErrorEvent - : ModelBase, - IFromRaw -{ - /// - /// Unique identifier for the event. - /// - public required string ID - { - get - { - if (!this.Properties.TryGetValue("id", out JsonElement element)) - throw new ArgumentOutOfRangeException("id", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("id"); - } - set - { - this.Properties["id"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Timestamp of when the event occurred in ISO8601 format. - /// - public required DateTime CreatedAt - { - get - { - if (!this.Properties.TryGetValue("created_at", out JsonElement element)) - throw new ArgumentOutOfRangeException("created_at", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["created_at"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required Data Data - { - get - { - if (!this.Properties.TryGetValue("data", out JsonElement element)) - throw new ArgumentOutOfRangeException("data", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("data"); - } - set - { - this.Properties["data"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required Request Request - { - get - { - if (!this.Properties.TryGetValue("request", out JsonElement element)) - throw new ArgumentOutOfRangeException("request", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("request"); - } - set - { - this.Properties["request"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.ID; - _ = this.CreatedAt; - this.Data.Validate(); - this.Request.Validate(); - } - - public UploadPreTransformErrorEvent() - { - this.Type = JsonSerializer.Deserialize("\"upload.pre-transform.error\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - UploadPreTransformErrorEvent(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static UploadPreTransformErrorEvent FromRawUnchecked( - Dictionary properties - ) - { - return new(properties); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Webhooks.UploadPreTransformErrorEventProperties; + +namespace Imagekit.Models.Webhooks; + +/// +/// Triggered when a pre-transformation fails. The file upload may have been accepted, +/// but the requested transformation could not be applied. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class UploadPreTransformErrorEvent + : ModelBase, + IFromRaw +{ + /// + /// Unique identifier for the event. + /// + public required string ID + { + get + { + if (!this.Properties.TryGetValue("id", out JsonElement element)) + throw new ArgumentOutOfRangeException("id", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("id"); + } + set + { + this.Properties["id"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Timestamp of when the event occurred in ISO8601 format. + /// + public required DateTime CreatedAt + { + get + { + if (!this.Properties.TryGetValue("created_at", out JsonElement element)) + throw new ArgumentOutOfRangeException("created_at", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["created_at"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required Data Data + { + get + { + if (!this.Properties.TryGetValue("data", out JsonElement element)) + throw new ArgumentOutOfRangeException("data", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("data"); + } + set + { + this.Properties["data"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required Request Request + { + get + { + if (!this.Properties.TryGetValue("request", out JsonElement element)) + throw new ArgumentOutOfRangeException("request", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("request"); + } + set + { + this.Properties["request"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.ID; + _ = this.CreatedAt; + this.Data.Validate(); + this.Request.Validate(); + } + + public UploadPreTransformErrorEvent() + { + this.Type = JsonSerializer.Deserialize("\"upload.pre-transform.error\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UploadPreTransformErrorEvent(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static UploadPreTransformErrorEvent FromRawUnchecked( + Dictionary properties + ) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEvent.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEvent.cs index 11b65760..f60e43ac 100644 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEvent.cs +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEvent.cs @@ -1,149 +1,149 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties; - -namespace Imagekit.Models.Webhooks; - -/// -/// Triggered when a pre-transformation completes successfully. The file has been -/// processed with the requested transformation and is now available in the Media -/// Library. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class UploadPreTransformSuccessEvent - : ModelBase, - IFromRaw -{ - /// - /// Unique identifier for the event. - /// - public required string ID - { - get - { - if (!this.Properties.TryGetValue("id", out JsonElement element)) - throw new ArgumentOutOfRangeException("id", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("id"); - } - set - { - this.Properties["id"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Timestamp of when the event occurred in ISO8601 format. - /// - public required DateTime CreatedAt - { - get - { - if (!this.Properties.TryGetValue("created_at", out JsonElement element)) - throw new ArgumentOutOfRangeException("created_at", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["created_at"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Object containing details of a successful upload. - /// - public required Data Data - { - get - { - if (!this.Properties.TryGetValue("data", out JsonElement element)) - throw new ArgumentOutOfRangeException("data", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("data"); - } - set - { - this.Properties["data"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required Request Request - { - get - { - if (!this.Properties.TryGetValue("request", out JsonElement element)) - throw new ArgumentOutOfRangeException("request", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("request"); - } - set - { - this.Properties["request"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.ID; - _ = this.CreatedAt; - this.Data.Validate(); - this.Request.Validate(); - } - - public UploadPreTransformSuccessEvent() - { - this.Type = JsonSerializer.Deserialize("\"upload.pre-transform.success\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - UploadPreTransformSuccessEvent(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static UploadPreTransformSuccessEvent FromRawUnchecked( - Dictionary properties - ) - { - return new(properties); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties; + +namespace Imagekit.Models.Webhooks; + +/// +/// Triggered when a pre-transformation completes successfully. The file has been +/// processed with the requested transformation and is now available in the Media +/// Library. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class UploadPreTransformSuccessEvent + : ModelBase, + IFromRaw +{ + /// + /// Unique identifier for the event. + /// + public required string ID + { + get + { + if (!this.Properties.TryGetValue("id", out JsonElement element)) + throw new ArgumentOutOfRangeException("id", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("id"); + } + set + { + this.Properties["id"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Timestamp of when the event occurred in ISO8601 format. + /// + public required DateTime CreatedAt + { + get + { + if (!this.Properties.TryGetValue("created_at", out JsonElement element)) + throw new ArgumentOutOfRangeException("created_at", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["created_at"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Object containing details of a successful upload. + /// + public required Data Data + { + get + { + if (!this.Properties.TryGetValue("data", out JsonElement element)) + throw new ArgumentOutOfRangeException("data", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("data"); + } + set + { + this.Properties["data"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required Request Request + { + get + { + if (!this.Properties.TryGetValue("request", out JsonElement element)) + throw new ArgumentOutOfRangeException("request", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("request"); + } + set + { + this.Properties["request"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.ID; + _ = this.CreatedAt; + this.Data.Validate(); + this.Request.Validate(); + } + + public UploadPreTransformSuccessEvent() + { + this.Type = JsonSerializer.Deserialize("\"upload.pre-transform.success\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UploadPreTransformSuccessEvent(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static UploadPreTransformSuccessEvent FromRawUnchecked( + Dictionary properties + ) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEvent.cs b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEvent.cs index e3dc0196..f796b9ac 100644 --- a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEvent.cs +++ b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEvent.cs @@ -1,149 +1,149 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties; - -namespace Imagekit.Models.Webhooks; - -/// -/// Triggered when a new video transformation request is accepted for processing. -/// This event confirms that ImageKit has received and queued your transformation -/// request. Use this for debugging and tracking transformation lifecycle. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class VideoTransformationAcceptedEvent - : ModelBase, - IFromRaw -{ - /// - /// Unique identifier for the event. - /// - public required string ID - { - get - { - if (!this.Properties.TryGetValue("id", out JsonElement element)) - throw new ArgumentOutOfRangeException("id", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("id"); - } - set - { - this.Properties["id"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Timestamp when the event was created in ISO8601 format. - /// - public required DateTime CreatedAt - { - get - { - if (!this.Properties.TryGetValue("created_at", out JsonElement element)) - throw new ArgumentOutOfRangeException("created_at", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["created_at"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required Data Data - { - get - { - if (!this.Properties.TryGetValue("data", out JsonElement element)) - throw new ArgumentOutOfRangeException("data", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("data"); - } - set - { - this.Properties["data"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Information about the original request that triggered the video transformation. - /// - public required Request Request - { - get - { - if (!this.Properties.TryGetValue("request", out JsonElement element)) - throw new ArgumentOutOfRangeException("request", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("request"); - } - set - { - this.Properties["request"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.ID; - _ = this.CreatedAt; - this.Data.Validate(); - this.Request.Validate(); - } - - public VideoTransformationAcceptedEvent() - { - this.Type = JsonSerializer.Deserialize("\"video.transformation.accepted\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - VideoTransformationAcceptedEvent(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static VideoTransformationAcceptedEvent FromRawUnchecked( - Dictionary properties - ) - { - return new(properties); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties; + +namespace Imagekit.Models.Webhooks; + +/// +/// Triggered when a new video transformation request is accepted for processing. +/// This event confirms that ImageKit has received and queued your transformation +/// request. Use this for debugging and tracking transformation lifecycle. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class VideoTransformationAcceptedEvent + : ModelBase, + IFromRaw +{ + /// + /// Unique identifier for the event. + /// + public required string ID + { + get + { + if (!this.Properties.TryGetValue("id", out JsonElement element)) + throw new ArgumentOutOfRangeException("id", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("id"); + } + set + { + this.Properties["id"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Timestamp when the event was created in ISO8601 format. + /// + public required DateTime CreatedAt + { + get + { + if (!this.Properties.TryGetValue("created_at", out JsonElement element)) + throw new ArgumentOutOfRangeException("created_at", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["created_at"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required Data Data + { + get + { + if (!this.Properties.TryGetValue("data", out JsonElement element)) + throw new ArgumentOutOfRangeException("data", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("data"); + } + set + { + this.Properties["data"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Information about the original request that triggered the video transformation. + /// + public required Request Request + { + get + { + if (!this.Properties.TryGetValue("request", out JsonElement element)) + throw new ArgumentOutOfRangeException("request", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("request"); + } + set + { + this.Properties["request"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.ID; + _ = this.CreatedAt; + this.Data.Validate(); + this.Request.Validate(); + } + + public VideoTransformationAcceptedEvent() + { + this.Type = JsonSerializer.Deserialize("\"video.transformation.accepted\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + VideoTransformationAcceptedEvent(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static VideoTransformationAcceptedEvent FromRawUnchecked( + Dictionary properties + ) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEvent.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEvent.cs index f8e5a29c..a36eed25 100644 --- a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEvent.cs +++ b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEvent.cs @@ -1,150 +1,150 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties; - -namespace Imagekit.Models.Webhooks; - -/// -/// Triggered when an error occurs during video encoding. Listen to this webhook to -/// log error reasons and debug issues. Check your origin and URL endpoint settings -/// if the reason is related to download failure. For other errors, contact ImageKit -/// support. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class VideoTransformationErrorEvent - : ModelBase, - IFromRaw -{ - /// - /// Unique identifier for the event. - /// - public required string ID - { - get - { - if (!this.Properties.TryGetValue("id", out JsonElement element)) - throw new ArgumentOutOfRangeException("id", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("id"); - } - set - { - this.Properties["id"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Timestamp when the event was created in ISO8601 format. - /// - public required DateTime CreatedAt - { - get - { - if (!this.Properties.TryGetValue("created_at", out JsonElement element)) - throw new ArgumentOutOfRangeException("created_at", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["created_at"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required Data Data - { - get - { - if (!this.Properties.TryGetValue("data", out JsonElement element)) - throw new ArgumentOutOfRangeException("data", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("data"); - } - set - { - this.Properties["data"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Information about the original request that triggered the video transformation. - /// - public required Request Request - { - get - { - if (!this.Properties.TryGetValue("request", out JsonElement element)) - throw new ArgumentOutOfRangeException("request", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("request"); - } - set - { - this.Properties["request"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.ID; - _ = this.CreatedAt; - this.Data.Validate(); - this.Request.Validate(); - } - - public VideoTransformationErrorEvent() - { - this.Type = JsonSerializer.Deserialize("\"video.transformation.error\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - VideoTransformationErrorEvent(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static VideoTransformationErrorEvent FromRawUnchecked( - Dictionary properties - ) - { - return new(properties); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties; + +namespace Imagekit.Models.Webhooks; + +/// +/// Triggered when an error occurs during video encoding. Listen to this webhook to +/// log error reasons and debug issues. Check your origin and URL endpoint settings +/// if the reason is related to download failure. For other errors, contact ImageKit +/// support. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class VideoTransformationErrorEvent + : ModelBase, + IFromRaw +{ + /// + /// Unique identifier for the event. + /// + public required string ID + { + get + { + if (!this.Properties.TryGetValue("id", out JsonElement element)) + throw new ArgumentOutOfRangeException("id", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("id"); + } + set + { + this.Properties["id"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Timestamp when the event was created in ISO8601 format. + /// + public required DateTime CreatedAt + { + get + { + if (!this.Properties.TryGetValue("created_at", out JsonElement element)) + throw new ArgumentOutOfRangeException("created_at", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["created_at"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required Data Data + { + get + { + if (!this.Properties.TryGetValue("data", out JsonElement element)) + throw new ArgumentOutOfRangeException("data", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("data"); + } + set + { + this.Properties["data"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Information about the original request that triggered the video transformation. + /// + public required Request Request + { + get + { + if (!this.Properties.TryGetValue("request", out JsonElement element)) + throw new ArgumentOutOfRangeException("request", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("request"); + } + set + { + this.Properties["request"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.ID; + _ = this.CreatedAt; + this.Data.Validate(); + this.Request.Validate(); + } + + public VideoTransformationErrorEvent() + { + this.Type = JsonSerializer.Deserialize("\"video.transformation.error\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + VideoTransformationErrorEvent(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static VideoTransformationErrorEvent FromRawUnchecked( + Dictionary properties + ) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEvent.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEvent.cs index ebd61c2f..330228c5 100644 --- a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEvent.cs +++ b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEvent.cs @@ -1,172 +1,172 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties; - -namespace Imagekit.Models.Webhooks; - -/// -/// Triggered when video encoding is finished and the transformed resource is ready -/// to be served. This is the key event to listen for - update your database or CMS -/// flags when you receive this so your application can start showing the transformed -/// video to users. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class VideoTransformationReadyEvent - : ModelBase, - IFromRaw -{ - /// - /// Unique identifier for the event. - /// - public required string ID - { - get - { - if (!this.Properties.TryGetValue("id", out JsonElement element)) - throw new ArgumentOutOfRangeException("id", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("id"); - } - set - { - this.Properties["id"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Timestamp when the event was created in ISO8601 format. - /// - public required DateTime CreatedAt - { - get - { - if (!this.Properties.TryGetValue("created_at", out JsonElement element)) - throw new ArgumentOutOfRangeException("created_at", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["created_at"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required Data Data - { - get - { - if (!this.Properties.TryGetValue("data", out JsonElement element)) - throw new ArgumentOutOfRangeException("data", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("data"); - } - set - { - this.Properties["data"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Information about the original request that triggered the video transformation. - /// - public required Request Request - { - get - { - if (!this.Properties.TryGetValue("request", out JsonElement element)) - throw new ArgumentOutOfRangeException("request", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("request"); - } - set - { - this.Properties["request"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Performance metrics for the transformation process. - /// - public Timings? Timings - { - get - { - if (!this.Properties.TryGetValue("timings", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["timings"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.ID; - _ = this.CreatedAt; - this.Data.Validate(); - this.Request.Validate(); - this.Timings?.Validate(); - } - - public VideoTransformationReadyEvent() - { - this.Type = JsonSerializer.Deserialize("\"video.transformation.ready\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - VideoTransformationReadyEvent(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static VideoTransformationReadyEvent FromRawUnchecked( - Dictionary properties - ) - { - return new(properties); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties; + +namespace Imagekit.Models.Webhooks; + +/// +/// Triggered when video encoding is finished and the transformed resource is ready +/// to be served. This is the key event to listen for - update your database or CMS +/// flags when you receive this so your application can start showing the transformed +/// video to users. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class VideoTransformationReadyEvent + : ModelBase, + IFromRaw +{ + /// + /// Unique identifier for the event. + /// + public required string ID + { + get + { + if (!this.Properties.TryGetValue("id", out JsonElement element)) + throw new ArgumentOutOfRangeException("id", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("id"); + } + set + { + this.Properties["id"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Timestamp when the event was created in ISO8601 format. + /// + public required DateTime CreatedAt + { + get + { + if (!this.Properties.TryGetValue("created_at", out JsonElement element)) + throw new ArgumentOutOfRangeException("created_at", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["created_at"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required Data Data + { + get + { + if (!this.Properties.TryGetValue("data", out JsonElement element)) + throw new ArgumentOutOfRangeException("data", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("data"); + } + set + { + this.Properties["data"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Information about the original request that triggered the video transformation. + /// + public required Request Request + { + get + { + if (!this.Properties.TryGetValue("request", out JsonElement element)) + throw new ArgumentOutOfRangeException("request", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("request"); + } + set + { + this.Properties["request"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Performance metrics for the transformation process. + /// + public Timings? Timings + { + get + { + if (!this.Properties.TryGetValue("timings", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["timings"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.ID; + _ = this.CreatedAt; + this.Data.Validate(); + this.Request.Validate(); + this.Timings?.Validate(); + } + + public VideoTransformationReadyEvent() + { + this.Type = JsonSerializer.Deserialize("\"video.transformation.ready\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + VideoTransformationReadyEvent(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static VideoTransformationReadyEvent FromRawUnchecked( + Dictionary properties + ) + { + return new(properties); + } +} From aec488450d0b633c965719590fa554d32e377a1c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 28 Jan 2026 16:28:01 +0000 Subject: [PATCH 004/129] feat(api): manual updates --- .stats.yml | 2 +- .../Models/Webhooks/BaseWebhookEvent.cs | 76 +++++++++ .../Webhooks/UploadPostTransformErrorEvent.cs | 50 +++--- .../IntersectionMember1.cs | 118 ++++++++++++++ .../Data.cs | 0 .../DataProperties/Transformation.cs | 0 .../TransformationProperties/Error.cs | 0 .../Request.cs | 0 .../RequestProperties/Transformation.cs | 0 .../TransformationProperties/Protocol.cs | 0 .../TransformationProperties/Type.cs | 0 .../UploadPostTransformSuccessEvent.cs | 53 ++++--- .../IntersectionMember1.cs | 119 ++++++++++++++ .../Data.cs | 0 .../Request.cs | 0 .../RequestProperties/Transformation.cs | 0 .../TransformationProperties/Protocol.cs | 0 .../TransformationProperties/Type.cs | 0 .../Webhooks/UploadPreTransformErrorEvent.cs | 50 +++--- .../IntersectionMember1.cs | 118 ++++++++++++++ .../Data.cs | 0 .../DataProperties/Transformation.cs | 0 .../TransformationProperties/Error.cs | 0 .../Request.cs | 0 .../UploadPreTransformSuccessEvent.cs | 53 ++++--- .../IntersectionMember1.cs | 122 +++++++++++++++ .../Data.cs | 0 .../DataProperties/AITag.cs | 0 .../DataProperties/ExtensionStatus.cs | 0 .../AIAutoDescription.cs | 0 .../AwsAutoTagging.cs | 0 .../GoogleAutoTagging.cs | 0 .../ExtensionStatusProperties/RemoveBg.cs | 0 .../DataProperties/VersionInfo.cs | 0 .../Request.cs | 0 .../VideoTransformationAcceptedEvent.cs | 53 ++++--- .../IntersectionMember1.cs | 122 +++++++++++++++ .../Data.cs | 0 .../DataProperties/Asset.cs | 0 .../DataProperties/Transformation.cs | 0 .../TransformationProperties/Options.cs | 0 .../OptionsProperties/AudioCodec.cs | 0 .../OptionsProperties/Format.cs | 0 .../OptionsProperties/StreamProtocol.cs | 0 .../OptionsProperties/VideoCodec.cs | 0 .../TransformationProperties/Type.cs | 0 .../Request.cs | 0 .../Webhooks/VideoTransformationErrorEvent.cs | 50 +++--- .../IntersectionMember1.cs | 123 +++++++++++++++ .../Data.cs | 0 .../DataProperties/Asset.cs | 0 .../DataProperties/Transformation.cs | 0 .../TransformationProperties/Error.cs | 0 .../ErrorProperties/Reason.cs | 0 .../TransformationProperties/Options.cs | 0 .../OptionsProperties/AudioCodec.cs | 0 .../OptionsProperties/Format.cs | 0 .../OptionsProperties/StreamProtocol.cs | 0 .../OptionsProperties/VideoCodec.cs | 0 .../TransformationProperties/Type.cs | 0 .../Request.cs | 0 .../Webhooks/VideoTransformationReadyEvent.cs | 52 ++++--- .../IntersectionMember1.cs | 145 ++++++++++++++++++ .../Data.cs | 4 +- .../DataProperties/Asset.cs | 0 .../DataProperties/Transformation.cs | 0 .../TransformationProperties/Options.cs | 0 .../OptionsProperties/AudioCodec.cs | 0 .../OptionsProperties/Format.cs | 0 .../OptionsProperties/StreamProtocol.cs | 0 .../OptionsProperties/VideoCodec.cs | 0 .../TransformationProperties/Output.cs | 0 .../OutputProperties/VideoMetadata.cs | 0 .../TransformationProperties/Type.cs | 0 .../Request.cs | 0 .../Timings.cs | 0 76 files changed, 1155 insertions(+), 155 deletions(-) create mode 100644 src/Imagekit/Models/Webhooks/BaseWebhookEvent.cs create mode 100644 src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1.cs rename src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/{ => IntersectionMember1Properties}/Data.cs (100%) rename src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/{ => IntersectionMember1Properties}/DataProperties/Transformation.cs (100%) rename src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/{ => IntersectionMember1Properties}/DataProperties/TransformationProperties/Error.cs (100%) rename src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/{ => IntersectionMember1Properties}/Request.cs (100%) rename src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/{ => IntersectionMember1Properties}/RequestProperties/Transformation.cs (100%) rename src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/{ => IntersectionMember1Properties}/RequestProperties/TransformationProperties/Protocol.cs (100%) rename src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/{ => IntersectionMember1Properties}/RequestProperties/TransformationProperties/Type.cs (100%) create mode 100644 src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1.cs rename src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/{ => IntersectionMember1Properties}/Data.cs (100%) rename src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/{ => IntersectionMember1Properties}/Request.cs (100%) rename src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/{ => IntersectionMember1Properties}/RequestProperties/Transformation.cs (100%) rename src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/{ => IntersectionMember1Properties}/RequestProperties/TransformationProperties/Protocol.cs (100%) rename src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/{ => IntersectionMember1Properties}/RequestProperties/TransformationProperties/Type.cs (100%) create mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/IntersectionMember1.cs rename src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/{ => IntersectionMember1Properties}/Data.cs (100%) rename src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/{ => IntersectionMember1Properties}/DataProperties/Transformation.cs (100%) rename src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/{ => IntersectionMember1Properties}/DataProperties/TransformationProperties/Error.cs (100%) rename src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/{ => IntersectionMember1Properties}/Request.cs (100%) create mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1.cs rename src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/{ => IntersectionMember1Properties}/Data.cs (100%) rename src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/{ => IntersectionMember1Properties}/DataProperties/AITag.cs (100%) rename src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/{ => IntersectionMember1Properties}/DataProperties/ExtensionStatus.cs (100%) rename src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/{ => IntersectionMember1Properties}/DataProperties/ExtensionStatusProperties/AIAutoDescription.cs (100%) rename src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/{ => IntersectionMember1Properties}/DataProperties/ExtensionStatusProperties/AwsAutoTagging.cs (100%) rename src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/{ => IntersectionMember1Properties}/DataProperties/ExtensionStatusProperties/GoogleAutoTagging.cs (100%) rename src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/{ => IntersectionMember1Properties}/DataProperties/ExtensionStatusProperties/RemoveBg.cs (100%) rename src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/{ => IntersectionMember1Properties}/DataProperties/VersionInfo.cs (100%) rename src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/{ => IntersectionMember1Properties}/Request.cs (100%) create mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1.cs rename src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/{ => IntersectionMember1Properties}/Data.cs (100%) rename src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/{ => IntersectionMember1Properties}/DataProperties/Asset.cs (100%) rename src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/{ => IntersectionMember1Properties}/DataProperties/Transformation.cs (100%) rename src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/{ => IntersectionMember1Properties}/DataProperties/TransformationProperties/Options.cs (100%) rename src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/{ => IntersectionMember1Properties}/DataProperties/TransformationProperties/OptionsProperties/AudioCodec.cs (100%) rename src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/{ => IntersectionMember1Properties}/DataProperties/TransformationProperties/OptionsProperties/Format.cs (100%) rename src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/{ => IntersectionMember1Properties}/DataProperties/TransformationProperties/OptionsProperties/StreamProtocol.cs (100%) rename src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/{ => IntersectionMember1Properties}/DataProperties/TransformationProperties/OptionsProperties/VideoCodec.cs (100%) rename src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/{ => IntersectionMember1Properties}/DataProperties/TransformationProperties/Type.cs (100%) rename src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/{ => IntersectionMember1Properties}/Request.cs (100%) create mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1.cs rename src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/{ => IntersectionMember1Properties}/Data.cs (100%) rename src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/{ => IntersectionMember1Properties}/DataProperties/Asset.cs (100%) rename src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/{ => IntersectionMember1Properties}/DataProperties/Transformation.cs (100%) rename src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/{ => IntersectionMember1Properties}/DataProperties/TransformationProperties/Error.cs (100%) rename src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/{ => IntersectionMember1Properties}/DataProperties/TransformationProperties/ErrorProperties/Reason.cs (100%) rename src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/{ => IntersectionMember1Properties}/DataProperties/TransformationProperties/Options.cs (100%) rename src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/{ => IntersectionMember1Properties}/DataProperties/TransformationProperties/OptionsProperties/AudioCodec.cs (100%) rename src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/{ => IntersectionMember1Properties}/DataProperties/TransformationProperties/OptionsProperties/Format.cs (100%) rename src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/{ => IntersectionMember1Properties}/DataProperties/TransformationProperties/OptionsProperties/StreamProtocol.cs (100%) rename src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/{ => IntersectionMember1Properties}/DataProperties/TransformationProperties/OptionsProperties/VideoCodec.cs (100%) rename src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/{ => IntersectionMember1Properties}/DataProperties/TransformationProperties/Type.cs (100%) rename src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/{ => IntersectionMember1Properties}/Request.cs (100%) create mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1.cs rename src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/{ => IntersectionMember1Properties}/Data.cs (95%) rename src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/{ => IntersectionMember1Properties}/DataProperties/Asset.cs (100%) rename src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/{ => IntersectionMember1Properties}/DataProperties/Transformation.cs (100%) rename src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/{ => IntersectionMember1Properties}/DataProperties/TransformationProperties/Options.cs (100%) rename src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/{ => IntersectionMember1Properties}/DataProperties/TransformationProperties/OptionsProperties/AudioCodec.cs (100%) rename src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/{ => IntersectionMember1Properties}/DataProperties/TransformationProperties/OptionsProperties/Format.cs (100%) rename src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/{ => IntersectionMember1Properties}/DataProperties/TransformationProperties/OptionsProperties/StreamProtocol.cs (100%) rename src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/{ => IntersectionMember1Properties}/DataProperties/TransformationProperties/OptionsProperties/VideoCodec.cs (100%) rename src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/{ => IntersectionMember1Properties}/DataProperties/TransformationProperties/Output.cs (100%) rename src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/{ => IntersectionMember1Properties}/DataProperties/TransformationProperties/OutputProperties/VideoMetadata.cs (100%) rename src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/{ => IntersectionMember1Properties}/DataProperties/TransformationProperties/Type.cs (100%) rename src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/{ => IntersectionMember1Properties}/Request.cs (100%) rename src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/{ => IntersectionMember1Properties}/Timings.cs (100%) diff --git a/.stats.yml b/.stats.yml index 08185446..52f982ba 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-667f7f4988b44bc587d6eb9960ff5c8326e9f7e9b072f3f724f9f54166eff8b1.yml openapi_spec_hash: f2081864a4abee0480e5ff991b4c936a -config_hash: 4e73c7e12a531edcd1366dab7eccc360 +config_hash: 08e12746cdca1c59c897cf2e50893c3c diff --git a/src/Imagekit/Models/Webhooks/BaseWebhookEvent.cs b/src/Imagekit/Models/Webhooks/BaseWebhookEvent.cs new file mode 100644 index 00000000..d3a84bb1 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/BaseWebhookEvent.cs @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Webhooks; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class BaseWebhookEvent : ModelBase, IFromRaw +{ + /// + /// Unique identifier for the event. + /// + public required string ID + { + get + { + if (!this.Properties.TryGetValue("id", out JsonElement element)) + throw new ArgumentOutOfRangeException("id", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("id"); + } + set + { + this.Properties["id"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The type of webhook event. + /// + public required string Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("type"); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.ID; + _ = this.Type; + } + + public BaseWebhookEvent() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + BaseWebhookEvent(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static BaseWebhookEvent FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEvent.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEvent.cs index 3dea0812..85608b50 100644 --- a/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEvent.cs +++ b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEvent.cs @@ -3,7 +3,7 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using Imagekit.Models.Webhooks.UploadPostTransformErrorEventProperties; +using Imagekit.Models.Webhooks.UploadPostTransformErrorEventProperties.IntersectionMember1Properties; namespace Imagekit.Models.Webhooks; @@ -38,6 +38,28 @@ public required string ID } } + /// + /// The type of webhook event. + /// + public required string Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("type"); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + /// /// Timestamp of when the event occurred in ISO8601 format. /// @@ -97,36 +119,20 @@ public required Request Request } } - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } + public static implicit operator BaseWebhookEvent( + UploadPostTransformErrorEvent uploadPostTransformErrorEvent + ) => new() { ID = uploadPostTransformErrorEvent.ID, Type = uploadPostTransformErrorEvent.Type }; public override void Validate() { _ = this.ID; + _ = this.Type; _ = this.CreatedAt; this.Data.Validate(); this.Request.Validate(); } - public UploadPostTransformErrorEvent() - { - this.Type = JsonSerializer.Deserialize("\"upload.post-transform.error\""); - } + public UploadPostTransformErrorEvent() { } #pragma warning disable CS8618 [SetsRequiredMembers] diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1.cs new file mode 100644 index 00000000..0d8b3b16 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1.cs @@ -0,0 +1,118 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Webhooks.UploadPostTransformErrorEventProperties.IntersectionMember1Properties; + +namespace Imagekit.Models.Webhooks.UploadPostTransformErrorEventProperties; + +/// +/// Triggered when a post-transformation fails. The original file remains available, +/// but the requested transformation could not be generated. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class IntersectionMember1 : ModelBase, IFromRaw +{ + /// + /// Timestamp of when the event occurred in ISO8601 format. + /// + public required DateTime CreatedAt + { + get + { + if (!this.Properties.TryGetValue("created_at", out JsonElement element)) + throw new ArgumentOutOfRangeException("created_at", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["created_at"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required Data Data + { + get + { + if (!this.Properties.TryGetValue("data", out JsonElement element)) + throw new ArgumentOutOfRangeException("data", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("data"); + } + set + { + this.Properties["data"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required Request Request + { + get + { + if (!this.Properties.TryGetValue("request", out JsonElement element)) + throw new ArgumentOutOfRangeException("request", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("request"); + } + set + { + this.Properties["request"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.CreatedAt; + this.Data.Validate(); + this.Request.Validate(); + } + + public IntersectionMember1() + { + this.Type = JsonSerializer.Deserialize("\"upload.post-transform.error\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + IntersectionMember1(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static IntersectionMember1 FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/Data.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1Properties/Data.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/Data.cs rename to src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1Properties/Data.cs diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/DataProperties/Transformation.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/DataProperties/Transformation.cs rename to src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/DataProperties/TransformationProperties/Error.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Error.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/DataProperties/TransformationProperties/Error.cs rename to src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Error.cs diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/Request.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1Properties/Request.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/Request.cs rename to src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1Properties/Request.cs diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/RequestProperties/Transformation.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1Properties/RequestProperties/Transformation.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/RequestProperties/Transformation.cs rename to src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1Properties/RequestProperties/Transformation.cs diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/RequestProperties/TransformationProperties/Protocol.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1Properties/RequestProperties/TransformationProperties/Protocol.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/RequestProperties/TransformationProperties/Protocol.cs rename to src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1Properties/RequestProperties/TransformationProperties/Protocol.cs diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/RequestProperties/TransformationProperties/Type.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1Properties/RequestProperties/TransformationProperties/Type.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/RequestProperties/TransformationProperties/Type.cs rename to src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1Properties/RequestProperties/TransformationProperties/Type.cs diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEvent.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEvent.cs index 6a64eb24..cdbe3a90 100644 --- a/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEvent.cs +++ b/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEvent.cs @@ -3,7 +3,7 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using Imagekit.Models.Webhooks.UploadPostTransformSuccessEventProperties; +using Imagekit.Models.Webhooks.UploadPostTransformSuccessEventProperties.IntersectionMember1Properties; namespace Imagekit.Models.Webhooks; @@ -39,6 +39,28 @@ public required string ID } } + /// + /// The type of webhook event. + /// + public required string Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("type"); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + /// /// Timestamp of when the event occurred in ISO8601 format. /// @@ -98,36 +120,25 @@ public required Request Request } } - public JsonElement Type - { - get + public static implicit operator BaseWebhookEvent( + UploadPostTransformSuccessEvent uploadPostTransformSuccessEvent + ) => + new() { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } + ID = uploadPostTransformSuccessEvent.ID, + Type = uploadPostTransformSuccessEvent.Type, + }; public override void Validate() { _ = this.ID; + _ = this.Type; _ = this.CreatedAt; this.Data.Validate(); this.Request.Validate(); } - public UploadPostTransformSuccessEvent() - { - this.Type = JsonSerializer.Deserialize("\"upload.post-transform.success\""); - } + public UploadPostTransformSuccessEvent() { } #pragma warning disable CS8618 [SetsRequiredMembers] diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1.cs new file mode 100644 index 00000000..ec74e143 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1.cs @@ -0,0 +1,119 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Webhooks.UploadPostTransformSuccessEventProperties.IntersectionMember1Properties; + +namespace Imagekit.Models.Webhooks.UploadPostTransformSuccessEventProperties; + +/// +/// Triggered when a post-transformation completes successfully. The transformed version +/// of the file is now ready and can be accessed via the provided URL. Note that +/// each post-transformation generates a separate webhook event. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class IntersectionMember1 : ModelBase, IFromRaw +{ + /// + /// Timestamp of when the event occurred in ISO8601 format. + /// + public required DateTime CreatedAt + { + get + { + if (!this.Properties.TryGetValue("created_at", out JsonElement element)) + throw new ArgumentOutOfRangeException("created_at", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["created_at"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required Data Data + { + get + { + if (!this.Properties.TryGetValue("data", out JsonElement element)) + throw new ArgumentOutOfRangeException("data", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("data"); + } + set + { + this.Properties["data"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required Request Request + { + get + { + if (!this.Properties.TryGetValue("request", out JsonElement element)) + throw new ArgumentOutOfRangeException("request", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("request"); + } + set + { + this.Properties["request"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.CreatedAt; + this.Data.Validate(); + this.Request.Validate(); + } + + public IntersectionMember1() + { + this.Type = JsonSerializer.Deserialize("\"upload.post-transform.success\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + IntersectionMember1(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static IntersectionMember1 FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/Data.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1Properties/Data.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/Data.cs rename to src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1Properties/Data.cs diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/Request.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1Properties/Request.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/Request.cs rename to src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1Properties/Request.cs diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/RequestProperties/Transformation.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1Properties/RequestProperties/Transformation.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/RequestProperties/Transformation.cs rename to src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1Properties/RequestProperties/Transformation.cs diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/RequestProperties/TransformationProperties/Protocol.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1Properties/RequestProperties/TransformationProperties/Protocol.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/RequestProperties/TransformationProperties/Protocol.cs rename to src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1Properties/RequestProperties/TransformationProperties/Protocol.cs diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/RequestProperties/TransformationProperties/Type.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1Properties/RequestProperties/TransformationProperties/Type.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/RequestProperties/TransformationProperties/Type.cs rename to src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1Properties/RequestProperties/TransformationProperties/Type.cs diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEvent.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEvent.cs index f31c21d5..6c4f2fab 100644 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEvent.cs +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEvent.cs @@ -3,7 +3,7 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using Imagekit.Models.Webhooks.UploadPreTransformErrorEventProperties; +using Imagekit.Models.Webhooks.UploadPreTransformErrorEventProperties.IntersectionMember1Properties; namespace Imagekit.Models.Webhooks; @@ -38,6 +38,28 @@ public required string ID } } + /// + /// The type of webhook event. + /// + public required string Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("type"); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + /// /// Timestamp of when the event occurred in ISO8601 format. /// @@ -97,36 +119,20 @@ public required Request Request } } - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } + public static implicit operator BaseWebhookEvent( + UploadPreTransformErrorEvent uploadPreTransformErrorEvent + ) => new() { ID = uploadPreTransformErrorEvent.ID, Type = uploadPreTransformErrorEvent.Type }; public override void Validate() { _ = this.ID; + _ = this.Type; _ = this.CreatedAt; this.Data.Validate(); this.Request.Validate(); } - public UploadPreTransformErrorEvent() - { - this.Type = JsonSerializer.Deserialize("\"upload.pre-transform.error\""); - } + public UploadPreTransformErrorEvent() { } #pragma warning disable CS8618 [SetsRequiredMembers] diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/IntersectionMember1.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/IntersectionMember1.cs new file mode 100644 index 00000000..7dbcd6dd --- /dev/null +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/IntersectionMember1.cs @@ -0,0 +1,118 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Webhooks.UploadPreTransformErrorEventProperties.IntersectionMember1Properties; + +namespace Imagekit.Models.Webhooks.UploadPreTransformErrorEventProperties; + +/// +/// Triggered when a pre-transformation fails. The file upload may have been accepted, +/// but the requested transformation could not be applied. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class IntersectionMember1 : ModelBase, IFromRaw +{ + /// + /// Timestamp of when the event occurred in ISO8601 format. + /// + public required DateTime CreatedAt + { + get + { + if (!this.Properties.TryGetValue("created_at", out JsonElement element)) + throw new ArgumentOutOfRangeException("created_at", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["created_at"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required Data Data + { + get + { + if (!this.Properties.TryGetValue("data", out JsonElement element)) + throw new ArgumentOutOfRangeException("data", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("data"); + } + set + { + this.Properties["data"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required Request Request + { + get + { + if (!this.Properties.TryGetValue("request", out JsonElement element)) + throw new ArgumentOutOfRangeException("request", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("request"); + } + set + { + this.Properties["request"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.CreatedAt; + this.Data.Validate(); + this.Request.Validate(); + } + + public IntersectionMember1() + { + this.Type = JsonSerializer.Deserialize("\"upload.pre-transform.error\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + IntersectionMember1(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static IntersectionMember1 FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/Data.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/IntersectionMember1Properties/Data.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/Data.cs rename to src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/IntersectionMember1Properties/Data.cs diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/DataProperties/Transformation.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/DataProperties/Transformation.cs rename to src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/DataProperties/TransformationProperties/Error.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Error.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/DataProperties/TransformationProperties/Error.cs rename to src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Error.cs diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/Request.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/IntersectionMember1Properties/Request.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/Request.cs rename to src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/IntersectionMember1Properties/Request.cs diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEvent.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEvent.cs index f60e43ac..79c83d14 100644 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEvent.cs +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEvent.cs @@ -3,7 +3,7 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties; +using Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties; namespace Imagekit.Models.Webhooks; @@ -39,6 +39,28 @@ public required string ID } } + /// + /// The type of webhook event. + /// + public required string Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("type"); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + /// /// Timestamp of when the event occurred in ISO8601 format. /// @@ -101,36 +123,25 @@ public required Request Request } } - public JsonElement Type - { - get + public static implicit operator BaseWebhookEvent( + UploadPreTransformSuccessEvent uploadPreTransformSuccessEvent + ) => + new() { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } + ID = uploadPreTransformSuccessEvent.ID, + Type = uploadPreTransformSuccessEvent.Type, + }; public override void Validate() { _ = this.ID; + _ = this.Type; _ = this.CreatedAt; this.Data.Validate(); this.Request.Validate(); } - public UploadPreTransformSuccessEvent() - { - this.Type = JsonSerializer.Deserialize("\"upload.pre-transform.success\""); - } + public UploadPreTransformSuccessEvent() { } #pragma warning disable CS8618 [SetsRequiredMembers] diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1.cs new file mode 100644 index 00000000..10895afc --- /dev/null +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1.cs @@ -0,0 +1,122 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties; + +namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties; + +/// +/// Triggered when a pre-transformation completes successfully. The file has been +/// processed with the requested transformation and is now available in the Media +/// Library. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class IntersectionMember1 : ModelBase, IFromRaw +{ + /// + /// Timestamp of when the event occurred in ISO8601 format. + /// + public required DateTime CreatedAt + { + get + { + if (!this.Properties.TryGetValue("created_at", out JsonElement element)) + throw new ArgumentOutOfRangeException("created_at", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["created_at"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Object containing details of a successful upload. + /// + public required Data Data + { + get + { + if (!this.Properties.TryGetValue("data", out JsonElement element)) + throw new ArgumentOutOfRangeException("data", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("data"); + } + set + { + this.Properties["data"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required Request Request + { + get + { + if (!this.Properties.TryGetValue("request", out JsonElement element)) + throw new ArgumentOutOfRangeException("request", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("request"); + } + set + { + this.Properties["request"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.CreatedAt; + this.Data.Validate(); + this.Request.Validate(); + } + + public IntersectionMember1() + { + this.Type = JsonSerializer.Deserialize("\"upload.pre-transform.success\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + IntersectionMember1(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static IntersectionMember1 FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/Data.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/Data.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/Data.cs rename to src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/Data.cs diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/DataProperties/AITag.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/AITag.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/DataProperties/AITag.cs rename to src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/AITag.cs diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/DataProperties/ExtensionStatus.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/ExtensionStatus.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/DataProperties/ExtensionStatus.cs rename to src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/ExtensionStatus.cs diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/DataProperties/ExtensionStatusProperties/AIAutoDescription.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/ExtensionStatusProperties/AIAutoDescription.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/DataProperties/ExtensionStatusProperties/AIAutoDescription.cs rename to src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/ExtensionStatusProperties/AIAutoDescription.cs diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/DataProperties/ExtensionStatusProperties/AwsAutoTagging.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/ExtensionStatusProperties/AwsAutoTagging.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/DataProperties/ExtensionStatusProperties/AwsAutoTagging.cs rename to src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/ExtensionStatusProperties/AwsAutoTagging.cs diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/DataProperties/ExtensionStatusProperties/GoogleAutoTagging.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/ExtensionStatusProperties/GoogleAutoTagging.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/DataProperties/ExtensionStatusProperties/GoogleAutoTagging.cs rename to src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/ExtensionStatusProperties/GoogleAutoTagging.cs diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/DataProperties/ExtensionStatusProperties/RemoveBg.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/ExtensionStatusProperties/RemoveBg.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/DataProperties/ExtensionStatusProperties/RemoveBg.cs rename to src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/ExtensionStatusProperties/RemoveBg.cs diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/DataProperties/VersionInfo.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/VersionInfo.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/DataProperties/VersionInfo.cs rename to src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/VersionInfo.cs diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/Request.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/Request.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/Request.cs rename to src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/Request.cs diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEvent.cs b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEvent.cs index f796b9ac..94589e5d 100644 --- a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEvent.cs +++ b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEvent.cs @@ -3,7 +3,7 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties; +using Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.IntersectionMember1Properties; namespace Imagekit.Models.Webhooks; @@ -39,6 +39,28 @@ public required string ID } } + /// + /// The type of webhook event. + /// + public required string Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("type"); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + /// /// Timestamp when the event was created in ISO8601 format. /// @@ -101,36 +123,25 @@ public required Request Request } } - public JsonElement Type - { - get + public static implicit operator BaseWebhookEvent( + VideoTransformationAcceptedEvent videoTransformationAcceptedEvent + ) => + new() { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } + ID = videoTransformationAcceptedEvent.ID, + Type = videoTransformationAcceptedEvent.Type, + }; public override void Validate() { _ = this.ID; + _ = this.Type; _ = this.CreatedAt; this.Data.Validate(); this.Request.Validate(); } - public VideoTransformationAcceptedEvent() - { - this.Type = JsonSerializer.Deserialize("\"video.transformation.accepted\""); - } + public VideoTransformationAcceptedEvent() { } #pragma warning disable CS8618 [SetsRequiredMembers] diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1.cs b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1.cs new file mode 100644 index 00000000..5ad7ffe7 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1.cs @@ -0,0 +1,122 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.IntersectionMember1Properties; + +namespace Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties; + +/// +/// Triggered when a new video transformation request is accepted for processing. +/// This event confirms that ImageKit has received and queued your transformation +/// request. Use this for debugging and tracking transformation lifecycle. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class IntersectionMember1 : ModelBase, IFromRaw +{ + /// + /// Timestamp when the event was created in ISO8601 format. + /// + public required DateTime CreatedAt + { + get + { + if (!this.Properties.TryGetValue("created_at", out JsonElement element)) + throw new ArgumentOutOfRangeException("created_at", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["created_at"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required Data Data + { + get + { + if (!this.Properties.TryGetValue("data", out JsonElement element)) + throw new ArgumentOutOfRangeException("data", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("data"); + } + set + { + this.Properties["data"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Information about the original request that triggered the video transformation. + /// + public required Request Request + { + get + { + if (!this.Properties.TryGetValue("request", out JsonElement element)) + throw new ArgumentOutOfRangeException("request", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("request"); + } + set + { + this.Properties["request"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.CreatedAt; + this.Data.Validate(); + this.Request.Validate(); + } + + public IntersectionMember1() + { + this.Type = JsonSerializer.Deserialize("\"video.transformation.accepted\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + IntersectionMember1(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static IntersectionMember1 FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/Data.cs b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/Data.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/Data.cs rename to src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/Data.cs diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/DataProperties/Asset.cs b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/Asset.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/DataProperties/Asset.cs rename to src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/Asset.cs diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/DataProperties/Transformation.cs b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/DataProperties/Transformation.cs rename to src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/DataProperties/TransformationProperties/Options.cs b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Options.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/DataProperties/TransformationProperties/Options.cs rename to src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Options.cs diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/DataProperties/TransformationProperties/OptionsProperties/AudioCodec.cs b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/AudioCodec.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/DataProperties/TransformationProperties/OptionsProperties/AudioCodec.cs rename to src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/AudioCodec.cs diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/DataProperties/TransformationProperties/OptionsProperties/Format.cs b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/Format.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/DataProperties/TransformationProperties/OptionsProperties/Format.cs rename to src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/Format.cs diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/DataProperties/TransformationProperties/OptionsProperties/StreamProtocol.cs b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/StreamProtocol.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/DataProperties/TransformationProperties/OptionsProperties/StreamProtocol.cs rename to src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/StreamProtocol.cs diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/DataProperties/TransformationProperties/OptionsProperties/VideoCodec.cs b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/VideoCodec.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/DataProperties/TransformationProperties/OptionsProperties/VideoCodec.cs rename to src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/VideoCodec.cs diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/DataProperties/TransformationProperties/Type.cs b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Type.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/DataProperties/TransformationProperties/Type.cs rename to src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Type.cs diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/Request.cs b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/Request.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/Request.cs rename to src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/Request.cs diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEvent.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEvent.cs index a36eed25..111ff2cc 100644 --- a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEvent.cs +++ b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEvent.cs @@ -3,7 +3,7 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties; +using Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.IntersectionMember1Properties; namespace Imagekit.Models.Webhooks; @@ -40,6 +40,28 @@ public required string ID } } + /// + /// The type of webhook event. + /// + public required string Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("type"); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + /// /// Timestamp when the event was created in ISO8601 format. /// @@ -102,36 +124,20 @@ public required Request Request } } - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } + public static implicit operator BaseWebhookEvent( + VideoTransformationErrorEvent videoTransformationErrorEvent + ) => new() { ID = videoTransformationErrorEvent.ID, Type = videoTransformationErrorEvent.Type }; public override void Validate() { _ = this.ID; + _ = this.Type; _ = this.CreatedAt; this.Data.Validate(); this.Request.Validate(); } - public VideoTransformationErrorEvent() - { - this.Type = JsonSerializer.Deserialize("\"video.transformation.error\""); - } + public VideoTransformationErrorEvent() { } #pragma warning disable CS8618 [SetsRequiredMembers] diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1.cs new file mode 100644 index 00000000..f09b6c0a --- /dev/null +++ b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1.cs @@ -0,0 +1,123 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.IntersectionMember1Properties; + +namespace Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties; + +/// +/// Triggered when an error occurs during video encoding. Listen to this webhook to +/// log error reasons and debug issues. Check your origin and URL endpoint settings +/// if the reason is related to download failure. For other errors, contact ImageKit +/// support. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class IntersectionMember1 : ModelBase, IFromRaw +{ + /// + /// Timestamp when the event was created in ISO8601 format. + /// + public required DateTime CreatedAt + { + get + { + if (!this.Properties.TryGetValue("created_at", out JsonElement element)) + throw new ArgumentOutOfRangeException("created_at", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["created_at"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required Data Data + { + get + { + if (!this.Properties.TryGetValue("data", out JsonElement element)) + throw new ArgumentOutOfRangeException("data", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("data"); + } + set + { + this.Properties["data"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Information about the original request that triggered the video transformation. + /// + public required Request Request + { + get + { + if (!this.Properties.TryGetValue("request", out JsonElement element)) + throw new ArgumentOutOfRangeException("request", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("request"); + } + set + { + this.Properties["request"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.CreatedAt; + this.Data.Validate(); + this.Request.Validate(); + } + + public IntersectionMember1() + { + this.Type = JsonSerializer.Deserialize("\"video.transformation.error\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + IntersectionMember1(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static IntersectionMember1 FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/Data.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/Data.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/Data.cs rename to src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/Data.cs diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/Asset.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/Asset.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/Asset.cs rename to src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/Asset.cs diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/Transformation.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/Transformation.cs rename to src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/TransformationProperties/Error.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Error.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/TransformationProperties/Error.cs rename to src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Error.cs diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/TransformationProperties/ErrorProperties/Reason.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/ErrorProperties/Reason.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/TransformationProperties/ErrorProperties/Reason.cs rename to src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/ErrorProperties/Reason.cs diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/TransformationProperties/Options.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Options.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/TransformationProperties/Options.cs rename to src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Options.cs diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/TransformationProperties/OptionsProperties/AudioCodec.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/AudioCodec.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/TransformationProperties/OptionsProperties/AudioCodec.cs rename to src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/AudioCodec.cs diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/TransformationProperties/OptionsProperties/Format.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/Format.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/TransformationProperties/OptionsProperties/Format.cs rename to src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/Format.cs diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/TransformationProperties/OptionsProperties/StreamProtocol.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/StreamProtocol.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/TransformationProperties/OptionsProperties/StreamProtocol.cs rename to src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/StreamProtocol.cs diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/TransformationProperties/OptionsProperties/VideoCodec.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/VideoCodec.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/TransformationProperties/OptionsProperties/VideoCodec.cs rename to src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/VideoCodec.cs diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/TransformationProperties/Type.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Type.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/DataProperties/TransformationProperties/Type.cs rename to src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Type.cs diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/Request.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/Request.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/Request.cs rename to src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/Request.cs diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEvent.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEvent.cs index 330228c5..68b4823c 100644 --- a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEvent.cs +++ b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEvent.cs @@ -3,7 +3,7 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties; +using Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.IntersectionMember1Properties; namespace Imagekit.Models.Webhooks; @@ -40,6 +40,28 @@ public required string ID } } + /// + /// The type of webhook event. + /// + public required string Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("type"); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + /// /// Timestamp when the event was created in ISO8601 format. /// @@ -102,24 +124,6 @@ public required Request Request } } - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - /// /// Performance metrics for the transformation process. /// @@ -141,19 +145,21 @@ public Timings? Timings } } + public static implicit operator BaseWebhookEvent( + VideoTransformationReadyEvent videoTransformationReadyEvent + ) => new() { ID = videoTransformationReadyEvent.ID, Type = videoTransformationReadyEvent.Type }; + public override void Validate() { _ = this.ID; + _ = this.Type; _ = this.CreatedAt; this.Data.Validate(); this.Request.Validate(); this.Timings?.Validate(); } - public VideoTransformationReadyEvent() - { - this.Type = JsonSerializer.Deserialize("\"video.transformation.ready\""); - } + public VideoTransformationReadyEvent() { } #pragma warning disable CS8618 [SetsRequiredMembers] diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1.cs new file mode 100644 index 00000000..c8f14e2c --- /dev/null +++ b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1.cs @@ -0,0 +1,145 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.IntersectionMember1Properties; + +namespace Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties; + +/// +/// Triggered when video encoding is finished and the transformed resource is ready +/// to be served. This is the key event to listen for - update your database or CMS +/// flags when you receive this so your application can start showing the transformed +/// video to users. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class IntersectionMember1 : ModelBase, IFromRaw +{ + /// + /// Timestamp when the event was created in ISO8601 format. + /// + public required DateTime CreatedAt + { + get + { + if (!this.Properties.TryGetValue("created_at", out JsonElement element)) + throw new ArgumentOutOfRangeException("created_at", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["created_at"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required Data Data + { + get + { + if (!this.Properties.TryGetValue("data", out JsonElement element)) + throw new ArgumentOutOfRangeException("data", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("data"); + } + set + { + this.Properties["data"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Information about the original request that triggered the video transformation. + /// + public required Request Request + { + get + { + if (!this.Properties.TryGetValue("request", out JsonElement element)) + throw new ArgumentOutOfRangeException("request", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("request"); + } + set + { + this.Properties["request"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Performance metrics for the transformation process. + /// + public Timings? Timings + { + get + { + if (!this.Properties.TryGetValue("timings", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["timings"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.CreatedAt; + this.Data.Validate(); + this.Request.Validate(); + this.Timings?.Validate(); + } + + public IntersectionMember1() + { + this.Type = JsonSerializer.Deserialize("\"video.transformation.ready\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + IntersectionMember1(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static IntersectionMember1 FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/Data.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/Data.cs similarity index 95% rename from src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/Data.cs rename to src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/Data.cs index 1dd96038..9d7c11dd 100644 --- a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/Data.cs +++ b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/Data.cs @@ -3,9 +3,9 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using DataProperties = Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties; +using DataProperties = Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.IntersectionMember1Properties.DataProperties; -namespace Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties; +namespace Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.IntersectionMember1Properties; [JsonConverter(typeof(ModelConverter))] public sealed record class Data : ModelBase, IFromRaw diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/Asset.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/Asset.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/Asset.cs rename to src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/Asset.cs diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/Transformation.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/Transformation.cs rename to src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/TransformationProperties/Options.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Options.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/TransformationProperties/Options.cs rename to src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Options.cs diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/TransformationProperties/OptionsProperties/AudioCodec.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/AudioCodec.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/TransformationProperties/OptionsProperties/AudioCodec.cs rename to src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/AudioCodec.cs diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/TransformationProperties/OptionsProperties/Format.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/Format.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/TransformationProperties/OptionsProperties/Format.cs rename to src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/Format.cs diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/TransformationProperties/OptionsProperties/StreamProtocol.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/StreamProtocol.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/TransformationProperties/OptionsProperties/StreamProtocol.cs rename to src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/StreamProtocol.cs diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/TransformationProperties/OptionsProperties/VideoCodec.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/VideoCodec.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/TransformationProperties/OptionsProperties/VideoCodec.cs rename to src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/VideoCodec.cs diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/TransformationProperties/Output.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Output.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/TransformationProperties/Output.cs rename to src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Output.cs diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/TransformationProperties/OutputProperties/VideoMetadata.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OutputProperties/VideoMetadata.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/TransformationProperties/OutputProperties/VideoMetadata.cs rename to src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OutputProperties/VideoMetadata.cs diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/TransformationProperties/Type.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Type.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/DataProperties/TransformationProperties/Type.cs rename to src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Type.cs diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/Request.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/Request.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/Request.cs rename to src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/Request.cs diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/Timings.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/Timings.cs similarity index 100% rename from src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/Timings.cs rename to src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/Timings.cs From 17035ec25c24bf173d8145467e65ffca9f3d60c2 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 2 Sep 2025 08:15:32 +0000 Subject: [PATCH 005/129] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 52f982ba..cfcbd7f7 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-667f7f4988b44bc587d6eb9960ff5c8326e9f7e9b072f3f724f9f54166eff8b1.yml openapi_spec_hash: f2081864a4abee0480e5ff991b4c936a -config_hash: 08e12746cdca1c59c897cf2e50893c3c +config_hash: 70f9408b8d1dfbcf262a20d6eed50e1c From 255025ede629cc2a6a12462a12e82f99a4e88047 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 28 Jan 2026 16:30:58 +0000 Subject: [PATCH 006/129] feat(api): manual updates --- .stats.yml | 4 +- README.md | 2 +- .../Services/Files/FileServiceTest.cs | 140 +++++++++--------- 3 files changed, 73 insertions(+), 73 deletions(-) diff --git a/.stats.yml b/.stats.yml index cfcbd7f7..282d18eb 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-667f7f4988b44bc587d6eb9960ff5c8326e9f7e9b072f3f724f9f54166eff8b1.yml -openapi_spec_hash: f2081864a4abee0480e5ff991b4c936a +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-eab9713fd85da68b41e881dfd9cd71f654e8620132da2023bab7dd01e5f7852e.yml +openapi_spec_hash: b5037b26fbe7360c6bfaf9947a65bb85 config_hash: 70f9408b8d1dfbcf262a20d6eed50e1c diff --git a/README.md b/README.md index 22709ca0..24026d22 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ ImageKitClient client = new(); FileUploadParams parameters = new() { - File = "a value", + File = "https://www.example.com/public-url.jpg", FileName = "file-name.jpg", }; diff --git a/src/Imagekit.Tests/Services/Files/FileServiceTest.cs b/src/Imagekit.Tests/Services/Files/FileServiceTest.cs index 9241f04d..0ccbc624 100644 --- a/src/Imagekit.Tests/Services/Files/FileServiceTest.cs +++ b/src/Imagekit.Tests/Services/Files/FileServiceTest.cs @@ -1,70 +1,70 @@ -using System.Threading.Tasks; - -namespace Imagekit.Tests.Services.Files; - -public class FileServiceTest : TestBase -{ - [Fact(Skip = "Prism tests are disabled")] - public async Task Update_Works() - { - var file = await this.client.Files.Update(new() { FileID = "fileId" }); - file.Validate(); - } - - [Fact(Skip = "Prism tests are disabled")] - public async Task Delete_Works() - { - await this.client.Files.Delete(new() { FileID = "fileId" }); - } - - [Fact(Skip = "Prism tests are disabled")] - public async Task Copy_Works() - { - var response = await this.client.Files.Copy( - new() - { - DestinationPath = "/folder/to/copy/into/", - SourceFilePath = "/path/to/file.jpg", - } - ); - response.Validate(); - } - - [Fact(Skip = "Prism tests are disabled")] - public async Task Get_Works() - { - var file = await this.client.Files.Get(new() { FileID = "fileId" }); - file.Validate(); - } - - [Fact(Skip = "Prism tests are disabled")] - public async Task Move_Works() - { - var response = await this.client.Files.Move( - new() - { - DestinationPath = "/folder/to/move/into/", - SourceFilePath = "/path/to/file.jpg", - } - ); - response.Validate(); - } - - [Fact(Skip = "Prism tests are disabled")] - public async Task Rename_Works() - { - var response = await this.client.Files.Rename( - new() { FilePath = "/path/to/file.jpg", NewFileName = "newFileName.jpg" } - ); - response.Validate(); - } - - [Fact(Skip = "Prism tests are disabled")] - public async Task Upload_Works() - { - var response = await this.client.Files.Upload( - new() { File = "a value", FileName = "fileName" } - ); - response.Validate(); - } -} +using System.Threading.Tasks; + +namespace Imagekit.Tests.Services.Files; + +public class FileServiceTest : TestBase +{ + [Fact(Skip = "Prism tests are disabled")] + public async Task Update_Works() + { + var file = await this.client.Files.Update(new() { FileID = "fileId" }); + file.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Delete_Works() + { + await this.client.Files.Delete(new() { FileID = "fileId" }); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Copy_Works() + { + var response = await this.client.Files.Copy( + new() + { + DestinationPath = "/folder/to/copy/into/", + SourceFilePath = "/path/to/file.jpg", + } + ); + response.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Get_Works() + { + var file = await this.client.Files.Get(new() { FileID = "fileId" }); + file.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Move_Works() + { + var response = await this.client.Files.Move( + new() + { + DestinationPath = "/folder/to/move/into/", + SourceFilePath = "/path/to/file.jpg", + } + ); + response.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Rename_Works() + { + var response = await this.client.Files.Rename( + new() { FilePath = "/path/to/file.jpg", NewFileName = "newFileName.jpg" } + ); + response.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Upload_Works() + { + var response = await this.client.Files.Upload( + new() { File = "a value", FileName = "fileName" } + ); + response.Validate(); + } +} From a1a7ff4d748d705978d0f48f382780dd1eaa3c8f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 28 Jan 2026 16:34:22 +0000 Subject: [PATCH 007/129] feat(api): manual updates --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 282d18eb..7698a81b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-eab9713fd85da68b41e881dfd9cd71f654e8620132da2023bab7dd01e5f7852e.yml -openapi_spec_hash: b5037b26fbe7360c6bfaf9947a65bb85 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-911102f2eaf3be4b34381f6ba089330bed099bb72eb93667ce2f6e72b5934c8c.yml +openapi_spec_hash: 637ad417a580137914441bd790b04cc2 config_hash: 70f9408b8d1dfbcf262a20d6eed50e1c From 1bb691ba1c7bd346d5f9b43f83bf661f27f23767 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 2 Sep 2025 08:23:19 +0000 Subject: [PATCH 008/129] feat(api): manual updates --- .stats.yml | 4 ++-- README.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.stats.yml b/.stats.yml index 7698a81b..d42605f1 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-911102f2eaf3be4b34381f6ba089330bed099bb72eb93667ce2f6e72b5934c8c.yml -openapi_spec_hash: 637ad417a580137914441bd790b04cc2 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-0726d89b19f532c7fb92990d688a9bfb5aa4a9a871d64f49d4ba45bac6998e4a.yml +openapi_spec_hash: 9525bb02ab496b3459a1f93ac50968e3 config_hash: 70f9408b8d1dfbcf262a20d6eed50e1c diff --git a/README.md b/README.md index 24026d22..22709ca0 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ ImageKitClient client = new(); FileUploadParams parameters = new() { - File = "https://www.example.com/public-url.jpg", + File = "a value", FileName = "file-name.jpg", }; From 0bb2d8f21313a947a0a718f09317e325de0ae47b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 2 Sep 2025 08:32:30 +0000 Subject: [PATCH 009/129] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index d42605f1..cfcbd7f7 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-0726d89b19f532c7fb92990d688a9bfb5aa4a9a871d64f49d4ba45bac6998e4a.yml -openapi_spec_hash: 9525bb02ab496b3459a1f93ac50968e3 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-667f7f4988b44bc587d6eb9960ff5c8326e9f7e9b072f3f724f9f54166eff8b1.yml +openapi_spec_hash: f2081864a4abee0480e5ff991b4c936a config_hash: 70f9408b8d1dfbcf262a20d6eed50e1c From 3101896649dbd245ce572e34882675540953406e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 28 Jan 2026 17:09:51 +0000 Subject: [PATCH 010/129] feat(api): manual updates --- .stats.yml | 4 +- README.md | 9 +- .../Services/Files/FileServiceTest.cs | 4 +- src/Imagekit/ModelBase.cs | 412 +++++------ src/Imagekit/Models/Files/FileUploadParams.cs | 567 +--------------- .../Files/FileUploadParamsProperties/Body.cs | 117 ++++ .../BodyProperties/FileUploadV1.cs | 642 ++++++++++++++++++ .../BodyProperties/FileUploadV1ByURL.cs | 637 +++++++++++++++++ .../FileUploadV1ByURLProperties/Extension.cs | 177 +++++ .../AutoTaggingExtension.cs | 100 +++ .../AutoTaggingExtensionProperties/Name.cs | 46 ++ .../ExtensionProperties/RemoveBg.cs | 74 ++ .../RemoveBgProperties/Options.cs | 122 ++++ .../ExtensionVariants/All.cs | 46 ++ .../ResponseField.cs | 62 ++ .../Transformation.cs | 92 +++ .../TransformationProperties/Post.cs | 225 ++++++ .../PostProperties/Abs.cs | 103 +++ .../PostProperties/AbsProperties/Protocol.cs | 46 ++ .../PostProperties/GifToVideo.cs | 77 +++ .../PostProperties/Thumbnail.cs | 76 +++ .../PostProperties/Transformation.cs | 85 +++ .../PostVariants/All.cs | 61 ++ .../FileUploadV1Properties}/Extension.cs | 6 +- .../AutoTaggingExtension.cs | 4 +- .../AutoTaggingExtensionProperties/Name.cs | 2 +- .../ExtensionProperties/RemoveBg.cs | 4 +- .../RemoveBgProperties/Options.cs | 2 +- .../ExtensionVariants/All.cs | 4 +- .../FileUploadV1Properties}/ResponseField.cs | 2 +- .../FileUploadV1Properties}/Transformation.cs | 4 +- .../TransformationProperties/Post.cs | 6 +- .../PostProperties/Abs.cs | 4 +- .../PostProperties/AbsProperties/Protocol.cs | 2 +- .../PostProperties/GifToVideo.cs | 2 +- .../PostProperties/Thumbnail.cs | 2 +- .../PostProperties/Transformation.cs | 2 +- .../PostVariants/All.cs | 4 +- .../BodyVariants/All.cs | 33 + src/Imagekit/Services/Files/FileService.cs | 4 +- src/Imagekit/Services/Files/IFileService.cs | 2 +- 41 files changed, 3069 insertions(+), 804 deletions(-) create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/Body.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURL.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/Extension.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/ExtensionProperties/AutoTaggingExtension.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/ExtensionProperties/RemoveBg.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/ExtensionProperties/RemoveBgProperties/Options.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/ExtensionVariants/All.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/ResponseField.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/Transformation.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/Post.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/PostProperties/Abs.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/PostProperties/GifToVideo.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/PostProperties/Thumbnail.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/PostProperties/Transformation.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/PostVariants/All.cs rename src/Imagekit/Models/Files/FileUploadParamsProperties/{ => BodyProperties/FileUploadV1Properties}/Extension.cs (95%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{ => BodyProperties/FileUploadV1Properties}/ExtensionProperties/AutoTaggingExtension.cs (91%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{ => BodyProperties/FileUploadV1Properties}/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs (88%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{ => BodyProperties/FileUploadV1Properties}/ExtensionProperties/RemoveBg.cs (88%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{ => BodyProperties/FileUploadV1Properties}/ExtensionProperties/RemoveBgProperties/Options.cs (96%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{ => BodyProperties/FileUploadV1Properties}/ExtensionVariants/All.cs (85%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{ => BodyProperties/FileUploadV1Properties}/ResponseField.cs (94%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{ => BodyProperties/FileUploadV1Properties}/Transformation.cs (92%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{ => BodyProperties/FileUploadV1Properties}/TransformationProperties/Post.cs (95%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{ => BodyProperties/FileUploadV1Properties}/TransformationProperties/PostProperties/Abs.cs (90%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{ => BodyProperties/FileUploadV1Properties}/TransformationProperties/PostProperties/AbsProperties/Protocol.cs (87%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{ => BodyProperties/FileUploadV1Properties}/TransformationProperties/PostProperties/GifToVideo.cs (93%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{ => BodyProperties/FileUploadV1Properties}/TransformationProperties/PostProperties/Thumbnail.cs (93%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{ => BodyProperties/FileUploadV1Properties}/TransformationProperties/PostProperties/Transformation.cs (94%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{ => BodyProperties/FileUploadV1Properties}/TransformationProperties/PostVariants/All.cs (85%) create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyVariants/All.cs diff --git a/.stats.yml b/.stats.yml index cfcbd7f7..d458a07c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-667f7f4988b44bc587d6eb9960ff5c8326e9f7e9b072f3f724f9f54166eff8b1.yml -openapi_spec_hash: f2081864a4abee0480e5ff991b4c936a +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-e7bc47a9221d7da9c8c9653d3fd1d4cfdf2408588e32c4aa62bd02a50ec93c36.yml +openapi_spec_hash: 8d061396a2fff9d1add4d5baf03ab939 config_hash: 70f9408b8d1dfbcf262a20d6eed50e1c diff --git a/README.md b/README.md index 22709ca0..983e086a 100644 --- a/README.md +++ b/README.md @@ -34,18 +34,11 @@ See the [`examples`](examples) directory for complete and runnable examples. ```csharp using System; using Imagekit; -using Imagekit.Models.Files; // Configured using the IMAGEKIT_PRIVATE_API_KEY, OPTIONAL_IMAGEKIT_IGNORES_THIS, IMAGEKIT_WEBHOOK_SECRET and IMAGE_KIT_BASE_URL environment variables ImageKitClient client = new(); -FileUploadParams parameters = new() -{ - File = "a value", - FileName = "file-name.jpg", -}; - -var response = await client.Files.Upload(parameters); +var response = await client.Files.Upload(); Console.WriteLine(response); ``` diff --git a/src/Imagekit.Tests/Services/Files/FileServiceTest.cs b/src/Imagekit.Tests/Services/Files/FileServiceTest.cs index 0ccbc624..2d71ee4f 100644 --- a/src/Imagekit.Tests/Services/Files/FileServiceTest.cs +++ b/src/Imagekit.Tests/Services/Files/FileServiceTest.cs @@ -62,9 +62,7 @@ public async Task Rename_Works() [Fact(Skip = "Prism tests are disabled")] public async Task Upload_Works() { - var response = await this.client.Files.Upload( - new() { File = "a value", FileName = "fileName" } - ); + var response = await this.client.Files.Upload(); response.Validate(); } } diff --git a/src/Imagekit/ModelBase.cs b/src/Imagekit/ModelBase.cs index 7e43b00e..5b88cb2f 100644 --- a/src/Imagekit/ModelBase.cs +++ b/src/Imagekit/ModelBase.cs @@ -1,202 +1,210 @@ -using System.Collections.Generic; -using System.Text.Json; -using Imagekit.Models; -using Imagekit.Models.Cache.Invalidation.InvalidationGetResponseProperties; -using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties; -using Imagekit.Models.Files.FileUpdateParamsProperties.UpdateProperties.UpdateFileDetailsProperties.ExtensionProperties.AutoTaggingExtensionProperties; -using Imagekit.Models.Files.FileUpdateResponseProperties.IntersectionMember1Properties.ExtensionStatusProperties; -using Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.AbsProperties; -using Imagekit.Models.ImageOverlayProperties.IntersectionMember1Properties; -using Imagekit.Models.OverlayPositionProperties; -using Imagekit.Models.SubtitleOverlayTransformationProperties; -using Imagekit.Models.TextOverlayTransformationProperties; -using Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.DataProperties.TransformationProperties.OptionsProperties; -using Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.DataProperties.TransformationProperties.ErrorProperties; -using AbsProperties = Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.AbsProperties; -using AssetListParamsProperties = Imagekit.Models.Assets.AssetListParamsProperties; -using AutoTaggingExtensionProperties = Imagekit.Models.Files.FileUploadParamsProperties.ExtensionProperties.AutoTaggingExtensionProperties; -using ExtensionStatusProperties = Imagekit.Models.Files.FileUploadResponseProperties.ExtensionStatusProperties; -using FileProperties = Imagekit.Models.Files.FileProperties; -using FileUploadParamsProperties = Imagekit.Models.Files.FileUploadParamsProperties; -using FolderProperties = Imagekit.Models.Files.FolderProperties; -using IntersectionMember1Properties = Imagekit.Models.SubtitleOverlayProperties.IntersectionMember1Properties; -using JobGetResponseProperties = Imagekit.Models.Folders.Job.JobGetResponseProperties; -using OptionsProperties = Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.DataProperties.TransformationProperties.OptionsProperties; -using SchemaProperties = Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties; -using TransformationProperties = Imagekit.Models.TransformationProperties; - -namespace Imagekit; - -public abstract record class ModelBase -{ - public Dictionary Properties { get; set; } = []; - - internal static readonly JsonSerializerOptions SerializerOptions = new() - { - Converters = - { - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter< - string, - global::Imagekit.Models.TextOverlayProperties.IntersectionMember1Properties.Encoding - >(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter< - string, - global::Imagekit.Models.VideoOverlayProperties.IntersectionMember1Properties.Encoding - >(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter< - string, - global::Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.ExtensionStatusProperties.AIAutoDescription - >(), - new ApiEnumConverter< - string, - global::Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.ExtensionStatusProperties.AwsAutoTagging - >(), - new ApiEnumConverter< - string, - global::Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.ExtensionStatusProperties.GoogleAutoTagging - >(), - new ApiEnumConverter< - string, - global::Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.ExtensionStatusProperties.RemoveBg - >(), - new ApiEnumConverter< - string, - global::Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.ExtensionProperties.AutoTaggingExtensionProperties.Name - >(), - new ApiEnumConverter< - string, - global::Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.ResponseField - >(), - new ApiEnumConverter(), - new ApiEnumConverter< - string, - global::Imagekit.Models.Webhooks.UploadPostTransformErrorEventProperties.RequestProperties.TransformationProperties.Type - >(), - new ApiEnumConverter< - string, - global::Imagekit.Models.Webhooks.UploadPostTransformErrorEventProperties.RequestProperties.TransformationProperties.Protocol - >(), - new ApiEnumConverter< - string, - global::Imagekit.Models.Webhooks.UploadPostTransformSuccessEventProperties.RequestProperties.TransformationProperties.Type - >(), - new ApiEnumConverter< - string, - global::Imagekit.Models.Webhooks.UploadPostTransformSuccessEventProperties.RequestProperties.TransformationProperties.Protocol - >(), - new ApiEnumConverter< - string, - global::Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.DataProperties.ExtensionStatusProperties.AIAutoDescription - >(), - new ApiEnumConverter< - string, - global::Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.DataProperties.ExtensionStatusProperties.AwsAutoTagging - >(), - new ApiEnumConverter< - string, - global::Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.DataProperties.ExtensionStatusProperties.GoogleAutoTagging - >(), - new ApiEnumConverter< - string, - global::Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.DataProperties.ExtensionStatusProperties.RemoveBg - >(), - new ApiEnumConverter< - string, - global::Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.DataProperties.TransformationProperties.Type - >(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter< - string, - global::Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.DataProperties.TransformationProperties.Type - >(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter< - string, - global::Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties.TransformationProperties.Type - >(), - new ApiEnumConverter< - string, - global::Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties.TransformationProperties.OptionsProperties.AudioCodec - >(), - new ApiEnumConverter< - string, - global::Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties.TransformationProperties.OptionsProperties.Format - >(), - new ApiEnumConverter< - string, - global::Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties.TransformationProperties.OptionsProperties.StreamProtocol - >(), - new ApiEnumConverter< - string, - global::Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties.TransformationProperties.OptionsProperties.VideoCodec - >(), - }, - }; - - static readonly JsonSerializerOptions _toStringSerializerOptions = new(SerializerOptions) - { - WriteIndented = true, - }; - - public sealed override string? ToString() - { - return JsonSerializer.Serialize(this.Properties, _toStringSerializerOptions); - } - - public abstract void Validate(); -} - -interface IFromRaw -{ - static abstract T FromRawUnchecked(Dictionary properties); -} +using System.Collections.Generic; +using System.Text.Json; +using Imagekit.Models; +using Imagekit.Models.Cache.Invalidation.InvalidationGetResponseProperties; +using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties; +using Imagekit.Models.Files.FileUpdateParamsProperties.UpdateProperties.UpdateFileDetailsProperties.ExtensionProperties.AutoTaggingExtensionProperties; +using Imagekit.Models.Files.FileUpdateResponseProperties.IntersectionMember1Properties.ExtensionStatusProperties; +using Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.TransformationProperties.PostProperties.AbsProperties; +using Imagekit.Models.ImageOverlayProperties.IntersectionMember1Properties; +using Imagekit.Models.OverlayPositionProperties; +using Imagekit.Models.SubtitleOverlayTransformationProperties; +using Imagekit.Models.TextOverlayTransformationProperties; +using Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.IntersectionMember1Properties.DataProperties.TransformationProperties.OptionsProperties; +using Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.IntersectionMember1Properties.DataProperties.TransformationProperties.ErrorProperties; +using AbsProperties = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties.TransformationProperties.PostProperties.AbsProperties; +using AssetListParamsProperties = Imagekit.Models.Assets.AssetListParamsProperties; +using AutoTaggingExtensionProperties = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.ExtensionProperties.AutoTaggingExtensionProperties; +using ExtensionStatusProperties = Imagekit.Models.Files.FileUploadResponseProperties.ExtensionStatusProperties; +using FileProperties = Imagekit.Models.Files.FileProperties; +using FileUploadParamsProperties = Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties; +using FileUploadV1ByURLProperties = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties; +using FileUploadV1Properties = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties; +using FolderProperties = Imagekit.Models.Files.FolderProperties; +using IntersectionMember1Properties = Imagekit.Models.SubtitleOverlayProperties.IntersectionMember1Properties; +using JobGetResponseProperties = Imagekit.Models.Folders.Job.JobGetResponseProperties; +using OptionsProperties = Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.IntersectionMember1Properties.DataProperties.TransformationProperties.OptionsProperties; +using SchemaProperties = Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties; +using TransformationProperties = Imagekit.Models.TransformationProperties; + +namespace Imagekit; + +public abstract record class ModelBase +{ + public Dictionary Properties { get; set; } = []; + + internal static readonly JsonSerializerOptions SerializerOptions = new() + { + Converters = + { + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter< + string, + global::Imagekit.Models.TextOverlayProperties.IntersectionMember1Properties.Encoding + >(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter< + string, + global::Imagekit.Models.VideoOverlayProperties.IntersectionMember1Properties.Encoding + >(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter< + string, + global::Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties.ExtensionProperties.AutoTaggingExtensionProperties.Name + >(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter< + string, + global::Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.ExtensionStatusProperties.AIAutoDescription + >(), + new ApiEnumConverter< + string, + global::Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.ExtensionStatusProperties.AwsAutoTagging + >(), + new ApiEnumConverter< + string, + global::Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.ExtensionStatusProperties.GoogleAutoTagging + >(), + new ApiEnumConverter< + string, + global::Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.ExtensionStatusProperties.RemoveBg + >(), + new ApiEnumConverter< + string, + global::Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.ExtensionProperties.AutoTaggingExtensionProperties.Name + >(), + new ApiEnumConverter(), + new ApiEnumConverter< + string, + global::Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.AbsProperties.Protocol + >(), + new ApiEnumConverter< + string, + global::Imagekit.Models.Webhooks.UploadPostTransformErrorEventProperties.IntersectionMember1Properties.RequestProperties.TransformationProperties.Type + >(), + new ApiEnumConverter< + string, + global::Imagekit.Models.Webhooks.UploadPostTransformErrorEventProperties.IntersectionMember1Properties.RequestProperties.TransformationProperties.Protocol + >(), + new ApiEnumConverter< + string, + global::Imagekit.Models.Webhooks.UploadPostTransformSuccessEventProperties.IntersectionMember1Properties.RequestProperties.TransformationProperties.Type + >(), + new ApiEnumConverter< + string, + global::Imagekit.Models.Webhooks.UploadPostTransformSuccessEventProperties.IntersectionMember1Properties.RequestProperties.TransformationProperties.Protocol + >(), + new ApiEnumConverter< + string, + global::Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.ExtensionStatusProperties.AIAutoDescription + >(), + new ApiEnumConverter< + string, + global::Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.ExtensionStatusProperties.AwsAutoTagging + >(), + new ApiEnumConverter< + string, + global::Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.ExtensionStatusProperties.GoogleAutoTagging + >(), + new ApiEnumConverter< + string, + global::Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.ExtensionStatusProperties.RemoveBg + >(), + new ApiEnumConverter< + string, + global::Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.IntersectionMember1Properties.DataProperties.TransformationProperties.Type + >(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter< + string, + global::Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.IntersectionMember1Properties.DataProperties.TransformationProperties.Type + >(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter< + string, + global::Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.IntersectionMember1Properties.DataProperties.TransformationProperties.Type + >(), + new ApiEnumConverter< + string, + global::Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.IntersectionMember1Properties.DataProperties.TransformationProperties.OptionsProperties.AudioCodec + >(), + new ApiEnumConverter< + string, + global::Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.IntersectionMember1Properties.DataProperties.TransformationProperties.OptionsProperties.Format + >(), + new ApiEnumConverter< + string, + global::Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.IntersectionMember1Properties.DataProperties.TransformationProperties.OptionsProperties.StreamProtocol + >(), + new ApiEnumConverter< + string, + global::Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.IntersectionMember1Properties.DataProperties.TransformationProperties.OptionsProperties.VideoCodec + >(), + }, + }; + + static readonly JsonSerializerOptions _toStringSerializerOptions = new(SerializerOptions) + { + WriteIndented = true, + }; + + public sealed override string? ToString() + { + return JsonSerializer.Serialize(this.Properties, _toStringSerializerOptions); + } + + public abstract void Validate(); +} + +interface IFromRaw +{ + static abstract T FromRawUnchecked(Dictionary properties); +} diff --git a/src/Imagekit/Models/Files/FileUploadParams.cs b/src/Imagekit/Models/Files/FileUploadParams.cs index 6d1d3bd2..8942bd04 100644 --- a/src/Imagekit/Models/Files/FileUploadParams.cs +++ b/src/Imagekit/Models/Files/FileUploadParams.cs @@ -3,7 +3,7 @@ using System.Net.Http; using System.Text; using System.Text.Json; -using FileUploadParamsProperties = Imagekit.Models.Files.FileUploadParamsProperties; +using Imagekit.Models.Files.FileUploadParamsProperties; namespace Imagekit.Models.Files; @@ -35,575 +35,18 @@ public sealed record class FileUploadParams : ParamsBase { public Dictionary BodyProperties { get; set; } = []; - /// - /// The API accepts any of the following: - /// - /// - **Binary data** – send the raw bytes as `multipart/form-data`. - **HTTP - /// / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. - /// - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. - /// - /// When supplying a URL, the server must receive the response headers within - /// 8 seconds; otherwise the request fails with 400 Bad Request. - /// - public required string File + public Body? Body { get { - if (!this.BodyProperties.TryGetValue("file", out JsonElement element)) - throw new ArgumentOutOfRangeException("file", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("file"); - } - set - { - this.BodyProperties["file"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The name with which the file has to be uploaded. The file name can contain: - /// - /// - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. - Special Characters: - /// `.`, `-` - /// - /// Any other character including space will be replaced by `_` - /// - public required string FileName - { - get - { - if (!this.BodyProperties.TryGetValue("fileName", out JsonElement element)) - throw new ArgumentOutOfRangeException("fileName", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("fileName"); - } - set - { - this.BodyProperties["fileName"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// A unique value that the ImageKit.io server will use to recognize and prevent - /// subsequent retries for the same request. We suggest using V4 UUIDs, or another - /// random string with enough entropy to avoid collisions. This field is only - /// required for authentication when uploading a file from the client side. - /// - /// **Note**: Sending a value that has been used in the past will result in a - /// validation error. Even if your previous request resulted in an error, you - /// should always send a new value for this field. - /// - public string? Token - { - get - { - if (!this.BodyProperties.TryGetValue("token", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["token"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Server-side checks to run on the asset. Read more about [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). - /// - public string? Checks - { - get - { - if (!this.BodyProperties.TryGetValue("checks", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["checks"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Define an important area in the image. This is only relevant for image type files. - /// - /// - To be passed as a string with the x and y coordinates of the top-left - /// corner, and width and height of the area of interest in the format `x,y,width,height`. - /// For example - `10,10,100,100` - Can be used with fo-customtransformation. - /// - If this field is not specified and the file is overwritten, then customCoordinates - /// will be removed. - /// - public string? CustomCoordinates - { - get - { - if (!this.BodyProperties.TryGetValue("customCoordinates", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["customCoordinates"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// JSON key-value pairs to associate with the asset. Create the custom metadata - /// fields before setting these values. - /// - public Dictionary? CustomMetadata - { - get - { - if (!this.BodyProperties.TryGetValue("customMetadata", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.BodyProperties["customMetadata"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Optional text to describe the contents of the file. - /// - public string? Description - { - get - { - if (!this.BodyProperties.TryGetValue("description", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["description"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The time until your signature is valid. It must be a [Unix time](https://en.wikipedia.org/wiki/Unix_time) - /// in less than 1 hour into the future. It should be in seconds. This field is - /// only required for authentication when uploading a file from the client side. - /// - public long? Expire - { - get - { - if (!this.BodyProperties.TryGetValue("expire", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["expire"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Array of extensions to be applied to the image. Each extension can be configured - /// with specific parameters based on the extension type. - /// - public List? Extensions - { - get - { - if (!this.BodyProperties.TryGetValue("extensions", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.BodyProperties["extensions"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The folder path in which the image has to be uploaded. If the folder(s) didn't - /// exist before, a new folder(s) is created. - /// - /// The folder name can contain: - /// - /// - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` - Special Characters: - /// `/` , `_` , `-` - /// - /// Using multiple `/` creates a nested folder. - /// - public string? Folder - { - get - { - if (!this.BodyProperties.TryGetValue("folder", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["folder"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to mark the file as private or not. - /// - /// If `true`, the file is marked as private and is accessible only using named - /// transformation or signed URL. - /// - public bool? IsPrivateFile - { - get - { - if (!this.BodyProperties.TryGetValue("isPrivateFile", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["isPrivateFile"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to upload file as published or not. - /// - /// If `false`, the file is marked as unpublished, which restricts access to the - /// file only via the media library. Files in draft or unpublished state can only - /// be publicly accessed after being published. - /// - /// The option to upload in draft state is only available in custom enterprise - /// pricing plans. - /// - public bool? IsPublished - { - get - { - if (!this.BodyProperties.TryGetValue("isPublished", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["isPublished"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// If set to `true` and a file already exists at the exact location, its AITags - /// will be removed. Set `overwriteAITags` to `false` to preserve AITags. - /// - public bool? OverwriteAITags - { - get - { - if (!this.BodyProperties.TryGetValue("overwriteAITags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["overwriteAITags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// If the request does not have `customMetadata`, and a file already exists at - /// the exact location, existing customMetadata will be removed. - /// - public bool? OverwriteCustomMetadata - { - get - { - if ( - !this.BodyProperties.TryGetValue("overwriteCustomMetadata", out JsonElement element) - ) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["overwriteCustomMetadata"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// If `false` and `useUniqueFileName` is also `false`, and a file already exists - /// at the exact location, upload API will return an error immediately. - /// - public bool? OverwriteFile - { - get - { - if (!this.BodyProperties.TryGetValue("overwriteFile", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["overwriteFile"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// If the request does not have `tags`, and a file already exists at the exact - /// location, existing tags will be removed. - /// - public bool? OverwriteTags - { - get - { - if (!this.BodyProperties.TryGetValue("overwriteTags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["overwriteTags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Your ImageKit.io public key. This field is only required for authentication - /// when uploading a file from the client side. - /// - public string? PublicKey - { - get - { - if (!this.BodyProperties.TryGetValue("publicKey", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["publicKey"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Array of response field keys to include in the API response body. - /// - public List>? ResponseFields - { - get - { - if (!this.BodyProperties.TryGetValue("responseFields", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize - >?>(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["responseFields"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key - /// as a key. Learn how to create a signature on the page below. This should be - /// in lowercase. - /// - /// Signature must be calculated on the server-side. This field is only required - /// for authentication when uploading a file from the client side. - /// - public string? Signature - { - get - { - if (!this.BodyProperties.TryGetValue("signature", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["signature"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Set the tags while uploading the file. Provide an array of tag strings (e.g. - /// `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must - /// not exceed 500, and the `%` character is not allowed. If this field is not - /// specified and the file is overwritten, the existing tags will be removed. - /// - public List? Tags - { - get - { - if (!this.BodyProperties.TryGetValue("tags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["tags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Configure pre-processing (`pre`) and post-processing (`post`) transformations. - /// - /// - `pre` — applied before the file is uploaded to the Media Library. Useful - /// for reducing file size or applying basic optimizations upfront (e.g., resize, compress). - /// - /// - `post` — applied immediately after upload. Ideal for generating transformed - /// versions (like video encodes or thumbnails) in advance, so they're ready for - /// delivery without delay. - /// - /// You can mix and match any combination of post-processing types. - /// - public FileUploadParamsProperties::Transformation? Transformation - { - get - { - if (!this.BodyProperties.TryGetValue("transformation", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.BodyProperties["transformation"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to use a unique filename for this file or not. - /// - /// If `true`, ImageKit.io will add a unique suffix to the filename parameter - /// to get a unique filename. - /// - /// If `false`, then the image is uploaded with the provided filename parameter, - /// and any existing file with the same name is replaced. - /// - public bool? UseUniqueFileName - { - get - { - if (!this.BodyProperties.TryGetValue("useUniqueFileName", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["useUniqueFileName"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The final status of extensions after they have completed execution will be - /// delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) - /// about the webhook payload structure. - /// - public string? WebhookURL - { - get - { - if (!this.BodyProperties.TryGetValue("webhookUrl", out JsonElement element)) + if (!this.BodyProperties.TryGetValue("body", out JsonElement element)) return null; - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); } set { - this.BodyProperties["webhookUrl"] = JsonSerializer.SerializeToElement( + this.BodyProperties["body"] = JsonSerializer.SerializeToElement( value, ModelBase.SerializerOptions ); diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/Body.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/Body.cs new file mode 100644 index 00000000..833d7774 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/Body.cs @@ -0,0 +1,117 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties; +using BodyVariants = Imagekit.Models.Files.FileUploadParamsProperties.BodyVariants; + +namespace Imagekit.Models.Files.FileUploadParamsProperties; + +[JsonConverter(typeof(BodyConverter))] +public abstract record class Body +{ + internal Body() { } + + public static implicit operator Body(FileUploadV1 value) => + new BodyVariants::FileUploadV1(value); + + public static implicit operator Body(FileUploadV1ByURL value) => + new BodyVariants::FileUploadV1ByURL(value); + + public bool TryPickFileUploadV1([NotNullWhen(true)] out FileUploadV1? value) + { + value = (this as BodyVariants::FileUploadV1)?.Value; + return value != null; + } + + public bool TryPickFileUploadV1ByURL([NotNullWhen(true)] out FileUploadV1ByURL? value) + { + value = (this as BodyVariants::FileUploadV1ByURL)?.Value; + return value != null; + } + + public void Switch( + Action fileUploadV1, + Action fileUploadV1ByURL + ) + { + switch (this) + { + case BodyVariants::FileUploadV1 inner: + fileUploadV1(inner); + break; + case BodyVariants::FileUploadV1ByURL inner: + fileUploadV1ByURL(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func fileUploadV1, + Func fileUploadV1ByURL + ) + { + return this switch + { + BodyVariants::FileUploadV1 inner => fileUploadV1(inner), + BodyVariants::FileUploadV1ByURL inner => fileUploadV1ByURL(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class BodyConverter : JsonConverter +{ + public override Body? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new BodyVariants::FileUploadV1(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new BodyVariants::FileUploadV1ByURL(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + + public override void Write(Utf8JsonWriter writer, Body value, JsonSerializerOptions options) + { + object variant = value switch + { + BodyVariants::FileUploadV1(var fileUploadV1) => fileUploadV1, + BodyVariants::FileUploadV1ByURL(var fileUploadV1ByURL) => fileUploadV1ByURL, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1.cs new file mode 100644 index 00000000..25020d6b --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1.cs @@ -0,0 +1,642 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using FileUploadV1Properties = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class FileUploadV1 : ModelBase, IFromRaw +{ + /// + /// The API accepts any of the following: + /// + /// - **Binary data** – send the raw bytes as `multipart/form-data`. - **HTTP + /// / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + /// - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + /// + /// When supplying a URL, the server must receive the response headers within + /// 8 seconds; otherwise the request fails with 400 Bad Request. + /// + public required string File + { + get + { + if (!this.Properties.TryGetValue("file", out JsonElement element)) + throw new ArgumentOutOfRangeException("file", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("file"); + } + set + { + this.Properties["file"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The name with which the file has to be uploaded. The file name can contain: + /// + /// - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. - Special Characters: + /// `.`, `-` + /// + /// Any other character including space will be replaced by `_` + /// + public required string FileName + { + get + { + if (!this.Properties.TryGetValue("fileName", out JsonElement element)) + throw new ArgumentOutOfRangeException("fileName", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("fileName"); + } + set + { + this.Properties["fileName"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// A unique value that the ImageKit.io server will use to recognize and prevent + /// subsequent retries for the same request. We suggest using V4 UUIDs, or another + /// random string with enough entropy to avoid collisions. This field is only + /// required for authentication when uploading a file from the client side. + /// + /// **Note**: Sending a value that has been used in the past will result in a + /// validation error. Even if your previous request resulted in an error, you + /// should always send a new value for this field. + /// + public string? Token + { + get + { + if (!this.Properties.TryGetValue("token", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["token"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Server-side checks to run on the asset. Read more about [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). + /// + public string? Checks + { + get + { + if (!this.Properties.TryGetValue("checks", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["checks"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Define an important area in the image. This is only relevant for image type files. + /// + /// - To be passed as a string with the x and y coordinates of the top-left + /// corner, and width and height of the area of interest in the format `x,y,width,height`. + /// For example - `10,10,100,100` - Can be used with fo-customtransformation. + /// - If this field is not specified and the file is overwritten, then customCoordinates + /// will be removed. + /// + public string? CustomCoordinates + { + get + { + if (!this.Properties.TryGetValue("customCoordinates", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["customCoordinates"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// JSON key-value pairs to associate with the asset. Create the custom metadata + /// fields before setting these values. + /// + public Dictionary? CustomMetadata + { + get + { + if (!this.Properties.TryGetValue("customMetadata", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["customMetadata"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Optional text to describe the contents of the file. + /// + public string? Description + { + get + { + if (!this.Properties.TryGetValue("description", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["description"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The time until your signature is valid. It must be a [Unix time](https://en.wikipedia.org/wiki/Unix_time) + /// in less than 1 hour into the future. It should be in seconds. This field is + /// only required for authentication when uploading a file from the client side. + /// + public long? Expire + { + get + { + if (!this.Properties.TryGetValue("expire", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["expire"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Array of extensions to be applied to the image. Each extension can be configured + /// with specific parameters based on the extension type. + /// + public List? Extensions + { + get + { + if (!this.Properties.TryGetValue("extensions", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["extensions"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The folder path in which the image has to be uploaded. If the folder(s) didn't + /// exist before, a new folder(s) is created. + /// + /// The folder name can contain: + /// + /// - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` - Special Characters: + /// `/` , `_` , `-` + /// + /// Using multiple `/` creates a nested folder. + /// + public string? Folder + { + get + { + if (!this.Properties.TryGetValue("folder", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["folder"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to mark the file as private or not. + /// + /// If `true`, the file is marked as private and is accessible only using named + /// transformation or signed URL. + /// + public bool? IsPrivateFile + { + get + { + if (!this.Properties.TryGetValue("isPrivateFile", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["isPrivateFile"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to upload file as published or not. + /// + /// If `false`, the file is marked as unpublished, which restricts access to the + /// file only via the media library. Files in draft or unpublished state can only + /// be publicly accessed after being published. + /// + /// The option to upload in draft state is only available in custom enterprise + /// pricing plans. + /// + public bool? IsPublished + { + get + { + if (!this.Properties.TryGetValue("isPublished", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["isPublished"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// If set to `true` and a file already exists at the exact location, its AITags + /// will be removed. Set `overwriteAITags` to `false` to preserve AITags. + /// + public bool? OverwriteAITags + { + get + { + if (!this.Properties.TryGetValue("overwriteAITags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["overwriteAITags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// If the request does not have `customMetadata`, and a file already exists at + /// the exact location, existing customMetadata will be removed. + /// + public bool? OverwriteCustomMetadata + { + get + { + if (!this.Properties.TryGetValue("overwriteCustomMetadata", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["overwriteCustomMetadata"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// If `false` and `useUniqueFileName` is also `false`, and a file already exists + /// at the exact location, upload API will return an error immediately. + /// + public bool? OverwriteFile + { + get + { + if (!this.Properties.TryGetValue("overwriteFile", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["overwriteFile"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// If the request does not have `tags`, and a file already exists at the exact + /// location, existing tags will be removed. + /// + public bool? OverwriteTags + { + get + { + if (!this.Properties.TryGetValue("overwriteTags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["overwriteTags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Your ImageKit.io public key. This field is only required for authentication + /// when uploading a file from the client side. + /// + public string? PublicKey + { + get + { + if (!this.Properties.TryGetValue("publicKey", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["publicKey"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Array of response field keys to include in the API response body. + /// + public List>? ResponseFields + { + get + { + if (!this.Properties.TryGetValue("responseFields", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize + >?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["responseFields"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key + /// as a key. Learn how to create a signature on the page below. This should be + /// in lowercase. + /// + /// Signature must be calculated on the server-side. This field is only required + /// for authentication when uploading a file from the client side. + /// + public string? Signature + { + get + { + if (!this.Properties.TryGetValue("signature", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["signature"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Set the tags while uploading the file. Provide an array of tag strings (e.g. + /// `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must + /// not exceed 500, and the `%` character is not allowed. If this field is not + /// specified and the file is overwritten, the existing tags will be removed. + /// + public List? Tags + { + get + { + if (!this.Properties.TryGetValue("tags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["tags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Configure pre-processing (`pre`) and post-processing (`post`) transformations. + /// + /// - `pre` — applied before the file is uploaded to the Media Library. Useful + /// for reducing file size or applying basic optimizations upfront (e.g., resize, compress). + /// + /// - `post` — applied immediately after upload. Ideal for generating transformed + /// versions (like video encodes or thumbnails) in advance, so they're ready for + /// delivery without delay. + /// + /// You can mix and match any combination of post-processing types. + /// + public FileUploadV1Properties::Transformation? Transformation + { + get + { + if (!this.Properties.TryGetValue("transformation", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["transformation"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to use a unique filename for this file or not. + /// + /// If `true`, ImageKit.io will add a unique suffix to the filename parameter + /// to get a unique filename. + /// + /// If `false`, then the image is uploaded with the provided filename parameter, + /// and any existing file with the same name is replaced. + /// + public bool? UseUniqueFileName + { + get + { + if (!this.Properties.TryGetValue("useUniqueFileName", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["useUniqueFileName"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The final status of extensions after they have completed execution will be + /// delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + /// about the webhook payload structure. + /// + public string? WebhookURL + { + get + { + if (!this.Properties.TryGetValue("webhookUrl", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["webhookUrl"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.File; + _ = this.FileName; + _ = this.Token; + _ = this.Checks; + _ = this.CustomCoordinates; + if (this.CustomMetadata != null) + { + foreach (var item in this.CustomMetadata.Values) + { + _ = item; + } + } + _ = this.Description; + _ = this.Expire; + foreach (var item in this.Extensions ?? []) + { + item.Validate(); + } + _ = this.Folder; + _ = this.IsPrivateFile; + _ = this.IsPublished; + _ = this.OverwriteAITags; + _ = this.OverwriteCustomMetadata; + _ = this.OverwriteFile; + _ = this.OverwriteTags; + _ = this.PublicKey; + foreach (var item in this.ResponseFields ?? []) + { + item.Validate(); + } + _ = this.Signature; + foreach (var item in this.Tags ?? []) + { + _ = item; + } + this.Transformation?.Validate(); + _ = this.UseUniqueFileName; + _ = this.WebhookURL; + } + + public FileUploadV1() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FileUploadV1(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static FileUploadV1 FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURL.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURL.cs new file mode 100644 index 00000000..4865375d --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURL.cs @@ -0,0 +1,637 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using FileUploadV1ByURLProperties = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class FileUploadV1ByURL : ModelBase, IFromRaw +{ + /// + /// A publicly reachable URL that ImageKit’s servers can fetch. The server must + /// receive the response headers within 8 seconds; otherwise the request fails + /// with 400 Bad Request. + /// + public required string File + { + get + { + if (!this.Properties.TryGetValue("file", out JsonElement element)) + throw new ArgumentOutOfRangeException("file", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("file"); + } + set + { + this.Properties["file"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The name with which the file has to be uploaded. The file name can contain: + /// + /// - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. - Special Characters: + /// `.`, `-` + /// + /// Any other character including space will be replaced by `_` + /// + public required string FileName + { + get + { + if (!this.Properties.TryGetValue("fileName", out JsonElement element)) + throw new ArgumentOutOfRangeException("fileName", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("fileName"); + } + set + { + this.Properties["fileName"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// A unique value that the ImageKit.io server will use to recognize and prevent + /// subsequent retries for the same request. We suggest using V4 UUIDs, or another + /// random string with enough entropy to avoid collisions. This field is only + /// required for authentication when uploading a file from the client side. + /// + /// **Note**: Sending a value that has been used in the past will result in a + /// validation error. Even if your previous request resulted in an error, you + /// should always send a new value for this field. + /// + public string? Token + { + get + { + if (!this.Properties.TryGetValue("token", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["token"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Server-side checks to run on the asset. Read more about [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). + /// + public string? Checks + { + get + { + if (!this.Properties.TryGetValue("checks", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["checks"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Define an important area in the image. This is only relevant for image type files. + /// + /// - To be passed as a string with the x and y coordinates of the top-left + /// corner, and width and height of the area of interest in the format `x,y,width,height`. + /// For example - `10,10,100,100` - Can be used with fo-customtransformation. + /// - If this field is not specified and the file is overwritten, then customCoordinates + /// will be removed. + /// + public string? CustomCoordinates + { + get + { + if (!this.Properties.TryGetValue("customCoordinates", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["customCoordinates"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// JSON key-value pairs to associate with the asset. Create the custom metadata + /// fields before setting these values. + /// + public Dictionary? CustomMetadata + { + get + { + if (!this.Properties.TryGetValue("customMetadata", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["customMetadata"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Optional text to describe the contents of the file. + /// + public string? Description + { + get + { + if (!this.Properties.TryGetValue("description", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["description"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The time until your signature is valid. It must be a [Unix time](https://en.wikipedia.org/wiki/Unix_time) + /// in less than 1 hour into the future. It should be in seconds. This field is + /// only required for authentication when uploading a file from the client side. + /// + public long? Expire + { + get + { + if (!this.Properties.TryGetValue("expire", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["expire"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Array of extensions to be applied to the image. Each extension can be configured + /// with specific parameters based on the extension type. + /// + public List? Extensions + { + get + { + if (!this.Properties.TryGetValue("extensions", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["extensions"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The folder path in which the image has to be uploaded. If the folder(s) didn't + /// exist before, a new folder(s) is created. + /// + /// The folder name can contain: + /// + /// - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` - Special Characters: + /// `/` , `_` , `-` + /// + /// Using multiple `/` creates a nested folder. + /// + public string? Folder + { + get + { + if (!this.Properties.TryGetValue("folder", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["folder"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to mark the file as private or not. + /// + /// If `true`, the file is marked as private and is accessible only using named + /// transformation or signed URL. + /// + public bool? IsPrivateFile + { + get + { + if (!this.Properties.TryGetValue("isPrivateFile", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["isPrivateFile"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to upload file as published or not. + /// + /// If `false`, the file is marked as unpublished, which restricts access to the + /// file only via the media library. Files in draft or unpublished state can only + /// be publicly accessed after being published. + /// + /// The option to upload in draft state is only available in custom enterprise + /// pricing plans. + /// + public bool? IsPublished + { + get + { + if (!this.Properties.TryGetValue("isPublished", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["isPublished"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// If set to `true` and a file already exists at the exact location, its AITags + /// will be removed. Set `overwriteAITags` to `false` to preserve AITags. + /// + public bool? OverwriteAITags + { + get + { + if (!this.Properties.TryGetValue("overwriteAITags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["overwriteAITags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// If the request does not have `customMetadata`, and a file already exists at + /// the exact location, existing customMetadata will be removed. + /// + public bool? OverwriteCustomMetadata + { + get + { + if (!this.Properties.TryGetValue("overwriteCustomMetadata", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["overwriteCustomMetadata"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// If `false` and `useUniqueFileName` is also `false`, and a file already exists + /// at the exact location, upload API will return an error immediately. + /// + public bool? OverwriteFile + { + get + { + if (!this.Properties.TryGetValue("overwriteFile", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["overwriteFile"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// If the request does not have `tags`, and a file already exists at the exact + /// location, existing tags will be removed. + /// + public bool? OverwriteTags + { + get + { + if (!this.Properties.TryGetValue("overwriteTags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["overwriteTags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Your ImageKit.io public key. This field is only required for authentication + /// when uploading a file from the client side. + /// + public string? PublicKey + { + get + { + if (!this.Properties.TryGetValue("publicKey", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["publicKey"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Array of response field keys to include in the API response body. + /// + public List>? ResponseFields + { + get + { + if (!this.Properties.TryGetValue("responseFields", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize + >?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["responseFields"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key + /// as a key. Learn how to create a signature on the page below. This should be + /// in lowercase. + /// + /// Signature must be calculated on the server-side. This field is only required + /// for authentication when uploading a file from the client side. + /// + public string? Signature + { + get + { + if (!this.Properties.TryGetValue("signature", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["signature"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Set the tags while uploading the file. Provide an array of tag strings (e.g. + /// `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must + /// not exceed 500, and the `%` character is not allowed. If this field is not + /// specified and the file is overwritten, the existing tags will be removed. + /// + public List? Tags + { + get + { + if (!this.Properties.TryGetValue("tags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["tags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Configure pre-processing (`pre`) and post-processing (`post`) transformations. + /// + /// - `pre` — applied before the file is uploaded to the Media Library. Useful + /// for reducing file size or applying basic optimizations upfront (e.g., resize, compress). + /// + /// - `post` — applied immediately after upload. Ideal for generating transformed + /// versions (like video encodes or thumbnails) in advance, so they're ready for + /// delivery without delay. + /// + /// You can mix and match any combination of post-processing types. + /// + public FileUploadV1ByURLProperties::Transformation? Transformation + { + get + { + if (!this.Properties.TryGetValue("transformation", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["transformation"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to use a unique filename for this file or not. + /// + /// If `true`, ImageKit.io will add a unique suffix to the filename parameter + /// to get a unique filename. + /// + /// If `false`, then the image is uploaded with the provided filename parameter, + /// and any existing file with the same name is replaced. + /// + public bool? UseUniqueFileName + { + get + { + if (!this.Properties.TryGetValue("useUniqueFileName", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["useUniqueFileName"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The final status of extensions after they have completed execution will be + /// delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + /// about the webhook payload structure. + /// + public string? WebhookURL + { + get + { + if (!this.Properties.TryGetValue("webhookUrl", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["webhookUrl"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.File; + _ = this.FileName; + _ = this.Token; + _ = this.Checks; + _ = this.CustomCoordinates; + if (this.CustomMetadata != null) + { + foreach (var item in this.CustomMetadata.Values) + { + _ = item; + } + } + _ = this.Description; + _ = this.Expire; + foreach (var item in this.Extensions ?? []) + { + item.Validate(); + } + _ = this.Folder; + _ = this.IsPrivateFile; + _ = this.IsPublished; + _ = this.OverwriteAITags; + _ = this.OverwriteCustomMetadata; + _ = this.OverwriteFile; + _ = this.OverwriteTags; + _ = this.PublicKey; + foreach (var item in this.ResponseFields ?? []) + { + item.Validate(); + } + _ = this.Signature; + foreach (var item in this.Tags ?? []) + { + _ = item; + } + this.Transformation?.Validate(); + _ = this.UseUniqueFileName; + _ = this.WebhookURL; + } + + public FileUploadV1ByURL() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FileUploadV1ByURL(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static FileUploadV1ByURL FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/Extension.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/Extension.cs new file mode 100644 index 00000000..8b6e388b --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/Extension.cs @@ -0,0 +1,177 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties.ExtensionProperties; +using ExtensionVariants = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties.ExtensionVariants; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties; + +[JsonConverter(typeof(ExtensionConverter))] +public abstract record class Extension +{ + internal Extension() { } + + public static implicit operator Extension(RemoveBg value) => + new ExtensionVariants::RemoveBg(value); + + public static implicit operator Extension(AutoTaggingExtension value) => + new ExtensionVariants::AutoTaggingExtension(value); + + public bool TryPickRemoveBg([NotNullWhen(true)] out RemoveBg? value) + { + value = (this as ExtensionVariants::RemoveBg)?.Value; + return value != null; + } + + public bool TryPickAutoTagging([NotNullWhen(true)] out AutoTaggingExtension? value) + { + value = (this as ExtensionVariants::AutoTaggingExtension)?.Value; + return value != null; + } + + public bool TryPickAIAutoDescription([NotNullWhen(true)] out JsonElement? value) + { + value = (this as ExtensionVariants::AIAutoDescription)?.Value; + return value != null; + } + + public void Switch( + Action removeBg, + Action autoTagging, + Action aiAutoDescription + ) + { + switch (this) + { + case ExtensionVariants::RemoveBg inner: + removeBg(inner); + break; + case ExtensionVariants::AutoTaggingExtension inner: + autoTagging(inner); + break; + case ExtensionVariants::AIAutoDescription inner: + aiAutoDescription(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func removeBg, + Func autoTagging, + Func aiAutoDescription + ) + { + return this switch + { + ExtensionVariants::RemoveBg inner => removeBg(inner), + ExtensionVariants::AutoTaggingExtension inner => autoTagging(inner), + ExtensionVariants::AIAutoDescription inner => aiAutoDescription(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class ExtensionConverter : JsonConverter +{ + public override Extension? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var json = JsonSerializer.Deserialize(ref reader, options); + string? name; + try + { + name = json.GetProperty("name").GetString(); + } + catch + { + name = null; + } + + switch (name) + { + case "remove-bg": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new ExtensionVariants::RemoveBg(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "ai-auto-description": + { + List exceptions = []; + + try + { + return new ExtensionVariants::AIAutoDescription( + JsonSerializer.Deserialize(json, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + default: + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize( + json, + options + ); + if (deserialized != null) + { + return new ExtensionVariants::AutoTaggingExtension(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + Extension value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + ExtensionVariants::RemoveBg(var removeBg) => removeBg, + ExtensionVariants::AutoTaggingExtension(var autoTagging) => autoTagging, + ExtensionVariants::AIAutoDescription(var aiAutoDescription) => aiAutoDescription, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/ExtensionProperties/AutoTaggingExtension.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/ExtensionProperties/AutoTaggingExtension.cs new file mode 100644 index 00000000..4b462fc4 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/ExtensionProperties/AutoTaggingExtension.cs @@ -0,0 +1,100 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties.ExtensionProperties.AutoTaggingExtensionProperties; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties.ExtensionProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class AutoTaggingExtension : ModelBase, IFromRaw +{ + /// + /// Maximum number of tags to attach to the asset. + /// + public required long MaxTags + { + get + { + if (!this.Properties.TryGetValue("maxTags", out JsonElement element)) + throw new ArgumentOutOfRangeException("maxTags", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["maxTags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Minimum confidence level for tags to be considered valid. + /// + public required long MinConfidence + { + get + { + if (!this.Properties.TryGetValue("minConfidence", out JsonElement element)) + throw new ArgumentOutOfRangeException("minConfidence", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["minConfidence"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies the auto-tagging extension used. + /// + public required ApiEnum Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + throw new ArgumentOutOfRangeException("name", "Missing required argument"); + + return JsonSerializer.Deserialize>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.MaxTags; + _ = this.MinConfidence; + this.Name.Validate(); + } + + public AutoTaggingExtension() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + AutoTaggingExtension(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static AutoTaggingExtension FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs new file mode 100644 index 00000000..59b726ea --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs @@ -0,0 +1,46 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties.ExtensionProperties.AutoTaggingExtensionProperties; + +/// +/// Specifies the auto-tagging extension used. +/// +[JsonConverter(typeof(NameConverter))] +public enum Name +{ + GoogleAutoTagging, + AwsAutoTagging, +} + +sealed class NameConverter : JsonConverter +{ + public override Name Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "google-auto-tagging" => Name.GoogleAutoTagging, + "aws-auto-tagging" => Name.AwsAutoTagging, + _ => (Name)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Name value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + Name.GoogleAutoTagging => "google-auto-tagging", + Name.AwsAutoTagging => "aws-auto-tagging", + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/ExtensionProperties/RemoveBg.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/ExtensionProperties/RemoveBg.cs new file mode 100644 index 00000000..408fe2e7 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/ExtensionProperties/RemoveBg.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties.ExtensionProperties.RemoveBgProperties; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties.ExtensionProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class RemoveBg : ModelBase, IFromRaw +{ + /// + /// Specifies the background removal extension. + /// + public JsonElement Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + throw new ArgumentOutOfRangeException("name", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public Options? Options + { + get + { + if (!this.Properties.TryGetValue("options", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["options"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.Options?.Validate(); + } + + public RemoveBg() + { + this.Name = JsonSerializer.Deserialize("\"remove-bg\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + RemoveBg(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static RemoveBg FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/ExtensionProperties/RemoveBgProperties/Options.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/ExtensionProperties/RemoveBgProperties/Options.cs new file mode 100644 index 00000000..b3aeb0e3 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/ExtensionProperties/RemoveBgProperties/Options.cs @@ -0,0 +1,122 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties.ExtensionProperties.RemoveBgProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Options : ModelBase, IFromRaw +{ + /// + /// Whether to add an artificial shadow to the result. Default is false. Note: + /// Adding shadows is currently only supported for car photos. + /// + public bool? AddShadow + { + get + { + if (!this.Properties.TryGetValue("add_shadow", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["add_shadow"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies a solid color background using hex code (e.g., "81d4fa", "fff") + /// or color name (e.g., "green"). If this parameter is set, `bg_image_url` must + /// be empty. + /// + public string? BgColor + { + get + { + if (!this.Properties.TryGetValue("bg_color", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["bg_color"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Sets a background image from a URL. If this parameter is set, `bg_color` + /// must be empty. + /// + public string? BgImageURL + { + get + { + if (!this.Properties.TryGetValue("bg_image_url", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["bg_image_url"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Allows semi-transparent regions in the result. Default is true. Note: Semitransparency + /// is currently only supported for car windows. + /// + public bool? Semitransparency + { + get + { + if (!this.Properties.TryGetValue("semitransparency", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["semitransparency"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.AddShadow; + _ = this.BgColor; + _ = this.BgImageURL; + _ = this.Semitransparency; + } + + public Options() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Options(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Options FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/ExtensionVariants/All.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/ExtensionVariants/All.cs new file mode 100644 index 00000000..1d6e8757 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/ExtensionVariants/All.cs @@ -0,0 +1,46 @@ +using System.Text.Json; +using ExtensionProperties = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties.ExtensionProperties; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties.ExtensionVariants; + +public sealed record class RemoveBg(ExtensionProperties::RemoveBg Value) + : Extension, + IVariant +{ + public static RemoveBg From(ExtensionProperties::RemoveBg value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class AutoTaggingExtension(ExtensionProperties::AutoTaggingExtension Value) + : Extension, + IVariant +{ + public static AutoTaggingExtension From(ExtensionProperties::AutoTaggingExtension value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class AIAutoDescription(JsonElement Value) + : Extension, + IVariant +{ + public static AIAutoDescription From(JsonElement value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/ResponseField.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/ResponseField.cs new file mode 100644 index 00000000..5ec04597 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/ResponseField.cs @@ -0,0 +1,62 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties; + +[JsonConverter(typeof(ResponseFieldConverter))] +public enum ResponseField +{ + Tags, + CustomCoordinates, + IsPrivateFile, + EmbeddedMetadata, + IsPublished, + CustomMetadata, + Metadata, +} + +sealed class ResponseFieldConverter : JsonConverter +{ + public override ResponseField Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "tags" => ResponseField.Tags, + "customCoordinates" => ResponseField.CustomCoordinates, + "isPrivateFile" => ResponseField.IsPrivateFile, + "embeddedMetadata" => ResponseField.EmbeddedMetadata, + "isPublished" => ResponseField.IsPublished, + "customMetadata" => ResponseField.CustomMetadata, + "metadata" => ResponseField.Metadata, + _ => (ResponseField)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ResponseField value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ResponseField.Tags => "tags", + ResponseField.CustomCoordinates => "customCoordinates", + ResponseField.IsPrivateFile => "isPrivateFile", + ResponseField.EmbeddedMetadata => "embeddedMetadata", + ResponseField.IsPublished => "isPublished", + ResponseField.CustomMetadata => "customMetadata", + ResponseField.Metadata => "metadata", + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/Transformation.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/Transformation.cs new file mode 100644 index 00000000..b38d9ff1 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/Transformation.cs @@ -0,0 +1,92 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties.TransformationProperties; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties; + +/// +/// Configure pre-processing (`pre`) and post-processing (`post`) transformations. +/// +/// - `pre` — applied before the file is uploaded to the Media Library. Useful +/// for reducing file size or applying basic optimizations upfront (e.g., resize, compress). +/// +/// - `post` — applied immediately after upload. Ideal for generating transformed +/// versions (like video encodes or thumbnails) in advance, so they're ready for +/// delivery without delay. +/// +/// You can mix and match any combination of post-processing types. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class Transformation : ModelBase, IFromRaw +{ + /// + /// List of transformations to apply *after* the file is uploaded. Each item + /// must match one of the following types: `transformation`, `gif-to-video`, + /// `thumbnail`, `abs`. + /// + public List? Post + { + get + { + if (!this.Properties.TryGetValue("post", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["post"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Transformation string to apply before uploading the file to the Media Library. + /// Useful for optimizing files at ingestion. + /// + public string? Pre + { + get + { + if (!this.Properties.TryGetValue("pre", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["pre"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + foreach (var item in this.Post ?? []) + { + item.Validate(); + } + _ = this.Pre; + } + + public Transformation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Transformation(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Transformation FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/Post.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/Post.cs new file mode 100644 index 00000000..e3e9b5dc --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/Post.cs @@ -0,0 +1,225 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using PostProperties = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties.TransformationProperties.PostProperties; +using PostVariants = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties.TransformationProperties.PostVariants; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties.TransformationProperties; + +[JsonConverter(typeof(PostConverter))] +public abstract record class Post +{ + internal Post() { } + + public static implicit operator Post(PostProperties::Transformation value) => + new PostVariants::Transformation(value); + + public static implicit operator Post(PostProperties::GifToVideo value) => + new PostVariants::GifToVideo(value); + + public static implicit operator Post(PostProperties::Thumbnail value) => + new PostVariants::Thumbnail(value); + + public static implicit operator Post(PostProperties::Abs value) => new PostVariants::Abs(value); + + public bool TryPickTransformation([NotNullWhen(true)] out PostProperties::Transformation? value) + { + value = (this as PostVariants::Transformation)?.Value; + return value != null; + } + + public bool TryPickGifToVideo([NotNullWhen(true)] out PostProperties::GifToVideo? value) + { + value = (this as PostVariants::GifToVideo)?.Value; + return value != null; + } + + public bool TryPickThumbnail([NotNullWhen(true)] out PostProperties::Thumbnail? value) + { + value = (this as PostVariants::Thumbnail)?.Value; + return value != null; + } + + public bool TryPickAbs([NotNullWhen(true)] out PostProperties::Abs? value) + { + value = (this as PostVariants::Abs)?.Value; + return value != null; + } + + public void Switch( + Action transformation, + Action gifToVideo, + Action thumbnail, + Action abs + ) + { + switch (this) + { + case PostVariants::Transformation inner: + transformation(inner); + break; + case PostVariants::GifToVideo inner: + gifToVideo(inner); + break; + case PostVariants::Thumbnail inner: + thumbnail(inner); + break; + case PostVariants::Abs inner: + abs(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func transformation, + Func gifToVideo, + Func thumbnail, + Func abs + ) + { + return this switch + { + PostVariants::Transformation inner => transformation(inner), + PostVariants::GifToVideo inner => gifToVideo(inner), + PostVariants::Thumbnail inner => thumbnail(inner), + PostVariants::Abs inner => abs(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class PostConverter : JsonConverter +{ + public override Post? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var json = JsonSerializer.Deserialize(ref reader, options); + string? type; + try + { + type = json.GetProperty("type").GetString(); + } + catch + { + type = null; + } + + switch (type) + { + case "transformation": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize( + json, + options + ); + if (deserialized != null) + { + return new PostVariants::Transformation(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "gif-to-video": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize( + json, + options + ); + if (deserialized != null) + { + return new PostVariants::GifToVideo(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "thumbnail": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize( + json, + options + ); + if (deserialized != null) + { + return new PostVariants::Thumbnail(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "abs": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize( + json, + options + ); + if (deserialized != null) + { + return new PostVariants::Abs(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + default: + { + throw new Exception(); + } + } + } + + public override void Write(Utf8JsonWriter writer, Post value, JsonSerializerOptions options) + { + object variant = value switch + { + PostVariants::Transformation(var transformation) => transformation, + PostVariants::GifToVideo(var gifToVideo) => gifToVideo, + PostVariants::Thumbnail(var thumbnail) => thumbnail, + PostVariants::Abs(var abs) => abs, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/PostProperties/Abs.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/PostProperties/Abs.cs new file mode 100644 index 00000000..74928750 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/PostProperties/Abs.cs @@ -0,0 +1,103 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties.TransformationProperties.PostProperties.AbsProperties; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties.TransformationProperties.PostProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Abs : ModelBase, IFromRaw +{ + /// + /// Streaming protocol to use (`hls` or `dash`). + /// + public required ApiEnum Protocol + { + get + { + if (!this.Properties.TryGetValue("protocol", out JsonElement element)) + throw new ArgumentOutOfRangeException("protocol", "Missing required argument"); + + return JsonSerializer.Deserialize>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["protocol"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Adaptive Bitrate Streaming (ABS) setup. + /// + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// List of different representations you want to create separated by an underscore. + /// + public required string Value + { + get + { + if (!this.Properties.TryGetValue("value", out JsonElement element)) + throw new ArgumentOutOfRangeException("value", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("value"); + } + set + { + this.Properties["value"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.Protocol.Validate(); + _ = this.Value; + } + + public Abs() + { + this.Type = JsonSerializer.Deserialize("\"abs\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Abs(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Abs FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs new file mode 100644 index 00000000..74cc77b5 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs @@ -0,0 +1,46 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties.TransformationProperties.PostProperties.AbsProperties; + +/// +/// Streaming protocol to use (`hls` or `dash`). +/// +[JsonConverter(typeof(ProtocolConverter))] +public enum Protocol +{ + Hls, + Dash, +} + +sealed class ProtocolConverter : JsonConverter +{ + public override Protocol Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "hls" => Protocol.Hls, + "dash" => Protocol.Dash, + _ => (Protocol)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Protocol value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + Protocol.Hls => "hls", + Protocol.Dash => "dash", + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/PostProperties/GifToVideo.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/PostProperties/GifToVideo.cs new file mode 100644 index 00000000..83983308 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/PostProperties/GifToVideo.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties.TransformationProperties.PostProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class GifToVideo : ModelBase, IFromRaw +{ + /// + /// Converts an animated GIF into an MP4. + /// + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Optional transformation string to apply to the output video. **Example**: + /// `q-80` + /// + public string? Value + { + get + { + if (!this.Properties.TryGetValue("value", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["value"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.Value; + } + + public GifToVideo() + { + this.Type = JsonSerializer.Deserialize("\"gif-to-video\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GifToVideo(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static GifToVideo FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/PostProperties/Thumbnail.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/PostProperties/Thumbnail.cs new file mode 100644 index 00000000..1ae871a5 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/PostProperties/Thumbnail.cs @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties.TransformationProperties.PostProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Thumbnail : ModelBase, IFromRaw +{ + /// + /// Generates a thumbnail image. + /// + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Optional transformation string. **Example**: `w-150,h-150` + /// + public string? Value + { + get + { + if (!this.Properties.TryGetValue("value", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["value"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.Value; + } + + public Thumbnail() + { + this.Type = JsonSerializer.Deserialize("\"thumbnail\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Thumbnail(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Thumbnail FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/PostProperties/Transformation.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/PostProperties/Transformation.cs new file mode 100644 index 00000000..9b8a76e1 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/PostProperties/Transformation.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties.TransformationProperties.PostProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Transformation : ModelBase, IFromRaw +{ + /// + /// Transformation type. + /// + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Transformation string (e.g. `w-200,h-200`). Same syntax as ImageKit URL-based + /// transformations. + /// + public required string Value + { + get + { + if (!this.Properties.TryGetValue("value", out JsonElement element)) + throw new ArgumentOutOfRangeException("value", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("value"); + } + set + { + this.Properties["value"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.Value; + } + + public Transformation() + { + this.Type = JsonSerializer.Deserialize("\"transformation\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Transformation(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Transformation FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public Transformation(string value) + : this() + { + this.Value = value; + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/PostVariants/All.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/PostVariants/All.cs new file mode 100644 index 00000000..b33c0181 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/PostVariants/All.cs @@ -0,0 +1,61 @@ +using PostProperties = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties.TransformationProperties.PostProperties; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties.TransformationProperties.PostVariants; + +public sealed record class Transformation(PostProperties::Transformation Value) + : Post, + IVariant +{ + public static Transformation From(PostProperties::Transformation value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class GifToVideo(PostProperties::GifToVideo Value) + : Post, + IVariant +{ + public static GifToVideo From(PostProperties::GifToVideo value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class Thumbnail(PostProperties::Thumbnail Value) + : Post, + IVariant +{ + public static Thumbnail From(PostProperties::Thumbnail value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class Abs(PostProperties::Abs Value) : Post, IVariant +{ + public static Abs From(PostProperties::Abs value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/Extension.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/Extension.cs similarity index 95% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/Extension.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/Extension.cs index aca5f9b4..438024fd 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/Extension.cs +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/Extension.cs @@ -3,10 +3,10 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using Imagekit.Models.Files.FileUploadParamsProperties.ExtensionProperties; -using ExtensionVariants = Imagekit.Models.Files.FileUploadParamsProperties.ExtensionVariants; +using Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.ExtensionProperties; +using ExtensionVariants = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.ExtensionVariants; -namespace Imagekit.Models.Files.FileUploadParamsProperties; +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties; [JsonConverter(typeof(ExtensionConverter))] public abstract record class Extension diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/AutoTaggingExtension.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ExtensionProperties/AutoTaggingExtension.cs similarity index 91% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/AutoTaggingExtension.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ExtensionProperties/AutoTaggingExtension.cs index 11eab9ca..e708a2de 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/AutoTaggingExtension.cs +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ExtensionProperties/AutoTaggingExtension.cs @@ -3,9 +3,9 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using Imagekit.Models.Files.FileUploadParamsProperties.ExtensionProperties.AutoTaggingExtensionProperties; +using Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.ExtensionProperties.AutoTaggingExtensionProperties; -namespace Imagekit.Models.Files.FileUploadParamsProperties.ExtensionProperties; +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.ExtensionProperties; [JsonConverter(typeof(ModelConverter))] public sealed record class AutoTaggingExtension : ModelBase, IFromRaw diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs similarity index 88% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs index 55796f3b..343532bc 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs @@ -2,7 +2,7 @@ using System.Text.Json; using System.Text.Json.Serialization; -namespace Imagekit.Models.Files.FileUploadParamsProperties.ExtensionProperties.AutoTaggingExtensionProperties; +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.ExtensionProperties.AutoTaggingExtensionProperties; /// /// Specifies the auto-tagging extension used. diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/RemoveBg.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ExtensionProperties/RemoveBg.cs similarity index 88% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/RemoveBg.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ExtensionProperties/RemoveBg.cs index 68223612..6c64ff28 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/RemoveBg.cs +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ExtensionProperties/RemoveBg.cs @@ -3,9 +3,9 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using Imagekit.Models.Files.FileUploadParamsProperties.ExtensionProperties.RemoveBgProperties; +using Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.ExtensionProperties.RemoveBgProperties; -namespace Imagekit.Models.Files.FileUploadParamsProperties.ExtensionProperties; +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.ExtensionProperties; [JsonConverter(typeof(ModelConverter))] public sealed record class RemoveBg : ModelBase, IFromRaw diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/RemoveBgProperties/Options.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ExtensionProperties/RemoveBgProperties/Options.cs similarity index 96% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/RemoveBgProperties/Options.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ExtensionProperties/RemoveBgProperties/Options.cs index 7f5799e6..f85a0ea6 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/RemoveBgProperties/Options.cs +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ExtensionProperties/RemoveBgProperties/Options.cs @@ -3,7 +3,7 @@ using System.Text.Json; using System.Text.Json.Serialization; -namespace Imagekit.Models.Files.FileUploadParamsProperties.ExtensionProperties.RemoveBgProperties; +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.ExtensionProperties.RemoveBgProperties; [JsonConverter(typeof(ModelConverter))] public sealed record class Options : ModelBase, IFromRaw diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionVariants/All.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ExtensionVariants/All.cs similarity index 85% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionVariants/All.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ExtensionVariants/All.cs index b312f63e..f1660feb 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionVariants/All.cs +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ExtensionVariants/All.cs @@ -1,7 +1,7 @@ using System.Text.Json; -using ExtensionProperties = Imagekit.Models.Files.FileUploadParamsProperties.ExtensionProperties; +using ExtensionProperties = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.ExtensionProperties; -namespace Imagekit.Models.Files.FileUploadParamsProperties.ExtensionVariants; +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.ExtensionVariants; public sealed record class RemoveBg(ExtensionProperties::RemoveBg Value) : Extension, diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/ResponseField.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ResponseField.cs similarity index 94% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/ResponseField.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ResponseField.cs index c5b5b8f7..b823b0fa 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/ResponseField.cs +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ResponseField.cs @@ -2,7 +2,7 @@ using System.Text.Json; using System.Text.Json.Serialization; -namespace Imagekit.Models.Files.FileUploadParamsProperties; +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties; [JsonConverter(typeof(ResponseFieldConverter))] public enum ResponseField diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/Transformation.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/Transformation.cs similarity index 92% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/Transformation.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/Transformation.cs index e8cdd4c6..69579c4d 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/Transformation.cs +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/Transformation.cs @@ -2,9 +2,9 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties; +using Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.TransformationProperties; -namespace Imagekit.Models.Files.FileUploadParamsProperties; +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties; /// /// Configure pre-processing (`pre`) and post-processing (`post`) transformations. diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/Post.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/Post.cs similarity index 95% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/Post.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/Post.cs index 9f7a1ec3..555e08ed 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/Post.cs +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/Post.cs @@ -3,10 +3,10 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using PostProperties = Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; -using PostVariants = Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostVariants; +using PostProperties = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.TransformationProperties.PostProperties; +using PostVariants = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.TransformationProperties.PostVariants; -namespace Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties; +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.TransformationProperties; [JsonConverter(typeof(PostConverter))] public abstract record class Post diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Abs.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostProperties/Abs.cs similarity index 90% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Abs.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostProperties/Abs.cs index 10c95b3c..35d58a5b 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Abs.cs +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostProperties/Abs.cs @@ -3,9 +3,9 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.AbsProperties; +using Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.TransformationProperties.PostProperties.AbsProperties; -namespace Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.TransformationProperties.PostProperties; [JsonConverter(typeof(ModelConverter))] public sealed record class Abs : ModelBase, IFromRaw diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs similarity index 87% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs index 56d80f9f..876df70b 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs @@ -2,7 +2,7 @@ using System.Text.Json; using System.Text.Json.Serialization; -namespace Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.AbsProperties; +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.TransformationProperties.PostProperties.AbsProperties; /// /// Streaming protocol to use (`hls` or `dash`). diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideo.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostProperties/GifToVideo.cs similarity index 93% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideo.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostProperties/GifToVideo.cs index 44e57f2a..c23153e9 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideo.cs +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostProperties/GifToVideo.cs @@ -4,7 +4,7 @@ using System.Text.Json; using System.Text.Json.Serialization; -namespace Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.TransformationProperties.PostProperties; [JsonConverter(typeof(ModelConverter))] public sealed record class GifToVideo : ModelBase, IFromRaw diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Thumbnail.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostProperties/Thumbnail.cs similarity index 93% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Thumbnail.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostProperties/Thumbnail.cs index 879f27c1..7454152f 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Thumbnail.cs +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostProperties/Thumbnail.cs @@ -4,7 +4,7 @@ using System.Text.Json; using System.Text.Json.Serialization; -namespace Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.TransformationProperties.PostProperties; [JsonConverter(typeof(ModelConverter))] public sealed record class Thumbnail : ModelBase, IFromRaw diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Transformation.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostProperties/Transformation.cs similarity index 94% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Transformation.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostProperties/Transformation.cs index b68c748b..cd34b1fc 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Transformation.cs +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostProperties/Transformation.cs @@ -4,7 +4,7 @@ using System.Text.Json; using System.Text.Json.Serialization; -namespace Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.TransformationProperties.PostProperties; [JsonConverter(typeof(ModelConverter))] public sealed record class Transformation : ModelBase, IFromRaw diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostVariants/All.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostVariants/All.cs similarity index 85% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostVariants/All.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostVariants/All.cs index ae864596..aca8a9cb 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostVariants/All.cs +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostVariants/All.cs @@ -1,6 +1,6 @@ -using PostProperties = Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; +using PostProperties = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.TransformationProperties.PostProperties; -namespace Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostVariants; +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.TransformationProperties.PostVariants; public sealed record class Transformation(PostProperties::Transformation Value) : Post, diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyVariants/All.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyVariants/All.cs new file mode 100644 index 00000000..4cedc4de --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyVariants/All.cs @@ -0,0 +1,33 @@ +using BodyProperties = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyVariants; + +public sealed record class FileUploadV1(BodyProperties::FileUploadV1 Value) + : Body, + IVariant +{ + public static FileUploadV1 From(BodyProperties::FileUploadV1 value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class FileUploadV1ByURL(BodyProperties::FileUploadV1ByURL Value) + : Body, + IVariant +{ + public static FileUploadV1ByURL From(BodyProperties::FileUploadV1ByURL value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} diff --git a/src/Imagekit/Services/Files/FileService.cs b/src/Imagekit/Services/Files/FileService.cs index 7ec98b70..344a8f65 100644 --- a/src/Imagekit/Services/Files/FileService.cs +++ b/src/Imagekit/Services/Files/FileService.cs @@ -172,8 +172,10 @@ await response.Content.ReadAsStreamAsync().ConfigureAwait(false), ) ?? throw new NullReferenceException(); } - public async Task Upload(FileUploadParams parameters) + public async Task Upload(FileUploadParams? parameters = null) { + parameters ??= new(); + using HttpRequestMessage request = new(HttpMethod.Post, parameters.Url(this._client)) { Content = parameters.BodyContent(), diff --git a/src/Imagekit/Services/Files/IFileService.cs b/src/Imagekit/Services/Files/IFileService.cs index 183d998d..64cd4040 100644 --- a/src/Imagekit/Services/Files/IFileService.cs +++ b/src/Imagekit/Services/Files/IFileService.cs @@ -87,5 +87,5 @@ public interface IFileService /// Instagram, and more. - [Quick start guides](/docs/quick-start-guides) for /// various frameworks and technologies. /// - Task Upload(FileUploadParams parameters); + Task Upload(FileUploadParams? parameters = null); } From 1d0ef2c5d92c060278cf3a78744b0656fe5afc44 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 28 Jan 2026 17:15:14 +0000 Subject: [PATCH 011/129] feat(api): manual updates --- .stats.yml | 4 +- README.md | 9 +- .../Services/Files/FileServiceTest.cs | 4 +- src/Imagekit/ModelBase.cs | 22 +- src/Imagekit/Models/Files/FileUploadParams.cs | 719 ++++++++++++++++-- .../Files/FileUploadParamsProperties/Body.cs | 117 --- .../BodyProperties/FileUploadV1.cs | 642 ---------------- .../BodyProperties/FileUploadV1ByURL.cs | 637 ---------------- .../FileUploadV1ByURLProperties/Extension.cs | 177 ----- .../AutoTaggingExtension.cs | 100 --- .../AutoTaggingExtensionProperties/Name.cs | 46 -- .../ExtensionProperties/RemoveBg.cs | 74 -- .../RemoveBgProperties/Options.cs | 122 --- .../ExtensionVariants/All.cs | 46 -- .../ResponseField.cs | 62 -- .../Transformation.cs | 92 --- .../TransformationProperties/Post.cs | 225 ------ .../PostProperties/Abs.cs | 103 --- .../PostProperties/AbsProperties/Protocol.cs | 46 -- .../PostProperties/GifToVideo.cs | 77 -- .../PostProperties/Thumbnail.cs | 76 -- .../PostProperties/Transformation.cs | 85 --- .../PostVariants/All.cs | 61 -- .../BodyVariants/All.cs | 33 - .../FileUploadV1Properties => }/Extension.cs | 6 +- .../AutoTaggingExtension.cs | 4 +- .../AutoTaggingExtensionProperties/Name.cs | 2 +- .../ExtensionProperties/RemoveBg.cs | 4 +- .../RemoveBgProperties/Options.cs | 2 +- .../ExtensionVariants/All.cs | 4 +- .../ResponseField.cs | 2 +- .../Transformation.cs | 4 +- .../TransformationProperties/Post.cs | 6 +- .../PostProperties/Abs.cs | 4 +- .../PostProperties/AbsProperties/Protocol.cs | 2 +- .../PostProperties/GifToVideo.cs | 2 +- .../PostProperties/Thumbnail.cs | 2 +- .../PostProperties/Transformation.cs | 2 +- .../PostVariants/All.cs | 4 +- src/Imagekit/Services/Files/FileService.cs | 4 +- src/Imagekit/Services/Files/IFileService.cs | 2 +- 41 files changed, 685 insertions(+), 2950 deletions(-) delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/Body.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURL.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/Extension.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/ExtensionProperties/AutoTaggingExtension.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/ExtensionProperties/RemoveBg.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/ExtensionProperties/RemoveBgProperties/Options.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/ExtensionVariants/All.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/ResponseField.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/Transformation.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/Post.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/PostProperties/Abs.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/PostProperties/GifToVideo.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/PostProperties/Thumbnail.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/PostProperties/Transformation.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/PostVariants/All.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyVariants/All.cs rename src/Imagekit/Models/Files/FileUploadParamsProperties/{BodyProperties/FileUploadV1Properties => }/Extension.cs (95%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{BodyProperties/FileUploadV1Properties => }/ExtensionProperties/AutoTaggingExtension.cs (91%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{BodyProperties/FileUploadV1Properties => }/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs (88%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{BodyProperties/FileUploadV1Properties => }/ExtensionProperties/RemoveBg.cs (88%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{BodyProperties/FileUploadV1Properties => }/ExtensionProperties/RemoveBgProperties/Options.cs (96%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{BodyProperties/FileUploadV1Properties => }/ExtensionVariants/All.cs (85%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{BodyProperties/FileUploadV1Properties => }/ResponseField.cs (94%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{BodyProperties/FileUploadV1Properties => }/Transformation.cs (92%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{BodyProperties/FileUploadV1Properties => }/TransformationProperties/Post.cs (95%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{BodyProperties/FileUploadV1Properties => }/TransformationProperties/PostProperties/Abs.cs (90%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{BodyProperties/FileUploadV1Properties => }/TransformationProperties/PostProperties/AbsProperties/Protocol.cs (87%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{BodyProperties/FileUploadV1Properties => }/TransformationProperties/PostProperties/GifToVideo.cs (93%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{BodyProperties/FileUploadV1Properties => }/TransformationProperties/PostProperties/Thumbnail.cs (93%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{BodyProperties/FileUploadV1Properties => }/TransformationProperties/PostProperties/Transformation.cs (94%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{BodyProperties/FileUploadV1Properties => }/TransformationProperties/PostVariants/All.cs (85%) diff --git a/.stats.yml b/.stats.yml index d458a07c..cfcbd7f7 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-e7bc47a9221d7da9c8c9653d3fd1d4cfdf2408588e32c4aa62bd02a50ec93c36.yml -openapi_spec_hash: 8d061396a2fff9d1add4d5baf03ab939 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-667f7f4988b44bc587d6eb9960ff5c8326e9f7e9b072f3f724f9f54166eff8b1.yml +openapi_spec_hash: f2081864a4abee0480e5ff991b4c936a config_hash: 70f9408b8d1dfbcf262a20d6eed50e1c diff --git a/README.md b/README.md index 983e086a..22709ca0 100644 --- a/README.md +++ b/README.md @@ -34,11 +34,18 @@ See the [`examples`](examples) directory for complete and runnable examples. ```csharp using System; using Imagekit; +using Imagekit.Models.Files; // Configured using the IMAGEKIT_PRIVATE_API_KEY, OPTIONAL_IMAGEKIT_IGNORES_THIS, IMAGEKIT_WEBHOOK_SECRET and IMAGE_KIT_BASE_URL environment variables ImageKitClient client = new(); -var response = await client.Files.Upload(); +FileUploadParams parameters = new() +{ + File = "a value", + FileName = "file-name.jpg", +}; + +var response = await client.Files.Upload(parameters); Console.WriteLine(response); ``` diff --git a/src/Imagekit.Tests/Services/Files/FileServiceTest.cs b/src/Imagekit.Tests/Services/Files/FileServiceTest.cs index 2d71ee4f..0ccbc624 100644 --- a/src/Imagekit.Tests/Services/Files/FileServiceTest.cs +++ b/src/Imagekit.Tests/Services/Files/FileServiceTest.cs @@ -62,7 +62,9 @@ public async Task Rename_Works() [Fact(Skip = "Prism tests are disabled")] public async Task Upload_Works() { - var response = await this.client.Files.Upload(); + var response = await this.client.Files.Upload( + new() { File = "a value", FileName = "fileName" } + ); response.Validate(); } } diff --git a/src/Imagekit/ModelBase.cs b/src/Imagekit/ModelBase.cs index 5b88cb2f..e9e70c6b 100644 --- a/src/Imagekit/ModelBase.cs +++ b/src/Imagekit/ModelBase.cs @@ -5,21 +5,19 @@ using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties; using Imagekit.Models.Files.FileUpdateParamsProperties.UpdateProperties.UpdateFileDetailsProperties.ExtensionProperties.AutoTaggingExtensionProperties; using Imagekit.Models.Files.FileUpdateResponseProperties.IntersectionMember1Properties.ExtensionStatusProperties; -using Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.TransformationProperties.PostProperties.AbsProperties; +using Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.AbsProperties; using Imagekit.Models.ImageOverlayProperties.IntersectionMember1Properties; using Imagekit.Models.OverlayPositionProperties; using Imagekit.Models.SubtitleOverlayTransformationProperties; using Imagekit.Models.TextOverlayTransformationProperties; using Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.IntersectionMember1Properties.DataProperties.TransformationProperties.OptionsProperties; using Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.IntersectionMember1Properties.DataProperties.TransformationProperties.ErrorProperties; -using AbsProperties = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties.TransformationProperties.PostProperties.AbsProperties; +using AbsProperties = Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.AbsProperties; using AssetListParamsProperties = Imagekit.Models.Assets.AssetListParamsProperties; -using AutoTaggingExtensionProperties = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.ExtensionProperties.AutoTaggingExtensionProperties; +using AutoTaggingExtensionProperties = Imagekit.Models.Files.FileUploadParamsProperties.ExtensionProperties.AutoTaggingExtensionProperties; using ExtensionStatusProperties = Imagekit.Models.Files.FileUploadResponseProperties.ExtensionStatusProperties; using FileProperties = Imagekit.Models.Files.FileProperties; -using FileUploadParamsProperties = Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties; -using FileUploadV1ByURLProperties = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties; -using FileUploadV1Properties = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties; +using FileUploadParamsProperties = Imagekit.Models.Files.FileUploadParamsProperties; using FolderProperties = Imagekit.Models.Files.FolderProperties; using IntersectionMember1Properties = Imagekit.Models.SubtitleOverlayProperties.IntersectionMember1Properties; using JobGetResponseProperties = Imagekit.Models.Folders.Job.JobGetResponseProperties; @@ -80,14 +78,8 @@ public abstract record class ModelBase new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), - new ApiEnumConverter(), + new ApiEnumConverter(), new ApiEnumConverter(), - new ApiEnumConverter< - string, - global::Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties.ExtensionProperties.AutoTaggingExtensionProperties.Name - >(), - new ApiEnumConverter(), - new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), @@ -114,11 +106,11 @@ public abstract record class ModelBase string, global::Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.ExtensionProperties.AutoTaggingExtensionProperties.Name >(), - new ApiEnumConverter(), new ApiEnumConverter< string, - global::Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.AbsProperties.Protocol + global::Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.ResponseField >(), + new ApiEnumConverter(), new ApiEnumConverter< string, global::Imagekit.Models.Webhooks.UploadPostTransformErrorEventProperties.IntersectionMember1Properties.RequestProperties.TransformationProperties.Type diff --git a/src/Imagekit/Models/Files/FileUploadParams.cs b/src/Imagekit/Models/Files/FileUploadParams.cs index 8942bd04..5dd1291e 100644 --- a/src/Imagekit/Models/Files/FileUploadParams.cs +++ b/src/Imagekit/Models/Files/FileUploadParams.cs @@ -1,81 +1,638 @@ -using System; -using System.Collections.Generic; -using System.Net.Http; -using System.Text; -using System.Text.Json; -using Imagekit.Models.Files.FileUploadParamsProperties; - -namespace Imagekit.Models.Files; - -/// -/// ImageKit.io allows you to upload files directly from both the server and client -/// sides. For server-side uploads, private API key authentication is used. For client-side -/// uploads, generate a one-time `token`, `signature`, and `expire` from your secure -/// backend using private API. [Learn more](/docs/api-reference/upload-file/upload-file#how-to-implement-client-side-file-upload) -/// about how to implement client-side file upload. -/// -/// The [V2 API](/docs/api-reference/upload-file/upload-file-v2) enhances security -/// by verifying the entire payload using JWT. -/// -/// **File size limit** \ On the free plan, the maximum upload file sizes are 20MB -/// for images, audio, and raw files and 100MB for videos. On the paid plan, these -/// limits increase to 40MB for images, audio, and raw files and 2GB for videos. These -/// limits can be further increased with higher-tier plans. -/// -/// **Version limit** \ A file can have a maximum of 100 versions. -/// -/// **Demo applications** -/// -/// - A full-fledged [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), -/// supporting file selections from local storage, URL, Dropbox, Google Drive, Instagram, -/// and more. - [Quick start guides](/docs/quick-start-guides) for various frameworks -/// and technologies. -/// -public sealed record class FileUploadParams : ParamsBase -{ - public Dictionary BodyProperties { get; set; } = []; - - public Body? Body - { - get - { - if (!this.BodyProperties.TryGetValue("body", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["body"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override Uri Url(IImageKitClient client) - { - return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/api/v1/files/upload") - { - Query = this.QueryString(client), - }.Uri; - } - - public StringContent BodyContent() - { - return new( - JsonSerializer.Serialize(this.BodyProperties), - Encoding.UTF8, - "application/json" - ); - } - - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Text; +using System.Text.Json; +using FileUploadParamsProperties = Imagekit.Models.Files.FileUploadParamsProperties; + +namespace Imagekit.Models.Files; + +/// +/// ImageKit.io allows you to upload files directly from both the server and client +/// sides. For server-side uploads, private API key authentication is used. For client-side +/// uploads, generate a one-time `token`, `signature`, and `expire` from your secure +/// backend using private API. [Learn more](/docs/api-reference/upload-file/upload-file#how-to-implement-client-side-file-upload) +/// about how to implement client-side file upload. +/// +/// The [V2 API](/docs/api-reference/upload-file/upload-file-v2) enhances security +/// by verifying the entire payload using JWT. +/// +/// **File size limit** \ On the free plan, the maximum upload file sizes are 20MB +/// for images, audio, and raw files and 100MB for videos. On the paid plan, these +/// limits increase to 40MB for images, audio, and raw files and 2GB for videos. These +/// limits can be further increased with higher-tier plans. +/// +/// **Version limit** \ A file can have a maximum of 100 versions. +/// +/// **Demo applications** +/// +/// - A full-fledged [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), +/// supporting file selections from local storage, URL, Dropbox, Google Drive, Instagram, +/// and more. - [Quick start guides](/docs/quick-start-guides) for various frameworks +/// and technologies. +/// +public sealed record class FileUploadParams : ParamsBase +{ + public Dictionary BodyProperties { get; set; } = []; + + /// + /// The API accepts any of the following: + /// + /// - **Binary data** – send the raw bytes as `multipart/form-data`. - **HTTP + /// / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + /// - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + /// + /// When supplying a URL, the server must receive the response headers within + /// 8 seconds; otherwise the request fails with 400 Bad Request. + /// + public required string File + { + get + { + if (!this.BodyProperties.TryGetValue("file", out JsonElement element)) + throw new ArgumentOutOfRangeException("file", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("file"); + } + set + { + this.BodyProperties["file"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The name with which the file has to be uploaded. The file name can contain: + /// + /// - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. - Special Characters: + /// `.`, `-` + /// + /// Any other character including space will be replaced by `_` + /// + public required string FileName + { + get + { + if (!this.BodyProperties.TryGetValue("fileName", out JsonElement element)) + throw new ArgumentOutOfRangeException("fileName", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("fileName"); + } + set + { + this.BodyProperties["fileName"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// A unique value that the ImageKit.io server will use to recognize and prevent + /// subsequent retries for the same request. We suggest using V4 UUIDs, or another + /// random string with enough entropy to avoid collisions. This field is only + /// required for authentication when uploading a file from the client side. + /// + /// **Note**: Sending a value that has been used in the past will result in a + /// validation error. Even if your previous request resulted in an error, you + /// should always send a new value for this field. + /// + public string? Token + { + get + { + if (!this.BodyProperties.TryGetValue("token", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["token"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Server-side checks to run on the asset. Read more about [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). + /// + public string? Checks + { + get + { + if (!this.BodyProperties.TryGetValue("checks", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["checks"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Define an important area in the image. This is only relevant for image type files. + /// + /// - To be passed as a string with the x and y coordinates of the top-left + /// corner, and width and height of the area of interest in the format `x,y,width,height`. + /// For example - `10,10,100,100` - Can be used with fo-customtransformation. + /// - If this field is not specified and the file is overwritten, then customCoordinates + /// will be removed. + /// + public string? CustomCoordinates + { + get + { + if (!this.BodyProperties.TryGetValue("customCoordinates", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["customCoordinates"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// JSON key-value pairs to associate with the asset. Create the custom metadata + /// fields before setting these values. + /// + public Dictionary? CustomMetadata + { + get + { + if (!this.BodyProperties.TryGetValue("customMetadata", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.BodyProperties["customMetadata"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Optional text to describe the contents of the file. + /// + public string? Description + { + get + { + if (!this.BodyProperties.TryGetValue("description", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["description"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The time until your signature is valid. It must be a [Unix time](https://en.wikipedia.org/wiki/Unix_time) + /// in less than 1 hour into the future. It should be in seconds. This field is + /// only required for authentication when uploading a file from the client side. + /// + public long? Expire + { + get + { + if (!this.BodyProperties.TryGetValue("expire", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["expire"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Array of extensions to be applied to the image. Each extension can be configured + /// with specific parameters based on the extension type. + /// + public List? Extensions + { + get + { + if (!this.BodyProperties.TryGetValue("extensions", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.BodyProperties["extensions"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The folder path in which the image has to be uploaded. If the folder(s) didn't + /// exist before, a new folder(s) is created. + /// + /// The folder name can contain: + /// + /// - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` - Special Characters: + /// `/` , `_` , `-` + /// + /// Using multiple `/` creates a nested folder. + /// + public string? Folder + { + get + { + if (!this.BodyProperties.TryGetValue("folder", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["folder"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to mark the file as private or not. + /// + /// If `true`, the file is marked as private and is accessible only using named + /// transformation or signed URL. + /// + public bool? IsPrivateFile + { + get + { + if (!this.BodyProperties.TryGetValue("isPrivateFile", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["isPrivateFile"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to upload file as published or not. + /// + /// If `false`, the file is marked as unpublished, which restricts access to the + /// file only via the media library. Files in draft or unpublished state can only + /// be publicly accessed after being published. + /// + /// The option to upload in draft state is only available in custom enterprise + /// pricing plans. + /// + public bool? IsPublished + { + get + { + if (!this.BodyProperties.TryGetValue("isPublished", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["isPublished"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// If set to `true` and a file already exists at the exact location, its AITags + /// will be removed. Set `overwriteAITags` to `false` to preserve AITags. + /// + public bool? OverwriteAITags + { + get + { + if (!this.BodyProperties.TryGetValue("overwriteAITags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["overwriteAITags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// If the request does not have `customMetadata`, and a file already exists at + /// the exact location, existing customMetadata will be removed. + /// + public bool? OverwriteCustomMetadata + { + get + { + if ( + !this.BodyProperties.TryGetValue("overwriteCustomMetadata", out JsonElement element) + ) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["overwriteCustomMetadata"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// If `false` and `useUniqueFileName` is also `false`, and a file already exists + /// at the exact location, upload API will return an error immediately. + /// + public bool? OverwriteFile + { + get + { + if (!this.BodyProperties.TryGetValue("overwriteFile", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["overwriteFile"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// If the request does not have `tags`, and a file already exists at the exact + /// location, existing tags will be removed. + /// + public bool? OverwriteTags + { + get + { + if (!this.BodyProperties.TryGetValue("overwriteTags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["overwriteTags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Your ImageKit.io public key. This field is only required for authentication + /// when uploading a file from the client side. + /// + public string? PublicKey + { + get + { + if (!this.BodyProperties.TryGetValue("publicKey", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["publicKey"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Array of response field keys to include in the API response body. + /// + public List>? ResponseFields + { + get + { + if (!this.BodyProperties.TryGetValue("responseFields", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize + >?>(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["responseFields"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key + /// as a key. Learn how to create a signature on the page below. This should be + /// in lowercase. + /// + /// Signature must be calculated on the server-side. This field is only required + /// for authentication when uploading a file from the client side. + /// + public string? Signature + { + get + { + if (!this.BodyProperties.TryGetValue("signature", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["signature"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Set the tags while uploading the file. Provide an array of tag strings (e.g. + /// `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must + /// not exceed 500, and the `%` character is not allowed. If this field is not + /// specified and the file is overwritten, the existing tags will be removed. + /// + public List? Tags + { + get + { + if (!this.BodyProperties.TryGetValue("tags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["tags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Configure pre-processing (`pre`) and post-processing (`post`) transformations. + /// + /// - `pre` — applied before the file is uploaded to the Media Library. Useful + /// for reducing file size or applying basic optimizations upfront (e.g., resize, compress). + /// + /// - `post` — applied immediately after upload. Ideal for generating transformed + /// versions (like video encodes or thumbnails) in advance, so they're ready for + /// delivery without delay. + /// + /// You can mix and match any combination of post-processing types. + /// + public FileUploadParamsProperties::Transformation? Transformation + { + get + { + if (!this.BodyProperties.TryGetValue("transformation", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.BodyProperties["transformation"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to use a unique filename for this file or not. + /// + /// If `true`, ImageKit.io will add a unique suffix to the filename parameter + /// to get a unique filename. + /// + /// If `false`, then the image is uploaded with the provided filename parameter, + /// and any existing file with the same name is replaced. + /// + public bool? UseUniqueFileName + { + get + { + if (!this.BodyProperties.TryGetValue("useUniqueFileName", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["useUniqueFileName"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The final status of extensions after they have completed execution will be + /// delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + /// about the webhook payload structure. + /// + public string? WebhookURL + { + get + { + if (!this.BodyProperties.TryGetValue("webhookUrl", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["webhookUrl"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override Uri Url(IImageKitClient client) + { + return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/api/v1/files/upload") + { + Query = this.QueryString(client), + }.Uri; + } + + public StringContent BodyContent() + { + return new( + JsonSerializer.Serialize(this.BodyProperties), + Encoding.UTF8, + "application/json" + ); + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/Body.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/Body.cs deleted file mode 100644 index 833d7774..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/Body.cs +++ /dev/null @@ -1,117 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties; -using BodyVariants = Imagekit.Models.Files.FileUploadParamsProperties.BodyVariants; - -namespace Imagekit.Models.Files.FileUploadParamsProperties; - -[JsonConverter(typeof(BodyConverter))] -public abstract record class Body -{ - internal Body() { } - - public static implicit operator Body(FileUploadV1 value) => - new BodyVariants::FileUploadV1(value); - - public static implicit operator Body(FileUploadV1ByURL value) => - new BodyVariants::FileUploadV1ByURL(value); - - public bool TryPickFileUploadV1([NotNullWhen(true)] out FileUploadV1? value) - { - value = (this as BodyVariants::FileUploadV1)?.Value; - return value != null; - } - - public bool TryPickFileUploadV1ByURL([NotNullWhen(true)] out FileUploadV1ByURL? value) - { - value = (this as BodyVariants::FileUploadV1ByURL)?.Value; - return value != null; - } - - public void Switch( - Action fileUploadV1, - Action fileUploadV1ByURL - ) - { - switch (this) - { - case BodyVariants::FileUploadV1 inner: - fileUploadV1(inner); - break; - case BodyVariants::FileUploadV1ByURL inner: - fileUploadV1ByURL(inner); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match( - Func fileUploadV1, - Func fileUploadV1ByURL - ) - { - return this switch - { - BodyVariants::FileUploadV1 inner => fileUploadV1(inner), - BodyVariants::FileUploadV1ByURL inner => fileUploadV1ByURL(inner), - _ => throw new InvalidOperationException(), - }; - } - - public abstract void Validate(); -} - -sealed class BodyConverter : JsonConverter -{ - public override Body? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new BodyVariants::FileUploadV1(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new BodyVariants::FileUploadV1ByURL(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - - public override void Write(Utf8JsonWriter writer, Body value, JsonSerializerOptions options) - { - object variant = value switch - { - BodyVariants::FileUploadV1(var fileUploadV1) => fileUploadV1, - BodyVariants::FileUploadV1ByURL(var fileUploadV1ByURL) => fileUploadV1ByURL, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1.cs deleted file mode 100644 index 25020d6b..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1.cs +++ /dev/null @@ -1,642 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using FileUploadV1Properties = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class FileUploadV1 : ModelBase, IFromRaw -{ - /// - /// The API accepts any of the following: - /// - /// - **Binary data** – send the raw bytes as `multipart/form-data`. - **HTTP - /// / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. - /// - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. - /// - /// When supplying a URL, the server must receive the response headers within - /// 8 seconds; otherwise the request fails with 400 Bad Request. - /// - public required string File - { - get - { - if (!this.Properties.TryGetValue("file", out JsonElement element)) - throw new ArgumentOutOfRangeException("file", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("file"); - } - set - { - this.Properties["file"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The name with which the file has to be uploaded. The file name can contain: - /// - /// - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. - Special Characters: - /// `.`, `-` - /// - /// Any other character including space will be replaced by `_` - /// - public required string FileName - { - get - { - if (!this.Properties.TryGetValue("fileName", out JsonElement element)) - throw new ArgumentOutOfRangeException("fileName", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("fileName"); - } - set - { - this.Properties["fileName"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// A unique value that the ImageKit.io server will use to recognize and prevent - /// subsequent retries for the same request. We suggest using V4 UUIDs, or another - /// random string with enough entropy to avoid collisions. This field is only - /// required for authentication when uploading a file from the client side. - /// - /// **Note**: Sending a value that has been used in the past will result in a - /// validation error. Even if your previous request resulted in an error, you - /// should always send a new value for this field. - /// - public string? Token - { - get - { - if (!this.Properties.TryGetValue("token", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["token"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Server-side checks to run on the asset. Read more about [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). - /// - public string? Checks - { - get - { - if (!this.Properties.TryGetValue("checks", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["checks"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Define an important area in the image. This is only relevant for image type files. - /// - /// - To be passed as a string with the x and y coordinates of the top-left - /// corner, and width and height of the area of interest in the format `x,y,width,height`. - /// For example - `10,10,100,100` - Can be used with fo-customtransformation. - /// - If this field is not specified and the file is overwritten, then customCoordinates - /// will be removed. - /// - public string? CustomCoordinates - { - get - { - if (!this.Properties.TryGetValue("customCoordinates", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["customCoordinates"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// JSON key-value pairs to associate with the asset. Create the custom metadata - /// fields before setting these values. - /// - public Dictionary? CustomMetadata - { - get - { - if (!this.Properties.TryGetValue("customMetadata", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["customMetadata"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Optional text to describe the contents of the file. - /// - public string? Description - { - get - { - if (!this.Properties.TryGetValue("description", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["description"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The time until your signature is valid. It must be a [Unix time](https://en.wikipedia.org/wiki/Unix_time) - /// in less than 1 hour into the future. It should be in seconds. This field is - /// only required for authentication when uploading a file from the client side. - /// - public long? Expire - { - get - { - if (!this.Properties.TryGetValue("expire", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["expire"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Array of extensions to be applied to the image. Each extension can be configured - /// with specific parameters based on the extension type. - /// - public List? Extensions - { - get - { - if (!this.Properties.TryGetValue("extensions", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["extensions"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The folder path in which the image has to be uploaded. If the folder(s) didn't - /// exist before, a new folder(s) is created. - /// - /// The folder name can contain: - /// - /// - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` - Special Characters: - /// `/` , `_` , `-` - /// - /// Using multiple `/` creates a nested folder. - /// - public string? Folder - { - get - { - if (!this.Properties.TryGetValue("folder", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["folder"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to mark the file as private or not. - /// - /// If `true`, the file is marked as private and is accessible only using named - /// transformation or signed URL. - /// - public bool? IsPrivateFile - { - get - { - if (!this.Properties.TryGetValue("isPrivateFile", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["isPrivateFile"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to upload file as published or not. - /// - /// If `false`, the file is marked as unpublished, which restricts access to the - /// file only via the media library. Files in draft or unpublished state can only - /// be publicly accessed after being published. - /// - /// The option to upload in draft state is only available in custom enterprise - /// pricing plans. - /// - public bool? IsPublished - { - get - { - if (!this.Properties.TryGetValue("isPublished", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["isPublished"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// If set to `true` and a file already exists at the exact location, its AITags - /// will be removed. Set `overwriteAITags` to `false` to preserve AITags. - /// - public bool? OverwriteAITags - { - get - { - if (!this.Properties.TryGetValue("overwriteAITags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["overwriteAITags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// If the request does not have `customMetadata`, and a file already exists at - /// the exact location, existing customMetadata will be removed. - /// - public bool? OverwriteCustomMetadata - { - get - { - if (!this.Properties.TryGetValue("overwriteCustomMetadata", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["overwriteCustomMetadata"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// If `false` and `useUniqueFileName` is also `false`, and a file already exists - /// at the exact location, upload API will return an error immediately. - /// - public bool? OverwriteFile - { - get - { - if (!this.Properties.TryGetValue("overwriteFile", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["overwriteFile"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// If the request does not have `tags`, and a file already exists at the exact - /// location, existing tags will be removed. - /// - public bool? OverwriteTags - { - get - { - if (!this.Properties.TryGetValue("overwriteTags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["overwriteTags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Your ImageKit.io public key. This field is only required for authentication - /// when uploading a file from the client side. - /// - public string? PublicKey - { - get - { - if (!this.Properties.TryGetValue("publicKey", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["publicKey"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Array of response field keys to include in the API response body. - /// - public List>? ResponseFields - { - get - { - if (!this.Properties.TryGetValue("responseFields", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize - >?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["responseFields"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key - /// as a key. Learn how to create a signature on the page below. This should be - /// in lowercase. - /// - /// Signature must be calculated on the server-side. This field is only required - /// for authentication when uploading a file from the client side. - /// - public string? Signature - { - get - { - if (!this.Properties.TryGetValue("signature", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["signature"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Set the tags while uploading the file. Provide an array of tag strings (e.g. - /// `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must - /// not exceed 500, and the `%` character is not allowed. If this field is not - /// specified and the file is overwritten, the existing tags will be removed. - /// - public List? Tags - { - get - { - if (!this.Properties.TryGetValue("tags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["tags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Configure pre-processing (`pre`) and post-processing (`post`) transformations. - /// - /// - `pre` — applied before the file is uploaded to the Media Library. Useful - /// for reducing file size or applying basic optimizations upfront (e.g., resize, compress). - /// - /// - `post` — applied immediately after upload. Ideal for generating transformed - /// versions (like video encodes or thumbnails) in advance, so they're ready for - /// delivery without delay. - /// - /// You can mix and match any combination of post-processing types. - /// - public FileUploadV1Properties::Transformation? Transformation - { - get - { - if (!this.Properties.TryGetValue("transformation", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["transformation"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to use a unique filename for this file or not. - /// - /// If `true`, ImageKit.io will add a unique suffix to the filename parameter - /// to get a unique filename. - /// - /// If `false`, then the image is uploaded with the provided filename parameter, - /// and any existing file with the same name is replaced. - /// - public bool? UseUniqueFileName - { - get - { - if (!this.Properties.TryGetValue("useUniqueFileName", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["useUniqueFileName"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The final status of extensions after they have completed execution will be - /// delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) - /// about the webhook payload structure. - /// - public string? WebhookURL - { - get - { - if (!this.Properties.TryGetValue("webhookUrl", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["webhookUrl"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.File; - _ = this.FileName; - _ = this.Token; - _ = this.Checks; - _ = this.CustomCoordinates; - if (this.CustomMetadata != null) - { - foreach (var item in this.CustomMetadata.Values) - { - _ = item; - } - } - _ = this.Description; - _ = this.Expire; - foreach (var item in this.Extensions ?? []) - { - item.Validate(); - } - _ = this.Folder; - _ = this.IsPrivateFile; - _ = this.IsPublished; - _ = this.OverwriteAITags; - _ = this.OverwriteCustomMetadata; - _ = this.OverwriteFile; - _ = this.OverwriteTags; - _ = this.PublicKey; - foreach (var item in this.ResponseFields ?? []) - { - item.Validate(); - } - _ = this.Signature; - foreach (var item in this.Tags ?? []) - { - _ = item; - } - this.Transformation?.Validate(); - _ = this.UseUniqueFileName; - _ = this.WebhookURL; - } - - public FileUploadV1() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - FileUploadV1(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static FileUploadV1 FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURL.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURL.cs deleted file mode 100644 index 4865375d..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURL.cs +++ /dev/null @@ -1,637 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using FileUploadV1ByURLProperties = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class FileUploadV1ByURL : ModelBase, IFromRaw -{ - /// - /// A publicly reachable URL that ImageKit’s servers can fetch. The server must - /// receive the response headers within 8 seconds; otherwise the request fails - /// with 400 Bad Request. - /// - public required string File - { - get - { - if (!this.Properties.TryGetValue("file", out JsonElement element)) - throw new ArgumentOutOfRangeException("file", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("file"); - } - set - { - this.Properties["file"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The name with which the file has to be uploaded. The file name can contain: - /// - /// - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. - Special Characters: - /// `.`, `-` - /// - /// Any other character including space will be replaced by `_` - /// - public required string FileName - { - get - { - if (!this.Properties.TryGetValue("fileName", out JsonElement element)) - throw new ArgumentOutOfRangeException("fileName", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("fileName"); - } - set - { - this.Properties["fileName"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// A unique value that the ImageKit.io server will use to recognize and prevent - /// subsequent retries for the same request. We suggest using V4 UUIDs, or another - /// random string with enough entropy to avoid collisions. This field is only - /// required for authentication when uploading a file from the client side. - /// - /// **Note**: Sending a value that has been used in the past will result in a - /// validation error. Even if your previous request resulted in an error, you - /// should always send a new value for this field. - /// - public string? Token - { - get - { - if (!this.Properties.TryGetValue("token", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["token"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Server-side checks to run on the asset. Read more about [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). - /// - public string? Checks - { - get - { - if (!this.Properties.TryGetValue("checks", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["checks"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Define an important area in the image. This is only relevant for image type files. - /// - /// - To be passed as a string with the x and y coordinates of the top-left - /// corner, and width and height of the area of interest in the format `x,y,width,height`. - /// For example - `10,10,100,100` - Can be used with fo-customtransformation. - /// - If this field is not specified and the file is overwritten, then customCoordinates - /// will be removed. - /// - public string? CustomCoordinates - { - get - { - if (!this.Properties.TryGetValue("customCoordinates", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["customCoordinates"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// JSON key-value pairs to associate with the asset. Create the custom metadata - /// fields before setting these values. - /// - public Dictionary? CustomMetadata - { - get - { - if (!this.Properties.TryGetValue("customMetadata", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["customMetadata"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Optional text to describe the contents of the file. - /// - public string? Description - { - get - { - if (!this.Properties.TryGetValue("description", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["description"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The time until your signature is valid. It must be a [Unix time](https://en.wikipedia.org/wiki/Unix_time) - /// in less than 1 hour into the future. It should be in seconds. This field is - /// only required for authentication when uploading a file from the client side. - /// - public long? Expire - { - get - { - if (!this.Properties.TryGetValue("expire", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["expire"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Array of extensions to be applied to the image. Each extension can be configured - /// with specific parameters based on the extension type. - /// - public List? Extensions - { - get - { - if (!this.Properties.TryGetValue("extensions", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["extensions"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The folder path in which the image has to be uploaded. If the folder(s) didn't - /// exist before, a new folder(s) is created. - /// - /// The folder name can contain: - /// - /// - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` - Special Characters: - /// `/` , `_` , `-` - /// - /// Using multiple `/` creates a nested folder. - /// - public string? Folder - { - get - { - if (!this.Properties.TryGetValue("folder", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["folder"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to mark the file as private or not. - /// - /// If `true`, the file is marked as private and is accessible only using named - /// transformation or signed URL. - /// - public bool? IsPrivateFile - { - get - { - if (!this.Properties.TryGetValue("isPrivateFile", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["isPrivateFile"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to upload file as published or not. - /// - /// If `false`, the file is marked as unpublished, which restricts access to the - /// file only via the media library. Files in draft or unpublished state can only - /// be publicly accessed after being published. - /// - /// The option to upload in draft state is only available in custom enterprise - /// pricing plans. - /// - public bool? IsPublished - { - get - { - if (!this.Properties.TryGetValue("isPublished", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["isPublished"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// If set to `true` and a file already exists at the exact location, its AITags - /// will be removed. Set `overwriteAITags` to `false` to preserve AITags. - /// - public bool? OverwriteAITags - { - get - { - if (!this.Properties.TryGetValue("overwriteAITags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["overwriteAITags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// If the request does not have `customMetadata`, and a file already exists at - /// the exact location, existing customMetadata will be removed. - /// - public bool? OverwriteCustomMetadata - { - get - { - if (!this.Properties.TryGetValue("overwriteCustomMetadata", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["overwriteCustomMetadata"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// If `false` and `useUniqueFileName` is also `false`, and a file already exists - /// at the exact location, upload API will return an error immediately. - /// - public bool? OverwriteFile - { - get - { - if (!this.Properties.TryGetValue("overwriteFile", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["overwriteFile"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// If the request does not have `tags`, and a file already exists at the exact - /// location, existing tags will be removed. - /// - public bool? OverwriteTags - { - get - { - if (!this.Properties.TryGetValue("overwriteTags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["overwriteTags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Your ImageKit.io public key. This field is only required for authentication - /// when uploading a file from the client side. - /// - public string? PublicKey - { - get - { - if (!this.Properties.TryGetValue("publicKey", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["publicKey"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Array of response field keys to include in the API response body. - /// - public List>? ResponseFields - { - get - { - if (!this.Properties.TryGetValue("responseFields", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize - >?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["responseFields"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key - /// as a key. Learn how to create a signature on the page below. This should be - /// in lowercase. - /// - /// Signature must be calculated on the server-side. This field is only required - /// for authentication when uploading a file from the client side. - /// - public string? Signature - { - get - { - if (!this.Properties.TryGetValue("signature", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["signature"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Set the tags while uploading the file. Provide an array of tag strings (e.g. - /// `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must - /// not exceed 500, and the `%` character is not allowed. If this field is not - /// specified and the file is overwritten, the existing tags will be removed. - /// - public List? Tags - { - get - { - if (!this.Properties.TryGetValue("tags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["tags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Configure pre-processing (`pre`) and post-processing (`post`) transformations. - /// - /// - `pre` — applied before the file is uploaded to the Media Library. Useful - /// for reducing file size or applying basic optimizations upfront (e.g., resize, compress). - /// - /// - `post` — applied immediately after upload. Ideal for generating transformed - /// versions (like video encodes or thumbnails) in advance, so they're ready for - /// delivery without delay. - /// - /// You can mix and match any combination of post-processing types. - /// - public FileUploadV1ByURLProperties::Transformation? Transformation - { - get - { - if (!this.Properties.TryGetValue("transformation", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["transformation"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to use a unique filename for this file or not. - /// - /// If `true`, ImageKit.io will add a unique suffix to the filename parameter - /// to get a unique filename. - /// - /// If `false`, then the image is uploaded with the provided filename parameter, - /// and any existing file with the same name is replaced. - /// - public bool? UseUniqueFileName - { - get - { - if (!this.Properties.TryGetValue("useUniqueFileName", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["useUniqueFileName"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The final status of extensions after they have completed execution will be - /// delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) - /// about the webhook payload structure. - /// - public string? WebhookURL - { - get - { - if (!this.Properties.TryGetValue("webhookUrl", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["webhookUrl"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.File; - _ = this.FileName; - _ = this.Token; - _ = this.Checks; - _ = this.CustomCoordinates; - if (this.CustomMetadata != null) - { - foreach (var item in this.CustomMetadata.Values) - { - _ = item; - } - } - _ = this.Description; - _ = this.Expire; - foreach (var item in this.Extensions ?? []) - { - item.Validate(); - } - _ = this.Folder; - _ = this.IsPrivateFile; - _ = this.IsPublished; - _ = this.OverwriteAITags; - _ = this.OverwriteCustomMetadata; - _ = this.OverwriteFile; - _ = this.OverwriteTags; - _ = this.PublicKey; - foreach (var item in this.ResponseFields ?? []) - { - item.Validate(); - } - _ = this.Signature; - foreach (var item in this.Tags ?? []) - { - _ = item; - } - this.Transformation?.Validate(); - _ = this.UseUniqueFileName; - _ = this.WebhookURL; - } - - public FileUploadV1ByURL() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - FileUploadV1ByURL(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static FileUploadV1ByURL FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/Extension.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/Extension.cs deleted file mode 100644 index 8b6e388b..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/Extension.cs +++ /dev/null @@ -1,177 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties.ExtensionProperties; -using ExtensionVariants = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties.ExtensionVariants; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties; - -[JsonConverter(typeof(ExtensionConverter))] -public abstract record class Extension -{ - internal Extension() { } - - public static implicit operator Extension(RemoveBg value) => - new ExtensionVariants::RemoveBg(value); - - public static implicit operator Extension(AutoTaggingExtension value) => - new ExtensionVariants::AutoTaggingExtension(value); - - public bool TryPickRemoveBg([NotNullWhen(true)] out RemoveBg? value) - { - value = (this as ExtensionVariants::RemoveBg)?.Value; - return value != null; - } - - public bool TryPickAutoTagging([NotNullWhen(true)] out AutoTaggingExtension? value) - { - value = (this as ExtensionVariants::AutoTaggingExtension)?.Value; - return value != null; - } - - public bool TryPickAIAutoDescription([NotNullWhen(true)] out JsonElement? value) - { - value = (this as ExtensionVariants::AIAutoDescription)?.Value; - return value != null; - } - - public void Switch( - Action removeBg, - Action autoTagging, - Action aiAutoDescription - ) - { - switch (this) - { - case ExtensionVariants::RemoveBg inner: - removeBg(inner); - break; - case ExtensionVariants::AutoTaggingExtension inner: - autoTagging(inner); - break; - case ExtensionVariants::AIAutoDescription inner: - aiAutoDescription(inner); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match( - Func removeBg, - Func autoTagging, - Func aiAutoDescription - ) - { - return this switch - { - ExtensionVariants::RemoveBg inner => removeBg(inner), - ExtensionVariants::AutoTaggingExtension inner => autoTagging(inner), - ExtensionVariants::AIAutoDescription inner => aiAutoDescription(inner), - _ => throw new InvalidOperationException(), - }; - } - - public abstract void Validate(); -} - -sealed class ExtensionConverter : JsonConverter -{ - public override Extension? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - var json = JsonSerializer.Deserialize(ref reader, options); - string? name; - try - { - name = json.GetProperty("name").GetString(); - } - catch - { - name = null; - } - - switch (name) - { - case "remove-bg": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - return new ExtensionVariants::RemoveBg(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "ai-auto-description": - { - List exceptions = []; - - try - { - return new ExtensionVariants::AIAutoDescription( - JsonSerializer.Deserialize(json, options) - ); - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - default: - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize( - json, - options - ); - if (deserialized != null) - { - return new ExtensionVariants::AutoTaggingExtension(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - } - } - - public override void Write( - Utf8JsonWriter writer, - Extension value, - JsonSerializerOptions options - ) - { - object variant = value switch - { - ExtensionVariants::RemoveBg(var removeBg) => removeBg, - ExtensionVariants::AutoTaggingExtension(var autoTagging) => autoTagging, - ExtensionVariants::AIAutoDescription(var aiAutoDescription) => aiAutoDescription, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/ExtensionProperties/AutoTaggingExtension.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/ExtensionProperties/AutoTaggingExtension.cs deleted file mode 100644 index 4b462fc4..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/ExtensionProperties/AutoTaggingExtension.cs +++ /dev/null @@ -1,100 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties.ExtensionProperties.AutoTaggingExtensionProperties; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties.ExtensionProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class AutoTaggingExtension : ModelBase, IFromRaw -{ - /// - /// Maximum number of tags to attach to the asset. - /// - public required long MaxTags - { - get - { - if (!this.Properties.TryGetValue("maxTags", out JsonElement element)) - throw new ArgumentOutOfRangeException("maxTags", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["maxTags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Minimum confidence level for tags to be considered valid. - /// - public required long MinConfidence - { - get - { - if (!this.Properties.TryGetValue("minConfidence", out JsonElement element)) - throw new ArgumentOutOfRangeException("minConfidence", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["minConfidence"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies the auto-tagging extension used. - /// - public required ApiEnum Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - throw new ArgumentOutOfRangeException("name", "Missing required argument"); - - return JsonSerializer.Deserialize>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.MaxTags; - _ = this.MinConfidence; - this.Name.Validate(); - } - - public AutoTaggingExtension() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - AutoTaggingExtension(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static AutoTaggingExtension FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs deleted file mode 100644 index 59b726ea..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties.ExtensionProperties.AutoTaggingExtensionProperties; - -/// -/// Specifies the auto-tagging extension used. -/// -[JsonConverter(typeof(NameConverter))] -public enum Name -{ - GoogleAutoTagging, - AwsAutoTagging, -} - -sealed class NameConverter : JsonConverter -{ - public override Name Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "google-auto-tagging" => Name.GoogleAutoTagging, - "aws-auto-tagging" => Name.AwsAutoTagging, - _ => (Name)(-1), - }; - } - - public override void Write(Utf8JsonWriter writer, Name value, JsonSerializerOptions options) - { - JsonSerializer.Serialize( - writer, - value switch - { - Name.GoogleAutoTagging => "google-auto-tagging", - Name.AwsAutoTagging => "aws-auto-tagging", - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/ExtensionProperties/RemoveBg.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/ExtensionProperties/RemoveBg.cs deleted file mode 100644 index 408fe2e7..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/ExtensionProperties/RemoveBg.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties.ExtensionProperties.RemoveBgProperties; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties.ExtensionProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class RemoveBg : ModelBase, IFromRaw -{ - /// - /// Specifies the background removal extension. - /// - public JsonElement Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - throw new ArgumentOutOfRangeException("name", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public Options? Options - { - get - { - if (!this.Properties.TryGetValue("options", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["options"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Options?.Validate(); - } - - public RemoveBg() - { - this.Name = JsonSerializer.Deserialize("\"remove-bg\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - RemoveBg(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static RemoveBg FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/ExtensionProperties/RemoveBgProperties/Options.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/ExtensionProperties/RemoveBgProperties/Options.cs deleted file mode 100644 index b3aeb0e3..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/ExtensionProperties/RemoveBgProperties/Options.cs +++ /dev/null @@ -1,122 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties.ExtensionProperties.RemoveBgProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Options : ModelBase, IFromRaw -{ - /// - /// Whether to add an artificial shadow to the result. Default is false. Note: - /// Adding shadows is currently only supported for car photos. - /// - public bool? AddShadow - { - get - { - if (!this.Properties.TryGetValue("add_shadow", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["add_shadow"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies a solid color background using hex code (e.g., "81d4fa", "fff") - /// or color name (e.g., "green"). If this parameter is set, `bg_image_url` must - /// be empty. - /// - public string? BgColor - { - get - { - if (!this.Properties.TryGetValue("bg_color", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["bg_color"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Sets a background image from a URL. If this parameter is set, `bg_color` - /// must be empty. - /// - public string? BgImageURL - { - get - { - if (!this.Properties.TryGetValue("bg_image_url", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["bg_image_url"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Allows semi-transparent regions in the result. Default is true. Note: Semitransparency - /// is currently only supported for car windows. - /// - public bool? Semitransparency - { - get - { - if (!this.Properties.TryGetValue("semitransparency", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["semitransparency"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.AddShadow; - _ = this.BgColor; - _ = this.BgImageURL; - _ = this.Semitransparency; - } - - public Options() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Options(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Options FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/ExtensionVariants/All.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/ExtensionVariants/All.cs deleted file mode 100644 index 1d6e8757..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/ExtensionVariants/All.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System.Text.Json; -using ExtensionProperties = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties.ExtensionProperties; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties.ExtensionVariants; - -public sealed record class RemoveBg(ExtensionProperties::RemoveBg Value) - : Extension, - IVariant -{ - public static RemoveBg From(ExtensionProperties::RemoveBg value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class AutoTaggingExtension(ExtensionProperties::AutoTaggingExtension Value) - : Extension, - IVariant -{ - public static AutoTaggingExtension From(ExtensionProperties::AutoTaggingExtension value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class AIAutoDescription(JsonElement Value) - : Extension, - IVariant -{ - public static AIAutoDescription From(JsonElement value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/ResponseField.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/ResponseField.cs deleted file mode 100644 index 5ec04597..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/ResponseField.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties; - -[JsonConverter(typeof(ResponseFieldConverter))] -public enum ResponseField -{ - Tags, - CustomCoordinates, - IsPrivateFile, - EmbeddedMetadata, - IsPublished, - CustomMetadata, - Metadata, -} - -sealed class ResponseFieldConverter : JsonConverter -{ - public override ResponseField Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "tags" => ResponseField.Tags, - "customCoordinates" => ResponseField.CustomCoordinates, - "isPrivateFile" => ResponseField.IsPrivateFile, - "embeddedMetadata" => ResponseField.EmbeddedMetadata, - "isPublished" => ResponseField.IsPublished, - "customMetadata" => ResponseField.CustomMetadata, - "metadata" => ResponseField.Metadata, - _ => (ResponseField)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - ResponseField value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - ResponseField.Tags => "tags", - ResponseField.CustomCoordinates => "customCoordinates", - ResponseField.IsPrivateFile => "isPrivateFile", - ResponseField.EmbeddedMetadata => "embeddedMetadata", - ResponseField.IsPublished => "isPublished", - ResponseField.CustomMetadata => "customMetadata", - ResponseField.Metadata => "metadata", - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/Transformation.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/Transformation.cs deleted file mode 100644 index b38d9ff1..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/Transformation.cs +++ /dev/null @@ -1,92 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties.TransformationProperties; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties; - -/// -/// Configure pre-processing (`pre`) and post-processing (`post`) transformations. -/// -/// - `pre` — applied before the file is uploaded to the Media Library. Useful -/// for reducing file size or applying basic optimizations upfront (e.g., resize, compress). -/// -/// - `post` — applied immediately after upload. Ideal for generating transformed -/// versions (like video encodes or thumbnails) in advance, so they're ready for -/// delivery without delay. -/// -/// You can mix and match any combination of post-processing types. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class Transformation : ModelBase, IFromRaw -{ - /// - /// List of transformations to apply *after* the file is uploaded. Each item - /// must match one of the following types: `transformation`, `gif-to-video`, - /// `thumbnail`, `abs`. - /// - public List? Post - { - get - { - if (!this.Properties.TryGetValue("post", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["post"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Transformation string to apply before uploading the file to the Media Library. - /// Useful for optimizing files at ingestion. - /// - public string? Pre - { - get - { - if (!this.Properties.TryGetValue("pre", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["pre"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - foreach (var item in this.Post ?? []) - { - item.Validate(); - } - _ = this.Pre; - } - - public Transformation() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Transformation(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Transformation FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/Post.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/Post.cs deleted file mode 100644 index e3e9b5dc..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/Post.cs +++ /dev/null @@ -1,225 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using PostProperties = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties.TransformationProperties.PostProperties; -using PostVariants = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties.TransformationProperties.PostVariants; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties.TransformationProperties; - -[JsonConverter(typeof(PostConverter))] -public abstract record class Post -{ - internal Post() { } - - public static implicit operator Post(PostProperties::Transformation value) => - new PostVariants::Transformation(value); - - public static implicit operator Post(PostProperties::GifToVideo value) => - new PostVariants::GifToVideo(value); - - public static implicit operator Post(PostProperties::Thumbnail value) => - new PostVariants::Thumbnail(value); - - public static implicit operator Post(PostProperties::Abs value) => new PostVariants::Abs(value); - - public bool TryPickTransformation([NotNullWhen(true)] out PostProperties::Transformation? value) - { - value = (this as PostVariants::Transformation)?.Value; - return value != null; - } - - public bool TryPickGifToVideo([NotNullWhen(true)] out PostProperties::GifToVideo? value) - { - value = (this as PostVariants::GifToVideo)?.Value; - return value != null; - } - - public bool TryPickThumbnail([NotNullWhen(true)] out PostProperties::Thumbnail? value) - { - value = (this as PostVariants::Thumbnail)?.Value; - return value != null; - } - - public bool TryPickAbs([NotNullWhen(true)] out PostProperties::Abs? value) - { - value = (this as PostVariants::Abs)?.Value; - return value != null; - } - - public void Switch( - Action transformation, - Action gifToVideo, - Action thumbnail, - Action abs - ) - { - switch (this) - { - case PostVariants::Transformation inner: - transformation(inner); - break; - case PostVariants::GifToVideo inner: - gifToVideo(inner); - break; - case PostVariants::Thumbnail inner: - thumbnail(inner); - break; - case PostVariants::Abs inner: - abs(inner); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match( - Func transformation, - Func gifToVideo, - Func thumbnail, - Func abs - ) - { - return this switch - { - PostVariants::Transformation inner => transformation(inner), - PostVariants::GifToVideo inner => gifToVideo(inner), - PostVariants::Thumbnail inner => thumbnail(inner), - PostVariants::Abs inner => abs(inner), - _ => throw new InvalidOperationException(), - }; - } - - public abstract void Validate(); -} - -sealed class PostConverter : JsonConverter -{ - public override Post? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - var json = JsonSerializer.Deserialize(ref reader, options); - string? type; - try - { - type = json.GetProperty("type").GetString(); - } - catch - { - type = null; - } - - switch (type) - { - case "transformation": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize( - json, - options - ); - if (deserialized != null) - { - return new PostVariants::Transformation(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "gif-to-video": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize( - json, - options - ); - if (deserialized != null) - { - return new PostVariants::GifToVideo(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "thumbnail": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize( - json, - options - ); - if (deserialized != null) - { - return new PostVariants::Thumbnail(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "abs": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize( - json, - options - ); - if (deserialized != null) - { - return new PostVariants::Abs(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - default: - { - throw new Exception(); - } - } - } - - public override void Write(Utf8JsonWriter writer, Post value, JsonSerializerOptions options) - { - object variant = value switch - { - PostVariants::Transformation(var transformation) => transformation, - PostVariants::GifToVideo(var gifToVideo) => gifToVideo, - PostVariants::Thumbnail(var thumbnail) => thumbnail, - PostVariants::Abs(var abs) => abs, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/PostProperties/Abs.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/PostProperties/Abs.cs deleted file mode 100644 index 74928750..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/PostProperties/Abs.cs +++ /dev/null @@ -1,103 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties.TransformationProperties.PostProperties.AbsProperties; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties.TransformationProperties.PostProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Abs : ModelBase, IFromRaw -{ - /// - /// Streaming protocol to use (`hls` or `dash`). - /// - public required ApiEnum Protocol - { - get - { - if (!this.Properties.TryGetValue("protocol", out JsonElement element)) - throw new ArgumentOutOfRangeException("protocol", "Missing required argument"); - - return JsonSerializer.Deserialize>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["protocol"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Adaptive Bitrate Streaming (ABS) setup. - /// - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// List of different representations you want to create separated by an underscore. - /// - public required string Value - { - get - { - if (!this.Properties.TryGetValue("value", out JsonElement element)) - throw new ArgumentOutOfRangeException("value", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("value"); - } - set - { - this.Properties["value"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Protocol.Validate(); - _ = this.Value; - } - - public Abs() - { - this.Type = JsonSerializer.Deserialize("\"abs\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Abs(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Abs FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs deleted file mode 100644 index 74cc77b5..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties.TransformationProperties.PostProperties.AbsProperties; - -/// -/// Streaming protocol to use (`hls` or `dash`). -/// -[JsonConverter(typeof(ProtocolConverter))] -public enum Protocol -{ - Hls, - Dash, -} - -sealed class ProtocolConverter : JsonConverter -{ - public override Protocol Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "hls" => Protocol.Hls, - "dash" => Protocol.Dash, - _ => (Protocol)(-1), - }; - } - - public override void Write(Utf8JsonWriter writer, Protocol value, JsonSerializerOptions options) - { - JsonSerializer.Serialize( - writer, - value switch - { - Protocol.Hls => "hls", - Protocol.Dash => "dash", - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/PostProperties/GifToVideo.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/PostProperties/GifToVideo.cs deleted file mode 100644 index 83983308..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/PostProperties/GifToVideo.cs +++ /dev/null @@ -1,77 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties.TransformationProperties.PostProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class GifToVideo : ModelBase, IFromRaw -{ - /// - /// Converts an animated GIF into an MP4. - /// - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Optional transformation string to apply to the output video. **Example**: - /// `q-80` - /// - public string? Value - { - get - { - if (!this.Properties.TryGetValue("value", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["value"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.Value; - } - - public GifToVideo() - { - this.Type = JsonSerializer.Deserialize("\"gif-to-video\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - GifToVideo(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static GifToVideo FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/PostProperties/Thumbnail.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/PostProperties/Thumbnail.cs deleted file mode 100644 index 1ae871a5..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/PostProperties/Thumbnail.cs +++ /dev/null @@ -1,76 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties.TransformationProperties.PostProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Thumbnail : ModelBase, IFromRaw -{ - /// - /// Generates a thumbnail image. - /// - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Optional transformation string. **Example**: `w-150,h-150` - /// - public string? Value - { - get - { - if (!this.Properties.TryGetValue("value", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["value"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.Value; - } - - public Thumbnail() - { - this.Type = JsonSerializer.Deserialize("\"thumbnail\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Thumbnail(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Thumbnail FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/PostProperties/Transformation.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/PostProperties/Transformation.cs deleted file mode 100644 index 9b8a76e1..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/PostProperties/Transformation.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties.TransformationProperties.PostProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Transformation : ModelBase, IFromRaw -{ - /// - /// Transformation type. - /// - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Transformation string (e.g. `w-200,h-200`). Same syntax as ImageKit URL-based - /// transformations. - /// - public required string Value - { - get - { - if (!this.Properties.TryGetValue("value", out JsonElement element)) - throw new ArgumentOutOfRangeException("value", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("value"); - } - set - { - this.Properties["value"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.Value; - } - - public Transformation() - { - this.Type = JsonSerializer.Deserialize("\"transformation\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Transformation(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Transformation FromRawUnchecked(Dictionary properties) - { - return new(properties); - } - - [SetsRequiredMembers] - public Transformation(string value) - : this() - { - this.Value = value; - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/PostVariants/All.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/PostVariants/All.cs deleted file mode 100644 index b33c0181..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1ByURLProperties/TransformationProperties/PostVariants/All.cs +++ /dev/null @@ -1,61 +0,0 @@ -using PostProperties = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties.TransformationProperties.PostProperties; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1ByURLProperties.TransformationProperties.PostVariants; - -public sealed record class Transformation(PostProperties::Transformation Value) - : Post, - IVariant -{ - public static Transformation From(PostProperties::Transformation value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class GifToVideo(PostProperties::GifToVideo Value) - : Post, - IVariant -{ - public static GifToVideo From(PostProperties::GifToVideo value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class Thumbnail(PostProperties::Thumbnail Value) - : Post, - IVariant -{ - public static Thumbnail From(PostProperties::Thumbnail value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class Abs(PostProperties::Abs Value) : Post, IVariant -{ - public static Abs From(PostProperties::Abs value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyVariants/All.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyVariants/All.cs deleted file mode 100644 index 4cedc4de..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyVariants/All.cs +++ /dev/null @@ -1,33 +0,0 @@ -using BodyProperties = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyVariants; - -public sealed record class FileUploadV1(BodyProperties::FileUploadV1 Value) - : Body, - IVariant -{ - public static FileUploadV1 From(BodyProperties::FileUploadV1 value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class FileUploadV1ByURL(BodyProperties::FileUploadV1ByURL Value) - : Body, - IVariant -{ - public static FileUploadV1ByURL From(BodyProperties::FileUploadV1ByURL value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/Extension.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/Extension.cs similarity index 95% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/Extension.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/Extension.cs index 438024fd..aca5f9b4 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/Extension.cs +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/Extension.cs @@ -3,10 +3,10 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.ExtensionProperties; -using ExtensionVariants = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.ExtensionVariants; +using Imagekit.Models.Files.FileUploadParamsProperties.ExtensionProperties; +using ExtensionVariants = Imagekit.Models.Files.FileUploadParamsProperties.ExtensionVariants; -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties; +namespace Imagekit.Models.Files.FileUploadParamsProperties; [JsonConverter(typeof(ExtensionConverter))] public abstract record class Extension diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ExtensionProperties/AutoTaggingExtension.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/AutoTaggingExtension.cs similarity index 91% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ExtensionProperties/AutoTaggingExtension.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/AutoTaggingExtension.cs index e708a2de..11eab9ca 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ExtensionProperties/AutoTaggingExtension.cs +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/AutoTaggingExtension.cs @@ -3,9 +3,9 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.ExtensionProperties.AutoTaggingExtensionProperties; +using Imagekit.Models.Files.FileUploadParamsProperties.ExtensionProperties.AutoTaggingExtensionProperties; -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.ExtensionProperties; +namespace Imagekit.Models.Files.FileUploadParamsProperties.ExtensionProperties; [JsonConverter(typeof(ModelConverter))] public sealed record class AutoTaggingExtension : ModelBase, IFromRaw diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs similarity index 88% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs index 343532bc..55796f3b 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs @@ -2,7 +2,7 @@ using System.Text.Json; using System.Text.Json.Serialization; -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.ExtensionProperties.AutoTaggingExtensionProperties; +namespace Imagekit.Models.Files.FileUploadParamsProperties.ExtensionProperties.AutoTaggingExtensionProperties; /// /// Specifies the auto-tagging extension used. diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ExtensionProperties/RemoveBg.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/RemoveBg.cs similarity index 88% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ExtensionProperties/RemoveBg.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/RemoveBg.cs index 6c64ff28..68223612 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ExtensionProperties/RemoveBg.cs +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/RemoveBg.cs @@ -3,9 +3,9 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.ExtensionProperties.RemoveBgProperties; +using Imagekit.Models.Files.FileUploadParamsProperties.ExtensionProperties.RemoveBgProperties; -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.ExtensionProperties; +namespace Imagekit.Models.Files.FileUploadParamsProperties.ExtensionProperties; [JsonConverter(typeof(ModelConverter))] public sealed record class RemoveBg : ModelBase, IFromRaw diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ExtensionProperties/RemoveBgProperties/Options.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/RemoveBgProperties/Options.cs similarity index 96% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ExtensionProperties/RemoveBgProperties/Options.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/RemoveBgProperties/Options.cs index f85a0ea6..7f5799e6 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ExtensionProperties/RemoveBgProperties/Options.cs +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/RemoveBgProperties/Options.cs @@ -3,7 +3,7 @@ using System.Text.Json; using System.Text.Json.Serialization; -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.ExtensionProperties.RemoveBgProperties; +namespace Imagekit.Models.Files.FileUploadParamsProperties.ExtensionProperties.RemoveBgProperties; [JsonConverter(typeof(ModelConverter))] public sealed record class Options : ModelBase, IFromRaw diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ExtensionVariants/All.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionVariants/All.cs similarity index 85% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ExtensionVariants/All.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionVariants/All.cs index f1660feb..b312f63e 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ExtensionVariants/All.cs +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionVariants/All.cs @@ -1,7 +1,7 @@ using System.Text.Json; -using ExtensionProperties = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.ExtensionProperties; +using ExtensionProperties = Imagekit.Models.Files.FileUploadParamsProperties.ExtensionProperties; -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.ExtensionVariants; +namespace Imagekit.Models.Files.FileUploadParamsProperties.ExtensionVariants; public sealed record class RemoveBg(ExtensionProperties::RemoveBg Value) : Extension, diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ResponseField.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/ResponseField.cs similarity index 94% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ResponseField.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/ResponseField.cs index b823b0fa..c5b5b8f7 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ResponseField.cs +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/ResponseField.cs @@ -2,7 +2,7 @@ using System.Text.Json; using System.Text.Json.Serialization; -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties; +namespace Imagekit.Models.Files.FileUploadParamsProperties; [JsonConverter(typeof(ResponseFieldConverter))] public enum ResponseField diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/Transformation.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/Transformation.cs similarity index 92% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/Transformation.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/Transformation.cs index 69579c4d..e8cdd4c6 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/Transformation.cs +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/Transformation.cs @@ -2,9 +2,9 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.TransformationProperties; +using Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties; -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties; +namespace Imagekit.Models.Files.FileUploadParamsProperties; /// /// Configure pre-processing (`pre`) and post-processing (`post`) transformations. diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/Post.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/Post.cs similarity index 95% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/Post.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/Post.cs index 555e08ed..9f7a1ec3 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/Post.cs +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/Post.cs @@ -3,10 +3,10 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using PostProperties = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.TransformationProperties.PostProperties; -using PostVariants = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.TransformationProperties.PostVariants; +using PostProperties = Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; +using PostVariants = Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostVariants; -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.TransformationProperties; +namespace Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties; [JsonConverter(typeof(PostConverter))] public abstract record class Post diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostProperties/Abs.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Abs.cs similarity index 90% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostProperties/Abs.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Abs.cs index 35d58a5b..10c95b3c 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostProperties/Abs.cs +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Abs.cs @@ -3,9 +3,9 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.TransformationProperties.PostProperties.AbsProperties; +using Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.AbsProperties; -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.TransformationProperties.PostProperties; +namespace Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; [JsonConverter(typeof(ModelConverter))] public sealed record class Abs : ModelBase, IFromRaw diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs similarity index 87% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs index 876df70b..56d80f9f 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs @@ -2,7 +2,7 @@ using System.Text.Json; using System.Text.Json.Serialization; -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.TransformationProperties.PostProperties.AbsProperties; +namespace Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.AbsProperties; /// /// Streaming protocol to use (`hls` or `dash`). diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostProperties/GifToVideo.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideo.cs similarity index 93% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostProperties/GifToVideo.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideo.cs index c23153e9..44e57f2a 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostProperties/GifToVideo.cs +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideo.cs @@ -4,7 +4,7 @@ using System.Text.Json; using System.Text.Json.Serialization; -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.TransformationProperties.PostProperties; +namespace Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; [JsonConverter(typeof(ModelConverter))] public sealed record class GifToVideo : ModelBase, IFromRaw diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostProperties/Thumbnail.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Thumbnail.cs similarity index 93% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostProperties/Thumbnail.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Thumbnail.cs index 7454152f..879f27c1 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostProperties/Thumbnail.cs +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Thumbnail.cs @@ -4,7 +4,7 @@ using System.Text.Json; using System.Text.Json.Serialization; -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.TransformationProperties.PostProperties; +namespace Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; [JsonConverter(typeof(ModelConverter))] public sealed record class Thumbnail : ModelBase, IFromRaw diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostProperties/Transformation.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Transformation.cs similarity index 94% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostProperties/Transformation.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Transformation.cs index cd34b1fc..b68c748b 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostProperties/Transformation.cs +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Transformation.cs @@ -4,7 +4,7 @@ using System.Text.Json; using System.Text.Json.Serialization; -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.TransformationProperties.PostProperties; +namespace Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; [JsonConverter(typeof(ModelConverter))] public sealed record class Transformation : ModelBase, IFromRaw diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostVariants/All.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostVariants/All.cs similarity index 85% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostVariants/All.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostVariants/All.cs index aca8a9cb..ae864596 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostVariants/All.cs +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostVariants/All.cs @@ -1,6 +1,6 @@ -using PostProperties = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.TransformationProperties.PostProperties; +using PostProperties = Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.TransformationProperties.PostVariants; +namespace Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostVariants; public sealed record class Transformation(PostProperties::Transformation Value) : Post, diff --git a/src/Imagekit/Services/Files/FileService.cs b/src/Imagekit/Services/Files/FileService.cs index 344a8f65..7ec98b70 100644 --- a/src/Imagekit/Services/Files/FileService.cs +++ b/src/Imagekit/Services/Files/FileService.cs @@ -172,10 +172,8 @@ await response.Content.ReadAsStreamAsync().ConfigureAwait(false), ) ?? throw new NullReferenceException(); } - public async Task Upload(FileUploadParams? parameters = null) + public async Task Upload(FileUploadParams parameters) { - parameters ??= new(); - using HttpRequestMessage request = new(HttpMethod.Post, parameters.Url(this._client)) { Content = parameters.BodyContent(), diff --git a/src/Imagekit/Services/Files/IFileService.cs b/src/Imagekit/Services/Files/IFileService.cs index 64cd4040..183d998d 100644 --- a/src/Imagekit/Services/Files/IFileService.cs +++ b/src/Imagekit/Services/Files/IFileService.cs @@ -87,5 +87,5 @@ public interface IFileService /// Instagram, and more. - [Quick start guides](/docs/quick-start-guides) for /// various frameworks and technologies. /// - Task Upload(FileUploadParams? parameters = null); + Task Upload(FileUploadParams parameters); } From 465abaaa4fa857aefb0d25bd1bfa5f5938841350 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 28 Jan 2026 17:26:13 +0000 Subject: [PATCH 012/129] feat(api): manual updates --- .stats.yml | 4 +- README.md | 9 +- .../Services/Files/FileServiceTest.cs | 4 +- src/Imagekit/ModelBase.cs | 22 +- src/Imagekit/Models/Files/FileUploadParams.cs | 567 +--------------- .../Files/FileUploadParamsProperties/Body.cs | 117 ++++ .../BodyProperties/FileUploadByUrlv1.cs | 637 +++++++++++++++++ .../FileUploadByUrlv1Properties/Extension.cs | 177 +++++ .../AutoTaggingExtension.cs | 100 +++ .../AutoTaggingExtensionProperties/Name.cs | 46 ++ .../ExtensionProperties/RemoveBg.cs | 74 ++ .../RemoveBgProperties/Options.cs | 122 ++++ .../ExtensionVariants/All.cs | 46 ++ .../ResponseField.cs | 62 ++ .../Transformation.cs | 92 +++ .../TransformationProperties/Post.cs | 225 ++++++ .../PostProperties/Abs.cs | 103 +++ .../PostProperties/AbsProperties/Protocol.cs | 46 ++ .../PostProperties/GifToVideo.cs | 77 +++ .../PostProperties/Thumbnail.cs | 76 +++ .../PostProperties/Transformation.cs | 85 +++ .../PostVariants/All.cs | 61 ++ .../BodyProperties/FileUploadV1.cs | 642 ++++++++++++++++++ .../FileUploadV1Properties}/Extension.cs | 0 .../AutoTaggingExtension.cs | 0 .../AutoTaggingExtensionProperties/Name.cs | 0 .../ExtensionProperties/RemoveBg.cs | 0 .../RemoveBgProperties/Options.cs | 0 .../ExtensionVariants/All.cs | 0 .../FileUploadV1Properties}/ResponseField.cs | 0 .../FileUploadV1Properties}/Transformation.cs | 0 .../TransformationProperties/Post.cs | 0 .../PostProperties/Abs.cs | 0 .../PostProperties/AbsProperties/Protocol.cs | 0 .../PostProperties/GifToVideo.cs | 0 .../PostProperties/Thumbnail.cs | 0 .../PostProperties/Transformation.cs | 0 .../PostVariants/All.cs | 0 .../BodyVariants/All.cs | 33 + 39 files changed, 2845 insertions(+), 582 deletions(-) create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/Body.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/Extension.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/ExtensionProperties/AutoTaggingExtension.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/ExtensionProperties/RemoveBg.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/ExtensionProperties/RemoveBgProperties/Options.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/ExtensionVariants/All.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/ResponseField.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/Transformation.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/Post.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/PostProperties/Abs.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/PostProperties/GifToVideo.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/PostProperties/Thumbnail.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/PostProperties/Transformation.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/PostVariants/All.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1.cs rename src/Imagekit/Models/Files/FileUploadParamsProperties/{ => BodyProperties/FileUploadV1Properties}/Extension.cs (100%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{ => BodyProperties/FileUploadV1Properties}/ExtensionProperties/AutoTaggingExtension.cs (100%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{ => BodyProperties/FileUploadV1Properties}/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs (100%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{ => BodyProperties/FileUploadV1Properties}/ExtensionProperties/RemoveBg.cs (100%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{ => BodyProperties/FileUploadV1Properties}/ExtensionProperties/RemoveBgProperties/Options.cs (100%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{ => BodyProperties/FileUploadV1Properties}/ExtensionVariants/All.cs (100%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{ => BodyProperties/FileUploadV1Properties}/ResponseField.cs (100%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{ => BodyProperties/FileUploadV1Properties}/Transformation.cs (100%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{ => BodyProperties/FileUploadV1Properties}/TransformationProperties/Post.cs (100%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{ => BodyProperties/FileUploadV1Properties}/TransformationProperties/PostProperties/Abs.cs (100%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{ => BodyProperties/FileUploadV1Properties}/TransformationProperties/PostProperties/AbsProperties/Protocol.cs (100%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{ => BodyProperties/FileUploadV1Properties}/TransformationProperties/PostProperties/GifToVideo.cs (100%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{ => BodyProperties/FileUploadV1Properties}/TransformationProperties/PostProperties/Thumbnail.cs (100%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{ => BodyProperties/FileUploadV1Properties}/TransformationProperties/PostProperties/Transformation.cs (100%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{ => BodyProperties/FileUploadV1Properties}/TransformationProperties/PostVariants/All.cs (100%) create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyVariants/All.cs diff --git a/.stats.yml b/.stats.yml index cfcbd7f7..db7d8f1e 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-667f7f4988b44bc587d6eb9960ff5c8326e9f7e9b072f3f724f9f54166eff8b1.yml -openapi_spec_hash: f2081864a4abee0480e5ff991b4c936a +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-9ae7b43dcfd6208ca37c32c887630ae186ec338bcdd36902b6fe5d1cc66459dc.yml +openapi_spec_hash: 25fb64c067e64bcff6eaaabda26de397 config_hash: 70f9408b8d1dfbcf262a20d6eed50e1c diff --git a/README.md b/README.md index 22709ca0..983e086a 100644 --- a/README.md +++ b/README.md @@ -34,18 +34,11 @@ See the [`examples`](examples) directory for complete and runnable examples. ```csharp using System; using Imagekit; -using Imagekit.Models.Files; // Configured using the IMAGEKIT_PRIVATE_API_KEY, OPTIONAL_IMAGEKIT_IGNORES_THIS, IMAGEKIT_WEBHOOK_SECRET and IMAGE_KIT_BASE_URL environment variables ImageKitClient client = new(); -FileUploadParams parameters = new() -{ - File = "a value", - FileName = "file-name.jpg", -}; - -var response = await client.Files.Upload(parameters); +var response = await client.Files.Upload(); Console.WriteLine(response); ``` diff --git a/src/Imagekit.Tests/Services/Files/FileServiceTest.cs b/src/Imagekit.Tests/Services/Files/FileServiceTest.cs index 0ccbc624..2d71ee4f 100644 --- a/src/Imagekit.Tests/Services/Files/FileServiceTest.cs +++ b/src/Imagekit.Tests/Services/Files/FileServiceTest.cs @@ -62,9 +62,7 @@ public async Task Rename_Works() [Fact(Skip = "Prism tests are disabled")] public async Task Upload_Works() { - var response = await this.client.Files.Upload( - new() { File = "a value", FileName = "fileName" } - ); + var response = await this.client.Files.Upload(); response.Validate(); } } diff --git a/src/Imagekit/ModelBase.cs b/src/Imagekit/ModelBase.cs index e9e70c6b..134e0b02 100644 --- a/src/Imagekit/ModelBase.cs +++ b/src/Imagekit/ModelBase.cs @@ -5,19 +5,21 @@ using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties; using Imagekit.Models.Files.FileUpdateParamsProperties.UpdateProperties.UpdateFileDetailsProperties.ExtensionProperties.AutoTaggingExtensionProperties; using Imagekit.Models.Files.FileUpdateResponseProperties.IntersectionMember1Properties.ExtensionStatusProperties; -using Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.AbsProperties; +using Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.TransformationProperties.PostProperties.AbsProperties; using Imagekit.Models.ImageOverlayProperties.IntersectionMember1Properties; using Imagekit.Models.OverlayPositionProperties; using Imagekit.Models.SubtitleOverlayTransformationProperties; using Imagekit.Models.TextOverlayTransformationProperties; using Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.IntersectionMember1Properties.DataProperties.TransformationProperties.OptionsProperties; using Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.IntersectionMember1Properties.DataProperties.TransformationProperties.ErrorProperties; -using AbsProperties = Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.AbsProperties; +using AbsProperties = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties.TransformationProperties.PostProperties.AbsProperties; using AssetListParamsProperties = Imagekit.Models.Assets.AssetListParamsProperties; -using AutoTaggingExtensionProperties = Imagekit.Models.Files.FileUploadParamsProperties.ExtensionProperties.AutoTaggingExtensionProperties; +using AutoTaggingExtensionProperties = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.ExtensionProperties.AutoTaggingExtensionProperties; using ExtensionStatusProperties = Imagekit.Models.Files.FileUploadResponseProperties.ExtensionStatusProperties; using FileProperties = Imagekit.Models.Files.FileProperties; -using FileUploadParamsProperties = Imagekit.Models.Files.FileUploadParamsProperties; +using FileUploadByUrlv1Properties = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties; +using FileUploadParamsProperties = Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties; +using FileUploadV1Properties = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties; using FolderProperties = Imagekit.Models.Files.FolderProperties; using IntersectionMember1Properties = Imagekit.Models.SubtitleOverlayProperties.IntersectionMember1Properties; using JobGetResponseProperties = Imagekit.Models.Folders.Job.JobGetResponseProperties; @@ -78,8 +80,14 @@ public abstract record class ModelBase new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), - new ApiEnumConverter(), + new ApiEnumConverter(), new ApiEnumConverter(), + new ApiEnumConverter< + string, + global::Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties.ExtensionProperties.AutoTaggingExtensionProperties.Name + >(), + new ApiEnumConverter(), + new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), @@ -106,11 +114,11 @@ public abstract record class ModelBase string, global::Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.ExtensionProperties.AutoTaggingExtensionProperties.Name >(), + new ApiEnumConverter(), new ApiEnumConverter< string, - global::Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.ResponseField + global::Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.AbsProperties.Protocol >(), - new ApiEnumConverter(), new ApiEnumConverter< string, global::Imagekit.Models.Webhooks.UploadPostTransformErrorEventProperties.IntersectionMember1Properties.RequestProperties.TransformationProperties.Type diff --git a/src/Imagekit/Models/Files/FileUploadParams.cs b/src/Imagekit/Models/Files/FileUploadParams.cs index 5dd1291e..72ca6fee 100644 --- a/src/Imagekit/Models/Files/FileUploadParams.cs +++ b/src/Imagekit/Models/Files/FileUploadParams.cs @@ -3,7 +3,7 @@ using System.Net.Http; using System.Text; using System.Text.Json; -using FileUploadParamsProperties = Imagekit.Models.Files.FileUploadParamsProperties; +using Imagekit.Models.Files.FileUploadParamsProperties; namespace Imagekit.Models.Files; @@ -35,575 +35,18 @@ public sealed record class FileUploadParams : ParamsBase { public Dictionary BodyProperties { get; set; } = []; - /// - /// The API accepts any of the following: - /// - /// - **Binary data** – send the raw bytes as `multipart/form-data`. - **HTTP - /// / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. - /// - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. - /// - /// When supplying a URL, the server must receive the response headers within - /// 8 seconds; otherwise the request fails with 400 Bad Request. - /// - public required string File + public Body? Body { get { - if (!this.BodyProperties.TryGetValue("file", out JsonElement element)) - throw new ArgumentOutOfRangeException("file", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("file"); - } - set - { - this.BodyProperties["file"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The name with which the file has to be uploaded. The file name can contain: - /// - /// - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. - Special Characters: - /// `.`, `-` - /// - /// Any other character including space will be replaced by `_` - /// - public required string FileName - { - get - { - if (!this.BodyProperties.TryGetValue("fileName", out JsonElement element)) - throw new ArgumentOutOfRangeException("fileName", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("fileName"); - } - set - { - this.BodyProperties["fileName"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// A unique value that the ImageKit.io server will use to recognize and prevent - /// subsequent retries for the same request. We suggest using V4 UUIDs, or another - /// random string with enough entropy to avoid collisions. This field is only - /// required for authentication when uploading a file from the client side. - /// - /// **Note**: Sending a value that has been used in the past will result in a - /// validation error. Even if your previous request resulted in an error, you - /// should always send a new value for this field. - /// - public string? Token - { - get - { - if (!this.BodyProperties.TryGetValue("token", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["token"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Server-side checks to run on the asset. Read more about [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). - /// - public string? Checks - { - get - { - if (!this.BodyProperties.TryGetValue("checks", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["checks"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Define an important area in the image. This is only relevant for image type files. - /// - /// - To be passed as a string with the x and y coordinates of the top-left - /// corner, and width and height of the area of interest in the format `x,y,width,height`. - /// For example - `10,10,100,100` - Can be used with fo-customtransformation. - /// - If this field is not specified and the file is overwritten, then customCoordinates - /// will be removed. - /// - public string? CustomCoordinates - { - get - { - if (!this.BodyProperties.TryGetValue("customCoordinates", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["customCoordinates"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// JSON key-value pairs to associate with the asset. Create the custom metadata - /// fields before setting these values. - /// - public Dictionary? CustomMetadata - { - get - { - if (!this.BodyProperties.TryGetValue("customMetadata", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.BodyProperties["customMetadata"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Optional text to describe the contents of the file. - /// - public string? Description - { - get - { - if (!this.BodyProperties.TryGetValue("description", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["description"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The time until your signature is valid. It must be a [Unix time](https://en.wikipedia.org/wiki/Unix_time) - /// in less than 1 hour into the future. It should be in seconds. This field is - /// only required for authentication when uploading a file from the client side. - /// - public long? Expire - { - get - { - if (!this.BodyProperties.TryGetValue("expire", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["expire"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Array of extensions to be applied to the image. Each extension can be configured - /// with specific parameters based on the extension type. - /// - public List? Extensions - { - get - { - if (!this.BodyProperties.TryGetValue("extensions", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.BodyProperties["extensions"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The folder path in which the image has to be uploaded. If the folder(s) didn't - /// exist before, a new folder(s) is created. - /// - /// The folder name can contain: - /// - /// - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` - Special Characters: - /// `/` , `_` , `-` - /// - /// Using multiple `/` creates a nested folder. - /// - public string? Folder - { - get - { - if (!this.BodyProperties.TryGetValue("folder", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["folder"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to mark the file as private or not. - /// - /// If `true`, the file is marked as private and is accessible only using named - /// transformation or signed URL. - /// - public bool? IsPrivateFile - { - get - { - if (!this.BodyProperties.TryGetValue("isPrivateFile", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["isPrivateFile"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to upload file as published or not. - /// - /// If `false`, the file is marked as unpublished, which restricts access to the - /// file only via the media library. Files in draft or unpublished state can only - /// be publicly accessed after being published. - /// - /// The option to upload in draft state is only available in custom enterprise - /// pricing plans. - /// - public bool? IsPublished - { - get - { - if (!this.BodyProperties.TryGetValue("isPublished", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["isPublished"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// If set to `true` and a file already exists at the exact location, its AITags - /// will be removed. Set `overwriteAITags` to `false` to preserve AITags. - /// - public bool? OverwriteAITags - { - get - { - if (!this.BodyProperties.TryGetValue("overwriteAITags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["overwriteAITags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// If the request does not have `customMetadata`, and a file already exists at - /// the exact location, existing customMetadata will be removed. - /// - public bool? OverwriteCustomMetadata - { - get - { - if ( - !this.BodyProperties.TryGetValue("overwriteCustomMetadata", out JsonElement element) - ) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["overwriteCustomMetadata"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// If `false` and `useUniqueFileName` is also `false`, and a file already exists - /// at the exact location, upload API will return an error immediately. - /// - public bool? OverwriteFile - { - get - { - if (!this.BodyProperties.TryGetValue("overwriteFile", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["overwriteFile"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// If the request does not have `tags`, and a file already exists at the exact - /// location, existing tags will be removed. - /// - public bool? OverwriteTags - { - get - { - if (!this.BodyProperties.TryGetValue("overwriteTags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["overwriteTags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Your ImageKit.io public key. This field is only required for authentication - /// when uploading a file from the client side. - /// - public string? PublicKey - { - get - { - if (!this.BodyProperties.TryGetValue("publicKey", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["publicKey"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Array of response field keys to include in the API response body. - /// - public List>? ResponseFields - { - get - { - if (!this.BodyProperties.TryGetValue("responseFields", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize - >?>(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["responseFields"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key - /// as a key. Learn how to create a signature on the page below. This should be - /// in lowercase. - /// - /// Signature must be calculated on the server-side. This field is only required - /// for authentication when uploading a file from the client side. - /// - public string? Signature - { - get - { - if (!this.BodyProperties.TryGetValue("signature", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["signature"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Set the tags while uploading the file. Provide an array of tag strings (e.g. - /// `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must - /// not exceed 500, and the `%` character is not allowed. If this field is not - /// specified and the file is overwritten, the existing tags will be removed. - /// - public List? Tags - { - get - { - if (!this.BodyProperties.TryGetValue("tags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["tags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Configure pre-processing (`pre`) and post-processing (`post`) transformations. - /// - /// - `pre` — applied before the file is uploaded to the Media Library. Useful - /// for reducing file size or applying basic optimizations upfront (e.g., resize, compress). - /// - /// - `post` — applied immediately after upload. Ideal for generating transformed - /// versions (like video encodes or thumbnails) in advance, so they're ready for - /// delivery without delay. - /// - /// You can mix and match any combination of post-processing types. - /// - public FileUploadParamsProperties::Transformation? Transformation - { - get - { - if (!this.BodyProperties.TryGetValue("transformation", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.BodyProperties["transformation"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to use a unique filename for this file or not. - /// - /// If `true`, ImageKit.io will add a unique suffix to the filename parameter - /// to get a unique filename. - /// - /// If `false`, then the image is uploaded with the provided filename parameter, - /// and any existing file with the same name is replaced. - /// - public bool? UseUniqueFileName - { - get - { - if (!this.BodyProperties.TryGetValue("useUniqueFileName", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["useUniqueFileName"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The final status of extensions after they have completed execution will be - /// delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) - /// about the webhook payload structure. - /// - public string? WebhookURL - { - get - { - if (!this.BodyProperties.TryGetValue("webhookUrl", out JsonElement element)) + if (!this.BodyProperties.TryGetValue("body", out JsonElement element)) return null; - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); } set { - this.BodyProperties["webhookUrl"] = JsonSerializer.SerializeToElement( + this.BodyProperties["body"] = JsonSerializer.SerializeToElement( value, ModelBase.SerializerOptions ); diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/Body.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/Body.cs new file mode 100644 index 00000000..aabad9fe --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/Body.cs @@ -0,0 +1,117 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties; +using BodyVariants = Imagekit.Models.Files.FileUploadParamsProperties.BodyVariants; + +namespace Imagekit.Models.Files.FileUploadParamsProperties; + +[JsonConverter(typeof(BodyConverter))] +public abstract record class Body +{ + internal Body() { } + + public static implicit operator Body(FileUploadV1 value) => + new BodyVariants::FileUploadV1(value); + + public static implicit operator Body(FileUploadByUrlv1 value) => + new BodyVariants::FileUploadByUrlv1(value); + + public bool TryPickFileUploadV1([NotNullWhen(true)] out FileUploadV1? value) + { + value = (this as BodyVariants::FileUploadV1)?.Value; + return value != null; + } + + public bool TryPickFileUploadByUrlv1([NotNullWhen(true)] out FileUploadByUrlv1? value) + { + value = (this as BodyVariants::FileUploadByUrlv1)?.Value; + return value != null; + } + + public void Switch( + Action fileUploadV1, + Action fileUploadByUrlv1 + ) + { + switch (this) + { + case BodyVariants::FileUploadV1 inner: + fileUploadV1(inner); + break; + case BodyVariants::FileUploadByUrlv1 inner: + fileUploadByUrlv1(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func fileUploadV1, + Func fileUploadByUrlv1 + ) + { + return this switch + { + BodyVariants::FileUploadV1 inner => fileUploadV1(inner), + BodyVariants::FileUploadByUrlv1 inner => fileUploadByUrlv1(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class BodyConverter : JsonConverter +{ + public override Body? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new BodyVariants::FileUploadV1(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new BodyVariants::FileUploadByUrlv1(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + + public override void Write(Utf8JsonWriter writer, Body value, JsonSerializerOptions options) + { + object variant = value switch + { + BodyVariants::FileUploadV1(var fileUploadV1) => fileUploadV1, + BodyVariants::FileUploadByUrlv1(var fileUploadByUrlv1) => fileUploadByUrlv1, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1.cs new file mode 100644 index 00000000..82bb36fb --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1.cs @@ -0,0 +1,637 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using FileUploadByUrlv1Properties = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class FileUploadByUrlv1 : ModelBase, IFromRaw +{ + /// + /// The URL of the file to upload. A publicly reachable URL that ImageKit servers + /// can fetch. The server must receive the response headers within 8 seconds; + /// otherwise the request fails with 400 Bad Request. + /// + public required string File + { + get + { + if (!this.Properties.TryGetValue("file", out JsonElement element)) + throw new ArgumentOutOfRangeException("file", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("file"); + } + set + { + this.Properties["file"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The name with which the file has to be uploaded. The file name can contain: + /// + /// - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. - Special Characters: + /// `.`, `-` + /// + /// Any other character including space will be replaced by `_` + /// + public required string FileName + { + get + { + if (!this.Properties.TryGetValue("fileName", out JsonElement element)) + throw new ArgumentOutOfRangeException("fileName", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("fileName"); + } + set + { + this.Properties["fileName"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// A unique value that the ImageKit.io server will use to recognize and prevent + /// subsequent retries for the same request. We suggest using V4 UUIDs, or another + /// random string with enough entropy to avoid collisions. This field is only + /// required for authentication when uploading a file from the client side. + /// + /// **Note**: Sending a value that has been used in the past will result in a + /// validation error. Even if your previous request resulted in an error, you + /// should always send a new value for this field. + /// + public string? Token + { + get + { + if (!this.Properties.TryGetValue("token", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["token"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Server-side checks to run on the asset. Read more about [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). + /// + public string? Checks + { + get + { + if (!this.Properties.TryGetValue("checks", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["checks"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Define an important area in the image. This is only relevant for image type files. + /// + /// - To be passed as a string with the x and y coordinates of the top-left + /// corner, and width and height of the area of interest in the format `x,y,width,height`. + /// For example - `10,10,100,100` - Can be used with fo-customtransformation. + /// - If this field is not specified and the file is overwritten, then customCoordinates + /// will be removed. + /// + public string? CustomCoordinates + { + get + { + if (!this.Properties.TryGetValue("customCoordinates", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["customCoordinates"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// JSON key-value pairs to associate with the asset. Create the custom metadata + /// fields before setting these values. + /// + public Dictionary? CustomMetadata + { + get + { + if (!this.Properties.TryGetValue("customMetadata", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["customMetadata"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Optional text to describe the contents of the file. + /// + public string? Description + { + get + { + if (!this.Properties.TryGetValue("description", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["description"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The time until your signature is valid. It must be a [Unix time](https://en.wikipedia.org/wiki/Unix_time) + /// in less than 1 hour into the future. It should be in seconds. This field is + /// only required for authentication when uploading a file from the client side. + /// + public long? Expire + { + get + { + if (!this.Properties.TryGetValue("expire", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["expire"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Array of extensions to be applied to the image. Each extension can be configured + /// with specific parameters based on the extension type. + /// + public List? Extensions + { + get + { + if (!this.Properties.TryGetValue("extensions", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["extensions"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The folder path in which the image has to be uploaded. If the folder(s) didn't + /// exist before, a new folder(s) is created. + /// + /// The folder name can contain: + /// + /// - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` - Special Characters: + /// `/` , `_` , `-` + /// + /// Using multiple `/` creates a nested folder. + /// + public string? Folder + { + get + { + if (!this.Properties.TryGetValue("folder", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["folder"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to mark the file as private or not. + /// + /// If `true`, the file is marked as private and is accessible only using named + /// transformation or signed URL. + /// + public bool? IsPrivateFile + { + get + { + if (!this.Properties.TryGetValue("isPrivateFile", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["isPrivateFile"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to upload file as published or not. + /// + /// If `false`, the file is marked as unpublished, which restricts access to the + /// file only via the media library. Files in draft or unpublished state can only + /// be publicly accessed after being published. + /// + /// The option to upload in draft state is only available in custom enterprise + /// pricing plans. + /// + public bool? IsPublished + { + get + { + if (!this.Properties.TryGetValue("isPublished", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["isPublished"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// If set to `true` and a file already exists at the exact location, its AITags + /// will be removed. Set `overwriteAITags` to `false` to preserve AITags. + /// + public bool? OverwriteAITags + { + get + { + if (!this.Properties.TryGetValue("overwriteAITags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["overwriteAITags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// If the request does not have `customMetadata`, and a file already exists at + /// the exact location, existing customMetadata will be removed. + /// + public bool? OverwriteCustomMetadata + { + get + { + if (!this.Properties.TryGetValue("overwriteCustomMetadata", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["overwriteCustomMetadata"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// If `false` and `useUniqueFileName` is also `false`, and a file already exists + /// at the exact location, upload API will return an error immediately. + /// + public bool? OverwriteFile + { + get + { + if (!this.Properties.TryGetValue("overwriteFile", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["overwriteFile"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// If the request does not have `tags`, and a file already exists at the exact + /// location, existing tags will be removed. + /// + public bool? OverwriteTags + { + get + { + if (!this.Properties.TryGetValue("overwriteTags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["overwriteTags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Your ImageKit.io public key. This field is only required for authentication + /// when uploading a file from the client side. + /// + public string? PublicKey + { + get + { + if (!this.Properties.TryGetValue("publicKey", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["publicKey"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Array of response field keys to include in the API response body. + /// + public List>? ResponseFields + { + get + { + if (!this.Properties.TryGetValue("responseFields", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize + >?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["responseFields"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key + /// as a key. Learn how to create a signature on the page below. This should be + /// in lowercase. + /// + /// Signature must be calculated on the server-side. This field is only required + /// for authentication when uploading a file from the client side. + /// + public string? Signature + { + get + { + if (!this.Properties.TryGetValue("signature", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["signature"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Set the tags while uploading the file. Provide an array of tag strings (e.g. + /// `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must + /// not exceed 500, and the `%` character is not allowed. If this field is not + /// specified and the file is overwritten, the existing tags will be removed. + /// + public List? Tags + { + get + { + if (!this.Properties.TryGetValue("tags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["tags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Configure pre-processing (`pre`) and post-processing (`post`) transformations. + /// + /// - `pre` — applied before the file is uploaded to the Media Library. Useful + /// for reducing file size or applying basic optimizations upfront (e.g., resize, compress). + /// + /// - `post` — applied immediately after upload. Ideal for generating transformed + /// versions (like video encodes or thumbnails) in advance, so they're ready for + /// delivery without delay. + /// + /// You can mix and match any combination of post-processing types. + /// + public FileUploadByUrlv1Properties::Transformation? Transformation + { + get + { + if (!this.Properties.TryGetValue("transformation", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["transformation"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to use a unique filename for this file or not. + /// + /// If `true`, ImageKit.io will add a unique suffix to the filename parameter + /// to get a unique filename. + /// + /// If `false`, then the image is uploaded with the provided filename parameter, + /// and any existing file with the same name is replaced. + /// + public bool? UseUniqueFileName + { + get + { + if (!this.Properties.TryGetValue("useUniqueFileName", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["useUniqueFileName"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The final status of extensions after they have completed execution will be + /// delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + /// about the webhook payload structure. + /// + public string? WebhookURL + { + get + { + if (!this.Properties.TryGetValue("webhookUrl", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["webhookUrl"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.File; + _ = this.FileName; + _ = this.Token; + _ = this.Checks; + _ = this.CustomCoordinates; + if (this.CustomMetadata != null) + { + foreach (var item in this.CustomMetadata.Values) + { + _ = item; + } + } + _ = this.Description; + _ = this.Expire; + foreach (var item in this.Extensions ?? []) + { + item.Validate(); + } + _ = this.Folder; + _ = this.IsPrivateFile; + _ = this.IsPublished; + _ = this.OverwriteAITags; + _ = this.OverwriteCustomMetadata; + _ = this.OverwriteFile; + _ = this.OverwriteTags; + _ = this.PublicKey; + foreach (var item in this.ResponseFields ?? []) + { + item.Validate(); + } + _ = this.Signature; + foreach (var item in this.Tags ?? []) + { + _ = item; + } + this.Transformation?.Validate(); + _ = this.UseUniqueFileName; + _ = this.WebhookURL; + } + + public FileUploadByUrlv1() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FileUploadByUrlv1(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static FileUploadByUrlv1 FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/Extension.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/Extension.cs new file mode 100644 index 00000000..8c22bcf0 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/Extension.cs @@ -0,0 +1,177 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties.ExtensionProperties; +using ExtensionVariants = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties.ExtensionVariants; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties; + +[JsonConverter(typeof(ExtensionConverter))] +public abstract record class Extension +{ + internal Extension() { } + + public static implicit operator Extension(RemoveBg value) => + new ExtensionVariants::RemoveBg(value); + + public static implicit operator Extension(AutoTaggingExtension value) => + new ExtensionVariants::AutoTaggingExtension(value); + + public bool TryPickRemoveBg([NotNullWhen(true)] out RemoveBg? value) + { + value = (this as ExtensionVariants::RemoveBg)?.Value; + return value != null; + } + + public bool TryPickAutoTagging([NotNullWhen(true)] out AutoTaggingExtension? value) + { + value = (this as ExtensionVariants::AutoTaggingExtension)?.Value; + return value != null; + } + + public bool TryPickAIAutoDescription([NotNullWhen(true)] out JsonElement? value) + { + value = (this as ExtensionVariants::AIAutoDescription)?.Value; + return value != null; + } + + public void Switch( + Action removeBg, + Action autoTagging, + Action aiAutoDescription + ) + { + switch (this) + { + case ExtensionVariants::RemoveBg inner: + removeBg(inner); + break; + case ExtensionVariants::AutoTaggingExtension inner: + autoTagging(inner); + break; + case ExtensionVariants::AIAutoDescription inner: + aiAutoDescription(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func removeBg, + Func autoTagging, + Func aiAutoDescription + ) + { + return this switch + { + ExtensionVariants::RemoveBg inner => removeBg(inner), + ExtensionVariants::AutoTaggingExtension inner => autoTagging(inner), + ExtensionVariants::AIAutoDescription inner => aiAutoDescription(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class ExtensionConverter : JsonConverter +{ + public override Extension? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var json = JsonSerializer.Deserialize(ref reader, options); + string? name; + try + { + name = json.GetProperty("name").GetString(); + } + catch + { + name = null; + } + + switch (name) + { + case "remove-bg": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new ExtensionVariants::RemoveBg(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "ai-auto-description": + { + List exceptions = []; + + try + { + return new ExtensionVariants::AIAutoDescription( + JsonSerializer.Deserialize(json, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + default: + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize( + json, + options + ); + if (deserialized != null) + { + return new ExtensionVariants::AutoTaggingExtension(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + Extension value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + ExtensionVariants::RemoveBg(var removeBg) => removeBg, + ExtensionVariants::AutoTaggingExtension(var autoTagging) => autoTagging, + ExtensionVariants::AIAutoDescription(var aiAutoDescription) => aiAutoDescription, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/ExtensionProperties/AutoTaggingExtension.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/ExtensionProperties/AutoTaggingExtension.cs new file mode 100644 index 00000000..0a09cc4f --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/ExtensionProperties/AutoTaggingExtension.cs @@ -0,0 +1,100 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties.ExtensionProperties.AutoTaggingExtensionProperties; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties.ExtensionProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class AutoTaggingExtension : ModelBase, IFromRaw +{ + /// + /// Maximum number of tags to attach to the asset. + /// + public required long MaxTags + { + get + { + if (!this.Properties.TryGetValue("maxTags", out JsonElement element)) + throw new ArgumentOutOfRangeException("maxTags", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["maxTags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Minimum confidence level for tags to be considered valid. + /// + public required long MinConfidence + { + get + { + if (!this.Properties.TryGetValue("minConfidence", out JsonElement element)) + throw new ArgumentOutOfRangeException("minConfidence", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["minConfidence"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies the auto-tagging extension used. + /// + public required ApiEnum Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + throw new ArgumentOutOfRangeException("name", "Missing required argument"); + + return JsonSerializer.Deserialize>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.MaxTags; + _ = this.MinConfidence; + this.Name.Validate(); + } + + public AutoTaggingExtension() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + AutoTaggingExtension(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static AutoTaggingExtension FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs new file mode 100644 index 00000000..b021f711 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs @@ -0,0 +1,46 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties.ExtensionProperties.AutoTaggingExtensionProperties; + +/// +/// Specifies the auto-tagging extension used. +/// +[JsonConverter(typeof(NameConverter))] +public enum Name +{ + GoogleAutoTagging, + AwsAutoTagging, +} + +sealed class NameConverter : JsonConverter +{ + public override Name Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "google-auto-tagging" => Name.GoogleAutoTagging, + "aws-auto-tagging" => Name.AwsAutoTagging, + _ => (Name)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Name value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + Name.GoogleAutoTagging => "google-auto-tagging", + Name.AwsAutoTagging => "aws-auto-tagging", + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/ExtensionProperties/RemoveBg.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/ExtensionProperties/RemoveBg.cs new file mode 100644 index 00000000..9f7f3376 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/ExtensionProperties/RemoveBg.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties.ExtensionProperties.RemoveBgProperties; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties.ExtensionProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class RemoveBg : ModelBase, IFromRaw +{ + /// + /// Specifies the background removal extension. + /// + public JsonElement Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + throw new ArgumentOutOfRangeException("name", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public Options? Options + { + get + { + if (!this.Properties.TryGetValue("options", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["options"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.Options?.Validate(); + } + + public RemoveBg() + { + this.Name = JsonSerializer.Deserialize("\"remove-bg\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + RemoveBg(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static RemoveBg FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/ExtensionProperties/RemoveBgProperties/Options.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/ExtensionProperties/RemoveBgProperties/Options.cs new file mode 100644 index 00000000..4db46138 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/ExtensionProperties/RemoveBgProperties/Options.cs @@ -0,0 +1,122 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties.ExtensionProperties.RemoveBgProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Options : ModelBase, IFromRaw +{ + /// + /// Whether to add an artificial shadow to the result. Default is false. Note: + /// Adding shadows is currently only supported for car photos. + /// + public bool? AddShadow + { + get + { + if (!this.Properties.TryGetValue("add_shadow", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["add_shadow"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies a solid color background using hex code (e.g., "81d4fa", "fff") + /// or color name (e.g., "green"). If this parameter is set, `bg_image_url` must + /// be empty. + /// + public string? BgColor + { + get + { + if (!this.Properties.TryGetValue("bg_color", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["bg_color"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Sets a background image from a URL. If this parameter is set, `bg_color` + /// must be empty. + /// + public string? BgImageURL + { + get + { + if (!this.Properties.TryGetValue("bg_image_url", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["bg_image_url"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Allows semi-transparent regions in the result. Default is true. Note: Semitransparency + /// is currently only supported for car windows. + /// + public bool? Semitransparency + { + get + { + if (!this.Properties.TryGetValue("semitransparency", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["semitransparency"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.AddShadow; + _ = this.BgColor; + _ = this.BgImageURL; + _ = this.Semitransparency; + } + + public Options() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Options(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Options FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/ExtensionVariants/All.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/ExtensionVariants/All.cs new file mode 100644 index 00000000..5bca09c4 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/ExtensionVariants/All.cs @@ -0,0 +1,46 @@ +using System.Text.Json; +using ExtensionProperties = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties.ExtensionProperties; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties.ExtensionVariants; + +public sealed record class RemoveBg(ExtensionProperties::RemoveBg Value) + : Extension, + IVariant +{ + public static RemoveBg From(ExtensionProperties::RemoveBg value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class AutoTaggingExtension(ExtensionProperties::AutoTaggingExtension Value) + : Extension, + IVariant +{ + public static AutoTaggingExtension From(ExtensionProperties::AutoTaggingExtension value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class AIAutoDescription(JsonElement Value) + : Extension, + IVariant +{ + public static AIAutoDescription From(JsonElement value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/ResponseField.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/ResponseField.cs new file mode 100644 index 00000000..274b0693 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/ResponseField.cs @@ -0,0 +1,62 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties; + +[JsonConverter(typeof(ResponseFieldConverter))] +public enum ResponseField +{ + Tags, + CustomCoordinates, + IsPrivateFile, + EmbeddedMetadata, + IsPublished, + CustomMetadata, + Metadata, +} + +sealed class ResponseFieldConverter : JsonConverter +{ + public override ResponseField Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "tags" => ResponseField.Tags, + "customCoordinates" => ResponseField.CustomCoordinates, + "isPrivateFile" => ResponseField.IsPrivateFile, + "embeddedMetadata" => ResponseField.EmbeddedMetadata, + "isPublished" => ResponseField.IsPublished, + "customMetadata" => ResponseField.CustomMetadata, + "metadata" => ResponseField.Metadata, + _ => (ResponseField)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ResponseField value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ResponseField.Tags => "tags", + ResponseField.CustomCoordinates => "customCoordinates", + ResponseField.IsPrivateFile => "isPrivateFile", + ResponseField.EmbeddedMetadata => "embeddedMetadata", + ResponseField.IsPublished => "isPublished", + ResponseField.CustomMetadata => "customMetadata", + ResponseField.Metadata => "metadata", + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/Transformation.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/Transformation.cs new file mode 100644 index 00000000..808e2c12 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/Transformation.cs @@ -0,0 +1,92 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties.TransformationProperties; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties; + +/// +/// Configure pre-processing (`pre`) and post-processing (`post`) transformations. +/// +/// - `pre` — applied before the file is uploaded to the Media Library. Useful +/// for reducing file size or applying basic optimizations upfront (e.g., resize, compress). +/// +/// - `post` — applied immediately after upload. Ideal for generating transformed +/// versions (like video encodes or thumbnails) in advance, so they're ready for +/// delivery without delay. +/// +/// You can mix and match any combination of post-processing types. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class Transformation : ModelBase, IFromRaw +{ + /// + /// List of transformations to apply *after* the file is uploaded. Each item + /// must match one of the following types: `transformation`, `gif-to-video`, + /// `thumbnail`, `abs`. + /// + public List? Post + { + get + { + if (!this.Properties.TryGetValue("post", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["post"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Transformation string to apply before uploading the file to the Media Library. + /// Useful for optimizing files at ingestion. + /// + public string? Pre + { + get + { + if (!this.Properties.TryGetValue("pre", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["pre"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + foreach (var item in this.Post ?? []) + { + item.Validate(); + } + _ = this.Pre; + } + + public Transformation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Transformation(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Transformation FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/Post.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/Post.cs new file mode 100644 index 00000000..f6a2bc35 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/Post.cs @@ -0,0 +1,225 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using PostProperties = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties.TransformationProperties.PostProperties; +using PostVariants = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties.TransformationProperties.PostVariants; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties.TransformationProperties; + +[JsonConverter(typeof(PostConverter))] +public abstract record class Post +{ + internal Post() { } + + public static implicit operator Post(PostProperties::Transformation value) => + new PostVariants::Transformation(value); + + public static implicit operator Post(PostProperties::GifToVideo value) => + new PostVariants::GifToVideo(value); + + public static implicit operator Post(PostProperties::Thumbnail value) => + new PostVariants::Thumbnail(value); + + public static implicit operator Post(PostProperties::Abs value) => new PostVariants::Abs(value); + + public bool TryPickTransformation([NotNullWhen(true)] out PostProperties::Transformation? value) + { + value = (this as PostVariants::Transformation)?.Value; + return value != null; + } + + public bool TryPickGifToVideo([NotNullWhen(true)] out PostProperties::GifToVideo? value) + { + value = (this as PostVariants::GifToVideo)?.Value; + return value != null; + } + + public bool TryPickThumbnail([NotNullWhen(true)] out PostProperties::Thumbnail? value) + { + value = (this as PostVariants::Thumbnail)?.Value; + return value != null; + } + + public bool TryPickAbs([NotNullWhen(true)] out PostProperties::Abs? value) + { + value = (this as PostVariants::Abs)?.Value; + return value != null; + } + + public void Switch( + Action transformation, + Action gifToVideo, + Action thumbnail, + Action abs + ) + { + switch (this) + { + case PostVariants::Transformation inner: + transformation(inner); + break; + case PostVariants::GifToVideo inner: + gifToVideo(inner); + break; + case PostVariants::Thumbnail inner: + thumbnail(inner); + break; + case PostVariants::Abs inner: + abs(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func transformation, + Func gifToVideo, + Func thumbnail, + Func abs + ) + { + return this switch + { + PostVariants::Transformation inner => transformation(inner), + PostVariants::GifToVideo inner => gifToVideo(inner), + PostVariants::Thumbnail inner => thumbnail(inner), + PostVariants::Abs inner => abs(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class PostConverter : JsonConverter +{ + public override Post? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var json = JsonSerializer.Deserialize(ref reader, options); + string? type; + try + { + type = json.GetProperty("type").GetString(); + } + catch + { + type = null; + } + + switch (type) + { + case "transformation": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize( + json, + options + ); + if (deserialized != null) + { + return new PostVariants::Transformation(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "gif-to-video": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize( + json, + options + ); + if (deserialized != null) + { + return new PostVariants::GifToVideo(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "thumbnail": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize( + json, + options + ); + if (deserialized != null) + { + return new PostVariants::Thumbnail(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "abs": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize( + json, + options + ); + if (deserialized != null) + { + return new PostVariants::Abs(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + default: + { + throw new Exception(); + } + } + } + + public override void Write(Utf8JsonWriter writer, Post value, JsonSerializerOptions options) + { + object variant = value switch + { + PostVariants::Transformation(var transformation) => transformation, + PostVariants::GifToVideo(var gifToVideo) => gifToVideo, + PostVariants::Thumbnail(var thumbnail) => thumbnail, + PostVariants::Abs(var abs) => abs, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/PostProperties/Abs.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/PostProperties/Abs.cs new file mode 100644 index 00000000..1f776dcc --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/PostProperties/Abs.cs @@ -0,0 +1,103 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties.TransformationProperties.PostProperties.AbsProperties; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties.TransformationProperties.PostProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Abs : ModelBase, IFromRaw +{ + /// + /// Streaming protocol to use (`hls` or `dash`). + /// + public required ApiEnum Protocol + { + get + { + if (!this.Properties.TryGetValue("protocol", out JsonElement element)) + throw new ArgumentOutOfRangeException("protocol", "Missing required argument"); + + return JsonSerializer.Deserialize>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["protocol"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Adaptive Bitrate Streaming (ABS) setup. + /// + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// List of different representations you want to create separated by an underscore. + /// + public required string Value + { + get + { + if (!this.Properties.TryGetValue("value", out JsonElement element)) + throw new ArgumentOutOfRangeException("value", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("value"); + } + set + { + this.Properties["value"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.Protocol.Validate(); + _ = this.Value; + } + + public Abs() + { + this.Type = JsonSerializer.Deserialize("\"abs\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Abs(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Abs FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs new file mode 100644 index 00000000..fc5aba5d --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs @@ -0,0 +1,46 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties.TransformationProperties.PostProperties.AbsProperties; + +/// +/// Streaming protocol to use (`hls` or `dash`). +/// +[JsonConverter(typeof(ProtocolConverter))] +public enum Protocol +{ + Hls, + Dash, +} + +sealed class ProtocolConverter : JsonConverter +{ + public override Protocol Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "hls" => Protocol.Hls, + "dash" => Protocol.Dash, + _ => (Protocol)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Protocol value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + Protocol.Hls => "hls", + Protocol.Dash => "dash", + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/PostProperties/GifToVideo.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/PostProperties/GifToVideo.cs new file mode 100644 index 00000000..af6e7d25 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/PostProperties/GifToVideo.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties.TransformationProperties.PostProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class GifToVideo : ModelBase, IFromRaw +{ + /// + /// Converts an animated GIF into an MP4. + /// + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Optional transformation string to apply to the output video. **Example**: + /// `q-80` + /// + public string? Value + { + get + { + if (!this.Properties.TryGetValue("value", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["value"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.Value; + } + + public GifToVideo() + { + this.Type = JsonSerializer.Deserialize("\"gif-to-video\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GifToVideo(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static GifToVideo FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/PostProperties/Thumbnail.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/PostProperties/Thumbnail.cs new file mode 100644 index 00000000..f16e468e --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/PostProperties/Thumbnail.cs @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties.TransformationProperties.PostProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Thumbnail : ModelBase, IFromRaw +{ + /// + /// Generates a thumbnail image. + /// + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Optional transformation string. **Example**: `w-150,h-150` + /// + public string? Value + { + get + { + if (!this.Properties.TryGetValue("value", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["value"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.Value; + } + + public Thumbnail() + { + this.Type = JsonSerializer.Deserialize("\"thumbnail\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Thumbnail(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Thumbnail FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/PostProperties/Transformation.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/PostProperties/Transformation.cs new file mode 100644 index 00000000..2b953ea2 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/PostProperties/Transformation.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties.TransformationProperties.PostProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Transformation : ModelBase, IFromRaw +{ + /// + /// Transformation type. + /// + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Transformation string (e.g. `w-200,h-200`). Same syntax as ImageKit URL-based + /// transformations. + /// + public required string Value + { + get + { + if (!this.Properties.TryGetValue("value", out JsonElement element)) + throw new ArgumentOutOfRangeException("value", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("value"); + } + set + { + this.Properties["value"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.Value; + } + + public Transformation() + { + this.Type = JsonSerializer.Deserialize("\"transformation\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Transformation(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Transformation FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public Transformation(string value) + : this() + { + this.Value = value; + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/PostVariants/All.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/PostVariants/All.cs new file mode 100644 index 00000000..dc9900e4 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/PostVariants/All.cs @@ -0,0 +1,61 @@ +using PostProperties = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties.TransformationProperties.PostProperties; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties.TransformationProperties.PostVariants; + +public sealed record class Transformation(PostProperties::Transformation Value) + : Post, + IVariant +{ + public static Transformation From(PostProperties::Transformation value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class GifToVideo(PostProperties::GifToVideo Value) + : Post, + IVariant +{ + public static GifToVideo From(PostProperties::GifToVideo value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class Thumbnail(PostProperties::Thumbnail Value) + : Post, + IVariant +{ + public static Thumbnail From(PostProperties::Thumbnail value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class Abs(PostProperties::Abs Value) : Post, IVariant +{ + public static Abs From(PostProperties::Abs value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1.cs new file mode 100644 index 00000000..25020d6b --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1.cs @@ -0,0 +1,642 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using FileUploadV1Properties = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class FileUploadV1 : ModelBase, IFromRaw +{ + /// + /// The API accepts any of the following: + /// + /// - **Binary data** – send the raw bytes as `multipart/form-data`. - **HTTP + /// / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + /// - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + /// + /// When supplying a URL, the server must receive the response headers within + /// 8 seconds; otherwise the request fails with 400 Bad Request. + /// + public required string File + { + get + { + if (!this.Properties.TryGetValue("file", out JsonElement element)) + throw new ArgumentOutOfRangeException("file", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("file"); + } + set + { + this.Properties["file"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The name with which the file has to be uploaded. The file name can contain: + /// + /// - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. - Special Characters: + /// `.`, `-` + /// + /// Any other character including space will be replaced by `_` + /// + public required string FileName + { + get + { + if (!this.Properties.TryGetValue("fileName", out JsonElement element)) + throw new ArgumentOutOfRangeException("fileName", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("fileName"); + } + set + { + this.Properties["fileName"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// A unique value that the ImageKit.io server will use to recognize and prevent + /// subsequent retries for the same request. We suggest using V4 UUIDs, or another + /// random string with enough entropy to avoid collisions. This field is only + /// required for authentication when uploading a file from the client side. + /// + /// **Note**: Sending a value that has been used in the past will result in a + /// validation error. Even if your previous request resulted in an error, you + /// should always send a new value for this field. + /// + public string? Token + { + get + { + if (!this.Properties.TryGetValue("token", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["token"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Server-side checks to run on the asset. Read more about [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). + /// + public string? Checks + { + get + { + if (!this.Properties.TryGetValue("checks", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["checks"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Define an important area in the image. This is only relevant for image type files. + /// + /// - To be passed as a string with the x and y coordinates of the top-left + /// corner, and width and height of the area of interest in the format `x,y,width,height`. + /// For example - `10,10,100,100` - Can be used with fo-customtransformation. + /// - If this field is not specified and the file is overwritten, then customCoordinates + /// will be removed. + /// + public string? CustomCoordinates + { + get + { + if (!this.Properties.TryGetValue("customCoordinates", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["customCoordinates"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// JSON key-value pairs to associate with the asset. Create the custom metadata + /// fields before setting these values. + /// + public Dictionary? CustomMetadata + { + get + { + if (!this.Properties.TryGetValue("customMetadata", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["customMetadata"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Optional text to describe the contents of the file. + /// + public string? Description + { + get + { + if (!this.Properties.TryGetValue("description", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["description"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The time until your signature is valid. It must be a [Unix time](https://en.wikipedia.org/wiki/Unix_time) + /// in less than 1 hour into the future. It should be in seconds. This field is + /// only required for authentication when uploading a file from the client side. + /// + public long? Expire + { + get + { + if (!this.Properties.TryGetValue("expire", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["expire"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Array of extensions to be applied to the image. Each extension can be configured + /// with specific parameters based on the extension type. + /// + public List? Extensions + { + get + { + if (!this.Properties.TryGetValue("extensions", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["extensions"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The folder path in which the image has to be uploaded. If the folder(s) didn't + /// exist before, a new folder(s) is created. + /// + /// The folder name can contain: + /// + /// - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` - Special Characters: + /// `/` , `_` , `-` + /// + /// Using multiple `/` creates a nested folder. + /// + public string? Folder + { + get + { + if (!this.Properties.TryGetValue("folder", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["folder"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to mark the file as private or not. + /// + /// If `true`, the file is marked as private and is accessible only using named + /// transformation or signed URL. + /// + public bool? IsPrivateFile + { + get + { + if (!this.Properties.TryGetValue("isPrivateFile", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["isPrivateFile"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to upload file as published or not. + /// + /// If `false`, the file is marked as unpublished, which restricts access to the + /// file only via the media library. Files in draft or unpublished state can only + /// be publicly accessed after being published. + /// + /// The option to upload in draft state is only available in custom enterprise + /// pricing plans. + /// + public bool? IsPublished + { + get + { + if (!this.Properties.TryGetValue("isPublished", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["isPublished"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// If set to `true` and a file already exists at the exact location, its AITags + /// will be removed. Set `overwriteAITags` to `false` to preserve AITags. + /// + public bool? OverwriteAITags + { + get + { + if (!this.Properties.TryGetValue("overwriteAITags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["overwriteAITags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// If the request does not have `customMetadata`, and a file already exists at + /// the exact location, existing customMetadata will be removed. + /// + public bool? OverwriteCustomMetadata + { + get + { + if (!this.Properties.TryGetValue("overwriteCustomMetadata", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["overwriteCustomMetadata"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// If `false` and `useUniqueFileName` is also `false`, and a file already exists + /// at the exact location, upload API will return an error immediately. + /// + public bool? OverwriteFile + { + get + { + if (!this.Properties.TryGetValue("overwriteFile", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["overwriteFile"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// If the request does not have `tags`, and a file already exists at the exact + /// location, existing tags will be removed. + /// + public bool? OverwriteTags + { + get + { + if (!this.Properties.TryGetValue("overwriteTags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["overwriteTags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Your ImageKit.io public key. This field is only required for authentication + /// when uploading a file from the client side. + /// + public string? PublicKey + { + get + { + if (!this.Properties.TryGetValue("publicKey", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["publicKey"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Array of response field keys to include in the API response body. + /// + public List>? ResponseFields + { + get + { + if (!this.Properties.TryGetValue("responseFields", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize + >?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["responseFields"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key + /// as a key. Learn how to create a signature on the page below. This should be + /// in lowercase. + /// + /// Signature must be calculated on the server-side. This field is only required + /// for authentication when uploading a file from the client side. + /// + public string? Signature + { + get + { + if (!this.Properties.TryGetValue("signature", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["signature"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Set the tags while uploading the file. Provide an array of tag strings (e.g. + /// `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must + /// not exceed 500, and the `%` character is not allowed. If this field is not + /// specified and the file is overwritten, the existing tags will be removed. + /// + public List? Tags + { + get + { + if (!this.Properties.TryGetValue("tags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["tags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Configure pre-processing (`pre`) and post-processing (`post`) transformations. + /// + /// - `pre` — applied before the file is uploaded to the Media Library. Useful + /// for reducing file size or applying basic optimizations upfront (e.g., resize, compress). + /// + /// - `post` — applied immediately after upload. Ideal for generating transformed + /// versions (like video encodes or thumbnails) in advance, so they're ready for + /// delivery without delay. + /// + /// You can mix and match any combination of post-processing types. + /// + public FileUploadV1Properties::Transformation? Transformation + { + get + { + if (!this.Properties.TryGetValue("transformation", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["transformation"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to use a unique filename for this file or not. + /// + /// If `true`, ImageKit.io will add a unique suffix to the filename parameter + /// to get a unique filename. + /// + /// If `false`, then the image is uploaded with the provided filename parameter, + /// and any existing file with the same name is replaced. + /// + public bool? UseUniqueFileName + { + get + { + if (!this.Properties.TryGetValue("useUniqueFileName", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["useUniqueFileName"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The final status of extensions after they have completed execution will be + /// delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + /// about the webhook payload structure. + /// + public string? WebhookURL + { + get + { + if (!this.Properties.TryGetValue("webhookUrl", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["webhookUrl"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.File; + _ = this.FileName; + _ = this.Token; + _ = this.Checks; + _ = this.CustomCoordinates; + if (this.CustomMetadata != null) + { + foreach (var item in this.CustomMetadata.Values) + { + _ = item; + } + } + _ = this.Description; + _ = this.Expire; + foreach (var item in this.Extensions ?? []) + { + item.Validate(); + } + _ = this.Folder; + _ = this.IsPrivateFile; + _ = this.IsPublished; + _ = this.OverwriteAITags; + _ = this.OverwriteCustomMetadata; + _ = this.OverwriteFile; + _ = this.OverwriteTags; + _ = this.PublicKey; + foreach (var item in this.ResponseFields ?? []) + { + item.Validate(); + } + _ = this.Signature; + foreach (var item in this.Tags ?? []) + { + _ = item; + } + this.Transformation?.Validate(); + _ = this.UseUniqueFileName; + _ = this.WebhookURL; + } + + public FileUploadV1() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FileUploadV1(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static FileUploadV1 FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/Extension.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/Extension.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/Extension.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/Extension.cs diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/AutoTaggingExtension.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ExtensionProperties/AutoTaggingExtension.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/AutoTaggingExtension.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ExtensionProperties/AutoTaggingExtension.cs diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/RemoveBg.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ExtensionProperties/RemoveBg.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/RemoveBg.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ExtensionProperties/RemoveBg.cs diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/RemoveBgProperties/Options.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ExtensionProperties/RemoveBgProperties/Options.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/RemoveBgProperties/Options.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ExtensionProperties/RemoveBgProperties/Options.cs diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionVariants/All.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ExtensionVariants/All.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionVariants/All.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ExtensionVariants/All.cs diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/ResponseField.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ResponseField.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/ResponseField.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ResponseField.cs diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/Transformation.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/Transformation.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/Transformation.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/Transformation.cs diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/Post.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/Post.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/Post.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/Post.cs diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Abs.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostProperties/Abs.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Abs.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostProperties/Abs.cs diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideo.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostProperties/GifToVideo.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideo.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostProperties/GifToVideo.cs diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Thumbnail.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostProperties/Thumbnail.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Thumbnail.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostProperties/Thumbnail.cs diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Transformation.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostProperties/Transformation.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Transformation.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostProperties/Transformation.cs diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostVariants/All.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostVariants/All.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostVariants/All.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostVariants/All.cs diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyVariants/All.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyVariants/All.cs new file mode 100644 index 00000000..0ad364cf --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyVariants/All.cs @@ -0,0 +1,33 @@ +using BodyProperties = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyVariants; + +public sealed record class FileUploadV1(BodyProperties::FileUploadV1 Value) + : Body, + IVariant +{ + public static FileUploadV1 From(BodyProperties::FileUploadV1 value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class FileUploadByUrlv1(BodyProperties::FileUploadByUrlv1 Value) + : Body, + IVariant +{ + public static FileUploadByUrlv1 From(BodyProperties::FileUploadByUrlv1 value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} From 9b5645c145ace5a171f5de3ff8087dc216e4a8ac Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 3 Sep 2025 11:44:57 +0000 Subject: [PATCH 013/129] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index db7d8f1e..f8166f44 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-9ae7b43dcfd6208ca37c32c887630ae186ec338bcdd36902b6fe5d1cc66459dc.yml -openapi_spec_hash: 25fb64c067e64bcff6eaaabda26de397 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-5ce78cb448cc4520f5fbcc753452e0237b50a4bf64902e0548a8ad24bbdc82cf.yml +openapi_spec_hash: fd8ac4c2cdddc3d3a0b0c81be6a9edfe config_hash: 70f9408b8d1dfbcf262a20d6eed50e1c From 9a9015da3bf6746e1a29374124b2e7079a6d4715 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 28 Jan 2026 17:38:03 +0000 Subject: [PATCH 014/129] feat(api): manual updates --- .stats.yml | 4 +- README.md | 9 +- .../Services/Files/FileServiceTest.cs | 4 +- src/Imagekit/ModelBase.cs | 22 +- src/Imagekit/Models/Files/FileUploadParams.cs | 567 +++++++++++++++- .../Files/FileUploadParamsProperties/Body.cs | 117 ---- .../BodyProperties/FileUploadByUrlv1.cs | 637 ----------------- .../FileUploadByUrlv1Properties/Extension.cs | 177 ----- .../AutoTaggingExtension.cs | 100 --- .../AutoTaggingExtensionProperties/Name.cs | 46 -- .../ExtensionProperties/RemoveBg.cs | 74 -- .../RemoveBgProperties/Options.cs | 122 ---- .../ExtensionVariants/All.cs | 46 -- .../ResponseField.cs | 62 -- .../Transformation.cs | 92 --- .../TransformationProperties/Post.cs | 225 ------ .../PostProperties/Abs.cs | 103 --- .../PostProperties/AbsProperties/Protocol.cs | 46 -- .../PostProperties/GifToVideo.cs | 77 --- .../PostProperties/Thumbnail.cs | 76 --- .../PostProperties/Transformation.cs | 85 --- .../PostVariants/All.cs | 61 -- .../BodyProperties/FileUploadV1.cs | 642 ------------------ .../BodyVariants/All.cs | 33 - .../FileUploadV1Properties => }/Extension.cs | 0 .../AutoTaggingExtension.cs | 0 .../AutoTaggingExtensionProperties/Name.cs | 0 .../ExtensionProperties/RemoveBg.cs | 0 .../RemoveBgProperties/Options.cs | 0 .../ExtensionVariants/All.cs | 0 .../ResponseField.cs | 0 .../Transformation.cs | 0 .../TransformationProperties/Post.cs | 0 .../PostProperties/Abs.cs | 0 .../PostProperties/AbsProperties/Protocol.cs | 0 .../PostProperties/GifToVideo.cs | 0 .../PostProperties/Thumbnail.cs | 0 .../PostProperties/Transformation.cs | 0 .../PostVariants/All.cs | 0 39 files changed, 582 insertions(+), 2845 deletions(-) delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/Body.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/Extension.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/ExtensionProperties/AutoTaggingExtension.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/ExtensionProperties/RemoveBg.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/ExtensionProperties/RemoveBgProperties/Options.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/ExtensionVariants/All.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/ResponseField.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/Transformation.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/Post.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/PostProperties/Abs.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/PostProperties/GifToVideo.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/PostProperties/Thumbnail.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/PostProperties/Transformation.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/PostVariants/All.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/BodyVariants/All.cs rename src/Imagekit/Models/Files/FileUploadParamsProperties/{BodyProperties/FileUploadV1Properties => }/Extension.cs (100%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{BodyProperties/FileUploadV1Properties => }/ExtensionProperties/AutoTaggingExtension.cs (100%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{BodyProperties/FileUploadV1Properties => }/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs (100%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{BodyProperties/FileUploadV1Properties => }/ExtensionProperties/RemoveBg.cs (100%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{BodyProperties/FileUploadV1Properties => }/ExtensionProperties/RemoveBgProperties/Options.cs (100%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{BodyProperties/FileUploadV1Properties => }/ExtensionVariants/All.cs (100%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{BodyProperties/FileUploadV1Properties => }/ResponseField.cs (100%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{BodyProperties/FileUploadV1Properties => }/Transformation.cs (100%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{BodyProperties/FileUploadV1Properties => }/TransformationProperties/Post.cs (100%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{BodyProperties/FileUploadV1Properties => }/TransformationProperties/PostProperties/Abs.cs (100%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{BodyProperties/FileUploadV1Properties => }/TransformationProperties/PostProperties/AbsProperties/Protocol.cs (100%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{BodyProperties/FileUploadV1Properties => }/TransformationProperties/PostProperties/GifToVideo.cs (100%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{BodyProperties/FileUploadV1Properties => }/TransformationProperties/PostProperties/Thumbnail.cs (100%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{BodyProperties/FileUploadV1Properties => }/TransformationProperties/PostProperties/Transformation.cs (100%) rename src/Imagekit/Models/Files/FileUploadParamsProperties/{BodyProperties/FileUploadV1Properties => }/TransformationProperties/PostVariants/All.cs (100%) diff --git a/.stats.yml b/.stats.yml index f8166f44..cfcbd7f7 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-5ce78cb448cc4520f5fbcc753452e0237b50a4bf64902e0548a8ad24bbdc82cf.yml -openapi_spec_hash: fd8ac4c2cdddc3d3a0b0c81be6a9edfe +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-667f7f4988b44bc587d6eb9960ff5c8326e9f7e9b072f3f724f9f54166eff8b1.yml +openapi_spec_hash: f2081864a4abee0480e5ff991b4c936a config_hash: 70f9408b8d1dfbcf262a20d6eed50e1c diff --git a/README.md b/README.md index 983e086a..22709ca0 100644 --- a/README.md +++ b/README.md @@ -34,11 +34,18 @@ See the [`examples`](examples) directory for complete and runnable examples. ```csharp using System; using Imagekit; +using Imagekit.Models.Files; // Configured using the IMAGEKIT_PRIVATE_API_KEY, OPTIONAL_IMAGEKIT_IGNORES_THIS, IMAGEKIT_WEBHOOK_SECRET and IMAGE_KIT_BASE_URL environment variables ImageKitClient client = new(); -var response = await client.Files.Upload(); +FileUploadParams parameters = new() +{ + File = "a value", + FileName = "file-name.jpg", +}; + +var response = await client.Files.Upload(parameters); Console.WriteLine(response); ``` diff --git a/src/Imagekit.Tests/Services/Files/FileServiceTest.cs b/src/Imagekit.Tests/Services/Files/FileServiceTest.cs index 2d71ee4f..0ccbc624 100644 --- a/src/Imagekit.Tests/Services/Files/FileServiceTest.cs +++ b/src/Imagekit.Tests/Services/Files/FileServiceTest.cs @@ -62,7 +62,9 @@ public async Task Rename_Works() [Fact(Skip = "Prism tests are disabled")] public async Task Upload_Works() { - var response = await this.client.Files.Upload(); + var response = await this.client.Files.Upload( + new() { File = "a value", FileName = "fileName" } + ); response.Validate(); } } diff --git a/src/Imagekit/ModelBase.cs b/src/Imagekit/ModelBase.cs index 134e0b02..e9e70c6b 100644 --- a/src/Imagekit/ModelBase.cs +++ b/src/Imagekit/ModelBase.cs @@ -5,21 +5,19 @@ using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties; using Imagekit.Models.Files.FileUpdateParamsProperties.UpdateProperties.UpdateFileDetailsProperties.ExtensionProperties.AutoTaggingExtensionProperties; using Imagekit.Models.Files.FileUpdateResponseProperties.IntersectionMember1Properties.ExtensionStatusProperties; -using Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.TransformationProperties.PostProperties.AbsProperties; +using Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.AbsProperties; using Imagekit.Models.ImageOverlayProperties.IntersectionMember1Properties; using Imagekit.Models.OverlayPositionProperties; using Imagekit.Models.SubtitleOverlayTransformationProperties; using Imagekit.Models.TextOverlayTransformationProperties; using Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.IntersectionMember1Properties.DataProperties.TransformationProperties.OptionsProperties; using Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.IntersectionMember1Properties.DataProperties.TransformationProperties.ErrorProperties; -using AbsProperties = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties.TransformationProperties.PostProperties.AbsProperties; +using AbsProperties = Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.AbsProperties; using AssetListParamsProperties = Imagekit.Models.Assets.AssetListParamsProperties; -using AutoTaggingExtensionProperties = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties.ExtensionProperties.AutoTaggingExtensionProperties; +using AutoTaggingExtensionProperties = Imagekit.Models.Files.FileUploadParamsProperties.ExtensionProperties.AutoTaggingExtensionProperties; using ExtensionStatusProperties = Imagekit.Models.Files.FileUploadResponseProperties.ExtensionStatusProperties; using FileProperties = Imagekit.Models.Files.FileProperties; -using FileUploadByUrlv1Properties = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties; -using FileUploadParamsProperties = Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties; -using FileUploadV1Properties = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties; +using FileUploadParamsProperties = Imagekit.Models.Files.FileUploadParamsProperties; using FolderProperties = Imagekit.Models.Files.FolderProperties; using IntersectionMember1Properties = Imagekit.Models.SubtitleOverlayProperties.IntersectionMember1Properties; using JobGetResponseProperties = Imagekit.Models.Folders.Job.JobGetResponseProperties; @@ -80,14 +78,8 @@ public abstract record class ModelBase new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), - new ApiEnumConverter(), + new ApiEnumConverter(), new ApiEnumConverter(), - new ApiEnumConverter< - string, - global::Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties.ExtensionProperties.AutoTaggingExtensionProperties.Name - >(), - new ApiEnumConverter(), - new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), @@ -114,11 +106,11 @@ public abstract record class ModelBase string, global::Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.ExtensionProperties.AutoTaggingExtensionProperties.Name >(), - new ApiEnumConverter(), new ApiEnumConverter< string, - global::Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.AbsProperties.Protocol + global::Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.ResponseField >(), + new ApiEnumConverter(), new ApiEnumConverter< string, global::Imagekit.Models.Webhooks.UploadPostTransformErrorEventProperties.IntersectionMember1Properties.RequestProperties.TransformationProperties.Type diff --git a/src/Imagekit/Models/Files/FileUploadParams.cs b/src/Imagekit/Models/Files/FileUploadParams.cs index 72ca6fee..5dd1291e 100644 --- a/src/Imagekit/Models/Files/FileUploadParams.cs +++ b/src/Imagekit/Models/Files/FileUploadParams.cs @@ -3,7 +3,7 @@ using System.Net.Http; using System.Text; using System.Text.Json; -using Imagekit.Models.Files.FileUploadParamsProperties; +using FileUploadParamsProperties = Imagekit.Models.Files.FileUploadParamsProperties; namespace Imagekit.Models.Files; @@ -35,18 +35,575 @@ public sealed record class FileUploadParams : ParamsBase { public Dictionary BodyProperties { get; set; } = []; - public Body? Body + /// + /// The API accepts any of the following: + /// + /// - **Binary data** – send the raw bytes as `multipart/form-data`. - **HTTP + /// / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + /// - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + /// + /// When supplying a URL, the server must receive the response headers within + /// 8 seconds; otherwise the request fails with 400 Bad Request. + /// + public required string File { get { - if (!this.BodyProperties.TryGetValue("body", out JsonElement element)) + if (!this.BodyProperties.TryGetValue("file", out JsonElement element)) + throw new ArgumentOutOfRangeException("file", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("file"); + } + set + { + this.BodyProperties["file"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The name with which the file has to be uploaded. The file name can contain: + /// + /// - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. - Special Characters: + /// `.`, `-` + /// + /// Any other character including space will be replaced by `_` + /// + public required string FileName + { + get + { + if (!this.BodyProperties.TryGetValue("fileName", out JsonElement element)) + throw new ArgumentOutOfRangeException("fileName", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("fileName"); + } + set + { + this.BodyProperties["fileName"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// A unique value that the ImageKit.io server will use to recognize and prevent + /// subsequent retries for the same request. We suggest using V4 UUIDs, or another + /// random string with enough entropy to avoid collisions. This field is only + /// required for authentication when uploading a file from the client side. + /// + /// **Note**: Sending a value that has been used in the past will result in a + /// validation error. Even if your previous request resulted in an error, you + /// should always send a new value for this field. + /// + public string? Token + { + get + { + if (!this.BodyProperties.TryGetValue("token", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["token"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Server-side checks to run on the asset. Read more about [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). + /// + public string? Checks + { + get + { + if (!this.BodyProperties.TryGetValue("checks", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["checks"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Define an important area in the image. This is only relevant for image type files. + /// + /// - To be passed as a string with the x and y coordinates of the top-left + /// corner, and width and height of the area of interest in the format `x,y,width,height`. + /// For example - `10,10,100,100` - Can be used with fo-customtransformation. + /// - If this field is not specified and the file is overwritten, then customCoordinates + /// will be removed. + /// + public string? CustomCoordinates + { + get + { + if (!this.BodyProperties.TryGetValue("customCoordinates", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["customCoordinates"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// JSON key-value pairs to associate with the asset. Create the custom metadata + /// fields before setting these values. + /// + public Dictionary? CustomMetadata + { + get + { + if (!this.BodyProperties.TryGetValue("customMetadata", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.BodyProperties["customMetadata"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Optional text to describe the contents of the file. + /// + public string? Description + { + get + { + if (!this.BodyProperties.TryGetValue("description", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["description"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The time until your signature is valid. It must be a [Unix time](https://en.wikipedia.org/wiki/Unix_time) + /// in less than 1 hour into the future. It should be in seconds. This field is + /// only required for authentication when uploading a file from the client side. + /// + public long? Expire + { + get + { + if (!this.BodyProperties.TryGetValue("expire", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["expire"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Array of extensions to be applied to the image. Each extension can be configured + /// with specific parameters based on the extension type. + /// + public List? Extensions + { + get + { + if (!this.BodyProperties.TryGetValue("extensions", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.BodyProperties["extensions"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The folder path in which the image has to be uploaded. If the folder(s) didn't + /// exist before, a new folder(s) is created. + /// + /// The folder name can contain: + /// + /// - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` - Special Characters: + /// `/` , `_` , `-` + /// + /// Using multiple `/` creates a nested folder. + /// + public string? Folder + { + get + { + if (!this.BodyProperties.TryGetValue("folder", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["folder"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to mark the file as private or not. + /// + /// If `true`, the file is marked as private and is accessible only using named + /// transformation or signed URL. + /// + public bool? IsPrivateFile + { + get + { + if (!this.BodyProperties.TryGetValue("isPrivateFile", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["isPrivateFile"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to upload file as published or not. + /// + /// If `false`, the file is marked as unpublished, which restricts access to the + /// file only via the media library. Files in draft or unpublished state can only + /// be publicly accessed after being published. + /// + /// The option to upload in draft state is only available in custom enterprise + /// pricing plans. + /// + public bool? IsPublished + { + get + { + if (!this.BodyProperties.TryGetValue("isPublished", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["isPublished"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// If set to `true` and a file already exists at the exact location, its AITags + /// will be removed. Set `overwriteAITags` to `false` to preserve AITags. + /// + public bool? OverwriteAITags + { + get + { + if (!this.BodyProperties.TryGetValue("overwriteAITags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["overwriteAITags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// If the request does not have `customMetadata`, and a file already exists at + /// the exact location, existing customMetadata will be removed. + /// + public bool? OverwriteCustomMetadata + { + get + { + if ( + !this.BodyProperties.TryGetValue("overwriteCustomMetadata", out JsonElement element) + ) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["overwriteCustomMetadata"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// If `false` and `useUniqueFileName` is also `false`, and a file already exists + /// at the exact location, upload API will return an error immediately. + /// + public bool? OverwriteFile + { + get + { + if (!this.BodyProperties.TryGetValue("overwriteFile", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["overwriteFile"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// If the request does not have `tags`, and a file already exists at the exact + /// location, existing tags will be removed. + /// + public bool? OverwriteTags + { + get + { + if (!this.BodyProperties.TryGetValue("overwriteTags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["overwriteTags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Your ImageKit.io public key. This field is only required for authentication + /// when uploading a file from the client side. + /// + public string? PublicKey + { + get + { + if (!this.BodyProperties.TryGetValue("publicKey", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["publicKey"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Array of response field keys to include in the API response body. + /// + public List>? ResponseFields + { + get + { + if (!this.BodyProperties.TryGetValue("responseFields", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize + >?>(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["responseFields"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key + /// as a key. Learn how to create a signature on the page below. This should be + /// in lowercase. + /// + /// Signature must be calculated on the server-side. This field is only required + /// for authentication when uploading a file from the client side. + /// + public string? Signature + { + get + { + if (!this.BodyProperties.TryGetValue("signature", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["signature"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Set the tags while uploading the file. Provide an array of tag strings (e.g. + /// `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must + /// not exceed 500, and the `%` character is not allowed. If this field is not + /// specified and the file is overwritten, the existing tags will be removed. + /// + public List? Tags + { + get + { + if (!this.BodyProperties.TryGetValue("tags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["tags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Configure pre-processing (`pre`) and post-processing (`post`) transformations. + /// + /// - `pre` — applied before the file is uploaded to the Media Library. Useful + /// for reducing file size or applying basic optimizations upfront (e.g., resize, compress). + /// + /// - `post` — applied immediately after upload. Ideal for generating transformed + /// versions (like video encodes or thumbnails) in advance, so they're ready for + /// delivery without delay. + /// + /// You can mix and match any combination of post-processing types. + /// + public FileUploadParamsProperties::Transformation? Transformation + { + get + { + if (!this.BodyProperties.TryGetValue("transformation", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.BodyProperties["transformation"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to use a unique filename for this file or not. + /// + /// If `true`, ImageKit.io will add a unique suffix to the filename parameter + /// to get a unique filename. + /// + /// If `false`, then the image is uploaded with the provided filename parameter, + /// and any existing file with the same name is replaced. + /// + public bool? UseUniqueFileName + { + get + { + if (!this.BodyProperties.TryGetValue("useUniqueFileName", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["useUniqueFileName"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The final status of extensions after they have completed execution will be + /// delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + /// about the webhook payload structure. + /// + public string? WebhookURL + { + get + { + if (!this.BodyProperties.TryGetValue("webhookUrl", out JsonElement element)) return null; - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); } set { - this.BodyProperties["body"] = JsonSerializer.SerializeToElement( + this.BodyProperties["webhookUrl"] = JsonSerializer.SerializeToElement( value, ModelBase.SerializerOptions ); diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/Body.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/Body.cs deleted file mode 100644 index aabad9fe..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/Body.cs +++ /dev/null @@ -1,117 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties; -using BodyVariants = Imagekit.Models.Files.FileUploadParamsProperties.BodyVariants; - -namespace Imagekit.Models.Files.FileUploadParamsProperties; - -[JsonConverter(typeof(BodyConverter))] -public abstract record class Body -{ - internal Body() { } - - public static implicit operator Body(FileUploadV1 value) => - new BodyVariants::FileUploadV1(value); - - public static implicit operator Body(FileUploadByUrlv1 value) => - new BodyVariants::FileUploadByUrlv1(value); - - public bool TryPickFileUploadV1([NotNullWhen(true)] out FileUploadV1? value) - { - value = (this as BodyVariants::FileUploadV1)?.Value; - return value != null; - } - - public bool TryPickFileUploadByUrlv1([NotNullWhen(true)] out FileUploadByUrlv1? value) - { - value = (this as BodyVariants::FileUploadByUrlv1)?.Value; - return value != null; - } - - public void Switch( - Action fileUploadV1, - Action fileUploadByUrlv1 - ) - { - switch (this) - { - case BodyVariants::FileUploadV1 inner: - fileUploadV1(inner); - break; - case BodyVariants::FileUploadByUrlv1 inner: - fileUploadByUrlv1(inner); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match( - Func fileUploadV1, - Func fileUploadByUrlv1 - ) - { - return this switch - { - BodyVariants::FileUploadV1 inner => fileUploadV1(inner), - BodyVariants::FileUploadByUrlv1 inner => fileUploadByUrlv1(inner), - _ => throw new InvalidOperationException(), - }; - } - - public abstract void Validate(); -} - -sealed class BodyConverter : JsonConverter -{ - public override Body? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new BodyVariants::FileUploadV1(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new BodyVariants::FileUploadByUrlv1(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - - public override void Write(Utf8JsonWriter writer, Body value, JsonSerializerOptions options) - { - object variant = value switch - { - BodyVariants::FileUploadV1(var fileUploadV1) => fileUploadV1, - BodyVariants::FileUploadByUrlv1(var fileUploadByUrlv1) => fileUploadByUrlv1, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1.cs deleted file mode 100644 index 82bb36fb..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1.cs +++ /dev/null @@ -1,637 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using FileUploadByUrlv1Properties = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class FileUploadByUrlv1 : ModelBase, IFromRaw -{ - /// - /// The URL of the file to upload. A publicly reachable URL that ImageKit servers - /// can fetch. The server must receive the response headers within 8 seconds; - /// otherwise the request fails with 400 Bad Request. - /// - public required string File - { - get - { - if (!this.Properties.TryGetValue("file", out JsonElement element)) - throw new ArgumentOutOfRangeException("file", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("file"); - } - set - { - this.Properties["file"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The name with which the file has to be uploaded. The file name can contain: - /// - /// - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. - Special Characters: - /// `.`, `-` - /// - /// Any other character including space will be replaced by `_` - /// - public required string FileName - { - get - { - if (!this.Properties.TryGetValue("fileName", out JsonElement element)) - throw new ArgumentOutOfRangeException("fileName", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("fileName"); - } - set - { - this.Properties["fileName"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// A unique value that the ImageKit.io server will use to recognize and prevent - /// subsequent retries for the same request. We suggest using V4 UUIDs, or another - /// random string with enough entropy to avoid collisions. This field is only - /// required for authentication when uploading a file from the client side. - /// - /// **Note**: Sending a value that has been used in the past will result in a - /// validation error. Even if your previous request resulted in an error, you - /// should always send a new value for this field. - /// - public string? Token - { - get - { - if (!this.Properties.TryGetValue("token", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["token"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Server-side checks to run on the asset. Read more about [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). - /// - public string? Checks - { - get - { - if (!this.Properties.TryGetValue("checks", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["checks"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Define an important area in the image. This is only relevant for image type files. - /// - /// - To be passed as a string with the x and y coordinates of the top-left - /// corner, and width and height of the area of interest in the format `x,y,width,height`. - /// For example - `10,10,100,100` - Can be used with fo-customtransformation. - /// - If this field is not specified and the file is overwritten, then customCoordinates - /// will be removed. - /// - public string? CustomCoordinates - { - get - { - if (!this.Properties.TryGetValue("customCoordinates", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["customCoordinates"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// JSON key-value pairs to associate with the asset. Create the custom metadata - /// fields before setting these values. - /// - public Dictionary? CustomMetadata - { - get - { - if (!this.Properties.TryGetValue("customMetadata", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["customMetadata"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Optional text to describe the contents of the file. - /// - public string? Description - { - get - { - if (!this.Properties.TryGetValue("description", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["description"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The time until your signature is valid. It must be a [Unix time](https://en.wikipedia.org/wiki/Unix_time) - /// in less than 1 hour into the future. It should be in seconds. This field is - /// only required for authentication when uploading a file from the client side. - /// - public long? Expire - { - get - { - if (!this.Properties.TryGetValue("expire", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["expire"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Array of extensions to be applied to the image. Each extension can be configured - /// with specific parameters based on the extension type. - /// - public List? Extensions - { - get - { - if (!this.Properties.TryGetValue("extensions", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["extensions"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The folder path in which the image has to be uploaded. If the folder(s) didn't - /// exist before, a new folder(s) is created. - /// - /// The folder name can contain: - /// - /// - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` - Special Characters: - /// `/` , `_` , `-` - /// - /// Using multiple `/` creates a nested folder. - /// - public string? Folder - { - get - { - if (!this.Properties.TryGetValue("folder", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["folder"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to mark the file as private or not. - /// - /// If `true`, the file is marked as private and is accessible only using named - /// transformation or signed URL. - /// - public bool? IsPrivateFile - { - get - { - if (!this.Properties.TryGetValue("isPrivateFile", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["isPrivateFile"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to upload file as published or not. - /// - /// If `false`, the file is marked as unpublished, which restricts access to the - /// file only via the media library. Files in draft or unpublished state can only - /// be publicly accessed after being published. - /// - /// The option to upload in draft state is only available in custom enterprise - /// pricing plans. - /// - public bool? IsPublished - { - get - { - if (!this.Properties.TryGetValue("isPublished", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["isPublished"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// If set to `true` and a file already exists at the exact location, its AITags - /// will be removed. Set `overwriteAITags` to `false` to preserve AITags. - /// - public bool? OverwriteAITags - { - get - { - if (!this.Properties.TryGetValue("overwriteAITags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["overwriteAITags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// If the request does not have `customMetadata`, and a file already exists at - /// the exact location, existing customMetadata will be removed. - /// - public bool? OverwriteCustomMetadata - { - get - { - if (!this.Properties.TryGetValue("overwriteCustomMetadata", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["overwriteCustomMetadata"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// If `false` and `useUniqueFileName` is also `false`, and a file already exists - /// at the exact location, upload API will return an error immediately. - /// - public bool? OverwriteFile - { - get - { - if (!this.Properties.TryGetValue("overwriteFile", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["overwriteFile"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// If the request does not have `tags`, and a file already exists at the exact - /// location, existing tags will be removed. - /// - public bool? OverwriteTags - { - get - { - if (!this.Properties.TryGetValue("overwriteTags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["overwriteTags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Your ImageKit.io public key. This field is only required for authentication - /// when uploading a file from the client side. - /// - public string? PublicKey - { - get - { - if (!this.Properties.TryGetValue("publicKey", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["publicKey"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Array of response field keys to include in the API response body. - /// - public List>? ResponseFields - { - get - { - if (!this.Properties.TryGetValue("responseFields", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize - >?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["responseFields"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key - /// as a key. Learn how to create a signature on the page below. This should be - /// in lowercase. - /// - /// Signature must be calculated on the server-side. This field is only required - /// for authentication when uploading a file from the client side. - /// - public string? Signature - { - get - { - if (!this.Properties.TryGetValue("signature", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["signature"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Set the tags while uploading the file. Provide an array of tag strings (e.g. - /// `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must - /// not exceed 500, and the `%` character is not allowed. If this field is not - /// specified and the file is overwritten, the existing tags will be removed. - /// - public List? Tags - { - get - { - if (!this.Properties.TryGetValue("tags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["tags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Configure pre-processing (`pre`) and post-processing (`post`) transformations. - /// - /// - `pre` — applied before the file is uploaded to the Media Library. Useful - /// for reducing file size or applying basic optimizations upfront (e.g., resize, compress). - /// - /// - `post` — applied immediately after upload. Ideal for generating transformed - /// versions (like video encodes or thumbnails) in advance, so they're ready for - /// delivery without delay. - /// - /// You can mix and match any combination of post-processing types. - /// - public FileUploadByUrlv1Properties::Transformation? Transformation - { - get - { - if (!this.Properties.TryGetValue("transformation", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["transformation"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to use a unique filename for this file or not. - /// - /// If `true`, ImageKit.io will add a unique suffix to the filename parameter - /// to get a unique filename. - /// - /// If `false`, then the image is uploaded with the provided filename parameter, - /// and any existing file with the same name is replaced. - /// - public bool? UseUniqueFileName - { - get - { - if (!this.Properties.TryGetValue("useUniqueFileName", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["useUniqueFileName"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The final status of extensions after they have completed execution will be - /// delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) - /// about the webhook payload structure. - /// - public string? WebhookURL - { - get - { - if (!this.Properties.TryGetValue("webhookUrl", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["webhookUrl"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.File; - _ = this.FileName; - _ = this.Token; - _ = this.Checks; - _ = this.CustomCoordinates; - if (this.CustomMetadata != null) - { - foreach (var item in this.CustomMetadata.Values) - { - _ = item; - } - } - _ = this.Description; - _ = this.Expire; - foreach (var item in this.Extensions ?? []) - { - item.Validate(); - } - _ = this.Folder; - _ = this.IsPrivateFile; - _ = this.IsPublished; - _ = this.OverwriteAITags; - _ = this.OverwriteCustomMetadata; - _ = this.OverwriteFile; - _ = this.OverwriteTags; - _ = this.PublicKey; - foreach (var item in this.ResponseFields ?? []) - { - item.Validate(); - } - _ = this.Signature; - foreach (var item in this.Tags ?? []) - { - _ = item; - } - this.Transformation?.Validate(); - _ = this.UseUniqueFileName; - _ = this.WebhookURL; - } - - public FileUploadByUrlv1() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - FileUploadByUrlv1(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static FileUploadByUrlv1 FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/Extension.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/Extension.cs deleted file mode 100644 index 8c22bcf0..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/Extension.cs +++ /dev/null @@ -1,177 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties.ExtensionProperties; -using ExtensionVariants = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties.ExtensionVariants; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties; - -[JsonConverter(typeof(ExtensionConverter))] -public abstract record class Extension -{ - internal Extension() { } - - public static implicit operator Extension(RemoveBg value) => - new ExtensionVariants::RemoveBg(value); - - public static implicit operator Extension(AutoTaggingExtension value) => - new ExtensionVariants::AutoTaggingExtension(value); - - public bool TryPickRemoveBg([NotNullWhen(true)] out RemoveBg? value) - { - value = (this as ExtensionVariants::RemoveBg)?.Value; - return value != null; - } - - public bool TryPickAutoTagging([NotNullWhen(true)] out AutoTaggingExtension? value) - { - value = (this as ExtensionVariants::AutoTaggingExtension)?.Value; - return value != null; - } - - public bool TryPickAIAutoDescription([NotNullWhen(true)] out JsonElement? value) - { - value = (this as ExtensionVariants::AIAutoDescription)?.Value; - return value != null; - } - - public void Switch( - Action removeBg, - Action autoTagging, - Action aiAutoDescription - ) - { - switch (this) - { - case ExtensionVariants::RemoveBg inner: - removeBg(inner); - break; - case ExtensionVariants::AutoTaggingExtension inner: - autoTagging(inner); - break; - case ExtensionVariants::AIAutoDescription inner: - aiAutoDescription(inner); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match( - Func removeBg, - Func autoTagging, - Func aiAutoDescription - ) - { - return this switch - { - ExtensionVariants::RemoveBg inner => removeBg(inner), - ExtensionVariants::AutoTaggingExtension inner => autoTagging(inner), - ExtensionVariants::AIAutoDescription inner => aiAutoDescription(inner), - _ => throw new InvalidOperationException(), - }; - } - - public abstract void Validate(); -} - -sealed class ExtensionConverter : JsonConverter -{ - public override Extension? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - var json = JsonSerializer.Deserialize(ref reader, options); - string? name; - try - { - name = json.GetProperty("name").GetString(); - } - catch - { - name = null; - } - - switch (name) - { - case "remove-bg": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - return new ExtensionVariants::RemoveBg(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "ai-auto-description": - { - List exceptions = []; - - try - { - return new ExtensionVariants::AIAutoDescription( - JsonSerializer.Deserialize(json, options) - ); - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - default: - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize( - json, - options - ); - if (deserialized != null) - { - return new ExtensionVariants::AutoTaggingExtension(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - } - } - - public override void Write( - Utf8JsonWriter writer, - Extension value, - JsonSerializerOptions options - ) - { - object variant = value switch - { - ExtensionVariants::RemoveBg(var removeBg) => removeBg, - ExtensionVariants::AutoTaggingExtension(var autoTagging) => autoTagging, - ExtensionVariants::AIAutoDescription(var aiAutoDescription) => aiAutoDescription, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/ExtensionProperties/AutoTaggingExtension.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/ExtensionProperties/AutoTaggingExtension.cs deleted file mode 100644 index 0a09cc4f..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/ExtensionProperties/AutoTaggingExtension.cs +++ /dev/null @@ -1,100 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties.ExtensionProperties.AutoTaggingExtensionProperties; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties.ExtensionProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class AutoTaggingExtension : ModelBase, IFromRaw -{ - /// - /// Maximum number of tags to attach to the asset. - /// - public required long MaxTags - { - get - { - if (!this.Properties.TryGetValue("maxTags", out JsonElement element)) - throw new ArgumentOutOfRangeException("maxTags", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["maxTags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Minimum confidence level for tags to be considered valid. - /// - public required long MinConfidence - { - get - { - if (!this.Properties.TryGetValue("minConfidence", out JsonElement element)) - throw new ArgumentOutOfRangeException("minConfidence", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["minConfidence"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies the auto-tagging extension used. - /// - public required ApiEnum Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - throw new ArgumentOutOfRangeException("name", "Missing required argument"); - - return JsonSerializer.Deserialize>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.MaxTags; - _ = this.MinConfidence; - this.Name.Validate(); - } - - public AutoTaggingExtension() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - AutoTaggingExtension(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static AutoTaggingExtension FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs deleted file mode 100644 index b021f711..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties.ExtensionProperties.AutoTaggingExtensionProperties; - -/// -/// Specifies the auto-tagging extension used. -/// -[JsonConverter(typeof(NameConverter))] -public enum Name -{ - GoogleAutoTagging, - AwsAutoTagging, -} - -sealed class NameConverter : JsonConverter -{ - public override Name Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "google-auto-tagging" => Name.GoogleAutoTagging, - "aws-auto-tagging" => Name.AwsAutoTagging, - _ => (Name)(-1), - }; - } - - public override void Write(Utf8JsonWriter writer, Name value, JsonSerializerOptions options) - { - JsonSerializer.Serialize( - writer, - value switch - { - Name.GoogleAutoTagging => "google-auto-tagging", - Name.AwsAutoTagging => "aws-auto-tagging", - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/ExtensionProperties/RemoveBg.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/ExtensionProperties/RemoveBg.cs deleted file mode 100644 index 9f7f3376..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/ExtensionProperties/RemoveBg.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties.ExtensionProperties.RemoveBgProperties; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties.ExtensionProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class RemoveBg : ModelBase, IFromRaw -{ - /// - /// Specifies the background removal extension. - /// - public JsonElement Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - throw new ArgumentOutOfRangeException("name", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public Options? Options - { - get - { - if (!this.Properties.TryGetValue("options", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["options"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Options?.Validate(); - } - - public RemoveBg() - { - this.Name = JsonSerializer.Deserialize("\"remove-bg\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - RemoveBg(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static RemoveBg FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/ExtensionProperties/RemoveBgProperties/Options.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/ExtensionProperties/RemoveBgProperties/Options.cs deleted file mode 100644 index 4db46138..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/ExtensionProperties/RemoveBgProperties/Options.cs +++ /dev/null @@ -1,122 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties.ExtensionProperties.RemoveBgProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Options : ModelBase, IFromRaw -{ - /// - /// Whether to add an artificial shadow to the result. Default is false. Note: - /// Adding shadows is currently only supported for car photos. - /// - public bool? AddShadow - { - get - { - if (!this.Properties.TryGetValue("add_shadow", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["add_shadow"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies a solid color background using hex code (e.g., "81d4fa", "fff") - /// or color name (e.g., "green"). If this parameter is set, `bg_image_url` must - /// be empty. - /// - public string? BgColor - { - get - { - if (!this.Properties.TryGetValue("bg_color", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["bg_color"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Sets a background image from a URL. If this parameter is set, `bg_color` - /// must be empty. - /// - public string? BgImageURL - { - get - { - if (!this.Properties.TryGetValue("bg_image_url", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["bg_image_url"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Allows semi-transparent regions in the result. Default is true. Note: Semitransparency - /// is currently only supported for car windows. - /// - public bool? Semitransparency - { - get - { - if (!this.Properties.TryGetValue("semitransparency", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["semitransparency"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.AddShadow; - _ = this.BgColor; - _ = this.BgImageURL; - _ = this.Semitransparency; - } - - public Options() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Options(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Options FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/ExtensionVariants/All.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/ExtensionVariants/All.cs deleted file mode 100644 index 5bca09c4..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/ExtensionVariants/All.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System.Text.Json; -using ExtensionProperties = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties.ExtensionProperties; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties.ExtensionVariants; - -public sealed record class RemoveBg(ExtensionProperties::RemoveBg Value) - : Extension, - IVariant -{ - public static RemoveBg From(ExtensionProperties::RemoveBg value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class AutoTaggingExtension(ExtensionProperties::AutoTaggingExtension Value) - : Extension, - IVariant -{ - public static AutoTaggingExtension From(ExtensionProperties::AutoTaggingExtension value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class AIAutoDescription(JsonElement Value) - : Extension, - IVariant -{ - public static AIAutoDescription From(JsonElement value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/ResponseField.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/ResponseField.cs deleted file mode 100644 index 274b0693..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/ResponseField.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties; - -[JsonConverter(typeof(ResponseFieldConverter))] -public enum ResponseField -{ - Tags, - CustomCoordinates, - IsPrivateFile, - EmbeddedMetadata, - IsPublished, - CustomMetadata, - Metadata, -} - -sealed class ResponseFieldConverter : JsonConverter -{ - public override ResponseField Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "tags" => ResponseField.Tags, - "customCoordinates" => ResponseField.CustomCoordinates, - "isPrivateFile" => ResponseField.IsPrivateFile, - "embeddedMetadata" => ResponseField.EmbeddedMetadata, - "isPublished" => ResponseField.IsPublished, - "customMetadata" => ResponseField.CustomMetadata, - "metadata" => ResponseField.Metadata, - _ => (ResponseField)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - ResponseField value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - ResponseField.Tags => "tags", - ResponseField.CustomCoordinates => "customCoordinates", - ResponseField.IsPrivateFile => "isPrivateFile", - ResponseField.EmbeddedMetadata => "embeddedMetadata", - ResponseField.IsPublished => "isPublished", - ResponseField.CustomMetadata => "customMetadata", - ResponseField.Metadata => "metadata", - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/Transformation.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/Transformation.cs deleted file mode 100644 index 808e2c12..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/Transformation.cs +++ /dev/null @@ -1,92 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties.TransformationProperties; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties; - -/// -/// Configure pre-processing (`pre`) and post-processing (`post`) transformations. -/// -/// - `pre` — applied before the file is uploaded to the Media Library. Useful -/// for reducing file size or applying basic optimizations upfront (e.g., resize, compress). -/// -/// - `post` — applied immediately after upload. Ideal for generating transformed -/// versions (like video encodes or thumbnails) in advance, so they're ready for -/// delivery without delay. -/// -/// You can mix and match any combination of post-processing types. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class Transformation : ModelBase, IFromRaw -{ - /// - /// List of transformations to apply *after* the file is uploaded. Each item - /// must match one of the following types: `transformation`, `gif-to-video`, - /// `thumbnail`, `abs`. - /// - public List? Post - { - get - { - if (!this.Properties.TryGetValue("post", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["post"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Transformation string to apply before uploading the file to the Media Library. - /// Useful for optimizing files at ingestion. - /// - public string? Pre - { - get - { - if (!this.Properties.TryGetValue("pre", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["pre"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - foreach (var item in this.Post ?? []) - { - item.Validate(); - } - _ = this.Pre; - } - - public Transformation() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Transformation(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Transformation FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/Post.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/Post.cs deleted file mode 100644 index f6a2bc35..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/Post.cs +++ /dev/null @@ -1,225 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using PostProperties = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties.TransformationProperties.PostProperties; -using PostVariants = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties.TransformationProperties.PostVariants; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties.TransformationProperties; - -[JsonConverter(typeof(PostConverter))] -public abstract record class Post -{ - internal Post() { } - - public static implicit operator Post(PostProperties::Transformation value) => - new PostVariants::Transformation(value); - - public static implicit operator Post(PostProperties::GifToVideo value) => - new PostVariants::GifToVideo(value); - - public static implicit operator Post(PostProperties::Thumbnail value) => - new PostVariants::Thumbnail(value); - - public static implicit operator Post(PostProperties::Abs value) => new PostVariants::Abs(value); - - public bool TryPickTransformation([NotNullWhen(true)] out PostProperties::Transformation? value) - { - value = (this as PostVariants::Transformation)?.Value; - return value != null; - } - - public bool TryPickGifToVideo([NotNullWhen(true)] out PostProperties::GifToVideo? value) - { - value = (this as PostVariants::GifToVideo)?.Value; - return value != null; - } - - public bool TryPickThumbnail([NotNullWhen(true)] out PostProperties::Thumbnail? value) - { - value = (this as PostVariants::Thumbnail)?.Value; - return value != null; - } - - public bool TryPickAbs([NotNullWhen(true)] out PostProperties::Abs? value) - { - value = (this as PostVariants::Abs)?.Value; - return value != null; - } - - public void Switch( - Action transformation, - Action gifToVideo, - Action thumbnail, - Action abs - ) - { - switch (this) - { - case PostVariants::Transformation inner: - transformation(inner); - break; - case PostVariants::GifToVideo inner: - gifToVideo(inner); - break; - case PostVariants::Thumbnail inner: - thumbnail(inner); - break; - case PostVariants::Abs inner: - abs(inner); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match( - Func transformation, - Func gifToVideo, - Func thumbnail, - Func abs - ) - { - return this switch - { - PostVariants::Transformation inner => transformation(inner), - PostVariants::GifToVideo inner => gifToVideo(inner), - PostVariants::Thumbnail inner => thumbnail(inner), - PostVariants::Abs inner => abs(inner), - _ => throw new InvalidOperationException(), - }; - } - - public abstract void Validate(); -} - -sealed class PostConverter : JsonConverter -{ - public override Post? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - var json = JsonSerializer.Deserialize(ref reader, options); - string? type; - try - { - type = json.GetProperty("type").GetString(); - } - catch - { - type = null; - } - - switch (type) - { - case "transformation": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize( - json, - options - ); - if (deserialized != null) - { - return new PostVariants::Transformation(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "gif-to-video": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize( - json, - options - ); - if (deserialized != null) - { - return new PostVariants::GifToVideo(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "thumbnail": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize( - json, - options - ); - if (deserialized != null) - { - return new PostVariants::Thumbnail(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "abs": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize( - json, - options - ); - if (deserialized != null) - { - return new PostVariants::Abs(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - default: - { - throw new Exception(); - } - } - } - - public override void Write(Utf8JsonWriter writer, Post value, JsonSerializerOptions options) - { - object variant = value switch - { - PostVariants::Transformation(var transformation) => transformation, - PostVariants::GifToVideo(var gifToVideo) => gifToVideo, - PostVariants::Thumbnail(var thumbnail) => thumbnail, - PostVariants::Abs(var abs) => abs, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/PostProperties/Abs.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/PostProperties/Abs.cs deleted file mode 100644 index 1f776dcc..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/PostProperties/Abs.cs +++ /dev/null @@ -1,103 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties.TransformationProperties.PostProperties.AbsProperties; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties.TransformationProperties.PostProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Abs : ModelBase, IFromRaw -{ - /// - /// Streaming protocol to use (`hls` or `dash`). - /// - public required ApiEnum Protocol - { - get - { - if (!this.Properties.TryGetValue("protocol", out JsonElement element)) - throw new ArgumentOutOfRangeException("protocol", "Missing required argument"); - - return JsonSerializer.Deserialize>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["protocol"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Adaptive Bitrate Streaming (ABS) setup. - /// - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// List of different representations you want to create separated by an underscore. - /// - public required string Value - { - get - { - if (!this.Properties.TryGetValue("value", out JsonElement element)) - throw new ArgumentOutOfRangeException("value", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("value"); - } - set - { - this.Properties["value"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Protocol.Validate(); - _ = this.Value; - } - - public Abs() - { - this.Type = JsonSerializer.Deserialize("\"abs\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Abs(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Abs FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs deleted file mode 100644 index fc5aba5d..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties.TransformationProperties.PostProperties.AbsProperties; - -/// -/// Streaming protocol to use (`hls` or `dash`). -/// -[JsonConverter(typeof(ProtocolConverter))] -public enum Protocol -{ - Hls, - Dash, -} - -sealed class ProtocolConverter : JsonConverter -{ - public override Protocol Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "hls" => Protocol.Hls, - "dash" => Protocol.Dash, - _ => (Protocol)(-1), - }; - } - - public override void Write(Utf8JsonWriter writer, Protocol value, JsonSerializerOptions options) - { - JsonSerializer.Serialize( - writer, - value switch - { - Protocol.Hls => "hls", - Protocol.Dash => "dash", - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/PostProperties/GifToVideo.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/PostProperties/GifToVideo.cs deleted file mode 100644 index af6e7d25..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/PostProperties/GifToVideo.cs +++ /dev/null @@ -1,77 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties.TransformationProperties.PostProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class GifToVideo : ModelBase, IFromRaw -{ - /// - /// Converts an animated GIF into an MP4. - /// - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Optional transformation string to apply to the output video. **Example**: - /// `q-80` - /// - public string? Value - { - get - { - if (!this.Properties.TryGetValue("value", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["value"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.Value; - } - - public GifToVideo() - { - this.Type = JsonSerializer.Deserialize("\"gif-to-video\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - GifToVideo(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static GifToVideo FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/PostProperties/Thumbnail.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/PostProperties/Thumbnail.cs deleted file mode 100644 index f16e468e..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/PostProperties/Thumbnail.cs +++ /dev/null @@ -1,76 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties.TransformationProperties.PostProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Thumbnail : ModelBase, IFromRaw -{ - /// - /// Generates a thumbnail image. - /// - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Optional transformation string. **Example**: `w-150,h-150` - /// - public string? Value - { - get - { - if (!this.Properties.TryGetValue("value", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["value"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.Value; - } - - public Thumbnail() - { - this.Type = JsonSerializer.Deserialize("\"thumbnail\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Thumbnail(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Thumbnail FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/PostProperties/Transformation.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/PostProperties/Transformation.cs deleted file mode 100644 index 2b953ea2..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/PostProperties/Transformation.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties.TransformationProperties.PostProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Transformation : ModelBase, IFromRaw -{ - /// - /// Transformation type. - /// - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Transformation string (e.g. `w-200,h-200`). Same syntax as ImageKit URL-based - /// transformations. - /// - public required string Value - { - get - { - if (!this.Properties.TryGetValue("value", out JsonElement element)) - throw new ArgumentOutOfRangeException("value", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("value"); - } - set - { - this.Properties["value"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.Value; - } - - public Transformation() - { - this.Type = JsonSerializer.Deserialize("\"transformation\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Transformation(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Transformation FromRawUnchecked(Dictionary properties) - { - return new(properties); - } - - [SetsRequiredMembers] - public Transformation(string value) - : this() - { - this.Value = value; - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/PostVariants/All.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/PostVariants/All.cs deleted file mode 100644 index dc9900e4..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadByUrlv1Properties/TransformationProperties/PostVariants/All.cs +++ /dev/null @@ -1,61 +0,0 @@ -using PostProperties = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties.TransformationProperties.PostProperties; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadByUrlv1Properties.TransformationProperties.PostVariants; - -public sealed record class Transformation(PostProperties::Transformation Value) - : Post, - IVariant -{ - public static Transformation From(PostProperties::Transformation value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class GifToVideo(PostProperties::GifToVideo Value) - : Post, - IVariant -{ - public static GifToVideo From(PostProperties::GifToVideo value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class Thumbnail(PostProperties::Thumbnail Value) - : Post, - IVariant -{ - public static Thumbnail From(PostProperties::Thumbnail value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class Abs(PostProperties::Abs Value) : Post, IVariant -{ - public static Abs From(PostProperties::Abs value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1.cs deleted file mode 100644 index 25020d6b..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1.cs +++ /dev/null @@ -1,642 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using FileUploadV1Properties = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties.FileUploadV1Properties; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class FileUploadV1 : ModelBase, IFromRaw -{ - /// - /// The API accepts any of the following: - /// - /// - **Binary data** – send the raw bytes as `multipart/form-data`. - **HTTP - /// / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. - /// - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. - /// - /// When supplying a URL, the server must receive the response headers within - /// 8 seconds; otherwise the request fails with 400 Bad Request. - /// - public required string File - { - get - { - if (!this.Properties.TryGetValue("file", out JsonElement element)) - throw new ArgumentOutOfRangeException("file", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("file"); - } - set - { - this.Properties["file"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The name with which the file has to be uploaded. The file name can contain: - /// - /// - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. - Special Characters: - /// `.`, `-` - /// - /// Any other character including space will be replaced by `_` - /// - public required string FileName - { - get - { - if (!this.Properties.TryGetValue("fileName", out JsonElement element)) - throw new ArgumentOutOfRangeException("fileName", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("fileName"); - } - set - { - this.Properties["fileName"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// A unique value that the ImageKit.io server will use to recognize and prevent - /// subsequent retries for the same request. We suggest using V4 UUIDs, or another - /// random string with enough entropy to avoid collisions. This field is only - /// required for authentication when uploading a file from the client side. - /// - /// **Note**: Sending a value that has been used in the past will result in a - /// validation error. Even if your previous request resulted in an error, you - /// should always send a new value for this field. - /// - public string? Token - { - get - { - if (!this.Properties.TryGetValue("token", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["token"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Server-side checks to run on the asset. Read more about [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). - /// - public string? Checks - { - get - { - if (!this.Properties.TryGetValue("checks", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["checks"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Define an important area in the image. This is only relevant for image type files. - /// - /// - To be passed as a string with the x and y coordinates of the top-left - /// corner, and width and height of the area of interest in the format `x,y,width,height`. - /// For example - `10,10,100,100` - Can be used with fo-customtransformation. - /// - If this field is not specified and the file is overwritten, then customCoordinates - /// will be removed. - /// - public string? CustomCoordinates - { - get - { - if (!this.Properties.TryGetValue("customCoordinates", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["customCoordinates"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// JSON key-value pairs to associate with the asset. Create the custom metadata - /// fields before setting these values. - /// - public Dictionary? CustomMetadata - { - get - { - if (!this.Properties.TryGetValue("customMetadata", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["customMetadata"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Optional text to describe the contents of the file. - /// - public string? Description - { - get - { - if (!this.Properties.TryGetValue("description", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["description"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The time until your signature is valid. It must be a [Unix time](https://en.wikipedia.org/wiki/Unix_time) - /// in less than 1 hour into the future. It should be in seconds. This field is - /// only required for authentication when uploading a file from the client side. - /// - public long? Expire - { - get - { - if (!this.Properties.TryGetValue("expire", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["expire"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Array of extensions to be applied to the image. Each extension can be configured - /// with specific parameters based on the extension type. - /// - public List? Extensions - { - get - { - if (!this.Properties.TryGetValue("extensions", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["extensions"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The folder path in which the image has to be uploaded. If the folder(s) didn't - /// exist before, a new folder(s) is created. - /// - /// The folder name can contain: - /// - /// - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` - Special Characters: - /// `/` , `_` , `-` - /// - /// Using multiple `/` creates a nested folder. - /// - public string? Folder - { - get - { - if (!this.Properties.TryGetValue("folder", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["folder"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to mark the file as private or not. - /// - /// If `true`, the file is marked as private and is accessible only using named - /// transformation or signed URL. - /// - public bool? IsPrivateFile - { - get - { - if (!this.Properties.TryGetValue("isPrivateFile", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["isPrivateFile"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to upload file as published or not. - /// - /// If `false`, the file is marked as unpublished, which restricts access to the - /// file only via the media library. Files in draft or unpublished state can only - /// be publicly accessed after being published. - /// - /// The option to upload in draft state is only available in custom enterprise - /// pricing plans. - /// - public bool? IsPublished - { - get - { - if (!this.Properties.TryGetValue("isPublished", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["isPublished"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// If set to `true` and a file already exists at the exact location, its AITags - /// will be removed. Set `overwriteAITags` to `false` to preserve AITags. - /// - public bool? OverwriteAITags - { - get - { - if (!this.Properties.TryGetValue("overwriteAITags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["overwriteAITags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// If the request does not have `customMetadata`, and a file already exists at - /// the exact location, existing customMetadata will be removed. - /// - public bool? OverwriteCustomMetadata - { - get - { - if (!this.Properties.TryGetValue("overwriteCustomMetadata", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["overwriteCustomMetadata"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// If `false` and `useUniqueFileName` is also `false`, and a file already exists - /// at the exact location, upload API will return an error immediately. - /// - public bool? OverwriteFile - { - get - { - if (!this.Properties.TryGetValue("overwriteFile", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["overwriteFile"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// If the request does not have `tags`, and a file already exists at the exact - /// location, existing tags will be removed. - /// - public bool? OverwriteTags - { - get - { - if (!this.Properties.TryGetValue("overwriteTags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["overwriteTags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Your ImageKit.io public key. This field is only required for authentication - /// when uploading a file from the client side. - /// - public string? PublicKey - { - get - { - if (!this.Properties.TryGetValue("publicKey", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["publicKey"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Array of response field keys to include in the API response body. - /// - public List>? ResponseFields - { - get - { - if (!this.Properties.TryGetValue("responseFields", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize - >?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["responseFields"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key - /// as a key. Learn how to create a signature on the page below. This should be - /// in lowercase. - /// - /// Signature must be calculated on the server-side. This field is only required - /// for authentication when uploading a file from the client side. - /// - public string? Signature - { - get - { - if (!this.Properties.TryGetValue("signature", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["signature"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Set the tags while uploading the file. Provide an array of tag strings (e.g. - /// `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must - /// not exceed 500, and the `%` character is not allowed. If this field is not - /// specified and the file is overwritten, the existing tags will be removed. - /// - public List? Tags - { - get - { - if (!this.Properties.TryGetValue("tags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["tags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Configure pre-processing (`pre`) and post-processing (`post`) transformations. - /// - /// - `pre` — applied before the file is uploaded to the Media Library. Useful - /// for reducing file size or applying basic optimizations upfront (e.g., resize, compress). - /// - /// - `post` — applied immediately after upload. Ideal for generating transformed - /// versions (like video encodes or thumbnails) in advance, so they're ready for - /// delivery without delay. - /// - /// You can mix and match any combination of post-processing types. - /// - public FileUploadV1Properties::Transformation? Transformation - { - get - { - if (!this.Properties.TryGetValue("transformation", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["transformation"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to use a unique filename for this file or not. - /// - /// If `true`, ImageKit.io will add a unique suffix to the filename parameter - /// to get a unique filename. - /// - /// If `false`, then the image is uploaded with the provided filename parameter, - /// and any existing file with the same name is replaced. - /// - public bool? UseUniqueFileName - { - get - { - if (!this.Properties.TryGetValue("useUniqueFileName", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["useUniqueFileName"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The final status of extensions after they have completed execution will be - /// delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) - /// about the webhook payload structure. - /// - public string? WebhookURL - { - get - { - if (!this.Properties.TryGetValue("webhookUrl", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["webhookUrl"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.File; - _ = this.FileName; - _ = this.Token; - _ = this.Checks; - _ = this.CustomCoordinates; - if (this.CustomMetadata != null) - { - foreach (var item in this.CustomMetadata.Values) - { - _ = item; - } - } - _ = this.Description; - _ = this.Expire; - foreach (var item in this.Extensions ?? []) - { - item.Validate(); - } - _ = this.Folder; - _ = this.IsPrivateFile; - _ = this.IsPublished; - _ = this.OverwriteAITags; - _ = this.OverwriteCustomMetadata; - _ = this.OverwriteFile; - _ = this.OverwriteTags; - _ = this.PublicKey; - foreach (var item in this.ResponseFields ?? []) - { - item.Validate(); - } - _ = this.Signature; - foreach (var item in this.Tags ?? []) - { - _ = item; - } - this.Transformation?.Validate(); - _ = this.UseUniqueFileName; - _ = this.WebhookURL; - } - - public FileUploadV1() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - FileUploadV1(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static FileUploadV1 FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyVariants/All.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyVariants/All.cs deleted file mode 100644 index 0ad364cf..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyVariants/All.cs +++ /dev/null @@ -1,33 +0,0 @@ -using BodyProperties = Imagekit.Models.Files.FileUploadParamsProperties.BodyProperties; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.BodyVariants; - -public sealed record class FileUploadV1(BodyProperties::FileUploadV1 Value) - : Body, - IVariant -{ - public static FileUploadV1 From(BodyProperties::FileUploadV1 value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class FileUploadByUrlv1(BodyProperties::FileUploadByUrlv1 Value) - : Body, - IVariant -{ - public static FileUploadByUrlv1 From(BodyProperties::FileUploadByUrlv1 value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/Extension.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/Extension.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/Extension.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/Extension.cs diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ExtensionProperties/AutoTaggingExtension.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/AutoTaggingExtension.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ExtensionProperties/AutoTaggingExtension.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/AutoTaggingExtension.cs diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ExtensionProperties/RemoveBg.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/RemoveBg.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ExtensionProperties/RemoveBg.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/RemoveBg.cs diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ExtensionProperties/RemoveBgProperties/Options.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/RemoveBgProperties/Options.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ExtensionProperties/RemoveBgProperties/Options.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/RemoveBgProperties/Options.cs diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ExtensionVariants/All.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionVariants/All.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ExtensionVariants/All.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionVariants/All.cs diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ResponseField.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/ResponseField.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/ResponseField.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/ResponseField.cs diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/Transformation.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/Transformation.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/Transformation.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/Transformation.cs diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/Post.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/Post.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/Post.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/Post.cs diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostProperties/Abs.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Abs.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostProperties/Abs.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Abs.cs diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostProperties/GifToVideo.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideo.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostProperties/GifToVideo.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideo.cs diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostProperties/Thumbnail.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Thumbnail.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostProperties/Thumbnail.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Thumbnail.cs diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostProperties/Transformation.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Transformation.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostProperties/Transformation.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Transformation.cs diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostVariants/All.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostVariants/All.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/BodyProperties/FileUploadV1Properties/TransformationProperties/PostVariants/All.cs rename to src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostVariants/All.cs From 63483ccdb648667fbdb97bb000852d9437d9e710 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 28 Jan 2026 17:39:06 +0000 Subject: [PATCH 015/129] feat(api): manual updates --- .stats.yml | 4 +- .../Models/Beta/V2/Files/FileUploadParams.cs | 1122 ++++++++--------- src/Imagekit/Models/Files/FileUploadParams.cs | 2 +- 3 files changed, 564 insertions(+), 564 deletions(-) diff --git a/.stats.yml b/.stats.yml index cfcbd7f7..5908457a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-667f7f4988b44bc587d6eb9960ff5c8326e9f7e9b072f3f724f9f54166eff8b1.yml -openapi_spec_hash: f2081864a4abee0480e5ff991b4c936a +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-0470196862abd722b09f1af798d6f2bcbdeba0f82d1162f57c287b1a43233531.yml +openapi_spec_hash: 043dd7c67d741d0034b86f2fc0bce072 config_hash: 70f9408b8d1dfbcf262a20d6eed50e1c diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParams.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParams.cs index 69983989..4cc0df73 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParams.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParams.cs @@ -1,561 +1,561 @@ -using System; -using System.Collections.Generic; -using System.Net.Http; -using System.Text; -using System.Text.Json; -using FileUploadParamsProperties = Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties; - -namespace Imagekit.Models.Beta.V2.Files; - -/// -/// The V2 API enhances security by verifying the entire payload using JWT. This -/// API is in beta. -/// -/// ImageKit.io allows you to upload files directly from both the server and client -/// sides. For server-side uploads, private API key authentication is used. For client-side -/// uploads, generate a one-time `token` from your secure backend using private API. -/// [Learn more](/docs/api-reference/upload-file/upload-file-v2#how-to-implement-secure-client-side-file-upload) -/// about how to implement secure client-side file upload. -/// -/// **File size limit** \ On the free plan, the maximum upload file sizes are 20MB -/// for images, audio, and raw files, and 100MB for videos. On the paid plan, these -/// limits increase to 40MB for images, audio, and raw files, and 2GB for videos. -/// These limits can be further increased with higher-tier plans. -/// -/// **Version limit** \ A file can have a maximum of 100 versions. -/// -/// **Demo applications** -/// -/// - A full-fledged [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), -/// supporting file selections from local storage, URL, Dropbox, Google Drive, Instagram, -/// and more. - [Quick start guides](/docs/quick-start-guides) for various frameworks -/// and technologies. -/// -public sealed record class FileUploadParams : ParamsBase -{ - public Dictionary BodyProperties { get; set; } = []; - - /// - /// The API accepts any of the following: - /// - /// - **Binary data** – send the raw bytes as `multipart/form-data`. - **HTTP - /// / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. - /// - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. - /// - /// When supplying a URL, the server must receive the response headers within - /// 8 seconds; otherwise the request fails with 400 Bad Request. - /// - public required string File - { - get - { - if (!this.BodyProperties.TryGetValue("file", out JsonElement element)) - throw new ArgumentOutOfRangeException("file", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("file"); - } - set - { - this.BodyProperties["file"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The name with which the file has to be uploaded. - /// - public required string FileName - { - get - { - if (!this.BodyProperties.TryGetValue("fileName", out JsonElement element)) - throw new ArgumentOutOfRangeException("fileName", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("fileName"); - } - set - { - this.BodyProperties["fileName"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// This is the client-generated JSON Web Token (JWT). The ImageKit.io server - /// uses it to authenticate and check that the upload request parameters have - /// not been tampered with after the token has been generated. Learn how to create - /// the token on the page below. This field is only required for authentication - /// when uploading a file from the client side. - /// - /// **Note**: Sending a JWT that has been used in the past will result in a validation - /// error. Even if your previous request resulted in an error, you should always - /// send a new token. - /// - /// **⚠️Warning**: JWT must be generated on the server-side because it is generated - /// using your account's private API key. This field is required for authentication - /// when uploading a file from the client-side. - /// - public string? Token - { - get - { - if (!this.BodyProperties.TryGetValue("token", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["token"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Server-side checks to run on the asset. Read more about [Upload API checks](/docs/api-reference/upload-file/upload-file-v2#upload-api-checks). - /// - public string? Checks - { - get - { - if (!this.BodyProperties.TryGetValue("checks", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["checks"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Define an important area in the image. This is only relevant for image type files. - /// - /// - To be passed as a string with the x and y coordinates of the top-left - /// corner, and width and height of the area of interest in the format `x,y,width,height`. - /// For example - `10,10,100,100` - Can be used with fo-customtransformation. - /// - If this field is not specified and the file is overwritten, then customCoordinates - /// will be removed. - /// - public string? CustomCoordinates - { - get - { - if (!this.BodyProperties.TryGetValue("customCoordinates", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["customCoordinates"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// JSON key-value pairs to associate with the asset. Create the custom metadata - /// fields before setting these values. - /// - public Dictionary? CustomMetadata - { - get - { - if (!this.BodyProperties.TryGetValue("customMetadata", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.BodyProperties["customMetadata"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Optional text to describe the contents of the file. - /// - public string? Description - { - get - { - if (!this.BodyProperties.TryGetValue("description", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["description"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Array of extensions to be applied to the image. Each extension can be configured - /// with specific parameters based on the extension type. - /// - public List? Extensions - { - get - { - if (!this.BodyProperties.TryGetValue("extensions", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.BodyProperties["extensions"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The folder path in which the image has to be uploaded. If the folder(s) didn't - /// exist before, a new folder(s) is created. Using multiple `/` creates a nested - /// folder. - /// - public string? Folder - { - get - { - if (!this.BodyProperties.TryGetValue("folder", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["folder"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to mark the file as private or not. - /// - /// If `true`, the file is marked as private and is accessible only using named - /// transformation or signed URL. - /// - public bool? IsPrivateFile - { - get - { - if (!this.BodyProperties.TryGetValue("isPrivateFile", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["isPrivateFile"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to upload file as published or not. - /// - /// If `false`, the file is marked as unpublished, which restricts access to the - /// file only via the media library. Files in draft or unpublished state can only - /// be publicly accessed after being published. - /// - /// The option to upload in draft state is only available in custom enterprise - /// pricing plans. - /// - public bool? IsPublished - { - get - { - if (!this.BodyProperties.TryGetValue("isPublished", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["isPublished"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// If set to `true` and a file already exists at the exact location, its AITags - /// will be removed. Set `overwriteAITags` to `false` to preserve AITags. - /// - public bool? OverwriteAITags - { - get - { - if (!this.BodyProperties.TryGetValue("overwriteAITags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["overwriteAITags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// If the request does not have `customMetadata`, and a file already exists at - /// the exact location, existing customMetadata will be removed. - /// - public bool? OverwriteCustomMetadata - { - get - { - if ( - !this.BodyProperties.TryGetValue("overwriteCustomMetadata", out JsonElement element) - ) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["overwriteCustomMetadata"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// If `false` and `useUniqueFileName` is also `false`, and a file already exists - /// at the exact location, upload API will return an error immediately. - /// - public bool? OverwriteFile - { - get - { - if (!this.BodyProperties.TryGetValue("overwriteFile", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["overwriteFile"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// If the request does not have `tags`, and a file already exists at the exact - /// location, existing tags will be removed. - /// - public bool? OverwriteTags - { - get - { - if (!this.BodyProperties.TryGetValue("overwriteTags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["overwriteTags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Array of response field keys to include in the API response body. - /// - public List>? ResponseFields - { - get - { - if (!this.BodyProperties.TryGetValue("responseFields", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize - >?>(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["responseFields"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Set the tags while uploading the file. Provide an array of tag strings (e.g. - /// `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must - /// not exceed 500, and the `%` character is not allowed. If this field is not - /// specified and the file is overwritten, the existing tags will be removed. - /// - public List? Tags - { - get - { - if (!this.BodyProperties.TryGetValue("tags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["tags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Configure pre-processing (`pre`) and post-processing (`post`) transformations. - /// - /// - `pre` — applied before the file is uploaded to the Media Library. Useful - /// for reducing file size or applying basic optimizations upfront (e.g., resize, compress). - /// - /// - `post` — applied immediately after upload. Ideal for generating transformed - /// versions (like video encodes or thumbnails) in advance, so they're ready for - /// delivery without delay. - /// - /// You can mix and match any combination of post-processing types. - /// - public FileUploadParamsProperties::Transformation? Transformation - { - get - { - if (!this.BodyProperties.TryGetValue("transformation", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.BodyProperties["transformation"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to use a unique filename for this file or not. - /// - /// If `true`, ImageKit.io will add a unique suffix to the filename parameter - /// to get a unique filename. - /// - /// If `false`, then the image is uploaded with the provided filename parameter, - /// and any existing file with the same name is replaced. - /// - public bool? UseUniqueFileName - { - get - { - if (!this.BodyProperties.TryGetValue("useUniqueFileName", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["useUniqueFileName"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The final status of extensions after they have completed execution will be - /// delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) - /// about the webhook payload structure. - /// - public string? WebhookURL - { - get - { - if (!this.BodyProperties.TryGetValue("webhookUrl", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["webhookUrl"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override Uri Url(IImageKitClient client) - { - return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/api/v2/files/upload") - { - Query = this.QueryString(client), - }.Uri; - } - - public StringContent BodyContent() - { - return new( - JsonSerializer.Serialize(this.BodyProperties), - Encoding.UTF8, - "application/json" - ); - } - - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Text; +using System.Text.Json; +using FileUploadParamsProperties = Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties; + +namespace Imagekit.Models.Beta.V2.Files; + +/// +/// The V2 API enhances security by verifying the entire payload using JWT. This +/// API is in beta. +/// +/// ImageKit.io allows you to upload files directly from both the server and client +/// sides. For server-side uploads, private API key authentication is used. For client-side +/// uploads, generate a one-time `token` from your secure backend using private API. +/// [Learn more](/docs/api-reference/upload-file/upload-file-v2#how-to-implement-secure-client-side-file-upload) +/// about how to implement secure client-side file upload. +/// +/// **File size limit** \ On the free plan, the maximum upload file sizes are 20MB +/// for images, audio, and raw files, and 100MB for videos. On the paid plan, these +/// limits increase to 40MB for images, audio, and raw files, and 2GB for videos. +/// These limits can be further increased with higher-tier plans. +/// +/// **Version limit** \ A file can have a maximum of 100 versions. +/// +/// **Demo applications** +/// +/// - A full-fledged [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), +/// supporting file selections from local storage, URL, Dropbox, Google Drive, Instagram, +/// and more. - [Quick start guides](/docs/quick-start-guides) for various frameworks +/// and technologies. +/// +public sealed record class FileUploadParams : ParamsBase +{ + public Dictionary BodyProperties { get; set; } = []; + + /// + /// The API accepts any of the following: + /// + /// - **Binary data** – send the raw bytes as `multipart/form-data`. - **HTTP + /// / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + /// - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + /// + /// When supplying a URL, the server must receive the response headers within + /// 8 seconds; otherwise the request fails with 400 Bad Request. + /// + public required string File + { + get + { + if (!this.BodyProperties.TryGetValue("file", out JsonElement element)) + throw new ArgumentOutOfRangeException("file", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("file"); + } + set + { + this.BodyProperties["file"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The name with which the file has to be uploaded. + /// + public required string FileName + { + get + { + if (!this.BodyProperties.TryGetValue("fileName", out JsonElement element)) + throw new ArgumentOutOfRangeException("fileName", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("fileName"); + } + set + { + this.BodyProperties["fileName"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// This is the client-generated JSON Web Token (JWT). The ImageKit.io server + /// uses it to authenticate and check that the upload request parameters have + /// not been tampered with after the token has been generated. Learn how to create + /// the token on the page below. This field is only required for authentication + /// when uploading a file from the client side. + /// + /// **Note**: Sending a JWT that has been used in the past will result in a validation + /// error. Even if your previous request resulted in an error, you should always + /// send a new token. + /// + /// **⚠️Warning**: JWT must be generated on the server-side because it is generated + /// using your account's private API key. This field is required for authentication + /// when uploading a file from the client-side. + /// + public string? Token + { + get + { + if (!this.BodyProperties.TryGetValue("token", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["token"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Server-side checks to run on the asset. Read more about [Upload API checks](/docs/api-reference/upload-file/upload-file-v2#upload-api-checks). + /// + public string? Checks + { + get + { + if (!this.BodyProperties.TryGetValue("checks", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["checks"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Define an important area in the image. This is only relevant for image type files. + /// + /// - To be passed as a string with the x and y coordinates of the top-left + /// corner, and width and height of the area of interest in the format `x,y,width,height`. + /// For example - `10,10,100,100` - Can be used with fo-customtransformation. + /// - If this field is not specified and the file is overwritten, then customCoordinates + /// will be removed. + /// + public string? CustomCoordinates + { + get + { + if (!this.BodyProperties.TryGetValue("customCoordinates", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["customCoordinates"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// JSON key-value pairs to associate with the asset. Create the custom metadata + /// fields before setting these values. + /// + public Dictionary? CustomMetadata + { + get + { + if (!this.BodyProperties.TryGetValue("customMetadata", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.BodyProperties["customMetadata"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Optional text to describe the contents of the file. + /// + public string? Description + { + get + { + if (!this.BodyProperties.TryGetValue("description", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["description"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Array of extensions to be applied to the asset. Each extension can be configured + /// with specific parameters based on the extension type. + /// + public List? Extensions + { + get + { + if (!this.BodyProperties.TryGetValue("extensions", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.BodyProperties["extensions"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The folder path in which the image has to be uploaded. If the folder(s) didn't + /// exist before, a new folder(s) is created. Using multiple `/` creates a nested + /// folder. + /// + public string? Folder + { + get + { + if (!this.BodyProperties.TryGetValue("folder", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["folder"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to mark the file as private or not. + /// + /// If `true`, the file is marked as private and is accessible only using named + /// transformation or signed URL. + /// + public bool? IsPrivateFile + { + get + { + if (!this.BodyProperties.TryGetValue("isPrivateFile", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["isPrivateFile"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to upload file as published or not. + /// + /// If `false`, the file is marked as unpublished, which restricts access to the + /// file only via the media library. Files in draft or unpublished state can only + /// be publicly accessed after being published. + /// + /// The option to upload in draft state is only available in custom enterprise + /// pricing plans. + /// + public bool? IsPublished + { + get + { + if (!this.BodyProperties.TryGetValue("isPublished", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["isPublished"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// If set to `true` and a file already exists at the exact location, its AITags + /// will be removed. Set `overwriteAITags` to `false` to preserve AITags. + /// + public bool? OverwriteAITags + { + get + { + if (!this.BodyProperties.TryGetValue("overwriteAITags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["overwriteAITags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// If the request does not have `customMetadata`, and a file already exists at + /// the exact location, existing customMetadata will be removed. + /// + public bool? OverwriteCustomMetadata + { + get + { + if ( + !this.BodyProperties.TryGetValue("overwriteCustomMetadata", out JsonElement element) + ) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["overwriteCustomMetadata"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// If `false` and `useUniqueFileName` is also `false`, and a file already exists + /// at the exact location, upload API will return an error immediately. + /// + public bool? OverwriteFile + { + get + { + if (!this.BodyProperties.TryGetValue("overwriteFile", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["overwriteFile"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// If the request does not have `tags`, and a file already exists at the exact + /// location, existing tags will be removed. + /// + public bool? OverwriteTags + { + get + { + if (!this.BodyProperties.TryGetValue("overwriteTags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["overwriteTags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Array of response field keys to include in the API response body. + /// + public List>? ResponseFields + { + get + { + if (!this.BodyProperties.TryGetValue("responseFields", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize + >?>(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["responseFields"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Set the tags while uploading the file. Provide an array of tag strings (e.g. + /// `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must + /// not exceed 500, and the `%` character is not allowed. If this field is not + /// specified and the file is overwritten, the existing tags will be removed. + /// + public List? Tags + { + get + { + if (!this.BodyProperties.TryGetValue("tags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["tags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Configure pre-processing (`pre`) and post-processing (`post`) transformations. + /// + /// - `pre` — applied before the file is uploaded to the Media Library. Useful + /// for reducing file size or applying basic optimizations upfront (e.g., resize, compress). + /// + /// - `post` — applied immediately after upload. Ideal for generating transformed + /// versions (like video encodes or thumbnails) in advance, so they're ready for + /// delivery without delay. + /// + /// You can mix and match any combination of post-processing types. + /// + public FileUploadParamsProperties::Transformation? Transformation + { + get + { + if (!this.BodyProperties.TryGetValue("transformation", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.BodyProperties["transformation"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to use a unique filename for this file or not. + /// + /// If `true`, ImageKit.io will add a unique suffix to the filename parameter + /// to get a unique filename. + /// + /// If `false`, then the image is uploaded with the provided filename parameter, + /// and any existing file with the same name is replaced. + /// + public bool? UseUniqueFileName + { + get + { + if (!this.BodyProperties.TryGetValue("useUniqueFileName", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["useUniqueFileName"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The final status of extensions after they have completed execution will be + /// delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + /// about the webhook payload structure. + /// + public string? WebhookURL + { + get + { + if (!this.BodyProperties.TryGetValue("webhookUrl", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["webhookUrl"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override Uri Url(IImageKitClient client) + { + return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/api/v2/files/upload") + { + Query = this.QueryString(client), + }.Uri; + } + + public StringContent BodyContent() + { + return new( + JsonSerializer.Serialize(this.BodyProperties), + Encoding.UTF8, + "application/json" + ); + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParams.cs b/src/Imagekit/Models/Files/FileUploadParams.cs index 5dd1291e..2a922679 100644 --- a/src/Imagekit/Models/Files/FileUploadParams.cs +++ b/src/Imagekit/Models/Files/FileUploadParams.cs @@ -237,7 +237,7 @@ public long? Expire } /// - /// Array of extensions to be applied to the image. Each extension can be configured + /// Array of extensions to be applied to the asset. Each extension can be configured /// with specific parameters based on the extension type. /// public List? Extensions From 6e57b6f0d596828bb289ab651ec388398511e2ea Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 28 Jan 2026 17:43:09 +0000 Subject: [PATCH 016/129] feat(api): manual updates --- .stats.yml | 2 +- src/Imagekit/ModelBase.cs | 10 +- .../Models/Beta/V2/Files/FileUploadParams.cs | 4 +- .../UnnamedSchemaWithArrayParent2.cs} | 0 .../All.cs | 0 .../UnnamedSchemaWithArrayParent1.cs | 0 .../All.cs | 0 ...t2.cs => UnnamedSchemaWithArrayParent3.cs} | 0 .../All.cs | 0 src/Imagekit/Models/Files/FileUploadParams.cs | 4 +- .../Models/UnnamedSchemaWithArrayParent0.cs | 184 ++++++++++++++++++ .../AutoTaggingExtension.cs | 0 .../AutoTaggingExtensionProperties/Name.cs | 0 .../RemoveBg.cs | 0 .../RemoveBgProperties/Options.cs | 0 .../All.cs | 53 +++++ 16 files changed, 244 insertions(+), 13 deletions(-) rename src/Imagekit/Models/CustomMetadataFields/{CustomMetadataFieldProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent0.cs => CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent2.cs} (100%) rename src/Imagekit/Models/CustomMetadataFields/{CustomMetadataFieldUpdateParamsProperties => CustomMetadataFieldCreateParamsProperties}/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent2Variants/All.cs (100%) rename src/Imagekit/Models/CustomMetadataFields/{CustomMetadataFieldCreateParamsProperties => CustomMetadataFieldProperties}/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent1.cs (100%) rename src/Imagekit/Models/CustomMetadataFields/{CustomMetadataFieldCreateParamsProperties => CustomMetadataFieldProperties}/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent1Variants/All.cs (100%) rename src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValueProperties/{UnnamedSchemaWithArrayParent2.cs => UnnamedSchemaWithArrayParent3.cs} (100%) rename src/Imagekit/Models/CustomMetadataFields/{CustomMetadataFieldProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent0Variants => CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent3Variants}/All.cs (100%) create mode 100644 src/Imagekit/Models/UnnamedSchemaWithArrayParent0.cs rename src/Imagekit/Models/{Files/FileUploadParamsProperties/ExtensionProperties => UnnamedSchemaWithArrayParent0Properties}/AutoTaggingExtension.cs (100%) rename src/Imagekit/Models/{Files/FileUploadParamsProperties/ExtensionProperties => UnnamedSchemaWithArrayParent0Properties}/AutoTaggingExtensionProperties/Name.cs (100%) rename src/Imagekit/Models/{Files/FileUploadParamsProperties/ExtensionProperties => UnnamedSchemaWithArrayParent0Properties}/RemoveBg.cs (100%) rename src/Imagekit/Models/{Files/FileUploadParamsProperties/ExtensionProperties => UnnamedSchemaWithArrayParent0Properties}/RemoveBgProperties/Options.cs (100%) create mode 100644 src/Imagekit/Models/UnnamedSchemaWithArrayParent0Variants/All.cs diff --git a/.stats.yml b/.stats.yml index 5908457a..2dc65d21 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-0470196862abd722b09f1af798d6f2bcbdeba0f82d1162f57c287b1a43233531.yml openapi_spec_hash: 043dd7c67d741d0034b86f2fc0bce072 -config_hash: 70f9408b8d1dfbcf262a20d6eed50e1c +config_hash: da949a1217f48ac01676eab81ca9d1b1 diff --git a/src/Imagekit/ModelBase.cs b/src/Imagekit/ModelBase.cs index e9e70c6b..32b552db 100644 --- a/src/Imagekit/ModelBase.cs +++ b/src/Imagekit/ModelBase.cs @@ -3,18 +3,17 @@ using Imagekit.Models; using Imagekit.Models.Cache.Invalidation.InvalidationGetResponseProperties; using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties; -using Imagekit.Models.Files.FileUpdateParamsProperties.UpdateProperties.UpdateFileDetailsProperties.ExtensionProperties.AutoTaggingExtensionProperties; using Imagekit.Models.Files.FileUpdateResponseProperties.IntersectionMember1Properties.ExtensionStatusProperties; using Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.AbsProperties; using Imagekit.Models.ImageOverlayProperties.IntersectionMember1Properties; using Imagekit.Models.OverlayPositionProperties; using Imagekit.Models.SubtitleOverlayTransformationProperties; using Imagekit.Models.TextOverlayTransformationProperties; +using Imagekit.Models.UnnamedSchemaWithArrayParent0Properties.AutoTaggingExtensionProperties; using Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.IntersectionMember1Properties.DataProperties.TransformationProperties.OptionsProperties; using Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.IntersectionMember1Properties.DataProperties.TransformationProperties.ErrorProperties; using AbsProperties = Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.AbsProperties; using AssetListParamsProperties = Imagekit.Models.Assets.AssetListParamsProperties; -using AutoTaggingExtensionProperties = Imagekit.Models.Files.FileUploadParamsProperties.ExtensionProperties.AutoTaggingExtensionProperties; using ExtensionStatusProperties = Imagekit.Models.Files.FileUploadResponseProperties.ExtensionStatusProperties; using FileProperties = Imagekit.Models.Files.FileProperties; using FileUploadParamsProperties = Imagekit.Models.Files.FileUploadParamsProperties; @@ -35,6 +34,7 @@ public abstract record class ModelBase { Converters = { + new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), @@ -76,8 +76,6 @@ public abstract record class ModelBase new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), @@ -102,10 +100,6 @@ public abstract record class ModelBase string, global::Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.ExtensionStatusProperties.RemoveBg >(), - new ApiEnumConverter< - string, - global::Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.ExtensionProperties.AutoTaggingExtensionProperties.Name - >(), new ApiEnumConverter< string, global::Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.ResponseField diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParams.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParams.cs index 4cc0df73..217968e5 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParams.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParams.cs @@ -217,14 +217,14 @@ public string? Description /// Array of extensions to be applied to the asset. Each extension can be configured /// with specific parameters based on the extension type. /// - public List? Extensions + public List? Extensions { get { if (!this.BodyProperties.TryGetValue("extensions", out JsonElement element)) return null; - return JsonSerializer.Deserialize?>( + return JsonSerializer.Deserialize?>( element, ModelBase.SerializerOptions ); diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent0.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent2.cs similarity index 100% rename from src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent0.cs rename to src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent2.cs diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent2Variants/All.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent2Variants/All.cs similarity index 100% rename from src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent2Variants/All.cs rename to src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent2Variants/All.cs diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent1.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent1.cs similarity index 100% rename from src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent1.cs rename to src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent1.cs diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent1Variants/All.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent1Variants/All.cs similarity index 100% rename from src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent1Variants/All.cs rename to src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent1Variants/All.cs diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent2.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent3.cs similarity index 100% rename from src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent2.cs rename to src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent3.cs diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent0Variants/All.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent3Variants/All.cs similarity index 100% rename from src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent0Variants/All.cs rename to src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent3Variants/All.cs diff --git a/src/Imagekit/Models/Files/FileUploadParams.cs b/src/Imagekit/Models/Files/FileUploadParams.cs index 2a922679..f9951c2e 100644 --- a/src/Imagekit/Models/Files/FileUploadParams.cs +++ b/src/Imagekit/Models/Files/FileUploadParams.cs @@ -240,14 +240,14 @@ public long? Expire /// Array of extensions to be applied to the asset. Each extension can be configured /// with specific parameters based on the extension type. /// - public List? Extensions + public List? Extensions { get { if (!this.BodyProperties.TryGetValue("extensions", out JsonElement element)) return null; - return JsonSerializer.Deserialize?>( + return JsonSerializer.Deserialize?>( element, ModelBase.SerializerOptions ); diff --git a/src/Imagekit/Models/UnnamedSchemaWithArrayParent0.cs b/src/Imagekit/Models/UnnamedSchemaWithArrayParent0.cs new file mode 100644 index 00000000..8978a6f4 --- /dev/null +++ b/src/Imagekit/Models/UnnamedSchemaWithArrayParent0.cs @@ -0,0 +1,184 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.UnnamedSchemaWithArrayParent0Properties; +using UnnamedSchemaWithArrayParent0Variants = Imagekit.Models.UnnamedSchemaWithArrayParent0Variants; + +namespace Imagekit.Models; + +[JsonConverter(typeof(UnnamedSchemaWithArrayParent0Converter))] +public abstract record class UnnamedSchemaWithArrayParent0 +{ + internal UnnamedSchemaWithArrayParent0() { } + + public static implicit operator UnnamedSchemaWithArrayParent0(RemoveBg value) => + new UnnamedSchemaWithArrayParent0Variants::RemoveBg(value); + + public static implicit operator UnnamedSchemaWithArrayParent0(AutoTaggingExtension value) => + new UnnamedSchemaWithArrayParent0Variants::AutoTaggingExtension(value); + + public bool TryPickRemoveBg([NotNullWhen(true)] out RemoveBg? value) + { + value = (this as UnnamedSchemaWithArrayParent0Variants::RemoveBg)?.Value; + return value != null; + } + + public bool TryPickAutoTaggingExtension([NotNullWhen(true)] out AutoTaggingExtension? value) + { + value = (this as UnnamedSchemaWithArrayParent0Variants::AutoTaggingExtension)?.Value; + return value != null; + } + + public bool TryPickAIAutoDescription([NotNullWhen(true)] out JsonElement? value) + { + value = (this as UnnamedSchemaWithArrayParent0Variants::AIAutoDescription)?.Value; + return value != null; + } + + public void Switch( + Action removeBg, + Action autoTaggingExtension, + Action aiAutoDescription + ) + { + switch (this) + { + case UnnamedSchemaWithArrayParent0Variants::RemoveBg inner: + removeBg(inner); + break; + case UnnamedSchemaWithArrayParent0Variants::AutoTaggingExtension inner: + autoTaggingExtension(inner); + break; + case UnnamedSchemaWithArrayParent0Variants::AIAutoDescription inner: + aiAutoDescription(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func removeBg, + Func autoTaggingExtension, + Func aiAutoDescription + ) + { + return this switch + { + UnnamedSchemaWithArrayParent0Variants::RemoveBg inner => removeBg(inner), + UnnamedSchemaWithArrayParent0Variants::AutoTaggingExtension inner => + autoTaggingExtension(inner), + UnnamedSchemaWithArrayParent0Variants::AIAutoDescription inner => aiAutoDescription( + inner + ), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class UnnamedSchemaWithArrayParent0Converter : JsonConverter +{ + public override UnnamedSchemaWithArrayParent0? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var json = JsonSerializer.Deserialize(ref reader, options); + string? name; + try + { + name = json.GetProperty("name").GetString(); + } + catch + { + name = null; + } + + switch (name) + { + case "remove-bg": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new UnnamedSchemaWithArrayParent0Variants::RemoveBg(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "ai-auto-description": + { + List exceptions = []; + + try + { + return new UnnamedSchemaWithArrayParent0Variants::AIAutoDescription( + JsonSerializer.Deserialize(json, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + default: + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize( + json, + options + ); + if (deserialized != null) + { + return new UnnamedSchemaWithArrayParent0Variants::AutoTaggingExtension( + deserialized + ); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + UnnamedSchemaWithArrayParent0 value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + UnnamedSchemaWithArrayParent0Variants::RemoveBg(var removeBg) => removeBg, + UnnamedSchemaWithArrayParent0Variants::AutoTaggingExtension(var autoTaggingExtension) => + autoTaggingExtension, + UnnamedSchemaWithArrayParent0Variants::AIAutoDescription(var aiAutoDescription) => + aiAutoDescription, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/AutoTaggingExtension.cs b/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/AutoTaggingExtension.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/AutoTaggingExtension.cs rename to src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/AutoTaggingExtension.cs diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs b/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/AutoTaggingExtensionProperties/Name.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs rename to src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/AutoTaggingExtensionProperties/Name.cs diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/RemoveBg.cs b/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/RemoveBg.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/RemoveBg.cs rename to src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/RemoveBg.cs diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/RemoveBgProperties/Options.cs b/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/RemoveBgProperties/Options.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionProperties/RemoveBgProperties/Options.cs rename to src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/RemoveBgProperties/Options.cs diff --git a/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Variants/All.cs b/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Variants/All.cs new file mode 100644 index 00000000..9ea8ce68 --- /dev/null +++ b/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Variants/All.cs @@ -0,0 +1,53 @@ +using System.Text.Json; +using UnnamedSchemaWithArrayParent0Properties = Imagekit.Models.UnnamedSchemaWithArrayParent0Properties; + +namespace Imagekit.Models.UnnamedSchemaWithArrayParent0Variants; + +public sealed record class RemoveBg(UnnamedSchemaWithArrayParent0Properties::RemoveBg Value) + : UnnamedSchemaWithArrayParent0, + IVariant +{ + public static RemoveBg From(UnnamedSchemaWithArrayParent0Properties::RemoveBg value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class AutoTaggingExtension( + UnnamedSchemaWithArrayParent0Properties::AutoTaggingExtension Value +) + : UnnamedSchemaWithArrayParent0, + IVariant< + AutoTaggingExtension, + UnnamedSchemaWithArrayParent0Properties::AutoTaggingExtension + > +{ + public static AutoTaggingExtension From( + UnnamedSchemaWithArrayParent0Properties::AutoTaggingExtension value + ) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class AIAutoDescription(JsonElement Value) + : UnnamedSchemaWithArrayParent0, + IVariant +{ + public static AIAutoDescription From(JsonElement value) + { + return new(value); + } + + public override void Validate() { } +} From fb27300dabd8f706901ecdb3375c893968d58198 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 28 Jan 2026 17:46:32 +0000 Subject: [PATCH 017/129] feat(api): manual updates --- .stats.yml | 2 +- .../Files/FileUpdateParamsProperties/Body.cs | 123 ++++++++++++++++++ .../ChangePublicationStatus.cs | 0 .../Publish.cs | 0 .../UpdateFileDetails.cs | 0 .../UpdateFileDetailsProperties/Extension.cs | 0 .../AutoTaggingExtension.cs | 0 .../AutoTaggingExtensionProperties/Name.cs | 0 .../ExtensionProperties/RemoveBg.cs | 0 .../RemoveBgProperties/Options.cs | 0 .../ExtensionVariants/All.cs | 0 .../RemoveAITags.cs | 0 .../RemoveAITagsVariants/All.cs | 0 .../BodyVariants/All.cs | 33 +++++ 14 files changed, 157 insertions(+), 1 deletion(-) create mode 100644 src/Imagekit/Models/Files/FileUpdateParamsProperties/Body.cs rename src/Imagekit/Models/Files/FileUpdateParamsProperties/{UpdateProperties => BodyProperties}/ChangePublicationStatus.cs (100%) rename src/Imagekit/Models/Files/FileUpdateParamsProperties/{UpdateProperties => BodyProperties}/ChangePublicationStatusProperties/Publish.cs (100%) rename src/Imagekit/Models/Files/FileUpdateParamsProperties/{UpdateProperties => BodyProperties}/UpdateFileDetails.cs (100%) rename src/Imagekit/Models/Files/FileUpdateParamsProperties/{UpdateProperties => BodyProperties}/UpdateFileDetailsProperties/Extension.cs (100%) rename src/Imagekit/Models/Files/FileUpdateParamsProperties/{UpdateProperties => BodyProperties}/UpdateFileDetailsProperties/ExtensionProperties/AutoTaggingExtension.cs (100%) rename src/Imagekit/Models/Files/FileUpdateParamsProperties/{UpdateProperties => BodyProperties}/UpdateFileDetailsProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs (100%) rename src/Imagekit/Models/Files/FileUpdateParamsProperties/{UpdateProperties => BodyProperties}/UpdateFileDetailsProperties/ExtensionProperties/RemoveBg.cs (100%) rename src/Imagekit/Models/Files/FileUpdateParamsProperties/{UpdateProperties => BodyProperties}/UpdateFileDetailsProperties/ExtensionProperties/RemoveBgProperties/Options.cs (100%) rename src/Imagekit/Models/Files/FileUpdateParamsProperties/{UpdateProperties => BodyProperties}/UpdateFileDetailsProperties/ExtensionVariants/All.cs (100%) rename src/Imagekit/Models/Files/FileUpdateParamsProperties/{UpdateProperties => BodyProperties}/UpdateFileDetailsProperties/RemoveAITags.cs (100%) rename src/Imagekit/Models/Files/FileUpdateParamsProperties/{UpdateProperties => BodyProperties}/UpdateFileDetailsProperties/RemoveAITagsVariants/All.cs (100%) create mode 100644 src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyVariants/All.cs diff --git a/.stats.yml b/.stats.yml index 2dc65d21..335e38ec 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-0470196862abd722b09f1af798d6f2bcbdeba0f82d1162f57c287b1a43233531.yml openapi_spec_hash: 043dd7c67d741d0034b86f2fc0bce072 -config_hash: da949a1217f48ac01676eab81ca9d1b1 +config_hash: a652d68098d82eaf611a49507fb4b831 diff --git a/src/Imagekit/Models/Files/FileUpdateParamsProperties/Body.cs b/src/Imagekit/Models/Files/FileUpdateParamsProperties/Body.cs new file mode 100644 index 00000000..3213efd5 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUpdateParamsProperties/Body.cs @@ -0,0 +1,123 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files.FileUpdateParamsProperties.BodyProperties; +using BodyVariants = Imagekit.Models.Files.FileUpdateParamsProperties.BodyVariants; + +namespace Imagekit.Models.Files.FileUpdateParamsProperties; + +[JsonConverter(typeof(BodyConverter))] +public abstract record class Body +{ + internal Body() { } + + public static implicit operator Body(UpdateFileDetails value) => + new BodyVariants::UpdateFileDetails(value); + + public static implicit operator Body(ChangePublicationStatus value) => + new BodyVariants::ChangePublicationStatus(value); + + public bool TryPickUpdateFileDetails([NotNullWhen(true)] out UpdateFileDetails? value) + { + value = (this as BodyVariants::UpdateFileDetails)?.Value; + return value != null; + } + + public bool TryPickChangePublicationStatus( + [NotNullWhen(true)] out ChangePublicationStatus? value + ) + { + value = (this as BodyVariants::ChangePublicationStatus)?.Value; + return value != null; + } + + public void Switch( + Action updateFileDetails, + Action changePublicationStatus + ) + { + switch (this) + { + case BodyVariants::UpdateFileDetails inner: + updateFileDetails(inner); + break; + case BodyVariants::ChangePublicationStatus inner: + changePublicationStatus(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func updateFileDetails, + Func changePublicationStatus + ) + { + return this switch + { + BodyVariants::UpdateFileDetails inner => updateFileDetails(inner), + BodyVariants::ChangePublicationStatus inner => changePublicationStatus(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class BodyConverter : JsonConverter +{ + public override Body? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new BodyVariants::UpdateFileDetails(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize( + ref reader, + options + ); + if (deserialized != null) + { + return new BodyVariants::ChangePublicationStatus(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + + public override void Write(Utf8JsonWriter writer, Body value, JsonSerializerOptions options) + { + object variant = value switch + { + BodyVariants::UpdateFileDetails(var updateFileDetails) => updateFileDetails, + BodyVariants::ChangePublicationStatus(var changePublicationStatus) => + changePublicationStatus, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/ChangePublicationStatus.cs b/src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyProperties/ChangePublicationStatus.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/ChangePublicationStatus.cs rename to src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyProperties/ChangePublicationStatus.cs diff --git a/src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/ChangePublicationStatusProperties/Publish.cs b/src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyProperties/ChangePublicationStatusProperties/Publish.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/ChangePublicationStatusProperties/Publish.cs rename to src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyProperties/ChangePublicationStatusProperties/Publish.cs diff --git a/src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetails.cs b/src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyProperties/UpdateFileDetails.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetails.cs rename to src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyProperties/UpdateFileDetails.cs diff --git a/src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetailsProperties/Extension.cs b/src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyProperties/UpdateFileDetailsProperties/Extension.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetailsProperties/Extension.cs rename to src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyProperties/UpdateFileDetailsProperties/Extension.cs diff --git a/src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetailsProperties/ExtensionProperties/AutoTaggingExtension.cs b/src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyProperties/UpdateFileDetailsProperties/ExtensionProperties/AutoTaggingExtension.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetailsProperties/ExtensionProperties/AutoTaggingExtension.cs rename to src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyProperties/UpdateFileDetailsProperties/ExtensionProperties/AutoTaggingExtension.cs diff --git a/src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetailsProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs b/src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyProperties/UpdateFileDetailsProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetailsProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs rename to src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyProperties/UpdateFileDetailsProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs diff --git a/src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetailsProperties/ExtensionProperties/RemoveBg.cs b/src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyProperties/UpdateFileDetailsProperties/ExtensionProperties/RemoveBg.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetailsProperties/ExtensionProperties/RemoveBg.cs rename to src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyProperties/UpdateFileDetailsProperties/ExtensionProperties/RemoveBg.cs diff --git a/src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetailsProperties/ExtensionProperties/RemoveBgProperties/Options.cs b/src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyProperties/UpdateFileDetailsProperties/ExtensionProperties/RemoveBgProperties/Options.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetailsProperties/ExtensionProperties/RemoveBgProperties/Options.cs rename to src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyProperties/UpdateFileDetailsProperties/ExtensionProperties/RemoveBgProperties/Options.cs diff --git a/src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetailsProperties/ExtensionVariants/All.cs b/src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyProperties/UpdateFileDetailsProperties/ExtensionVariants/All.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetailsProperties/ExtensionVariants/All.cs rename to src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyProperties/UpdateFileDetailsProperties/ExtensionVariants/All.cs diff --git a/src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetailsProperties/RemoveAITags.cs b/src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyProperties/UpdateFileDetailsProperties/RemoveAITags.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetailsProperties/RemoveAITags.cs rename to src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyProperties/UpdateFileDetailsProperties/RemoveAITags.cs diff --git a/src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetailsProperties/RemoveAITagsVariants/All.cs b/src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyProperties/UpdateFileDetailsProperties/RemoveAITagsVariants/All.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateProperties/UpdateFileDetailsProperties/RemoveAITagsVariants/All.cs rename to src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyProperties/UpdateFileDetailsProperties/RemoveAITagsVariants/All.cs diff --git a/src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyVariants/All.cs b/src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyVariants/All.cs new file mode 100644 index 00000000..72cf901a --- /dev/null +++ b/src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyVariants/All.cs @@ -0,0 +1,33 @@ +using BodyProperties = Imagekit.Models.Files.FileUpdateParamsProperties.BodyProperties; + +namespace Imagekit.Models.Files.FileUpdateParamsProperties.BodyVariants; + +public sealed record class UpdateFileDetails(BodyProperties::UpdateFileDetails Value) + : Body, + IVariant +{ + public static UpdateFileDetails From(BodyProperties::UpdateFileDetails value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class ChangePublicationStatus(BodyProperties::ChangePublicationStatus Value) + : Body, + IVariant +{ + public static ChangePublicationStatus From(BodyProperties::ChangePublicationStatus value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} From 0946dff73c362ff604a4f560ad06db82bbec7f3f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 4 Sep 2025 07:05:01 +0000 Subject: [PATCH 018/129] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 335e38ec..e13d3275 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-0470196862abd722b09f1af798d6f2bcbdeba0f82d1162f57c287b1a43233531.yml -openapi_spec_hash: 043dd7c67d741d0034b86f2fc0bce072 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-afb67c3a2098b1a2dca37d0995d183fa6cf59dd144ed47bcdb924f14e3cc90a3.yml +openapi_spec_hash: 55a2f38df85126a87d1be0b27b9b8470 config_hash: a652d68098d82eaf611a49507fb4b831 From 585c5b587ca8c1b6e7eacaa75f3030ecd1f9ead7 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 4 Sep 2025 07:10:46 +0000 Subject: [PATCH 019/129] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index e13d3275..bbfdcb43 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-afb67c3a2098b1a2dca37d0995d183fa6cf59dd144ed47bcdb924f14e3cc90a3.yml -openapi_spec_hash: 55a2f38df85126a87d1be0b27b9b8470 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-bc7c0d27962b30c19c778656988e154b54696819389289f34420a5e5fdfbd3b8.yml +openapi_spec_hash: 1bfde02a63416c036e9545927f727459 config_hash: a652d68098d82eaf611a49507fb4b831 From 4958ee3f016ed279619ce85a2fcf2631a70dd48c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 28 Jan 2026 17:48:50 +0000 Subject: [PATCH 020/129] feat(api): extract UpdateFileDetailsRequest to model --- .stats.yml | 2 +- src/Imagekit/Models/Files/FileUpdateParams.cs | 134 +++++++++--------- .../Files/FileUpdateParamsProperties/Body.cs | 123 ---------------- .../BodyVariants/All.cs | 33 ----- .../Models/Files/UpdateFileDetailsRequest.cs | 130 +++++++++++++++++ .../ChangePublicationStatus.cs | 0 .../Publish.cs | 0 .../UpdateFileDetails.cs | 0 .../UpdateFileDetailsProperties/Extension.cs | 0 .../AutoTaggingExtension.cs | 0 .../AutoTaggingExtensionProperties/Name.cs | 0 .../ExtensionProperties/RemoveBg.cs | 0 .../RemoveBgProperties/Options.cs | 0 .../ExtensionVariants/All.cs | 0 .../RemoveAITags.cs | 0 .../RemoveAITagsVariants/All.cs | 0 .../UpdateFileDetailsRequestVariants/All.cs | 44 ++++++ 17 files changed, 242 insertions(+), 224 deletions(-) delete mode 100644 src/Imagekit/Models/Files/FileUpdateParamsProperties/Body.cs delete mode 100644 src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyVariants/All.cs create mode 100644 src/Imagekit/Models/Files/UpdateFileDetailsRequest.cs rename src/Imagekit/Models/Files/{FileUpdateParamsProperties/BodyProperties => UpdateFileDetailsRequestProperties}/ChangePublicationStatus.cs (100%) rename src/Imagekit/Models/Files/{FileUpdateParamsProperties/BodyProperties => UpdateFileDetailsRequestProperties}/ChangePublicationStatusProperties/Publish.cs (100%) rename src/Imagekit/Models/Files/{FileUpdateParamsProperties/BodyProperties => UpdateFileDetailsRequestProperties}/UpdateFileDetails.cs (100%) rename src/Imagekit/Models/Files/{FileUpdateParamsProperties/BodyProperties => UpdateFileDetailsRequestProperties}/UpdateFileDetailsProperties/Extension.cs (100%) rename src/Imagekit/Models/Files/{FileUpdateParamsProperties/BodyProperties => UpdateFileDetailsRequestProperties}/UpdateFileDetailsProperties/ExtensionProperties/AutoTaggingExtension.cs (100%) rename src/Imagekit/Models/Files/{FileUpdateParamsProperties/BodyProperties => UpdateFileDetailsRequestProperties}/UpdateFileDetailsProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs (100%) rename src/Imagekit/Models/Files/{FileUpdateParamsProperties/BodyProperties => UpdateFileDetailsRequestProperties}/UpdateFileDetailsProperties/ExtensionProperties/RemoveBg.cs (100%) rename src/Imagekit/Models/Files/{FileUpdateParamsProperties/BodyProperties => UpdateFileDetailsRequestProperties}/UpdateFileDetailsProperties/ExtensionProperties/RemoveBgProperties/Options.cs (100%) rename src/Imagekit/Models/Files/{FileUpdateParamsProperties/BodyProperties => UpdateFileDetailsRequestProperties}/UpdateFileDetailsProperties/ExtensionVariants/All.cs (100%) rename src/Imagekit/Models/Files/{FileUpdateParamsProperties/BodyProperties => UpdateFileDetailsRequestProperties}/UpdateFileDetailsProperties/RemoveAITags.cs (100%) rename src/Imagekit/Models/Files/{FileUpdateParamsProperties/BodyProperties => UpdateFileDetailsRequestProperties}/UpdateFileDetailsProperties/RemoveAITagsVariants/All.cs (100%) create mode 100644 src/Imagekit/Models/Files/UpdateFileDetailsRequestVariants/All.cs diff --git a/.stats.yml b/.stats.yml index bbfdcb43..b0086e96 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-bc7c0d27962b30c19c778656988e154b54696819389289f34420a5e5fdfbd3b8.yml openapi_spec_hash: 1bfde02a63416c036e9545927f727459 -config_hash: a652d68098d82eaf611a49507fb4b831 +config_hash: b415c06a3b29485af4601beb94ae1aeb diff --git a/src/Imagekit/Models/Files/FileUpdateParams.cs b/src/Imagekit/Models/Files/FileUpdateParams.cs index 100f51ab..8210b1d8 100644 --- a/src/Imagekit/Models/Files/FileUpdateParams.cs +++ b/src/Imagekit/Models/Files/FileUpdateParams.cs @@ -1,67 +1,67 @@ -using System; -using System.Collections.Generic; -using System.Net.Http; -using System.Text; -using System.Text.Json; -using Imagekit.Models.Files.FileUpdateParamsProperties; - -namespace Imagekit.Models.Files; - -/// -/// This API updates the details or attributes of the current version of the file. -/// You can update `tags`, `customCoordinates`, `customMetadata`, publication status, -/// remove existing `AITags` and apply extensions using this API. -/// -public sealed record class FileUpdateParams : ParamsBase -{ - public Dictionary BodyProperties { get; set; } = []; - - public required string FileID; - - public Update? Update - { - get - { - if (!this.BodyProperties.TryGetValue("update", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["update"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override Uri Url(IImageKitClient client) - { - return new UriBuilder( - client.BaseUrl.ToString().TrimEnd('/') - + string.Format("/v1/files/{0}/details", this.FileID) - ) - { - Query = this.QueryString(client), - }.Uri; - } - - public StringContent BodyContent() - { - return new( - JsonSerializer.Serialize(this.BodyProperties), - Encoding.UTF8, - "application/json" - ); - } - - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Text; +using System.Text.Json; +using Imagekit.Models.Files.FileUpdateParamsProperties; + +namespace Imagekit.Models.Files; + +/// +/// This API updates the details or attributes of the current version of the file. +/// You can update `tags`, `customCoordinates`, `customMetadata`, publication status, +/// remove existing `AITags` and apply extensions using this API. +/// +public sealed record class FileUpdateParams : ParamsBase +{ + public Dictionary BodyProperties { get; set; } = []; + + public required string FileID; + + public Update? Update + { + get + { + if (!this.BodyProperties.TryGetValue("update", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["update"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override Uri Url(IImageKitClient client) + { + return new UriBuilder( + client.BaseUrl.ToString().TrimEnd('/') + + string.Format("/v1/files/{0}/details", this.FileID) + ) + { + Query = this.QueryString(client), + }.Uri; + } + + public StringContent BodyContent() + { + return new( + JsonSerializer.Serialize(this.BodyProperties), + Encoding.UTF8, + "application/json" + ); + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/Files/FileUpdateParamsProperties/Body.cs b/src/Imagekit/Models/Files/FileUpdateParamsProperties/Body.cs deleted file mode 100644 index 3213efd5..00000000 --- a/src/Imagekit/Models/Files/FileUpdateParamsProperties/Body.cs +++ /dev/null @@ -1,123 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Files.FileUpdateParamsProperties.BodyProperties; -using BodyVariants = Imagekit.Models.Files.FileUpdateParamsProperties.BodyVariants; - -namespace Imagekit.Models.Files.FileUpdateParamsProperties; - -[JsonConverter(typeof(BodyConverter))] -public abstract record class Body -{ - internal Body() { } - - public static implicit operator Body(UpdateFileDetails value) => - new BodyVariants::UpdateFileDetails(value); - - public static implicit operator Body(ChangePublicationStatus value) => - new BodyVariants::ChangePublicationStatus(value); - - public bool TryPickUpdateFileDetails([NotNullWhen(true)] out UpdateFileDetails? value) - { - value = (this as BodyVariants::UpdateFileDetails)?.Value; - return value != null; - } - - public bool TryPickChangePublicationStatus( - [NotNullWhen(true)] out ChangePublicationStatus? value - ) - { - value = (this as BodyVariants::ChangePublicationStatus)?.Value; - return value != null; - } - - public void Switch( - Action updateFileDetails, - Action changePublicationStatus - ) - { - switch (this) - { - case BodyVariants::UpdateFileDetails inner: - updateFileDetails(inner); - break; - case BodyVariants::ChangePublicationStatus inner: - changePublicationStatus(inner); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match( - Func updateFileDetails, - Func changePublicationStatus - ) - { - return this switch - { - BodyVariants::UpdateFileDetails inner => updateFileDetails(inner), - BodyVariants::ChangePublicationStatus inner => changePublicationStatus(inner), - _ => throw new InvalidOperationException(), - }; - } - - public abstract void Validate(); -} - -sealed class BodyConverter : JsonConverter -{ - public override Body? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new BodyVariants::UpdateFileDetails(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - try - { - var deserialized = JsonSerializer.Deserialize( - ref reader, - options - ); - if (deserialized != null) - { - return new BodyVariants::ChangePublicationStatus(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - - public override void Write(Utf8JsonWriter writer, Body value, JsonSerializerOptions options) - { - object variant = value switch - { - BodyVariants::UpdateFileDetails(var updateFileDetails) => updateFileDetails, - BodyVariants::ChangePublicationStatus(var changePublicationStatus) => - changePublicationStatus, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyVariants/All.cs b/src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyVariants/All.cs deleted file mode 100644 index 72cf901a..00000000 --- a/src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyVariants/All.cs +++ /dev/null @@ -1,33 +0,0 @@ -using BodyProperties = Imagekit.Models.Files.FileUpdateParamsProperties.BodyProperties; - -namespace Imagekit.Models.Files.FileUpdateParamsProperties.BodyVariants; - -public sealed record class UpdateFileDetails(BodyProperties::UpdateFileDetails Value) - : Body, - IVariant -{ - public static UpdateFileDetails From(BodyProperties::UpdateFileDetails value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class ChangePublicationStatus(BodyProperties::ChangePublicationStatus Value) - : Body, - IVariant -{ - public static ChangePublicationStatus From(BodyProperties::ChangePublicationStatus value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} diff --git a/src/Imagekit/Models/Files/UpdateFileDetailsRequest.cs b/src/Imagekit/Models/Files/UpdateFileDetailsRequest.cs new file mode 100644 index 00000000..795e3f7b --- /dev/null +++ b/src/Imagekit/Models/Files/UpdateFileDetailsRequest.cs @@ -0,0 +1,130 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files.UpdateFileDetailsRequestProperties; +using UpdateFileDetailsRequestVariants = Imagekit.Models.Files.UpdateFileDetailsRequestVariants; + +namespace Imagekit.Models.Files; + +[JsonConverter(typeof(UpdateFileDetailsRequestConverter))] +public abstract record class UpdateFileDetailsRequest +{ + internal UpdateFileDetailsRequest() { } + + public static implicit operator UpdateFileDetailsRequest(UpdateFileDetails value) => + new UpdateFileDetailsRequestVariants::UpdateFileDetails(value); + + public static implicit operator UpdateFileDetailsRequest(ChangePublicationStatus value) => + new UpdateFileDetailsRequestVariants::ChangePublicationStatus(value); + + public bool TryPickUpdateFileDetails([NotNullWhen(true)] out UpdateFileDetails? value) + { + value = (this as UpdateFileDetailsRequestVariants::UpdateFileDetails)?.Value; + return value != null; + } + + public bool TryPickChangePublicationStatus( + [NotNullWhen(true)] out ChangePublicationStatus? value + ) + { + value = (this as UpdateFileDetailsRequestVariants::ChangePublicationStatus)?.Value; + return value != null; + } + + public void Switch( + Action updateFileDetails, + Action changePublicationStatus + ) + { + switch (this) + { + case UpdateFileDetailsRequestVariants::UpdateFileDetails inner: + updateFileDetails(inner); + break; + case UpdateFileDetailsRequestVariants::ChangePublicationStatus inner: + changePublicationStatus(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func updateFileDetails, + Func changePublicationStatus + ) + { + return this switch + { + UpdateFileDetailsRequestVariants::UpdateFileDetails inner => updateFileDetails(inner), + UpdateFileDetailsRequestVariants::ChangePublicationStatus inner => + changePublicationStatus(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class UpdateFileDetailsRequestConverter : JsonConverter +{ + public override UpdateFileDetailsRequest? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new UpdateFileDetailsRequestVariants::UpdateFileDetails(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize( + ref reader, + options + ); + if (deserialized != null) + { + return new UpdateFileDetailsRequestVariants::ChangePublicationStatus(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + + public override void Write( + Utf8JsonWriter writer, + UpdateFileDetailsRequest value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + UpdateFileDetailsRequestVariants::UpdateFileDetails(var updateFileDetails) => + updateFileDetails, + UpdateFileDetailsRequestVariants::ChangePublicationStatus( + var changePublicationStatus + ) => changePublicationStatus, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyProperties/ChangePublicationStatus.cs b/src/Imagekit/Models/Files/UpdateFileDetailsRequestProperties/ChangePublicationStatus.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyProperties/ChangePublicationStatus.cs rename to src/Imagekit/Models/Files/UpdateFileDetailsRequestProperties/ChangePublicationStatus.cs diff --git a/src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyProperties/ChangePublicationStatusProperties/Publish.cs b/src/Imagekit/Models/Files/UpdateFileDetailsRequestProperties/ChangePublicationStatusProperties/Publish.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyProperties/ChangePublicationStatusProperties/Publish.cs rename to src/Imagekit/Models/Files/UpdateFileDetailsRequestProperties/ChangePublicationStatusProperties/Publish.cs diff --git a/src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyProperties/UpdateFileDetails.cs b/src/Imagekit/Models/Files/UpdateFileDetailsRequestProperties/UpdateFileDetails.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyProperties/UpdateFileDetails.cs rename to src/Imagekit/Models/Files/UpdateFileDetailsRequestProperties/UpdateFileDetails.cs diff --git a/src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyProperties/UpdateFileDetailsProperties/Extension.cs b/src/Imagekit/Models/Files/UpdateFileDetailsRequestProperties/UpdateFileDetailsProperties/Extension.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyProperties/UpdateFileDetailsProperties/Extension.cs rename to src/Imagekit/Models/Files/UpdateFileDetailsRequestProperties/UpdateFileDetailsProperties/Extension.cs diff --git a/src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyProperties/UpdateFileDetailsProperties/ExtensionProperties/AutoTaggingExtension.cs b/src/Imagekit/Models/Files/UpdateFileDetailsRequestProperties/UpdateFileDetailsProperties/ExtensionProperties/AutoTaggingExtension.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyProperties/UpdateFileDetailsProperties/ExtensionProperties/AutoTaggingExtension.cs rename to src/Imagekit/Models/Files/UpdateFileDetailsRequestProperties/UpdateFileDetailsProperties/ExtensionProperties/AutoTaggingExtension.cs diff --git a/src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyProperties/UpdateFileDetailsProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs b/src/Imagekit/Models/Files/UpdateFileDetailsRequestProperties/UpdateFileDetailsProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyProperties/UpdateFileDetailsProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs rename to src/Imagekit/Models/Files/UpdateFileDetailsRequestProperties/UpdateFileDetailsProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs diff --git a/src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyProperties/UpdateFileDetailsProperties/ExtensionProperties/RemoveBg.cs b/src/Imagekit/Models/Files/UpdateFileDetailsRequestProperties/UpdateFileDetailsProperties/ExtensionProperties/RemoveBg.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyProperties/UpdateFileDetailsProperties/ExtensionProperties/RemoveBg.cs rename to src/Imagekit/Models/Files/UpdateFileDetailsRequestProperties/UpdateFileDetailsProperties/ExtensionProperties/RemoveBg.cs diff --git a/src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyProperties/UpdateFileDetailsProperties/ExtensionProperties/RemoveBgProperties/Options.cs b/src/Imagekit/Models/Files/UpdateFileDetailsRequestProperties/UpdateFileDetailsProperties/ExtensionProperties/RemoveBgProperties/Options.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyProperties/UpdateFileDetailsProperties/ExtensionProperties/RemoveBgProperties/Options.cs rename to src/Imagekit/Models/Files/UpdateFileDetailsRequestProperties/UpdateFileDetailsProperties/ExtensionProperties/RemoveBgProperties/Options.cs diff --git a/src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyProperties/UpdateFileDetailsProperties/ExtensionVariants/All.cs b/src/Imagekit/Models/Files/UpdateFileDetailsRequestProperties/UpdateFileDetailsProperties/ExtensionVariants/All.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyProperties/UpdateFileDetailsProperties/ExtensionVariants/All.cs rename to src/Imagekit/Models/Files/UpdateFileDetailsRequestProperties/UpdateFileDetailsProperties/ExtensionVariants/All.cs diff --git a/src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyProperties/UpdateFileDetailsProperties/RemoveAITags.cs b/src/Imagekit/Models/Files/UpdateFileDetailsRequestProperties/UpdateFileDetailsProperties/RemoveAITags.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyProperties/UpdateFileDetailsProperties/RemoveAITags.cs rename to src/Imagekit/Models/Files/UpdateFileDetailsRequestProperties/UpdateFileDetailsProperties/RemoveAITags.cs diff --git a/src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyProperties/UpdateFileDetailsProperties/RemoveAITagsVariants/All.cs b/src/Imagekit/Models/Files/UpdateFileDetailsRequestProperties/UpdateFileDetailsProperties/RemoveAITagsVariants/All.cs similarity index 100% rename from src/Imagekit/Models/Files/FileUpdateParamsProperties/BodyProperties/UpdateFileDetailsProperties/RemoveAITagsVariants/All.cs rename to src/Imagekit/Models/Files/UpdateFileDetailsRequestProperties/UpdateFileDetailsProperties/RemoveAITagsVariants/All.cs diff --git a/src/Imagekit/Models/Files/UpdateFileDetailsRequestVariants/All.cs b/src/Imagekit/Models/Files/UpdateFileDetailsRequestVariants/All.cs new file mode 100644 index 00000000..e83f047b --- /dev/null +++ b/src/Imagekit/Models/Files/UpdateFileDetailsRequestVariants/All.cs @@ -0,0 +1,44 @@ +using UpdateFileDetailsRequestProperties = Imagekit.Models.Files.UpdateFileDetailsRequestProperties; + +namespace Imagekit.Models.Files.UpdateFileDetailsRequestVariants; + +public sealed record class UpdateFileDetails( + UpdateFileDetailsRequestProperties::UpdateFileDetails Value +) + : UpdateFileDetailsRequest, + IVariant +{ + public static UpdateFileDetails From( + UpdateFileDetailsRequestProperties::UpdateFileDetails value + ) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class ChangePublicationStatus( + UpdateFileDetailsRequestProperties::ChangePublicationStatus Value +) + : UpdateFileDetailsRequest, + IVariant< + ChangePublicationStatus, + UpdateFileDetailsRequestProperties::ChangePublicationStatus + > +{ + public static ChangePublicationStatus From( + UpdateFileDetailsRequestProperties::ChangePublicationStatus value + ) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} From 9fcf3b3f18b8450f12c48f904406e74cbbc12ccb Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 28 Jan 2026 17:53:43 +0000 Subject: [PATCH 021/129] chore(internal): codegen related update --- src/Imagekit/ParamsBase.cs | 333 +++++++++++++++++++------------------ 1 file changed, 169 insertions(+), 164 deletions(-) diff --git a/src/Imagekit/ParamsBase.cs b/src/Imagekit/ParamsBase.cs index 2f20430a..da9602e9 100644 --- a/src/Imagekit/ParamsBase.cs +++ b/src/Imagekit/ParamsBase.cs @@ -1,164 +1,169 @@ -using System; -using System.Collections.Generic; -using System.Collections.Specialized; -using System.Linq; -using System.Net.Http; -using System.Text; -using System.Text.Json; -using Web = System.Web; - -namespace Imagekit; - -public abstract record class ParamsBase -{ - public Dictionary QueryProperties { get; set; } = []; - - public Dictionary HeaderProperties { get; set; } = []; - - public abstract Uri Url(IImageKitClient client); - - protected static void AddQueryElementToCollection( - NameValueCollection collection, - string key, - JsonElement element - ) - { - switch (element.ValueKind) - { - case JsonValueKind.Undefined: - case JsonValueKind.Null: - collection.Add(key, ""); - break; - case JsonValueKind.String: - case JsonValueKind.Number: - collection.Add(key, element.ToString()); - break; - case JsonValueKind.True: - collection.Add(key, "true"); - break; - case JsonValueKind.False: - collection.Add(key, "false"); - break; - case JsonValueKind.Object: - foreach (var item in element.EnumerateObject()) - { - AddQueryElementToCollection( - collection, - string.Format("{0}[{1}]", key, item.Name), - item.Value - ); - } - break; - case JsonValueKind.Array: - collection.Add( - key, - string.Join( - ",", - Enumerable.Select( - element.EnumerateArray(), - x => - x.ValueKind switch - { - JsonValueKind.Null => "", - JsonValueKind.True => "true", - JsonValueKind.False => "false", - _ => x.GetString(), - } - ) - ) - ); - break; - } - } - - protected static void AddHeaderElementToRequest( - HttpRequestMessage request, - string key, - JsonElement element - ) - { - switch (element.ValueKind) - { - case JsonValueKind.Undefined: - case JsonValueKind.Null: - request.Headers.Add(key, ""); - break; - case JsonValueKind.String: - case JsonValueKind.Number: - request.Headers.Add(key, element.ToString()); - break; - case JsonValueKind.True: - request.Headers.Add(key, "true"); - break; - case JsonValueKind.False: - request.Headers.Add(key, "false"); - break; - case JsonValueKind.Object: - foreach (var item in element.EnumerateObject()) - { - AddHeaderElementToRequest( - request, - string.Format("{0}.{1}", key, item.Name), - item.Value - ); - } - break; - case JsonValueKind.Array: - foreach (var item in element.EnumerateArray()) - { - request.Headers.Add( - key, - item.ValueKind switch - { - JsonValueKind.Null => "", - JsonValueKind.True => "true", - JsonValueKind.False => "false", - _ => item.GetString(), - } - ); - } - break; - } - } - - protected string QueryString(IImageKitClient client) - { - NameValueCollection collection = []; - foreach (var item in this.QueryProperties) - { - ParamsBase.AddQueryElementToCollection(collection, item.Key, item.Value); - } - StringBuilder sb = new(); - bool first = true; - foreach (var key in collection.AllKeys) - { - foreach (var value in collection.GetValues(key) ?? []) - { - if (!first) - { - sb.Append('&'); - } - first = false; - sb.Append(Web::HttpUtility.UrlEncode(key)); - sb.Append('='); - sb.Append(Web::HttpUtility.UrlEncode(value)); - } - } - return sb.ToString(); - } - - protected static void AddDefaultHeaders(HttpRequestMessage request, IImageKitClient client) - { - request.Headers.Add( - "Authorization", - string.Format( - "Basic {0}", - Convert.ToBase64String( - Encoding - .GetEncoding("ISO-8859-1") - .GetBytes(string.Format("{0}:{1}", client.PrivateAPIKey, client.Password)) - ) - ) - ); - } -} +using System; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.Linq; +using System.Net.Http; +using System.Text; +using System.Text.Json; +using Web = System.Web; + +namespace Imagekit; + +public abstract record class ParamsBase +{ + public Dictionary QueryProperties { get; set; } = []; + + public Dictionary HeaderProperties { get; set; } = []; + + public abstract Uri Url(IImageKitClient client); + + protected static void AddQueryElementToCollection( + NameValueCollection collection, + string key, + JsonElement element + ) + { + switch (element.ValueKind) + { + case JsonValueKind.Undefined: + case JsonValueKind.Null: + collection.Add(key, ""); + break; + case JsonValueKind.String: + case JsonValueKind.Number: + collection.Add(key, element.ToString()); + break; + case JsonValueKind.True: + collection.Add(key, "true"); + break; + case JsonValueKind.False: + collection.Add(key, "false"); + break; + case JsonValueKind.Object: + foreach (var item in element.EnumerateObject()) + { + AddQueryElementToCollection( + collection, + string.Format("{0}[{1}]", key, item.Name), + item.Value + ); + } + break; + case JsonValueKind.Array: + collection.Add( + key, + string.Join( + ",", + Enumerable.Select( + element.EnumerateArray(), + x => + x.ValueKind switch + { + JsonValueKind.Null => "", + JsonValueKind.True => "true", + JsonValueKind.False => "false", + _ => x.GetString(), + } + ) + ) + ); + break; + } + } + + protected static void AddHeaderElementToRequest( + HttpRequestMessage request, + string key, + JsonElement element + ) + { + switch (element.ValueKind) + { + case JsonValueKind.Undefined: + case JsonValueKind.Null: + request.Headers.Add(key, ""); + break; + case JsonValueKind.String: + case JsonValueKind.Number: + request.Headers.Add(key, element.ToString()); + break; + case JsonValueKind.True: + request.Headers.Add(key, "true"); + break; + case JsonValueKind.False: + request.Headers.Add(key, "false"); + break; + case JsonValueKind.Object: + foreach (var item in element.EnumerateObject()) + { + AddHeaderElementToRequest( + request, + string.Format("{0}.{1}", key, item.Name), + item.Value + ); + } + break; + case JsonValueKind.Array: + foreach (var item in element.EnumerateArray()) + { + request.Headers.Add( + key, + item.ValueKind switch + { + JsonValueKind.Null => "", + JsonValueKind.True => "true", + JsonValueKind.False => "false", + _ => item.GetString(), + } + ); + } + break; + } + } + + protected string QueryString(IImageKitClient client) + { + NameValueCollection collection = []; + foreach (var item in this.QueryProperties) + { + ParamsBase.AddQueryElementToCollection(collection, item.Key, item.Value); + } + StringBuilder sb = new(); + bool first = true; + foreach (var key in collection.AllKeys) + { + foreach (var value in collection.GetValues(key) ?? []) + { + if (!first) + { + sb.Append('&'); + } + first = false; + sb.Append(Web::HttpUtility.UrlEncode(key)); + sb.Append('='); + sb.Append(Web::HttpUtility.UrlEncode(value)); + } + } + return sb.ToString(); + } + + protected static void AddDefaultHeaders(HttpRequestMessage request, IImageKitClient client) + { + if (client.PrivateAPIKey != null && client.Password != null) + { + request.Headers.Add( + "Authorization", + string.Format( + "Basic {0}", + Convert.ToBase64String( + Encoding + .GetEncoding("ISO-8859-1") + .GetBytes( + string.Format("{0}:{1}", client.PrivateAPIKey, client.Password) + ) + ) + ) + ); + } + } +} From 35baab00edb0c48b67292fdafd03649f3fb676c8 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 18 Sep 2025 02:13:46 +0000 Subject: [PATCH 022/129] fix(internal): remove example csproj --- examples/.keep | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 examples/.keep diff --git a/examples/.keep b/examples/.keep new file mode 100644 index 00000000..e69de29b From ccc0a10db64ebe3a81990503390bfb991ff401f2 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 28 Jan 2026 17:55:59 +0000 Subject: [PATCH 023/129] feat(api): manual updates --- .stats.yml | 6 +- .../Services/Files/FileServiceTest.cs | 49 ++++++- .../Models/Files/UpdateFileDetailsRequest.cs | 130 ------------------ .../UpdateFileDetailsRequestVariants/All.cs | 44 ------ .../Models/Files/UpdateFileRequest.cs | 125 +++++++++++++++++ .../UpdateFileDetails.cs | 0 .../UpdateFileDetailsProperties/Extension.cs | 0 .../AutoTaggingExtension.cs | 0 .../AutoTaggingExtensionProperties/Name.cs | 0 .../ExtensionProperties/RemoveBg.cs | 0 .../RemoveBgProperties/Options.cs | 0 .../ExtensionVariants/All.cs | 0 .../RemoveAITags.cs | 0 .../RemoveAITagsVariants/All.cs | 0 .../Files/UpdateFileRequestVariants/All.cs | 31 +++++ 15 files changed, 207 insertions(+), 178 deletions(-) delete mode 100644 src/Imagekit/Models/Files/UpdateFileDetailsRequest.cs delete mode 100644 src/Imagekit/Models/Files/UpdateFileDetailsRequestVariants/All.cs create mode 100644 src/Imagekit/Models/Files/UpdateFileRequest.cs rename src/Imagekit/Models/Files/{UpdateFileDetailsRequestProperties => UpdateFileRequestProperties}/UpdateFileDetails.cs (100%) rename src/Imagekit/Models/Files/{UpdateFileDetailsRequestProperties => UpdateFileRequestProperties}/UpdateFileDetailsProperties/Extension.cs (100%) rename src/Imagekit/Models/Files/{UpdateFileDetailsRequestProperties => UpdateFileRequestProperties}/UpdateFileDetailsProperties/ExtensionProperties/AutoTaggingExtension.cs (100%) rename src/Imagekit/Models/Files/{UpdateFileDetailsRequestProperties => UpdateFileRequestProperties}/UpdateFileDetailsProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs (100%) rename src/Imagekit/Models/Files/{UpdateFileDetailsRequestProperties => UpdateFileRequestProperties}/UpdateFileDetailsProperties/ExtensionProperties/RemoveBg.cs (100%) rename src/Imagekit/Models/Files/{UpdateFileDetailsRequestProperties => UpdateFileRequestProperties}/UpdateFileDetailsProperties/ExtensionProperties/RemoveBgProperties/Options.cs (100%) rename src/Imagekit/Models/Files/{UpdateFileDetailsRequestProperties => UpdateFileRequestProperties}/UpdateFileDetailsProperties/ExtensionVariants/All.cs (100%) rename src/Imagekit/Models/Files/{UpdateFileDetailsRequestProperties => UpdateFileRequestProperties}/UpdateFileDetailsProperties/RemoveAITags.cs (100%) rename src/Imagekit/Models/Files/{UpdateFileDetailsRequestProperties => UpdateFileRequestProperties}/UpdateFileDetailsProperties/RemoveAITagsVariants/All.cs (100%) create mode 100644 src/Imagekit/Models/Files/UpdateFileRequestVariants/All.cs diff --git a/.stats.yml b/.stats.yml index b0086e96..bb4a090c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-bc7c0d27962b30c19c778656988e154b54696819389289f34420a5e5fdfbd3b8.yml -openapi_spec_hash: 1bfde02a63416c036e9545927f727459 -config_hash: b415c06a3b29485af4601beb94ae1aeb +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-dd864816d7f4316ae89f57394da2fd1926166d4704db5a0bb5d23461d2d75e49.yml +openapi_spec_hash: 7f7c416563a15bbaea98804ecdc1a8f9 +config_hash: 54c05a157f2cc730fac9e1df5dc3ca29 diff --git a/src/Imagekit.Tests/Services/Files/FileServiceTest.cs b/src/Imagekit.Tests/Services/Files/FileServiceTest.cs index 0ccbc624..c3d46fd1 100644 --- a/src/Imagekit.Tests/Services/Files/FileServiceTest.cs +++ b/src/Imagekit.Tests/Services/Files/FileServiceTest.cs @@ -1,4 +1,10 @@ +using System.Collections.Generic; +using System.Text.Json; using System.Threading.Tasks; +using Imagekit.Models.Files.UpdateFileRequestProperties; +using Imagekit.Models.UnnamedSchemaWithArrayParent0Properties; +using Imagekit.Models.UnnamedSchemaWithArrayParent0Properties.AutoTaggingExtensionProperties; +using UnnamedSchemaWithArrayParent0Variants = Imagekit.Models.UnnamedSchemaWithArrayParent0Variants; namespace Imagekit.Tests.Services.Files; @@ -7,7 +13,48 @@ public class FileServiceTest : TestBase [Fact(Skip = "Prism tests are disabled")] public async Task Update_Works() { - var file = await this.client.Files.Update(new() { FileID = "fileId" }); + var file = await this.client.Files.Update( + new() + { + FileID = "fileId", + UpdateFileRequest = new UpdateFileDetails() + { + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Extensions = + [ + new RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageURL = "bg_image_url", + Semitransparency = true, + }, + }, + new AutoTaggingExtension() + { + MaxTags = 5, + MinConfidence = 95, + Name = Name.GoogleAutoTagging, + }, + new UnnamedSchemaWithArrayParent0Variants::AIAutoDescription( + JsonSerializer.Deserialize( + "{\"name\":\"ai-auto-description\"}" + ) + ), + ], + RemoveAITags = new List() { "string" }, + Tags = ["car", "vehicle", "motorsports"], + WebhookURL = "https://example.com", + }, + } + ); file.Validate(); } diff --git a/src/Imagekit/Models/Files/UpdateFileDetailsRequest.cs b/src/Imagekit/Models/Files/UpdateFileDetailsRequest.cs deleted file mode 100644 index 795e3f7b..00000000 --- a/src/Imagekit/Models/Files/UpdateFileDetailsRequest.cs +++ /dev/null @@ -1,130 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Files.UpdateFileDetailsRequestProperties; -using UpdateFileDetailsRequestVariants = Imagekit.Models.Files.UpdateFileDetailsRequestVariants; - -namespace Imagekit.Models.Files; - -[JsonConverter(typeof(UpdateFileDetailsRequestConverter))] -public abstract record class UpdateFileDetailsRequest -{ - internal UpdateFileDetailsRequest() { } - - public static implicit operator UpdateFileDetailsRequest(UpdateFileDetails value) => - new UpdateFileDetailsRequestVariants::UpdateFileDetails(value); - - public static implicit operator UpdateFileDetailsRequest(ChangePublicationStatus value) => - new UpdateFileDetailsRequestVariants::ChangePublicationStatus(value); - - public bool TryPickUpdateFileDetails([NotNullWhen(true)] out UpdateFileDetails? value) - { - value = (this as UpdateFileDetailsRequestVariants::UpdateFileDetails)?.Value; - return value != null; - } - - public bool TryPickChangePublicationStatus( - [NotNullWhen(true)] out ChangePublicationStatus? value - ) - { - value = (this as UpdateFileDetailsRequestVariants::ChangePublicationStatus)?.Value; - return value != null; - } - - public void Switch( - Action updateFileDetails, - Action changePublicationStatus - ) - { - switch (this) - { - case UpdateFileDetailsRequestVariants::UpdateFileDetails inner: - updateFileDetails(inner); - break; - case UpdateFileDetailsRequestVariants::ChangePublicationStatus inner: - changePublicationStatus(inner); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match( - Func updateFileDetails, - Func changePublicationStatus - ) - { - return this switch - { - UpdateFileDetailsRequestVariants::UpdateFileDetails inner => updateFileDetails(inner), - UpdateFileDetailsRequestVariants::ChangePublicationStatus inner => - changePublicationStatus(inner), - _ => throw new InvalidOperationException(), - }; - } - - public abstract void Validate(); -} - -sealed class UpdateFileDetailsRequestConverter : JsonConverter -{ - public override UpdateFileDetailsRequest? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new UpdateFileDetailsRequestVariants::UpdateFileDetails(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - try - { - var deserialized = JsonSerializer.Deserialize( - ref reader, - options - ); - if (deserialized != null) - { - return new UpdateFileDetailsRequestVariants::ChangePublicationStatus(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - - public override void Write( - Utf8JsonWriter writer, - UpdateFileDetailsRequest value, - JsonSerializerOptions options - ) - { - object variant = value switch - { - UpdateFileDetailsRequestVariants::UpdateFileDetails(var updateFileDetails) => - updateFileDetails, - UpdateFileDetailsRequestVariants::ChangePublicationStatus( - var changePublicationStatus - ) => changePublicationStatus, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/Files/UpdateFileDetailsRequestVariants/All.cs b/src/Imagekit/Models/Files/UpdateFileDetailsRequestVariants/All.cs deleted file mode 100644 index e83f047b..00000000 --- a/src/Imagekit/Models/Files/UpdateFileDetailsRequestVariants/All.cs +++ /dev/null @@ -1,44 +0,0 @@ -using UpdateFileDetailsRequestProperties = Imagekit.Models.Files.UpdateFileDetailsRequestProperties; - -namespace Imagekit.Models.Files.UpdateFileDetailsRequestVariants; - -public sealed record class UpdateFileDetails( - UpdateFileDetailsRequestProperties::UpdateFileDetails Value -) - : UpdateFileDetailsRequest, - IVariant -{ - public static UpdateFileDetails From( - UpdateFileDetailsRequestProperties::UpdateFileDetails value - ) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class ChangePublicationStatus( - UpdateFileDetailsRequestProperties::ChangePublicationStatus Value -) - : UpdateFileDetailsRequest, - IVariant< - ChangePublicationStatus, - UpdateFileDetailsRequestProperties::ChangePublicationStatus - > -{ - public static ChangePublicationStatus From( - UpdateFileDetailsRequestProperties::ChangePublicationStatus value - ) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} diff --git a/src/Imagekit/Models/Files/UpdateFileRequest.cs b/src/Imagekit/Models/Files/UpdateFileRequest.cs new file mode 100644 index 00000000..6152360a --- /dev/null +++ b/src/Imagekit/Models/Files/UpdateFileRequest.cs @@ -0,0 +1,125 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files.UpdateFileRequestProperties; +using UpdateFileRequestVariants = Imagekit.Models.Files.UpdateFileRequestVariants; + +namespace Imagekit.Models.Files; + +/// +/// Schema for update file update request. +/// +[JsonConverter(typeof(UpdateFileRequestConverter))] +public abstract record class UpdateFileRequest +{ + internal UpdateFileRequest() { } + + public static implicit operator UpdateFileRequest(UpdateFileDetails value) => + new UpdateFileRequestVariants::UpdateFileDetails(value); + + public static implicit operator UpdateFileRequest(JsonElement value) => + new UpdateFileRequestVariants::ChangePublicationStatus(value); + + public bool TryPickDetails([NotNullWhen(true)] out UpdateFileDetails? value) + { + value = (this as UpdateFileRequestVariants::UpdateFileDetails)?.Value; + return value != null; + } + + public bool TryPickChangePublicationStatus([NotNullWhen(true)] out JsonElement? value) + { + value = (this as UpdateFileRequestVariants::ChangePublicationStatus)?.Value; + return value != null; + } + + public void Switch( + Action details, + Action changePublicationStatus + ) + { + switch (this) + { + case UpdateFileRequestVariants::UpdateFileDetails inner: + details(inner); + break; + case UpdateFileRequestVariants::ChangePublicationStatus inner: + changePublicationStatus(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func details, + Func changePublicationStatus + ) + { + return this switch + { + UpdateFileRequestVariants::UpdateFileDetails inner => details(inner), + UpdateFileRequestVariants::ChangePublicationStatus inner => changePublicationStatus( + inner + ), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class UpdateFileRequestConverter : JsonConverter +{ + public override UpdateFileRequest? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new UpdateFileRequestVariants::UpdateFileDetails(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new UpdateFileRequestVariants::ChangePublicationStatus( + JsonSerializer.Deserialize(ref reader, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + + public override void Write( + Utf8JsonWriter writer, + UpdateFileRequest value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + UpdateFileRequestVariants::UpdateFileDetails(var details) => details, + UpdateFileRequestVariants::ChangePublicationStatus(var changePublicationStatus) => + changePublicationStatus, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Files/UpdateFileDetailsRequestProperties/UpdateFileDetails.cs b/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetails.cs similarity index 100% rename from src/Imagekit/Models/Files/UpdateFileDetailsRequestProperties/UpdateFileDetails.cs rename to src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetails.cs diff --git a/src/Imagekit/Models/Files/UpdateFileDetailsRequestProperties/UpdateFileDetailsProperties/Extension.cs b/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/Extension.cs similarity index 100% rename from src/Imagekit/Models/Files/UpdateFileDetailsRequestProperties/UpdateFileDetailsProperties/Extension.cs rename to src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/Extension.cs diff --git a/src/Imagekit/Models/Files/UpdateFileDetailsRequestProperties/UpdateFileDetailsProperties/ExtensionProperties/AutoTaggingExtension.cs b/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/ExtensionProperties/AutoTaggingExtension.cs similarity index 100% rename from src/Imagekit/Models/Files/UpdateFileDetailsRequestProperties/UpdateFileDetailsProperties/ExtensionProperties/AutoTaggingExtension.cs rename to src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/ExtensionProperties/AutoTaggingExtension.cs diff --git a/src/Imagekit/Models/Files/UpdateFileDetailsRequestProperties/UpdateFileDetailsProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs b/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs similarity index 100% rename from src/Imagekit/Models/Files/UpdateFileDetailsRequestProperties/UpdateFileDetailsProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs rename to src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs diff --git a/src/Imagekit/Models/Files/UpdateFileDetailsRequestProperties/UpdateFileDetailsProperties/ExtensionProperties/RemoveBg.cs b/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/ExtensionProperties/RemoveBg.cs similarity index 100% rename from src/Imagekit/Models/Files/UpdateFileDetailsRequestProperties/UpdateFileDetailsProperties/ExtensionProperties/RemoveBg.cs rename to src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/ExtensionProperties/RemoveBg.cs diff --git a/src/Imagekit/Models/Files/UpdateFileDetailsRequestProperties/UpdateFileDetailsProperties/ExtensionProperties/RemoveBgProperties/Options.cs b/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/ExtensionProperties/RemoveBgProperties/Options.cs similarity index 100% rename from src/Imagekit/Models/Files/UpdateFileDetailsRequestProperties/UpdateFileDetailsProperties/ExtensionProperties/RemoveBgProperties/Options.cs rename to src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/ExtensionProperties/RemoveBgProperties/Options.cs diff --git a/src/Imagekit/Models/Files/UpdateFileDetailsRequestProperties/UpdateFileDetailsProperties/ExtensionVariants/All.cs b/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/ExtensionVariants/All.cs similarity index 100% rename from src/Imagekit/Models/Files/UpdateFileDetailsRequestProperties/UpdateFileDetailsProperties/ExtensionVariants/All.cs rename to src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/ExtensionVariants/All.cs diff --git a/src/Imagekit/Models/Files/UpdateFileDetailsRequestProperties/UpdateFileDetailsProperties/RemoveAITags.cs b/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/RemoveAITags.cs similarity index 100% rename from src/Imagekit/Models/Files/UpdateFileDetailsRequestProperties/UpdateFileDetailsProperties/RemoveAITags.cs rename to src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/RemoveAITags.cs diff --git a/src/Imagekit/Models/Files/UpdateFileDetailsRequestProperties/UpdateFileDetailsProperties/RemoveAITagsVariants/All.cs b/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/RemoveAITagsVariants/All.cs similarity index 100% rename from src/Imagekit/Models/Files/UpdateFileDetailsRequestProperties/UpdateFileDetailsProperties/RemoveAITagsVariants/All.cs rename to src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/RemoveAITagsVariants/All.cs diff --git a/src/Imagekit/Models/Files/UpdateFileRequestVariants/All.cs b/src/Imagekit/Models/Files/UpdateFileRequestVariants/All.cs new file mode 100644 index 00000000..84d8ce0c --- /dev/null +++ b/src/Imagekit/Models/Files/UpdateFileRequestVariants/All.cs @@ -0,0 +1,31 @@ +using System.Text.Json; +using UpdateFileRequestProperties = Imagekit.Models.Files.UpdateFileRequestProperties; + +namespace Imagekit.Models.Files.UpdateFileRequestVariants; + +public sealed record class UpdateFileDetails(UpdateFileRequestProperties::UpdateFileDetails Value) + : UpdateFileRequest, + IVariant +{ + public static UpdateFileDetails From(UpdateFileRequestProperties::UpdateFileDetails value) + { + return new(value); + } + + public override void Validate() + { + this.Value.Validate(); + } +} + +public sealed record class ChangePublicationStatus(JsonElement Value) + : UpdateFileRequest, + IVariant +{ + public static ChangePublicationStatus From(JsonElement value) + { + return new(value); + } + + public override void Validate() { } +} From 18c4aa6a58f084886562d0a3b4237cacaaf81881 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 19 Sep 2025 13:02:02 +0000 Subject: [PATCH 024/129] feat(api): manual updates --- .stats.yml | 4 +- .../Services/Files/FileServiceTest.cs | 21 +++-- .../Models/Files/UpdateFileRequest.cs | 15 +++- .../ChangePublicationStatus.cs | 54 ++++++++++++ .../Publish.cs | 85 +++++++++++++++++++ .../Files/UpdateFileRequestVariants/All.cs | 16 ++-- 6 files changed, 177 insertions(+), 18 deletions(-) create mode 100644 src/Imagekit/Models/Files/UpdateFileRequestProperties/ChangePublicationStatus.cs create mode 100644 src/Imagekit/Models/Files/UpdateFileRequestProperties/ChangePublicationStatusProperties/Publish.cs diff --git a/.stats.yml b/.stats.yml index bb4a090c..c9c84db9 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-dd864816d7f4316ae89f57394da2fd1926166d4704db5a0bb5d23461d2d75e49.yml -openapi_spec_hash: 7f7c416563a15bbaea98804ecdc1a8f9 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-d1a3e6dfc45ae832b6b14a0aef25878985c679fa9f48c1470df188b1578ba648.yml +openapi_spec_hash: 1d382866fce3284f26d341f112988d9d config_hash: 54c05a157f2cc730fac9e1df5dc3ca29 diff --git a/src/Imagekit.Tests/Services/Files/FileServiceTest.cs b/src/Imagekit.Tests/Services/Files/FileServiceTest.cs index c3d46fd1..db59412d 100644 --- a/src/Imagekit.Tests/Services/Files/FileServiceTest.cs +++ b/src/Imagekit.Tests/Services/Files/FileServiceTest.cs @@ -19,10 +19,11 @@ public async Task Update_Works() FileID = "fileId", UpdateFileRequest = new UpdateFileDetails() { - CustomCoordinates = "customCoordinates", + CustomCoordinates = "10,10,100,100", CustomMetadata = new Dictionary() { - { "foo", JsonSerializer.SerializeToElement("bar") }, + { "brand", JsonSerializer.SerializeToElement("bar") }, + { "color", JsonSerializer.SerializeToElement("bar") }, }, Description = "description", Extensions = @@ -39,19 +40,25 @@ public async Task Update_Works() }, new AutoTaggingExtension() { - MaxTags = 5, - MinConfidence = 95, + MaxTags = 10, + MinConfidence = 80, Name = Name.GoogleAutoTagging, }, + new AutoTaggingExtension() + { + MaxTags = 10, + MinConfidence = 80, + Name = Name.AwsAutoTagging, + }, new UnnamedSchemaWithArrayParent0Variants::AIAutoDescription( JsonSerializer.Deserialize( "{\"name\":\"ai-auto-description\"}" ) ), ], - RemoveAITags = new List() { "string" }, - Tags = ["car", "vehicle", "motorsports"], - WebhookURL = "https://example.com", + RemoveAITags = new List() { "car", "vehicle", "motorsports" }, + Tags = ["tag1", "tag2"], + WebhookURL = "https://webhook.site/0d6b6c7a-8e5a-4b3a-8b7c-0d6b6c7a8e5a", }, } ); diff --git a/src/Imagekit/Models/Files/UpdateFileRequest.cs b/src/Imagekit/Models/Files/UpdateFileRequest.cs index 6152360a..9663adf0 100644 --- a/src/Imagekit/Models/Files/UpdateFileRequest.cs +++ b/src/Imagekit/Models/Files/UpdateFileRequest.cs @@ -19,7 +19,7 @@ internal UpdateFileRequest() { } public static implicit operator UpdateFileRequest(UpdateFileDetails value) => new UpdateFileRequestVariants::UpdateFileDetails(value); - public static implicit operator UpdateFileRequest(JsonElement value) => + public static implicit operator UpdateFileRequest(ChangePublicationStatus value) => new UpdateFileRequestVariants::ChangePublicationStatus(value); public bool TryPickDetails([NotNullWhen(true)] out UpdateFileDetails? value) @@ -28,7 +28,9 @@ public bool TryPickDetails([NotNullWhen(true)] out UpdateFileDetails? value) return value != null; } - public bool TryPickChangePublicationStatus([NotNullWhen(true)] out JsonElement? value) + public bool TryPickChangePublicationStatus( + [NotNullWhen(true)] out ChangePublicationStatus? value + ) { value = (this as UpdateFileRequestVariants::ChangePublicationStatus)?.Value; return value != null; @@ -95,9 +97,14 @@ JsonSerializerOptions options try { - return new UpdateFileRequestVariants::ChangePublicationStatus( - JsonSerializer.Deserialize(ref reader, options) + var deserialized = JsonSerializer.Deserialize( + ref reader, + options ); + if (deserialized != null) + { + return new UpdateFileRequestVariants::ChangePublicationStatus(deserialized); + } } catch (JsonException e) { diff --git a/src/Imagekit/Models/Files/UpdateFileRequestProperties/ChangePublicationStatus.cs b/src/Imagekit/Models/Files/UpdateFileRequestProperties/ChangePublicationStatus.cs new file mode 100644 index 00000000..153d1de7 --- /dev/null +++ b/src/Imagekit/Models/Files/UpdateFileRequestProperties/ChangePublicationStatus.cs @@ -0,0 +1,54 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files.UpdateFileRequestProperties.ChangePublicationStatusProperties; + +namespace Imagekit.Models.Files.UpdateFileRequestProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class ChangePublicationStatus : ModelBase, IFromRaw +{ + /// + /// Configure the publication status of a file and its versions. + /// + public Publish? Publish + { + get + { + if (!this.Properties.TryGetValue("publish", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["publish"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.Publish?.Validate(); + } + + public ChangePublicationStatus() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ChangePublicationStatus(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static ChangePublicationStatus FromRawUnchecked( + Dictionary properties + ) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/UpdateFileRequestProperties/ChangePublicationStatusProperties/Publish.cs b/src/Imagekit/Models/Files/UpdateFileRequestProperties/ChangePublicationStatusProperties/Publish.cs new file mode 100644 index 00000000..6a330fe0 --- /dev/null +++ b/src/Imagekit/Models/Files/UpdateFileRequestProperties/ChangePublicationStatusProperties/Publish.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.UpdateFileRequestProperties.ChangePublicationStatusProperties; + +/// +/// Configure the publication status of a file and its versions. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class Publish : ModelBase, IFromRaw +{ + /// + /// Set to `true` to publish the file. Set to `false` to unpublish the file. + /// + public required bool IsPublished + { + get + { + if (!this.Properties.TryGetValue("isPublished", out JsonElement element)) + throw new ArgumentOutOfRangeException("isPublished", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["isPublished"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Set to `true` to publish/unpublish all versions of the file. Set to `false` + /// to publish/unpublish only the current version of the file. + /// + public bool? IncludeFileVersions + { + get + { + if (!this.Properties.TryGetValue("includeFileVersions", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["includeFileVersions"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.IsPublished; + _ = this.IncludeFileVersions; + } + + public Publish() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Publish(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Publish FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public Publish(bool isPublished) + : this() + { + this.IsPublished = isPublished; + } +} diff --git a/src/Imagekit/Models/Files/UpdateFileRequestVariants/All.cs b/src/Imagekit/Models/Files/UpdateFileRequestVariants/All.cs index 84d8ce0c..70db1b61 100644 --- a/src/Imagekit/Models/Files/UpdateFileRequestVariants/All.cs +++ b/src/Imagekit/Models/Files/UpdateFileRequestVariants/All.cs @@ -1,4 +1,3 @@ -using System.Text.Json; using UpdateFileRequestProperties = Imagekit.Models.Files.UpdateFileRequestProperties; namespace Imagekit.Models.Files.UpdateFileRequestVariants; @@ -18,14 +17,21 @@ public override void Validate() } } -public sealed record class ChangePublicationStatus(JsonElement Value) +public sealed record class ChangePublicationStatus( + UpdateFileRequestProperties::ChangePublicationStatus Value +) : UpdateFileRequest, - IVariant + IVariant { - public static ChangePublicationStatus From(JsonElement value) + public static ChangePublicationStatus From( + UpdateFileRequestProperties::ChangePublicationStatus value + ) { return new(value); } - public override void Validate() { } + public override void Validate() + { + this.Value.Validate(); + } } From 8f803dc6a878ba5b16c68f16e8d84e507e1a95dd Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 28 Jan 2026 17:57:04 +0000 Subject: [PATCH 025/129] feat(api): manual updates --- .stats.yml | 2 +- README.md | 4 +- src/Imagekit.Tests/TestBase.cs | 42 +++--- src/Imagekit/IImageKitClient.cs | 112 +++++++-------- src/Imagekit/ImageKitClient.cs | 232 ++++++++++++++++---------------- src/Imagekit/ParamsBase.cs | 6 +- 6 files changed, 198 insertions(+), 200 deletions(-) diff --git a/.stats.yml b/.stats.yml index c9c84db9..00fd95da 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-d1a3e6dfc45ae832b6b14a0aef25878985c679fa9f48c1470df188b1578ba648.yml openapi_spec_hash: 1d382866fce3284f26d341f112988d9d -config_hash: 54c05a157f2cc730fac9e1df5dc3ca29 +config_hash: 29a2351fe2be89392b15719be8bc964f diff --git a/README.md b/README.md index 22709ca0..977de7e3 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ using Imagekit; ImageKitClient client = new() { - PrivateAPIKey = "My Private API Key", + PrivateKey = "My Private Key", Password = "My Password", }; ``` @@ -79,7 +79,7 @@ See this table for the available options: | Property | Environment variable | Required | Default value | | --------------- | -------------------------------- | -------- | --------------------------- | -| `PrivateAPIKey` | `IMAGEKIT_PRIVATE_API_KEY` | true | - | +| `PrivateKey` | `IMAGEKIT_PRIVATE_API_KEY` | true | - | | `Password` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` | | `WebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - | | `BaseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` | diff --git a/src/Imagekit.Tests/TestBase.cs b/src/Imagekit.Tests/TestBase.cs index a045d668..55cb514b 100644 --- a/src/Imagekit.Tests/TestBase.cs +++ b/src/Imagekit.Tests/TestBase.cs @@ -1,21 +1,21 @@ -using System; -using Imagekit; - -namespace Imagekit.Tests; - -public class TestBase -{ - protected IImageKitClient client; - - public TestBase() - { - client = new ImageKitClient() - { - BaseUrl = new Uri( - Environment.GetEnvironmentVariable("TEST_API_BASE_URL") ?? "http://localhost:4010" - ), - PrivateAPIKey = "My Private API Key", - Password = "My Password", - }; - } -} +using System; +using Imagekit; + +namespace Imagekit.Tests; + +public class TestBase +{ + protected IImageKitClient client; + + public TestBase() + { + client = new ImageKitClient() + { + BaseUrl = new Uri( + Environment.GetEnvironmentVariable("TEST_API_BASE_URL") ?? "http://localhost:4010" + ), + PrivateKey = "My Private Key", + Password = "My Password", + }; + } +} diff --git a/src/Imagekit/IImageKitClient.cs b/src/Imagekit/IImageKitClient.cs index 784f4b94..2a6ced90 100644 --- a/src/Imagekit/IImageKitClient.cs +++ b/src/Imagekit/IImageKitClient.cs @@ -1,56 +1,56 @@ -using System; -using System.Net.Http; -using Imagekit.Services.Accounts; -using Imagekit.Services.Assets; -using Imagekit.Services.Beta; -using Imagekit.Services.Cache; -using Imagekit.Services.CustomMetadataFields; -using Imagekit.Services.Files; -using Imagekit.Services.Folders; -using Imagekit.Services.Webhooks; - -namespace Imagekit; - -public interface IImageKitClient -{ - HttpClient HttpClient { get; init; } - - Uri BaseUrl { get; init; } - - /// - /// Your ImageKit private API key (it starts with `private_`). You can view and - /// manage API keys in the [dashboard](https://imagekit.io/dashboard/developer/api-keys). - /// - string PrivateAPIKey { get; init; } - - /// - /// ImageKit Basic Auth only uses the username field and ignores the password. - /// This field is unused. - /// - string? Password { get; init; } - - /// - /// Your ImageKit webhook secret. This is used by the SDK to verify webhook signatures. - /// It starts with a `whsec_` prefix. You can view and manage your webhook secret - /// in the [dashboard](https://imagekit.io/dashboard/developer/webhooks). Treat - /// the secret like a password, keep it private and do not expose it publicly. - /// Learn more about [webhook verification](https://imagekit.io/docs/webhooks#verify-webhook-signature). - /// - string? WebhookSecret { get; init; } - - ICustomMetadataFieldService CustomMetadataFields { get; } - - IFileService Files { get; } - - IAssetService Assets { get; } - - ICacheService Cache { get; } - - IFolderService Folders { get; } - - IAccountService Accounts { get; } - - IBetaService Beta { get; } - - IWebhookService Webhooks { get; } -} +using System; +using System.Net.Http; +using Imagekit.Services.Accounts; +using Imagekit.Services.Assets; +using Imagekit.Services.Beta; +using Imagekit.Services.Cache; +using Imagekit.Services.CustomMetadataFields; +using Imagekit.Services.Files; +using Imagekit.Services.Folders; +using Imagekit.Services.Webhooks; + +namespace Imagekit; + +public interface IImageKitClient +{ + HttpClient HttpClient { get; init; } + + Uri BaseUrl { get; init; } + + /// + /// Your ImageKit private API key (it starts with `private_`). You can view and + /// manage API keys in the [dashboard](https://imagekit.io/dashboard/developer/api-keys). + /// + string PrivateKey { get; init; } + + /// + /// ImageKit Basic Auth only uses the `private_key` as username and ignores the + /// password. + /// + string? Password { get; init; } + + /// + /// Your ImageKit webhook secret. This is used by the SDK to verify webhook signatures. + /// It starts with a `whsec_` prefix. You can view and manage your webhook secret + /// in the [dashboard](https://imagekit.io/dashboard/developer/webhooks). Treat + /// the secret like a password, keep it private and do not expose it publicly. + /// Learn more about [webhook verification](https://imagekit.io/docs/webhooks#verify-webhook-signature). + /// + string? WebhookSecret { get; init; } + + ICustomMetadataFieldService CustomMetadataFields { get; } + + IFileService Files { get; } + + IAssetService Assets { get; } + + ICacheService Cache { get; } + + IFolderService Folders { get; } + + IAccountService Accounts { get; } + + IBetaService Beta { get; } + + IWebhookService Webhooks { get; } +} diff --git a/src/Imagekit/ImageKitClient.cs b/src/Imagekit/ImageKitClient.cs index 73466d00..8533bd1e 100644 --- a/src/Imagekit/ImageKitClient.cs +++ b/src/Imagekit/ImageKitClient.cs @@ -1,116 +1,116 @@ -using System; -using System.Net.Http; -using Imagekit.Services.Accounts; -using Imagekit.Services.Assets; -using Imagekit.Services.Beta; -using Imagekit.Services.Cache; -using Imagekit.Services.CustomMetadataFields; -using Imagekit.Services.Files; -using Imagekit.Services.Folders; -using Imagekit.Services.Webhooks; - -namespace Imagekit; - -public sealed class ImageKitClient : IImageKitClient -{ - public HttpClient HttpClient { get; init; } = new(); - - Lazy _baseUrl = new(() => - new Uri( - Environment.GetEnvironmentVariable("IMAGE_KIT_BASE_URL") ?? "https://api.imagekit.io" - ) - ); - public Uri BaseUrl - { - get { return _baseUrl.Value; } - init { _baseUrl = new(() => value); } - } - - Lazy _privateAPIKey = new(() => - Environment.GetEnvironmentVariable("IMAGEKIT_PRIVATE_API_KEY") - ?? throw new ArgumentNullException(nameof(PrivateAPIKey)) - ); - public string PrivateAPIKey - { - get { return _privateAPIKey.Value; } - init { _privateAPIKey = new(() => value); } - } - - Lazy _password = new(() => - Environment.GetEnvironmentVariable("OPTIONAL_IMAGEKIT_IGNORES_THIS") ?? "do_not_set" - ); - public string? Password - { - get { return _password.Value; } - init { _password = new(() => value); } - } - - Lazy _webhookSecret = new(() => - Environment.GetEnvironmentVariable("IMAGEKIT_WEBHOOK_SECRET") - ); - public string? WebhookSecret - { - get { return _webhookSecret.Value; } - init { _webhookSecret = new(() => value); } - } - - readonly Lazy _customMetadataFields; - public ICustomMetadataFieldService CustomMetadataFields - { - get { return _customMetadataFields.Value; } - } - - readonly Lazy _files; - public IFileService Files - { - get { return _files.Value; } - } - - readonly Lazy _assets; - public IAssetService Assets - { - get { return _assets.Value; } - } - - readonly Lazy _cache; - public ICacheService Cache - { - get { return _cache.Value; } - } - - readonly Lazy _folders; - public IFolderService Folders - { - get { return _folders.Value; } - } - - readonly Lazy _accounts; - public IAccountService Accounts - { - get { return _accounts.Value; } - } - - readonly Lazy _beta; - public IBetaService Beta - { - get { return _beta.Value; } - } - - readonly Lazy _webhooks; - public IWebhookService Webhooks - { - get { return _webhooks.Value; } - } - - public ImageKitClient() - { - _customMetadataFields = new(() => new CustomMetadataFieldService(this)); - _files = new(() => new FileService(this)); - _assets = new(() => new AssetService(this)); - _cache = new(() => new CacheService(this)); - _folders = new(() => new FolderService(this)); - _accounts = new(() => new AccountService(this)); - _beta = new(() => new BetaService(this)); - _webhooks = new(() => new WebhookService(this)); - } -} +using System; +using System.Net.Http; +using Imagekit.Services.Accounts; +using Imagekit.Services.Assets; +using Imagekit.Services.Beta; +using Imagekit.Services.Cache; +using Imagekit.Services.CustomMetadataFields; +using Imagekit.Services.Files; +using Imagekit.Services.Folders; +using Imagekit.Services.Webhooks; + +namespace Imagekit; + +public sealed class ImageKitClient : IImageKitClient +{ + public HttpClient HttpClient { get; init; } = new(); + + Lazy _baseUrl = new(() => + new Uri( + Environment.GetEnvironmentVariable("IMAGE_KIT_BASE_URL") ?? "https://api.imagekit.io" + ) + ); + public Uri BaseUrl + { + get { return _baseUrl.Value; } + init { _baseUrl = new(() => value); } + } + + Lazy _privateKey = new(() => + Environment.GetEnvironmentVariable("IMAGEKIT_PRIVATE_API_KEY") + ?? throw new ArgumentNullException(nameof(PrivateKey)) + ); + public string PrivateKey + { + get { return _privateKey.Value; } + init { _privateKey = new(() => value); } + } + + Lazy _password = new(() => + Environment.GetEnvironmentVariable("OPTIONAL_IMAGEKIT_IGNORES_THIS") ?? "do_not_set" + ); + public string? Password + { + get { return _password.Value; } + init { _password = new(() => value); } + } + + Lazy _webhookSecret = new(() => + Environment.GetEnvironmentVariable("IMAGEKIT_WEBHOOK_SECRET") + ); + public string? WebhookSecret + { + get { return _webhookSecret.Value; } + init { _webhookSecret = new(() => value); } + } + + readonly Lazy _customMetadataFields; + public ICustomMetadataFieldService CustomMetadataFields + { + get { return _customMetadataFields.Value; } + } + + readonly Lazy _files; + public IFileService Files + { + get { return _files.Value; } + } + + readonly Lazy _assets; + public IAssetService Assets + { + get { return _assets.Value; } + } + + readonly Lazy _cache; + public ICacheService Cache + { + get { return _cache.Value; } + } + + readonly Lazy _folders; + public IFolderService Folders + { + get { return _folders.Value; } + } + + readonly Lazy _accounts; + public IAccountService Accounts + { + get { return _accounts.Value; } + } + + readonly Lazy _beta; + public IBetaService Beta + { + get { return _beta.Value; } + } + + readonly Lazy _webhooks; + public IWebhookService Webhooks + { + get { return _webhooks.Value; } + } + + public ImageKitClient() + { + _customMetadataFields = new(() => new CustomMetadataFieldService(this)); + _files = new(() => new FileService(this)); + _assets = new(() => new AssetService(this)); + _cache = new(() => new CacheService(this)); + _folders = new(() => new FolderService(this)); + _accounts = new(() => new AccountService(this)); + _beta = new(() => new BetaService(this)); + _webhooks = new(() => new WebhookService(this)); + } +} diff --git a/src/Imagekit/ParamsBase.cs b/src/Imagekit/ParamsBase.cs index da9602e9..3a2e56af 100644 --- a/src/Imagekit/ParamsBase.cs +++ b/src/Imagekit/ParamsBase.cs @@ -149,7 +149,7 @@ protected string QueryString(IImageKitClient client) protected static void AddDefaultHeaders(HttpRequestMessage request, IImageKitClient client) { - if (client.PrivateAPIKey != null && client.Password != null) + if (client.PrivateKey != null && client.Password != null) { request.Headers.Add( "Authorization", @@ -158,9 +158,7 @@ protected static void AddDefaultHeaders(HttpRequestMessage request, IImageKitCli Convert.ToBase64String( Encoding .GetEncoding("ISO-8859-1") - .GetBytes( - string.Format("{0}:{1}", client.PrivateAPIKey, client.Password) - ) + .GetBytes(string.Format("{0}:{1}", client.PrivateKey, client.Password)) ) ) ); From a5aa0191ba84c42d6427904e0b84a55b8504e5e5 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 19 Sep 2025 13:45:22 +0000 Subject: [PATCH 026/129] feat(api): manual updates --- .stats.yml | 2 +- src/Imagekit/IImageKitClient.cs | 22 +++++++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/.stats.yml b/.stats.yml index 00fd95da..d3fcabb4 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-d1a3e6dfc45ae832b6b14a0aef25878985c679fa9f48c1470df188b1578ba648.yml openapi_spec_hash: 1d382866fce3284f26d341f112988d9d -config_hash: 29a2351fe2be89392b15719be8bc964f +config_hash: c9c7bed2a4341f915a2dc85958ce7f0e diff --git a/src/Imagekit/IImageKitClient.cs b/src/Imagekit/IImageKitClient.cs index 2a6ced90..8b39f99e 100644 --- a/src/Imagekit/IImageKitClient.cs +++ b/src/Imagekit/IImageKitClient.cs @@ -18,23 +18,27 @@ public interface IImageKitClient Uri BaseUrl { get; init; } /// - /// Your ImageKit private API key (it starts with `private_`). You can view and - /// manage API keys in the [dashboard](https://imagekit.io/dashboard/developer/api-keys). + /// Your ImageKit private API key (starts with `private_`). You can find this + /// in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/api-keys). /// string PrivateKey { get; init; } /// - /// ImageKit Basic Auth only uses the `private_key` as username and ignores the - /// password. + /// Leave this field unset. ImageKit uses Basic Authentication scheme that requires + /// the `private_key` as the username and empty string as the password. The password + /// field is automatically managed by the SDK and should not be set. /// string? Password { get; init; } /// - /// Your ImageKit webhook secret. This is used by the SDK to verify webhook signatures. - /// It starts with a `whsec_` prefix. You can view and manage your webhook secret - /// in the [dashboard](https://imagekit.io/dashboard/developer/webhooks). Treat - /// the secret like a password, keep it private and do not expose it publicly. - /// Learn more about [webhook verification](https://imagekit.io/docs/webhooks#verify-webhook-signature). + /// Your ImageKit webhook secret used by the SDK to verify webhook signatures + /// for security. This secret starts with a `whsec_` prefix and is essential for + /// webhook verification. You can view and manage your webhook secret in the + /// [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks). + /// + /// **Security Note**: Treat this secret like a password - keep it private and + /// never expose it publicly. This field is optional and only required if you + /// plan to use webhook signature verification. Learn more about [webhook verification](https://imagekit.io/docs/webhooks#verify-webhook-signature). /// string? WebhookSecret { get; init; } From e5be541283d8c3fa0c54109c1a21a0ec044c2c1b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 19 Sep 2025 13:51:52 +0000 Subject: [PATCH 027/129] feat(api): manual updates --- .stats.yml | 2 +- src/Imagekit/IImageKitClient.cs | 16 +++++----------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/.stats.yml b/.stats.yml index d3fcabb4..ee45f3d5 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-d1a3e6dfc45ae832b6b14a0aef25878985c679fa9f48c1470df188b1578ba648.yml openapi_spec_hash: 1d382866fce3284f26d341f112988d9d -config_hash: c9c7bed2a4341f915a2dc85958ce7f0e +config_hash: 51a9632be24fc533ad69a5bd56934651 diff --git a/src/Imagekit/IImageKitClient.cs b/src/Imagekit/IImageKitClient.cs index 8b39f99e..63cadd53 100644 --- a/src/Imagekit/IImageKitClient.cs +++ b/src/Imagekit/IImageKitClient.cs @@ -24,21 +24,15 @@ public interface IImageKitClient string PrivateKey { get; init; } /// - /// Leave this field unset. ImageKit uses Basic Authentication scheme that requires - /// the `private_key` as the username and empty string as the password. The password - /// field is automatically managed by the SDK and should not be set. + /// ImageKit uses your API key as username and ignores the password. The SDK + /// sets a dummy value. You can ignore this field. /// string? Password { get; init; } /// - /// Your ImageKit webhook secret used by the SDK to verify webhook signatures - /// for security. This secret starts with a `whsec_` prefix and is essential for - /// webhook verification. You can view and manage your webhook secret in the - /// [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks). - /// - /// **Security Note**: Treat this secret like a password - keep it private and - /// never expose it publicly. This field is optional and only required if you - /// plan to use webhook signature verification. Learn more about [webhook verification](https://imagekit.io/docs/webhooks#verify-webhook-signature). + /// Your ImageKit webhook secret for verifying webhook signatures (starts with + /// `whsec_`). You can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks). + /// Only required if you're using webhooks. /// string? WebhookSecret { get; init; } From 07bd820f7ad0352f08c574bbec421b147ec04095 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 20 Sep 2025 08:05:07 +0000 Subject: [PATCH 028/129] feat(api): Update env var name --- .stats.yml | 2 +- README.md | 6 +++--- src/Imagekit/ImageKitClient.cs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.stats.yml b/.stats.yml index ee45f3d5..0f9a4aa3 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-d1a3e6dfc45ae832b6b14a0aef25878985c679fa9f48c1470df188b1578ba648.yml openapi_spec_hash: 1d382866fce3284f26d341f112988d9d -config_hash: 51a9632be24fc533ad69a5bd56934651 +config_hash: f1fafe5e607e996b58b67fd1dd3e74fa diff --git a/README.md b/README.md index 977de7e3..74fbb1a9 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ using System; using Imagekit; using Imagekit.Models.Files; -// Configured using the IMAGEKIT_PRIVATE_API_KEY, OPTIONAL_IMAGEKIT_IGNORES_THIS, IMAGEKIT_WEBHOOK_SECRET and IMAGE_KIT_BASE_URL environment variables +// Configured using the IMAGEKIT_PRIVATE_KEY, OPTIONAL_IMAGEKIT_IGNORES_THIS, IMAGEKIT_WEBHOOK_SECRET and IMAGE_KIT_BASE_URL environment variables ImageKitClient client = new(); FileUploadParams parameters = new() @@ -57,7 +57,7 @@ Configure the client using environment variables: ```csharp using Imagekit; -// Configured using the IMAGEKIT_PRIVATE_API_KEY, OPTIONAL_IMAGEKIT_IGNORES_THIS, IMAGEKIT_WEBHOOK_SECRET and IMAGE_KIT_BASE_URL environment variables +// Configured using the IMAGEKIT_PRIVATE_KEY, OPTIONAL_IMAGEKIT_IGNORES_THIS, IMAGEKIT_WEBHOOK_SECRET and IMAGE_KIT_BASE_URL environment variables ImageKitClient client = new(); ``` @@ -79,7 +79,7 @@ See this table for the available options: | Property | Environment variable | Required | Default value | | --------------- | -------------------------------- | -------- | --------------------------- | -| `PrivateKey` | `IMAGEKIT_PRIVATE_API_KEY` | true | - | +| `PrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - | | `Password` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` | | `WebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - | | `BaseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` | diff --git a/src/Imagekit/ImageKitClient.cs b/src/Imagekit/ImageKitClient.cs index 8533bd1e..dc889f81 100644 --- a/src/Imagekit/ImageKitClient.cs +++ b/src/Imagekit/ImageKitClient.cs @@ -27,7 +27,7 @@ public Uri BaseUrl } Lazy _privateKey = new(() => - Environment.GetEnvironmentVariable("IMAGEKIT_PRIVATE_API_KEY") + Environment.GetEnvironmentVariable("IMAGEKIT_PRIVATE_KEY") ?? throw new ArgumentNullException(nameof(PrivateKey)) ); public string PrivateKey From 73f6625fa7a36186824fd9252d95428a798c1ba1 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 20 Sep 2025 09:23:44 +0000 Subject: [PATCH 029/129] feat(api): update api docs link --- .stats.yml | 2 +- README.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.stats.yml b/.stats.yml index 0f9a4aa3..7dfc3c2a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-d1a3e6dfc45ae832b6b14a0aef25878985c679fa9f48c1470df188b1578ba648.yml openapi_spec_hash: 1d382866fce3284f26d341f112988d9d -config_hash: f1fafe5e607e996b58b67fd1dd3e74fa +config_hash: 5f7498f5ea66e8a544c6c37b10f77467 diff --git a/README.md b/README.md index 74fbb1a9..2d404176 100644 --- a/README.md +++ b/README.md @@ -7,11 +7,11 @@ > > **We'd love your feedback!** Please share any suggestions, bug reports, feature requests, or general thoughts by [filing an issue](https://www.github.com/imagekit-developer/imagekit-dotnet/issues/new). -The Image Kit C# SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs) from applications written in C#. +The Image Kit C# SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in C#. It is generated with [Stainless](https://www.stainless.com/). -The REST API documentation can be found on [imagekit.io](https://imagekit.io/docs). +The REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). ## Installation From ad835287843cf028cd20018636e10dccacf2ba91 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 20 Sep 2025 09:25:05 +0000 Subject: [PATCH 030/129] feat(api): remove Stainless attribution from readme --- .stats.yml | 2 +- README.md | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.stats.yml b/.stats.yml index 7dfc3c2a..e1604c7a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-d1a3e6dfc45ae832b6b14a0aef25878985c679fa9f48c1470df188b1578ba648.yml openapi_spec_hash: 1d382866fce3284f26d341f112988d9d -config_hash: 5f7498f5ea66e8a544c6c37b10f77467 +config_hash: ff23f46fe08ef3f43c57c8cf13eff3a1 diff --git a/README.md b/README.md index 2d404176..bbe1f589 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,6 @@ The Image Kit C# SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in C#. -It is generated with [Stainless](https://www.stainless.com/). - The REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). ## Installation From a25748b0ff0bf97dbe7e5410dcdecf098e79c423 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sun, 21 Sep 2025 03:10:01 +0000 Subject: [PATCH 031/129] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index e1604c7a..031fed99 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-d1a3e6dfc45ae832b6b14a0aef25878985c679fa9f48c1470df188b1578ba648.yml openapi_spec_hash: 1d382866fce3284f26d341f112988d9d -config_hash: ff23f46fe08ef3f43c57c8cf13eff3a1 +config_hash: d57f3c7c581048428b41398f30da8b9b From 3692348fb7fb0233b9e56029fb617f34a8aaf0b2 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 22 Sep 2025 12:33:52 +0000 Subject: [PATCH 032/129] feat(api): manual updates --- .release-please-manifest.json | 3 -- .stats.yml | 2 +- README.md | 8 ++-- release-please-config.json | 71 ----------------------------------- src/Imagekit/Imagekit.csproj | 2 +- 5 files changed, 6 insertions(+), 80 deletions(-) delete mode 100644 .release-please-manifest.json delete mode 100644 release-please-config.json diff --git a/.release-please-manifest.json b/.release-please-manifest.json deleted file mode 100644 index 1332969b..00000000 --- a/.release-please-manifest.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - ".": "0.0.1" -} \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 031fed99..7c3aae1c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-d1a3e6dfc45ae832b6b14a0aef25878985c679fa9f48c1470df188b1578ba648.yml openapi_spec_hash: 1d382866fce3284f26d341f112988d9d -config_hash: d57f3c7c581048428b41398f30da8b9b +config_hash: e42d7fc3a8c92c35099cc283f9a4467a diff --git a/README.md b/README.md index bbe1f589..df4f4913 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ > > This library has not yet been exhaustively tested in production environments and may be missing some features you'd expect in a stable release. As we continue development, there may be breaking changes that require updates to your code. > -> **We'd love your feedback!** Please share any suggestions, bug reports, feature requests, or general thoughts by [filing an issue](https://www.github.com/imagekit-developer/imagekit-dotnet/issues/new). +> **We'd love your feedback!** Please share any suggestions, bug reports, feature requests, or general thoughts by [filing an issue](https://www.github.com/stainless-sdks/imagekit-csharp/issues/new). The Image Kit C# SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in C#. @@ -14,8 +14,8 @@ The REST API documentation can be found on [imagekit.io](https://imagekit.io/doc ## Installation ```bash -git clone git@github.com:imagekit-developer/imagekit-dotnet.git -dotnet add reference imagekit-dotnet/src/Imagekit +git clone git@github.com:stainless-sdks/imagekit-csharp.git +dotnet add reference imagekit-csharp/src/Imagekit ``` ## Requirements @@ -97,4 +97,4 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience. -We are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-dotnet/issues) with questions, bugs, or suggestions. +We are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/imagekit-csharp/issues) with questions, bugs, or suggestions. diff --git a/release-please-config.json b/release-please-config.json deleted file mode 100644 index 66eb8d5c..00000000 --- a/release-please-config.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "packages": { - ".": {} - }, - "$schema": "https://raw.githubusercontent.com/stainless-api/release-please/main/schemas/config.json", - "include-v-in-tag": true, - "include-component-in-tag": false, - "versioning": "prerelease", - "prerelease": true, - "bump-minor-pre-major": true, - "bump-patch-for-minor-pre-major": false, - "pull-request-header": "Automated Release PR", - "pull-request-title-pattern": "release: ${version}", - "changelog-sections": [ - { - "type": "feat", - "section": "Features" - }, - { - "type": "fix", - "section": "Bug Fixes" - }, - { - "type": "perf", - "section": "Performance Improvements" - }, - { - "type": "revert", - "section": "Reverts" - }, - { - "type": "chore", - "section": "Chores" - }, - { - "type": "docs", - "section": "Documentation" - }, - { - "type": "style", - "section": "Styles" - }, - { - "type": "refactor", - "section": "Refactors" - }, - { - "type": "test", - "section": "Tests", - "hidden": true - }, - { - "type": "build", - "section": "Build System" - }, - { - "type": "ci", - "section": "Continuous Integration", - "hidden": true - } - ], - "release-type": "simple", - "extra-files": [ - "README.md", - { - "type": "xml", - "path": "src/Imagekit/Imagekit.csproj", - "xpath": "//Project/PropertyGroup/VersionPrefix" - } - ] -} \ No newline at end of file diff --git a/src/Imagekit/Imagekit.csproj b/src/Imagekit/Imagekit.csproj index 0d709b38..042a3402 100644 --- a/src/Imagekit/Imagekit.csproj +++ b/src/Imagekit/Imagekit.csproj @@ -12,7 +12,7 @@ true README.md - https://www.github.com/imagekit-developer/imagekit-dotnet + https://www.github.com/stainless-sdks/imagekit-csharp git true From 11c74cca1bf612f470f91445006867addf0c31cb Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 28 Jan 2026 17:58:07 +0000 Subject: [PATCH 033/129] chore: improve example values --- .../CustomMetadataFieldServiceTest.cs | 118 +++++++++--------- .../Services/Files/Bulk/BulkServiceTest.cs | 94 ++++++++------ .../Services/Folders/FolderServiceTest.cs | 114 ++++++++--------- 3 files changed, 170 insertions(+), 156 deletions(-) diff --git a/src/Imagekit.Tests/Services/CustomMetadataFields/CustomMetadataFieldServiceTest.cs b/src/Imagekit.Tests/Services/CustomMetadataFields/CustomMetadataFieldServiceTest.cs index 645b10df..ec7675df 100644 --- a/src/Imagekit.Tests/Services/CustomMetadataFields/CustomMetadataFieldServiceTest.cs +++ b/src/Imagekit.Tests/Services/CustomMetadataFields/CustomMetadataFieldServiceTest.cs @@ -1,59 +1,59 @@ -using System.Threading.Tasks; -using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties; - -namespace Imagekit.Tests.Services.CustomMetadataFields; - -public class CustomMetadataFieldServiceTest : TestBase -{ - [Fact(Skip = "Prism tests are disabled")] - public async Task Create_Works() - { - var customMetadataField = await this.client.CustomMetadataFields.Create( - new() - { - Label = "label", - Name = "name", - Schema = new() - { - Type = Type.Text, - DefaultValue = "string", - IsValueRequired = true, - MaxLength = 0, - MaxValue = "string", - MinLength = 0, - MinValue = "string", - SelectOptions = ["small", "medium", "large", 30, 40, true], - }, - } - ); - customMetadataField.Validate(); - } - - [Fact(Skip = "Prism tests are disabled")] - public async Task Update_Works() - { - var customMetadataField = await this.client.CustomMetadataFields.Update( - new() { ID = "id" } - ); - customMetadataField.Validate(); - } - - [Fact(Skip = "Prism tests are disabled")] - public async Task List_Works() - { - var customMetadataFields = await this.client.CustomMetadataFields.List(); - foreach (var item in customMetadataFields) - { - item.Validate(); - } - } - - [Fact(Skip = "Prism tests are disabled")] - public async Task Delete_Works() - { - var customMetadataField = await this.client.CustomMetadataFields.Delete( - new() { ID = "id" } - ); - customMetadataField.Validate(); - } -} +using System.Threading.Tasks; +using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties; + +namespace Imagekit.Tests.Services.CustomMetadataFields; + +public class CustomMetadataFieldServiceTest : TestBase +{ + [Fact(Skip = "Prism tests are disabled")] + public async Task Create_Works() + { + var customMetadataField = await this.client.CustomMetadataFields.Create( + new() + { + Label = "price", + Name = "price", + Schema = new() + { + Type = Type.Number, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = 3000, + MinLength = 0, + MinValue = 1000, + SelectOptions = ["small", "medium", "large", 30, 40, true], + }, + } + ); + customMetadataField.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Update_Works() + { + var customMetadataField = await this.client.CustomMetadataFields.Update( + new() { ID = "id" } + ); + customMetadataField.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task List_Works() + { + var customMetadataFields = await this.client.CustomMetadataFields.List(); + foreach (var item in customMetadataFields) + { + item.Validate(); + } + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Delete_Works() + { + var customMetadataField = await this.client.CustomMetadataFields.Delete( + new() { ID = "id" } + ); + customMetadataField.Validate(); + } +} diff --git a/src/Imagekit.Tests/Services/Files/Bulk/BulkServiceTest.cs b/src/Imagekit.Tests/Services/Files/Bulk/BulkServiceTest.cs index 76a30ceb..b7645de3 100644 --- a/src/Imagekit.Tests/Services/Files/Bulk/BulkServiceTest.cs +++ b/src/Imagekit.Tests/Services/Files/Bulk/BulkServiceTest.cs @@ -1,40 +1,54 @@ -using System.Threading.Tasks; - -namespace Imagekit.Tests.Services.Files.Bulk; - -public class BulkServiceTest : TestBase -{ - [Fact(Skip = "Prism tests are disabled")] - public async Task Delete_Works() - { - var bulk = await this.client.Files.Bulk.Delete(new() { FileIDs = ["string"] }); - bulk.Validate(); - } - - [Fact(Skip = "Prism tests are disabled")] - public async Task AddTags_Works() - { - var response = await this.client.Files.Bulk.AddTags( - new() { FileIDs = ["string"], Tags = ["string"] } - ); - response.Validate(); - } - - [Fact(Skip = "Prism tests are disabled")] - public async Task RemoveAITags_Works() - { - var response = await this.client.Files.Bulk.RemoveAITags( - new() { AITags = ["string"], FileIDs = ["string"] } - ); - response.Validate(); - } - - [Fact(Skip = "Prism tests are disabled")] - public async Task RemoveTags_Works() - { - var response = await this.client.Files.Bulk.RemoveTags( - new() { FileIDs = ["string"], Tags = ["string"] } - ); - response.Validate(); - } -} +using System.Threading.Tasks; + +namespace Imagekit.Tests.Services.Files.Bulk; + +public class BulkServiceTest : TestBase +{ + [Fact(Skip = "Prism tests are disabled")] + public async Task Delete_Works() + { + var bulk = await this.client.Files.Bulk.Delete( + new() { FileIDs = ["598821f949c0a938d57563bd", "598821f949c0a938d57563be"] } + ); + bulk.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task AddTags_Works() + { + var response = await this.client.Files.Bulk.AddTags( + new() + { + FileIDs = ["598821f949c0a938d57563bd", "598821f949c0a938d57563be"], + Tags = ["t-shirt", "round-neck", "sale2019"], + } + ); + response.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task RemoveAITags_Works() + { + var response = await this.client.Files.Bulk.RemoveAITags( + new() + { + AITags = ["t-shirt", "round-neck", "sale2019"], + FileIDs = ["598821f949c0a938d57563bd", "598821f949c0a938d57563be"], + } + ); + response.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task RemoveTags_Works() + { + var response = await this.client.Files.Bulk.RemoveTags( + new() + { + FileIDs = ["598821f949c0a938d57563bd", "598821f949c0a938d57563be"], + Tags = ["t-shirt", "round-neck", "sale2019"], + } + ); + response.Validate(); + } +} diff --git a/src/Imagekit.Tests/Services/Folders/FolderServiceTest.cs b/src/Imagekit.Tests/Services/Folders/FolderServiceTest.cs index 21dcc7f5..99b33c2a 100644 --- a/src/Imagekit.Tests/Services/Folders/FolderServiceTest.cs +++ b/src/Imagekit.Tests/Services/Folders/FolderServiceTest.cs @@ -1,57 +1,57 @@ -using System.Threading.Tasks; - -namespace Imagekit.Tests.Services.Folders; - -public class FolderServiceTest : TestBase -{ - [Fact(Skip = "Prism tests are disabled")] - public async Task Create_Works() - { - var folder = await this.client.Folders.Create( - new() { FolderName = "folderName", ParentFolderPath = "parentFolderPath" } - ); - folder.Validate(); - } - - [Fact(Skip = "Prism tests are disabled")] - public async Task Delete_Works() - { - var folder = await this.client.Folders.Delete(new() { FolderPath = "folderPath" }); - folder.Validate(); - } - - [Fact(Skip = "Prism tests are disabled")] - public async Task Copy_Works() - { - var response = await this.client.Folders.Copy( - new() - { - DestinationPath = "/path/of/destination/folder", - SourceFolderPath = "/path/of/source/folder", - } - ); - response.Validate(); - } - - [Fact(Skip = "Prism tests are disabled")] - public async Task Move_Works() - { - var response = await this.client.Folders.Move( - new() - { - DestinationPath = "/path/of/destination/folder", - SourceFolderPath = "/path/of/source/folder", - } - ); - response.Validate(); - } - - [Fact(Skip = "Prism tests are disabled")] - public async Task Rename_Works() - { - var response = await this.client.Folders.Rename( - new() { FolderPath = "/path/of/folder", NewFolderName = "new-folder-name" } - ); - response.Validate(); - } -} +using System.Threading.Tasks; + +namespace Imagekit.Tests.Services.Folders; + +public class FolderServiceTest : TestBase +{ + [Fact(Skip = "Prism tests are disabled")] + public async Task Create_Works() + { + var folder = await this.client.Folders.Create( + new() { FolderName = "summer", ParentFolderPath = "/product/images/" } + ); + folder.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Delete_Works() + { + var folder = await this.client.Folders.Delete(new() { FolderPath = "/folder/to/delete/" }); + folder.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Copy_Works() + { + var response = await this.client.Folders.Copy( + new() + { + DestinationPath = "/path/of/destination/folder", + SourceFolderPath = "/path/of/source/folder", + } + ); + response.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Move_Works() + { + var response = await this.client.Folders.Move( + new() + { + DestinationPath = "/path/of/destination/folder", + SourceFolderPath = "/path/of/source/folder", + } + ); + response.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Rename_Works() + { + var response = await this.client.Folders.Rename( + new() { FolderPath = "/path/of/folder", NewFolderName = "new-folder-name" } + ); + response.Validate(); + } +} From 7ef8fbc6749320ddb5e9bcfb872039d58b13526c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 28 Jan 2026 17:59:05 +0000 Subject: [PATCH 034/129] feat(api): add path policy related non-breaking changes --- .stats.yml | 4 +- .../ResponseField.cs | 127 ++++++++--------- .../CustomMetadataFieldListParams.cs | 131 +++++++++++------- .../ResponseField.cs | 127 ++++++++--------- .../ICustomMetadataFieldService.cs | 73 +++++----- 5 files changed, 251 insertions(+), 211 deletions(-) diff --git a/.stats.yml b/.stats.yml index 7c3aae1c..da19a2b5 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-d1a3e6dfc45ae832b6b14a0aef25878985c679fa9f48c1470df188b1578ba648.yml -openapi_spec_hash: 1d382866fce3284f26d341f112988d9d +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-1499148ce5fc81b4d8c8b3eaadf7adfaf54df5fa0b3a0452c3f5ef0dfe884a95.yml +openapi_spec_hash: e91526b143d3e696bef2b4d0ea3aa2b4 config_hash: e42d7fc3a8c92c35099cc283f9a4467a diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ResponseField.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ResponseField.cs index 91a2f19c..b801f518 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ResponseField.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ResponseField.cs @@ -1,62 +1,65 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties; - -[JsonConverter(typeof(ResponseFieldConverter))] -public enum ResponseField -{ - Tags, - CustomCoordinates, - IsPrivateFile, - EmbeddedMetadata, - IsPublished, - CustomMetadata, - Metadata, -} - -sealed class ResponseFieldConverter : JsonConverter -{ - public override ResponseField Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "tags" => ResponseField.Tags, - "customCoordinates" => ResponseField.CustomCoordinates, - "isPrivateFile" => ResponseField.IsPrivateFile, - "embeddedMetadata" => ResponseField.EmbeddedMetadata, - "isPublished" => ResponseField.IsPublished, - "customMetadata" => ResponseField.CustomMetadata, - "metadata" => ResponseField.Metadata, - _ => (ResponseField)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - ResponseField value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - ResponseField.Tags => "tags", - ResponseField.CustomCoordinates => "customCoordinates", - ResponseField.IsPrivateFile => "isPrivateFile", - ResponseField.EmbeddedMetadata => "embeddedMetadata", - ResponseField.IsPublished => "isPublished", - ResponseField.CustomMetadata => "customMetadata", - ResponseField.Metadata => "metadata", - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties; + +[JsonConverter(typeof(ResponseFieldConverter))] +public enum ResponseField +{ + Tags, + CustomCoordinates, + IsPrivateFile, + EmbeddedMetadata, + IsPublished, + CustomMetadata, + Metadata, + SelectedFieldsSchema, +} + +sealed class ResponseFieldConverter : JsonConverter +{ + public override ResponseField Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "tags" => ResponseField.Tags, + "customCoordinates" => ResponseField.CustomCoordinates, + "isPrivateFile" => ResponseField.IsPrivateFile, + "embeddedMetadata" => ResponseField.EmbeddedMetadata, + "isPublished" => ResponseField.IsPublished, + "customMetadata" => ResponseField.CustomMetadata, + "metadata" => ResponseField.Metadata, + "selectedFieldsSchema" => ResponseField.SelectedFieldsSchema, + _ => (ResponseField)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ResponseField value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ResponseField.Tags => "tags", + ResponseField.CustomCoordinates => "customCoordinates", + ResponseField.IsPrivateFile => "isPrivateFile", + ResponseField.EmbeddedMetadata => "embeddedMetadata", + ResponseField.IsPublished => "isPublished", + ResponseField.CustomMetadata => "customMetadata", + ResponseField.Metadata => "metadata", + ResponseField.SelectedFieldsSchema => "selectedFieldsSchema", + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldListParams.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldListParams.cs index 72aeee66..0b3649da 100644 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldListParams.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldListParams.cs @@ -1,51 +1,80 @@ -using System; -using System.Net.Http; -using System.Text.Json; - -namespace Imagekit.Models.CustomMetadataFields; - -/// -/// This API returns the array of created custom metadata field objects. By default -/// the API returns only non deleted field objects, but you can include deleted fields -/// in the API response. -/// -public sealed record class CustomMetadataFieldListParams : ParamsBase -{ - /// - /// Set it to `true` to include deleted field objects in the API response. - /// - public bool? IncludeDeleted - { - get - { - if (!this.QueryProperties.TryGetValue("includeDeleted", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.QueryProperties["includeDeleted"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override Uri Url(IImageKitClient client) - { - return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/customMetadataFields") - { - Query = this.QueryString(client), - }.Uri; - } - - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} +using System; +using System.Net.Http; +using System.Text.Json; + +namespace Imagekit.Models.CustomMetadataFields; + +/// +/// This API returns the array of created custom metadata field objects. By default +/// the API returns only non deleted field objects, but you can include deleted fields +/// in the API response. +/// +/// You can also filter results by a specific folder path to retrieve custom metadata +/// fields applicable at that location. This path-specific filtering is useful when +/// using the **Path policy** feature to determine which custom metadata fields are +/// selected for a given path. +/// +public sealed record class CustomMetadataFieldListParams : ParamsBase +{ + /// + /// The folder path (e.g., `/path/to/folder`) for which to retrieve applicable + /// custom metadata fields. Useful for determining path-specific field selections + /// when the [Path policy](https://imagekit.io/docs/dam/path-policy) feature is + /// in use. + /// + public string? FolderPath + { + get + { + if (!this.QueryProperties.TryGetValue("folderPath", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.QueryProperties["folderPath"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Set it to `true` to include deleted field objects in the API response. + /// + public bool? IncludeDeleted + { + get + { + if (!this.QueryProperties.TryGetValue("includeDeleted", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.QueryProperties["includeDeleted"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override Uri Url(IImageKitClient client) + { + return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/customMetadataFields") + { + Query = this.QueryString(client), + }.Uri; + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/ResponseField.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/ResponseField.cs index c5b5b8f7..179d40c1 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/ResponseField.cs +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/ResponseField.cs @@ -1,62 +1,65 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files.FileUploadParamsProperties; - -[JsonConverter(typeof(ResponseFieldConverter))] -public enum ResponseField -{ - Tags, - CustomCoordinates, - IsPrivateFile, - EmbeddedMetadata, - IsPublished, - CustomMetadata, - Metadata, -} - -sealed class ResponseFieldConverter : JsonConverter -{ - public override ResponseField Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "tags" => ResponseField.Tags, - "customCoordinates" => ResponseField.CustomCoordinates, - "isPrivateFile" => ResponseField.IsPrivateFile, - "embeddedMetadata" => ResponseField.EmbeddedMetadata, - "isPublished" => ResponseField.IsPublished, - "customMetadata" => ResponseField.CustomMetadata, - "metadata" => ResponseField.Metadata, - _ => (ResponseField)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - ResponseField value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - ResponseField.Tags => "tags", - ResponseField.CustomCoordinates => "customCoordinates", - ResponseField.IsPrivateFile => "isPrivateFile", - ResponseField.EmbeddedMetadata => "embeddedMetadata", - ResponseField.IsPublished => "isPublished", - ResponseField.CustomMetadata => "customMetadata", - ResponseField.Metadata => "metadata", - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.FileUploadParamsProperties; + +[JsonConverter(typeof(ResponseFieldConverter))] +public enum ResponseField +{ + Tags, + CustomCoordinates, + IsPrivateFile, + EmbeddedMetadata, + IsPublished, + CustomMetadata, + Metadata, + SelectedFieldsSchema, +} + +sealed class ResponseFieldConverter : JsonConverter +{ + public override ResponseField Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "tags" => ResponseField.Tags, + "customCoordinates" => ResponseField.CustomCoordinates, + "isPrivateFile" => ResponseField.IsPrivateFile, + "embeddedMetadata" => ResponseField.EmbeddedMetadata, + "isPublished" => ResponseField.IsPublished, + "customMetadata" => ResponseField.CustomMetadata, + "metadata" => ResponseField.Metadata, + "selectedFieldsSchema" => ResponseField.SelectedFieldsSchema, + _ => (ResponseField)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ResponseField value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ResponseField.Tags => "tags", + ResponseField.CustomCoordinates => "customCoordinates", + ResponseField.IsPrivateFile => "isPrivateFile", + ResponseField.EmbeddedMetadata => "embeddedMetadata", + ResponseField.IsPublished => "isPublished", + ResponseField.CustomMetadata => "customMetadata", + ResponseField.Metadata => "metadata", + ResponseField.SelectedFieldsSchema => "selectedFieldsSchema", + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Services/CustomMetadataFields/ICustomMetadataFieldService.cs b/src/Imagekit/Services/CustomMetadataFields/ICustomMetadataFieldService.cs index 1661789f..0333af7b 100644 --- a/src/Imagekit/Services/CustomMetadataFields/ICustomMetadataFieldService.cs +++ b/src/Imagekit/Services/CustomMetadataFields/ICustomMetadataFieldService.cs @@ -1,34 +1,39 @@ -using System.Collections.Generic; -using System.Threading.Tasks; -using Imagekit.Models.CustomMetadataFields; - -namespace Imagekit.Services.CustomMetadataFields; - -public interface ICustomMetadataFieldService -{ - /// - /// This API creates a new custom metadata field. Once a custom metadata field - /// is created either through this API or using the dashboard UI, its value can - /// be set on the assets. The value of a field for an asset can be set using the - /// media library UI or programmatically through upload or update assets API. - /// - Task Create(CustomMetadataFieldCreateParams parameters); - - /// - /// This API updates the label or schema of an existing custom metadata field. - /// - Task Update(CustomMetadataFieldUpdateParams parameters); - - /// - /// This API returns the array of created custom metadata field objects. By default - /// the API returns only non deleted field objects, but you can include deleted - /// fields in the API response. - /// - Task> List(CustomMetadataFieldListParams? parameters = null); - - /// - /// This API deletes a custom metadata field. Even after deleting a custom metadata - /// field, you cannot create any new custom metadata field with the same name. - /// - Task Delete(CustomMetadataFieldDeleteParams parameters); -} +using System.Collections.Generic; +using System.Threading.Tasks; +using Imagekit.Models.CustomMetadataFields; + +namespace Imagekit.Services.CustomMetadataFields; + +public interface ICustomMetadataFieldService +{ + /// + /// This API creates a new custom metadata field. Once a custom metadata field + /// is created either through this API or using the dashboard UI, its value can + /// be set on the assets. The value of a field for an asset can be set using the + /// media library UI or programmatically through upload or update assets API. + /// + Task Create(CustomMetadataFieldCreateParams parameters); + + /// + /// This API updates the label or schema of an existing custom metadata field. + /// + Task Update(CustomMetadataFieldUpdateParams parameters); + + /// + /// This API returns the array of created custom metadata field objects. By default + /// the API returns only non deleted field objects, but you can include deleted + /// fields in the API response. + /// + /// You can also filter results by a specific folder path to retrieve custom + /// metadata fields applicable at that location. This path-specific filtering + /// is useful when using the **Path policy** feature to determine which custom + /// metadata fields are selected for a given path. + /// + Task> List(CustomMetadataFieldListParams? parameters = null); + + /// + /// This API deletes a custom metadata field. Even after deleting a custom metadata + /// field, you cannot create any new custom metadata field with the same name. + /// + Task Delete(CustomMetadataFieldDeleteParams parameters); +} From b5174e6035410537160d0273de0e1d762de7b041 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 30 Sep 2025 07:24:42 +0000 Subject: [PATCH 035/129] feat(api): updated docs --- .stats.yml | 4 ++-- .../CustomMetadataFields/CustomMetadataFieldListParams.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.stats.yml b/.stats.yml index da19a2b5..6b1c558b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-1499148ce5fc81b4d8c8b3eaadf7adfaf54df5fa0b3a0452c3f5ef0dfe884a95.yml -openapi_spec_hash: e91526b143d3e696bef2b4d0ea3aa2b4 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-8d944c932f09191791cc09e90ebf8142e523c0a6dd82ae9d1dbd7ff884acfc4b.yml +openapi_spec_hash: 179e38a7a472a5f98d17aed41099cbfd config_hash: e42d7fc3a8c92c35099cc283f9a4467a diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldListParams.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldListParams.cs index 0b3649da..8d3d91da 100644 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldListParams.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldListParams.cs @@ -18,7 +18,7 @@ public sealed record class CustomMetadataFieldListParams : ParamsBase { /// /// The folder path (e.g., `/path/to/folder`) for which to retrieve applicable - /// custom metadata fields. Useful for determining path-specific field selections + /// custom metadata fields. Useful for determining path-specific field selections /// when the [Path policy](https://imagekit.io/docs/dam/path-policy) feature is /// in use. /// From 00a9878283bbbedff0ec20b428b1b95eb49f3b68 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 28 Jan 2026 18:00:14 +0000 Subject: [PATCH 036/129] feat(api): add selectedFieldsSchema in upload and list API response --- .stats.yml | 4 +- src/Imagekit/ModelBase.cs | 10 + .../Models/Beta/V2/Files/FileUploadParams.cs | 31 + .../SelectedFieldsSchemaItem.cs | 285 ++++ .../DefaultValue.cs | 175 +++ .../UnnamedSchemaWithArrayParent6.cs | 140 ++ .../All.cs | 35 + .../DefaultValueVariants/All.cs | 50 + .../MaxValue.cs | 109 ++ .../MaxValueVariants/All.cs | 21 + .../MinValue.cs | 109 ++ .../MinValueVariants/All.cs | 21 + .../SelectOption.cs | 138 ++ .../SelectOptionVariants/All.cs | 31 + .../Type.cs | 61 + src/Imagekit/Models/Files/File.cs | 1138 +++++++-------- .../SelectedFieldsSchemaItem.cs | 285 ++++ .../DefaultValue.cs | 175 +++ .../UnnamedSchemaWithArrayParent4.cs | 140 ++ .../All.cs | 35 + .../DefaultValueVariants/All.cs | 50 + .../MaxValue.cs | 109 ++ .../MaxValueVariants/All.cs | 21 + .../MinValue.cs | 109 ++ .../MinValueVariants/All.cs | 21 + .../SelectOption.cs | 138 ++ .../SelectOptionVariants/All.cs | 31 + .../Type.cs | 61 + .../Models/Files/FileUpdateResponse.cs | 1239 +++++++++-------- src/Imagekit/Models/Files/FileUploadParams.cs | 31 + .../SelectedFieldsSchemaItem.cs | 285 ++++ .../DefaultValue.cs | 175 +++ .../UnnamedSchemaWithArrayParent5.cs | 140 ++ .../All.cs | 35 + .../DefaultValueVariants/All.cs | 50 + .../MaxValue.cs | 109 ++ .../MaxValueVariants/All.cs | 21 + .../MinValue.cs | 109 ++ .../MinValueVariants/All.cs | 21 + .../SelectOption.cs | 138 ++ .../SelectOptionVariants/All.cs | 31 + .../Type.cs | 61 + 42 files changed, 4826 insertions(+), 1152 deletions(-) create mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs create mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs create mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent6.cs create mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent6Variants/All.cs create mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs create mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs create mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs create mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs create mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs create mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs create mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs create mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs create mode 100644 src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs create mode 100644 src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs create mode 100644 src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent4.cs create mode 100644 src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent4Variants/All.cs create mode 100644 src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs create mode 100644 src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs create mode 100644 src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs create mode 100644 src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs create mode 100644 src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs create mode 100644 src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs create mode 100644 src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs create mode 100644 src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent5.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent5Variants/All.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs diff --git a/.stats.yml b/.stats.yml index 6b1c558b..bceb847c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-8d944c932f09191791cc09e90ebf8142e523c0a6dd82ae9d1dbd7ff884acfc4b.yml -openapi_spec_hash: 179e38a7a472a5f98d17aed41099cbfd +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-7a42233daaf82345cc6d92cc49d4885126176b014c05ea0618c035869319fe53.yml +openapi_spec_hash: c41b1b6062b7c2ea548b16e0462aa358 config_hash: e42d7fc3a8c92c35099cc283f9a4467a diff --git a/src/Imagekit/ModelBase.cs b/src/Imagekit/ModelBase.cs index 32b552db..a2d49a73 100644 --- a/src/Imagekit/ModelBase.cs +++ b/src/Imagekit/ModelBase.cs @@ -22,6 +22,7 @@ using JobGetResponseProperties = Imagekit.Models.Folders.Job.JobGetResponseProperties; using OptionsProperties = Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.IntersectionMember1Properties.DataProperties.TransformationProperties.OptionsProperties; using SchemaProperties = Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties; +using SelectedFieldsSchemaItemProperties = Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; using TransformationProperties = Imagekit.Models.TransformationProperties; namespace Imagekit; @@ -66,6 +67,7 @@ public abstract record class ModelBase >(), new ApiEnumConverter(), new ApiEnumConverter(), + new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), @@ -77,6 +79,10 @@ public abstract record class ModelBase new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), + new ApiEnumConverter< + string, + global::Imagekit.Models.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.Type + >(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), @@ -104,6 +110,10 @@ public abstract record class ModelBase string, global::Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.ResponseField >(), + new ApiEnumConverter< + string, + global::Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.Type + >(), new ApiEnumConverter(), new ApiEnumConverter< string, diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParams.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParams.cs index 217968e5..9f761ae3 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParams.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParams.cs @@ -3,6 +3,7 @@ using System.Net.Http; using System.Text; using System.Text.Json; +using Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties; using FileUploadParamsProperties = Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties; namespace Imagekit.Models.Beta.V2.Files; @@ -426,6 +427,36 @@ public bool? OverwriteTags } } + /// + /// This field is included in the response only if the Path policy feature is + /// available in the plan. It contains schema definitions for the custom metadata + /// fields selected for the specified file path. Field selection can only be done + /// when the Path policy feature is enabled. + /// + /// Keys are the names of the custom metadata fields; the value object has details + /// about the custom metadata schema. + /// + public Dictionary? SelectedFieldsSchema + { + get + { + if (!this.BodyProperties.TryGetValue("selectedFieldsSchema", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.BodyProperties["selectedFieldsSchema"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + /// /// Set the tags while uploading the file. Provide an array of tag strings (e.g. /// `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs new file mode 100644 index 00000000..a464b0be --- /dev/null +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs @@ -0,0 +1,285 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using SelectedFieldsSchemaItemProperties = Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; + +namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class SelectedFieldsSchemaItem : ModelBase, IFromRaw +{ + /// + /// Type of the custom metadata field. + /// + public required ApiEnum Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize< + ApiEnum + >(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The default value for this custom metadata field. The value should match the + /// `type` of custom metadata field. + /// + public SelectedFieldsSchemaItemProperties::DefaultValue? DefaultValue + { + get + { + if (!this.Properties.TryGetValue("defaultValue", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["defaultValue"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies if the custom metadata field is required or not. + /// + public bool? IsValueRequired + { + get + { + if (!this.Properties.TryGetValue("isValueRequired", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["isValueRequired"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. + /// + public double? MaxLength + { + get + { + if (!this.Properties.TryGetValue("maxLength", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["maxLength"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Maximum value of the field. Only set if field type is `Date` or `Number`. + /// For `Date` type field, the value will be in ISO8601 string format. For `Number` + /// type field, it will be a numeric value. + /// + public SelectedFieldsSchemaItemProperties::MaxValue? MaxValue + { + get + { + if (!this.Properties.TryGetValue("maxValue", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["maxValue"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. + /// + public double? MinLength + { + get + { + if (!this.Properties.TryGetValue("minLength", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["minLength"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Minimum value of the field. Only set if field type is `Date` or `Number`. + /// For `Date` type field, the value will be in ISO8601 string format. For `Number` + /// type field, it will be a numeric value. + /// + public SelectedFieldsSchemaItemProperties::MinValue? MinValue + { + get + { + if (!this.Properties.TryGetValue("minValue", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["minValue"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Indicates whether the custom metadata field is read only. A read only field + /// cannot be modified after being set. This field is configurable only via the + /// **Path policy** feature. + /// + public bool? ReadOnly + { + get + { + if (!this.Properties.TryGetValue("readOnly", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["readOnly"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// An array of allowed values when field type is `SingleSelect` or `MultiSelect`. + /// + public List? SelectOptions + { + get + { + if (!this.Properties.TryGetValue("selectOptions", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["selectOptions"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies if the selectOptions array is truncated. It is truncated when number + /// of options are > 100. + /// + public bool? SelectOptionsTruncated + { + get + { + if (!this.Properties.TryGetValue("selectOptionsTruncated", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["selectOptionsTruncated"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.Type.Validate(); + this.DefaultValue?.Validate(); + _ = this.IsValueRequired; + _ = this.MaxLength; + this.MaxValue?.Validate(); + _ = this.MinLength; + this.MinValue?.Validate(); + _ = this.ReadOnly; + foreach (var item in this.SelectOptions ?? []) + { + item.Validate(); + } + _ = this.SelectOptionsTruncated; + } + + public SelectedFieldsSchemaItem() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + SelectedFieldsSchemaItem(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static SelectedFieldsSchemaItem FromRawUnchecked( + Dictionary properties + ) + { + return new(properties); + } + + [SetsRequiredMembers] + public SelectedFieldsSchemaItem(ApiEnum type) + : this() + { + this.Type = type; + } +} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs new file mode 100644 index 00000000..f50cc93c --- /dev/null +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs @@ -0,0 +1,175 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties; +using Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueVariants; +using System = System; + +namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; + +/// +/// The default value for this custom metadata field. The value should match the +/// `type` of custom metadata field. +/// +[JsonConverter(typeof(DefaultValueConverter))] +public abstract record class DefaultValue +{ + internal DefaultValue() { } + + public static implicit operator DefaultValue(string value) => new String(value); + + public static implicit operator DefaultValue(double value) => new Double(value); + + public static implicit operator DefaultValue(bool value) => new Bool(value); + + public static implicit operator DefaultValue(List value) => + new Mixed(value); + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as String)?.Value; + return value != null; + } + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as Double)?.Value; + return value != null; + } + + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = (this as Bool)?.Value; + return value != null; + } + + public bool TryPickMixed([NotNullWhen(true)] out List? value) + { + value = (this as Mixed)?.Value; + return value != null; + } + + public void Switch( + System::Action @string, + System::Action @double, + System::Action @bool, + System::Action mixed + ) + { + switch (this) + { + case String inner: + @string(inner); + break; + case Double inner: + @double(inner); + break; + case Bool inner: + @bool(inner); + break; + case Mixed inner: + mixed(inner); + break; + default: + throw new System::InvalidOperationException(); + } + } + + public T Match( + System::Func @string, + System::Func @double, + System::Func @bool, + System::Func mixed + ) + { + return this switch + { + String inner => @string(inner), + Double inner => @double(inner), + Bool inner => @bool(inner), + Mixed inner => mixed(inner), + _ => throw new System::InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class DefaultValueConverter : JsonConverter +{ + public override DefaultValue? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new Double(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new Bool(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize>( + ref reader, + options + ); + if (deserialized != null) + { + return new Mixed(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new System::AggregateException(exceptions); + } + + public override void Write( + Utf8JsonWriter writer, + DefaultValue value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + String(var @string) => @string, + Double(var @double) => @double, + Bool(var @bool) => @bool, + Mixed(var mixed) => mixed, + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent6.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent6.cs new file mode 100644 index 00000000..c5c11caf --- /dev/null +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent6.cs @@ -0,0 +1,140 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties.UnnamedSchemaWithArrayParent6Variants; +using System = System; + +namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties; + +[JsonConverter(typeof(UnnamedSchemaWithArrayParent6Converter))] +public abstract record class UnnamedSchemaWithArrayParent6 +{ + internal UnnamedSchemaWithArrayParent6() { } + + public static implicit operator UnnamedSchemaWithArrayParent6(string value) => + new String(value); + + public static implicit operator UnnamedSchemaWithArrayParent6(double value) => + new Double(value); + + public static implicit operator UnnamedSchemaWithArrayParent6(bool value) => new Bool(value); + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as String)?.Value; + return value != null; + } + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as Double)?.Value; + return value != null; + } + + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = (this as Bool)?.Value; + return value != null; + } + + public void Switch( + System::Action @string, + System::Action @double, + System::Action @bool + ) + { + switch (this) + { + case String inner: + @string(inner); + break; + case Double inner: + @double(inner); + break; + case Bool inner: + @bool(inner); + break; + default: + throw new System::InvalidOperationException(); + } + } + + public T Match( + System::Func @string, + System::Func @double, + System::Func @bool + ) + { + return this switch + { + String inner => @string(inner), + Double inner => @double(inner), + Bool inner => @bool(inner), + _ => throw new System::InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class UnnamedSchemaWithArrayParent6Converter : JsonConverter +{ + public override UnnamedSchemaWithArrayParent6? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new Double(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new Bool(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new System::AggregateException(exceptions); + } + + public override void Write( + Utf8JsonWriter writer, + UnnamedSchemaWithArrayParent6 value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + String(var @string) => @string, + Double(var @double) => @double, + Bool(var @bool) => @bool, + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent6Variants/All.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent6Variants/All.cs new file mode 100644 index 00000000..cefdec9a --- /dev/null +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent6Variants/All.cs @@ -0,0 +1,35 @@ +namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties.UnnamedSchemaWithArrayParent6Variants; + +public sealed record class String(string Value) + : UnnamedSchemaWithArrayParent6, + IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Double(double Value) + : UnnamedSchemaWithArrayParent6, + IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Bool(bool Value) : UnnamedSchemaWithArrayParent6, IVariant +{ + public static Bool From(bool value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs new file mode 100644 index 00000000..4aef728b --- /dev/null +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs @@ -0,0 +1,50 @@ +using System.Collections.Generic; +using Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties; + +namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueVariants; + +public sealed record class String(string Value) : DefaultValue, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Double(double Value) : DefaultValue, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Bool(bool Value) : DefaultValue, IVariant +{ + public static Bool From(bool value) + { + return new(value); + } + + public override void Validate() { } +} + +/// +/// Default value should be of type array when custom metadata field type is set to +/// `MultiSelect`. +/// +public sealed record class Mixed(List Value) + : DefaultValue, + IVariant> +{ + public static Mixed From(List value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs new file mode 100644 index 00000000..3087a60d --- /dev/null +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs @@ -0,0 +1,109 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MaxValueVariants; +using System = System; + +namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; + +/// +/// Maximum value of the field. Only set if field type is `Date` or `Number`. For +/// `Date` type field, the value will be in ISO8601 string format. For `Number` type +/// field, it will be a numeric value. +/// +[JsonConverter(typeof(MaxValueConverter))] +public abstract record class MaxValue +{ + internal MaxValue() { } + + public static implicit operator MaxValue(string value) => new String(value); + + public static implicit operator MaxValue(double value) => new Double(value); + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as String)?.Value; + return value != null; + } + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as Double)?.Value; + return value != null; + } + + public void Switch(System::Action @string, System::Action @double) + { + switch (this) + { + case String inner: + @string(inner); + break; + case Double inner: + @double(inner); + break; + default: + throw new System::InvalidOperationException(); + } + } + + public T Match(System::Func @string, System::Func @double) + { + return this switch + { + String inner => @string(inner), + Double inner => @double(inner), + _ => throw new System::InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class MaxValueConverter : JsonConverter +{ + public override MaxValue? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new Double(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new System::AggregateException(exceptions); + } + + public override void Write(Utf8JsonWriter writer, MaxValue value, JsonSerializerOptions options) + { + object variant = value switch + { + String(var @string) => @string, + Double(var @double) => @double, + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs new file mode 100644 index 00000000..93b9bb6f --- /dev/null +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs @@ -0,0 +1,21 @@ +namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MaxValueVariants; + +public sealed record class String(string Value) : MaxValue, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Double(double Value) : MaxValue, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs new file mode 100644 index 00000000..5830e59d --- /dev/null +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs @@ -0,0 +1,109 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MinValueVariants; +using System = System; + +namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; + +/// +/// Minimum value of the field. Only set if field type is `Date` or `Number`. For +/// `Date` type field, the value will be in ISO8601 string format. For `Number` type +/// field, it will be a numeric value. +/// +[JsonConverter(typeof(MinValueConverter))] +public abstract record class MinValue +{ + internal MinValue() { } + + public static implicit operator MinValue(string value) => new String(value); + + public static implicit operator MinValue(double value) => new Double(value); + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as String)?.Value; + return value != null; + } + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as Double)?.Value; + return value != null; + } + + public void Switch(System::Action @string, System::Action @double) + { + switch (this) + { + case String inner: + @string(inner); + break; + case Double inner: + @double(inner); + break; + default: + throw new System::InvalidOperationException(); + } + } + + public T Match(System::Func @string, System::Func @double) + { + return this switch + { + String inner => @string(inner), + Double inner => @double(inner), + _ => throw new System::InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class MinValueConverter : JsonConverter +{ + public override MinValue? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new Double(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new System::AggregateException(exceptions); + } + + public override void Write(Utf8JsonWriter writer, MinValue value, JsonSerializerOptions options) + { + object variant = value switch + { + String(var @string) => @string, + Double(var @double) => @double, + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs new file mode 100644 index 00000000..a2b979c2 --- /dev/null +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs @@ -0,0 +1,21 @@ +namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MinValueVariants; + +public sealed record class String(string Value) : MinValue, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Double(double Value) : MinValue, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs new file mode 100644 index 00000000..b6d8dea0 --- /dev/null +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs @@ -0,0 +1,138 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.SelectOptionVariants; +using System = System; + +namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; + +[JsonConverter(typeof(SelectOptionConverter))] +public abstract record class SelectOption +{ + internal SelectOption() { } + + public static implicit operator SelectOption(string value) => new String(value); + + public static implicit operator SelectOption(double value) => new Double(value); + + public static implicit operator SelectOption(bool value) => new Bool(value); + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as String)?.Value; + return value != null; + } + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as Double)?.Value; + return value != null; + } + + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = (this as Bool)?.Value; + return value != null; + } + + public void Switch( + System::Action @string, + System::Action @double, + System::Action @bool + ) + { + switch (this) + { + case String inner: + @string(inner); + break; + case Double inner: + @double(inner); + break; + case Bool inner: + @bool(inner); + break; + default: + throw new System::InvalidOperationException(); + } + } + + public T Match( + System::Func @string, + System::Func @double, + System::Func @bool + ) + { + return this switch + { + String inner => @string(inner), + Double inner => @double(inner), + Bool inner => @bool(inner), + _ => throw new System::InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class SelectOptionConverter : JsonConverter +{ + public override SelectOption? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new Double(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new Bool(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new System::AggregateException(exceptions); + } + + public override void Write( + Utf8JsonWriter writer, + SelectOption value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + String(var @string) => @string, + Double(var @double) => @double, + Bool(var @bool) => @bool, + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs new file mode 100644 index 00000000..a4c3468e --- /dev/null +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs @@ -0,0 +1,31 @@ +namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.SelectOptionVariants; + +public sealed record class String(string Value) : SelectOption, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Double(double Value) : SelectOption, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Bool(bool Value) : SelectOption, IVariant +{ + public static Bool From(bool value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs new file mode 100644 index 00000000..df93e8c5 --- /dev/null +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs @@ -0,0 +1,61 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using System = System; + +namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; + +/// +/// Type of the custom metadata field. +/// +[JsonConverter(typeof(TypeConverter))] +public enum Type +{ + Text, + Textarea, + Number, + Date, + Boolean, + SingleSelect, + MultiSelect, +} + +sealed class TypeConverter : JsonConverter +{ + public override Type Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "Text" => SelectedFieldsSchemaItemProperties.Type.Text, + "Textarea" => SelectedFieldsSchemaItemProperties.Type.Textarea, + "Number" => SelectedFieldsSchemaItemProperties.Type.Number, + "Date" => SelectedFieldsSchemaItemProperties.Type.Date, + "Boolean" => SelectedFieldsSchemaItemProperties.Type.Boolean, + "SingleSelect" => SelectedFieldsSchemaItemProperties.Type.SingleSelect, + "MultiSelect" => SelectedFieldsSchemaItemProperties.Type.MultiSelect, + _ => (Type)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + SelectedFieldsSchemaItemProperties.Type.Text => "Text", + SelectedFieldsSchemaItemProperties.Type.Textarea => "Textarea", + SelectedFieldsSchemaItemProperties.Type.Number => "Number", + SelectedFieldsSchemaItemProperties.Type.Date => "Date", + SelectedFieldsSchemaItemProperties.Type.Boolean => "Boolean", + SelectedFieldsSchemaItemProperties.Type.SingleSelect => "SingleSelect", + SelectedFieldsSchemaItemProperties.Type.MultiSelect => "MultiSelect", + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Files/File.cs b/src/Imagekit/Models/Files/File.cs index 0840cb97..dbd518bf 100644 --- a/src/Imagekit/Models/Files/File.cs +++ b/src/Imagekit/Models/Files/File.cs @@ -1,550 +1,588 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using FileProperties = Imagekit.Models.Files.FileProperties; - -namespace Imagekit.Models.Files; - -/// -/// Object containing details of a file or file version. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class File : ModelBase, IFromRaw -{ - /// - /// An array of tags assigned to the file by auto tagging. - /// - public List? AITags - { - get - { - if (!this.Properties.TryGetValue("AITags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["AITags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Date and time when the file was uploaded. The date and time is in ISO8601 - /// format. - /// - public DateTime? CreatedAt - { - get - { - if (!this.Properties.TryGetValue("createdAt", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["createdAt"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// An string with custom coordinates of the file. - /// - public string? CustomCoordinates - { - get - { - if (!this.Properties.TryGetValue("customCoordinates", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["customCoordinates"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// An object with custom metadata for the file. - /// - public Dictionary? CustomMetadata - { - get - { - if (!this.Properties.TryGetValue("customMetadata", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["customMetadata"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Optional text to describe the contents of the file. Can be set by the user - /// or the ai-auto-description extension. - /// - public string? Description - { - get - { - if (!this.Properties.TryGetValue("description", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["description"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Unique identifier of the asset. - /// - public string? FileID - { - get - { - if (!this.Properties.TryGetValue("fileId", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["fileId"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Path of the file. This is the path you would use in the URL to access the - /// file. For example, if the file is at the root of the media library, the path - /// will be `/file.jpg`. If the file is inside a folder named `images`, the path - /// will be `/images/file.jpg`. - /// - public string? FilePath - { - get - { - if (!this.Properties.TryGetValue("filePath", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["filePath"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Type of the file. Possible values are `image`, `non-image`. - /// - public string? FileType - { - get - { - if (!this.Properties.TryGetValue("fileType", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["fileType"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies if the image has an alpha channel. - /// - public bool? HasAlpha - { - get - { - if (!this.Properties.TryGetValue("hasAlpha", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["hasAlpha"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Height of the file. - /// - public double? Height - { - get - { - if (!this.Properties.TryGetValue("height", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["height"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies if the file is private or not. - /// - public bool? IsPrivateFile - { - get - { - if (!this.Properties.TryGetValue("isPrivateFile", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["isPrivateFile"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies if the file is published or not. - /// - public bool? IsPublished - { - get - { - if (!this.Properties.TryGetValue("isPublished", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["isPublished"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// MIME type of the file. - /// - public string? Mime - { - get - { - if (!this.Properties.TryGetValue("mime", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["mime"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Name of the asset. - /// - public string? Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Size of the file in bytes. - /// - public double? Size - { - get - { - if (!this.Properties.TryGetValue("size", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["size"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// An array of tags assigned to the file. Tags are used to search files in the - /// media library. - /// - public List? Tags - { - get - { - if (!this.Properties.TryGetValue("tags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["tags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// URL of the thumbnail image. This URL is used to access the thumbnail image - /// of the file in the media library. - /// - public string? Thumbnail - { - get - { - if (!this.Properties.TryGetValue("thumbnail", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["thumbnail"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Type of the asset. - /// - public ApiEnum? Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Date and time when the file was last updated. The date and time is in ISO8601 - /// format. - /// - public DateTime? UpdatedAt - { - get - { - if (!this.Properties.TryGetValue("updatedAt", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["updatedAt"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// URL of the file. - /// - public string? URL - { - get - { - if (!this.Properties.TryGetValue("url", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["url"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// An object with details of the file version. - /// - public FileProperties::VersionInfo? VersionInfo - { - get - { - if (!this.Properties.TryGetValue("versionInfo", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["versionInfo"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Width of the file. - /// - public double? Width - { - get - { - if (!this.Properties.TryGetValue("width", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["width"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - foreach (var item in this.AITags ?? []) - { - item.Validate(); - } - _ = this.CreatedAt; - _ = this.CustomCoordinates; - if (this.CustomMetadata != null) - { - foreach (var item in this.CustomMetadata.Values) - { - _ = item; - } - } - _ = this.Description; - _ = this.FileID; - _ = this.FilePath; - _ = this.FileType; - _ = this.HasAlpha; - _ = this.Height; - _ = this.IsPrivateFile; - _ = this.IsPublished; - _ = this.Mime; - _ = this.Name; - _ = this.Size; - foreach (var item in this.Tags ?? []) - { - _ = item; - } - _ = this.Thumbnail; - this.Type?.Validate(); - _ = this.UpdatedAt; - _ = this.URL; - this.VersionInfo?.Validate(); - _ = this.Width; - } - - public File() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - File(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static File FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties; +using FileProperties = Imagekit.Models.Files.FileProperties; + +namespace Imagekit.Models.Files; + +/// +/// Object containing details of a file or file version. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class File : ModelBase, IFromRaw +{ + /// + /// An array of tags assigned to the file by auto tagging. + /// + public List? AITags + { + get + { + if (!this.Properties.TryGetValue("AITags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["AITags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Date and time when the file was uploaded. The date and time is in ISO8601 + /// format. + /// + public DateTime? CreatedAt + { + get + { + if (!this.Properties.TryGetValue("createdAt", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["createdAt"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// An string with custom coordinates of the file. + /// + public string? CustomCoordinates + { + get + { + if (!this.Properties.TryGetValue("customCoordinates", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["customCoordinates"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// An object with custom metadata for the file. + /// + public Dictionary? CustomMetadata + { + get + { + if (!this.Properties.TryGetValue("customMetadata", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["customMetadata"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Optional text to describe the contents of the file. Can be set by the user + /// or the ai-auto-description extension. + /// + public string? Description + { + get + { + if (!this.Properties.TryGetValue("description", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["description"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Unique identifier of the asset. + /// + public string? FileID + { + get + { + if (!this.Properties.TryGetValue("fileId", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["fileId"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Path of the file. This is the path you would use in the URL to access the + /// file. For example, if the file is at the root of the media library, the path + /// will be `/file.jpg`. If the file is inside a folder named `images`, the path + /// will be `/images/file.jpg`. + /// + public string? FilePath + { + get + { + if (!this.Properties.TryGetValue("filePath", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["filePath"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Type of the file. Possible values are `image`, `non-image`. + /// + public string? FileType + { + get + { + if (!this.Properties.TryGetValue("fileType", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["fileType"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies if the image has an alpha channel. + /// + public bool? HasAlpha + { + get + { + if (!this.Properties.TryGetValue("hasAlpha", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["hasAlpha"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Height of the file. + /// + public double? Height + { + get + { + if (!this.Properties.TryGetValue("height", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["height"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies if the file is private or not. + /// + public bool? IsPrivateFile + { + get + { + if (!this.Properties.TryGetValue("isPrivateFile", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["isPrivateFile"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies if the file is published or not. + /// + public bool? IsPublished + { + get + { + if (!this.Properties.TryGetValue("isPublished", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["isPublished"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// MIME type of the file. + /// + public string? Mime + { + get + { + if (!this.Properties.TryGetValue("mime", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["mime"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Name of the asset. + /// + public string? Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// This field is included in the response only if the Path policy feature is + /// available in the plan. It contains schema definitions for the custom metadata + /// fields selected for the specified file path. Field selection can only be done + /// when the Path policy feature is enabled. + /// + /// Keys are the names of the custom metadata fields; the value object has details + /// about the custom metadata schema. + /// + public Dictionary? SelectedFieldsSchema + { + get + { + if (!this.Properties.TryGetValue("selectedFieldsSchema", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["selectedFieldsSchema"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Size of the file in bytes. + /// + public double? Size + { + get + { + if (!this.Properties.TryGetValue("size", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["size"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// An array of tags assigned to the file. Tags are used to search files in the + /// media library. + /// + public List? Tags + { + get + { + if (!this.Properties.TryGetValue("tags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["tags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// URL of the thumbnail image. This URL is used to access the thumbnail image + /// of the file in the media library. + /// + public string? Thumbnail + { + get + { + if (!this.Properties.TryGetValue("thumbnail", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["thumbnail"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Type of the asset. + /// + public ApiEnum? Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Date and time when the file was last updated. The date and time is in ISO8601 + /// format. + /// + public DateTime? UpdatedAt + { + get + { + if (!this.Properties.TryGetValue("updatedAt", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["updatedAt"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// URL of the file. + /// + public string? URL + { + get + { + if (!this.Properties.TryGetValue("url", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["url"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// An object with details of the file version. + /// + public FileProperties::VersionInfo? VersionInfo + { + get + { + if (!this.Properties.TryGetValue("versionInfo", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["versionInfo"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Width of the file. + /// + public double? Width + { + get + { + if (!this.Properties.TryGetValue("width", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["width"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + foreach (var item in this.AITags ?? []) + { + item.Validate(); + } + _ = this.CreatedAt; + _ = this.CustomCoordinates; + if (this.CustomMetadata != null) + { + foreach (var item in this.CustomMetadata.Values) + { + _ = item; + } + } + _ = this.Description; + _ = this.FileID; + _ = this.FilePath; + _ = this.FileType; + _ = this.HasAlpha; + _ = this.Height; + _ = this.IsPrivateFile; + _ = this.IsPublished; + _ = this.Mime; + _ = this.Name; + if (this.SelectedFieldsSchema != null) + { + foreach (var item in this.SelectedFieldsSchema.Values) + { + item.Validate(); + } + } + _ = this.Size; + foreach (var item in this.Tags ?? []) + { + _ = item; + } + _ = this.Thumbnail; + this.Type?.Validate(); + _ = this.UpdatedAt; + _ = this.URL; + this.VersionInfo?.Validate(); + _ = this.Width; + } + + public File() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + File(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static File FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs new file mode 100644 index 00000000..2e98daaf --- /dev/null +++ b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs @@ -0,0 +1,285 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using SelectedFieldsSchemaItemProperties = Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; + +namespace Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class SelectedFieldsSchemaItem : ModelBase, IFromRaw +{ + /// + /// Type of the custom metadata field. + /// + public required ApiEnum Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize< + ApiEnum + >(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The default value for this custom metadata field. The value should match the + /// `type` of custom metadata field. + /// + public SelectedFieldsSchemaItemProperties::DefaultValue? DefaultValue + { + get + { + if (!this.Properties.TryGetValue("defaultValue", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["defaultValue"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies if the custom metadata field is required or not. + /// + public bool? IsValueRequired + { + get + { + if (!this.Properties.TryGetValue("isValueRequired", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["isValueRequired"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. + /// + public double? MaxLength + { + get + { + if (!this.Properties.TryGetValue("maxLength", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["maxLength"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Maximum value of the field. Only set if field type is `Date` or `Number`. + /// For `Date` type field, the value will be in ISO8601 string format. For `Number` + /// type field, it will be a numeric value. + /// + public SelectedFieldsSchemaItemProperties::MaxValue? MaxValue + { + get + { + if (!this.Properties.TryGetValue("maxValue", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["maxValue"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. + /// + public double? MinLength + { + get + { + if (!this.Properties.TryGetValue("minLength", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["minLength"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Minimum value of the field. Only set if field type is `Date` or `Number`. + /// For `Date` type field, the value will be in ISO8601 string format. For `Number` + /// type field, it will be a numeric value. + /// + public SelectedFieldsSchemaItemProperties::MinValue? MinValue + { + get + { + if (!this.Properties.TryGetValue("minValue", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["minValue"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Indicates whether the custom metadata field is read only. A read only field + /// cannot be modified after being set. This field is configurable only via the + /// **Path policy** feature. + /// + public bool? ReadOnly + { + get + { + if (!this.Properties.TryGetValue("readOnly", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["readOnly"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// An array of allowed values when field type is `SingleSelect` or `MultiSelect`. + /// + public List? SelectOptions + { + get + { + if (!this.Properties.TryGetValue("selectOptions", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["selectOptions"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies if the selectOptions array is truncated. It is truncated when number + /// of options are > 100. + /// + public bool? SelectOptionsTruncated + { + get + { + if (!this.Properties.TryGetValue("selectOptionsTruncated", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["selectOptionsTruncated"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.Type.Validate(); + this.DefaultValue?.Validate(); + _ = this.IsValueRequired; + _ = this.MaxLength; + this.MaxValue?.Validate(); + _ = this.MinLength; + this.MinValue?.Validate(); + _ = this.ReadOnly; + foreach (var item in this.SelectOptions ?? []) + { + item.Validate(); + } + _ = this.SelectOptionsTruncated; + } + + public SelectedFieldsSchemaItem() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + SelectedFieldsSchemaItem(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static SelectedFieldsSchemaItem FromRawUnchecked( + Dictionary properties + ) + { + return new(properties); + } + + [SetsRequiredMembers] + public SelectedFieldsSchemaItem(ApiEnum type) + : this() + { + this.Type = type; + } +} diff --git a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs new file mode 100644 index 00000000..8962e190 --- /dev/null +++ b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs @@ -0,0 +1,175 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties; +using Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueVariants; +using System = System; + +namespace Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; + +/// +/// The default value for this custom metadata field. The value should match the +/// `type` of custom metadata field. +/// +[JsonConverter(typeof(DefaultValueConverter))] +public abstract record class DefaultValue +{ + internal DefaultValue() { } + + public static implicit operator DefaultValue(string value) => new String(value); + + public static implicit operator DefaultValue(double value) => new Double(value); + + public static implicit operator DefaultValue(bool value) => new Bool(value); + + public static implicit operator DefaultValue(List value) => + new Mixed(value); + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as String)?.Value; + return value != null; + } + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as Double)?.Value; + return value != null; + } + + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = (this as Bool)?.Value; + return value != null; + } + + public bool TryPickMixed([NotNullWhen(true)] out List? value) + { + value = (this as Mixed)?.Value; + return value != null; + } + + public void Switch( + System::Action @string, + System::Action @double, + System::Action @bool, + System::Action mixed + ) + { + switch (this) + { + case String inner: + @string(inner); + break; + case Double inner: + @double(inner); + break; + case Bool inner: + @bool(inner); + break; + case Mixed inner: + mixed(inner); + break; + default: + throw new System::InvalidOperationException(); + } + } + + public T Match( + System::Func @string, + System::Func @double, + System::Func @bool, + System::Func mixed + ) + { + return this switch + { + String inner => @string(inner), + Double inner => @double(inner), + Bool inner => @bool(inner), + Mixed inner => mixed(inner), + _ => throw new System::InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class DefaultValueConverter : JsonConverter +{ + public override DefaultValue? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new Double(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new Bool(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize>( + ref reader, + options + ); + if (deserialized != null) + { + return new Mixed(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new System::AggregateException(exceptions); + } + + public override void Write( + Utf8JsonWriter writer, + DefaultValue value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + String(var @string) => @string, + Double(var @double) => @double, + Bool(var @bool) => @bool, + Mixed(var mixed) => mixed, + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent4.cs b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent4.cs new file mode 100644 index 00000000..08112b37 --- /dev/null +++ b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent4.cs @@ -0,0 +1,140 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties.UnnamedSchemaWithArrayParent4Variants; +using System = System; + +namespace Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties; + +[JsonConverter(typeof(UnnamedSchemaWithArrayParent4Converter))] +public abstract record class UnnamedSchemaWithArrayParent4 +{ + internal UnnamedSchemaWithArrayParent4() { } + + public static implicit operator UnnamedSchemaWithArrayParent4(string value) => + new String(value); + + public static implicit operator UnnamedSchemaWithArrayParent4(double value) => + new Double(value); + + public static implicit operator UnnamedSchemaWithArrayParent4(bool value) => new Bool(value); + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as String)?.Value; + return value != null; + } + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as Double)?.Value; + return value != null; + } + + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = (this as Bool)?.Value; + return value != null; + } + + public void Switch( + System::Action @string, + System::Action @double, + System::Action @bool + ) + { + switch (this) + { + case String inner: + @string(inner); + break; + case Double inner: + @double(inner); + break; + case Bool inner: + @bool(inner); + break; + default: + throw new System::InvalidOperationException(); + } + } + + public T Match( + System::Func @string, + System::Func @double, + System::Func @bool + ) + { + return this switch + { + String inner => @string(inner), + Double inner => @double(inner), + Bool inner => @bool(inner), + _ => throw new System::InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class UnnamedSchemaWithArrayParent4Converter : JsonConverter +{ + public override UnnamedSchemaWithArrayParent4? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new Double(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new Bool(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new System::AggregateException(exceptions); + } + + public override void Write( + Utf8JsonWriter writer, + UnnamedSchemaWithArrayParent4 value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + String(var @string) => @string, + Double(var @double) => @double, + Bool(var @bool) => @bool, + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent4Variants/All.cs b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent4Variants/All.cs new file mode 100644 index 00000000..a4066489 --- /dev/null +++ b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent4Variants/All.cs @@ -0,0 +1,35 @@ +namespace Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties.UnnamedSchemaWithArrayParent4Variants; + +public sealed record class String(string Value) + : UnnamedSchemaWithArrayParent4, + IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Double(double Value) + : UnnamedSchemaWithArrayParent4, + IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Bool(bool Value) : UnnamedSchemaWithArrayParent4, IVariant +{ + public static Bool From(bool value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs new file mode 100644 index 00000000..560883e3 --- /dev/null +++ b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs @@ -0,0 +1,50 @@ +using System.Collections.Generic; +using Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties; + +namespace Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueVariants; + +public sealed record class String(string Value) : DefaultValue, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Double(double Value) : DefaultValue, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Bool(bool Value) : DefaultValue, IVariant +{ + public static Bool From(bool value) + { + return new(value); + } + + public override void Validate() { } +} + +/// +/// Default value should be of type array when custom metadata field type is set to +/// `MultiSelect`. +/// +public sealed record class Mixed(List Value) + : DefaultValue, + IVariant> +{ + public static Mixed From(List value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs new file mode 100644 index 00000000..0002975f --- /dev/null +++ b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs @@ -0,0 +1,109 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MaxValueVariants; +using System = System; + +namespace Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; + +/// +/// Maximum value of the field. Only set if field type is `Date` or `Number`. For +/// `Date` type field, the value will be in ISO8601 string format. For `Number` type +/// field, it will be a numeric value. +/// +[JsonConverter(typeof(MaxValueConverter))] +public abstract record class MaxValue +{ + internal MaxValue() { } + + public static implicit operator MaxValue(string value) => new String(value); + + public static implicit operator MaxValue(double value) => new Double(value); + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as String)?.Value; + return value != null; + } + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as Double)?.Value; + return value != null; + } + + public void Switch(System::Action @string, System::Action @double) + { + switch (this) + { + case String inner: + @string(inner); + break; + case Double inner: + @double(inner); + break; + default: + throw new System::InvalidOperationException(); + } + } + + public T Match(System::Func @string, System::Func @double) + { + return this switch + { + String inner => @string(inner), + Double inner => @double(inner), + _ => throw new System::InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class MaxValueConverter : JsonConverter +{ + public override MaxValue? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new Double(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new System::AggregateException(exceptions); + } + + public override void Write(Utf8JsonWriter writer, MaxValue value, JsonSerializerOptions options) + { + object variant = value switch + { + String(var @string) => @string, + Double(var @double) => @double, + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs new file mode 100644 index 00000000..bf536ec7 --- /dev/null +++ b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs @@ -0,0 +1,21 @@ +namespace Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MaxValueVariants; + +public sealed record class String(string Value) : MaxValue, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Double(double Value) : MaxValue, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs new file mode 100644 index 00000000..318b207e --- /dev/null +++ b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs @@ -0,0 +1,109 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MinValueVariants; +using System = System; + +namespace Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; + +/// +/// Minimum value of the field. Only set if field type is `Date` or `Number`. For +/// `Date` type field, the value will be in ISO8601 string format. For `Number` type +/// field, it will be a numeric value. +/// +[JsonConverter(typeof(MinValueConverter))] +public abstract record class MinValue +{ + internal MinValue() { } + + public static implicit operator MinValue(string value) => new String(value); + + public static implicit operator MinValue(double value) => new Double(value); + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as String)?.Value; + return value != null; + } + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as Double)?.Value; + return value != null; + } + + public void Switch(System::Action @string, System::Action @double) + { + switch (this) + { + case String inner: + @string(inner); + break; + case Double inner: + @double(inner); + break; + default: + throw new System::InvalidOperationException(); + } + } + + public T Match(System::Func @string, System::Func @double) + { + return this switch + { + String inner => @string(inner), + Double inner => @double(inner), + _ => throw new System::InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class MinValueConverter : JsonConverter +{ + public override MinValue? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new Double(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new System::AggregateException(exceptions); + } + + public override void Write(Utf8JsonWriter writer, MinValue value, JsonSerializerOptions options) + { + object variant = value switch + { + String(var @string) => @string, + Double(var @double) => @double, + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs new file mode 100644 index 00000000..ebe9c896 --- /dev/null +++ b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs @@ -0,0 +1,21 @@ +namespace Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MinValueVariants; + +public sealed record class String(string Value) : MinValue, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Double(double Value) : MinValue, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs new file mode 100644 index 00000000..0128f953 --- /dev/null +++ b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs @@ -0,0 +1,138 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.SelectOptionVariants; +using System = System; + +namespace Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; + +[JsonConverter(typeof(SelectOptionConverter))] +public abstract record class SelectOption +{ + internal SelectOption() { } + + public static implicit operator SelectOption(string value) => new String(value); + + public static implicit operator SelectOption(double value) => new Double(value); + + public static implicit operator SelectOption(bool value) => new Bool(value); + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as String)?.Value; + return value != null; + } + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as Double)?.Value; + return value != null; + } + + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = (this as Bool)?.Value; + return value != null; + } + + public void Switch( + System::Action @string, + System::Action @double, + System::Action @bool + ) + { + switch (this) + { + case String inner: + @string(inner); + break; + case Double inner: + @double(inner); + break; + case Bool inner: + @bool(inner); + break; + default: + throw new System::InvalidOperationException(); + } + } + + public T Match( + System::Func @string, + System::Func @double, + System::Func @bool + ) + { + return this switch + { + String inner => @string(inner), + Double inner => @double(inner), + Bool inner => @bool(inner), + _ => throw new System::InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class SelectOptionConverter : JsonConverter +{ + public override SelectOption? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new Double(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new Bool(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new System::AggregateException(exceptions); + } + + public override void Write( + Utf8JsonWriter writer, + SelectOption value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + String(var @string) => @string, + Double(var @double) => @double, + Bool(var @bool) => @bool, + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs new file mode 100644 index 00000000..0d47411b --- /dev/null +++ b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs @@ -0,0 +1,31 @@ +namespace Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.SelectOptionVariants; + +public sealed record class String(string Value) : SelectOption, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Double(double Value) : SelectOption, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Bool(bool Value) : SelectOption, IVariant +{ + public static Bool From(bool value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs new file mode 100644 index 00000000..5d4847af --- /dev/null +++ b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs @@ -0,0 +1,61 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using System = System; + +namespace Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; + +/// +/// Type of the custom metadata field. +/// +[JsonConverter(typeof(TypeConverter))] +public enum Type +{ + Text, + Textarea, + Number, + Date, + Boolean, + SingleSelect, + MultiSelect, +} + +sealed class TypeConverter : JsonConverter +{ + public override Type Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "Text" => SelectedFieldsSchemaItemProperties.Type.Text, + "Textarea" => SelectedFieldsSchemaItemProperties.Type.Textarea, + "Number" => SelectedFieldsSchemaItemProperties.Type.Number, + "Date" => SelectedFieldsSchemaItemProperties.Type.Date, + "Boolean" => SelectedFieldsSchemaItemProperties.Type.Boolean, + "SingleSelect" => SelectedFieldsSchemaItemProperties.Type.SingleSelect, + "MultiSelect" => SelectedFieldsSchemaItemProperties.Type.MultiSelect, + _ => (Type)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + SelectedFieldsSchemaItemProperties.Type.Text => "Text", + SelectedFieldsSchemaItemProperties.Type.Textarea => "Textarea", + SelectedFieldsSchemaItemProperties.Type.Number => "Number", + SelectedFieldsSchemaItemProperties.Type.Date => "Date", + SelectedFieldsSchemaItemProperties.Type.Boolean => "Boolean", + SelectedFieldsSchemaItemProperties.Type.SingleSelect => "SingleSelect", + SelectedFieldsSchemaItemProperties.Type.MultiSelect => "MultiSelect", + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} diff --git a/src/Imagekit/Models/Files/FileUpdateResponse.cs b/src/Imagekit/Models/Files/FileUpdateResponse.cs index 8f361123..4752c71a 100644 --- a/src/Imagekit/Models/Files/FileUpdateResponse.cs +++ b/src/Imagekit/Models/Files/FileUpdateResponse.cs @@ -1,600 +1,639 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Files.FileUpdateResponseProperties.IntersectionMember1Properties; -using FileProperties = Imagekit.Models.Files.FileProperties; - -namespace Imagekit.Models.Files; - -/// -/// Object containing details of a file or file version. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class FileUpdateResponse : ModelBase, IFromRaw -{ - /// - /// An array of tags assigned to the file by auto tagging. - /// - public List? AITags - { - get - { - if (!this.Properties.TryGetValue("AITags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["AITags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Date and time when the file was uploaded. The date and time is in ISO8601 - /// format. - /// - public DateTime? CreatedAt - { - get - { - if (!this.Properties.TryGetValue("createdAt", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["createdAt"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// An string with custom coordinates of the file. - /// - public string? CustomCoordinates - { - get - { - if (!this.Properties.TryGetValue("customCoordinates", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["customCoordinates"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// An object with custom metadata for the file. - /// - public Dictionary? CustomMetadata - { - get - { - if (!this.Properties.TryGetValue("customMetadata", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["customMetadata"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Optional text to describe the contents of the file. Can be set by the user - /// or the ai-auto-description extension. - /// - public string? Description - { - get - { - if (!this.Properties.TryGetValue("description", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["description"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Unique identifier of the asset. - /// - public string? FileID - { - get - { - if (!this.Properties.TryGetValue("fileId", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["fileId"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Path of the file. This is the path you would use in the URL to access the - /// file. For example, if the file is at the root of the media library, the path - /// will be `/file.jpg`. If the file is inside a folder named `images`, the path - /// will be `/images/file.jpg`. - /// - public string? FilePath - { - get - { - if (!this.Properties.TryGetValue("filePath", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["filePath"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Type of the file. Possible values are `image`, `non-image`. - /// - public string? FileType - { - get - { - if (!this.Properties.TryGetValue("fileType", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["fileType"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies if the image has an alpha channel. - /// - public bool? HasAlpha - { - get - { - if (!this.Properties.TryGetValue("hasAlpha", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["hasAlpha"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Height of the file. - /// - public double? Height - { - get - { - if (!this.Properties.TryGetValue("height", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["height"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies if the file is private or not. - /// - public bool? IsPrivateFile - { - get - { - if (!this.Properties.TryGetValue("isPrivateFile", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["isPrivateFile"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies if the file is published or not. - /// - public bool? IsPublished - { - get - { - if (!this.Properties.TryGetValue("isPublished", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["isPublished"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// MIME type of the file. - /// - public string? Mime - { - get - { - if (!this.Properties.TryGetValue("mime", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["mime"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Name of the asset. - /// - public string? Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Size of the file in bytes. - /// - public double? Size - { - get - { - if (!this.Properties.TryGetValue("size", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["size"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// An array of tags assigned to the file. Tags are used to search files in the - /// media library. - /// - public List? Tags - { - get - { - if (!this.Properties.TryGetValue("tags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["tags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// URL of the thumbnail image. This URL is used to access the thumbnail image - /// of the file in the media library. - /// - public string? Thumbnail - { - get - { - if (!this.Properties.TryGetValue("thumbnail", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["thumbnail"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Type of the asset. - /// - public ApiEnum? Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Date and time when the file was last updated. The date and time is in ISO8601 - /// format. - /// - public DateTime? UpdatedAt - { - get - { - if (!this.Properties.TryGetValue("updatedAt", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["updatedAt"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// URL of the file. - /// - public string? URL - { - get - { - if (!this.Properties.TryGetValue("url", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["url"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// An object with details of the file version. - /// - public FileProperties::VersionInfo? VersionInfo - { - get - { - if (!this.Properties.TryGetValue("versionInfo", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["versionInfo"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Width of the file. - /// - public double? Width - { - get - { - if (!this.Properties.TryGetValue("width", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["width"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public ExtensionStatus? ExtensionStatus - { - get - { - if (!this.Properties.TryGetValue("extensionStatus", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["extensionStatus"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public static implicit operator File(FileUpdateResponse fileUpdateResponse) => - new() - { - AITags = fileUpdateResponse.AITags, - CreatedAt = fileUpdateResponse.CreatedAt, - CustomCoordinates = fileUpdateResponse.CustomCoordinates, - CustomMetadata = fileUpdateResponse.CustomMetadata, - Description = fileUpdateResponse.Description, - FileID = fileUpdateResponse.FileID, - FilePath = fileUpdateResponse.FilePath, - FileType = fileUpdateResponse.FileType, - HasAlpha = fileUpdateResponse.HasAlpha, - Height = fileUpdateResponse.Height, - IsPrivateFile = fileUpdateResponse.IsPrivateFile, - IsPublished = fileUpdateResponse.IsPublished, - Mime = fileUpdateResponse.Mime, - Name = fileUpdateResponse.Name, - Size = fileUpdateResponse.Size, - Tags = fileUpdateResponse.Tags, - Thumbnail = fileUpdateResponse.Thumbnail, - Type = fileUpdateResponse.Type, - UpdatedAt = fileUpdateResponse.UpdatedAt, - URL = fileUpdateResponse.URL, - VersionInfo = fileUpdateResponse.VersionInfo, - Width = fileUpdateResponse.Width, - }; - - public override void Validate() - { - foreach (var item in this.AITags ?? []) - { - item.Validate(); - } - _ = this.CreatedAt; - _ = this.CustomCoordinates; - if (this.CustomMetadata != null) - { - foreach (var item in this.CustomMetadata.Values) - { - _ = item; - } - } - _ = this.Description; - _ = this.FileID; - _ = this.FilePath; - _ = this.FileType; - _ = this.HasAlpha; - _ = this.Height; - _ = this.IsPrivateFile; - _ = this.IsPublished; - _ = this.Mime; - _ = this.Name; - _ = this.Size; - foreach (var item in this.Tags ?? []) - { - _ = item; - } - _ = this.Thumbnail; - this.Type?.Validate(); - _ = this.UpdatedAt; - _ = this.URL; - this.VersionInfo?.Validate(); - _ = this.Width; - this.ExtensionStatus?.Validate(); - } - - public FileUpdateResponse() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - FileUpdateResponse(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static FileUpdateResponse FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties; +using Imagekit.Models.Files.FileUpdateResponseProperties.IntersectionMember1Properties; +using FileProperties = Imagekit.Models.Files.FileProperties; + +namespace Imagekit.Models.Files; + +/// +/// Object containing details of a file or file version. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class FileUpdateResponse : ModelBase, IFromRaw +{ + /// + /// An array of tags assigned to the file by auto tagging. + /// + public List? AITags + { + get + { + if (!this.Properties.TryGetValue("AITags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["AITags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Date and time when the file was uploaded. The date and time is in ISO8601 + /// format. + /// + public DateTime? CreatedAt + { + get + { + if (!this.Properties.TryGetValue("createdAt", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["createdAt"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// An string with custom coordinates of the file. + /// + public string? CustomCoordinates + { + get + { + if (!this.Properties.TryGetValue("customCoordinates", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["customCoordinates"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// An object with custom metadata for the file. + /// + public Dictionary? CustomMetadata + { + get + { + if (!this.Properties.TryGetValue("customMetadata", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["customMetadata"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Optional text to describe the contents of the file. Can be set by the user + /// or the ai-auto-description extension. + /// + public string? Description + { + get + { + if (!this.Properties.TryGetValue("description", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["description"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Unique identifier of the asset. + /// + public string? FileID + { + get + { + if (!this.Properties.TryGetValue("fileId", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["fileId"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Path of the file. This is the path you would use in the URL to access the + /// file. For example, if the file is at the root of the media library, the path + /// will be `/file.jpg`. If the file is inside a folder named `images`, the path + /// will be `/images/file.jpg`. + /// + public string? FilePath + { + get + { + if (!this.Properties.TryGetValue("filePath", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["filePath"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Type of the file. Possible values are `image`, `non-image`. + /// + public string? FileType + { + get + { + if (!this.Properties.TryGetValue("fileType", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["fileType"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies if the image has an alpha channel. + /// + public bool? HasAlpha + { + get + { + if (!this.Properties.TryGetValue("hasAlpha", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["hasAlpha"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Height of the file. + /// + public double? Height + { + get + { + if (!this.Properties.TryGetValue("height", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["height"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies if the file is private or not. + /// + public bool? IsPrivateFile + { + get + { + if (!this.Properties.TryGetValue("isPrivateFile", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["isPrivateFile"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies if the file is published or not. + /// + public bool? IsPublished + { + get + { + if (!this.Properties.TryGetValue("isPublished", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["isPublished"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// MIME type of the file. + /// + public string? Mime + { + get + { + if (!this.Properties.TryGetValue("mime", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["mime"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Name of the asset. + /// + public string? Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// This field is included in the response only if the Path policy feature is + /// available in the plan. It contains schema definitions for the custom metadata + /// fields selected for the specified file path. Field selection can only be done + /// when the Path policy feature is enabled. + /// + /// Keys are the names of the custom metadata fields; the value object has details + /// about the custom metadata schema. + /// + public Dictionary? SelectedFieldsSchema + { + get + { + if (!this.Properties.TryGetValue("selectedFieldsSchema", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["selectedFieldsSchema"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Size of the file in bytes. + /// + public double? Size + { + get + { + if (!this.Properties.TryGetValue("size", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["size"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// An array of tags assigned to the file. Tags are used to search files in the + /// media library. + /// + public List? Tags + { + get + { + if (!this.Properties.TryGetValue("tags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["tags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// URL of the thumbnail image. This URL is used to access the thumbnail image + /// of the file in the media library. + /// + public string? Thumbnail + { + get + { + if (!this.Properties.TryGetValue("thumbnail", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["thumbnail"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Type of the asset. + /// + public ApiEnum? Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Date and time when the file was last updated. The date and time is in ISO8601 + /// format. + /// + public DateTime? UpdatedAt + { + get + { + if (!this.Properties.TryGetValue("updatedAt", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["updatedAt"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// URL of the file. + /// + public string? URL + { + get + { + if (!this.Properties.TryGetValue("url", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["url"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// An object with details of the file version. + /// + public FileProperties::VersionInfo? VersionInfo + { + get + { + if (!this.Properties.TryGetValue("versionInfo", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["versionInfo"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Width of the file. + /// + public double? Width + { + get + { + if (!this.Properties.TryGetValue("width", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["width"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public ExtensionStatus? ExtensionStatus + { + get + { + if (!this.Properties.TryGetValue("extensionStatus", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["extensionStatus"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public static implicit operator File(FileUpdateResponse fileUpdateResponse) => + new() + { + AITags = fileUpdateResponse.AITags, + CreatedAt = fileUpdateResponse.CreatedAt, + CustomCoordinates = fileUpdateResponse.CustomCoordinates, + CustomMetadata = fileUpdateResponse.CustomMetadata, + Description = fileUpdateResponse.Description, + FileID = fileUpdateResponse.FileID, + FilePath = fileUpdateResponse.FilePath, + FileType = fileUpdateResponse.FileType, + HasAlpha = fileUpdateResponse.HasAlpha, + Height = fileUpdateResponse.Height, + IsPrivateFile = fileUpdateResponse.IsPrivateFile, + IsPublished = fileUpdateResponse.IsPublished, + Mime = fileUpdateResponse.Mime, + Name = fileUpdateResponse.Name, + SelectedFieldsSchema = fileUpdateResponse.SelectedFieldsSchema, + Size = fileUpdateResponse.Size, + Tags = fileUpdateResponse.Tags, + Thumbnail = fileUpdateResponse.Thumbnail, + Type = fileUpdateResponse.Type, + UpdatedAt = fileUpdateResponse.UpdatedAt, + URL = fileUpdateResponse.URL, + VersionInfo = fileUpdateResponse.VersionInfo, + Width = fileUpdateResponse.Width, + }; + + public override void Validate() + { + foreach (var item in this.AITags ?? []) + { + item.Validate(); + } + _ = this.CreatedAt; + _ = this.CustomCoordinates; + if (this.CustomMetadata != null) + { + foreach (var item in this.CustomMetadata.Values) + { + _ = item; + } + } + _ = this.Description; + _ = this.FileID; + _ = this.FilePath; + _ = this.FileType; + _ = this.HasAlpha; + _ = this.Height; + _ = this.IsPrivateFile; + _ = this.IsPublished; + _ = this.Mime; + _ = this.Name; + if (this.SelectedFieldsSchema != null) + { + foreach (var item in this.SelectedFieldsSchema.Values) + { + item.Validate(); + } + } + _ = this.Size; + foreach (var item in this.Tags ?? []) + { + _ = item; + } + _ = this.Thumbnail; + this.Type?.Validate(); + _ = this.UpdatedAt; + _ = this.URL; + this.VersionInfo?.Validate(); + _ = this.Width; + this.ExtensionStatus?.Validate(); + } + + public FileUpdateResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FileUpdateResponse(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static FileUpdateResponse FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParams.cs b/src/Imagekit/Models/Files/FileUploadParams.cs index f9951c2e..68cdceb7 100644 --- a/src/Imagekit/Models/Files/FileUploadParams.cs +++ b/src/Imagekit/Models/Files/FileUploadParams.cs @@ -3,6 +3,7 @@ using System.Net.Http; using System.Text; using System.Text.Json; +using Imagekit.Models.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties; using FileUploadParamsProperties = Imagekit.Models.Files.FileUploadParamsProperties; namespace Imagekit.Models.Files; @@ -477,6 +478,36 @@ public string? PublicKey } } + /// + /// This field is included in the response only if the Path policy feature is + /// available in the plan. It contains schema definitions for the custom metadata + /// fields selected for the specified file path. Field selection can only be done + /// when the Path policy feature is enabled. + /// + /// Keys are the names of the custom metadata fields; the value object has details + /// about the custom metadata schema. + /// + public Dictionary? SelectedFieldsSchema + { + get + { + if (!this.BodyProperties.TryGetValue("selectedFieldsSchema", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.BodyProperties["selectedFieldsSchema"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + /// /// HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key /// as a key. Learn how to create a signature on the page below. This should be diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs new file mode 100644 index 00000000..d16b44d9 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs @@ -0,0 +1,285 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using SelectedFieldsSchemaItemProperties = Imagekit.Models.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class SelectedFieldsSchemaItem : ModelBase, IFromRaw +{ + /// + /// Type of the custom metadata field. + /// + public required ApiEnum Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize< + ApiEnum + >(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The default value for this custom metadata field. The value should match the + /// `type` of custom metadata field. + /// + public SelectedFieldsSchemaItemProperties::DefaultValue? DefaultValue + { + get + { + if (!this.Properties.TryGetValue("defaultValue", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["defaultValue"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies if the custom metadata field is required or not. + /// + public bool? IsValueRequired + { + get + { + if (!this.Properties.TryGetValue("isValueRequired", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["isValueRequired"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. + /// + public double? MaxLength + { + get + { + if (!this.Properties.TryGetValue("maxLength", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["maxLength"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Maximum value of the field. Only set if field type is `Date` or `Number`. + /// For `Date` type field, the value will be in ISO8601 string format. For `Number` + /// type field, it will be a numeric value. + /// + public SelectedFieldsSchemaItemProperties::MaxValue? MaxValue + { + get + { + if (!this.Properties.TryGetValue("maxValue", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["maxValue"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. + /// + public double? MinLength + { + get + { + if (!this.Properties.TryGetValue("minLength", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["minLength"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Minimum value of the field. Only set if field type is `Date` or `Number`. + /// For `Date` type field, the value will be in ISO8601 string format. For `Number` + /// type field, it will be a numeric value. + /// + public SelectedFieldsSchemaItemProperties::MinValue? MinValue + { + get + { + if (!this.Properties.TryGetValue("minValue", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["minValue"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Indicates whether the custom metadata field is read only. A read only field + /// cannot be modified after being set. This field is configurable only via the + /// **Path policy** feature. + /// + public bool? ReadOnly + { + get + { + if (!this.Properties.TryGetValue("readOnly", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["readOnly"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// An array of allowed values when field type is `SingleSelect` or `MultiSelect`. + /// + public List? SelectOptions + { + get + { + if (!this.Properties.TryGetValue("selectOptions", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["selectOptions"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies if the selectOptions array is truncated. It is truncated when number + /// of options are > 100. + /// + public bool? SelectOptionsTruncated + { + get + { + if (!this.Properties.TryGetValue("selectOptionsTruncated", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["selectOptionsTruncated"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.Type.Validate(); + this.DefaultValue?.Validate(); + _ = this.IsValueRequired; + _ = this.MaxLength; + this.MaxValue?.Validate(); + _ = this.MinLength; + this.MinValue?.Validate(); + _ = this.ReadOnly; + foreach (var item in this.SelectOptions ?? []) + { + item.Validate(); + } + _ = this.SelectOptionsTruncated; + } + + public SelectedFieldsSchemaItem() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + SelectedFieldsSchemaItem(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static SelectedFieldsSchemaItem FromRawUnchecked( + Dictionary properties + ) + { + return new(properties); + } + + [SetsRequiredMembers] + public SelectedFieldsSchemaItem(ApiEnum type) + : this() + { + this.Type = type; + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs new file mode 100644 index 00000000..32519654 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs @@ -0,0 +1,175 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties; +using Imagekit.Models.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueVariants; +using System = System; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; + +/// +/// The default value for this custom metadata field. The value should match the +/// `type` of custom metadata field. +/// +[JsonConverter(typeof(DefaultValueConverter))] +public abstract record class DefaultValue +{ + internal DefaultValue() { } + + public static implicit operator DefaultValue(string value) => new String(value); + + public static implicit operator DefaultValue(double value) => new Double(value); + + public static implicit operator DefaultValue(bool value) => new Bool(value); + + public static implicit operator DefaultValue(List value) => + new Mixed(value); + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as String)?.Value; + return value != null; + } + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as Double)?.Value; + return value != null; + } + + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = (this as Bool)?.Value; + return value != null; + } + + public bool TryPickMixed([NotNullWhen(true)] out List? value) + { + value = (this as Mixed)?.Value; + return value != null; + } + + public void Switch( + System::Action @string, + System::Action @double, + System::Action @bool, + System::Action mixed + ) + { + switch (this) + { + case String inner: + @string(inner); + break; + case Double inner: + @double(inner); + break; + case Bool inner: + @bool(inner); + break; + case Mixed inner: + mixed(inner); + break; + default: + throw new System::InvalidOperationException(); + } + } + + public T Match( + System::Func @string, + System::Func @double, + System::Func @bool, + System::Func mixed + ) + { + return this switch + { + String inner => @string(inner), + Double inner => @double(inner), + Bool inner => @bool(inner), + Mixed inner => mixed(inner), + _ => throw new System::InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class DefaultValueConverter : JsonConverter +{ + public override DefaultValue? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new Double(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new Bool(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize>( + ref reader, + options + ); + if (deserialized != null) + { + return new Mixed(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new System::AggregateException(exceptions); + } + + public override void Write( + Utf8JsonWriter writer, + DefaultValue value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + String(var @string) => @string, + Double(var @double) => @double, + Bool(var @bool) => @bool, + Mixed(var mixed) => mixed, + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent5.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent5.cs new file mode 100644 index 00000000..97c275f1 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent5.cs @@ -0,0 +1,140 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties.UnnamedSchemaWithArrayParent5Variants; +using System = System; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties; + +[JsonConverter(typeof(UnnamedSchemaWithArrayParent5Converter))] +public abstract record class UnnamedSchemaWithArrayParent5 +{ + internal UnnamedSchemaWithArrayParent5() { } + + public static implicit operator UnnamedSchemaWithArrayParent5(string value) => + new String(value); + + public static implicit operator UnnamedSchemaWithArrayParent5(double value) => + new Double(value); + + public static implicit operator UnnamedSchemaWithArrayParent5(bool value) => new Bool(value); + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as String)?.Value; + return value != null; + } + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as Double)?.Value; + return value != null; + } + + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = (this as Bool)?.Value; + return value != null; + } + + public void Switch( + System::Action @string, + System::Action @double, + System::Action @bool + ) + { + switch (this) + { + case String inner: + @string(inner); + break; + case Double inner: + @double(inner); + break; + case Bool inner: + @bool(inner); + break; + default: + throw new System::InvalidOperationException(); + } + } + + public T Match( + System::Func @string, + System::Func @double, + System::Func @bool + ) + { + return this switch + { + String inner => @string(inner), + Double inner => @double(inner), + Bool inner => @bool(inner), + _ => throw new System::InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class UnnamedSchemaWithArrayParent5Converter : JsonConverter +{ + public override UnnamedSchemaWithArrayParent5? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new Double(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new Bool(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new System::AggregateException(exceptions); + } + + public override void Write( + Utf8JsonWriter writer, + UnnamedSchemaWithArrayParent5 value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + String(var @string) => @string, + Double(var @double) => @double, + Bool(var @bool) => @bool, + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent5Variants/All.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent5Variants/All.cs new file mode 100644 index 00000000..e9c33ce3 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent5Variants/All.cs @@ -0,0 +1,35 @@ +namespace Imagekit.Models.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties.UnnamedSchemaWithArrayParent5Variants; + +public sealed record class String(string Value) + : UnnamedSchemaWithArrayParent5, + IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Double(double Value) + : UnnamedSchemaWithArrayParent5, + IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Bool(bool Value) : UnnamedSchemaWithArrayParent5, IVariant +{ + public static Bool From(bool value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs new file mode 100644 index 00000000..9b639827 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs @@ -0,0 +1,50 @@ +using System.Collections.Generic; +using Imagekit.Models.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueVariants; + +public sealed record class String(string Value) : DefaultValue, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Double(double Value) : DefaultValue, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Bool(bool Value) : DefaultValue, IVariant +{ + public static Bool From(bool value) + { + return new(value); + } + + public override void Validate() { } +} + +/// +/// Default value should be of type array when custom metadata field type is set to +/// `MultiSelect`. +/// +public sealed record class Mixed(List Value) + : DefaultValue, + IVariant> +{ + public static Mixed From(List value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs new file mode 100644 index 00000000..1a8dcc97 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs @@ -0,0 +1,109 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MaxValueVariants; +using System = System; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; + +/// +/// Maximum value of the field. Only set if field type is `Date` or `Number`. For +/// `Date` type field, the value will be in ISO8601 string format. For `Number` type +/// field, it will be a numeric value. +/// +[JsonConverter(typeof(MaxValueConverter))] +public abstract record class MaxValue +{ + internal MaxValue() { } + + public static implicit operator MaxValue(string value) => new String(value); + + public static implicit operator MaxValue(double value) => new Double(value); + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as String)?.Value; + return value != null; + } + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as Double)?.Value; + return value != null; + } + + public void Switch(System::Action @string, System::Action @double) + { + switch (this) + { + case String inner: + @string(inner); + break; + case Double inner: + @double(inner); + break; + default: + throw new System::InvalidOperationException(); + } + } + + public T Match(System::Func @string, System::Func @double) + { + return this switch + { + String inner => @string(inner), + Double inner => @double(inner), + _ => throw new System::InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class MaxValueConverter : JsonConverter +{ + public override MaxValue? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new Double(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new System::AggregateException(exceptions); + } + + public override void Write(Utf8JsonWriter writer, MaxValue value, JsonSerializerOptions options) + { + object variant = value switch + { + String(var @string) => @string, + Double(var @double) => @double, + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs new file mode 100644 index 00000000..a1e259d1 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs @@ -0,0 +1,21 @@ +namespace Imagekit.Models.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MaxValueVariants; + +public sealed record class String(string Value) : MaxValue, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Double(double Value) : MaxValue, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs new file mode 100644 index 00000000..8f407d1f --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs @@ -0,0 +1,109 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MinValueVariants; +using System = System; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; + +/// +/// Minimum value of the field. Only set if field type is `Date` or `Number`. For +/// `Date` type field, the value will be in ISO8601 string format. For `Number` type +/// field, it will be a numeric value. +/// +[JsonConverter(typeof(MinValueConverter))] +public abstract record class MinValue +{ + internal MinValue() { } + + public static implicit operator MinValue(string value) => new String(value); + + public static implicit operator MinValue(double value) => new Double(value); + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as String)?.Value; + return value != null; + } + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as Double)?.Value; + return value != null; + } + + public void Switch(System::Action @string, System::Action @double) + { + switch (this) + { + case String inner: + @string(inner); + break; + case Double inner: + @double(inner); + break; + default: + throw new System::InvalidOperationException(); + } + } + + public T Match(System::Func @string, System::Func @double) + { + return this switch + { + String inner => @string(inner), + Double inner => @double(inner), + _ => throw new System::InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class MinValueConverter : JsonConverter +{ + public override MinValue? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new Double(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new System::AggregateException(exceptions); + } + + public override void Write(Utf8JsonWriter writer, MinValue value, JsonSerializerOptions options) + { + object variant = value switch + { + String(var @string) => @string, + Double(var @double) => @double, + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs new file mode 100644 index 00000000..894b577c --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs @@ -0,0 +1,21 @@ +namespace Imagekit.Models.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MinValueVariants; + +public sealed record class String(string Value) : MinValue, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Double(double Value) : MinValue, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs new file mode 100644 index 00000000..0cb2862a --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs @@ -0,0 +1,138 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.SelectOptionVariants; +using System = System; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; + +[JsonConverter(typeof(SelectOptionConverter))] +public abstract record class SelectOption +{ + internal SelectOption() { } + + public static implicit operator SelectOption(string value) => new String(value); + + public static implicit operator SelectOption(double value) => new Double(value); + + public static implicit operator SelectOption(bool value) => new Bool(value); + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as String)?.Value; + return value != null; + } + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as Double)?.Value; + return value != null; + } + + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = (this as Bool)?.Value; + return value != null; + } + + public void Switch( + System::Action @string, + System::Action @double, + System::Action @bool + ) + { + switch (this) + { + case String inner: + @string(inner); + break; + case Double inner: + @double(inner); + break; + case Bool inner: + @bool(inner); + break; + default: + throw new System::InvalidOperationException(); + } + } + + public T Match( + System::Func @string, + System::Func @double, + System::Func @bool + ) + { + return this switch + { + String inner => @string(inner), + Double inner => @double(inner), + Bool inner => @bool(inner), + _ => throw new System::InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class SelectOptionConverter : JsonConverter +{ + public override SelectOption? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new Double(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new Bool(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new System::AggregateException(exceptions); + } + + public override void Write( + Utf8JsonWriter writer, + SelectOption value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + String(var @string) => @string, + Double(var @double) => @double, + Bool(var @bool) => @bool, + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs new file mode 100644 index 00000000..e9ca5cc8 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs @@ -0,0 +1,31 @@ +namespace Imagekit.Models.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.SelectOptionVariants; + +public sealed record class String(string Value) : SelectOption, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Double(double Value) : SelectOption, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Bool(bool Value) : SelectOption, IVariant +{ + public static Bool From(bool value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs new file mode 100644 index 00000000..2de35337 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs @@ -0,0 +1,61 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using System = System; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; + +/// +/// Type of the custom metadata field. +/// +[JsonConverter(typeof(TypeConverter))] +public enum Type +{ + Text, + Textarea, + Number, + Date, + Boolean, + SingleSelect, + MultiSelect, +} + +sealed class TypeConverter : JsonConverter +{ + public override Type Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "Text" => SelectedFieldsSchemaItemProperties.Type.Text, + "Textarea" => SelectedFieldsSchemaItemProperties.Type.Textarea, + "Number" => SelectedFieldsSchemaItemProperties.Type.Number, + "Date" => SelectedFieldsSchemaItemProperties.Type.Date, + "Boolean" => SelectedFieldsSchemaItemProperties.Type.Boolean, + "SingleSelect" => SelectedFieldsSchemaItemProperties.Type.SingleSelect, + "MultiSelect" => SelectedFieldsSchemaItemProperties.Type.MultiSelect, + _ => (Type)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + SelectedFieldsSchemaItemProperties.Type.Text => "Text", + SelectedFieldsSchemaItemProperties.Type.Textarea => "Textarea", + SelectedFieldsSchemaItemProperties.Type.Number => "Number", + SelectedFieldsSchemaItemProperties.Type.Date => "Date", + SelectedFieldsSchemaItemProperties.Type.Boolean => "Boolean", + SelectedFieldsSchemaItemProperties.Type.SingleSelect => "SingleSelect", + SelectedFieldsSchemaItemProperties.Type.MultiSelect => "MultiSelect", + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} From a37618772b40763b5191e0ab4713465bd3eb296d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 28 Jan 2026 18:00:59 +0000 Subject: [PATCH 037/129] docs: correct typo in default value description for custom metadata field --- .stats.yml | 4 +- .../CustomMetadataFieldProperties/Schema.cs | 480 +++++++++--------- .../SchemaProperties/DefaultValue.cs | 350 ++++++------- 3 files changed, 417 insertions(+), 417 deletions(-) diff --git a/.stats.yml b/.stats.yml index bceb847c..56e1384b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-7a42233daaf82345cc6d92cc49d4885126176b014c05ea0618c035869319fe53.yml -openapi_spec_hash: c41b1b6062b7c2ea548b16e0462aa358 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-aa4c8e857ae03b12dabf168c83c62f759e2706d69fa4eb77d11519d45a5dada2.yml +openapi_spec_hash: 6ea00242c4685fb6422328f0dd53f9b1 config_hash: e42d7fc3a8c92c35099cc283f9a4467a diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/Schema.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/Schema.cs index c650c1cf..178bdea8 100644 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/Schema.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/Schema.cs @@ -1,240 +1,240 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using SchemaProperties = Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties; - -namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties; - -/// -/// An object that describes the rules for the custom metadata field value. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class Schema : ModelBase, IFromRaw -{ - /// - /// Type of the custom metadata field. - /// - public required ApiEnum Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The default value for this custom metadata field. Date type of default value - /// depends on the field type. - /// - public SchemaProperties::DefaultValue? DefaultValue - { - get - { - if (!this.Properties.TryGetValue("defaultValue", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["defaultValue"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies if the this custom metadata field is required or not. - /// - public bool? IsValueRequired - { - get - { - if (!this.Properties.TryGetValue("isValueRequired", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["isValueRequired"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. - /// - public double? MaxLength - { - get - { - if (!this.Properties.TryGetValue("maxLength", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["maxLength"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Maximum value of the field. Only set if field type is `Date` or `Number`. - /// For `Date` type field, the value will be in ISO8601 string format. For `Number` - /// type field, it will be a numeric value. - /// - public SchemaProperties::MaxValue? MaxValue - { - get - { - if (!this.Properties.TryGetValue("maxValue", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["maxValue"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. - /// - public double? MinLength - { - get - { - if (!this.Properties.TryGetValue("minLength", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["minLength"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Minimum value of the field. Only set if field type is `Date` or `Number`. - /// For `Date` type field, the value will be in ISO8601 string format. For `Number` - /// type field, it will be a numeric value. - /// - public SchemaProperties::MinValue? MinValue - { - get - { - if (!this.Properties.TryGetValue("minValue", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["minValue"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// An array of allowed values when field type is `SingleSelect` or `MultiSelect`. - /// - public List? SelectOptions - { - get - { - if (!this.Properties.TryGetValue("selectOptions", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["selectOptions"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Type.Validate(); - this.DefaultValue?.Validate(); - _ = this.IsValueRequired; - _ = this.MaxLength; - this.MaxValue?.Validate(); - _ = this.MinLength; - this.MinValue?.Validate(); - foreach (var item in this.SelectOptions ?? []) - { - item.Validate(); - } - } - - public Schema() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Schema(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Schema FromRawUnchecked(Dictionary properties) - { - return new(properties); - } - - [SetsRequiredMembers] - public Schema(ApiEnum type) - : this() - { - this.Type = type; - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using SchemaProperties = Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties; + +namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties; + +/// +/// An object that describes the rules for the custom metadata field value. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class Schema : ModelBase, IFromRaw +{ + /// + /// Type of the custom metadata field. + /// + public required ApiEnum Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The default value for this custom metadata field. Data type of default value + /// depends on the field type. + /// + public SchemaProperties::DefaultValue? DefaultValue + { + get + { + if (!this.Properties.TryGetValue("defaultValue", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["defaultValue"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies if the this custom metadata field is required or not. + /// + public bool? IsValueRequired + { + get + { + if (!this.Properties.TryGetValue("isValueRequired", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["isValueRequired"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. + /// + public double? MaxLength + { + get + { + if (!this.Properties.TryGetValue("maxLength", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["maxLength"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Maximum value of the field. Only set if field type is `Date` or `Number`. + /// For `Date` type field, the value will be in ISO8601 string format. For `Number` + /// type field, it will be a numeric value. + /// + public SchemaProperties::MaxValue? MaxValue + { + get + { + if (!this.Properties.TryGetValue("maxValue", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["maxValue"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. + /// + public double? MinLength + { + get + { + if (!this.Properties.TryGetValue("minLength", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["minLength"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Minimum value of the field. Only set if field type is `Date` or `Number`. + /// For `Date` type field, the value will be in ISO8601 string format. For `Number` + /// type field, it will be a numeric value. + /// + public SchemaProperties::MinValue? MinValue + { + get + { + if (!this.Properties.TryGetValue("minValue", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["minValue"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// An array of allowed values when field type is `SingleSelect` or `MultiSelect`. + /// + public List? SelectOptions + { + get + { + if (!this.Properties.TryGetValue("selectOptions", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["selectOptions"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.Type.Validate(); + this.DefaultValue?.Validate(); + _ = this.IsValueRequired; + _ = this.MaxLength; + this.MaxValue?.Validate(); + _ = this.MinLength; + this.MinValue?.Validate(); + foreach (var item in this.SelectOptions ?? []) + { + item.Validate(); + } + } + + public Schema() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Schema(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Schema FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public Schema(ApiEnum type) + : this() + { + this.Type = type; + } +} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValue.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValue.cs index d825c283..221ec9fa 100644 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValue.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValue.cs @@ -1,175 +1,175 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties.DefaultValueProperties; -using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties.DefaultValueVariants; -using System = System; - -namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties; - -/// -/// The default value for this custom metadata field. Date type of default value -/// depends on the field type. -/// -[JsonConverter(typeof(DefaultValueConverter))] -public abstract record class DefaultValue -{ - internal DefaultValue() { } - - public static implicit operator DefaultValue(string value) => new String(value); - - public static implicit operator DefaultValue(double value) => new Double(value); - - public static implicit operator DefaultValue(bool value) => new Bool(value); - - public static implicit operator DefaultValue(List value) => - new Mixed(value); - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = (this as String)?.Value; - return value != null; - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = (this as Double)?.Value; - return value != null; - } - - public bool TryPickBool([NotNullWhen(true)] out bool? value) - { - value = (this as Bool)?.Value; - return value != null; - } - - public bool TryPickMixed([NotNullWhen(true)] out List? value) - { - value = (this as Mixed)?.Value; - return value != null; - } - - public void Switch( - System::Action @string, - System::Action @double, - System::Action @bool, - System::Action mixed - ) - { - switch (this) - { - case String inner: - @string(inner); - break; - case Double inner: - @double(inner); - break; - case Bool inner: - @bool(inner); - break; - case Mixed inner: - mixed(inner); - break; - default: - throw new System::InvalidOperationException(); - } - } - - public T Match( - System::Func @string, - System::Func @double, - System::Func @bool, - System::Func mixed - ) - { - return this switch - { - String inner => @string(inner), - Double inner => @double(inner), - Bool inner => @bool(inner), - Mixed inner => mixed(inner), - _ => throw new System::InvalidOperationException(), - }; - } - - public abstract void Validate(); -} - -sealed class DefaultValueConverter : JsonConverter -{ - public override DefaultValue? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new String(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - try - { - return new Double(JsonSerializer.Deserialize(ref reader, options)); - } - catch (JsonException e) - { - exceptions.Add(e); - } - - try - { - return new Bool(JsonSerializer.Deserialize(ref reader, options)); - } - catch (JsonException e) - { - exceptions.Add(e); - } - - try - { - var deserialized = JsonSerializer.Deserialize>( - ref reader, - options - ); - if (deserialized != null) - { - return new Mixed(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new System::AggregateException(exceptions); - } - - public override void Write( - Utf8JsonWriter writer, - DefaultValue value, - JsonSerializerOptions options - ) - { - object variant = value switch - { - String(var @string) => @string, - Double(var @double) => @double, - Bool(var @bool) => @bool, - Mixed(var mixed) => mixed, - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties.DefaultValueProperties; +using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties.DefaultValueVariants; +using System = System; + +namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties; + +/// +/// The default value for this custom metadata field. Data type of default value +/// depends on the field type. +/// +[JsonConverter(typeof(DefaultValueConverter))] +public abstract record class DefaultValue +{ + internal DefaultValue() { } + + public static implicit operator DefaultValue(string value) => new String(value); + + public static implicit operator DefaultValue(double value) => new Double(value); + + public static implicit operator DefaultValue(bool value) => new Bool(value); + + public static implicit operator DefaultValue(List value) => + new Mixed(value); + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as String)?.Value; + return value != null; + } + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as Double)?.Value; + return value != null; + } + + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = (this as Bool)?.Value; + return value != null; + } + + public bool TryPickMixed([NotNullWhen(true)] out List? value) + { + value = (this as Mixed)?.Value; + return value != null; + } + + public void Switch( + System::Action @string, + System::Action @double, + System::Action @bool, + System::Action mixed + ) + { + switch (this) + { + case String inner: + @string(inner); + break; + case Double inner: + @double(inner); + break; + case Bool inner: + @bool(inner); + break; + case Mixed inner: + mixed(inner); + break; + default: + throw new System::InvalidOperationException(); + } + } + + public T Match( + System::Func @string, + System::Func @double, + System::Func @bool, + System::Func mixed + ) + { + return this switch + { + String inner => @string(inner), + Double inner => @double(inner), + Bool inner => @bool(inner), + Mixed inner => mixed(inner), + _ => throw new System::InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class DefaultValueConverter : JsonConverter +{ + public override DefaultValue? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new Double(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new Bool(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize>( + ref reader, + options + ); + if (deserialized != null) + { + return new Mixed(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new System::AggregateException(exceptions); + } + + public override void Write( + Utf8JsonWriter writer, + DefaultValue value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + String(var @string) => @string, + Double(var @double) => @double, + Bool(var @bool) => @bool, + Mixed(var mixed) => mixed, + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} From 351bd8b5257ef15e730a4d6d75a3376bd0e6ec88 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 28 Jan 2026 18:02:06 +0000 Subject: [PATCH 038/129] feat(api): fix upload API request params --- .stats.yml | 4 +- src/Imagekit/ModelBase.cs | 12 +- .../Models/Beta/V2/Files/FileUploadParams.cs | 31 - .../Beta/V2/Files/FileUploadResponse.cs | 1270 +++++++++-------- .../SelectedFieldsSchemaItem.cs | 4 +- .../DefaultValue.cs | 6 +- .../UnnamedSchemaWithArrayParent6.cs | 4 +- .../All.cs | 2 +- .../DefaultValueVariants/All.cs | 4 +- .../MaxValue.cs | 4 +- .../MaxValueVariants/All.cs | 2 +- .../MinValue.cs | 4 +- .../MinValueVariants/All.cs | 2 +- .../SelectOption.cs | 4 +- .../SelectOptionVariants/All.cs | 2 +- .../Type.cs | 2 +- src/Imagekit/Models/Files/FileUploadParams.cs | 31 - .../Models/Files/FileUploadResponse.cs | 1262 ++++++++-------- .../SelectedFieldsSchemaItem.cs | 4 +- .../DefaultValue.cs | 6 +- .../UnnamedSchemaWithArrayParent5.cs | 4 +- .../All.cs | 2 +- .../DefaultValueVariants/All.cs | 4 +- .../MaxValue.cs | 4 +- .../MaxValueVariants/All.cs | 2 +- .../MinValue.cs | 4 +- .../MinValueVariants/All.cs | 2 +- .../SelectOption.cs | 4 +- .../SelectOptionVariants/All.cs | 2 +- .../Type.cs | 2 +- .../IntersectionMember1Properties/Data.cs | 1264 ++++++++-------- .../SelectedFieldsSchemaItem.cs | 285 ++++ .../DefaultValue.cs | 175 +++ .../UnnamedSchemaWithArrayParent7.cs | 140 ++ .../All.cs | 35 + .../DefaultValueVariants/All.cs | 50 + .../MaxValue.cs | 109 ++ .../MaxValueVariants/All.cs | 21 + .../MinValue.cs | 109 ++ .../MinValueVariants/All.cs | 21 + .../SelectOption.cs | 138 ++ .../SelectOptionVariants/All.cs | 31 + .../Type.cs | 61 + 43 files changed, 3180 insertions(+), 1949 deletions(-) rename src/Imagekit/Models/Beta/V2/Files/{FileUploadParamsProperties => FileUploadResponseProperties}/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs (94%) rename src/Imagekit/Models/Beta/V2/Files/{FileUploadParamsProperties => FileUploadResponseProperties}/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs (88%) rename src/Imagekit/Models/Beta/V2/Files/{FileUploadParamsProperties => FileUploadResponseProperties}/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent6.cs (88%) rename src/Imagekit/Models/Beta/V2/Files/{FileUploadParamsProperties => FileUploadResponseProperties}/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent6Variants/All.cs (75%) rename src/Imagekit/Models/Beta/V2/Files/{FileUploadParamsProperties => FileUploadResponseProperties}/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs (75%) rename src/Imagekit/Models/Beta/V2/Files/{FileUploadParamsProperties => FileUploadResponseProperties}/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs (88%) rename src/Imagekit/Models/Beta/V2/Files/{FileUploadParamsProperties => FileUploadResponseProperties}/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs (71%) rename src/Imagekit/Models/Beta/V2/Files/{FileUploadParamsProperties => FileUploadResponseProperties}/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs (88%) rename src/Imagekit/Models/Beta/V2/Files/{FileUploadParamsProperties => FileUploadResponseProperties}/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs (71%) rename src/Imagekit/Models/Beta/V2/Files/{FileUploadParamsProperties => FileUploadResponseProperties}/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs (89%) rename src/Imagekit/Models/Beta/V2/Files/{FileUploadParamsProperties => FileUploadResponseProperties}/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs (77%) rename src/Imagekit/Models/Beta/V2/Files/{FileUploadParamsProperties => FileUploadResponseProperties}/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs (91%) rename src/Imagekit/Models/Files/{FileUploadParamsProperties => FileUploadResponseProperties}/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs (94%) rename src/Imagekit/Models/Files/{FileUploadParamsProperties => FileUploadResponseProperties}/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs (88%) rename src/Imagekit/Models/Files/{FileUploadParamsProperties => FileUploadResponseProperties}/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent5.cs (88%) rename src/Imagekit/Models/Files/{FileUploadParamsProperties => FileUploadResponseProperties}/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent5Variants/All.cs (76%) rename src/Imagekit/Models/Files/{FileUploadParamsProperties => FileUploadResponseProperties}/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs (76%) rename src/Imagekit/Models/Files/{FileUploadParamsProperties => FileUploadResponseProperties}/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs (88%) rename src/Imagekit/Models/Files/{FileUploadParamsProperties => FileUploadResponseProperties}/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs (72%) rename src/Imagekit/Models/Files/{FileUploadParamsProperties => FileUploadResponseProperties}/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs (88%) rename src/Imagekit/Models/Files/{FileUploadParamsProperties => FileUploadResponseProperties}/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs (72%) rename src/Imagekit/Models/Files/{FileUploadParamsProperties => FileUploadResponseProperties}/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs (89%) rename src/Imagekit/Models/Files/{FileUploadParamsProperties => FileUploadResponseProperties}/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs (78%) rename src/Imagekit/Models/Files/{FileUploadParamsProperties => FileUploadResponseProperties}/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs (91%) create mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs create mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs create mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent7.cs create mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent7Variants/All.cs create mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs create mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs create mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs create mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs create mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs create mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs create mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs create mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs diff --git a/.stats.yml b/.stats.yml index 56e1384b..0c9c486c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-aa4c8e857ae03b12dabf168c83c62f759e2706d69fa4eb77d11519d45a5dada2.yml -openapi_spec_hash: 6ea00242c4685fb6422328f0dd53f9b1 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-01aef94bd928f40b7209dc21df71e2312d4bee430119b30ee05d75cf5e1b4801.yml +openapi_spec_hash: 054c332db88b23d362f72583dd24b2aa config_hash: e42d7fc3a8c92c35099cc283f9a4467a diff --git a/src/Imagekit/ModelBase.cs b/src/Imagekit/ModelBase.cs index a2d49a73..18896c48 100644 --- a/src/Imagekit/ModelBase.cs +++ b/src/Imagekit/ModelBase.cs @@ -78,11 +78,11 @@ public abstract record class ModelBase new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), - new ApiEnumConverter(), new ApiEnumConverter< string, - global::Imagekit.Models.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.Type + global::Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.Type >(), + new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), @@ -108,11 +108,11 @@ public abstract record class ModelBase >(), new ApiEnumConverter< string, - global::Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.ResponseField + global::Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.Type >(), new ApiEnumConverter< string, - global::Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.Type + global::Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.ResponseField >(), new ApiEnumConverter(), new ApiEnumConverter< @@ -147,6 +147,10 @@ public abstract record class ModelBase string, global::Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.ExtensionStatusProperties.RemoveBg >(), + new ApiEnumConverter< + string, + global::Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.Type + >(), new ApiEnumConverter< string, global::Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.IntersectionMember1Properties.DataProperties.TransformationProperties.Type diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParams.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParams.cs index 9f761ae3..217968e5 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParams.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParams.cs @@ -3,7 +3,6 @@ using System.Net.Http; using System.Text; using System.Text.Json; -using Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties; using FileUploadParamsProperties = Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties; namespace Imagekit.Models.Beta.V2.Files; @@ -427,36 +426,6 @@ public bool? OverwriteTags } } - /// - /// This field is included in the response only if the Path policy feature is - /// available in the plan. It contains schema definitions for the custom metadata - /// fields selected for the specified file path. Field selection can only be done - /// when the Path policy feature is enabled. - /// - /// Keys are the names of the custom metadata fields; the value object has details - /// about the custom metadata schema. - /// - public Dictionary? SelectedFieldsSchema - { - get - { - if (!this.BodyProperties.TryGetValue("selectedFieldsSchema", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.BodyProperties["selectedFieldsSchema"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - /// /// Set the tags while uploading the file. Provide an array of tag strings (e.g. /// `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponse.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponse.cs index 723b749b..8a2aaf32 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponse.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponse.cs @@ -1,616 +1,654 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties; -using Files = Imagekit.Models.Files; - -namespace Imagekit.Models.Beta.V2.Files; - -/// -/// Object containing details of a successful upload. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class FileUploadResponse : ModelBase, IFromRaw -{ - /// - /// An array of tags assigned to the uploaded file by auto tagging. - /// - public List? AITags - { - get - { - if (!this.Properties.TryGetValue("AITags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["AITags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The audio codec used in the video (only for video). - /// - public string? AudioCodec - { - get - { - if (!this.Properties.TryGetValue("audioCodec", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["audioCodec"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The bit rate of the video in kbps (only for video). - /// - public long? BitRate - { - get - { - if (!this.Properties.TryGetValue("bitRate", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["bitRate"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Value of custom coordinates associated with the image in the format `x,y,width,height`. - /// If `customCoordinates` are not defined, then it is `null`. Send `customCoordinates` - /// in `responseFields` in API request to get the value of this field. - /// - public string? CustomCoordinates - { - get - { - if (!this.Properties.TryGetValue("customCoordinates", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["customCoordinates"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// A key-value data associated with the asset. Use `responseField` in API request - /// to get `customMetadata` in the upload API response. Before setting any custom - /// metadata on an asset, you have to create the field using custom metadata - /// fields API. Send `customMetadata` in `responseFields` in API request to get - /// the value of this field. - /// - public Dictionary? CustomMetadata - { - get - { - if (!this.Properties.TryGetValue("customMetadata", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["customMetadata"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Optional text to describe the contents of the file. Can be set by the user - /// or the ai-auto-description extension. - /// - public string? Description - { - get - { - if (!this.Properties.TryGetValue("description", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["description"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The duration of the video in seconds (only for video). - /// - public long? Duration - { - get - { - if (!this.Properties.TryGetValue("duration", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["duration"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Consolidated embedded metadata associated with the file. It includes exif, - /// iptc, and xmp data. Send `embeddedMetadata` in `responseFields` in API request - /// to get embeddedMetadata in the upload API response. - /// - public Dictionary? EmbeddedMetadata - { - get - { - if (!this.Properties.TryGetValue("embeddedMetadata", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["embeddedMetadata"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Extension names with their processing status at the time of completion of - /// the request. It could have one of the following status values: - /// - /// `success`: The extension has been successfully applied. `failed`: The extension - /// has failed and will not be retried. `pending`: The extension will finish processing - /// in some time. On completion, the final status (success / failed) will be sent - /// to the `webhookUrl` provided. - /// - /// If no extension was requested, then this parameter is not returned. - /// - public ExtensionStatus? ExtensionStatus - { - get - { - if (!this.Properties.TryGetValue("extensionStatus", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["extensionStatus"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Unique fileId. Store this fileld in your database, as this will be used to - /// perform update action on this file. - /// - public string? FileID - { - get - { - if (!this.Properties.TryGetValue("fileId", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["fileId"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The relative path of the file in the media library e.g. `/marketing-assets/new-banner.jpg`. - /// - public string? FilePath - { - get - { - if (!this.Properties.TryGetValue("filePath", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["filePath"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Type of the uploaded file. Possible values are `image`, `non-image`. - /// - public string? FileType - { - get - { - if (!this.Properties.TryGetValue("fileType", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["fileType"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Height of the image in pixels (Only for images) - /// - public double? Height - { - get - { - if (!this.Properties.TryGetValue("height", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["height"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Is the file marked as private. It can be either `true` or `false`. Send `isPrivateFile` - /// in `responseFields` in API request to get the value of this field. - /// - public bool? IsPrivateFile - { - get - { - if (!this.Properties.TryGetValue("isPrivateFile", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["isPrivateFile"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Is the file published or in draft state. It can be either `true` or `false`. - /// Send `isPublished` in `responseFields` in API request to get the value of - /// this field. - /// - public bool? IsPublished - { - get - { - if (!this.Properties.TryGetValue("isPublished", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["isPublished"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Legacy metadata. Send `metadata` in `responseFields` in API request to get - /// metadata in the upload API response. - /// - public Files::Metadata? Metadata - { - get - { - if (!this.Properties.TryGetValue("metadata", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["metadata"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Name of the asset. - /// - public string? Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Size of the image file in Bytes. - /// - public double? Size - { - get - { - if (!this.Properties.TryGetValue("size", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["size"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The array of tags associated with the asset. If no tags are set, it will - /// be `null`. Send `tags` in `responseFields` in API request to get the value - /// of this field. - /// - public List? Tags - { - get - { - if (!this.Properties.TryGetValue("tags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["tags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// In the case of an image, a small thumbnail URL. - /// - public string? ThumbnailURL - { - get - { - if (!this.Properties.TryGetValue("thumbnailUrl", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["thumbnailUrl"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// A publicly accessible URL of the file. - /// - public string? URL - { - get - { - if (!this.Properties.TryGetValue("url", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["url"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// An object containing the file or file version's `id` (versionId) and `name`. - /// - public VersionInfo? VersionInfo - { - get - { - if (!this.Properties.TryGetValue("versionInfo", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["versionInfo"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The video codec used in the video (only for video). - /// - public string? VideoCodec - { - get - { - if (!this.Properties.TryGetValue("videoCodec", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["videoCodec"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Width of the image in pixels (Only for Images) - /// - public double? Width - { - get - { - if (!this.Properties.TryGetValue("width", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["width"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - foreach (var item in this.AITags ?? []) - { - item.Validate(); - } - _ = this.AudioCodec; - _ = this.BitRate; - _ = this.CustomCoordinates; - if (this.CustomMetadata != null) - { - foreach (var item in this.CustomMetadata.Values) - { - _ = item; - } - } - _ = this.Description; - _ = this.Duration; - if (this.EmbeddedMetadata != null) - { - foreach (var item in this.EmbeddedMetadata.Values) - { - _ = item; - } - } - this.ExtensionStatus?.Validate(); - _ = this.FileID; - _ = this.FilePath; - _ = this.FileType; - _ = this.Height; - _ = this.IsPrivateFile; - _ = this.IsPublished; - this.Metadata?.Validate(); - _ = this.Name; - _ = this.Size; - foreach (var item in this.Tags ?? []) - { - _ = item; - } - _ = this.ThumbnailURL; - _ = this.URL; - this.VersionInfo?.Validate(); - _ = this.VideoCodec; - _ = this.Width; - } - - public FileUploadResponse() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - FileUploadResponse(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static FileUploadResponse FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties; +using Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties; +using Files = Imagekit.Models.Files; + +namespace Imagekit.Models.Beta.V2.Files; + +/// +/// Object containing details of a successful upload. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class FileUploadResponse : ModelBase, IFromRaw +{ + /// + /// An array of tags assigned to the uploaded file by auto tagging. + /// + public List? AITags + { + get + { + if (!this.Properties.TryGetValue("AITags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["AITags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The audio codec used in the video (only for video). + /// + public string? AudioCodec + { + get + { + if (!this.Properties.TryGetValue("audioCodec", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["audioCodec"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The bit rate of the video in kbps (only for video). + /// + public long? BitRate + { + get + { + if (!this.Properties.TryGetValue("bitRate", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["bitRate"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Value of custom coordinates associated with the image in the format `x,y,width,height`. + /// If `customCoordinates` are not defined, then it is `null`. Send `customCoordinates` + /// in `responseFields` in API request to get the value of this field. + /// + public string? CustomCoordinates + { + get + { + if (!this.Properties.TryGetValue("customCoordinates", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["customCoordinates"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// A key-value data associated with the asset. Use `responseField` in API request + /// to get `customMetadata` in the upload API response. Before setting any custom + /// metadata on an asset, you have to create the field using custom metadata + /// fields API. Send `customMetadata` in `responseFields` in API request to get + /// the value of this field. + /// + public Dictionary? CustomMetadata + { + get + { + if (!this.Properties.TryGetValue("customMetadata", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["customMetadata"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Optional text to describe the contents of the file. Can be set by the user + /// or the ai-auto-description extension. + /// + public string? Description + { + get + { + if (!this.Properties.TryGetValue("description", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["description"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The duration of the video in seconds (only for video). + /// + public long? Duration + { + get + { + if (!this.Properties.TryGetValue("duration", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["duration"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Consolidated embedded metadata associated with the file. It includes exif, + /// iptc, and xmp data. Send `embeddedMetadata` in `responseFields` in API request + /// to get embeddedMetadata in the upload API response. + /// + public Dictionary? EmbeddedMetadata + { + get + { + if (!this.Properties.TryGetValue("embeddedMetadata", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["embeddedMetadata"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Extension names with their processing status at the time of completion of + /// the request. It could have one of the following status values: + /// + /// `success`: The extension has been successfully applied. `failed`: The extension + /// has failed and will not be retried. `pending`: The extension will finish processing + /// in some time. On completion, the final status (success / failed) will be sent + /// to the `webhookUrl` provided. + /// + /// If no extension was requested, then this parameter is not returned. + /// + public ExtensionStatus? ExtensionStatus + { + get + { + if (!this.Properties.TryGetValue("extensionStatus", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["extensionStatus"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Unique fileId. Store this fileld in your database, as this will be used to + /// perform update action on this file. + /// + public string? FileID + { + get + { + if (!this.Properties.TryGetValue("fileId", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["fileId"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The relative path of the file in the media library e.g. `/marketing-assets/new-banner.jpg`. + /// + public string? FilePath + { + get + { + if (!this.Properties.TryGetValue("filePath", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["filePath"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Type of the uploaded file. Possible values are `image`, `non-image`. + /// + public string? FileType + { + get + { + if (!this.Properties.TryGetValue("fileType", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["fileType"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Height of the image in pixels (Only for images) + /// + public double? Height + { + get + { + if (!this.Properties.TryGetValue("height", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["height"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Is the file marked as private. It can be either `true` or `false`. Send `isPrivateFile` + /// in `responseFields` in API request to get the value of this field. + /// + public bool? IsPrivateFile + { + get + { + if (!this.Properties.TryGetValue("isPrivateFile", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["isPrivateFile"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Is the file published or in draft state. It can be either `true` or `false`. + /// Send `isPublished` in `responseFields` in API request to get the value of + /// this field. + /// + public bool? IsPublished + { + get + { + if (!this.Properties.TryGetValue("isPublished", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["isPublished"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Legacy metadata. Send `metadata` in `responseFields` in API request to get + /// metadata in the upload API response. + /// + public Files::Metadata? Metadata + { + get + { + if (!this.Properties.TryGetValue("metadata", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["metadata"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Name of the asset. + /// + public string? Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// This field is included in the response only if the Path policy feature is + /// available in the plan. It contains schema definitions for the custom metadata + /// fields selected for the specified file path. Field selection can only be done + /// when the Path policy feature is enabled. + /// + /// Keys are the names of the custom metadata fields; the value object has details + /// about the custom metadata schema. + /// + public Dictionary? SelectedFieldsSchema + { + get + { + if (!this.Properties.TryGetValue("selectedFieldsSchema", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["selectedFieldsSchema"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Size of the image file in Bytes. + /// + public double? Size + { + get + { + if (!this.Properties.TryGetValue("size", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["size"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The array of tags associated with the asset. If no tags are set, it will + /// be `null`. Send `tags` in `responseFields` in API request to get the value + /// of this field. + /// + public List? Tags + { + get + { + if (!this.Properties.TryGetValue("tags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["tags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// In the case of an image, a small thumbnail URL. + /// + public string? ThumbnailURL + { + get + { + if (!this.Properties.TryGetValue("thumbnailUrl", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["thumbnailUrl"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// A publicly accessible URL of the file. + /// + public string? URL + { + get + { + if (!this.Properties.TryGetValue("url", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["url"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// An object containing the file or file version's `id` (versionId) and `name`. + /// + public VersionInfo? VersionInfo + { + get + { + if (!this.Properties.TryGetValue("versionInfo", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["versionInfo"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The video codec used in the video (only for video). + /// + public string? VideoCodec + { + get + { + if (!this.Properties.TryGetValue("videoCodec", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["videoCodec"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Width of the image in pixels (Only for Images) + /// + public double? Width + { + get + { + if (!this.Properties.TryGetValue("width", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["width"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + foreach (var item in this.AITags ?? []) + { + item.Validate(); + } + _ = this.AudioCodec; + _ = this.BitRate; + _ = this.CustomCoordinates; + if (this.CustomMetadata != null) + { + foreach (var item in this.CustomMetadata.Values) + { + _ = item; + } + } + _ = this.Description; + _ = this.Duration; + if (this.EmbeddedMetadata != null) + { + foreach (var item in this.EmbeddedMetadata.Values) + { + _ = item; + } + } + this.ExtensionStatus?.Validate(); + _ = this.FileID; + _ = this.FilePath; + _ = this.FileType; + _ = this.Height; + _ = this.IsPrivateFile; + _ = this.IsPublished; + this.Metadata?.Validate(); + _ = this.Name; + if (this.SelectedFieldsSchema != null) + { + foreach (var item in this.SelectedFieldsSchema.Values) + { + item.Validate(); + } + } + _ = this.Size; + foreach (var item in this.Tags ?? []) + { + _ = item; + } + _ = this.ThumbnailURL; + _ = this.URL; + this.VersionInfo?.Validate(); + _ = this.VideoCodec; + _ = this.Width; + } + + public FileUploadResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FileUploadResponse(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static FileUploadResponse FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs similarity index 94% rename from src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs rename to src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs index a464b0be..1a668162 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs @@ -3,9 +3,9 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using SelectedFieldsSchemaItemProperties = Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; +using SelectedFieldsSchemaItemProperties = Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; -namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties; +namespace Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties; [JsonConverter(typeof(ModelConverter))] public sealed record class SelectedFieldsSchemaItem : ModelBase, IFromRaw diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs similarity index 88% rename from src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs rename to src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs index f50cc93c..48776045 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs @@ -2,11 +2,11 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties; -using Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueVariants; +using Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties; +using Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueVariants; using System = System; -namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; +namespace Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; /// /// The default value for this custom metadata field. The value should match the diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent6.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent6.cs similarity index 88% rename from src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent6.cs rename to src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent6.cs index c5c11caf..fcc84c16 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent6.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent6.cs @@ -2,10 +2,10 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties.UnnamedSchemaWithArrayParent6Variants; +using Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties.UnnamedSchemaWithArrayParent6Variants; using System = System; -namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties; +namespace Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties; [JsonConverter(typeof(UnnamedSchemaWithArrayParent6Converter))] public abstract record class UnnamedSchemaWithArrayParent6 diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent6Variants/All.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent6Variants/All.cs similarity index 75% rename from src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent6Variants/All.cs rename to src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent6Variants/All.cs index cefdec9a..87cf07c3 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent6Variants/All.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent6Variants/All.cs @@ -1,4 +1,4 @@ -namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties.UnnamedSchemaWithArrayParent6Variants; +namespace Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties.UnnamedSchemaWithArrayParent6Variants; public sealed record class String(string Value) : UnnamedSchemaWithArrayParent6, diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs similarity index 75% rename from src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs rename to src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs index 4aef728b..3215077b 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; -using Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties; +using Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties; -namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueVariants; +namespace Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueVariants; public sealed record class String(string Value) : DefaultValue, IVariant { diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs similarity index 88% rename from src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs rename to src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs index 3087a60d..e308a468 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs @@ -2,10 +2,10 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MaxValueVariants; +using Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MaxValueVariants; using System = System; -namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; +namespace Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; /// /// Maximum value of the field. Only set if field type is `Date` or `Number`. For diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs similarity index 71% rename from src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs rename to src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs index 93b9bb6f..307485bb 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs @@ -1,4 +1,4 @@ -namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MaxValueVariants; +namespace Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MaxValueVariants; public sealed record class String(string Value) : MaxValue, IVariant { diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs similarity index 88% rename from src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs rename to src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs index 5830e59d..e67d5f8e 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs @@ -2,10 +2,10 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MinValueVariants; +using Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MinValueVariants; using System = System; -namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; +namespace Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; /// /// Minimum value of the field. Only set if field type is `Date` or `Number`. For diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs similarity index 71% rename from src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs rename to src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs index a2b979c2..64552e00 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs @@ -1,4 +1,4 @@ -namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MinValueVariants; +namespace Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MinValueVariants; public sealed record class String(string Value) : MinValue, IVariant { diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs similarity index 89% rename from src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs rename to src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs index b6d8dea0..5dd0fd13 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs @@ -2,10 +2,10 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.SelectOptionVariants; +using Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.SelectOptionVariants; using System = System; -namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; +namespace Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; [JsonConverter(typeof(SelectOptionConverter))] public abstract record class SelectOption diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs similarity index 77% rename from src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs rename to src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs index a4c3468e..be64f591 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs @@ -1,4 +1,4 @@ -namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.SelectOptionVariants; +namespace Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.SelectOptionVariants; public sealed record class String(string Value) : SelectOption, IVariant { diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs similarity index 91% rename from src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs rename to src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs index df93e8c5..0bf374c9 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs @@ -2,7 +2,7 @@ using System.Text.Json.Serialization; using System = System; -namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; +namespace Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; /// /// Type of the custom metadata field. diff --git a/src/Imagekit/Models/Files/FileUploadParams.cs b/src/Imagekit/Models/Files/FileUploadParams.cs index 68cdceb7..f9951c2e 100644 --- a/src/Imagekit/Models/Files/FileUploadParams.cs +++ b/src/Imagekit/Models/Files/FileUploadParams.cs @@ -3,7 +3,6 @@ using System.Net.Http; using System.Text; using System.Text.Json; -using Imagekit.Models.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties; using FileUploadParamsProperties = Imagekit.Models.Files.FileUploadParamsProperties; namespace Imagekit.Models.Files; @@ -478,36 +477,6 @@ public string? PublicKey } } - /// - /// This field is included in the response only if the Path policy feature is - /// available in the plan. It contains schema definitions for the custom metadata - /// fields selected for the specified file path. Field selection can only be done - /// when the Path policy feature is enabled. - /// - /// Keys are the names of the custom metadata fields; the value object has details - /// about the custom metadata schema. - /// - public Dictionary? SelectedFieldsSchema - { - get - { - if (!this.BodyProperties.TryGetValue("selectedFieldsSchema", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.BodyProperties["selectedFieldsSchema"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - /// /// HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key /// as a key. Learn how to create a signature on the page below. This should be diff --git a/src/Imagekit/Models/Files/FileUploadResponse.cs b/src/Imagekit/Models/Files/FileUploadResponse.cs index 1321dab1..6b2dadb8 100644 --- a/src/Imagekit/Models/Files/FileUploadResponse.cs +++ b/src/Imagekit/Models/Files/FileUploadResponse.cs @@ -1,612 +1,650 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Files.FileUploadResponseProperties; - -namespace Imagekit.Models.Files; - -/// -/// Object containing details of a successful upload. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class FileUploadResponse : ModelBase, IFromRaw -{ - /// - /// An array of tags assigned to the uploaded file by auto tagging. - /// - public List? AITags - { - get - { - if (!this.Properties.TryGetValue("AITags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["AITags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The audio codec used in the video (only for video). - /// - public string? AudioCodec - { - get - { - if (!this.Properties.TryGetValue("audioCodec", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["audioCodec"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The bit rate of the video in kbps (only for video). - /// - public long? BitRate - { - get - { - if (!this.Properties.TryGetValue("bitRate", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["bitRate"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Value of custom coordinates associated with the image in the format `x,y,width,height`. - /// If `customCoordinates` are not defined, then it is `null`. Send `customCoordinates` - /// in `responseFields` in API request to get the value of this field. - /// - public string? CustomCoordinates - { - get - { - if (!this.Properties.TryGetValue("customCoordinates", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["customCoordinates"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// A key-value data associated with the asset. Use `responseField` in API request - /// to get `customMetadata` in the upload API response. Before setting any custom - /// metadata on an asset, you have to create the field using custom metadata - /// fields API. Send `customMetadata` in `responseFields` in API request to get - /// the value of this field. - /// - public Dictionary? CustomMetadata - { - get - { - if (!this.Properties.TryGetValue("customMetadata", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["customMetadata"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Optional text to describe the contents of the file. Can be set by the user - /// or the ai-auto-description extension. - /// - public string? Description - { - get - { - if (!this.Properties.TryGetValue("description", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["description"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The duration of the video in seconds (only for video). - /// - public long? Duration - { - get - { - if (!this.Properties.TryGetValue("duration", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["duration"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Consolidated embedded metadata associated with the file. It includes exif, - /// iptc, and xmp data. Send `embeddedMetadata` in `responseFields` in API request - /// to get embeddedMetadata in the upload API response. - /// - public Dictionary? EmbeddedMetadata - { - get - { - if (!this.Properties.TryGetValue("embeddedMetadata", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["embeddedMetadata"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Extension names with their processing status at the time of completion of - /// the request. It could have one of the following status values: - /// - /// `success`: The extension has been successfully applied. `failed`: The extension - /// has failed and will not be retried. `pending`: The extension will finish processing - /// in some time. On completion, the final status (success / failed) will be sent - /// to the `webhookUrl` provided. - /// - /// If no extension was requested, then this parameter is not returned. - /// - public ExtensionStatus? ExtensionStatus - { - get - { - if (!this.Properties.TryGetValue("extensionStatus", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["extensionStatus"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Unique fileId. Store this fileld in your database, as this will be used to - /// perform update action on this file. - /// - public string? FileID - { - get - { - if (!this.Properties.TryGetValue("fileId", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["fileId"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The relative path of the file in the media library e.g. `/marketing-assets/new-banner.jpg`. - /// - public string? FilePath - { - get - { - if (!this.Properties.TryGetValue("filePath", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["filePath"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Type of the uploaded file. Possible values are `image`, `non-image`. - /// - public string? FileType - { - get - { - if (!this.Properties.TryGetValue("fileType", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["fileType"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Height of the image in pixels (Only for images) - /// - public double? Height - { - get - { - if (!this.Properties.TryGetValue("height", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["height"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Is the file marked as private. It can be either `true` or `false`. Send `isPrivateFile` - /// in `responseFields` in API request to get the value of this field. - /// - public bool? IsPrivateFile - { - get - { - if (!this.Properties.TryGetValue("isPrivateFile", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["isPrivateFile"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Is the file published or in draft state. It can be either `true` or `false`. - /// Send `isPublished` in `responseFields` in API request to get the value of - /// this field. - /// - public bool? IsPublished - { - get - { - if (!this.Properties.TryGetValue("isPublished", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["isPublished"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Legacy metadata. Send `metadata` in `responseFields` in API request to get - /// metadata in the upload API response. - /// - public Metadata? Metadata - { - get - { - if (!this.Properties.TryGetValue("metadata", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["metadata"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Name of the asset. - /// - public string? Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Size of the image file in Bytes. - /// - public double? Size - { - get - { - if (!this.Properties.TryGetValue("size", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["size"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The array of tags associated with the asset. If no tags are set, it will - /// be `null`. Send `tags` in `responseFields` in API request to get the value - /// of this field. - /// - public List? Tags - { - get - { - if (!this.Properties.TryGetValue("tags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["tags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// In the case of an image, a small thumbnail URL. - /// - public string? ThumbnailURL - { - get - { - if (!this.Properties.TryGetValue("thumbnailUrl", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["thumbnailUrl"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// A publicly accessible URL of the file. - /// - public string? URL - { - get - { - if (!this.Properties.TryGetValue("url", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["url"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// An object containing the file or file version's `id` (versionId) and `name`. - /// - public VersionInfo? VersionInfo - { - get - { - if (!this.Properties.TryGetValue("versionInfo", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["versionInfo"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The video codec used in the video (only for video). - /// - public string? VideoCodec - { - get - { - if (!this.Properties.TryGetValue("videoCodec", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["videoCodec"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Width of the image in pixels (Only for Images) - /// - public double? Width - { - get - { - if (!this.Properties.TryGetValue("width", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["width"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - foreach (var item in this.AITags ?? []) - { - item.Validate(); - } - _ = this.AudioCodec; - _ = this.BitRate; - _ = this.CustomCoordinates; - if (this.CustomMetadata != null) - { - foreach (var item in this.CustomMetadata.Values) - { - _ = item; - } - } - _ = this.Description; - _ = this.Duration; - if (this.EmbeddedMetadata != null) - { - foreach (var item in this.EmbeddedMetadata.Values) - { - _ = item; - } - } - this.ExtensionStatus?.Validate(); - _ = this.FileID; - _ = this.FilePath; - _ = this.FileType; - _ = this.Height; - _ = this.IsPrivateFile; - _ = this.IsPublished; - this.Metadata?.Validate(); - _ = this.Name; - _ = this.Size; - foreach (var item in this.Tags ?? []) - { - _ = item; - } - _ = this.ThumbnailURL; - _ = this.URL; - this.VersionInfo?.Validate(); - _ = this.VideoCodec; - _ = this.Width; - } - - public FileUploadResponse() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - FileUploadResponse(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static FileUploadResponse FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files.FileUploadResponseProperties; +using Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties; + +namespace Imagekit.Models.Files; + +/// +/// Object containing details of a successful upload. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class FileUploadResponse : ModelBase, IFromRaw +{ + /// + /// An array of tags assigned to the uploaded file by auto tagging. + /// + public List? AITags + { + get + { + if (!this.Properties.TryGetValue("AITags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["AITags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The audio codec used in the video (only for video). + /// + public string? AudioCodec + { + get + { + if (!this.Properties.TryGetValue("audioCodec", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["audioCodec"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The bit rate of the video in kbps (only for video). + /// + public long? BitRate + { + get + { + if (!this.Properties.TryGetValue("bitRate", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["bitRate"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Value of custom coordinates associated with the image in the format `x,y,width,height`. + /// If `customCoordinates` are not defined, then it is `null`. Send `customCoordinates` + /// in `responseFields` in API request to get the value of this field. + /// + public string? CustomCoordinates + { + get + { + if (!this.Properties.TryGetValue("customCoordinates", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["customCoordinates"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// A key-value data associated with the asset. Use `responseField` in API request + /// to get `customMetadata` in the upload API response. Before setting any custom + /// metadata on an asset, you have to create the field using custom metadata + /// fields API. Send `customMetadata` in `responseFields` in API request to get + /// the value of this field. + /// + public Dictionary? CustomMetadata + { + get + { + if (!this.Properties.TryGetValue("customMetadata", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["customMetadata"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Optional text to describe the contents of the file. Can be set by the user + /// or the ai-auto-description extension. + /// + public string? Description + { + get + { + if (!this.Properties.TryGetValue("description", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["description"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The duration of the video in seconds (only for video). + /// + public long? Duration + { + get + { + if (!this.Properties.TryGetValue("duration", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["duration"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Consolidated embedded metadata associated with the file. It includes exif, + /// iptc, and xmp data. Send `embeddedMetadata` in `responseFields` in API request + /// to get embeddedMetadata in the upload API response. + /// + public Dictionary? EmbeddedMetadata + { + get + { + if (!this.Properties.TryGetValue("embeddedMetadata", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["embeddedMetadata"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Extension names with their processing status at the time of completion of + /// the request. It could have one of the following status values: + /// + /// `success`: The extension has been successfully applied. `failed`: The extension + /// has failed and will not be retried. `pending`: The extension will finish processing + /// in some time. On completion, the final status (success / failed) will be sent + /// to the `webhookUrl` provided. + /// + /// If no extension was requested, then this parameter is not returned. + /// + public ExtensionStatus? ExtensionStatus + { + get + { + if (!this.Properties.TryGetValue("extensionStatus", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["extensionStatus"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Unique fileId. Store this fileld in your database, as this will be used to + /// perform update action on this file. + /// + public string? FileID + { + get + { + if (!this.Properties.TryGetValue("fileId", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["fileId"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The relative path of the file in the media library e.g. `/marketing-assets/new-banner.jpg`. + /// + public string? FilePath + { + get + { + if (!this.Properties.TryGetValue("filePath", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["filePath"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Type of the uploaded file. Possible values are `image`, `non-image`. + /// + public string? FileType + { + get + { + if (!this.Properties.TryGetValue("fileType", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["fileType"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Height of the image in pixels (Only for images) + /// + public double? Height + { + get + { + if (!this.Properties.TryGetValue("height", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["height"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Is the file marked as private. It can be either `true` or `false`. Send `isPrivateFile` + /// in `responseFields` in API request to get the value of this field. + /// + public bool? IsPrivateFile + { + get + { + if (!this.Properties.TryGetValue("isPrivateFile", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["isPrivateFile"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Is the file published or in draft state. It can be either `true` or `false`. + /// Send `isPublished` in `responseFields` in API request to get the value of + /// this field. + /// + public bool? IsPublished + { + get + { + if (!this.Properties.TryGetValue("isPublished", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["isPublished"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Legacy metadata. Send `metadata` in `responseFields` in API request to get + /// metadata in the upload API response. + /// + public Metadata? Metadata + { + get + { + if (!this.Properties.TryGetValue("metadata", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["metadata"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Name of the asset. + /// + public string? Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// This field is included in the response only if the Path policy feature is + /// available in the plan. It contains schema definitions for the custom metadata + /// fields selected for the specified file path. Field selection can only be done + /// when the Path policy feature is enabled. + /// + /// Keys are the names of the custom metadata fields; the value object has details + /// about the custom metadata schema. + /// + public Dictionary? SelectedFieldsSchema + { + get + { + if (!this.Properties.TryGetValue("selectedFieldsSchema", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["selectedFieldsSchema"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Size of the image file in Bytes. + /// + public double? Size + { + get + { + if (!this.Properties.TryGetValue("size", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["size"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The array of tags associated with the asset. If no tags are set, it will + /// be `null`. Send `tags` in `responseFields` in API request to get the value + /// of this field. + /// + public List? Tags + { + get + { + if (!this.Properties.TryGetValue("tags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["tags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// In the case of an image, a small thumbnail URL. + /// + public string? ThumbnailURL + { + get + { + if (!this.Properties.TryGetValue("thumbnailUrl", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["thumbnailUrl"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// A publicly accessible URL of the file. + /// + public string? URL + { + get + { + if (!this.Properties.TryGetValue("url", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["url"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// An object containing the file or file version's `id` (versionId) and `name`. + /// + public VersionInfo? VersionInfo + { + get + { + if (!this.Properties.TryGetValue("versionInfo", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["versionInfo"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The video codec used in the video (only for video). + /// + public string? VideoCodec + { + get + { + if (!this.Properties.TryGetValue("videoCodec", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["videoCodec"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Width of the image in pixels (Only for Images) + /// + public double? Width + { + get + { + if (!this.Properties.TryGetValue("width", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["width"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + foreach (var item in this.AITags ?? []) + { + item.Validate(); + } + _ = this.AudioCodec; + _ = this.BitRate; + _ = this.CustomCoordinates; + if (this.CustomMetadata != null) + { + foreach (var item in this.CustomMetadata.Values) + { + _ = item; + } + } + _ = this.Description; + _ = this.Duration; + if (this.EmbeddedMetadata != null) + { + foreach (var item in this.EmbeddedMetadata.Values) + { + _ = item; + } + } + this.ExtensionStatus?.Validate(); + _ = this.FileID; + _ = this.FilePath; + _ = this.FileType; + _ = this.Height; + _ = this.IsPrivateFile; + _ = this.IsPublished; + this.Metadata?.Validate(); + _ = this.Name; + if (this.SelectedFieldsSchema != null) + { + foreach (var item in this.SelectedFieldsSchema.Values) + { + item.Validate(); + } + } + _ = this.Size; + foreach (var item in this.Tags ?? []) + { + _ = item; + } + _ = this.ThumbnailURL; + _ = this.URL; + this.VersionInfo?.Validate(); + _ = this.VideoCodec; + _ = this.Width; + } + + public FileUploadResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FileUploadResponse(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static FileUploadResponse FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs similarity index 94% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs rename to src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs index d16b44d9..e493b8d7 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs +++ b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs @@ -3,9 +3,9 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using SelectedFieldsSchemaItemProperties = Imagekit.Models.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; +using SelectedFieldsSchemaItemProperties = Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; -namespace Imagekit.Models.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties; +namespace Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties; [JsonConverter(typeof(ModelConverter))] public sealed record class SelectedFieldsSchemaItem : ModelBase, IFromRaw diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs similarity index 88% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs rename to src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs index 32519654..8ce27531 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs +++ b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs @@ -2,11 +2,11 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using Imagekit.Models.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties; -using Imagekit.Models.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueVariants; +using Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties; +using Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueVariants; using System = System; -namespace Imagekit.Models.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; +namespace Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; /// /// The default value for this custom metadata field. The value should match the diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent5.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent5.cs similarity index 88% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent5.cs rename to src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent5.cs index 97c275f1..0d6b68da 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent5.cs +++ b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent5.cs @@ -2,10 +2,10 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using Imagekit.Models.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties.UnnamedSchemaWithArrayParent5Variants; +using Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties.UnnamedSchemaWithArrayParent5Variants; using System = System; -namespace Imagekit.Models.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties; +namespace Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties; [JsonConverter(typeof(UnnamedSchemaWithArrayParent5Converter))] public abstract record class UnnamedSchemaWithArrayParent5 diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent5Variants/All.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent5Variants/All.cs similarity index 76% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent5Variants/All.cs rename to src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent5Variants/All.cs index e9c33ce3..b904b07e 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent5Variants/All.cs +++ b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent5Variants/All.cs @@ -1,4 +1,4 @@ -namespace Imagekit.Models.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties.UnnamedSchemaWithArrayParent5Variants; +namespace Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties.UnnamedSchemaWithArrayParent5Variants; public sealed record class String(string Value) : UnnamedSchemaWithArrayParent5, diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs similarity index 76% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs rename to src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs index 9b639827..f250669b 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs +++ b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; -using Imagekit.Models.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties; +using Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties; -namespace Imagekit.Models.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueVariants; +namespace Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueVariants; public sealed record class String(string Value) : DefaultValue, IVariant { diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs similarity index 88% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs rename to src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs index 1a8dcc97..c35dd988 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs +++ b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs @@ -2,10 +2,10 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using Imagekit.Models.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MaxValueVariants; +using Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MaxValueVariants; using System = System; -namespace Imagekit.Models.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; +namespace Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; /// /// Maximum value of the field. Only set if field type is `Date` or `Number`. For diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs similarity index 72% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs rename to src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs index a1e259d1..557de34e 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs +++ b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs @@ -1,4 +1,4 @@ -namespace Imagekit.Models.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MaxValueVariants; +namespace Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MaxValueVariants; public sealed record class String(string Value) : MaxValue, IVariant { diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs similarity index 88% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs rename to src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs index 8f407d1f..6450e72f 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs +++ b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs @@ -2,10 +2,10 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using Imagekit.Models.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MinValueVariants; +using Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MinValueVariants; using System = System; -namespace Imagekit.Models.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; +namespace Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; /// /// Minimum value of the field. Only set if field type is `Date` or `Number`. For diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs similarity index 72% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs rename to src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs index 894b577c..64d01d26 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs +++ b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs @@ -1,4 +1,4 @@ -namespace Imagekit.Models.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MinValueVariants; +namespace Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MinValueVariants; public sealed record class String(string Value) : MinValue, IVariant { diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs similarity index 89% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs rename to src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs index 0cb2862a..b160f9ee 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs +++ b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs @@ -2,10 +2,10 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using Imagekit.Models.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.SelectOptionVariants; +using Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.SelectOptionVariants; using System = System; -namespace Imagekit.Models.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; +namespace Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; [JsonConverter(typeof(SelectOptionConverter))] public abstract record class SelectOption diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs similarity index 78% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs rename to src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs index e9ca5cc8..45bb569d 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs +++ b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs @@ -1,4 +1,4 @@ -namespace Imagekit.Models.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.SelectOptionVariants; +namespace Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.SelectOptionVariants; public sealed record class String(string Value) : SelectOption, IVariant { diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs similarity index 91% rename from src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs rename to src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs index 2de35337..95701507 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs +++ b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs @@ -2,7 +2,7 @@ using System.Text.Json.Serialization; using System = System; -namespace Imagekit.Models.Files.FileUploadParamsProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; +namespace Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; /// /// Type of the custom metadata field. diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/Data.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/Data.cs index 52c1dc77..f40ecdaa 100644 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/Data.cs +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/Data.cs @@ -1,613 +1,651 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Files; -using Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.DataProperties; - -namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties; - -/// -/// Object containing details of a successful upload. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class Data : ModelBase, IFromRaw -{ - /// - /// An array of tags assigned to the uploaded file by auto tagging. - /// - public List? AITags - { - get - { - if (!this.Properties.TryGetValue("AITags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["AITags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The audio codec used in the video (only for video). - /// - public string? AudioCodec - { - get - { - if (!this.Properties.TryGetValue("audioCodec", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["audioCodec"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The bit rate of the video in kbps (only for video). - /// - public long? BitRate - { - get - { - if (!this.Properties.TryGetValue("bitRate", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["bitRate"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Value of custom coordinates associated with the image in the format `x,y,width,height`. - /// If `customCoordinates` are not defined, then it is `null`. Send `customCoordinates` - /// in `responseFields` in API request to get the value of this field. - /// - public string? CustomCoordinates - { - get - { - if (!this.Properties.TryGetValue("customCoordinates", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["customCoordinates"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// A key-value data associated with the asset. Use `responseField` in API request - /// to get `customMetadata` in the upload API response. Before setting any custom - /// metadata on an asset, you have to create the field using custom metadata - /// fields API. Send `customMetadata` in `responseFields` in API request to get - /// the value of this field. - /// - public Dictionary? CustomMetadata - { - get - { - if (!this.Properties.TryGetValue("customMetadata", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["customMetadata"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Optional text to describe the contents of the file. Can be set by the user - /// or the ai-auto-description extension. - /// - public string? Description - { - get - { - if (!this.Properties.TryGetValue("description", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["description"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The duration of the video in seconds (only for video). - /// - public long? Duration - { - get - { - if (!this.Properties.TryGetValue("duration", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["duration"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Consolidated embedded metadata associated with the file. It includes exif, - /// iptc, and xmp data. Send `embeddedMetadata` in `responseFields` in API request - /// to get embeddedMetadata in the upload API response. - /// - public Dictionary? EmbeddedMetadata - { - get - { - if (!this.Properties.TryGetValue("embeddedMetadata", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["embeddedMetadata"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Extension names with their processing status at the time of completion of - /// the request. It could have one of the following status values: - /// - /// `success`: The extension has been successfully applied. `failed`: The extension - /// has failed and will not be retried. `pending`: The extension will finish processing - /// in some time. On completion, the final status (success / failed) will be sent - /// to the `webhookUrl` provided. - /// - /// If no extension was requested, then this parameter is not returned. - /// - public ExtensionStatus? ExtensionStatus - { - get - { - if (!this.Properties.TryGetValue("extensionStatus", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["extensionStatus"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Unique fileId. Store this fileld in your database, as this will be used to - /// perform update action on this file. - /// - public string? FileID - { - get - { - if (!this.Properties.TryGetValue("fileId", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["fileId"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The relative path of the file in the media library e.g. `/marketing-assets/new-banner.jpg`. - /// - public string? FilePath - { - get - { - if (!this.Properties.TryGetValue("filePath", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["filePath"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Type of the uploaded file. Possible values are `image`, `non-image`. - /// - public string? FileType - { - get - { - if (!this.Properties.TryGetValue("fileType", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["fileType"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Height of the image in pixels (Only for images) - /// - public double? Height - { - get - { - if (!this.Properties.TryGetValue("height", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["height"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Is the file marked as private. It can be either `true` or `false`. Send `isPrivateFile` - /// in `responseFields` in API request to get the value of this field. - /// - public bool? IsPrivateFile - { - get - { - if (!this.Properties.TryGetValue("isPrivateFile", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["isPrivateFile"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Is the file published or in draft state. It can be either `true` or `false`. - /// Send `isPublished` in `responseFields` in API request to get the value of - /// this field. - /// - public bool? IsPublished - { - get - { - if (!this.Properties.TryGetValue("isPublished", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["isPublished"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Legacy metadata. Send `metadata` in `responseFields` in API request to get - /// metadata in the upload API response. - /// - public Metadata? Metadata - { - get - { - if (!this.Properties.TryGetValue("metadata", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["metadata"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Name of the asset. - /// - public string? Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Size of the image file in Bytes. - /// - public double? Size - { - get - { - if (!this.Properties.TryGetValue("size", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["size"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The array of tags associated with the asset. If no tags are set, it will - /// be `null`. Send `tags` in `responseFields` in API request to get the value - /// of this field. - /// - public List? Tags - { - get - { - if (!this.Properties.TryGetValue("tags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["tags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// In the case of an image, a small thumbnail URL. - /// - public string? ThumbnailURL - { - get - { - if (!this.Properties.TryGetValue("thumbnailUrl", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["thumbnailUrl"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// A publicly accessible URL of the file. - /// - public string? URL - { - get - { - if (!this.Properties.TryGetValue("url", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["url"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// An object containing the file or file version's `id` (versionId) and `name`. - /// - public VersionInfo? VersionInfo - { - get - { - if (!this.Properties.TryGetValue("versionInfo", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["versionInfo"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The video codec used in the video (only for video). - /// - public string? VideoCodec - { - get - { - if (!this.Properties.TryGetValue("videoCodec", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["videoCodec"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Width of the image in pixels (Only for Images) - /// - public double? Width - { - get - { - if (!this.Properties.TryGetValue("width", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["width"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - foreach (var item in this.AITags ?? []) - { - item.Validate(); - } - _ = this.AudioCodec; - _ = this.BitRate; - _ = this.CustomCoordinates; - if (this.CustomMetadata != null) - { - foreach (var item in this.CustomMetadata.Values) - { - _ = item; - } - } - _ = this.Description; - _ = this.Duration; - if (this.EmbeddedMetadata != null) - { - foreach (var item in this.EmbeddedMetadata.Values) - { - _ = item; - } - } - this.ExtensionStatus?.Validate(); - _ = this.FileID; - _ = this.FilePath; - _ = this.FileType; - _ = this.Height; - _ = this.IsPrivateFile; - _ = this.IsPublished; - this.Metadata?.Validate(); - _ = this.Name; - _ = this.Size; - foreach (var item in this.Tags ?? []) - { - _ = item; - } - _ = this.ThumbnailURL; - _ = this.URL; - this.VersionInfo?.Validate(); - _ = this.VideoCodec; - _ = this.Width; - } - - public Data() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Data(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Data FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files; +using Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties; +using Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties; + +namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties; + +/// +/// Object containing details of a successful upload. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class Data : ModelBase, IFromRaw +{ + /// + /// An array of tags assigned to the uploaded file by auto tagging. + /// + public List? AITags + { + get + { + if (!this.Properties.TryGetValue("AITags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["AITags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The audio codec used in the video (only for video). + /// + public string? AudioCodec + { + get + { + if (!this.Properties.TryGetValue("audioCodec", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["audioCodec"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The bit rate of the video in kbps (only for video). + /// + public long? BitRate + { + get + { + if (!this.Properties.TryGetValue("bitRate", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["bitRate"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Value of custom coordinates associated with the image in the format `x,y,width,height`. + /// If `customCoordinates` are not defined, then it is `null`. Send `customCoordinates` + /// in `responseFields` in API request to get the value of this field. + /// + public string? CustomCoordinates + { + get + { + if (!this.Properties.TryGetValue("customCoordinates", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["customCoordinates"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// A key-value data associated with the asset. Use `responseField` in API request + /// to get `customMetadata` in the upload API response. Before setting any custom + /// metadata on an asset, you have to create the field using custom metadata + /// fields API. Send `customMetadata` in `responseFields` in API request to get + /// the value of this field. + /// + public Dictionary? CustomMetadata + { + get + { + if (!this.Properties.TryGetValue("customMetadata", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["customMetadata"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Optional text to describe the contents of the file. Can be set by the user + /// or the ai-auto-description extension. + /// + public string? Description + { + get + { + if (!this.Properties.TryGetValue("description", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["description"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The duration of the video in seconds (only for video). + /// + public long? Duration + { + get + { + if (!this.Properties.TryGetValue("duration", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["duration"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Consolidated embedded metadata associated with the file. It includes exif, + /// iptc, and xmp data. Send `embeddedMetadata` in `responseFields` in API request + /// to get embeddedMetadata in the upload API response. + /// + public Dictionary? EmbeddedMetadata + { + get + { + if (!this.Properties.TryGetValue("embeddedMetadata", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["embeddedMetadata"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Extension names with their processing status at the time of completion of + /// the request. It could have one of the following status values: + /// + /// `success`: The extension has been successfully applied. `failed`: The extension + /// has failed and will not be retried. `pending`: The extension will finish processing + /// in some time. On completion, the final status (success / failed) will be sent + /// to the `webhookUrl` provided. + /// + /// If no extension was requested, then this parameter is not returned. + /// + public ExtensionStatus? ExtensionStatus + { + get + { + if (!this.Properties.TryGetValue("extensionStatus", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["extensionStatus"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Unique fileId. Store this fileld in your database, as this will be used to + /// perform update action on this file. + /// + public string? FileID + { + get + { + if (!this.Properties.TryGetValue("fileId", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["fileId"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The relative path of the file in the media library e.g. `/marketing-assets/new-banner.jpg`. + /// + public string? FilePath + { + get + { + if (!this.Properties.TryGetValue("filePath", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["filePath"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Type of the uploaded file. Possible values are `image`, `non-image`. + /// + public string? FileType + { + get + { + if (!this.Properties.TryGetValue("fileType", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["fileType"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Height of the image in pixels (Only for images) + /// + public double? Height + { + get + { + if (!this.Properties.TryGetValue("height", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["height"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Is the file marked as private. It can be either `true` or `false`. Send `isPrivateFile` + /// in `responseFields` in API request to get the value of this field. + /// + public bool? IsPrivateFile + { + get + { + if (!this.Properties.TryGetValue("isPrivateFile", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["isPrivateFile"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Is the file published or in draft state. It can be either `true` or `false`. + /// Send `isPublished` in `responseFields` in API request to get the value of + /// this field. + /// + public bool? IsPublished + { + get + { + if (!this.Properties.TryGetValue("isPublished", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["isPublished"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Legacy metadata. Send `metadata` in `responseFields` in API request to get + /// metadata in the upload API response. + /// + public Metadata? Metadata + { + get + { + if (!this.Properties.TryGetValue("metadata", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["metadata"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Name of the asset. + /// + public string? Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// This field is included in the response only if the Path policy feature is + /// available in the plan. It contains schema definitions for the custom metadata + /// fields selected for the specified file path. Field selection can only be done + /// when the Path policy feature is enabled. + /// + /// Keys are the names of the custom metadata fields; the value object has details + /// about the custom metadata schema. + /// + public Dictionary? SelectedFieldsSchema + { + get + { + if (!this.Properties.TryGetValue("selectedFieldsSchema", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["selectedFieldsSchema"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Size of the image file in Bytes. + /// + public double? Size + { + get + { + if (!this.Properties.TryGetValue("size", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["size"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The array of tags associated with the asset. If no tags are set, it will + /// be `null`. Send `tags` in `responseFields` in API request to get the value + /// of this field. + /// + public List? Tags + { + get + { + if (!this.Properties.TryGetValue("tags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["tags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// In the case of an image, a small thumbnail URL. + /// + public string? ThumbnailURL + { + get + { + if (!this.Properties.TryGetValue("thumbnailUrl", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["thumbnailUrl"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// A publicly accessible URL of the file. + /// + public string? URL + { + get + { + if (!this.Properties.TryGetValue("url", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["url"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// An object containing the file or file version's `id` (versionId) and `name`. + /// + public VersionInfo? VersionInfo + { + get + { + if (!this.Properties.TryGetValue("versionInfo", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["versionInfo"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The video codec used in the video (only for video). + /// + public string? VideoCodec + { + get + { + if (!this.Properties.TryGetValue("videoCodec", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["videoCodec"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Width of the image in pixels (Only for Images) + /// + public double? Width + { + get + { + if (!this.Properties.TryGetValue("width", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["width"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + foreach (var item in this.AITags ?? []) + { + item.Validate(); + } + _ = this.AudioCodec; + _ = this.BitRate; + _ = this.CustomCoordinates; + if (this.CustomMetadata != null) + { + foreach (var item in this.CustomMetadata.Values) + { + _ = item; + } + } + _ = this.Description; + _ = this.Duration; + if (this.EmbeddedMetadata != null) + { + foreach (var item in this.EmbeddedMetadata.Values) + { + _ = item; + } + } + this.ExtensionStatus?.Validate(); + _ = this.FileID; + _ = this.FilePath; + _ = this.FileType; + _ = this.Height; + _ = this.IsPrivateFile; + _ = this.IsPublished; + this.Metadata?.Validate(); + _ = this.Name; + if (this.SelectedFieldsSchema != null) + { + foreach (var item in this.SelectedFieldsSchema.Values) + { + item.Validate(); + } + } + _ = this.Size; + foreach (var item in this.Tags ?? []) + { + _ = item; + } + _ = this.ThumbnailURL; + _ = this.URL; + this.VersionInfo?.Validate(); + _ = this.VideoCodec; + _ = this.Width; + } + + public Data() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Data(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Data FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs new file mode 100644 index 00000000..810e0d29 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs @@ -0,0 +1,285 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using SelectedFieldsSchemaItemProperties = Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; + +namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class SelectedFieldsSchemaItem : ModelBase, IFromRaw +{ + /// + /// Type of the custom metadata field. + /// + public required ApiEnum Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize< + ApiEnum + >(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The default value for this custom metadata field. The value should match the + /// `type` of custom metadata field. + /// + public SelectedFieldsSchemaItemProperties::DefaultValue? DefaultValue + { + get + { + if (!this.Properties.TryGetValue("defaultValue", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["defaultValue"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies if the custom metadata field is required or not. + /// + public bool? IsValueRequired + { + get + { + if (!this.Properties.TryGetValue("isValueRequired", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["isValueRequired"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. + /// + public double? MaxLength + { + get + { + if (!this.Properties.TryGetValue("maxLength", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["maxLength"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Maximum value of the field. Only set if field type is `Date` or `Number`. + /// For `Date` type field, the value will be in ISO8601 string format. For `Number` + /// type field, it will be a numeric value. + /// + public SelectedFieldsSchemaItemProperties::MaxValue? MaxValue + { + get + { + if (!this.Properties.TryGetValue("maxValue", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["maxValue"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. + /// + public double? MinLength + { + get + { + if (!this.Properties.TryGetValue("minLength", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["minLength"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Minimum value of the field. Only set if field type is `Date` or `Number`. + /// For `Date` type field, the value will be in ISO8601 string format. For `Number` + /// type field, it will be a numeric value. + /// + public SelectedFieldsSchemaItemProperties::MinValue? MinValue + { + get + { + if (!this.Properties.TryGetValue("minValue", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["minValue"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Indicates whether the custom metadata field is read only. A read only field + /// cannot be modified after being set. This field is configurable only via the + /// **Path policy** feature. + /// + public bool? ReadOnly + { + get + { + if (!this.Properties.TryGetValue("readOnly", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["readOnly"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// An array of allowed values when field type is `SingleSelect` or `MultiSelect`. + /// + public List? SelectOptions + { + get + { + if (!this.Properties.TryGetValue("selectOptions", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["selectOptions"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specifies if the selectOptions array is truncated. It is truncated when number + /// of options are > 100. + /// + public bool? SelectOptionsTruncated + { + get + { + if (!this.Properties.TryGetValue("selectOptionsTruncated", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["selectOptionsTruncated"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.Type.Validate(); + this.DefaultValue?.Validate(); + _ = this.IsValueRequired; + _ = this.MaxLength; + this.MaxValue?.Validate(); + _ = this.MinLength; + this.MinValue?.Validate(); + _ = this.ReadOnly; + foreach (var item in this.SelectOptions ?? []) + { + item.Validate(); + } + _ = this.SelectOptionsTruncated; + } + + public SelectedFieldsSchemaItem() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + SelectedFieldsSchemaItem(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static SelectedFieldsSchemaItem FromRawUnchecked( + Dictionary properties + ) + { + return new(properties); + } + + [SetsRequiredMembers] + public SelectedFieldsSchemaItem(ApiEnum type) + : this() + { + this.Type = type; + } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs new file mode 100644 index 00000000..a1b2e6b7 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs @@ -0,0 +1,175 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties; +using Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueVariants; +using System = System; + +namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; + +/// +/// The default value for this custom metadata field. The value should match the +/// `type` of custom metadata field. +/// +[JsonConverter(typeof(DefaultValueConverter))] +public abstract record class DefaultValue +{ + internal DefaultValue() { } + + public static implicit operator DefaultValue(string value) => new String(value); + + public static implicit operator DefaultValue(double value) => new Double(value); + + public static implicit operator DefaultValue(bool value) => new Bool(value); + + public static implicit operator DefaultValue(List value) => + new Mixed(value); + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as String)?.Value; + return value != null; + } + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as Double)?.Value; + return value != null; + } + + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = (this as Bool)?.Value; + return value != null; + } + + public bool TryPickMixed([NotNullWhen(true)] out List? value) + { + value = (this as Mixed)?.Value; + return value != null; + } + + public void Switch( + System::Action @string, + System::Action @double, + System::Action @bool, + System::Action mixed + ) + { + switch (this) + { + case String inner: + @string(inner); + break; + case Double inner: + @double(inner); + break; + case Bool inner: + @bool(inner); + break; + case Mixed inner: + mixed(inner); + break; + default: + throw new System::InvalidOperationException(); + } + } + + public T Match( + System::Func @string, + System::Func @double, + System::Func @bool, + System::Func mixed + ) + { + return this switch + { + String inner => @string(inner), + Double inner => @double(inner), + Bool inner => @bool(inner), + Mixed inner => mixed(inner), + _ => throw new System::InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class DefaultValueConverter : JsonConverter +{ + public override DefaultValue? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new Double(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new Bool(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + var deserialized = JsonSerializer.Deserialize>( + ref reader, + options + ); + if (deserialized != null) + { + return new Mixed(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new System::AggregateException(exceptions); + } + + public override void Write( + Utf8JsonWriter writer, + DefaultValue value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + String(var @string) => @string, + Double(var @double) => @double, + Bool(var @bool) => @bool, + Mixed(var mixed) => mixed, + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent7.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent7.cs new file mode 100644 index 00000000..c2cc3596 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent7.cs @@ -0,0 +1,140 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties.UnnamedSchemaWithArrayParent7Variants; +using System = System; + +namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties; + +[JsonConverter(typeof(UnnamedSchemaWithArrayParent7Converter))] +public abstract record class UnnamedSchemaWithArrayParent7 +{ + internal UnnamedSchemaWithArrayParent7() { } + + public static implicit operator UnnamedSchemaWithArrayParent7(string value) => + new String(value); + + public static implicit operator UnnamedSchemaWithArrayParent7(double value) => + new Double(value); + + public static implicit operator UnnamedSchemaWithArrayParent7(bool value) => new Bool(value); + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as String)?.Value; + return value != null; + } + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as Double)?.Value; + return value != null; + } + + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = (this as Bool)?.Value; + return value != null; + } + + public void Switch( + System::Action @string, + System::Action @double, + System::Action @bool + ) + { + switch (this) + { + case String inner: + @string(inner); + break; + case Double inner: + @double(inner); + break; + case Bool inner: + @bool(inner); + break; + default: + throw new System::InvalidOperationException(); + } + } + + public T Match( + System::Func @string, + System::Func @double, + System::Func @bool + ) + { + return this switch + { + String inner => @string(inner), + Double inner => @double(inner), + Bool inner => @bool(inner), + _ => throw new System::InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class UnnamedSchemaWithArrayParent7Converter : JsonConverter +{ + public override UnnamedSchemaWithArrayParent7? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new Double(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new Bool(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new System::AggregateException(exceptions); + } + + public override void Write( + Utf8JsonWriter writer, + UnnamedSchemaWithArrayParent7 value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + String(var @string) => @string, + Double(var @double) => @double, + Bool(var @bool) => @bool, + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent7Variants/All.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent7Variants/All.cs new file mode 100644 index 00000000..f4fe8bd6 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent7Variants/All.cs @@ -0,0 +1,35 @@ +namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties.UnnamedSchemaWithArrayParent7Variants; + +public sealed record class String(string Value) + : UnnamedSchemaWithArrayParent7, + IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Double(double Value) + : UnnamedSchemaWithArrayParent7, + IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Bool(bool Value) : UnnamedSchemaWithArrayParent7, IVariant +{ + public static Bool From(bool value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs new file mode 100644 index 00000000..a36a62ee --- /dev/null +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs @@ -0,0 +1,50 @@ +using System.Collections.Generic; +using Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties; + +namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueVariants; + +public sealed record class String(string Value) : DefaultValue, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Double(double Value) : DefaultValue, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Bool(bool Value) : DefaultValue, IVariant +{ + public static Bool From(bool value) + { + return new(value); + } + + public override void Validate() { } +} + +/// +/// Default value should be of type array when custom metadata field type is set to +/// `MultiSelect`. +/// +public sealed record class Mixed(List Value) + : DefaultValue, + IVariant> +{ + public static Mixed From(List value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs new file mode 100644 index 00000000..e69a8780 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs @@ -0,0 +1,109 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MaxValueVariants; +using System = System; + +namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; + +/// +/// Maximum value of the field. Only set if field type is `Date` or `Number`. For +/// `Date` type field, the value will be in ISO8601 string format. For `Number` type +/// field, it will be a numeric value. +/// +[JsonConverter(typeof(MaxValueConverter))] +public abstract record class MaxValue +{ + internal MaxValue() { } + + public static implicit operator MaxValue(string value) => new String(value); + + public static implicit operator MaxValue(double value) => new Double(value); + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as String)?.Value; + return value != null; + } + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as Double)?.Value; + return value != null; + } + + public void Switch(System::Action @string, System::Action @double) + { + switch (this) + { + case String inner: + @string(inner); + break; + case Double inner: + @double(inner); + break; + default: + throw new System::InvalidOperationException(); + } + } + + public T Match(System::Func @string, System::Func @double) + { + return this switch + { + String inner => @string(inner), + Double inner => @double(inner), + _ => throw new System::InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class MaxValueConverter : JsonConverter +{ + public override MaxValue? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new Double(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new System::AggregateException(exceptions); + } + + public override void Write(Utf8JsonWriter writer, MaxValue value, JsonSerializerOptions options) + { + object variant = value switch + { + String(var @string) => @string, + Double(var @double) => @double, + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs new file mode 100644 index 00000000..f7c39b8c --- /dev/null +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs @@ -0,0 +1,21 @@ +namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MaxValueVariants; + +public sealed record class String(string Value) : MaxValue, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Double(double Value) : MaxValue, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs new file mode 100644 index 00000000..e5153553 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs @@ -0,0 +1,109 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MinValueVariants; +using System = System; + +namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; + +/// +/// Minimum value of the field. Only set if field type is `Date` or `Number`. For +/// `Date` type field, the value will be in ISO8601 string format. For `Number` type +/// field, it will be a numeric value. +/// +[JsonConverter(typeof(MinValueConverter))] +public abstract record class MinValue +{ + internal MinValue() { } + + public static implicit operator MinValue(string value) => new String(value); + + public static implicit operator MinValue(double value) => new Double(value); + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as String)?.Value; + return value != null; + } + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as Double)?.Value; + return value != null; + } + + public void Switch(System::Action @string, System::Action @double) + { + switch (this) + { + case String inner: + @string(inner); + break; + case Double inner: + @double(inner); + break; + default: + throw new System::InvalidOperationException(); + } + } + + public T Match(System::Func @string, System::Func @double) + { + return this switch + { + String inner => @string(inner), + Double inner => @double(inner), + _ => throw new System::InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class MinValueConverter : JsonConverter +{ + public override MinValue? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new Double(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new System::AggregateException(exceptions); + } + + public override void Write(Utf8JsonWriter writer, MinValue value, JsonSerializerOptions options) + { + object variant = value switch + { + String(var @string) => @string, + Double(var @double) => @double, + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs new file mode 100644 index 00000000..c809c0bb --- /dev/null +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs @@ -0,0 +1,21 @@ +namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MinValueVariants; + +public sealed record class String(string Value) : MinValue, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Double(double Value) : MinValue, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs new file mode 100644 index 00000000..7bfedd0c --- /dev/null +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs @@ -0,0 +1,138 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.SelectOptionVariants; +using System = System; + +namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; + +[JsonConverter(typeof(SelectOptionConverter))] +public abstract record class SelectOption +{ + internal SelectOption() { } + + public static implicit operator SelectOption(string value) => new String(value); + + public static implicit operator SelectOption(double value) => new Double(value); + + public static implicit operator SelectOption(bool value) => new Bool(value); + + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = (this as String)?.Value; + return value != null; + } + + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = (this as Double)?.Value; + return value != null; + } + + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = (this as Bool)?.Value; + return value != null; + } + + public void Switch( + System::Action @string, + System::Action @double, + System::Action @bool + ) + { + switch (this) + { + case String inner: + @string(inner); + break; + case Double inner: + @double(inner); + break; + case Bool inner: + @bool(inner); + break; + default: + throw new System::InvalidOperationException(); + } + } + + public T Match( + System::Func @string, + System::Func @double, + System::Func @bool + ) + { + return this switch + { + String inner => @string(inner), + Double inner => @double(inner), + Bool inner => @bool(inner), + _ => throw new System::InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class SelectOptionConverter : JsonConverter +{ + public override SelectOption? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + return new String(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new Double(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + try + { + return new Bool(JsonSerializer.Deserialize(ref reader, options)); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new System::AggregateException(exceptions); + } + + public override void Write( + Utf8JsonWriter writer, + SelectOption value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + String(var @string) => @string, + Double(var @double) => @double, + Bool(var @bool) => @bool, + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs new file mode 100644 index 00000000..7cddb76a --- /dev/null +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs @@ -0,0 +1,31 @@ +namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.SelectOptionVariants; + +public sealed record class String(string Value) : SelectOption, IVariant +{ + public static String From(string value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Double(double Value) : SelectOption, IVariant +{ + public static Double From(double value) + { + return new(value); + } + + public override void Validate() { } +} + +public sealed record class Bool(bool Value) : SelectOption, IVariant +{ + public static Bool From(bool value) + { + return new(value); + } + + public override void Validate() { } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs new file mode 100644 index 00000000..382b8567 --- /dev/null +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs @@ -0,0 +1,61 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using System = System; + +namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; + +/// +/// Type of the custom metadata field. +/// +[JsonConverter(typeof(TypeConverter))] +public enum Type +{ + Text, + Textarea, + Number, + Date, + Boolean, + SingleSelect, + MultiSelect, +} + +sealed class TypeConverter : JsonConverter +{ + public override Type Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "Text" => SelectedFieldsSchemaItemProperties.Type.Text, + "Textarea" => SelectedFieldsSchemaItemProperties.Type.Textarea, + "Number" => SelectedFieldsSchemaItemProperties.Type.Number, + "Date" => SelectedFieldsSchemaItemProperties.Type.Date, + "Boolean" => SelectedFieldsSchemaItemProperties.Type.Boolean, + "SingleSelect" => SelectedFieldsSchemaItemProperties.Type.SingleSelect, + "MultiSelect" => SelectedFieldsSchemaItemProperties.Type.MultiSelect, + _ => (Type)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + SelectedFieldsSchemaItemProperties.Type.Text => "Text", + SelectedFieldsSchemaItemProperties.Type.Textarea => "Textarea", + SelectedFieldsSchemaItemProperties.Type.Number => "Number", + SelectedFieldsSchemaItemProperties.Type.Date => "Date", + SelectedFieldsSchemaItemProperties.Type.Boolean => "Boolean", + SelectedFieldsSchemaItemProperties.Type.SingleSelect => "SingleSelect", + SelectedFieldsSchemaItemProperties.Type.MultiSelect => "MultiSelect", + _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + }, + options + ); + } +} From 0a7ef589948993f75c1ef55cde0cf328e4045a23 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 28 Jan 2026 18:17:39 +0000 Subject: [PATCH 039/129] feat(client): refactor exceptions --- README.md | 27 + src/Imagekit/{ => Core}/ApiEnum.cs | 0 src/Imagekit/Core/HttpRequest.cs | 11 + src/Imagekit/Core/HttpResponse.cs | 32 + src/Imagekit/{ => Core}/IVariant.cs | 0 src/Imagekit/{ => Core}/ModelBase.cs | 2 +- src/Imagekit/{ => Core}/ModelConverter.cs | 0 src/Imagekit/{ => Core}/ParamsBase.cs | 9 +- .../Exceptions/ImageKit4xxException.cs | 9 + .../Exceptions/ImageKit5xxException.cs | 9 + .../Exceptions/ImageKitApiException.cs | 35 + .../Exceptions/ImageKitBadRequestException.cs | 9 + src/Imagekit/Exceptions/ImageKitException.cs | 13 + .../Exceptions/ImageKitExceptionFactory.cs | 61 ++ .../Exceptions/ImageKitForbiddenException.cs | 9 + .../Exceptions/ImageKitIOException.cs | 22 + .../ImageKitInvalidDataException.cs | 9 + .../Exceptions/ImageKitNotFoundException.cs | 9 + .../Exceptions/ImageKitRateLimitException.cs | 9 + .../ImageKitUnauthorizedException.cs | 9 + .../ImageKitUnexpectedStatusCodeException.cs | 9 + .../ImageKitUnprocessableEntityException.cs | 9 + src/Imagekit/IImageKitClient.cs | 5 + src/Imagekit/ImageKitClient.cs | 48 +- .../Accounts/Origins/OriginCreateParams.cs | 128 ++-- .../Models/Accounts/Origins/OriginRequest.cs | 720 ++++++++--------- .../OriginRequestProperties/AkeneoPim.cs | 466 +++++------ .../OriginRequestProperties/AzureBlob.cs | 394 +++++----- .../CloudinaryBackup.cs | 418 +++++----- .../Origins/OriginRequestProperties/Gcs.cs | 394 +++++----- .../Origins/OriginRequestProperties/S3.cs | 418 +++++----- .../OriginRequestProperties/S3Compatible.cs | 508 ++++++------ .../OriginRequestProperties/WebFolder.cs | 326 ++++---- .../OriginRequestProperties/WebProxy.cs | 250 +++--- .../Models/Accounts/Origins/OriginResponse.cs | 722 +++++++++--------- .../OriginResponseProperties/AkeneoPim.cs | 336 ++++---- .../OriginResponseProperties/AzureBlob.cs | 410 +++++----- .../CloudinaryBackup.cs | 382 ++++----- .../Origins/OriginResponseProperties/Gcs.cs | 410 +++++----- .../Origins/OriginResponseProperties/S3.cs | 382 ++++----- .../OriginResponseProperties/S3Compatible.cs | 478 ++++++------ .../OriginResponseProperties/WebFolder.cs | 386 +++++----- .../OriginResponseProperties/WebProxy.cs | 290 +++---- .../Accounts/Origins/OriginUpdateParams.cs | 138 ++-- .../URLEndpoints/URLEndpointCreateParams.cs | 262 +++---- .../URLRewriter.cs | 352 ++++----- .../URLRewriterProperties/Cloudinary.cs | 146 ++-- .../URLEndpoints/URLEndpointRequest.cs | 272 +++---- .../URLRewriter.cs | 352 ++++----- .../URLRewriterProperties/Cloudinary.cs | 146 ++-- .../URLEndpoints/URLEndpointResponse.cs | 310 ++++---- .../URLRewriter.cs | 352 ++++----- .../URLRewriterProperties/Cloudinary.cs | 166 ++-- .../URLEndpoints/URLEndpointUpdateParams.cs | 272 +++---- .../URLRewriter.cs | 352 ++++----- .../URLRewriterProperties/Cloudinary.cs | 146 ++-- .../Models/Accounts/Usage/UsageGetParams.cs | 150 ++-- .../Models/Assets/AssetListResponse.cs | 294 +++---- .../Models/Beta/V2/Files/FileUploadParams.cs | 26 +- .../ResponseField.cs | 5 +- .../TransformationProperties/Post.cs | 450 +++++------ .../PostProperties/Abs.cs | 206 ++--- .../PostProperties/GifToVideo.cs | 154 ++-- .../PostProperties/Thumbnail.cs | 152 ++-- .../PostProperties/Transformation.cs | 170 ++--- .../Beta/V2/Files/FileUploadResponse.cs | 1 + .../SelectedFieldsSchemaItem.cs | 7 +- .../DefaultValue.cs | 31 +- .../UnnamedSchemaWithArrayParent6.cs | 27 +- .../All.cs | 2 + .../DefaultValueVariants/All.cs | 1 + .../MaxValue.cs | 23 +- .../MaxValueVariants/All.cs | 2 + .../MinValue.cs | 23 +- .../MinValueVariants/All.cs | 2 + .../SelectOption.cs | 27 +- .../SelectOptionVariants/All.cs | 2 + .../Type.cs | 5 +- .../Invalidation/InvalidationCreateParams.cs | 130 ++-- .../CustomMetadataField.cs | 258 +++---- .../CustomMetadataFieldCreateParams.cs | 222 +++--- .../Schema.cs | 486 ++++++------ .../SchemaProperties/DefaultValue.cs | 352 ++++----- .../UnnamedSchemaWithArrayParent2.cs | 280 +++---- .../SchemaProperties/MaxValue.cs | 218 +++--- .../SchemaProperties/MinValue.cs | 218 +++--- .../SchemaProperties/SelectOption.cs | 276 +++---- .../CustomMetadataFieldListParams.cs | 3 +- .../CustomMetadataFieldProperties/Schema.cs | 7 +- .../SchemaProperties/DefaultValue.cs | 31 +- .../UnnamedSchemaWithArrayParent1.cs | 280 +++---- .../SchemaProperties/MaxValue.cs | 218 +++--- .../SchemaProperties/MinValue.cs | 218 +++--- .../SchemaProperties/SelectOption.cs | 276 +++---- .../SchemaProperties/DefaultValue.cs | 366 ++++----- .../UnnamedSchemaWithArrayParent3.cs | 290 +++---- .../SchemaProperties/MaxValue.cs | 234 +++--- .../SchemaProperties/MinValue.cs | 234 +++--- .../SchemaProperties/SelectOption.cs | 290 +++---- .../Models/Files/Bulk/BulkAddTagsParams.cs | 172 ++--- .../Models/Files/Bulk/BulkDeleteParams.cs | 142 ++-- .../Files/Bulk/BulkRemoveAITagsParams.cs | 172 ++--- .../Models/Files/Bulk/BulkRemoveTagsParams.cs | 172 ++--- src/Imagekit/Models/Files/File.cs | 1 + src/Imagekit/Models/Files/FileCopyParams.cs | 236 +++--- src/Imagekit/Models/Files/FileMoveParams.cs | 188 ++--- .../SelectedFieldsSchemaItem.cs | 7 +- .../DefaultValue.cs | 31 +- .../UnnamedSchemaWithArrayParent4.cs | 27 +- .../All.cs | 2 + .../DefaultValueVariants/All.cs | 1 + .../MaxValue.cs | 23 +- .../MaxValueVariants/All.cs | 2 + .../MinValue.cs | 23 +- .../MinValueVariants/All.cs | 2 + .../SelectOption.cs | 27 +- .../SelectOptionVariants/All.cs | 2 + .../Type.cs | 5 +- src/Imagekit/Models/Files/FileRenameParams.cs | 258 +++---- src/Imagekit/Models/Files/FileUpdateParams.cs | 4 +- .../Models/Files/FileUpdateResponse.cs | 1 + src/Imagekit/Models/Files/FileUploadParams.cs | 26 +- .../ResponseField.cs | 5 +- .../TransformationProperties/Post.cs | 450 +++++------ .../PostProperties/Abs.cs | 206 ++--- .../PostProperties/GifToVideo.cs | 154 ++-- .../PostProperties/Thumbnail.cs | 152 ++-- .../PostProperties/Transformation.cs | 170 ++--- .../Models/Files/FileUploadResponse.cs | 1 + .../SelectedFieldsSchemaItem.cs | 7 +- .../DefaultValue.cs | 31 +- .../UnnamedSchemaWithArrayParent5.cs | 27 +- .../All.cs | 2 + .../DefaultValueVariants/All.cs | 1 + .../MaxValue.cs | 23 +- .../MaxValueVariants/All.cs | 2 + .../MinValue.cs | 23 +- .../MinValueVariants/All.cs | 2 + .../SelectOption.cs | 27 +- .../SelectOptionVariants/All.cs | 2 + .../Type.cs | 5 +- .../Metadata/MetadataGetFromURLParams.cs | 104 +-- .../Models/Files/UpdateFileRequest.cs | 29 +- .../ChangePublicationStatus.cs | 1 + .../Publish.cs | 7 +- .../RemoveAITags.cs | 230 +++--- .../Files/UpdateFileRequestVariants/All.cs | 1 + .../Models/Folders/FolderCopyParams.cs | 240 +++--- .../Models/Folders/FolderCopyResponse.cs | 128 ++-- .../Models/Folders/FolderCreateParams.cs | 198 ++--- .../Models/Folders/FolderDeleteParams.cs | 128 ++-- .../Models/Folders/FolderMoveParams.cs | 190 ++--- .../Models/Folders/FolderMoveResponse.cs | 128 ++-- .../Models/Folders/FolderRenameParams.cs | 252 +++--- .../Models/Folders/FolderRenameResponse.cs | 128 ++-- src/Imagekit/Models/ImageOverlay.cs | 368 ++++----- .../IntersectionMember1.cs | 280 +++---- src/Imagekit/Models/Overlay.cs | 506 ++++++------ .../Models/OverlayPositionProperties/X.cs | 220 +++--- .../Models/OverlayPositionProperties/Y.cs | 220 +++--- .../OverlayTimingProperties/Duration.cs | 236 +++--- .../Models/OverlayTimingProperties/End.cs | 222 +++--- .../Models/OverlayTimingProperties/Start.cs | 230 +++--- src/Imagekit/Models/SolidColorOverlay.cs | 316 ++++---- .../IntersectionMember1.cs | 228 +++--- .../Gradient.cs | 230 +++--- .../Height.cs | 232 +++--- .../Radius.cs | 212 ++--- .../Width.cs | 226 +++--- src/Imagekit/Models/SrcOptions.cs | 460 +++++------ src/Imagekit/Models/SubtitleOverlay.cs | 364 ++++----- .../IntersectionMember1.cs | 276 +++---- src/Imagekit/Models/TextOverlay.cs | 366 ++++----- .../IntersectionMember1.cs | 278 +++---- .../FontSize.cs | 230 +++--- .../LineHeight.cs | 246 +++--- .../Padding.cs | 234 +++--- .../Radius.cs | 212 ++--- .../Rotation.cs | 232 +++--- .../Width.cs | 230 +++--- .../TransformationProperties/AIDropShadow.cs | 244 +++--- .../TransformationProperties/AspectRatio.cs | 246 +++--- .../TransformationProperties/Duration.cs | 234 +++--- .../TransformationProperties/EndOffset.cs | 242 +++--- .../TransformationProperties/Gradient.cs | 228 +++--- .../Models/TransformationProperties/Height.cs | 236 +++--- .../Models/TransformationProperties/Page.cs | 126 +++ .../Models/TransformationProperties/Radius.cs | 212 ++--- .../TransformationProperties/Rotation.cs | 236 +++--- .../Models/TransformationProperties/Shadow.cs | 218 +++--- .../TransformationProperties/Sharpen.cs | 220 +++--- .../TransformationProperties/StartOffset.cs | 244 +++--- .../Models/TransformationProperties/Trim.cs | 214 +++--- .../TransformationProperties/UnsharpMask.cs | 240 +++--- .../Models/TransformationProperties/Width.cs | 230 +++--- .../Models/TransformationProperties/X.cs | 214 +++--- .../TransformationProperties/XCenter.cs | 232 +++--- .../Models/TransformationProperties/Y.cs | 214 +++--- .../TransformationProperties/YCenter.cs | 232 +++--- .../Models/UnnamedSchemaWithArrayParent0.cs | 40 +- .../AutoTaggingExtension.cs | 200 ++--- .../RemoveBg.cs | 148 ++-- .../All.cs | 1 + src/Imagekit/Models/VideoOverlay.cs | 366 ++++----- .../IntersectionMember1.cs | 278 +++---- .../Models/Webhooks/BaseWebhookEvent.cs | 22 +- .../Webhooks/UnsafeUnwrapWebhookEvent.cs | 64 +- .../UnsafeUnwrapWebhookEventVariants/All.cs | 1 + .../Models/Webhooks/UnwrapWebhookEvent.cs | 64 +- .../UnwrapWebhookEventVariants/All.cs | 1 + .../Webhooks/UploadPostTransformErrorEvent.cs | 47 +- .../IntersectionMember1.cs | 32 +- .../IntersectionMember1Properties/Data.cs | 296 +++---- .../DataProperties/Transformation.cs | 116 +-- .../TransformationProperties/Error.cs | 120 +-- .../IntersectionMember1Properties/Request.cs | 158 ++-- .../RequestProperties/Transformation.cs | 220 +++--- .../UploadPostTransformSuccessEvent.cs | 47 +- .../IntersectionMember1.cs | 32 +- .../IntersectionMember1Properties/Data.cs | 198 ++--- .../IntersectionMember1Properties/Request.cs | 158 ++-- .../RequestProperties/Transformation.cs | 220 +++--- .../Webhooks/UploadPreTransformErrorEvent.cs | 47 +- .../IntersectionMember1.cs | 32 +- .../IntersectionMember1Properties/Data.cs | 204 ++--- .../DataProperties/Transformation.cs | 116 +-- .../TransformationProperties/Error.cs | 120 +-- .../IntersectionMember1Properties/Request.cs | 158 ++-- .../UploadPreTransformSuccessEvent.cs | 47 +- .../IntersectionMember1.cs | 32 +- .../IntersectionMember1Properties/Data.cs | 1 + .../SelectedFieldsSchemaItem.cs | 7 +- .../DefaultValue.cs | 31 +- .../UnnamedSchemaWithArrayParent7.cs | 27 +- .../All.cs | 2 + .../DefaultValueVariants/All.cs | 1 + .../MaxValue.cs | 23 +- .../MaxValueVariants/All.cs | 2 + .../MinValue.cs | 23 +- .../MinValueVariants/All.cs | 2 + .../SelectOption.cs | 27 +- .../SelectOptionVariants/All.cs | 2 + .../Type.cs | 5 +- .../IntersectionMember1Properties/Request.cs | 158 ++-- .../VideoTransformationAcceptedEvent.cs | 47 +- .../IntersectionMember1.cs | 32 +- .../IntersectionMember1Properties/Data.cs | 168 ++-- .../DataProperties/Asset.cs | 126 +-- .../DataProperties/Transformation.cs | 186 ++--- .../IntersectionMember1Properties/Request.cs | 202 ++--- .../Webhooks/VideoTransformationErrorEvent.cs | 47 +- .../IntersectionMember1.cs | 32 +- .../IntersectionMember1Properties/Data.cs | 162 ++-- .../DataProperties/Asset.cs | 126 +-- .../DataProperties/Transformation.cs | 230 +++--- .../IntersectionMember1Properties/Request.cs | 202 ++--- .../Webhooks/VideoTransformationReadyEvent.cs | 47 +- .../IntersectionMember1.cs | 32 +- .../IntersectionMember1Properties/Data.cs | 162 ++-- .../DataProperties/Asset.cs | 126 +-- .../DataProperties/Transformation.cs | 230 +++--- .../TransformationProperties/Output.cs | 172 ++--- .../OutputProperties/VideoMetadata.cs | 242 +++--- .../IntersectionMember1Properties/Request.cs | 202 ++--- 264 files changed, 20897 insertions(+), 19552 deletions(-) rename src/Imagekit/{ => Core}/ApiEnum.cs (100%) create mode 100644 src/Imagekit/Core/HttpRequest.cs create mode 100644 src/Imagekit/Core/HttpResponse.cs rename src/Imagekit/{ => Core}/IVariant.cs (100%) rename src/Imagekit/{ => Core}/ModelBase.cs (98%) rename src/Imagekit/{ => Core}/ModelConverter.cs (100%) rename src/Imagekit/{ => Core}/ParamsBase.cs (93%) create mode 100644 src/Imagekit/Exceptions/ImageKit4xxException.cs create mode 100644 src/Imagekit/Exceptions/ImageKit5xxException.cs create mode 100644 src/Imagekit/Exceptions/ImageKitApiException.cs create mode 100644 src/Imagekit/Exceptions/ImageKitBadRequestException.cs create mode 100644 src/Imagekit/Exceptions/ImageKitException.cs create mode 100644 src/Imagekit/Exceptions/ImageKitExceptionFactory.cs create mode 100644 src/Imagekit/Exceptions/ImageKitForbiddenException.cs create mode 100644 src/Imagekit/Exceptions/ImageKitIOException.cs create mode 100644 src/Imagekit/Exceptions/ImageKitInvalidDataException.cs create mode 100644 src/Imagekit/Exceptions/ImageKitNotFoundException.cs create mode 100644 src/Imagekit/Exceptions/ImageKitRateLimitException.cs create mode 100644 src/Imagekit/Exceptions/ImageKitUnauthorizedException.cs create mode 100644 src/Imagekit/Exceptions/ImageKitUnexpectedStatusCodeException.cs create mode 100644 src/Imagekit/Exceptions/ImageKitUnprocessableEntityException.cs diff --git a/README.md b/README.md index df4f4913..d69a5379 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,33 @@ To send a request to the Image Kit API, build an instance of some `Params` class For example, `client.Files.Upload` should be called with an instance of `FileUploadParams`, and it will return an instance of `Task`. +## Error handling + +The SDK throws custom unchecked exception types: + +- `ImageKitApiException`: Base class for API errors. See this table for which exception subclass is thrown for each HTTP status code: + +| Status | Exception | +| ------ | --------------------------------------- | +| 400 | `ImageKitBadRequestException` | +| 401 | `ImageKitUnauthorizedException` | +| 403 | `ImageKitForbiddenException` | +| 404 | `ImageKitNotFoundException` | +| 422 | `ImageKitUnprocessableEntityException` | +| 429 | `ImageKitRateLimitException` | +| 5xx | `ImageKit5xxException` | +| others | `ImageKitUnexpectedStatusCodeException` | + +Additionally, all 4xx errors inherit from `ImageKit4xxException`. + +false + +- `ImageKitIOException`: I/O networking errors. + +- `ImageKitInvalidDataException`: Failure to interpret successfully parsed data. For example, when accessing a property that's supposed to be required, but the API unexpectedly omitted it from the response. + +- `ImageKitException`: Base class for all exceptions. + ## Semantic versioning This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions: diff --git a/src/Imagekit/ApiEnum.cs b/src/Imagekit/Core/ApiEnum.cs similarity index 100% rename from src/Imagekit/ApiEnum.cs rename to src/Imagekit/Core/ApiEnum.cs diff --git a/src/Imagekit/Core/HttpRequest.cs b/src/Imagekit/Core/HttpRequest.cs new file mode 100644 index 00000000..f30f7039 --- /dev/null +++ b/src/Imagekit/Core/HttpRequest.cs @@ -0,0 +1,11 @@ +using System.Net.Http; + +namespace Imagekit.Core; + +public sealed class HttpRequest

+ where P : ParamsBase +{ + public required HttpMethod Method { get; init; } + + public required P Params { get; init; } +} diff --git a/src/Imagekit/Core/HttpResponse.cs b/src/Imagekit/Core/HttpResponse.cs new file mode 100644 index 00000000..7c2123b6 --- /dev/null +++ b/src/Imagekit/Core/HttpResponse.cs @@ -0,0 +1,32 @@ +using System; +using System.Net.Http; +using System.Text.Json; +using System.Threading.Tasks; +using Imagekit.Exceptions; + +namespace Imagekit.Core; + +public sealed class HttpResponse : IDisposable +{ + public required HttpResponseMessage Message { get; init; } + + public async Task Deserialize() + { + try + { + return JsonSerializer.Deserialize( + await Message.Content.ReadAsStreamAsync().ConfigureAwait(false), + ModelBase.SerializerOptions + ) ?? throw new ImageKitInvalidDataException("Response cannot be null"); + } + catch (HttpRequestException e) + { + throw new ImageKitIOException("I/O Exception", e); + } + } + + public void Dispose() + { + this.Message.Dispose(); + } +} diff --git a/src/Imagekit/IVariant.cs b/src/Imagekit/Core/IVariant.cs similarity index 100% rename from src/Imagekit/IVariant.cs rename to src/Imagekit/Core/IVariant.cs diff --git a/src/Imagekit/ModelBase.cs b/src/Imagekit/Core/ModelBase.cs similarity index 98% rename from src/Imagekit/ModelBase.cs rename to src/Imagekit/Core/ModelBase.cs index 18896c48..ccbf5247 100644 --- a/src/Imagekit/ModelBase.cs +++ b/src/Imagekit/Core/ModelBase.cs @@ -25,7 +25,7 @@ using SelectedFieldsSchemaItemProperties = Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; using TransformationProperties = Imagekit.Models.TransformationProperties; -namespace Imagekit; +namespace Imagekit.Core; public abstract record class ModelBase { diff --git a/src/Imagekit/ModelConverter.cs b/src/Imagekit/Core/ModelConverter.cs similarity index 100% rename from src/Imagekit/ModelConverter.cs rename to src/Imagekit/Core/ModelConverter.cs diff --git a/src/Imagekit/ParamsBase.cs b/src/Imagekit/Core/ParamsBase.cs similarity index 93% rename from src/Imagekit/ParamsBase.cs rename to src/Imagekit/Core/ParamsBase.cs index 3a2e56af..5e15b725 100644 --- a/src/Imagekit/ParamsBase.cs +++ b/src/Imagekit/Core/ParamsBase.cs @@ -7,7 +7,7 @@ using System.Text.Json; using Web = System.Web; -namespace Imagekit; +namespace Imagekit.Core; public abstract record class ParamsBase { @@ -147,6 +147,13 @@ protected string QueryString(IImageKitClient client) return sb.ToString(); } + internal abstract void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client); + + internal virtual StringContent? BodyContent() + { + return null; + } + protected static void AddDefaultHeaders(HttpRequestMessage request, IImageKitClient client) { if (client.PrivateKey != null && client.Password != null) diff --git a/src/Imagekit/Exceptions/ImageKit4xxException.cs b/src/Imagekit/Exceptions/ImageKit4xxException.cs new file mode 100644 index 00000000..fb904eee --- /dev/null +++ b/src/Imagekit/Exceptions/ImageKit4xxException.cs @@ -0,0 +1,9 @@ +using System.Net.Http; + +namespace Imagekit.Exceptions; + +public class ImageKit4xxException : ImageKitApiException +{ + public ImageKit4xxException(HttpRequestException? innerException = null) + : base(innerException) { } +} diff --git a/src/Imagekit/Exceptions/ImageKit5xxException.cs b/src/Imagekit/Exceptions/ImageKit5xxException.cs new file mode 100644 index 00000000..5c3bf57b --- /dev/null +++ b/src/Imagekit/Exceptions/ImageKit5xxException.cs @@ -0,0 +1,9 @@ +using System.Net.Http; + +namespace Imagekit.Exceptions; + +public class ImageKit5xxException : ImageKitApiException +{ + public ImageKit5xxException(HttpRequestException? innerException = null) + : base(innerException) { } +} diff --git a/src/Imagekit/Exceptions/ImageKitApiException.cs b/src/Imagekit/Exceptions/ImageKitApiException.cs new file mode 100644 index 00000000..9ff6b86b --- /dev/null +++ b/src/Imagekit/Exceptions/ImageKitApiException.cs @@ -0,0 +1,35 @@ +using System; +using System.Net; +using System.Net.Http; + +namespace Imagekit.Exceptions; + +public class ImageKitApiException : ImageKitException +{ + public new HttpRequestException InnerException + { + get + { + if (base.InnerException == null) + { + throw new ArgumentNullException(); + } + return (HttpRequestException)base.InnerException; + } + } + + public ImageKitApiException(string message, HttpRequestException? innerException = null) + : base(message, innerException) { } + + protected ImageKitApiException(HttpRequestException? innerException) + : base(innerException) { } + + public required HttpStatusCode StatusCode { get; init; } + + public required string ResponseBody { get; init; } + + public override string Message + { + get { return string.Format("Status Code: {0}\n{1}", StatusCode, ResponseBody); } + } +} diff --git a/src/Imagekit/Exceptions/ImageKitBadRequestException.cs b/src/Imagekit/Exceptions/ImageKitBadRequestException.cs new file mode 100644 index 00000000..5c95d8d4 --- /dev/null +++ b/src/Imagekit/Exceptions/ImageKitBadRequestException.cs @@ -0,0 +1,9 @@ +using System.Net.Http; + +namespace Imagekit.Exceptions; + +public class ImageKitBadRequestException : ImageKit4xxException +{ + public ImageKitBadRequestException(HttpRequestException? innerException = null) + : base(innerException) { } +} diff --git a/src/Imagekit/Exceptions/ImageKitException.cs b/src/Imagekit/Exceptions/ImageKitException.cs new file mode 100644 index 00000000..bf964025 --- /dev/null +++ b/src/Imagekit/Exceptions/ImageKitException.cs @@ -0,0 +1,13 @@ +using System; +using System.Net.Http; + +namespace Imagekit.Exceptions; + +public class ImageKitException : Exception +{ + public ImageKitException(string message, Exception? innerException = null) + : base(message, innerException) { } + + protected ImageKitException(HttpRequestException? innerException) + : base(null, innerException) { } +} diff --git a/src/Imagekit/Exceptions/ImageKitExceptionFactory.cs b/src/Imagekit/Exceptions/ImageKitExceptionFactory.cs new file mode 100644 index 00000000..768f05e5 --- /dev/null +++ b/src/Imagekit/Exceptions/ImageKitExceptionFactory.cs @@ -0,0 +1,61 @@ +using System.Net; + +namespace Imagekit.Exceptions; + +public class ImageKitExceptionFactory +{ + public static ImageKitApiException CreateApiException( + HttpStatusCode statusCode, + string responseBody + ) + { + return (int)statusCode switch + { + 400 => new ImageKitBadRequestException() + { + StatusCode = statusCode, + ResponseBody = responseBody, + }, + 401 => new ImageKitUnauthorizedException() + { + StatusCode = statusCode, + ResponseBody = responseBody, + }, + 403 => new ImageKitForbiddenException() + { + StatusCode = statusCode, + ResponseBody = responseBody, + }, + 404 => new ImageKitNotFoundException() + { + StatusCode = statusCode, + ResponseBody = responseBody, + }, + 422 => new ImageKitUnprocessableEntityException() + { + StatusCode = statusCode, + ResponseBody = responseBody, + }, + 429 => new ImageKitRateLimitException() + { + StatusCode = statusCode, + ResponseBody = responseBody, + }, + >= 400 and <= 499 => new ImageKit4xxException() + { + StatusCode = statusCode, + ResponseBody = responseBody, + }, + >= 500 and <= 599 => new ImageKit5xxException() + { + StatusCode = statusCode, + ResponseBody = responseBody, + }, + _ => new ImageKitUnexpectedStatusCodeException() + { + StatusCode = statusCode, + ResponseBody = responseBody, + }, + }; + } +} diff --git a/src/Imagekit/Exceptions/ImageKitForbiddenException.cs b/src/Imagekit/Exceptions/ImageKitForbiddenException.cs new file mode 100644 index 00000000..fbd39380 --- /dev/null +++ b/src/Imagekit/Exceptions/ImageKitForbiddenException.cs @@ -0,0 +1,9 @@ +using System.Net.Http; + +namespace Imagekit.Exceptions; + +public class ImageKitForbiddenException : ImageKit4xxException +{ + public ImageKitForbiddenException(HttpRequestException? innerException = null) + : base(innerException) { } +} diff --git a/src/Imagekit/Exceptions/ImageKitIOException.cs b/src/Imagekit/Exceptions/ImageKitIOException.cs new file mode 100644 index 00000000..bcfb380a --- /dev/null +++ b/src/Imagekit/Exceptions/ImageKitIOException.cs @@ -0,0 +1,22 @@ +using System; +using System.Net.Http; + +namespace Imagekit.Exceptions; + +public class ImageKitIOException : ImageKitException +{ + public new HttpRequestException InnerException + { + get + { + if (base.InnerException == null) + { + throw new ArgumentNullException(); + } + return (HttpRequestException)base.InnerException; + } + } + + public ImageKitIOException(string message, HttpRequestException? innerException = null) + : base(message, innerException) { } +} diff --git a/src/Imagekit/Exceptions/ImageKitInvalidDataException.cs b/src/Imagekit/Exceptions/ImageKitInvalidDataException.cs new file mode 100644 index 00000000..eda54a08 --- /dev/null +++ b/src/Imagekit/Exceptions/ImageKitInvalidDataException.cs @@ -0,0 +1,9 @@ +using System; + +namespace Imagekit.Exceptions; + +public class ImageKitInvalidDataException : ImageKitException +{ + public ImageKitInvalidDataException(string message, Exception? innerException = null) + : base(message, innerException) { } +} diff --git a/src/Imagekit/Exceptions/ImageKitNotFoundException.cs b/src/Imagekit/Exceptions/ImageKitNotFoundException.cs new file mode 100644 index 00000000..70c81820 --- /dev/null +++ b/src/Imagekit/Exceptions/ImageKitNotFoundException.cs @@ -0,0 +1,9 @@ +using System.Net.Http; + +namespace Imagekit.Exceptions; + +public class ImageKitNotFoundException : ImageKit4xxException +{ + public ImageKitNotFoundException(HttpRequestException? innerException = null) + : base(innerException) { } +} diff --git a/src/Imagekit/Exceptions/ImageKitRateLimitException.cs b/src/Imagekit/Exceptions/ImageKitRateLimitException.cs new file mode 100644 index 00000000..b93fe95a --- /dev/null +++ b/src/Imagekit/Exceptions/ImageKitRateLimitException.cs @@ -0,0 +1,9 @@ +using System.Net.Http; + +namespace Imagekit.Exceptions; + +public class ImageKitRateLimitException : ImageKit4xxException +{ + public ImageKitRateLimitException(HttpRequestException? innerException = null) + : base(innerException) { } +} diff --git a/src/Imagekit/Exceptions/ImageKitUnauthorizedException.cs b/src/Imagekit/Exceptions/ImageKitUnauthorizedException.cs new file mode 100644 index 00000000..0d360cc0 --- /dev/null +++ b/src/Imagekit/Exceptions/ImageKitUnauthorizedException.cs @@ -0,0 +1,9 @@ +using System.Net.Http; + +namespace Imagekit.Exceptions; + +public class ImageKitUnauthorizedException : ImageKit4xxException +{ + public ImageKitUnauthorizedException(HttpRequestException? innerException = null) + : base(innerException) { } +} diff --git a/src/Imagekit/Exceptions/ImageKitUnexpectedStatusCodeException.cs b/src/Imagekit/Exceptions/ImageKitUnexpectedStatusCodeException.cs new file mode 100644 index 00000000..155b0053 --- /dev/null +++ b/src/Imagekit/Exceptions/ImageKitUnexpectedStatusCodeException.cs @@ -0,0 +1,9 @@ +using System.Net.Http; + +namespace Imagekit.Exceptions; + +public class ImageKitUnexpectedStatusCodeException : ImageKitApiException +{ + public ImageKitUnexpectedStatusCodeException(HttpRequestException? innerException = null) + : base(innerException) { } +} diff --git a/src/Imagekit/Exceptions/ImageKitUnprocessableEntityException.cs b/src/Imagekit/Exceptions/ImageKitUnprocessableEntityException.cs new file mode 100644 index 00000000..bc4d6cb8 --- /dev/null +++ b/src/Imagekit/Exceptions/ImageKitUnprocessableEntityException.cs @@ -0,0 +1,9 @@ +using System.Net.Http; + +namespace Imagekit.Exceptions; + +public class ImageKitUnprocessableEntityException : ImageKit4xxException +{ + public ImageKitUnprocessableEntityException(HttpRequestException? innerException = null) + : base(innerException) { } +} diff --git a/src/Imagekit/IImageKitClient.cs b/src/Imagekit/IImageKitClient.cs index 63cadd53..3c7a1536 100644 --- a/src/Imagekit/IImageKitClient.cs +++ b/src/Imagekit/IImageKitClient.cs @@ -1,5 +1,7 @@ using System; using System.Net.Http; +using System.Threading.Tasks; +using Imagekit.Core; using Imagekit.Services.Accounts; using Imagekit.Services.Assets; using Imagekit.Services.Beta; @@ -51,4 +53,7 @@ public interface IImageKitClient IBetaService Beta { get; } IWebhookService Webhooks { get; } + + Task Execute(HttpRequest request) + where T : ParamsBase; } diff --git a/src/Imagekit/ImageKitClient.cs b/src/Imagekit/ImageKitClient.cs index dc889f81..2555a7e8 100644 --- a/src/Imagekit/ImageKitClient.cs +++ b/src/Imagekit/ImageKitClient.cs @@ -1,5 +1,8 @@ using System; using System.Net.Http; +using System.Threading.Tasks; +using Imagekit.Core; +using Imagekit.Exceptions; using Imagekit.Services.Accounts; using Imagekit.Services.Assets; using Imagekit.Services.Beta; @@ -28,7 +31,10 @@ public Uri BaseUrl Lazy _privateKey = new(() => Environment.GetEnvironmentVariable("IMAGEKIT_PRIVATE_KEY") - ?? throw new ArgumentNullException(nameof(PrivateKey)) + ?? throw new ImageKitInvalidDataException( + string.Format("{0} cannot be null", nameof(PrivateKey)), + new ArgumentNullException(nameof(PrivateKey)) + ) ); public string PrivateKey { @@ -102,6 +108,46 @@ public IWebhookService Webhooks get { return _webhooks.Value; } } + public async Task Execute(HttpRequest request) + where T : ParamsBase + { + using HttpRequestMessage requestMessage = new(request.Method, request.Params.Url(this)) + { + Content = request.Params.BodyContent(), + }; + request.Params.AddHeadersToRequest(requestMessage, this); + HttpResponseMessage responseMessage; + try + { + responseMessage = await this + .HttpClient.SendAsync(requestMessage, HttpCompletionOption.ResponseHeadersRead) + .ConfigureAwait(false); + } + catch (HttpRequestException e1) + { + throw new ImageKitIOException("I/O exception", e1); + } + if (!responseMessage.IsSuccessStatusCode) + { + try + { + throw ImageKitExceptionFactory.CreateApiException( + responseMessage.StatusCode, + await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false) + ); + } + catch (HttpRequestException e) + { + throw new ImageKitIOException("I/O Exception", e); + } + finally + { + responseMessage.Dispose(); + } + } + return new() { Message = responseMessage }; + } + public ImageKitClient() { _customMetadataFields = new(() => new CustomMetadataFieldService(this)); diff --git a/src/Imagekit/Models/Accounts/Origins/OriginCreateParams.cs b/src/Imagekit/Models/Accounts/Origins/OriginCreateParams.cs index b485becb..828bf691 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginCreateParams.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginCreateParams.cs @@ -1,64 +1,64 @@ -using System; -using System.Collections.Generic; -using System.Net.Http; -using System.Text; -using System.Text.Json; - -namespace Imagekit.Models.Accounts.Origins; - -///

-/// **Note:** This API is currently in beta. Creates a new origin and returns the -/// origin object. -/// -public sealed record class OriginCreateParams : ParamsBase -{ - public Dictionary BodyProperties { get; set; } = []; - - /// - /// Schema for origin request resources. - /// - public required OriginRequest Origin - { - get - { - if (!this.BodyProperties.TryGetValue("origin", out JsonElement element)) - throw new ArgumentOutOfRangeException("origin", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("origin"); - } - set - { - this.BodyProperties["origin"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override Uri Url(IImageKitClient client) - { - return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/accounts/origins") - { - Query = this.QueryString(client), - }.Uri; - } - - public StringContent BodyContent() - { - return new( - JsonSerializer.Serialize(this.BodyProperties), - Encoding.UTF8, - "application/json" - ); - } - - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Text; +using System.Text.Json; + +namespace Imagekit.Models.Accounts.Origins; + +/// +/// **Note:** This API is currently in beta. Creates a new origin and returns the +/// origin object. +/// +public sealed record class OriginCreateParams : ParamsBase +{ + public Dictionary BodyProperties { get; set; } = []; + + /// + /// Schema for origin request resources. + /// + public required OriginRequest Origin + { + get + { + if (!this.BodyProperties.TryGetValue("origin", out JsonElement element)) + throw new ArgumentOutOfRangeException("origin", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("origin"); + } + set + { + this.BodyProperties["origin"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override Uri Url(IImageKitClient client) + { + return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/accounts/origins") + { + Query = this.QueryString(client), + }.Uri; + } + + public StringContent BodyContent() + { + return new( + JsonSerializer.Serialize(this.BodyProperties), + Encoding.UTF8, + "application/json" + ); + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequest.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequest.cs index be08db0e..7ae8c583 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginRequest.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginRequest.cs @@ -1,360 +1,360 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Accounts.Origins.OriginRequestProperties; -using OriginRequestVariants = Imagekit.Models.Accounts.Origins.OriginRequestVariants; - -namespace Imagekit.Models.Accounts.Origins; - -/// -/// Schema for origin request resources. -/// -[JsonConverter(typeof(OriginRequestConverter))] -public abstract record class OriginRequest -{ - internal OriginRequest() { } - - public static implicit operator OriginRequest(S3 value) => new OriginRequestVariants::S3(value); - - public static implicit operator OriginRequest(S3Compatible value) => - new OriginRequestVariants::S3Compatible(value); - - public static implicit operator OriginRequest(CloudinaryBackup value) => - new OriginRequestVariants::CloudinaryBackup(value); - - public static implicit operator OriginRequest(WebFolder value) => - new OriginRequestVariants::WebFolder(value); - - public static implicit operator OriginRequest(WebProxy value) => - new OriginRequestVariants::WebProxy(value); - - public static implicit operator OriginRequest(Gcs value) => - new OriginRequestVariants::Gcs(value); - - public static implicit operator OriginRequest(AzureBlob value) => - new OriginRequestVariants::AzureBlob(value); - - public static implicit operator OriginRequest(AkeneoPim value) => - new OriginRequestVariants::AkeneoPim(value); - - public bool TryPickS3([NotNullWhen(true)] out S3? value) - { - value = (this as OriginRequestVariants::S3)?.Value; - return value != null; - } - - public bool TryPickS3Compatible([NotNullWhen(true)] out S3Compatible? value) - { - value = (this as OriginRequestVariants::S3Compatible)?.Value; - return value != null; - } - - public bool TryPickCloudinaryBackup([NotNullWhen(true)] out CloudinaryBackup? value) - { - value = (this as OriginRequestVariants::CloudinaryBackup)?.Value; - return value != null; - } - - public bool TryPickWebFolder([NotNullWhen(true)] out WebFolder? value) - { - value = (this as OriginRequestVariants::WebFolder)?.Value; - return value != null; - } - - public bool TryPickWebProxy([NotNullWhen(true)] out WebProxy? value) - { - value = (this as OriginRequestVariants::WebProxy)?.Value; - return value != null; - } - - public bool TryPickGcs([NotNullWhen(true)] out Gcs? value) - { - value = (this as OriginRequestVariants::Gcs)?.Value; - return value != null; - } - - public bool TryPickAzureBlob([NotNullWhen(true)] out AzureBlob? value) - { - value = (this as OriginRequestVariants::AzureBlob)?.Value; - return value != null; - } - - public bool TryPickAkeneoPim([NotNullWhen(true)] out AkeneoPim? value) - { - value = (this as OriginRequestVariants::AkeneoPim)?.Value; - return value != null; - } - - public void Switch( - Action s3, - Action s3Compatible, - Action cloudinaryBackup, - Action webFolder, - Action webProxy, - Action gcs, - Action azureBlob, - Action akeneoPim - ) - { - switch (this) - { - case OriginRequestVariants::S3 inner: - s3(inner); - break; - case OriginRequestVariants::S3Compatible inner: - s3Compatible(inner); - break; - case OriginRequestVariants::CloudinaryBackup inner: - cloudinaryBackup(inner); - break; - case OriginRequestVariants::WebFolder inner: - webFolder(inner); - break; - case OriginRequestVariants::WebProxy inner: - webProxy(inner); - break; - case OriginRequestVariants::Gcs inner: - gcs(inner); - break; - case OriginRequestVariants::AzureBlob inner: - azureBlob(inner); - break; - case OriginRequestVariants::AkeneoPim inner: - akeneoPim(inner); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match( - Func s3, - Func s3Compatible, - Func cloudinaryBackup, - Func webFolder, - Func webProxy, - Func gcs, - Func azureBlob, - Func akeneoPim - ) - { - return this switch - { - OriginRequestVariants::S3 inner => s3(inner), - OriginRequestVariants::S3Compatible inner => s3Compatible(inner), - OriginRequestVariants::CloudinaryBackup inner => cloudinaryBackup(inner), - OriginRequestVariants::WebFolder inner => webFolder(inner), - OriginRequestVariants::WebProxy inner => webProxy(inner), - OriginRequestVariants::Gcs inner => gcs(inner), - OriginRequestVariants::AzureBlob inner => azureBlob(inner), - OriginRequestVariants::AkeneoPim inner => akeneoPim(inner), - _ => throw new InvalidOperationException(), - }; - } - - public abstract void Validate(); -} - -sealed class OriginRequestConverter : JsonConverter -{ - public override OriginRequest? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - var json = JsonSerializer.Deserialize(ref reader, options); - string? type; - try - { - type = json.GetProperty("type").GetString(); - } - catch - { - type = null; - } - - switch (type) - { - case "S3": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - return new OriginRequestVariants::S3(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "S3_COMPATIBLE": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - return new OriginRequestVariants::S3Compatible(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "CLOUDINARY_BACKUP": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - return new OriginRequestVariants::CloudinaryBackup(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "WEB_FOLDER": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - return new OriginRequestVariants::WebFolder(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "WEB_PROXY": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - return new OriginRequestVariants::WebProxy(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "GCS": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - return new OriginRequestVariants::Gcs(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "AZURE_BLOB": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - return new OriginRequestVariants::AzureBlob(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "AKENEO_PIM": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - return new OriginRequestVariants::AkeneoPim(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - default: - { - throw new Exception(); - } - } - } - - public override void Write( - Utf8JsonWriter writer, - OriginRequest value, - JsonSerializerOptions options - ) - { - object variant = value switch - { - OriginRequestVariants::S3(var s3) => s3, - OriginRequestVariants::S3Compatible(var s3Compatible) => s3Compatible, - OriginRequestVariants::CloudinaryBackup(var cloudinaryBackup) => cloudinaryBackup, - OriginRequestVariants::WebFolder(var webFolder) => webFolder, - OriginRequestVariants::WebProxy(var webProxy) => webProxy, - OriginRequestVariants::Gcs(var gcs) => gcs, - OriginRequestVariants::AzureBlob(var azureBlob) => azureBlob, - OriginRequestVariants::AkeneoPim(var akeneoPim) => akeneoPim, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Accounts.Origins.OriginRequestProperties; +using OriginRequestVariants = Imagekit.Models.Accounts.Origins.OriginRequestVariants; + +namespace Imagekit.Models.Accounts.Origins; + +/// +/// Schema for origin request resources. +/// +[JsonConverter(typeof(OriginRequestConverter))] +public abstract record class OriginRequest +{ + internal OriginRequest() { } + + public static implicit operator OriginRequest(S3 value) => new OriginRequestVariants::S3(value); + + public static implicit operator OriginRequest(S3Compatible value) => + new OriginRequestVariants::S3Compatible(value); + + public static implicit operator OriginRequest(CloudinaryBackup value) => + new OriginRequestVariants::CloudinaryBackup(value); + + public static implicit operator OriginRequest(WebFolder value) => + new OriginRequestVariants::WebFolder(value); + + public static implicit operator OriginRequest(WebProxy value) => + new OriginRequestVariants::WebProxy(value); + + public static implicit operator OriginRequest(Gcs value) => + new OriginRequestVariants::Gcs(value); + + public static implicit operator OriginRequest(AzureBlob value) => + new OriginRequestVariants::AzureBlob(value); + + public static implicit operator OriginRequest(AkeneoPim value) => + new OriginRequestVariants::AkeneoPim(value); + + public bool TryPickS3([NotNullWhen(true)] out S3? value) + { + value = (this as OriginRequestVariants::S3)?.Value; + return value != null; + } + + public bool TryPickS3Compatible([NotNullWhen(true)] out S3Compatible? value) + { + value = (this as OriginRequestVariants::S3Compatible)?.Value; + return value != null; + } + + public bool TryPickCloudinaryBackup([NotNullWhen(true)] out CloudinaryBackup? value) + { + value = (this as OriginRequestVariants::CloudinaryBackup)?.Value; + return value != null; + } + + public bool TryPickWebFolder([NotNullWhen(true)] out WebFolder? value) + { + value = (this as OriginRequestVariants::WebFolder)?.Value; + return value != null; + } + + public bool TryPickWebProxy([NotNullWhen(true)] out WebProxy? value) + { + value = (this as OriginRequestVariants::WebProxy)?.Value; + return value != null; + } + + public bool TryPickGcs([NotNullWhen(true)] out Gcs? value) + { + value = (this as OriginRequestVariants::Gcs)?.Value; + return value != null; + } + + public bool TryPickAzureBlob([NotNullWhen(true)] out AzureBlob? value) + { + value = (this as OriginRequestVariants::AzureBlob)?.Value; + return value != null; + } + + public bool TryPickAkeneoPim([NotNullWhen(true)] out AkeneoPim? value) + { + value = (this as OriginRequestVariants::AkeneoPim)?.Value; + return value != null; + } + + public void Switch( + Action s3, + Action s3Compatible, + Action cloudinaryBackup, + Action webFolder, + Action webProxy, + Action gcs, + Action azureBlob, + Action akeneoPim + ) + { + switch (this) + { + case OriginRequestVariants::S3 inner: + s3(inner); + break; + case OriginRequestVariants::S3Compatible inner: + s3Compatible(inner); + break; + case OriginRequestVariants::CloudinaryBackup inner: + cloudinaryBackup(inner); + break; + case OriginRequestVariants::WebFolder inner: + webFolder(inner); + break; + case OriginRequestVariants::WebProxy inner: + webProxy(inner); + break; + case OriginRequestVariants::Gcs inner: + gcs(inner); + break; + case OriginRequestVariants::AzureBlob inner: + azureBlob(inner); + break; + case OriginRequestVariants::AkeneoPim inner: + akeneoPim(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func s3, + Func s3Compatible, + Func cloudinaryBackup, + Func webFolder, + Func webProxy, + Func gcs, + Func azureBlob, + Func akeneoPim + ) + { + return this switch + { + OriginRequestVariants::S3 inner => s3(inner), + OriginRequestVariants::S3Compatible inner => s3Compatible(inner), + OriginRequestVariants::CloudinaryBackup inner => cloudinaryBackup(inner), + OriginRequestVariants::WebFolder inner => webFolder(inner), + OriginRequestVariants::WebProxy inner => webProxy(inner), + OriginRequestVariants::Gcs inner => gcs(inner), + OriginRequestVariants::AzureBlob inner => azureBlob(inner), + OriginRequestVariants::AkeneoPim inner => akeneoPim(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class OriginRequestConverter : JsonConverter +{ + public override OriginRequest? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var json = JsonSerializer.Deserialize(ref reader, options); + string? type; + try + { + type = json.GetProperty("type").GetString(); + } + catch + { + type = null; + } + + switch (type) + { + case "S3": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new OriginRequestVariants::S3(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "S3_COMPATIBLE": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new OriginRequestVariants::S3Compatible(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "CLOUDINARY_BACKUP": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new OriginRequestVariants::CloudinaryBackup(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "WEB_FOLDER": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new OriginRequestVariants::WebFolder(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "WEB_PROXY": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new OriginRequestVariants::WebProxy(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "GCS": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new OriginRequestVariants::Gcs(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "AZURE_BLOB": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new OriginRequestVariants::AzureBlob(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "AKENEO_PIM": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new OriginRequestVariants::AkeneoPim(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + default: + { + throw new Exception(); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + OriginRequest value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + OriginRequestVariants::S3(var s3) => s3, + OriginRequestVariants::S3Compatible(var s3Compatible) => s3Compatible, + OriginRequestVariants::CloudinaryBackup(var cloudinaryBackup) => cloudinaryBackup, + OriginRequestVariants::WebFolder(var webFolder) => webFolder, + OriginRequestVariants::WebProxy(var webProxy) => webProxy, + OriginRequestVariants::Gcs(var gcs) => gcs, + OriginRequestVariants::AzureBlob(var azureBlob) => azureBlob, + OriginRequestVariants::AkeneoPim(var akeneoPim) => akeneoPim, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AkeneoPim.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AkeneoPim.cs index e3bb4329..4f328361 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AkeneoPim.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AkeneoPim.cs @@ -1,233 +1,233 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Accounts.Origins.OriginRequestProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class AkeneoPim : ModelBase, IFromRaw -{ - /// - /// Akeneo instance base URL. - /// - public required string BaseURL - { - get - { - if (!this.Properties.TryGetValue("baseUrl", out JsonElement element)) - throw new ArgumentOutOfRangeException("baseUrl", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("baseUrl"); - } - set - { - this.Properties["baseUrl"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Akeneo API client ID. - /// - public required string ClientID - { - get - { - if (!this.Properties.TryGetValue("clientId", out JsonElement element)) - throw new ArgumentOutOfRangeException("clientId", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("clientId"); - } - set - { - this.Properties["clientId"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Akeneo API client secret. - /// - public required string ClientSecret - { - get - { - if (!this.Properties.TryGetValue("clientSecret", out JsonElement element)) - throw new ArgumentOutOfRangeException("clientSecret", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("clientSecret"); - } - set - { - this.Properties["clientSecret"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Display name of the origin. - /// - public required string Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - throw new ArgumentOutOfRangeException("name", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("name"); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Akeneo API password. - /// - public required string Password - { - get - { - if (!this.Properties.TryGetValue("password", out JsonElement element)) - throw new ArgumentOutOfRangeException("password", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("password"); - } - set - { - this.Properties["password"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Akeneo API username. - /// - public required string Username - { - get - { - if (!this.Properties.TryGetValue("username", out JsonElement element)) - throw new ArgumentOutOfRangeException("username", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("username"); - } - set - { - this.Properties["username"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// URL used in the Canonical header (if enabled). - /// - public string? BaseURLForCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to send a Canonical header. - /// - public bool? IncludeCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.BaseURL; - _ = this.ClientID; - _ = this.ClientSecret; - _ = this.Name; - _ = this.Password; - _ = this.Username; - _ = this.BaseURLForCanonicalHeader; - _ = this.IncludeCanonicalHeader; - } - - public AkeneoPim() - { - this.Type = JsonSerializer.Deserialize("\"AKENEO_PIM\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - AkeneoPim(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static AkeneoPim FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Accounts.Origins.OriginRequestProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class AkeneoPim : ModelBase, IFromRaw +{ + /// + /// Akeneo instance base URL. + /// + public required string BaseURL + { + get + { + if (!this.Properties.TryGetValue("baseUrl", out JsonElement element)) + throw new ArgumentOutOfRangeException("baseUrl", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("baseUrl"); + } + set + { + this.Properties["baseUrl"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Akeneo API client ID. + /// + public required string ClientID + { + get + { + if (!this.Properties.TryGetValue("clientId", out JsonElement element)) + throw new ArgumentOutOfRangeException("clientId", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("clientId"); + } + set + { + this.Properties["clientId"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Akeneo API client secret. + /// + public required string ClientSecret + { + get + { + if (!this.Properties.TryGetValue("clientSecret", out JsonElement element)) + throw new ArgumentOutOfRangeException("clientSecret", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("clientSecret"); + } + set + { + this.Properties["clientSecret"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Display name of the origin. + /// + public required string Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + throw new ArgumentOutOfRangeException("name", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("name"); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Akeneo API password. + /// + public required string Password + { + get + { + if (!this.Properties.TryGetValue("password", out JsonElement element)) + throw new ArgumentOutOfRangeException("password", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("password"); + } + set + { + this.Properties["password"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Akeneo API username. + /// + public required string Username + { + get + { + if (!this.Properties.TryGetValue("username", out JsonElement element)) + throw new ArgumentOutOfRangeException("username", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("username"); + } + set + { + this.Properties["username"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// URL used in the Canonical header (if enabled). + /// + public string? BaseURLForCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to send a Canonical header. + /// + public bool? IncludeCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.BaseURL; + _ = this.ClientID; + _ = this.ClientSecret; + _ = this.Name; + _ = this.Password; + _ = this.Username; + _ = this.BaseURLForCanonicalHeader; + _ = this.IncludeCanonicalHeader; + } + + public AkeneoPim() + { + this.Type = JsonSerializer.Deserialize("\"AKENEO_PIM\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + AkeneoPim(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static AkeneoPim FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AzureBlob.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AzureBlob.cs index 130af741..eb0fd659 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AzureBlob.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AzureBlob.cs @@ -1,197 +1,197 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Accounts.Origins.OriginRequestProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class AzureBlob : ModelBase, IFromRaw -{ - public required string AccountName - { - get - { - if (!this.Properties.TryGetValue("accountName", out JsonElement element)) - throw new ArgumentOutOfRangeException("accountName", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("accountName"); - } - set - { - this.Properties["accountName"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required string Container - { - get - { - if (!this.Properties.TryGetValue("container", out JsonElement element)) - throw new ArgumentOutOfRangeException("container", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("container"); - } - set - { - this.Properties["container"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Display name of the origin. - /// - public required string Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - throw new ArgumentOutOfRangeException("name", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("name"); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required string SasToken - { - get - { - if (!this.Properties.TryGetValue("sasToken", out JsonElement element)) - throw new ArgumentOutOfRangeException("sasToken", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("sasToken"); - } - set - { - this.Properties["sasToken"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// URL used in the Canonical header (if enabled). - /// - public string? BaseURLForCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to send a Canonical header. - /// - public bool? IncludeCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public string? Prefix - { - get - { - if (!this.Properties.TryGetValue("prefix", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["prefix"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.AccountName; - _ = this.Container; - _ = this.Name; - _ = this.SasToken; - _ = this.BaseURLForCanonicalHeader; - _ = this.IncludeCanonicalHeader; - _ = this.Prefix; - } - - public AzureBlob() - { - this.Type = JsonSerializer.Deserialize("\"AZURE_BLOB\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - AzureBlob(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static AzureBlob FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Accounts.Origins.OriginRequestProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class AzureBlob : ModelBase, IFromRaw +{ + public required string AccountName + { + get + { + if (!this.Properties.TryGetValue("accountName", out JsonElement element)) + throw new ArgumentOutOfRangeException("accountName", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("accountName"); + } + set + { + this.Properties["accountName"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required string Container + { + get + { + if (!this.Properties.TryGetValue("container", out JsonElement element)) + throw new ArgumentOutOfRangeException("container", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("container"); + } + set + { + this.Properties["container"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Display name of the origin. + /// + public required string Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + throw new ArgumentOutOfRangeException("name", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("name"); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required string SasToken + { + get + { + if (!this.Properties.TryGetValue("sasToken", out JsonElement element)) + throw new ArgumentOutOfRangeException("sasToken", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("sasToken"); + } + set + { + this.Properties["sasToken"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// URL used in the Canonical header (if enabled). + /// + public string? BaseURLForCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to send a Canonical header. + /// + public bool? IncludeCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public string? Prefix + { + get + { + if (!this.Properties.TryGetValue("prefix", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["prefix"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.AccountName; + _ = this.Container; + _ = this.Name; + _ = this.SasToken; + _ = this.BaseURLForCanonicalHeader; + _ = this.IncludeCanonicalHeader; + _ = this.Prefix; + } + + public AzureBlob() + { + this.Type = JsonSerializer.Deserialize("\"AZURE_BLOB\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + AzureBlob(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static AzureBlob FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/CloudinaryBackup.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/CloudinaryBackup.cs index a4b9bb4f..9796a6b4 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/CloudinaryBackup.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/CloudinaryBackup.cs @@ -1,209 +1,209 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Accounts.Origins.OriginRequestProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class CloudinaryBackup : ModelBase, IFromRaw -{ - /// - /// Access key for the bucket. - /// - public required string AccessKey - { - get - { - if (!this.Properties.TryGetValue("accessKey", out JsonElement element)) - throw new ArgumentOutOfRangeException("accessKey", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("accessKey"); - } - set - { - this.Properties["accessKey"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// S3 bucket name. - /// - public required string Bucket - { - get - { - if (!this.Properties.TryGetValue("bucket", out JsonElement element)) - throw new ArgumentOutOfRangeException("bucket", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("bucket"); - } - set - { - this.Properties["bucket"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Display name of the origin. - /// - public required string Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - throw new ArgumentOutOfRangeException("name", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("name"); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Secret key for the bucket. - /// - public required string SecretKey - { - get - { - if (!this.Properties.TryGetValue("secretKey", out JsonElement element)) - throw new ArgumentOutOfRangeException("secretKey", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("secretKey"); - } - set - { - this.Properties["secretKey"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// URL used in the Canonical header (if enabled). - /// - public string? BaseURLForCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to send a Canonical header. - /// - public bool? IncludeCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Path prefix inside the bucket. - /// - public string? Prefix - { - get - { - if (!this.Properties.TryGetValue("prefix", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["prefix"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.AccessKey; - _ = this.Bucket; - _ = this.Name; - _ = this.SecretKey; - _ = this.BaseURLForCanonicalHeader; - _ = this.IncludeCanonicalHeader; - _ = this.Prefix; - } - - public CloudinaryBackup() - { - this.Type = JsonSerializer.Deserialize("\"CLOUDINARY_BACKUP\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - CloudinaryBackup(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static CloudinaryBackup FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Accounts.Origins.OriginRequestProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class CloudinaryBackup : ModelBase, IFromRaw +{ + /// + /// Access key for the bucket. + /// + public required string AccessKey + { + get + { + if (!this.Properties.TryGetValue("accessKey", out JsonElement element)) + throw new ArgumentOutOfRangeException("accessKey", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("accessKey"); + } + set + { + this.Properties["accessKey"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// S3 bucket name. + /// + public required string Bucket + { + get + { + if (!this.Properties.TryGetValue("bucket", out JsonElement element)) + throw new ArgumentOutOfRangeException("bucket", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("bucket"); + } + set + { + this.Properties["bucket"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Display name of the origin. + /// + public required string Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + throw new ArgumentOutOfRangeException("name", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("name"); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Secret key for the bucket. + /// + public required string SecretKey + { + get + { + if (!this.Properties.TryGetValue("secretKey", out JsonElement element)) + throw new ArgumentOutOfRangeException("secretKey", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("secretKey"); + } + set + { + this.Properties["secretKey"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// URL used in the Canonical header (if enabled). + /// + public string? BaseURLForCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to send a Canonical header. + /// + public bool? IncludeCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Path prefix inside the bucket. + /// + public string? Prefix + { + get + { + if (!this.Properties.TryGetValue("prefix", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["prefix"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.AccessKey; + _ = this.Bucket; + _ = this.Name; + _ = this.SecretKey; + _ = this.BaseURLForCanonicalHeader; + _ = this.IncludeCanonicalHeader; + _ = this.Prefix; + } + + public CloudinaryBackup() + { + this.Type = JsonSerializer.Deserialize("\"CLOUDINARY_BACKUP\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + CloudinaryBackup(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static CloudinaryBackup FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/Gcs.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/Gcs.cs index ad22fac8..82f507da 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/Gcs.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/Gcs.cs @@ -1,197 +1,197 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Accounts.Origins.OriginRequestProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Gcs : ModelBase, IFromRaw -{ - public required string Bucket - { - get - { - if (!this.Properties.TryGetValue("bucket", out JsonElement element)) - throw new ArgumentOutOfRangeException("bucket", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("bucket"); - } - set - { - this.Properties["bucket"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required string ClientEmail - { - get - { - if (!this.Properties.TryGetValue("clientEmail", out JsonElement element)) - throw new ArgumentOutOfRangeException("clientEmail", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("clientEmail"); - } - set - { - this.Properties["clientEmail"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Display name of the origin. - /// - public required string Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - throw new ArgumentOutOfRangeException("name", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("name"); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required string PrivateKey - { - get - { - if (!this.Properties.TryGetValue("privateKey", out JsonElement element)) - throw new ArgumentOutOfRangeException("privateKey", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("privateKey"); - } - set - { - this.Properties["privateKey"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// URL used in the Canonical header (if enabled). - /// - public string? BaseURLForCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to send a Canonical header. - /// - public bool? IncludeCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public string? Prefix - { - get - { - if (!this.Properties.TryGetValue("prefix", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["prefix"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.Bucket; - _ = this.ClientEmail; - _ = this.Name; - _ = this.PrivateKey; - _ = this.BaseURLForCanonicalHeader; - _ = this.IncludeCanonicalHeader; - _ = this.Prefix; - } - - public Gcs() - { - this.Type = JsonSerializer.Deserialize("\"GCS\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Gcs(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Gcs FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Accounts.Origins.OriginRequestProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Gcs : ModelBase, IFromRaw +{ + public required string Bucket + { + get + { + if (!this.Properties.TryGetValue("bucket", out JsonElement element)) + throw new ArgumentOutOfRangeException("bucket", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("bucket"); + } + set + { + this.Properties["bucket"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required string ClientEmail + { + get + { + if (!this.Properties.TryGetValue("clientEmail", out JsonElement element)) + throw new ArgumentOutOfRangeException("clientEmail", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("clientEmail"); + } + set + { + this.Properties["clientEmail"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Display name of the origin. + /// + public required string Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + throw new ArgumentOutOfRangeException("name", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("name"); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required string PrivateKey + { + get + { + if (!this.Properties.TryGetValue("privateKey", out JsonElement element)) + throw new ArgumentOutOfRangeException("privateKey", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("privateKey"); + } + set + { + this.Properties["privateKey"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// URL used in the Canonical header (if enabled). + /// + public string? BaseURLForCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to send a Canonical header. + /// + public bool? IncludeCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public string? Prefix + { + get + { + if (!this.Properties.TryGetValue("prefix", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["prefix"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.Bucket; + _ = this.ClientEmail; + _ = this.Name; + _ = this.PrivateKey; + _ = this.BaseURLForCanonicalHeader; + _ = this.IncludeCanonicalHeader; + _ = this.Prefix; + } + + public Gcs() + { + this.Type = JsonSerializer.Deserialize("\"GCS\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Gcs(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Gcs FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3.cs index f9d0d5f1..05605806 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3.cs @@ -1,209 +1,209 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Accounts.Origins.OriginRequestProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class S3 : ModelBase, IFromRaw -{ - /// - /// Access key for the bucket. - /// - public required string AccessKey - { - get - { - if (!this.Properties.TryGetValue("accessKey", out JsonElement element)) - throw new ArgumentOutOfRangeException("accessKey", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("accessKey"); - } - set - { - this.Properties["accessKey"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// S3 bucket name. - /// - public required string Bucket - { - get - { - if (!this.Properties.TryGetValue("bucket", out JsonElement element)) - throw new ArgumentOutOfRangeException("bucket", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("bucket"); - } - set - { - this.Properties["bucket"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Display name of the origin. - /// - public required string Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - throw new ArgumentOutOfRangeException("name", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("name"); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Secret key for the bucket. - /// - public required string SecretKey - { - get - { - if (!this.Properties.TryGetValue("secretKey", out JsonElement element)) - throw new ArgumentOutOfRangeException("secretKey", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("secretKey"); - } - set - { - this.Properties["secretKey"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// URL used in the Canonical header (if enabled). - /// - public string? BaseURLForCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to send a Canonical header. - /// - public bool? IncludeCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Path prefix inside the bucket. - /// - public string? Prefix - { - get - { - if (!this.Properties.TryGetValue("prefix", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["prefix"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.AccessKey; - _ = this.Bucket; - _ = this.Name; - _ = this.SecretKey; - _ = this.BaseURLForCanonicalHeader; - _ = this.IncludeCanonicalHeader; - _ = this.Prefix; - } - - public S3() - { - this.Type = JsonSerializer.Deserialize("\"S3\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - S3(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static S3 FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Accounts.Origins.OriginRequestProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class S3 : ModelBase, IFromRaw +{ + /// + /// Access key for the bucket. + /// + public required string AccessKey + { + get + { + if (!this.Properties.TryGetValue("accessKey", out JsonElement element)) + throw new ArgumentOutOfRangeException("accessKey", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("accessKey"); + } + set + { + this.Properties["accessKey"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// S3 bucket name. + /// + public required string Bucket + { + get + { + if (!this.Properties.TryGetValue("bucket", out JsonElement element)) + throw new ArgumentOutOfRangeException("bucket", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("bucket"); + } + set + { + this.Properties["bucket"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Display name of the origin. + /// + public required string Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + throw new ArgumentOutOfRangeException("name", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("name"); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Secret key for the bucket. + /// + public required string SecretKey + { + get + { + if (!this.Properties.TryGetValue("secretKey", out JsonElement element)) + throw new ArgumentOutOfRangeException("secretKey", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("secretKey"); + } + set + { + this.Properties["secretKey"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// URL used in the Canonical header (if enabled). + /// + public string? BaseURLForCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to send a Canonical header. + /// + public bool? IncludeCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Path prefix inside the bucket. + /// + public string? Prefix + { + get + { + if (!this.Properties.TryGetValue("prefix", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["prefix"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.AccessKey; + _ = this.Bucket; + _ = this.Name; + _ = this.SecretKey; + _ = this.BaseURLForCanonicalHeader; + _ = this.IncludeCanonicalHeader; + _ = this.Prefix; + } + + public S3() + { + this.Type = JsonSerializer.Deserialize("\"S3\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + S3(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static S3 FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3Compatible.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3Compatible.cs index 500d31b5..9c719e79 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3Compatible.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3Compatible.cs @@ -1,254 +1,254 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Accounts.Origins.OriginRequestProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class S3Compatible : ModelBase, IFromRaw -{ - /// - /// Access key for the bucket. - /// - public required string AccessKey - { - get - { - if (!this.Properties.TryGetValue("accessKey", out JsonElement element)) - throw new ArgumentOutOfRangeException("accessKey", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("accessKey"); - } - set - { - this.Properties["accessKey"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// S3 bucket name. - /// - public required string Bucket - { - get - { - if (!this.Properties.TryGetValue("bucket", out JsonElement element)) - throw new ArgumentOutOfRangeException("bucket", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("bucket"); - } - set - { - this.Properties["bucket"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Custom S3-compatible endpoint. - /// - public required string Endpoint - { - get - { - if (!this.Properties.TryGetValue("endpoint", out JsonElement element)) - throw new ArgumentOutOfRangeException("endpoint", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("endpoint"); - } - set - { - this.Properties["endpoint"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Display name of the origin. - /// - public required string Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - throw new ArgumentOutOfRangeException("name", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("name"); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Secret key for the bucket. - /// - public required string SecretKey - { - get - { - if (!this.Properties.TryGetValue("secretKey", out JsonElement element)) - throw new ArgumentOutOfRangeException("secretKey", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("secretKey"); - } - set - { - this.Properties["secretKey"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// URL used in the Canonical header (if enabled). - /// - public string? BaseURLForCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to send a Canonical header. - /// - public bool? IncludeCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Path prefix inside the bucket. - /// - public string? Prefix - { - get - { - if (!this.Properties.TryGetValue("prefix", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["prefix"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Use path-style S3 URLs? - /// - public bool? S3ForcePathStyle - { - get - { - if (!this.Properties.TryGetValue("s3ForcePathStyle", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["s3ForcePathStyle"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.AccessKey; - _ = this.Bucket; - _ = this.Endpoint; - _ = this.Name; - _ = this.SecretKey; - _ = this.BaseURLForCanonicalHeader; - _ = this.IncludeCanonicalHeader; - _ = this.Prefix; - _ = this.S3ForcePathStyle; - } - - public S3Compatible() - { - this.Type = JsonSerializer.Deserialize("\"S3_COMPATIBLE\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - S3Compatible(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static S3Compatible FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Accounts.Origins.OriginRequestProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class S3Compatible : ModelBase, IFromRaw +{ + /// + /// Access key for the bucket. + /// + public required string AccessKey + { + get + { + if (!this.Properties.TryGetValue("accessKey", out JsonElement element)) + throw new ArgumentOutOfRangeException("accessKey", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("accessKey"); + } + set + { + this.Properties["accessKey"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// S3 bucket name. + /// + public required string Bucket + { + get + { + if (!this.Properties.TryGetValue("bucket", out JsonElement element)) + throw new ArgumentOutOfRangeException("bucket", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("bucket"); + } + set + { + this.Properties["bucket"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Custom S3-compatible endpoint. + /// + public required string Endpoint + { + get + { + if (!this.Properties.TryGetValue("endpoint", out JsonElement element)) + throw new ArgumentOutOfRangeException("endpoint", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("endpoint"); + } + set + { + this.Properties["endpoint"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Display name of the origin. + /// + public required string Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + throw new ArgumentOutOfRangeException("name", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("name"); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Secret key for the bucket. + /// + public required string SecretKey + { + get + { + if (!this.Properties.TryGetValue("secretKey", out JsonElement element)) + throw new ArgumentOutOfRangeException("secretKey", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("secretKey"); + } + set + { + this.Properties["secretKey"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// URL used in the Canonical header (if enabled). + /// + public string? BaseURLForCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to send a Canonical header. + /// + public bool? IncludeCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Path prefix inside the bucket. + /// + public string? Prefix + { + get + { + if (!this.Properties.TryGetValue("prefix", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["prefix"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Use path-style S3 URLs? + /// + public bool? S3ForcePathStyle + { + get + { + if (!this.Properties.TryGetValue("s3ForcePathStyle", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["s3ForcePathStyle"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.AccessKey; + _ = this.Bucket; + _ = this.Endpoint; + _ = this.Name; + _ = this.SecretKey; + _ = this.BaseURLForCanonicalHeader; + _ = this.IncludeCanonicalHeader; + _ = this.Prefix; + _ = this.S3ForcePathStyle; + } + + public S3Compatible() + { + this.Type = JsonSerializer.Deserialize("\"S3_COMPATIBLE\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + S3Compatible(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static S3Compatible FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebFolder.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebFolder.cs index 09bf8765..8f84dc3e 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebFolder.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebFolder.cs @@ -1,163 +1,163 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Accounts.Origins.OriginRequestProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class WebFolder : ModelBase, IFromRaw -{ - /// - /// Root URL for the web folder origin. - /// - public required string BaseURL - { - get - { - if (!this.Properties.TryGetValue("baseUrl", out JsonElement element)) - throw new ArgumentOutOfRangeException("baseUrl", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("baseUrl"); - } - set - { - this.Properties["baseUrl"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Display name of the origin. - /// - public required string Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - throw new ArgumentOutOfRangeException("name", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("name"); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// URL used in the Canonical header (if enabled). - /// - public string? BaseURLForCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Forward the Host header to origin? - /// - public bool? ForwardHostHeaderToOrigin - { - get - { - if (!this.Properties.TryGetValue("forwardHostHeaderToOrigin", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["forwardHostHeaderToOrigin"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to send a Canonical header. - /// - public bool? IncludeCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.BaseURL; - _ = this.Name; - _ = this.BaseURLForCanonicalHeader; - _ = this.ForwardHostHeaderToOrigin; - _ = this.IncludeCanonicalHeader; - } - - public WebFolder() - { - this.Type = JsonSerializer.Deserialize("\"WEB_FOLDER\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - WebFolder(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static WebFolder FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Accounts.Origins.OriginRequestProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class WebFolder : ModelBase, IFromRaw +{ + /// + /// Root URL for the web folder origin. + /// + public required string BaseURL + { + get + { + if (!this.Properties.TryGetValue("baseUrl", out JsonElement element)) + throw new ArgumentOutOfRangeException("baseUrl", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("baseUrl"); + } + set + { + this.Properties["baseUrl"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Display name of the origin. + /// + public required string Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + throw new ArgumentOutOfRangeException("name", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("name"); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// URL used in the Canonical header (if enabled). + /// + public string? BaseURLForCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Forward the Host header to origin? + /// + public bool? ForwardHostHeaderToOrigin + { + get + { + if (!this.Properties.TryGetValue("forwardHostHeaderToOrigin", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["forwardHostHeaderToOrigin"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to send a Canonical header. + /// + public bool? IncludeCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.BaseURL; + _ = this.Name; + _ = this.BaseURLForCanonicalHeader; + _ = this.ForwardHostHeaderToOrigin; + _ = this.IncludeCanonicalHeader; + } + + public WebFolder() + { + this.Type = JsonSerializer.Deserialize("\"WEB_FOLDER\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + WebFolder(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static WebFolder FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebProxy.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebProxy.cs index bf88baa9..73afbce7 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebProxy.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebProxy.cs @@ -1,125 +1,125 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Accounts.Origins.OriginRequestProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class WebProxy : ModelBase, IFromRaw -{ - /// - /// Display name of the origin. - /// - public required string Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - throw new ArgumentOutOfRangeException("name", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("name"); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// URL used in the Canonical header (if enabled). - /// - public string? BaseURLForCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to send a Canonical header. - /// - public bool? IncludeCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.Name; - _ = this.BaseURLForCanonicalHeader; - _ = this.IncludeCanonicalHeader; - } - - public WebProxy() - { - this.Type = JsonSerializer.Deserialize("\"WEB_PROXY\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - WebProxy(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static WebProxy FromRawUnchecked(Dictionary properties) - { - return new(properties); - } - - [SetsRequiredMembers] - public WebProxy(string name) - : this() - { - this.Name = name; - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Accounts.Origins.OriginRequestProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class WebProxy : ModelBase, IFromRaw +{ + /// + /// Display name of the origin. + /// + public required string Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + throw new ArgumentOutOfRangeException("name", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("name"); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// URL used in the Canonical header (if enabled). + /// + public string? BaseURLForCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to send a Canonical header. + /// + public bool? IncludeCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.Name; + _ = this.BaseURLForCanonicalHeader; + _ = this.IncludeCanonicalHeader; + } + + public WebProxy() + { + this.Type = JsonSerializer.Deserialize("\"WEB_PROXY\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + WebProxy(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static WebProxy FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public WebProxy(string name) + : this() + { + this.Name = name; + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponse.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponse.cs index 9fd7dadf..60d7a68c 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginResponse.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginResponse.cs @@ -1,361 +1,361 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Accounts.Origins.OriginResponseProperties; -using OriginResponseVariants = Imagekit.Models.Accounts.Origins.OriginResponseVariants; - -namespace Imagekit.Models.Accounts.Origins; - -/// -/// Origin object as returned by the API (sensitive fields removed). -/// -[JsonConverter(typeof(OriginResponseConverter))] -public abstract record class OriginResponse -{ - internal OriginResponse() { } - - public static implicit operator OriginResponse(S3 value) => - new OriginResponseVariants::S3(value); - - public static implicit operator OriginResponse(S3Compatible value) => - new OriginResponseVariants::S3Compatible(value); - - public static implicit operator OriginResponse(CloudinaryBackup value) => - new OriginResponseVariants::CloudinaryBackup(value); - - public static implicit operator OriginResponse(WebFolder value) => - new OriginResponseVariants::WebFolder(value); - - public static implicit operator OriginResponse(WebProxy value) => - new OriginResponseVariants::WebProxy(value); - - public static implicit operator OriginResponse(Gcs value) => - new OriginResponseVariants::Gcs(value); - - public static implicit operator OriginResponse(AzureBlob value) => - new OriginResponseVariants::AzureBlob(value); - - public static implicit operator OriginResponse(AkeneoPim value) => - new OriginResponseVariants::AkeneoPim(value); - - public bool TryPickS3([NotNullWhen(true)] out S3? value) - { - value = (this as OriginResponseVariants::S3)?.Value; - return value != null; - } - - public bool TryPickS3Compatible([NotNullWhen(true)] out S3Compatible? value) - { - value = (this as OriginResponseVariants::S3Compatible)?.Value; - return value != null; - } - - public bool TryPickCloudinaryBackup([NotNullWhen(true)] out CloudinaryBackup? value) - { - value = (this as OriginResponseVariants::CloudinaryBackup)?.Value; - return value != null; - } - - public bool TryPickWebFolder([NotNullWhen(true)] out WebFolder? value) - { - value = (this as OriginResponseVariants::WebFolder)?.Value; - return value != null; - } - - public bool TryPickWebProxy([NotNullWhen(true)] out WebProxy? value) - { - value = (this as OriginResponseVariants::WebProxy)?.Value; - return value != null; - } - - public bool TryPickGcs([NotNullWhen(true)] out Gcs? value) - { - value = (this as OriginResponseVariants::Gcs)?.Value; - return value != null; - } - - public bool TryPickAzureBlob([NotNullWhen(true)] out AzureBlob? value) - { - value = (this as OriginResponseVariants::AzureBlob)?.Value; - return value != null; - } - - public bool TryPickAkeneoPim([NotNullWhen(true)] out AkeneoPim? value) - { - value = (this as OriginResponseVariants::AkeneoPim)?.Value; - return value != null; - } - - public void Switch( - Action s3, - Action s3Compatible, - Action cloudinaryBackup, - Action webFolder, - Action webProxy, - Action gcs, - Action azureBlob, - Action akeneoPim - ) - { - switch (this) - { - case OriginResponseVariants::S3 inner: - s3(inner); - break; - case OriginResponseVariants::S3Compatible inner: - s3Compatible(inner); - break; - case OriginResponseVariants::CloudinaryBackup inner: - cloudinaryBackup(inner); - break; - case OriginResponseVariants::WebFolder inner: - webFolder(inner); - break; - case OriginResponseVariants::WebProxy inner: - webProxy(inner); - break; - case OriginResponseVariants::Gcs inner: - gcs(inner); - break; - case OriginResponseVariants::AzureBlob inner: - azureBlob(inner); - break; - case OriginResponseVariants::AkeneoPim inner: - akeneoPim(inner); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match( - Func s3, - Func s3Compatible, - Func cloudinaryBackup, - Func webFolder, - Func webProxy, - Func gcs, - Func azureBlob, - Func akeneoPim - ) - { - return this switch - { - OriginResponseVariants::S3 inner => s3(inner), - OriginResponseVariants::S3Compatible inner => s3Compatible(inner), - OriginResponseVariants::CloudinaryBackup inner => cloudinaryBackup(inner), - OriginResponseVariants::WebFolder inner => webFolder(inner), - OriginResponseVariants::WebProxy inner => webProxy(inner), - OriginResponseVariants::Gcs inner => gcs(inner), - OriginResponseVariants::AzureBlob inner => azureBlob(inner), - OriginResponseVariants::AkeneoPim inner => akeneoPim(inner), - _ => throw new InvalidOperationException(), - }; - } - - public abstract void Validate(); -} - -sealed class OriginResponseConverter : JsonConverter -{ - public override OriginResponse? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - var json = JsonSerializer.Deserialize(ref reader, options); - string? type; - try - { - type = json.GetProperty("type").GetString(); - } - catch - { - type = null; - } - - switch (type) - { - case "S3": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - return new OriginResponseVariants::S3(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "S3_COMPATIBLE": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - return new OriginResponseVariants::S3Compatible(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "CLOUDINARY_BACKUP": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - return new OriginResponseVariants::CloudinaryBackup(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "WEB_FOLDER": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - return new OriginResponseVariants::WebFolder(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "WEB_PROXY": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - return new OriginResponseVariants::WebProxy(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "GCS": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - return new OriginResponseVariants::Gcs(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "AZURE_BLOB": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - return new OriginResponseVariants::AzureBlob(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "AKENEO_PIM": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - return new OriginResponseVariants::AkeneoPim(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - default: - { - throw new Exception(); - } - } - } - - public override void Write( - Utf8JsonWriter writer, - OriginResponse value, - JsonSerializerOptions options - ) - { - object variant = value switch - { - OriginResponseVariants::S3(var s3) => s3, - OriginResponseVariants::S3Compatible(var s3Compatible) => s3Compatible, - OriginResponseVariants::CloudinaryBackup(var cloudinaryBackup) => cloudinaryBackup, - OriginResponseVariants::WebFolder(var webFolder) => webFolder, - OriginResponseVariants::WebProxy(var webProxy) => webProxy, - OriginResponseVariants::Gcs(var gcs) => gcs, - OriginResponseVariants::AzureBlob(var azureBlob) => azureBlob, - OriginResponseVariants::AkeneoPim(var akeneoPim) => akeneoPim, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Accounts.Origins.OriginResponseProperties; +using OriginResponseVariants = Imagekit.Models.Accounts.Origins.OriginResponseVariants; + +namespace Imagekit.Models.Accounts.Origins; + +/// +/// Origin object as returned by the API (sensitive fields removed). +/// +[JsonConverter(typeof(OriginResponseConverter))] +public abstract record class OriginResponse +{ + internal OriginResponse() { } + + public static implicit operator OriginResponse(S3 value) => + new OriginResponseVariants::S3(value); + + public static implicit operator OriginResponse(S3Compatible value) => + new OriginResponseVariants::S3Compatible(value); + + public static implicit operator OriginResponse(CloudinaryBackup value) => + new OriginResponseVariants::CloudinaryBackup(value); + + public static implicit operator OriginResponse(WebFolder value) => + new OriginResponseVariants::WebFolder(value); + + public static implicit operator OriginResponse(WebProxy value) => + new OriginResponseVariants::WebProxy(value); + + public static implicit operator OriginResponse(Gcs value) => + new OriginResponseVariants::Gcs(value); + + public static implicit operator OriginResponse(AzureBlob value) => + new OriginResponseVariants::AzureBlob(value); + + public static implicit operator OriginResponse(AkeneoPim value) => + new OriginResponseVariants::AkeneoPim(value); + + public bool TryPickS3([NotNullWhen(true)] out S3? value) + { + value = (this as OriginResponseVariants::S3)?.Value; + return value != null; + } + + public bool TryPickS3Compatible([NotNullWhen(true)] out S3Compatible? value) + { + value = (this as OriginResponseVariants::S3Compatible)?.Value; + return value != null; + } + + public bool TryPickCloudinaryBackup([NotNullWhen(true)] out CloudinaryBackup? value) + { + value = (this as OriginResponseVariants::CloudinaryBackup)?.Value; + return value != null; + } + + public bool TryPickWebFolder([NotNullWhen(true)] out WebFolder? value) + { + value = (this as OriginResponseVariants::WebFolder)?.Value; + return value != null; + } + + public bool TryPickWebProxy([NotNullWhen(true)] out WebProxy? value) + { + value = (this as OriginResponseVariants::WebProxy)?.Value; + return value != null; + } + + public bool TryPickGcs([NotNullWhen(true)] out Gcs? value) + { + value = (this as OriginResponseVariants::Gcs)?.Value; + return value != null; + } + + public bool TryPickAzureBlob([NotNullWhen(true)] out AzureBlob? value) + { + value = (this as OriginResponseVariants::AzureBlob)?.Value; + return value != null; + } + + public bool TryPickAkeneoPim([NotNullWhen(true)] out AkeneoPim? value) + { + value = (this as OriginResponseVariants::AkeneoPim)?.Value; + return value != null; + } + + public void Switch( + Action s3, + Action s3Compatible, + Action cloudinaryBackup, + Action webFolder, + Action webProxy, + Action gcs, + Action azureBlob, + Action akeneoPim + ) + { + switch (this) + { + case OriginResponseVariants::S3 inner: + s3(inner); + break; + case OriginResponseVariants::S3Compatible inner: + s3Compatible(inner); + break; + case OriginResponseVariants::CloudinaryBackup inner: + cloudinaryBackup(inner); + break; + case OriginResponseVariants::WebFolder inner: + webFolder(inner); + break; + case OriginResponseVariants::WebProxy inner: + webProxy(inner); + break; + case OriginResponseVariants::Gcs inner: + gcs(inner); + break; + case OriginResponseVariants::AzureBlob inner: + azureBlob(inner); + break; + case OriginResponseVariants::AkeneoPim inner: + akeneoPim(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func s3, + Func s3Compatible, + Func cloudinaryBackup, + Func webFolder, + Func webProxy, + Func gcs, + Func azureBlob, + Func akeneoPim + ) + { + return this switch + { + OriginResponseVariants::S3 inner => s3(inner), + OriginResponseVariants::S3Compatible inner => s3Compatible(inner), + OriginResponseVariants::CloudinaryBackup inner => cloudinaryBackup(inner), + OriginResponseVariants::WebFolder inner => webFolder(inner), + OriginResponseVariants::WebProxy inner => webProxy(inner), + OriginResponseVariants::Gcs inner => gcs(inner), + OriginResponseVariants::AzureBlob inner => azureBlob(inner), + OriginResponseVariants::AkeneoPim inner => akeneoPim(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class OriginResponseConverter : JsonConverter +{ + public override OriginResponse? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var json = JsonSerializer.Deserialize(ref reader, options); + string? type; + try + { + type = json.GetProperty("type").GetString(); + } + catch + { + type = null; + } + + switch (type) + { + case "S3": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new OriginResponseVariants::S3(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "S3_COMPATIBLE": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new OriginResponseVariants::S3Compatible(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "CLOUDINARY_BACKUP": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new OriginResponseVariants::CloudinaryBackup(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "WEB_FOLDER": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new OriginResponseVariants::WebFolder(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "WEB_PROXY": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new OriginResponseVariants::WebProxy(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "GCS": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new OriginResponseVariants::Gcs(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "AZURE_BLOB": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new OriginResponseVariants::AzureBlob(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "AKENEO_PIM": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new OriginResponseVariants::AkeneoPim(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + default: + { + throw new Exception(); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + OriginResponse value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + OriginResponseVariants::S3(var s3) => s3, + OriginResponseVariants::S3Compatible(var s3Compatible) => s3Compatible, + OriginResponseVariants::CloudinaryBackup(var cloudinaryBackup) => cloudinaryBackup, + OriginResponseVariants::WebFolder(var webFolder) => webFolder, + OriginResponseVariants::WebProxy(var webProxy) => webProxy, + OriginResponseVariants::Gcs(var gcs) => gcs, + OriginResponseVariants::AzureBlob(var azureBlob) => azureBlob, + OriginResponseVariants::AkeneoPim(var akeneoPim) => akeneoPim, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AkeneoPim.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AkeneoPim.cs index 9860c44c..8bc2a167 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AkeneoPim.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AkeneoPim.cs @@ -1,168 +1,168 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Accounts.Origins.OriginResponseProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class AkeneoPim : ModelBase, IFromRaw -{ - /// - /// Unique identifier for the origin. This is generated by ImageKit when you create - /// a new origin. - /// - public required string ID - { - get - { - if (!this.Properties.TryGetValue("id", out JsonElement element)) - throw new ArgumentOutOfRangeException("id", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("id"); - } - set - { - this.Properties["id"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Akeneo instance base URL. - /// - public required string BaseURL - { - get - { - if (!this.Properties.TryGetValue("baseUrl", out JsonElement element)) - throw new ArgumentOutOfRangeException("baseUrl", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("baseUrl"); - } - set - { - this.Properties["baseUrl"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to send a Canonical header. - /// - public required bool IncludeCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) - throw new ArgumentOutOfRangeException( - "includeCanonicalHeader", - "Missing required argument" - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Display name of the origin. - /// - public required string Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - throw new ArgumentOutOfRangeException("name", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("name"); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// URL used in the Canonical header (if enabled). - /// - public string? BaseURLForCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.ID; - _ = this.BaseURL; - _ = this.IncludeCanonicalHeader; - _ = this.Name; - _ = this.BaseURLForCanonicalHeader; - } - - public AkeneoPim() - { - this.Type = JsonSerializer.Deserialize("\"AKENEO_PIM\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - AkeneoPim(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static AkeneoPim FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Accounts.Origins.OriginResponseProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class AkeneoPim : ModelBase, IFromRaw +{ + /// + /// Unique identifier for the origin. This is generated by ImageKit when you create + /// a new origin. + /// + public required string ID + { + get + { + if (!this.Properties.TryGetValue("id", out JsonElement element)) + throw new ArgumentOutOfRangeException("id", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("id"); + } + set + { + this.Properties["id"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Akeneo instance base URL. + /// + public required string BaseURL + { + get + { + if (!this.Properties.TryGetValue("baseUrl", out JsonElement element)) + throw new ArgumentOutOfRangeException("baseUrl", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("baseUrl"); + } + set + { + this.Properties["baseUrl"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to send a Canonical header. + /// + public required bool IncludeCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) + throw new ArgumentOutOfRangeException( + "includeCanonicalHeader", + "Missing required argument" + ); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Display name of the origin. + /// + public required string Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + throw new ArgumentOutOfRangeException("name", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("name"); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// URL used in the Canonical header (if enabled). + /// + public string? BaseURLForCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.ID; + _ = this.BaseURL; + _ = this.IncludeCanonicalHeader; + _ = this.Name; + _ = this.BaseURLForCanonicalHeader; + } + + public AkeneoPim() + { + this.Type = JsonSerializer.Deserialize("\"AKENEO_PIM\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + AkeneoPim(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static AkeneoPim FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AzureBlob.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AzureBlob.cs index afd047bd..3c8c3936 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AzureBlob.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AzureBlob.cs @@ -1,205 +1,205 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Accounts.Origins.OriginResponseProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class AzureBlob : ModelBase, IFromRaw -{ - /// - /// Unique identifier for the origin. This is generated by ImageKit when you create - /// a new origin. - /// - public required string ID - { - get - { - if (!this.Properties.TryGetValue("id", out JsonElement element)) - throw new ArgumentOutOfRangeException("id", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("id"); - } - set - { - this.Properties["id"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required string AccountName - { - get - { - if (!this.Properties.TryGetValue("accountName", out JsonElement element)) - throw new ArgumentOutOfRangeException("accountName", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("accountName"); - } - set - { - this.Properties["accountName"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required string Container - { - get - { - if (!this.Properties.TryGetValue("container", out JsonElement element)) - throw new ArgumentOutOfRangeException("container", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("container"); - } - set - { - this.Properties["container"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to send a Canonical header. - /// - public required bool IncludeCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) - throw new ArgumentOutOfRangeException( - "includeCanonicalHeader", - "Missing required argument" - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Display name of the origin. - /// - public required string Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - throw new ArgumentOutOfRangeException("name", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("name"); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required string Prefix - { - get - { - if (!this.Properties.TryGetValue("prefix", out JsonElement element)) - throw new ArgumentOutOfRangeException("prefix", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("prefix"); - } - set - { - this.Properties["prefix"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// URL used in the Canonical header (if enabled). - /// - public string? BaseURLForCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.ID; - _ = this.AccountName; - _ = this.Container; - _ = this.IncludeCanonicalHeader; - _ = this.Name; - _ = this.Prefix; - _ = this.BaseURLForCanonicalHeader; - } - - public AzureBlob() - { - this.Type = JsonSerializer.Deserialize("\"AZURE_BLOB\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - AzureBlob(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static AzureBlob FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Accounts.Origins.OriginResponseProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class AzureBlob : ModelBase, IFromRaw +{ + /// + /// Unique identifier for the origin. This is generated by ImageKit when you create + /// a new origin. + /// + public required string ID + { + get + { + if (!this.Properties.TryGetValue("id", out JsonElement element)) + throw new ArgumentOutOfRangeException("id", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("id"); + } + set + { + this.Properties["id"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required string AccountName + { + get + { + if (!this.Properties.TryGetValue("accountName", out JsonElement element)) + throw new ArgumentOutOfRangeException("accountName", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("accountName"); + } + set + { + this.Properties["accountName"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required string Container + { + get + { + if (!this.Properties.TryGetValue("container", out JsonElement element)) + throw new ArgumentOutOfRangeException("container", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("container"); + } + set + { + this.Properties["container"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to send a Canonical header. + /// + public required bool IncludeCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) + throw new ArgumentOutOfRangeException( + "includeCanonicalHeader", + "Missing required argument" + ); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Display name of the origin. + /// + public required string Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + throw new ArgumentOutOfRangeException("name", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("name"); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required string Prefix + { + get + { + if (!this.Properties.TryGetValue("prefix", out JsonElement element)) + throw new ArgumentOutOfRangeException("prefix", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("prefix"); + } + set + { + this.Properties["prefix"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// URL used in the Canonical header (if enabled). + /// + public string? BaseURLForCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.ID; + _ = this.AccountName; + _ = this.Container; + _ = this.IncludeCanonicalHeader; + _ = this.Name; + _ = this.Prefix; + _ = this.BaseURLForCanonicalHeader; + } + + public AzureBlob() + { + this.Type = JsonSerializer.Deserialize("\"AZURE_BLOB\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + AzureBlob(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static AzureBlob FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/CloudinaryBackup.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/CloudinaryBackup.cs index 288553c5..f3c5e1e6 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/CloudinaryBackup.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/CloudinaryBackup.cs @@ -1,191 +1,191 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Accounts.Origins.OriginResponseProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class CloudinaryBackup : ModelBase, IFromRaw -{ - /// - /// Unique identifier for the origin. This is generated by ImageKit when you create - /// a new origin. - /// - public required string ID - { - get - { - if (!this.Properties.TryGetValue("id", out JsonElement element)) - throw new ArgumentOutOfRangeException("id", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("id"); - } - set - { - this.Properties["id"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// S3 bucket name. - /// - public required string Bucket - { - get - { - if (!this.Properties.TryGetValue("bucket", out JsonElement element)) - throw new ArgumentOutOfRangeException("bucket", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("bucket"); - } - set - { - this.Properties["bucket"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to send a Canonical header. - /// - public required bool IncludeCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) - throw new ArgumentOutOfRangeException( - "includeCanonicalHeader", - "Missing required argument" - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Display name of the origin. - /// - public required string Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - throw new ArgumentOutOfRangeException("name", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("name"); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Path prefix inside the bucket. - /// - public required string Prefix - { - get - { - if (!this.Properties.TryGetValue("prefix", out JsonElement element)) - throw new ArgumentOutOfRangeException("prefix", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("prefix"); - } - set - { - this.Properties["prefix"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// URL used in the Canonical header (if enabled). - /// - public string? BaseURLForCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.ID; - _ = this.Bucket; - _ = this.IncludeCanonicalHeader; - _ = this.Name; - _ = this.Prefix; - _ = this.BaseURLForCanonicalHeader; - } - - public CloudinaryBackup() - { - this.Type = JsonSerializer.Deserialize("\"CLOUDINARY_BACKUP\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - CloudinaryBackup(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static CloudinaryBackup FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Accounts.Origins.OriginResponseProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class CloudinaryBackup : ModelBase, IFromRaw +{ + /// + /// Unique identifier for the origin. This is generated by ImageKit when you create + /// a new origin. + /// + public required string ID + { + get + { + if (!this.Properties.TryGetValue("id", out JsonElement element)) + throw new ArgumentOutOfRangeException("id", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("id"); + } + set + { + this.Properties["id"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// S3 bucket name. + /// + public required string Bucket + { + get + { + if (!this.Properties.TryGetValue("bucket", out JsonElement element)) + throw new ArgumentOutOfRangeException("bucket", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("bucket"); + } + set + { + this.Properties["bucket"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to send a Canonical header. + /// + public required bool IncludeCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) + throw new ArgumentOutOfRangeException( + "includeCanonicalHeader", + "Missing required argument" + ); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Display name of the origin. + /// + public required string Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + throw new ArgumentOutOfRangeException("name", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("name"); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Path prefix inside the bucket. + /// + public required string Prefix + { + get + { + if (!this.Properties.TryGetValue("prefix", out JsonElement element)) + throw new ArgumentOutOfRangeException("prefix", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("prefix"); + } + set + { + this.Properties["prefix"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// URL used in the Canonical header (if enabled). + /// + public string? BaseURLForCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.ID; + _ = this.Bucket; + _ = this.IncludeCanonicalHeader; + _ = this.Name; + _ = this.Prefix; + _ = this.BaseURLForCanonicalHeader; + } + + public CloudinaryBackup() + { + this.Type = JsonSerializer.Deserialize("\"CLOUDINARY_BACKUP\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + CloudinaryBackup(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static CloudinaryBackup FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/Gcs.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/Gcs.cs index 17a6daac..cbf792ed 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/Gcs.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/Gcs.cs @@ -1,205 +1,205 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Accounts.Origins.OriginResponseProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Gcs : ModelBase, IFromRaw -{ - /// - /// Unique identifier for the origin. This is generated by ImageKit when you create - /// a new origin. - /// - public required string ID - { - get - { - if (!this.Properties.TryGetValue("id", out JsonElement element)) - throw new ArgumentOutOfRangeException("id", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("id"); - } - set - { - this.Properties["id"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required string Bucket - { - get - { - if (!this.Properties.TryGetValue("bucket", out JsonElement element)) - throw new ArgumentOutOfRangeException("bucket", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("bucket"); - } - set - { - this.Properties["bucket"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required string ClientEmail - { - get - { - if (!this.Properties.TryGetValue("clientEmail", out JsonElement element)) - throw new ArgumentOutOfRangeException("clientEmail", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("clientEmail"); - } - set - { - this.Properties["clientEmail"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to send a Canonical header. - /// - public required bool IncludeCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) - throw new ArgumentOutOfRangeException( - "includeCanonicalHeader", - "Missing required argument" - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Display name of the origin. - /// - public required string Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - throw new ArgumentOutOfRangeException("name", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("name"); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required string Prefix - { - get - { - if (!this.Properties.TryGetValue("prefix", out JsonElement element)) - throw new ArgumentOutOfRangeException("prefix", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("prefix"); - } - set - { - this.Properties["prefix"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// URL used in the Canonical header (if enabled). - /// - public string? BaseURLForCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.ID; - _ = this.Bucket; - _ = this.ClientEmail; - _ = this.IncludeCanonicalHeader; - _ = this.Name; - _ = this.Prefix; - _ = this.BaseURLForCanonicalHeader; - } - - public Gcs() - { - this.Type = JsonSerializer.Deserialize("\"GCS\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Gcs(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Gcs FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Accounts.Origins.OriginResponseProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Gcs : ModelBase, IFromRaw +{ + /// + /// Unique identifier for the origin. This is generated by ImageKit when you create + /// a new origin. + /// + public required string ID + { + get + { + if (!this.Properties.TryGetValue("id", out JsonElement element)) + throw new ArgumentOutOfRangeException("id", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("id"); + } + set + { + this.Properties["id"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required string Bucket + { + get + { + if (!this.Properties.TryGetValue("bucket", out JsonElement element)) + throw new ArgumentOutOfRangeException("bucket", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("bucket"); + } + set + { + this.Properties["bucket"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required string ClientEmail + { + get + { + if (!this.Properties.TryGetValue("clientEmail", out JsonElement element)) + throw new ArgumentOutOfRangeException("clientEmail", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("clientEmail"); + } + set + { + this.Properties["clientEmail"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to send a Canonical header. + /// + public required bool IncludeCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) + throw new ArgumentOutOfRangeException( + "includeCanonicalHeader", + "Missing required argument" + ); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Display name of the origin. + /// + public required string Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + throw new ArgumentOutOfRangeException("name", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("name"); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required string Prefix + { + get + { + if (!this.Properties.TryGetValue("prefix", out JsonElement element)) + throw new ArgumentOutOfRangeException("prefix", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("prefix"); + } + set + { + this.Properties["prefix"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// URL used in the Canonical header (if enabled). + /// + public string? BaseURLForCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.ID; + _ = this.Bucket; + _ = this.ClientEmail; + _ = this.IncludeCanonicalHeader; + _ = this.Name; + _ = this.Prefix; + _ = this.BaseURLForCanonicalHeader; + } + + public Gcs() + { + this.Type = JsonSerializer.Deserialize("\"GCS\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Gcs(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Gcs FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3.cs index b2046890..452a32e4 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3.cs @@ -1,191 +1,191 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Accounts.Origins.OriginResponseProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class S3 : ModelBase, IFromRaw -{ - /// - /// Unique identifier for the origin. This is generated by ImageKit when you create - /// a new origin. - /// - public required string ID - { - get - { - if (!this.Properties.TryGetValue("id", out JsonElement element)) - throw new ArgumentOutOfRangeException("id", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("id"); - } - set - { - this.Properties["id"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// S3 bucket name. - /// - public required string Bucket - { - get - { - if (!this.Properties.TryGetValue("bucket", out JsonElement element)) - throw new ArgumentOutOfRangeException("bucket", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("bucket"); - } - set - { - this.Properties["bucket"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to send a Canonical header. - /// - public required bool IncludeCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) - throw new ArgumentOutOfRangeException( - "includeCanonicalHeader", - "Missing required argument" - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Display name of the origin. - /// - public required string Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - throw new ArgumentOutOfRangeException("name", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("name"); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Path prefix inside the bucket. - /// - public required string Prefix - { - get - { - if (!this.Properties.TryGetValue("prefix", out JsonElement element)) - throw new ArgumentOutOfRangeException("prefix", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("prefix"); - } - set - { - this.Properties["prefix"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// URL used in the Canonical header (if enabled). - /// - public string? BaseURLForCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.ID; - _ = this.Bucket; - _ = this.IncludeCanonicalHeader; - _ = this.Name; - _ = this.Prefix; - _ = this.BaseURLForCanonicalHeader; - } - - public S3() - { - this.Type = JsonSerializer.Deserialize("\"S3\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - S3(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static S3 FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Accounts.Origins.OriginResponseProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class S3 : ModelBase, IFromRaw +{ + /// + /// Unique identifier for the origin. This is generated by ImageKit when you create + /// a new origin. + /// + public required string ID + { + get + { + if (!this.Properties.TryGetValue("id", out JsonElement element)) + throw new ArgumentOutOfRangeException("id", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("id"); + } + set + { + this.Properties["id"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// S3 bucket name. + /// + public required string Bucket + { + get + { + if (!this.Properties.TryGetValue("bucket", out JsonElement element)) + throw new ArgumentOutOfRangeException("bucket", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("bucket"); + } + set + { + this.Properties["bucket"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to send a Canonical header. + /// + public required bool IncludeCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) + throw new ArgumentOutOfRangeException( + "includeCanonicalHeader", + "Missing required argument" + ); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Display name of the origin. + /// + public required string Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + throw new ArgumentOutOfRangeException("name", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("name"); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Path prefix inside the bucket. + /// + public required string Prefix + { + get + { + if (!this.Properties.TryGetValue("prefix", out JsonElement element)) + throw new ArgumentOutOfRangeException("prefix", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("prefix"); + } + set + { + this.Properties["prefix"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// URL used in the Canonical header (if enabled). + /// + public string? BaseURLForCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.ID; + _ = this.Bucket; + _ = this.IncludeCanonicalHeader; + _ = this.Name; + _ = this.Prefix; + _ = this.BaseURLForCanonicalHeader; + } + + public S3() + { + this.Type = JsonSerializer.Deserialize("\"S3\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + S3(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static S3 FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3Compatible.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3Compatible.cs index 8d36f4a9..22da674c 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3Compatible.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3Compatible.cs @@ -1,239 +1,239 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Accounts.Origins.OriginResponseProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class S3Compatible : ModelBase, IFromRaw -{ - /// - /// Unique identifier for the origin. This is generated by ImageKit when you create - /// a new origin. - /// - public required string ID - { - get - { - if (!this.Properties.TryGetValue("id", out JsonElement element)) - throw new ArgumentOutOfRangeException("id", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("id"); - } - set - { - this.Properties["id"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// S3 bucket name. - /// - public required string Bucket - { - get - { - if (!this.Properties.TryGetValue("bucket", out JsonElement element)) - throw new ArgumentOutOfRangeException("bucket", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("bucket"); - } - set - { - this.Properties["bucket"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Custom S3-compatible endpoint. - /// - public required string Endpoint - { - get - { - if (!this.Properties.TryGetValue("endpoint", out JsonElement element)) - throw new ArgumentOutOfRangeException("endpoint", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("endpoint"); - } - set - { - this.Properties["endpoint"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to send a Canonical header. - /// - public required bool IncludeCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) - throw new ArgumentOutOfRangeException( - "includeCanonicalHeader", - "Missing required argument" - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Display name of the origin. - /// - public required string Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - throw new ArgumentOutOfRangeException("name", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("name"); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Path prefix inside the bucket. - /// - public required string Prefix - { - get - { - if (!this.Properties.TryGetValue("prefix", out JsonElement element)) - throw new ArgumentOutOfRangeException("prefix", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("prefix"); - } - set - { - this.Properties["prefix"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Use path-style S3 URLs? - /// - public required bool S3ForcePathStyle - { - get - { - if (!this.Properties.TryGetValue("s3ForcePathStyle", out JsonElement element)) - throw new ArgumentOutOfRangeException( - "s3ForcePathStyle", - "Missing required argument" - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["s3ForcePathStyle"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// URL used in the Canonical header (if enabled). - /// - public string? BaseURLForCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.ID; - _ = this.Bucket; - _ = this.Endpoint; - _ = this.IncludeCanonicalHeader; - _ = this.Name; - _ = this.Prefix; - _ = this.S3ForcePathStyle; - _ = this.BaseURLForCanonicalHeader; - } - - public S3Compatible() - { - this.Type = JsonSerializer.Deserialize("\"S3_COMPATIBLE\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - S3Compatible(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static S3Compatible FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Accounts.Origins.OriginResponseProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class S3Compatible : ModelBase, IFromRaw +{ + /// + /// Unique identifier for the origin. This is generated by ImageKit when you create + /// a new origin. + /// + public required string ID + { + get + { + if (!this.Properties.TryGetValue("id", out JsonElement element)) + throw new ArgumentOutOfRangeException("id", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("id"); + } + set + { + this.Properties["id"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// S3 bucket name. + /// + public required string Bucket + { + get + { + if (!this.Properties.TryGetValue("bucket", out JsonElement element)) + throw new ArgumentOutOfRangeException("bucket", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("bucket"); + } + set + { + this.Properties["bucket"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Custom S3-compatible endpoint. + /// + public required string Endpoint + { + get + { + if (!this.Properties.TryGetValue("endpoint", out JsonElement element)) + throw new ArgumentOutOfRangeException("endpoint", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("endpoint"); + } + set + { + this.Properties["endpoint"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to send a Canonical header. + /// + public required bool IncludeCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) + throw new ArgumentOutOfRangeException( + "includeCanonicalHeader", + "Missing required argument" + ); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Display name of the origin. + /// + public required string Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + throw new ArgumentOutOfRangeException("name", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("name"); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Path prefix inside the bucket. + /// + public required string Prefix + { + get + { + if (!this.Properties.TryGetValue("prefix", out JsonElement element)) + throw new ArgumentOutOfRangeException("prefix", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("prefix"); + } + set + { + this.Properties["prefix"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Use path-style S3 URLs? + /// + public required bool S3ForcePathStyle + { + get + { + if (!this.Properties.TryGetValue("s3ForcePathStyle", out JsonElement element)) + throw new ArgumentOutOfRangeException( + "s3ForcePathStyle", + "Missing required argument" + ); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["s3ForcePathStyle"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// URL used in the Canonical header (if enabled). + /// + public string? BaseURLForCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.ID; + _ = this.Bucket; + _ = this.Endpoint; + _ = this.IncludeCanonicalHeader; + _ = this.Name; + _ = this.Prefix; + _ = this.S3ForcePathStyle; + _ = this.BaseURLForCanonicalHeader; + } + + public S3Compatible() + { + this.Type = JsonSerializer.Deserialize("\"S3_COMPATIBLE\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + S3Compatible(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static S3Compatible FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebFolder.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebFolder.cs index 8313749f..a88b45e9 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebFolder.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebFolder.cs @@ -1,193 +1,193 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Accounts.Origins.OriginResponseProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class WebFolder : ModelBase, IFromRaw -{ - /// - /// Unique identifier for the origin. This is generated by ImageKit when you create - /// a new origin. - /// - public required string ID - { - get - { - if (!this.Properties.TryGetValue("id", out JsonElement element)) - throw new ArgumentOutOfRangeException("id", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("id"); - } - set - { - this.Properties["id"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Root URL for the web folder origin. - /// - public required string BaseURL - { - get - { - if (!this.Properties.TryGetValue("baseUrl", out JsonElement element)) - throw new ArgumentOutOfRangeException("baseUrl", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("baseUrl"); - } - set - { - this.Properties["baseUrl"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Forward the Host header to origin? - /// - public required bool ForwardHostHeaderToOrigin - { - get - { - if (!this.Properties.TryGetValue("forwardHostHeaderToOrigin", out JsonElement element)) - throw new ArgumentOutOfRangeException( - "forwardHostHeaderToOrigin", - "Missing required argument" - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["forwardHostHeaderToOrigin"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to send a Canonical header. - /// - public required bool IncludeCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) - throw new ArgumentOutOfRangeException( - "includeCanonicalHeader", - "Missing required argument" - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Display name of the origin. - /// - public required string Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - throw new ArgumentOutOfRangeException("name", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("name"); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// URL used in the Canonical header (if enabled). - /// - public string? BaseURLForCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.ID; - _ = this.BaseURL; - _ = this.ForwardHostHeaderToOrigin; - _ = this.IncludeCanonicalHeader; - _ = this.Name; - _ = this.BaseURLForCanonicalHeader; - } - - public WebFolder() - { - this.Type = JsonSerializer.Deserialize("\"WEB_FOLDER\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - WebFolder(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static WebFolder FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Accounts.Origins.OriginResponseProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class WebFolder : ModelBase, IFromRaw +{ + /// + /// Unique identifier for the origin. This is generated by ImageKit when you create + /// a new origin. + /// + public required string ID + { + get + { + if (!this.Properties.TryGetValue("id", out JsonElement element)) + throw new ArgumentOutOfRangeException("id", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("id"); + } + set + { + this.Properties["id"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Root URL for the web folder origin. + /// + public required string BaseURL + { + get + { + if (!this.Properties.TryGetValue("baseUrl", out JsonElement element)) + throw new ArgumentOutOfRangeException("baseUrl", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("baseUrl"); + } + set + { + this.Properties["baseUrl"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Forward the Host header to origin? + /// + public required bool ForwardHostHeaderToOrigin + { + get + { + if (!this.Properties.TryGetValue("forwardHostHeaderToOrigin", out JsonElement element)) + throw new ArgumentOutOfRangeException( + "forwardHostHeaderToOrigin", + "Missing required argument" + ); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["forwardHostHeaderToOrigin"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to send a Canonical header. + /// + public required bool IncludeCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) + throw new ArgumentOutOfRangeException( + "includeCanonicalHeader", + "Missing required argument" + ); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Display name of the origin. + /// + public required string Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + throw new ArgumentOutOfRangeException("name", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("name"); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// URL used in the Canonical header (if enabled). + /// + public string? BaseURLForCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.ID; + _ = this.BaseURL; + _ = this.ForwardHostHeaderToOrigin; + _ = this.IncludeCanonicalHeader; + _ = this.Name; + _ = this.BaseURLForCanonicalHeader; + } + + public WebFolder() + { + this.Type = JsonSerializer.Deserialize("\"WEB_FOLDER\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + WebFolder(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static WebFolder FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebProxy.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebProxy.cs index 150c5901..17fa6eaa 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebProxy.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebProxy.cs @@ -1,145 +1,145 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Accounts.Origins.OriginResponseProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class WebProxy : ModelBase, IFromRaw -{ - /// - /// Unique identifier for the origin. This is generated by ImageKit when you create - /// a new origin. - /// - public required string ID - { - get - { - if (!this.Properties.TryGetValue("id", out JsonElement element)) - throw new ArgumentOutOfRangeException("id", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("id"); - } - set - { - this.Properties["id"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to send a Canonical header. - /// - public required bool IncludeCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) - throw new ArgumentOutOfRangeException( - "includeCanonicalHeader", - "Missing required argument" - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Display name of the origin. - /// - public required string Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - throw new ArgumentOutOfRangeException("name", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("name"); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// URL used in the Canonical header (if enabled). - /// - public string? BaseURLForCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.ID; - _ = this.IncludeCanonicalHeader; - _ = this.Name; - _ = this.BaseURLForCanonicalHeader; - } - - public WebProxy() - { - this.Type = JsonSerializer.Deserialize("\"WEB_PROXY\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - WebProxy(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static WebProxy FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Accounts.Origins.OriginResponseProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class WebProxy : ModelBase, IFromRaw +{ + /// + /// Unique identifier for the origin. This is generated by ImageKit when you create + /// a new origin. + /// + public required string ID + { + get + { + if (!this.Properties.TryGetValue("id", out JsonElement element)) + throw new ArgumentOutOfRangeException("id", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("id"); + } + set + { + this.Properties["id"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to send a Canonical header. + /// + public required bool IncludeCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) + throw new ArgumentOutOfRangeException( + "includeCanonicalHeader", + "Missing required argument" + ); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Display name of the origin. + /// + public required string Name + { + get + { + if (!this.Properties.TryGetValue("name", out JsonElement element)) + throw new ArgumentOutOfRangeException("name", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("name"); + } + set + { + this.Properties["name"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// URL used in the Canonical header (if enabled). + /// + public string? BaseURLForCanonicalHeader + { + get + { + if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.ID; + _ = this.IncludeCanonicalHeader; + _ = this.Name; + _ = this.BaseURLForCanonicalHeader; + } + + public WebProxy() + { + this.Type = JsonSerializer.Deserialize("\"WEB_PROXY\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + WebProxy(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static WebProxy FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginUpdateParams.cs b/src/Imagekit/Models/Accounts/Origins/OriginUpdateParams.cs index e2b40c56..b7307994 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginUpdateParams.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginUpdateParams.cs @@ -1,69 +1,69 @@ -using System; -using System.Collections.Generic; -using System.Net.Http; -using System.Text; -using System.Text.Json; - -namespace Imagekit.Models.Accounts.Origins; - -/// -/// **Note:** This API is currently in beta. Updates the origin identified by `id` -/// and returns the updated origin object. -/// -public sealed record class OriginUpdateParams : ParamsBase -{ - public Dictionary BodyProperties { get; set; } = []; - - public required string ID; - - /// - /// Schema for origin request resources. - /// - public required OriginRequest Origin - { - get - { - if (!this.BodyProperties.TryGetValue("origin", out JsonElement element)) - throw new ArgumentOutOfRangeException("origin", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("origin"); - } - set - { - this.BodyProperties["origin"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override Uri Url(IImageKitClient client) - { - return new UriBuilder( - client.BaseUrl.ToString().TrimEnd('/') - + string.Format("/v1/accounts/origins/{0}", this.ID) - ) - { - Query = this.QueryString(client), - }.Uri; - } - - public StringContent BodyContent() - { - return new( - JsonSerializer.Serialize(this.BodyProperties), - Encoding.UTF8, - "application/json" - ); - } - - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Text; +using System.Text.Json; + +namespace Imagekit.Models.Accounts.Origins; + +/// +/// **Note:** This API is currently in beta. Updates the origin identified by `id` +/// and returns the updated origin object. +/// +public sealed record class OriginUpdateParams : ParamsBase +{ + public Dictionary BodyProperties { get; set; } = []; + + public required string ID; + + /// + /// Schema for origin request resources. + /// + public required OriginRequest Origin + { + get + { + if (!this.BodyProperties.TryGetValue("origin", out JsonElement element)) + throw new ArgumentOutOfRangeException("origin", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("origin"); + } + set + { + this.BodyProperties["origin"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override Uri Url(IImageKitClient client) + { + return new UriBuilder( + client.BaseUrl.ToString().TrimEnd('/') + + string.Format("/v1/accounts/origins/{0}", this.ID) + ) + { + Query = this.QueryString(client), + }.Uri; + } + + public StringContent BodyContent() + { + return new( + JsonSerializer.Serialize(this.BodyProperties), + Encoding.UTF8, + "application/json" + ); + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParams.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParams.cs index 246f09e9..6d3c58b5 100644 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParams.cs +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParams.cs @@ -1,131 +1,131 @@ -using System; -using System.Collections.Generic; -using System.Net.Http; -using System.Text; -using System.Text.Json; -using Imagekit.Models.Accounts.URLEndpoints.URLEndpointCreateParamsProperties; - -namespace Imagekit.Models.Accounts.URLEndpoints; - -/// -/// **Note:** This API is currently in beta. Creates a new URL‑endpoint and returns -/// the resulting object. -/// -public sealed record class URLEndpointCreateParams : ParamsBase -{ - public Dictionary BodyProperties { get; set; } = []; - - /// - /// Description of the URL endpoint. - /// - public required string Description - { - get - { - if (!this.BodyProperties.TryGetValue("description", out JsonElement element)) - throw new ArgumentOutOfRangeException("description", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("description"); - } - set - { - this.BodyProperties["description"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Ordered list of origin IDs to try when the file isn’t in the Media Library; - /// ImageKit checks them in the sequence provided. Origin must be created before - /// it can be used in a URL endpoint. - /// - public List? Origins - { - get - { - if (!this.BodyProperties.TryGetValue("origins", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["origins"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Path segment appended to your base URL to form the endpoint (letters, digits, - /// and hyphens only — or empty for the default endpoint). - /// - public string? URLPrefix - { - get - { - if (!this.BodyProperties.TryGetValue("urlPrefix", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["urlPrefix"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Configuration for third-party URL rewriting. - /// - public URLRewriter? URLRewriter - { - get - { - if (!this.BodyProperties.TryGetValue("urlRewriter", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["urlRewriter"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override Uri Url(IImageKitClient client) - { - return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/accounts/url-endpoints") - { - Query = this.QueryString(client), - }.Uri; - } - - public StringContent BodyContent() - { - return new( - JsonSerializer.Serialize(this.BodyProperties), - Encoding.UTF8, - "application/json" - ); - } - - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Text; +using System.Text.Json; +using Imagekit.Models.Accounts.URLEndpoints.URLEndpointCreateParamsProperties; + +namespace Imagekit.Models.Accounts.URLEndpoints; + +/// +/// **Note:** This API is currently in beta. Creates a new URL‑endpoint and returns +/// the resulting object. +/// +public sealed record class URLEndpointCreateParams : ParamsBase +{ + public Dictionary BodyProperties { get; set; } = []; + + /// + /// Description of the URL endpoint. + /// + public required string Description + { + get + { + if (!this.BodyProperties.TryGetValue("description", out JsonElement element)) + throw new ArgumentOutOfRangeException("description", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("description"); + } + set + { + this.BodyProperties["description"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Ordered list of origin IDs to try when the file isn’t in the Media Library; + /// ImageKit checks them in the sequence provided. Origin must be created before + /// it can be used in a URL endpoint. + /// + public List? Origins + { + get + { + if (!this.BodyProperties.TryGetValue("origins", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["origins"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Path segment appended to your base URL to form the endpoint (letters, digits, + /// and hyphens only — or empty for the default endpoint). + /// + public string? URLPrefix + { + get + { + if (!this.BodyProperties.TryGetValue("urlPrefix", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["urlPrefix"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Configuration for third-party URL rewriting. + /// + public URLRewriter? URLRewriter + { + get + { + if (!this.BodyProperties.TryGetValue("urlRewriter", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["urlRewriter"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override Uri Url(IImageKitClient client) + { + return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/accounts/url-endpoints") + { + Query = this.QueryString(client), + }.Uri; + } + + public StringContent BodyContent() + { + return new( + JsonSerializer.Serialize(this.BodyProperties), + Encoding.UTF8, + "application/json" + ); + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriter.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriter.cs index 5d26268a..566303bf 100644 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriter.cs +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriter.cs @@ -1,176 +1,176 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Accounts.URLEndpoints.URLEndpointCreateParamsProperties.URLRewriterProperties; -using URLRewriterVariants = Imagekit.Models.Accounts.URLEndpoints.URLEndpointCreateParamsProperties.URLRewriterVariants; - -namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointCreateParamsProperties; - -/// -/// Configuration for third-party URL rewriting. -/// -[JsonConverter(typeof(URLRewriterConverter))] -public abstract record class URLRewriter -{ - internal URLRewriter() { } - - public static implicit operator URLRewriter(Cloudinary value) => - new URLRewriterVariants::Cloudinary(value); - - public bool TryPickCloudinary([NotNullWhen(true)] out Cloudinary? value) - { - value = (this as URLRewriterVariants::Cloudinary)?.Value; - return value != null; - } - - public bool TryPickImgix([NotNullWhen(true)] out JsonElement? value) - { - value = (this as URLRewriterVariants::Imgix)?.Value; - return value != null; - } - - public bool TryPickAkamai([NotNullWhen(true)] out JsonElement? value) - { - value = (this as URLRewriterVariants::Akamai)?.Value; - return value != null; - } - - public void Switch( - Action cloudinary, - Action imgix, - Action akamai - ) - { - switch (this) - { - case URLRewriterVariants::Cloudinary inner: - cloudinary(inner); - break; - case URLRewriterVariants::Imgix inner: - imgix(inner); - break; - case URLRewriterVariants::Akamai inner: - akamai(inner); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match( - Func cloudinary, - Func imgix, - Func akamai - ) - { - return this switch - { - URLRewriterVariants::Cloudinary inner => cloudinary(inner), - URLRewriterVariants::Imgix inner => imgix(inner), - URLRewriterVariants::Akamai inner => akamai(inner), - _ => throw new InvalidOperationException(), - }; - } - - public abstract void Validate(); -} - -sealed class URLRewriterConverter : JsonConverter -{ - public override URLRewriter? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - var json = JsonSerializer.Deserialize(ref reader, options); - string? type; - try - { - type = json.GetProperty("type").GetString(); - } - catch - { - type = null; - } - - switch (type) - { - case "CLOUDINARY": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - return new URLRewriterVariants::Cloudinary(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "IMGIX": - { - List exceptions = []; - - try - { - return new URLRewriterVariants::Imgix( - JsonSerializer.Deserialize(json, options) - ); - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "AKAMAI": - { - List exceptions = []; - - try - { - return new URLRewriterVariants::Akamai( - JsonSerializer.Deserialize(json, options) - ); - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - default: - { - throw new Exception(); - } - } - } - - public override void Write( - Utf8JsonWriter writer, - URLRewriter value, - JsonSerializerOptions options - ) - { - object variant = value switch - { - URLRewriterVariants::Cloudinary(var cloudinary) => cloudinary, - URLRewriterVariants::Imgix(var imgix) => imgix, - URLRewriterVariants::Akamai(var akamai) => akamai, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Accounts.URLEndpoints.URLEndpointCreateParamsProperties.URLRewriterProperties; +using URLRewriterVariants = Imagekit.Models.Accounts.URLEndpoints.URLEndpointCreateParamsProperties.URLRewriterVariants; + +namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointCreateParamsProperties; + +/// +/// Configuration for third-party URL rewriting. +/// +[JsonConverter(typeof(URLRewriterConverter))] +public abstract record class URLRewriter +{ + internal URLRewriter() { } + + public static implicit operator URLRewriter(Cloudinary value) => + new URLRewriterVariants::Cloudinary(value); + + public bool TryPickCloudinary([NotNullWhen(true)] out Cloudinary? value) + { + value = (this as URLRewriterVariants::Cloudinary)?.Value; + return value != null; + } + + public bool TryPickImgix([NotNullWhen(true)] out JsonElement? value) + { + value = (this as URLRewriterVariants::Imgix)?.Value; + return value != null; + } + + public bool TryPickAkamai([NotNullWhen(true)] out JsonElement? value) + { + value = (this as URLRewriterVariants::Akamai)?.Value; + return value != null; + } + + public void Switch( + Action cloudinary, + Action imgix, + Action akamai + ) + { + switch (this) + { + case URLRewriterVariants::Cloudinary inner: + cloudinary(inner); + break; + case URLRewriterVariants::Imgix inner: + imgix(inner); + break; + case URLRewriterVariants::Akamai inner: + akamai(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func cloudinary, + Func imgix, + Func akamai + ) + { + return this switch + { + URLRewriterVariants::Cloudinary inner => cloudinary(inner), + URLRewriterVariants::Imgix inner => imgix(inner), + URLRewriterVariants::Akamai inner => akamai(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class URLRewriterConverter : JsonConverter +{ + public override URLRewriter? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var json = JsonSerializer.Deserialize(ref reader, options); + string? type; + try + { + type = json.GetProperty("type").GetString(); + } + catch + { + type = null; + } + + switch (type) + { + case "CLOUDINARY": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new URLRewriterVariants::Cloudinary(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "IMGIX": + { + List exceptions = []; + + try + { + return new URLRewriterVariants::Imgix( + JsonSerializer.Deserialize(json, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "AKAMAI": + { + List exceptions = []; + + try + { + return new URLRewriterVariants::Akamai( + JsonSerializer.Deserialize(json, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + default: + { + throw new Exception(); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + URLRewriter value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + URLRewriterVariants::Cloudinary(var cloudinary) => cloudinary, + URLRewriterVariants::Imgix(var imgix) => imgix, + URLRewriterVariants::Akamai(var akamai) => akamai, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/Cloudinary.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/Cloudinary.cs index e1342282..b3ff7019 100644 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/Cloudinary.cs +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/Cloudinary.cs @@ -1,73 +1,73 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointCreateParamsProperties.URLRewriterProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Cloudinary : ModelBase, IFromRaw -{ - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to preserve `/` in the rewritten URL. - /// - public bool? PreserveAssetDeliveryTypes - { - get - { - if (!this.Properties.TryGetValue("preserveAssetDeliveryTypes", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["preserveAssetDeliveryTypes"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.PreserveAssetDeliveryTypes; - } - - public Cloudinary() - { - this.Type = JsonSerializer.Deserialize("\"CLOUDINARY\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Cloudinary(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Cloudinary FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointCreateParamsProperties.URLRewriterProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Cloudinary : ModelBase, IFromRaw +{ + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to preserve `/` in the rewritten URL. + /// + public bool? PreserveAssetDeliveryTypes + { + get + { + if (!this.Properties.TryGetValue("preserveAssetDeliveryTypes", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["preserveAssetDeliveryTypes"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.PreserveAssetDeliveryTypes; + } + + public Cloudinary() + { + this.Type = JsonSerializer.Deserialize("\"CLOUDINARY\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Cloudinary(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Cloudinary FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequest.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequest.cs index 69d87d20..a98fbb1f 100644 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequest.cs +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequest.cs @@ -1,136 +1,136 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Accounts.URLEndpoints.URLEndpointRequestProperties; - -namespace Imagekit.Models.Accounts.URLEndpoints; - -/// -/// Schema for URL endpoint resource. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class URLEndpointRequest : ModelBase, IFromRaw -{ - /// - /// Description of the URL endpoint. - /// - public required string Description - { - get - { - if (!this.Properties.TryGetValue("description", out JsonElement element)) - throw new ArgumentOutOfRangeException("description", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("description"); - } - set - { - this.Properties["description"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Ordered list of origin IDs to try when the file isn’t in the Media Library; - /// ImageKit checks them in the sequence provided. Origin must be created before - /// it can be used in a URL endpoint. - /// - public List? Origins - { - get - { - if (!this.Properties.TryGetValue("origins", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["origins"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Path segment appended to your base URL to form the endpoint (letters, digits, - /// and hyphens only — or empty for the default endpoint). - /// - public string? URLPrefix - { - get - { - if (!this.Properties.TryGetValue("urlPrefix", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["urlPrefix"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Configuration for third-party URL rewriting. - /// - public URLRewriter? URLRewriter - { - get - { - if (!this.Properties.TryGetValue("urlRewriter", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["urlRewriter"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.Description; - foreach (var item in this.Origins ?? []) - { - _ = item; - } - _ = this.URLPrefix; - this.URLRewriter?.Validate(); - } - - public URLEndpointRequest() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - URLEndpointRequest(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static URLEndpointRequest FromRawUnchecked(Dictionary properties) - { - return new(properties); - } - - [SetsRequiredMembers] - public URLEndpointRequest(string description) - : this() - { - this.Description = description; - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Accounts.URLEndpoints.URLEndpointRequestProperties; + +namespace Imagekit.Models.Accounts.URLEndpoints; + +/// +/// Schema for URL endpoint resource. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class URLEndpointRequest : ModelBase, IFromRaw +{ + /// + /// Description of the URL endpoint. + /// + public required string Description + { + get + { + if (!this.Properties.TryGetValue("description", out JsonElement element)) + throw new ArgumentOutOfRangeException("description", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("description"); + } + set + { + this.Properties["description"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Ordered list of origin IDs to try when the file isn’t in the Media Library; + /// ImageKit checks them in the sequence provided. Origin must be created before + /// it can be used in a URL endpoint. + /// + public List? Origins + { + get + { + if (!this.Properties.TryGetValue("origins", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["origins"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Path segment appended to your base URL to form the endpoint (letters, digits, + /// and hyphens only — or empty for the default endpoint). + /// + public string? URLPrefix + { + get + { + if (!this.Properties.TryGetValue("urlPrefix", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["urlPrefix"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Configuration for third-party URL rewriting. + /// + public URLRewriter? URLRewriter + { + get + { + if (!this.Properties.TryGetValue("urlRewriter", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["urlRewriter"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.Description; + foreach (var item in this.Origins ?? []) + { + _ = item; + } + _ = this.URLPrefix; + this.URLRewriter?.Validate(); + } + + public URLEndpointRequest() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + URLEndpointRequest(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static URLEndpointRequest FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public URLEndpointRequest(string description) + : this() + { + this.Description = description; + } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriter.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriter.cs index 9ee41202..71eb3496 100644 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriter.cs +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriter.cs @@ -1,176 +1,176 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Accounts.URLEndpoints.URLEndpointRequestProperties.URLRewriterProperties; -using URLRewriterVariants = Imagekit.Models.Accounts.URLEndpoints.URLEndpointRequestProperties.URLRewriterVariants; - -namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointRequestProperties; - -/// -/// Configuration for third-party URL rewriting. -/// -[JsonConverter(typeof(URLRewriterConverter))] -public abstract record class URLRewriter -{ - internal URLRewriter() { } - - public static implicit operator URLRewriter(Cloudinary value) => - new URLRewriterVariants::Cloudinary(value); - - public bool TryPickCloudinary([NotNullWhen(true)] out Cloudinary? value) - { - value = (this as URLRewriterVariants::Cloudinary)?.Value; - return value != null; - } - - public bool TryPickImgix([NotNullWhen(true)] out JsonElement? value) - { - value = (this as URLRewriterVariants::Imgix)?.Value; - return value != null; - } - - public bool TryPickAkamai([NotNullWhen(true)] out JsonElement? value) - { - value = (this as URLRewriterVariants::Akamai)?.Value; - return value != null; - } - - public void Switch( - Action cloudinary, - Action imgix, - Action akamai - ) - { - switch (this) - { - case URLRewriterVariants::Cloudinary inner: - cloudinary(inner); - break; - case URLRewriterVariants::Imgix inner: - imgix(inner); - break; - case URLRewriterVariants::Akamai inner: - akamai(inner); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match( - Func cloudinary, - Func imgix, - Func akamai - ) - { - return this switch - { - URLRewriterVariants::Cloudinary inner => cloudinary(inner), - URLRewriterVariants::Imgix inner => imgix(inner), - URLRewriterVariants::Akamai inner => akamai(inner), - _ => throw new InvalidOperationException(), - }; - } - - public abstract void Validate(); -} - -sealed class URLRewriterConverter : JsonConverter -{ - public override URLRewriter? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - var json = JsonSerializer.Deserialize(ref reader, options); - string? type; - try - { - type = json.GetProperty("type").GetString(); - } - catch - { - type = null; - } - - switch (type) - { - case "CLOUDINARY": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - return new URLRewriterVariants::Cloudinary(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "IMGIX": - { - List exceptions = []; - - try - { - return new URLRewriterVariants::Imgix( - JsonSerializer.Deserialize(json, options) - ); - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "AKAMAI": - { - List exceptions = []; - - try - { - return new URLRewriterVariants::Akamai( - JsonSerializer.Deserialize(json, options) - ); - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - default: - { - throw new Exception(); - } - } - } - - public override void Write( - Utf8JsonWriter writer, - URLRewriter value, - JsonSerializerOptions options - ) - { - object variant = value switch - { - URLRewriterVariants::Cloudinary(var cloudinary) => cloudinary, - URLRewriterVariants::Imgix(var imgix) => imgix, - URLRewriterVariants::Akamai(var akamai) => akamai, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Accounts.URLEndpoints.URLEndpointRequestProperties.URLRewriterProperties; +using URLRewriterVariants = Imagekit.Models.Accounts.URLEndpoints.URLEndpointRequestProperties.URLRewriterVariants; + +namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointRequestProperties; + +/// +/// Configuration for third-party URL rewriting. +/// +[JsonConverter(typeof(URLRewriterConverter))] +public abstract record class URLRewriter +{ + internal URLRewriter() { } + + public static implicit operator URLRewriter(Cloudinary value) => + new URLRewriterVariants::Cloudinary(value); + + public bool TryPickCloudinary([NotNullWhen(true)] out Cloudinary? value) + { + value = (this as URLRewriterVariants::Cloudinary)?.Value; + return value != null; + } + + public bool TryPickImgix([NotNullWhen(true)] out JsonElement? value) + { + value = (this as URLRewriterVariants::Imgix)?.Value; + return value != null; + } + + public bool TryPickAkamai([NotNullWhen(true)] out JsonElement? value) + { + value = (this as URLRewriterVariants::Akamai)?.Value; + return value != null; + } + + public void Switch( + Action cloudinary, + Action imgix, + Action akamai + ) + { + switch (this) + { + case URLRewriterVariants::Cloudinary inner: + cloudinary(inner); + break; + case URLRewriterVariants::Imgix inner: + imgix(inner); + break; + case URLRewriterVariants::Akamai inner: + akamai(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func cloudinary, + Func imgix, + Func akamai + ) + { + return this switch + { + URLRewriterVariants::Cloudinary inner => cloudinary(inner), + URLRewriterVariants::Imgix inner => imgix(inner), + URLRewriterVariants::Akamai inner => akamai(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class URLRewriterConverter : JsonConverter +{ + public override URLRewriter? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var json = JsonSerializer.Deserialize(ref reader, options); + string? type; + try + { + type = json.GetProperty("type").GetString(); + } + catch + { + type = null; + } + + switch (type) + { + case "CLOUDINARY": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new URLRewriterVariants::Cloudinary(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "IMGIX": + { + List exceptions = []; + + try + { + return new URLRewriterVariants::Imgix( + JsonSerializer.Deserialize(json, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "AKAMAI": + { + List exceptions = []; + + try + { + return new URLRewriterVariants::Akamai( + JsonSerializer.Deserialize(json, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + default: + { + throw new Exception(); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + URLRewriter value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + URLRewriterVariants::Cloudinary(var cloudinary) => cloudinary, + URLRewriterVariants::Imgix(var imgix) => imgix, + URLRewriterVariants::Akamai(var akamai) => akamai, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/Cloudinary.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/Cloudinary.cs index 67997088..e411df9a 100644 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/Cloudinary.cs +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/Cloudinary.cs @@ -1,73 +1,73 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointRequestProperties.URLRewriterProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Cloudinary : ModelBase, IFromRaw -{ - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to preserve `/` in the rewritten URL. - /// - public bool? PreserveAssetDeliveryTypes - { - get - { - if (!this.Properties.TryGetValue("preserveAssetDeliveryTypes", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["preserveAssetDeliveryTypes"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.PreserveAssetDeliveryTypes; - } - - public Cloudinary() - { - this.Type = JsonSerializer.Deserialize("\"CLOUDINARY\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Cloudinary(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Cloudinary FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointRequestProperties.URLRewriterProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Cloudinary : ModelBase, IFromRaw +{ + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to preserve `/` in the rewritten URL. + /// + public bool? PreserveAssetDeliveryTypes + { + get + { + if (!this.Properties.TryGetValue("preserveAssetDeliveryTypes", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["preserveAssetDeliveryTypes"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.PreserveAssetDeliveryTypes; + } + + public Cloudinary() + { + this.Type = JsonSerializer.Deserialize("\"CLOUDINARY\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Cloudinary(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Cloudinary FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponse.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponse.cs index 478785dc..e99f3904 100644 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponse.cs +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponse.cs @@ -1,155 +1,155 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Accounts.URLEndpoints.URLEndpointResponseProperties; - -namespace Imagekit.Models.Accounts.URLEndpoints; - -/// -/// URL‑endpoint object as returned by the API. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class URLEndpointResponse : ModelBase, IFromRaw -{ - /// - /// Unique identifier for the URL-endpoint. This is generated by ImageKit when - /// you create a new URL-endpoint. For the default URL-endpoint, this is always `default`. - /// - public required string ID - { - get - { - if (!this.Properties.TryGetValue("id", out JsonElement element)) - throw new ArgumentOutOfRangeException("id", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("id"); - } - set - { - this.Properties["id"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Description of the URL endpoint. - /// - public required string Description - { - get - { - if (!this.Properties.TryGetValue("description", out JsonElement element)) - throw new ArgumentOutOfRangeException("description", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("description"); - } - set - { - this.Properties["description"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Ordered list of origin IDs to try when the file isn’t in the Media Library; - /// ImageKit checks them in the sequence provided. Origin must be created before - /// it can be used in a URL endpoint. - /// - public required List Origins - { - get - { - if (!this.Properties.TryGetValue("origins", out JsonElement element)) - throw new ArgumentOutOfRangeException("origins", "Missing required argument"); - - return JsonSerializer.Deserialize>(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("origins"); - } - set - { - this.Properties["origins"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Path segment appended to your base URL to form the endpoint (letters, digits, - /// and hyphens only — or empty for the default endpoint). - /// - public required string URLPrefix - { - get - { - if (!this.Properties.TryGetValue("urlPrefix", out JsonElement element)) - throw new ArgumentOutOfRangeException("urlPrefix", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("urlPrefix"); - } - set - { - this.Properties["urlPrefix"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Configuration for third-party URL rewriting. - /// - public URLRewriter? URLRewriter - { - get - { - if (!this.Properties.TryGetValue("urlRewriter", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["urlRewriter"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.ID; - _ = this.Description; - foreach (var item in this.Origins) - { - _ = item; - } - _ = this.URLPrefix; - this.URLRewriter?.Validate(); - } - - public URLEndpointResponse() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - URLEndpointResponse(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static URLEndpointResponse FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Accounts.URLEndpoints.URLEndpointResponseProperties; + +namespace Imagekit.Models.Accounts.URLEndpoints; + +/// +/// URL‑endpoint object as returned by the API. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class URLEndpointResponse : ModelBase, IFromRaw +{ + /// + /// Unique identifier for the URL-endpoint. This is generated by ImageKit when + /// you create a new URL-endpoint. For the default URL-endpoint, this is always `default`. + /// + public required string ID + { + get + { + if (!this.Properties.TryGetValue("id", out JsonElement element)) + throw new ArgumentOutOfRangeException("id", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("id"); + } + set + { + this.Properties["id"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Description of the URL endpoint. + /// + public required string Description + { + get + { + if (!this.Properties.TryGetValue("description", out JsonElement element)) + throw new ArgumentOutOfRangeException("description", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("description"); + } + set + { + this.Properties["description"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Ordered list of origin IDs to try when the file isn’t in the Media Library; + /// ImageKit checks them in the sequence provided. Origin must be created before + /// it can be used in a URL endpoint. + /// + public required List Origins + { + get + { + if (!this.Properties.TryGetValue("origins", out JsonElement element)) + throw new ArgumentOutOfRangeException("origins", "Missing required argument"); + + return JsonSerializer.Deserialize>(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("origins"); + } + set + { + this.Properties["origins"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Path segment appended to your base URL to form the endpoint (letters, digits, + /// and hyphens only — or empty for the default endpoint). + /// + public required string URLPrefix + { + get + { + if (!this.Properties.TryGetValue("urlPrefix", out JsonElement element)) + throw new ArgumentOutOfRangeException("urlPrefix", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("urlPrefix"); + } + set + { + this.Properties["urlPrefix"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Configuration for third-party URL rewriting. + /// + public URLRewriter? URLRewriter + { + get + { + if (!this.Properties.TryGetValue("urlRewriter", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["urlRewriter"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.ID; + _ = this.Description; + foreach (var item in this.Origins) + { + _ = item; + } + _ = this.URLPrefix; + this.URLRewriter?.Validate(); + } + + public URLEndpointResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + URLEndpointResponse(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static URLEndpointResponse FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriter.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriter.cs index 26256e1c..8c65e9f6 100644 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriter.cs +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriter.cs @@ -1,176 +1,176 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Accounts.URLEndpoints.URLEndpointResponseProperties.URLRewriterProperties; -using URLRewriterVariants = Imagekit.Models.Accounts.URLEndpoints.URLEndpointResponseProperties.URLRewriterVariants; - -namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointResponseProperties; - -/// -/// Configuration for third-party URL rewriting. -/// -[JsonConverter(typeof(URLRewriterConverter))] -public abstract record class URLRewriter -{ - internal URLRewriter() { } - - public static implicit operator URLRewriter(Cloudinary value) => - new URLRewriterVariants::Cloudinary(value); - - public bool TryPickCloudinary([NotNullWhen(true)] out Cloudinary? value) - { - value = (this as URLRewriterVariants::Cloudinary)?.Value; - return value != null; - } - - public bool TryPickImgix([NotNullWhen(true)] out JsonElement? value) - { - value = (this as URLRewriterVariants::Imgix)?.Value; - return value != null; - } - - public bool TryPickAkamai([NotNullWhen(true)] out JsonElement? value) - { - value = (this as URLRewriterVariants::Akamai)?.Value; - return value != null; - } - - public void Switch( - Action cloudinary, - Action imgix, - Action akamai - ) - { - switch (this) - { - case URLRewriterVariants::Cloudinary inner: - cloudinary(inner); - break; - case URLRewriterVariants::Imgix inner: - imgix(inner); - break; - case URLRewriterVariants::Akamai inner: - akamai(inner); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match( - Func cloudinary, - Func imgix, - Func akamai - ) - { - return this switch - { - URLRewriterVariants::Cloudinary inner => cloudinary(inner), - URLRewriterVariants::Imgix inner => imgix(inner), - URLRewriterVariants::Akamai inner => akamai(inner), - _ => throw new InvalidOperationException(), - }; - } - - public abstract void Validate(); -} - -sealed class URLRewriterConverter : JsonConverter -{ - public override URLRewriter? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - var json = JsonSerializer.Deserialize(ref reader, options); - string? type; - try - { - type = json.GetProperty("type").GetString(); - } - catch - { - type = null; - } - - switch (type) - { - case "CLOUDINARY": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - return new URLRewriterVariants::Cloudinary(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "IMGIX": - { - List exceptions = []; - - try - { - return new URLRewriterVariants::Imgix( - JsonSerializer.Deserialize(json, options) - ); - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "AKAMAI": - { - List exceptions = []; - - try - { - return new URLRewriterVariants::Akamai( - JsonSerializer.Deserialize(json, options) - ); - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - default: - { - throw new Exception(); - } - } - } - - public override void Write( - Utf8JsonWriter writer, - URLRewriter value, - JsonSerializerOptions options - ) - { - object variant = value switch - { - URLRewriterVariants::Cloudinary(var cloudinary) => cloudinary, - URLRewriterVariants::Imgix(var imgix) => imgix, - URLRewriterVariants::Akamai(var akamai) => akamai, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Accounts.URLEndpoints.URLEndpointResponseProperties.URLRewriterProperties; +using URLRewriterVariants = Imagekit.Models.Accounts.URLEndpoints.URLEndpointResponseProperties.URLRewriterVariants; + +namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointResponseProperties; + +/// +/// Configuration for third-party URL rewriting. +/// +[JsonConverter(typeof(URLRewriterConverter))] +public abstract record class URLRewriter +{ + internal URLRewriter() { } + + public static implicit operator URLRewriter(Cloudinary value) => + new URLRewriterVariants::Cloudinary(value); + + public bool TryPickCloudinary([NotNullWhen(true)] out Cloudinary? value) + { + value = (this as URLRewriterVariants::Cloudinary)?.Value; + return value != null; + } + + public bool TryPickImgix([NotNullWhen(true)] out JsonElement? value) + { + value = (this as URLRewriterVariants::Imgix)?.Value; + return value != null; + } + + public bool TryPickAkamai([NotNullWhen(true)] out JsonElement? value) + { + value = (this as URLRewriterVariants::Akamai)?.Value; + return value != null; + } + + public void Switch( + Action cloudinary, + Action imgix, + Action akamai + ) + { + switch (this) + { + case URLRewriterVariants::Cloudinary inner: + cloudinary(inner); + break; + case URLRewriterVariants::Imgix inner: + imgix(inner); + break; + case URLRewriterVariants::Akamai inner: + akamai(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func cloudinary, + Func imgix, + Func akamai + ) + { + return this switch + { + URLRewriterVariants::Cloudinary inner => cloudinary(inner), + URLRewriterVariants::Imgix inner => imgix(inner), + URLRewriterVariants::Akamai inner => akamai(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class URLRewriterConverter : JsonConverter +{ + public override URLRewriter? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var json = JsonSerializer.Deserialize(ref reader, options); + string? type; + try + { + type = json.GetProperty("type").GetString(); + } + catch + { + type = null; + } + + switch (type) + { + case "CLOUDINARY": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new URLRewriterVariants::Cloudinary(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "IMGIX": + { + List exceptions = []; + + try + { + return new URLRewriterVariants::Imgix( + JsonSerializer.Deserialize(json, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "AKAMAI": + { + List exceptions = []; + + try + { + return new URLRewriterVariants::Akamai( + JsonSerializer.Deserialize(json, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + default: + { + throw new Exception(); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + URLRewriter value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + URLRewriterVariants::Cloudinary(var cloudinary) => cloudinary, + URLRewriterVariants::Imgix(var imgix) => imgix, + URLRewriterVariants::Akamai(var akamai) => akamai, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/Cloudinary.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/Cloudinary.cs index e2ebff1d..0629bebe 100644 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/Cloudinary.cs +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/Cloudinary.cs @@ -1,83 +1,83 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointResponseProperties.URLRewriterProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Cloudinary : ModelBase, IFromRaw -{ - /// - /// Whether to preserve `/` in the rewritten URL. - /// - public required bool PreserveAssetDeliveryTypes - { - get - { - if (!this.Properties.TryGetValue("preserveAssetDeliveryTypes", out JsonElement element)) - throw new ArgumentOutOfRangeException( - "preserveAssetDeliveryTypes", - "Missing required argument" - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["preserveAssetDeliveryTypes"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.PreserveAssetDeliveryTypes; - } - - public Cloudinary() - { - this.Type = JsonSerializer.Deserialize("\"CLOUDINARY\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Cloudinary(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Cloudinary FromRawUnchecked(Dictionary properties) - { - return new(properties); - } - - [SetsRequiredMembers] - public Cloudinary(bool preserveAssetDeliveryTypes) - : this() - { - this.PreserveAssetDeliveryTypes = preserveAssetDeliveryTypes; - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointResponseProperties.URLRewriterProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Cloudinary : ModelBase, IFromRaw +{ + /// + /// Whether to preserve `/` in the rewritten URL. + /// + public required bool PreserveAssetDeliveryTypes + { + get + { + if (!this.Properties.TryGetValue("preserveAssetDeliveryTypes", out JsonElement element)) + throw new ArgumentOutOfRangeException( + "preserveAssetDeliveryTypes", + "Missing required argument" + ); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["preserveAssetDeliveryTypes"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.PreserveAssetDeliveryTypes; + } + + public Cloudinary() + { + this.Type = JsonSerializer.Deserialize("\"CLOUDINARY\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Cloudinary(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Cloudinary FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public Cloudinary(bool preserveAssetDeliveryTypes) + : this() + { + this.PreserveAssetDeliveryTypes = preserveAssetDeliveryTypes; + } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParams.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParams.cs index 8a2aac55..d19bc332 100644 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParams.cs +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParams.cs @@ -1,136 +1,136 @@ -using System; -using System.Collections.Generic; -using System.Net.Http; -using System.Text; -using System.Text.Json; -using Imagekit.Models.Accounts.URLEndpoints.URLEndpointUpdateParamsProperties; - -namespace Imagekit.Models.Accounts.URLEndpoints; - -/// -/// **Note:** This API is currently in beta. Updates the URL‑endpoint identified -/// by `id` and returns the updated object. -/// -public sealed record class URLEndpointUpdateParams : ParamsBase -{ - public Dictionary BodyProperties { get; set; } = []; - - public required string ID; - - /// - /// Description of the URL endpoint. - /// - public required string Description - { - get - { - if (!this.BodyProperties.TryGetValue("description", out JsonElement element)) - throw new ArgumentOutOfRangeException("description", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("description"); - } - set - { - this.BodyProperties["description"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Ordered list of origin IDs to try when the file isn’t in the Media Library; - /// ImageKit checks them in the sequence provided. Origin must be created before - /// it can be used in a URL endpoint. - /// - public List? Origins - { - get - { - if (!this.BodyProperties.TryGetValue("origins", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["origins"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Path segment appended to your base URL to form the endpoint (letters, digits, - /// and hyphens only — or empty for the default endpoint). - /// - public string? URLPrefix - { - get - { - if (!this.BodyProperties.TryGetValue("urlPrefix", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["urlPrefix"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Configuration for third-party URL rewriting. - /// - public URLRewriter? URLRewriter - { - get - { - if (!this.BodyProperties.TryGetValue("urlRewriter", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["urlRewriter"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override Uri Url(IImageKitClient client) - { - return new UriBuilder( - client.BaseUrl.ToString().TrimEnd('/') - + string.Format("/v1/accounts/url-endpoints/{0}", this.ID) - ) - { - Query = this.QueryString(client), - }.Uri; - } - - public StringContent BodyContent() - { - return new( - JsonSerializer.Serialize(this.BodyProperties), - Encoding.UTF8, - "application/json" - ); - } - - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Text; +using System.Text.Json; +using Imagekit.Models.Accounts.URLEndpoints.URLEndpointUpdateParamsProperties; + +namespace Imagekit.Models.Accounts.URLEndpoints; + +/// +/// **Note:** This API is currently in beta. Updates the URL‑endpoint identified +/// by `id` and returns the updated object. +/// +public sealed record class URLEndpointUpdateParams : ParamsBase +{ + public Dictionary BodyProperties { get; set; } = []; + + public required string ID; + + /// + /// Description of the URL endpoint. + /// + public required string Description + { + get + { + if (!this.BodyProperties.TryGetValue("description", out JsonElement element)) + throw new ArgumentOutOfRangeException("description", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("description"); + } + set + { + this.BodyProperties["description"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Ordered list of origin IDs to try when the file isn’t in the Media Library; + /// ImageKit checks them in the sequence provided. Origin must be created before + /// it can be used in a URL endpoint. + /// + public List? Origins + { + get + { + if (!this.BodyProperties.TryGetValue("origins", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["origins"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Path segment appended to your base URL to form the endpoint (letters, digits, + /// and hyphens only — or empty for the default endpoint). + /// + public string? URLPrefix + { + get + { + if (!this.BodyProperties.TryGetValue("urlPrefix", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["urlPrefix"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Configuration for third-party URL rewriting. + /// + public URLRewriter? URLRewriter + { + get + { + if (!this.BodyProperties.TryGetValue("urlRewriter", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["urlRewriter"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override Uri Url(IImageKitClient client) + { + return new UriBuilder( + client.BaseUrl.ToString().TrimEnd('/') + + string.Format("/v1/accounts/url-endpoints/{0}", this.ID) + ) + { + Query = this.QueryString(client), + }.Uri; + } + + public StringContent BodyContent() + { + return new( + JsonSerializer.Serialize(this.BodyProperties), + Encoding.UTF8, + "application/json" + ); + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriter.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriter.cs index a33a02b3..46a017ae 100644 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriter.cs +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriter.cs @@ -1,176 +1,176 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Accounts.URLEndpoints.URLEndpointUpdateParamsProperties.URLRewriterProperties; -using URLRewriterVariants = Imagekit.Models.Accounts.URLEndpoints.URLEndpointUpdateParamsProperties.URLRewriterVariants; - -namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointUpdateParamsProperties; - -/// -/// Configuration for third-party URL rewriting. -/// -[JsonConverter(typeof(URLRewriterConverter))] -public abstract record class URLRewriter -{ - internal URLRewriter() { } - - public static implicit operator URLRewriter(Cloudinary value) => - new URLRewriterVariants::Cloudinary(value); - - public bool TryPickCloudinary([NotNullWhen(true)] out Cloudinary? value) - { - value = (this as URLRewriterVariants::Cloudinary)?.Value; - return value != null; - } - - public bool TryPickImgix([NotNullWhen(true)] out JsonElement? value) - { - value = (this as URLRewriterVariants::Imgix)?.Value; - return value != null; - } - - public bool TryPickAkamai([NotNullWhen(true)] out JsonElement? value) - { - value = (this as URLRewriterVariants::Akamai)?.Value; - return value != null; - } - - public void Switch( - Action cloudinary, - Action imgix, - Action akamai - ) - { - switch (this) - { - case URLRewriterVariants::Cloudinary inner: - cloudinary(inner); - break; - case URLRewriterVariants::Imgix inner: - imgix(inner); - break; - case URLRewriterVariants::Akamai inner: - akamai(inner); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match( - Func cloudinary, - Func imgix, - Func akamai - ) - { - return this switch - { - URLRewriterVariants::Cloudinary inner => cloudinary(inner), - URLRewriterVariants::Imgix inner => imgix(inner), - URLRewriterVariants::Akamai inner => akamai(inner), - _ => throw new InvalidOperationException(), - }; - } - - public abstract void Validate(); -} - -sealed class URLRewriterConverter : JsonConverter -{ - public override URLRewriter? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - var json = JsonSerializer.Deserialize(ref reader, options); - string? type; - try - { - type = json.GetProperty("type").GetString(); - } - catch - { - type = null; - } - - switch (type) - { - case "CLOUDINARY": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - return new URLRewriterVariants::Cloudinary(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "IMGIX": - { - List exceptions = []; - - try - { - return new URLRewriterVariants::Imgix( - JsonSerializer.Deserialize(json, options) - ); - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "AKAMAI": - { - List exceptions = []; - - try - { - return new URLRewriterVariants::Akamai( - JsonSerializer.Deserialize(json, options) - ); - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - default: - { - throw new Exception(); - } - } - } - - public override void Write( - Utf8JsonWriter writer, - URLRewriter value, - JsonSerializerOptions options - ) - { - object variant = value switch - { - URLRewriterVariants::Cloudinary(var cloudinary) => cloudinary, - URLRewriterVariants::Imgix(var imgix) => imgix, - URLRewriterVariants::Akamai(var akamai) => akamai, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Accounts.URLEndpoints.URLEndpointUpdateParamsProperties.URLRewriterProperties; +using URLRewriterVariants = Imagekit.Models.Accounts.URLEndpoints.URLEndpointUpdateParamsProperties.URLRewriterVariants; + +namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointUpdateParamsProperties; + +/// +/// Configuration for third-party URL rewriting. +/// +[JsonConverter(typeof(URLRewriterConverter))] +public abstract record class URLRewriter +{ + internal URLRewriter() { } + + public static implicit operator URLRewriter(Cloudinary value) => + new URLRewriterVariants::Cloudinary(value); + + public bool TryPickCloudinary([NotNullWhen(true)] out Cloudinary? value) + { + value = (this as URLRewriterVariants::Cloudinary)?.Value; + return value != null; + } + + public bool TryPickImgix([NotNullWhen(true)] out JsonElement? value) + { + value = (this as URLRewriterVariants::Imgix)?.Value; + return value != null; + } + + public bool TryPickAkamai([NotNullWhen(true)] out JsonElement? value) + { + value = (this as URLRewriterVariants::Akamai)?.Value; + return value != null; + } + + public void Switch( + Action cloudinary, + Action imgix, + Action akamai + ) + { + switch (this) + { + case URLRewriterVariants::Cloudinary inner: + cloudinary(inner); + break; + case URLRewriterVariants::Imgix inner: + imgix(inner); + break; + case URLRewriterVariants::Akamai inner: + akamai(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func cloudinary, + Func imgix, + Func akamai + ) + { + return this switch + { + URLRewriterVariants::Cloudinary inner => cloudinary(inner), + URLRewriterVariants::Imgix inner => imgix(inner), + URLRewriterVariants::Akamai inner => akamai(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class URLRewriterConverter : JsonConverter +{ + public override URLRewriter? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var json = JsonSerializer.Deserialize(ref reader, options); + string? type; + try + { + type = json.GetProperty("type").GetString(); + } + catch + { + type = null; + } + + switch (type) + { + case "CLOUDINARY": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new URLRewriterVariants::Cloudinary(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "IMGIX": + { + List exceptions = []; + + try + { + return new URLRewriterVariants::Imgix( + JsonSerializer.Deserialize(json, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "AKAMAI": + { + List exceptions = []; + + try + { + return new URLRewriterVariants::Akamai( + JsonSerializer.Deserialize(json, options) + ); + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + default: + { + throw new Exception(); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + URLRewriter value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + URLRewriterVariants::Cloudinary(var cloudinary) => cloudinary, + URLRewriterVariants::Imgix(var imgix) => imgix, + URLRewriterVariants::Akamai(var akamai) => akamai, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/Cloudinary.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/Cloudinary.cs index 169c202f..52353ebb 100644 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/Cloudinary.cs +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/Cloudinary.cs @@ -1,73 +1,73 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointUpdateParamsProperties.URLRewriterProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Cloudinary : ModelBase, IFromRaw -{ - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to preserve `/` in the rewritten URL. - /// - public bool? PreserveAssetDeliveryTypes - { - get - { - if (!this.Properties.TryGetValue("preserveAssetDeliveryTypes", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["preserveAssetDeliveryTypes"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.PreserveAssetDeliveryTypes; - } - - public Cloudinary() - { - this.Type = JsonSerializer.Deserialize("\"CLOUDINARY\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Cloudinary(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Cloudinary FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointUpdateParamsProperties.URLRewriterProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Cloudinary : ModelBase, IFromRaw +{ + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to preserve `/` in the rewritten URL. + /// + public bool? PreserveAssetDeliveryTypes + { + get + { + if (!this.Properties.TryGetValue("preserveAssetDeliveryTypes", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["preserveAssetDeliveryTypes"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.PreserveAssetDeliveryTypes; + } + + public Cloudinary() + { + this.Type = JsonSerializer.Deserialize("\"CLOUDINARY\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Cloudinary(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Cloudinary FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Accounts/Usage/UsageGetParams.cs b/src/Imagekit/Models/Accounts/Usage/UsageGetParams.cs index fe843155..6920035b 100644 --- a/src/Imagekit/Models/Accounts/Usage/UsageGetParams.cs +++ b/src/Imagekit/Models/Accounts/Usage/UsageGetParams.cs @@ -1,75 +1,75 @@ -using System; -using System.Net.Http; -using System.Text.Json; - -namespace Imagekit.Models.Accounts.Usage; - -/// -/// Get the account usage information between two dates. Note that the API response -/// includes data from the start date while excluding data from the end date. In -/// other words, the data covers the period starting from the specified start date -/// up to, but not including, the end date. -/// -public sealed record class UsageGetParams : ParamsBase -{ - /// - /// Specify a `endDate` in `YYYY-MM-DD` format. It should be after the `startDate`. - /// The difference between `startDate` and `endDate` should be less than 90 days. - /// - public required DateOnly EndDate - { - get - { - if (!this.QueryProperties.TryGetValue("endDate", out JsonElement element)) - throw new ArgumentOutOfRangeException("endDate", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.QueryProperties["endDate"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specify a `startDate` in `YYYY-MM-DD` format. It should be before the `endDate`. - /// The difference between `startDate` and `endDate` should be less than 90 days. - /// - public required DateOnly StartDate - { - get - { - if (!this.QueryProperties.TryGetValue("startDate", out JsonElement element)) - throw new ArgumentOutOfRangeException("startDate", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.QueryProperties["startDate"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override Uri Url(IImageKitClient client) - { - return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/accounts/usage") - { - Query = this.QueryString(client), - }.Uri; - } - - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} +using System; +using System.Net.Http; +using System.Text.Json; + +namespace Imagekit.Models.Accounts.Usage; + +/// +/// Get the account usage information between two dates. Note that the API response +/// includes data from the start date while excluding data from the end date. In +/// other words, the data covers the period starting from the specified start date +/// up to, but not including, the end date. +/// +public sealed record class UsageGetParams : ParamsBase +{ + /// + /// Specify a `endDate` in `YYYY-MM-DD` format. It should be after the `startDate`. + /// The difference between `startDate` and `endDate` should be less than 90 days. + /// + public required DateOnly EndDate + { + get + { + if (!this.QueryProperties.TryGetValue("endDate", out JsonElement element)) + throw new ArgumentOutOfRangeException("endDate", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.QueryProperties["endDate"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Specify a `startDate` in `YYYY-MM-DD` format. It should be before the `endDate`. + /// The difference between `startDate` and `endDate` should be less than 90 days. + /// + public required DateOnly StartDate + { + get + { + if (!this.QueryProperties.TryGetValue("startDate", out JsonElement element)) + throw new ArgumentOutOfRangeException("startDate", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.QueryProperties["startDate"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override Uri Url(IImageKitClient client) + { + return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/accounts/usage") + { + Query = this.QueryString(client), + }.Uri; + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/Assets/AssetListResponse.cs b/src/Imagekit/Models/Assets/AssetListResponse.cs index 4fb2cf1b..0bc73723 100644 --- a/src/Imagekit/Models/Assets/AssetListResponse.cs +++ b/src/Imagekit/Models/Assets/AssetListResponse.cs @@ -1,147 +1,147 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Files; -using AssetListResponseVariants = Imagekit.Models.Assets.AssetListResponseVariants; - -namespace Imagekit.Models.Assets; - -/// -/// Object containing details of a file or file version. -/// -[JsonConverter(typeof(AssetListResponseConverter))] -public abstract record class AssetListResponse -{ - internal AssetListResponse() { } - - public static implicit operator AssetListResponse(File value) => - new AssetListResponseVariants::File(value); - - public static implicit operator AssetListResponse(Folder value) => - new AssetListResponseVariants::Folder(value); - - public bool TryPickFile([NotNullWhen(true)] out File? value) - { - value = (this as AssetListResponseVariants::File)?.Value; - return value != null; - } - - public bool TryPickFolder([NotNullWhen(true)] out Folder? value) - { - value = (this as AssetListResponseVariants::Folder)?.Value; - return value != null; - } - - public void Switch( - Action file, - Action folder - ) - { - switch (this) - { - case AssetListResponseVariants::File inner: - file(inner); - break; - case AssetListResponseVariants::Folder inner: - folder(inner); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match( - Func file, - Func folder - ) - { - return this switch - { - AssetListResponseVariants::File inner => file(inner), - AssetListResponseVariants::Folder inner => folder(inner), - _ => throw new InvalidOperationException(), - }; - } - - public abstract void Validate(); -} - -sealed class AssetListResponseConverter : JsonConverter -{ - public override AssetListResponse? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - var json = JsonSerializer.Deserialize(ref reader, options); - string? type; - try - { - type = json.GetProperty("type").GetString(); - } - catch - { - type = null; - } - - switch (type) - { - case "folder": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - return new AssetListResponseVariants::Folder(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - default: - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - return new AssetListResponseVariants::File(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - } - } - - public override void Write( - Utf8JsonWriter writer, - AssetListResponse value, - JsonSerializerOptions options - ) - { - object variant = value switch - { - AssetListResponseVariants::File(var file) => file, - AssetListResponseVariants::Folder(var folder) => folder, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files; +using AssetListResponseVariants = Imagekit.Models.Assets.AssetListResponseVariants; + +namespace Imagekit.Models.Assets; + +/// +/// Object containing details of a file or file version. +/// +[JsonConverter(typeof(AssetListResponseConverter))] +public abstract record class AssetListResponse +{ + internal AssetListResponse() { } + + public static implicit operator AssetListResponse(File value) => + new AssetListResponseVariants::File(value); + + public static implicit operator AssetListResponse(Folder value) => + new AssetListResponseVariants::Folder(value); + + public bool TryPickFile([NotNullWhen(true)] out File? value) + { + value = (this as AssetListResponseVariants::File)?.Value; + return value != null; + } + + public bool TryPickFolder([NotNullWhen(true)] out Folder? value) + { + value = (this as AssetListResponseVariants::Folder)?.Value; + return value != null; + } + + public void Switch( + Action file, + Action folder + ) + { + switch (this) + { + case AssetListResponseVariants::File inner: + file(inner); + break; + case AssetListResponseVariants::Folder inner: + folder(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func file, + Func folder + ) + { + return this switch + { + AssetListResponseVariants::File inner => file(inner), + AssetListResponseVariants::Folder inner => folder(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class AssetListResponseConverter : JsonConverter +{ + public override AssetListResponse? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var json = JsonSerializer.Deserialize(ref reader, options); + string? type; + try + { + type = json.GetProperty("type").GetString(); + } + catch + { + type = null; + } + + switch (type) + { + case "folder": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new AssetListResponseVariants::Folder(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + default: + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + return new AssetListResponseVariants::File(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + AssetListResponse value, + JsonSerializerOptions options + ) + { + object variant = value switch + { + AssetListResponseVariants::File(var file) => file, + AssetListResponseVariants::Folder(var folder) => folder, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParams.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParams.cs index 217968e5..4385ef03 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParams.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParams.cs @@ -3,6 +3,8 @@ using System.Net.Http; using System.Text; using System.Text.Json; +using Imagekit.Core; +using Imagekit.Exceptions; using FileUploadParamsProperties = Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties; namespace Imagekit.Models.Beta.V2.Files; @@ -50,10 +52,16 @@ public required string File get { if (!this.BodyProperties.TryGetValue("file", out JsonElement element)) - throw new ArgumentOutOfRangeException("file", "Missing required argument"); + throw new ImageKitInvalidDataException( + "'file' cannot be null", + new ArgumentOutOfRangeException("file", "Missing required argument") + ); return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("file"); + ?? throw new ImageKitInvalidDataException( + "'file' cannot be null", + new ArgumentNullException("file") + ); } set { @@ -72,10 +80,16 @@ public required string FileName get { if (!this.BodyProperties.TryGetValue("fileName", out JsonElement element)) - throw new ArgumentOutOfRangeException("fileName", "Missing required argument"); + throw new ImageKitInvalidDataException( + "'fileName' cannot be null", + new ArgumentOutOfRangeException("fileName", "Missing required argument") + ); return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("fileName"); + ?? throw new ImageKitInvalidDataException( + "'fileName' cannot be null", + new ArgumentNullException("fileName") + ); } set { @@ -541,7 +555,7 @@ public override Uri Url(IImageKitClient client) }.Uri; } - public StringContent BodyContent() + internal override StringContent? BodyContent() { return new( JsonSerializer.Serialize(this.BodyProperties), @@ -550,7 +564,7 @@ public StringContent BodyContent() ); } - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + internal override void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) { ParamsBase.AddDefaultHeaders(request, client); foreach (var item in this.HeaderProperties) diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ResponseField.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ResponseField.cs index b801f518..648ab787 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ResponseField.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ResponseField.cs @@ -1,6 +1,7 @@ using System; using System.Text.Json; using System.Text.Json.Serialization; +using Imagekit.Exceptions; namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties; @@ -57,7 +58,9 @@ JsonSerializerOptions options ResponseField.CustomMetadata => "customMetadata", ResponseField.Metadata => "metadata", ResponseField.SelectedFieldsSchema => "selectedFieldsSchema", - _ => throw new ArgumentOutOfRangeException(nameof(value)), + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), }, options ); diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/Post.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/Post.cs index 80ec39d5..aafee3dc 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/Post.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/Post.cs @@ -1,225 +1,225 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using PostProperties = Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; -using PostVariants = Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostVariants; - -namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties; - -[JsonConverter(typeof(PostConverter))] -public abstract record class Post -{ - internal Post() { } - - public static implicit operator Post(PostProperties::Transformation value) => - new PostVariants::Transformation(value); - - public static implicit operator Post(PostProperties::GifToVideo value) => - new PostVariants::GifToVideo(value); - - public static implicit operator Post(PostProperties::Thumbnail value) => - new PostVariants::Thumbnail(value); - - public static implicit operator Post(PostProperties::Abs value) => new PostVariants::Abs(value); - - public bool TryPickTransformation([NotNullWhen(true)] out PostProperties::Transformation? value) - { - value = (this as PostVariants::Transformation)?.Value; - return value != null; - } - - public bool TryPickGifToVideo([NotNullWhen(true)] out PostProperties::GifToVideo? value) - { - value = (this as PostVariants::GifToVideo)?.Value; - return value != null; - } - - public bool TryPickThumbnail([NotNullWhen(true)] out PostProperties::Thumbnail? value) - { - value = (this as PostVariants::Thumbnail)?.Value; - return value != null; - } - - public bool TryPickAbs([NotNullWhen(true)] out PostProperties::Abs? value) - { - value = (this as PostVariants::Abs)?.Value; - return value != null; - } - - public void Switch( - Action transformation, - Action gifToVideo, - Action thumbnail, - Action abs - ) - { - switch (this) - { - case PostVariants::Transformation inner: - transformation(inner); - break; - case PostVariants::GifToVideo inner: - gifToVideo(inner); - break; - case PostVariants::Thumbnail inner: - thumbnail(inner); - break; - case PostVariants::Abs inner: - abs(inner); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match( - Func transformation, - Func gifToVideo, - Func thumbnail, - Func abs - ) - { - return this switch - { - PostVariants::Transformation inner => transformation(inner), - PostVariants::GifToVideo inner => gifToVideo(inner), - PostVariants::Thumbnail inner => thumbnail(inner), - PostVariants::Abs inner => abs(inner), - _ => throw new InvalidOperationException(), - }; - } - - public abstract void Validate(); -} - -sealed class PostConverter : JsonConverter -{ - public override Post? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - var json = JsonSerializer.Deserialize(ref reader, options); - string? type; - try - { - type = json.GetProperty("type").GetString(); - } - catch - { - type = null; - } - - switch (type) - { - case "transformation": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize( - json, - options - ); - if (deserialized != null) - { - return new PostVariants::Transformation(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "gif-to-video": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize( - json, - options - ); - if (deserialized != null) - { - return new PostVariants::GifToVideo(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "thumbnail": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize( - json, - options - ); - if (deserialized != null) - { - return new PostVariants::Thumbnail(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "abs": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize( - json, - options - ); - if (deserialized != null) - { - return new PostVariants::Abs(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - default: - { - throw new Exception(); - } - } - } - - public override void Write(Utf8JsonWriter writer, Post value, JsonSerializerOptions options) - { - object variant = value switch - { - PostVariants::Transformation(var transformation) => transformation, - PostVariants::GifToVideo(var gifToVideo) => gifToVideo, - PostVariants::Thumbnail(var thumbnail) => thumbnail, - PostVariants::Abs(var abs) => abs, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using PostProperties = Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; +using PostVariants = Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostVariants; + +namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties; + +[JsonConverter(typeof(PostConverter))] +public abstract record class Post +{ + internal Post() { } + + public static implicit operator Post(PostProperties::Transformation value) => + new PostVariants::Transformation(value); + + public static implicit operator Post(PostProperties::GifToVideo value) => + new PostVariants::GifToVideo(value); + + public static implicit operator Post(PostProperties::Thumbnail value) => + new PostVariants::Thumbnail(value); + + public static implicit operator Post(PostProperties::Abs value) => new PostVariants::Abs(value); + + public bool TryPickTransformation([NotNullWhen(true)] out PostProperties::Transformation? value) + { + value = (this as PostVariants::Transformation)?.Value; + return value != null; + } + + public bool TryPickGifToVideo([NotNullWhen(true)] out PostProperties::GifToVideo? value) + { + value = (this as PostVariants::GifToVideo)?.Value; + return value != null; + } + + public bool TryPickThumbnail([NotNullWhen(true)] out PostProperties::Thumbnail? value) + { + value = (this as PostVariants::Thumbnail)?.Value; + return value != null; + } + + public bool TryPickAbs([NotNullWhen(true)] out PostProperties::Abs? value) + { + value = (this as PostVariants::Abs)?.Value; + return value != null; + } + + public void Switch( + Action transformation, + Action gifToVideo, + Action thumbnail, + Action abs + ) + { + switch (this) + { + case PostVariants::Transformation inner: + transformation(inner); + break; + case PostVariants::GifToVideo inner: + gifToVideo(inner); + break; + case PostVariants::Thumbnail inner: + thumbnail(inner); + break; + case PostVariants::Abs inner: + abs(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func transformation, + Func gifToVideo, + Func thumbnail, + Func abs + ) + { + return this switch + { + PostVariants::Transformation inner => transformation(inner), + PostVariants::GifToVideo inner => gifToVideo(inner), + PostVariants::Thumbnail inner => thumbnail(inner), + PostVariants::Abs inner => abs(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class PostConverter : JsonConverter +{ + public override Post? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var json = JsonSerializer.Deserialize(ref reader, options); + string? type; + try + { + type = json.GetProperty("type").GetString(); + } + catch + { + type = null; + } + + switch (type) + { + case "transformation": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize( + json, + options + ); + if (deserialized != null) + { + return new PostVariants::Transformation(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "gif-to-video": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize( + json, + options + ); + if (deserialized != null) + { + return new PostVariants::GifToVideo(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "thumbnail": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize( + json, + options + ); + if (deserialized != null) + { + return new PostVariants::Thumbnail(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "abs": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize( + json, + options + ); + if (deserialized != null) + { + return new PostVariants::Abs(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + default: + { + throw new Exception(); + } + } + } + + public override void Write(Utf8JsonWriter writer, Post value, JsonSerializerOptions options) + { + object variant = value switch + { + PostVariants::Transformation(var transformation) => transformation, + PostVariants::GifToVideo(var gifToVideo) => gifToVideo, + PostVariants::Thumbnail(var thumbnail) => thumbnail, + PostVariants::Abs(var abs) => abs, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Abs.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Abs.cs index f6369541..baf612e4 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Abs.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Abs.cs @@ -1,103 +1,103 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.AbsProperties; - -namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Abs : ModelBase, IFromRaw -{ - /// - /// Streaming protocol to use (`hls` or `dash`). - /// - public required ApiEnum Protocol - { - get - { - if (!this.Properties.TryGetValue("protocol", out JsonElement element)) - throw new ArgumentOutOfRangeException("protocol", "Missing required argument"); - - return JsonSerializer.Deserialize>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["protocol"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Adaptive Bitrate Streaming (ABS) setup. - /// - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// List of different representations you want to create separated by an underscore. - /// - public required string Value - { - get - { - if (!this.Properties.TryGetValue("value", out JsonElement element)) - throw new ArgumentOutOfRangeException("value", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("value"); - } - set - { - this.Properties["value"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Protocol.Validate(); - _ = this.Value; - } - - public Abs() - { - this.Type = JsonSerializer.Deserialize("\"abs\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Abs(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Abs FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.AbsProperties; + +namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Abs : ModelBase, IFromRaw +{ + /// + /// Streaming protocol to use (`hls` or `dash`). + /// + public required ApiEnum Protocol + { + get + { + if (!this.Properties.TryGetValue("protocol", out JsonElement element)) + throw new ArgumentOutOfRangeException("protocol", "Missing required argument"); + + return JsonSerializer.Deserialize>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["protocol"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Adaptive Bitrate Streaming (ABS) setup. + /// + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// List of different representations you want to create separated by an underscore. + /// + public required string Value + { + get + { + if (!this.Properties.TryGetValue("value", out JsonElement element)) + throw new ArgumentOutOfRangeException("value", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("value"); + } + set + { + this.Properties["value"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.Protocol.Validate(); + _ = this.Value; + } + + public Abs() + { + this.Type = JsonSerializer.Deserialize("\"abs\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Abs(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Abs FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideo.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideo.cs index 6f180d0b..0f17f223 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideo.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideo.cs @@ -1,77 +1,77 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class GifToVideo : ModelBase, IFromRaw -{ - /// - /// Converts an animated GIF into an MP4. - /// - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Optional transformation string to apply to the output video. **Example**: - /// `q-80` - /// - public string? Value - { - get - { - if (!this.Properties.TryGetValue("value", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["value"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.Value; - } - - public GifToVideo() - { - this.Type = JsonSerializer.Deserialize("\"gif-to-video\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - GifToVideo(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static GifToVideo FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class GifToVideo : ModelBase, IFromRaw +{ + /// + /// Converts an animated GIF into an MP4. + /// + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Optional transformation string to apply to the output video. **Example**: + /// `q-80` + /// + public string? Value + { + get + { + if (!this.Properties.TryGetValue("value", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["value"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.Value; + } + + public GifToVideo() + { + this.Type = JsonSerializer.Deserialize("\"gif-to-video\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GifToVideo(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static GifToVideo FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Thumbnail.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Thumbnail.cs index b2ee20f1..46493eea 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Thumbnail.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Thumbnail.cs @@ -1,76 +1,76 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Thumbnail : ModelBase, IFromRaw -{ - /// - /// Generates a thumbnail image. - /// - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Optional transformation string. **Example**: `w-150,h-150` - /// - public string? Value - { - get - { - if (!this.Properties.TryGetValue("value", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["value"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.Value; - } - - public Thumbnail() - { - this.Type = JsonSerializer.Deserialize("\"thumbnail\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Thumbnail(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Thumbnail FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Thumbnail : ModelBase, IFromRaw +{ + /// + /// Generates a thumbnail image. + /// + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Optional transformation string. **Example**: `w-150,h-150` + /// + public string? Value + { + get + { + if (!this.Properties.TryGetValue("value", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["value"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.Value; + } + + public Thumbnail() + { + this.Type = JsonSerializer.Deserialize("\"thumbnail\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Thumbnail(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Thumbnail FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Transformation.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Transformation.cs index 4fdd2185..9492fb7a 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Transformation.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Transformation.cs @@ -1,85 +1,85 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Transformation : ModelBase, IFromRaw -{ - /// - /// Transformation type. - /// - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Transformation string (e.g. `w-200,h-200`). Same syntax as ImageKit URL-based - /// transformations. - /// - public required string Value - { - get - { - if (!this.Properties.TryGetValue("value", out JsonElement element)) - throw new ArgumentOutOfRangeException("value", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("value"); - } - set - { - this.Properties["value"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.Value; - } - - public Transformation() - { - this.Type = JsonSerializer.Deserialize("\"transformation\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Transformation(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Transformation FromRawUnchecked(Dictionary properties) - { - return new(properties); - } - - [SetsRequiredMembers] - public Transformation(string value) - : this() - { - this.Value = value; - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Transformation : ModelBase, IFromRaw +{ + /// + /// Transformation type. + /// + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Transformation string (e.g. `w-200,h-200`). Same syntax as ImageKit URL-based + /// transformations. + /// + public required string Value + { + get + { + if (!this.Properties.TryGetValue("value", out JsonElement element)) + throw new ArgumentOutOfRangeException("value", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("value"); + } + set + { + this.Properties["value"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.Value; + } + + public Transformation() + { + this.Type = JsonSerializer.Deserialize("\"transformation\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Transformation(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Transformation FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public Transformation(string value) + : this() + { + this.Value = value; + } +} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponse.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponse.cs index 8a2aaf32..93a9dae4 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponse.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponse.cs @@ -2,6 +2,7 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; +using Imagekit.Core; using Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties; using Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties; using Files = Imagekit.Models.Files; diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs index 1a668162..ac1dd069 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs @@ -3,6 +3,8 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; +using Imagekit.Core; +using Imagekit.Exceptions; using SelectedFieldsSchemaItemProperties = Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; namespace Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties; @@ -18,7 +20,10 @@ public sealed record class SelectedFieldsSchemaItem : ModelBase, IFromRaw diff --git a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs index 8962e190..f6b52828 100644 --- a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs +++ b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs @@ -2,6 +2,7 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; +using Imagekit.Exceptions; using Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties; using Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueVariants; using System = System; @@ -72,7 +73,9 @@ public void Switch( mixed(inner); break; default: - throw new System::InvalidOperationException(); + throw new ImageKitInvalidDataException( + "Data did not match any variant of DefaultValue" + ); } } @@ -89,7 +92,9 @@ public T Match( Double inner => @double(inner), Bool inner => @bool(inner), Mixed inner => mixed(inner), - _ => throw new System::InvalidOperationException(), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of DefaultValue" + ), }; } @@ -104,7 +109,7 @@ sealed class DefaultValueConverter : JsonConverter JsonSerializerOptions options ) { - List exceptions = []; + List exceptions = []; try { @@ -116,7 +121,9 @@ JsonSerializerOptions options } catch (JsonException e) { - exceptions.Add(e); + exceptions.Add( + new ImageKitInvalidDataException("Data does not match union variant String", e) + ); } try @@ -125,7 +132,9 @@ JsonSerializerOptions options } catch (JsonException e) { - exceptions.Add(e); + exceptions.Add( + new ImageKitInvalidDataException("Data does not match union variant Double", e) + ); } try @@ -134,7 +143,9 @@ JsonSerializerOptions options } catch (JsonException e) { - exceptions.Add(e); + exceptions.Add( + new ImageKitInvalidDataException("Data does not match union variant Bool", e) + ); } try @@ -150,7 +161,9 @@ JsonSerializerOptions options } catch (JsonException e) { - exceptions.Add(e); + exceptions.Add( + new ImageKitInvalidDataException("Data does not match union variant Mixed", e) + ); } throw new System::AggregateException(exceptions); @@ -168,7 +181,9 @@ JsonSerializerOptions options Double(var @double) => @double, Bool(var @bool) => @bool, Mixed(var mixed) => mixed, - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of DefaultValue" + ), }; JsonSerializer.Serialize(writer, variant, options); } diff --git a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent4.cs b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent4.cs index 08112b37..43eae369 100644 --- a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent4.cs +++ b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent4.cs @@ -2,6 +2,7 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; +using Imagekit.Exceptions; using Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties.UnnamedSchemaWithArrayParent4Variants; using System = System; @@ -56,7 +57,9 @@ public void Switch( @bool(inner); break; default: - throw new System::InvalidOperationException(); + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent4" + ); } } @@ -71,7 +74,9 @@ public T Match( String inner => @string(inner), Double inner => @double(inner), Bool inner => @bool(inner), - _ => throw new System::InvalidOperationException(), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent4" + ), }; } @@ -86,7 +91,7 @@ sealed class UnnamedSchemaWithArrayParent4Converter : JsonConverter exceptions = []; + List exceptions = []; try { @@ -98,7 +103,9 @@ JsonSerializerOptions options } catch (JsonException e) { - exceptions.Add(e); + exceptions.Add( + new ImageKitInvalidDataException("Data does not match union variant String", e) + ); } try @@ -107,7 +114,9 @@ JsonSerializerOptions options } catch (JsonException e) { - exceptions.Add(e); + exceptions.Add( + new ImageKitInvalidDataException("Data does not match union variant Double", e) + ); } try @@ -116,7 +125,9 @@ JsonSerializerOptions options } catch (JsonException e) { - exceptions.Add(e); + exceptions.Add( + new ImageKitInvalidDataException("Data does not match union variant Bool", e) + ); } throw new System::AggregateException(exceptions); @@ -133,7 +144,9 @@ JsonSerializerOptions options String(var @string) => @string, Double(var @double) => @double, Bool(var @bool) => @bool, - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent4" + ), }; JsonSerializer.Serialize(writer, variant, options); } diff --git a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent4Variants/All.cs b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent4Variants/All.cs index a4066489..a094a29d 100644 --- a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent4Variants/All.cs +++ b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent4Variants/All.cs @@ -1,3 +1,5 @@ +using Imagekit.Core; + namespace Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties.UnnamedSchemaWithArrayParent4Variants; public sealed record class String(string Value) diff --git a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs index 560883e3..52dc3861 100644 --- a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs +++ b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using Imagekit.Core; using Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties; namespace Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueVariants; diff --git a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs index 0002975f..e0a19349 100644 --- a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs +++ b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs @@ -2,6 +2,7 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; +using Imagekit.Exceptions; using Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MaxValueVariants; using System = System; @@ -44,7 +45,9 @@ public void Switch(System::Action @string, System::Action @doubl @double(inner); break; default: - throw new System::InvalidOperationException(); + throw new ImageKitInvalidDataException( + "Data did not match any variant of MaxValue" + ); } } @@ -54,7 +57,9 @@ public T Match(System::Func @string, System::Func @doub { String inner => @string(inner), Double inner => @double(inner), - _ => throw new System::InvalidOperationException(), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of MaxValue" + ), }; } @@ -69,7 +74,7 @@ sealed class MaxValueConverter : JsonConverter JsonSerializerOptions options ) { - List exceptions = []; + List exceptions = []; try { @@ -81,7 +86,9 @@ JsonSerializerOptions options } catch (JsonException e) { - exceptions.Add(e); + exceptions.Add( + new ImageKitInvalidDataException("Data does not match union variant String", e) + ); } try @@ -90,7 +97,9 @@ JsonSerializerOptions options } catch (JsonException e) { - exceptions.Add(e); + exceptions.Add( + new ImageKitInvalidDataException("Data does not match union variant Double", e) + ); } throw new System::AggregateException(exceptions); @@ -102,7 +111,9 @@ public override void Write(Utf8JsonWriter writer, MaxValue value, JsonSerializer { String(var @string) => @string, Double(var @double) => @double, - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of MaxValue" + ), }; JsonSerializer.Serialize(writer, variant, options); } diff --git a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs index bf536ec7..3641cf3e 100644 --- a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs +++ b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs @@ -1,3 +1,5 @@ +using Imagekit.Core; + namespace Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MaxValueVariants; public sealed record class String(string Value) : MaxValue, IVariant diff --git a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs index 318b207e..74c56254 100644 --- a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs +++ b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs @@ -2,6 +2,7 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; +using Imagekit.Exceptions; using Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MinValueVariants; using System = System; @@ -44,7 +45,9 @@ public void Switch(System::Action @string, System::Action @doubl @double(inner); break; default: - throw new System::InvalidOperationException(); + throw new ImageKitInvalidDataException( + "Data did not match any variant of MinValue" + ); } } @@ -54,7 +57,9 @@ public T Match(System::Func @string, System::Func @doub { String inner => @string(inner), Double inner => @double(inner), - _ => throw new System::InvalidOperationException(), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of MinValue" + ), }; } @@ -69,7 +74,7 @@ sealed class MinValueConverter : JsonConverter JsonSerializerOptions options ) { - List exceptions = []; + List exceptions = []; try { @@ -81,7 +86,9 @@ JsonSerializerOptions options } catch (JsonException e) { - exceptions.Add(e); + exceptions.Add( + new ImageKitInvalidDataException("Data does not match union variant String", e) + ); } try @@ -90,7 +97,9 @@ JsonSerializerOptions options } catch (JsonException e) { - exceptions.Add(e); + exceptions.Add( + new ImageKitInvalidDataException("Data does not match union variant Double", e) + ); } throw new System::AggregateException(exceptions); @@ -102,7 +111,9 @@ public override void Write(Utf8JsonWriter writer, MinValue value, JsonSerializer { String(var @string) => @string, Double(var @double) => @double, - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of MinValue" + ), }; JsonSerializer.Serialize(writer, variant, options); } diff --git a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs index ebe9c896..6f4cdde3 100644 --- a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs +++ b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs @@ -1,3 +1,5 @@ +using Imagekit.Core; + namespace Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MinValueVariants; public sealed record class String(string Value) : MinValue, IVariant diff --git a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs index 0128f953..3c953117 100644 --- a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs +++ b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs @@ -2,6 +2,7 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; +using Imagekit.Exceptions; using Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.SelectOptionVariants; using System = System; @@ -54,7 +55,9 @@ public void Switch( @bool(inner); break; default: - throw new System::InvalidOperationException(); + throw new ImageKitInvalidDataException( + "Data did not match any variant of SelectOption" + ); } } @@ -69,7 +72,9 @@ public T Match( String inner => @string(inner), Double inner => @double(inner), Bool inner => @bool(inner), - _ => throw new System::InvalidOperationException(), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of SelectOption" + ), }; } @@ -84,7 +89,7 @@ sealed class SelectOptionConverter : JsonConverter JsonSerializerOptions options ) { - List exceptions = []; + List exceptions = []; try { @@ -96,7 +101,9 @@ JsonSerializerOptions options } catch (JsonException e) { - exceptions.Add(e); + exceptions.Add( + new ImageKitInvalidDataException("Data does not match union variant String", e) + ); } try @@ -105,7 +112,9 @@ JsonSerializerOptions options } catch (JsonException e) { - exceptions.Add(e); + exceptions.Add( + new ImageKitInvalidDataException("Data does not match union variant Double", e) + ); } try @@ -114,7 +123,9 @@ JsonSerializerOptions options } catch (JsonException e) { - exceptions.Add(e); + exceptions.Add( + new ImageKitInvalidDataException("Data does not match union variant Bool", e) + ); } throw new System::AggregateException(exceptions); @@ -131,7 +142,9 @@ JsonSerializerOptions options String(var @string) => @string, Double(var @double) => @double, Bool(var @bool) => @bool, - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of SelectOption" + ), }; JsonSerializer.Serialize(writer, variant, options); } diff --git a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs index 0d47411b..20eb16c4 100644 --- a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs +++ b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs @@ -1,3 +1,5 @@ +using Imagekit.Core; + namespace Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.SelectOptionVariants; public sealed record class String(string Value) : SelectOption, IVariant diff --git a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs index 5d4847af..cbc9d0e3 100644 --- a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs +++ b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs @@ -1,5 +1,6 @@ using System.Text.Json; using System.Text.Json.Serialization; +using Imagekit.Exceptions; using System = System; namespace Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; @@ -53,7 +54,9 @@ public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOpti SelectedFieldsSchemaItemProperties.Type.Boolean => "Boolean", SelectedFieldsSchemaItemProperties.Type.SingleSelect => "SingleSelect", SelectedFieldsSchemaItemProperties.Type.MultiSelect => "MultiSelect", - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), }, options ); diff --git a/src/Imagekit/Models/Files/FileRenameParams.cs b/src/Imagekit/Models/Files/FileRenameParams.cs index 8c378757..a0b6121b 100644 --- a/src/Imagekit/Models/Files/FileRenameParams.cs +++ b/src/Imagekit/Models/Files/FileRenameParams.cs @@ -1,129 +1,129 @@ -using System; -using System.Collections.Generic; -using System.Net.Http; -using System.Text; -using System.Text.Json; - -namespace Imagekit.Models.Files; - -/// -/// You can rename an already existing file in the media library using rename file -/// API. This operation would rename all file versions of the file. -/// -/// Note: The old URLs will stop working. The file/file version URLs cached on CDN -/// will continue to work unless a purge is requested. -/// -public sealed record class FileRenameParams : ParamsBase -{ - public Dictionary BodyProperties { get; set; } = []; - - /// - /// The full path of the file you want to rename. - /// - public required string FilePath - { - get - { - if (!this.BodyProperties.TryGetValue("filePath", out JsonElement element)) - throw new ArgumentOutOfRangeException("filePath", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("filePath"); - } - set - { - this.BodyProperties["filePath"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The new name of the file. A filename can contain: - /// - /// Alphanumeric Characters: `a-z`, `A-Z`, `0-9` (including Unicode letters, marks, - /// and numerals in other languages). Special Characters: `.`, `_`, and `-`. - /// - /// Any other character, including space, will be replaced by `_`. - /// - public required string NewFileName - { - get - { - if (!this.BodyProperties.TryGetValue("newFileName", out JsonElement element)) - throw new ArgumentOutOfRangeException("newFileName", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("newFileName"); - } - set - { - this.BodyProperties["newFileName"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Option to purge cache for the old file and its versions' URLs. - /// - /// When set to true, it will internally issue a purge cache request on CDN to - /// remove cached content of old file and its versions. This purge request is - /// counted against your monthly purge quota. - /// - /// Note: If the old file were accessible at `https://ik.imagekit.io/demo/old-filename.jpg`, - /// a purge cache request would be issued against `https://ik.imagekit.io/demo/old-filename.jpg*` - /// (with a wildcard at the end). It will remove the file and its versions' URLs - /// and any transformations made using query parameters on this file or its versions. - /// However, the cache for file transformations made using path parameters will - /// persist. You can purge them using the purge API. For more details, refer to - /// the purge API documentation. - /// - /// Default value - `false` - /// - public bool? PurgeCache - { - get - { - if (!this.BodyProperties.TryGetValue("purgeCache", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["purgeCache"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override Uri Url(IImageKitClient client) - { - return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/files/rename") - { - Query = this.QueryString(client), - }.Uri; - } - - public StringContent BodyContent() - { - return new( - JsonSerializer.Serialize(this.BodyProperties), - Encoding.UTF8, - "application/json" - ); - } - - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Text; +using System.Text.Json; + +namespace Imagekit.Models.Files; + +/// +/// You can rename an already existing file in the media library using rename file +/// API. This operation would rename all file versions of the file. +/// +/// Note: The old URLs will stop working. The file/file version URLs cached on CDN +/// will continue to work unless a purge is requested. +/// +public sealed record class FileRenameParams : ParamsBase +{ + public Dictionary BodyProperties { get; set; } = []; + + /// + /// The full path of the file you want to rename. + /// + public required string FilePath + { + get + { + if (!this.BodyProperties.TryGetValue("filePath", out JsonElement element)) + throw new ArgumentOutOfRangeException("filePath", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("filePath"); + } + set + { + this.BodyProperties["filePath"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The new name of the file. A filename can contain: + /// + /// Alphanumeric Characters: `a-z`, `A-Z`, `0-9` (including Unicode letters, marks, + /// and numerals in other languages). Special Characters: `.`, `_`, and `-`. + /// + /// Any other character, including space, will be replaced by `_`. + /// + public required string NewFileName + { + get + { + if (!this.BodyProperties.TryGetValue("newFileName", out JsonElement element)) + throw new ArgumentOutOfRangeException("newFileName", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("newFileName"); + } + set + { + this.BodyProperties["newFileName"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Option to purge cache for the old file and its versions' URLs. + /// + /// When set to true, it will internally issue a purge cache request on CDN to + /// remove cached content of old file and its versions. This purge request is + /// counted against your monthly purge quota. + /// + /// Note: If the old file were accessible at `https://ik.imagekit.io/demo/old-filename.jpg`, + /// a purge cache request would be issued against `https://ik.imagekit.io/demo/old-filename.jpg*` + /// (with a wildcard at the end). It will remove the file and its versions' URLs + /// and any transformations made using query parameters on this file or its versions. + /// However, the cache for file transformations made using path parameters will + /// persist. You can purge them using the purge API. For more details, refer to + /// the purge API documentation. + /// + /// Default value - `false` + /// + public bool? PurgeCache + { + get + { + if (!this.BodyProperties.TryGetValue("purgeCache", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.BodyProperties["purgeCache"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override Uri Url(IImageKitClient client) + { + return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/files/rename") + { + Query = this.QueryString(client), + }.Uri; + } + + public StringContent BodyContent() + { + return new( + JsonSerializer.Serialize(this.BodyProperties), + Encoding.UTF8, + "application/json" + ); + } + + public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + { + ParamsBase.AddDefaultHeaders(request, client); + foreach (var item in this.HeaderProperties) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } +} diff --git a/src/Imagekit/Models/Files/FileUpdateParams.cs b/src/Imagekit/Models/Files/FileUpdateParams.cs index 8210b1d8..eb48f23f 100644 --- a/src/Imagekit/Models/Files/FileUpdateParams.cs +++ b/src/Imagekit/Models/Files/FileUpdateParams.cs @@ -47,7 +47,7 @@ public override Uri Url(IImageKitClient client) }.Uri; } - public StringContent BodyContent() + internal override StringContent? BodyContent() { return new( JsonSerializer.Serialize(this.BodyProperties), @@ -56,7 +56,7 @@ public StringContent BodyContent() ); } - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + internal override void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) { ParamsBase.AddDefaultHeaders(request, client); foreach (var item in this.HeaderProperties) diff --git a/src/Imagekit/Models/Files/FileUpdateResponse.cs b/src/Imagekit/Models/Files/FileUpdateResponse.cs index 4752c71a..782321bd 100644 --- a/src/Imagekit/Models/Files/FileUpdateResponse.cs +++ b/src/Imagekit/Models/Files/FileUpdateResponse.cs @@ -3,6 +3,7 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; +using Imagekit.Core; using Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties; using Imagekit.Models.Files.FileUpdateResponseProperties.IntersectionMember1Properties; using FileProperties = Imagekit.Models.Files.FileProperties; diff --git a/src/Imagekit/Models/Files/FileUploadParams.cs b/src/Imagekit/Models/Files/FileUploadParams.cs index f9951c2e..3be2d945 100644 --- a/src/Imagekit/Models/Files/FileUploadParams.cs +++ b/src/Imagekit/Models/Files/FileUploadParams.cs @@ -3,6 +3,8 @@ using System.Net.Http; using System.Text; using System.Text.Json; +using Imagekit.Core; +using Imagekit.Exceptions; using FileUploadParamsProperties = Imagekit.Models.Files.FileUploadParamsProperties; namespace Imagekit.Models.Files; @@ -50,10 +52,16 @@ public required string File get { if (!this.BodyProperties.TryGetValue("file", out JsonElement element)) - throw new ArgumentOutOfRangeException("file", "Missing required argument"); + throw new ImageKitInvalidDataException( + "'file' cannot be null", + new ArgumentOutOfRangeException("file", "Missing required argument") + ); return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("file"); + ?? throw new ImageKitInvalidDataException( + "'file' cannot be null", + new ArgumentNullException("file") + ); } set { @@ -77,10 +85,16 @@ public required string FileName get { if (!this.BodyProperties.TryGetValue("fileName", out JsonElement element)) - throw new ArgumentOutOfRangeException("fileName", "Missing required argument"); + throw new ImageKitInvalidDataException( + "'fileName' cannot be null", + new ArgumentOutOfRangeException("fileName", "Missing required argument") + ); return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("fileName"); + ?? throw new ImageKitInvalidDataException( + "'fileName' cannot be null", + new ArgumentNullException("fileName") + ); } set { @@ -618,7 +632,7 @@ public override Uri Url(IImageKitClient client) }.Uri; } - public StringContent BodyContent() + internal override StringContent? BodyContent() { return new( JsonSerializer.Serialize(this.BodyProperties), @@ -627,7 +641,7 @@ public StringContent BodyContent() ); } - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) + internal override void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) { ParamsBase.AddDefaultHeaders(request, client); foreach (var item in this.HeaderProperties) diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/ResponseField.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/ResponseField.cs index 179d40c1..ce14903f 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/ResponseField.cs +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/ResponseField.cs @@ -1,6 +1,7 @@ using System; using System.Text.Json; using System.Text.Json.Serialization; +using Imagekit.Exceptions; namespace Imagekit.Models.Files.FileUploadParamsProperties; @@ -57,7 +58,9 @@ JsonSerializerOptions options ResponseField.CustomMetadata => "customMetadata", ResponseField.Metadata => "metadata", ResponseField.SelectedFieldsSchema => "selectedFieldsSchema", - _ => throw new ArgumentOutOfRangeException(nameof(value)), + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), }, options ); diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/Post.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/Post.cs index 9f7a1ec3..9c23e88d 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/Post.cs +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/Post.cs @@ -1,225 +1,225 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using PostProperties = Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; -using PostVariants = Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostVariants; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties; - -[JsonConverter(typeof(PostConverter))] -public abstract record class Post -{ - internal Post() { } - - public static implicit operator Post(PostProperties::Transformation value) => - new PostVariants::Transformation(value); - - public static implicit operator Post(PostProperties::GifToVideo value) => - new PostVariants::GifToVideo(value); - - public static implicit operator Post(PostProperties::Thumbnail value) => - new PostVariants::Thumbnail(value); - - public static implicit operator Post(PostProperties::Abs value) => new PostVariants::Abs(value); - - public bool TryPickTransformation([NotNullWhen(true)] out PostProperties::Transformation? value) - { - value = (this as PostVariants::Transformation)?.Value; - return value != null; - } - - public bool TryPickGifToVideo([NotNullWhen(true)] out PostProperties::GifToVideo? value) - { - value = (this as PostVariants::GifToVideo)?.Value; - return value != null; - } - - public bool TryPickThumbnail([NotNullWhen(true)] out PostProperties::Thumbnail? value) - { - value = (this as PostVariants::Thumbnail)?.Value; - return value != null; - } - - public bool TryPickAbs([NotNullWhen(true)] out PostProperties::Abs? value) - { - value = (this as PostVariants::Abs)?.Value; - return value != null; - } - - public void Switch( - Action transformation, - Action gifToVideo, - Action thumbnail, - Action abs - ) - { - switch (this) - { - case PostVariants::Transformation inner: - transformation(inner); - break; - case PostVariants::GifToVideo inner: - gifToVideo(inner); - break; - case PostVariants::Thumbnail inner: - thumbnail(inner); - break; - case PostVariants::Abs inner: - abs(inner); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match( - Func transformation, - Func gifToVideo, - Func thumbnail, - Func abs - ) - { - return this switch - { - PostVariants::Transformation inner => transformation(inner), - PostVariants::GifToVideo inner => gifToVideo(inner), - PostVariants::Thumbnail inner => thumbnail(inner), - PostVariants::Abs inner => abs(inner), - _ => throw new InvalidOperationException(), - }; - } - - public abstract void Validate(); -} - -sealed class PostConverter : JsonConverter -{ - public override Post? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - var json = JsonSerializer.Deserialize(ref reader, options); - string? type; - try - { - type = json.GetProperty("type").GetString(); - } - catch - { - type = null; - } - - switch (type) - { - case "transformation": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize( - json, - options - ); - if (deserialized != null) - { - return new PostVariants::Transformation(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "gif-to-video": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize( - json, - options - ); - if (deserialized != null) - { - return new PostVariants::GifToVideo(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "thumbnail": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize( - json, - options - ); - if (deserialized != null) - { - return new PostVariants::Thumbnail(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "abs": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize( - json, - options - ); - if (deserialized != null) - { - return new PostVariants::Abs(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - default: - { - throw new Exception(); - } - } - } - - public override void Write(Utf8JsonWriter writer, Post value, JsonSerializerOptions options) - { - object variant = value switch - { - PostVariants::Transformation(var transformation) => transformation, - PostVariants::GifToVideo(var gifToVideo) => gifToVideo, - PostVariants::Thumbnail(var thumbnail) => thumbnail, - PostVariants::Abs(var abs) => abs, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using PostProperties = Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; +using PostVariants = Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostVariants; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties; + +[JsonConverter(typeof(PostConverter))] +public abstract record class Post +{ + internal Post() { } + + public static implicit operator Post(PostProperties::Transformation value) => + new PostVariants::Transformation(value); + + public static implicit operator Post(PostProperties::GifToVideo value) => + new PostVariants::GifToVideo(value); + + public static implicit operator Post(PostProperties::Thumbnail value) => + new PostVariants::Thumbnail(value); + + public static implicit operator Post(PostProperties::Abs value) => new PostVariants::Abs(value); + + public bool TryPickTransformation([NotNullWhen(true)] out PostProperties::Transformation? value) + { + value = (this as PostVariants::Transformation)?.Value; + return value != null; + } + + public bool TryPickGifToVideo([NotNullWhen(true)] out PostProperties::GifToVideo? value) + { + value = (this as PostVariants::GifToVideo)?.Value; + return value != null; + } + + public bool TryPickThumbnail([NotNullWhen(true)] out PostProperties::Thumbnail? value) + { + value = (this as PostVariants::Thumbnail)?.Value; + return value != null; + } + + public bool TryPickAbs([NotNullWhen(true)] out PostProperties::Abs? value) + { + value = (this as PostVariants::Abs)?.Value; + return value != null; + } + + public void Switch( + Action transformation, + Action gifToVideo, + Action thumbnail, + Action abs + ) + { + switch (this) + { + case PostVariants::Transformation inner: + transformation(inner); + break; + case PostVariants::GifToVideo inner: + gifToVideo(inner); + break; + case PostVariants::Thumbnail inner: + thumbnail(inner); + break; + case PostVariants::Abs inner: + abs(inner); + break; + default: + throw new InvalidOperationException(); + } + } + + public T Match( + Func transformation, + Func gifToVideo, + Func thumbnail, + Func abs + ) + { + return this switch + { + PostVariants::Transformation inner => transformation(inner), + PostVariants::GifToVideo inner => gifToVideo(inner), + PostVariants::Thumbnail inner => thumbnail(inner), + PostVariants::Abs inner => abs(inner), + _ => throw new InvalidOperationException(), + }; + } + + public abstract void Validate(); +} + +sealed class PostConverter : JsonConverter +{ + public override Post? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var json = JsonSerializer.Deserialize(ref reader, options); + string? type; + try + { + type = json.GetProperty("type").GetString(); + } + catch + { + type = null; + } + + switch (type) + { + case "transformation": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize( + json, + options + ); + if (deserialized != null) + { + return new PostVariants::Transformation(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "gif-to-video": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize( + json, + options + ); + if (deserialized != null) + { + return new PostVariants::GifToVideo(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "thumbnail": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize( + json, + options + ); + if (deserialized != null) + { + return new PostVariants::Thumbnail(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + case "abs": + { + List exceptions = []; + + try + { + var deserialized = JsonSerializer.Deserialize( + json, + options + ); + if (deserialized != null) + { + return new PostVariants::Abs(deserialized); + } + } + catch (JsonException e) + { + exceptions.Add(e); + } + + throw new AggregateException(exceptions); + } + default: + { + throw new Exception(); + } + } + } + + public override void Write(Utf8JsonWriter writer, Post value, JsonSerializerOptions options) + { + object variant = value switch + { + PostVariants::Transformation(var transformation) => transformation, + PostVariants::GifToVideo(var gifToVideo) => gifToVideo, + PostVariants::Thumbnail(var thumbnail) => thumbnail, + PostVariants::Abs(var abs) => abs, + _ => throw new ArgumentOutOfRangeException(nameof(value)), + }; + JsonSerializer.Serialize(writer, variant, options); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Abs.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Abs.cs index 10c95b3c..49ff3366 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Abs.cs +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Abs.cs @@ -1,103 +1,103 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.AbsProperties; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Abs : ModelBase, IFromRaw -{ - /// - /// Streaming protocol to use (`hls` or `dash`). - /// - public required ApiEnum Protocol - { - get - { - if (!this.Properties.TryGetValue("protocol", out JsonElement element)) - throw new ArgumentOutOfRangeException("protocol", "Missing required argument"); - - return JsonSerializer.Deserialize>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["protocol"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Adaptive Bitrate Streaming (ABS) setup. - /// - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// List of different representations you want to create separated by an underscore. - /// - public required string Value - { - get - { - if (!this.Properties.TryGetValue("value", out JsonElement element)) - throw new ArgumentOutOfRangeException("value", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("value"); - } - set - { - this.Properties["value"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Protocol.Validate(); - _ = this.Value; - } - - public Abs() - { - this.Type = JsonSerializer.Deserialize("\"abs\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Abs(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Abs FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.AbsProperties; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Abs : ModelBase, IFromRaw +{ + /// + /// Streaming protocol to use (`hls` or `dash`). + /// + public required ApiEnum Protocol + { + get + { + if (!this.Properties.TryGetValue("protocol", out JsonElement element)) + throw new ArgumentOutOfRangeException("protocol", "Missing required argument"); + + return JsonSerializer.Deserialize>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["protocol"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Adaptive Bitrate Streaming (ABS) setup. + /// + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// List of different representations you want to create separated by an underscore. + /// + public required string Value + { + get + { + if (!this.Properties.TryGetValue("value", out JsonElement element)) + throw new ArgumentOutOfRangeException("value", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("value"); + } + set + { + this.Properties["value"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.Protocol.Validate(); + _ = this.Value; + } + + public Abs() + { + this.Type = JsonSerializer.Deserialize("\"abs\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Abs(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Abs FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideo.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideo.cs index 44e57f2a..889e5951 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideo.cs +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideo.cs @@ -1,77 +1,77 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class GifToVideo : ModelBase, IFromRaw -{ - /// - /// Converts an animated GIF into an MP4. - /// - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Optional transformation string to apply to the output video. **Example**: - /// `q-80` - /// - public string? Value - { - get - { - if (!this.Properties.TryGetValue("value", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["value"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.Value; - } - - public GifToVideo() - { - this.Type = JsonSerializer.Deserialize("\"gif-to-video\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - GifToVideo(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static GifToVideo FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class GifToVideo : ModelBase, IFromRaw +{ + /// + /// Converts an animated GIF into an MP4. + /// + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Optional transformation string to apply to the output video. **Example**: + /// `q-80` + /// + public string? Value + { + get + { + if (!this.Properties.TryGetValue("value", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["value"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.Value; + } + + public GifToVideo() + { + this.Type = JsonSerializer.Deserialize("\"gif-to-video\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GifToVideo(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static GifToVideo FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Thumbnail.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Thumbnail.cs index 879f27c1..4b2e57c3 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Thumbnail.cs +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Thumbnail.cs @@ -1,76 +1,76 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Thumbnail : ModelBase, IFromRaw -{ - /// - /// Generates a thumbnail image. - /// - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Optional transformation string. **Example**: `w-150,h-150` - /// - public string? Value - { - get - { - if (!this.Properties.TryGetValue("value", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["value"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.Value; - } - - public Thumbnail() - { - this.Type = JsonSerializer.Deserialize("\"thumbnail\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Thumbnail(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Thumbnail FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Thumbnail : ModelBase, IFromRaw +{ + /// + /// Generates a thumbnail image. + /// + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Optional transformation string. **Example**: `w-150,h-150` + /// + public string? Value + { + get + { + if (!this.Properties.TryGetValue("value", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["value"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.Value; + } + + public Thumbnail() + { + this.Type = JsonSerializer.Deserialize("\"thumbnail\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Thumbnail(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Thumbnail FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Transformation.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Transformation.cs index b68c748b..556b8c65 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Transformation.cs +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Transformation.cs @@ -1,85 +1,85 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Transformation : ModelBase, IFromRaw -{ - /// - /// Transformation type. - /// - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Transformation string (e.g. `w-200,h-200`). Same syntax as ImageKit URL-based - /// transformations. - /// - public required string Value - { - get - { - if (!this.Properties.TryGetValue("value", out JsonElement element)) - throw new ArgumentOutOfRangeException("value", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("value"); - } - set - { - this.Properties["value"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.Value; - } - - public Transformation() - { - this.Type = JsonSerializer.Deserialize("\"transformation\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Transformation(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Transformation FromRawUnchecked(Dictionary properties) - { - return new(properties); - } - - [SetsRequiredMembers] - public Transformation(string value) - : this() - { - this.Value = value; - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Transformation : ModelBase, IFromRaw +{ + /// + /// Transformation type. + /// + public JsonElement Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Transformation string (e.g. `w-200,h-200`). Same syntax as ImageKit URL-based + /// transformations. + /// + public required string Value + { + get + { + if (!this.Properties.TryGetValue("value", out JsonElement element)) + throw new ArgumentOutOfRangeException("value", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("value"); + } + set + { + this.Properties["value"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.Value; + } + + public Transformation() + { + this.Type = JsonSerializer.Deserialize("\"transformation\""); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Transformation(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Transformation FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public Transformation(string value) + : this() + { + this.Value = value; + } +} diff --git a/src/Imagekit/Models/Files/FileUploadResponse.cs b/src/Imagekit/Models/Files/FileUploadResponse.cs index 6b2dadb8..e6de32e1 100644 --- a/src/Imagekit/Models/Files/FileUploadResponse.cs +++ b/src/Imagekit/Models/Files/FileUploadResponse.cs @@ -2,6 +2,7 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; +using Imagekit.Core; using Imagekit.Models.Files.FileUploadResponseProperties; using Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties; diff --git a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs index e493b8d7..959763f7 100644 --- a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs +++ b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs @@ -3,6 +3,8 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; +using Imagekit.Core; +using Imagekit.Exceptions; using SelectedFieldsSchemaItemProperties = Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; namespace Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties; @@ -18,7 +20,10 @@ public sealed record class SelectedFieldsSchemaItem : ModelBase, IFromRaw diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs index a1b2e6b7..749bea34 100644 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs @@ -2,6 +2,7 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; +using Imagekit.Exceptions; using Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties; using Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueVariants; using System = System; @@ -72,7 +73,9 @@ public void Switch( mixed(inner); break; default: - throw new System::InvalidOperationException(); + throw new ImageKitInvalidDataException( + "Data did not match any variant of DefaultValue" + ); } } @@ -89,7 +92,9 @@ public T Match( Double inner => @double(inner), Bool inner => @bool(inner), Mixed inner => mixed(inner), - _ => throw new System::InvalidOperationException(), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of DefaultValue" + ), }; } @@ -104,7 +109,7 @@ sealed class DefaultValueConverter : JsonConverter JsonSerializerOptions options ) { - List exceptions = []; + List exceptions = []; try { @@ -116,7 +121,9 @@ JsonSerializerOptions options } catch (JsonException e) { - exceptions.Add(e); + exceptions.Add( + new ImageKitInvalidDataException("Data does not match union variant String", e) + ); } try @@ -125,7 +132,9 @@ JsonSerializerOptions options } catch (JsonException e) { - exceptions.Add(e); + exceptions.Add( + new ImageKitInvalidDataException("Data does not match union variant Double", e) + ); } try @@ -134,7 +143,9 @@ JsonSerializerOptions options } catch (JsonException e) { - exceptions.Add(e); + exceptions.Add( + new ImageKitInvalidDataException("Data does not match union variant Bool", e) + ); } try @@ -150,7 +161,9 @@ JsonSerializerOptions options } catch (JsonException e) { - exceptions.Add(e); + exceptions.Add( + new ImageKitInvalidDataException("Data does not match union variant Mixed", e) + ); } throw new System::AggregateException(exceptions); @@ -168,7 +181,9 @@ JsonSerializerOptions options Double(var @double) => @double, Bool(var @bool) => @bool, Mixed(var mixed) => mixed, - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of DefaultValue" + ), }; JsonSerializer.Serialize(writer, variant, options); } diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent7.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent7.cs index c2cc3596..97000cb3 100644 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent7.cs +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent7.cs @@ -2,6 +2,7 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; +using Imagekit.Exceptions; using Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties.UnnamedSchemaWithArrayParent7Variants; using System = System; @@ -56,7 +57,9 @@ public void Switch( @bool(inner); break; default: - throw new System::InvalidOperationException(); + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent7" + ); } } @@ -71,7 +74,9 @@ public T Match( String inner => @string(inner), Double inner => @double(inner), Bool inner => @bool(inner), - _ => throw new System::InvalidOperationException(), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent7" + ), }; } @@ -86,7 +91,7 @@ sealed class UnnamedSchemaWithArrayParent7Converter : JsonConverter exceptions = []; + List exceptions = []; try { @@ -98,7 +103,9 @@ JsonSerializerOptions options } catch (JsonException e) { - exceptions.Add(e); + exceptions.Add( + new ImageKitInvalidDataException("Data does not match union variant String", e) + ); } try @@ -107,7 +114,9 @@ JsonSerializerOptions options } catch (JsonException e) { - exceptions.Add(e); + exceptions.Add( + new ImageKitInvalidDataException("Data does not match union variant Double", e) + ); } try @@ -116,7 +125,9 @@ JsonSerializerOptions options } catch (JsonException e) { - exceptions.Add(e); + exceptions.Add( + new ImageKitInvalidDataException("Data does not match union variant Bool", e) + ); } throw new System::AggregateException(exceptions); @@ -133,7 +144,9 @@ JsonSerializerOptions options String(var @string) => @string, Double(var @double) => @double, Bool(var @bool) => @bool, - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent7" + ), }; JsonSerializer.Serialize(writer, variant, options); } diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent7Variants/All.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent7Variants/All.cs index f4fe8bd6..ba9221b3 100644 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent7Variants/All.cs +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent7Variants/All.cs @@ -1,3 +1,5 @@ +using Imagekit.Core; + namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties.UnnamedSchemaWithArrayParent7Variants; public sealed record class String(string Value) diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs index a36a62ee..616f3f51 100644 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using Imagekit.Core; using Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties; namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueVariants; diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs index e69a8780..f5d6db94 100644 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs @@ -2,6 +2,7 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; +using Imagekit.Exceptions; using Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MaxValueVariants; using System = System; @@ -44,7 +45,9 @@ public void Switch(System::Action @string, System::Action @doubl @double(inner); break; default: - throw new System::InvalidOperationException(); + throw new ImageKitInvalidDataException( + "Data did not match any variant of MaxValue" + ); } } @@ -54,7 +57,9 @@ public T Match(System::Func @string, System::Func @doub { String inner => @string(inner), Double inner => @double(inner), - _ => throw new System::InvalidOperationException(), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of MaxValue" + ), }; } @@ -69,7 +74,7 @@ sealed class MaxValueConverter : JsonConverter JsonSerializerOptions options ) { - List exceptions = []; + List exceptions = []; try { @@ -81,7 +86,9 @@ JsonSerializerOptions options } catch (JsonException e) { - exceptions.Add(e); + exceptions.Add( + new ImageKitInvalidDataException("Data does not match union variant String", e) + ); } try @@ -90,7 +97,9 @@ JsonSerializerOptions options } catch (JsonException e) { - exceptions.Add(e); + exceptions.Add( + new ImageKitInvalidDataException("Data does not match union variant Double", e) + ); } throw new System::AggregateException(exceptions); @@ -102,7 +111,9 @@ public override void Write(Utf8JsonWriter writer, MaxValue value, JsonSerializer { String(var @string) => @string, Double(var @double) => @double, - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of MaxValue" + ), }; JsonSerializer.Serialize(writer, variant, options); } diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs index f7c39b8c..109edfee 100644 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs @@ -1,3 +1,5 @@ +using Imagekit.Core; + namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MaxValueVariants; public sealed record class String(string Value) : MaxValue, IVariant diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs index e5153553..98c63ae3 100644 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs @@ -2,6 +2,7 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; +using Imagekit.Exceptions; using Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MinValueVariants; using System = System; @@ -44,7 +45,9 @@ public void Switch(System::Action @string, System::Action @doubl @double(inner); break; default: - throw new System::InvalidOperationException(); + throw new ImageKitInvalidDataException( + "Data did not match any variant of MinValue" + ); } } @@ -54,7 +57,9 @@ public T Match(System::Func @string, System::Func @doub { String inner => @string(inner), Double inner => @double(inner), - _ => throw new System::InvalidOperationException(), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of MinValue" + ), }; } @@ -69,7 +74,7 @@ sealed class MinValueConverter : JsonConverter JsonSerializerOptions options ) { - List exceptions = []; + List exceptions = []; try { @@ -81,7 +86,9 @@ JsonSerializerOptions options } catch (JsonException e) { - exceptions.Add(e); + exceptions.Add( + new ImageKitInvalidDataException("Data does not match union variant String", e) + ); } try @@ -90,7 +97,9 @@ JsonSerializerOptions options } catch (JsonException e) { - exceptions.Add(e); + exceptions.Add( + new ImageKitInvalidDataException("Data does not match union variant Double", e) + ); } throw new System::AggregateException(exceptions); @@ -102,7 +111,9 @@ public override void Write(Utf8JsonWriter writer, MinValue value, JsonSerializer { String(var @string) => @string, Double(var @double) => @double, - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of MinValue" + ), }; JsonSerializer.Serialize(writer, variant, options); } diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs index c809c0bb..6aed2033 100644 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs @@ -1,3 +1,5 @@ +using Imagekit.Core; + namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MinValueVariants; public sealed record class String(string Value) : MinValue, IVariant diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs index 7bfedd0c..e84f0625 100644 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs @@ -2,6 +2,7 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; +using Imagekit.Exceptions; using Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.SelectOptionVariants; using System = System; @@ -54,7 +55,9 @@ public void Switch( @bool(inner); break; default: - throw new System::InvalidOperationException(); + throw new ImageKitInvalidDataException( + "Data did not match any variant of SelectOption" + ); } } @@ -69,7 +72,9 @@ public T Match( String inner => @string(inner), Double inner => @double(inner), Bool inner => @bool(inner), - _ => throw new System::InvalidOperationException(), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of SelectOption" + ), }; } @@ -84,7 +89,7 @@ sealed class SelectOptionConverter : JsonConverter JsonSerializerOptions options ) { - List exceptions = []; + List exceptions = []; try { @@ -96,7 +101,9 @@ JsonSerializerOptions options } catch (JsonException e) { - exceptions.Add(e); + exceptions.Add( + new ImageKitInvalidDataException("Data does not match union variant String", e) + ); } try @@ -105,7 +112,9 @@ JsonSerializerOptions options } catch (JsonException e) { - exceptions.Add(e); + exceptions.Add( + new ImageKitInvalidDataException("Data does not match union variant Double", e) + ); } try @@ -114,7 +123,9 @@ JsonSerializerOptions options } catch (JsonException e) { - exceptions.Add(e); + exceptions.Add( + new ImageKitInvalidDataException("Data does not match union variant Bool", e) + ); } throw new System::AggregateException(exceptions); @@ -131,7 +142,9 @@ JsonSerializerOptions options String(var @string) => @string, Double(var @double) => @double, Bool(var @bool) => @bool, - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of SelectOption" + ), }; JsonSerializer.Serialize(writer, variant, options); } diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs index 7cddb76a..fdc17863 100644 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs @@ -1,3 +1,5 @@ +using Imagekit.Core; + namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.SelectOptionVariants; public sealed record class String(string Value) : SelectOption, IVariant diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs index 382b8567..d6ce2ec5 100644 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs @@ -1,5 +1,6 @@ using System.Text.Json; using System.Text.Json.Serialization; +using Imagekit.Exceptions; using System = System; namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; @@ -53,7 +54,9 @@ public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOpti SelectedFieldsSchemaItemProperties.Type.Boolean => "Boolean", SelectedFieldsSchemaItemProperties.Type.SingleSelect => "SingleSelect", SelectedFieldsSchemaItemProperties.Type.MultiSelect => "MultiSelect", - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), }, options ); diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/Request.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/Request.cs index 848061a5..c51ab264 100644 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/Request.cs +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/Request.cs @@ -1,79 +1,79 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Request : ModelBase, IFromRaw -{ - /// - /// The requested pre-transformation string. - /// - public required string Transformation - { - get - { - if (!this.Properties.TryGetValue("transformation", out JsonElement element)) - throw new ArgumentOutOfRangeException( - "transformation", - "Missing required argument" - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("transformation"); - } - set - { - this.Properties["transformation"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Unique identifier for the originating request. - /// - public required string XRequestID - { - get - { - if (!this.Properties.TryGetValue("x_request_id", out JsonElement element)) - throw new ArgumentOutOfRangeException("x_request_id", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("x_request_id"); - } - set - { - this.Properties["x_request_id"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.Transformation; - _ = this.XRequestID; - } - - public Request() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Request(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Request FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Request : ModelBase, IFromRaw +{ + /// + /// The requested pre-transformation string. + /// + public required string Transformation + { + get + { + if (!this.Properties.TryGetValue("transformation", out JsonElement element)) + throw new ArgumentOutOfRangeException( + "transformation", + "Missing required argument" + ); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("transformation"); + } + set + { + this.Properties["transformation"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Unique identifier for the originating request. + /// + public required string XRequestID + { + get + { + if (!this.Properties.TryGetValue("x_request_id", out JsonElement element)) + throw new ArgumentOutOfRangeException("x_request_id", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("x_request_id"); + } + set + { + this.Properties["x_request_id"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.Transformation; + _ = this.XRequestID; + } + + public Request() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Request(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Request FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEvent.cs b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEvent.cs index 94589e5d..2aa0d50e 100644 --- a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEvent.cs +++ b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEvent.cs @@ -3,6 +3,8 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; +using Imagekit.Core; +using Imagekit.Exceptions; using Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.IntersectionMember1Properties; namespace Imagekit.Models.Webhooks; @@ -25,10 +27,16 @@ public required string ID get { if (!this.Properties.TryGetValue("id", out JsonElement element)) - throw new ArgumentOutOfRangeException("id", "Missing required argument"); + throw new ImageKitInvalidDataException( + "'id' cannot be null", + new ArgumentOutOfRangeException("id", "Missing required argument") + ); return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("id"); + ?? throw new ImageKitInvalidDataException( + "'id' cannot be null", + new ArgumentNullException("id") + ); } set { @@ -47,10 +55,16 @@ public required string Type get { if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); + throw new ImageKitInvalidDataException( + "'type' cannot be null", + new ArgumentOutOfRangeException("type", "Missing required argument") + ); return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("type"); + ?? throw new ImageKitInvalidDataException( + "'type' cannot be null", + new ArgumentNullException("type") + ); } set { @@ -69,7 +83,10 @@ public required DateTime CreatedAt get { if (!this.Properties.TryGetValue("created_at", out JsonElement element)) - throw new ArgumentOutOfRangeException("created_at", "Missing required argument"); + throw new ImageKitInvalidDataException( + "'created_at' cannot be null", + new ArgumentOutOfRangeException("created_at", "Missing required argument") + ); return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); } @@ -87,10 +104,16 @@ public required Data Data get { if (!this.Properties.TryGetValue("data", out JsonElement element)) - throw new ArgumentOutOfRangeException("data", "Missing required argument"); + throw new ImageKitInvalidDataException( + "'data' cannot be null", + new ArgumentOutOfRangeException("data", "Missing required argument") + ); return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("data"); + ?? throw new ImageKitInvalidDataException( + "'data' cannot be null", + new ArgumentNullException("data") + ); } set { @@ -109,10 +132,16 @@ public required Request Request get { if (!this.Properties.TryGetValue("request", out JsonElement element)) - throw new ArgumentOutOfRangeException("request", "Missing required argument"); + throw new ImageKitInvalidDataException( + "'request' cannot be null", + new ArgumentOutOfRangeException("request", "Missing required argument") + ); return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("request"); + ?? throw new ImageKitInvalidDataException( + "'request' cannot be null", + new ArgumentNullException("request") + ); } set { diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1.cs b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1.cs index 5ad7ffe7..af53cd9d 100644 --- a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1.cs +++ b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1.cs @@ -3,6 +3,8 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; +using Imagekit.Core; +using Imagekit.Exceptions; using Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.IntersectionMember1Properties; namespace Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties; @@ -23,7 +25,10 @@ public required DateTime CreatedAt get { if (!this.Properties.TryGetValue("created_at", out JsonElement element)) - throw new ArgumentOutOfRangeException("created_at", "Missing required argument"); + throw new ImageKitInvalidDataException( + "'created_at' cannot be null", + new ArgumentOutOfRangeException("created_at", "Missing required argument") + ); return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); } @@ -41,10 +46,16 @@ public required Data Data get { if (!this.Properties.TryGetValue("data", out JsonElement element)) - throw new ArgumentOutOfRangeException("data", "Missing required argument"); + throw new ImageKitInvalidDataException( + "'data' cannot be null", + new ArgumentOutOfRangeException("data", "Missing required argument") + ); return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("data"); + ?? throw new ImageKitInvalidDataException( + "'data' cannot be null", + new ArgumentNullException("data") + ); } set { @@ -63,10 +74,16 @@ public required Request Request get { if (!this.Properties.TryGetValue("request", out JsonElement element)) - throw new ArgumentOutOfRangeException("request", "Missing required argument"); + throw new ImageKitInvalidDataException( + "'request' cannot be null", + new ArgumentOutOfRangeException("request", "Missing required argument") + ); return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("request"); + ?? throw new ImageKitInvalidDataException( + "'request' cannot be null", + new ArgumentNullException("request") + ); } set { @@ -82,7 +99,10 @@ public JsonElement Type get { if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); + throw new ImageKitInvalidDataException( + "'type' cannot be null", + new ArgumentOutOfRangeException("type", "Missing required argument") + ); return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); } diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/Data.cs b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/Data.cs index d28eb91a..cfb5ce1a 100644 --- a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/Data.cs +++ b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/Data.cs @@ -1,84 +1,84 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using DataProperties = Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.DataProperties; - -namespace Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Data : ModelBase, IFromRaw -{ - /// - /// Information about the source video asset being transformed. - /// - public required DataProperties::Asset Asset - { - get - { - if (!this.Properties.TryGetValue("asset", out JsonElement element)) - throw new ArgumentOutOfRangeException("asset", "Missing required argument"); - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ) ?? throw new ArgumentNullException("asset"); - } - set - { - this.Properties["asset"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Base information about a video transformation request. - /// - public required DataProperties::Transformation Transformation - { - get - { - if (!this.Properties.TryGetValue("transformation", out JsonElement element)) - throw new ArgumentOutOfRangeException( - "transformation", - "Missing required argument" - ); - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ) ?? throw new ArgumentNullException("transformation"); - } - set - { - this.Properties["transformation"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Asset.Validate(); - this.Transformation.Validate(); - } - - public Data() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Data(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Data FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using DataProperties = Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.DataProperties; + +namespace Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Data : ModelBase, IFromRaw +{ + /// + /// Information about the source video asset being transformed. + /// + public required DataProperties::Asset Asset + { + get + { + if (!this.Properties.TryGetValue("asset", out JsonElement element)) + throw new ArgumentOutOfRangeException("asset", "Missing required argument"); + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ) ?? throw new ArgumentNullException("asset"); + } + set + { + this.Properties["asset"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Base information about a video transformation request. + /// + public required DataProperties::Transformation Transformation + { + get + { + if (!this.Properties.TryGetValue("transformation", out JsonElement element)) + throw new ArgumentOutOfRangeException( + "transformation", + "Missing required argument" + ); + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ) ?? throw new ArgumentNullException("transformation"); + } + set + { + this.Properties["transformation"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.Asset.Validate(); + this.Transformation.Validate(); + } + + public Data() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Data(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Data FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/Asset.cs b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/Asset.cs index f54723b5..fd5e4052 100644 --- a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/Asset.cs +++ b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/Asset.cs @@ -1,63 +1,63 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.DataProperties; - -/// -/// Information about the source video asset being transformed. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class Asset : ModelBase, IFromRaw -{ - /// - /// URL to download or access the source video file. - /// - public required string URL - { - get - { - if (!this.Properties.TryGetValue("url", out JsonElement element)) - throw new ArgumentOutOfRangeException("url", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("url"); - } - set - { - this.Properties["url"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.URL; - } - - public Asset() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Asset(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Asset FromRawUnchecked(Dictionary properties) - { - return new(properties); - } - - [SetsRequiredMembers] - public Asset(string url) - : this() - { - this.URL = url; - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.DataProperties; + +/// +/// Information about the source video asset being transformed. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class Asset : ModelBase, IFromRaw +{ + /// + /// URL to download or access the source video file. + /// + public required string URL + { + get + { + if (!this.Properties.TryGetValue("url", out JsonElement element)) + throw new ArgumentOutOfRangeException("url", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("url"); + } + set + { + this.Properties["url"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.URL; + } + + public Asset() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Asset(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Asset FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public Asset(string url) + : this() + { + this.URL = url; + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs index 24e72bab..7c5b2209 100644 --- a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs +++ b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs @@ -1,93 +1,93 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using TransformationProperties = Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.DataProperties.TransformationProperties; - -namespace Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.DataProperties; - -/// -/// Base information about a video transformation request. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class Transformation : ModelBase, IFromRaw -{ - /// - /// Type of video transformation: - `video-transformation`: Standard video processing - /// (resize, format conversion, etc.) - `gif-to-video`: Convert animated GIF to - /// video format - `video-thumbnail`: Generate thumbnail image from video - /// - public required ApiEnum Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Configuration options for video transformations. - /// - public TransformationProperties::Options? Options - { - get - { - if (!this.Properties.TryGetValue("options", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["options"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Type.Validate(); - this.Options?.Validate(); - } - - public Transformation() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Transformation(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Transformation FromRawUnchecked(Dictionary properties) - { - return new(properties); - } - - [SetsRequiredMembers] - public Transformation(ApiEnum type) - : this() - { - this.Type = type; - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using TransformationProperties = Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.DataProperties.TransformationProperties; + +namespace Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.DataProperties; + +/// +/// Base information about a video transformation request. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class Transformation : ModelBase, IFromRaw +{ + /// + /// Type of video transformation: - `video-transformation`: Standard video processing + /// (resize, format conversion, etc.) - `gif-to-video`: Convert animated GIF to + /// video format - `video-thumbnail`: Generate thumbnail image from video + /// + public required ApiEnum Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Configuration options for video transformations. + /// + public TransformationProperties::Options? Options + { + get + { + if (!this.Properties.TryGetValue("options", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["options"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.Type.Validate(); + this.Options?.Validate(); + } + + public Transformation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Transformation(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Transformation FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public Transformation(ApiEnum type) + : this() + { + this.Type = type; + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/Request.cs b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/Request.cs index 28c0f652..6ed7b7c9 100644 --- a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/Request.cs +++ b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/Request.cs @@ -1,101 +1,101 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties; - -/// -/// Information about the original request that triggered the video transformation. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class Request : ModelBase, IFromRaw -{ - /// - /// Full URL of the transformation request that was submitted. - /// - public required string URL - { - get - { - if (!this.Properties.TryGetValue("url", out JsonElement element)) - throw new ArgumentOutOfRangeException("url", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("url"); - } - set - { - this.Properties["url"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Unique identifier for the originating transformation request. - /// - public required string XRequestID - { - get - { - if (!this.Properties.TryGetValue("x_request_id", out JsonElement element)) - throw new ArgumentOutOfRangeException("x_request_id", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("x_request_id"); - } - set - { - this.Properties["x_request_id"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// User-Agent header from the original request that triggered the transformation. - /// - public string? UserAgent - { - get - { - if (!this.Properties.TryGetValue("user_agent", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["user_agent"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.URL; - _ = this.XRequestID; - _ = this.UserAgent; - } - - public Request() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Request(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Request FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties; + +/// +/// Information about the original request that triggered the video transformation. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class Request : ModelBase, IFromRaw +{ + /// + /// Full URL of the transformation request that was submitted. + /// + public required string URL + { + get + { + if (!this.Properties.TryGetValue("url", out JsonElement element)) + throw new ArgumentOutOfRangeException("url", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("url"); + } + set + { + this.Properties["url"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Unique identifier for the originating transformation request. + /// + public required string XRequestID + { + get + { + if (!this.Properties.TryGetValue("x_request_id", out JsonElement element)) + throw new ArgumentOutOfRangeException("x_request_id", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("x_request_id"); + } + set + { + this.Properties["x_request_id"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// User-Agent header from the original request that triggered the transformation. + /// + public string? UserAgent + { + get + { + if (!this.Properties.TryGetValue("user_agent", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["user_agent"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.URL; + _ = this.XRequestID; + _ = this.UserAgent; + } + + public Request() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Request(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Request FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEvent.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEvent.cs index 111ff2cc..65008586 100644 --- a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEvent.cs +++ b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEvent.cs @@ -3,6 +3,8 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; +using Imagekit.Core; +using Imagekit.Exceptions; using Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.IntersectionMember1Properties; namespace Imagekit.Models.Webhooks; @@ -26,10 +28,16 @@ public required string ID get { if (!this.Properties.TryGetValue("id", out JsonElement element)) - throw new ArgumentOutOfRangeException("id", "Missing required argument"); + throw new ImageKitInvalidDataException( + "'id' cannot be null", + new ArgumentOutOfRangeException("id", "Missing required argument") + ); return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("id"); + ?? throw new ImageKitInvalidDataException( + "'id' cannot be null", + new ArgumentNullException("id") + ); } set { @@ -48,10 +56,16 @@ public required string Type get { if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); + throw new ImageKitInvalidDataException( + "'type' cannot be null", + new ArgumentOutOfRangeException("type", "Missing required argument") + ); return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("type"); + ?? throw new ImageKitInvalidDataException( + "'type' cannot be null", + new ArgumentNullException("type") + ); } set { @@ -70,7 +84,10 @@ public required DateTime CreatedAt get { if (!this.Properties.TryGetValue("created_at", out JsonElement element)) - throw new ArgumentOutOfRangeException("created_at", "Missing required argument"); + throw new ImageKitInvalidDataException( + "'created_at' cannot be null", + new ArgumentOutOfRangeException("created_at", "Missing required argument") + ); return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); } @@ -88,10 +105,16 @@ public required Data Data get { if (!this.Properties.TryGetValue("data", out JsonElement element)) - throw new ArgumentOutOfRangeException("data", "Missing required argument"); + throw new ImageKitInvalidDataException( + "'data' cannot be null", + new ArgumentOutOfRangeException("data", "Missing required argument") + ); return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("data"); + ?? throw new ImageKitInvalidDataException( + "'data' cannot be null", + new ArgumentNullException("data") + ); } set { @@ -110,10 +133,16 @@ public required Request Request get { if (!this.Properties.TryGetValue("request", out JsonElement element)) - throw new ArgumentOutOfRangeException("request", "Missing required argument"); + throw new ImageKitInvalidDataException( + "'request' cannot be null", + new ArgumentOutOfRangeException("request", "Missing required argument") + ); return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("request"); + ?? throw new ImageKitInvalidDataException( + "'request' cannot be null", + new ArgumentNullException("request") + ); } set { diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1.cs index f09b6c0a..778dcbed 100644 --- a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1.cs +++ b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1.cs @@ -3,6 +3,8 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; +using Imagekit.Core; +using Imagekit.Exceptions; using Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.IntersectionMember1Properties; namespace Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties; @@ -24,7 +26,10 @@ public required DateTime CreatedAt get { if (!this.Properties.TryGetValue("created_at", out JsonElement element)) - throw new ArgumentOutOfRangeException("created_at", "Missing required argument"); + throw new ImageKitInvalidDataException( + "'created_at' cannot be null", + new ArgumentOutOfRangeException("created_at", "Missing required argument") + ); return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); } @@ -42,10 +47,16 @@ public required Data Data get { if (!this.Properties.TryGetValue("data", out JsonElement element)) - throw new ArgumentOutOfRangeException("data", "Missing required argument"); + throw new ImageKitInvalidDataException( + "'data' cannot be null", + new ArgumentOutOfRangeException("data", "Missing required argument") + ); return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("data"); + ?? throw new ImageKitInvalidDataException( + "'data' cannot be null", + new ArgumentNullException("data") + ); } set { @@ -64,10 +75,16 @@ public required Request Request get { if (!this.Properties.TryGetValue("request", out JsonElement element)) - throw new ArgumentOutOfRangeException("request", "Missing required argument"); + throw new ImageKitInvalidDataException( + "'request' cannot be null", + new ArgumentOutOfRangeException("request", "Missing required argument") + ); return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("request"); + ?? throw new ImageKitInvalidDataException( + "'request' cannot be null", + new ArgumentNullException("request") + ); } set { @@ -83,7 +100,10 @@ public JsonElement Type get { if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); + throw new ImageKitInvalidDataException( + "'type' cannot be null", + new ArgumentOutOfRangeException("type", "Missing required argument") + ); return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); } diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/Data.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/Data.cs index 92ae506e..f43d5aa1 100644 --- a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/Data.cs +++ b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/Data.cs @@ -1,81 +1,81 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using DataProperties = Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.DataProperties; - -namespace Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Data : ModelBase, IFromRaw -{ - /// - /// Information about the source video asset being transformed. - /// - public required DataProperties::Asset Asset - { - get - { - if (!this.Properties.TryGetValue("asset", out JsonElement element)) - throw new ArgumentOutOfRangeException("asset", "Missing required argument"); - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ) ?? throw new ArgumentNullException("asset"); - } - set - { - this.Properties["asset"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required DataProperties::Transformation Transformation - { - get - { - if (!this.Properties.TryGetValue("transformation", out JsonElement element)) - throw new ArgumentOutOfRangeException( - "transformation", - "Missing required argument" - ); - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ) ?? throw new ArgumentNullException("transformation"); - } - set - { - this.Properties["transformation"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Asset.Validate(); - this.Transformation.Validate(); - } - - public Data() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Data(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Data FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using DataProperties = Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.DataProperties; + +namespace Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Data : ModelBase, IFromRaw +{ + /// + /// Information about the source video asset being transformed. + /// + public required DataProperties::Asset Asset + { + get + { + if (!this.Properties.TryGetValue("asset", out JsonElement element)) + throw new ArgumentOutOfRangeException("asset", "Missing required argument"); + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ) ?? throw new ArgumentNullException("asset"); + } + set + { + this.Properties["asset"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required DataProperties::Transformation Transformation + { + get + { + if (!this.Properties.TryGetValue("transformation", out JsonElement element)) + throw new ArgumentOutOfRangeException( + "transformation", + "Missing required argument" + ); + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ) ?? throw new ArgumentNullException("transformation"); + } + set + { + this.Properties["transformation"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.Asset.Validate(); + this.Transformation.Validate(); + } + + public Data() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Data(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Data FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/Asset.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/Asset.cs index 31f10dbe..442afbf4 100644 --- a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/Asset.cs +++ b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/Asset.cs @@ -1,63 +1,63 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.DataProperties; - -/// -/// Information about the source video asset being transformed. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class Asset : ModelBase, IFromRaw -{ - /// - /// URL to download or access the source video file. - /// - public required string URL - { - get - { - if (!this.Properties.TryGetValue("url", out JsonElement element)) - throw new ArgumentOutOfRangeException("url", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("url"); - } - set - { - this.Properties["url"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.URL; - } - - public Asset() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Asset(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Asset FromRawUnchecked(Dictionary properties) - { - return new(properties); - } - - [SetsRequiredMembers] - public Asset(string url) - : this() - { - this.URL = url; - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.DataProperties; + +/// +/// Information about the source video asset being transformed. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class Asset : ModelBase, IFromRaw +{ + /// + /// URL to download or access the source video file. + /// + public required string URL + { + get + { + if (!this.Properties.TryGetValue("url", out JsonElement element)) + throw new ArgumentOutOfRangeException("url", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("url"); + } + set + { + this.Properties["url"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.URL; + } + + public Asset() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Asset(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Asset FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public Asset(string url) + : this() + { + this.URL = url; + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs index 99f6feee..ad5cd3d6 100644 --- a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs +++ b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs @@ -1,115 +1,115 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using TransformationProperties = Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.DataProperties.TransformationProperties; - -namespace Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.DataProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Transformation : ModelBase, IFromRaw -{ - /// - /// Type of video transformation: - `video-transformation`: Standard video processing - /// (resize, format conversion, etc.) - `gif-to-video`: Convert animated GIF to - /// video format - `video-thumbnail`: Generate thumbnail image from video - /// - public required ApiEnum Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Details about the transformation error. - /// - public TransformationProperties::Error? Error - { - get - { - if (!this.Properties.TryGetValue("error", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["error"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Configuration options for video transformations. - /// - public TransformationProperties::Options? Options - { - get - { - if (!this.Properties.TryGetValue("options", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["options"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Type.Validate(); - this.Error?.Validate(); - this.Options?.Validate(); - } - - public Transformation() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Transformation(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Transformation FromRawUnchecked(Dictionary properties) - { - return new(properties); - } - - [SetsRequiredMembers] - public Transformation(ApiEnum type) - : this() - { - this.Type = type; - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using TransformationProperties = Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.DataProperties.TransformationProperties; + +namespace Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.DataProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Transformation : ModelBase, IFromRaw +{ + /// + /// Type of video transformation: - `video-transformation`: Standard video processing + /// (resize, format conversion, etc.) - `gif-to-video`: Convert animated GIF to + /// video format - `video-thumbnail`: Generate thumbnail image from video + /// + public required ApiEnum Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Details about the transformation error. + /// + public TransformationProperties::Error? Error + { + get + { + if (!this.Properties.TryGetValue("error", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["error"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Configuration options for video transformations. + /// + public TransformationProperties::Options? Options + { + get + { + if (!this.Properties.TryGetValue("options", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["options"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.Type.Validate(); + this.Error?.Validate(); + this.Options?.Validate(); + } + + public Transformation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Transformation(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Transformation FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public Transformation(ApiEnum type) + : this() + { + this.Type = type; + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/Request.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/Request.cs index 74ac3484..f18d4bde 100644 --- a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/Request.cs +++ b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/Request.cs @@ -1,101 +1,101 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties; - -/// -/// Information about the original request that triggered the video transformation. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class Request : ModelBase, IFromRaw -{ - /// - /// Full URL of the transformation request that was submitted. - /// - public required string URL - { - get - { - if (!this.Properties.TryGetValue("url", out JsonElement element)) - throw new ArgumentOutOfRangeException("url", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("url"); - } - set - { - this.Properties["url"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Unique identifier for the originating transformation request. - /// - public required string XRequestID - { - get - { - if (!this.Properties.TryGetValue("x_request_id", out JsonElement element)) - throw new ArgumentOutOfRangeException("x_request_id", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("x_request_id"); - } - set - { - this.Properties["x_request_id"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// User-Agent header from the original request that triggered the transformation. - /// - public string? UserAgent - { - get - { - if (!this.Properties.TryGetValue("user_agent", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["user_agent"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.URL; - _ = this.XRequestID; - _ = this.UserAgent; - } - - public Request() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Request(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Request FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties; + +/// +/// Information about the original request that triggered the video transformation. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class Request : ModelBase, IFromRaw +{ + /// + /// Full URL of the transformation request that was submitted. + /// + public required string URL + { + get + { + if (!this.Properties.TryGetValue("url", out JsonElement element)) + throw new ArgumentOutOfRangeException("url", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("url"); + } + set + { + this.Properties["url"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Unique identifier for the originating transformation request. + /// + public required string XRequestID + { + get + { + if (!this.Properties.TryGetValue("x_request_id", out JsonElement element)) + throw new ArgumentOutOfRangeException("x_request_id", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("x_request_id"); + } + set + { + this.Properties["x_request_id"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// User-Agent header from the original request that triggered the transformation. + /// + public string? UserAgent + { + get + { + if (!this.Properties.TryGetValue("user_agent", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["user_agent"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.URL; + _ = this.XRequestID; + _ = this.UserAgent; + } + + public Request() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Request(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Request FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEvent.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEvent.cs index 68b4823c..25bba269 100644 --- a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEvent.cs +++ b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEvent.cs @@ -3,6 +3,8 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; +using Imagekit.Core; +using Imagekit.Exceptions; using Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.IntersectionMember1Properties; namespace Imagekit.Models.Webhooks; @@ -26,10 +28,16 @@ public required string ID get { if (!this.Properties.TryGetValue("id", out JsonElement element)) - throw new ArgumentOutOfRangeException("id", "Missing required argument"); + throw new ImageKitInvalidDataException( + "'id' cannot be null", + new ArgumentOutOfRangeException("id", "Missing required argument") + ); return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("id"); + ?? throw new ImageKitInvalidDataException( + "'id' cannot be null", + new ArgumentNullException("id") + ); } set { @@ -48,10 +56,16 @@ public required string Type get { if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); + throw new ImageKitInvalidDataException( + "'type' cannot be null", + new ArgumentOutOfRangeException("type", "Missing required argument") + ); return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("type"); + ?? throw new ImageKitInvalidDataException( + "'type' cannot be null", + new ArgumentNullException("type") + ); } set { @@ -70,7 +84,10 @@ public required DateTime CreatedAt get { if (!this.Properties.TryGetValue("created_at", out JsonElement element)) - throw new ArgumentOutOfRangeException("created_at", "Missing required argument"); + throw new ImageKitInvalidDataException( + "'created_at' cannot be null", + new ArgumentOutOfRangeException("created_at", "Missing required argument") + ); return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); } @@ -88,10 +105,16 @@ public required Data Data get { if (!this.Properties.TryGetValue("data", out JsonElement element)) - throw new ArgumentOutOfRangeException("data", "Missing required argument"); + throw new ImageKitInvalidDataException( + "'data' cannot be null", + new ArgumentOutOfRangeException("data", "Missing required argument") + ); return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("data"); + ?? throw new ImageKitInvalidDataException( + "'data' cannot be null", + new ArgumentNullException("data") + ); } set { @@ -110,10 +133,16 @@ public required Request Request get { if (!this.Properties.TryGetValue("request", out JsonElement element)) - throw new ArgumentOutOfRangeException("request", "Missing required argument"); + throw new ImageKitInvalidDataException( + "'request' cannot be null", + new ArgumentOutOfRangeException("request", "Missing required argument") + ); return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("request"); + ?? throw new ImageKitInvalidDataException( + "'request' cannot be null", + new ArgumentNullException("request") + ); } set { diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1.cs index c8f14e2c..263c0fc8 100644 --- a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1.cs +++ b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1.cs @@ -3,6 +3,8 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; +using Imagekit.Core; +using Imagekit.Exceptions; using Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.IntersectionMember1Properties; namespace Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties; @@ -24,7 +26,10 @@ public required DateTime CreatedAt get { if (!this.Properties.TryGetValue("created_at", out JsonElement element)) - throw new ArgumentOutOfRangeException("created_at", "Missing required argument"); + throw new ImageKitInvalidDataException( + "'created_at' cannot be null", + new ArgumentOutOfRangeException("created_at", "Missing required argument") + ); return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); } @@ -42,10 +47,16 @@ public required Data Data get { if (!this.Properties.TryGetValue("data", out JsonElement element)) - throw new ArgumentOutOfRangeException("data", "Missing required argument"); + throw new ImageKitInvalidDataException( + "'data' cannot be null", + new ArgumentOutOfRangeException("data", "Missing required argument") + ); return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("data"); + ?? throw new ImageKitInvalidDataException( + "'data' cannot be null", + new ArgumentNullException("data") + ); } set { @@ -64,10 +75,16 @@ public required Request Request get { if (!this.Properties.TryGetValue("request", out JsonElement element)) - throw new ArgumentOutOfRangeException("request", "Missing required argument"); + throw new ImageKitInvalidDataException( + "'request' cannot be null", + new ArgumentOutOfRangeException("request", "Missing required argument") + ); return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("request"); + ?? throw new ImageKitInvalidDataException( + "'request' cannot be null", + new ArgumentNullException("request") + ); } set { @@ -83,7 +100,10 @@ public JsonElement Type get { if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); + throw new ImageKitInvalidDataException( + "'type' cannot be null", + new ArgumentOutOfRangeException("type", "Missing required argument") + ); return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); } diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/Data.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/Data.cs index 9d7c11dd..af2b0005 100644 --- a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/Data.cs +++ b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/Data.cs @@ -1,81 +1,81 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using DataProperties = Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.IntersectionMember1Properties.DataProperties; - -namespace Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.IntersectionMember1Properties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Data : ModelBase, IFromRaw -{ - /// - /// Information about the source video asset being transformed. - /// - public required DataProperties::Asset Asset - { - get - { - if (!this.Properties.TryGetValue("asset", out JsonElement element)) - throw new ArgumentOutOfRangeException("asset", "Missing required argument"); - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ) ?? throw new ArgumentNullException("asset"); - } - set - { - this.Properties["asset"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required DataProperties::Transformation Transformation - { - get - { - if (!this.Properties.TryGetValue("transformation", out JsonElement element)) - throw new ArgumentOutOfRangeException( - "transformation", - "Missing required argument" - ); - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ) ?? throw new ArgumentNullException("transformation"); - } - set - { - this.Properties["transformation"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Asset.Validate(); - this.Transformation.Validate(); - } - - public Data() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Data(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Data FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using DataProperties = Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.IntersectionMember1Properties.DataProperties; + +namespace Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.IntersectionMember1Properties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Data : ModelBase, IFromRaw +{ + /// + /// Information about the source video asset being transformed. + /// + public required DataProperties::Asset Asset + { + get + { + if (!this.Properties.TryGetValue("asset", out JsonElement element)) + throw new ArgumentOutOfRangeException("asset", "Missing required argument"); + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ) ?? throw new ArgumentNullException("asset"); + } + set + { + this.Properties["asset"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public required DataProperties::Transformation Transformation + { + get + { + if (!this.Properties.TryGetValue("transformation", out JsonElement element)) + throw new ArgumentOutOfRangeException( + "transformation", + "Missing required argument" + ); + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ) ?? throw new ArgumentNullException("transformation"); + } + set + { + this.Properties["transformation"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.Asset.Validate(); + this.Transformation.Validate(); + } + + public Data() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Data(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Data FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/Asset.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/Asset.cs index 0859135a..3644c1f7 100644 --- a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/Asset.cs +++ b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/Asset.cs @@ -1,63 +1,63 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties; - -/// -/// Information about the source video asset being transformed. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class Asset : ModelBase, IFromRaw -{ - /// - /// URL to download or access the source video file. - /// - public required string URL - { - get - { - if (!this.Properties.TryGetValue("url", out JsonElement element)) - throw new ArgumentOutOfRangeException("url", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("url"); - } - set - { - this.Properties["url"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.URL; - } - - public Asset() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Asset(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Asset FromRawUnchecked(Dictionary properties) - { - return new(properties); - } - - [SetsRequiredMembers] - public Asset(string url) - : this() - { - this.URL = url; - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties; + +/// +/// Information about the source video asset being transformed. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class Asset : ModelBase, IFromRaw +{ + /// + /// URL to download or access the source video file. + /// + public required string URL + { + get + { + if (!this.Properties.TryGetValue("url", out JsonElement element)) + throw new ArgumentOutOfRangeException("url", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("url"); + } + set + { + this.Properties["url"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.URL; + } + + public Asset() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Asset(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Asset FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public Asset(string url) + : this() + { + this.URL = url; + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs index 3c0c8315..c68bf310 100644 --- a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs +++ b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs @@ -1,115 +1,115 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using TransformationProperties = Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties.TransformationProperties; - -namespace Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Transformation : ModelBase, IFromRaw -{ - /// - /// Type of video transformation: - `video-transformation`: Standard video processing - /// (resize, format conversion, etc.) - `gif-to-video`: Convert animated GIF to - /// video format - `video-thumbnail`: Generate thumbnail image from video - /// - public required ApiEnum Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Configuration options for video transformations. - /// - public TransformationProperties::Options? Options - { - get - { - if (!this.Properties.TryGetValue("options", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["options"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Information about the transformed output video. - /// - public TransformationProperties::Output? Output - { - get - { - if (!this.Properties.TryGetValue("output", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["output"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Type.Validate(); - this.Options?.Validate(); - this.Output?.Validate(); - } - - public Transformation() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Transformation(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Transformation FromRawUnchecked(Dictionary properties) - { - return new(properties); - } - - [SetsRequiredMembers] - public Transformation(ApiEnum type) - : this() - { - this.Type = type; - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using TransformationProperties = Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties.TransformationProperties; + +namespace Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Transformation : ModelBase, IFromRaw +{ + /// + /// Type of video transformation: - `video-transformation`: Standard video processing + /// (resize, format conversion, etc.) - `gif-to-video`: Convert animated GIF to + /// video format - `video-thumbnail`: Generate thumbnail image from video + /// + public required ApiEnum Type + { + get + { + if (!this.Properties.TryGetValue("type", out JsonElement element)) + throw new ArgumentOutOfRangeException("type", "Missing required argument"); + + return JsonSerializer.Deserialize>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["type"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Configuration options for video transformations. + /// + public TransformationProperties::Options? Options + { + get + { + if (!this.Properties.TryGetValue("options", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["options"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Information about the transformed output video. + /// + public TransformationProperties::Output? Output + { + get + { + if (!this.Properties.TryGetValue("output", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["output"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.Type.Validate(); + this.Options?.Validate(); + this.Output?.Validate(); + } + + public Transformation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Transformation(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Transformation FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public Transformation(ApiEnum type) + : this() + { + this.Type = type; + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Output.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Output.cs index ddcbfa27..9b2d5adf 100644 --- a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Output.cs +++ b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Output.cs @@ -1,86 +1,86 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties.TransformationProperties.OutputProperties; -using System = System; - -namespace Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties.TransformationProperties; - -/// -/// Information about the transformed output video. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class Output : ModelBase, IFromRaw -{ - /// - /// URL to access the transformed video. - /// - public required string URL - { - get - { - if (!this.Properties.TryGetValue("url", out JsonElement element)) - throw new System::ArgumentOutOfRangeException("url", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new System::ArgumentNullException("url"); - } - set - { - this.Properties["url"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Metadata of the output video file. - /// - public VideoMetadata? VideoMetadata - { - get - { - if (!this.Properties.TryGetValue("video_metadata", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["video_metadata"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.URL; - this.VideoMetadata?.Validate(); - } - - public Output() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Output(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Output FromRawUnchecked(Dictionary properties) - { - return new(properties); - } - - [SetsRequiredMembers] - public Output(string url) - : this() - { - this.URL = url; - } -} +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties.TransformationProperties.OutputProperties; +using System = System; + +namespace Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties.TransformationProperties; + +/// +/// Information about the transformed output video. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class Output : ModelBase, IFromRaw +{ + /// + /// URL to access the transformed video. + /// + public required string URL + { + get + { + if (!this.Properties.TryGetValue("url", out JsonElement element)) + throw new System::ArgumentOutOfRangeException("url", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new System::ArgumentNullException("url"); + } + set + { + this.Properties["url"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Metadata of the output video file. + /// + public VideoMetadata? VideoMetadata + { + get + { + if (!this.Properties.TryGetValue("video_metadata", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["video_metadata"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.URL; + this.VideoMetadata?.Validate(); + } + + public Output() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Output(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Output FromRawUnchecked(Dictionary properties) + { + return new(properties); + } + + [SetsRequiredMembers] + public Output(string url) + : this() + { + this.URL = url; + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OutputProperties/VideoMetadata.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OutputProperties/VideoMetadata.cs index 60f5f015..32d2e85e 100644 --- a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OutputProperties/VideoMetadata.cs +++ b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OutputProperties/VideoMetadata.cs @@ -1,121 +1,121 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties.TransformationProperties.OutputProperties; - -/// -/// Metadata of the output video file. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class VideoMetadata : ModelBase, IFromRaw -{ - /// - /// Bitrate of the output video in bits per second. - /// - public required long Bitrate - { - get - { - if (!this.Properties.TryGetValue("bitrate", out JsonElement element)) - throw new ArgumentOutOfRangeException("bitrate", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["bitrate"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Duration of the output video in seconds. - /// - public required double Duration - { - get - { - if (!this.Properties.TryGetValue("duration", out JsonElement element)) - throw new ArgumentOutOfRangeException("duration", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["duration"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Height of the output video in pixels. - /// - public required long Height - { - get - { - if (!this.Properties.TryGetValue("height", out JsonElement element)) - throw new ArgumentOutOfRangeException("height", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["height"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Width of the output video in pixels. - /// - public required long Width - { - get - { - if (!this.Properties.TryGetValue("width", out JsonElement element)) - throw new ArgumentOutOfRangeException("width", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["width"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.Bitrate; - _ = this.Duration; - _ = this.Height; - _ = this.Width; - } - - public VideoMetadata() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - VideoMetadata(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static VideoMetadata FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties.TransformationProperties.OutputProperties; + +/// +/// Metadata of the output video file. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class VideoMetadata : ModelBase, IFromRaw +{ + /// + /// Bitrate of the output video in bits per second. + /// + public required long Bitrate + { + get + { + if (!this.Properties.TryGetValue("bitrate", out JsonElement element)) + throw new ArgumentOutOfRangeException("bitrate", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["bitrate"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Duration of the output video in seconds. + /// + public required double Duration + { + get + { + if (!this.Properties.TryGetValue("duration", out JsonElement element)) + throw new ArgumentOutOfRangeException("duration", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["duration"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Height of the output video in pixels. + /// + public required long Height + { + get + { + if (!this.Properties.TryGetValue("height", out JsonElement element)) + throw new ArgumentOutOfRangeException("height", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["height"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Width of the output video in pixels. + /// + public required long Width + { + get + { + if (!this.Properties.TryGetValue("width", out JsonElement element)) + throw new ArgumentOutOfRangeException("width", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["width"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.Bitrate; + _ = this.Duration; + _ = this.Height; + _ = this.Width; + } + + public VideoMetadata() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + VideoMetadata(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static VideoMetadata FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/Request.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/Request.cs index 2de96a55..b22d60ea 100644 --- a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/Request.cs +++ b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/Request.cs @@ -1,101 +1,101 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties; - -/// -/// Information about the original request that triggered the video transformation. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class Request : ModelBase, IFromRaw -{ - /// - /// Full URL of the transformation request that was submitted. - /// - public required string URL - { - get - { - if (!this.Properties.TryGetValue("url", out JsonElement element)) - throw new ArgumentOutOfRangeException("url", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("url"); - } - set - { - this.Properties["url"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Unique identifier for the originating transformation request. - /// - public required string XRequestID - { - get - { - if (!this.Properties.TryGetValue("x_request_id", out JsonElement element)) - throw new ArgumentOutOfRangeException("x_request_id", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("x_request_id"); - } - set - { - this.Properties["x_request_id"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// User-Agent header from the original request that triggered the transformation. - /// - public string? UserAgent - { - get - { - if (!this.Properties.TryGetValue("user_agent", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["user_agent"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.URL; - _ = this.XRequestID; - _ = this.UserAgent; - } - - public Request() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Request(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Request FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties; + +/// +/// Information about the original request that triggered the video transformation. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class Request : ModelBase, IFromRaw +{ + /// + /// Full URL of the transformation request that was submitted. + /// + public required string URL + { + get + { + if (!this.Properties.TryGetValue("url", out JsonElement element)) + throw new ArgumentOutOfRangeException("url", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("url"); + } + set + { + this.Properties["url"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Unique identifier for the originating transformation request. + /// + public required string XRequestID + { + get + { + if (!this.Properties.TryGetValue("x_request_id", out JsonElement element)) + throw new ArgumentOutOfRangeException("x_request_id", "Missing required argument"); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ArgumentNullException("x_request_id"); + } + set + { + this.Properties["x_request_id"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// User-Agent header from the original request that triggered the transformation. + /// + public string? UserAgent + { + get + { + if (!this.Properties.TryGetValue("user_agent", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["user_agent"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.URL; + _ = this.XRequestID; + _ = this.UserAgent; + } + + public Request() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Request(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Request FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} From 29ee45db5046c5ba5dcf2518b8940901831d2ccc Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 28 Jan 2026 18:18:40 +0000 Subject: [PATCH 040/129] fix(internal): build fixes --- src/Imagekit/Models/StreamingResolution.cs | 133 +++++++++++---------- 1 file changed, 68 insertions(+), 65 deletions(-) diff --git a/src/Imagekit/Models/StreamingResolution.cs b/src/Imagekit/Models/StreamingResolution.cs index b6978e9e..66591680 100644 --- a/src/Imagekit/Models/StreamingResolution.cs +++ b/src/Imagekit/Models/StreamingResolution.cs @@ -1,65 +1,68 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models; - -/// -/// Available streaming resolutions for [adaptive bitrate streaming](https://imagekit.io/docs/adaptive-bitrate-streaming) -/// -[JsonConverter(typeof(StreamingResolutionConverter))] -public enum StreamingResolution -{ - v240, - v360, - v480, - v720, - v1080, - v1440, - v2160, -} - -sealed class StreamingResolutionConverter : JsonConverter -{ - public override StreamingResolution Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "240" => StreamingResolution.v240, - "360" => StreamingResolution.v360, - "480" => StreamingResolution.v480, - "720" => StreamingResolution.v720, - "1080" => StreamingResolution.v1080, - "1440" => StreamingResolution.v1440, - "2160" => StreamingResolution.v2160, - _ => (StreamingResolution)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - StreamingResolution value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - StreamingResolution.v240 => "240", - StreamingResolution.v360 => "360", - StreamingResolution.v480 => "480", - StreamingResolution.v720 => "720", - StreamingResolution.v1080 => "1080", - StreamingResolution.v1440 => "1440", - StreamingResolution.v2160 => "2160", - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} +using System; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; + +namespace Imagekit.Models; + +/// +/// Available streaming resolutions for [adaptive bitrate streaming](https://imagekit.io/docs/adaptive-bitrate-streaming) +/// +[JsonConverter(typeof(StreamingResolutionConverter))] +public enum StreamingResolution +{ + V240, + V360, + V480, + V720, + V1080, + V1440, + V2160, +} + +sealed class StreamingResolutionConverter : JsonConverter +{ + public override StreamingResolution Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "240" => StreamingResolution.V240, + "360" => StreamingResolution.V360, + "480" => StreamingResolution.V480, + "720" => StreamingResolution.V720, + "1080" => StreamingResolution.V1080, + "1440" => StreamingResolution.V1440, + "2160" => StreamingResolution.V2160, + _ => (StreamingResolution)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + StreamingResolution value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + StreamingResolution.V240 => "240", + StreamingResolution.V360 => "360", + StreamingResolution.V480 => "480", + StreamingResolution.V720 => "720", + StreamingResolution.V1080 => "1080", + StreamingResolution.V1440 => "1440", + StreamingResolution.V2160 => "2160", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} From 0079482ed996fb0a98bdf1f67fe0cd5f3b6e51d0 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 2 Oct 2025 15:32:46 +0000 Subject: [PATCH 041/129] feat(internal): add dev container --- .devcontainer/devcontainer.json | 8 ++++++++ .vscode/extensions.json | 10 ++++++++++ 2 files changed, 18 insertions(+) create mode 100644 .devcontainer/devcontainer.json create mode 100644 .vscode/extensions.json diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..a503ddd5 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,8 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/dotnet +{ + "name": "C# (.NET)", + "image": "mcr.microsoft.com/devcontainers/dotnet:1-9.0-noble", + "postAttachCommand": "cat .vscode/extensions.json | jq -r .recommendations[] | xargs -n 1 code --install-extension", + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}" +} diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 00000000..921dd6d6 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,10 @@ +{ + "recommendations": [ + "ms-dotnettools.csharp", + "editorconfig.editorconfig", + "github.vscode-github-actions", + "ms-dotnettools.vscode-dotnet-runtime", + "ms-dotnettools.csdevkit" + ], + "unwantedRecommendations": [] +} From abe956872d0ec9a94492dbd95c1799a356a3c709 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 3 Oct 2025 07:36:13 +0000 Subject: [PATCH 042/129] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 0c9c486c..90e53979 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-01aef94bd928f40b7209dc21df71e2312d4bee430119b30ee05d75cf5e1b4801.yml openapi_spec_hash: 054c332db88b23d362f72583dd24b2aa -config_hash: e42d7fc3a8c92c35099cc283f9a4467a +config_hash: 371b1694848e02828dd8db3265557ddf From c94fbdfa889ff7d9949ea41fcbdff74a4fa756eb Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 3 Oct 2025 07:36:31 +0000 Subject: [PATCH 043/129] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 90e53979..bb92027a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-01aef94bd928f40b7209dc21df71e2312d4bee430119b30ee05d75cf5e1b4801.yml openapi_spec_hash: 054c332db88b23d362f72583dd24b2aa -config_hash: 371b1694848e02828dd8db3265557ddf +config_hash: 719e92ff078b4a030a1480b546be0b7a From b556d4d1399183600b6d924b092c2ed4de888d03 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 3 Oct 2025 07:48:06 +0000 Subject: [PATCH 044/129] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index bb92027a..88337313 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-01aef94bd928f40b7209dc21df71e2312d4bee430119b30ee05d75cf5e1b4801.yml openapi_spec_hash: 054c332db88b23d362f72583dd24b2aa -config_hash: 719e92ff078b4a030a1480b546be0b7a +config_hash: cb0b86a64fed7f839bb0ef6568a8ba37 From 2c16359d6752700c1615bbb40e1cd44be6b33304 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 3 Oct 2025 07:50:27 +0000 Subject: [PATCH 045/129] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 88337313..b346bb7b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-01aef94bd928f40b7209dc21df71e2312d4bee430119b30ee05d75cf5e1b4801.yml openapi_spec_hash: 054c332db88b23d362f72583dd24b2aa -config_hash: cb0b86a64fed7f839bb0ef6568a8ba37 +config_hash: f351b784e512ad36eafbc0641ad61183 From 31c92ee67ff8973d649ec41a1eeb577de75a54a3 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 3 Oct 2025 09:21:01 +0000 Subject: [PATCH 046/129] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index b346bb7b..3d1832c1 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-01aef94bd928f40b7209dc21df71e2312d4bee430119b30ee05d75cf5e1b4801.yml openapi_spec_hash: 054c332db88b23d362f72583dd24b2aa -config_hash: f351b784e512ad36eafbc0641ad61183 +config_hash: 8d97605bd07a42f98d8142059b56522c From 6d6e75097c356c77d1c8b7d6f5e8728818a75d66 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 3 Oct 2025 10:02:18 +0000 Subject: [PATCH 047/129] codegen metadata --- .stats.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.stats.yml b/.stats.yml index 3d1832c1..ad4cfbf9 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-01aef94bd928f40b7209dc21df71e2312d4bee430119b30ee05d75cf5e1b4801.yml -openapi_spec_hash: 054c332db88b23d362f72583dd24b2aa -config_hash: 8d97605bd07a42f98d8142059b56522c +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-c7ad6f552b38f2145781847f8b390fa1ec43068d64e45a33012a97a9299edc10.yml +openapi_spec_hash: 50f281e91210ad5018ac7e4eee216f56 +config_hash: 6d15773e29070b9c1d4820e4897f17a5 From 0eef7939f92494ddd6020ccc721c9e8ca9fb52b8 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sun, 5 Oct 2025 13:50:15 +0000 Subject: [PATCH 048/129] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index ad4cfbf9..f035d349 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-c7ad6f552b38f2145781847f8b390fa1ec43068d64e45a33012a97a9299edc10.yml openapi_spec_hash: 50f281e91210ad5018ac7e4eee216f56 -config_hash: 6d15773e29070b9c1d4820e4897f17a5 +config_hash: 74a8263b80c732a2b016177e7d56bb9c From bc48acbdaad71dff524ec71d788988d8120d11bc Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 28 Jan 2026 18:20:46 +0000 Subject: [PATCH 049/129] feat(client): refactor unions --- .../Accounts/Origins/OriginServiceTest.cs | 146 ++++---- .../CustomMetadataFieldServiceTest.cs | 16 +- .../Services/Files/FileServiceTest.cs | 85 ++--- src/Imagekit/Core/ModelBase.cs | 10 +- src/Imagekit/Imagekit.csproj | 3 + .../Models/Accounts/Origins/OriginRequest.cs | 334 ++++++++++++++---- .../OriginRequestProperties/AkeneoPim.cs | 14 +- .../AkeneoPimProperties/Type.cs | 47 +++ .../OriginRequestProperties/AzureBlob.cs | 14 +- .../AzureBlobProperties/Type.cs | 47 +++ .../CloudinaryBackup.cs | 14 +- .../CloudinaryBackupProperties/Type.cs | 47 +++ .../Origins/OriginRequestProperties/Gcs.cs | 14 +- .../GcsProperties/Type.cs | 47 +++ .../Origins/OriginRequestProperties/S3.cs | 14 +- .../OriginRequestProperties/S3Compatible.cs | 14 +- .../S3CompatibleProperties/Type.cs | 47 +++ .../S3Properties/Type.cs | 47 +++ .../OriginRequestProperties/WebFolder.cs | 14 +- .../WebFolderProperties/Type.cs | 47 +++ .../OriginRequestProperties/WebProxy.cs | 14 +- .../WebProxyProperties/Type.cs | 47 +++ .../Models/Accounts/Origins/OriginResponse.cs | 318 +++++++++++++---- .../OriginResponseProperties/AkeneoPim.cs | 14 +- .../AkeneoPimProperties/Type.cs | 47 +++ .../OriginResponseProperties/AzureBlob.cs | 14 +- .../AzureBlobProperties/Type.cs | 47 +++ .../CloudinaryBackup.cs | 14 +- .../CloudinaryBackupProperties/Type.cs | 47 +++ .../Origins/OriginResponseProperties/Gcs.cs | 14 +- .../GcsProperties/Type.cs | 47 +++ .../Origins/OriginResponseProperties/S3.cs | 14 +- .../OriginResponseProperties/S3Compatible.cs | 14 +- .../S3CompatibleProperties/Type.cs | 47 +++ .../S3Properties/Type.cs | 47 +++ .../OriginResponseProperties/WebFolder.cs | 14 +- .../WebFolderProperties/Type.cs | 47 +++ .../OriginResponseProperties/WebProxy.cs | 14 +- .../WebProxyProperties/Type.cs | 47 +++ .../URLRewriter.cs | 106 ++++-- .../URLRewriterProperties/Akamai.cs | 51 +++ .../AkamaiProperties/Type.cs | 47 +++ .../URLRewriterProperties/Cloudinary.cs | 14 +- .../CloudinaryProperties/Type.cs | 47 +++ .../URLRewriterProperties/Imgix.cs | 51 +++ .../ImgixProperties/Type.cs | 47 +++ .../URLRewriter.cs | 106 ++++-- .../URLRewriterProperties/Akamai.cs | 51 +++ .../AkamaiProperties/Type.cs | 47 +++ .../URLRewriterProperties/Cloudinary.cs | 14 +- .../CloudinaryProperties/Type.cs | 47 +++ .../URLRewriterProperties/Imgix.cs | 51 +++ .../ImgixProperties/Type.cs | 47 +++ .../URLRewriter.cs | 106 ++++-- .../URLRewriterProperties/Akamai.cs | 51 +++ .../AkamaiProperties/Type.cs | 47 +++ .../URLRewriterProperties/Cloudinary.cs | 14 +- .../CloudinaryProperties/Type.cs | 47 +++ .../URLRewriterProperties/Imgix.cs | 51 +++ .../ImgixProperties/Type.cs | 47 +++ .../URLRewriter.cs | 106 ++++-- .../URLRewriterProperties/Akamai.cs | 51 +++ .../AkamaiProperties/Type.cs | 47 +++ .../URLRewriterProperties/Cloudinary.cs | 14 +- .../CloudinaryProperties/Type.cs | 47 +++ .../URLRewriterProperties/Imgix.cs | 51 +++ .../ImgixProperties/Type.cs | 47 +++ .../Models/Assets/AssetListResponse.cs | 90 +++-- .../TransformationProperties/Post.cs | 125 ++++--- .../PostProperties/Abs.cs | 18 +- .../PostProperties/AbsProperties/Type.cs | 50 +++ .../PostProperties/GifToVideo.cs | 14 +- .../GifToVideoProperties/Type.cs | 50 +++ .../PostProperties/Thumbnail.cs | 14 +- .../ThumbnailProperties/Type.cs | 50 +++ .../PostProperties/Transformation.cs | 14 +- .../TransformationProperties/Type.cs | 50 +++ .../DefaultValue.cs | 138 +++++--- .../UnnamedSchemaWithArrayParent6.cs | 116 +++--- .../All.cs | 37 -- .../DefaultValueVariants/All.cs | 51 --- .../MaxValue.cs | 80 +++-- .../MaxValueVariants/All.cs | 23 -- .../MinValue.cs | 80 +++-- .../MinValueVariants/All.cs | 23 -- .../SelectOption.cs | 110 +++--- .../SelectOptionVariants/All.cs | 33 -- .../SchemaProperties/DefaultValue.cs | 92 +++-- .../UnnamedSchemaWithArrayParent2.cs | 62 ++-- .../SchemaProperties/MaxValue.cs | 62 +++- .../SchemaProperties/MinValue.cs | 62 +++- .../SchemaProperties/SelectOption.cs | 87 +++-- .../SchemaProperties/DefaultValue.cs | 138 +++++--- .../UnnamedSchemaWithArrayParent1.cs | 93 +++-- .../SchemaProperties/MaxValue.cs | 62 +++- .../SchemaProperties/MinValue.cs | 62 +++- .../SchemaProperties/SelectOption.cs | 87 +++-- .../SchemaProperties/DefaultValue.cs | 99 +++--- .../UnnamedSchemaWithArrayParent3.cs | 22 +- .../SchemaProperties/MaxValue.cs | 70 ++-- .../SchemaProperties/MinValue.cs | 70 ++-- .../SchemaProperties/SelectOption.cs | 94 ++--- .../DefaultValue.cs | 138 +++++--- .../UnnamedSchemaWithArrayParent4.cs | 116 +++--- .../All.cs | 37 -- .../DefaultValueVariants/All.cs | 51 --- .../MaxValue.cs | 80 +++-- .../MaxValueVariants/All.cs | 23 -- .../MinValue.cs | 80 +++-- .../MinValueVariants/All.cs | 23 -- .../SelectOption.cs | 110 +++--- .../SelectOptionVariants/All.cs | 33 -- .../TransformationProperties/Post.cs | 125 ++++--- .../PostProperties/Abs.cs | 18 +- .../PostProperties/AbsProperties/Type.cs | 50 +++ .../PostProperties/GifToVideo.cs | 14 +- .../GifToVideoProperties/Type.cs | 50 +++ .../PostProperties/Thumbnail.cs | 14 +- .../ThumbnailProperties/Type.cs | 50 +++ .../PostProperties/Transformation.cs | 14 +- .../TransformationProperties/Type.cs | 50 +++ .../DefaultValue.cs | 138 +++++--- .../UnnamedSchemaWithArrayParent5.cs | 116 +++--- .../All.cs | 37 -- .../DefaultValueVariants/All.cs | 51 --- .../MaxValue.cs | 80 +++-- .../MaxValueVariants/All.cs | 23 -- .../MinValue.cs | 80 +++-- .../MinValueVariants/All.cs | 23 -- .../SelectOption.cs | 110 +++--- .../SelectOptionVariants/All.cs | 33 -- .../Models/Files/UpdateFileRequest.cs | 93 +++-- .../RemoveAITags.cs | 71 +++- .../RemoveAITagsProperties/UnionMember1.cs | 51 +++ .../Files/UpdateFileRequestVariants/All.cs | 38 -- src/Imagekit/Models/ImageOverlay.cs | 2 +- .../IntersectionMember1.cs | 2 +- src/Imagekit/Models/Overlay.cs | 189 +++++++--- .../Models/OverlayPositionProperties/X.cs | 62 +++- .../Models/OverlayPositionProperties/Y.cs | 62 +++- .../OverlayTimingProperties/Duration.cs | 70 ++-- .../Models/OverlayTimingProperties/End.cs | 62 +++- .../Models/OverlayTimingProperties/Start.cs | 67 ++-- src/Imagekit/Models/SolidColorOverlay.cs | 2 +- .../IntersectionMember1.cs | 2 +- .../Gradient.cs | 77 ++-- .../GradientProperties/UnionMember0.cs | 51 +++ .../Height.cs | 70 ++-- .../Radius.cs | 73 ++-- .../RadiusProperties/UnionMember1.cs | 51 +++ .../Width.cs | 67 ++-- src/Imagekit/Models/SubtitleOverlay.cs | 2 +- .../IntersectionMember1.cs | 2 +- src/Imagekit/Models/TextOverlay.cs | 2 +- .../IntersectionMember1.cs | 2 +- .../FontSize.cs | 70 ++-- .../LineHeight.cs | 72 ++-- .../Padding.cs | 70 ++-- .../Radius.cs | 73 ++-- .../RadiusProperties/UnionMember1.cs | 51 +++ .../Rotation.cs | 70 ++-- .../Width.cs | 67 ++-- .../TransformationProperties/AIDropShadow.cs | 80 +++-- .../AIDropShadowProperties/UnionMember0.cs | 51 +++ .../TransformationProperties/AspectRatio.cs | 72 ++-- .../TransformationProperties/Duration.cs | 70 ++-- .../TransformationProperties/EndOffset.cs | 70 ++-- .../TransformationProperties/Gradient.cs | 77 ++-- .../GradientProperties/UnionMember0.cs | 51 +++ .../Models/TransformationProperties/Height.cs | 70 ++-- .../Models/TransformationProperties/Page.cs | 86 +++-- .../Models/TransformationProperties/Radius.cs | 73 ++-- .../RadiusProperties/UnionMember1.cs | 51 +++ .../TransformationProperties/Rotation.cs | 70 ++-- .../Models/TransformationProperties/Shadow.cs | 71 ++-- .../ShadowProperties/UnionMember0.cs | 51 +++ .../TransformationProperties/Sharpen.cs | 76 ++-- .../SharpenProperties/UnionMember0.cs | 51 +++ .../TransformationProperties/StartOffset.cs | 72 ++-- .../Models/TransformationProperties/Trim.cs | 73 ++-- .../TrimProperties/UnionMember0.cs | 51 +++ .../TransformationProperties/UnsharpMask.cs | 78 ++-- .../UnsharpMaskProperties/UnionMember0.cs | 51 +++ .../Models/TransformationProperties/Width.cs | 67 ++-- .../Models/TransformationProperties/X.cs | 62 +++- .../TransformationProperties/XCenter.cs | 70 ++-- .../Models/TransformationProperties/Y.cs | 62 +++- .../TransformationProperties/YCenter.cs | 70 ++-- .../Models/UnnamedSchemaWithArrayParent0.cs | 130 ++++--- .../AIAutoDescription.cs | 53 +++ .../AIAutoDescriptionProperties/Name.cs | 50 +++ .../RemoveBg.cs | 11 +- .../RemoveBgProperties/Name.cs | 50 +++ .../All.cs | 54 --- src/Imagekit/Models/VideoOverlay.cs | 2 +- .../IntersectionMember1.cs | 2 +- .../Webhooks/UnsafeUnwrapWebhookEvent.cs | 327 +++++++++-------- .../UnsafeUnwrapWebhookEventVariants/All.cs | 164 --------- .../Models/Webhooks/UnwrapWebhookEvent.cs | 301 +++++++++------- .../UnwrapWebhookEventVariants/All.cs | 164 --------- .../IntersectionMember1.cs | 2 +- .../IntersectionMember1.cs | 2 +- .../IntersectionMember1.cs | 2 +- .../IntersectionMember1.cs | 2 +- .../DefaultValue.cs | 138 +++++--- .../UnnamedSchemaWithArrayParent7.cs | 116 +++--- .../All.cs | 37 -- .../DefaultValueVariants/All.cs | 51 --- .../MaxValue.cs | 80 +++-- .../MaxValueVariants/All.cs | 23 -- .../MinValue.cs | 80 +++-- .../MinValueVariants/All.cs | 23 -- .../SelectOption.cs | 110 +++--- .../SelectOptionVariants/All.cs | 33 -- .../IntersectionMember1.cs | 2 +- .../IntersectionMember1.cs | 2 +- .../IntersectionMember1.cs | 2 +- 217 files changed, 8489 insertions(+), 4328 deletions(-) create mode 100644 src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AkeneoPimProperties/Type.cs create mode 100644 src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AzureBlobProperties/Type.cs create mode 100644 src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/CloudinaryBackupProperties/Type.cs create mode 100644 src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/GcsProperties/Type.cs create mode 100644 src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3CompatibleProperties/Type.cs create mode 100644 src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3Properties/Type.cs create mode 100644 src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebFolderProperties/Type.cs create mode 100644 src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebProxyProperties/Type.cs create mode 100644 src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AkeneoPimProperties/Type.cs create mode 100644 src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AzureBlobProperties/Type.cs create mode 100644 src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/CloudinaryBackupProperties/Type.cs create mode 100644 src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/GcsProperties/Type.cs create mode 100644 src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3CompatibleProperties/Type.cs create mode 100644 src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3Properties/Type.cs create mode 100644 src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebFolderProperties/Type.cs create mode 100644 src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebProxyProperties/Type.cs create mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/Akamai.cs create mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/AkamaiProperties/Type.cs create mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/CloudinaryProperties/Type.cs create mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/Imgix.cs create mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/ImgixProperties/Type.cs create mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/Akamai.cs create mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/AkamaiProperties/Type.cs create mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/CloudinaryProperties/Type.cs create mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/Imgix.cs create mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/ImgixProperties/Type.cs create mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/Akamai.cs create mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/AkamaiProperties/Type.cs create mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/CloudinaryProperties/Type.cs create mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/Imgix.cs create mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/ImgixProperties/Type.cs create mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/Akamai.cs create mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/AkamaiProperties/Type.cs create mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/CloudinaryProperties/Type.cs create mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/Imgix.cs create mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/ImgixProperties/Type.cs create mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/AbsProperties/Type.cs create mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideoProperties/Type.cs create mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/ThumbnailProperties/Type.cs create mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/TransformationProperties/Type.cs delete mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent6Variants/All.cs delete mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs delete mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs delete mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs delete mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs delete mode 100644 src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent4Variants/All.cs delete mode 100644 src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs delete mode 100644 src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs delete mode 100644 src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs delete mode 100644 src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/AbsProperties/Type.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideoProperties/Type.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/ThumbnailProperties/Type.cs create mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/TransformationProperties/Type.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent5Variants/All.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs create mode 100644 src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/RemoveAITagsProperties/UnionMember1.cs delete mode 100644 src/Imagekit/Models/Files/UpdateFileRequestVariants/All.cs create mode 100644 src/Imagekit/Models/SolidColorOverlayTransformationProperties/GradientProperties/UnionMember0.cs create mode 100644 src/Imagekit/Models/SolidColorOverlayTransformationProperties/RadiusProperties/UnionMember1.cs create mode 100644 src/Imagekit/Models/TextOverlayTransformationProperties/RadiusProperties/UnionMember1.cs create mode 100644 src/Imagekit/Models/TransformationProperties/AIDropShadowProperties/UnionMember0.cs create mode 100644 src/Imagekit/Models/TransformationProperties/GradientProperties/UnionMember0.cs create mode 100644 src/Imagekit/Models/TransformationProperties/RadiusProperties/UnionMember1.cs create mode 100644 src/Imagekit/Models/TransformationProperties/ShadowProperties/UnionMember0.cs create mode 100644 src/Imagekit/Models/TransformationProperties/SharpenProperties/UnionMember0.cs create mode 100644 src/Imagekit/Models/TransformationProperties/TrimProperties/UnionMember0.cs create mode 100644 src/Imagekit/Models/TransformationProperties/UnsharpMaskProperties/UnionMember0.cs create mode 100644 src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/AIAutoDescription.cs create mode 100644 src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/AIAutoDescriptionProperties/Name.cs create mode 100644 src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/RemoveBgProperties/Name.cs delete mode 100644 src/Imagekit/Models/UnnamedSchemaWithArrayParent0Variants/All.cs delete mode 100644 src/Imagekit/Models/Webhooks/UnsafeUnwrapWebhookEventVariants/All.cs delete mode 100644 src/Imagekit/Models/Webhooks/UnwrapWebhookEventVariants/All.cs delete mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent7Variants/All.cs delete mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs delete mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs delete mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs delete mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs diff --git a/src/Imagekit.Tests/Services/Accounts/Origins/OriginServiceTest.cs b/src/Imagekit.Tests/Services/Accounts/Origins/OriginServiceTest.cs index 596ba623..b377895e 100644 --- a/src/Imagekit.Tests/Services/Accounts/Origins/OriginServiceTest.cs +++ b/src/Imagekit.Tests/Services/Accounts/Origins/OriginServiceTest.cs @@ -1,73 +1,73 @@ -using System.Threading.Tasks; -using Imagekit.Models.Accounts.Origins.OriginRequestProperties; - -namespace Imagekit.Tests.Services.Accounts.Origins; - -public class OriginServiceTest : TestBase -{ - [Fact(Skip = "Prism tests are disabled")] - public async Task Create_Works() - { - var originResponse = await this.client.Accounts.Origins.Create( - new() - { - Origin = new S3() - { - AccessKey = "AKIATEST123", - Bucket = "test-bucket", - Name = "My S3 Origin", - SecretKey = "secrettest123", - BaseURLForCanonicalHeader = "https://cdn.example.com", - IncludeCanonicalHeader = false, - Prefix = "images", - }, - } - ); - originResponse.Validate(); - } - - [Fact(Skip = "Prism tests are disabled")] - public async Task Update_Works() - { - var originResponse = await this.client.Accounts.Origins.Update( - new() - { - ID = "id", - Origin = new S3() - { - AccessKey = "AKIATEST123", - Bucket = "test-bucket", - Name = "My S3 Origin", - SecretKey = "secrettest123", - BaseURLForCanonicalHeader = "https://cdn.example.com", - IncludeCanonicalHeader = false, - Prefix = "images", - }, - } - ); - originResponse.Validate(); - } - - [Fact(Skip = "Prism tests are disabled")] - public async Task List_Works() - { - var originResponses = await this.client.Accounts.Origins.List(); - foreach (var item in originResponses) - { - item.Validate(); - } - } - - [Fact(Skip = "Prism tests are disabled")] - public async Task Delete_Works() - { - await this.client.Accounts.Origins.Delete(new() { ID = "id" }); - } - - [Fact(Skip = "Prism tests are disabled")] - public async Task Get_Works() - { - var originResponse = await this.client.Accounts.Origins.Get(new() { ID = "id" }); - originResponse.Validate(); - } -} +using System.Threading.Tasks; +using Imagekit.Models.Accounts.Origins.OriginRequestProperties; + +namespace Imagekit.Tests.Services.Accounts.Origins; + +public class OriginServiceTest : TestBase +{ + [Fact(Skip = "Prism tests are disabled")] + public async Task Create_Works() + { + var originResponse = await this.client.Accounts.Origins.Create( + new() + { + Origin = new S3() + { + AccessKey = "AKIATEST123", + Bucket = "test-bucket", + Name = "My S3 Origin", + SecretKey = "secrettest123", + BaseURLForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + Prefix = "images", + }, + } + ); + originResponse.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Update_Works() + { + var originResponse = await this.client.Accounts.Origins.Update( + new() + { + ID = "id", + Origin = new S3() + { + AccessKey = "AKIATEST123", + Bucket = "test-bucket", + Name = "My S3 Origin", + SecretKey = "secrettest123", + BaseURLForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + Prefix = "images", + }, + } + ); + originResponse.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task List_Works() + { + var originResponses = await this.client.Accounts.Origins.List(); + foreach (var item in originResponses) + { + item.Validate(); + } + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Delete_Works() + { + await this.client.Accounts.Origins.Delete(new() { ID = "id" }); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Get_Works() + { + var originResponse = await this.client.Accounts.Origins.Get(new() { ID = "id" }); + originResponse.Validate(); + } +} diff --git a/src/Imagekit.Tests/Services/CustomMetadataFields/CustomMetadataFieldServiceTest.cs b/src/Imagekit.Tests/Services/CustomMetadataFields/CustomMetadataFieldServiceTest.cs index ec7675df..86e41b54 100644 --- a/src/Imagekit.Tests/Services/CustomMetadataFields/CustomMetadataFieldServiceTest.cs +++ b/src/Imagekit.Tests/Services/CustomMetadataFields/CustomMetadataFieldServiceTest.cs @@ -16,13 +16,21 @@ public async Task Create_Works() Schema = new() { Type = Type.Number, - DefaultValue = "string", + DefaultValue = new("string"), IsValueRequired = true, MaxLength = 0, - MaxValue = 3000, + MaxValue = new(3000), MinLength = 0, - MinValue = 1000, - SelectOptions = ["small", "medium", "large", 30, 40, true], + MinValue = new(1000), + SelectOptions = + [ + new("small"), + new("medium"), + new("large"), + new(30), + new(40), + new(true), + ], }, } ); diff --git a/src/Imagekit.Tests/Services/Files/FileServiceTest.cs b/src/Imagekit.Tests/Services/Files/FileServiceTest.cs index db59412d..106a1cc3 100644 --- a/src/Imagekit.Tests/Services/Files/FileServiceTest.cs +++ b/src/Imagekit.Tests/Services/Files/FileServiceTest.cs @@ -4,7 +4,6 @@ using Imagekit.Models.Files.UpdateFileRequestProperties; using Imagekit.Models.UnnamedSchemaWithArrayParent0Properties; using Imagekit.Models.UnnamedSchemaWithArrayParent0Properties.AutoTaggingExtensionProperties; -using UnnamedSchemaWithArrayParent0Variants = Imagekit.Models.UnnamedSchemaWithArrayParent0Variants; namespace Imagekit.Tests.Services.Files; @@ -17,49 +16,53 @@ public async Task Update_Works() new() { FileID = "fileId", - UpdateFileRequest = new UpdateFileDetails() - { - CustomCoordinates = "10,10,100,100", - CustomMetadata = new Dictionary() + UpdateFileRequest = new( + new UpdateFileDetails() { - { "brand", JsonSerializer.SerializeToElement("bar") }, - { "color", JsonSerializer.SerializeToElement("bar") }, - }, - Description = "description", - Extensions = - [ - new RemoveBg() + CustomCoordinates = "10,10,100,100", + CustomMetadata = new Dictionary() { - Options = new() - { - AddShadow = true, - BgColor = "bg_color", - BgImageURL = "bg_image_url", - Semitransparency = true, - }, + { "brand", JsonSerializer.SerializeToElement("bar") }, + { "color", JsonSerializer.SerializeToElement("bar") }, }, - new AutoTaggingExtension() - { - MaxTags = 10, - MinConfidence = 80, - Name = Name.GoogleAutoTagging, - }, - new AutoTaggingExtension() - { - MaxTags = 10, - MinConfidence = 80, - Name = Name.AwsAutoTagging, - }, - new UnnamedSchemaWithArrayParent0Variants::AIAutoDescription( - JsonSerializer.Deserialize( - "{\"name\":\"ai-auto-description\"}" - ) - ), - ], - RemoveAITags = new List() { "car", "vehicle", "motorsports" }, - Tags = ["tag1", "tag2"], - WebhookURL = "https://webhook.site/0d6b6c7a-8e5a-4b3a-8b7c-0d6b6c7a8e5a", - }, + Description = "description", + Extensions = + [ + new( + new RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageURL = "bg_image_url", + Semitransparency = true, + }, + } + ), + new( + new AutoTaggingExtension() + { + MaxTags = 10, + MinConfidence = 80, + Name = Name.GoogleAutoTagging, + } + ), + new( + new AutoTaggingExtension() + { + MaxTags = 10, + MinConfidence = 80, + Name = Name.AwsAutoTagging, + } + ), + new(new()), + ], + RemoveAITags = new(new List() { "car", "vehicle", "motorsports" }), + Tags = ["tag1", "tag2"], + WebhookURL = "https://webhook.site/0d6b6c7a-8e5a-4b3a-8b7c-0d6b6c7a8e5a", + } + ), } ); file.Validate(); diff --git a/src/Imagekit/Core/ModelBase.cs b/src/Imagekit/Core/ModelBase.cs index ccbf5247..36549c63 100644 --- a/src/Imagekit/Core/ModelBase.cs +++ b/src/Imagekit/Core/ModelBase.cs @@ -4,7 +4,6 @@ using Imagekit.Models.Cache.Invalidation.InvalidationGetResponseProperties; using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties; using Imagekit.Models.Files.FileUpdateResponseProperties.IntersectionMember1Properties.ExtensionStatusProperties; -using Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.AbsProperties; using Imagekit.Models.ImageOverlayProperties.IntersectionMember1Properties; using Imagekit.Models.OverlayPositionProperties; using Imagekit.Models.SubtitleOverlayTransformationProperties; @@ -12,7 +11,7 @@ using Imagekit.Models.UnnamedSchemaWithArrayParent0Properties.AutoTaggingExtensionProperties; using Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.IntersectionMember1Properties.DataProperties.TransformationProperties.OptionsProperties; using Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.IntersectionMember1Properties.DataProperties.TransformationProperties.ErrorProperties; -using AbsProperties = Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.AbsProperties; +using AbsProperties = Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.AbsProperties; using AssetListParamsProperties = Imagekit.Models.Assets.AssetListParamsProperties; using ExtensionStatusProperties = Imagekit.Models.Files.FileUploadResponseProperties.ExtensionStatusProperties; using FileProperties = Imagekit.Models.Files.FileProperties; @@ -83,7 +82,7 @@ public abstract record class ModelBase global::Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.Type >(), new ApiEnumConverter(), - new ApiEnumConverter(), + new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), @@ -114,7 +113,10 @@ public abstract record class ModelBase string, global::Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.ResponseField >(), - new ApiEnumConverter(), + new ApiEnumConverter< + string, + global::Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.AbsProperties.Protocol + >(), new ApiEnumConverter< string, global::Imagekit.Models.Webhooks.UploadPostTransformErrorEventProperties.IntersectionMember1Properties.RequestProperties.TransformationProperties.Type diff --git a/src/Imagekit/Imagekit.csproj b/src/Imagekit/Imagekit.csproj index 042a3402..577627ab 100644 --- a/src/Imagekit/Imagekit.csproj +++ b/src/Imagekit/Imagekit.csproj @@ -35,4 +35,7 @@ + + + diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequest.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequest.cs index 7ae8c583..2fe383a5 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginRequest.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginRequest.cs @@ -4,7 +4,6 @@ using System.Text.Json; using System.Text.Json.Serialization; using Imagekit.Models.Accounts.Origins.OriginRequestProperties; -using OriginRequestVariants = Imagekit.Models.Accounts.Origins.OriginRequestVariants; namespace Imagekit.Models.Accounts.Origins; @@ -12,117 +11,280 @@ namespace Imagekit.Models.Accounts.Origins; /// Schema for origin request resources. ///
[JsonConverter(typeof(OriginRequestConverter))] -public abstract record class OriginRequest +public record class OriginRequest { - internal OriginRequest() { } + public object Value { get; private init; } - public static implicit operator OriginRequest(S3 value) => new OriginRequestVariants::S3(value); + public string? AccessKey + { + get + { + return Match( + s3: (x) => x.AccessKey, + s3Compatible: (x) => x.AccessKey, + cloudinaryBackup: (x) => x.AccessKey, + webFolder: (_) => null, + webProxy: (_) => null, + gcs: (_) => null, + azureBlob: (_) => null, + akeneoPim: (_) => null + ); + } + } - public static implicit operator OriginRequest(S3Compatible value) => - new OriginRequestVariants::S3Compatible(value); + public string? Bucket + { + get + { + return Match( + s3: (x) => x.Bucket, + s3Compatible: (x) => x.Bucket, + cloudinaryBackup: (x) => x.Bucket, + webFolder: (_) => null, + webProxy: (_) => null, + gcs: (x) => x.Bucket, + azureBlob: (_) => null, + akeneoPim: (_) => null + ); + } + } - public static implicit operator OriginRequest(CloudinaryBackup value) => - new OriginRequestVariants::CloudinaryBackup(value); + public string Name + { + get + { + return Match( + s3: (x) => x.Name, + s3Compatible: (x) => x.Name, + cloudinaryBackup: (x) => x.Name, + webFolder: (x) => x.Name, + webProxy: (x) => x.Name, + gcs: (x) => x.Name, + azureBlob: (x) => x.Name, + akeneoPim: (x) => x.Name + ); + } + } - public static implicit operator OriginRequest(WebFolder value) => - new OriginRequestVariants::WebFolder(value); + public string? SecretKey + { + get + { + return Match( + s3: (x) => x.SecretKey, + s3Compatible: (x) => x.SecretKey, + cloudinaryBackup: (x) => x.SecretKey, + webFolder: (_) => null, + webProxy: (_) => null, + gcs: (_) => null, + azureBlob: (_) => null, + akeneoPim: (_) => null + ); + } + } - public static implicit operator OriginRequest(WebProxy value) => - new OriginRequestVariants::WebProxy(value); + public string? BaseURLForCanonicalHeader + { + get + { + return Match( + s3: (x) => x.BaseURLForCanonicalHeader, + s3Compatible: (x) => x.BaseURLForCanonicalHeader, + cloudinaryBackup: (x) => x.BaseURLForCanonicalHeader, + webFolder: (x) => x.BaseURLForCanonicalHeader, + webProxy: (x) => x.BaseURLForCanonicalHeader, + gcs: (x) => x.BaseURLForCanonicalHeader, + azureBlob: (x) => x.BaseURLForCanonicalHeader, + akeneoPim: (x) => x.BaseURLForCanonicalHeader + ); + } + } - public static implicit operator OriginRequest(Gcs value) => - new OriginRequestVariants::Gcs(value); + public bool? IncludeCanonicalHeader + { + get + { + return Match( + s3: (x) => x.IncludeCanonicalHeader, + s3Compatible: (x) => x.IncludeCanonicalHeader, + cloudinaryBackup: (x) => x.IncludeCanonicalHeader, + webFolder: (x) => x.IncludeCanonicalHeader, + webProxy: (x) => x.IncludeCanonicalHeader, + gcs: (x) => x.IncludeCanonicalHeader, + azureBlob: (x) => x.IncludeCanonicalHeader, + akeneoPim: (x) => x.IncludeCanonicalHeader + ); + } + } - public static implicit operator OriginRequest(AzureBlob value) => - new OriginRequestVariants::AzureBlob(value); + public string? Prefix + { + get + { + return Match( + s3: (x) => x.Prefix, + s3Compatible: (x) => x.Prefix, + cloudinaryBackup: (x) => x.Prefix, + webFolder: (_) => null, + webProxy: (_) => null, + gcs: (x) => x.Prefix, + azureBlob: (x) => x.Prefix, + akeneoPim: (_) => null + ); + } + } - public static implicit operator OriginRequest(AkeneoPim value) => - new OriginRequestVariants::AkeneoPim(value); + public string? BaseURL + { + get + { + return Match( + s3: (_) => null, + s3Compatible: (_) => null, + cloudinaryBackup: (_) => null, + webFolder: (x) => x.BaseURL, + webProxy: (_) => null, + gcs: (_) => null, + azureBlob: (_) => null, + akeneoPim: (x) => x.BaseURL + ); + } + } + + public OriginRequest(S3 value) + { + Value = value; + } + + public OriginRequest(S3Compatible value) + { + Value = value; + } + + public OriginRequest(CloudinaryBackup value) + { + Value = value; + } + + public OriginRequest(WebFolder value) + { + Value = value; + } + + public OriginRequest(WebProxy value) + { + Value = value; + } + + public OriginRequest(Gcs value) + { + Value = value; + } + + public OriginRequest(AzureBlob value) + { + Value = value; + } + + public OriginRequest(AkeneoPim value) + { + Value = value; + } + + OriginRequest(UnknownVariant value) + { + Value = value; + } + + public static OriginRequest CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickS3([NotNullWhen(true)] out S3? value) { - value = (this as OriginRequestVariants::S3)?.Value; + value = this.Value as S3; return value != null; } public bool TryPickS3Compatible([NotNullWhen(true)] out S3Compatible? value) { - value = (this as OriginRequestVariants::S3Compatible)?.Value; + value = this.Value as S3Compatible; return value != null; } public bool TryPickCloudinaryBackup([NotNullWhen(true)] out CloudinaryBackup? value) { - value = (this as OriginRequestVariants::CloudinaryBackup)?.Value; + value = this.Value as CloudinaryBackup; return value != null; } public bool TryPickWebFolder([NotNullWhen(true)] out WebFolder? value) { - value = (this as OriginRequestVariants::WebFolder)?.Value; + value = this.Value as WebFolder; return value != null; } public bool TryPickWebProxy([NotNullWhen(true)] out WebProxy? value) { - value = (this as OriginRequestVariants::WebProxy)?.Value; + value = this.Value as WebProxy; return value != null; } public bool TryPickGcs([NotNullWhen(true)] out Gcs? value) { - value = (this as OriginRequestVariants::Gcs)?.Value; + value = this.Value as Gcs; return value != null; } public bool TryPickAzureBlob([NotNullWhen(true)] out AzureBlob? value) { - value = (this as OriginRequestVariants::AzureBlob)?.Value; + value = this.Value as AzureBlob; return value != null; } public bool TryPickAkeneoPim([NotNullWhen(true)] out AkeneoPim? value) { - value = (this as OriginRequestVariants::AkeneoPim)?.Value; + value = this.Value as AkeneoPim; return value != null; } public void Switch( - Action s3, - Action s3Compatible, - Action cloudinaryBackup, - Action webFolder, - Action webProxy, - Action gcs, - Action azureBlob, - Action akeneoPim + Action s3, + Action s3Compatible, + Action cloudinaryBackup, + Action webFolder, + Action webProxy, + Action gcs, + Action azureBlob, + Action akeneoPim ) { - switch (this) + switch (this.Value) { - case OriginRequestVariants::S3 inner: - s3(inner); + case S3 value: + s3(value); break; - case OriginRequestVariants::S3Compatible inner: - s3Compatible(inner); + case S3Compatible value: + s3Compatible(value); break; - case OriginRequestVariants::CloudinaryBackup inner: - cloudinaryBackup(inner); + case CloudinaryBackup value: + cloudinaryBackup(value); break; - case OriginRequestVariants::WebFolder inner: - webFolder(inner); + case WebFolder value: + webFolder(value); break; - case OriginRequestVariants::WebProxy inner: - webProxy(inner); + case WebProxy value: + webProxy(value); break; - case OriginRequestVariants::Gcs inner: - gcs(inner); + case Gcs value: + gcs(value); break; - case OriginRequestVariants::AzureBlob inner: - azureBlob(inner); + case AzureBlob value: + azureBlob(value); break; - case OriginRequestVariants::AkeneoPim inner: - akeneoPim(inner); + case AkeneoPim value: + akeneoPim(value); break; default: throw new InvalidOperationException(); @@ -130,17 +292,17 @@ public void Switch( } public T Match( - Func s3, - Func s3Compatible, - Func cloudinaryBackup, - Func webFolder, - Func webProxy, - Func gcs, - Func azureBlob, - Func akeneoPim + Func s3, + Func s3Compatible, + Func cloudinaryBackup, + Func webFolder, + Func webProxy, + Func gcs, + Func azureBlob, + Func akeneoPim ) { - return this switch + return this.Value switch { OriginRequestVariants::S3 inner => s3(inner), OriginRequestVariants::S3Compatible inner => s3Compatible(inner), @@ -154,7 +316,17 @@ public T Match( }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of OriginRequest" + ); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class OriginRequestConverter : JsonConverter @@ -187,10 +359,11 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(json, options); if (deserialized != null) { - return new OriginRequestVariants::S3(deserialized); + deserialized.Validate(); + return new OriginRequest(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -206,10 +379,11 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(json, options); if (deserialized != null) { - return new OriginRequestVariants::S3Compatible(deserialized); + deserialized.Validate(); + return new OriginRequest(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -225,10 +399,11 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(json, options); if (deserialized != null) { - return new OriginRequestVariants::CloudinaryBackup(deserialized); + deserialized.Validate(); + return new OriginRequest(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -244,10 +419,11 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(json, options); if (deserialized != null) { - return new OriginRequestVariants::WebFolder(deserialized); + deserialized.Validate(); + return new OriginRequest(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -263,10 +439,11 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(json, options); if (deserialized != null) { - return new OriginRequestVariants::WebProxy(deserialized); + deserialized.Validate(); + return new OriginRequest(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -282,10 +459,11 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(json, options); if (deserialized != null) { - return new OriginRequestVariants::Gcs(deserialized); + deserialized.Validate(); + return new OriginRequest(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -301,10 +479,11 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(json, options); if (deserialized != null) { - return new OriginRequestVariants::AzureBlob(deserialized); + deserialized.Validate(); + return new OriginRequest(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -320,10 +499,11 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(json, options); if (deserialized != null) { - return new OriginRequestVariants::AkeneoPim(deserialized); + deserialized.Validate(); + return new OriginRequest(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AkeneoPim.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AkeneoPim.cs index 4f328361..1638783d 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AkeneoPim.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AkeneoPim.cs @@ -119,14 +119,21 @@ public required string Password } } - public JsonElement Type + public AkeneoPimProperties::Type Type { get { if (!this.Properties.TryGetValue("type", out JsonElement element)) throw new ArgumentOutOfRangeException("type", "Missing required argument"); - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ) + ?? throw new ImageKitInvalidDataException( + "'type' cannot be null", + new ArgumentNullException("type") + ); } set { @@ -208,6 +215,7 @@ public override void Validate() _ = this.ClientSecret; _ = this.Name; _ = this.Password; + this.Type.Validate(); _ = this.Username; _ = this.BaseURLForCanonicalHeader; _ = this.IncludeCanonicalHeader; @@ -215,7 +223,7 @@ public override void Validate() public AkeneoPim() { - this.Type = JsonSerializer.Deserialize("\"AKENEO_PIM\""); + this.Type = new(); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AkeneoPimProperties/Type.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AkeneoPimProperties/Type.cs new file mode 100644 index 00000000..c44e8601 --- /dev/null +++ b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AkeneoPimProperties/Type.cs @@ -0,0 +1,47 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; +using System = System; + +namespace Imagekit.Models.Accounts.Origins.OriginRequestProperties.AkeneoPimProperties; + +[JsonConverter(typeof(Converter))] +public class Type +{ + public JsonElement Json { get; private init; } + + public Type() + { + Json = JsonSerializer.Deserialize("\"AKENEO_PIM\""); + } + + Type(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new Type().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); + } + } + + private class Converter : JsonConverter + { + public override Type? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AzureBlob.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AzureBlob.cs index eb0fd659..12199139 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AzureBlob.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AzureBlob.cs @@ -88,14 +88,21 @@ public required string SasToken } } - public JsonElement Type + public AzureBlobProperties::Type Type { get { if (!this.Properties.TryGetValue("type", out JsonElement element)) throw new ArgumentOutOfRangeException("type", "Missing required argument"); - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ) + ?? throw new ImageKitInvalidDataException( + "'type' cannot be null", + new ArgumentNullException("type") + ); } set { @@ -172,6 +179,7 @@ public override void Validate() _ = this.Container; _ = this.Name; _ = this.SasToken; + this.Type.Validate(); _ = this.BaseURLForCanonicalHeader; _ = this.IncludeCanonicalHeader; _ = this.Prefix; @@ -179,7 +187,7 @@ public override void Validate() public AzureBlob() { - this.Type = JsonSerializer.Deserialize("\"AZURE_BLOB\""); + this.Type = new(); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AzureBlobProperties/Type.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AzureBlobProperties/Type.cs new file mode 100644 index 00000000..02cd7436 --- /dev/null +++ b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AzureBlobProperties/Type.cs @@ -0,0 +1,47 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; +using System = System; + +namespace Imagekit.Models.Accounts.Origins.OriginRequestProperties.AzureBlobProperties; + +[JsonConverter(typeof(Converter))] +public class Type +{ + public JsonElement Json { get; private init; } + + public Type() + { + Json = JsonSerializer.Deserialize("\"AZURE_BLOB\""); + } + + Type(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new Type().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); + } + } + + private class Converter : JsonConverter + { + public override Type? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/CloudinaryBackup.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/CloudinaryBackup.cs index 9796a6b4..5c214845 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/CloudinaryBackup.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/CloudinaryBackup.cs @@ -97,14 +97,21 @@ public required string SecretKey } } - public JsonElement Type + public CloudinaryBackupProperties::Type Type { get { if (!this.Properties.TryGetValue("type", out JsonElement element)) throw new ArgumentOutOfRangeException("type", "Missing required argument"); - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ) + ?? throw new ImageKitInvalidDataException( + "'type' cannot be null", + new ArgumentNullException("type") + ); } set { @@ -184,6 +191,7 @@ public override void Validate() _ = this.Bucket; _ = this.Name; _ = this.SecretKey; + this.Type.Validate(); _ = this.BaseURLForCanonicalHeader; _ = this.IncludeCanonicalHeader; _ = this.Prefix; @@ -191,7 +199,7 @@ public override void Validate() public CloudinaryBackup() { - this.Type = JsonSerializer.Deserialize("\"CLOUDINARY_BACKUP\""); + this.Type = new(); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/CloudinaryBackupProperties/Type.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/CloudinaryBackupProperties/Type.cs new file mode 100644 index 00000000..b1d2412f --- /dev/null +++ b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/CloudinaryBackupProperties/Type.cs @@ -0,0 +1,47 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; +using System = System; + +namespace Imagekit.Models.Accounts.Origins.OriginRequestProperties.CloudinaryBackupProperties; + +[JsonConverter(typeof(Converter))] +public class Type +{ + public JsonElement Json { get; private init; } + + public Type() + { + Json = JsonSerializer.Deserialize("\"CLOUDINARY_BACKUP\""); + } + + Type(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new Type().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); + } + } + + private class Converter : JsonConverter + { + public override Type? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/Gcs.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/Gcs.cs index 82f507da..7c29c679 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/Gcs.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/Gcs.cs @@ -88,14 +88,21 @@ public required string PrivateKey } } - public JsonElement Type + public GcsProperties::Type Type { get { if (!this.Properties.TryGetValue("type", out JsonElement element)) throw new ArgumentOutOfRangeException("type", "Missing required argument"); - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ) + ?? throw new ImageKitInvalidDataException( + "'type' cannot be null", + new ArgumentNullException("type") + ); } set { @@ -172,6 +179,7 @@ public override void Validate() _ = this.ClientEmail; _ = this.Name; _ = this.PrivateKey; + this.Type.Validate(); _ = this.BaseURLForCanonicalHeader; _ = this.IncludeCanonicalHeader; _ = this.Prefix; @@ -179,7 +187,7 @@ public override void Validate() public Gcs() { - this.Type = JsonSerializer.Deserialize("\"GCS\""); + this.Type = new(); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/GcsProperties/Type.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/GcsProperties/Type.cs new file mode 100644 index 00000000..5b0552c0 --- /dev/null +++ b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/GcsProperties/Type.cs @@ -0,0 +1,47 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; +using System = System; + +namespace Imagekit.Models.Accounts.Origins.OriginRequestProperties.GcsProperties; + +[JsonConverter(typeof(Converter))] +public class Type +{ + public JsonElement Json { get; private init; } + + public Type() + { + Json = JsonSerializer.Deserialize("\"GCS\""); + } + + Type(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new Type().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); + } + } + + private class Converter : JsonConverter + { + public override Type? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3.cs index 05605806..792e8aac 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3.cs @@ -97,14 +97,21 @@ public required string SecretKey } } - public JsonElement Type + public S3Properties::Type Type { get { if (!this.Properties.TryGetValue("type", out JsonElement element)) throw new ArgumentOutOfRangeException("type", "Missing required argument"); - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ) + ?? throw new ImageKitInvalidDataException( + "'type' cannot be null", + new ArgumentNullException("type") + ); } set { @@ -184,6 +191,7 @@ public override void Validate() _ = this.Bucket; _ = this.Name; _ = this.SecretKey; + this.Type.Validate(); _ = this.BaseURLForCanonicalHeader; _ = this.IncludeCanonicalHeader; _ = this.Prefix; @@ -191,7 +199,7 @@ public override void Validate() public S3() { - this.Type = JsonSerializer.Deserialize("\"S3\""); + this.Type = new(); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3Compatible.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3Compatible.cs index 9c719e79..006876e0 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3Compatible.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3Compatible.cs @@ -119,14 +119,21 @@ public required string SecretKey } } - public JsonElement Type + public S3CompatibleProperties::Type Type { get { if (!this.Properties.TryGetValue("type", out JsonElement element)) throw new ArgumentOutOfRangeException("type", "Missing required argument"); - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ) + ?? throw new ImageKitInvalidDataException( + "'type' cannot be null", + new ArgumentNullException("type") + ); } set { @@ -228,6 +235,7 @@ public override void Validate() _ = this.Endpoint; _ = this.Name; _ = this.SecretKey; + this.Type.Validate(); _ = this.BaseURLForCanonicalHeader; _ = this.IncludeCanonicalHeader; _ = this.Prefix; @@ -236,7 +244,7 @@ public override void Validate() public S3Compatible() { - this.Type = JsonSerializer.Deserialize("\"S3_COMPATIBLE\""); + this.Type = new(); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3CompatibleProperties/Type.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3CompatibleProperties/Type.cs new file mode 100644 index 00000000..fea09e9b --- /dev/null +++ b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3CompatibleProperties/Type.cs @@ -0,0 +1,47 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; +using System = System; + +namespace Imagekit.Models.Accounts.Origins.OriginRequestProperties.S3CompatibleProperties; + +[JsonConverter(typeof(Converter))] +public class Type +{ + public JsonElement Json { get; private init; } + + public Type() + { + Json = JsonSerializer.Deserialize("\"S3_COMPATIBLE\""); + } + + Type(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new Type().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); + } + } + + private class Converter : JsonConverter + { + public override Type? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3Properties/Type.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3Properties/Type.cs new file mode 100644 index 00000000..35e49069 --- /dev/null +++ b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3Properties/Type.cs @@ -0,0 +1,47 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; +using System = System; + +namespace Imagekit.Models.Accounts.Origins.OriginRequestProperties.S3Properties; + +[JsonConverter(typeof(Converter))] +public class Type +{ + public JsonElement Json { get; private init; } + + public Type() + { + Json = JsonSerializer.Deserialize("\"S3\""); + } + + Type(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new Type().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); + } + } + + private class Converter : JsonConverter + { + public override Type? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebFolder.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebFolder.cs index 8f84dc3e..fb7d4142 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebFolder.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebFolder.cs @@ -53,14 +53,21 @@ public required string Name } } - public JsonElement Type + public WebFolderProperties::Type Type { get { if (!this.Properties.TryGetValue("type", out JsonElement element)) throw new ArgumentOutOfRangeException("type", "Missing required argument"); - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ) + ?? throw new ImageKitInvalidDataException( + "'type' cannot be null", + new ArgumentNullException("type") + ); } set { @@ -138,6 +145,7 @@ public override void Validate() { _ = this.BaseURL; _ = this.Name; + this.Type.Validate(); _ = this.BaseURLForCanonicalHeader; _ = this.ForwardHostHeaderToOrigin; _ = this.IncludeCanonicalHeader; @@ -145,7 +153,7 @@ public override void Validate() public WebFolder() { - this.Type = JsonSerializer.Deserialize("\"WEB_FOLDER\""); + this.Type = new(); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebFolderProperties/Type.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebFolderProperties/Type.cs new file mode 100644 index 00000000..ff01fb13 --- /dev/null +++ b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebFolderProperties/Type.cs @@ -0,0 +1,47 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; +using System = System; + +namespace Imagekit.Models.Accounts.Origins.OriginRequestProperties.WebFolderProperties; + +[JsonConverter(typeof(Converter))] +public class Type +{ + public JsonElement Json { get; private init; } + + public Type() + { + Json = JsonSerializer.Deserialize("\"WEB_FOLDER\""); + } + + Type(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new Type().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); + } + } + + private class Converter : JsonConverter + { + public override Type? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebProxy.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebProxy.cs index 73afbce7..7f521700 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebProxy.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebProxy.cs @@ -31,14 +31,21 @@ public required string Name } } - public JsonElement Type + public WebProxyProperties::Type Type { get { if (!this.Properties.TryGetValue("type", out JsonElement element)) throw new ArgumentOutOfRangeException("type", "Missing required argument"); - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ) + ?? throw new ImageKitInvalidDataException( + "'type' cannot be null", + new ArgumentNullException("type") + ); } set { @@ -94,13 +101,14 @@ public bool? IncludeCanonicalHeader public override void Validate() { _ = this.Name; + this.Type.Validate(); _ = this.BaseURLForCanonicalHeader; _ = this.IncludeCanonicalHeader; } public WebProxy() { - this.Type = JsonSerializer.Deserialize("\"WEB_PROXY\""); + this.Type = new(); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebProxyProperties/Type.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebProxyProperties/Type.cs new file mode 100644 index 00000000..f652f82f --- /dev/null +++ b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebProxyProperties/Type.cs @@ -0,0 +1,47 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; +using System = System; + +namespace Imagekit.Models.Accounts.Origins.OriginRequestProperties.WebProxyProperties; + +[JsonConverter(typeof(Converter))] +public class Type +{ + public JsonElement Json { get; private init; } + + public Type() + { + Json = JsonSerializer.Deserialize("\"WEB_PROXY\""); + } + + Type(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new Type().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); + } + } + + private class Converter : JsonConverter + { + public override Type? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponse.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponse.cs index 60d7a68c..b042f46a 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginResponse.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginResponse.cs @@ -4,7 +4,6 @@ using System.Text.Json; using System.Text.Json.Serialization; using Imagekit.Models.Accounts.Origins.OriginResponseProperties; -using OriginResponseVariants = Imagekit.Models.Accounts.Origins.OriginResponseVariants; namespace Imagekit.Models.Accounts.Origins; @@ -12,118 +11,263 @@ namespace Imagekit.Models.Accounts.Origins; /// Origin object as returned by the API (sensitive fields removed). ///
[JsonConverter(typeof(OriginResponseConverter))] -public abstract record class OriginResponse +public record class OriginResponse { - internal OriginResponse() { } + public object Value { get; private init; } - public static implicit operator OriginResponse(S3 value) => - new OriginResponseVariants::S3(value); + public string ID + { + get + { + return Match( + s3: (x) => x.ID, + s3Compatible: (x) => x.ID, + cloudinaryBackup: (x) => x.ID, + webFolder: (x) => x.ID, + webProxy: (x) => x.ID, + gcs: (x) => x.ID, + azureBlob: (x) => x.ID, + akeneoPim: (x) => x.ID + ); + } + } + + public string? Bucket + { + get + { + return Match( + s3: (x) => x.Bucket, + s3Compatible: (x) => x.Bucket, + cloudinaryBackup: (x) => x.Bucket, + webFolder: (_) => null, + webProxy: (_) => null, + gcs: (x) => x.Bucket, + azureBlob: (_) => null, + akeneoPim: (_) => null + ); + } + } + + public bool IncludeCanonicalHeader + { + get + { + return Match( + s3: (x) => x.IncludeCanonicalHeader, + s3Compatible: (x) => x.IncludeCanonicalHeader, + cloudinaryBackup: (x) => x.IncludeCanonicalHeader, + webFolder: (x) => x.IncludeCanonicalHeader, + webProxy: (x) => x.IncludeCanonicalHeader, + gcs: (x) => x.IncludeCanonicalHeader, + azureBlob: (x) => x.IncludeCanonicalHeader, + akeneoPim: (x) => x.IncludeCanonicalHeader + ); + } + } + + public string Name + { + get + { + return Match( + s3: (x) => x.Name, + s3Compatible: (x) => x.Name, + cloudinaryBackup: (x) => x.Name, + webFolder: (x) => x.Name, + webProxy: (x) => x.Name, + gcs: (x) => x.Name, + azureBlob: (x) => x.Name, + akeneoPim: (x) => x.Name + ); + } + } + + public string? Prefix + { + get + { + return Match( + s3: (x) => x.Prefix, + s3Compatible: (x) => x.Prefix, + cloudinaryBackup: (x) => x.Prefix, + webFolder: (_) => null, + webProxy: (_) => null, + gcs: (x) => x.Prefix, + azureBlob: (x) => x.Prefix, + akeneoPim: (_) => null + ); + } + } + + public string? BaseURLForCanonicalHeader + { + get + { + return Match( + s3: (x) => x.BaseURLForCanonicalHeader, + s3Compatible: (x) => x.BaseURLForCanonicalHeader, + cloudinaryBackup: (x) => x.BaseURLForCanonicalHeader, + webFolder: (x) => x.BaseURLForCanonicalHeader, + webProxy: (x) => x.BaseURLForCanonicalHeader, + gcs: (x) => x.BaseURLForCanonicalHeader, + azureBlob: (x) => x.BaseURLForCanonicalHeader, + akeneoPim: (x) => x.BaseURLForCanonicalHeader + ); + } + } + + public string? BaseURL + { + get + { + return Match( + s3: (_) => null, + s3Compatible: (_) => null, + cloudinaryBackup: (_) => null, + webFolder: (x) => x.BaseURL, + webProxy: (_) => null, + gcs: (_) => null, + azureBlob: (_) => null, + akeneoPim: (x) => x.BaseURL + ); + } + } - public static implicit operator OriginResponse(S3Compatible value) => - new OriginResponseVariants::S3Compatible(value); + public OriginResponse(S3 value) + { + Value = value; + } - public static implicit operator OriginResponse(CloudinaryBackup value) => - new OriginResponseVariants::CloudinaryBackup(value); + public OriginResponse(S3Compatible value) + { + Value = value; + } - public static implicit operator OriginResponse(WebFolder value) => - new OriginResponseVariants::WebFolder(value); + public OriginResponse(CloudinaryBackup value) + { + Value = value; + } - public static implicit operator OriginResponse(WebProxy value) => - new OriginResponseVariants::WebProxy(value); + public OriginResponse(WebFolder value) + { + Value = value; + } - public static implicit operator OriginResponse(Gcs value) => - new OriginResponseVariants::Gcs(value); + public OriginResponse(WebProxy value) + { + Value = value; + } - public static implicit operator OriginResponse(AzureBlob value) => - new OriginResponseVariants::AzureBlob(value); + public OriginResponse(Gcs value) + { + Value = value; + } - public static implicit operator OriginResponse(AkeneoPim value) => - new OriginResponseVariants::AkeneoPim(value); + public OriginResponse(AzureBlob value) + { + Value = value; + } + + public OriginResponse(AkeneoPim value) + { + Value = value; + } + + OriginResponse(UnknownVariant value) + { + Value = value; + } + + public static OriginResponse CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickS3([NotNullWhen(true)] out S3? value) { - value = (this as OriginResponseVariants::S3)?.Value; + value = this.Value as S3; return value != null; } public bool TryPickS3Compatible([NotNullWhen(true)] out S3Compatible? value) { - value = (this as OriginResponseVariants::S3Compatible)?.Value; + value = this.Value as S3Compatible; return value != null; } public bool TryPickCloudinaryBackup([NotNullWhen(true)] out CloudinaryBackup? value) { - value = (this as OriginResponseVariants::CloudinaryBackup)?.Value; + value = this.Value as CloudinaryBackup; return value != null; } public bool TryPickWebFolder([NotNullWhen(true)] out WebFolder? value) { - value = (this as OriginResponseVariants::WebFolder)?.Value; + value = this.Value as WebFolder; return value != null; } public bool TryPickWebProxy([NotNullWhen(true)] out WebProxy? value) { - value = (this as OriginResponseVariants::WebProxy)?.Value; + value = this.Value as WebProxy; return value != null; } public bool TryPickGcs([NotNullWhen(true)] out Gcs? value) { - value = (this as OriginResponseVariants::Gcs)?.Value; + value = this.Value as Gcs; return value != null; } public bool TryPickAzureBlob([NotNullWhen(true)] out AzureBlob? value) { - value = (this as OriginResponseVariants::AzureBlob)?.Value; + value = this.Value as AzureBlob; return value != null; } public bool TryPickAkeneoPim([NotNullWhen(true)] out AkeneoPim? value) { - value = (this as OriginResponseVariants::AkeneoPim)?.Value; + value = this.Value as AkeneoPim; return value != null; } public void Switch( - Action s3, - Action s3Compatible, - Action cloudinaryBackup, - Action webFolder, - Action webProxy, - Action gcs, - Action azureBlob, - Action akeneoPim + Action s3, + Action s3Compatible, + Action cloudinaryBackup, + Action webFolder, + Action webProxy, + Action gcs, + Action azureBlob, + Action akeneoPim ) { - switch (this) + switch (this.Value) { - case OriginResponseVariants::S3 inner: - s3(inner); + case S3 value: + s3(value); break; - case OriginResponseVariants::S3Compatible inner: - s3Compatible(inner); + case S3Compatible value: + s3Compatible(value); break; - case OriginResponseVariants::CloudinaryBackup inner: - cloudinaryBackup(inner); + case CloudinaryBackup value: + cloudinaryBackup(value); break; - case OriginResponseVariants::WebFolder inner: - webFolder(inner); + case WebFolder value: + webFolder(value); break; - case OriginResponseVariants::WebProxy inner: - webProxy(inner); + case WebProxy value: + webProxy(value); break; - case OriginResponseVariants::Gcs inner: - gcs(inner); + case Gcs value: + gcs(value); break; - case OriginResponseVariants::AzureBlob inner: - azureBlob(inner); + case AzureBlob value: + azureBlob(value); break; - case OriginResponseVariants::AkeneoPim inner: - akeneoPim(inner); + case AkeneoPim value: + akeneoPim(value); break; default: throw new InvalidOperationException(); @@ -131,17 +275,17 @@ public void Switch( } public T Match( - Func s3, - Func s3Compatible, - Func cloudinaryBackup, - Func webFolder, - Func webProxy, - Func gcs, - Func azureBlob, - Func akeneoPim + Func s3, + Func s3Compatible, + Func cloudinaryBackup, + Func webFolder, + Func webProxy, + Func gcs, + Func azureBlob, + Func akeneoPim ) { - return this switch + return this.Value switch { OriginResponseVariants::S3 inner => s3(inner), OriginResponseVariants::S3Compatible inner => s3Compatible(inner), @@ -155,7 +299,17 @@ public T Match( }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of OriginResponse" + ); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class OriginResponseConverter : JsonConverter @@ -188,10 +342,11 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(json, options); if (deserialized != null) { - return new OriginResponseVariants::S3(deserialized); + deserialized.Validate(); + return new OriginResponse(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -207,10 +362,11 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(json, options); if (deserialized != null) { - return new OriginResponseVariants::S3Compatible(deserialized); + deserialized.Validate(); + return new OriginResponse(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -226,10 +382,11 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(json, options); if (deserialized != null) { - return new OriginResponseVariants::CloudinaryBackup(deserialized); + deserialized.Validate(); + return new OriginResponse(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -245,10 +402,11 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(json, options); if (deserialized != null) { - return new OriginResponseVariants::WebFolder(deserialized); + deserialized.Validate(); + return new OriginResponse(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -264,10 +422,11 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(json, options); if (deserialized != null) { - return new OriginResponseVariants::WebProxy(deserialized); + deserialized.Validate(); + return new OriginResponse(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -283,10 +442,11 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(json, options); if (deserialized != null) { - return new OriginResponseVariants::Gcs(deserialized); + deserialized.Validate(); + return new OriginResponse(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -302,10 +462,11 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(json, options); if (deserialized != null) { - return new OriginResponseVariants::AzureBlob(deserialized); + deserialized.Validate(); + return new OriginResponse(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -321,10 +482,11 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(json, options); if (deserialized != null) { - return new OriginResponseVariants::AkeneoPim(deserialized); + deserialized.Validate(); + return new OriginResponse(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AkeneoPim.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AkeneoPim.cs index 8bc2a167..0e91e534 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AkeneoPim.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AkeneoPim.cs @@ -100,14 +100,21 @@ public required string Name } } - public JsonElement Type + public AkeneoPimProperties::Type Type { get { if (!this.Properties.TryGetValue("type", out JsonElement element)) throw new ArgumentOutOfRangeException("type", "Missing required argument"); - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ) + ?? throw new ImageKitInvalidDataException( + "'type' cannot be null", + new ArgumentNullException("type") + ); } set { @@ -145,12 +152,13 @@ public override void Validate() _ = this.BaseURL; _ = this.IncludeCanonicalHeader; _ = this.Name; + this.Type.Validate(); _ = this.BaseURLForCanonicalHeader; } public AkeneoPim() { - this.Type = JsonSerializer.Deserialize("\"AKENEO_PIM\""); + this.Type = new(); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AkeneoPimProperties/Type.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AkeneoPimProperties/Type.cs new file mode 100644 index 00000000..9c33dea1 --- /dev/null +++ b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AkeneoPimProperties/Type.cs @@ -0,0 +1,47 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; +using System = System; + +namespace Imagekit.Models.Accounts.Origins.OriginResponseProperties.AkeneoPimProperties; + +[JsonConverter(typeof(Converter))] +public class Type +{ + public JsonElement Json { get; private init; } + + public Type() + { + Json = JsonSerializer.Deserialize("\"AKENEO_PIM\""); + } + + Type(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new Type().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); + } + } + + private class Converter : JsonConverter + { + public override Type? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AzureBlob.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AzureBlob.cs index 3c8c3936..adf4dbdd 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AzureBlob.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AzureBlob.cs @@ -135,14 +135,21 @@ public required string Prefix } } - public JsonElement Type + public AzureBlobProperties::Type Type { get { if (!this.Properties.TryGetValue("type", out JsonElement element)) throw new ArgumentOutOfRangeException("type", "Missing required argument"); - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ) + ?? throw new ImageKitInvalidDataException( + "'type' cannot be null", + new ArgumentNullException("type") + ); } set { @@ -182,12 +189,13 @@ public override void Validate() _ = this.IncludeCanonicalHeader; _ = this.Name; _ = this.Prefix; + this.Type.Validate(); _ = this.BaseURLForCanonicalHeader; } public AzureBlob() { - this.Type = JsonSerializer.Deserialize("\"AZURE_BLOB\""); + this.Type = new(); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AzureBlobProperties/Type.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AzureBlobProperties/Type.cs new file mode 100644 index 00000000..221a2d36 --- /dev/null +++ b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AzureBlobProperties/Type.cs @@ -0,0 +1,47 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; +using System = System; + +namespace Imagekit.Models.Accounts.Origins.OriginResponseProperties.AzureBlobProperties; + +[JsonConverter(typeof(Converter))] +public class Type +{ + public JsonElement Json { get; private init; } + + public Type() + { + Json = JsonSerializer.Deserialize("\"AZURE_BLOB\""); + } + + Type(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new Type().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); + } + } + + private class Converter : JsonConverter + { + public override Type? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/CloudinaryBackup.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/CloudinaryBackup.cs index f3c5e1e6..608e2365 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/CloudinaryBackup.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/CloudinaryBackup.cs @@ -122,14 +122,21 @@ public required string Prefix } } - public JsonElement Type + public CloudinaryBackupProperties::Type Type { get { if (!this.Properties.TryGetValue("type", out JsonElement element)) throw new ArgumentOutOfRangeException("type", "Missing required argument"); - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ) + ?? throw new ImageKitInvalidDataException( + "'type' cannot be null", + new ArgumentNullException("type") + ); } set { @@ -168,12 +175,13 @@ public override void Validate() _ = this.IncludeCanonicalHeader; _ = this.Name; _ = this.Prefix; + this.Type.Validate(); _ = this.BaseURLForCanonicalHeader; } public CloudinaryBackup() { - this.Type = JsonSerializer.Deserialize("\"CLOUDINARY_BACKUP\""); + this.Type = new(); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/CloudinaryBackupProperties/Type.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/CloudinaryBackupProperties/Type.cs new file mode 100644 index 00000000..a9e7f082 --- /dev/null +++ b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/CloudinaryBackupProperties/Type.cs @@ -0,0 +1,47 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; +using System = System; + +namespace Imagekit.Models.Accounts.Origins.OriginResponseProperties.CloudinaryBackupProperties; + +[JsonConverter(typeof(Converter))] +public class Type +{ + public JsonElement Json { get; private init; } + + public Type() + { + Json = JsonSerializer.Deserialize("\"CLOUDINARY_BACKUP\""); + } + + Type(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new Type().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); + } + } + + private class Converter : JsonConverter + { + public override Type? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/Gcs.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/Gcs.cs index cbf792ed..25a84665 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/Gcs.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/Gcs.cs @@ -135,14 +135,21 @@ public required string Prefix } } - public JsonElement Type + public GcsProperties::Type Type { get { if (!this.Properties.TryGetValue("type", out JsonElement element)) throw new ArgumentOutOfRangeException("type", "Missing required argument"); - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ) + ?? throw new ImageKitInvalidDataException( + "'type' cannot be null", + new ArgumentNullException("type") + ); } set { @@ -182,12 +189,13 @@ public override void Validate() _ = this.IncludeCanonicalHeader; _ = this.Name; _ = this.Prefix; + this.Type.Validate(); _ = this.BaseURLForCanonicalHeader; } public Gcs() { - this.Type = JsonSerializer.Deserialize("\"GCS\""); + this.Type = new(); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/GcsProperties/Type.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/GcsProperties/Type.cs new file mode 100644 index 00000000..f4230283 --- /dev/null +++ b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/GcsProperties/Type.cs @@ -0,0 +1,47 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; +using System = System; + +namespace Imagekit.Models.Accounts.Origins.OriginResponseProperties.GcsProperties; + +[JsonConverter(typeof(Converter))] +public class Type +{ + public JsonElement Json { get; private init; } + + public Type() + { + Json = JsonSerializer.Deserialize("\"GCS\""); + } + + Type(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new Type().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); + } + } + + private class Converter : JsonConverter + { + public override Type? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3.cs index 452a32e4..c9d37af2 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3.cs @@ -122,14 +122,21 @@ public required string Prefix } } - public JsonElement Type + public S3Properties::Type Type { get { if (!this.Properties.TryGetValue("type", out JsonElement element)) throw new ArgumentOutOfRangeException("type", "Missing required argument"); - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ) + ?? throw new ImageKitInvalidDataException( + "'type' cannot be null", + new ArgumentNullException("type") + ); } set { @@ -168,12 +175,13 @@ public override void Validate() _ = this.IncludeCanonicalHeader; _ = this.Name; _ = this.Prefix; + this.Type.Validate(); _ = this.BaseURLForCanonicalHeader; } public S3() { - this.Type = JsonSerializer.Deserialize("\"S3\""); + this.Type = new(); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3Compatible.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3Compatible.cs index 22da674c..8cdb00df 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3Compatible.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3Compatible.cs @@ -168,14 +168,21 @@ public required bool S3ForcePathStyle } } - public JsonElement Type + public S3CompatibleProperties::Type Type { get { if (!this.Properties.TryGetValue("type", out JsonElement element)) throw new ArgumentOutOfRangeException("type", "Missing required argument"); - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ) + ?? throw new ImageKitInvalidDataException( + "'type' cannot be null", + new ArgumentNullException("type") + ); } set { @@ -216,12 +223,13 @@ public override void Validate() _ = this.Name; _ = this.Prefix; _ = this.S3ForcePathStyle; + this.Type.Validate(); _ = this.BaseURLForCanonicalHeader; } public S3Compatible() { - this.Type = JsonSerializer.Deserialize("\"S3_COMPATIBLE\""); + this.Type = new(); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3CompatibleProperties/Type.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3CompatibleProperties/Type.cs new file mode 100644 index 00000000..8790f6a5 --- /dev/null +++ b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3CompatibleProperties/Type.cs @@ -0,0 +1,47 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; +using System = System; + +namespace Imagekit.Models.Accounts.Origins.OriginResponseProperties.S3CompatibleProperties; + +[JsonConverter(typeof(Converter))] +public class Type +{ + public JsonElement Json { get; private init; } + + public Type() + { + Json = JsonSerializer.Deserialize("\"S3_COMPATIBLE\""); + } + + Type(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new Type().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); + } + } + + private class Converter : JsonConverter + { + public override Type? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3Properties/Type.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3Properties/Type.cs new file mode 100644 index 00000000..be31fc07 --- /dev/null +++ b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3Properties/Type.cs @@ -0,0 +1,47 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; +using System = System; + +namespace Imagekit.Models.Accounts.Origins.OriginResponseProperties.S3Properties; + +[JsonConverter(typeof(Converter))] +public class Type +{ + public JsonElement Json { get; private init; } + + public Type() + { + Json = JsonSerializer.Deserialize("\"S3\""); + } + + Type(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new Type().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); + } + } + + private class Converter : JsonConverter + { + public override Type? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebFolder.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebFolder.cs index a88b45e9..1164787d 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebFolder.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebFolder.cs @@ -124,14 +124,21 @@ public required string Name } } - public JsonElement Type + public WebFolderProperties::Type Type { get { if (!this.Properties.TryGetValue("type", out JsonElement element)) throw new ArgumentOutOfRangeException("type", "Missing required argument"); - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ) + ?? throw new ImageKitInvalidDataException( + "'type' cannot be null", + new ArgumentNullException("type") + ); } set { @@ -170,12 +177,13 @@ public override void Validate() _ = this.ForwardHostHeaderToOrigin; _ = this.IncludeCanonicalHeader; _ = this.Name; + this.Type.Validate(); _ = this.BaseURLForCanonicalHeader; } public WebFolder() { - this.Type = JsonSerializer.Deserialize("\"WEB_FOLDER\""); + this.Type = new(); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebFolderProperties/Type.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebFolderProperties/Type.cs new file mode 100644 index 00000000..4c0f90fb --- /dev/null +++ b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebFolderProperties/Type.cs @@ -0,0 +1,47 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; +using System = System; + +namespace Imagekit.Models.Accounts.Origins.OriginResponseProperties.WebFolderProperties; + +[JsonConverter(typeof(Converter))] +public class Type +{ + public JsonElement Json { get; private init; } + + public Type() + { + Json = JsonSerializer.Deserialize("\"WEB_FOLDER\""); + } + + Type(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new Type().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); + } + } + + private class Converter : JsonConverter + { + public override Type? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebProxy.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebProxy.cs index 17fa6eaa..abe746c9 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebProxy.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebProxy.cs @@ -78,14 +78,21 @@ public required string Name } } - public JsonElement Type + public WebProxyProperties::Type Type { get { if (!this.Properties.TryGetValue("type", out JsonElement element)) throw new ArgumentOutOfRangeException("type", "Missing required argument"); - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ) + ?? throw new ImageKitInvalidDataException( + "'type' cannot be null", + new ArgumentNullException("type") + ); } set { @@ -122,12 +129,13 @@ public override void Validate() _ = this.ID; _ = this.IncludeCanonicalHeader; _ = this.Name; + this.Type.Validate(); _ = this.BaseURLForCanonicalHeader; } public WebProxy() { - this.Type = JsonSerializer.Deserialize("\"WEB_PROXY\""); + this.Type = new(); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebProxyProperties/Type.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebProxyProperties/Type.cs new file mode 100644 index 00000000..14596d66 --- /dev/null +++ b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebProxyProperties/Type.cs @@ -0,0 +1,47 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; +using System = System; + +namespace Imagekit.Models.Accounts.Origins.OriginResponseProperties.WebProxyProperties; + +[JsonConverter(typeof(Converter))] +public class Type +{ + public JsonElement Json { get; private init; } + + public Type() + { + Json = JsonSerializer.Deserialize("\"WEB_PROXY\""); + } + + Type(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new Type().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); + } + } + + private class Converter : JsonConverter + { + public override Type? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriter.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriter.cs index 566303bf..9dad57b5 100644 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriter.cs +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriter.cs @@ -4,7 +4,6 @@ using System.Text.Json; using System.Text.Json.Serialization; using Imagekit.Models.Accounts.URLEndpoints.URLEndpointCreateParamsProperties.URLRewriterProperties; -using URLRewriterVariants = Imagekit.Models.Accounts.URLEndpoints.URLEndpointCreateParamsProperties.URLRewriterVariants; namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointCreateParamsProperties; @@ -12,60 +11,74 @@ namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointCreateParamsPropertie /// Configuration for third-party URL rewriting. ///
[JsonConverter(typeof(URLRewriterConverter))] -public abstract record class URLRewriter +public record class URLRewriter { - internal URLRewriter() { } + public object Value { get; private init; } - public static implicit operator URLRewriter(Cloudinary value) => - new URLRewriterVariants::Cloudinary(value); + public URLRewriter(Cloudinary value) + { + Value = value; + } + + public URLRewriter(Imgix value) + { + Value = value; + } + + public URLRewriter(Akamai value) + { + Value = value; + } + + URLRewriter(UnknownVariant value) + { + Value = value; + } + + public static URLRewriter CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickCloudinary([NotNullWhen(true)] out Cloudinary? value) { - value = (this as URLRewriterVariants::Cloudinary)?.Value; + value = this.Value as Cloudinary; return value != null; } - public bool TryPickImgix([NotNullWhen(true)] out JsonElement? value) + public bool TryPickImgix([NotNullWhen(true)] out Imgix? value) { - value = (this as URLRewriterVariants::Imgix)?.Value; + value = this.Value as Imgix; return value != null; } - public bool TryPickAkamai([NotNullWhen(true)] out JsonElement? value) + public bool TryPickAkamai([NotNullWhen(true)] out Akamai? value) { - value = (this as URLRewriterVariants::Akamai)?.Value; + value = this.Value as Akamai; return value != null; } - public void Switch( - Action cloudinary, - Action imgix, - Action akamai - ) + public void Switch(Action cloudinary, Action imgix, Action akamai) { - switch (this) + switch (this.Value) { - case URLRewriterVariants::Cloudinary inner: - cloudinary(inner); + case Cloudinary value: + cloudinary(value); break; - case URLRewriterVariants::Imgix inner: - imgix(inner); + case Imgix value: + imgix(value); break; - case URLRewriterVariants::Akamai inner: - akamai(inner); + case Akamai value: + akamai(value); break; default: throw new InvalidOperationException(); } } - public T Match( - Func cloudinary, - Func imgix, - Func akamai - ) + public T Match(Func cloudinary, Func imgix, Func akamai) { - return this switch + return this.Value switch { URLRewriterVariants::Cloudinary inner => cloudinary(inner), URLRewriterVariants::Imgix inner => imgix(inner), @@ -74,7 +87,15 @@ public T Match( }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException("Data did not match any variant of URLRewriter"); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class URLRewriterConverter : JsonConverter @@ -107,10 +128,11 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(json, options); if (deserialized != null) { - return new URLRewriterVariants::Cloudinary(deserialized); + deserialized.Validate(); + return new URLRewriter(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -123,11 +145,14 @@ JsonSerializerOptions options try { - return new URLRewriterVariants::Imgix( - JsonSerializer.Deserialize(json, options) - ); + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + deserialized.Validate(); + return new URLRewriter(deserialized); + } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -140,11 +165,14 @@ JsonSerializerOptions options try { - return new URLRewriterVariants::Akamai( - JsonSerializer.Deserialize(json, options) - ); + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + deserialized.Validate(); + return new URLRewriter(deserialized); + } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/Akamai.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/Akamai.cs new file mode 100644 index 00000000..fa60b271 --- /dev/null +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/Akamai.cs @@ -0,0 +1,51 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; + +namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointCreateParamsProperties.URLRewriterProperties; + +[JsonConverter(typeof(Converter))] +public class Akamai +{ + public JsonElement Json { get; private init; } + + public Akamai() + { + Json = JsonSerializer.Deserialize("{\"type\":\"AKAMAI\"}"); + } + + Akamai(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new Akamai().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'Akamai'"); + } + } + + private class Converter : JsonConverter + { + public override Akamai? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write( + Utf8JsonWriter writer, + Akamai value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/AkamaiProperties/Type.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/AkamaiProperties/Type.cs new file mode 100644 index 00000000..2bee015a --- /dev/null +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/AkamaiProperties/Type.cs @@ -0,0 +1,47 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; +using System = System; + +namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointCreateParamsProperties.URLRewriterProperties.AkamaiProperties; + +[JsonConverter(typeof(Converter))] +public class Type +{ + public JsonElement Json { get; private init; } + + public Type() + { + Json = JsonSerializer.Deserialize("\"AKAMAI\""); + } + + Type(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new Type().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); + } + } + + private class Converter : JsonConverter + { + public override Type? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/Cloudinary.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/Cloudinary.cs index b3ff7019..10cd32d5 100644 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/Cloudinary.cs +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/Cloudinary.cs @@ -9,14 +9,21 @@ namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointCreateParamsPropertie [JsonConverter(typeof(ModelConverter))] public sealed record class Cloudinary : ModelBase, IFromRaw { - public JsonElement Type + public CloudinaryProperties::Type Type { get { if (!this.Properties.TryGetValue("type", out JsonElement element)) throw new ArgumentOutOfRangeException("type", "Missing required argument"); - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ) + ?? throw new ImageKitInvalidDataException( + "'type' cannot be null", + new ArgumentNullException("type") + ); } set { @@ -50,12 +57,13 @@ public bool? PreserveAssetDeliveryTypes public override void Validate() { + this.Type.Validate(); _ = this.PreserveAssetDeliveryTypes; } public Cloudinary() { - this.Type = JsonSerializer.Deserialize("\"CLOUDINARY\""); + this.Type = new(); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/CloudinaryProperties/Type.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/CloudinaryProperties/Type.cs new file mode 100644 index 00000000..f7c999cc --- /dev/null +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/CloudinaryProperties/Type.cs @@ -0,0 +1,47 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; +using System = System; + +namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointCreateParamsProperties.URLRewriterProperties.CloudinaryProperties; + +[JsonConverter(typeof(Converter))] +public class Type +{ + public JsonElement Json { get; private init; } + + public Type() + { + Json = JsonSerializer.Deserialize("\"CLOUDINARY\""); + } + + Type(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new Type().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); + } + } + + private class Converter : JsonConverter + { + public override Type? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/Imgix.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/Imgix.cs new file mode 100644 index 00000000..d27e674a --- /dev/null +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/Imgix.cs @@ -0,0 +1,51 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; + +namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointCreateParamsProperties.URLRewriterProperties; + +[JsonConverter(typeof(Converter))] +public class Imgix +{ + public JsonElement Json { get; private init; } + + public Imgix() + { + Json = JsonSerializer.Deserialize("{\"type\":\"IMGIX\"}"); + } + + Imgix(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new Imgix().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'Imgix'"); + } + } + + private class Converter : JsonConverter + { + public override Imgix? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write( + Utf8JsonWriter writer, + Imgix value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/ImgixProperties/Type.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/ImgixProperties/Type.cs new file mode 100644 index 00000000..6557764d --- /dev/null +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/ImgixProperties/Type.cs @@ -0,0 +1,47 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; +using System = System; + +namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointCreateParamsProperties.URLRewriterProperties.ImgixProperties; + +[JsonConverter(typeof(Converter))] +public class Type +{ + public JsonElement Json { get; private init; } + + public Type() + { + Json = JsonSerializer.Deserialize("\"IMGIX\""); + } + + Type(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new Type().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); + } + } + + private class Converter : JsonConverter + { + public override Type? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriter.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriter.cs index 71eb3496..3220fb71 100644 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriter.cs +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriter.cs @@ -4,7 +4,6 @@ using System.Text.Json; using System.Text.Json.Serialization; using Imagekit.Models.Accounts.URLEndpoints.URLEndpointRequestProperties.URLRewriterProperties; -using URLRewriterVariants = Imagekit.Models.Accounts.URLEndpoints.URLEndpointRequestProperties.URLRewriterVariants; namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointRequestProperties; @@ -12,60 +11,74 @@ namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointRequestProperties; /// Configuration for third-party URL rewriting. ///
[JsonConverter(typeof(URLRewriterConverter))] -public abstract record class URLRewriter +public record class URLRewriter { - internal URLRewriter() { } + public object Value { get; private init; } - public static implicit operator URLRewriter(Cloudinary value) => - new URLRewriterVariants::Cloudinary(value); + public URLRewriter(Cloudinary value) + { + Value = value; + } + + public URLRewriter(Imgix value) + { + Value = value; + } + + public URLRewriter(Akamai value) + { + Value = value; + } + + URLRewriter(UnknownVariant value) + { + Value = value; + } + + public static URLRewriter CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickCloudinary([NotNullWhen(true)] out Cloudinary? value) { - value = (this as URLRewriterVariants::Cloudinary)?.Value; + value = this.Value as Cloudinary; return value != null; } - public bool TryPickImgix([NotNullWhen(true)] out JsonElement? value) + public bool TryPickImgix([NotNullWhen(true)] out Imgix? value) { - value = (this as URLRewriterVariants::Imgix)?.Value; + value = this.Value as Imgix; return value != null; } - public bool TryPickAkamai([NotNullWhen(true)] out JsonElement? value) + public bool TryPickAkamai([NotNullWhen(true)] out Akamai? value) { - value = (this as URLRewriterVariants::Akamai)?.Value; + value = this.Value as Akamai; return value != null; } - public void Switch( - Action cloudinary, - Action imgix, - Action akamai - ) + public void Switch(Action cloudinary, Action imgix, Action akamai) { - switch (this) + switch (this.Value) { - case URLRewriterVariants::Cloudinary inner: - cloudinary(inner); + case Cloudinary value: + cloudinary(value); break; - case URLRewriterVariants::Imgix inner: - imgix(inner); + case Imgix value: + imgix(value); break; - case URLRewriterVariants::Akamai inner: - akamai(inner); + case Akamai value: + akamai(value); break; default: throw new InvalidOperationException(); } } - public T Match( - Func cloudinary, - Func imgix, - Func akamai - ) + public T Match(Func cloudinary, Func imgix, Func akamai) { - return this switch + return this.Value switch { URLRewriterVariants::Cloudinary inner => cloudinary(inner), URLRewriterVariants::Imgix inner => imgix(inner), @@ -74,7 +87,15 @@ public T Match( }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException("Data did not match any variant of URLRewriter"); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class URLRewriterConverter : JsonConverter @@ -107,10 +128,11 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(json, options); if (deserialized != null) { - return new URLRewriterVariants::Cloudinary(deserialized); + deserialized.Validate(); + return new URLRewriter(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -123,11 +145,14 @@ JsonSerializerOptions options try { - return new URLRewriterVariants::Imgix( - JsonSerializer.Deserialize(json, options) - ); + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + deserialized.Validate(); + return new URLRewriter(deserialized); + } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -140,11 +165,14 @@ JsonSerializerOptions options try { - return new URLRewriterVariants::Akamai( - JsonSerializer.Deserialize(json, options) - ); + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + deserialized.Validate(); + return new URLRewriter(deserialized); + } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/Akamai.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/Akamai.cs new file mode 100644 index 00000000..4a48a300 --- /dev/null +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/Akamai.cs @@ -0,0 +1,51 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; + +namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointRequestProperties.URLRewriterProperties; + +[JsonConverter(typeof(Converter))] +public class Akamai +{ + public JsonElement Json { get; private init; } + + public Akamai() + { + Json = JsonSerializer.Deserialize("{\"type\":\"AKAMAI\"}"); + } + + Akamai(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new Akamai().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'Akamai'"); + } + } + + private class Converter : JsonConverter + { + public override Akamai? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write( + Utf8JsonWriter writer, + Akamai value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/AkamaiProperties/Type.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/AkamaiProperties/Type.cs new file mode 100644 index 00000000..a6688bd3 --- /dev/null +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/AkamaiProperties/Type.cs @@ -0,0 +1,47 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; +using System = System; + +namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointRequestProperties.URLRewriterProperties.AkamaiProperties; + +[JsonConverter(typeof(Converter))] +public class Type +{ + public JsonElement Json { get; private init; } + + public Type() + { + Json = JsonSerializer.Deserialize("\"AKAMAI\""); + } + + Type(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new Type().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); + } + } + + private class Converter : JsonConverter + { + public override Type? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/Cloudinary.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/Cloudinary.cs index e411df9a..ebb8f940 100644 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/Cloudinary.cs +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/Cloudinary.cs @@ -9,14 +9,21 @@ namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointRequestProperties.URL [JsonConverter(typeof(ModelConverter))] public sealed record class Cloudinary : ModelBase, IFromRaw { - public JsonElement Type + public CloudinaryProperties::Type Type { get { if (!this.Properties.TryGetValue("type", out JsonElement element)) throw new ArgumentOutOfRangeException("type", "Missing required argument"); - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ) + ?? throw new ImageKitInvalidDataException( + "'type' cannot be null", + new ArgumentNullException("type") + ); } set { @@ -50,12 +57,13 @@ public bool? PreserveAssetDeliveryTypes public override void Validate() { + this.Type.Validate(); _ = this.PreserveAssetDeliveryTypes; } public Cloudinary() { - this.Type = JsonSerializer.Deserialize("\"CLOUDINARY\""); + this.Type = new(); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/CloudinaryProperties/Type.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/CloudinaryProperties/Type.cs new file mode 100644 index 00000000..7b86640b --- /dev/null +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/CloudinaryProperties/Type.cs @@ -0,0 +1,47 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; +using System = System; + +namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointRequestProperties.URLRewriterProperties.CloudinaryProperties; + +[JsonConverter(typeof(Converter))] +public class Type +{ + public JsonElement Json { get; private init; } + + public Type() + { + Json = JsonSerializer.Deserialize("\"CLOUDINARY\""); + } + + Type(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new Type().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); + } + } + + private class Converter : JsonConverter + { + public override Type? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/Imgix.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/Imgix.cs new file mode 100644 index 00000000..5b8bda44 --- /dev/null +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/Imgix.cs @@ -0,0 +1,51 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; + +namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointRequestProperties.URLRewriterProperties; + +[JsonConverter(typeof(Converter))] +public class Imgix +{ + public JsonElement Json { get; private init; } + + public Imgix() + { + Json = JsonSerializer.Deserialize("{\"type\":\"IMGIX\"}"); + } + + Imgix(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new Imgix().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'Imgix'"); + } + } + + private class Converter : JsonConverter + { + public override Imgix? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write( + Utf8JsonWriter writer, + Imgix value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/ImgixProperties/Type.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/ImgixProperties/Type.cs new file mode 100644 index 00000000..ccc09db0 --- /dev/null +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/ImgixProperties/Type.cs @@ -0,0 +1,47 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; +using System = System; + +namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointRequestProperties.URLRewriterProperties.ImgixProperties; + +[JsonConverter(typeof(Converter))] +public class Type +{ + public JsonElement Json { get; private init; } + + public Type() + { + Json = JsonSerializer.Deserialize("\"IMGIX\""); + } + + Type(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new Type().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); + } + } + + private class Converter : JsonConverter + { + public override Type? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriter.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriter.cs index 8c65e9f6..613a5503 100644 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriter.cs +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriter.cs @@ -4,7 +4,6 @@ using System.Text.Json; using System.Text.Json.Serialization; using Imagekit.Models.Accounts.URLEndpoints.URLEndpointResponseProperties.URLRewriterProperties; -using URLRewriterVariants = Imagekit.Models.Accounts.URLEndpoints.URLEndpointResponseProperties.URLRewriterVariants; namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointResponseProperties; @@ -12,60 +11,74 @@ namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointResponseProperties; /// Configuration for third-party URL rewriting. ///
[JsonConverter(typeof(URLRewriterConverter))] -public abstract record class URLRewriter +public record class URLRewriter { - internal URLRewriter() { } + public object Value { get; private init; } - public static implicit operator URLRewriter(Cloudinary value) => - new URLRewriterVariants::Cloudinary(value); + public URLRewriter(Cloudinary value) + { + Value = value; + } + + public URLRewriter(Imgix value) + { + Value = value; + } + + public URLRewriter(Akamai value) + { + Value = value; + } + + URLRewriter(UnknownVariant value) + { + Value = value; + } + + public static URLRewriter CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickCloudinary([NotNullWhen(true)] out Cloudinary? value) { - value = (this as URLRewriterVariants::Cloudinary)?.Value; + value = this.Value as Cloudinary; return value != null; } - public bool TryPickImgix([NotNullWhen(true)] out JsonElement? value) + public bool TryPickImgix([NotNullWhen(true)] out Imgix? value) { - value = (this as URLRewriterVariants::Imgix)?.Value; + value = this.Value as Imgix; return value != null; } - public bool TryPickAkamai([NotNullWhen(true)] out JsonElement? value) + public bool TryPickAkamai([NotNullWhen(true)] out Akamai? value) { - value = (this as URLRewriterVariants::Akamai)?.Value; + value = this.Value as Akamai; return value != null; } - public void Switch( - Action cloudinary, - Action imgix, - Action akamai - ) + public void Switch(Action cloudinary, Action imgix, Action akamai) { - switch (this) + switch (this.Value) { - case URLRewriterVariants::Cloudinary inner: - cloudinary(inner); + case Cloudinary value: + cloudinary(value); break; - case URLRewriterVariants::Imgix inner: - imgix(inner); + case Imgix value: + imgix(value); break; - case URLRewriterVariants::Akamai inner: - akamai(inner); + case Akamai value: + akamai(value); break; default: throw new InvalidOperationException(); } } - public T Match( - Func cloudinary, - Func imgix, - Func akamai - ) + public T Match(Func cloudinary, Func imgix, Func akamai) { - return this switch + return this.Value switch { URLRewriterVariants::Cloudinary inner => cloudinary(inner), URLRewriterVariants::Imgix inner => imgix(inner), @@ -74,7 +87,15 @@ public T Match( }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException("Data did not match any variant of URLRewriter"); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class URLRewriterConverter : JsonConverter @@ -107,10 +128,11 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(json, options); if (deserialized != null) { - return new URLRewriterVariants::Cloudinary(deserialized); + deserialized.Validate(); + return new URLRewriter(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -123,11 +145,14 @@ JsonSerializerOptions options try { - return new URLRewriterVariants::Imgix( - JsonSerializer.Deserialize(json, options) - ); + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + deserialized.Validate(); + return new URLRewriter(deserialized); + } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -140,11 +165,14 @@ JsonSerializerOptions options try { - return new URLRewriterVariants::Akamai( - JsonSerializer.Deserialize(json, options) - ); + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + deserialized.Validate(); + return new URLRewriter(deserialized); + } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/Akamai.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/Akamai.cs new file mode 100644 index 00000000..6a511314 --- /dev/null +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/Akamai.cs @@ -0,0 +1,51 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; + +namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointResponseProperties.URLRewriterProperties; + +[JsonConverter(typeof(Converter))] +public class Akamai +{ + public JsonElement Json { get; private init; } + + public Akamai() + { + Json = JsonSerializer.Deserialize("{\"type\":\"AKAMAI\"}"); + } + + Akamai(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new Akamai().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'Akamai'"); + } + } + + private class Converter : JsonConverter + { + public override Akamai? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write( + Utf8JsonWriter writer, + Akamai value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/AkamaiProperties/Type.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/AkamaiProperties/Type.cs new file mode 100644 index 00000000..ee57be83 --- /dev/null +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/AkamaiProperties/Type.cs @@ -0,0 +1,47 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; +using System = System; + +namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointResponseProperties.URLRewriterProperties.AkamaiProperties; + +[JsonConverter(typeof(Converter))] +public class Type +{ + public JsonElement Json { get; private init; } + + public Type() + { + Json = JsonSerializer.Deserialize("\"AKAMAI\""); + } + + Type(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new Type().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); + } + } + + private class Converter : JsonConverter + { + public override Type? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/Cloudinary.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/Cloudinary.cs index 0629bebe..86d99730 100644 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/Cloudinary.cs +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/Cloudinary.cs @@ -33,14 +33,21 @@ public required bool PreserveAssetDeliveryTypes } } - public JsonElement Type + public CloudinaryProperties::Type Type { get { if (!this.Properties.TryGetValue("type", out JsonElement element)) throw new ArgumentOutOfRangeException("type", "Missing required argument"); - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ) + ?? throw new ImageKitInvalidDataException( + "'type' cannot be null", + new ArgumentNullException("type") + ); } set { @@ -54,11 +61,12 @@ public JsonElement Type public override void Validate() { _ = this.PreserveAssetDeliveryTypes; + this.Type.Validate(); } public Cloudinary() { - this.Type = JsonSerializer.Deserialize("\"CLOUDINARY\""); + this.Type = new(); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/CloudinaryProperties/Type.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/CloudinaryProperties/Type.cs new file mode 100644 index 00000000..c5b9419c --- /dev/null +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/CloudinaryProperties/Type.cs @@ -0,0 +1,47 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; +using System = System; + +namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointResponseProperties.URLRewriterProperties.CloudinaryProperties; + +[JsonConverter(typeof(Converter))] +public class Type +{ + public JsonElement Json { get; private init; } + + public Type() + { + Json = JsonSerializer.Deserialize("\"CLOUDINARY\""); + } + + Type(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new Type().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); + } + } + + private class Converter : JsonConverter + { + public override Type? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/Imgix.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/Imgix.cs new file mode 100644 index 00000000..c22720f1 --- /dev/null +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/Imgix.cs @@ -0,0 +1,51 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; + +namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointResponseProperties.URLRewriterProperties; + +[JsonConverter(typeof(Converter))] +public class Imgix +{ + public JsonElement Json { get; private init; } + + public Imgix() + { + Json = JsonSerializer.Deserialize("{\"type\":\"IMGIX\"}"); + } + + Imgix(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new Imgix().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'Imgix'"); + } + } + + private class Converter : JsonConverter + { + public override Imgix? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write( + Utf8JsonWriter writer, + Imgix value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/ImgixProperties/Type.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/ImgixProperties/Type.cs new file mode 100644 index 00000000..1d907a37 --- /dev/null +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/ImgixProperties/Type.cs @@ -0,0 +1,47 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; +using System = System; + +namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointResponseProperties.URLRewriterProperties.ImgixProperties; + +[JsonConverter(typeof(Converter))] +public class Type +{ + public JsonElement Json { get; private init; } + + public Type() + { + Json = JsonSerializer.Deserialize("\"IMGIX\""); + } + + Type(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new Type().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); + } + } + + private class Converter : JsonConverter + { + public override Type? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriter.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriter.cs index 46a017ae..ef6f853a 100644 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriter.cs +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriter.cs @@ -4,7 +4,6 @@ using System.Text.Json; using System.Text.Json.Serialization; using Imagekit.Models.Accounts.URLEndpoints.URLEndpointUpdateParamsProperties.URLRewriterProperties; -using URLRewriterVariants = Imagekit.Models.Accounts.URLEndpoints.URLEndpointUpdateParamsProperties.URLRewriterVariants; namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointUpdateParamsProperties; @@ -12,60 +11,74 @@ namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointUpdateParamsPropertie /// Configuration for third-party URL rewriting. ///
[JsonConverter(typeof(URLRewriterConverter))] -public abstract record class URLRewriter +public record class URLRewriter { - internal URLRewriter() { } + public object Value { get; private init; } - public static implicit operator URLRewriter(Cloudinary value) => - new URLRewriterVariants::Cloudinary(value); + public URLRewriter(Cloudinary value) + { + Value = value; + } + + public URLRewriter(Imgix value) + { + Value = value; + } + + public URLRewriter(Akamai value) + { + Value = value; + } + + URLRewriter(UnknownVariant value) + { + Value = value; + } + + public static URLRewriter CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickCloudinary([NotNullWhen(true)] out Cloudinary? value) { - value = (this as URLRewriterVariants::Cloudinary)?.Value; + value = this.Value as Cloudinary; return value != null; } - public bool TryPickImgix([NotNullWhen(true)] out JsonElement? value) + public bool TryPickImgix([NotNullWhen(true)] out Imgix? value) { - value = (this as URLRewriterVariants::Imgix)?.Value; + value = this.Value as Imgix; return value != null; } - public bool TryPickAkamai([NotNullWhen(true)] out JsonElement? value) + public bool TryPickAkamai([NotNullWhen(true)] out Akamai? value) { - value = (this as URLRewriterVariants::Akamai)?.Value; + value = this.Value as Akamai; return value != null; } - public void Switch( - Action cloudinary, - Action imgix, - Action akamai - ) + public void Switch(Action cloudinary, Action imgix, Action akamai) { - switch (this) + switch (this.Value) { - case URLRewriterVariants::Cloudinary inner: - cloudinary(inner); + case Cloudinary value: + cloudinary(value); break; - case URLRewriterVariants::Imgix inner: - imgix(inner); + case Imgix value: + imgix(value); break; - case URLRewriterVariants::Akamai inner: - akamai(inner); + case Akamai value: + akamai(value); break; default: throw new InvalidOperationException(); } } - public T Match( - Func cloudinary, - Func imgix, - Func akamai - ) + public T Match(Func cloudinary, Func imgix, Func akamai) { - return this switch + return this.Value switch { URLRewriterVariants::Cloudinary inner => cloudinary(inner), URLRewriterVariants::Imgix inner => imgix(inner), @@ -74,7 +87,15 @@ public T Match( }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException("Data did not match any variant of URLRewriter"); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class URLRewriterConverter : JsonConverter @@ -107,10 +128,11 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(json, options); if (deserialized != null) { - return new URLRewriterVariants::Cloudinary(deserialized); + deserialized.Validate(); + return new URLRewriter(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -123,11 +145,14 @@ JsonSerializerOptions options try { - return new URLRewriterVariants::Imgix( - JsonSerializer.Deserialize(json, options) - ); + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + deserialized.Validate(); + return new URLRewriter(deserialized); + } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -140,11 +165,14 @@ JsonSerializerOptions options try { - return new URLRewriterVariants::Akamai( - JsonSerializer.Deserialize(json, options) - ); + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + deserialized.Validate(); + return new URLRewriter(deserialized); + } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/Akamai.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/Akamai.cs new file mode 100644 index 00000000..9707dc31 --- /dev/null +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/Akamai.cs @@ -0,0 +1,51 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; + +namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointUpdateParamsProperties.URLRewriterProperties; + +[JsonConverter(typeof(Converter))] +public class Akamai +{ + public JsonElement Json { get; private init; } + + public Akamai() + { + Json = JsonSerializer.Deserialize("{\"type\":\"AKAMAI\"}"); + } + + Akamai(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new Akamai().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'Akamai'"); + } + } + + private class Converter : JsonConverter + { + public override Akamai? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write( + Utf8JsonWriter writer, + Akamai value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/AkamaiProperties/Type.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/AkamaiProperties/Type.cs new file mode 100644 index 00000000..bffd19fd --- /dev/null +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/AkamaiProperties/Type.cs @@ -0,0 +1,47 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; +using System = System; + +namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointUpdateParamsProperties.URLRewriterProperties.AkamaiProperties; + +[JsonConverter(typeof(Converter))] +public class Type +{ + public JsonElement Json { get; private init; } + + public Type() + { + Json = JsonSerializer.Deserialize("\"AKAMAI\""); + } + + Type(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new Type().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); + } + } + + private class Converter : JsonConverter + { + public override Type? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/Cloudinary.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/Cloudinary.cs index 52353ebb..aba050c2 100644 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/Cloudinary.cs +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/Cloudinary.cs @@ -9,14 +9,21 @@ namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointUpdateParamsPropertie [JsonConverter(typeof(ModelConverter))] public sealed record class Cloudinary : ModelBase, IFromRaw { - public JsonElement Type + public CloudinaryProperties::Type Type { get { if (!this.Properties.TryGetValue("type", out JsonElement element)) throw new ArgumentOutOfRangeException("type", "Missing required argument"); - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ) + ?? throw new ImageKitInvalidDataException( + "'type' cannot be null", + new ArgumentNullException("type") + ); } set { @@ -50,12 +57,13 @@ public bool? PreserveAssetDeliveryTypes public override void Validate() { + this.Type.Validate(); _ = this.PreserveAssetDeliveryTypes; } public Cloudinary() { - this.Type = JsonSerializer.Deserialize("\"CLOUDINARY\""); + this.Type = new(); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/CloudinaryProperties/Type.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/CloudinaryProperties/Type.cs new file mode 100644 index 00000000..adf4e4c8 --- /dev/null +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/CloudinaryProperties/Type.cs @@ -0,0 +1,47 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; +using System = System; + +namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointUpdateParamsProperties.URLRewriterProperties.CloudinaryProperties; + +[JsonConverter(typeof(Converter))] +public class Type +{ + public JsonElement Json { get; private init; } + + public Type() + { + Json = JsonSerializer.Deserialize("\"CLOUDINARY\""); + } + + Type(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new Type().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); + } + } + + private class Converter : JsonConverter + { + public override Type? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/Imgix.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/Imgix.cs new file mode 100644 index 00000000..b77b8c08 --- /dev/null +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/Imgix.cs @@ -0,0 +1,51 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; + +namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointUpdateParamsProperties.URLRewriterProperties; + +[JsonConverter(typeof(Converter))] +public class Imgix +{ + public JsonElement Json { get; private init; } + + public Imgix() + { + Json = JsonSerializer.Deserialize("{\"type\":\"IMGIX\"}"); + } + + Imgix(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new Imgix().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'Imgix'"); + } + } + + private class Converter : JsonConverter + { + public override Imgix? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write( + Utf8JsonWriter writer, + Imgix value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/ImgixProperties/Type.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/ImgixProperties/Type.cs new file mode 100644 index 00000000..18f37014 --- /dev/null +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/ImgixProperties/Type.cs @@ -0,0 +1,47 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; +using System = System; + +namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointUpdateParamsProperties.URLRewriterProperties.ImgixProperties; + +[JsonConverter(typeof(Converter))] +public class Type +{ + public JsonElement Json { get; private init; } + + public Type() + { + Json = JsonSerializer.Deserialize("\"IMGIX\""); + } + + Type(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new Type().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); + } + } + + private class Converter : JsonConverter + { + public override Type? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/Assets/AssetListResponse.cs b/src/Imagekit/Models/Assets/AssetListResponse.cs index 0bc73723..71abd63f 100644 --- a/src/Imagekit/Models/Assets/AssetListResponse.cs +++ b/src/Imagekit/Models/Assets/AssetListResponse.cs @@ -4,7 +4,6 @@ using System.Text.Json; using System.Text.Json.Serialization; using Imagekit.Models.Files; -using AssetListResponseVariants = Imagekit.Models.Assets.AssetListResponseVariants; namespace Imagekit.Models.Assets; @@ -12,52 +11,75 @@ namespace Imagekit.Models.Assets; /// Object containing details of a file or file version. ///
[JsonConverter(typeof(AssetListResponseConverter))] -public abstract record class AssetListResponse +public record class AssetListResponse { - internal AssetListResponse() { } + public object Value { get; private init; } - public static implicit operator AssetListResponse(File value) => - new AssetListResponseVariants::File(value); + public DateTime? CreatedAt + { + get { return Match(file: (x) => x.CreatedAt, folder: (x) => x.CreatedAt); } + } + + public string? Name + { + get { return Match(file: (x) => x.Name, folder: (x) => x.Name); } + } + + public DateTime? UpdatedAt + { + get { return Match(file: (x) => x.UpdatedAt, folder: (x) => x.UpdatedAt); } + } + + public AssetListResponse(File value) + { + Value = value; + } + + public AssetListResponse(Folder value) + { + Value = value; + } - public static implicit operator AssetListResponse(Folder value) => - new AssetListResponseVariants::Folder(value); + AssetListResponse(UnknownVariant value) + { + Value = value; + } + + public static AssetListResponse CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickFile([NotNullWhen(true)] out File? value) { - value = (this as AssetListResponseVariants::File)?.Value; + value = this.Value as File; return value != null; } public bool TryPickFolder([NotNullWhen(true)] out Folder? value) { - value = (this as AssetListResponseVariants::Folder)?.Value; + value = this.Value as Folder; return value != null; } - public void Switch( - Action file, - Action folder - ) + public void Switch(Action file, Action folder) { - switch (this) + switch (this.Value) { - case AssetListResponseVariants::File inner: - file(inner); + case File value: + file(value); break; - case AssetListResponseVariants::Folder inner: - folder(inner); + case Folder value: + folder(value); break; default: throw new InvalidOperationException(); } } - public T Match( - Func file, - Func folder - ) + public T Match(Func file, Func folder) { - return this switch + return this.Value switch { AssetListResponseVariants::File inner => file(inner), AssetListResponseVariants::Folder inner => folder(inner), @@ -65,7 +87,17 @@ public T Match( }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of AssetListResponse" + ); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class AssetListResponseConverter : JsonConverter @@ -98,10 +130,11 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(json, options); if (deserialized != null) { - return new AssetListResponseVariants::Folder(deserialized); + deserialized.Validate(); + return new AssetListResponse(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -117,10 +150,11 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(json, options); if (deserialized != null) { - return new AssetListResponseVariants::File(deserialized); + deserialized.Validate(); + return new AssetListResponse(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/Post.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/Post.cs index aafee3dc..0ed859e6 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/Post.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/Post.cs @@ -4,70 +4,101 @@ using System.Text.Json; using System.Text.Json.Serialization; using PostProperties = Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; -using PostVariants = Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostVariants; namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties; [JsonConverter(typeof(PostConverter))] -public abstract record class Post +public record class Post { - internal Post() { } + public object Value { get; private init; } - public static implicit operator Post(PostProperties::Transformation value) => - new PostVariants::Transformation(value); + public string? Value1 + { + get + { + return Match( + transformation: (x) => x.Value, + gifToVideo: (x) => x.Value, + thumbnail: (x) => x.Value, + abs: (x) => x.Value + ); + } + } + + public Post(PostProperties::Transformation value) + { + Value = value; + } + + public Post(PostProperties::GifToVideo value) + { + Value = value; + } + + public Post(PostProperties::Thumbnail value) + { + Value = value; + } - public static implicit operator Post(PostProperties::GifToVideo value) => - new PostVariants::GifToVideo(value); + public Post(PostProperties::Abs value) + { + Value = value; + } - public static implicit operator Post(PostProperties::Thumbnail value) => - new PostVariants::Thumbnail(value); + Post(UnknownVariant value) + { + Value = value; + } - public static implicit operator Post(PostProperties::Abs value) => new PostVariants::Abs(value); + public static Post CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickTransformation([NotNullWhen(true)] out PostProperties::Transformation? value) { - value = (this as PostVariants::Transformation)?.Value; + value = this.Value as PostProperties::Transformation; return value != null; } public bool TryPickGifToVideo([NotNullWhen(true)] out PostProperties::GifToVideo? value) { - value = (this as PostVariants::GifToVideo)?.Value; + value = this.Value as PostProperties::GifToVideo; return value != null; } public bool TryPickThumbnail([NotNullWhen(true)] out PostProperties::Thumbnail? value) { - value = (this as PostVariants::Thumbnail)?.Value; + value = this.Value as PostProperties::Thumbnail; return value != null; } public bool TryPickAbs([NotNullWhen(true)] out PostProperties::Abs? value) { - value = (this as PostVariants::Abs)?.Value; + value = this.Value as PostProperties::Abs; return value != null; } public void Switch( - Action transformation, - Action gifToVideo, - Action thumbnail, - Action abs + Action transformation, + Action gifToVideo, + Action thumbnail, + Action abs ) { - switch (this) + switch (this.Value) { - case PostVariants::Transformation inner: - transformation(inner); + case PostProperties::Transformation value: + transformation(value); break; - case PostVariants::GifToVideo inner: - gifToVideo(inner); + case PostProperties::GifToVideo value: + gifToVideo(value); break; - case PostVariants::Thumbnail inner: - thumbnail(inner); + case PostProperties::Thumbnail value: + thumbnail(value); break; - case PostVariants::Abs inner: - abs(inner); + case PostProperties::Abs value: + abs(value); break; default: throw new InvalidOperationException(); @@ -75,13 +106,13 @@ public void Switch( } public T Match( - Func transformation, - Func gifToVideo, - Func thumbnail, - Func abs + Func transformation, + Func gifToVideo, + Func thumbnail, + Func abs ) { - return this switch + return this.Value switch { PostVariants::Transformation inner => transformation(inner), PostVariants::GifToVideo inner => gifToVideo(inner), @@ -91,7 +122,15 @@ public T Match( }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException("Data did not match any variant of Post"); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class PostConverter : JsonConverter @@ -127,10 +166,11 @@ JsonSerializerOptions options ); if (deserialized != null) { - return new PostVariants::Transformation(deserialized); + deserialized.Validate(); + return new Post(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -149,10 +189,11 @@ JsonSerializerOptions options ); if (deserialized != null) { - return new PostVariants::GifToVideo(deserialized); + deserialized.Validate(); + return new Post(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -171,10 +212,11 @@ JsonSerializerOptions options ); if (deserialized != null) { - return new PostVariants::Thumbnail(deserialized); + deserialized.Validate(); + return new Post(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -193,10 +235,11 @@ JsonSerializerOptions options ); if (deserialized != null) { - return new PostVariants::Abs(deserialized); + deserialized.Validate(); + return new Post(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Abs.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Abs.cs index baf612e4..56cb3f6e 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Abs.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Abs.cs @@ -13,14 +13,14 @@ public sealed record class Abs : ModelBase, IFromRaw /// /// Streaming protocol to use (`hls` or `dash`). /// - public required ApiEnum Protocol + public required ApiEnum Protocol { get { if (!this.Properties.TryGetValue("protocol", out JsonElement element)) throw new ArgumentOutOfRangeException("protocol", "Missing required argument"); - return JsonSerializer.Deserialize>( + return JsonSerializer.Deserialize>( element, ModelBase.SerializerOptions ); @@ -37,14 +37,21 @@ public required ApiEnum Protocol /// /// Adaptive Bitrate Streaming (ABS) setup. /// - public JsonElement Type + public AbsProperties::Type Type { get { if (!this.Properties.TryGetValue("type", out JsonElement element)) throw new ArgumentOutOfRangeException("type", "Missing required argument"); - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ) + ?? throw new ImageKitInvalidDataException( + "'type' cannot be null", + new ArgumentNullException("type") + ); } set { @@ -80,12 +87,13 @@ public required string Value public override void Validate() { this.Protocol.Validate(); + this.Type.Validate(); _ = this.Value; } public Abs() { - this.Type = JsonSerializer.Deserialize("\"abs\""); + this.Type = new(); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/AbsProperties/Type.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/AbsProperties/Type.cs new file mode 100644 index 00000000..2b68a5eb --- /dev/null +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/AbsProperties/Type.cs @@ -0,0 +1,50 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; +using System = System; + +namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.AbsProperties; + +/// +/// Adaptive Bitrate Streaming (ABS) setup. +/// +[JsonConverter(typeof(Converter))] +public class Type +{ + public JsonElement Json { get; private init; } + + public Type() + { + Json = JsonSerializer.Deserialize("\"abs\""); + } + + Type(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new Type().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); + } + } + + private class Converter : JsonConverter + { + public override Type? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideo.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideo.cs index 0f17f223..565aed5d 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideo.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideo.cs @@ -12,14 +12,21 @@ public sealed record class GifToVideo : ModelBase, IFromRaw /// /// Converts an animated GIF into an MP4. /// - public JsonElement Type + public GifToVideoProperties::Type Type { get { if (!this.Properties.TryGetValue("type", out JsonElement element)) throw new ArgumentOutOfRangeException("type", "Missing required argument"); - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ) + ?? throw new ImageKitInvalidDataException( + "'type' cannot be null", + new ArgumentNullException("type") + ); } set { @@ -54,12 +61,13 @@ public string? Value public override void Validate() { + this.Type.Validate(); _ = this.Value; } public GifToVideo() { - this.Type = JsonSerializer.Deserialize("\"gif-to-video\""); + this.Type = new(); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideoProperties/Type.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideoProperties/Type.cs new file mode 100644 index 00000000..b429e756 --- /dev/null +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideoProperties/Type.cs @@ -0,0 +1,50 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; +using System = System; + +namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.GifToVideoProperties; + +/// +/// Converts an animated GIF into an MP4. +/// +[JsonConverter(typeof(Converter))] +public class Type +{ + public JsonElement Json { get; private init; } + + public Type() + { + Json = JsonSerializer.Deserialize("\"gif-to-video\""); + } + + Type(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new Type().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); + } + } + + private class Converter : JsonConverter + { + public override Type? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Thumbnail.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Thumbnail.cs index 46493eea..23ab2438 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Thumbnail.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Thumbnail.cs @@ -12,14 +12,21 @@ public sealed record class Thumbnail : ModelBase, IFromRaw /// /// Generates a thumbnail image. /// - public JsonElement Type + public ThumbnailProperties::Type Type { get { if (!this.Properties.TryGetValue("type", out JsonElement element)) throw new ArgumentOutOfRangeException("type", "Missing required argument"); - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ) + ?? throw new ImageKitInvalidDataException( + "'type' cannot be null", + new ArgumentNullException("type") + ); } set { @@ -53,12 +60,13 @@ public string? Value public override void Validate() { + this.Type.Validate(); _ = this.Value; } public Thumbnail() { - this.Type = JsonSerializer.Deserialize("\"thumbnail\""); + this.Type = new(); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/ThumbnailProperties/Type.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/ThumbnailProperties/Type.cs new file mode 100644 index 00000000..283c5d2a --- /dev/null +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/ThumbnailProperties/Type.cs @@ -0,0 +1,50 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; +using System = System; + +namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.ThumbnailProperties; + +/// +/// Generates a thumbnail image. +/// +[JsonConverter(typeof(Converter))] +public class Type +{ + public JsonElement Json { get; private init; } + + public Type() + { + Json = JsonSerializer.Deserialize("\"thumbnail\""); + } + + Type(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new Type().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); + } + } + + private class Converter : JsonConverter + { + public override Type? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Transformation.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Transformation.cs index 9492fb7a..a63f82cf 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Transformation.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Transformation.cs @@ -12,14 +12,21 @@ public sealed record class Transformation : ModelBase, IFromRaw /// /// Transformation type. /// - public JsonElement Type + public TransformationProperties::Type Type { get { if (!this.Properties.TryGetValue("type", out JsonElement element)) throw new ArgumentOutOfRangeException("type", "Missing required argument"); - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ) + ?? throw new ImageKitInvalidDataException( + "'type' cannot be null", + new ArgumentNullException("type") + ); } set { @@ -55,12 +62,13 @@ public required string Value public override void Validate() { + this.Type.Validate(); _ = this.Value; } public Transformation() { - this.Type = JsonSerializer.Deserialize("\"transformation\""); + this.Type = new(); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/TransformationProperties/Type.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/TransformationProperties/Type.cs new file mode 100644 index 00000000..cd309429 --- /dev/null +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/TransformationProperties/Type.cs @@ -0,0 +1,50 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; +using System = System; + +namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.TransformationProperties; + +/// +/// Transformation type. +/// +[JsonConverter(typeof(Converter))] +public class Type +{ + public JsonElement Json { get; private init; } + + public Type() + { + Json = JsonSerializer.Deserialize("\"transformation\""); + } + + Type(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new Type().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); + } + } + + private class Converter : JsonConverter + { + public override Type? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs index e9c9cfc6..fc1fc3cd 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs @@ -4,7 +4,6 @@ using System.Text.Json.Serialization; using Imagekit.Exceptions; using Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties; -using Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueVariants; using System = System; namespace Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; @@ -14,63 +13,84 @@ namespace Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFie /// `type` of custom metadata field. ///
[JsonConverter(typeof(DefaultValueConverter))] -public abstract record class DefaultValue +public record class DefaultValue { - internal DefaultValue() { } + public object Value { get; private init; } - public static implicit operator DefaultValue(string value) => new String(value); + public DefaultValue(string value) + { + Value = value; + } - public static implicit operator DefaultValue(double value) => new Double(value); + public DefaultValue(double value) + { + Value = value; + } - public static implicit operator DefaultValue(bool value) => new Bool(value); + public DefaultValue(bool value) + { + Value = value; + } - public static implicit operator DefaultValue(List value) => - new Mixed(value); + public DefaultValue(List value) + { + Value = value; + } + + DefaultValue(UnknownVariant value) + { + Value = value; + } + + public static DefaultValue CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as String)?.Value; + value = this.Value as string; return value != null; } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as Double)?.Value; + value = this.Value as double?; return value != null; } public bool TryPickBool([NotNullWhen(true)] out bool? value) { - value = (this as Bool)?.Value; + value = this.Value as bool?; return value != null; } public bool TryPickMixed([NotNullWhen(true)] out List? value) { - value = (this as Mixed)?.Value; + value = this.Value as List; return value != null; } public void Switch( - System::Action @string, - System::Action @double, - System::Action @bool, - System::Action mixed + System::Action @string, + System::Action @double, + System::Action @bool, + System::Action> mixed ) { - switch (this) + switch (this.Value) { - case String inner: - @string(inner); + case string value: + @string(value); break; - case Double inner: - @double(inner); + case double value: + @double(value); break; - case Bool inner: - @bool(inner); + case bool value: + @bool(value); break; - case Mixed inner: - mixed(inner); + case List value: + mixed(value); break; default: throw new ImageKitInvalidDataException( @@ -80,25 +100,35 @@ public void Switch( } public T Match( - System::Func @string, - System::Func @double, - System::Func @bool, - System::Func mixed + System::Func @string, + System::Func @double, + System::Func @bool, + System::Func, T> mixed ) { - return this switch + return this.Value switch { - String inner => @string(inner), - Double inner => @double(inner), - Bool inner => @bool(inner), - Mixed inner => mixed(inner), + string value => @string(value), + double value => @double(value), + bool value => @bool(value), + List value => mixed(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of DefaultValue" ), }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of DefaultValue" + ); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class DefaultValueConverter : JsonConverter @@ -116,35 +146,35 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new String(deserialized); + return new DefaultValue(deserialized); } } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant String", e) + new ImageKitInvalidDataException("Data does not match union variant 'string'", e) ); } try { - return new Double(JsonSerializer.Deserialize(ref reader, options)); + return new DefaultValue(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant Double", e) + new ImageKitInvalidDataException("Data does not match union variant 'double'", e) ); } try { - return new Bool(JsonSerializer.Deserialize(ref reader, options)); + return new DefaultValue(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant Bool", e) + new ImageKitInvalidDataException("Data does not match union variant 'bool'", e) ); } @@ -156,13 +186,16 @@ JsonSerializerOptions options ); if (deserialized != null) { - return new Mixed(deserialized); + return new DefaultValue(deserialized); } } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant Mixed", e) + new ImageKitInvalidDataException( + "Data does not match union variant 'List'", + e + ) ); } @@ -175,16 +208,7 @@ public override void Write( JsonSerializerOptions options ) { - object variant = value switch - { - String(var @string) => @string, - Double(var @double) => @double, - Bool(var @bool) => @bool, - Mixed(var mixed) => mixed, - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of DefaultValue" - ), - }; + object variant = value.Value; JsonSerializer.Serialize(writer, variant, options); } } diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent6.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent6.cs index c75eaa8f..e5e94bbe 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent6.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent6.cs @@ -3,58 +3,74 @@ using System.Text.Json; using System.Text.Json.Serialization; using Imagekit.Exceptions; -using Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties.UnnamedSchemaWithArrayParent6Variants; using System = System; namespace Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties; [JsonConverter(typeof(UnnamedSchemaWithArrayParent6Converter))] -public abstract record class UnnamedSchemaWithArrayParent6 +public record class UnnamedSchemaWithArrayParent6 { - internal UnnamedSchemaWithArrayParent6() { } + public object Value { get; private init; } - public static implicit operator UnnamedSchemaWithArrayParent6(string value) => - new String(value); + public UnnamedSchemaWithArrayParent6(string value) + { + Value = value; + } - public static implicit operator UnnamedSchemaWithArrayParent6(double value) => - new Double(value); + public UnnamedSchemaWithArrayParent6(double value) + { + Value = value; + } - public static implicit operator UnnamedSchemaWithArrayParent6(bool value) => new Bool(value); + public UnnamedSchemaWithArrayParent6(bool value) + { + Value = value; + } + + UnnamedSchemaWithArrayParent6(UnknownVariant value) + { + Value = value; + } + + public static UnnamedSchemaWithArrayParent6 CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as String)?.Value; + value = this.Value as string; return value != null; } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as Double)?.Value; + value = this.Value as double?; return value != null; } public bool TryPickBool([NotNullWhen(true)] out bool? value) { - value = (this as Bool)?.Value; + value = this.Value as bool?; return value != null; } public void Switch( - System::Action @string, - System::Action @double, - System::Action @bool + System::Action @string, + System::Action @double, + System::Action @bool ) { - switch (this) + switch (this.Value) { - case String inner: - @string(inner); + case string value: + @string(value); break; - case Double inner: - @double(inner); + case double value: + @double(value); break; - case Bool inner: - @bool(inner); + case bool value: + @bool(value); break; default: throw new ImageKitInvalidDataException( @@ -64,23 +80,33 @@ public void Switch( } public T Match( - System::Func @string, - System::Func @double, - System::Func @bool + System::Func @string, + System::Func @double, + System::Func @bool ) { - return this switch + return this.Value switch { - String inner => @string(inner), - Double inner => @double(inner), - Bool inner => @bool(inner), + string value => @string(value), + double value => @double(value), + bool value => @bool(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of UnnamedSchemaWithArrayParent6" ), }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent6" + ); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class UnnamedSchemaWithArrayParent6Converter : JsonConverter @@ -98,35 +124,39 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new String(deserialized); + return new UnnamedSchemaWithArrayParent6(deserialized); } } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant String", e) + new ImageKitInvalidDataException("Data does not match union variant 'string'", e) ); } try { - return new Double(JsonSerializer.Deserialize(ref reader, options)); + return new UnnamedSchemaWithArrayParent6( + JsonSerializer.Deserialize(ref reader, options) + ); } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant Double", e) + new ImageKitInvalidDataException("Data does not match union variant 'double'", e) ); } try { - return new Bool(JsonSerializer.Deserialize(ref reader, options)); + return new UnnamedSchemaWithArrayParent6( + JsonSerializer.Deserialize(ref reader, options) + ); } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant Bool", e) + new ImageKitInvalidDataException("Data does not match union variant 'bool'", e) ); } @@ -139,15 +169,7 @@ public override void Write( JsonSerializerOptions options ) { - object variant = value switch - { - String(var @string) => @string, - Double(var @double) => @double, - Bool(var @bool) => @bool, - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent6" - ), - }; + object variant = value.Value; JsonSerializer.Serialize(writer, variant, options); } } diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent6Variants/All.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent6Variants/All.cs deleted file mode 100644 index afcf6f89..00000000 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent6Variants/All.cs +++ /dev/null @@ -1,37 +0,0 @@ -using Imagekit.Core; - -namespace Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties.UnnamedSchemaWithArrayParent6Variants; - -public sealed record class String(string Value) - : UnnamedSchemaWithArrayParent6, - IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Double(double Value) - : UnnamedSchemaWithArrayParent6, - IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Bool(bool Value) : UnnamedSchemaWithArrayParent6, IVariant -{ - public static Bool From(bool value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs deleted file mode 100644 index 1b506942..00000000 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System.Collections.Generic; -using Imagekit.Core; -using Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties; - -namespace Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueVariants; - -public sealed record class String(string Value) : DefaultValue, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Double(double Value) : DefaultValue, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Bool(bool Value) : DefaultValue, IVariant -{ - public static Bool From(bool value) - { - return new(value); - } - - public override void Validate() { } -} - -/// -/// Default value should be of type array when custom metadata field type is set to -/// `MultiSelect`. -/// -public sealed record class Mixed(List Value) - : DefaultValue, - IVariant> -{ - public static Mixed From(List value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs index a9d52057..a284b25f 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs @@ -3,7 +3,6 @@ using System.Text.Json; using System.Text.Json.Serialization; using Imagekit.Exceptions; -using Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MaxValueVariants; using System = System; namespace Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; @@ -14,35 +13,51 @@ namespace Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFie /// field, it will be a numeric value. ///
[JsonConverter(typeof(MaxValueConverter))] -public abstract record class MaxValue +public record class MaxValue { - internal MaxValue() { } + public object Value { get; private init; } - public static implicit operator MaxValue(string value) => new String(value); + public MaxValue(string value) + { + Value = value; + } + + public MaxValue(double value) + { + Value = value; + } - public static implicit operator MaxValue(double value) => new Double(value); + MaxValue(UnknownVariant value) + { + Value = value; + } + + public static MaxValue CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as String)?.Value; + value = this.Value as string; return value != null; } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as Double)?.Value; + value = this.Value as double?; return value != null; } - public void Switch(System::Action @string, System::Action @double) + public void Switch(System::Action @string, System::Action @double) { - switch (this) + switch (this.Value) { - case String inner: - @string(inner); + case string value: + @string(value); break; - case Double inner: - @double(inner); + case double value: + @double(value); break; default: throw new ImageKitInvalidDataException( @@ -51,19 +66,27 @@ public void Switch(System::Action @string, System::Action @doubl } } - public T Match(System::Func @string, System::Func @double) + public T Match(System::Func @string, System::Func @double) { - return this switch + return this.Value switch { - String inner => @string(inner), - Double inner => @double(inner), + string value => @string(value), + double value => @double(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of MaxValue" ), }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException("Data did not match any variant of MaxValue"); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class MaxValueConverter : JsonConverter @@ -81,24 +104,24 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new String(deserialized); + return new MaxValue(deserialized); } } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant String", e) + new ImageKitInvalidDataException("Data does not match union variant 'string'", e) ); } try { - return new Double(JsonSerializer.Deserialize(ref reader, options)); + return new MaxValue(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant Double", e) + new ImageKitInvalidDataException("Data does not match union variant 'double'", e) ); } @@ -107,14 +130,7 @@ JsonSerializerOptions options public override void Write(Utf8JsonWriter writer, MaxValue value, JsonSerializerOptions options) { - object variant = value switch - { - String(var @string) => @string, - Double(var @double) => @double, - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of MaxValue" - ), - }; + object variant = value.Value; JsonSerializer.Serialize(writer, variant, options); } } diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs deleted file mode 100644 index f473a7ab..00000000 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Imagekit.Core; - -namespace Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MaxValueVariants; - -public sealed record class String(string Value) : MaxValue, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Double(double Value) : MaxValue, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs index 1486d111..cd83f46b 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs @@ -3,7 +3,6 @@ using System.Text.Json; using System.Text.Json.Serialization; using Imagekit.Exceptions; -using Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MinValueVariants; using System = System; namespace Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; @@ -14,35 +13,51 @@ namespace Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFie /// field, it will be a numeric value. ///
[JsonConverter(typeof(MinValueConverter))] -public abstract record class MinValue +public record class MinValue { - internal MinValue() { } + public object Value { get; private init; } - public static implicit operator MinValue(string value) => new String(value); + public MinValue(string value) + { + Value = value; + } + + public MinValue(double value) + { + Value = value; + } - public static implicit operator MinValue(double value) => new Double(value); + MinValue(UnknownVariant value) + { + Value = value; + } + + public static MinValue CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as String)?.Value; + value = this.Value as string; return value != null; } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as Double)?.Value; + value = this.Value as double?; return value != null; } - public void Switch(System::Action @string, System::Action @double) + public void Switch(System::Action @string, System::Action @double) { - switch (this) + switch (this.Value) { - case String inner: - @string(inner); + case string value: + @string(value); break; - case Double inner: - @double(inner); + case double value: + @double(value); break; default: throw new ImageKitInvalidDataException( @@ -51,19 +66,27 @@ public void Switch(System::Action @string, System::Action @doubl } } - public T Match(System::Func @string, System::Func @double) + public T Match(System::Func @string, System::Func @double) { - return this switch + return this.Value switch { - String inner => @string(inner), - Double inner => @double(inner), + string value => @string(value), + double value => @double(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of MinValue" ), }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException("Data did not match any variant of MinValue"); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class MinValueConverter : JsonConverter @@ -81,24 +104,24 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new String(deserialized); + return new MinValue(deserialized); } } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant String", e) + new ImageKitInvalidDataException("Data does not match union variant 'string'", e) ); } try { - return new Double(JsonSerializer.Deserialize(ref reader, options)); + return new MinValue(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant Double", e) + new ImageKitInvalidDataException("Data does not match union variant 'double'", e) ); } @@ -107,14 +130,7 @@ JsonSerializerOptions options public override void Write(Utf8JsonWriter writer, MinValue value, JsonSerializerOptions options) { - object variant = value switch - { - String(var @string) => @string, - Double(var @double) => @double, - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of MinValue" - ), - }; + object variant = value.Value; JsonSerializer.Serialize(writer, variant, options); } } diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs deleted file mode 100644 index 329e987f..00000000 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Imagekit.Core; - -namespace Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MinValueVariants; - -public sealed record class String(string Value) : MinValue, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Double(double Value) : MinValue, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs index 69801483..3136c82c 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs @@ -3,56 +3,74 @@ using System.Text.Json; using System.Text.Json.Serialization; using Imagekit.Exceptions; -using Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.SelectOptionVariants; using System = System; namespace Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; [JsonConverter(typeof(SelectOptionConverter))] -public abstract record class SelectOption +public record class SelectOption { - internal SelectOption() { } + public object Value { get; private init; } - public static implicit operator SelectOption(string value) => new String(value); + public SelectOption(string value) + { + Value = value; + } + + public SelectOption(double value) + { + Value = value; + } + + public SelectOption(bool value) + { + Value = value; + } - public static implicit operator SelectOption(double value) => new Double(value); + SelectOption(UnknownVariant value) + { + Value = value; + } - public static implicit operator SelectOption(bool value) => new Bool(value); + public static SelectOption CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as String)?.Value; + value = this.Value as string; return value != null; } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as Double)?.Value; + value = this.Value as double?; return value != null; } public bool TryPickBool([NotNullWhen(true)] out bool? value) { - value = (this as Bool)?.Value; + value = this.Value as bool?; return value != null; } public void Switch( - System::Action @string, - System::Action @double, - System::Action @bool + System::Action @string, + System::Action @double, + System::Action @bool ) { - switch (this) + switch (this.Value) { - case String inner: - @string(inner); + case string value: + @string(value); break; - case Double inner: - @double(inner); + case double value: + @double(value); break; - case Bool inner: - @bool(inner); + case bool value: + @bool(value); break; default: throw new ImageKitInvalidDataException( @@ -62,23 +80,33 @@ public void Switch( } public T Match( - System::Func @string, - System::Func @double, - System::Func @bool + System::Func @string, + System::Func @double, + System::Func @bool ) { - return this switch + return this.Value switch { - String inner => @string(inner), - Double inner => @double(inner), - Bool inner => @bool(inner), + string value => @string(value), + double value => @double(value), + bool value => @bool(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of SelectOption" ), }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of SelectOption" + ); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class SelectOptionConverter : JsonConverter @@ -96,35 +124,35 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new String(deserialized); + return new SelectOption(deserialized); } } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant String", e) + new ImageKitInvalidDataException("Data does not match union variant 'string'", e) ); } try { - return new Double(JsonSerializer.Deserialize(ref reader, options)); + return new SelectOption(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant Double", e) + new ImageKitInvalidDataException("Data does not match union variant 'double'", e) ); } try { - return new Bool(JsonSerializer.Deserialize(ref reader, options)); + return new SelectOption(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant Bool", e) + new ImageKitInvalidDataException("Data does not match union variant 'bool'", e) ); } @@ -137,15 +165,7 @@ public override void Write( JsonSerializerOptions options ) { - object variant = value switch - { - String(var @string) => @string, - Double(var @double) => @double, - Bool(var @bool) => @bool, - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of SelectOption" - ), - }; + object variant = value.Value; JsonSerializer.Serialize(writer, variant, options); } } diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs deleted file mode 100644 index 92bc5e6f..00000000 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs +++ /dev/null @@ -1,33 +0,0 @@ -using Imagekit.Core; - -namespace Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.SelectOptionVariants; - -public sealed record class String(string Value) : SelectOption, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Double(double Value) : SelectOption, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Bool(bool Value) : SelectOption, IVariant -{ - public static Bool From(bool value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValue.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValue.cs index 0c92b23e..0f230a7b 100644 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValue.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValue.cs @@ -3,7 +3,6 @@ using System.Text.Json; using System.Text.Json.Serialization; using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties.DefaultValueProperties; -using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties.DefaultValueVariants; using System = System; namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties; @@ -14,63 +13,72 @@ namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsPr /// of custom metadata field. ///
[JsonConverter(typeof(DefaultValueConverter))] -public abstract record class DefaultValue +public record class DefaultValue { - internal DefaultValue() { } + public object Value { get; private init; } - public static implicit operator DefaultValue(string value) => new String(value); + public DefaultValue(string value) + { + Value = value; + } - public static implicit operator DefaultValue(double value) => new Double(value); + public DefaultValue(double value) + { + Value = value; + } - public static implicit operator DefaultValue(bool value) => new Bool(value); + public DefaultValue(bool value) + { + Value = value; + } public static implicit operator DefaultValue(List value) => new Mixed(value); public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as String)?.Value; + value = this.Value as string; return value != null; } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as Double)?.Value; + value = this.Value as double?; return value != null; } public bool TryPickBool([NotNullWhen(true)] out bool? value) { - value = (this as Bool)?.Value; + value = this.Value as bool?; return value != null; } public bool TryPickMixed([NotNullWhen(true)] out List? value) { - value = (this as Mixed)?.Value; + value = this.Value as List; return value != null; } public void Switch( - System::Action @string, - System::Action @double, - System::Action @bool, - System::Action mixed + System::Action @string, + System::Action @double, + System::Action @bool, + System::Action> mixed ) { - switch (this) + switch (this.Value) { - case String inner: - @string(inner); + case string value: + @string(value); break; - case Double inner: - @double(inner); + case double value: + @double(value); break; - case Bool inner: - @bool(inner); + case bool value: + @bool(value); break; - case Mixed inner: - mixed(inner); + case List value: + mixed(value); break; default: throw new System::InvalidOperationException(); @@ -78,13 +86,13 @@ public void Switch( } public T Match( - System::Func @string, - System::Func @double, - System::Func @bool, - System::Func mixed + System::Func @string, + System::Func @double, + System::Func @bool, + System::Func, T> mixed ) { - return this switch + return this.Value switch { String inner => @string(inner), Double inner => @double(inner), @@ -94,7 +102,17 @@ public T Match( }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of DefaultValue" + ); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class DefaultValueConverter : JsonConverter @@ -112,28 +130,28 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new String(deserialized); + return new DefaultValue(deserialized); } } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } try { - return new Double(JsonSerializer.Deserialize(ref reader, options)); + return new DefaultValue(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } try { - return new Bool(JsonSerializer.Deserialize(ref reader, options)); + return new DefaultValue(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -146,10 +164,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - return new Mixed(deserialized); + return new DefaultValue(deserialized); } } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent2.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent2.cs index 16e9336e..b5209741 100644 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent2.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent2.cs @@ -22,38 +22,38 @@ public static implicit operator UnnamedSchemaWithArrayParent0(double value) => public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as String)?.Value; + value = this.Value as string; return value != null; } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as Double)?.Value; + value = this.Value as double?; return value != null; } public bool TryPickBool([NotNullWhen(true)] out bool? value) { - value = (this as Bool)?.Value; + value = this.Value as bool?; return value != null; } public void Switch( - System::Action @string, - System::Action @double, - System::Action @bool + System::Action @string, + System::Action @double, + System::Action @bool ) { - switch (this) + switch (this.Value) { - case String inner: - @string(inner); + case string value: + @string(value); break; - case Double inner: - @double(inner); + case double value: + @double(value); break; - case Bool inner: - @bool(inner); + case bool value: + @bool(value); break; default: throw new System::InvalidOperationException(); @@ -61,12 +61,12 @@ public void Switch( } public T Match( - System::Func @string, - System::Func @double, - System::Func @bool + System::Func @string, + System::Func @double, + System::Func @bool ) { - return this switch + return this.Value switch { String inner => @string(inner), Double inner => @double(inner), @@ -75,7 +75,17 @@ public T Match( }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent2" + ); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class UnnamedSchemaWithArrayParent0Converter : JsonConverter @@ -93,28 +103,32 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new String(deserialized); + return new UnnamedSchemaWithArrayParent2(deserialized); } } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } try { - return new Double(JsonSerializer.Deserialize(ref reader, options)); + return new UnnamedSchemaWithArrayParent2( + JsonSerializer.Deserialize(ref reader, options) + ); } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } try { - return new Bool(JsonSerializer.Deserialize(ref reader, options)); + return new UnnamedSchemaWithArrayParent2( + JsonSerializer.Deserialize(ref reader, options) + ); } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MaxValue.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MaxValue.cs index 14cb5444..176b3c2b 100644 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MaxValue.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MaxValue.cs @@ -13,44 +13,60 @@ namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsPr /// For `Number` type field, set the minimum numeric value. ///
[JsonConverter(typeof(MaxValueConverter))] -public abstract record class MaxValue +public record class MaxValue { - internal MaxValue() { } + public object Value { get; private init; } - public static implicit operator MaxValue(string value) => new String(value); + public MaxValue(string value) + { + Value = value; + } + + public MaxValue(double value) + { + Value = value; + } - public static implicit operator MaxValue(double value) => new Double(value); + MaxValue(UnknownVariant value) + { + Value = value; + } + + public static MaxValue CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as String)?.Value; + value = this.Value as string; return value != null; } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as Double)?.Value; + value = this.Value as double?; return value != null; } - public void Switch(System::Action @string, System::Action @double) + public void Switch(System::Action @string, System::Action @double) { - switch (this) + switch (this.Value) { - case String inner: - @string(inner); + case string value: + @string(value); break; - case Double inner: - @double(inner); + case double value: + @double(value); break; default: throw new System::InvalidOperationException(); } } - public T Match(System::Func @string, System::Func @double) + public T Match(System::Func @string, System::Func @double) { - return this switch + return this.Value switch { String inner => @string(inner), Double inner => @double(inner), @@ -58,7 +74,15 @@ public T Match(System::Func @string, System::Func @doub }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException("Data did not match any variant of MaxValue"); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class MaxValueConverter : JsonConverter @@ -76,19 +100,19 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new String(deserialized); + return new MaxValue(deserialized); } } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } try { - return new Double(JsonSerializer.Deserialize(ref reader, options)); + return new MaxValue(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MinValue.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MinValue.cs index a3bfe01f..36036350 100644 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MinValue.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MinValue.cs @@ -13,44 +13,60 @@ namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsPr /// For `Number` type field, set the minimum numeric value. ///
[JsonConverter(typeof(MinValueConverter))] -public abstract record class MinValue +public record class MinValue { - internal MinValue() { } + public object Value { get; private init; } - public static implicit operator MinValue(string value) => new String(value); + public MinValue(string value) + { + Value = value; + } + + public MinValue(double value) + { + Value = value; + } - public static implicit operator MinValue(double value) => new Double(value); + MinValue(UnknownVariant value) + { + Value = value; + } + + public static MinValue CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as String)?.Value; + value = this.Value as string; return value != null; } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as Double)?.Value; + value = this.Value as double?; return value != null; } - public void Switch(System::Action @string, System::Action @double) + public void Switch(System::Action @string, System::Action @double) { - switch (this) + switch (this.Value) { - case String inner: - @string(inner); + case string value: + @string(value); break; - case Double inner: - @double(inner); + case double value: + @double(value); break; default: throw new System::InvalidOperationException(); } } - public T Match(System::Func @string, System::Func @double) + public T Match(System::Func @string, System::Func @double) { - return this switch + return this.Value switch { String inner => @string(inner), Double inner => @double(inner), @@ -58,7 +74,15 @@ public T Match(System::Func @string, System::Func @doub }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException("Data did not match any variant of MinValue"); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class MinValueConverter : JsonConverter @@ -76,19 +100,19 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new String(deserialized); + return new MinValue(deserialized); } } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } try { - return new Double(JsonSerializer.Deserialize(ref reader, options)); + return new MinValue(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/SelectOption.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/SelectOption.cs index ed09d277..9ca07698 100644 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/SelectOption.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/SelectOption.cs @@ -8,50 +8,69 @@ namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties; [JsonConverter(typeof(SelectOptionConverter))] -public abstract record class SelectOption +public record class SelectOption { - internal SelectOption() { } + public object Value { get; private init; } - public static implicit operator SelectOption(string value) => new String(value); + public SelectOption(string value) + { + Value = value; + } - public static implicit operator SelectOption(double value) => new Double(value); + public SelectOption(double value) + { + Value = value; + } - public static implicit operator SelectOption(bool value) => new Bool(value); + public SelectOption(bool value) + { + Value = value; + } + + SelectOption(UnknownVariant value) + { + Value = value; + } + + public static SelectOption CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as String)?.Value; + value = this.Value as string; return value != null; } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as Double)?.Value; + value = this.Value as double?; return value != null; } public bool TryPickBool([NotNullWhen(true)] out bool? value) { - value = (this as Bool)?.Value; + value = this.Value as bool?; return value != null; } public void Switch( - System::Action @string, - System::Action @double, - System::Action @bool + System::Action @string, + System::Action @double, + System::Action @bool ) { - switch (this) + switch (this.Value) { - case String inner: - @string(inner); + case string value: + @string(value); break; - case Double inner: - @double(inner); + case double value: + @double(value); break; - case Bool inner: - @bool(inner); + case bool value: + @bool(value); break; default: throw new System::InvalidOperationException(); @@ -59,12 +78,12 @@ public void Switch( } public T Match( - System::Func @string, - System::Func @double, - System::Func @bool + System::Func @string, + System::Func @double, + System::Func @bool ) { - return this switch + return this.Value switch { String inner => @string(inner), Double inner => @double(inner), @@ -73,7 +92,17 @@ public T Match( }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of SelectOption" + ); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class SelectOptionConverter : JsonConverter @@ -91,28 +120,28 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new String(deserialized); + return new SelectOption(deserialized); } } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } try { - return new Double(JsonSerializer.Deserialize(ref reader, options)); + return new SelectOption(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } try { - return new Bool(JsonSerializer.Deserialize(ref reader, options)); + return new SelectOption(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValue.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValue.cs index 560e1687..4122d47a 100644 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValue.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValue.cs @@ -4,7 +4,6 @@ using System.Text.Json.Serialization; using Imagekit.Exceptions; using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties.DefaultValueProperties; -using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties.DefaultValueVariants; using System = System; namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties; @@ -14,63 +13,84 @@ namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.Sch /// depends on the field type. ///
[JsonConverter(typeof(DefaultValueConverter))] -public abstract record class DefaultValue +public record class DefaultValue { - internal DefaultValue() { } + public object Value { get; private init; } - public static implicit operator DefaultValue(string value) => new String(value); + public DefaultValue(string value) + { + Value = value; + } - public static implicit operator DefaultValue(double value) => new Double(value); + public DefaultValue(double value) + { + Value = value; + } - public static implicit operator DefaultValue(bool value) => new Bool(value); + public DefaultValue(bool value) + { + Value = value; + } - public static implicit operator DefaultValue(List value) => - new Mixed(value); + public DefaultValue(List value) + { + Value = value; + } + + DefaultValue(UnknownVariant value) + { + Value = value; + } + + public static DefaultValue CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as String)?.Value; + value = this.Value as string; return value != null; } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as Double)?.Value; + value = this.Value as double?; return value != null; } public bool TryPickBool([NotNullWhen(true)] out bool? value) { - value = (this as Bool)?.Value; + value = this.Value as bool?; return value != null; } public bool TryPickMixed([NotNullWhen(true)] out List? value) { - value = (this as Mixed)?.Value; + value = this.Value as List; return value != null; } public void Switch( - System::Action @string, - System::Action @double, - System::Action @bool, - System::Action mixed + System::Action @string, + System::Action @double, + System::Action @bool, + System::Action> mixed ) { - switch (this) + switch (this.Value) { - case String inner: - @string(inner); + case string value: + @string(value); break; - case Double inner: - @double(inner); + case double value: + @double(value); break; - case Bool inner: - @bool(inner); + case bool value: + @bool(value); break; - case Mixed inner: - mixed(inner); + case List value: + mixed(value); break; default: throw new ImageKitInvalidDataException( @@ -80,25 +100,35 @@ public void Switch( } public T Match( - System::Func @string, - System::Func @double, - System::Func @bool, - System::Func mixed + System::Func @string, + System::Func @double, + System::Func @bool, + System::Func, T> mixed ) { - return this switch + return this.Value switch { - String inner => @string(inner), - Double inner => @double(inner), - Bool inner => @bool(inner), - Mixed inner => mixed(inner), + string value => @string(value), + double value => @double(value), + bool value => @bool(value), + List value => mixed(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of DefaultValue" ), }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of DefaultValue" + ); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class DefaultValueConverter : JsonConverter @@ -116,35 +146,35 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new String(deserialized); + return new DefaultValue(deserialized); } } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant String", e) + new ImageKitInvalidDataException("Data does not match union variant 'string'", e) ); } try { - return new Double(JsonSerializer.Deserialize(ref reader, options)); + return new DefaultValue(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant Double", e) + new ImageKitInvalidDataException("Data does not match union variant 'double'", e) ); } try { - return new Bool(JsonSerializer.Deserialize(ref reader, options)); + return new DefaultValue(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant Bool", e) + new ImageKitInvalidDataException("Data does not match union variant 'bool'", e) ); } @@ -156,13 +186,16 @@ JsonSerializerOptions options ); if (deserialized != null) { - return new Mixed(deserialized); + return new DefaultValue(deserialized); } } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant Mixed", e) + new ImageKitInvalidDataException( + "Data does not match union variant 'List'", + e + ) ); } @@ -175,16 +208,7 @@ public override void Write( JsonSerializerOptions options ) { - object variant = value switch - { - String(var @string) => @string, - Double(var @double) => @double, - Bool(var @bool) => @bool, - Mixed(var mixed) => mixed, - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of DefaultValue" - ), - }; + object variant = value.Value; JsonSerializer.Serialize(writer, variant, options); } } diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent1.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent1.cs index a393e0f4..43977039 100644 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent1.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent1.cs @@ -8,52 +8,69 @@ namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties.DefaultValueProperties; [JsonConverter(typeof(UnnamedSchemaWithArrayParent1Converter))] -public abstract record class UnnamedSchemaWithArrayParent1 +public record class UnnamedSchemaWithArrayParent1 { - internal UnnamedSchemaWithArrayParent1() { } + public object Value { get; private init; } - public static implicit operator UnnamedSchemaWithArrayParent1(string value) => - new String(value); + public UnnamedSchemaWithArrayParent1(string value) + { + Value = value; + } - public static implicit operator UnnamedSchemaWithArrayParent1(double value) => - new Double(value); + public UnnamedSchemaWithArrayParent1(double value) + { + Value = value; + } - public static implicit operator UnnamedSchemaWithArrayParent1(bool value) => new Bool(value); + public UnnamedSchemaWithArrayParent1(bool value) + { + Value = value; + } + + UnnamedSchemaWithArrayParent1(UnknownVariant value) + { + Value = value; + } + + public static UnnamedSchemaWithArrayParent1 CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as String)?.Value; + value = this.Value as string; return value != null; } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as Double)?.Value; + value = this.Value as double?; return value != null; } public bool TryPickBool([NotNullWhen(true)] out bool? value) { - value = (this as Bool)?.Value; + value = this.Value as bool?; return value != null; } public void Switch( - System::Action @string, - System::Action @double, - System::Action @bool + System::Action @string, + System::Action @double, + System::Action @bool ) { - switch (this) + switch (this.Value) { - case String inner: - @string(inner); + case string value: + @string(value); break; - case Double inner: - @double(inner); + case double value: + @double(value); break; - case Bool inner: - @bool(inner); + case bool value: + @bool(value); break; default: throw new System::InvalidOperationException(); @@ -61,12 +78,12 @@ public void Switch( } public T Match( - System::Func @string, - System::Func @double, - System::Func @bool + System::Func @string, + System::Func @double, + System::Func @bool ) { - return this switch + return this.Value switch { String inner => @string(inner), Double inner => @double(inner), @@ -75,7 +92,17 @@ public T Match( }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent1" + ); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class UnnamedSchemaWithArrayParent1Converter : JsonConverter @@ -93,28 +120,32 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new String(deserialized); + return new UnnamedSchemaWithArrayParent1(deserialized); } } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } try { - return new Double(JsonSerializer.Deserialize(ref reader, options)); + return new UnnamedSchemaWithArrayParent1( + JsonSerializer.Deserialize(ref reader, options) + ); } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } try { - return new Bool(JsonSerializer.Deserialize(ref reader, options)); + return new UnnamedSchemaWithArrayParent1( + JsonSerializer.Deserialize(ref reader, options) + ); } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MaxValue.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MaxValue.cs index d79cacd1..17131e6c 100644 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MaxValue.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MaxValue.cs @@ -13,44 +13,60 @@ namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.Sch /// field, it will be a numeric value. /// [JsonConverter(typeof(MaxValueConverter))] -public abstract record class MaxValue +public record class MaxValue { - internal MaxValue() { } + public object Value { get; private init; } - public static implicit operator MaxValue(string value) => new String(value); + public MaxValue(string value) + { + Value = value; + } + + public MaxValue(double value) + { + Value = value; + } - public static implicit operator MaxValue(double value) => new Double(value); + MaxValue(UnknownVariant value) + { + Value = value; + } + + public static MaxValue CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as String)?.Value; + value = this.Value as string; return value != null; } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as Double)?.Value; + value = this.Value as double?; return value != null; } - public void Switch(System::Action @string, System::Action @double) + public void Switch(System::Action @string, System::Action @double) { - switch (this) + switch (this.Value) { - case String inner: - @string(inner); + case string value: + @string(value); break; - case Double inner: - @double(inner); + case double value: + @double(value); break; default: throw new System::InvalidOperationException(); } } - public T Match(System::Func @string, System::Func @double) + public T Match(System::Func @string, System::Func @double) { - return this switch + return this.Value switch { String inner => @string(inner), Double inner => @double(inner), @@ -58,7 +74,15 @@ public T Match(System::Func @string, System::Func @doub }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException("Data did not match any variant of MaxValue"); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class MaxValueConverter : JsonConverter @@ -76,19 +100,19 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new String(deserialized); + return new MaxValue(deserialized); } } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } try { - return new Double(JsonSerializer.Deserialize(ref reader, options)); + return new MaxValue(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MinValue.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MinValue.cs index 52798dd7..6d002b31 100644 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MinValue.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MinValue.cs @@ -13,44 +13,60 @@ namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.Sch /// field, it will be a numeric value. /// [JsonConverter(typeof(MinValueConverter))] -public abstract record class MinValue +public record class MinValue { - internal MinValue() { } + public object Value { get; private init; } - public static implicit operator MinValue(string value) => new String(value); + public MinValue(string value) + { + Value = value; + } + + public MinValue(double value) + { + Value = value; + } - public static implicit operator MinValue(double value) => new Double(value); + MinValue(UnknownVariant value) + { + Value = value; + } + + public static MinValue CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as String)?.Value; + value = this.Value as string; return value != null; } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as Double)?.Value; + value = this.Value as double?; return value != null; } - public void Switch(System::Action @string, System::Action @double) + public void Switch(System::Action @string, System::Action @double) { - switch (this) + switch (this.Value) { - case String inner: - @string(inner); + case string value: + @string(value); break; - case Double inner: - @double(inner); + case double value: + @double(value); break; default: throw new System::InvalidOperationException(); } } - public T Match(System::Func @string, System::Func @double) + public T Match(System::Func @string, System::Func @double) { - return this switch + return this.Value switch { String inner => @string(inner), Double inner => @double(inner), @@ -58,7 +74,15 @@ public T Match(System::Func @string, System::Func @doub }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException("Data did not match any variant of MinValue"); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class MinValueConverter : JsonConverter @@ -76,19 +100,19 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new String(deserialized); + return new MinValue(deserialized); } } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } try { - return new Double(JsonSerializer.Deserialize(ref reader, options)); + return new MinValue(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/SelectOption.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/SelectOption.cs index 22636a9a..8dc43114 100644 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/SelectOption.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/SelectOption.cs @@ -8,50 +8,69 @@ namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties; [JsonConverter(typeof(SelectOptionConverter))] -public abstract record class SelectOption +public record class SelectOption { - internal SelectOption() { } + public object Value { get; private init; } - public static implicit operator SelectOption(string value) => new String(value); + public SelectOption(string value) + { + Value = value; + } - public static implicit operator SelectOption(double value) => new Double(value); + public SelectOption(double value) + { + Value = value; + } - public static implicit operator SelectOption(bool value) => new Bool(value); + public SelectOption(bool value) + { + Value = value; + } + + SelectOption(UnknownVariant value) + { + Value = value; + } + + public static SelectOption CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as String)?.Value; + value = this.Value as string; return value != null; } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as Double)?.Value; + value = this.Value as double?; return value != null; } public bool TryPickBool([NotNullWhen(true)] out bool? value) { - value = (this as Bool)?.Value; + value = this.Value as bool?; return value != null; } public void Switch( - System::Action @string, - System::Action @double, - System::Action @bool + System::Action @string, + System::Action @double, + System::Action @bool ) { - switch (this) + switch (this.Value) { - case String inner: - @string(inner); + case string value: + @string(value); break; - case Double inner: - @double(inner); + case double value: + @double(value); break; - case Bool inner: - @bool(inner); + case bool value: + @bool(value); break; default: throw new System::InvalidOperationException(); @@ -59,12 +78,12 @@ public void Switch( } public T Match( - System::Func @string, - System::Func @double, - System::Func @bool + System::Func @string, + System::Func @double, + System::Func @bool ) { - return this switch + return this.Value switch { String inner => @string(inner), Double inner => @double(inner), @@ -73,7 +92,17 @@ public T Match( }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of SelectOption" + ); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class SelectOptionConverter : JsonConverter @@ -91,28 +120,28 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new String(deserialized); + return new SelectOption(deserialized); } } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } try { - return new Double(JsonSerializer.Deserialize(ref reader, options)); + return new SelectOption(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } try { - return new Bool(JsonSerializer.Deserialize(ref reader, options)); + return new SelectOption(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValue.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValue.cs index 8f8e115a..f7091ca1 100644 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValue.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValue.cs @@ -4,7 +4,6 @@ using System.Text.Json; using System.Text.Json.Serialization; using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldUpdateParamsProperties.SchemaProperties.DefaultValueProperties; -using DefaultValueVariants = Imagekit.Models.CustomMetadataFields.CustomMetadataFieldUpdateParamsProperties.SchemaProperties.DefaultValueVariants; namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldUpdateParamsProperties.SchemaProperties; @@ -14,66 +13,72 @@ namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldUpdateParamsPr /// of custom metadata field. /// [JsonConverter(typeof(DefaultValueConverter))] -public abstract record class DefaultValue +public record class DefaultValue { - internal DefaultValue() { } + public object Value { get; private init; } - public static implicit operator DefaultValue(string value) => - new DefaultValueVariants::String(value); + public DefaultValue(string value) + { + Value = value; + } - public static implicit operator DefaultValue(double value) => - new DefaultValueVariants::Double(value); + public DefaultValue(double value) + { + Value = value; + } - public static implicit operator DefaultValue(bool value) => - new DefaultValueVariants::Bool(value); + public DefaultValue(bool value) + { + Value = value; + } public static implicit operator DefaultValue(List value) => new DefaultValueVariants::Mixed(value); public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as DefaultValueVariants::String)?.Value; + value = this.Value as string; return value != null; } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as DefaultValueVariants::Double)?.Value; + value = this.Value as double?; return value != null; } public bool TryPickBool([NotNullWhen(true)] out bool? value) { - value = (this as DefaultValueVariants::Bool)?.Value; + value = this.Value as bool?; return value != null; } public bool TryPickMixed([NotNullWhen(true)] out List? value) { - value = (this as DefaultValueVariants::Mixed)?.Value; + value = this.Value as List; return value != null; } public void Switch( - Action @string, - Action @double, - Action @bool, - Action mixed + Action @string, + Action @double, + Action @bool, + Action> mixed ) { - switch (this) + switch (this.Value) { - case DefaultValueVariants::String inner: - @string(inner); + case string value: + @string(value); break; - case DefaultValueVariants::Double inner: - @double(inner); + case double value: + @double(value); break; - case DefaultValueVariants::Bool inner: - @bool(inner); + case bool value: + @bool(value); break; - case DefaultValueVariants::Mixed inner: - mixed(inner); + case List value: + mixed(value); break; default: throw new InvalidOperationException(); @@ -81,13 +86,13 @@ public void Switch( } public T Match( - Func @string, - Func @double, - Func @bool, - Func mixed + Func @string, + Func @double, + Func @bool, + Func, T> mixed ) { - return this switch + return this.Value switch { DefaultValueVariants::String inner => @string(inner), DefaultValueVariants::Double inner => @double(inner), @@ -97,7 +102,17 @@ public T Match( }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of DefaultValue" + ); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class DefaultValueConverter : JsonConverter @@ -115,32 +130,28 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new DefaultValueVariants::String(deserialized); + return new DefaultValue(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } try { - return new DefaultValueVariants::Double( - JsonSerializer.Deserialize(ref reader, options) - ); + return new DefaultValue(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } try { - return new DefaultValueVariants::Bool( - JsonSerializer.Deserialize(ref reader, options) - ); + return new DefaultValue(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -153,10 +164,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - return new DefaultValueVariants::Mixed(deserialized); + return new DefaultValue(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent3.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent3.cs index 90d94777..f6ce96d8 100644 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent3.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent3.cs @@ -45,7 +45,7 @@ public void Switch( Action @bool ) { - switch (this) + switch (this.Value) { case UnnamedSchemaWithArrayParent2Variants::String inner: @string(inner); @@ -67,7 +67,7 @@ public T Match( Func @bool ) { - return this switch + return this.Value switch { UnnamedSchemaWithArrayParent2Variants::String inner => @string(inner), UnnamedSchemaWithArrayParent2Variants::Double inner => @double(inner), @@ -76,7 +76,17 @@ public T Match( }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent3" + ); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class UnnamedSchemaWithArrayParent2Converter : JsonConverter @@ -97,7 +107,7 @@ JsonSerializerOptions options return new UnnamedSchemaWithArrayParent2Variants::String(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -108,7 +118,7 @@ JsonSerializerOptions options JsonSerializer.Deserialize(ref reader, options) ); } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -119,7 +129,7 @@ JsonSerializerOptions options JsonSerializer.Deserialize(ref reader, options) ); } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MaxValue.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MaxValue.cs index 8917b7c5..39d79c7a 100644 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MaxValue.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MaxValue.cs @@ -13,50 +13,60 @@ namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldUpdateParamsPr /// For `Number` type field, set the minimum numeric value. /// [JsonConverter(typeof(MaxValueConverter))] -public abstract record class MaxValue +public record class MaxValue { - internal MaxValue() { } + public object Value { get; private init; } - public static implicit operator MaxValue(string value) => new MaxValueVariants::String(value); + public MaxValue(string value) + { + Value = value; + } - public static implicit operator MaxValue(double value) => new MaxValueVariants::Double(value); + public MaxValue(double value) + { + Value = value; + } + + MaxValue(UnknownVariant value) + { + Value = value; + } + + public static MaxValue CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as MaxValueVariants::String)?.Value; + value = this.Value as string; return value != null; } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as MaxValueVariants::Double)?.Value; + value = this.Value as double?; return value != null; } - public void Switch( - Action @string, - Action @double - ) + public void Switch(Action @string, Action @double) { - switch (this) + switch (this.Value) { - case MaxValueVariants::String inner: - @string(inner); + case string value: + @string(value); break; - case MaxValueVariants::Double inner: - @double(inner); + case double value: + @double(value); break; default: throw new InvalidOperationException(); } } - public T Match( - Func @string, - Func @double - ) + public T Match(Func @string, Func @double) { - return this switch + return this.Value switch { MaxValueVariants::String inner => @string(inner), MaxValueVariants::Double inner => @double(inner), @@ -64,7 +74,15 @@ public T Match( }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException("Data did not match any variant of MaxValue"); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class MaxValueConverter : JsonConverter @@ -82,21 +100,19 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new MaxValueVariants::String(deserialized); + return new MaxValue(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } try { - return new MaxValueVariants::Double( - JsonSerializer.Deserialize(ref reader, options) - ); + return new MaxValue(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MinValue.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MinValue.cs index de40ef58..509139aa 100644 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MinValue.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MinValue.cs @@ -13,50 +13,60 @@ namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldUpdateParamsPr /// For `Number` type field, set the minimum numeric value. /// [JsonConverter(typeof(MinValueConverter))] -public abstract record class MinValue +public record class MinValue { - internal MinValue() { } + public object Value { get; private init; } - public static implicit operator MinValue(string value) => new MinValueVariants::String(value); + public MinValue(string value) + { + Value = value; + } - public static implicit operator MinValue(double value) => new MinValueVariants::Double(value); + public MinValue(double value) + { + Value = value; + } + + MinValue(UnknownVariant value) + { + Value = value; + } + + public static MinValue CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as MinValueVariants::String)?.Value; + value = this.Value as string; return value != null; } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as MinValueVariants::Double)?.Value; + value = this.Value as double?; return value != null; } - public void Switch( - Action @string, - Action @double - ) + public void Switch(Action @string, Action @double) { - switch (this) + switch (this.Value) { - case MinValueVariants::String inner: - @string(inner); + case string value: + @string(value); break; - case MinValueVariants::Double inner: - @double(inner); + case double value: + @double(value); break; default: throw new InvalidOperationException(); } } - public T Match( - Func @string, - Func @double - ) + public T Match(Func @string, Func @double) { - return this switch + return this.Value switch { MinValueVariants::String inner => @string(inner), MinValueVariants::Double inner => @double(inner), @@ -64,7 +74,15 @@ public T Match( }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException("Data did not match any variant of MinValue"); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class MinValueConverter : JsonConverter @@ -82,21 +100,19 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new MinValueVariants::String(deserialized); + return new MinValue(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } try { - return new MinValueVariants::Double( - JsonSerializer.Deserialize(ref reader, options) - ); + return new MinValue(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/SelectOption.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/SelectOption.cs index f4cb1bbb..60435b53 100644 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/SelectOption.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/SelectOption.cs @@ -8,66 +8,74 @@ namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldUpdateParamsProperties.SchemaProperties; [JsonConverter(typeof(SelectOptionConverter))] -public abstract record class SelectOption +public record class SelectOption { - internal SelectOption() { } + public object Value { get; private init; } - public static implicit operator SelectOption(string value) => - new SelectOptionVariants::String(value); + public SelectOption(string value) + { + Value = value; + } - public static implicit operator SelectOption(double value) => - new SelectOptionVariants::Double(value); + public SelectOption(double value) + { + Value = value; + } - public static implicit operator SelectOption(bool value) => - new SelectOptionVariants::Bool(value); + public SelectOption(bool value) + { + Value = value; + } + + SelectOption(UnknownVariant value) + { + Value = value; + } + + public static SelectOption CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as SelectOptionVariants::String)?.Value; + value = this.Value as string; return value != null; } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as SelectOptionVariants::Double)?.Value; + value = this.Value as double?; return value != null; } public bool TryPickBool([NotNullWhen(true)] out bool? value) { - value = (this as SelectOptionVariants::Bool)?.Value; + value = this.Value as bool?; return value != null; } - public void Switch( - Action @string, - Action @double, - Action @bool - ) + public void Switch(Action @string, Action @double, Action @bool) { - switch (this) + switch (this.Value) { - case SelectOptionVariants::String inner: - @string(inner); + case string value: + @string(value); break; - case SelectOptionVariants::Double inner: - @double(inner); + case double value: + @double(value); break; - case SelectOptionVariants::Bool inner: - @bool(inner); + case bool value: + @bool(value); break; default: throw new InvalidOperationException(); } } - public T Match( - Func @string, - Func @double, - Func @bool - ) + public T Match(Func @string, Func @double, Func @bool) { - return this switch + return this.Value switch { SelectOptionVariants::String inner => @string(inner), SelectOptionVariants::Double inner => @double(inner), @@ -76,7 +84,17 @@ public T Match( }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of SelectOption" + ); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class SelectOptionConverter : JsonConverter @@ -94,32 +112,28 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new SelectOptionVariants::String(deserialized); + return new SelectOption(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } try { - return new SelectOptionVariants::Double( - JsonSerializer.Deserialize(ref reader, options) - ); + return new SelectOption(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } try { - return new SelectOptionVariants::Bool( - JsonSerializer.Deserialize(ref reader, options) - ); + return new SelectOption(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs index f6b52828..ebf7c2ec 100644 --- a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs +++ b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs @@ -4,7 +4,6 @@ using System.Text.Json.Serialization; using Imagekit.Exceptions; using Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties; -using Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueVariants; using System = System; namespace Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; @@ -14,63 +13,84 @@ namespace Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.Se /// `type` of custom metadata field. /// [JsonConverter(typeof(DefaultValueConverter))] -public abstract record class DefaultValue +public record class DefaultValue { - internal DefaultValue() { } + public object Value { get; private init; } - public static implicit operator DefaultValue(string value) => new String(value); + public DefaultValue(string value) + { + Value = value; + } - public static implicit operator DefaultValue(double value) => new Double(value); + public DefaultValue(double value) + { + Value = value; + } - public static implicit operator DefaultValue(bool value) => new Bool(value); + public DefaultValue(bool value) + { + Value = value; + } - public static implicit operator DefaultValue(List value) => - new Mixed(value); + public DefaultValue(List value) + { + Value = value; + } + + DefaultValue(UnknownVariant value) + { + Value = value; + } + + public static DefaultValue CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as String)?.Value; + value = this.Value as string; return value != null; } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as Double)?.Value; + value = this.Value as double?; return value != null; } public bool TryPickBool([NotNullWhen(true)] out bool? value) { - value = (this as Bool)?.Value; + value = this.Value as bool?; return value != null; } public bool TryPickMixed([NotNullWhen(true)] out List? value) { - value = (this as Mixed)?.Value; + value = this.Value as List; return value != null; } public void Switch( - System::Action @string, - System::Action @double, - System::Action @bool, - System::Action mixed + System::Action @string, + System::Action @double, + System::Action @bool, + System::Action> mixed ) { - switch (this) + switch (this.Value) { - case String inner: - @string(inner); + case string value: + @string(value); break; - case Double inner: - @double(inner); + case double value: + @double(value); break; - case Bool inner: - @bool(inner); + case bool value: + @bool(value); break; - case Mixed inner: - mixed(inner); + case List value: + mixed(value); break; default: throw new ImageKitInvalidDataException( @@ -80,25 +100,35 @@ public void Switch( } public T Match( - System::Func @string, - System::Func @double, - System::Func @bool, - System::Func mixed + System::Func @string, + System::Func @double, + System::Func @bool, + System::Func, T> mixed ) { - return this switch + return this.Value switch { - String inner => @string(inner), - Double inner => @double(inner), - Bool inner => @bool(inner), - Mixed inner => mixed(inner), + string value => @string(value), + double value => @double(value), + bool value => @bool(value), + List value => mixed(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of DefaultValue" ), }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of DefaultValue" + ); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class DefaultValueConverter : JsonConverter @@ -116,35 +146,35 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new String(deserialized); + return new DefaultValue(deserialized); } } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant String", e) + new ImageKitInvalidDataException("Data does not match union variant 'string'", e) ); } try { - return new Double(JsonSerializer.Deserialize(ref reader, options)); + return new DefaultValue(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant Double", e) + new ImageKitInvalidDataException("Data does not match union variant 'double'", e) ); } try { - return new Bool(JsonSerializer.Deserialize(ref reader, options)); + return new DefaultValue(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant Bool", e) + new ImageKitInvalidDataException("Data does not match union variant 'bool'", e) ); } @@ -156,13 +186,16 @@ JsonSerializerOptions options ); if (deserialized != null) { - return new Mixed(deserialized); + return new DefaultValue(deserialized); } } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant Mixed", e) + new ImageKitInvalidDataException( + "Data does not match union variant 'List'", + e + ) ); } @@ -175,16 +208,7 @@ public override void Write( JsonSerializerOptions options ) { - object variant = value switch - { - String(var @string) => @string, - Double(var @double) => @double, - Bool(var @bool) => @bool, - Mixed(var mixed) => mixed, - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of DefaultValue" - ), - }; + object variant = value.Value; JsonSerializer.Serialize(writer, variant, options); } } diff --git a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent4.cs b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent4.cs index 43eae369..8d35f0e3 100644 --- a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent4.cs +++ b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent4.cs @@ -3,58 +3,74 @@ using System.Text.Json; using System.Text.Json.Serialization; using Imagekit.Exceptions; -using Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties.UnnamedSchemaWithArrayParent4Variants; using System = System; namespace Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties; [JsonConverter(typeof(UnnamedSchemaWithArrayParent4Converter))] -public abstract record class UnnamedSchemaWithArrayParent4 +public record class UnnamedSchemaWithArrayParent4 { - internal UnnamedSchemaWithArrayParent4() { } + public object Value { get; private init; } - public static implicit operator UnnamedSchemaWithArrayParent4(string value) => - new String(value); + public UnnamedSchemaWithArrayParent4(string value) + { + Value = value; + } - public static implicit operator UnnamedSchemaWithArrayParent4(double value) => - new Double(value); + public UnnamedSchemaWithArrayParent4(double value) + { + Value = value; + } - public static implicit operator UnnamedSchemaWithArrayParent4(bool value) => new Bool(value); + public UnnamedSchemaWithArrayParent4(bool value) + { + Value = value; + } + + UnnamedSchemaWithArrayParent4(UnknownVariant value) + { + Value = value; + } + + public static UnnamedSchemaWithArrayParent4 CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as String)?.Value; + value = this.Value as string; return value != null; } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as Double)?.Value; + value = this.Value as double?; return value != null; } public bool TryPickBool([NotNullWhen(true)] out bool? value) { - value = (this as Bool)?.Value; + value = this.Value as bool?; return value != null; } public void Switch( - System::Action @string, - System::Action @double, - System::Action @bool + System::Action @string, + System::Action @double, + System::Action @bool ) { - switch (this) + switch (this.Value) { - case String inner: - @string(inner); + case string value: + @string(value); break; - case Double inner: - @double(inner); + case double value: + @double(value); break; - case Bool inner: - @bool(inner); + case bool value: + @bool(value); break; default: throw new ImageKitInvalidDataException( @@ -64,23 +80,33 @@ public void Switch( } public T Match( - System::Func @string, - System::Func @double, - System::Func @bool + System::Func @string, + System::Func @double, + System::Func @bool ) { - return this switch + return this.Value switch { - String inner => @string(inner), - Double inner => @double(inner), - Bool inner => @bool(inner), + string value => @string(value), + double value => @double(value), + bool value => @bool(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of UnnamedSchemaWithArrayParent4" ), }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent4" + ); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class UnnamedSchemaWithArrayParent4Converter : JsonConverter @@ -98,35 +124,39 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new String(deserialized); + return new UnnamedSchemaWithArrayParent4(deserialized); } } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant String", e) + new ImageKitInvalidDataException("Data does not match union variant 'string'", e) ); } try { - return new Double(JsonSerializer.Deserialize(ref reader, options)); + return new UnnamedSchemaWithArrayParent4( + JsonSerializer.Deserialize(ref reader, options) + ); } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant Double", e) + new ImageKitInvalidDataException("Data does not match union variant 'double'", e) ); } try { - return new Bool(JsonSerializer.Deserialize(ref reader, options)); + return new UnnamedSchemaWithArrayParent4( + JsonSerializer.Deserialize(ref reader, options) + ); } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant Bool", e) + new ImageKitInvalidDataException("Data does not match union variant 'bool'", e) ); } @@ -139,15 +169,7 @@ public override void Write( JsonSerializerOptions options ) { - object variant = value switch - { - String(var @string) => @string, - Double(var @double) => @double, - Bool(var @bool) => @bool, - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent4" - ), - }; + object variant = value.Value; JsonSerializer.Serialize(writer, variant, options); } } diff --git a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent4Variants/All.cs b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent4Variants/All.cs deleted file mode 100644 index a094a29d..00000000 --- a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent4Variants/All.cs +++ /dev/null @@ -1,37 +0,0 @@ -using Imagekit.Core; - -namespace Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties.UnnamedSchemaWithArrayParent4Variants; - -public sealed record class String(string Value) - : UnnamedSchemaWithArrayParent4, - IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Double(double Value) - : UnnamedSchemaWithArrayParent4, - IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Bool(bool Value) : UnnamedSchemaWithArrayParent4, IVariant -{ - public static Bool From(bool value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs deleted file mode 100644 index 52dc3861..00000000 --- a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System.Collections.Generic; -using Imagekit.Core; -using Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties; - -namespace Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueVariants; - -public sealed record class String(string Value) : DefaultValue, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Double(double Value) : DefaultValue, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Bool(bool Value) : DefaultValue, IVariant -{ - public static Bool From(bool value) - { - return new(value); - } - - public override void Validate() { } -} - -/// -/// Default value should be of type array when custom metadata field type is set to -/// `MultiSelect`. -/// -public sealed record class Mixed(List Value) - : DefaultValue, - IVariant> -{ - public static Mixed From(List value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs index e0a19349..f15c4393 100644 --- a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs +++ b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs @@ -3,7 +3,6 @@ using System.Text.Json; using System.Text.Json.Serialization; using Imagekit.Exceptions; -using Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MaxValueVariants; using System = System; namespace Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; @@ -14,35 +13,51 @@ namespace Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.Se /// field, it will be a numeric value. /// [JsonConverter(typeof(MaxValueConverter))] -public abstract record class MaxValue +public record class MaxValue { - internal MaxValue() { } + public object Value { get; private init; } - public static implicit operator MaxValue(string value) => new String(value); + public MaxValue(string value) + { + Value = value; + } + + public MaxValue(double value) + { + Value = value; + } - public static implicit operator MaxValue(double value) => new Double(value); + MaxValue(UnknownVariant value) + { + Value = value; + } + + public static MaxValue CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as String)?.Value; + value = this.Value as string; return value != null; } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as Double)?.Value; + value = this.Value as double?; return value != null; } - public void Switch(System::Action @string, System::Action @double) + public void Switch(System::Action @string, System::Action @double) { - switch (this) + switch (this.Value) { - case String inner: - @string(inner); + case string value: + @string(value); break; - case Double inner: - @double(inner); + case double value: + @double(value); break; default: throw new ImageKitInvalidDataException( @@ -51,19 +66,27 @@ public void Switch(System::Action @string, System::Action @doubl } } - public T Match(System::Func @string, System::Func @double) + public T Match(System::Func @string, System::Func @double) { - return this switch + return this.Value switch { - String inner => @string(inner), - Double inner => @double(inner), + string value => @string(value), + double value => @double(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of MaxValue" ), }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException("Data did not match any variant of MaxValue"); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class MaxValueConverter : JsonConverter @@ -81,24 +104,24 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new String(deserialized); + return new MaxValue(deserialized); } } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant String", e) + new ImageKitInvalidDataException("Data does not match union variant 'string'", e) ); } try { - return new Double(JsonSerializer.Deserialize(ref reader, options)); + return new MaxValue(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant Double", e) + new ImageKitInvalidDataException("Data does not match union variant 'double'", e) ); } @@ -107,14 +130,7 @@ JsonSerializerOptions options public override void Write(Utf8JsonWriter writer, MaxValue value, JsonSerializerOptions options) { - object variant = value switch - { - String(var @string) => @string, - Double(var @double) => @double, - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of MaxValue" - ), - }; + object variant = value.Value; JsonSerializer.Serialize(writer, variant, options); } } diff --git a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs deleted file mode 100644 index 3641cf3e..00000000 --- a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Imagekit.Core; - -namespace Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MaxValueVariants; - -public sealed record class String(string Value) : MaxValue, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Double(double Value) : MaxValue, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs index 74c56254..d655fecb 100644 --- a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs +++ b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs @@ -3,7 +3,6 @@ using System.Text.Json; using System.Text.Json.Serialization; using Imagekit.Exceptions; -using Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MinValueVariants; using System = System; namespace Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; @@ -14,35 +13,51 @@ namespace Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.Se /// field, it will be a numeric value. /// [JsonConverter(typeof(MinValueConverter))] -public abstract record class MinValue +public record class MinValue { - internal MinValue() { } + public object Value { get; private init; } - public static implicit operator MinValue(string value) => new String(value); + public MinValue(string value) + { + Value = value; + } + + public MinValue(double value) + { + Value = value; + } - public static implicit operator MinValue(double value) => new Double(value); + MinValue(UnknownVariant value) + { + Value = value; + } + + public static MinValue CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as String)?.Value; + value = this.Value as string; return value != null; } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as Double)?.Value; + value = this.Value as double?; return value != null; } - public void Switch(System::Action @string, System::Action @double) + public void Switch(System::Action @string, System::Action @double) { - switch (this) + switch (this.Value) { - case String inner: - @string(inner); + case string value: + @string(value); break; - case Double inner: - @double(inner); + case double value: + @double(value); break; default: throw new ImageKitInvalidDataException( @@ -51,19 +66,27 @@ public void Switch(System::Action @string, System::Action @doubl } } - public T Match(System::Func @string, System::Func @double) + public T Match(System::Func @string, System::Func @double) { - return this switch + return this.Value switch { - String inner => @string(inner), - Double inner => @double(inner), + string value => @string(value), + double value => @double(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of MinValue" ), }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException("Data did not match any variant of MinValue"); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class MinValueConverter : JsonConverter @@ -81,24 +104,24 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new String(deserialized); + return new MinValue(deserialized); } } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant String", e) + new ImageKitInvalidDataException("Data does not match union variant 'string'", e) ); } try { - return new Double(JsonSerializer.Deserialize(ref reader, options)); + return new MinValue(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant Double", e) + new ImageKitInvalidDataException("Data does not match union variant 'double'", e) ); } @@ -107,14 +130,7 @@ JsonSerializerOptions options public override void Write(Utf8JsonWriter writer, MinValue value, JsonSerializerOptions options) { - object variant = value switch - { - String(var @string) => @string, - Double(var @double) => @double, - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of MinValue" - ), - }; + object variant = value.Value; JsonSerializer.Serialize(writer, variant, options); } } diff --git a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs deleted file mode 100644 index 6f4cdde3..00000000 --- a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Imagekit.Core; - -namespace Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MinValueVariants; - -public sealed record class String(string Value) : MinValue, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Double(double Value) : MinValue, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs index 3c953117..939622b6 100644 --- a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs +++ b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs @@ -3,56 +3,74 @@ using System.Text.Json; using System.Text.Json.Serialization; using Imagekit.Exceptions; -using Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.SelectOptionVariants; using System = System; namespace Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; [JsonConverter(typeof(SelectOptionConverter))] -public abstract record class SelectOption +public record class SelectOption { - internal SelectOption() { } + public object Value { get; private init; } - public static implicit operator SelectOption(string value) => new String(value); + public SelectOption(string value) + { + Value = value; + } + + public SelectOption(double value) + { + Value = value; + } + + public SelectOption(bool value) + { + Value = value; + } - public static implicit operator SelectOption(double value) => new Double(value); + SelectOption(UnknownVariant value) + { + Value = value; + } - public static implicit operator SelectOption(bool value) => new Bool(value); + public static SelectOption CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as String)?.Value; + value = this.Value as string; return value != null; } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as Double)?.Value; + value = this.Value as double?; return value != null; } public bool TryPickBool([NotNullWhen(true)] out bool? value) { - value = (this as Bool)?.Value; + value = this.Value as bool?; return value != null; } public void Switch( - System::Action @string, - System::Action @double, - System::Action @bool + System::Action @string, + System::Action @double, + System::Action @bool ) { - switch (this) + switch (this.Value) { - case String inner: - @string(inner); + case string value: + @string(value); break; - case Double inner: - @double(inner); + case double value: + @double(value); break; - case Bool inner: - @bool(inner); + case bool value: + @bool(value); break; default: throw new ImageKitInvalidDataException( @@ -62,23 +80,33 @@ public void Switch( } public T Match( - System::Func @string, - System::Func @double, - System::Func @bool + System::Func @string, + System::Func @double, + System::Func @bool ) { - return this switch + return this.Value switch { - String inner => @string(inner), - Double inner => @double(inner), - Bool inner => @bool(inner), + string value => @string(value), + double value => @double(value), + bool value => @bool(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of SelectOption" ), }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of SelectOption" + ); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class SelectOptionConverter : JsonConverter @@ -96,35 +124,35 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new String(deserialized); + return new SelectOption(deserialized); } } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant String", e) + new ImageKitInvalidDataException("Data does not match union variant 'string'", e) ); } try { - return new Double(JsonSerializer.Deserialize(ref reader, options)); + return new SelectOption(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant Double", e) + new ImageKitInvalidDataException("Data does not match union variant 'double'", e) ); } try { - return new Bool(JsonSerializer.Deserialize(ref reader, options)); + return new SelectOption(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant Bool", e) + new ImageKitInvalidDataException("Data does not match union variant 'bool'", e) ); } @@ -137,15 +165,7 @@ public override void Write( JsonSerializerOptions options ) { - object variant = value switch - { - String(var @string) => @string, - Double(var @double) => @double, - Bool(var @bool) => @bool, - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of SelectOption" - ), - }; + object variant = value.Value; JsonSerializer.Serialize(writer, variant, options); } } diff --git a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs deleted file mode 100644 index 20eb16c4..00000000 --- a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs +++ /dev/null @@ -1,33 +0,0 @@ -using Imagekit.Core; - -namespace Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.SelectOptionVariants; - -public sealed record class String(string Value) : SelectOption, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Double(double Value) : SelectOption, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Bool(bool Value) : SelectOption, IVariant -{ - public static Bool From(bool value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/Post.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/Post.cs index 9c23e88d..bfc3372c 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/Post.cs +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/Post.cs @@ -4,70 +4,101 @@ using System.Text.Json; using System.Text.Json.Serialization; using PostProperties = Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; -using PostVariants = Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostVariants; namespace Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties; [JsonConverter(typeof(PostConverter))] -public abstract record class Post +public record class Post { - internal Post() { } + public object Value { get; private init; } - public static implicit operator Post(PostProperties::Transformation value) => - new PostVariants::Transformation(value); + public string? Value1 + { + get + { + return Match( + transformation: (x) => x.Value, + gifToVideo: (x) => x.Value, + thumbnail: (x) => x.Value, + abs: (x) => x.Value + ); + } + } + + public Post(PostProperties::Transformation value) + { + Value = value; + } + + public Post(PostProperties::GifToVideo value) + { + Value = value; + } + + public Post(PostProperties::Thumbnail value) + { + Value = value; + } - public static implicit operator Post(PostProperties::GifToVideo value) => - new PostVariants::GifToVideo(value); + public Post(PostProperties::Abs value) + { + Value = value; + } - public static implicit operator Post(PostProperties::Thumbnail value) => - new PostVariants::Thumbnail(value); + Post(UnknownVariant value) + { + Value = value; + } - public static implicit operator Post(PostProperties::Abs value) => new PostVariants::Abs(value); + public static Post CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickTransformation([NotNullWhen(true)] out PostProperties::Transformation? value) { - value = (this as PostVariants::Transformation)?.Value; + value = this.Value as PostProperties::Transformation; return value != null; } public bool TryPickGifToVideo([NotNullWhen(true)] out PostProperties::GifToVideo? value) { - value = (this as PostVariants::GifToVideo)?.Value; + value = this.Value as PostProperties::GifToVideo; return value != null; } public bool TryPickThumbnail([NotNullWhen(true)] out PostProperties::Thumbnail? value) { - value = (this as PostVariants::Thumbnail)?.Value; + value = this.Value as PostProperties::Thumbnail; return value != null; } public bool TryPickAbs([NotNullWhen(true)] out PostProperties::Abs? value) { - value = (this as PostVariants::Abs)?.Value; + value = this.Value as PostProperties::Abs; return value != null; } public void Switch( - Action transformation, - Action gifToVideo, - Action thumbnail, - Action abs + Action transformation, + Action gifToVideo, + Action thumbnail, + Action abs ) { - switch (this) + switch (this.Value) { - case PostVariants::Transformation inner: - transformation(inner); + case PostProperties::Transformation value: + transformation(value); break; - case PostVariants::GifToVideo inner: - gifToVideo(inner); + case PostProperties::GifToVideo value: + gifToVideo(value); break; - case PostVariants::Thumbnail inner: - thumbnail(inner); + case PostProperties::Thumbnail value: + thumbnail(value); break; - case PostVariants::Abs inner: - abs(inner); + case PostProperties::Abs value: + abs(value); break; default: throw new InvalidOperationException(); @@ -75,13 +106,13 @@ public void Switch( } public T Match( - Func transformation, - Func gifToVideo, - Func thumbnail, - Func abs + Func transformation, + Func gifToVideo, + Func thumbnail, + Func abs ) { - return this switch + return this.Value switch { PostVariants::Transformation inner => transformation(inner), PostVariants::GifToVideo inner => gifToVideo(inner), @@ -91,7 +122,15 @@ public T Match( }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException("Data did not match any variant of Post"); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class PostConverter : JsonConverter @@ -127,10 +166,11 @@ JsonSerializerOptions options ); if (deserialized != null) { - return new PostVariants::Transformation(deserialized); + deserialized.Validate(); + return new Post(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -149,10 +189,11 @@ JsonSerializerOptions options ); if (deserialized != null) { - return new PostVariants::GifToVideo(deserialized); + deserialized.Validate(); + return new Post(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -171,10 +212,11 @@ JsonSerializerOptions options ); if (deserialized != null) { - return new PostVariants::Thumbnail(deserialized); + deserialized.Validate(); + return new Post(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -193,10 +235,11 @@ JsonSerializerOptions options ); if (deserialized != null) { - return new PostVariants::Abs(deserialized); + deserialized.Validate(); + return new Post(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Abs.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Abs.cs index 49ff3366..d0126436 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Abs.cs +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Abs.cs @@ -13,14 +13,14 @@ public sealed record class Abs : ModelBase, IFromRaw /// /// Streaming protocol to use (`hls` or `dash`). /// - public required ApiEnum Protocol + public required ApiEnum Protocol { get { if (!this.Properties.TryGetValue("protocol", out JsonElement element)) throw new ArgumentOutOfRangeException("protocol", "Missing required argument"); - return JsonSerializer.Deserialize>( + return JsonSerializer.Deserialize>( element, ModelBase.SerializerOptions ); @@ -37,14 +37,21 @@ public required ApiEnum Protocol /// /// Adaptive Bitrate Streaming (ABS) setup. /// - public JsonElement Type + public AbsProperties::Type Type { get { if (!this.Properties.TryGetValue("type", out JsonElement element)) throw new ArgumentOutOfRangeException("type", "Missing required argument"); - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ) + ?? throw new ImageKitInvalidDataException( + "'type' cannot be null", + new ArgumentNullException("type") + ); } set { @@ -80,12 +87,13 @@ public required string Value public override void Validate() { this.Protocol.Validate(); + this.Type.Validate(); _ = this.Value; } public Abs() { - this.Type = JsonSerializer.Deserialize("\"abs\""); + this.Type = new(); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/AbsProperties/Type.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/AbsProperties/Type.cs new file mode 100644 index 00000000..45eebee8 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/AbsProperties/Type.cs @@ -0,0 +1,50 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; +using System = System; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.AbsProperties; + +/// +/// Adaptive Bitrate Streaming (ABS) setup. +/// +[JsonConverter(typeof(Converter))] +public class Type +{ + public JsonElement Json { get; private init; } + + public Type() + { + Json = JsonSerializer.Deserialize("\"abs\""); + } + + Type(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new Type().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); + } + } + + private class Converter : JsonConverter + { + public override Type? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideo.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideo.cs index 889e5951..1a2366ec 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideo.cs +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideo.cs @@ -12,14 +12,21 @@ public sealed record class GifToVideo : ModelBase, IFromRaw /// /// Converts an animated GIF into an MP4. /// - public JsonElement Type + public GifToVideoProperties::Type Type { get { if (!this.Properties.TryGetValue("type", out JsonElement element)) throw new ArgumentOutOfRangeException("type", "Missing required argument"); - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ) + ?? throw new ImageKitInvalidDataException( + "'type' cannot be null", + new ArgumentNullException("type") + ); } set { @@ -54,12 +61,13 @@ public string? Value public override void Validate() { + this.Type.Validate(); _ = this.Value; } public GifToVideo() { - this.Type = JsonSerializer.Deserialize("\"gif-to-video\""); + this.Type = new(); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideoProperties/Type.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideoProperties/Type.cs new file mode 100644 index 00000000..91af05c2 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideoProperties/Type.cs @@ -0,0 +1,50 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; +using System = System; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.GifToVideoProperties; + +/// +/// Converts an animated GIF into an MP4. +/// +[JsonConverter(typeof(Converter))] +public class Type +{ + public JsonElement Json { get; private init; } + + public Type() + { + Json = JsonSerializer.Deserialize("\"gif-to-video\""); + } + + Type(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new Type().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); + } + } + + private class Converter : JsonConverter + { + public override Type? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Thumbnail.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Thumbnail.cs index 4b2e57c3..8f177cb5 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Thumbnail.cs +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Thumbnail.cs @@ -12,14 +12,21 @@ public sealed record class Thumbnail : ModelBase, IFromRaw /// /// Generates a thumbnail image. /// - public JsonElement Type + public ThumbnailProperties::Type Type { get { if (!this.Properties.TryGetValue("type", out JsonElement element)) throw new ArgumentOutOfRangeException("type", "Missing required argument"); - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ) + ?? throw new ImageKitInvalidDataException( + "'type' cannot be null", + new ArgumentNullException("type") + ); } set { @@ -53,12 +60,13 @@ public string? Value public override void Validate() { + this.Type.Validate(); _ = this.Value; } public Thumbnail() { - this.Type = JsonSerializer.Deserialize("\"thumbnail\""); + this.Type = new(); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/ThumbnailProperties/Type.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/ThumbnailProperties/Type.cs new file mode 100644 index 00000000..622fac4a --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/ThumbnailProperties/Type.cs @@ -0,0 +1,50 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; +using System = System; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.ThumbnailProperties; + +/// +/// Generates a thumbnail image. +/// +[JsonConverter(typeof(Converter))] +public class Type +{ + public JsonElement Json { get; private init; } + + public Type() + { + Json = JsonSerializer.Deserialize("\"thumbnail\""); + } + + Type(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new Type().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); + } + } + + private class Converter : JsonConverter + { + public override Type? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Transformation.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Transformation.cs index 556b8c65..df1933ae 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Transformation.cs +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Transformation.cs @@ -12,14 +12,21 @@ public sealed record class Transformation : ModelBase, IFromRaw /// /// Transformation type. /// - public JsonElement Type + public TransformationProperties::Type Type { get { if (!this.Properties.TryGetValue("type", out JsonElement element)) throw new ArgumentOutOfRangeException("type", "Missing required argument"); - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ) + ?? throw new ImageKitInvalidDataException( + "'type' cannot be null", + new ArgumentNullException("type") + ); } set { @@ -55,12 +62,13 @@ public required string Value public override void Validate() { + this.Type.Validate(); _ = this.Value; } public Transformation() { - this.Type = JsonSerializer.Deserialize("\"transformation\""); + this.Type = new(); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/TransformationProperties/Type.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/TransformationProperties/Type.cs new file mode 100644 index 00000000..87788254 --- /dev/null +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/TransformationProperties/Type.cs @@ -0,0 +1,50 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; +using System = System; + +namespace Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.TransformationProperties; + +/// +/// Transformation type. +/// +[JsonConverter(typeof(Converter))] +public class Type +{ + public JsonElement Json { get; private init; } + + public Type() + { + Json = JsonSerializer.Deserialize("\"transformation\""); + } + + Type(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new Type().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); + } + } + + private class Converter : JsonConverter + { + public override Type? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs index 667872fa..f9663760 100644 --- a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs +++ b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs @@ -4,7 +4,6 @@ using System.Text.Json.Serialization; using Imagekit.Exceptions; using Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties; -using Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueVariants; using System = System; namespace Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; @@ -14,63 +13,84 @@ namespace Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchem /// `type` of custom metadata field. /// [JsonConverter(typeof(DefaultValueConverter))] -public abstract record class DefaultValue +public record class DefaultValue { - internal DefaultValue() { } + public object Value { get; private init; } - public static implicit operator DefaultValue(string value) => new String(value); + public DefaultValue(string value) + { + Value = value; + } - public static implicit operator DefaultValue(double value) => new Double(value); + public DefaultValue(double value) + { + Value = value; + } - public static implicit operator DefaultValue(bool value) => new Bool(value); + public DefaultValue(bool value) + { + Value = value; + } - public static implicit operator DefaultValue(List value) => - new Mixed(value); + public DefaultValue(List value) + { + Value = value; + } + + DefaultValue(UnknownVariant value) + { + Value = value; + } + + public static DefaultValue CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as String)?.Value; + value = this.Value as string; return value != null; } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as Double)?.Value; + value = this.Value as double?; return value != null; } public bool TryPickBool([NotNullWhen(true)] out bool? value) { - value = (this as Bool)?.Value; + value = this.Value as bool?; return value != null; } public bool TryPickMixed([NotNullWhen(true)] out List? value) { - value = (this as Mixed)?.Value; + value = this.Value as List; return value != null; } public void Switch( - System::Action @string, - System::Action @double, - System::Action @bool, - System::Action mixed + System::Action @string, + System::Action @double, + System::Action @bool, + System::Action> mixed ) { - switch (this) + switch (this.Value) { - case String inner: - @string(inner); + case string value: + @string(value); break; - case Double inner: - @double(inner); + case double value: + @double(value); break; - case Bool inner: - @bool(inner); + case bool value: + @bool(value); break; - case Mixed inner: - mixed(inner); + case List value: + mixed(value); break; default: throw new ImageKitInvalidDataException( @@ -80,25 +100,35 @@ public void Switch( } public T Match( - System::Func @string, - System::Func @double, - System::Func @bool, - System::Func mixed + System::Func @string, + System::Func @double, + System::Func @bool, + System::Func, T> mixed ) { - return this switch + return this.Value switch { - String inner => @string(inner), - Double inner => @double(inner), - Bool inner => @bool(inner), - Mixed inner => mixed(inner), + string value => @string(value), + double value => @double(value), + bool value => @bool(value), + List value => mixed(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of DefaultValue" ), }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of DefaultValue" + ); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class DefaultValueConverter : JsonConverter @@ -116,35 +146,35 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new String(deserialized); + return new DefaultValue(deserialized); } } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant String", e) + new ImageKitInvalidDataException("Data does not match union variant 'string'", e) ); } try { - return new Double(JsonSerializer.Deserialize(ref reader, options)); + return new DefaultValue(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant Double", e) + new ImageKitInvalidDataException("Data does not match union variant 'double'", e) ); } try { - return new Bool(JsonSerializer.Deserialize(ref reader, options)); + return new DefaultValue(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant Bool", e) + new ImageKitInvalidDataException("Data does not match union variant 'bool'", e) ); } @@ -156,13 +186,16 @@ JsonSerializerOptions options ); if (deserialized != null) { - return new Mixed(deserialized); + return new DefaultValue(deserialized); } } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant Mixed", e) + new ImageKitInvalidDataException( + "Data does not match union variant 'List'", + e + ) ); } @@ -175,16 +208,7 @@ public override void Write( JsonSerializerOptions options ) { - object variant = value switch - { - String(var @string) => @string, - Double(var @double) => @double, - Bool(var @bool) => @bool, - Mixed(var mixed) => mixed, - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of DefaultValue" - ), - }; + object variant = value.Value; JsonSerializer.Serialize(writer, variant, options); } } diff --git a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent5.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent5.cs index bc2558b2..fe3e9e78 100644 --- a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent5.cs +++ b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent5.cs @@ -3,58 +3,74 @@ using System.Text.Json; using System.Text.Json.Serialization; using Imagekit.Exceptions; -using Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties.UnnamedSchemaWithArrayParent5Variants; using System = System; namespace Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties; [JsonConverter(typeof(UnnamedSchemaWithArrayParent5Converter))] -public abstract record class UnnamedSchemaWithArrayParent5 +public record class UnnamedSchemaWithArrayParent5 { - internal UnnamedSchemaWithArrayParent5() { } + public object Value { get; private init; } - public static implicit operator UnnamedSchemaWithArrayParent5(string value) => - new String(value); + public UnnamedSchemaWithArrayParent5(string value) + { + Value = value; + } - public static implicit operator UnnamedSchemaWithArrayParent5(double value) => - new Double(value); + public UnnamedSchemaWithArrayParent5(double value) + { + Value = value; + } - public static implicit operator UnnamedSchemaWithArrayParent5(bool value) => new Bool(value); + public UnnamedSchemaWithArrayParent5(bool value) + { + Value = value; + } + + UnnamedSchemaWithArrayParent5(UnknownVariant value) + { + Value = value; + } + + public static UnnamedSchemaWithArrayParent5 CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as String)?.Value; + value = this.Value as string; return value != null; } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as Double)?.Value; + value = this.Value as double?; return value != null; } public bool TryPickBool([NotNullWhen(true)] out bool? value) { - value = (this as Bool)?.Value; + value = this.Value as bool?; return value != null; } public void Switch( - System::Action @string, - System::Action @double, - System::Action @bool + System::Action @string, + System::Action @double, + System::Action @bool ) { - switch (this) + switch (this.Value) { - case String inner: - @string(inner); + case string value: + @string(value); break; - case Double inner: - @double(inner); + case double value: + @double(value); break; - case Bool inner: - @bool(inner); + case bool value: + @bool(value); break; default: throw new ImageKitInvalidDataException( @@ -64,23 +80,33 @@ public void Switch( } public T Match( - System::Func @string, - System::Func @double, - System::Func @bool + System::Func @string, + System::Func @double, + System::Func @bool ) { - return this switch + return this.Value switch { - String inner => @string(inner), - Double inner => @double(inner), - Bool inner => @bool(inner), + string value => @string(value), + double value => @double(value), + bool value => @bool(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of UnnamedSchemaWithArrayParent5" ), }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent5" + ); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class UnnamedSchemaWithArrayParent5Converter : JsonConverter @@ -98,35 +124,39 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new String(deserialized); + return new UnnamedSchemaWithArrayParent5(deserialized); } } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant String", e) + new ImageKitInvalidDataException("Data does not match union variant 'string'", e) ); } try { - return new Double(JsonSerializer.Deserialize(ref reader, options)); + return new UnnamedSchemaWithArrayParent5( + JsonSerializer.Deserialize(ref reader, options) + ); } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant Double", e) + new ImageKitInvalidDataException("Data does not match union variant 'double'", e) ); } try { - return new Bool(JsonSerializer.Deserialize(ref reader, options)); + return new UnnamedSchemaWithArrayParent5( + JsonSerializer.Deserialize(ref reader, options) + ); } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant Bool", e) + new ImageKitInvalidDataException("Data does not match union variant 'bool'", e) ); } @@ -139,15 +169,7 @@ public override void Write( JsonSerializerOptions options ) { - object variant = value switch - { - String(var @string) => @string, - Double(var @double) => @double, - Bool(var @bool) => @bool, - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent5" - ), - }; + object variant = value.Value; JsonSerializer.Serialize(writer, variant, options); } } diff --git a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent5Variants/All.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent5Variants/All.cs deleted file mode 100644 index e458bb13..00000000 --- a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent5Variants/All.cs +++ /dev/null @@ -1,37 +0,0 @@ -using Imagekit.Core; - -namespace Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties.UnnamedSchemaWithArrayParent5Variants; - -public sealed record class String(string Value) - : UnnamedSchemaWithArrayParent5, - IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Double(double Value) - : UnnamedSchemaWithArrayParent5, - IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Bool(bool Value) : UnnamedSchemaWithArrayParent5, IVariant -{ - public static Bool From(bool value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs deleted file mode 100644 index aaad001b..00000000 --- a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System.Collections.Generic; -using Imagekit.Core; -using Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties; - -namespace Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueVariants; - -public sealed record class String(string Value) : DefaultValue, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Double(double Value) : DefaultValue, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Bool(bool Value) : DefaultValue, IVariant -{ - public static Bool From(bool value) - { - return new(value); - } - - public override void Validate() { } -} - -/// -/// Default value should be of type array when custom metadata field type is set to -/// `MultiSelect`. -/// -public sealed record class Mixed(List Value) - : DefaultValue, - IVariant> -{ - public static Mixed From(List value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs index d1c78dbc..f1b73284 100644 --- a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs +++ b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs @@ -3,7 +3,6 @@ using System.Text.Json; using System.Text.Json.Serialization; using Imagekit.Exceptions; -using Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MaxValueVariants; using System = System; namespace Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; @@ -14,35 +13,51 @@ namespace Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchem /// field, it will be a numeric value. /// [JsonConverter(typeof(MaxValueConverter))] -public abstract record class MaxValue +public record class MaxValue { - internal MaxValue() { } + public object Value { get; private init; } - public static implicit operator MaxValue(string value) => new String(value); + public MaxValue(string value) + { + Value = value; + } + + public MaxValue(double value) + { + Value = value; + } - public static implicit operator MaxValue(double value) => new Double(value); + MaxValue(UnknownVariant value) + { + Value = value; + } + + public static MaxValue CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as String)?.Value; + value = this.Value as string; return value != null; } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as Double)?.Value; + value = this.Value as double?; return value != null; } - public void Switch(System::Action @string, System::Action @double) + public void Switch(System::Action @string, System::Action @double) { - switch (this) + switch (this.Value) { - case String inner: - @string(inner); + case string value: + @string(value); break; - case Double inner: - @double(inner); + case double value: + @double(value); break; default: throw new ImageKitInvalidDataException( @@ -51,19 +66,27 @@ public void Switch(System::Action @string, System::Action @doubl } } - public T Match(System::Func @string, System::Func @double) + public T Match(System::Func @string, System::Func @double) { - return this switch + return this.Value switch { - String inner => @string(inner), - Double inner => @double(inner), + string value => @string(value), + double value => @double(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of MaxValue" ), }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException("Data did not match any variant of MaxValue"); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class MaxValueConverter : JsonConverter @@ -81,24 +104,24 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new String(deserialized); + return new MaxValue(deserialized); } } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant String", e) + new ImageKitInvalidDataException("Data does not match union variant 'string'", e) ); } try { - return new Double(JsonSerializer.Deserialize(ref reader, options)); + return new MaxValue(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant Double", e) + new ImageKitInvalidDataException("Data does not match union variant 'double'", e) ); } @@ -107,14 +130,7 @@ JsonSerializerOptions options public override void Write(Utf8JsonWriter writer, MaxValue value, JsonSerializerOptions options) { - object variant = value switch - { - String(var @string) => @string, - Double(var @double) => @double, - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of MaxValue" - ), - }; + object variant = value.Value; JsonSerializer.Serialize(writer, variant, options); } } diff --git a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs deleted file mode 100644 index c61194c8..00000000 --- a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Imagekit.Core; - -namespace Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MaxValueVariants; - -public sealed record class String(string Value) : MaxValue, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Double(double Value) : MaxValue, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs index 6ba03bd9..274d1d00 100644 --- a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs +++ b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs @@ -3,7 +3,6 @@ using System.Text.Json; using System.Text.Json.Serialization; using Imagekit.Exceptions; -using Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MinValueVariants; using System = System; namespace Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; @@ -14,35 +13,51 @@ namespace Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchem /// field, it will be a numeric value. /// [JsonConverter(typeof(MinValueConverter))] -public abstract record class MinValue +public record class MinValue { - internal MinValue() { } + public object Value { get; private init; } - public static implicit operator MinValue(string value) => new String(value); + public MinValue(string value) + { + Value = value; + } + + public MinValue(double value) + { + Value = value; + } - public static implicit operator MinValue(double value) => new Double(value); + MinValue(UnknownVariant value) + { + Value = value; + } + + public static MinValue CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as String)?.Value; + value = this.Value as string; return value != null; } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as Double)?.Value; + value = this.Value as double?; return value != null; } - public void Switch(System::Action @string, System::Action @double) + public void Switch(System::Action @string, System::Action @double) { - switch (this) + switch (this.Value) { - case String inner: - @string(inner); + case string value: + @string(value); break; - case Double inner: - @double(inner); + case double value: + @double(value); break; default: throw new ImageKitInvalidDataException( @@ -51,19 +66,27 @@ public void Switch(System::Action @string, System::Action @doubl } } - public T Match(System::Func @string, System::Func @double) + public T Match(System::Func @string, System::Func @double) { - return this switch + return this.Value switch { - String inner => @string(inner), - Double inner => @double(inner), + string value => @string(value), + double value => @double(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of MinValue" ), }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException("Data did not match any variant of MinValue"); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class MinValueConverter : JsonConverter @@ -81,24 +104,24 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new String(deserialized); + return new MinValue(deserialized); } } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant String", e) + new ImageKitInvalidDataException("Data does not match union variant 'string'", e) ); } try { - return new Double(JsonSerializer.Deserialize(ref reader, options)); + return new MinValue(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant Double", e) + new ImageKitInvalidDataException("Data does not match union variant 'double'", e) ); } @@ -107,14 +130,7 @@ JsonSerializerOptions options public override void Write(Utf8JsonWriter writer, MinValue value, JsonSerializerOptions options) { - object variant = value switch - { - String(var @string) => @string, - Double(var @double) => @double, - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of MinValue" - ), - }; + object variant = value.Value; JsonSerializer.Serialize(writer, variant, options); } } diff --git a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs deleted file mode 100644 index 31316111..00000000 --- a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Imagekit.Core; - -namespace Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MinValueVariants; - -public sealed record class String(string Value) : MinValue, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Double(double Value) : MinValue, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs index fc38be94..3ba7aa67 100644 --- a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs +++ b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs @@ -3,56 +3,74 @@ using System.Text.Json; using System.Text.Json.Serialization; using Imagekit.Exceptions; -using Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.SelectOptionVariants; using System = System; namespace Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; [JsonConverter(typeof(SelectOptionConverter))] -public abstract record class SelectOption +public record class SelectOption { - internal SelectOption() { } + public object Value { get; private init; } - public static implicit operator SelectOption(string value) => new String(value); + public SelectOption(string value) + { + Value = value; + } + + public SelectOption(double value) + { + Value = value; + } + + public SelectOption(bool value) + { + Value = value; + } - public static implicit operator SelectOption(double value) => new Double(value); + SelectOption(UnknownVariant value) + { + Value = value; + } - public static implicit operator SelectOption(bool value) => new Bool(value); + public static SelectOption CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as String)?.Value; + value = this.Value as string; return value != null; } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as Double)?.Value; + value = this.Value as double?; return value != null; } public bool TryPickBool([NotNullWhen(true)] out bool? value) { - value = (this as Bool)?.Value; + value = this.Value as bool?; return value != null; } public void Switch( - System::Action @string, - System::Action @double, - System::Action @bool + System::Action @string, + System::Action @double, + System::Action @bool ) { - switch (this) + switch (this.Value) { - case String inner: - @string(inner); + case string value: + @string(value); break; - case Double inner: - @double(inner); + case double value: + @double(value); break; - case Bool inner: - @bool(inner); + case bool value: + @bool(value); break; default: throw new ImageKitInvalidDataException( @@ -62,23 +80,33 @@ public void Switch( } public T Match( - System::Func @string, - System::Func @double, - System::Func @bool + System::Func @string, + System::Func @double, + System::Func @bool ) { - return this switch + return this.Value switch { - String inner => @string(inner), - Double inner => @double(inner), - Bool inner => @bool(inner), + string value => @string(value), + double value => @double(value), + bool value => @bool(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of SelectOption" ), }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of SelectOption" + ); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class SelectOptionConverter : JsonConverter @@ -96,35 +124,35 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new String(deserialized); + return new SelectOption(deserialized); } } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant String", e) + new ImageKitInvalidDataException("Data does not match union variant 'string'", e) ); } try { - return new Double(JsonSerializer.Deserialize(ref reader, options)); + return new SelectOption(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant Double", e) + new ImageKitInvalidDataException("Data does not match union variant 'double'", e) ); } try { - return new Bool(JsonSerializer.Deserialize(ref reader, options)); + return new SelectOption(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant Bool", e) + new ImageKitInvalidDataException("Data does not match union variant 'bool'", e) ); } @@ -137,15 +165,7 @@ public override void Write( JsonSerializerOptions options ) { - object variant = value switch - { - String(var @string) => @string, - Double(var @double) => @double, - Bool(var @bool) => @bool, - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of SelectOption" - ), - }; + object variant = value.Value; JsonSerializer.Serialize(writer, variant, options); } } diff --git a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs deleted file mode 100644 index a17539fb..00000000 --- a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs +++ /dev/null @@ -1,33 +0,0 @@ -using Imagekit.Core; - -namespace Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.SelectOptionVariants; - -public sealed record class String(string Value) : SelectOption, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Double(double Value) : SelectOption, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Bool(bool Value) : SelectOption, IVariant -{ - public static Bool From(bool value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/Files/UpdateFileRequest.cs b/src/Imagekit/Models/Files/UpdateFileRequest.cs index 03f01642..fc16cb9a 100644 --- a/src/Imagekit/Models/Files/UpdateFileRequest.cs +++ b/src/Imagekit/Models/Files/UpdateFileRequest.cs @@ -5,7 +5,6 @@ using System.Text.Json.Serialization; using Imagekit.Exceptions; using Imagekit.Models.Files.UpdateFileRequestProperties; -using UpdateFileRequestVariants = Imagekit.Models.Files.UpdateFileRequestVariants; namespace Imagekit.Models.Files; @@ -13,19 +12,33 @@ namespace Imagekit.Models.Files; /// Schema for update file update request. /// [JsonConverter(typeof(UpdateFileRequestConverter))] -public abstract record class UpdateFileRequest +public record class UpdateFileRequest { - internal UpdateFileRequest() { } + public object Value { get; private init; } - public static implicit operator UpdateFileRequest(UpdateFileDetails value) => - new UpdateFileRequestVariants::UpdateFileDetails(value); + public UpdateFileRequest(UpdateFileDetails value) + { + Value = value; + } + + public UpdateFileRequest(ChangePublicationStatus value) + { + Value = value; + } + + UpdateFileRequest(UnknownVariant value) + { + Value = value; + } - public static implicit operator UpdateFileRequest(ChangePublicationStatus value) => - new UpdateFileRequestVariants::ChangePublicationStatus(value); + public static UpdateFileRequest CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickDetails([NotNullWhen(true)] out UpdateFileDetails? value) { - value = (this as UpdateFileRequestVariants::UpdateFileDetails)?.Value; + value = this.Value as UpdateFileDetails; return value != null; } @@ -33,22 +46,22 @@ public bool TryPickChangePublicationStatus( [NotNullWhen(true)] out ChangePublicationStatus? value ) { - value = (this as UpdateFileRequestVariants::ChangePublicationStatus)?.Value; + value = this.Value as ChangePublicationStatus; return value != null; } public void Switch( - Action details, - Action changePublicationStatus + Action details, + Action changePublicationStatus ) { - switch (this) + switch (this.Value) { - case UpdateFileRequestVariants::UpdateFileDetails inner: - details(inner); + case UpdateFileDetails value: + details(value); break; - case UpdateFileRequestVariants::ChangePublicationStatus inner: - changePublicationStatus(inner); + case ChangePublicationStatus value: + changePublicationStatus(value); break; default: throw new ImageKitInvalidDataException( @@ -58,23 +71,31 @@ public void Switch( } public T Match( - Func details, - Func changePublicationStatus + Func details, + Func changePublicationStatus ) { - return this switch + return this.Value switch { - UpdateFileRequestVariants::UpdateFileDetails inner => details(inner), - UpdateFileRequestVariants::ChangePublicationStatus inner => changePublicationStatus( - inner - ), + UpdateFileDetails value => details(value), + ChangePublicationStatus value => changePublicationStatus(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of UpdateFileRequest" ), }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of UpdateFileRequest" + ); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class UpdateFileRequestConverter : JsonConverter @@ -92,14 +113,15 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new UpdateFileRequestVariants::UpdateFileDetails(deserialized); + deserialized.Validate(); + return new UpdateFileRequest(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( new ImageKitInvalidDataException( - "Data does not match union variant UpdateFileRequestVariants::UpdateFileDetails", + "Data does not match union variant 'UpdateFileDetails'", e ) ); @@ -113,14 +135,15 @@ JsonSerializerOptions options ); if (deserialized != null) { - return new UpdateFileRequestVariants::ChangePublicationStatus(deserialized); + deserialized.Validate(); + return new UpdateFileRequest(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( new ImageKitInvalidDataException( - "Data does not match union variant UpdateFileRequestVariants::ChangePublicationStatus", + "Data does not match union variant 'ChangePublicationStatus'", e ) ); @@ -135,15 +158,7 @@ public override void Write( JsonSerializerOptions options ) { - object variant = value switch - { - UpdateFileRequestVariants::UpdateFileDetails(var details) => details, - UpdateFileRequestVariants::ChangePublicationStatus(var changePublicationStatus) => - changePublicationStatus, - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of UpdateFileRequest" - ), - }; + object variant = value.Value; JsonSerializer.Serialize(writer, variant, options); } } diff --git a/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/RemoveAITags.cs b/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/RemoveAITags.cs index 47f0db35..acb84e8f 100644 --- a/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/RemoveAITags.cs +++ b/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/RemoveAITags.cs @@ -17,42 +17,60 @@ namespace Imagekit.Models.Files.FileUpdateParamsProperties.UpdateProperties.Upda /// are processed. /// [JsonConverter(typeof(RemoveAITagsConverter))] -public abstract record class RemoveAITags +public record class RemoveAITags { - internal RemoveAITags() { } + public object Value { get; private init; } - public static implicit operator RemoveAITags(List value) => new Strings(value); + public RemoveAITags(List value) + { + Value = value; + } + + public RemoveAITags(UnionMember1 value) + { + Value = value; + } + + RemoveAITags(UnknownVariant value) + { + Value = value; + } + + public static RemoveAITags CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickStrings([NotNullWhen(true)] out List? value) { - value = (this as Strings)?.Value; + value = this.Value as List; return value != null; } - public bool TryPickAll([NotNullWhen(true)] out JsonElement? value) + public bool TryPickAll([NotNullWhen(true)] out UnionMember1? value) { - value = (this as All)?.Value; + value = this.Value as UnionMember1; return value != null; } - public void Switch(Action strings, Action all) + public void Switch(Action> strings, Action all) { - switch (this) + switch (this.Value) { - case Strings inner: - strings(inner); + case List value: + strings(value); break; - case All inner: - all(inner); + case UnionMember1 value: + all(value); break; default: throw new InvalidOperationException(); } } - public T Match(Func strings, Func all) + public T Match(Func, T> strings, Func all) { - return this switch + return this.Value switch { Strings inner => strings(inner), All inner => all(inner), @@ -60,7 +78,17 @@ public T Match(Func strings, Func all) }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of RemoveAITags" + ); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class RemoveAITagsConverter : JsonConverter @@ -75,9 +103,14 @@ JsonSerializerOptions options try { - return new All(JsonSerializer.Deserialize(ref reader, options)); + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + deserialized.Validate(); + return new RemoveAITags(deserialized); + } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -87,10 +120,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize>(ref reader, options); if (deserialized != null) { - return new Strings(deserialized); + return new RemoveAITags(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/RemoveAITagsProperties/UnionMember1.cs b/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/RemoveAITagsProperties/UnionMember1.cs new file mode 100644 index 00000000..a5afcbe0 --- /dev/null +++ b/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/RemoveAITagsProperties/UnionMember1.cs @@ -0,0 +1,51 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; + +namespace Imagekit.Models.Files.UpdateFileRequestProperties.UpdateFileDetailsProperties.RemoveAITagsProperties; + +[JsonConverter(typeof(Converter))] +public class UnionMember1 +{ + public JsonElement Json { get; private init; } + + public UnionMember1() + { + Json = JsonSerializer.Deserialize("\"all\""); + } + + UnionMember1(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new UnionMember1().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'UnionMember1'"); + } + } + + private class Converter : JsonConverter + { + public override UnionMember1? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write( + Utf8JsonWriter writer, + UnionMember1 value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/Files/UpdateFileRequestVariants/All.cs b/src/Imagekit/Models/Files/UpdateFileRequestVariants/All.cs deleted file mode 100644 index 4d7582ff..00000000 --- a/src/Imagekit/Models/Files/UpdateFileRequestVariants/All.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Imagekit.Core; -using UpdateFileRequestProperties = Imagekit.Models.Files.UpdateFileRequestProperties; - -namespace Imagekit.Models.Files.UpdateFileRequestVariants; - -public sealed record class UpdateFileDetails(UpdateFileRequestProperties::UpdateFileDetails Value) - : UpdateFileRequest, - IVariant -{ - public static UpdateFileDetails From(UpdateFileRequestProperties::UpdateFileDetails value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class ChangePublicationStatus( - UpdateFileRequestProperties::ChangePublicationStatus Value -) - : UpdateFileRequest, - IVariant -{ - public static ChangePublicationStatus From( - UpdateFileRequestProperties::ChangePublicationStatus value - ) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} diff --git a/src/Imagekit/Models/ImageOverlay.cs b/src/Imagekit/Models/ImageOverlay.cs index 17bc7fd4..d1fce933 100644 --- a/src/Imagekit/Models/ImageOverlay.cs +++ b/src/Imagekit/Models/ImageOverlay.cs @@ -159,7 +159,7 @@ public override void Validate() public ImageOverlay() { - this.Type = JsonSerializer.Deserialize("\"image\""); + this.Type = new(); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/ImageOverlayProperties/IntersectionMember1.cs b/src/Imagekit/Models/ImageOverlayProperties/IntersectionMember1.cs index 10900ce7..5366aae5 100644 --- a/src/Imagekit/Models/ImageOverlayProperties/IntersectionMember1.cs +++ b/src/Imagekit/Models/ImageOverlayProperties/IntersectionMember1.cs @@ -115,7 +115,7 @@ public override void Validate() public IntersectionMember1() { - this.Type = JsonSerializer.Deserialize("\"image\""); + this.Type = new(); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/Overlay.cs b/src/Imagekit/Models/Overlay.cs index a24cd5e1..386b9c2e 100644 --- a/src/Imagekit/Models/Overlay.cs +++ b/src/Imagekit/Models/Overlay.cs @@ -13,79 +13,155 @@ namespace Imagekit.Models; /// using layers](https://imagekit.io/docs/transformations#overlay-using-layers). /// [JsonConverter(typeof(OverlayConverter))] -public abstract record class Overlay +public record class Overlay { - internal Overlay() { } + public object Value { get; private init; } - public static implicit operator Overlay(TextOverlay value) => - new OverlayVariants::TextOverlay(value); + public OverlayPosition? Position + { + get + { + return Match( + text: (x) => x.Position, + image: (x) => x.Position, + video: (x) => x.Position, + subtitle: (x) => x.Position, + solidColor: (x) => x.Position + ); + } + } - public static implicit operator Overlay(ImageOverlay value) => - new OverlayVariants::ImageOverlay(value); + public OverlayTiming? Timing + { + get + { + return Match( + text: (x) => x.Timing, + image: (x) => x.Timing, + video: (x) => x.Timing, + subtitle: (x) => x.Timing, + solidColor: (x) => x.Timing + ); + } + } - public static implicit operator Overlay(VideoOverlay value) => - new OverlayVariants::VideoOverlay(value); + public JsonElement Type + { + get + { + return Match( + text: (x) => x.Type, + image: (x) => x.Type, + video: (x) => x.Type, + subtitle: (x) => x.Type, + solidColor: (x) => x.Type + ); + } + } + + public string? Input + { + get + { + return Match( + text: (_) => null, + image: (x) => x.Input, + video: (x) => x.Input, + subtitle: (x) => x.Input, + solidColor: (_) => null + ); + } + } - public static implicit operator Overlay(SubtitleOverlay value) => - new OverlayVariants::SubtitleOverlay(value); + public Overlay(TextOverlay value) + { + Value = value; + } - public static implicit operator Overlay(SolidColorOverlay value) => - new OverlayVariants::SolidColorOverlay(value); + public Overlay(ImageOverlay value) + { + Value = value; + } + + public Overlay(VideoOverlay value) + { + Value = value; + } + + public Overlay(SubtitleOverlay value) + { + Value = value; + } + + public Overlay(SolidColorOverlay value) + { + Value = value; + } + + Overlay(UnknownVariant value) + { + Value = value; + } + + public static Overlay CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickText([NotNullWhen(true)] out TextOverlay? value) { - value = (this as OverlayVariants::TextOverlay)?.Value; + value = this.Value as TextOverlay; return value != null; } public bool TryPickImage([NotNullWhen(true)] out ImageOverlay? value) { - value = (this as OverlayVariants::ImageOverlay)?.Value; + value = this.Value as ImageOverlay; return value != null; } public bool TryPickVideo([NotNullWhen(true)] out VideoOverlay? value) { - value = (this as OverlayVariants::VideoOverlay)?.Value; + value = this.Value as VideoOverlay; return value != null; } public bool TryPickSubtitle([NotNullWhen(true)] out SubtitleOverlay? value) { - value = (this as OverlayVariants::SubtitleOverlay)?.Value; + value = this.Value as SubtitleOverlay; return value != null; } public bool TryPickSolidColor([NotNullWhen(true)] out SolidColorOverlay? value) { - value = (this as OverlayVariants::SolidColorOverlay)?.Value; + value = this.Value as SolidColorOverlay; return value != null; } public void Switch( - Action text, - Action image, - Action video, - Action subtitle, - Action solidColor + Action text, + Action image, + Action video, + Action subtitle, + Action solidColor ) { - switch (this) + switch (this.Value) { - case OverlayVariants::TextOverlay inner: - text(inner); + case TextOverlay value: + text(value); break; - case OverlayVariants::ImageOverlay inner: - image(inner); + case ImageOverlay value: + image(value); break; - case OverlayVariants::VideoOverlay inner: - video(inner); + case VideoOverlay value: + video(value); break; - case OverlayVariants::SubtitleOverlay inner: - subtitle(inner); + case SubtitleOverlay value: + subtitle(value); break; - case OverlayVariants::SolidColorOverlay inner: - solidColor(inner); + case SolidColorOverlay value: + solidColor(value); break; default: throw new InvalidOperationException(); @@ -93,14 +169,14 @@ public void Switch( } public T Match( - Func text, - Func image, - Func video, - Func subtitle, - Func solidColor + Func text, + Func image, + Func video, + Func subtitle, + Func solidColor ) { - return this switch + return this.Value switch { OverlayVariants::TextOverlay inner => text(inner), OverlayVariants::ImageOverlay inner => image(inner), @@ -111,7 +187,15 @@ public T Match( }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException("Data did not match any variant of Overlay"); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class OverlayConverter : JsonConverter @@ -144,10 +228,11 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(json, options); if (deserialized != null) { - return new OverlayVariants::TextOverlay(deserialized); + deserialized.Validate(); + return new Overlay(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -163,10 +248,11 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(json, options); if (deserialized != null) { - return new OverlayVariants::ImageOverlay(deserialized); + deserialized.Validate(); + return new Overlay(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -182,10 +268,11 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(json, options); if (deserialized != null) { - return new OverlayVariants::VideoOverlay(deserialized); + deserialized.Validate(); + return new Overlay(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -201,10 +288,11 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(json, options); if (deserialized != null) { - return new OverlayVariants::SubtitleOverlay(deserialized); + deserialized.Validate(); + return new Overlay(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -220,10 +308,11 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(json, options); if (deserialized != null) { - return new OverlayVariants::SolidColorOverlay(deserialized); + deserialized.Validate(); + return new Overlay(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/OverlayPositionProperties/X.cs b/src/Imagekit/Models/OverlayPositionProperties/X.cs index 5b693cdc..b6fe25d7 100644 --- a/src/Imagekit/Models/OverlayPositionProperties/X.cs +++ b/src/Imagekit/Models/OverlayPositionProperties/X.cs @@ -14,44 +14,60 @@ namespace Imagekit.Models.OverlayPositionProperties; /// expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). /// [JsonConverter(typeof(XConverter))] -public abstract record class X +public record class X { - internal X() { } + public object Value { get; private init; } - public static implicit operator X(double value) => new XVariants::Double(value); + public X(double value) + { + Value = value; + } + + public X(string value) + { + Value = value; + } - public static implicit operator X(string value) => new XVariants::String(value); + X(UnknownVariant value) + { + Value = value; + } + + public static X CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as XVariants::Double)?.Value; + value = this.Value as double?; return value != null; } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as XVariants::String)?.Value; + value = this.Value as string; return value != null; } - public void Switch(Action @double, Action @string) + public void Switch(Action @double, Action @string) { - switch (this) + switch (this.Value) { - case XVariants::Double inner: - @double(inner); + case double value: + @double(value); break; - case XVariants::String inner: - @string(inner); + case string value: + @string(value); break; default: throw new InvalidOperationException(); } } - public T Match(Func @double, Func @string) + public T Match(Func @double, Func @string) { - return this switch + return this.Value switch { XVariants::Double inner => @double(inner), XVariants::String inner => @string(inner), @@ -59,7 +75,15 @@ public T Match(Func @double, Func }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException("Data did not match any variant of X"); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class XConverter : JsonConverter @@ -74,9 +98,9 @@ JsonSerializerOptions options try { - return new XVariants::Double(JsonSerializer.Deserialize(ref reader, options)); + return new X(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -86,10 +110,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new XVariants::String(deserialized); + return new X(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/OverlayPositionProperties/Y.cs b/src/Imagekit/Models/OverlayPositionProperties/Y.cs index 12234993..8a901e64 100644 --- a/src/Imagekit/Models/OverlayPositionProperties/Y.cs +++ b/src/Imagekit/Models/OverlayPositionProperties/Y.cs @@ -14,44 +14,60 @@ namespace Imagekit.Models.OverlayPositionProperties; /// expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). /// [JsonConverter(typeof(YConverter))] -public abstract record class Y +public record class Y { - internal Y() { } + public object Value { get; private init; } - public static implicit operator Y(double value) => new YVariants::Double(value); + public Y(double value) + { + Value = value; + } + + public Y(string value) + { + Value = value; + } - public static implicit operator Y(string value) => new YVariants::String(value); + Y(UnknownVariant value) + { + Value = value; + } + + public static Y CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as YVariants::Double)?.Value; + value = this.Value as double?; return value != null; } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as YVariants::String)?.Value; + value = this.Value as string; return value != null; } - public void Switch(Action @double, Action @string) + public void Switch(Action @double, Action @string) { - switch (this) + switch (this.Value) { - case YVariants::Double inner: - @double(inner); + case double value: + @double(value); break; - case YVariants::String inner: - @string(inner); + case string value: + @string(value); break; default: throw new InvalidOperationException(); } } - public T Match(Func @double, Func @string) + public T Match(Func @double, Func @string) { - return this switch + return this.Value switch { YVariants::Double inner => @double(inner), YVariants::String inner => @string(inner), @@ -59,7 +75,15 @@ public T Match(Func @double, Func }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException("Data did not match any variant of Y"); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class YConverter : JsonConverter @@ -74,9 +98,9 @@ JsonSerializerOptions options try { - return new YVariants::Double(JsonSerializer.Deserialize(ref reader, options)); + return new Y(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -86,10 +110,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new YVariants::String(deserialized); + return new Y(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/OverlayTimingProperties/Duration.cs b/src/Imagekit/Models/OverlayTimingProperties/Duration.cs index 3fba7aa6..a14b71a6 100644 --- a/src/Imagekit/Models/OverlayTimingProperties/Duration.cs +++ b/src/Imagekit/Models/OverlayTimingProperties/Duration.cs @@ -14,50 +14,60 @@ namespace Imagekit.Models.OverlayTimingProperties; /// Applies only if the base asset is a video. Maps to `ldu` in the URL. /// [JsonConverter(typeof(DurationConverter))] -public abstract record class Duration +public record class Duration { - internal Duration() { } + public object Value { get; private init; } - public static implicit operator Duration(double value) => new DurationVariants::Double(value); + public Duration(double value) + { + Value = value; + } - public static implicit operator Duration(string value) => new DurationVariants::String(value); + public Duration(string value) + { + Value = value; + } + + Duration(UnknownVariant value) + { + Value = value; + } + + public static Duration CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as DurationVariants::Double)?.Value; + value = this.Value as double?; return value != null; } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as DurationVariants::String)?.Value; + value = this.Value as string; return value != null; } - public void Switch( - Action @double, - Action @string - ) + public void Switch(Action @double, Action @string) { - switch (this) + switch (this.Value) { - case DurationVariants::Double inner: - @double(inner); + case double value: + @double(value); break; - case DurationVariants::String inner: - @string(inner); + case string value: + @string(value); break; default: throw new InvalidOperationException(); } } - public T Match( - Func @double, - Func @string - ) + public T Match(Func @double, Func @string) { - return this switch + return this.Value switch { DurationVariants::Double inner => @double(inner), DurationVariants::String inner => @string(inner), @@ -65,7 +75,15 @@ public T Match( }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException("Data did not match any variant of Duration"); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class DurationConverter : JsonConverter @@ -80,11 +98,9 @@ JsonSerializerOptions options try { - return new DurationVariants::Double( - JsonSerializer.Deserialize(ref reader, options) - ); + return new Duration(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -94,10 +110,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new DurationVariants::String(deserialized); + return new Duration(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/OverlayTimingProperties/End.cs b/src/Imagekit/Models/OverlayTimingProperties/End.cs index b1fc3570..9b88c99a 100644 --- a/src/Imagekit/Models/OverlayTimingProperties/End.cs +++ b/src/Imagekit/Models/OverlayTimingProperties/End.cs @@ -15,44 +15,60 @@ namespace Imagekit.Models.OverlayTimingProperties; /// is a video. Maps to `leo` in the URL. /// [JsonConverter(typeof(EndConverter))] -public abstract record class End +public record class End { - internal End() { } + public object Value { get; private init; } - public static implicit operator End(double value) => new EndVariants::Double(value); + public End(double value) + { + Value = value; + } + + public End(string value) + { + Value = value; + } - public static implicit operator End(string value) => new EndVariants::String(value); + End(UnknownVariant value) + { + Value = value; + } + + public static End CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as EndVariants::Double)?.Value; + value = this.Value as double?; return value != null; } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as EndVariants::String)?.Value; + value = this.Value as string; return value != null; } - public void Switch(Action @double, Action @string) + public void Switch(Action @double, Action @string) { - switch (this) + switch (this.Value) { - case EndVariants::Double inner: - @double(inner); + case double value: + @double(value); break; - case EndVariants::String inner: - @string(inner); + case string value: + @string(value); break; default: throw new InvalidOperationException(); } } - public T Match(Func @double, Func @string) + public T Match(Func @double, Func @string) { - return this switch + return this.Value switch { EndVariants::Double inner => @double(inner), EndVariants::String inner => @string(inner), @@ -60,7 +76,15 @@ public T Match(Func @double, Func @@ -75,9 +99,9 @@ JsonSerializerOptions options try { - return new EndVariants::Double(JsonSerializer.Deserialize(ref reader, options)); + return new End(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -87,10 +111,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new EndVariants::String(deserialized); + return new End(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/OverlayTimingProperties/Start.cs b/src/Imagekit/Models/OverlayTimingProperties/Start.cs index dceb5100..40dba4c8 100644 --- a/src/Imagekit/Models/OverlayTimingProperties/Start.cs +++ b/src/Imagekit/Models/OverlayTimingProperties/Start.cs @@ -14,47 +14,60 @@ namespace Imagekit.Models.OverlayTimingProperties; /// only if the base asset is a video. Maps to `lso` in the URL. /// [JsonConverter(typeof(StartConverter))] -public abstract record class Start +public record class Start { - internal Start() { } + public object Value { get; private init; } - public static implicit operator Start(double value) => new StartVariants::Double(value); + public Start(double value) + { + Value = value; + } + + public Start(string value) + { + Value = value; + } + + Start(UnknownVariant value) + { + Value = value; + } - public static implicit operator Start(string value) => new StartVariants::String(value); + public static Start CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as StartVariants::Double)?.Value; + value = this.Value as double?; return value != null; } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as StartVariants::String)?.Value; + value = this.Value as string; return value != null; } - public void Switch(Action @double, Action @string) + public void Switch(Action @double, Action @string) { - switch (this) + switch (this.Value) { - case StartVariants::Double inner: - @double(inner); + case double value: + @double(value); break; - case StartVariants::String inner: - @string(inner); + case string value: + @string(value); break; default: throw new InvalidOperationException(); } } - public T Match( - Func @double, - Func @string - ) + public T Match(Func @double, Func @string) { - return this switch + return this.Value switch { StartVariants::Double inner => @double(inner), StartVariants::String inner => @string(inner), @@ -62,7 +75,15 @@ public T Match( }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException("Data did not match any variant of Start"); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class StartConverter : JsonConverter @@ -77,11 +98,9 @@ JsonSerializerOptions options try { - return new StartVariants::Double( - JsonSerializer.Deserialize(ref reader, options) - ); + return new Start(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -91,10 +110,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new StartVariants::String(deserialized); + return new Start(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/SolidColorOverlay.cs b/src/Imagekit/Models/SolidColorOverlay.cs index 4f81be5f..8a045c39 100644 --- a/src/Imagekit/Models/SolidColorOverlay.cs +++ b/src/Imagekit/Models/SolidColorOverlay.cs @@ -133,7 +133,7 @@ public override void Validate() public SolidColorOverlay() { - this.Type = JsonSerializer.Deserialize("\"solidColor\""); + this.Type = new(); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/SolidColorOverlayProperties/IntersectionMember1.cs b/src/Imagekit/Models/SolidColorOverlayProperties/IntersectionMember1.cs index 4ae49341..364610ea 100644 --- a/src/Imagekit/Models/SolidColorOverlayProperties/IntersectionMember1.cs +++ b/src/Imagekit/Models/SolidColorOverlayProperties/IntersectionMember1.cs @@ -89,7 +89,7 @@ public override void Validate() public IntersectionMember1() { - this.Type = JsonSerializer.Deserialize("\"solidColor\""); + this.Type = new(); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Gradient.cs b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Gradient.cs index dd797e92..1c2b74b9 100644 --- a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Gradient.cs +++ b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Gradient.cs @@ -13,48 +13,60 @@ namespace Imagekit.Models.SolidColorOverlayTransformationProperties; /// image. See [gradient](https://imagekit.io/docs/effects-and-enhancements#gradient---e-gradient). /// [JsonConverter(typeof(GradientConverter))] -public abstract record class Gradient +public record class Gradient { - internal Gradient() { } + public object Value { get; private init; } - public static implicit operator Gradient(string value) => new GradientVariants::String(value); + public Gradient(UnionMember0 value) + { + Value = value; + } + + public Gradient(string value) + { + Value = value; + } + + Gradient(UnknownVariant value) + { + Value = value; + } + + public static Gradient CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } - public bool TryPickTrue([NotNullWhen(true)] out JsonElement? value) + public bool TryPickTrue([NotNullWhen(true)] out UnionMember0? value) { - value = (this as GradientVariants::True)?.Value; + value = this.Value as UnionMember0; return value != null; } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as GradientVariants::String)?.Value; + value = this.Value as string; return value != null; } - public void Switch( - Action true1, - Action @string - ) + public void Switch(Action true1, Action @string) { - switch (this) + switch (this.Value) { - case GradientVariants::True inner: - true1(inner); + case UnionMember0 value: + true1(value); break; - case GradientVariants::String inner: - @string(inner); + case string value: + @string(value); break; default: throw new InvalidOperationException(); } } - public T Match( - Func true1, - Func @string - ) + public T Match(Func true1, Func @string) { - return this switch + return this.Value switch { GradientVariants::True inner => true1(inner), GradientVariants::String inner => @string(inner), @@ -62,7 +74,15 @@ public T Match( }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException("Data did not match any variant of Gradient"); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class GradientConverter : JsonConverter @@ -77,11 +97,14 @@ JsonSerializerOptions options try { - return new GradientVariants::True( - JsonSerializer.Deserialize(ref reader, options) - ); + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + deserialized.Validate(); + return new Gradient(deserialized); + } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -91,10 +114,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new GradientVariants::String(deserialized); + return new Gradient(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/GradientProperties/UnionMember0.cs b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/GradientProperties/UnionMember0.cs new file mode 100644 index 00000000..e9765fd2 --- /dev/null +++ b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/GradientProperties/UnionMember0.cs @@ -0,0 +1,51 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; + +namespace Imagekit.Models.SolidColorOverlayTransformationProperties.GradientProperties; + +[JsonConverter(typeof(Converter))] +public class UnionMember0 +{ + public JsonElement Json { get; private init; } + + public UnionMember0() + { + Json = JsonSerializer.Deserialize("true"); + } + + UnionMember0(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new UnionMember0().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'UnionMember0'"); + } + } + + private class Converter : JsonConverter + { + public override UnionMember0? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write( + Utf8JsonWriter writer, + UnionMember0 value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Height.cs b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Height.cs index 04a99fe4..f9d5d539 100644 --- a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Height.cs +++ b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Height.cs @@ -12,50 +12,60 @@ namespace Imagekit.Models.SolidColorOverlayTransformationProperties; /// arithmetic expression. Learn about [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). /// [JsonConverter(typeof(HeightConverter))] -public abstract record class Height +public record class Height { - internal Height() { } + public object Value { get; private init; } - public static implicit operator Height(double value) => new HeightVariants::Double(value); + public Height(double value) + { + Value = value; + } - public static implicit operator Height(string value) => new HeightVariants::String(value); + public Height(string value) + { + Value = value; + } + + Height(UnknownVariant value) + { + Value = value; + } + + public static Height CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as HeightVariants::Double)?.Value; + value = this.Value as double?; return value != null; } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as HeightVariants::String)?.Value; + value = this.Value as string; return value != null; } - public void Switch( - Action @double, - Action @string - ) + public void Switch(Action @double, Action @string) { - switch (this) + switch (this.Value) { - case HeightVariants::Double inner: - @double(inner); + case double value: + @double(value); break; - case HeightVariants::String inner: - @string(inner); + case string value: + @string(value); break; default: throw new InvalidOperationException(); } } - public T Match( - Func @double, - Func @string - ) + public T Match(Func @double, Func @string) { - return this switch + return this.Value switch { HeightVariants::Double inner => @double(inner), HeightVariants::String inner => @string(inner), @@ -63,7 +73,15 @@ public T Match( }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException("Data did not match any variant of Height"); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class HeightConverter : JsonConverter @@ -78,11 +96,9 @@ JsonSerializerOptions options try { - return new HeightVariants::Double( - JsonSerializer.Deserialize(ref reader, options) - ); + return new Height(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -92,10 +108,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new HeightVariants::String(deserialized); + return new Height(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Radius.cs b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Radius.cs index 5246837d..b8f66bdf 100644 --- a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Radius.cs +++ b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Radius.cs @@ -12,42 +12,60 @@ namespace Imagekit.Models.SolidColorOverlayTransformationProperties; /// or oval shape. See [radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). /// [JsonConverter(typeof(RadiusConverter))] -public abstract record class Radius +public record class Radius { - internal Radius() { } + public object Value { get; private init; } - public static implicit operator Radius(double value) => new RadiusVariants::Double(value); + public Radius(double value) + { + Value = value; + } + + public Radius(UnionMember1 value) + { + Value = value; + } + + Radius(UnknownVariant value) + { + Value = value; + } + + public static Radius CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as RadiusVariants::Double)?.Value; + value = this.Value as double?; return value != null; } - public bool TryPickMax([NotNullWhen(true)] out JsonElement? value) + public bool TryPickMax([NotNullWhen(true)] out UnionMember1? value) { - value = (this as RadiusVariants::Max)?.Value; + value = this.Value as UnionMember1; return value != null; } - public void Switch(Action @double, Action max) + public void Switch(Action @double, Action max) { - switch (this) + switch (this.Value) { - case RadiusVariants::Double inner: - @double(inner); + case double value: + @double(value); break; - case RadiusVariants::Max inner: - max(inner); + case UnionMember1 value: + max(value); break; default: throw new InvalidOperationException(); } } - public T Match(Func @double, Func max) + public T Match(Func @double, Func max) { - return this switch + return this.Value switch { RadiusVariants::Double inner => @double(inner), RadiusVariants::Max inner => max(inner), @@ -55,7 +73,15 @@ public T Match(Func @double, Func @@ -70,22 +96,23 @@ JsonSerializerOptions options try { - return new RadiusVariants::Max( - JsonSerializer.Deserialize(ref reader, options) - ); + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + deserialized.Validate(); + return new Radius(deserialized); + } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } try { - return new RadiusVariants::Double( - JsonSerializer.Deserialize(ref reader, options) - ); + return new Radius(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/RadiusProperties/UnionMember1.cs b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/RadiusProperties/UnionMember1.cs new file mode 100644 index 00000000..78e3a76c --- /dev/null +++ b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/RadiusProperties/UnionMember1.cs @@ -0,0 +1,51 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; + +namespace Imagekit.Models.SolidColorOverlayTransformationProperties.RadiusProperties; + +[JsonConverter(typeof(Converter))] +public class UnionMember1 +{ + public JsonElement Json { get; private init; } + + public UnionMember1() + { + Json = JsonSerializer.Deserialize("\"max\""); + } + + UnionMember1(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new UnionMember1().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'UnionMember1'"); + } + } + + private class Converter : JsonConverter + { + public override UnionMember1? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write( + Utf8JsonWriter writer, + UnionMember1 value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Width.cs b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Width.cs index 60451a3c..b141eed1 100644 --- a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Width.cs +++ b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Width.cs @@ -12,47 +12,60 @@ namespace Imagekit.Models.SolidColorOverlayTransformationProperties; /// expression (e.g., `bw_mul_0.2` or `bh_div_2`). Learn about [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). /// [JsonConverter(typeof(WidthConverter))] -public abstract record class Width +public record class Width { - internal Width() { } + public object Value { get; private init; } - public static implicit operator Width(double value) => new WidthVariants::Double(value); + public Width(double value) + { + Value = value; + } + + public Width(string value) + { + Value = value; + } + + Width(UnknownVariant value) + { + Value = value; + } - public static implicit operator Width(string value) => new WidthVariants::String(value); + public static Width CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as WidthVariants::Double)?.Value; + value = this.Value as double?; return value != null; } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as WidthVariants::String)?.Value; + value = this.Value as string; return value != null; } - public void Switch(Action @double, Action @string) + public void Switch(Action @double, Action @string) { - switch (this) + switch (this.Value) { - case WidthVariants::Double inner: - @double(inner); + case double value: + @double(value); break; - case WidthVariants::String inner: - @string(inner); + case string value: + @string(value); break; default: throw new InvalidOperationException(); } } - public T Match( - Func @double, - Func @string - ) + public T Match(Func @double, Func @string) { - return this switch + return this.Value switch { WidthVariants::Double inner => @double(inner), WidthVariants::String inner => @string(inner), @@ -60,7 +73,15 @@ public T Match( }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException("Data did not match any variant of Width"); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class WidthConverter : JsonConverter @@ -75,11 +96,9 @@ JsonSerializerOptions options try { - return new WidthVariants::Double( - JsonSerializer.Deserialize(ref reader, options) - ); + return new Width(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -89,10 +108,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new WidthVariants::String(deserialized); + return new Width(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/SubtitleOverlay.cs b/src/Imagekit/Models/SubtitleOverlay.cs index 4baab6cb..3c581342 100644 --- a/src/Imagekit/Models/SubtitleOverlay.cs +++ b/src/Imagekit/Models/SubtitleOverlay.cs @@ -157,7 +157,7 @@ public override void Validate() public SubtitleOverlay() { - this.Type = JsonSerializer.Deserialize("\"subtitle\""); + this.Type = new(); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/SubtitleOverlayProperties/IntersectionMember1.cs b/src/Imagekit/Models/SubtitleOverlayProperties/IntersectionMember1.cs index 2baa35cc..7bfb5133 100644 --- a/src/Imagekit/Models/SubtitleOverlayProperties/IntersectionMember1.cs +++ b/src/Imagekit/Models/SubtitleOverlayProperties/IntersectionMember1.cs @@ -113,7 +113,7 @@ public override void Validate() public IntersectionMember1() { - this.Type = JsonSerializer.Deserialize("\"subtitle\""); + this.Type = new(); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/TextOverlay.cs b/src/Imagekit/Models/TextOverlay.cs index 9d77aafc..4e9a980c 100644 --- a/src/Imagekit/Models/TextOverlay.cs +++ b/src/Imagekit/Models/TextOverlay.cs @@ -158,7 +158,7 @@ public override void Validate() public TextOverlay() { - this.Type = JsonSerializer.Deserialize("\"text\""); + this.Type = new(); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/TextOverlayProperties/IntersectionMember1.cs b/src/Imagekit/Models/TextOverlayProperties/IntersectionMember1.cs index ebe9d333..5d9b0091 100644 --- a/src/Imagekit/Models/TextOverlayProperties/IntersectionMember1.cs +++ b/src/Imagekit/Models/TextOverlayProperties/IntersectionMember1.cs @@ -114,7 +114,7 @@ public override void Validate() public IntersectionMember1() { - this.Type = JsonSerializer.Deserialize("\"text\""); + this.Type = new(); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/TextOverlayTransformationProperties/FontSize.cs b/src/Imagekit/Models/TextOverlayTransformationProperties/FontSize.cs index ee66bbe7..f915b7f2 100644 --- a/src/Imagekit/Models/TextOverlayTransformationProperties/FontSize.cs +++ b/src/Imagekit/Models/TextOverlayTransformationProperties/FontSize.cs @@ -11,50 +11,60 @@ namespace Imagekit.Models.TextOverlayTransformationProperties; /// Specifies the font size of the overlaid text. Accepts a numeric value or an arithmetic expression. /// [JsonConverter(typeof(FontSizeConverter))] -public abstract record class FontSize +public record class FontSize { - internal FontSize() { } + public object Value { get; private init; } - public static implicit operator FontSize(double value) => new FontSizeVariants::Double(value); + public FontSize(double value) + { + Value = value; + } - public static implicit operator FontSize(string value) => new FontSizeVariants::String(value); + public FontSize(string value) + { + Value = value; + } + + FontSize(UnknownVariant value) + { + Value = value; + } + + public static FontSize CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as FontSizeVariants::Double)?.Value; + value = this.Value as double?; return value != null; } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as FontSizeVariants::String)?.Value; + value = this.Value as string; return value != null; } - public void Switch( - Action @double, - Action @string - ) + public void Switch(Action @double, Action @string) { - switch (this) + switch (this.Value) { - case FontSizeVariants::Double inner: - @double(inner); + case double value: + @double(value); break; - case FontSizeVariants::String inner: - @string(inner); + case string value: + @string(value); break; default: throw new InvalidOperationException(); } } - public T Match( - Func @double, - Func @string - ) + public T Match(Func @double, Func @string) { - return this switch + return this.Value switch { FontSizeVariants::Double inner => @double(inner), FontSizeVariants::String inner => @string(inner), @@ -62,7 +72,15 @@ public T Match( }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException("Data did not match any variant of FontSize"); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class FontSizeConverter : JsonConverter @@ -77,11 +95,9 @@ JsonSerializerOptions options try { - return new FontSizeVariants::Double( - JsonSerializer.Deserialize(ref reader, options) - ); + return new FontSize(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -91,10 +107,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new FontSizeVariants::String(deserialized); + return new FontSize(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/TextOverlayTransformationProperties/LineHeight.cs b/src/Imagekit/Models/TextOverlayTransformationProperties/LineHeight.cs index 54ccddef..0cc2555a 100644 --- a/src/Imagekit/Models/TextOverlayTransformationProperties/LineHeight.cs +++ b/src/Imagekit/Models/TextOverlayTransformationProperties/LineHeight.cs @@ -13,52 +13,60 @@ namespace Imagekit.Models.TextOverlayTransformationProperties; /// such as `bw_mul_0.2`, or `bh_div_20`. /// [JsonConverter(typeof(LineHeightConverter))] -public abstract record class LineHeight +public record class LineHeight { - internal LineHeight() { } + public object Value { get; private init; } - public static implicit operator LineHeight(double value) => - new LineHeightVariants::Double(value); + public LineHeight(double value) + { + Value = value; + } - public static implicit operator LineHeight(string value) => - new LineHeightVariants::String(value); + public LineHeight(string value) + { + Value = value; + } + + LineHeight(UnknownVariant value) + { + Value = value; + } + + public static LineHeight CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as LineHeightVariants::Double)?.Value; + value = this.Value as double?; return value != null; } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as LineHeightVariants::String)?.Value; + value = this.Value as string; return value != null; } - public void Switch( - Action @double, - Action @string - ) + public void Switch(Action @double, Action @string) { - switch (this) + switch (this.Value) { - case LineHeightVariants::Double inner: - @double(inner); + case double value: + @double(value); break; - case LineHeightVariants::String inner: - @string(inner); + case string value: + @string(value); break; default: throw new InvalidOperationException(); } } - public T Match( - Func @double, - Func @string - ) + public T Match(Func @double, Func @string) { - return this switch + return this.Value switch { LineHeightVariants::Double inner => @double(inner), LineHeightVariants::String inner => @string(inner), @@ -66,7 +74,15 @@ public T Match( }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException("Data did not match any variant of LineHeight"); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class LineHeightConverter : JsonConverter @@ -81,11 +97,9 @@ JsonSerializerOptions options try { - return new LineHeightVariants::Double( - JsonSerializer.Deserialize(ref reader, options) - ); + return new LineHeight(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -95,10 +109,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new LineHeightVariants::String(deserialized); + return new LineHeight(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/TextOverlayTransformationProperties/Padding.cs b/src/Imagekit/Models/TextOverlayTransformationProperties/Padding.cs index ae940034..ef906df1 100644 --- a/src/Imagekit/Models/TextOverlayTransformationProperties/Padding.cs +++ b/src/Imagekit/Models/TextOverlayTransformationProperties/Padding.cs @@ -13,50 +13,60 @@ namespace Imagekit.Models.TextOverlayTransformationProperties; /// Arithmetic expressions are also accepted. /// [JsonConverter(typeof(PaddingConverter))] -public abstract record class Padding +public record class Padding { - internal Padding() { } + public object Value { get; private init; } - public static implicit operator Padding(double value) => new PaddingVariants::Double(value); + public Padding(double value) + { + Value = value; + } - public static implicit operator Padding(string value) => new PaddingVariants::String(value); + public Padding(string value) + { + Value = value; + } + + Padding(UnknownVariant value) + { + Value = value; + } + + public static Padding CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as PaddingVariants::Double)?.Value; + value = this.Value as double?; return value != null; } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as PaddingVariants::String)?.Value; + value = this.Value as string; return value != null; } - public void Switch( - Action @double, - Action @string - ) + public void Switch(Action @double, Action @string) { - switch (this) + switch (this.Value) { - case PaddingVariants::Double inner: - @double(inner); + case double value: + @double(value); break; - case PaddingVariants::String inner: - @string(inner); + case string value: + @string(value); break; default: throw new InvalidOperationException(); } } - public T Match( - Func @double, - Func @string - ) + public T Match(Func @double, Func @string) { - return this switch + return this.Value switch { PaddingVariants::Double inner => @double(inner), PaddingVariants::String inner => @string(inner), @@ -64,7 +74,15 @@ public T Match( }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException("Data did not match any variant of Padding"); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class PaddingConverter : JsonConverter @@ -79,11 +97,9 @@ JsonSerializerOptions options try { - return new PaddingVariants::Double( - JsonSerializer.Deserialize(ref reader, options) - ); + return new Padding(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -93,10 +109,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new PaddingVariants::String(deserialized); + return new Padding(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/TextOverlayTransformationProperties/Radius.cs b/src/Imagekit/Models/TextOverlayTransformationProperties/Radius.cs index 62fd9c1c..4674dc45 100644 --- a/src/Imagekit/Models/TextOverlayTransformationProperties/Radius.cs +++ b/src/Imagekit/Models/TextOverlayTransformationProperties/Radius.cs @@ -12,42 +12,60 @@ namespace Imagekit.Models.TextOverlayTransformationProperties; /// or oval shape. /// [JsonConverter(typeof(RadiusConverter))] -public abstract record class Radius +public record class Radius { - internal Radius() { } + public object Value { get; private init; } - public static implicit operator Radius(double value) => new RadiusVariants::Double(value); + public Radius(double value) + { + Value = value; + } + + public Radius(UnionMember1 value) + { + Value = value; + } + + Radius(UnknownVariant value) + { + Value = value; + } + + public static Radius CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as RadiusVariants::Double)?.Value; + value = this.Value as double?; return value != null; } - public bool TryPickMax([NotNullWhen(true)] out JsonElement? value) + public bool TryPickMax([NotNullWhen(true)] out UnionMember1? value) { - value = (this as RadiusVariants::Max)?.Value; + value = this.Value as UnionMember1; return value != null; } - public void Switch(Action @double, Action max) + public void Switch(Action @double, Action max) { - switch (this) + switch (this.Value) { - case RadiusVariants::Double inner: - @double(inner); + case double value: + @double(value); break; - case RadiusVariants::Max inner: - max(inner); + case UnionMember1 value: + max(value); break; default: throw new InvalidOperationException(); } } - public T Match(Func @double, Func max) + public T Match(Func @double, Func max) { - return this switch + return this.Value switch { RadiusVariants::Double inner => @double(inner), RadiusVariants::Max inner => max(inner), @@ -55,7 +73,15 @@ public T Match(Func @double, Func @@ -70,22 +96,23 @@ JsonSerializerOptions options try { - return new RadiusVariants::Max( - JsonSerializer.Deserialize(ref reader, options) - ); + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + deserialized.Validate(); + return new Radius(deserialized); + } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } try { - return new RadiusVariants::Double( - JsonSerializer.Deserialize(ref reader, options) - ); + return new Radius(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/TextOverlayTransformationProperties/RadiusProperties/UnionMember1.cs b/src/Imagekit/Models/TextOverlayTransformationProperties/RadiusProperties/UnionMember1.cs new file mode 100644 index 00000000..359ce14f --- /dev/null +++ b/src/Imagekit/Models/TextOverlayTransformationProperties/RadiusProperties/UnionMember1.cs @@ -0,0 +1,51 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; + +namespace Imagekit.Models.TextOverlayTransformationProperties.RadiusProperties; + +[JsonConverter(typeof(Converter))] +public class UnionMember1 +{ + public JsonElement Json { get; private init; } + + public UnionMember1() + { + Json = JsonSerializer.Deserialize("\"max\""); + } + + UnionMember1(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new UnionMember1().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'UnionMember1'"); + } + } + + private class Converter : JsonConverter + { + public override UnionMember1? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write( + Utf8JsonWriter writer, + UnionMember1 value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/TextOverlayTransformationProperties/Rotation.cs b/src/Imagekit/Models/TextOverlayTransformationProperties/Rotation.cs index 3ede02d8..07b5277c 100644 --- a/src/Imagekit/Models/TextOverlayTransformationProperties/Rotation.cs +++ b/src/Imagekit/Models/TextOverlayTransformationProperties/Rotation.cs @@ -12,50 +12,60 @@ namespace Imagekit.Models.TextOverlayTransformationProperties; /// clockwise rotation or a string prefixed with "N" for counter-clockwise rotation. /// [JsonConverter(typeof(RotationConverter))] -public abstract record class Rotation +public record class Rotation { - internal Rotation() { } + public object Value { get; private init; } - public static implicit operator Rotation(double value) => new RotationVariants::Double(value); + public Rotation(double value) + { + Value = value; + } - public static implicit operator Rotation(string value) => new RotationVariants::String(value); + public Rotation(string value) + { + Value = value; + } + + Rotation(UnknownVariant value) + { + Value = value; + } + + public static Rotation CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as RotationVariants::Double)?.Value; + value = this.Value as double?; return value != null; } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as RotationVariants::String)?.Value; + value = this.Value as string; return value != null; } - public void Switch( - Action @double, - Action @string - ) + public void Switch(Action @double, Action @string) { - switch (this) + switch (this.Value) { - case RotationVariants::Double inner: - @double(inner); + case double value: + @double(value); break; - case RotationVariants::String inner: - @string(inner); + case string value: + @string(value); break; default: throw new InvalidOperationException(); } } - public T Match( - Func @double, - Func @string - ) + public T Match(Func @double, Func @string) { - return this switch + return this.Value switch { RotationVariants::Double inner => @double(inner), RotationVariants::String inner => @string(inner), @@ -63,7 +73,15 @@ public T Match( }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException("Data did not match any variant of Rotation"); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class RotationConverter : JsonConverter @@ -78,11 +96,9 @@ JsonSerializerOptions options try { - return new RotationVariants::Double( - JsonSerializer.Deserialize(ref reader, options) - ); + return new Rotation(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -92,10 +108,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new RotationVariants::String(deserialized); + return new Rotation(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/TextOverlayTransformationProperties/Width.cs b/src/Imagekit/Models/TextOverlayTransformationProperties/Width.cs index 14cec43e..9c1bd370 100644 --- a/src/Imagekit/Models/TextOverlayTransformationProperties/Width.cs +++ b/src/Imagekit/Models/TextOverlayTransformationProperties/Width.cs @@ -14,47 +14,60 @@ namespace Imagekit.Models.TextOverlayTransformationProperties; /// [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). /// [JsonConverter(typeof(WidthConverter))] -public abstract record class Width +public record class Width { - internal Width() { } + public object Value { get; private init; } - public static implicit operator Width(double value) => new WidthVariants::Double(value); + public Width(double value) + { + Value = value; + } + + public Width(string value) + { + Value = value; + } + + Width(UnknownVariant value) + { + Value = value; + } - public static implicit operator Width(string value) => new WidthVariants::String(value); + public static Width CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as WidthVariants::Double)?.Value; + value = this.Value as double?; return value != null; } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as WidthVariants::String)?.Value; + value = this.Value as string; return value != null; } - public void Switch(Action @double, Action @string) + public void Switch(Action @double, Action @string) { - switch (this) + switch (this.Value) { - case WidthVariants::Double inner: - @double(inner); + case double value: + @double(value); break; - case WidthVariants::String inner: - @string(inner); + case string value: + @string(value); break; default: throw new InvalidOperationException(); } } - public T Match( - Func @double, - Func @string - ) + public T Match(Func @double, Func @string) { - return this switch + return this.Value switch { WidthVariants::Double inner => @double(inner), WidthVariants::String inner => @string(inner), @@ -62,7 +75,15 @@ public T Match( }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException("Data did not match any variant of Width"); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class WidthConverter : JsonConverter @@ -77,11 +98,9 @@ JsonSerializerOptions options try { - return new WidthVariants::Double( - JsonSerializer.Deserialize(ref reader, options) - ); + return new Width(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -91,10 +110,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new WidthVariants::String(deserialized); + return new Width(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/TransformationProperties/AIDropShadow.cs b/src/Imagekit/Models/TransformationProperties/AIDropShadow.cs index c6a045e1..e7b8845f 100644 --- a/src/Imagekit/Models/TransformationProperties/AIDropShadow.cs +++ b/src/Imagekit/Models/TransformationProperties/AIDropShadow.cs @@ -15,49 +15,60 @@ namespace Imagekit.Models.TransformationProperties; /// inside overlay. See [AI Drop Shadow](https://imagekit.io/docs/ai-transformations#ai-drop-shadow-e-dropshadow). /// [JsonConverter(typeof(AIDropShadowConverter))] -public abstract record class AIDropShadow +public record class AIDropShadow { - internal AIDropShadow() { } + public object Value { get; private init; } - public static implicit operator AIDropShadow(string value) => - new AIDropShadowVariants::String(value); + public AIDropShadow(UnionMember0 value) + { + Value = value; + } + + public AIDropShadow(string value) + { + Value = value; + } + + AIDropShadow(UnknownVariant value) + { + Value = value; + } + + public static AIDropShadow CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } - public bool TryPickTrue([NotNullWhen(true)] out JsonElement? value) + public bool TryPickTrue([NotNullWhen(true)] out UnionMember0? value) { - value = (this as AIDropShadowVariants::True)?.Value; + value = this.Value as UnionMember0; return value != null; } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as AIDropShadowVariants::String)?.Value; + value = this.Value as string; return value != null; } - public void Switch( - Action true1, - Action @string - ) + public void Switch(Action true1, Action @string) { - switch (this) + switch (this.Value) { - case AIDropShadowVariants::True inner: - true1(inner); + case UnionMember0 value: + true1(value); break; - case AIDropShadowVariants::String inner: - @string(inner); + case string value: + @string(value); break; default: throw new InvalidOperationException(); } } - public T Match( - Func true1, - Func @string - ) + public T Match(Func true1, Func @string) { - return this switch + return this.Value switch { AIDropShadowVariants::True inner => true1(inner), AIDropShadowVariants::String inner => @string(inner), @@ -65,7 +76,17 @@ public T Match( }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of AIDropShadow" + ); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class AIDropShadowConverter : JsonConverter @@ -80,11 +101,14 @@ JsonSerializerOptions options try { - return new AIDropShadowVariants::True( - JsonSerializer.Deserialize(ref reader, options) - ); + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + deserialized.Validate(); + return new AIDropShadow(deserialized); + } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -94,10 +118,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new AIDropShadowVariants::String(deserialized); + return new AIDropShadow(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/TransformationProperties/AIDropShadowProperties/UnionMember0.cs b/src/Imagekit/Models/TransformationProperties/AIDropShadowProperties/UnionMember0.cs new file mode 100644 index 00000000..23c297a8 --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/AIDropShadowProperties/UnionMember0.cs @@ -0,0 +1,51 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; + +namespace Imagekit.Models.TransformationProperties.AIDropShadowProperties; + +[JsonConverter(typeof(Converter))] +public class UnionMember0 +{ + public JsonElement Json { get; private init; } + + public UnionMember0() + { + Json = JsonSerializer.Deserialize("true"); + } + + UnionMember0(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new UnionMember0().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'UnionMember0'"); + } + } + + private class Converter : JsonConverter + { + public override UnionMember0? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write( + Utf8JsonWriter writer, + UnionMember0 value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/TransformationProperties/AspectRatio.cs b/src/Imagekit/Models/TransformationProperties/AspectRatio.cs index 9f570541..ce816e0d 100644 --- a/src/Imagekit/Models/TransformationProperties/AspectRatio.cs +++ b/src/Imagekit/Models/TransformationProperties/AspectRatio.cs @@ -13,52 +13,60 @@ namespace Imagekit.Models.TransformationProperties; /// or an expression like `iar_div_2`. See [Image resize and crop – Aspect ratio](https://imagekit.io/docs/image-resize-and-crop#aspect-ratio---ar). /// [JsonConverter(typeof(AspectRatioConverter))] -public abstract record class AspectRatio +public record class AspectRatio { - internal AspectRatio() { } + public object Value { get; private init; } - public static implicit operator AspectRatio(double value) => - new AspectRatioVariants::Double(value); + public AspectRatio(double value) + { + Value = value; + } - public static implicit operator AspectRatio(string value) => - new AspectRatioVariants::String(value); + public AspectRatio(string value) + { + Value = value; + } + + AspectRatio(UnknownVariant value) + { + Value = value; + } + + public static AspectRatio CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as AspectRatioVariants::Double)?.Value; + value = this.Value as double?; return value != null; } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as AspectRatioVariants::String)?.Value; + value = this.Value as string; return value != null; } - public void Switch( - Action @double, - Action @string - ) + public void Switch(Action @double, Action @string) { - switch (this) + switch (this.Value) { - case AspectRatioVariants::Double inner: - @double(inner); + case double value: + @double(value); break; - case AspectRatioVariants::String inner: - @string(inner); + case string value: + @string(value); break; default: throw new InvalidOperationException(); } } - public T Match( - Func @double, - Func @string - ) + public T Match(Func @double, Func @string) { - return this switch + return this.Value switch { AspectRatioVariants::Double inner => @double(inner), AspectRatioVariants::String inner => @string(inner), @@ -66,7 +74,15 @@ public T Match( }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException("Data did not match any variant of AspectRatio"); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class AspectRatioConverter : JsonConverter @@ -81,11 +97,9 @@ JsonSerializerOptions options try { - return new AspectRatioVariants::Double( - JsonSerializer.Deserialize(ref reader, options) - ); + return new AspectRatio(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -95,10 +109,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new AspectRatioVariants::String(deserialized); + return new AspectRatio(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/TransformationProperties/Duration.cs b/src/Imagekit/Models/TransformationProperties/Duration.cs index 5ec66c6e..25b73cf6 100644 --- a/src/Imagekit/Models/TransformationProperties/Duration.cs +++ b/src/Imagekit/Models/TransformationProperties/Duration.cs @@ -13,50 +13,60 @@ namespace Imagekit.Models.TransformationProperties; /// Arithmetic expressions are supported. See [Trim videos – Duration](https://imagekit.io/docs/trim-videos#duration---du). /// [JsonConverter(typeof(DurationConverter))] -public abstract record class Duration +public record class Duration { - internal Duration() { } + public object Value { get; private init; } - public static implicit operator Duration(double value) => new DurationVariants::Double(value); + public Duration(double value) + { + Value = value; + } - public static implicit operator Duration(string value) => new DurationVariants::String(value); + public Duration(string value) + { + Value = value; + } + + Duration(UnknownVariant value) + { + Value = value; + } + + public static Duration CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as DurationVariants::Double)?.Value; + value = this.Value as double?; return value != null; } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as DurationVariants::String)?.Value; + value = this.Value as string; return value != null; } - public void Switch( - Action @double, - Action @string - ) + public void Switch(Action @double, Action @string) { - switch (this) + switch (this.Value) { - case DurationVariants::Double inner: - @double(inner); + case double value: + @double(value); break; - case DurationVariants::String inner: - @string(inner); + case string value: + @string(value); break; default: throw new InvalidOperationException(); } } - public T Match( - Func @double, - Func @string - ) + public T Match(Func @double, Func @string) { - return this switch + return this.Value switch { DurationVariants::Double inner => @double(inner), DurationVariants::String inner => @string(inner), @@ -64,7 +74,15 @@ public T Match( }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException("Data did not match any variant of Duration"); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class DurationConverter : JsonConverter @@ -79,11 +97,9 @@ JsonSerializerOptions options try { - return new DurationVariants::Double( - JsonSerializer.Deserialize(ref reader, options) - ); + return new Duration(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -93,10 +109,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new DurationVariants::String(deserialized); + return new Duration(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/TransformationProperties/EndOffset.cs b/src/Imagekit/Models/TransformationProperties/EndOffset.cs index cd04d92f..89f0960b 100644 --- a/src/Imagekit/Models/TransformationProperties/EndOffset.cs +++ b/src/Imagekit/Models/TransformationProperties/EndOffset.cs @@ -13,50 +13,60 @@ namespace Imagekit.Models.TransformationProperties; /// are supported. See [Trim videos – End offset](https://imagekit.io/docs/trim-videos#end-offset---eo). /// [JsonConverter(typeof(EndOffsetConverter))] -public abstract record class EndOffset +public record class EndOffset { - internal EndOffset() { } + public object Value { get; private init; } - public static implicit operator EndOffset(double value) => new EndOffsetVariants::Double(value); + public EndOffset(double value) + { + Value = value; + } - public static implicit operator EndOffset(string value) => new EndOffsetVariants::String(value); + public EndOffset(string value) + { + Value = value; + } + + EndOffset(UnknownVariant value) + { + Value = value; + } + + public static EndOffset CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as EndOffsetVariants::Double)?.Value; + value = this.Value as double?; return value != null; } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as EndOffsetVariants::String)?.Value; + value = this.Value as string; return value != null; } - public void Switch( - Action @double, - Action @string - ) + public void Switch(Action @double, Action @string) { - switch (this) + switch (this.Value) { - case EndOffsetVariants::Double inner: - @double(inner); + case double value: + @double(value); break; - case EndOffsetVariants::String inner: - @string(inner); + case string value: + @string(value); break; default: throw new InvalidOperationException(); } } - public T Match( - Func @double, - Func @string - ) + public T Match(Func @double, Func @string) { - return this switch + return this.Value switch { EndOffsetVariants::Double inner => @double(inner), EndOffsetVariants::String inner => @string(inner), @@ -64,7 +74,15 @@ public T Match( }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException("Data did not match any variant of EndOffset"); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class EndOffsetConverter : JsonConverter @@ -79,11 +97,9 @@ JsonSerializerOptions options try { - return new EndOffsetVariants::Double( - JsonSerializer.Deserialize(ref reader, options) - ); + return new EndOffset(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -93,10 +109,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new EndOffsetVariants::String(deserialized); + return new EndOffset(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/TransformationProperties/Gradient.cs b/src/Imagekit/Models/TransformationProperties/Gradient.cs index 38e71ce9..fb75235e 100644 --- a/src/Imagekit/Models/TransformationProperties/Gradient.cs +++ b/src/Imagekit/Models/TransformationProperties/Gradient.cs @@ -12,48 +12,60 @@ namespace Imagekit.Models.TransformationProperties; /// or provide a string for a custom gradient. See [Gradient](https://imagekit.io/docs/effects-and-enhancements#gradient---e-gradient). /// [JsonConverter(typeof(GradientConverter))] -public abstract record class Gradient +public record class Gradient { - internal Gradient() { } + public object Value { get; private init; } - public static implicit operator Gradient(string value) => new GradientVariants::String(value); + public Gradient(UnionMember0 value) + { + Value = value; + } + + public Gradient(string value) + { + Value = value; + } + + Gradient(UnknownVariant value) + { + Value = value; + } + + public static Gradient CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } - public bool TryPickTrue([NotNullWhen(true)] out JsonElement? value) + public bool TryPickTrue([NotNullWhen(true)] out UnionMember0? value) { - value = (this as GradientVariants::True)?.Value; + value = this.Value as UnionMember0; return value != null; } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as GradientVariants::String)?.Value; + value = this.Value as string; return value != null; } - public void Switch( - Action true1, - Action @string - ) + public void Switch(Action true1, Action @string) { - switch (this) + switch (this.Value) { - case GradientVariants::True inner: - true1(inner); + case UnionMember0 value: + true1(value); break; - case GradientVariants::String inner: - @string(inner); + case string value: + @string(value); break; default: throw new InvalidOperationException(); } } - public T Match( - Func true1, - Func @string - ) + public T Match(Func true1, Func @string) { - return this switch + return this.Value switch { GradientVariants::True inner => true1(inner), GradientVariants::String inner => @string(inner), @@ -61,7 +73,15 @@ public T Match( }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException("Data did not match any variant of Gradient"); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class GradientConverter : JsonConverter @@ -76,11 +96,14 @@ JsonSerializerOptions options try { - return new GradientVariants::True( - JsonSerializer.Deserialize(ref reader, options) - ); + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + deserialized.Validate(); + return new Gradient(deserialized); + } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -90,10 +113,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new GradientVariants::String(deserialized); + return new Gradient(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/TransformationProperties/GradientProperties/UnionMember0.cs b/src/Imagekit/Models/TransformationProperties/GradientProperties/UnionMember0.cs new file mode 100644 index 00000000..3488422b --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/GradientProperties/UnionMember0.cs @@ -0,0 +1,51 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; + +namespace Imagekit.Models.TransformationProperties.GradientProperties; + +[JsonConverter(typeof(Converter))] +public class UnionMember0 +{ + public JsonElement Json { get; private init; } + + public UnionMember0() + { + Json = JsonSerializer.Deserialize("true"); + } + + UnionMember0(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new UnionMember0().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'UnionMember0'"); + } + } + + private class Converter : JsonConverter + { + public override UnionMember0? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write( + Utf8JsonWriter writer, + UnionMember0 value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/TransformationProperties/Height.cs b/src/Imagekit/Models/TransformationProperties/Height.cs index ae6210e0..bf94bf79 100644 --- a/src/Imagekit/Models/TransformationProperties/Height.cs +++ b/src/Imagekit/Models/TransformationProperties/Height.cs @@ -14,50 +14,60 @@ namespace Imagekit.Models.TransformationProperties; /// – [Images](https://imagekit.io/docs/image-resize-and-crop#height---h) · [Videos](https://imagekit.io/docs/video-resize-and-crop#height---h) /// [JsonConverter(typeof(HeightConverter))] -public abstract record class Height +public record class Height { - internal Height() { } + public object Value { get; private init; } - public static implicit operator Height(double value) => new HeightVariants::Double(value); + public Height(double value) + { + Value = value; + } - public static implicit operator Height(string value) => new HeightVariants::String(value); + public Height(string value) + { + Value = value; + } + + Height(UnknownVariant value) + { + Value = value; + } + + public static Height CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as HeightVariants::Double)?.Value; + value = this.Value as double?; return value != null; } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as HeightVariants::String)?.Value; + value = this.Value as string; return value != null; } - public void Switch( - Action @double, - Action @string - ) + public void Switch(Action @double, Action @string) { - switch (this) + switch (this.Value) { - case HeightVariants::Double inner: - @double(inner); + case double value: + @double(value); break; - case HeightVariants::String inner: - @string(inner); + case string value: + @string(value); break; default: throw new InvalidOperationException(); } } - public T Match( - Func @double, - Func @string - ) + public T Match(Func @double, Func @string) { - return this switch + return this.Value switch { HeightVariants::Double inner => @double(inner), HeightVariants::String inner => @string(inner), @@ -65,7 +75,15 @@ public T Match( }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException("Data did not match any variant of Height"); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class HeightConverter : JsonConverter @@ -80,11 +98,9 @@ JsonSerializerOptions options try { - return new HeightVariants::Double( - JsonSerializer.Deserialize(ref reader, options) - ); + return new Height(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -94,10 +110,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new HeightVariants::String(deserialized); + return new Height(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/TransformationProperties/Page.cs b/src/Imagekit/Models/TransformationProperties/Page.cs index f223e8cf..75b8855a 100644 --- a/src/Imagekit/Models/TransformationProperties/Page.cs +++ b/src/Imagekit/Models/TransformationProperties/Page.cs @@ -118,7 +118,6 @@ public override void Write(Utf8JsonWriter writer, Page value, JsonSerializerOpti using System.Text.Json; using System.Text.Json.Serialization; using Imagekit.Exceptions; -using PageVariants = Imagekit.Models.TransformationProperties.PageVariants; namespace Imagekit.Models.TransformationProperties; @@ -129,52 +128,76 @@ namespace Imagekit.Models.TransformationProperties; /// extraction](https://imagekit.io/docs/vector-and-animated-images#get-thumbnail-from-psd-pdf-ai-eps-and-animated-files). /// [JsonConverter(typeof(PageConverter))] -public abstract record class Page +public record class Page { - internal Page() { } + public object Value { get; private init; } - public static implicit operator Page(double value) => new PageVariants::Double(value); + public Page(double value) + { + Value = value; + } + + public Page(string value) + { + Value = value; + } - public static implicit operator Page(string value) => new PageVariants::String(value); + Page(UnknownVariant value) + { + Value = value; + } + + public static Page CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as PageVariants::Double)?.Value; + value = this.Value as double?; return value != null; } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as PageVariants::String)?.Value; + value = this.Value as string; return value != null; } - public void Switch(Action @double, Action @string) + public void Switch(Action @double, Action @string) { - switch (this) + switch (this.Value) { - case PageVariants::Double inner: - @double(inner); + case double value: + @double(value); break; - case PageVariants::String inner: - @string(inner); + case string value: + @string(value); break; default: throw new ImageKitInvalidDataException("Data did not match any variant of Page"); } } - public T Match(Func @double, Func @string) + public T Match(Func @double, Func @string) { - return this switch + return this.Value switch { - PageVariants::Double inner => @double(inner), - PageVariants::String inner => @string(inner), + double value => @double(value), + string value => @string(value), _ => throw new ImageKitInvalidDataException("Data did not match any variant of Page"), }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException("Data did not match any variant of Page"); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class PageConverter : JsonConverter @@ -189,17 +212,12 @@ JsonSerializerOptions options try { - return new PageVariants::Double( - JsonSerializer.Deserialize(ref reader, options) - ); + return new Page(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException( - "Data does not match union variant PageVariants::Double", - e - ) + new ImageKitInvalidDataException("Data does not match union variant 'double'", e) ); } @@ -208,16 +226,13 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new PageVariants::String(deserialized); + return new Page(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException( - "Data does not match union variant PageVariants::String", - e - ) + new ImageKitInvalidDataException("Data does not match union variant 'string'", e) ); } @@ -226,12 +241,7 @@ JsonSerializerOptions options public override void Write(Utf8JsonWriter writer, Page value, JsonSerializerOptions options) { - object variant = value switch - { - PageVariants::Double(var @double) => @double, - PageVariants::String(var @string) => @string, - _ => throw new ImageKitInvalidDataException("Data did not match any variant of Page"), - }; + object variant = value.Value; JsonSerializer.Serialize(writer, variant, options); } } diff --git a/src/Imagekit/Models/TransformationProperties/Radius.cs b/src/Imagekit/Models/TransformationProperties/Radius.cs index 1fc6f1d9..65f3d4f7 100644 --- a/src/Imagekit/Models/TransformationProperties/Radius.cs +++ b/src/Imagekit/Models/TransformationProperties/Radius.cs @@ -12,42 +12,60 @@ namespace Imagekit.Models.TransformationProperties; /// or oval shape. See [Radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). /// [JsonConverter(typeof(RadiusConverter))] -public abstract record class Radius +public record class Radius { - internal Radius() { } + public object Value { get; private init; } - public static implicit operator Radius(double value) => new RadiusVariants::Double(value); + public Radius(double value) + { + Value = value; + } + + public Radius(UnionMember1 value) + { + Value = value; + } + + Radius(UnknownVariant value) + { + Value = value; + } + + public static Radius CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as RadiusVariants::Double)?.Value; + value = this.Value as double?; return value != null; } - public bool TryPickMax([NotNullWhen(true)] out JsonElement? value) + public bool TryPickMax([NotNullWhen(true)] out UnionMember1? value) { - value = (this as RadiusVariants::Max)?.Value; + value = this.Value as UnionMember1; return value != null; } - public void Switch(Action @double, Action max) + public void Switch(Action @double, Action max) { - switch (this) + switch (this.Value) { - case RadiusVariants::Double inner: - @double(inner); + case double value: + @double(value); break; - case RadiusVariants::Max inner: - max(inner); + case UnionMember1 value: + max(value); break; default: throw new InvalidOperationException(); } } - public T Match(Func @double, Func max) + public T Match(Func @double, Func max) { - return this switch + return this.Value switch { RadiusVariants::Double inner => @double(inner), RadiusVariants::Max inner => max(inner), @@ -55,7 +73,15 @@ public T Match(Func @double, Func @@ -70,22 +96,23 @@ JsonSerializerOptions options try { - return new RadiusVariants::Max( - JsonSerializer.Deserialize(ref reader, options) - ); + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + deserialized.Validate(); + return new Radius(deserialized); + } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } try { - return new RadiusVariants::Double( - JsonSerializer.Deserialize(ref reader, options) - ); + return new Radius(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/TransformationProperties/RadiusProperties/UnionMember1.cs b/src/Imagekit/Models/TransformationProperties/RadiusProperties/UnionMember1.cs new file mode 100644 index 00000000..9124e6b6 --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/RadiusProperties/UnionMember1.cs @@ -0,0 +1,51 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; + +namespace Imagekit.Models.TransformationProperties.RadiusProperties; + +[JsonConverter(typeof(Converter))] +public class UnionMember1 +{ + public JsonElement Json { get; private init; } + + public UnionMember1() + { + Json = JsonSerializer.Deserialize("\"max\""); + } + + UnionMember1(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new UnionMember1().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'UnionMember1'"); + } + } + + private class Converter : JsonConverter + { + public override UnionMember1? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write( + Utf8JsonWriter writer, + UnionMember1 value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/TransformationProperties/Rotation.cs b/src/Imagekit/Models/TransformationProperties/Rotation.cs index 6f8850c7..2462218d 100644 --- a/src/Imagekit/Models/TransformationProperties/Rotation.cs +++ b/src/Imagekit/Models/TransformationProperties/Rotation.cs @@ -14,50 +14,60 @@ namespace Imagekit.Models.TransformationProperties; /// following values are supported: 0, 90, 180, 270, or 360. See [Rotate](https://imagekit.io/docs/effects-and-enhancements#rotate---rt). /// [JsonConverter(typeof(RotationConverter))] -public abstract record class Rotation +public record class Rotation { - internal Rotation() { } + public object Value { get; private init; } - public static implicit operator Rotation(double value) => new RotationVariants::Double(value); + public Rotation(double value) + { + Value = value; + } - public static implicit operator Rotation(string value) => new RotationVariants::String(value); + public Rotation(string value) + { + Value = value; + } + + Rotation(UnknownVariant value) + { + Value = value; + } + + public static Rotation CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as RotationVariants::Double)?.Value; + value = this.Value as double?; return value != null; } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as RotationVariants::String)?.Value; + value = this.Value as string; return value != null; } - public void Switch( - Action @double, - Action @string - ) + public void Switch(Action @double, Action @string) { - switch (this) + switch (this.Value) { - case RotationVariants::Double inner: - @double(inner); + case double value: + @double(value); break; - case RotationVariants::String inner: - @string(inner); + case string value: + @string(value); break; default: throw new InvalidOperationException(); } } - public T Match( - Func @double, - Func @string - ) + public T Match(Func @double, Func @string) { - return this switch + return this.Value switch { RotationVariants::Double inner => @double(inner), RotationVariants::String inner => @string(inner), @@ -65,7 +75,15 @@ public T Match( }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException("Data did not match any variant of Rotation"); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class RotationConverter : JsonConverter @@ -80,11 +98,9 @@ JsonSerializerOptions options try { - return new RotationVariants::Double( - JsonSerializer.Deserialize(ref reader, options) - ); + return new Rotation(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -94,10 +110,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new RotationVariants::String(deserialized); + return new Rotation(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/TransformationProperties/Shadow.cs b/src/Imagekit/Models/TransformationProperties/Shadow.cs index 6d3e0cd4..e35c0530 100644 --- a/src/Imagekit/Models/TransformationProperties/Shadow.cs +++ b/src/Imagekit/Models/TransformationProperties/Shadow.cs @@ -13,42 +13,60 @@ namespace Imagekit.Models.TransformationProperties; /// shadow, or provide a string for a custom shadow. See [Shadow](https://imagekit.io/docs/effects-and-enhancements#shadow---e-shadow). /// [JsonConverter(typeof(ShadowConverter))] -public abstract record class Shadow +public record class Shadow { - internal Shadow() { } + public object Value { get; private init; } - public static implicit operator Shadow(string value) => new ShadowVariants::String(value); + public Shadow(UnionMember0 value) + { + Value = value; + } + + public Shadow(string value) + { + Value = value; + } - public bool TryPickTrue([NotNullWhen(true)] out JsonElement? value) + Shadow(UnknownVariant value) { - value = (this as ShadowVariants::True)?.Value; + Value = value; + } + + public static Shadow CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } + + public bool TryPickTrue([NotNullWhen(true)] out UnionMember0? value) + { + value = this.Value as UnionMember0; return value != null; } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as ShadowVariants::String)?.Value; + value = this.Value as string; return value != null; } - public void Switch(Action true1, Action @string) + public void Switch(Action true1, Action @string) { - switch (this) + switch (this.Value) { - case ShadowVariants::True inner: - true1(inner); + case UnionMember0 value: + true1(value); break; - case ShadowVariants::String inner: - @string(inner); + case string value: + @string(value); break; default: throw new InvalidOperationException(); } } - public T Match(Func true1, Func @string) + public T Match(Func true1, Func @string) { - return this switch + return this.Value switch { ShadowVariants::True inner => true1(inner), ShadowVariants::String inner => @string(inner), @@ -56,7 +74,15 @@ public T Match(Func true1, Func @@ -71,11 +97,14 @@ JsonSerializerOptions options try { - return new ShadowVariants::True( - JsonSerializer.Deserialize(ref reader, options) - ); + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + deserialized.Validate(); + return new Shadow(deserialized); + } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -85,10 +114,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new ShadowVariants::String(deserialized); + return new Shadow(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/TransformationProperties/ShadowProperties/UnionMember0.cs b/src/Imagekit/Models/TransformationProperties/ShadowProperties/UnionMember0.cs new file mode 100644 index 00000000..0ba20c36 --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/ShadowProperties/UnionMember0.cs @@ -0,0 +1,51 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; + +namespace Imagekit.Models.TransformationProperties.ShadowProperties; + +[JsonConverter(typeof(Converter))] +public class UnionMember0 +{ + public JsonElement Json { get; private init; } + + public UnionMember0() + { + Json = JsonSerializer.Deserialize("true"); + } + + UnionMember0(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new UnionMember0().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'UnionMember0'"); + } + } + + private class Converter : JsonConverter + { + public override UnionMember0? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write( + Utf8JsonWriter writer, + UnionMember0 value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/TransformationProperties/Sharpen.cs b/src/Imagekit/Models/TransformationProperties/Sharpen.cs index e82e5351..4d495c8c 100644 --- a/src/Imagekit/Models/TransformationProperties/Sharpen.cs +++ b/src/Imagekit/Models/TransformationProperties/Sharpen.cs @@ -13,45 +13,60 @@ namespace Imagekit.Models.TransformationProperties; /// [Sharpen](https://imagekit.io/docs/effects-and-enhancements#sharpen---e-sharpen). /// [JsonConverter(typeof(SharpenConverter))] -public abstract record class Sharpen +public record class Sharpen { - internal Sharpen() { } + public object Value { get; private init; } - public static implicit operator Sharpen(double value) => new SharpenVariants::Double(value); + public Sharpen(UnionMember0 value) + { + Value = value; + } + + public Sharpen(double value) + { + Value = value; + } - public bool TryPickTrue([NotNullWhen(true)] out JsonElement? value) + Sharpen(UnknownVariant value) { - value = (this as SharpenVariants::True)?.Value; + Value = value; + } + + public static Sharpen CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } + + public bool TryPickTrue([NotNullWhen(true)] out UnionMember0? value) + { + value = this.Value as UnionMember0; return value != null; } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as SharpenVariants::Double)?.Value; + value = this.Value as double?; return value != null; } - public void Switch(Action true1, Action @double) + public void Switch(Action true1, Action @double) { - switch (this) + switch (this.Value) { - case SharpenVariants::True inner: - true1(inner); + case UnionMember0 value: + true1(value); break; - case SharpenVariants::Double inner: - @double(inner); + case double value: + @double(value); break; default: throw new InvalidOperationException(); } } - public T Match( - Func true1, - Func @double - ) + public T Match(Func true1, Func @double) { - return this switch + return this.Value switch { SharpenVariants::True inner => true1(inner), SharpenVariants::Double inner => @double(inner), @@ -59,7 +74,15 @@ public T Match( }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException("Data did not match any variant of Sharpen"); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class SharpenConverter : JsonConverter @@ -74,22 +97,23 @@ JsonSerializerOptions options try { - return new SharpenVariants::True( - JsonSerializer.Deserialize(ref reader, options) - ); + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + deserialized.Validate(); + return new Sharpen(deserialized); + } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } try { - return new SharpenVariants::Double( - JsonSerializer.Deserialize(ref reader, options) - ); + return new Sharpen(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/TransformationProperties/SharpenProperties/UnionMember0.cs b/src/Imagekit/Models/TransformationProperties/SharpenProperties/UnionMember0.cs new file mode 100644 index 00000000..f1208c16 --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/SharpenProperties/UnionMember0.cs @@ -0,0 +1,51 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; + +namespace Imagekit.Models.TransformationProperties.SharpenProperties; + +[JsonConverter(typeof(Converter))] +public class UnionMember0 +{ + public JsonElement Json { get; private init; } + + public UnionMember0() + { + Json = JsonSerializer.Deserialize("true"); + } + + UnionMember0(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new UnionMember0().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'UnionMember0'"); + } + } + + private class Converter : JsonConverter + { + public override UnionMember0? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write( + Utf8JsonWriter writer, + UnionMember0 value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/TransformationProperties/StartOffset.cs b/src/Imagekit/Models/TransformationProperties/StartOffset.cs index e204e413..3b579d3e 100644 --- a/src/Imagekit/Models/TransformationProperties/StartOffset.cs +++ b/src/Imagekit/Models/TransformationProperties/StartOffset.cs @@ -12,52 +12,60 @@ namespace Imagekit.Models.TransformationProperties; /// Arithmetic expressions are also supported. See [Trim videos – Start offset](https://imagekit.io/docs/trim-videos#start-offset---so). /// [JsonConverter(typeof(StartOffsetConverter))] -public abstract record class StartOffset +public record class StartOffset { - internal StartOffset() { } + public object Value { get; private init; } - public static implicit operator StartOffset(double value) => - new StartOffsetVariants::Double(value); + public StartOffset(double value) + { + Value = value; + } - public static implicit operator StartOffset(string value) => - new StartOffsetVariants::String(value); + public StartOffset(string value) + { + Value = value; + } + + StartOffset(UnknownVariant value) + { + Value = value; + } + + public static StartOffset CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as StartOffsetVariants::Double)?.Value; + value = this.Value as double?; return value != null; } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as StartOffsetVariants::String)?.Value; + value = this.Value as string; return value != null; } - public void Switch( - Action @double, - Action @string - ) + public void Switch(Action @double, Action @string) { - switch (this) + switch (this.Value) { - case StartOffsetVariants::Double inner: - @double(inner); + case double value: + @double(value); break; - case StartOffsetVariants::String inner: - @string(inner); + case string value: + @string(value); break; default: throw new InvalidOperationException(); } } - public T Match( - Func @double, - Func @string - ) + public T Match(Func @double, Func @string) { - return this switch + return this.Value switch { StartOffsetVariants::Double inner => @double(inner), StartOffsetVariants::String inner => @string(inner), @@ -65,7 +73,15 @@ public T Match( }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException("Data did not match any variant of StartOffset"); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class StartOffsetConverter : JsonConverter @@ -80,11 +96,9 @@ JsonSerializerOptions options try { - return new StartOffsetVariants::Double( - JsonSerializer.Deserialize(ref reader, options) - ); + return new StartOffset(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -94,10 +108,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new StartOffsetVariants::String(deserialized); + return new StartOffset(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/TransformationProperties/Trim.cs b/src/Imagekit/Models/TransformationProperties/Trim.cs index 54952c99..aca0f337 100644 --- a/src/Imagekit/Models/TransformationProperties/Trim.cs +++ b/src/Imagekit/Models/TransformationProperties/Trim.cs @@ -13,42 +13,60 @@ namespace Imagekit.Models.TransformationProperties; /// image. See [Trim edges](https://imagekit.io/docs/effects-and-enhancements#trim-edges---t). /// [JsonConverter(typeof(TrimConverter))] -public abstract record class Trim +public record class Trim { - internal Trim() { } + public object Value { get; private init; } - public static implicit operator Trim(double value) => new TrimVariants::Double(value); + public Trim(UnionMember0 value) + { + Value = value; + } + + public Trim(double value) + { + Value = value; + } + + Trim(UnknownVariant value) + { + Value = value; + } - public bool TryPickTrue([NotNullWhen(true)] out JsonElement? value) + public static Trim CreateUnknownVariant(JsonElement value) { - value = (this as TrimVariants::True)?.Value; + return new(new UnknownVariant(value)); + } + + public bool TryPickTrue([NotNullWhen(true)] out UnionMember0? value) + { + value = this.Value as UnionMember0; return value != null; } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as TrimVariants::Double)?.Value; + value = this.Value as double?; return value != null; } - public void Switch(Action true1, Action @double) + public void Switch(Action true1, Action @double) { - switch (this) + switch (this.Value) { - case TrimVariants::True inner: - true1(inner); + case UnionMember0 value: + true1(value); break; - case TrimVariants::Double inner: - @double(inner); + case double value: + @double(value); break; default: throw new InvalidOperationException(); } } - public T Match(Func true1, Func @double) + public T Match(Func true1, Func @double) { - return this switch + return this.Value switch { TrimVariants::True inner => true1(inner), TrimVariants::Double inner => @double(inner), @@ -56,7 +74,15 @@ public T Match(Func true1, Func @@ -71,22 +97,23 @@ JsonSerializerOptions options try { - return new TrimVariants::True( - JsonSerializer.Deserialize(ref reader, options) - ); + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + deserialized.Validate(); + return new Trim(deserialized); + } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } try { - return new TrimVariants::Double( - JsonSerializer.Deserialize(ref reader, options) - ); + return new Trim(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/TransformationProperties/TrimProperties/UnionMember0.cs b/src/Imagekit/Models/TransformationProperties/TrimProperties/UnionMember0.cs new file mode 100644 index 00000000..02c238c9 --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/TrimProperties/UnionMember0.cs @@ -0,0 +1,51 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; + +namespace Imagekit.Models.TransformationProperties.TrimProperties; + +[JsonConverter(typeof(Converter))] +public class UnionMember0 +{ + public JsonElement Json { get; private init; } + + public UnionMember0() + { + Json = JsonSerializer.Deserialize("true"); + } + + UnionMember0(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new UnionMember0().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'UnionMember0'"); + } + } + + private class Converter : JsonConverter + { + public override UnionMember0? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write( + Utf8JsonWriter writer, + UnionMember0 value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/TransformationProperties/UnsharpMask.cs b/src/Imagekit/Models/TransformationProperties/UnsharpMask.cs index f730a55a..efa754cb 100644 --- a/src/Imagekit/Models/TransformationProperties/UnsharpMask.cs +++ b/src/Imagekit/Models/TransformationProperties/UnsharpMask.cs @@ -13,49 +13,60 @@ namespace Imagekit.Models.TransformationProperties; /// Mask](https://imagekit.io/docs/effects-and-enhancements#unsharp-mask---e-usm). /// [JsonConverter(typeof(UnsharpMaskConverter))] -public abstract record class UnsharpMask +public record class UnsharpMask { - internal UnsharpMask() { } + public object Value { get; private init; } - public static implicit operator UnsharpMask(string value) => - new UnsharpMaskVariants::String(value); + public UnsharpMask(UnionMember0 value) + { + Value = value; + } + + public UnsharpMask(string value) + { + Value = value; + } + + UnsharpMask(UnknownVariant value) + { + Value = value; + } + + public static UnsharpMask CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } - public bool TryPickTrue([NotNullWhen(true)] out JsonElement? value) + public bool TryPickTrue([NotNullWhen(true)] out UnionMember0? value) { - value = (this as UnsharpMaskVariants::True)?.Value; + value = this.Value as UnionMember0; return value != null; } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as UnsharpMaskVariants::String)?.Value; + value = this.Value as string; return value != null; } - public void Switch( - Action true1, - Action @string - ) + public void Switch(Action true1, Action @string) { - switch (this) + switch (this.Value) { - case UnsharpMaskVariants::True inner: - true1(inner); + case UnionMember0 value: + true1(value); break; - case UnsharpMaskVariants::String inner: - @string(inner); + case string value: + @string(value); break; default: throw new InvalidOperationException(); } } - public T Match( - Func true1, - Func @string - ) + public T Match(Func true1, Func @string) { - return this switch + return this.Value switch { UnsharpMaskVariants::True inner => true1(inner), UnsharpMaskVariants::String inner => @string(inner), @@ -63,7 +74,15 @@ public T Match( }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException("Data did not match any variant of UnsharpMask"); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class UnsharpMaskConverter : JsonConverter @@ -78,11 +97,14 @@ JsonSerializerOptions options try { - return new UnsharpMaskVariants::True( - JsonSerializer.Deserialize(ref reader, options) - ); + var deserialized = JsonSerializer.Deserialize(ref reader, options); + if (deserialized != null) + { + deserialized.Validate(); + return new UnsharpMask(deserialized); + } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -92,10 +114,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new UnsharpMaskVariants::String(deserialized); + return new UnsharpMask(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/TransformationProperties/UnsharpMaskProperties/UnionMember0.cs b/src/Imagekit/Models/TransformationProperties/UnsharpMaskProperties/UnionMember0.cs new file mode 100644 index 00000000..68dc0275 --- /dev/null +++ b/src/Imagekit/Models/TransformationProperties/UnsharpMaskProperties/UnionMember0.cs @@ -0,0 +1,51 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; + +namespace Imagekit.Models.TransformationProperties.UnsharpMaskProperties; + +[JsonConverter(typeof(Converter))] +public class UnionMember0 +{ + public JsonElement Json { get; private init; } + + public UnionMember0() + { + Json = JsonSerializer.Deserialize("true"); + } + + UnionMember0(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new UnionMember0().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'UnionMember0'"); + } + } + + private class Converter : JsonConverter + { + public override UnionMember0? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write( + Utf8JsonWriter writer, + UnionMember0 value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/TransformationProperties/Width.cs b/src/Imagekit/Models/TransformationProperties/Width.cs index aeb4a52a..722809d4 100644 --- a/src/Imagekit/Models/TransformationProperties/Width.cs +++ b/src/Imagekit/Models/TransformationProperties/Width.cs @@ -14,47 +14,60 @@ namespace Imagekit.Models.TransformationProperties; /// – [Images](https://imagekit.io/docs/image-resize-and-crop#width---w) · [Videos](https://imagekit.io/docs/video-resize-and-crop#width---w) /// [JsonConverter(typeof(WidthConverter))] -public abstract record class Width +public record class Width { - internal Width() { } + public object Value { get; private init; } - public static implicit operator Width(double value) => new WidthVariants::Double(value); + public Width(double value) + { + Value = value; + } + + public Width(string value) + { + Value = value; + } + + Width(UnknownVariant value) + { + Value = value; + } - public static implicit operator Width(string value) => new WidthVariants::String(value); + public static Width CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as WidthVariants::Double)?.Value; + value = this.Value as double?; return value != null; } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as WidthVariants::String)?.Value; + value = this.Value as string; return value != null; } - public void Switch(Action @double, Action @string) + public void Switch(Action @double, Action @string) { - switch (this) + switch (this.Value) { - case WidthVariants::Double inner: - @double(inner); + case double value: + @double(value); break; - case WidthVariants::String inner: - @string(inner); + case string value: + @string(value); break; default: throw new InvalidOperationException(); } } - public T Match( - Func @double, - Func @string - ) + public T Match(Func @double, Func @string) { - return this switch + return this.Value switch { WidthVariants::Double inner => @double(inner), WidthVariants::String inner => @string(inner), @@ -62,7 +75,15 @@ public T Match( }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException("Data did not match any variant of Width"); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class WidthConverter : JsonConverter @@ -77,11 +98,9 @@ JsonSerializerOptions options try { - return new WidthVariants::Double( - JsonSerializer.Deserialize(ref reader, options) - ); + return new Width(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -91,10 +110,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new WidthVariants::String(deserialized); + return new Width(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/TransformationProperties/X.cs b/src/Imagekit/Models/TransformationProperties/X.cs index 356770d1..8ab60929 100644 --- a/src/Imagekit/Models/TransformationProperties/X.cs +++ b/src/Imagekit/Models/TransformationProperties/X.cs @@ -11,44 +11,60 @@ namespace Imagekit.Models.TransformationProperties; /// Focus using cropped image coordinates - X coordinate. See [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). /// [JsonConverter(typeof(XConverter))] -public abstract record class X +public record class X { - internal X() { } + public object Value { get; private init; } - public static implicit operator X(double value) => new XVariants::Double(value); + public X(double value) + { + Value = value; + } + + public X(string value) + { + Value = value; + } - public static implicit operator X(string value) => new XVariants::String(value); + X(UnknownVariant value) + { + Value = value; + } + + public static X CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as XVariants::Double)?.Value; + value = this.Value as double?; return value != null; } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as XVariants::String)?.Value; + value = this.Value as string; return value != null; } - public void Switch(Action @double, Action @string) + public void Switch(Action @double, Action @string) { - switch (this) + switch (this.Value) { - case XVariants::Double inner: - @double(inner); + case double value: + @double(value); break; - case XVariants::String inner: - @string(inner); + case string value: + @string(value); break; default: throw new InvalidOperationException(); } } - public T Match(Func @double, Func @string) + public T Match(Func @double, Func @string) { - return this switch + return this.Value switch { XVariants::Double inner => @double(inner), XVariants::String inner => @string(inner), @@ -56,7 +72,15 @@ public T Match(Func @double, Func }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException("Data did not match any variant of X"); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class XConverter : JsonConverter @@ -71,9 +95,9 @@ JsonSerializerOptions options try { - return new XVariants::Double(JsonSerializer.Deserialize(ref reader, options)); + return new X(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -83,10 +107,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new XVariants::String(deserialized); + return new X(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/TransformationProperties/XCenter.cs b/src/Imagekit/Models/TransformationProperties/XCenter.cs index 733861a4..bf003525 100644 --- a/src/Imagekit/Models/TransformationProperties/XCenter.cs +++ b/src/Imagekit/Models/TransformationProperties/XCenter.cs @@ -12,50 +12,60 @@ namespace Imagekit.Models.TransformationProperties; /// cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). /// [JsonConverter(typeof(XCenterConverter))] -public abstract record class XCenter +public record class XCenter { - internal XCenter() { } + public object Value { get; private init; } - public static implicit operator XCenter(double value) => new XCenterVariants::Double(value); + public XCenter(double value) + { + Value = value; + } - public static implicit operator XCenter(string value) => new XCenterVariants::String(value); + public XCenter(string value) + { + Value = value; + } + + XCenter(UnknownVariant value) + { + Value = value; + } + + public static XCenter CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as XCenterVariants::Double)?.Value; + value = this.Value as double?; return value != null; } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as XCenterVariants::String)?.Value; + value = this.Value as string; return value != null; } - public void Switch( - Action @double, - Action @string - ) + public void Switch(Action @double, Action @string) { - switch (this) + switch (this.Value) { - case XCenterVariants::Double inner: - @double(inner); + case double value: + @double(value); break; - case XCenterVariants::String inner: - @string(inner); + case string value: + @string(value); break; default: throw new InvalidOperationException(); } } - public T Match( - Func @double, - Func @string - ) + public T Match(Func @double, Func @string) { - return this switch + return this.Value switch { XCenterVariants::Double inner => @double(inner), XCenterVariants::String inner => @string(inner), @@ -63,7 +73,15 @@ public T Match( }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException("Data did not match any variant of XCenter"); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class XCenterConverter : JsonConverter @@ -78,11 +96,9 @@ JsonSerializerOptions options try { - return new XCenterVariants::Double( - JsonSerializer.Deserialize(ref reader, options) - ); + return new XCenter(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -92,10 +108,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new XCenterVariants::String(deserialized); + return new XCenter(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/TransformationProperties/Y.cs b/src/Imagekit/Models/TransformationProperties/Y.cs index 9be0e9d6..37e9acf8 100644 --- a/src/Imagekit/Models/TransformationProperties/Y.cs +++ b/src/Imagekit/Models/TransformationProperties/Y.cs @@ -11,44 +11,60 @@ namespace Imagekit.Models.TransformationProperties; /// Focus using cropped image coordinates - Y coordinate. See [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). /// [JsonConverter(typeof(YConverter))] -public abstract record class Y +public record class Y { - internal Y() { } + public object Value { get; private init; } - public static implicit operator Y(double value) => new YVariants::Double(value); + public Y(double value) + { + Value = value; + } + + public Y(string value) + { + Value = value; + } - public static implicit operator Y(string value) => new YVariants::String(value); + Y(UnknownVariant value) + { + Value = value; + } + + public static Y CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as YVariants::Double)?.Value; + value = this.Value as double?; return value != null; } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as YVariants::String)?.Value; + value = this.Value as string; return value != null; } - public void Switch(Action @double, Action @string) + public void Switch(Action @double, Action @string) { - switch (this) + switch (this.Value) { - case YVariants::Double inner: - @double(inner); + case double value: + @double(value); break; - case YVariants::String inner: - @string(inner); + case string value: + @string(value); break; default: throw new InvalidOperationException(); } } - public T Match(Func @double, Func @string) + public T Match(Func @double, Func @string) { - return this switch + return this.Value switch { YVariants::Double inner => @double(inner), YVariants::String inner => @string(inner), @@ -56,7 +72,15 @@ public T Match(Func @double, Func }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException("Data did not match any variant of Y"); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class YConverter : JsonConverter @@ -71,9 +95,9 @@ JsonSerializerOptions options try { - return new YVariants::Double(JsonSerializer.Deserialize(ref reader, options)); + return new Y(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -83,10 +107,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new YVariants::String(deserialized); + return new Y(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/TransformationProperties/YCenter.cs b/src/Imagekit/Models/TransformationProperties/YCenter.cs index 99579e96..063b9df3 100644 --- a/src/Imagekit/Models/TransformationProperties/YCenter.cs +++ b/src/Imagekit/Models/TransformationProperties/YCenter.cs @@ -12,50 +12,60 @@ namespace Imagekit.Models.TransformationProperties; /// cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). /// [JsonConverter(typeof(YCenterConverter))] -public abstract record class YCenter +public record class YCenter { - internal YCenter() { } + public object Value { get; private init; } - public static implicit operator YCenter(double value) => new YCenterVariants::Double(value); + public YCenter(double value) + { + Value = value; + } - public static implicit operator YCenter(string value) => new YCenterVariants::String(value); + public YCenter(string value) + { + Value = value; + } + + YCenter(UnknownVariant value) + { + Value = value; + } + + public static YCenter CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as YCenterVariants::Double)?.Value; + value = this.Value as double?; return value != null; } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as YCenterVariants::String)?.Value; + value = this.Value as string; return value != null; } - public void Switch( - Action @double, - Action @string - ) + public void Switch(Action @double, Action @string) { - switch (this) + switch (this.Value) { - case YCenterVariants::Double inner: - @double(inner); + case double value: + @double(value); break; - case YCenterVariants::String inner: - @string(inner); + case string value: + @string(value); break; default: throw new InvalidOperationException(); } } - public T Match( - Func @double, - Func @string - ) + public T Match(Func @double, Func @string) { - return this switch + return this.Value switch { YCenterVariants::Double inner => @double(inner), YCenterVariants::String inner => @string(inner), @@ -63,7 +73,15 @@ public T Match( }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException("Data did not match any variant of YCenter"); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class YCenterConverter : JsonConverter @@ -78,11 +96,9 @@ JsonSerializerOptions options try { - return new YCenterVariants::Double( - JsonSerializer.Deserialize(ref reader, options) - ); + return new YCenter(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } @@ -92,10 +108,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new YCenterVariants::String(deserialized); + return new YCenter(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add(e); } diff --git a/src/Imagekit/Models/UnnamedSchemaWithArrayParent0.cs b/src/Imagekit/Models/UnnamedSchemaWithArrayParent0.cs index 36ce4c39..5e4e9b50 100644 --- a/src/Imagekit/Models/UnnamedSchemaWithArrayParent0.cs +++ b/src/Imagekit/Models/UnnamedSchemaWithArrayParent0.cs @@ -5,55 +5,73 @@ using System.Text.Json.Serialization; using Imagekit.Exceptions; using Imagekit.Models.UnnamedSchemaWithArrayParent0Properties; -using UnnamedSchemaWithArrayParent0Variants = Imagekit.Models.UnnamedSchemaWithArrayParent0Variants; namespace Imagekit.Models; [JsonConverter(typeof(UnnamedSchemaWithArrayParent0Converter))] -public abstract record class UnnamedSchemaWithArrayParent0 +public record class UnnamedSchemaWithArrayParent0 { - internal UnnamedSchemaWithArrayParent0() { } + public object Value { get; private init; } - public static implicit operator UnnamedSchemaWithArrayParent0(RemoveBg value) => - new UnnamedSchemaWithArrayParent0Variants::RemoveBg(value); + public UnnamedSchemaWithArrayParent0(RemoveBg value) + { + Value = value; + } + + public UnnamedSchemaWithArrayParent0(AutoTaggingExtension value) + { + Value = value; + } - public static implicit operator UnnamedSchemaWithArrayParent0(AutoTaggingExtension value) => - new UnnamedSchemaWithArrayParent0Variants::AutoTaggingExtension(value); + public UnnamedSchemaWithArrayParent0(AIAutoDescription value) + { + Value = value; + } + + UnnamedSchemaWithArrayParent0(UnknownVariant value) + { + Value = value; + } + + public static UnnamedSchemaWithArrayParent0 CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickRemoveBg([NotNullWhen(true)] out RemoveBg? value) { - value = (this as UnnamedSchemaWithArrayParent0Variants::RemoveBg)?.Value; + value = this.Value as RemoveBg; return value != null; } public bool TryPickAutoTaggingExtension([NotNullWhen(true)] out AutoTaggingExtension? value) { - value = (this as UnnamedSchemaWithArrayParent0Variants::AutoTaggingExtension)?.Value; + value = this.Value as AutoTaggingExtension; return value != null; } - public bool TryPickAIAutoDescription([NotNullWhen(true)] out JsonElement? value) + public bool TryPickAIAutoDescription([NotNullWhen(true)] out AIAutoDescription? value) { - value = (this as UnnamedSchemaWithArrayParent0Variants::AIAutoDescription)?.Value; + value = this.Value as AIAutoDescription; return value != null; } public void Switch( - Action removeBg, - Action autoTaggingExtension, - Action aiAutoDescription + Action removeBg, + Action autoTaggingExtension, + Action aiAutoDescription ) { - switch (this) + switch (this.Value) { - case UnnamedSchemaWithArrayParent0Variants::RemoveBg inner: - removeBg(inner); + case RemoveBg value: + removeBg(value); break; - case UnnamedSchemaWithArrayParent0Variants::AutoTaggingExtension inner: - autoTaggingExtension(inner); + case AutoTaggingExtension value: + autoTaggingExtension(value); break; - case UnnamedSchemaWithArrayParent0Variants::AIAutoDescription inner: - aiAutoDescription(inner); + case AIAutoDescription value: + aiAutoDescription(value); break; default: throw new ImageKitInvalidDataException( @@ -63,26 +81,33 @@ public void Switch( } public T Match( - Func removeBg, - Func autoTaggingExtension, - Func aiAutoDescription + Func removeBg, + Func autoTaggingExtension, + Func aiAutoDescription ) { - return this switch + return this.Value switch { - UnnamedSchemaWithArrayParent0Variants::RemoveBg inner => removeBg(inner), - UnnamedSchemaWithArrayParent0Variants::AutoTaggingExtension inner => - autoTaggingExtension(inner), - UnnamedSchemaWithArrayParent0Variants::AIAutoDescription inner => aiAutoDescription( - inner - ), + RemoveBg value => removeBg(value), + AutoTaggingExtension value => autoTaggingExtension(value), + AIAutoDescription value => aiAutoDescription(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of UnnamedSchemaWithArrayParent0" ), }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent0" + ); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class UnnamedSchemaWithArrayParent0Converter : JsonConverter @@ -115,14 +140,15 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(json, options); if (deserialized != null) { - return new UnnamedSchemaWithArrayParent0Variants::RemoveBg(deserialized); + deserialized.Validate(); + return new UnnamedSchemaWithArrayParent0(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( new ImageKitInvalidDataException( - "Data does not match union variant UnnamedSchemaWithArrayParent0Variants::RemoveBg", + "Data does not match union variant 'RemoveBg'", e ) ); @@ -136,15 +162,18 @@ JsonSerializerOptions options try { - return new UnnamedSchemaWithArrayParent0Variants::AIAutoDescription( - JsonSerializer.Deserialize(json, options) - ); + var deserialized = JsonSerializer.Deserialize(json, options); + if (deserialized != null) + { + deserialized.Validate(); + return new UnnamedSchemaWithArrayParent0(deserialized); + } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( new ImageKitInvalidDataException( - "Data does not match union variant UnnamedSchemaWithArrayParent0Variants::AIAutoDescription", + "Data does not match union variant 'AIAutoDescription'", e ) ); @@ -164,16 +193,15 @@ JsonSerializerOptions options ); if (deserialized != null) { - return new UnnamedSchemaWithArrayParent0Variants::AutoTaggingExtension( - deserialized - ); + deserialized.Validate(); + return new UnnamedSchemaWithArrayParent0(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( new ImageKitInvalidDataException( - "Data does not match union variant UnnamedSchemaWithArrayParent0Variants::AutoTaggingExtension", + "Data does not match union variant 'AutoTaggingExtension'", e ) ); @@ -190,17 +218,7 @@ public override void Write( JsonSerializerOptions options ) { - object variant = value switch - { - UnnamedSchemaWithArrayParent0Variants::RemoveBg(var removeBg) => removeBg, - UnnamedSchemaWithArrayParent0Variants::AutoTaggingExtension(var autoTaggingExtension) => - autoTaggingExtension, - UnnamedSchemaWithArrayParent0Variants::AIAutoDescription(var aiAutoDescription) => - aiAutoDescription, - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent0" - ), - }; + object variant = value.Value; JsonSerializer.Serialize(writer, variant, options); } } diff --git a/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/AIAutoDescription.cs b/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/AIAutoDescription.cs new file mode 100644 index 00000000..4c743fdd --- /dev/null +++ b/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/AIAutoDescription.cs @@ -0,0 +1,53 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; + +namespace Imagekit.Models.UnnamedSchemaWithArrayParent0Properties; + +[JsonConverter(typeof(Converter))] +public class AIAutoDescription +{ + public JsonElement Json { get; private init; } + + public AIAutoDescription() + { + Json = JsonSerializer.Deserialize("{\"name\":\"ai-auto-description\"}"); + } + + AIAutoDescription(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new AIAutoDescription().Json)) + { + throw new ImageKitInvalidDataException( + "Invalid constant given for 'AIAutoDescription'" + ); + } + } + + private class Converter : JsonConverter + { + public override AIAutoDescription? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write( + Utf8JsonWriter writer, + AIAutoDescription value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/AIAutoDescriptionProperties/Name.cs b/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/AIAutoDescriptionProperties/Name.cs new file mode 100644 index 00000000..6b22161b --- /dev/null +++ b/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/AIAutoDescriptionProperties/Name.cs @@ -0,0 +1,50 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; + +namespace Imagekit.Models.UnnamedSchemaWithArrayParent0Properties.AIAutoDescriptionProperties; + +/// +/// Specifies the auto description extension. +/// +[JsonConverter(typeof(Converter))] +public class Name +{ + public JsonElement Json { get; private init; } + + public Name() + { + Json = JsonSerializer.Deserialize("\"ai-auto-description\""); + } + + Name(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new Name().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'Name'"); + } + } + + private class Converter : JsonConverter + { + public override Name? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write(Utf8JsonWriter writer, Name value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/RemoveBg.cs b/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/RemoveBg.cs index 0c190907..4adf376d 100644 --- a/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/RemoveBg.cs +++ b/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/RemoveBg.cs @@ -13,14 +13,18 @@ public sealed record class RemoveBg : ModelBase, IFromRaw /// /// Specifies the background removal extension. /// - public JsonElement Name + public Name Name { get { if (!this.Properties.TryGetValue("name", out JsonElement element)) throw new ArgumentOutOfRangeException("name", "Missing required argument"); - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ImageKitInvalidDataException( + "'name' cannot be null", + new ArgumentNullException("name") + ); } set { @@ -51,12 +55,13 @@ public Options? Options public override void Validate() { + this.Name.Validate(); this.Options?.Validate(); } public RemoveBg() { - this.Name = JsonSerializer.Deserialize("\"remove-bg\""); + this.Name = new(); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/RemoveBgProperties/Name.cs b/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/RemoveBgProperties/Name.cs new file mode 100644 index 00000000..22a4bced --- /dev/null +++ b/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/RemoveBgProperties/Name.cs @@ -0,0 +1,50 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Exceptions; + +namespace Imagekit.Models.UnnamedSchemaWithArrayParent0Properties.RemoveBgProperties; + +/// +/// Specifies the background removal extension. +/// +[JsonConverter(typeof(Converter))] +public class Name +{ + public JsonElement Json { get; private init; } + + public Name() + { + Json = JsonSerializer.Deserialize("\"remove-bg\""); + } + + Name(JsonElement json) + { + Json = json; + } + + public void Validate() + { + if (JsonElement.DeepEquals(this.Json, new Name().Json)) + { + throw new ImageKitInvalidDataException("Invalid constant given for 'Name'"); + } + } + + private class Converter : JsonConverter + { + public override Name? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write(Utf8JsonWriter writer, Name value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } + } +} diff --git a/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Variants/All.cs b/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Variants/All.cs deleted file mode 100644 index 3f65f774..00000000 --- a/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Variants/All.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System.Text.Json; -using Imagekit.Core; -using UnnamedSchemaWithArrayParent0Properties = Imagekit.Models.UnnamedSchemaWithArrayParent0Properties; - -namespace Imagekit.Models.UnnamedSchemaWithArrayParent0Variants; - -public sealed record class RemoveBg(UnnamedSchemaWithArrayParent0Properties::RemoveBg Value) - : UnnamedSchemaWithArrayParent0, - IVariant -{ - public static RemoveBg From(UnnamedSchemaWithArrayParent0Properties::RemoveBg value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class AutoTaggingExtension( - UnnamedSchemaWithArrayParent0Properties::AutoTaggingExtension Value -) - : UnnamedSchemaWithArrayParent0, - IVariant< - AutoTaggingExtension, - UnnamedSchemaWithArrayParent0Properties::AutoTaggingExtension - > -{ - public static AutoTaggingExtension From( - UnnamedSchemaWithArrayParent0Properties::AutoTaggingExtension value - ) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class AIAutoDescription(JsonElement Value) - : UnnamedSchemaWithArrayParent0, - IVariant -{ - public static AIAutoDescription From(JsonElement value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/VideoOverlay.cs b/src/Imagekit/Models/VideoOverlay.cs index e74d29f0..afbdd73d 100644 --- a/src/Imagekit/Models/VideoOverlay.cs +++ b/src/Imagekit/Models/VideoOverlay.cs @@ -158,7 +158,7 @@ public override void Validate() public VideoOverlay() { - this.Type = JsonSerializer.Deserialize("\"video\""); + this.Type = new(); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/VideoOverlayProperties/IntersectionMember1.cs b/src/Imagekit/Models/VideoOverlayProperties/IntersectionMember1.cs index 70e42181..0e159a05 100644 --- a/src/Imagekit/Models/VideoOverlayProperties/IntersectionMember1.cs +++ b/src/Imagekit/Models/VideoOverlayProperties/IntersectionMember1.cs @@ -114,7 +114,7 @@ public override void Validate() public IntersectionMember1() { - this.Type = JsonSerializer.Deserialize("\"video\""); + this.Type = new(); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs b/src/Imagekit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs index fca13cb2..e05e94e6 100644 --- a/src/Imagekit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs +++ b/src/Imagekit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs @@ -4,7 +4,6 @@ using System.Text.Json; using System.Text.Json.Serialization; using Imagekit.Exceptions; -using UnsafeUnwrapWebhookEventVariants = Imagekit.Models.Webhooks.UnsafeUnwrapWebhookEventVariants; namespace Imagekit.Models.Webhooks; @@ -14,39 +13,108 @@ namespace Imagekit.Models.Webhooks; /// request. Use this for debugging and tracking transformation lifecycle. /// [JsonConverter(typeof(UnsafeUnwrapWebhookEventConverter))] -public abstract record class UnsafeUnwrapWebhookEvent +public record class UnsafeUnwrapWebhookEvent { - internal UnsafeUnwrapWebhookEvent() { } + public object Value { get; private init; } - public static implicit operator UnsafeUnwrapWebhookEvent( - VideoTransformationAcceptedEvent value - ) => new UnsafeUnwrapWebhookEventVariants::VideoTransformationAcceptedEvent(value); + public string ID + { + get + { + return Match( + videoTransformationAccepted: (x) => x.ID, + videoTransformationReady: (x) => x.ID, + videoTransformationError: (x) => x.ID, + uploadPreTransformSuccess: (x) => x.ID, + uploadPreTransformError: (x) => x.ID, + uploadPostTransformSuccess: (x) => x.ID, + uploadPostTransformError: (x) => x.ID + ); + } + } - public static implicit operator UnsafeUnwrapWebhookEvent(VideoTransformationReadyEvent value) => - new UnsafeUnwrapWebhookEventVariants::VideoTransformationReadyEvent(value); + public string Type + { + get + { + return Match( + videoTransformationAccepted: (x) => x.Type, + videoTransformationReady: (x) => x.Type, + videoTransformationError: (x) => x.Type, + uploadPreTransformSuccess: (x) => x.Type, + uploadPreTransformError: (x) => x.Type, + uploadPostTransformSuccess: (x) => x.Type, + uploadPostTransformError: (x) => x.Type + ); + } + } - public static implicit operator UnsafeUnwrapWebhookEvent(VideoTransformationErrorEvent value) => - new UnsafeUnwrapWebhookEventVariants::VideoTransformationErrorEvent(value); + public DateTime CreatedAt + { + get + { + return Match( + videoTransformationAccepted: (x) => x.CreatedAt, + videoTransformationReady: (x) => x.CreatedAt, + videoTransformationError: (x) => x.CreatedAt, + uploadPreTransformSuccess: (x) => x.CreatedAt, + uploadPreTransformError: (x) => x.CreatedAt, + uploadPostTransformSuccess: (x) => x.CreatedAt, + uploadPostTransformError: (x) => x.CreatedAt + ); + } + } - public static implicit operator UnsafeUnwrapWebhookEvent( - UploadPreTransformSuccessEvent value - ) => new UnsafeUnwrapWebhookEventVariants::UploadPreTransformSuccessEvent(value); + public UnsafeUnwrapWebhookEvent(VideoTransformationAcceptedEvent value) + { + Value = value; + } + + public UnsafeUnwrapWebhookEvent(VideoTransformationReadyEvent value) + { + Value = value; + } + + public UnsafeUnwrapWebhookEvent(VideoTransformationErrorEvent value) + { + Value = value; + } - public static implicit operator UnsafeUnwrapWebhookEvent(UploadPreTransformErrorEvent value) => - new UnsafeUnwrapWebhookEventVariants::UploadPreTransformErrorEvent(value); + public UnsafeUnwrapWebhookEvent(UploadPreTransformSuccessEvent value) + { + Value = value; + } - public static implicit operator UnsafeUnwrapWebhookEvent( - UploadPostTransformSuccessEvent value - ) => new UnsafeUnwrapWebhookEventVariants::UploadPostTransformSuccessEvent(value); + public UnsafeUnwrapWebhookEvent(UploadPreTransformErrorEvent value) + { + Value = value; + } - public static implicit operator UnsafeUnwrapWebhookEvent(UploadPostTransformErrorEvent value) => - new UnsafeUnwrapWebhookEventVariants::UploadPostTransformErrorEvent(value); + public UnsafeUnwrapWebhookEvent(UploadPostTransformSuccessEvent value) + { + Value = value; + } + + public UnsafeUnwrapWebhookEvent(UploadPostTransformErrorEvent value) + { + Value = value; + } + + UnsafeUnwrapWebhookEvent(UnknownVariant value) + { + Value = value; + } + + public static UnsafeUnwrapWebhookEvent CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickVideoTransformationAccepted( [NotNullWhen(true)] out VideoTransformationAcceptedEvent? value ) { - value = (this as UnsafeUnwrapWebhookEventVariants::VideoTransformationAcceptedEvent)?.Value; + value = this.Value as VideoTransformationAcceptedEvent; return value != null; } @@ -54,7 +122,7 @@ public bool TryPickVideoTransformationReady( [NotNullWhen(true)] out VideoTransformationReadyEvent? value ) { - value = (this as UnsafeUnwrapWebhookEventVariants::VideoTransformationReadyEvent)?.Value; + value = this.Value as VideoTransformationReadyEvent; return value != null; } @@ -62,7 +130,7 @@ public bool TryPickVideoTransformationError( [NotNullWhen(true)] out VideoTransformationErrorEvent? value ) { - value = (this as UnsafeUnwrapWebhookEventVariants::VideoTransformationErrorEvent)?.Value; + value = this.Value as VideoTransformationErrorEvent; return value != null; } @@ -70,7 +138,7 @@ public bool TryPickUploadPreTransformSuccess( [NotNullWhen(true)] out UploadPreTransformSuccessEvent? value ) { - value = (this as UnsafeUnwrapWebhookEventVariants::UploadPreTransformSuccessEvent)?.Value; + value = this.Value as UploadPreTransformSuccessEvent; return value != null; } @@ -78,7 +146,7 @@ public bool TryPickUploadPreTransformError( [NotNullWhen(true)] out UploadPreTransformErrorEvent? value ) { - value = (this as UnsafeUnwrapWebhookEventVariants::UploadPreTransformErrorEvent)?.Value; + value = this.Value as UploadPreTransformErrorEvent; return value != null; } @@ -86,7 +154,7 @@ public bool TryPickUploadPostTransformSuccess( [NotNullWhen(true)] out UploadPostTransformSuccessEvent? value ) { - value = (this as UnsafeUnwrapWebhookEventVariants::UploadPostTransformSuccessEvent)?.Value; + value = this.Value as UploadPostTransformSuccessEvent; return value != null; } @@ -94,42 +162,42 @@ public bool TryPickUploadPostTransformError( [NotNullWhen(true)] out UploadPostTransformErrorEvent? value ) { - value = (this as UnsafeUnwrapWebhookEventVariants::UploadPostTransformErrorEvent)?.Value; + value = this.Value as UploadPostTransformErrorEvent; return value != null; } public void Switch( - Action videoTransformationAccepted, - Action videoTransformationReady, - Action videoTransformationError, - Action uploadPreTransformSuccess, - Action uploadPreTransformError, - Action uploadPostTransformSuccess, - Action uploadPostTransformError + Action videoTransformationAccepted, + Action videoTransformationReady, + Action videoTransformationError, + Action uploadPreTransformSuccess, + Action uploadPreTransformError, + Action uploadPostTransformSuccess, + Action uploadPostTransformError ) { - switch (this) + switch (this.Value) { - case UnsafeUnwrapWebhookEventVariants::VideoTransformationAcceptedEvent inner: - videoTransformationAccepted(inner); + case VideoTransformationAcceptedEvent value: + videoTransformationAccepted(value); break; - case UnsafeUnwrapWebhookEventVariants::VideoTransformationReadyEvent inner: - videoTransformationReady(inner); + case VideoTransformationReadyEvent value: + videoTransformationReady(value); break; - case UnsafeUnwrapWebhookEventVariants::VideoTransformationErrorEvent inner: - videoTransformationError(inner); + case VideoTransformationErrorEvent value: + videoTransformationError(value); break; - case UnsafeUnwrapWebhookEventVariants::UploadPreTransformSuccessEvent inner: - uploadPreTransformSuccess(inner); + case UploadPreTransformSuccessEvent value: + uploadPreTransformSuccess(value); break; - case UnsafeUnwrapWebhookEventVariants::UploadPreTransformErrorEvent inner: - uploadPreTransformError(inner); + case UploadPreTransformErrorEvent value: + uploadPreTransformError(value); break; - case UnsafeUnwrapWebhookEventVariants::UploadPostTransformSuccessEvent inner: - uploadPostTransformSuccess(inner); + case UploadPostTransformSuccessEvent value: + uploadPostTransformSuccess(value); break; - case UnsafeUnwrapWebhookEventVariants::UploadPostTransformErrorEvent inner: - uploadPostTransformError(inner); + case UploadPostTransformErrorEvent value: + uploadPostTransformError(value); break; default: throw new ImageKitInvalidDataException( @@ -139,59 +207,41 @@ public void Switch( } public T Match( - Func< - UnsafeUnwrapWebhookEventVariants::VideoTransformationAcceptedEvent, - T - > videoTransformationAccepted, - Func< - UnsafeUnwrapWebhookEventVariants::VideoTransformationReadyEvent, - T - > videoTransformationReady, - Func< - UnsafeUnwrapWebhookEventVariants::VideoTransformationErrorEvent, - T - > videoTransformationError, - Func< - UnsafeUnwrapWebhookEventVariants::UploadPreTransformSuccessEvent, - T - > uploadPreTransformSuccess, - Func< - UnsafeUnwrapWebhookEventVariants::UploadPreTransformErrorEvent, - T - > uploadPreTransformError, - Func< - UnsafeUnwrapWebhookEventVariants::UploadPostTransformSuccessEvent, - T - > uploadPostTransformSuccess, - Func< - UnsafeUnwrapWebhookEventVariants::UploadPostTransformErrorEvent, - T - > uploadPostTransformError + Func videoTransformationAccepted, + Func videoTransformationReady, + Func videoTransformationError, + Func uploadPreTransformSuccess, + Func uploadPreTransformError, + Func uploadPostTransformSuccess, + Func uploadPostTransformError ) { - return this switch + return this.Value switch { - UnsafeUnwrapWebhookEventVariants::VideoTransformationAcceptedEvent inner => - videoTransformationAccepted(inner), - UnsafeUnwrapWebhookEventVariants::VideoTransformationReadyEvent inner => - videoTransformationReady(inner), - UnsafeUnwrapWebhookEventVariants::VideoTransformationErrorEvent inner => - videoTransformationError(inner), - UnsafeUnwrapWebhookEventVariants::UploadPreTransformSuccessEvent inner => - uploadPreTransformSuccess(inner), - UnsafeUnwrapWebhookEventVariants::UploadPreTransformErrorEvent inner => - uploadPreTransformError(inner), - UnsafeUnwrapWebhookEventVariants::UploadPostTransformSuccessEvent inner => - uploadPostTransformSuccess(inner), - UnsafeUnwrapWebhookEventVariants::UploadPostTransformErrorEvent inner => - uploadPostTransformError(inner), + VideoTransformationAcceptedEvent value => videoTransformationAccepted(value), + VideoTransformationReadyEvent value => videoTransformationReady(value), + VideoTransformationErrorEvent value => videoTransformationError(value), + UploadPreTransformSuccessEvent value => uploadPreTransformSuccess(value), + UploadPreTransformErrorEvent value => uploadPreTransformError(value), + UploadPostTransformSuccessEvent value => uploadPostTransformSuccess(value), + UploadPostTransformErrorEvent value => uploadPostTransformError(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of UnsafeUnwrapWebhookEvent" ), }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnsafeUnwrapWebhookEvent" + ); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class UnsafeUnwrapWebhookEventConverter : JsonConverter @@ -212,16 +262,15 @@ JsonSerializerOptions options ); if (deserialized != null) { - return new UnsafeUnwrapWebhookEventVariants::VideoTransformationAcceptedEvent( - deserialized - ); + deserialized.Validate(); + return new UnsafeUnwrapWebhookEvent(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( new ImageKitInvalidDataException( - "Data does not match union variant UnsafeUnwrapWebhookEventVariants::VideoTransformationAcceptedEvent", + "Data does not match union variant 'VideoTransformationAcceptedEvent'", e ) ); @@ -235,16 +284,15 @@ JsonSerializerOptions options ); if (deserialized != null) { - return new UnsafeUnwrapWebhookEventVariants::VideoTransformationReadyEvent( - deserialized - ); + deserialized.Validate(); + return new UnsafeUnwrapWebhookEvent(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( new ImageKitInvalidDataException( - "Data does not match union variant UnsafeUnwrapWebhookEventVariants::VideoTransformationReadyEvent", + "Data does not match union variant 'VideoTransformationReadyEvent'", e ) ); @@ -258,16 +306,15 @@ JsonSerializerOptions options ); if (deserialized != null) { - return new UnsafeUnwrapWebhookEventVariants::VideoTransformationErrorEvent( - deserialized - ); + deserialized.Validate(); + return new UnsafeUnwrapWebhookEvent(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( new ImageKitInvalidDataException( - "Data does not match union variant UnsafeUnwrapWebhookEventVariants::VideoTransformationErrorEvent", + "Data does not match union variant 'VideoTransformationErrorEvent'", e ) ); @@ -281,16 +328,15 @@ JsonSerializerOptions options ); if (deserialized != null) { - return new UnsafeUnwrapWebhookEventVariants::UploadPreTransformSuccessEvent( - deserialized - ); + deserialized.Validate(); + return new UnsafeUnwrapWebhookEvent(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( new ImageKitInvalidDataException( - "Data does not match union variant UnsafeUnwrapWebhookEventVariants::UploadPreTransformSuccessEvent", + "Data does not match union variant 'UploadPreTransformSuccessEvent'", e ) ); @@ -304,16 +350,15 @@ JsonSerializerOptions options ); if (deserialized != null) { - return new UnsafeUnwrapWebhookEventVariants::UploadPreTransformErrorEvent( - deserialized - ); + deserialized.Validate(); + return new UnsafeUnwrapWebhookEvent(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( new ImageKitInvalidDataException( - "Data does not match union variant UnsafeUnwrapWebhookEventVariants::UploadPreTransformErrorEvent", + "Data does not match union variant 'UploadPreTransformErrorEvent'", e ) ); @@ -327,16 +372,15 @@ JsonSerializerOptions options ); if (deserialized != null) { - return new UnsafeUnwrapWebhookEventVariants::UploadPostTransformSuccessEvent( - deserialized - ); + deserialized.Validate(); + return new UnsafeUnwrapWebhookEvent(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( new ImageKitInvalidDataException( - "Data does not match union variant UnsafeUnwrapWebhookEventVariants::UploadPostTransformSuccessEvent", + "Data does not match union variant 'UploadPostTransformSuccessEvent'", e ) ); @@ -350,16 +394,15 @@ JsonSerializerOptions options ); if (deserialized != null) { - return new UnsafeUnwrapWebhookEventVariants::UploadPostTransformErrorEvent( - deserialized - ); + deserialized.Validate(); + return new UnsafeUnwrapWebhookEvent(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( new ImageKitInvalidDataException( - "Data does not match union variant UnsafeUnwrapWebhookEventVariants::UploadPostTransformErrorEvent", + "Data does not match union variant 'UploadPostTransformErrorEvent'", e ) ); @@ -374,33 +417,7 @@ public override void Write( JsonSerializerOptions options ) { - object variant = value switch - { - UnsafeUnwrapWebhookEventVariants::VideoTransformationAcceptedEvent( - var videoTransformationAccepted - ) => videoTransformationAccepted, - UnsafeUnwrapWebhookEventVariants::VideoTransformationReadyEvent( - var videoTransformationReady - ) => videoTransformationReady, - UnsafeUnwrapWebhookEventVariants::VideoTransformationErrorEvent( - var videoTransformationError - ) => videoTransformationError, - UnsafeUnwrapWebhookEventVariants::UploadPreTransformSuccessEvent( - var uploadPreTransformSuccess - ) => uploadPreTransformSuccess, - UnsafeUnwrapWebhookEventVariants::UploadPreTransformErrorEvent( - var uploadPreTransformError - ) => uploadPreTransformError, - UnsafeUnwrapWebhookEventVariants::UploadPostTransformSuccessEvent( - var uploadPostTransformSuccess - ) => uploadPostTransformSuccess, - UnsafeUnwrapWebhookEventVariants::UploadPostTransformErrorEvent( - var uploadPostTransformError - ) => uploadPostTransformError, - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of UnsafeUnwrapWebhookEvent" - ), - }; + object variant = value.Value; JsonSerializer.Serialize(writer, variant, options); } } diff --git a/src/Imagekit/Models/Webhooks/UnsafeUnwrapWebhookEventVariants/All.cs b/src/Imagekit/Models/Webhooks/UnsafeUnwrapWebhookEventVariants/All.cs deleted file mode 100644 index c7ad54c1..00000000 --- a/src/Imagekit/Models/Webhooks/UnsafeUnwrapWebhookEventVariants/All.cs +++ /dev/null @@ -1,164 +0,0 @@ -using Imagekit.Core; -using Webhooks = Imagekit.Models.Webhooks; - -namespace Imagekit.Models.Webhooks.UnsafeUnwrapWebhookEventVariants; - -/// -/// Triggered when a new video transformation request is accepted for processing. -/// This event confirms that ImageKit has received and queued your transformation -/// request. Use this for debugging and tracking transformation lifecycle. -/// -public sealed record class VideoTransformationAcceptedEvent( - Webhooks::VideoTransformationAcceptedEvent Value -) - : Webhooks::UnsafeUnwrapWebhookEvent, - IVariant -{ - public static VideoTransformationAcceptedEvent From( - Webhooks::VideoTransformationAcceptedEvent value - ) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -/// -/// Triggered when video encoding is finished and the transformed resource is ready -/// to be served. This is the key event to listen for - update your database or CMS -/// flags when you receive this so your application can start showing the transformed -/// video to users. -/// -public sealed record class VideoTransformationReadyEvent( - Webhooks::VideoTransformationReadyEvent Value -) - : Webhooks::UnsafeUnwrapWebhookEvent, - IVariant -{ - public static VideoTransformationReadyEvent From(Webhooks::VideoTransformationReadyEvent value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -/// -/// Triggered when an error occurs during video encoding. Listen to this webhook to -/// log error reasons and debug issues. Check your origin and URL endpoint settings -/// if the reason is related to download failure. For other errors, contact ImageKit -/// support. -/// -public sealed record class VideoTransformationErrorEvent( - Webhooks::VideoTransformationErrorEvent Value -) - : Webhooks::UnsafeUnwrapWebhookEvent, - IVariant -{ - public static VideoTransformationErrorEvent From(Webhooks::VideoTransformationErrorEvent value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -/// -/// Triggered when a pre-transformation completes successfully. The file has been -/// processed with the requested transformation and is now available in the Media -/// Library. -/// -public sealed record class UploadPreTransformSuccessEvent( - Webhooks::UploadPreTransformSuccessEvent Value -) - : Webhooks::UnsafeUnwrapWebhookEvent, - IVariant -{ - public static UploadPreTransformSuccessEvent From( - Webhooks::UploadPreTransformSuccessEvent value - ) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -/// -/// Triggered when a pre-transformation fails. The file upload may have been accepted, -/// but the requested transformation could not be applied. -/// -public sealed record class UploadPreTransformErrorEvent( - Webhooks::UploadPreTransformErrorEvent Value -) - : Webhooks::UnsafeUnwrapWebhookEvent, - IVariant -{ - public static UploadPreTransformErrorEvent From(Webhooks::UploadPreTransformErrorEvent value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -/// -/// Triggered when a post-transformation completes successfully. The transformed version -/// of the file is now ready and can be accessed via the provided URL. Note that -/// each post-transformation generates a separate webhook event. -/// -public sealed record class UploadPostTransformSuccessEvent( - Webhooks::UploadPostTransformSuccessEvent Value -) - : Webhooks::UnsafeUnwrapWebhookEvent, - IVariant -{ - public static UploadPostTransformSuccessEvent From( - Webhooks::UploadPostTransformSuccessEvent value - ) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -/// -/// Triggered when a post-transformation fails. The original file remains available, -/// but the requested transformation could not be generated. -/// -public sealed record class UploadPostTransformErrorEvent( - Webhooks::UploadPostTransformErrorEvent Value -) - : Webhooks::UnsafeUnwrapWebhookEvent, - IVariant -{ - public static UploadPostTransformErrorEvent From(Webhooks::UploadPostTransformErrorEvent value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} diff --git a/src/Imagekit/Models/Webhooks/UnwrapWebhookEvent.cs b/src/Imagekit/Models/Webhooks/UnwrapWebhookEvent.cs index 4b10654f..ca9183fb 100644 --- a/src/Imagekit/Models/Webhooks/UnwrapWebhookEvent.cs +++ b/src/Imagekit/Models/Webhooks/UnwrapWebhookEvent.cs @@ -4,7 +4,6 @@ using System.Text.Json; using System.Text.Json.Serialization; using Imagekit.Exceptions; -using UnwrapWebhookEventVariants = Imagekit.Models.Webhooks.UnwrapWebhookEventVariants; namespace Imagekit.Models.Webhooks; @@ -14,36 +13,108 @@ namespace Imagekit.Models.Webhooks; /// request. Use this for debugging and tracking transformation lifecycle. /// [JsonConverter(typeof(UnwrapWebhookEventConverter))] -public abstract record class UnwrapWebhookEvent +public record class UnwrapWebhookEvent { - internal UnwrapWebhookEvent() { } + public object Value { get; private init; } - public static implicit operator UnwrapWebhookEvent(VideoTransformationAcceptedEvent value) => - new UnwrapWebhookEventVariants::VideoTransformationAcceptedEvent(value); + public string ID + { + get + { + return Match( + videoTransformationAccepted: (x) => x.ID, + videoTransformationReady: (x) => x.ID, + videoTransformationError: (x) => x.ID, + uploadPreTransformSuccess: (x) => x.ID, + uploadPreTransformError: (x) => x.ID, + uploadPostTransformSuccess: (x) => x.ID, + uploadPostTransformError: (x) => x.ID + ); + } + } + + public string Type + { + get + { + return Match( + videoTransformationAccepted: (x) => x.Type, + videoTransformationReady: (x) => x.Type, + videoTransformationError: (x) => x.Type, + uploadPreTransformSuccess: (x) => x.Type, + uploadPreTransformError: (x) => x.Type, + uploadPostTransformSuccess: (x) => x.Type, + uploadPostTransformError: (x) => x.Type + ); + } + } + + public DateTime CreatedAt + { + get + { + return Match( + videoTransformationAccepted: (x) => x.CreatedAt, + videoTransformationReady: (x) => x.CreatedAt, + videoTransformationError: (x) => x.CreatedAt, + uploadPreTransformSuccess: (x) => x.CreatedAt, + uploadPreTransformError: (x) => x.CreatedAt, + uploadPostTransformSuccess: (x) => x.CreatedAt, + uploadPostTransformError: (x) => x.CreatedAt + ); + } + } + + public UnwrapWebhookEvent(VideoTransformationAcceptedEvent value) + { + Value = value; + } + + public UnwrapWebhookEvent(VideoTransformationReadyEvent value) + { + Value = value; + } + + public UnwrapWebhookEvent(VideoTransformationErrorEvent value) + { + Value = value; + } - public static implicit operator UnwrapWebhookEvent(VideoTransformationReadyEvent value) => - new UnwrapWebhookEventVariants::VideoTransformationReadyEvent(value); + public UnwrapWebhookEvent(UploadPreTransformSuccessEvent value) + { + Value = value; + } - public static implicit operator UnwrapWebhookEvent(VideoTransformationErrorEvent value) => - new UnwrapWebhookEventVariants::VideoTransformationErrorEvent(value); + public UnwrapWebhookEvent(UploadPreTransformErrorEvent value) + { + Value = value; + } - public static implicit operator UnwrapWebhookEvent(UploadPreTransformSuccessEvent value) => - new UnwrapWebhookEventVariants::UploadPreTransformSuccessEvent(value); + public UnwrapWebhookEvent(UploadPostTransformSuccessEvent value) + { + Value = value; + } - public static implicit operator UnwrapWebhookEvent(UploadPreTransformErrorEvent value) => - new UnwrapWebhookEventVariants::UploadPreTransformErrorEvent(value); + public UnwrapWebhookEvent(UploadPostTransformErrorEvent value) + { + Value = value; + } - public static implicit operator UnwrapWebhookEvent(UploadPostTransformSuccessEvent value) => - new UnwrapWebhookEventVariants::UploadPostTransformSuccessEvent(value); + UnwrapWebhookEvent(UnknownVariant value) + { + Value = value; + } - public static implicit operator UnwrapWebhookEvent(UploadPostTransformErrorEvent value) => - new UnwrapWebhookEventVariants::UploadPostTransformErrorEvent(value); + public static UnwrapWebhookEvent CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickVideoTransformationAccepted( [NotNullWhen(true)] out VideoTransformationAcceptedEvent? value ) { - value = (this as UnwrapWebhookEventVariants::VideoTransformationAcceptedEvent)?.Value; + value = this.Value as VideoTransformationAcceptedEvent; return value != null; } @@ -51,7 +122,7 @@ public bool TryPickVideoTransformationReady( [NotNullWhen(true)] out VideoTransformationReadyEvent? value ) { - value = (this as UnwrapWebhookEventVariants::VideoTransformationReadyEvent)?.Value; + value = this.Value as VideoTransformationReadyEvent; return value != null; } @@ -59,7 +130,7 @@ public bool TryPickVideoTransformationError( [NotNullWhen(true)] out VideoTransformationErrorEvent? value ) { - value = (this as UnwrapWebhookEventVariants::VideoTransformationErrorEvent)?.Value; + value = this.Value as VideoTransformationErrorEvent; return value != null; } @@ -67,7 +138,7 @@ public bool TryPickUploadPreTransformSuccess( [NotNullWhen(true)] out UploadPreTransformSuccessEvent? value ) { - value = (this as UnwrapWebhookEventVariants::UploadPreTransformSuccessEvent)?.Value; + value = this.Value as UploadPreTransformSuccessEvent; return value != null; } @@ -75,7 +146,7 @@ public bool TryPickUploadPreTransformError( [NotNullWhen(true)] out UploadPreTransformErrorEvent? value ) { - value = (this as UnwrapWebhookEventVariants::UploadPreTransformErrorEvent)?.Value; + value = this.Value as UploadPreTransformErrorEvent; return value != null; } @@ -83,7 +154,7 @@ public bool TryPickUploadPostTransformSuccess( [NotNullWhen(true)] out UploadPostTransformSuccessEvent? value ) { - value = (this as UnwrapWebhookEventVariants::UploadPostTransformSuccessEvent)?.Value; + value = this.Value as UploadPostTransformSuccessEvent; return value != null; } @@ -91,42 +162,42 @@ public bool TryPickUploadPostTransformError( [NotNullWhen(true)] out UploadPostTransformErrorEvent? value ) { - value = (this as UnwrapWebhookEventVariants::UploadPostTransformErrorEvent)?.Value; + value = this.Value as UploadPostTransformErrorEvent; return value != null; } public void Switch( - Action videoTransformationAccepted, - Action videoTransformationReady, - Action videoTransformationError, - Action uploadPreTransformSuccess, - Action uploadPreTransformError, - Action uploadPostTransformSuccess, - Action uploadPostTransformError + Action videoTransformationAccepted, + Action videoTransformationReady, + Action videoTransformationError, + Action uploadPreTransformSuccess, + Action uploadPreTransformError, + Action uploadPostTransformSuccess, + Action uploadPostTransformError ) { - switch (this) + switch (this.Value) { - case UnwrapWebhookEventVariants::VideoTransformationAcceptedEvent inner: - videoTransformationAccepted(inner); + case VideoTransformationAcceptedEvent value: + videoTransformationAccepted(value); break; - case UnwrapWebhookEventVariants::VideoTransformationReadyEvent inner: - videoTransformationReady(inner); + case VideoTransformationReadyEvent value: + videoTransformationReady(value); break; - case UnwrapWebhookEventVariants::VideoTransformationErrorEvent inner: - videoTransformationError(inner); + case VideoTransformationErrorEvent value: + videoTransformationError(value); break; - case UnwrapWebhookEventVariants::UploadPreTransformSuccessEvent inner: - uploadPreTransformSuccess(inner); + case UploadPreTransformSuccessEvent value: + uploadPreTransformSuccess(value); break; - case UnwrapWebhookEventVariants::UploadPreTransformErrorEvent inner: - uploadPreTransformError(inner); + case UploadPreTransformErrorEvent value: + uploadPreTransformError(value); break; - case UnwrapWebhookEventVariants::UploadPostTransformSuccessEvent inner: - uploadPostTransformSuccess(inner); + case UploadPostTransformSuccessEvent value: + uploadPostTransformSuccess(value); break; - case UnwrapWebhookEventVariants::UploadPostTransformErrorEvent inner: - uploadPostTransformError(inner); + case UploadPostTransformErrorEvent value: + uploadPostTransformError(value); break; default: throw new ImageKitInvalidDataException( @@ -136,47 +207,41 @@ public void Switch( } public T Match( - Func< - UnwrapWebhookEventVariants::VideoTransformationAcceptedEvent, - T - > videoTransformationAccepted, - Func videoTransformationReady, - Func videoTransformationError, - Func< - UnwrapWebhookEventVariants::UploadPreTransformSuccessEvent, - T - > uploadPreTransformSuccess, - Func uploadPreTransformError, - Func< - UnwrapWebhookEventVariants::UploadPostTransformSuccessEvent, - T - > uploadPostTransformSuccess, - Func uploadPostTransformError + Func videoTransformationAccepted, + Func videoTransformationReady, + Func videoTransformationError, + Func uploadPreTransformSuccess, + Func uploadPreTransformError, + Func uploadPostTransformSuccess, + Func uploadPostTransformError ) { - return this switch + return this.Value switch { - UnwrapWebhookEventVariants::VideoTransformationAcceptedEvent inner => - videoTransformationAccepted(inner), - UnwrapWebhookEventVariants::VideoTransformationReadyEvent inner => - videoTransformationReady(inner), - UnwrapWebhookEventVariants::VideoTransformationErrorEvent inner => - videoTransformationError(inner), - UnwrapWebhookEventVariants::UploadPreTransformSuccessEvent inner => - uploadPreTransformSuccess(inner), - UnwrapWebhookEventVariants::UploadPreTransformErrorEvent inner => - uploadPreTransformError(inner), - UnwrapWebhookEventVariants::UploadPostTransformSuccessEvent inner => - uploadPostTransformSuccess(inner), - UnwrapWebhookEventVariants::UploadPostTransformErrorEvent inner => - uploadPostTransformError(inner), + VideoTransformationAcceptedEvent value => videoTransformationAccepted(value), + VideoTransformationReadyEvent value => videoTransformationReady(value), + VideoTransformationErrorEvent value => videoTransformationError(value), + UploadPreTransformSuccessEvent value => uploadPreTransformSuccess(value), + UploadPreTransformErrorEvent value => uploadPreTransformError(value), + UploadPostTransformSuccessEvent value => uploadPostTransformSuccess(value), + UploadPostTransformErrorEvent value => uploadPostTransformError(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of UnwrapWebhookEvent" ), }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnwrapWebhookEvent" + ); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class UnwrapWebhookEventConverter : JsonConverter @@ -197,16 +262,15 @@ JsonSerializerOptions options ); if (deserialized != null) { - return new UnwrapWebhookEventVariants::VideoTransformationAcceptedEvent( - deserialized - ); + deserialized.Validate(); + return new UnwrapWebhookEvent(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( new ImageKitInvalidDataException( - "Data does not match union variant UnwrapWebhookEventVariants::VideoTransformationAcceptedEvent", + "Data does not match union variant 'VideoTransformationAcceptedEvent'", e ) ); @@ -220,14 +284,15 @@ JsonSerializerOptions options ); if (deserialized != null) { - return new UnwrapWebhookEventVariants::VideoTransformationReadyEvent(deserialized); + deserialized.Validate(); + return new UnwrapWebhookEvent(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( new ImageKitInvalidDataException( - "Data does not match union variant UnwrapWebhookEventVariants::VideoTransformationReadyEvent", + "Data does not match union variant 'VideoTransformationReadyEvent'", e ) ); @@ -241,14 +306,15 @@ JsonSerializerOptions options ); if (deserialized != null) { - return new UnwrapWebhookEventVariants::VideoTransformationErrorEvent(deserialized); + deserialized.Validate(); + return new UnwrapWebhookEvent(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( new ImageKitInvalidDataException( - "Data does not match union variant UnwrapWebhookEventVariants::VideoTransformationErrorEvent", + "Data does not match union variant 'VideoTransformationErrorEvent'", e ) ); @@ -262,14 +328,15 @@ JsonSerializerOptions options ); if (deserialized != null) { - return new UnwrapWebhookEventVariants::UploadPreTransformSuccessEvent(deserialized); + deserialized.Validate(); + return new UnwrapWebhookEvent(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( new ImageKitInvalidDataException( - "Data does not match union variant UnwrapWebhookEventVariants::UploadPreTransformSuccessEvent", + "Data does not match union variant 'UploadPreTransformSuccessEvent'", e ) ); @@ -283,14 +350,15 @@ JsonSerializerOptions options ); if (deserialized != null) { - return new UnwrapWebhookEventVariants::UploadPreTransformErrorEvent(deserialized); + deserialized.Validate(); + return new UnwrapWebhookEvent(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( new ImageKitInvalidDataException( - "Data does not match union variant UnwrapWebhookEventVariants::UploadPreTransformErrorEvent", + "Data does not match union variant 'UploadPreTransformErrorEvent'", e ) ); @@ -304,16 +372,15 @@ JsonSerializerOptions options ); if (deserialized != null) { - return new UnwrapWebhookEventVariants::UploadPostTransformSuccessEvent( - deserialized - ); + deserialized.Validate(); + return new UnwrapWebhookEvent(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( new ImageKitInvalidDataException( - "Data does not match union variant UnwrapWebhookEventVariants::UploadPostTransformSuccessEvent", + "Data does not match union variant 'UploadPostTransformSuccessEvent'", e ) ); @@ -327,14 +394,15 @@ JsonSerializerOptions options ); if (deserialized != null) { - return new UnwrapWebhookEventVariants::UploadPostTransformErrorEvent(deserialized); + deserialized.Validate(); + return new UnwrapWebhookEvent(deserialized); } } - catch (JsonException e) + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( new ImageKitInvalidDataException( - "Data does not match union variant UnwrapWebhookEventVariants::UploadPostTransformErrorEvent", + "Data does not match union variant 'UploadPostTransformErrorEvent'", e ) ); @@ -349,32 +417,7 @@ public override void Write( JsonSerializerOptions options ) { - object variant = value switch - { - UnwrapWebhookEventVariants::VideoTransformationAcceptedEvent( - var videoTransformationAccepted - ) => videoTransformationAccepted, - UnwrapWebhookEventVariants::VideoTransformationReadyEvent( - var videoTransformationReady - ) => videoTransformationReady, - UnwrapWebhookEventVariants::VideoTransformationErrorEvent( - var videoTransformationError - ) => videoTransformationError, - UnwrapWebhookEventVariants::UploadPreTransformSuccessEvent( - var uploadPreTransformSuccess - ) => uploadPreTransformSuccess, - UnwrapWebhookEventVariants::UploadPreTransformErrorEvent(var uploadPreTransformError) => - uploadPreTransformError, - UnwrapWebhookEventVariants::UploadPostTransformSuccessEvent( - var uploadPostTransformSuccess - ) => uploadPostTransformSuccess, - UnwrapWebhookEventVariants::UploadPostTransformErrorEvent( - var uploadPostTransformError - ) => uploadPostTransformError, - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of UnwrapWebhookEvent" - ), - }; + object variant = value.Value; JsonSerializer.Serialize(writer, variant, options); } } diff --git a/src/Imagekit/Models/Webhooks/UnwrapWebhookEventVariants/All.cs b/src/Imagekit/Models/Webhooks/UnwrapWebhookEventVariants/All.cs deleted file mode 100644 index 45c96538..00000000 --- a/src/Imagekit/Models/Webhooks/UnwrapWebhookEventVariants/All.cs +++ /dev/null @@ -1,164 +0,0 @@ -using Imagekit.Core; -using Webhooks = Imagekit.Models.Webhooks; - -namespace Imagekit.Models.Webhooks.UnwrapWebhookEventVariants; - -/// -/// Triggered when a new video transformation request is accepted for processing. -/// This event confirms that ImageKit has received and queued your transformation -/// request. Use this for debugging and tracking transformation lifecycle. -/// -public sealed record class VideoTransformationAcceptedEvent( - Webhooks::VideoTransformationAcceptedEvent Value -) - : Webhooks::UnwrapWebhookEvent, - IVariant -{ - public static VideoTransformationAcceptedEvent From( - Webhooks::VideoTransformationAcceptedEvent value - ) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -/// -/// Triggered when video encoding is finished and the transformed resource is ready -/// to be served. This is the key event to listen for - update your database or CMS -/// flags when you receive this so your application can start showing the transformed -/// video to users. -/// -public sealed record class VideoTransformationReadyEvent( - Webhooks::VideoTransformationReadyEvent Value -) - : Webhooks::UnwrapWebhookEvent, - IVariant -{ - public static VideoTransformationReadyEvent From(Webhooks::VideoTransformationReadyEvent value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -/// -/// Triggered when an error occurs during video encoding. Listen to this webhook to -/// log error reasons and debug issues. Check your origin and URL endpoint settings -/// if the reason is related to download failure. For other errors, contact ImageKit -/// support. -/// -public sealed record class VideoTransformationErrorEvent( - Webhooks::VideoTransformationErrorEvent Value -) - : Webhooks::UnwrapWebhookEvent, - IVariant -{ - public static VideoTransformationErrorEvent From(Webhooks::VideoTransformationErrorEvent value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -/// -/// Triggered when a pre-transformation completes successfully. The file has been -/// processed with the requested transformation and is now available in the Media -/// Library. -/// -public sealed record class UploadPreTransformSuccessEvent( - Webhooks::UploadPreTransformSuccessEvent Value -) - : Webhooks::UnwrapWebhookEvent, - IVariant -{ - public static UploadPreTransformSuccessEvent From( - Webhooks::UploadPreTransformSuccessEvent value - ) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -/// -/// Triggered when a pre-transformation fails. The file upload may have been accepted, -/// but the requested transformation could not be applied. -/// -public sealed record class UploadPreTransformErrorEvent( - Webhooks::UploadPreTransformErrorEvent Value -) - : Webhooks::UnwrapWebhookEvent, - IVariant -{ - public static UploadPreTransformErrorEvent From(Webhooks::UploadPreTransformErrorEvent value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -/// -/// Triggered when a post-transformation completes successfully. The transformed version -/// of the file is now ready and can be accessed via the provided URL. Note that -/// each post-transformation generates a separate webhook event. -/// -public sealed record class UploadPostTransformSuccessEvent( - Webhooks::UploadPostTransformSuccessEvent Value -) - : Webhooks::UnwrapWebhookEvent, - IVariant -{ - public static UploadPostTransformSuccessEvent From( - Webhooks::UploadPostTransformSuccessEvent value - ) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -/// -/// Triggered when a post-transformation fails. The original file remains available, -/// but the requested transformation could not be generated. -/// -public sealed record class UploadPostTransformErrorEvent( - Webhooks::UploadPostTransformErrorEvent Value -) - : Webhooks::UnwrapWebhookEvent, - IVariant -{ - public static UploadPostTransformErrorEvent From(Webhooks::UploadPostTransformErrorEvent value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1.cs index aa680196..45ad1218 100644 --- a/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1.cs +++ b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1.cs @@ -120,7 +120,7 @@ public override void Validate() public IntersectionMember1() { - this.Type = JsonSerializer.Deserialize("\"upload.post-transform.error\""); + this.Type = new(); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1.cs index ac62a61d..bc4b6ff6 100644 --- a/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1.cs +++ b/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1.cs @@ -121,7 +121,7 @@ public override void Validate() public IntersectionMember1() { - this.Type = JsonSerializer.Deserialize("\"upload.post-transform.success\""); + this.Type = new(); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/IntersectionMember1.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/IntersectionMember1.cs index 2cde87e7..05fce33e 100644 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/IntersectionMember1.cs +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/IntersectionMember1.cs @@ -120,7 +120,7 @@ public override void Validate() public IntersectionMember1() { - this.Type = JsonSerializer.Deserialize("\"upload.pre-transform.error\""); + this.Type = new(); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1.cs index 61a51ae8..98d0b3d4 100644 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1.cs +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1.cs @@ -124,7 +124,7 @@ public override void Validate() public IntersectionMember1() { - this.Type = JsonSerializer.Deserialize("\"upload.pre-transform.success\""); + this.Type = new(); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs index 749bea34..08900bf2 100644 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs @@ -4,7 +4,6 @@ using System.Text.Json.Serialization; using Imagekit.Exceptions; using Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties; -using Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueVariants; using System = System; namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; @@ -14,63 +13,84 @@ namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.Inte /// `type` of custom metadata field. /// [JsonConverter(typeof(DefaultValueConverter))] -public abstract record class DefaultValue +public record class DefaultValue { - internal DefaultValue() { } + public object Value { get; private init; } - public static implicit operator DefaultValue(string value) => new String(value); + public DefaultValue(string value) + { + Value = value; + } - public static implicit operator DefaultValue(double value) => new Double(value); + public DefaultValue(double value) + { + Value = value; + } - public static implicit operator DefaultValue(bool value) => new Bool(value); + public DefaultValue(bool value) + { + Value = value; + } - public static implicit operator DefaultValue(List value) => - new Mixed(value); + public DefaultValue(List value) + { + Value = value; + } + + DefaultValue(UnknownVariant value) + { + Value = value; + } + + public static DefaultValue CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as String)?.Value; + value = this.Value as string; return value != null; } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as Double)?.Value; + value = this.Value as double?; return value != null; } public bool TryPickBool([NotNullWhen(true)] out bool? value) { - value = (this as Bool)?.Value; + value = this.Value as bool?; return value != null; } public bool TryPickMixed([NotNullWhen(true)] out List? value) { - value = (this as Mixed)?.Value; + value = this.Value as List; return value != null; } public void Switch( - System::Action @string, - System::Action @double, - System::Action @bool, - System::Action mixed + System::Action @string, + System::Action @double, + System::Action @bool, + System::Action> mixed ) { - switch (this) + switch (this.Value) { - case String inner: - @string(inner); + case string value: + @string(value); break; - case Double inner: - @double(inner); + case double value: + @double(value); break; - case Bool inner: - @bool(inner); + case bool value: + @bool(value); break; - case Mixed inner: - mixed(inner); + case List value: + mixed(value); break; default: throw new ImageKitInvalidDataException( @@ -80,25 +100,35 @@ public void Switch( } public T Match( - System::Func @string, - System::Func @double, - System::Func @bool, - System::Func mixed + System::Func @string, + System::Func @double, + System::Func @bool, + System::Func, T> mixed ) { - return this switch + return this.Value switch { - String inner => @string(inner), - Double inner => @double(inner), - Bool inner => @bool(inner), - Mixed inner => mixed(inner), + string value => @string(value), + double value => @double(value), + bool value => @bool(value), + List value => mixed(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of DefaultValue" ), }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of DefaultValue" + ); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class DefaultValueConverter : JsonConverter @@ -116,35 +146,35 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new String(deserialized); + return new DefaultValue(deserialized); } } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant String", e) + new ImageKitInvalidDataException("Data does not match union variant 'string'", e) ); } try { - return new Double(JsonSerializer.Deserialize(ref reader, options)); + return new DefaultValue(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant Double", e) + new ImageKitInvalidDataException("Data does not match union variant 'double'", e) ); } try { - return new Bool(JsonSerializer.Deserialize(ref reader, options)); + return new DefaultValue(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant Bool", e) + new ImageKitInvalidDataException("Data does not match union variant 'bool'", e) ); } @@ -156,13 +186,16 @@ JsonSerializerOptions options ); if (deserialized != null) { - return new Mixed(deserialized); + return new DefaultValue(deserialized); } } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant Mixed", e) + new ImageKitInvalidDataException( + "Data does not match union variant 'List'", + e + ) ); } @@ -175,16 +208,7 @@ public override void Write( JsonSerializerOptions options ) { - object variant = value switch - { - String(var @string) => @string, - Double(var @double) => @double, - Bool(var @bool) => @bool, - Mixed(var mixed) => mixed, - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of DefaultValue" - ), - }; + object variant = value.Value; JsonSerializer.Serialize(writer, variant, options); } } diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent7.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent7.cs index 97000cb3..debddca6 100644 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent7.cs +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent7.cs @@ -3,58 +3,74 @@ using System.Text.Json; using System.Text.Json.Serialization; using Imagekit.Exceptions; -using Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties.UnnamedSchemaWithArrayParent7Variants; using System = System; namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties; [JsonConverter(typeof(UnnamedSchemaWithArrayParent7Converter))] -public abstract record class UnnamedSchemaWithArrayParent7 +public record class UnnamedSchemaWithArrayParent7 { - internal UnnamedSchemaWithArrayParent7() { } + public object Value { get; private init; } - public static implicit operator UnnamedSchemaWithArrayParent7(string value) => - new String(value); + public UnnamedSchemaWithArrayParent7(string value) + { + Value = value; + } - public static implicit operator UnnamedSchemaWithArrayParent7(double value) => - new Double(value); + public UnnamedSchemaWithArrayParent7(double value) + { + Value = value; + } - public static implicit operator UnnamedSchemaWithArrayParent7(bool value) => new Bool(value); + public UnnamedSchemaWithArrayParent7(bool value) + { + Value = value; + } + + UnnamedSchemaWithArrayParent7(UnknownVariant value) + { + Value = value; + } + + public static UnnamedSchemaWithArrayParent7 CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as String)?.Value; + value = this.Value as string; return value != null; } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as Double)?.Value; + value = this.Value as double?; return value != null; } public bool TryPickBool([NotNullWhen(true)] out bool? value) { - value = (this as Bool)?.Value; + value = this.Value as bool?; return value != null; } public void Switch( - System::Action @string, - System::Action @double, - System::Action @bool + System::Action @string, + System::Action @double, + System::Action @bool ) { - switch (this) + switch (this.Value) { - case String inner: - @string(inner); + case string value: + @string(value); break; - case Double inner: - @double(inner); + case double value: + @double(value); break; - case Bool inner: - @bool(inner); + case bool value: + @bool(value); break; default: throw new ImageKitInvalidDataException( @@ -64,23 +80,33 @@ public void Switch( } public T Match( - System::Func @string, - System::Func @double, - System::Func @bool + System::Func @string, + System::Func @double, + System::Func @bool ) { - return this switch + return this.Value switch { - String inner => @string(inner), - Double inner => @double(inner), - Bool inner => @bool(inner), + string value => @string(value), + double value => @double(value), + bool value => @bool(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of UnnamedSchemaWithArrayParent7" ), }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent7" + ); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class UnnamedSchemaWithArrayParent7Converter : JsonConverter @@ -98,35 +124,39 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new String(deserialized); + return new UnnamedSchemaWithArrayParent7(deserialized); } } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant String", e) + new ImageKitInvalidDataException("Data does not match union variant 'string'", e) ); } try { - return new Double(JsonSerializer.Deserialize(ref reader, options)); + return new UnnamedSchemaWithArrayParent7( + JsonSerializer.Deserialize(ref reader, options) + ); } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant Double", e) + new ImageKitInvalidDataException("Data does not match union variant 'double'", e) ); } try { - return new Bool(JsonSerializer.Deserialize(ref reader, options)); + return new UnnamedSchemaWithArrayParent7( + JsonSerializer.Deserialize(ref reader, options) + ); } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant Bool", e) + new ImageKitInvalidDataException("Data does not match union variant 'bool'", e) ); } @@ -139,15 +169,7 @@ public override void Write( JsonSerializerOptions options ) { - object variant = value switch - { - String(var @string) => @string, - Double(var @double) => @double, - Bool(var @bool) => @bool, - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent7" - ), - }; + object variant = value.Value; JsonSerializer.Serialize(writer, variant, options); } } diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent7Variants/All.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent7Variants/All.cs deleted file mode 100644 index ba9221b3..00000000 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent7Variants/All.cs +++ /dev/null @@ -1,37 +0,0 @@ -using Imagekit.Core; - -namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties.UnnamedSchemaWithArrayParent7Variants; - -public sealed record class String(string Value) - : UnnamedSchemaWithArrayParent7, - IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Double(double Value) - : UnnamedSchemaWithArrayParent7, - IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Bool(bool Value) : UnnamedSchemaWithArrayParent7, IVariant -{ - public static Bool From(bool value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs deleted file mode 100644 index 616f3f51..00000000 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueVariants/All.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System.Collections.Generic; -using Imagekit.Core; -using Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties; - -namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueVariants; - -public sealed record class String(string Value) : DefaultValue, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Double(double Value) : DefaultValue, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Bool(bool Value) : DefaultValue, IVariant -{ - public static Bool From(bool value) - { - return new(value); - } - - public override void Validate() { } -} - -/// -/// Default value should be of type array when custom metadata field type is set to -/// `MultiSelect`. -/// -public sealed record class Mixed(List Value) - : DefaultValue, - IVariant> -{ - public static Mixed From(List value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs index f5d6db94..aecab449 100644 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs @@ -3,7 +3,6 @@ using System.Text.Json; using System.Text.Json.Serialization; using Imagekit.Exceptions; -using Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MaxValueVariants; using System = System; namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; @@ -14,35 +13,51 @@ namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.Inte /// field, it will be a numeric value. /// [JsonConverter(typeof(MaxValueConverter))] -public abstract record class MaxValue +public record class MaxValue { - internal MaxValue() { } + public object Value { get; private init; } - public static implicit operator MaxValue(string value) => new String(value); + public MaxValue(string value) + { + Value = value; + } + + public MaxValue(double value) + { + Value = value; + } - public static implicit operator MaxValue(double value) => new Double(value); + MaxValue(UnknownVariant value) + { + Value = value; + } + + public static MaxValue CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as String)?.Value; + value = this.Value as string; return value != null; } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as Double)?.Value; + value = this.Value as double?; return value != null; } - public void Switch(System::Action @string, System::Action @double) + public void Switch(System::Action @string, System::Action @double) { - switch (this) + switch (this.Value) { - case String inner: - @string(inner); + case string value: + @string(value); break; - case Double inner: - @double(inner); + case double value: + @double(value); break; default: throw new ImageKitInvalidDataException( @@ -51,19 +66,27 @@ public void Switch(System::Action @string, System::Action @doubl } } - public T Match(System::Func @string, System::Func @double) + public T Match(System::Func @string, System::Func @double) { - return this switch + return this.Value switch { - String inner => @string(inner), - Double inner => @double(inner), + string value => @string(value), + double value => @double(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of MaxValue" ), }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException("Data did not match any variant of MaxValue"); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class MaxValueConverter : JsonConverter @@ -81,24 +104,24 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new String(deserialized); + return new MaxValue(deserialized); } } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant String", e) + new ImageKitInvalidDataException("Data does not match union variant 'string'", e) ); } try { - return new Double(JsonSerializer.Deserialize(ref reader, options)); + return new MaxValue(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant Double", e) + new ImageKitInvalidDataException("Data does not match union variant 'double'", e) ); } @@ -107,14 +130,7 @@ JsonSerializerOptions options public override void Write(Utf8JsonWriter writer, MaxValue value, JsonSerializerOptions options) { - object variant = value switch - { - String(var @string) => @string, - Double(var @double) => @double, - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of MaxValue" - ), - }; + object variant = value.Value; JsonSerializer.Serialize(writer, variant, options); } } diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs deleted file mode 100644 index 109edfee..00000000 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValueVariants/All.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Imagekit.Core; - -namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MaxValueVariants; - -public sealed record class String(string Value) : MaxValue, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Double(double Value) : MaxValue, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs index 98c63ae3..a80050fe 100644 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs @@ -3,7 +3,6 @@ using System.Text.Json; using System.Text.Json.Serialization; using Imagekit.Exceptions; -using Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MinValueVariants; using System = System; namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; @@ -14,35 +13,51 @@ namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.Inte /// field, it will be a numeric value. /// [JsonConverter(typeof(MinValueConverter))] -public abstract record class MinValue +public record class MinValue { - internal MinValue() { } + public object Value { get; private init; } - public static implicit operator MinValue(string value) => new String(value); + public MinValue(string value) + { + Value = value; + } + + public MinValue(double value) + { + Value = value; + } - public static implicit operator MinValue(double value) => new Double(value); + MinValue(UnknownVariant value) + { + Value = value; + } + + public static MinValue CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as String)?.Value; + value = this.Value as string; return value != null; } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as Double)?.Value; + value = this.Value as double?; return value != null; } - public void Switch(System::Action @string, System::Action @double) + public void Switch(System::Action @string, System::Action @double) { - switch (this) + switch (this.Value) { - case String inner: - @string(inner); + case string value: + @string(value); break; - case Double inner: - @double(inner); + case double value: + @double(value); break; default: throw new ImageKitInvalidDataException( @@ -51,19 +66,27 @@ public void Switch(System::Action @string, System::Action @doubl } } - public T Match(System::Func @string, System::Func @double) + public T Match(System::Func @string, System::Func @double) { - return this switch + return this.Value switch { - String inner => @string(inner), - Double inner => @double(inner), + string value => @string(value), + double value => @double(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of MinValue" ), }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException("Data did not match any variant of MinValue"); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class MinValueConverter : JsonConverter @@ -81,24 +104,24 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new String(deserialized); + return new MinValue(deserialized); } } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant String", e) + new ImageKitInvalidDataException("Data does not match union variant 'string'", e) ); } try { - return new Double(JsonSerializer.Deserialize(ref reader, options)); + return new MinValue(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant Double", e) + new ImageKitInvalidDataException("Data does not match union variant 'double'", e) ); } @@ -107,14 +130,7 @@ JsonSerializerOptions options public override void Write(Utf8JsonWriter writer, MinValue value, JsonSerializerOptions options) { - object variant = value switch - { - String(var @string) => @string, - Double(var @double) => @double, - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of MinValue" - ), - }; + object variant = value.Value; JsonSerializer.Serialize(writer, variant, options); } } diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs deleted file mode 100644 index 6aed2033..00000000 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValueVariants/All.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Imagekit.Core; - -namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.MinValueVariants; - -public sealed record class String(string Value) : MinValue, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Double(double Value) : MinValue, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs index e84f0625..25c141ca 100644 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs @@ -3,56 +3,74 @@ using System.Text.Json; using System.Text.Json.Serialization; using Imagekit.Exceptions; -using Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.SelectOptionVariants; using System = System; namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; [JsonConverter(typeof(SelectOptionConverter))] -public abstract record class SelectOption +public record class SelectOption { - internal SelectOption() { } + public object Value { get; private init; } - public static implicit operator SelectOption(string value) => new String(value); + public SelectOption(string value) + { + Value = value; + } + + public SelectOption(double value) + { + Value = value; + } + + public SelectOption(bool value) + { + Value = value; + } - public static implicit operator SelectOption(double value) => new Double(value); + SelectOption(UnknownVariant value) + { + Value = value; + } - public static implicit operator SelectOption(bool value) => new Bool(value); + public static SelectOption CreateUnknownVariant(JsonElement value) + { + return new(new UnknownVariant(value)); + } public bool TryPickString([NotNullWhen(true)] out string? value) { - value = (this as String)?.Value; + value = this.Value as string; return value != null; } public bool TryPickDouble([NotNullWhen(true)] out double? value) { - value = (this as Double)?.Value; + value = this.Value as double?; return value != null; } public bool TryPickBool([NotNullWhen(true)] out bool? value) { - value = (this as Bool)?.Value; + value = this.Value as bool?; return value != null; } public void Switch( - System::Action @string, - System::Action @double, - System::Action @bool + System::Action @string, + System::Action @double, + System::Action @bool ) { - switch (this) + switch (this.Value) { - case String inner: - @string(inner); + case string value: + @string(value); break; - case Double inner: - @double(inner); + case double value: + @double(value); break; - case Bool inner: - @bool(inner); + case bool value: + @bool(value); break; default: throw new ImageKitInvalidDataException( @@ -62,23 +80,33 @@ public void Switch( } public T Match( - System::Func @string, - System::Func @double, - System::Func @bool + System::Func @string, + System::Func @double, + System::Func @bool ) { - return this switch + return this.Value switch { - String inner => @string(inner), - Double inner => @double(inner), - Bool inner => @bool(inner), + string value => @string(value), + double value => @double(value), + bool value => @bool(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of SelectOption" ), }; } - public abstract void Validate(); + public void Validate() + { + if (this.Value is not UnknownVariant) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of SelectOption" + ); + } + } + + private record struct UnknownVariant(JsonElement value); } sealed class SelectOptionConverter : JsonConverter @@ -96,35 +124,35 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(ref reader, options); if (deserialized != null) { - return new String(deserialized); + return new SelectOption(deserialized); } } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant String", e) + new ImageKitInvalidDataException("Data does not match union variant 'string'", e) ); } try { - return new Double(JsonSerializer.Deserialize(ref reader, options)); + return new SelectOption(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant Double", e) + new ImageKitInvalidDataException("Data does not match union variant 'double'", e) ); } try { - return new Bool(JsonSerializer.Deserialize(ref reader, options)); + return new SelectOption(JsonSerializer.Deserialize(ref reader, options)); } - catch (JsonException e) + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) { exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant Bool", e) + new ImageKitInvalidDataException("Data does not match union variant 'bool'", e) ); } @@ -137,15 +165,7 @@ public override void Write( JsonSerializerOptions options ) { - object variant = value switch - { - String(var @string) => @string, - Double(var @double) => @double, - Bool(var @bool) => @bool, - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of SelectOption" - ), - }; + object variant = value.Value; JsonSerializer.Serialize(writer, variant, options); } } diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs deleted file mode 100644 index fdc17863..00000000 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOptionVariants/All.cs +++ /dev/null @@ -1,33 +0,0 @@ -using Imagekit.Core; - -namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.SelectOptionVariants; - -public sealed record class String(string Value) : SelectOption, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Double(double Value) : SelectOption, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Bool(bool Value) : SelectOption, IVariant -{ - public static Bool From(bool value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1.cs b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1.cs index af53cd9d..1057f993 100644 --- a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1.cs +++ b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1.cs @@ -124,7 +124,7 @@ public override void Validate() public IntersectionMember1() { - this.Type = JsonSerializer.Deserialize("\"video.transformation.accepted\""); + this.Type = new(); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1.cs index 778dcbed..207e423b 100644 --- a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1.cs +++ b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1.cs @@ -125,7 +125,7 @@ public override void Validate() public IntersectionMember1() { - this.Type = JsonSerializer.Deserialize("\"video.transformation.error\""); + this.Type = new(); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1.cs index 263c0fc8..4f1c36d1 100644 --- a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1.cs +++ b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1.cs @@ -147,7 +147,7 @@ public override void Validate() public IntersectionMember1() { - this.Type = JsonSerializer.Deserialize("\"video.transformation.ready\""); + this.Type = new(); } #pragma warning disable CS8618 From 824969b0ce6f8e1fb89b055f56dfe4ccc2c356dd Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 9 Oct 2025 16:46:43 +0000 Subject: [PATCH 050/129] chore(internal): codegen related update --- src/Imagekit.Tests/Services/Files/FileServiceTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Imagekit.Tests/Services/Files/FileServiceTest.cs b/src/Imagekit.Tests/Services/Files/FileServiceTest.cs index 106a1cc3..ac839c40 100644 --- a/src/Imagekit.Tests/Services/Files/FileServiceTest.cs +++ b/src/Imagekit.Tests/Services/Files/FileServiceTest.cs @@ -58,7 +58,7 @@ public async Task Update_Works() ), new(new()), ], - RemoveAITags = new(new List() { "car", "vehicle", "motorsports" }), + RemoveAITags = new(["car", "vehicle", "motorsports"]), Tags = ["tag1", "tag2"], WebhookURL = "https://webhook.site/0d6b6c7a-8e5a-4b3a-8b7c-0d6b6c7a8e5a", } From 490b9336d427b06dbd912e11af1538c067766f06 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 21 Oct 2025 09:46:07 +0000 Subject: [PATCH 051/129] feat(api): add GetImageAttributesOptions and ResponsiveImageAttributes schemas; update resource references in main.yaml; remove dummy endpoint --- .stats.yml | 6 +- .../Models/GetImageAttributesOptions.cs | 378 ++++++++++++++++++ .../IntersectionMember1.cs | 144 +++++++ .../Models/ResponsiveImageAttributes.cs | 144 +++++++ 4 files changed, 669 insertions(+), 3 deletions(-) create mode 100644 src/Imagekit/Models/GetImageAttributesOptions.cs create mode 100644 src/Imagekit/Models/GetImageAttributesOptionsProperties/IntersectionMember1.cs create mode 100644 src/Imagekit/Models/ResponsiveImageAttributes.cs diff --git a/.stats.yml b/.stats.yml index f035d349..27ad9e7e 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-c7ad6f552b38f2145781847f8b390fa1ec43068d64e45a33012a97a9299edc10.yml -openapi_spec_hash: 50f281e91210ad5018ac7e4eee216f56 -config_hash: 74a8263b80c732a2b016177e7d56bb9c +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-0e4fa3c1f9d8cafecb9671fa76c0ff9156c643e05837804679e5e336bad8f4c1.yml +openapi_spec_hash: 4544b950730b721c252eb519358b8609 +config_hash: 3d7a0bc2844e9fb4797149b233e85770 diff --git a/src/Imagekit/Models/GetImageAttributesOptions.cs b/src/Imagekit/Models/GetImageAttributesOptions.cs new file mode 100644 index 00000000..c9679f8f --- /dev/null +++ b/src/Imagekit/Models/GetImageAttributesOptions.cs @@ -0,0 +1,378 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Core; +using Imagekit.Exceptions; + +namespace Imagekit.Models; + +/// +/// Options for generating responsive image attributes including `src`, `srcSet`, +/// and `sizes` for HTML `` elements. This schema extends `SrcOptions` to add +/// support for responsive image generation with breakpoints. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class GetImageAttributesOptions + : ModelBase, + IFromRaw +{ + /// + /// Accepts a relative or absolute path of the resource. If a relative path is + /// provided, it is appended to the `urlEndpoint`. If an absolute path is provided, + /// `urlEndpoint` is ignored. + /// + public required string Src + { + get + { + if (!this.Properties.TryGetValue("src", out JsonElement element)) + throw new ImageKitInvalidDataException( + "'src' cannot be null", + new ArgumentOutOfRangeException("src", "Missing required argument") + ); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ImageKitInvalidDataException( + "'src' cannot be null", + new ArgumentNullException("src") + ); + } + set + { + this.Properties["src"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Get your urlEndpoint from the [ImageKit dashboard](https://imagekit.io/dashboard/url-endpoints). + /// + public required string URLEndpoint + { + get + { + if (!this.Properties.TryGetValue("urlEndpoint", out JsonElement element)) + throw new ImageKitInvalidDataException( + "'urlEndpoint' cannot be null", + new ArgumentOutOfRangeException("urlEndpoint", "Missing required argument") + ); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ImageKitInvalidDataException( + "'urlEndpoint' cannot be null", + new ArgumentNullException("urlEndpoint") + ); + } + set + { + this.Properties["urlEndpoint"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// When you want the signed URL to expire, specified in seconds. If `expiresIn` + /// is anything above 0, the URL will always be signed even if `signed` is set + /// to false. If not specified and `signed` is `true`, the signed URL will not + /// expire (valid indefinitely). + /// + /// Example: Setting `expiresIn: 3600` will make the URL expire 1 hour from generation + /// time. After the expiry time, the signed URL will no longer be valid and ImageKit + /// will return a 401 Unauthorized status code. + /// + /// [Learn more](https://imagekit.io/docs/media-delivery-basic-security#how-to-generate-signed-urls). + /// + public double? ExpiresIn + { + get + { + if (!this.Properties.TryGetValue("expiresIn", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["expiresIn"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// These are additional query parameters that you want to add to the final URL. + /// They can be any query parameters and not necessarily related to ImageKit. + /// This is especially useful if you want to add a versioning parameter to your + /// URLs. + /// + public Dictionary? QueryParameters + { + get + { + if (!this.Properties.TryGetValue("queryParameters", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["queryParameters"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to sign the URL or not. Set this to `true` if you want to generate + /// a signed URL. If `signed` is `true` and `expiresIn` is not specified, the + /// signed URL will not expire (valid indefinitely). Note: If `expiresIn` is set + /// to any value above 0, the URL will always be signed regardless of this setting. + /// [Learn more](https://imagekit.io/docs/media-delivery-basic-security#how-to-generate-signed-urls). + /// + public bool? Signed + { + get + { + if (!this.Properties.TryGetValue("signed", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["signed"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// An array of objects specifying the transformations to be applied in the URL. + /// If more than one transformation is specified, they are applied in the order + /// they are specified as chained transformations. See [Chained transformations](https://imagekit.io/docs/transformations#chained-transformations). + /// + public List? Transformation + { + get + { + if (!this.Properties.TryGetValue("transformation", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["transformation"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// By default, the transformation string is added as a query parameter in the + /// URL, e.g., `?tr=w-100,h-100`. If you want to add the transformation string + /// in the path of the URL, set this to `path`. Learn more in the [Transformations + /// guide](https://imagekit.io/docs/transformations). + /// + public ApiEnum? TransformationPosition + { + get + { + if (!this.Properties.TryGetValue("transformationPosition", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["transformationPosition"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Custom list of **device-width breakpoints** in pixels. These define common + /// screen widths for responsive image generation. + /// + /// Defaults to `[640, 750, 828, 1080, 1200, 1920, 2048, 3840]`. Sorted automatically. + /// + public List? DeviceBreakpoints + { + get + { + if (!this.Properties.TryGetValue("deviceBreakpoints", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["deviceBreakpoints"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Custom list of **image-specific breakpoints** in pixels. Useful for generating + /// small variants (e.g., placeholders or thumbnails). + /// + /// Merged with `deviceBreakpoints` before calculating `srcSet`. Defaults to `[16, + /// 32, 48, 64, 96, 128, 256, 384]`. Sorted automatically. + /// + public List? ImageBreakpoints + { + get + { + if (!this.Properties.TryGetValue("imageBreakpoints", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["imageBreakpoints"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The value for the HTML `sizes` attribute (e.g., `"100vw"` or `"(min-width:768px) + /// 50vw, 100vw"`). + /// + /// - If it includes one or more `vw` units, breakpoints smaller than the corresponding + /// percentage of the smallest device width are excluded. - If it contains no + /// `vw` units, the full breakpoint list is used. + /// + /// Enables a width-based strategy and generates `w` descriptors in `srcSet`. + /// + public string? Sizes + { + get + { + if (!this.Properties.TryGetValue("sizes", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["sizes"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The intended display width of the image in pixels, used **only when the + /// `sizes` attribute is not provided**. + /// + /// Triggers a DPR-based strategy (1x and 2x variants) and generates `x` descriptors + /// in `srcSet`. + /// + /// Ignored if `sizes` is present. + /// + public double? Width + { + get + { + if (!this.Properties.TryGetValue("width", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["width"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public static implicit operator SrcOptions( + GetImageAttributesOptions getImageAttributesOptions + ) => + new() + { + Src = getImageAttributesOptions.Src, + URLEndpoint = getImageAttributesOptions.URLEndpoint, + ExpiresIn = getImageAttributesOptions.ExpiresIn, + QueryParameters = getImageAttributesOptions.QueryParameters, + Signed = getImageAttributesOptions.Signed, + Transformation = getImageAttributesOptions.Transformation, + TransformationPosition = getImageAttributesOptions.TransformationPosition, + }; + + public override void Validate() + { + _ = this.Src; + _ = this.URLEndpoint; + _ = this.ExpiresIn; + if (this.QueryParameters != null) + { + foreach (var item in this.QueryParameters.Values) + { + _ = item; + } + } + _ = this.Signed; + foreach (var item in this.Transformation ?? []) + { + item.Validate(); + } + this.TransformationPosition?.Validate(); + foreach (var item in this.DeviceBreakpoints ?? []) + { + _ = item; + } + foreach (var item in this.ImageBreakpoints ?? []) + { + _ = item; + } + _ = this.Sizes; + _ = this.Width; + } + + public GetImageAttributesOptions() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GetImageAttributesOptions(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static GetImageAttributesOptions FromRawUnchecked( + Dictionary properties + ) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/GetImageAttributesOptionsProperties/IntersectionMember1.cs b/src/Imagekit/Models/GetImageAttributesOptionsProperties/IntersectionMember1.cs new file mode 100644 index 00000000..98303fce --- /dev/null +++ b/src/Imagekit/Models/GetImageAttributesOptionsProperties/IntersectionMember1.cs @@ -0,0 +1,144 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Core; + +namespace Imagekit.Models.GetImageAttributesOptionsProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class IntersectionMember1 : ModelBase, IFromRaw +{ + /// + /// Custom list of **device-width breakpoints** in pixels. These define common + /// screen widths for responsive image generation. + /// + /// Defaults to `[640, 750, 828, 1080, 1200, 1920, 2048, 3840]`. Sorted automatically. + /// + public List? DeviceBreakpoints + { + get + { + if (!this.Properties.TryGetValue("deviceBreakpoints", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["deviceBreakpoints"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Custom list of **image-specific breakpoints** in pixels. Useful for generating + /// small variants (e.g., placeholders or thumbnails). + /// + /// Merged with `deviceBreakpoints` before calculating `srcSet`. Defaults to `[16, + /// 32, 48, 64, 96, 128, 256, 384]`. Sorted automatically. + /// + public List? ImageBreakpoints + { + get + { + if (!this.Properties.TryGetValue("imageBreakpoints", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["imageBreakpoints"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The value for the HTML `sizes` attribute (e.g., `"100vw"` or `"(min-width:768px) + /// 50vw, 100vw"`). + /// + /// - If it includes one or more `vw` units, breakpoints smaller than the corresponding + /// percentage of the smallest device width are excluded. - If it contains no + /// `vw` units, the full breakpoint list is used. + /// + /// Enables a width-based strategy and generates `w` descriptors in `srcSet`. + /// + public string? Sizes + { + get + { + if (!this.Properties.TryGetValue("sizes", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["sizes"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The intended display width of the image in pixels, used **only when the + /// `sizes` attribute is not provided**. + /// + /// Triggers a DPR-based strategy (1x and 2x variants) and generates `x` descriptors + /// in `srcSet`. + /// + /// Ignored if `sizes` is present. + /// + public double? Width + { + get + { + if (!this.Properties.TryGetValue("width", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["width"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + foreach (var item in this.DeviceBreakpoints ?? []) + { + _ = item; + } + foreach (var item in this.ImageBreakpoints ?? []) + { + _ = item; + } + _ = this.Sizes; + _ = this.Width; + } + + public IntersectionMember1() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + IntersectionMember1(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static IntersectionMember1 FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/ResponsiveImageAttributes.cs b/src/Imagekit/Models/ResponsiveImageAttributes.cs new file mode 100644 index 00000000..c368c569 --- /dev/null +++ b/src/Imagekit/Models/ResponsiveImageAttributes.cs @@ -0,0 +1,144 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Core; +using Imagekit.Exceptions; + +namespace Imagekit.Models; + +/// +/// Resulting set of attributes suitable for an HTML `` element. Useful for enabling +/// responsive image loading with `srcSet` and `sizes`. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class ResponsiveImageAttributes + : ModelBase, + IFromRaw +{ + /// + /// URL for the *largest* candidate (assigned to plain `src`). + /// + public required string Src + { + get + { + if (!this.Properties.TryGetValue("src", out JsonElement element)) + throw new ImageKitInvalidDataException( + "'src' cannot be null", + new ArgumentOutOfRangeException("src", "Missing required argument") + ); + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ImageKitInvalidDataException( + "'src' cannot be null", + new ArgumentNullException("src") + ); + } + set + { + this.Properties["src"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// `sizes` returned (or synthesised as `100vw`). The value for the HTML `sizes` + /// attribute. + /// + public string? Sizes + { + get + { + if (!this.Properties.TryGetValue("sizes", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["sizes"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Candidate set with `w` or `x` descriptors. Multiple image URLs separated + /// by commas, each with a descriptor. + /// + public string? SrcSet + { + get + { + if (!this.Properties.TryGetValue("srcSet", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["srcSet"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Width as a number (if `width` was provided in the input options). + /// + public double? Width + { + get + { + if (!this.Properties.TryGetValue("width", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["width"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.Src; + _ = this.Sizes; + _ = this.SrcSet; + _ = this.Width; + } + + public ResponsiveImageAttributes() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ResponsiveImageAttributes(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static ResponsiveImageAttributes FromRawUnchecked( + Dictionary properties + ) + { + return new(properties); + } + + [SetsRequiredMembers] + public ResponsiveImageAttributes(string src) + : this() + { + this.Src = src; + } +} From b5d84bc7d83bc24ccb340b0751a792b742c10a1c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 21 Oct 2025 10:14:17 +0000 Subject: [PATCH 052/129] codegen metadata --- .stats.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.stats.yml b/.stats.yml index 27ad9e7e..e27f9d4f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-0e4fa3c1f9d8cafecb9671fa76c0ff9156c643e05837804679e5e336bad8f4c1.yml -openapi_spec_hash: 4544b950730b721c252eb519358b8609 -config_hash: 3d7a0bc2844e9fb4797149b233e85770 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-9d184cb502ab32a85db2889c796cdfebe812f2a55a604df79c85dd4b5e7e2add.yml +openapi_spec_hash: a9aa620376fce66532c84f9364209b0b +config_hash: bb7229ef61cee50cd6c1ac02a5a74e81 From 8a550353bea0544017cdcd3ca28b07e72fb82f71 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 27 Oct 2025 19:07:27 +0000 Subject: [PATCH 053/129] fix(internal): minor bug fixes on model instantiation and union validation --- src/Imagekit/Models/Accounts/Origins/OriginRequest.cs | 2 +- src/Imagekit/Models/Accounts/Origins/OriginResponse.cs | 2 +- .../URLEndpointCreateParamsProperties/URLRewriter.cs | 2 +- .../URLEndpoints/URLEndpointRequestProperties/URLRewriter.cs | 2 +- .../URLEndpoints/URLEndpointResponseProperties/URLRewriter.cs | 2 +- .../URLEndpointUpdateParamsProperties/URLRewriter.cs | 2 +- src/Imagekit/Models/Assets/AssetListResponse.cs | 2 +- .../FileUploadParamsProperties/TransformationProperties/Post.cs | 2 +- .../SelectedFieldsSchemaItemProperties/DefaultValue.cs | 2 +- .../DefaultValueProperties/UnnamedSchemaWithArrayParent6.cs | 2 +- .../SelectedFieldsSchemaItemProperties/MaxValue.cs | 2 +- .../SelectedFieldsSchemaItemProperties/MinValue.cs | 2 +- .../SelectedFieldsSchemaItemProperties/SelectOption.cs | 2 +- .../SchemaProperties/DefaultValue.cs | 2 +- .../DefaultValueProperties/UnnamedSchemaWithArrayParent2.cs | 2 +- .../SchemaProperties/MaxValue.cs | 2 +- .../SchemaProperties/MinValue.cs | 2 +- .../SchemaProperties/SelectOption.cs | 2 +- .../SchemaProperties/DefaultValue.cs | 2 +- .../DefaultValueProperties/UnnamedSchemaWithArrayParent1.cs | 2 +- .../CustomMetadataFieldProperties/SchemaProperties/MaxValue.cs | 2 +- .../CustomMetadataFieldProperties/SchemaProperties/MinValue.cs | 2 +- .../SchemaProperties/SelectOption.cs | 2 +- .../SchemaProperties/DefaultValue.cs | 2 +- .../DefaultValueProperties/UnnamedSchemaWithArrayParent3.cs | 2 +- .../SchemaProperties/MaxValue.cs | 2 +- .../SchemaProperties/MinValue.cs | 2 +- .../SchemaProperties/SelectOption.cs | 2 +- .../SelectedFieldsSchemaItemProperties/DefaultValue.cs | 2 +- .../DefaultValueProperties/UnnamedSchemaWithArrayParent4.cs | 2 +- .../SelectedFieldsSchemaItemProperties/MaxValue.cs | 2 +- .../SelectedFieldsSchemaItemProperties/MinValue.cs | 2 +- .../SelectedFieldsSchemaItemProperties/SelectOption.cs | 2 +- .../FileUploadParamsProperties/TransformationProperties/Post.cs | 2 +- .../SelectedFieldsSchemaItemProperties/DefaultValue.cs | 2 +- .../DefaultValueProperties/UnnamedSchemaWithArrayParent5.cs | 2 +- .../SelectedFieldsSchemaItemProperties/MaxValue.cs | 2 +- .../SelectedFieldsSchemaItemProperties/MinValue.cs | 2 +- .../SelectedFieldsSchemaItemProperties/SelectOption.cs | 2 +- src/Imagekit/Models/Files/UpdateFileRequest.cs | 2 +- .../UpdateFileDetailsProperties/RemoveAITags.cs | 2 +- src/Imagekit/Models/ImageOverlay.cs | 2 +- .../Models/ImageOverlayProperties/IntersectionMember1.cs | 2 +- src/Imagekit/Models/Overlay.cs | 2 +- src/Imagekit/Models/OverlayPositionProperties/X.cs | 2 +- src/Imagekit/Models/OverlayPositionProperties/Y.cs | 2 +- src/Imagekit/Models/OverlayTimingProperties/Duration.cs | 2 +- src/Imagekit/Models/OverlayTimingProperties/End.cs | 2 +- src/Imagekit/Models/OverlayTimingProperties/Start.cs | 2 +- src/Imagekit/Models/SolidColorOverlay.cs | 2 +- .../Models/SolidColorOverlayProperties/IntersectionMember1.cs | 2 +- .../SolidColorOverlayTransformationProperties/Gradient.cs | 2 +- .../Models/SolidColorOverlayTransformationProperties/Height.cs | 2 +- .../Models/SolidColorOverlayTransformationProperties/Radius.cs | 2 +- .../Models/SolidColorOverlayTransformationProperties/Width.cs | 2 +- src/Imagekit/Models/SubtitleOverlay.cs | 2 +- .../Models/SubtitleOverlayProperties/IntersectionMember1.cs | 2 +- src/Imagekit/Models/TextOverlay.cs | 2 +- .../Models/TextOverlayProperties/IntersectionMember1.cs | 2 +- .../Models/TextOverlayTransformationProperties/FontSize.cs | 2 +- .../Models/TextOverlayTransformationProperties/LineHeight.cs | 2 +- .../Models/TextOverlayTransformationProperties/Padding.cs | 2 +- .../Models/TextOverlayTransformationProperties/Radius.cs | 2 +- .../Models/TextOverlayTransformationProperties/Rotation.cs | 2 +- .../Models/TextOverlayTransformationProperties/Width.cs | 2 +- src/Imagekit/Models/TransformationProperties/AIDropShadow.cs | 2 +- src/Imagekit/Models/TransformationProperties/AspectRatio.cs | 2 +- src/Imagekit/Models/TransformationProperties/Duration.cs | 2 +- src/Imagekit/Models/TransformationProperties/EndOffset.cs | 2 +- src/Imagekit/Models/TransformationProperties/Gradient.cs | 2 +- src/Imagekit/Models/TransformationProperties/Height.cs | 2 +- src/Imagekit/Models/TransformationProperties/Page.cs | 2 +- src/Imagekit/Models/TransformationProperties/Radius.cs | 2 +- src/Imagekit/Models/TransformationProperties/Rotation.cs | 2 +- src/Imagekit/Models/TransformationProperties/Shadow.cs | 2 +- src/Imagekit/Models/TransformationProperties/Sharpen.cs | 2 +- src/Imagekit/Models/TransformationProperties/StartOffset.cs | 2 +- src/Imagekit/Models/TransformationProperties/Trim.cs | 2 +- src/Imagekit/Models/TransformationProperties/UnsharpMask.cs | 2 +- src/Imagekit/Models/TransformationProperties/Width.cs | 2 +- src/Imagekit/Models/TransformationProperties/X.cs | 2 +- src/Imagekit/Models/TransformationProperties/XCenter.cs | 2 +- src/Imagekit/Models/TransformationProperties/Y.cs | 2 +- src/Imagekit/Models/TransformationProperties/YCenter.cs | 2 +- src/Imagekit/Models/UnnamedSchemaWithArrayParent0.cs | 2 +- src/Imagekit/Models/VideoOverlay.cs | 2 +- .../Models/VideoOverlayProperties/IntersectionMember1.cs | 2 +- src/Imagekit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs | 2 +- src/Imagekit/Models/Webhooks/UnwrapWebhookEvent.cs | 2 +- .../IntersectionMember1.cs | 2 +- .../IntersectionMember1.cs | 2 +- .../IntersectionMember1.cs | 2 +- .../IntersectionMember1.cs | 2 +- .../SelectedFieldsSchemaItemProperties/DefaultValue.cs | 2 +- .../DefaultValueProperties/UnnamedSchemaWithArrayParent7.cs | 2 +- .../SelectedFieldsSchemaItemProperties/MaxValue.cs | 2 +- .../SelectedFieldsSchemaItemProperties/MinValue.cs | 2 +- .../SelectedFieldsSchemaItemProperties/SelectOption.cs | 2 +- .../IntersectionMember1.cs | 2 +- .../IntersectionMember1.cs | 2 +- .../IntersectionMember1.cs | 2 +- 101 files changed, 101 insertions(+), 101 deletions(-) diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequest.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequest.cs index 2fe383a5..9ca8b0ef 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginRequest.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginRequest.cs @@ -318,7 +318,7 @@ Func akeneoPim public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException( "Data did not match any variant of OriginRequest" diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponse.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponse.cs index b042f46a..bbc447bc 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginResponse.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginResponse.cs @@ -301,7 +301,7 @@ Func akeneoPim public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException( "Data did not match any variant of OriginResponse" diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriter.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriter.cs index 9dad57b5..faf16996 100644 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriter.cs +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriter.cs @@ -89,7 +89,7 @@ public T Match(Func cloudinary, Func imgix, Func(Func cloudinary, Func imgix, Func(Func cloudinary, Func imgix, Func(Func cloudinary, Func imgix, Func(Func file, Func folder) public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException( "Data did not match any variant of AssetListResponse" diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/Post.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/Post.cs index 0ed859e6..98e17804 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/Post.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/Post.cs @@ -124,7 +124,7 @@ public T Match( public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException("Data did not match any variant of Post"); } diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs index fc1fc3cd..2f6b8e4d 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs @@ -120,7 +120,7 @@ public T Match( public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException( "Data did not match any variant of DefaultValue" diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent6.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent6.cs index e5e94bbe..f40dda0b 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent6.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent6.cs @@ -98,7 +98,7 @@ public T Match( public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException( "Data did not match any variant of UnnamedSchemaWithArrayParent6" diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs index a284b25f..a065b234 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs @@ -80,7 +80,7 @@ public T Match(System::Func @string, System::Func @doub public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException("Data did not match any variant of MaxValue"); } diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs index cd83f46b..0d299ad3 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs @@ -80,7 +80,7 @@ public T Match(System::Func @string, System::Func @doub public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException("Data did not match any variant of MinValue"); } diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs index 3136c82c..6bb4e82b 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs @@ -98,7 +98,7 @@ public T Match( public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException( "Data did not match any variant of SelectOption" diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValue.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValue.cs index 0f230a7b..47beabdb 100644 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValue.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValue.cs @@ -104,7 +104,7 @@ public T Match( public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException( "Data did not match any variant of DefaultValue" diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent2.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent2.cs index b5209741..26e76b85 100644 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent2.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent2.cs @@ -77,7 +77,7 @@ public T Match( public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException( "Data did not match any variant of UnnamedSchemaWithArrayParent2" diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MaxValue.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MaxValue.cs index 176b3c2b..0ebf26c3 100644 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MaxValue.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MaxValue.cs @@ -76,7 +76,7 @@ public T Match(System::Func @string, System::Func @doub public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException("Data did not match any variant of MaxValue"); } diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MinValue.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MinValue.cs index 36036350..694e297a 100644 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MinValue.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MinValue.cs @@ -76,7 +76,7 @@ public T Match(System::Func @string, System::Func @doub public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException("Data did not match any variant of MinValue"); } diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/SelectOption.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/SelectOption.cs index 9ca07698..e25c4638 100644 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/SelectOption.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/SelectOption.cs @@ -94,7 +94,7 @@ public T Match( public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException( "Data did not match any variant of SelectOption" diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValue.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValue.cs index 4122d47a..f7ebb17e 100644 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValue.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValue.cs @@ -120,7 +120,7 @@ public T Match( public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException( "Data did not match any variant of DefaultValue" diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent1.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent1.cs index 43977039..a7a7a74b 100644 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent1.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent1.cs @@ -94,7 +94,7 @@ public T Match( public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException( "Data did not match any variant of UnnamedSchemaWithArrayParent1" diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MaxValue.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MaxValue.cs index 17131e6c..cb5571ed 100644 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MaxValue.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MaxValue.cs @@ -76,7 +76,7 @@ public T Match(System::Func @string, System::Func @doub public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException("Data did not match any variant of MaxValue"); } diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MinValue.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MinValue.cs index 6d002b31..2b66fb7c 100644 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MinValue.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MinValue.cs @@ -76,7 +76,7 @@ public T Match(System::Func @string, System::Func @doub public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException("Data did not match any variant of MinValue"); } diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/SelectOption.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/SelectOption.cs index 8dc43114..8e129ee9 100644 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/SelectOption.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/SelectOption.cs @@ -94,7 +94,7 @@ public T Match( public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException( "Data did not match any variant of SelectOption" diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValue.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValue.cs index f7091ca1..737e3f19 100644 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValue.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValue.cs @@ -104,7 +104,7 @@ Func, T> mixed public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException( "Data did not match any variant of DefaultValue" diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent3.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent3.cs index f6ce96d8..aaf1fc64 100644 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent3.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent3.cs @@ -78,7 +78,7 @@ public T Match( public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException( "Data did not match any variant of UnnamedSchemaWithArrayParent3" diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MaxValue.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MaxValue.cs index 39d79c7a..d87d1194 100644 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MaxValue.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MaxValue.cs @@ -76,7 +76,7 @@ public T Match(Func @string, Func @double) public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException("Data did not match any variant of MaxValue"); } diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MinValue.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MinValue.cs index 509139aa..18967898 100644 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MinValue.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MinValue.cs @@ -76,7 +76,7 @@ public T Match(Func @string, Func @double) public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException("Data did not match any variant of MinValue"); } diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/SelectOption.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/SelectOption.cs index 60435b53..33cb3967 100644 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/SelectOption.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/SelectOption.cs @@ -86,7 +86,7 @@ public T Match(Func @string, Func @double, Func( public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException( "Data did not match any variant of DefaultValue" diff --git a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent4.cs b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent4.cs index 8d35f0e3..fd1d8943 100644 --- a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent4.cs +++ b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent4.cs @@ -98,7 +98,7 @@ public T Match( public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException( "Data did not match any variant of UnnamedSchemaWithArrayParent4" diff --git a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs index f15c4393..4d08e395 100644 --- a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs +++ b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs @@ -80,7 +80,7 @@ public T Match(System::Func @string, System::Func @doub public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException("Data did not match any variant of MaxValue"); } diff --git a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs index d655fecb..8e672fb6 100644 --- a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs +++ b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs @@ -80,7 +80,7 @@ public T Match(System::Func @string, System::Func @doub public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException("Data did not match any variant of MinValue"); } diff --git a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs index 939622b6..68f79ca6 100644 --- a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs +++ b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs @@ -98,7 +98,7 @@ public T Match( public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException( "Data did not match any variant of SelectOption" diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/Post.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/Post.cs index bfc3372c..505f085a 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/Post.cs +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/Post.cs @@ -124,7 +124,7 @@ public T Match( public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException("Data did not match any variant of Post"); } diff --git a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs index f9663760..e2750b95 100644 --- a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs +++ b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs @@ -120,7 +120,7 @@ public T Match( public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException( "Data did not match any variant of DefaultValue" diff --git a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent5.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent5.cs index fe3e9e78..dc3c8eca 100644 --- a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent5.cs +++ b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent5.cs @@ -98,7 +98,7 @@ public T Match( public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException( "Data did not match any variant of UnnamedSchemaWithArrayParent5" diff --git a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs index f1b73284..09e5dd0e 100644 --- a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs +++ b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs @@ -80,7 +80,7 @@ public T Match(System::Func @string, System::Func @doub public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException("Data did not match any variant of MaxValue"); } diff --git a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs index 274d1d00..1f7128ee 100644 --- a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs +++ b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs @@ -80,7 +80,7 @@ public T Match(System::Func @string, System::Func @doub public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException("Data did not match any variant of MinValue"); } diff --git a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs index 3ba7aa67..970730e0 100644 --- a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs +++ b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs @@ -98,7 +98,7 @@ public T Match( public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException( "Data did not match any variant of SelectOption" diff --git a/src/Imagekit/Models/Files/UpdateFileRequest.cs b/src/Imagekit/Models/Files/UpdateFileRequest.cs index fc16cb9a..b5fab031 100644 --- a/src/Imagekit/Models/Files/UpdateFileRequest.cs +++ b/src/Imagekit/Models/Files/UpdateFileRequest.cs @@ -87,7 +87,7 @@ Func changePublicationStatus public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException( "Data did not match any variant of UpdateFileRequest" diff --git a/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/RemoveAITags.cs b/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/RemoveAITags.cs index acb84e8f..1987bf9b 100644 --- a/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/RemoveAITags.cs +++ b/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/RemoveAITags.cs @@ -80,7 +80,7 @@ public T Match(Func, T> strings, Func all) public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException( "Data did not match any variant of RemoveAITags" diff --git a/src/Imagekit/Models/ImageOverlay.cs b/src/Imagekit/Models/ImageOverlay.cs index d1fce933..17bc7fd4 100644 --- a/src/Imagekit/Models/ImageOverlay.cs +++ b/src/Imagekit/Models/ImageOverlay.cs @@ -159,7 +159,7 @@ public override void Validate() public ImageOverlay() { - this.Type = new(); + this.Type = JsonSerializer.Deserialize("\"image\""); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/ImageOverlayProperties/IntersectionMember1.cs b/src/Imagekit/Models/ImageOverlayProperties/IntersectionMember1.cs index 5366aae5..10900ce7 100644 --- a/src/Imagekit/Models/ImageOverlayProperties/IntersectionMember1.cs +++ b/src/Imagekit/Models/ImageOverlayProperties/IntersectionMember1.cs @@ -115,7 +115,7 @@ public override void Validate() public IntersectionMember1() { - this.Type = new(); + this.Type = JsonSerializer.Deserialize("\"image\""); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/Overlay.cs b/src/Imagekit/Models/Overlay.cs index 386b9c2e..d7e9c65c 100644 --- a/src/Imagekit/Models/Overlay.cs +++ b/src/Imagekit/Models/Overlay.cs @@ -189,7 +189,7 @@ Func solidColor public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException("Data did not match any variant of Overlay"); } diff --git a/src/Imagekit/Models/OverlayPositionProperties/X.cs b/src/Imagekit/Models/OverlayPositionProperties/X.cs index b6fe25d7..929bc920 100644 --- a/src/Imagekit/Models/OverlayPositionProperties/X.cs +++ b/src/Imagekit/Models/OverlayPositionProperties/X.cs @@ -77,7 +77,7 @@ public T Match(Func @double, Func @string) public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException("Data did not match any variant of X"); } diff --git a/src/Imagekit/Models/OverlayPositionProperties/Y.cs b/src/Imagekit/Models/OverlayPositionProperties/Y.cs index 8a901e64..72c09aa0 100644 --- a/src/Imagekit/Models/OverlayPositionProperties/Y.cs +++ b/src/Imagekit/Models/OverlayPositionProperties/Y.cs @@ -77,7 +77,7 @@ public T Match(Func @double, Func @string) public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException("Data did not match any variant of Y"); } diff --git a/src/Imagekit/Models/OverlayTimingProperties/Duration.cs b/src/Imagekit/Models/OverlayTimingProperties/Duration.cs index a14b71a6..ddc56267 100644 --- a/src/Imagekit/Models/OverlayTimingProperties/Duration.cs +++ b/src/Imagekit/Models/OverlayTimingProperties/Duration.cs @@ -77,7 +77,7 @@ public T Match(Func @double, Func @string) public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException("Data did not match any variant of Duration"); } diff --git a/src/Imagekit/Models/OverlayTimingProperties/End.cs b/src/Imagekit/Models/OverlayTimingProperties/End.cs index 9b88c99a..9ba0eac4 100644 --- a/src/Imagekit/Models/OverlayTimingProperties/End.cs +++ b/src/Imagekit/Models/OverlayTimingProperties/End.cs @@ -78,7 +78,7 @@ public T Match(Func @double, Func @string) public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException("Data did not match any variant of End"); } diff --git a/src/Imagekit/Models/OverlayTimingProperties/Start.cs b/src/Imagekit/Models/OverlayTimingProperties/Start.cs index 40dba4c8..ddde0dd7 100644 --- a/src/Imagekit/Models/OverlayTimingProperties/Start.cs +++ b/src/Imagekit/Models/OverlayTimingProperties/Start.cs @@ -77,7 +77,7 @@ public T Match(Func @double, Func @string) public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException("Data did not match any variant of Start"); } diff --git a/src/Imagekit/Models/SolidColorOverlay.cs b/src/Imagekit/Models/SolidColorOverlay.cs index 8a045c39..4f81be5f 100644 --- a/src/Imagekit/Models/SolidColorOverlay.cs +++ b/src/Imagekit/Models/SolidColorOverlay.cs @@ -133,7 +133,7 @@ public override void Validate() public SolidColorOverlay() { - this.Type = new(); + this.Type = JsonSerializer.Deserialize("\"solidColor\""); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/SolidColorOverlayProperties/IntersectionMember1.cs b/src/Imagekit/Models/SolidColorOverlayProperties/IntersectionMember1.cs index 364610ea..4ae49341 100644 --- a/src/Imagekit/Models/SolidColorOverlayProperties/IntersectionMember1.cs +++ b/src/Imagekit/Models/SolidColorOverlayProperties/IntersectionMember1.cs @@ -89,7 +89,7 @@ public override void Validate() public IntersectionMember1() { - this.Type = new(); + this.Type = JsonSerializer.Deserialize("\"solidColor\""); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Gradient.cs b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Gradient.cs index 1c2b74b9..956b411e 100644 --- a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Gradient.cs +++ b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Gradient.cs @@ -76,7 +76,7 @@ public T Match(Func true1, Func @string) public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException("Data did not match any variant of Gradient"); } diff --git a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Height.cs b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Height.cs index f9d5d539..56ac91e2 100644 --- a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Height.cs +++ b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Height.cs @@ -75,7 +75,7 @@ public T Match(Func @double, Func @string) public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException("Data did not match any variant of Height"); } diff --git a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Radius.cs b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Radius.cs index b8f66bdf..c5126466 100644 --- a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Radius.cs +++ b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Radius.cs @@ -75,7 +75,7 @@ public T Match(Func @double, Func max) public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException("Data did not match any variant of Radius"); } diff --git a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Width.cs b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Width.cs index b141eed1..e094e1ea 100644 --- a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Width.cs +++ b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Width.cs @@ -75,7 +75,7 @@ public T Match(Func @double, Func @string) public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException("Data did not match any variant of Width"); } diff --git a/src/Imagekit/Models/SubtitleOverlay.cs b/src/Imagekit/Models/SubtitleOverlay.cs index 3c581342..4baab6cb 100644 --- a/src/Imagekit/Models/SubtitleOverlay.cs +++ b/src/Imagekit/Models/SubtitleOverlay.cs @@ -157,7 +157,7 @@ public override void Validate() public SubtitleOverlay() { - this.Type = new(); + this.Type = JsonSerializer.Deserialize("\"subtitle\""); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/SubtitleOverlayProperties/IntersectionMember1.cs b/src/Imagekit/Models/SubtitleOverlayProperties/IntersectionMember1.cs index 7bfb5133..2baa35cc 100644 --- a/src/Imagekit/Models/SubtitleOverlayProperties/IntersectionMember1.cs +++ b/src/Imagekit/Models/SubtitleOverlayProperties/IntersectionMember1.cs @@ -113,7 +113,7 @@ public override void Validate() public IntersectionMember1() { - this.Type = new(); + this.Type = JsonSerializer.Deserialize("\"subtitle\""); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/TextOverlay.cs b/src/Imagekit/Models/TextOverlay.cs index 4e9a980c..9d77aafc 100644 --- a/src/Imagekit/Models/TextOverlay.cs +++ b/src/Imagekit/Models/TextOverlay.cs @@ -158,7 +158,7 @@ public override void Validate() public TextOverlay() { - this.Type = new(); + this.Type = JsonSerializer.Deserialize("\"text\""); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/TextOverlayProperties/IntersectionMember1.cs b/src/Imagekit/Models/TextOverlayProperties/IntersectionMember1.cs index 5d9b0091..ebe9d333 100644 --- a/src/Imagekit/Models/TextOverlayProperties/IntersectionMember1.cs +++ b/src/Imagekit/Models/TextOverlayProperties/IntersectionMember1.cs @@ -114,7 +114,7 @@ public override void Validate() public IntersectionMember1() { - this.Type = new(); + this.Type = JsonSerializer.Deserialize("\"text\""); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/TextOverlayTransformationProperties/FontSize.cs b/src/Imagekit/Models/TextOverlayTransformationProperties/FontSize.cs index f915b7f2..4b2b31e4 100644 --- a/src/Imagekit/Models/TextOverlayTransformationProperties/FontSize.cs +++ b/src/Imagekit/Models/TextOverlayTransformationProperties/FontSize.cs @@ -74,7 +74,7 @@ public T Match(Func @double, Func @string) public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException("Data did not match any variant of FontSize"); } diff --git a/src/Imagekit/Models/TextOverlayTransformationProperties/LineHeight.cs b/src/Imagekit/Models/TextOverlayTransformationProperties/LineHeight.cs index 0cc2555a..57a4221e 100644 --- a/src/Imagekit/Models/TextOverlayTransformationProperties/LineHeight.cs +++ b/src/Imagekit/Models/TextOverlayTransformationProperties/LineHeight.cs @@ -76,7 +76,7 @@ public T Match(Func @double, Func @string) public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException("Data did not match any variant of LineHeight"); } diff --git a/src/Imagekit/Models/TextOverlayTransformationProperties/Padding.cs b/src/Imagekit/Models/TextOverlayTransformationProperties/Padding.cs index ef906df1..c4f4c51c 100644 --- a/src/Imagekit/Models/TextOverlayTransformationProperties/Padding.cs +++ b/src/Imagekit/Models/TextOverlayTransformationProperties/Padding.cs @@ -76,7 +76,7 @@ public T Match(Func @double, Func @string) public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException("Data did not match any variant of Padding"); } diff --git a/src/Imagekit/Models/TextOverlayTransformationProperties/Radius.cs b/src/Imagekit/Models/TextOverlayTransformationProperties/Radius.cs index 4674dc45..06d5a035 100644 --- a/src/Imagekit/Models/TextOverlayTransformationProperties/Radius.cs +++ b/src/Imagekit/Models/TextOverlayTransformationProperties/Radius.cs @@ -75,7 +75,7 @@ public T Match(Func @double, Func max) public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException("Data did not match any variant of Radius"); } diff --git a/src/Imagekit/Models/TextOverlayTransformationProperties/Rotation.cs b/src/Imagekit/Models/TextOverlayTransformationProperties/Rotation.cs index 07b5277c..e50d44b6 100644 --- a/src/Imagekit/Models/TextOverlayTransformationProperties/Rotation.cs +++ b/src/Imagekit/Models/TextOverlayTransformationProperties/Rotation.cs @@ -75,7 +75,7 @@ public T Match(Func @double, Func @string) public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException("Data did not match any variant of Rotation"); } diff --git a/src/Imagekit/Models/TextOverlayTransformationProperties/Width.cs b/src/Imagekit/Models/TextOverlayTransformationProperties/Width.cs index 9c1bd370..9c3a90df 100644 --- a/src/Imagekit/Models/TextOverlayTransformationProperties/Width.cs +++ b/src/Imagekit/Models/TextOverlayTransformationProperties/Width.cs @@ -77,7 +77,7 @@ public T Match(Func @double, Func @string) public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException("Data did not match any variant of Width"); } diff --git a/src/Imagekit/Models/TransformationProperties/AIDropShadow.cs b/src/Imagekit/Models/TransformationProperties/AIDropShadow.cs index e7b8845f..6c4458d1 100644 --- a/src/Imagekit/Models/TransformationProperties/AIDropShadow.cs +++ b/src/Imagekit/Models/TransformationProperties/AIDropShadow.cs @@ -78,7 +78,7 @@ public T Match(Func true1, Func @string) public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException( "Data did not match any variant of AIDropShadow" diff --git a/src/Imagekit/Models/TransformationProperties/AspectRatio.cs b/src/Imagekit/Models/TransformationProperties/AspectRatio.cs index ce816e0d..38977d63 100644 --- a/src/Imagekit/Models/TransformationProperties/AspectRatio.cs +++ b/src/Imagekit/Models/TransformationProperties/AspectRatio.cs @@ -76,7 +76,7 @@ public T Match(Func @double, Func @string) public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException("Data did not match any variant of AspectRatio"); } diff --git a/src/Imagekit/Models/TransformationProperties/Duration.cs b/src/Imagekit/Models/TransformationProperties/Duration.cs index 25b73cf6..b2ec794f 100644 --- a/src/Imagekit/Models/TransformationProperties/Duration.cs +++ b/src/Imagekit/Models/TransformationProperties/Duration.cs @@ -76,7 +76,7 @@ public T Match(Func @double, Func @string) public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException("Data did not match any variant of Duration"); } diff --git a/src/Imagekit/Models/TransformationProperties/EndOffset.cs b/src/Imagekit/Models/TransformationProperties/EndOffset.cs index 89f0960b..3201b99f 100644 --- a/src/Imagekit/Models/TransformationProperties/EndOffset.cs +++ b/src/Imagekit/Models/TransformationProperties/EndOffset.cs @@ -76,7 +76,7 @@ public T Match(Func @double, Func @string) public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException("Data did not match any variant of EndOffset"); } diff --git a/src/Imagekit/Models/TransformationProperties/Gradient.cs b/src/Imagekit/Models/TransformationProperties/Gradient.cs index fb75235e..cf22e1cc 100644 --- a/src/Imagekit/Models/TransformationProperties/Gradient.cs +++ b/src/Imagekit/Models/TransformationProperties/Gradient.cs @@ -75,7 +75,7 @@ public T Match(Func true1, Func @string) public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException("Data did not match any variant of Gradient"); } diff --git a/src/Imagekit/Models/TransformationProperties/Height.cs b/src/Imagekit/Models/TransformationProperties/Height.cs index bf94bf79..724bac2c 100644 --- a/src/Imagekit/Models/TransformationProperties/Height.cs +++ b/src/Imagekit/Models/TransformationProperties/Height.cs @@ -77,7 +77,7 @@ public T Match(Func @double, Func @string) public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException("Data did not match any variant of Height"); } diff --git a/src/Imagekit/Models/TransformationProperties/Page.cs b/src/Imagekit/Models/TransformationProperties/Page.cs index 75b8855a..0dc78f79 100644 --- a/src/Imagekit/Models/TransformationProperties/Page.cs +++ b/src/Imagekit/Models/TransformationProperties/Page.cs @@ -191,7 +191,7 @@ public T Match(Func @double, Func @string) public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException("Data did not match any variant of Page"); } diff --git a/src/Imagekit/Models/TransformationProperties/Radius.cs b/src/Imagekit/Models/TransformationProperties/Radius.cs index 65f3d4f7..09213816 100644 --- a/src/Imagekit/Models/TransformationProperties/Radius.cs +++ b/src/Imagekit/Models/TransformationProperties/Radius.cs @@ -75,7 +75,7 @@ public T Match(Func @double, Func max) public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException("Data did not match any variant of Radius"); } diff --git a/src/Imagekit/Models/TransformationProperties/Rotation.cs b/src/Imagekit/Models/TransformationProperties/Rotation.cs index 2462218d..1012869c 100644 --- a/src/Imagekit/Models/TransformationProperties/Rotation.cs +++ b/src/Imagekit/Models/TransformationProperties/Rotation.cs @@ -77,7 +77,7 @@ public T Match(Func @double, Func @string) public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException("Data did not match any variant of Rotation"); } diff --git a/src/Imagekit/Models/TransformationProperties/Shadow.cs b/src/Imagekit/Models/TransformationProperties/Shadow.cs index e35c0530..fe0560a8 100644 --- a/src/Imagekit/Models/TransformationProperties/Shadow.cs +++ b/src/Imagekit/Models/TransformationProperties/Shadow.cs @@ -76,7 +76,7 @@ public T Match(Func true1, Func @string) public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException("Data did not match any variant of Shadow"); } diff --git a/src/Imagekit/Models/TransformationProperties/Sharpen.cs b/src/Imagekit/Models/TransformationProperties/Sharpen.cs index 4d495c8c..a5018093 100644 --- a/src/Imagekit/Models/TransformationProperties/Sharpen.cs +++ b/src/Imagekit/Models/TransformationProperties/Sharpen.cs @@ -76,7 +76,7 @@ public T Match(Func true1, Func @double) public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException("Data did not match any variant of Sharpen"); } diff --git a/src/Imagekit/Models/TransformationProperties/StartOffset.cs b/src/Imagekit/Models/TransformationProperties/StartOffset.cs index 3b579d3e..47c7a7d7 100644 --- a/src/Imagekit/Models/TransformationProperties/StartOffset.cs +++ b/src/Imagekit/Models/TransformationProperties/StartOffset.cs @@ -75,7 +75,7 @@ public T Match(Func @double, Func @string) public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException("Data did not match any variant of StartOffset"); } diff --git a/src/Imagekit/Models/TransformationProperties/Trim.cs b/src/Imagekit/Models/TransformationProperties/Trim.cs index aca0f337..67c13ec1 100644 --- a/src/Imagekit/Models/TransformationProperties/Trim.cs +++ b/src/Imagekit/Models/TransformationProperties/Trim.cs @@ -76,7 +76,7 @@ public T Match(Func true1, Func @double) public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException("Data did not match any variant of Trim"); } diff --git a/src/Imagekit/Models/TransformationProperties/UnsharpMask.cs b/src/Imagekit/Models/TransformationProperties/UnsharpMask.cs index efa754cb..67f94a70 100644 --- a/src/Imagekit/Models/TransformationProperties/UnsharpMask.cs +++ b/src/Imagekit/Models/TransformationProperties/UnsharpMask.cs @@ -76,7 +76,7 @@ public T Match(Func true1, Func @string) public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException("Data did not match any variant of UnsharpMask"); } diff --git a/src/Imagekit/Models/TransformationProperties/Width.cs b/src/Imagekit/Models/TransformationProperties/Width.cs index 722809d4..21f6ab2e 100644 --- a/src/Imagekit/Models/TransformationProperties/Width.cs +++ b/src/Imagekit/Models/TransformationProperties/Width.cs @@ -77,7 +77,7 @@ public T Match(Func @double, Func @string) public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException("Data did not match any variant of Width"); } diff --git a/src/Imagekit/Models/TransformationProperties/X.cs b/src/Imagekit/Models/TransformationProperties/X.cs index 8ab60929..90c37307 100644 --- a/src/Imagekit/Models/TransformationProperties/X.cs +++ b/src/Imagekit/Models/TransformationProperties/X.cs @@ -74,7 +74,7 @@ public T Match(Func @double, Func @string) public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException("Data did not match any variant of X"); } diff --git a/src/Imagekit/Models/TransformationProperties/XCenter.cs b/src/Imagekit/Models/TransformationProperties/XCenter.cs index bf003525..b40023f1 100644 --- a/src/Imagekit/Models/TransformationProperties/XCenter.cs +++ b/src/Imagekit/Models/TransformationProperties/XCenter.cs @@ -75,7 +75,7 @@ public T Match(Func @double, Func @string) public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException("Data did not match any variant of XCenter"); } diff --git a/src/Imagekit/Models/TransformationProperties/Y.cs b/src/Imagekit/Models/TransformationProperties/Y.cs index 37e9acf8..83a5aeed 100644 --- a/src/Imagekit/Models/TransformationProperties/Y.cs +++ b/src/Imagekit/Models/TransformationProperties/Y.cs @@ -74,7 +74,7 @@ public T Match(Func @double, Func @string) public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException("Data did not match any variant of Y"); } diff --git a/src/Imagekit/Models/TransformationProperties/YCenter.cs b/src/Imagekit/Models/TransformationProperties/YCenter.cs index 063b9df3..4d2fa5a9 100644 --- a/src/Imagekit/Models/TransformationProperties/YCenter.cs +++ b/src/Imagekit/Models/TransformationProperties/YCenter.cs @@ -75,7 +75,7 @@ public T Match(Func @double, Func @string) public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException("Data did not match any variant of YCenter"); } diff --git a/src/Imagekit/Models/UnnamedSchemaWithArrayParent0.cs b/src/Imagekit/Models/UnnamedSchemaWithArrayParent0.cs index 5e4e9b50..4c2932f3 100644 --- a/src/Imagekit/Models/UnnamedSchemaWithArrayParent0.cs +++ b/src/Imagekit/Models/UnnamedSchemaWithArrayParent0.cs @@ -99,7 +99,7 @@ Func aiAutoDescription public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException( "Data did not match any variant of UnnamedSchemaWithArrayParent0" diff --git a/src/Imagekit/Models/VideoOverlay.cs b/src/Imagekit/Models/VideoOverlay.cs index afbdd73d..e74d29f0 100644 --- a/src/Imagekit/Models/VideoOverlay.cs +++ b/src/Imagekit/Models/VideoOverlay.cs @@ -158,7 +158,7 @@ public override void Validate() public VideoOverlay() { - this.Type = new(); + this.Type = JsonSerializer.Deserialize("\"video\""); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/VideoOverlayProperties/IntersectionMember1.cs b/src/Imagekit/Models/VideoOverlayProperties/IntersectionMember1.cs index 0e159a05..70e42181 100644 --- a/src/Imagekit/Models/VideoOverlayProperties/IntersectionMember1.cs +++ b/src/Imagekit/Models/VideoOverlayProperties/IntersectionMember1.cs @@ -114,7 +114,7 @@ public override void Validate() public IntersectionMember1() { - this.Type = new(); + this.Type = JsonSerializer.Deserialize("\"video\""); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs b/src/Imagekit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs index e05e94e6..d21a8c90 100644 --- a/src/Imagekit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs +++ b/src/Imagekit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs @@ -233,7 +233,7 @@ Func uploadPostTransformError public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException( "Data did not match any variant of UnsafeUnwrapWebhookEvent" diff --git a/src/Imagekit/Models/Webhooks/UnwrapWebhookEvent.cs b/src/Imagekit/Models/Webhooks/UnwrapWebhookEvent.cs index ca9183fb..af307b45 100644 --- a/src/Imagekit/Models/Webhooks/UnwrapWebhookEvent.cs +++ b/src/Imagekit/Models/Webhooks/UnwrapWebhookEvent.cs @@ -233,7 +233,7 @@ Func uploadPostTransformError public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException( "Data did not match any variant of UnwrapWebhookEvent" diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1.cs index 45ad1218..aa680196 100644 --- a/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1.cs +++ b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1.cs @@ -120,7 +120,7 @@ public override void Validate() public IntersectionMember1() { - this.Type = new(); + this.Type = JsonSerializer.Deserialize("\"upload.post-transform.error\""); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1.cs index bc4b6ff6..ac62a61d 100644 --- a/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1.cs +++ b/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1.cs @@ -121,7 +121,7 @@ public override void Validate() public IntersectionMember1() { - this.Type = new(); + this.Type = JsonSerializer.Deserialize("\"upload.post-transform.success\""); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/IntersectionMember1.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/IntersectionMember1.cs index 05fce33e..2cde87e7 100644 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/IntersectionMember1.cs +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/IntersectionMember1.cs @@ -120,7 +120,7 @@ public override void Validate() public IntersectionMember1() { - this.Type = new(); + this.Type = JsonSerializer.Deserialize("\"upload.pre-transform.error\""); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1.cs index 98d0b3d4..61a51ae8 100644 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1.cs +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1.cs @@ -124,7 +124,7 @@ public override void Validate() public IntersectionMember1() { - this.Type = new(); + this.Type = JsonSerializer.Deserialize("\"upload.pre-transform.success\""); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs index 08900bf2..796ca3a2 100644 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs @@ -120,7 +120,7 @@ public T Match( public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException( "Data did not match any variant of DefaultValue" diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent7.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent7.cs index debddca6..938d9014 100644 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent7.cs +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent7.cs @@ -98,7 +98,7 @@ public T Match( public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException( "Data did not match any variant of UnnamedSchemaWithArrayParent7" diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs index aecab449..c4902bc0 100644 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs @@ -80,7 +80,7 @@ public T Match(System::Func @string, System::Func @doub public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException("Data did not match any variant of MaxValue"); } diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs index a80050fe..1c90d555 100644 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs @@ -80,7 +80,7 @@ public T Match(System::Func @string, System::Func @doub public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException("Data did not match any variant of MinValue"); } diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs index 25c141ca..380f378b 100644 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs @@ -98,7 +98,7 @@ public T Match( public void Validate() { - if (this.Value is not UnknownVariant) + if (this.Value is UnknownVariant) { throw new ImageKitInvalidDataException( "Data did not match any variant of SelectOption" diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1.cs b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1.cs index 1057f993..af53cd9d 100644 --- a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1.cs +++ b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1.cs @@ -124,7 +124,7 @@ public override void Validate() public IntersectionMember1() { - this.Type = new(); + this.Type = JsonSerializer.Deserialize("\"video.transformation.accepted\""); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1.cs index 207e423b..778dcbed 100644 --- a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1.cs +++ b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1.cs @@ -125,7 +125,7 @@ public override void Validate() public IntersectionMember1() { - this.Type = new(); + this.Type = JsonSerializer.Deserialize("\"video.transformation.error\""); } #pragma warning disable CS8618 diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1.cs index 4f1c36d1..263c0fc8 100644 --- a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1.cs +++ b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1.cs @@ -147,7 +147,7 @@ public override void Validate() public IntersectionMember1() { - this.Type = new(); + this.Type = JsonSerializer.Deserialize("\"video.transformation.ready\""); } #pragma warning disable CS8618 From a743975bdbd242cd050f9c2eafbdc6f29fc84ec9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 Oct 2025 05:32:06 +0000 Subject: [PATCH 054/129] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index e27f9d4f..df4337df 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-9d184cb502ab32a85db2889c796cdfebe812f2a55a604df79c85dd4b5e7e2add.yml openapi_spec_hash: a9aa620376fce66532c84f9364209b0b -config_hash: bb7229ef61cee50cd6c1ac02a5a74e81 +config_hash: d7961ccc7e3cafdf8f56d6c89c3c7d62 From 42767fb844cc93197e2631d6106e6db0fbb64e35 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 Oct 2025 05:32:53 +0000 Subject: [PATCH 055/129] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index df4337df..43d92ddb 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-9d184cb502ab32a85db2889c796cdfebe812f2a55a604df79c85dd4b5e7e2add.yml openapi_spec_hash: a9aa620376fce66532c84f9364209b0b -config_hash: d7961ccc7e3cafdf8f56d6c89c3c7d62 +config_hash: c2c1c0a5c85d678e5aa8996f3637b616 From 10c0081a2298d067bbee125260dcc7c31414ff91 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 Oct 2025 05:45:28 +0000 Subject: [PATCH 056/129] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 43d92ddb..ae3aead6 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-9d184cb502ab32a85db2889c796cdfebe812f2a55a604df79c85dd4b5e7e2add.yml openapi_spec_hash: a9aa620376fce66532c84f9364209b0b -config_hash: c2c1c0a5c85d678e5aa8996f3637b616 +config_hash: eb4cf65a4c6b26a2901076eff5810d5d From 315b8a7aeffa8f014d489de9fd41973064037fc9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 28 Jan 2026 18:22:13 +0000 Subject: [PATCH 057/129] chore(internal): full qualify some references --- .../Transformation.cs | 191 +-- .../PostProperties/Transformation.cs | 12 +- .../Type.cs | 20 +- .../Transformation.cs | 191 +-- .../PostProperties/Transformation.cs | 12 +- .../MetadataProperties/ExifProperties/Exif.cs | 1059 +++++++++-------- .../DataProperties/Transformation.cs | 12 +- .../RequestProperties/Transformation.cs | 12 +- .../RequestProperties/Transformation.cs | 12 +- .../DataProperties/Transformation.cs | 12 +- .../DataProperties/Transformation.cs | 12 +- .../DataProperties/Transformation.cs | 12 +- .../DataProperties/Transformation.cs | 12 +- 13 files changed, 827 insertions(+), 742 deletions(-) diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/Transformation.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/Transformation.cs index 928b8185..49762273 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/Transformation.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/Transformation.cs @@ -1,92 +1,99 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties; - -namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties; - -/// -/// Configure pre-processing (`pre`) and post-processing (`post`) transformations. -/// -/// - `pre` — applied before the file is uploaded to the Media Library. Useful -/// for reducing file size or applying basic optimizations upfront (e.g., resize, compress). -/// -/// - `post` — applied immediately after upload. Ideal for generating transformed -/// versions (like video encodes or thumbnails) in advance, so they're ready for -/// delivery without delay. -/// -/// You can mix and match any combination of post-processing types. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class Transformation : ModelBase, IFromRaw -{ - /// - /// List of transformations to apply *after* the file is uploaded. Each item - /// must match one of the following types: `transformation`, `gif-to-video`, - /// `thumbnail`, `abs`. - /// - public List? Post - { - get - { - if (!this.Properties.TryGetValue("post", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["post"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Transformation string to apply before uploading the file to the Media Library. - /// Useful for optimizing files at ingestion. - /// - public string? Pre - { - get - { - if (!this.Properties.TryGetValue("pre", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["pre"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - foreach (var item in this.Post ?? []) - { - item.Validate(); - } - _ = this.Pre; - } - - public Transformation() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Transformation(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Transformation FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Core; +using Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties; + +namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties; + +/// +/// Configure pre-processing (`pre`) and post-processing (`post`) transformations. +/// +/// - `pre` — applied before the file is uploaded to the Media Library. Useful +/// for reducing file size or applying basic optimizations upfront (e.g., resize, compress). +/// +/// - `post` — applied immediately after upload. Ideal for generating transformed +/// versions (like video encodes or thumbnails) in advance, so they're ready for +/// delivery without delay. +/// +/// You can mix and match any combination of post-processing types. +/// +[JsonConverter( + typeof(ModelConverter) +)] +public sealed record class Transformation + : ModelBase, + IFromRaw +{ + /// + /// List of transformations to apply *after* the file is uploaded. Each item + /// must match one of the following types: `transformation`, `gif-to-video`, + /// `thumbnail`, `abs`. + /// + public List? Post + { + get + { + if (!this.Properties.TryGetValue("post", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["post"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Transformation string to apply before uploading the file to the Media Library. + /// Useful for optimizing files at ingestion. + /// + public string? Pre + { + get + { + if (!this.Properties.TryGetValue("pre", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["pre"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + foreach (var item in this.Post ?? []) + { + item.Validate(); + } + _ = this.Pre; + } + + public Transformation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Transformation(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static global::Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.Transformation FromRawUnchecked( + Dictionary properties + ) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Transformation.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Transformation.cs index a63f82cf..c21379bb 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Transformation.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Transformation.cs @@ -6,8 +6,12 @@ namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; -[JsonConverter(typeof(ModelConverter))] -public sealed record class Transformation : ModelBase, IFromRaw +[JsonConverter( + typeof(ModelConverter) +)] +public sealed record class Transformation + : ModelBase, + IFromRaw { /// /// Transformation type. @@ -79,7 +83,9 @@ public Transformation() } #pragma warning restore CS8618 - public static Transformation FromRawUnchecked(Dictionary properties) + public static global::Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.Transformation FromRawUnchecked( + Dictionary properties + ) { return new(properties); } diff --git a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs index cbc9d0e3..6c435de6 100644 --- a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs +++ b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs @@ -8,7 +8,9 @@ namespace Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.Se /// /// Type of the custom metadata field. /// -[JsonConverter(typeof(TypeConverter))] +[JsonConverter( + typeof(global::Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.TypeConverter) +)] public enum Type { Text, @@ -20,9 +22,10 @@ public enum Type MultiSelect, } -sealed class TypeConverter : JsonConverter +sealed class TypeConverter + : JsonConverter { - public override Type Read( + public override global::Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.Type Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -37,11 +40,18 @@ JsonSerializerOptions options "Boolean" => SelectedFieldsSchemaItemProperties.Type.Boolean, "SingleSelect" => SelectedFieldsSchemaItemProperties.Type.SingleSelect, "MultiSelect" => SelectedFieldsSchemaItemProperties.Type.MultiSelect, - _ => (Type)(-1), + _ => + (global::Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.Type)( + -1 + ), }; } - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + public override void Write( + Utf8JsonWriter writer, + global::Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.Type value, + JsonSerializerOptions options + ) { JsonSerializer.Serialize( writer, diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/Transformation.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/Transformation.cs index e8cdd4c6..afcbbd0d 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/Transformation.cs +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/Transformation.cs @@ -1,92 +1,99 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties; - -namespace Imagekit.Models.Files.FileUploadParamsProperties; - -/// -/// Configure pre-processing (`pre`) and post-processing (`post`) transformations. -/// -/// - `pre` — applied before the file is uploaded to the Media Library. Useful -/// for reducing file size or applying basic optimizations upfront (e.g., resize, compress). -/// -/// - `post` — applied immediately after upload. Ideal for generating transformed -/// versions (like video encodes or thumbnails) in advance, so they're ready for -/// delivery without delay. -/// -/// You can mix and match any combination of post-processing types. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class Transformation : ModelBase, IFromRaw -{ - /// - /// List of transformations to apply *after* the file is uploaded. Each item - /// must match one of the following types: `transformation`, `gif-to-video`, - /// `thumbnail`, `abs`. - /// - public List? Post - { - get - { - if (!this.Properties.TryGetValue("post", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["post"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Transformation string to apply before uploading the file to the Media Library. - /// Useful for optimizing files at ingestion. - /// - public string? Pre - { - get - { - if (!this.Properties.TryGetValue("pre", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["pre"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - foreach (var item in this.Post ?? []) - { - item.Validate(); - } - _ = this.Pre; - } - - public Transformation() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Transformation(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Transformation FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Core; +using Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties; + +namespace Imagekit.Models.Files.FileUploadParamsProperties; + +/// +/// Configure pre-processing (`pre`) and post-processing (`post`) transformations. +/// +/// - `pre` — applied before the file is uploaded to the Media Library. Useful +/// for reducing file size or applying basic optimizations upfront (e.g., resize, compress). +/// +/// - `post` — applied immediately after upload. Ideal for generating transformed +/// versions (like video encodes or thumbnails) in advance, so they're ready for +/// delivery without delay. +/// +/// You can mix and match any combination of post-processing types. +/// +[JsonConverter( + typeof(ModelConverter) +)] +public sealed record class Transformation + : ModelBase, + IFromRaw +{ + /// + /// List of transformations to apply *after* the file is uploaded. Each item + /// must match one of the following types: `transformation`, `gif-to-video`, + /// `thumbnail`, `abs`. + /// + public List? Post + { + get + { + if (!this.Properties.TryGetValue("post", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["post"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Transformation string to apply before uploading the file to the Media Library. + /// Useful for optimizing files at ingestion. + /// + public string? Pre + { + get + { + if (!this.Properties.TryGetValue("pre", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["pre"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + foreach (var item in this.Post ?? []) + { + item.Validate(); + } + _ = this.Pre; + } + + public Transformation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Transformation(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static global::Imagekit.Models.Files.FileUploadParamsProperties.Transformation FromRawUnchecked( + Dictionary properties + ) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Transformation.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Transformation.cs index df1933ae..8087d762 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Transformation.cs +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Transformation.cs @@ -6,8 +6,12 @@ namespace Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; -[JsonConverter(typeof(ModelConverter))] -public sealed record class Transformation : ModelBase, IFromRaw +[JsonConverter( + typeof(ModelConverter) +)] +public sealed record class Transformation + : ModelBase, + IFromRaw { /// /// Transformation type. @@ -79,7 +83,9 @@ public Transformation() } #pragma warning restore CS8618 - public static Transformation FromRawUnchecked(Dictionary properties) + public static global::Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.Transformation FromRawUnchecked( + Dictionary properties + ) { return new(properties); } diff --git a/src/Imagekit/Models/Files/MetadataProperties/ExifProperties/Exif.cs b/src/Imagekit/Models/Files/MetadataProperties/ExifProperties/Exif.cs index 2f1827b7..03fec205 100644 --- a/src/Imagekit/Models/Files/MetadataProperties/ExifProperties/Exif.cs +++ b/src/Imagekit/Models/Files/MetadataProperties/ExifProperties/Exif.cs @@ -1,526 +1,533 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files.MetadataProperties.ExifProperties; - -/// -/// Object containing Exif details. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class Exif : ModelBase, IFromRaw -{ - public double? ApertureValue - { - get - { - if (!this.Properties.TryGetValue("ApertureValue", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["ApertureValue"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public long? ColorSpace - { - get - { - if (!this.Properties.TryGetValue("ColorSpace", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["ColorSpace"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public string? CreateDate - { - get - { - if (!this.Properties.TryGetValue("CreateDate", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["CreateDate"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public long? CustomRendered - { - get - { - if (!this.Properties.TryGetValue("CustomRendered", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["CustomRendered"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public string? DateTimeOriginal - { - get - { - if (!this.Properties.TryGetValue("DateTimeOriginal", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["DateTimeOriginal"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public long? ExifImageHeight - { - get - { - if (!this.Properties.TryGetValue("ExifImageHeight", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["ExifImageHeight"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public long? ExifImageWidth - { - get - { - if (!this.Properties.TryGetValue("ExifImageWidth", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["ExifImageWidth"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public string? ExifVersion - { - get - { - if (!this.Properties.TryGetValue("ExifVersion", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["ExifVersion"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public double? ExposureCompensation - { - get - { - if (!this.Properties.TryGetValue("ExposureCompensation", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["ExposureCompensation"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public long? ExposureMode - { - get - { - if (!this.Properties.TryGetValue("ExposureMode", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["ExposureMode"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public long? ExposureProgram - { - get - { - if (!this.Properties.TryGetValue("ExposureProgram", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["ExposureProgram"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public double? ExposureTime - { - get - { - if (!this.Properties.TryGetValue("ExposureTime", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["ExposureTime"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public long? Flash - { - get - { - if (!this.Properties.TryGetValue("Flash", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["Flash"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public string? FlashpixVersion - { - get - { - if (!this.Properties.TryGetValue("FlashpixVersion", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["FlashpixVersion"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public double? FNumber - { - get - { - if (!this.Properties.TryGetValue("FNumber", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["FNumber"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public long? FocalLength - { - get - { - if (!this.Properties.TryGetValue("FocalLength", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["FocalLength"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public long? FocalPlaneResolutionUnit - { - get - { - if (!this.Properties.TryGetValue("FocalPlaneResolutionUnit", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["FocalPlaneResolutionUnit"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public double? FocalPlaneXResolution - { - get - { - if (!this.Properties.TryGetValue("FocalPlaneXResolution", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["FocalPlaneXResolution"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public double? FocalPlaneYResolution - { - get - { - if (!this.Properties.TryGetValue("FocalPlaneYResolution", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["FocalPlaneYResolution"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public long? InteropOffset - { - get - { - if (!this.Properties.TryGetValue("InteropOffset", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["InteropOffset"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public long? ISO - { - get - { - if (!this.Properties.TryGetValue("ISO", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["ISO"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public long? MeteringMode - { - get - { - if (!this.Properties.TryGetValue("MeteringMode", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["MeteringMode"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public long? SceneCaptureType - { - get - { - if (!this.Properties.TryGetValue("SceneCaptureType", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["SceneCaptureType"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public double? ShutterSpeedValue - { - get - { - if (!this.Properties.TryGetValue("ShutterSpeedValue", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["ShutterSpeedValue"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public string? SubSecTime - { - get - { - if (!this.Properties.TryGetValue("SubSecTime", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["SubSecTime"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public long? WhiteBalance - { - get - { - if (!this.Properties.TryGetValue("WhiteBalance", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["WhiteBalance"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.ApertureValue; - _ = this.ColorSpace; - _ = this.CreateDate; - _ = this.CustomRendered; - _ = this.DateTimeOriginal; - _ = this.ExifImageHeight; - _ = this.ExifImageWidth; - _ = this.ExifVersion; - _ = this.ExposureCompensation; - _ = this.ExposureMode; - _ = this.ExposureProgram; - _ = this.ExposureTime; - _ = this.Flash; - _ = this.FlashpixVersion; - _ = this.FNumber; - _ = this.FocalLength; - _ = this.FocalPlaneResolutionUnit; - _ = this.FocalPlaneXResolution; - _ = this.FocalPlaneYResolution; - _ = this.InteropOffset; - _ = this.ISO; - _ = this.MeteringMode; - _ = this.SceneCaptureType; - _ = this.ShutterSpeedValue; - _ = this.SubSecTime; - _ = this.WhiteBalance; - } - - public Exif() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Exif(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Exif FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Core; + +namespace Imagekit.Models.Files.MetadataProperties.ExifProperties; + +/// +/// Object containing Exif details. +/// +[JsonConverter( + typeof(ModelConverter) +)] +public sealed record class Exif + : ModelBase, + IFromRaw +{ + public double? ApertureValue + { + get + { + if (!this.Properties.TryGetValue("ApertureValue", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["ApertureValue"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public long? ColorSpace + { + get + { + if (!this.Properties.TryGetValue("ColorSpace", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["ColorSpace"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public string? CreateDate + { + get + { + if (!this.Properties.TryGetValue("CreateDate", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["CreateDate"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public long? CustomRendered + { + get + { + if (!this.Properties.TryGetValue("CustomRendered", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["CustomRendered"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public string? DateTimeOriginal + { + get + { + if (!this.Properties.TryGetValue("DateTimeOriginal", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["DateTimeOriginal"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public long? ExifImageHeight + { + get + { + if (!this.Properties.TryGetValue("ExifImageHeight", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["ExifImageHeight"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public long? ExifImageWidth + { + get + { + if (!this.Properties.TryGetValue("ExifImageWidth", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["ExifImageWidth"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public string? ExifVersion + { + get + { + if (!this.Properties.TryGetValue("ExifVersion", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["ExifVersion"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public double? ExposureCompensation + { + get + { + if (!this.Properties.TryGetValue("ExposureCompensation", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["ExposureCompensation"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public long? ExposureMode + { + get + { + if (!this.Properties.TryGetValue("ExposureMode", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["ExposureMode"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public long? ExposureProgram + { + get + { + if (!this.Properties.TryGetValue("ExposureProgram", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["ExposureProgram"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public double? ExposureTime + { + get + { + if (!this.Properties.TryGetValue("ExposureTime", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["ExposureTime"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public long? Flash + { + get + { + if (!this.Properties.TryGetValue("Flash", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["Flash"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public string? FlashpixVersion + { + get + { + if (!this.Properties.TryGetValue("FlashpixVersion", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["FlashpixVersion"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public double? FNumber + { + get + { + if (!this.Properties.TryGetValue("FNumber", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["FNumber"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public long? FocalLength + { + get + { + if (!this.Properties.TryGetValue("FocalLength", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["FocalLength"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public long? FocalPlaneResolutionUnit + { + get + { + if (!this.Properties.TryGetValue("FocalPlaneResolutionUnit", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["FocalPlaneResolutionUnit"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public double? FocalPlaneXResolution + { + get + { + if (!this.Properties.TryGetValue("FocalPlaneXResolution", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["FocalPlaneXResolution"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public double? FocalPlaneYResolution + { + get + { + if (!this.Properties.TryGetValue("FocalPlaneYResolution", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["FocalPlaneYResolution"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public long? InteropOffset + { + get + { + if (!this.Properties.TryGetValue("InteropOffset", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["InteropOffset"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public long? ISO + { + get + { + if (!this.Properties.TryGetValue("ISO", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["ISO"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public long? MeteringMode + { + get + { + if (!this.Properties.TryGetValue("MeteringMode", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["MeteringMode"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public long? SceneCaptureType + { + get + { + if (!this.Properties.TryGetValue("SceneCaptureType", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["SceneCaptureType"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public double? ShutterSpeedValue + { + get + { + if (!this.Properties.TryGetValue("ShutterSpeedValue", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["ShutterSpeedValue"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public string? SubSecTime + { + get + { + if (!this.Properties.TryGetValue("SubSecTime", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["SubSecTime"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public long? WhiteBalance + { + get + { + if (!this.Properties.TryGetValue("WhiteBalance", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["WhiteBalance"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.ApertureValue; + _ = this.ColorSpace; + _ = this.CreateDate; + _ = this.CustomRendered; + _ = this.DateTimeOriginal; + _ = this.ExifImageHeight; + _ = this.ExifImageWidth; + _ = this.ExifVersion; + _ = this.ExposureCompensation; + _ = this.ExposureMode; + _ = this.ExposureProgram; + _ = this.ExposureTime; + _ = this.Flash; + _ = this.FlashpixVersion; + _ = this.FNumber; + _ = this.FocalLength; + _ = this.FocalPlaneResolutionUnit; + _ = this.FocalPlaneXResolution; + _ = this.FocalPlaneYResolution; + _ = this.InteropOffset; + _ = this.ISO; + _ = this.MeteringMode; + _ = this.SceneCaptureType; + _ = this.ShutterSpeedValue; + _ = this.SubSecTime; + _ = this.WhiteBalance; + } + + public Exif() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Exif(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static global::Imagekit.Models.Files.MetadataProperties.ExifProperties.Exif FromRawUnchecked( + Dictionary properties + ) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs index 2127dfdb..448d585d 100644 --- a/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs +++ b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs @@ -7,8 +7,12 @@ namespace Imagekit.Models.Webhooks.UploadPostTransformErrorEventProperties.DataProperties; -[JsonConverter(typeof(ModelConverter))] -public sealed record class Transformation : ModelBase, IFromRaw +[JsonConverter( + typeof(ModelConverter) +)] +public sealed record class Transformation + : ModelBase, + IFromRaw { public required Error Error { @@ -44,7 +48,9 @@ public Transformation() { } } #pragma warning restore CS8618 - public static Transformation FromRawUnchecked(Dictionary properties) + public static global::Imagekit.Models.Webhooks.UploadPostTransformErrorEventProperties.IntersectionMember1Properties.DataProperties.Transformation FromRawUnchecked( + Dictionary properties + ) { return new(properties); } diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1Properties/RequestProperties/Transformation.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1Properties/RequestProperties/Transformation.cs index 2d32ba4c..4ebc989b 100644 --- a/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1Properties/RequestProperties/Transformation.cs +++ b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1Properties/RequestProperties/Transformation.cs @@ -7,8 +7,12 @@ namespace Imagekit.Models.Webhooks.UploadPostTransformErrorEventProperties.RequestProperties; -[JsonConverter(typeof(ModelConverter))] -public sealed record class Transformation : ModelBase, IFromRaw +[JsonConverter( + typeof(ModelConverter) +)] +public sealed record class Transformation + : ModelBase, + IFromRaw { /// /// Type of the requested post-transformation. @@ -96,7 +100,9 @@ public Transformation() { } } #pragma warning restore CS8618 - public static Transformation FromRawUnchecked(Dictionary properties) + public static global::Imagekit.Models.Webhooks.UploadPostTransformErrorEventProperties.IntersectionMember1Properties.RequestProperties.Transformation FromRawUnchecked( + Dictionary properties + ) { return new(properties); } diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1Properties/RequestProperties/Transformation.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1Properties/RequestProperties/Transformation.cs index 05a36b32..00a49edf 100644 --- a/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1Properties/RequestProperties/Transformation.cs +++ b/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1Properties/RequestProperties/Transformation.cs @@ -7,8 +7,12 @@ namespace Imagekit.Models.Webhooks.UploadPostTransformSuccessEventProperties.RequestProperties; -[JsonConverter(typeof(ModelConverter))] -public sealed record class Transformation : ModelBase, IFromRaw +[JsonConverter( + typeof(ModelConverter) +)] +public sealed record class Transformation + : ModelBase, + IFromRaw { /// /// Type of the requested post-transformation. @@ -96,7 +100,9 @@ public Transformation() { } } #pragma warning restore CS8618 - public static Transformation FromRawUnchecked(Dictionary properties) + public static global::Imagekit.Models.Webhooks.UploadPostTransformSuccessEventProperties.IntersectionMember1Properties.RequestProperties.Transformation FromRawUnchecked( + Dictionary properties + ) { return new(properties); } diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs index a00d04c1..c8a814c2 100644 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs @@ -7,8 +7,12 @@ namespace Imagekit.Models.Webhooks.UploadPreTransformErrorEventProperties.DataProperties; -[JsonConverter(typeof(ModelConverter))] -public sealed record class Transformation : ModelBase, IFromRaw +[JsonConverter( + typeof(ModelConverter) +)] +public sealed record class Transformation + : ModelBase, + IFromRaw { public required Error Error { @@ -44,7 +48,9 @@ public Transformation() { } } #pragma warning restore CS8618 - public static Transformation FromRawUnchecked(Dictionary properties) + public static global::Imagekit.Models.Webhooks.UploadPreTransformErrorEventProperties.IntersectionMember1Properties.DataProperties.Transformation FromRawUnchecked( + Dictionary properties + ) { return new(properties); } diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs index 7c5b2209..47e78e69 100644 --- a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs +++ b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs @@ -10,8 +10,12 @@ namespace Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.Da /// /// Base information about a video transformation request. /// -[JsonConverter(typeof(ModelConverter))] -public sealed record class Transformation : ModelBase, IFromRaw +[JsonConverter( + typeof(ModelConverter) +)] +public sealed record class Transformation + : ModelBase, + IFromRaw { /// /// Type of video transformation: - `video-transformation`: Standard video processing @@ -79,7 +83,9 @@ public Transformation() { } } #pragma warning restore CS8618 - public static Transformation FromRawUnchecked(Dictionary properties) + public static global::Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.IntersectionMember1Properties.DataProperties.Transformation FromRawUnchecked( + Dictionary properties + ) { return new(properties); } diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs index ad5cd3d6..101549eb 100644 --- a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs +++ b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs @@ -7,8 +7,12 @@ namespace Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.DataProperties; -[JsonConverter(typeof(ModelConverter))] -public sealed record class Transformation : ModelBase, IFromRaw +[JsonConverter( + typeof(ModelConverter) +)] +public sealed record class Transformation + : ModelBase, + IFromRaw { /// /// Type of video transformation: - `video-transformation`: Standard video processing @@ -101,7 +105,9 @@ public Transformation() { } } #pragma warning restore CS8618 - public static Transformation FromRawUnchecked(Dictionary properties) + public static global::Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.IntersectionMember1Properties.DataProperties.Transformation FromRawUnchecked( + Dictionary properties + ) { return new(properties); } diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs index c68bf310..fd7b253d 100644 --- a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs +++ b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs @@ -7,8 +7,12 @@ namespace Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties; -[JsonConverter(typeof(ModelConverter))] -public sealed record class Transformation : ModelBase, IFromRaw +[JsonConverter( + typeof(ModelConverter) +)] +public sealed record class Transformation + : ModelBase, + IFromRaw { /// /// Type of video transformation: - `video-transformation`: Standard video processing @@ -101,7 +105,9 @@ public Transformation() { } } #pragma warning restore CS8618 - public static Transformation FromRawUnchecked(Dictionary properties) + public static global::Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.IntersectionMember1Properties.DataProperties.Transformation FromRawUnchecked( + Dictionary properties + ) { return new(properties); } From c657ba48590fe74014a263188f32145b6489bd04 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 3 Nov 2025 19:13:52 +0000 Subject: [PATCH 058/129] chore(internal): extract `ClientOptions` struct --- src/Imagekit/Core/ClientOptions.cs | 81 +++++++++++++++++++ src/Imagekit/ImageKitClient.cs | 42 ++++------ .../Models/Accounts/Origins/OriginRequest.cs | 2 +- .../AkeneoPimProperties/Type.cs | 2 +- .../AzureBlobProperties/Type.cs | 2 +- .../CloudinaryBackupProperties/Type.cs | 2 +- .../GcsProperties/Type.cs | 2 +- .../S3CompatibleProperties/Type.cs | 2 +- .../S3Properties/Type.cs | 2 +- .../WebFolderProperties/Type.cs | 2 +- .../WebProxyProperties/Type.cs | 2 +- .../Models/Accounts/Origins/OriginResponse.cs | 2 +- .../AkeneoPimProperties/Type.cs | 2 +- .../AzureBlobProperties/Type.cs | 2 +- .../CloudinaryBackupProperties/Type.cs | 2 +- .../GcsProperties/Type.cs | 2 +- .../S3CompatibleProperties/Type.cs | 2 +- .../S3Properties/Type.cs | 2 +- .../WebFolderProperties/Type.cs | 2 +- .../WebProxyProperties/Type.cs | 2 +- .../URLRewriter.cs | 2 +- .../URLRewriterProperties/Akamai.cs | 2 +- .../AkamaiProperties/Type.cs | 2 +- .../CloudinaryProperties/Type.cs | 2 +- .../URLRewriterProperties/Imgix.cs | 2 +- .../ImgixProperties/Type.cs | 2 +- .../URLRewriter.cs | 2 +- .../URLRewriterProperties/Akamai.cs | 2 +- .../AkamaiProperties/Type.cs | 2 +- .../CloudinaryProperties/Type.cs | 2 +- .../URLRewriterProperties/Imgix.cs | 2 +- .../ImgixProperties/Type.cs | 2 +- .../URLRewriter.cs | 2 +- .../URLRewriterProperties/Akamai.cs | 2 +- .../AkamaiProperties/Type.cs | 2 +- .../CloudinaryProperties/Type.cs | 2 +- .../URLRewriterProperties/Imgix.cs | 2 +- .../ImgixProperties/Type.cs | 2 +- .../URLRewriter.cs | 2 +- .../URLRewriterProperties/Akamai.cs | 2 +- .../AkamaiProperties/Type.cs | 2 +- .../CloudinaryProperties/Type.cs | 2 +- .../URLRewriterProperties/Imgix.cs | 2 +- .../ImgixProperties/Type.cs | 2 +- .../Models/Assets/AssetListResponse.cs | 2 +- .../TransformationProperties/Post.cs | 2 +- .../PostProperties/AbsProperties/Type.cs | 2 +- .../GifToVideoProperties/Type.cs | 2 +- .../ThumbnailProperties/Type.cs | 2 +- .../TransformationProperties/Type.cs | 2 +- .../DefaultValue.cs | 2 +- .../UnnamedSchemaWithArrayParent6.cs | 2 +- .../MaxValue.cs | 2 +- .../MinValue.cs | 2 +- .../SelectOption.cs | 2 +- .../SchemaProperties/DefaultValue.cs | 2 +- .../UnnamedSchemaWithArrayParent2.cs | 2 +- .../SchemaProperties/MaxValue.cs | 2 +- .../SchemaProperties/MinValue.cs | 2 +- .../SchemaProperties/SelectOption.cs | 2 +- .../SchemaProperties/DefaultValue.cs | 2 +- .../UnnamedSchemaWithArrayParent1.cs | 2 +- .../SchemaProperties/MaxValue.cs | 2 +- .../SchemaProperties/MinValue.cs | 2 +- .../SchemaProperties/SelectOption.cs | 2 +- .../SchemaProperties/DefaultValue.cs | 2 +- .../UnnamedSchemaWithArrayParent3.cs | 2 +- .../SchemaProperties/MaxValue.cs | 2 +- .../SchemaProperties/MinValue.cs | 2 +- .../SchemaProperties/SelectOption.cs | 2 +- .../DefaultValue.cs | 2 +- .../UnnamedSchemaWithArrayParent4.cs | 2 +- .../MaxValue.cs | 2 +- .../MinValue.cs | 2 +- .../SelectOption.cs | 2 +- .../TransformationProperties/Post.cs | 2 +- .../PostProperties/AbsProperties/Type.cs | 2 +- .../GifToVideoProperties/Type.cs | 2 +- .../ThumbnailProperties/Type.cs | 2 +- .../TransformationProperties/Type.cs | 2 +- .../DefaultValue.cs | 2 +- .../UnnamedSchemaWithArrayParent5.cs | 2 +- .../MaxValue.cs | 2 +- .../MinValue.cs | 2 +- .../SelectOption.cs | 2 +- .../Models/Files/UpdateFileRequest.cs | 2 +- .../RemoveAITags.cs | 2 +- .../RemoveAITagsProperties/UnionMember1.cs | 2 +- src/Imagekit/Models/Overlay.cs | 2 +- .../Models/OverlayPositionProperties/X.cs | 2 +- .../Models/OverlayPositionProperties/Y.cs | 2 +- .../OverlayTimingProperties/Duration.cs | 2 +- .../Models/OverlayTimingProperties/End.cs | 2 +- .../Models/OverlayTimingProperties/Start.cs | 2 +- .../Gradient.cs | 2 +- .../GradientProperties/UnionMember0.cs | 2 +- .../Height.cs | 2 +- .../Radius.cs | 2 +- .../RadiusProperties/UnionMember1.cs | 2 +- .../Width.cs | 2 +- .../FontSize.cs | 2 +- .../LineHeight.cs | 2 +- .../Padding.cs | 2 +- .../Radius.cs | 2 +- .../RadiusProperties/UnionMember1.cs | 2 +- .../Rotation.cs | 2 +- .../Width.cs | 2 +- .../TransformationProperties/AIDropShadow.cs | 2 +- .../AIDropShadowProperties/UnionMember0.cs | 2 +- .../TransformationProperties/AspectRatio.cs | 2 +- .../TransformationProperties/Duration.cs | 2 +- .../TransformationProperties/EndOffset.cs | 2 +- .../TransformationProperties/Gradient.cs | 2 +- .../GradientProperties/UnionMember0.cs | 2 +- .../Models/TransformationProperties/Height.cs | 2 +- .../Models/TransformationProperties/Page.cs | 2 +- .../Models/TransformationProperties/Radius.cs | 2 +- .../RadiusProperties/UnionMember1.cs | 2 +- .../TransformationProperties/Rotation.cs | 2 +- .../Models/TransformationProperties/Shadow.cs | 2 +- .../ShadowProperties/UnionMember0.cs | 2 +- .../TransformationProperties/Sharpen.cs | 2 +- .../SharpenProperties/UnionMember0.cs | 2 +- .../TransformationProperties/StartOffset.cs | 2 +- .../Models/TransformationProperties/Trim.cs | 2 +- .../TrimProperties/UnionMember0.cs | 2 +- .../TransformationProperties/UnsharpMask.cs | 2 +- .../UnsharpMaskProperties/UnionMember0.cs | 2 +- .../Models/TransformationProperties/Width.cs | 2 +- .../Models/TransformationProperties/X.cs | 2 +- .../TransformationProperties/XCenter.cs | 2 +- .../Models/TransformationProperties/Y.cs | 2 +- .../TransformationProperties/YCenter.cs | 2 +- .../Models/UnnamedSchemaWithArrayParent0.cs | 2 +- .../AIAutoDescription.cs | 2 +- .../AIAutoDescriptionProperties/Name.cs | 2 +- .../RemoveBgProperties/Name.cs | 2 +- .../Webhooks/UnsafeUnwrapWebhookEvent.cs | 2 +- .../Models/Webhooks/UnwrapWebhookEvent.cs | 2 +- .../DefaultValue.cs | 2 +- .../UnnamedSchemaWithArrayParent7.cs | 2 +- .../MaxValue.cs | 2 +- .../MinValue.cs | 2 +- .../SelectOption.cs | 2 +- 144 files changed, 238 insertions(+), 169 deletions(-) create mode 100644 src/Imagekit/Core/ClientOptions.cs diff --git a/src/Imagekit/Core/ClientOptions.cs b/src/Imagekit/Core/ClientOptions.cs new file mode 100644 index 00000000..50d078a1 --- /dev/null +++ b/src/Imagekit/Core/ClientOptions.cs @@ -0,0 +1,81 @@ +using System; +using System.Net.Http; +using Imagekit.Exceptions; + +namespace Imagekit.Core; + +public struct ClientOptions() +{ + public HttpClient HttpClient { get; set; } = new(); + + Lazy _baseUrl = new(() => + new Uri( + Environment.GetEnvironmentVariable("IMAGE_KIT_BASE_URL") ?? "https://api.imagekit.io" + ) + ); + public Uri BaseUrl + { + readonly get { return _baseUrl.Value; } + set { _baseUrl = new(() => value); } + } + + /// + /// Your ImageKit private API key (starts with `private_`). You can find this + /// in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/api-keys). + /// + Lazy _privateKey = new(() => + Environment.GetEnvironmentVariable("IMAGEKIT_PRIVATE_KEY") + ?? throw new ImageKitInvalidDataException( + string.Format("{0} cannot be null", nameof(PrivateKey)), + new ArgumentNullException(nameof(PrivateKey)) + ) + ); + + /// + /// Your ImageKit private API key (starts with `private_`). You can find this + /// in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/api-keys). + /// + public string PrivateKey + { + readonly get { return _privateKey.Value; } + set { _privateKey = new(() => value); } + } + + /// + /// ImageKit uses your API key as username and ignores the password. The SDK + /// sets a dummy value. You can ignore this field. + /// + Lazy _password = new(() => + Environment.GetEnvironmentVariable("OPTIONAL_IMAGEKIT_IGNORES_THIS") ?? "do_not_set" + ); + + /// + /// ImageKit uses your API key as username and ignores the password. The SDK + /// sets a dummy value. You can ignore this field. + /// + public string? Password + { + readonly get { return _password.Value; } + set { _password = new(() => value); } + } + + /// + /// Your ImageKit webhook secret for verifying webhook signatures (starts with + /// `whsec_`). You can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks). + /// Only required if you're using webhooks. + /// + Lazy _webhookSecret = new(() => + Environment.GetEnvironmentVariable("IMAGEKIT_WEBHOOK_SECRET") + ); + + /// + /// Your ImageKit webhook secret for verifying webhook signatures (starts with + /// `whsec_`). You can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks). + /// Only required if you're using webhooks. + /// + public string? WebhookSecret + { + readonly get { return _webhookSecret.Value; } + set { _webhookSecret = new(() => value); } + } +} diff --git a/src/Imagekit/ImageKitClient.cs b/src/Imagekit/ImageKitClient.cs index 2555a7e8..7ed373d5 100644 --- a/src/Imagekit/ImageKitClient.cs +++ b/src/Imagekit/ImageKitClient.cs @@ -16,48 +16,36 @@ namespace Imagekit; public sealed class ImageKitClient : IImageKitClient { - public HttpClient HttpClient { get; init; } = new(); + readonly ClientOptions _options = new(); + + public HttpClient HttpClient + { + get { return this._options.HttpClient; } + init { this._options.HttpClient = value; } + } - Lazy _baseUrl = new(() => - new Uri( - Environment.GetEnvironmentVariable("IMAGE_KIT_BASE_URL") ?? "https://api.imagekit.io" - ) - ); public Uri BaseUrl { - get { return _baseUrl.Value; } - init { _baseUrl = new(() => value); } + get { return this._options.BaseUrl; } + init { this._options.BaseUrl = value; } } - Lazy _privateKey = new(() => - Environment.GetEnvironmentVariable("IMAGEKIT_PRIVATE_KEY") - ?? throw new ImageKitInvalidDataException( - string.Format("{0} cannot be null", nameof(PrivateKey)), - new ArgumentNullException(nameof(PrivateKey)) - ) - ); public string PrivateKey { - get { return _privateKey.Value; } - init { _privateKey = new(() => value); } + get { return this._options.PrivateKey; } + init { this._options.PrivateKey = value; } } - Lazy _password = new(() => - Environment.GetEnvironmentVariable("OPTIONAL_IMAGEKIT_IGNORES_THIS") ?? "do_not_set" - ); public string? Password { - get { return _password.Value; } - init { _password = new(() => value); } + get { return this._options.Password; } + init { this._options.Password = value; } } - Lazy _webhookSecret = new(() => - Environment.GetEnvironmentVariable("IMAGEKIT_WEBHOOK_SECRET") - ); public string? WebhookSecret { - get { return _webhookSecret.Value; } - init { _webhookSecret = new(() => value); } + get { return this._options.WebhookSecret; } + init { this._options.WebhookSecret = value; } } readonly Lazy _customMetadataFields; diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequest.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequest.cs index 9ca8b0ef..7feca17f 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginRequest.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginRequest.cs @@ -326,7 +326,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class OriginRequestConverter : JsonConverter diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AkeneoPimProperties/Type.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AkeneoPimProperties/Type.cs index c44e8601..8e6ca00f 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AkeneoPimProperties/Type.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AkeneoPimProperties/Type.cs @@ -28,7 +28,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override Type? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AzureBlobProperties/Type.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AzureBlobProperties/Type.cs index 02cd7436..95715670 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AzureBlobProperties/Type.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AzureBlobProperties/Type.cs @@ -28,7 +28,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override Type? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/CloudinaryBackupProperties/Type.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/CloudinaryBackupProperties/Type.cs index b1d2412f..760556a4 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/CloudinaryBackupProperties/Type.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/CloudinaryBackupProperties/Type.cs @@ -28,7 +28,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override Type? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/GcsProperties/Type.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/GcsProperties/Type.cs index 5b0552c0..d989ede9 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/GcsProperties/Type.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/GcsProperties/Type.cs @@ -28,7 +28,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override Type? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3CompatibleProperties/Type.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3CompatibleProperties/Type.cs index fea09e9b..3bb5fcc6 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3CompatibleProperties/Type.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3CompatibleProperties/Type.cs @@ -28,7 +28,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override Type? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3Properties/Type.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3Properties/Type.cs index 35e49069..dd05ded1 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3Properties/Type.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3Properties/Type.cs @@ -28,7 +28,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override Type? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebFolderProperties/Type.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebFolderProperties/Type.cs index ff01fb13..742ea776 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebFolderProperties/Type.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebFolderProperties/Type.cs @@ -28,7 +28,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override Type? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebProxyProperties/Type.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebProxyProperties/Type.cs index f652f82f..190a2659 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebProxyProperties/Type.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebProxyProperties/Type.cs @@ -28,7 +28,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override Type? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponse.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponse.cs index bbc447bc..78f9cfe7 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginResponse.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginResponse.cs @@ -309,7 +309,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class OriginResponseConverter : JsonConverter diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AkeneoPimProperties/Type.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AkeneoPimProperties/Type.cs index 9c33dea1..68757b6e 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AkeneoPimProperties/Type.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AkeneoPimProperties/Type.cs @@ -28,7 +28,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override Type? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AzureBlobProperties/Type.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AzureBlobProperties/Type.cs index 221a2d36..eb2d28b8 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AzureBlobProperties/Type.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AzureBlobProperties/Type.cs @@ -28,7 +28,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override Type? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/CloudinaryBackupProperties/Type.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/CloudinaryBackupProperties/Type.cs index a9e7f082..71521017 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/CloudinaryBackupProperties/Type.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/CloudinaryBackupProperties/Type.cs @@ -28,7 +28,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override Type? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/GcsProperties/Type.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/GcsProperties/Type.cs index f4230283..e366c330 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/GcsProperties/Type.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/GcsProperties/Type.cs @@ -28,7 +28,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override Type? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3CompatibleProperties/Type.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3CompatibleProperties/Type.cs index 8790f6a5..533601bf 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3CompatibleProperties/Type.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3CompatibleProperties/Type.cs @@ -28,7 +28,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override Type? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3Properties/Type.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3Properties/Type.cs index be31fc07..30dc6717 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3Properties/Type.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3Properties/Type.cs @@ -28,7 +28,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override Type? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebFolderProperties/Type.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebFolderProperties/Type.cs index 4c0f90fb..9ac24d56 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebFolderProperties/Type.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebFolderProperties/Type.cs @@ -28,7 +28,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override Type? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebProxyProperties/Type.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebProxyProperties/Type.cs index 14596d66..d46da7b5 100644 --- a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebProxyProperties/Type.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebProxyProperties/Type.cs @@ -28,7 +28,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override Type? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriter.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriter.cs index faf16996..2b1b5a54 100644 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriter.cs +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriter.cs @@ -95,7 +95,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class URLRewriterConverter : JsonConverter diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/Akamai.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/Akamai.cs index fa60b271..47ecfa36 100644 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/Akamai.cs +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/Akamai.cs @@ -28,7 +28,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override Akamai? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/AkamaiProperties/Type.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/AkamaiProperties/Type.cs index 2bee015a..52753b37 100644 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/AkamaiProperties/Type.cs +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/AkamaiProperties/Type.cs @@ -28,7 +28,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override Type? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/CloudinaryProperties/Type.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/CloudinaryProperties/Type.cs index f7c999cc..88babc5e 100644 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/CloudinaryProperties/Type.cs +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/CloudinaryProperties/Type.cs @@ -28,7 +28,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override Type? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/Imgix.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/Imgix.cs index d27e674a..972b4807 100644 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/Imgix.cs +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/Imgix.cs @@ -28,7 +28,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override Imgix? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/ImgixProperties/Type.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/ImgixProperties/Type.cs index 6557764d..e8f354ff 100644 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/ImgixProperties/Type.cs +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/ImgixProperties/Type.cs @@ -28,7 +28,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override Type? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriter.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriter.cs index cc0266ad..5412a719 100644 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriter.cs +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriter.cs @@ -95,7 +95,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class URLRewriterConverter : JsonConverter diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/Akamai.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/Akamai.cs index 4a48a300..6db02d06 100644 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/Akamai.cs +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/Akamai.cs @@ -28,7 +28,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override Akamai? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/AkamaiProperties/Type.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/AkamaiProperties/Type.cs index a6688bd3..30fcf7be 100644 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/AkamaiProperties/Type.cs +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/AkamaiProperties/Type.cs @@ -28,7 +28,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override Type? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/CloudinaryProperties/Type.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/CloudinaryProperties/Type.cs index 7b86640b..f8492246 100644 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/CloudinaryProperties/Type.cs +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/CloudinaryProperties/Type.cs @@ -28,7 +28,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override Type? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/Imgix.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/Imgix.cs index 5b8bda44..6b122f45 100644 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/Imgix.cs +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/Imgix.cs @@ -28,7 +28,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override Imgix? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/ImgixProperties/Type.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/ImgixProperties/Type.cs index ccc09db0..b64c63cc 100644 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/ImgixProperties/Type.cs +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/ImgixProperties/Type.cs @@ -28,7 +28,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override Type? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriter.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriter.cs index e9883946..6cc2ce73 100644 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriter.cs +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriter.cs @@ -95,7 +95,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class URLRewriterConverter : JsonConverter diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/Akamai.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/Akamai.cs index 6a511314..90264d6e 100644 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/Akamai.cs +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/Akamai.cs @@ -28,7 +28,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override Akamai? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/AkamaiProperties/Type.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/AkamaiProperties/Type.cs index ee57be83..69dc236e 100644 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/AkamaiProperties/Type.cs +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/AkamaiProperties/Type.cs @@ -28,7 +28,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override Type? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/CloudinaryProperties/Type.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/CloudinaryProperties/Type.cs index c5b9419c..1a557c4a 100644 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/CloudinaryProperties/Type.cs +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/CloudinaryProperties/Type.cs @@ -28,7 +28,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override Type? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/Imgix.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/Imgix.cs index c22720f1..b8d1ad34 100644 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/Imgix.cs +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/Imgix.cs @@ -28,7 +28,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override Imgix? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/ImgixProperties/Type.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/ImgixProperties/Type.cs index 1d907a37..a12bdc8a 100644 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/ImgixProperties/Type.cs +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/ImgixProperties/Type.cs @@ -28,7 +28,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override Type? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriter.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriter.cs index 131a1ee4..e30018df 100644 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriter.cs +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriter.cs @@ -95,7 +95,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class URLRewriterConverter : JsonConverter diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/Akamai.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/Akamai.cs index 9707dc31..dda4685e 100644 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/Akamai.cs +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/Akamai.cs @@ -28,7 +28,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override Akamai? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/AkamaiProperties/Type.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/AkamaiProperties/Type.cs index bffd19fd..3261f052 100644 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/AkamaiProperties/Type.cs +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/AkamaiProperties/Type.cs @@ -28,7 +28,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override Type? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/CloudinaryProperties/Type.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/CloudinaryProperties/Type.cs index adf4e4c8..367e88df 100644 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/CloudinaryProperties/Type.cs +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/CloudinaryProperties/Type.cs @@ -28,7 +28,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override Type? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/Imgix.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/Imgix.cs index b77b8c08..517efa64 100644 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/Imgix.cs +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/Imgix.cs @@ -28,7 +28,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override Imgix? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/ImgixProperties/Type.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/ImgixProperties/Type.cs index 18f37014..8e3a4b7f 100644 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/ImgixProperties/Type.cs +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/ImgixProperties/Type.cs @@ -28,7 +28,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override Type? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/Assets/AssetListResponse.cs b/src/Imagekit/Models/Assets/AssetListResponse.cs index 29e224a5..4076253d 100644 --- a/src/Imagekit/Models/Assets/AssetListResponse.cs +++ b/src/Imagekit/Models/Assets/AssetListResponse.cs @@ -97,7 +97,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class AssetListResponseConverter : JsonConverter diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/Post.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/Post.cs index 98e17804..29622f91 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/Post.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/Post.cs @@ -130,7 +130,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class PostConverter : JsonConverter diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/AbsProperties/Type.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/AbsProperties/Type.cs index 2b68a5eb..60311c27 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/AbsProperties/Type.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/AbsProperties/Type.cs @@ -31,7 +31,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override Type? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideoProperties/Type.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideoProperties/Type.cs index b429e756..53920414 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideoProperties/Type.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideoProperties/Type.cs @@ -31,7 +31,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override Type? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/ThumbnailProperties/Type.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/ThumbnailProperties/Type.cs index 283c5d2a..5dc6954e 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/ThumbnailProperties/Type.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/ThumbnailProperties/Type.cs @@ -31,7 +31,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override Type? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/TransformationProperties/Type.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/TransformationProperties/Type.cs index cd309429..5e56206b 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/TransformationProperties/Type.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/TransformationProperties/Type.cs @@ -31,7 +31,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override Type? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs index 2f6b8e4d..34d82394 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs @@ -128,7 +128,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class DefaultValueConverter : JsonConverter diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent6.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent6.cs index f40dda0b..fc9e6c7c 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent6.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent6.cs @@ -106,7 +106,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class UnnamedSchemaWithArrayParent6Converter : JsonConverter diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs index a065b234..98d54c61 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs @@ -86,7 +86,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class MaxValueConverter : JsonConverter diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs index 0d299ad3..708de7c7 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs @@ -86,7 +86,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class MinValueConverter : JsonConverter diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs index 6bb4e82b..ec3daccd 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs @@ -106,7 +106,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class SelectOptionConverter : JsonConverter diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValue.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValue.cs index 47beabdb..596568f6 100644 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValue.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValue.cs @@ -112,7 +112,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class DefaultValueConverter : JsonConverter diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent2.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent2.cs index 26e76b85..4e45aa28 100644 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent2.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent2.cs @@ -85,7 +85,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class UnnamedSchemaWithArrayParent0Converter : JsonConverter diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MaxValue.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MaxValue.cs index 0ebf26c3..d6efa5b8 100644 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MaxValue.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MaxValue.cs @@ -82,7 +82,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class MaxValueConverter : JsonConverter diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MinValue.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MinValue.cs index 694e297a..82fa645b 100644 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MinValue.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MinValue.cs @@ -82,7 +82,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class MinValueConverter : JsonConverter diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/SelectOption.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/SelectOption.cs index e25c4638..265d9883 100644 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/SelectOption.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/SelectOption.cs @@ -102,7 +102,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class SelectOptionConverter : JsonConverter diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValue.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValue.cs index f7ebb17e..2bddef38 100644 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValue.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValue.cs @@ -128,7 +128,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class DefaultValueConverter : JsonConverter diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent1.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent1.cs index a7a7a74b..a104ee4e 100644 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent1.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent1.cs @@ -102,7 +102,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class UnnamedSchemaWithArrayParent1Converter : JsonConverter diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MaxValue.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MaxValue.cs index cb5571ed..9b396ae9 100644 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MaxValue.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MaxValue.cs @@ -82,7 +82,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class MaxValueConverter : JsonConverter diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MinValue.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MinValue.cs index 2b66fb7c..f123f61e 100644 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MinValue.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MinValue.cs @@ -82,7 +82,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class MinValueConverter : JsonConverter diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/SelectOption.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/SelectOption.cs index 8e129ee9..e0f7bea7 100644 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/SelectOption.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/SelectOption.cs @@ -102,7 +102,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class SelectOptionConverter : JsonConverter diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValue.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValue.cs index 737e3f19..a5a70940 100644 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValue.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValue.cs @@ -112,7 +112,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class DefaultValueConverter : JsonConverter diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent3.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent3.cs index aaf1fc64..53690e36 100644 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent3.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent3.cs @@ -86,7 +86,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class UnnamedSchemaWithArrayParent2Converter : JsonConverter diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MaxValue.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MaxValue.cs index d87d1194..799667d7 100644 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MaxValue.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MaxValue.cs @@ -82,7 +82,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class MaxValueConverter : JsonConverter diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MinValue.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MinValue.cs index 18967898..114f65b7 100644 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MinValue.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MinValue.cs @@ -82,7 +82,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class MinValueConverter : JsonConverter diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/SelectOption.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/SelectOption.cs index 33cb3967..117d2a37 100644 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/SelectOption.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/SelectOption.cs @@ -94,7 +94,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class SelectOptionConverter : JsonConverter diff --git a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs index 5886fe35..0bb654a5 100644 --- a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs +++ b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs @@ -128,7 +128,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class DefaultValueConverter : JsonConverter diff --git a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent4.cs b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent4.cs index fd1d8943..4a46c3da 100644 --- a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent4.cs +++ b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent4.cs @@ -106,7 +106,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class UnnamedSchemaWithArrayParent4Converter : JsonConverter diff --git a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs index 4d08e395..8be662f7 100644 --- a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs +++ b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs @@ -86,7 +86,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class MaxValueConverter : JsonConverter diff --git a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs index 8e672fb6..667e024f 100644 --- a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs +++ b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs @@ -86,7 +86,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class MinValueConverter : JsonConverter diff --git a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs index 68f79ca6..6c7e8220 100644 --- a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs +++ b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs @@ -106,7 +106,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class SelectOptionConverter : JsonConverter diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/Post.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/Post.cs index 505f085a..8202b339 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/Post.cs +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/Post.cs @@ -130,7 +130,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class PostConverter : JsonConverter diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/AbsProperties/Type.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/AbsProperties/Type.cs index 45eebee8..536187f1 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/AbsProperties/Type.cs +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/AbsProperties/Type.cs @@ -31,7 +31,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override Type? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideoProperties/Type.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideoProperties/Type.cs index 91af05c2..84e534fa 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideoProperties/Type.cs +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideoProperties/Type.cs @@ -31,7 +31,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override Type? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/ThumbnailProperties/Type.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/ThumbnailProperties/Type.cs index 622fac4a..01486bd3 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/ThumbnailProperties/Type.cs +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/ThumbnailProperties/Type.cs @@ -31,7 +31,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override Type? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/TransformationProperties/Type.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/TransformationProperties/Type.cs index 87788254..0ed32429 100644 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/TransformationProperties/Type.cs +++ b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/TransformationProperties/Type.cs @@ -31,7 +31,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override Type? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs index e2750b95..eb7295d8 100644 --- a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs +++ b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs @@ -128,7 +128,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class DefaultValueConverter : JsonConverter diff --git a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent5.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent5.cs index dc3c8eca..0ae661e2 100644 --- a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent5.cs +++ b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent5.cs @@ -106,7 +106,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class UnnamedSchemaWithArrayParent5Converter : JsonConverter diff --git a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs index 09e5dd0e..3dd7f56c 100644 --- a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs +++ b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs @@ -86,7 +86,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class MaxValueConverter : JsonConverter diff --git a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs index 1f7128ee..3b0c2a22 100644 --- a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs +++ b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs @@ -86,7 +86,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class MinValueConverter : JsonConverter diff --git a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs index 970730e0..8af33b5b 100644 --- a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs +++ b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs @@ -106,7 +106,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class SelectOptionConverter : JsonConverter diff --git a/src/Imagekit/Models/Files/UpdateFileRequest.cs b/src/Imagekit/Models/Files/UpdateFileRequest.cs index b5fab031..9da396a0 100644 --- a/src/Imagekit/Models/Files/UpdateFileRequest.cs +++ b/src/Imagekit/Models/Files/UpdateFileRequest.cs @@ -95,7 +95,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class UpdateFileRequestConverter : JsonConverter diff --git a/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/RemoveAITags.cs b/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/RemoveAITags.cs index 1987bf9b..a5ab01a0 100644 --- a/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/RemoveAITags.cs +++ b/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/RemoveAITags.cs @@ -88,7 +88,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class RemoveAITagsConverter : JsonConverter diff --git a/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/RemoveAITagsProperties/UnionMember1.cs b/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/RemoveAITagsProperties/UnionMember1.cs index a5afcbe0..162cc220 100644 --- a/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/RemoveAITagsProperties/UnionMember1.cs +++ b/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/RemoveAITagsProperties/UnionMember1.cs @@ -28,7 +28,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override UnionMember1? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/Overlay.cs b/src/Imagekit/Models/Overlay.cs index d7e9c65c..8c17b85e 100644 --- a/src/Imagekit/Models/Overlay.cs +++ b/src/Imagekit/Models/Overlay.cs @@ -195,7 +195,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class OverlayConverter : JsonConverter diff --git a/src/Imagekit/Models/OverlayPositionProperties/X.cs b/src/Imagekit/Models/OverlayPositionProperties/X.cs index 929bc920..eb97367e 100644 --- a/src/Imagekit/Models/OverlayPositionProperties/X.cs +++ b/src/Imagekit/Models/OverlayPositionProperties/X.cs @@ -83,7 +83,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class XConverter : JsonConverter diff --git a/src/Imagekit/Models/OverlayPositionProperties/Y.cs b/src/Imagekit/Models/OverlayPositionProperties/Y.cs index 72c09aa0..251b7302 100644 --- a/src/Imagekit/Models/OverlayPositionProperties/Y.cs +++ b/src/Imagekit/Models/OverlayPositionProperties/Y.cs @@ -83,7 +83,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class YConverter : JsonConverter diff --git a/src/Imagekit/Models/OverlayTimingProperties/Duration.cs b/src/Imagekit/Models/OverlayTimingProperties/Duration.cs index ddc56267..037f53ac 100644 --- a/src/Imagekit/Models/OverlayTimingProperties/Duration.cs +++ b/src/Imagekit/Models/OverlayTimingProperties/Duration.cs @@ -83,7 +83,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class DurationConverter : JsonConverter diff --git a/src/Imagekit/Models/OverlayTimingProperties/End.cs b/src/Imagekit/Models/OverlayTimingProperties/End.cs index 9ba0eac4..67c1946f 100644 --- a/src/Imagekit/Models/OverlayTimingProperties/End.cs +++ b/src/Imagekit/Models/OverlayTimingProperties/End.cs @@ -84,7 +84,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class EndConverter : JsonConverter diff --git a/src/Imagekit/Models/OverlayTimingProperties/Start.cs b/src/Imagekit/Models/OverlayTimingProperties/Start.cs index ddde0dd7..c858773a 100644 --- a/src/Imagekit/Models/OverlayTimingProperties/Start.cs +++ b/src/Imagekit/Models/OverlayTimingProperties/Start.cs @@ -83,7 +83,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class StartConverter : JsonConverter diff --git a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Gradient.cs b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Gradient.cs index 956b411e..e900be7b 100644 --- a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Gradient.cs +++ b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Gradient.cs @@ -82,7 +82,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class GradientConverter : JsonConverter diff --git a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/GradientProperties/UnionMember0.cs b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/GradientProperties/UnionMember0.cs index e9765fd2..e4f011a8 100644 --- a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/GradientProperties/UnionMember0.cs +++ b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/GradientProperties/UnionMember0.cs @@ -28,7 +28,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override UnionMember0? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Height.cs b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Height.cs index 56ac91e2..69e31379 100644 --- a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Height.cs +++ b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Height.cs @@ -81,7 +81,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class HeightConverter : JsonConverter diff --git a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Radius.cs b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Radius.cs index c5126466..1728ccf5 100644 --- a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Radius.cs +++ b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Radius.cs @@ -81,7 +81,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class RadiusConverter : JsonConverter diff --git a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/RadiusProperties/UnionMember1.cs b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/RadiusProperties/UnionMember1.cs index 78e3a76c..90a6315f 100644 --- a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/RadiusProperties/UnionMember1.cs +++ b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/RadiusProperties/UnionMember1.cs @@ -28,7 +28,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override UnionMember1? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Width.cs b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Width.cs index e094e1ea..3b812d21 100644 --- a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Width.cs +++ b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Width.cs @@ -81,7 +81,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class WidthConverter : JsonConverter diff --git a/src/Imagekit/Models/TextOverlayTransformationProperties/FontSize.cs b/src/Imagekit/Models/TextOverlayTransformationProperties/FontSize.cs index 4b2b31e4..8d696caa 100644 --- a/src/Imagekit/Models/TextOverlayTransformationProperties/FontSize.cs +++ b/src/Imagekit/Models/TextOverlayTransformationProperties/FontSize.cs @@ -80,7 +80,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class FontSizeConverter : JsonConverter diff --git a/src/Imagekit/Models/TextOverlayTransformationProperties/LineHeight.cs b/src/Imagekit/Models/TextOverlayTransformationProperties/LineHeight.cs index 57a4221e..8335c67a 100644 --- a/src/Imagekit/Models/TextOverlayTransformationProperties/LineHeight.cs +++ b/src/Imagekit/Models/TextOverlayTransformationProperties/LineHeight.cs @@ -82,7 +82,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class LineHeightConverter : JsonConverter diff --git a/src/Imagekit/Models/TextOverlayTransformationProperties/Padding.cs b/src/Imagekit/Models/TextOverlayTransformationProperties/Padding.cs index c4f4c51c..abb7a69d 100644 --- a/src/Imagekit/Models/TextOverlayTransformationProperties/Padding.cs +++ b/src/Imagekit/Models/TextOverlayTransformationProperties/Padding.cs @@ -82,7 +82,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class PaddingConverter : JsonConverter diff --git a/src/Imagekit/Models/TextOverlayTransformationProperties/Radius.cs b/src/Imagekit/Models/TextOverlayTransformationProperties/Radius.cs index 06d5a035..262f7059 100644 --- a/src/Imagekit/Models/TextOverlayTransformationProperties/Radius.cs +++ b/src/Imagekit/Models/TextOverlayTransformationProperties/Radius.cs @@ -81,7 +81,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class RadiusConverter : JsonConverter diff --git a/src/Imagekit/Models/TextOverlayTransformationProperties/RadiusProperties/UnionMember1.cs b/src/Imagekit/Models/TextOverlayTransformationProperties/RadiusProperties/UnionMember1.cs index 359ce14f..9f1e2c56 100644 --- a/src/Imagekit/Models/TextOverlayTransformationProperties/RadiusProperties/UnionMember1.cs +++ b/src/Imagekit/Models/TextOverlayTransformationProperties/RadiusProperties/UnionMember1.cs @@ -28,7 +28,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override UnionMember1? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/TextOverlayTransformationProperties/Rotation.cs b/src/Imagekit/Models/TextOverlayTransformationProperties/Rotation.cs index e50d44b6..cc5a5341 100644 --- a/src/Imagekit/Models/TextOverlayTransformationProperties/Rotation.cs +++ b/src/Imagekit/Models/TextOverlayTransformationProperties/Rotation.cs @@ -81,7 +81,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class RotationConverter : JsonConverter diff --git a/src/Imagekit/Models/TextOverlayTransformationProperties/Width.cs b/src/Imagekit/Models/TextOverlayTransformationProperties/Width.cs index 9c3a90df..2a409897 100644 --- a/src/Imagekit/Models/TextOverlayTransformationProperties/Width.cs +++ b/src/Imagekit/Models/TextOverlayTransformationProperties/Width.cs @@ -83,7 +83,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class WidthConverter : JsonConverter diff --git a/src/Imagekit/Models/TransformationProperties/AIDropShadow.cs b/src/Imagekit/Models/TransformationProperties/AIDropShadow.cs index 6c4458d1..3fba9eb9 100644 --- a/src/Imagekit/Models/TransformationProperties/AIDropShadow.cs +++ b/src/Imagekit/Models/TransformationProperties/AIDropShadow.cs @@ -86,7 +86,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class AIDropShadowConverter : JsonConverter diff --git a/src/Imagekit/Models/TransformationProperties/AIDropShadowProperties/UnionMember0.cs b/src/Imagekit/Models/TransformationProperties/AIDropShadowProperties/UnionMember0.cs index 23c297a8..6d8c4f35 100644 --- a/src/Imagekit/Models/TransformationProperties/AIDropShadowProperties/UnionMember0.cs +++ b/src/Imagekit/Models/TransformationProperties/AIDropShadowProperties/UnionMember0.cs @@ -28,7 +28,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override UnionMember0? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/TransformationProperties/AspectRatio.cs b/src/Imagekit/Models/TransformationProperties/AspectRatio.cs index 38977d63..c7d78221 100644 --- a/src/Imagekit/Models/TransformationProperties/AspectRatio.cs +++ b/src/Imagekit/Models/TransformationProperties/AspectRatio.cs @@ -82,7 +82,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class AspectRatioConverter : JsonConverter diff --git a/src/Imagekit/Models/TransformationProperties/Duration.cs b/src/Imagekit/Models/TransformationProperties/Duration.cs index b2ec794f..84271fa2 100644 --- a/src/Imagekit/Models/TransformationProperties/Duration.cs +++ b/src/Imagekit/Models/TransformationProperties/Duration.cs @@ -82,7 +82,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class DurationConverter : JsonConverter diff --git a/src/Imagekit/Models/TransformationProperties/EndOffset.cs b/src/Imagekit/Models/TransformationProperties/EndOffset.cs index 3201b99f..48276d96 100644 --- a/src/Imagekit/Models/TransformationProperties/EndOffset.cs +++ b/src/Imagekit/Models/TransformationProperties/EndOffset.cs @@ -82,7 +82,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class EndOffsetConverter : JsonConverter diff --git a/src/Imagekit/Models/TransformationProperties/Gradient.cs b/src/Imagekit/Models/TransformationProperties/Gradient.cs index cf22e1cc..8868a3ae 100644 --- a/src/Imagekit/Models/TransformationProperties/Gradient.cs +++ b/src/Imagekit/Models/TransformationProperties/Gradient.cs @@ -81,7 +81,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class GradientConverter : JsonConverter diff --git a/src/Imagekit/Models/TransformationProperties/GradientProperties/UnionMember0.cs b/src/Imagekit/Models/TransformationProperties/GradientProperties/UnionMember0.cs index 3488422b..53e72624 100644 --- a/src/Imagekit/Models/TransformationProperties/GradientProperties/UnionMember0.cs +++ b/src/Imagekit/Models/TransformationProperties/GradientProperties/UnionMember0.cs @@ -28,7 +28,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override UnionMember0? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/TransformationProperties/Height.cs b/src/Imagekit/Models/TransformationProperties/Height.cs index 724bac2c..0e80cc07 100644 --- a/src/Imagekit/Models/TransformationProperties/Height.cs +++ b/src/Imagekit/Models/TransformationProperties/Height.cs @@ -83,7 +83,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class HeightConverter : JsonConverter diff --git a/src/Imagekit/Models/TransformationProperties/Page.cs b/src/Imagekit/Models/TransformationProperties/Page.cs index 0dc78f79..dacd8fb7 100644 --- a/src/Imagekit/Models/TransformationProperties/Page.cs +++ b/src/Imagekit/Models/TransformationProperties/Page.cs @@ -197,7 +197,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class PageConverter : JsonConverter diff --git a/src/Imagekit/Models/TransformationProperties/Radius.cs b/src/Imagekit/Models/TransformationProperties/Radius.cs index 09213816..cd247358 100644 --- a/src/Imagekit/Models/TransformationProperties/Radius.cs +++ b/src/Imagekit/Models/TransformationProperties/Radius.cs @@ -81,7 +81,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class RadiusConverter : JsonConverter diff --git a/src/Imagekit/Models/TransformationProperties/RadiusProperties/UnionMember1.cs b/src/Imagekit/Models/TransformationProperties/RadiusProperties/UnionMember1.cs index 9124e6b6..fe7d2e42 100644 --- a/src/Imagekit/Models/TransformationProperties/RadiusProperties/UnionMember1.cs +++ b/src/Imagekit/Models/TransformationProperties/RadiusProperties/UnionMember1.cs @@ -28,7 +28,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override UnionMember1? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/TransformationProperties/Rotation.cs b/src/Imagekit/Models/TransformationProperties/Rotation.cs index 1012869c..38f9a0ed 100644 --- a/src/Imagekit/Models/TransformationProperties/Rotation.cs +++ b/src/Imagekit/Models/TransformationProperties/Rotation.cs @@ -83,7 +83,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class RotationConverter : JsonConverter diff --git a/src/Imagekit/Models/TransformationProperties/Shadow.cs b/src/Imagekit/Models/TransformationProperties/Shadow.cs index fe0560a8..b64f6ecf 100644 --- a/src/Imagekit/Models/TransformationProperties/Shadow.cs +++ b/src/Imagekit/Models/TransformationProperties/Shadow.cs @@ -82,7 +82,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class ShadowConverter : JsonConverter diff --git a/src/Imagekit/Models/TransformationProperties/ShadowProperties/UnionMember0.cs b/src/Imagekit/Models/TransformationProperties/ShadowProperties/UnionMember0.cs index 0ba20c36..06dbd966 100644 --- a/src/Imagekit/Models/TransformationProperties/ShadowProperties/UnionMember0.cs +++ b/src/Imagekit/Models/TransformationProperties/ShadowProperties/UnionMember0.cs @@ -28,7 +28,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override UnionMember0? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/TransformationProperties/Sharpen.cs b/src/Imagekit/Models/TransformationProperties/Sharpen.cs index a5018093..9ec13412 100644 --- a/src/Imagekit/Models/TransformationProperties/Sharpen.cs +++ b/src/Imagekit/Models/TransformationProperties/Sharpen.cs @@ -82,7 +82,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class SharpenConverter : JsonConverter diff --git a/src/Imagekit/Models/TransformationProperties/SharpenProperties/UnionMember0.cs b/src/Imagekit/Models/TransformationProperties/SharpenProperties/UnionMember0.cs index f1208c16..eb9d1273 100644 --- a/src/Imagekit/Models/TransformationProperties/SharpenProperties/UnionMember0.cs +++ b/src/Imagekit/Models/TransformationProperties/SharpenProperties/UnionMember0.cs @@ -28,7 +28,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override UnionMember0? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/TransformationProperties/StartOffset.cs b/src/Imagekit/Models/TransformationProperties/StartOffset.cs index 47c7a7d7..4eaa72f8 100644 --- a/src/Imagekit/Models/TransformationProperties/StartOffset.cs +++ b/src/Imagekit/Models/TransformationProperties/StartOffset.cs @@ -81,7 +81,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class StartOffsetConverter : JsonConverter diff --git a/src/Imagekit/Models/TransformationProperties/Trim.cs b/src/Imagekit/Models/TransformationProperties/Trim.cs index 67c13ec1..ce1298ba 100644 --- a/src/Imagekit/Models/TransformationProperties/Trim.cs +++ b/src/Imagekit/Models/TransformationProperties/Trim.cs @@ -82,7 +82,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class TrimConverter : JsonConverter diff --git a/src/Imagekit/Models/TransformationProperties/TrimProperties/UnionMember0.cs b/src/Imagekit/Models/TransformationProperties/TrimProperties/UnionMember0.cs index 02c238c9..28421060 100644 --- a/src/Imagekit/Models/TransformationProperties/TrimProperties/UnionMember0.cs +++ b/src/Imagekit/Models/TransformationProperties/TrimProperties/UnionMember0.cs @@ -28,7 +28,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override UnionMember0? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/TransformationProperties/UnsharpMask.cs b/src/Imagekit/Models/TransformationProperties/UnsharpMask.cs index 67f94a70..cc5e6889 100644 --- a/src/Imagekit/Models/TransformationProperties/UnsharpMask.cs +++ b/src/Imagekit/Models/TransformationProperties/UnsharpMask.cs @@ -82,7 +82,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class UnsharpMaskConverter : JsonConverter diff --git a/src/Imagekit/Models/TransformationProperties/UnsharpMaskProperties/UnionMember0.cs b/src/Imagekit/Models/TransformationProperties/UnsharpMaskProperties/UnionMember0.cs index 68dc0275..5e6c8be9 100644 --- a/src/Imagekit/Models/TransformationProperties/UnsharpMaskProperties/UnionMember0.cs +++ b/src/Imagekit/Models/TransformationProperties/UnsharpMaskProperties/UnionMember0.cs @@ -28,7 +28,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override UnionMember0? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/TransformationProperties/Width.cs b/src/Imagekit/Models/TransformationProperties/Width.cs index 21f6ab2e..6b79c3fe 100644 --- a/src/Imagekit/Models/TransformationProperties/Width.cs +++ b/src/Imagekit/Models/TransformationProperties/Width.cs @@ -83,7 +83,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class WidthConverter : JsonConverter diff --git a/src/Imagekit/Models/TransformationProperties/X.cs b/src/Imagekit/Models/TransformationProperties/X.cs index 90c37307..a2fbde54 100644 --- a/src/Imagekit/Models/TransformationProperties/X.cs +++ b/src/Imagekit/Models/TransformationProperties/X.cs @@ -80,7 +80,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class XConverter : JsonConverter diff --git a/src/Imagekit/Models/TransformationProperties/XCenter.cs b/src/Imagekit/Models/TransformationProperties/XCenter.cs index b40023f1..068236c4 100644 --- a/src/Imagekit/Models/TransformationProperties/XCenter.cs +++ b/src/Imagekit/Models/TransformationProperties/XCenter.cs @@ -81,7 +81,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class XCenterConverter : JsonConverter diff --git a/src/Imagekit/Models/TransformationProperties/Y.cs b/src/Imagekit/Models/TransformationProperties/Y.cs index 83a5aeed..4680e0ae 100644 --- a/src/Imagekit/Models/TransformationProperties/Y.cs +++ b/src/Imagekit/Models/TransformationProperties/Y.cs @@ -80,7 +80,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class YConverter : JsonConverter diff --git a/src/Imagekit/Models/TransformationProperties/YCenter.cs b/src/Imagekit/Models/TransformationProperties/YCenter.cs index 4d2fa5a9..93006759 100644 --- a/src/Imagekit/Models/TransformationProperties/YCenter.cs +++ b/src/Imagekit/Models/TransformationProperties/YCenter.cs @@ -81,7 +81,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class YCenterConverter : JsonConverter diff --git a/src/Imagekit/Models/UnnamedSchemaWithArrayParent0.cs b/src/Imagekit/Models/UnnamedSchemaWithArrayParent0.cs index 4c2932f3..103e2a75 100644 --- a/src/Imagekit/Models/UnnamedSchemaWithArrayParent0.cs +++ b/src/Imagekit/Models/UnnamedSchemaWithArrayParent0.cs @@ -107,7 +107,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class UnnamedSchemaWithArrayParent0Converter : JsonConverter diff --git a/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/AIAutoDescription.cs b/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/AIAutoDescription.cs index 4c743fdd..e0c2f618 100644 --- a/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/AIAutoDescription.cs +++ b/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/AIAutoDescription.cs @@ -30,7 +30,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override AIAutoDescription? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/AIAutoDescriptionProperties/Name.cs b/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/AIAutoDescriptionProperties/Name.cs index 6b22161b..69b32c50 100644 --- a/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/AIAutoDescriptionProperties/Name.cs +++ b/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/AIAutoDescriptionProperties/Name.cs @@ -31,7 +31,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override Name? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/RemoveBgProperties/Name.cs b/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/RemoveBgProperties/Name.cs index 22a4bced..01447405 100644 --- a/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/RemoveBgProperties/Name.cs +++ b/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/RemoveBgProperties/Name.cs @@ -31,7 +31,7 @@ public void Validate() } } - private class Converter : JsonConverter + class Converter : JsonConverter { public override Name? Read( ref Utf8JsonReader reader, diff --git a/src/Imagekit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs b/src/Imagekit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs index d21a8c90..6482ffd2 100644 --- a/src/Imagekit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs +++ b/src/Imagekit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs @@ -241,7 +241,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class UnsafeUnwrapWebhookEventConverter : JsonConverter diff --git a/src/Imagekit/Models/Webhooks/UnwrapWebhookEvent.cs b/src/Imagekit/Models/Webhooks/UnwrapWebhookEvent.cs index af307b45..1614a815 100644 --- a/src/Imagekit/Models/Webhooks/UnwrapWebhookEvent.cs +++ b/src/Imagekit/Models/Webhooks/UnwrapWebhookEvent.cs @@ -241,7 +241,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class UnwrapWebhookEventConverter : JsonConverter diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs index 796ca3a2..cd6d134b 100644 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs @@ -128,7 +128,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class DefaultValueConverter : JsonConverter diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent7.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent7.cs index 938d9014..64c5b30c 100644 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent7.cs +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent7.cs @@ -106,7 +106,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class UnnamedSchemaWithArrayParent7Converter : JsonConverter diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs index c4902bc0..58d0c73e 100644 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs @@ -86,7 +86,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class MaxValueConverter : JsonConverter diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs index 1c90d555..509f7528 100644 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs @@ -86,7 +86,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class MinValueConverter : JsonConverter diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs index 380f378b..8090e8ef 100644 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs @@ -106,7 +106,7 @@ public void Validate() } } - private record struct UnknownVariant(JsonElement value); + record struct UnknownVariant(JsonElement value); } sealed class SelectOptionConverter : JsonConverter From 73a7359c4d76a55eb62c5caca49bbef68c5d3561 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 3 Nov 2025 22:40:43 +0000 Subject: [PATCH 059/129] feat(client): support request timeout --- src/Imagekit/Core/ClientOptions.cs | 2 ++ src/Imagekit/IImageKitClient.cs | 2 ++ src/Imagekit/ImageKitClient.cs | 14 +++++++++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Imagekit/Core/ClientOptions.cs b/src/Imagekit/Core/ClientOptions.cs index 50d078a1..64a0f2ba 100644 --- a/src/Imagekit/Core/ClientOptions.cs +++ b/src/Imagekit/Core/ClientOptions.cs @@ -19,6 +19,8 @@ public Uri BaseUrl set { _baseUrl = new(() => value); } } + public TimeSpan Timeout { get; set; } = TimeSpan.FromMinutes(1); + /// /// Your ImageKit private API key (starts with `private_`). You can find this /// in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/api-keys). diff --git a/src/Imagekit/IImageKitClient.cs b/src/Imagekit/IImageKitClient.cs index 3c7a1536..12fd09d3 100644 --- a/src/Imagekit/IImageKitClient.cs +++ b/src/Imagekit/IImageKitClient.cs @@ -19,6 +19,8 @@ public interface IImageKitClient Uri BaseUrl { get; init; } + TimeSpan Timeout { get; init; } + /// /// Your ImageKit private API key (starts with `private_`). You can find this /// in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/api-keys). diff --git a/src/Imagekit/ImageKitClient.cs b/src/Imagekit/ImageKitClient.cs index 7ed373d5..fe0467bb 100644 --- a/src/Imagekit/ImageKitClient.cs +++ b/src/Imagekit/ImageKitClient.cs @@ -1,5 +1,6 @@ using System; using System.Net.Http; +using System.Threading; using System.Threading.Tasks; using Imagekit.Core; using Imagekit.Exceptions; @@ -30,6 +31,12 @@ public Uri BaseUrl init { this._options.BaseUrl = value; } } + public TimeSpan Timeout + { + get { return this._options.Timeout; } + init { this._options.Timeout = value; } + } + public string PrivateKey { get { return this._options.PrivateKey; } @@ -104,11 +111,16 @@ public async Task Execute(HttpRequest request) Content = request.Params.BodyContent(), }; request.Params.AddHeadersToRequest(requestMessage, this); + using CancellationTokenSource cts = new(this.Timeout); HttpResponseMessage responseMessage; try { responseMessage = await this - .HttpClient.SendAsync(requestMessage, HttpCompletionOption.ResponseHeadersRead) + .HttpClient.SendAsync( + requestMessage, + HttpCompletionOption.ResponseHeadersRead, + cts.Token + ) .ConfigureAwait(false); } catch (HttpRequestException e1) From cbba006a767b6e1f34bbacd1a22b032fbb27f69a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 28 Jan 2026 18:26:22 +0000 Subject: [PATCH 060/129] feat(client): add response validation option chore(client): simplify field validations --- src/Imagekit/Core/ClientOptions.cs | 2 + src/Imagekit/IImageKitClient.cs | 2 + src/Imagekit/ImageKitClient.cs | 6 + .../URLEndpoints/URLEndpointRequest.cs | 5 +- .../URLEndpoints/URLEndpointResponse.cs | 5 +- .../Beta/V2/Files/FileUploadResponse.cs | 21 +- .../Models/Files/Bulk/BulkAddTagsResponse.cs | 106 +++-- .../Models/Files/Bulk/BulkDeleteResponse.cs | 106 +++-- .../Files/Bulk/BulkRemoveAITagsResponse.cs | 110 +++-- .../Files/Bulk/BulkRemoveTagsResponse.cs | 110 +++-- src/Imagekit/Models/Files/File.cs | 13 +- .../Models/Files/FileUpdateResponse.cs | 13 +- .../Models/Files/FileUploadResponse.cs | 21 +- .../Models/Files/MetadataProperties/Exif.cs | 361 ++++++++------- .../MetadataProperties/ExifProperties/Gps.cs | 106 +++-- .../UpdateFileDetails.cs | 422 +++++++++--------- .../Models/GetImageAttributesOptions.cs | 18 +- .../IntersectionMember1.cs | 10 +- src/Imagekit/Models/ImageOverlay.cs | 1 + .../IntersectionMember1.cs | 1 + src/Imagekit/Models/SolidColorOverlay.cs | 1 + .../IntersectionMember1.cs | 1 + src/Imagekit/Models/SrcOptions.cs | 8 +- src/Imagekit/Models/SubtitleOverlay.cs | 1 + .../IntersectionMember1.cs | 1 + src/Imagekit/Models/TextOverlay.cs | 1 + .../IntersectionMember1.cs | 1 + src/Imagekit/Models/VideoOverlay.cs | 1 + .../IntersectionMember1.cs | 1 + .../IntersectionMember1.cs | 1 + .../IntersectionMember1.cs | 1 + .../IntersectionMember1.cs | 1 + .../IntersectionMember1.cs | 1 + .../IntersectionMember1Properties/Data.cs | 21 +- .../IntersectionMember1.cs | 1 + .../TransformationProperties/Options.cs | 402 +++++++++-------- .../IntersectionMember1.cs | 1 + .../TransformationProperties/Options.cs | 402 +++++++++-------- .../IntersectionMember1.cs | 1 + .../TransformationProperties/Options.cs | 402 +++++++++-------- .../Accounts/Origins/OriginService.cs | 224 ++++------ .../URLEndpoints/URLEndpointService.cs | 230 +++++----- .../Services/Accounts/Usage/UsageService.cs | 70 ++- src/Imagekit/Services/Assets/AssetService.cs | 79 ++-- .../Services/Beta/V2/Files/FileService.cs | 75 ++-- .../Cache/Invalidation/InvalidationService.cs | 114 +++-- .../CustomMetadataFieldService.cs | 212 ++++----- .../Services/Files/Bulk/BulkService.cs | 199 ++++----- src/Imagekit/Services/Files/FileService.cs | 349 +++++++-------- .../Files/Metadata/MetadataService.cs | 109 ++--- .../Services/Files/Versions/VersionService.cs | 188 ++++---- .../Services/Folders/FolderService.cs | 256 +++++------ .../Services/Folders/Job/JobService.cs | 66 ++- 53 files changed, 2263 insertions(+), 2597 deletions(-) diff --git a/src/Imagekit/Core/ClientOptions.cs b/src/Imagekit/Core/ClientOptions.cs index 64a0f2ba..1d8a8278 100644 --- a/src/Imagekit/Core/ClientOptions.cs +++ b/src/Imagekit/Core/ClientOptions.cs @@ -19,6 +19,8 @@ public Uri BaseUrl set { _baseUrl = new(() => value); } } + public bool ResponseValidation { get; set; } = false; + public TimeSpan Timeout { get; set; } = TimeSpan.FromMinutes(1); /// diff --git a/src/Imagekit/IImageKitClient.cs b/src/Imagekit/IImageKitClient.cs index 12fd09d3..c35bc65a 100644 --- a/src/Imagekit/IImageKitClient.cs +++ b/src/Imagekit/IImageKitClient.cs @@ -19,6 +19,8 @@ public interface IImageKitClient Uri BaseUrl { get; init; } + bool ResponseValidation { get; init; } + TimeSpan Timeout { get; init; } /// diff --git a/src/Imagekit/ImageKitClient.cs b/src/Imagekit/ImageKitClient.cs index fe0467bb..32ec1de6 100644 --- a/src/Imagekit/ImageKitClient.cs +++ b/src/Imagekit/ImageKitClient.cs @@ -31,6 +31,12 @@ public Uri BaseUrl init { this._options.BaseUrl = value; } } + public bool ResponseValidation + { + get { return this._options.ResponseValidation; } + init { this._options.ResponseValidation = value; } + } + public TimeSpan Timeout { get { return this._options.Timeout; } diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequest.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequest.cs index a98fbb1f..f5a1569c 100644 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequest.cs +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequest.cs @@ -104,10 +104,7 @@ public URLRewriter? URLRewriter public override void Validate() { _ = this.Description; - foreach (var item in this.Origins ?? []) - { - _ = item; - } + _ = this.Origins; _ = this.URLPrefix; this.URLRewriter?.Validate(); } diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponse.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponse.cs index e99f3904..0416b53f 100644 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponse.cs +++ b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponse.cs @@ -130,10 +130,7 @@ public override void Validate() { _ = this.ID; _ = this.Description; - foreach (var item in this.Origins) - { - _ = item; - } + _ = this.Origins; _ = this.URLPrefix; this.URLRewriter?.Validate(); } diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponse.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponse.cs index 93a9dae4..a1df6d25 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponse.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponse.cs @@ -594,22 +594,10 @@ public override void Validate() _ = this.AudioCodec; _ = this.BitRate; _ = this.CustomCoordinates; - if (this.CustomMetadata != null) - { - foreach (var item in this.CustomMetadata.Values) - { - _ = item; - } - } + _ = this.CustomMetadata; _ = this.Description; _ = this.Duration; - if (this.EmbeddedMetadata != null) - { - foreach (var item in this.EmbeddedMetadata.Values) - { - _ = item; - } - } + _ = this.EmbeddedMetadata; this.ExtensionStatus?.Validate(); _ = this.FileID; _ = this.FilePath; @@ -627,10 +615,7 @@ public override void Validate() } } _ = this.Size; - foreach (var item in this.Tags ?? []) - { - _ = item; - } + _ = this.Tags; _ = this.ThumbnailURL; _ = this.URL; this.VersionInfo?.Validate(); diff --git a/src/Imagekit/Models/Files/Bulk/BulkAddTagsResponse.cs b/src/Imagekit/Models/Files/Bulk/BulkAddTagsResponse.cs index c346fd8b..90e7f3ca 100644 --- a/src/Imagekit/Models/Files/Bulk/BulkAddTagsResponse.cs +++ b/src/Imagekit/Models/Files/Bulk/BulkAddTagsResponse.cs @@ -1,54 +1,52 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files.Bulk; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class BulkAddTagsResponse : ModelBase, IFromRaw -{ - /// - /// An array of fileIds that in which tags were successfully added. - /// - public List? SuccessfullyUpdatedFileIDs - { - get - { - if (!this.Properties.TryGetValue("successfullyUpdatedFileIds", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["successfullyUpdatedFileIds"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - foreach (var item in this.SuccessfullyUpdatedFileIDs ?? []) - { - _ = item; - } - } - - public BulkAddTagsResponse() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - BulkAddTagsResponse(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static BulkAddTagsResponse FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Core; + +namespace Imagekit.Models.Files.Bulk; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class BulkAddTagsResponse : ModelBase, IFromRaw +{ + /// + /// An array of fileIds that in which tags were successfully added. + /// + public List? SuccessfullyUpdatedFileIDs + { + get + { + if (!this.Properties.TryGetValue("successfullyUpdatedFileIds", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["successfullyUpdatedFileIds"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.SuccessfullyUpdatedFileIDs; + } + + public BulkAddTagsResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + BulkAddTagsResponse(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static BulkAddTagsResponse FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/Bulk/BulkDeleteResponse.cs b/src/Imagekit/Models/Files/Bulk/BulkDeleteResponse.cs index e62d675a..618d4df5 100644 --- a/src/Imagekit/Models/Files/Bulk/BulkDeleteResponse.cs +++ b/src/Imagekit/Models/Files/Bulk/BulkDeleteResponse.cs @@ -1,54 +1,52 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files.Bulk; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class BulkDeleteResponse : ModelBase, IFromRaw -{ - /// - /// An array of fileIds that were successfully deleted. - /// - public List? SuccessfullyDeletedFileIDs - { - get - { - if (!this.Properties.TryGetValue("successfullyDeletedFileIds", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["successfullyDeletedFileIds"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - foreach (var item in this.SuccessfullyDeletedFileIDs ?? []) - { - _ = item; - } - } - - public BulkDeleteResponse() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - BulkDeleteResponse(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static BulkDeleteResponse FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Core; + +namespace Imagekit.Models.Files.Bulk; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class BulkDeleteResponse : ModelBase, IFromRaw +{ + /// + /// An array of fileIds that were successfully deleted. + /// + public List? SuccessfullyDeletedFileIDs + { + get + { + if (!this.Properties.TryGetValue("successfullyDeletedFileIds", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["successfullyDeletedFileIds"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.SuccessfullyDeletedFileIDs; + } + + public BulkDeleteResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + BulkDeleteResponse(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static BulkDeleteResponse FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/Bulk/BulkRemoveAITagsResponse.cs b/src/Imagekit/Models/Files/Bulk/BulkRemoveAITagsResponse.cs index 8eb52d35..2675d95b 100644 --- a/src/Imagekit/Models/Files/Bulk/BulkRemoveAITagsResponse.cs +++ b/src/Imagekit/Models/Files/Bulk/BulkRemoveAITagsResponse.cs @@ -1,56 +1,54 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files.Bulk; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class BulkRemoveAITagsResponse : ModelBase, IFromRaw -{ - /// - /// An array of fileIds that in which AITags were successfully removed. - /// - public List? SuccessfullyUpdatedFileIDs - { - get - { - if (!this.Properties.TryGetValue("successfullyUpdatedFileIds", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["successfullyUpdatedFileIds"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - foreach (var item in this.SuccessfullyUpdatedFileIDs ?? []) - { - _ = item; - } - } - - public BulkRemoveAITagsResponse() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - BulkRemoveAITagsResponse(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static BulkRemoveAITagsResponse FromRawUnchecked( - Dictionary properties - ) - { - return new(properties); - } -} +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Core; + +namespace Imagekit.Models.Files.Bulk; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class BulkRemoveAITagsResponse : ModelBase, IFromRaw +{ + /// + /// An array of fileIds that in which AITags were successfully removed. + /// + public List? SuccessfullyUpdatedFileIDs + { + get + { + if (!this.Properties.TryGetValue("successfullyUpdatedFileIds", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["successfullyUpdatedFileIds"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.SuccessfullyUpdatedFileIDs; + } + + public BulkRemoveAITagsResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + BulkRemoveAITagsResponse(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static BulkRemoveAITagsResponse FromRawUnchecked( + Dictionary properties + ) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/Bulk/BulkRemoveTagsResponse.cs b/src/Imagekit/Models/Files/Bulk/BulkRemoveTagsResponse.cs index 453899cb..2d9835eb 100644 --- a/src/Imagekit/Models/Files/Bulk/BulkRemoveTagsResponse.cs +++ b/src/Imagekit/Models/Files/Bulk/BulkRemoveTagsResponse.cs @@ -1,56 +1,54 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files.Bulk; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class BulkRemoveTagsResponse : ModelBase, IFromRaw -{ - /// - /// An array of fileIds that in which tags were successfully removed. - /// - public List? SuccessfullyUpdatedFileIDs - { - get - { - if (!this.Properties.TryGetValue("successfullyUpdatedFileIds", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["successfullyUpdatedFileIds"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - foreach (var item in this.SuccessfullyUpdatedFileIDs ?? []) - { - _ = item; - } - } - - public BulkRemoveTagsResponse() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - BulkRemoveTagsResponse(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static BulkRemoveTagsResponse FromRawUnchecked( - Dictionary properties - ) - { - return new(properties); - } -} +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Core; + +namespace Imagekit.Models.Files.Bulk; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class BulkRemoveTagsResponse : ModelBase, IFromRaw +{ + /// + /// An array of fileIds that in which tags were successfully removed. + /// + public List? SuccessfullyUpdatedFileIDs + { + get + { + if (!this.Properties.TryGetValue("successfullyUpdatedFileIds", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["successfullyUpdatedFileIds"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.SuccessfullyUpdatedFileIDs; + } + + public BulkRemoveTagsResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + BulkRemoveTagsResponse(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static BulkRemoveTagsResponse FromRawUnchecked( + Dictionary properties + ) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/File.cs b/src/Imagekit/Models/Files/File.cs index 959a4c2a..9b805262 100644 --- a/src/Imagekit/Models/Files/File.cs +++ b/src/Imagekit/Models/Files/File.cs @@ -535,13 +535,7 @@ public override void Validate() } _ = this.CreatedAt; _ = this.CustomCoordinates; - if (this.CustomMetadata != null) - { - foreach (var item in this.CustomMetadata.Values) - { - _ = item; - } - } + _ = this.CustomMetadata; _ = this.Description; _ = this.FileID; _ = this.FilePath; @@ -560,10 +554,7 @@ public override void Validate() } } _ = this.Size; - foreach (var item in this.Tags ?? []) - { - _ = item; - } + _ = this.Tags; _ = this.Thumbnail; this.Type?.Validate(); _ = this.UpdatedAt; diff --git a/src/Imagekit/Models/Files/FileUpdateResponse.cs b/src/Imagekit/Models/Files/FileUpdateResponse.cs index 782321bd..ba6c7ca7 100644 --- a/src/Imagekit/Models/Files/FileUpdateResponse.cs +++ b/src/Imagekit/Models/Files/FileUpdateResponse.cs @@ -585,13 +585,7 @@ public override void Validate() } _ = this.CreatedAt; _ = this.CustomCoordinates; - if (this.CustomMetadata != null) - { - foreach (var item in this.CustomMetadata.Values) - { - _ = item; - } - } + _ = this.CustomMetadata; _ = this.Description; _ = this.FileID; _ = this.FilePath; @@ -610,10 +604,7 @@ public override void Validate() } } _ = this.Size; - foreach (var item in this.Tags ?? []) - { - _ = item; - } + _ = this.Tags; _ = this.Thumbnail; this.Type?.Validate(); _ = this.UpdatedAt; diff --git a/src/Imagekit/Models/Files/FileUploadResponse.cs b/src/Imagekit/Models/Files/FileUploadResponse.cs index e6de32e1..9439aecd 100644 --- a/src/Imagekit/Models/Files/FileUploadResponse.cs +++ b/src/Imagekit/Models/Files/FileUploadResponse.cs @@ -590,22 +590,10 @@ public override void Validate() _ = this.AudioCodec; _ = this.BitRate; _ = this.CustomCoordinates; - if (this.CustomMetadata != null) - { - foreach (var item in this.CustomMetadata.Values) - { - _ = item; - } - } + _ = this.CustomMetadata; _ = this.Description; _ = this.Duration; - if (this.EmbeddedMetadata != null) - { - foreach (var item in this.EmbeddedMetadata.Values) - { - _ = item; - } - } + _ = this.EmbeddedMetadata; this.ExtensionStatus?.Validate(); _ = this.FileID; _ = this.FilePath; @@ -623,10 +611,7 @@ public override void Validate() } } _ = this.Size; - foreach (var item in this.Tags ?? []) - { - _ = item; - } + _ = this.Tags; _ = this.ThumbnailURL; _ = this.URL; this.VersionInfo?.Validate(); diff --git a/src/Imagekit/Models/Files/MetadataProperties/Exif.cs b/src/Imagekit/Models/Files/MetadataProperties/Exif.cs index db2ed74c..4ff86411 100644 --- a/src/Imagekit/Models/Files/MetadataProperties/Exif.cs +++ b/src/Imagekit/Models/Files/MetadataProperties/Exif.cs @@ -1,183 +1,178 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using ExifProperties = Imagekit.Models.Files.MetadataProperties.ExifProperties; - -namespace Imagekit.Models.Files.MetadataProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Exif : ModelBase, IFromRaw -{ - /// - /// Object containing Exif details. - /// - public ExifProperties::Exif? Exif1 - { - get - { - if (!this.Properties.TryGetValue("exif", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["exif"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Object containing GPS information. - /// - public ExifProperties::Gps? Gps - { - get - { - if (!this.Properties.TryGetValue("gps", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["gps"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Object containing EXIF image information. - /// - public ExifProperties::Image? Image - { - get - { - if (!this.Properties.TryGetValue("image", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["image"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// JSON object. - /// - public ExifProperties::Interoperability? Interoperability - { - get - { - if (!this.Properties.TryGetValue("interoperability", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["interoperability"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public Dictionary? Makernote - { - get - { - if (!this.Properties.TryGetValue("makernote", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["makernote"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Object containing Thumbnail information. - /// - public ExifProperties::Thumbnail? Thumbnail - { - get - { - if (!this.Properties.TryGetValue("thumbnail", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["thumbnail"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Exif1?.Validate(); - this.Gps?.Validate(); - this.Image?.Validate(); - this.Interoperability?.Validate(); - if (this.Makernote != null) - { - foreach (var item in this.Makernote.Values) - { - _ = item; - } - } - this.Thumbnail?.Validate(); - } - - public Exif() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Exif(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Exif FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Core; +using ExifProperties = Imagekit.Models.Files.MetadataProperties.ExifProperties; + +namespace Imagekit.Models.Files.MetadataProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class Exif : ModelBase, IFromRaw +{ + /// + /// Object containing Exif details. + /// + public ExifProperties::Exif? Exif1 + { + get + { + if (!this.Properties.TryGetValue("exif", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["exif"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Object containing GPS information. + /// + public ExifProperties::Gps? Gps + { + get + { + if (!this.Properties.TryGetValue("gps", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["gps"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Object containing EXIF image information. + /// + public ExifProperties::Image? Image + { + get + { + if (!this.Properties.TryGetValue("image", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["image"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// JSON object. + /// + public ExifProperties::Interoperability? Interoperability + { + get + { + if (!this.Properties.TryGetValue("interoperability", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["interoperability"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public Dictionary? Makernote + { + get + { + if (!this.Properties.TryGetValue("makernote", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["makernote"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Object containing Thumbnail information. + /// + public ExifProperties::Thumbnail? Thumbnail + { + get + { + if (!this.Properties.TryGetValue("thumbnail", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["thumbnail"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.Exif1?.Validate(); + this.Gps?.Validate(); + this.Image?.Validate(); + this.Interoperability?.Validate(); + _ = this.Makernote; + this.Thumbnail?.Validate(); + } + + public Exif() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Exif(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Exif FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/MetadataProperties/ExifProperties/Gps.cs b/src/Imagekit/Models/Files/MetadataProperties/ExifProperties/Gps.cs index aa6d03c1..94a2e672 100644 --- a/src/Imagekit/Models/Files/MetadataProperties/ExifProperties/Gps.cs +++ b/src/Imagekit/Models/Files/MetadataProperties/ExifProperties/Gps.cs @@ -1,54 +1,52 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files.MetadataProperties.ExifProperties; - -/// -/// Object containing GPS information. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class Gps : ModelBase, IFromRaw -{ - public List? GpsVersionID - { - get - { - if (!this.Properties.TryGetValue("GPSVersionID", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["GPSVersionID"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - foreach (var item in this.GpsVersionID ?? []) - { - _ = item; - } - } - - public Gps() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Gps(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Gps FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Core; + +namespace Imagekit.Models.Files.MetadataProperties.ExifProperties; + +/// +/// Object containing GPS information. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class Gps : ModelBase, IFromRaw +{ + public List? GpsVersionID + { + get + { + if (!this.Properties.TryGetValue("GPSVersionID", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["GPSVersionID"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.GpsVersionID; + } + + public Gps() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Gps(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Gps FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetails.cs b/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetails.cs index 54fbecbe..772e7d73 100644 --- a/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetails.cs +++ b/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetails.cs @@ -1,215 +1,207 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Files.FileUpdateParamsProperties.UpdateProperties.UpdateFileDetailsProperties; - -namespace Imagekit.Models.Files.FileUpdateParamsProperties.UpdateProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class UpdateFileDetails : ModelBase, IFromRaw -{ - /// - /// Define an important area in the image in the format `x,y,width,height` e.g. - /// `10,10,100,100`. Send `null` to unset this value. - /// - public string? CustomCoordinates - { - get - { - if (!this.Properties.TryGetValue("customCoordinates", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["customCoordinates"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// A key-value data to be associated with the asset. To unset a key, send `null` - /// value for that key. Before setting any custom metadata on an asset you have - /// to create the field using custom metadata fields API. - /// - public Dictionary? CustomMetadata - { - get - { - if (!this.Properties.TryGetValue("customMetadata", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["customMetadata"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Optional text to describe the contents of the file. - /// - public string? Description - { - get - { - if (!this.Properties.TryGetValue("description", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["description"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Array of extensions to be applied to the asset. Each extension can be configured - /// with specific parameters based on the extension type. - /// - public List? Extensions - { - get - { - if (!this.Properties.TryGetValue("extensions", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["extensions"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// An array of AITags associated with the file that you want to remove, e.g. - /// `["car", "vehicle", "motorsports"]`. - /// - /// If you want to remove all AITags associated with the file, send a string - "all". - /// - /// Note: The remove operation for `AITags` executes before any of the `extensions` - /// are processed. - /// - public RemoveAITags? RemoveAITags - { - get - { - if (!this.Properties.TryGetValue("removeAITags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["removeAITags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// An array of tags associated with the file, such as `["tag1", "tag2"]`. Send - /// `null` to unset all tags associated with the file. - /// - public List? Tags - { - get - { - if (!this.Properties.TryGetValue("tags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["tags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The final status of extensions after they have completed execution will be - /// delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) - /// about the webhook payload structure. - /// - public string? WebhookURL - { - get - { - if (!this.Properties.TryGetValue("webhookUrl", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["webhookUrl"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.CustomCoordinates; - if (this.CustomMetadata != null) - { - foreach (var item in this.CustomMetadata.Values) - { - _ = item; - } - } - _ = this.Description; - foreach (var item in this.Extensions ?? []) - { - item.Validate(); - } - this.RemoveAITags?.Validate(); - foreach (var item in this.Tags ?? []) - { - _ = item; - } - _ = this.WebhookURL; - } - - public UpdateFileDetails() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - UpdateFileDetails(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static UpdateFileDetails FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Core; +using Imagekit.Models.Files.UpdateFileRequestProperties.UpdateFileDetailsProperties; + +namespace Imagekit.Models.Files.UpdateFileRequestProperties; + +[JsonConverter(typeof(ModelConverter))] +public sealed record class UpdateFileDetails : ModelBase, IFromRaw +{ + /// + /// Define an important area in the image in the format `x,y,width,height` e.g. + /// `10,10,100,100`. Send `null` to unset this value. + /// + public string? CustomCoordinates + { + get + { + if (!this.Properties.TryGetValue("customCoordinates", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["customCoordinates"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// A key-value data to be associated with the asset. To unset a key, send `null` + /// value for that key. Before setting any custom metadata on an asset you have + /// to create the field using custom metadata fields API. + /// + public Dictionary? CustomMetadata + { + get + { + if (!this.Properties.TryGetValue("customMetadata", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["customMetadata"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Optional text to describe the contents of the file. + /// + public string? Description + { + get + { + if (!this.Properties.TryGetValue("description", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["description"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Array of extensions to be applied to the asset. Each extension can be configured + /// with specific parameters based on the extension type. + /// + public List? Extensions + { + get + { + if (!this.Properties.TryGetValue("extensions", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["extensions"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// An array of AITags associated with the file that you want to remove, e.g. + /// `["car", "vehicle", "motorsports"]`. + /// + /// If you want to remove all AITags associated with the file, send a string - "all". + /// + /// Note: The remove operation for `AITags` executes before any of the `extensions` + /// are processed. + /// + public RemoveAITags? RemoveAITags + { + get + { + if (!this.Properties.TryGetValue("removeAITags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["removeAITags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// An array of tags associated with the file, such as `["tag1", "tag2"]`. Send + /// `null` to unset all tags associated with the file. + /// + public List? Tags + { + get + { + if (!this.Properties.TryGetValue("tags", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["tags"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// The final status of extensions after they have completed execution will be + /// delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + /// about the webhook payload structure. + /// + public string? WebhookURL + { + get + { + if (!this.Properties.TryGetValue("webhookUrl", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["webhookUrl"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + _ = this.CustomCoordinates; + _ = this.CustomMetadata; + _ = this.Description; + foreach (var item in this.Extensions ?? []) + { + item.Validate(); + } + this.RemoveAITags?.Validate(); + _ = this.Tags; + _ = this.WebhookURL; + } + + public UpdateFileDetails() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UpdateFileDetails(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static UpdateFileDetails FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/GetImageAttributesOptions.cs b/src/Imagekit/Models/GetImageAttributesOptions.cs index c9679f8f..61119bc9 100644 --- a/src/Imagekit/Models/GetImageAttributesOptions.cs +++ b/src/Imagekit/Models/GetImageAttributesOptions.cs @@ -334,27 +334,15 @@ public override void Validate() _ = this.Src; _ = this.URLEndpoint; _ = this.ExpiresIn; - if (this.QueryParameters != null) - { - foreach (var item in this.QueryParameters.Values) - { - _ = item; - } - } + _ = this.QueryParameters; _ = this.Signed; foreach (var item in this.Transformation ?? []) { item.Validate(); } this.TransformationPosition?.Validate(); - foreach (var item in this.DeviceBreakpoints ?? []) - { - _ = item; - } - foreach (var item in this.ImageBreakpoints ?? []) - { - _ = item; - } + _ = this.DeviceBreakpoints; + _ = this.ImageBreakpoints; _ = this.Sizes; _ = this.Width; } diff --git a/src/Imagekit/Models/GetImageAttributesOptionsProperties/IntersectionMember1.cs b/src/Imagekit/Models/GetImageAttributesOptionsProperties/IntersectionMember1.cs index 98303fce..87e64549 100644 --- a/src/Imagekit/Models/GetImageAttributesOptionsProperties/IntersectionMember1.cs +++ b/src/Imagekit/Models/GetImageAttributesOptionsProperties/IntersectionMember1.cs @@ -115,14 +115,8 @@ public double? Width public override void Validate() { - foreach (var item in this.DeviceBreakpoints ?? []) - { - _ = item; - } - foreach (var item in this.ImageBreakpoints ?? []) - { - _ = item; - } + _ = this.DeviceBreakpoints; + _ = this.ImageBreakpoints; _ = this.Sizes; _ = this.Width; } diff --git a/src/Imagekit/Models/ImageOverlay.cs b/src/Imagekit/Models/ImageOverlay.cs index 17bc7fd4..67998652 100644 --- a/src/Imagekit/Models/ImageOverlay.cs +++ b/src/Imagekit/Models/ImageOverlay.cs @@ -150,6 +150,7 @@ public override void Validate() this.Position?.Validate(); this.Timing?.Validate(); _ = this.Input; + _ = this.Type; this.Encoding?.Validate(); foreach (var item in this.Transformation ?? []) { diff --git a/src/Imagekit/Models/ImageOverlayProperties/IntersectionMember1.cs b/src/Imagekit/Models/ImageOverlayProperties/IntersectionMember1.cs index 10900ce7..39ffe018 100644 --- a/src/Imagekit/Models/ImageOverlayProperties/IntersectionMember1.cs +++ b/src/Imagekit/Models/ImageOverlayProperties/IntersectionMember1.cs @@ -106,6 +106,7 @@ public List? Transformation public override void Validate() { _ = this.Input; + _ = this.Type; this.Encoding?.Validate(); foreach (var item in this.Transformation ?? []) { diff --git a/src/Imagekit/Models/SolidColorOverlay.cs b/src/Imagekit/Models/SolidColorOverlay.cs index 4f81be5f..1c2c5d47 100644 --- a/src/Imagekit/Models/SolidColorOverlay.cs +++ b/src/Imagekit/Models/SolidColorOverlay.cs @@ -125,6 +125,7 @@ public override void Validate() this.Position?.Validate(); this.Timing?.Validate(); _ = this.Color; + _ = this.Type; foreach (var item in this.Transformation ?? []) { item.Validate(); diff --git a/src/Imagekit/Models/SolidColorOverlayProperties/IntersectionMember1.cs b/src/Imagekit/Models/SolidColorOverlayProperties/IntersectionMember1.cs index 4ae49341..8cc91aad 100644 --- a/src/Imagekit/Models/SolidColorOverlayProperties/IntersectionMember1.cs +++ b/src/Imagekit/Models/SolidColorOverlayProperties/IntersectionMember1.cs @@ -81,6 +81,7 @@ public List? Transformation public override void Validate() { _ = this.Color; + _ = this.Type; foreach (var item in this.Transformation ?? []) { item.Validate(); diff --git a/src/Imagekit/Models/SrcOptions.cs b/src/Imagekit/Models/SrcOptions.cs index 5616cff3..6244b1fe 100644 --- a/src/Imagekit/Models/SrcOptions.cs +++ b/src/Imagekit/Models/SrcOptions.cs @@ -198,13 +198,7 @@ public override void Validate() _ = this.Src; _ = this.URLEndpoint; _ = this.ExpiresIn; - if (this.QueryParameters != null) - { - foreach (var item in this.QueryParameters.Values) - { - _ = item; - } - } + _ = this.QueryParameters; _ = this.Signed; foreach (var item in this.Transformation ?? []) { diff --git a/src/Imagekit/Models/SubtitleOverlay.cs b/src/Imagekit/Models/SubtitleOverlay.cs index 4baab6cb..78d6f51e 100644 --- a/src/Imagekit/Models/SubtitleOverlay.cs +++ b/src/Imagekit/Models/SubtitleOverlay.cs @@ -148,6 +148,7 @@ public override void Validate() this.Position?.Validate(); this.Timing?.Validate(); _ = this.Input; + _ = this.Type; this.Encoding?.Validate(); foreach (var item in this.Transformation ?? []) { diff --git a/src/Imagekit/Models/SubtitleOverlayProperties/IntersectionMember1.cs b/src/Imagekit/Models/SubtitleOverlayProperties/IntersectionMember1.cs index 2baa35cc..1b8c6a07 100644 --- a/src/Imagekit/Models/SubtitleOverlayProperties/IntersectionMember1.cs +++ b/src/Imagekit/Models/SubtitleOverlayProperties/IntersectionMember1.cs @@ -104,6 +104,7 @@ public List? Transformation public override void Validate() { _ = this.Input; + _ = this.Type; this.Encoding?.Validate(); foreach (var item in this.Transformation ?? []) { diff --git a/src/Imagekit/Models/TextOverlay.cs b/src/Imagekit/Models/TextOverlay.cs index 9d77aafc..d8d3689d 100644 --- a/src/Imagekit/Models/TextOverlay.cs +++ b/src/Imagekit/Models/TextOverlay.cs @@ -149,6 +149,7 @@ public override void Validate() this.Position?.Validate(); this.Timing?.Validate(); _ = this.Text; + _ = this.Type; this.Encoding?.Validate(); foreach (var item in this.Transformation ?? []) { diff --git a/src/Imagekit/Models/TextOverlayProperties/IntersectionMember1.cs b/src/Imagekit/Models/TextOverlayProperties/IntersectionMember1.cs index ebe9d333..df5af566 100644 --- a/src/Imagekit/Models/TextOverlayProperties/IntersectionMember1.cs +++ b/src/Imagekit/Models/TextOverlayProperties/IntersectionMember1.cs @@ -105,6 +105,7 @@ public List? Transformation public override void Validate() { _ = this.Text; + _ = this.Type; this.Encoding?.Validate(); foreach (var item in this.Transformation ?? []) { diff --git a/src/Imagekit/Models/VideoOverlay.cs b/src/Imagekit/Models/VideoOverlay.cs index e74d29f0..ce00be2c 100644 --- a/src/Imagekit/Models/VideoOverlay.cs +++ b/src/Imagekit/Models/VideoOverlay.cs @@ -149,6 +149,7 @@ public override void Validate() this.Position?.Validate(); this.Timing?.Validate(); _ = this.Input; + _ = this.Type; this.Encoding?.Validate(); foreach (var item in this.Transformation ?? []) { diff --git a/src/Imagekit/Models/VideoOverlayProperties/IntersectionMember1.cs b/src/Imagekit/Models/VideoOverlayProperties/IntersectionMember1.cs index 70e42181..65e26bf9 100644 --- a/src/Imagekit/Models/VideoOverlayProperties/IntersectionMember1.cs +++ b/src/Imagekit/Models/VideoOverlayProperties/IntersectionMember1.cs @@ -105,6 +105,7 @@ public List? Transformation public override void Validate() { _ = this.Input; + _ = this.Type; this.Encoding?.Validate(); foreach (var item in this.Transformation ?? []) { diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1.cs index aa680196..6670a2a3 100644 --- a/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1.cs +++ b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1.cs @@ -116,6 +116,7 @@ public override void Validate() _ = this.CreatedAt; this.Data.Validate(); this.Request.Validate(); + _ = this.Type; } public IntersectionMember1() diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1.cs index ac62a61d..f517484c 100644 --- a/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1.cs +++ b/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1.cs @@ -117,6 +117,7 @@ public override void Validate() _ = this.CreatedAt; this.Data.Validate(); this.Request.Validate(); + _ = this.Type; } public IntersectionMember1() diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/IntersectionMember1.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/IntersectionMember1.cs index 2cde87e7..44b9ee28 100644 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/IntersectionMember1.cs +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/IntersectionMember1.cs @@ -116,6 +116,7 @@ public override void Validate() _ = this.CreatedAt; this.Data.Validate(); this.Request.Validate(); + _ = this.Type; } public IntersectionMember1() diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1.cs index 61a51ae8..6cd7c856 100644 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1.cs +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1.cs @@ -120,6 +120,7 @@ public override void Validate() _ = this.CreatedAt; this.Data.Validate(); this.Request.Validate(); + _ = this.Type; } public IntersectionMember1() diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/Data.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/Data.cs index 3da5c72b..f9fb5e64 100644 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/Data.cs +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/Data.cs @@ -591,22 +591,10 @@ public override void Validate() _ = this.AudioCodec; _ = this.BitRate; _ = this.CustomCoordinates; - if (this.CustomMetadata != null) - { - foreach (var item in this.CustomMetadata.Values) - { - _ = item; - } - } + _ = this.CustomMetadata; _ = this.Description; _ = this.Duration; - if (this.EmbeddedMetadata != null) - { - foreach (var item in this.EmbeddedMetadata.Values) - { - _ = item; - } - } + _ = this.EmbeddedMetadata; this.ExtensionStatus?.Validate(); _ = this.FileID; _ = this.FilePath; @@ -624,10 +612,7 @@ public override void Validate() } } _ = this.Size; - foreach (var item in this.Tags ?? []) - { - _ = item; - } + _ = this.Tags; _ = this.ThumbnailURL; _ = this.URL; this.VersionInfo?.Validate(); diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1.cs b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1.cs index af53cd9d..7d8051ed 100644 --- a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1.cs +++ b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1.cs @@ -120,6 +120,7 @@ public override void Validate() _ = this.CreatedAt; this.Data.Validate(); this.Request.Validate(); + _ = this.Type; } public IntersectionMember1() diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Options.cs b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Options.cs index e841bd7a..5e8335ee 100644 --- a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Options.cs +++ b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Options.cs @@ -1,202 +1,200 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.DataProperties.TransformationProperties.OptionsProperties; - -namespace Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.DataProperties.TransformationProperties; - -/// -/// Configuration options for video transformations. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class Options : ModelBase, IFromRaw -{ - /// - /// Audio codec used for encoding (aac or opus). - /// - public ApiEnum? AudioCodec - { - get - { - if (!this.Properties.TryGetValue("audio_codec", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["audio_codec"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to automatically rotate the video based on metadata. - /// - public bool? AutoRotate - { - get - { - if (!this.Properties.TryGetValue("auto_rotate", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["auto_rotate"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Output format for the transformed video or thumbnail. - /// - public ApiEnum? Format - { - get - { - if (!this.Properties.TryGetValue("format", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["format"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Quality setting for the output video. - /// - public long? Quality - { - get - { - if (!this.Properties.TryGetValue("quality", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["quality"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Streaming protocol for adaptive bitrate streaming. - /// - public ApiEnum? StreamProtocol - { - get - { - if (!this.Properties.TryGetValue("stream_protocol", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["stream_protocol"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Array of quality representations for adaptive bitrate streaming. - /// - public List? Variants - { - get - { - if (!this.Properties.TryGetValue("variants", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["variants"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Video codec used for encoding (h264, vp9, or av1). - /// - public ApiEnum? VideoCodec - { - get - { - if (!this.Properties.TryGetValue("video_codec", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["video_codec"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.AudioCodec?.Validate(); - _ = this.AutoRotate; - this.Format?.Validate(); - _ = this.Quality; - this.StreamProtocol?.Validate(); - foreach (var item in this.Variants ?? []) - { - _ = item; - } - this.VideoCodec?.Validate(); - } - - public Options() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Options(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Options FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Core; +using Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.IntersectionMember1Properties.DataProperties.TransformationProperties.OptionsProperties; + +namespace Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.IntersectionMember1Properties.DataProperties.TransformationProperties; + +/// +/// Configuration options for video transformations. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class Options : ModelBase, IFromRaw +{ + /// + /// Audio codec used for encoding (aac or opus). + /// + public ApiEnum? AudioCodec + { + get + { + if (!this.Properties.TryGetValue("audio_codec", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["audio_codec"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to automatically rotate the video based on metadata. + /// + public bool? AutoRotate + { + get + { + if (!this.Properties.TryGetValue("auto_rotate", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["auto_rotate"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Output format for the transformed video or thumbnail. + /// + public ApiEnum? Format + { + get + { + if (!this.Properties.TryGetValue("format", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["format"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Quality setting for the output video. + /// + public long? Quality + { + get + { + if (!this.Properties.TryGetValue("quality", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["quality"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Streaming protocol for adaptive bitrate streaming. + /// + public ApiEnum? StreamProtocol + { + get + { + if (!this.Properties.TryGetValue("stream_protocol", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["stream_protocol"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Array of quality representations for adaptive bitrate streaming. + /// + public List? Variants + { + get + { + if (!this.Properties.TryGetValue("variants", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["variants"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Video codec used for encoding (h264, vp9, or av1). + /// + public ApiEnum? VideoCodec + { + get + { + if (!this.Properties.TryGetValue("video_codec", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["video_codec"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.AudioCodec?.Validate(); + _ = this.AutoRotate; + this.Format?.Validate(); + _ = this.Quality; + this.StreamProtocol?.Validate(); + _ = this.Variants; + this.VideoCodec?.Validate(); + } + + public Options() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Options(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Options FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1.cs index 778dcbed..bfa30916 100644 --- a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1.cs +++ b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1.cs @@ -121,6 +121,7 @@ public override void Validate() _ = this.CreatedAt; this.Data.Validate(); this.Request.Validate(); + _ = this.Type; } public IntersectionMember1() diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Options.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Options.cs index 7b11a0cb..d6b460e0 100644 --- a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Options.cs +++ b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Options.cs @@ -1,202 +1,200 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.DataProperties.TransformationProperties.OptionsProperties; - -namespace Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.DataProperties.TransformationProperties; - -/// -/// Configuration options for video transformations. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class Options : ModelBase, IFromRaw -{ - /// - /// Audio codec used for encoding (aac or opus). - /// - public ApiEnum? AudioCodec - { - get - { - if (!this.Properties.TryGetValue("audio_codec", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["audio_codec"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to automatically rotate the video based on metadata. - /// - public bool? AutoRotate - { - get - { - if (!this.Properties.TryGetValue("auto_rotate", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["auto_rotate"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Output format for the transformed video or thumbnail. - /// - public ApiEnum? Format - { - get - { - if (!this.Properties.TryGetValue("format", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["format"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Quality setting for the output video. - /// - public long? Quality - { - get - { - if (!this.Properties.TryGetValue("quality", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["quality"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Streaming protocol for adaptive bitrate streaming. - /// - public ApiEnum? StreamProtocol - { - get - { - if (!this.Properties.TryGetValue("stream_protocol", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["stream_protocol"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Array of quality representations for adaptive bitrate streaming. - /// - public List? Variants - { - get - { - if (!this.Properties.TryGetValue("variants", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["variants"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Video codec used for encoding (h264, vp9, or av1). - /// - public ApiEnum? VideoCodec - { - get - { - if (!this.Properties.TryGetValue("video_codec", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["video_codec"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.AudioCodec?.Validate(); - _ = this.AutoRotate; - this.Format?.Validate(); - _ = this.Quality; - this.StreamProtocol?.Validate(); - foreach (var item in this.Variants ?? []) - { - _ = item; - } - this.VideoCodec?.Validate(); - } - - public Options() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Options(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Options FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Core; +using Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.IntersectionMember1Properties.DataProperties.TransformationProperties.OptionsProperties; + +namespace Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.IntersectionMember1Properties.DataProperties.TransformationProperties; + +/// +/// Configuration options for video transformations. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class Options : ModelBase, IFromRaw +{ + /// + /// Audio codec used for encoding (aac or opus). + /// + public ApiEnum? AudioCodec + { + get + { + if (!this.Properties.TryGetValue("audio_codec", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["audio_codec"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to automatically rotate the video based on metadata. + /// + public bool? AutoRotate + { + get + { + if (!this.Properties.TryGetValue("auto_rotate", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["auto_rotate"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Output format for the transformed video or thumbnail. + /// + public ApiEnum? Format + { + get + { + if (!this.Properties.TryGetValue("format", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["format"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Quality setting for the output video. + /// + public long? Quality + { + get + { + if (!this.Properties.TryGetValue("quality", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["quality"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Streaming protocol for adaptive bitrate streaming. + /// + public ApiEnum? StreamProtocol + { + get + { + if (!this.Properties.TryGetValue("stream_protocol", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["stream_protocol"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Array of quality representations for adaptive bitrate streaming. + /// + public List? Variants + { + get + { + if (!this.Properties.TryGetValue("variants", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["variants"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Video codec used for encoding (h264, vp9, or av1). + /// + public ApiEnum? VideoCodec + { + get + { + if (!this.Properties.TryGetValue("video_codec", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["video_codec"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.AudioCodec?.Validate(); + _ = this.AutoRotate; + this.Format?.Validate(); + _ = this.Quality; + this.StreamProtocol?.Validate(); + _ = this.Variants; + this.VideoCodec?.Validate(); + } + + public Options() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Options(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Options FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1.cs index 263c0fc8..3cbd4061 100644 --- a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1.cs +++ b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1.cs @@ -142,6 +142,7 @@ public override void Validate() _ = this.CreatedAt; this.Data.Validate(); this.Request.Validate(); + _ = this.Type; this.Timings?.Validate(); } diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Options.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Options.cs index 232195b8..934fd73e 100644 --- a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Options.cs +++ b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Options.cs @@ -1,202 +1,200 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties.TransformationProperties.OptionsProperties; - -namespace Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties.TransformationProperties; - -/// -/// Configuration options for video transformations. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class Options : ModelBase, IFromRaw -{ - /// - /// Audio codec used for encoding (aac or opus). - /// - public ApiEnum? AudioCodec - { - get - { - if (!this.Properties.TryGetValue("audio_codec", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["audio_codec"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to automatically rotate the video based on metadata. - /// - public bool? AutoRotate - { - get - { - if (!this.Properties.TryGetValue("auto_rotate", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["auto_rotate"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Output format for the transformed video or thumbnail. - /// - public ApiEnum? Format - { - get - { - if (!this.Properties.TryGetValue("format", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["format"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Quality setting for the output video. - /// - public long? Quality - { - get - { - if (!this.Properties.TryGetValue("quality", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["quality"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Streaming protocol for adaptive bitrate streaming. - /// - public ApiEnum? StreamProtocol - { - get - { - if (!this.Properties.TryGetValue("stream_protocol", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["stream_protocol"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Array of quality representations for adaptive bitrate streaming. - /// - public List? Variants - { - get - { - if (!this.Properties.TryGetValue("variants", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["variants"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Video codec used for encoding (h264, vp9, or av1). - /// - public ApiEnum? VideoCodec - { - get - { - if (!this.Properties.TryGetValue("video_codec", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["video_codec"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.AudioCodec?.Validate(); - _ = this.AutoRotate; - this.Format?.Validate(); - _ = this.Quality; - this.StreamProtocol?.Validate(); - foreach (var item in this.Variants ?? []) - { - _ = item; - } - this.VideoCodec?.Validate(); - } - - public Options() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Options(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Options FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Core; +using Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.IntersectionMember1Properties.DataProperties.TransformationProperties.OptionsProperties; + +namespace Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.IntersectionMember1Properties.DataProperties.TransformationProperties; + +/// +/// Configuration options for video transformations. +/// +[JsonConverter(typeof(ModelConverter))] +public sealed record class Options : ModelBase, IFromRaw +{ + /// + /// Audio codec used for encoding (aac or opus). + /// + public ApiEnum? AudioCodec + { + get + { + if (!this.Properties.TryGetValue("audio_codec", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["audio_codec"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Whether to automatically rotate the video based on metadata. + /// + public bool? AutoRotate + { + get + { + if (!this.Properties.TryGetValue("auto_rotate", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["auto_rotate"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Output format for the transformed video or thumbnail. + /// + public ApiEnum? Format + { + get + { + if (!this.Properties.TryGetValue("format", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["format"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Quality setting for the output video. + /// + public long? Quality + { + get + { + if (!this.Properties.TryGetValue("quality", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["quality"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Streaming protocol for adaptive bitrate streaming. + /// + public ApiEnum? StreamProtocol + { + get + { + if (!this.Properties.TryGetValue("stream_protocol", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["stream_protocol"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Array of quality representations for adaptive bitrate streaming. + /// + public List? Variants + { + get + { + if (!this.Properties.TryGetValue("variants", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); + } + set + { + this.Properties["variants"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + /// + /// Video codec used for encoding (h264, vp9, or av1). + /// + public ApiEnum? VideoCodec + { + get + { + if (!this.Properties.TryGetValue("video_codec", out JsonElement element)) + return null; + + return JsonSerializer.Deserialize?>( + element, + ModelBase.SerializerOptions + ); + } + set + { + this.Properties["video_codec"] = JsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + } + } + + public override void Validate() + { + this.AudioCodec?.Validate(); + _ = this.AutoRotate; + this.Format?.Validate(); + _ = this.Quality; + this.StreamProtocol?.Validate(); + _ = this.Variants; + this.VideoCodec?.Validate(); + } + + public Options() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Options(Dictionary properties) + { + Properties = properties; + } +#pragma warning restore CS8618 + + public static Options FromRawUnchecked(Dictionary properties) + { + return new(properties); + } +} diff --git a/src/Imagekit/Services/Accounts/Origins/OriginService.cs b/src/Imagekit/Services/Accounts/Origins/OriginService.cs index 336b1f97..f19b6a2a 100644 --- a/src/Imagekit/Services/Accounts/Origins/OriginService.cs +++ b/src/Imagekit/Services/Accounts/Origins/OriginService.cs @@ -1,126 +1,98 @@ -using System; -using System.Collections.Generic; -using System.Net.Http; -using System.Text.Json; -using System.Threading.Tasks; -using Imagekit.Models.Accounts.Origins; - -namespace Imagekit.Services.Accounts.Origins; - -public sealed class OriginService : IOriginService -{ - readonly IImageKitClient _client; - - public OriginService(IImageKitClient client) - { - _client = client; - } - - public async Task Create(OriginCreateParams parameters) - { - using HttpRequestMessage request = new(HttpMethod.Post, parameters.Url(this._client)) - { - Content = parameters.BodyContent(), - }; - parameters.AddHeadersToRequest(request, this._client); - using HttpResponseMessage response = await this - ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) - .ConfigureAwait(false); - if (!response.IsSuccessStatusCode) - { - throw new HttpException( - response.StatusCode, - await response.Content.ReadAsStringAsync().ConfigureAwait(false) - ); - } - - return JsonSerializer.Deserialize( - await response.Content.ReadAsStreamAsync().ConfigureAwait(false), - ModelBase.SerializerOptions - ) ?? throw new NullReferenceException(); - } - - public async Task Update(OriginUpdateParams parameters) - { - using HttpRequestMessage request = new(HttpMethod.Put, parameters.Url(this._client)) - { - Content = parameters.BodyContent(), - }; - parameters.AddHeadersToRequest(request, this._client); - using HttpResponseMessage response = await this - ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) - .ConfigureAwait(false); - if (!response.IsSuccessStatusCode) - { - throw new HttpException( - response.StatusCode, - await response.Content.ReadAsStringAsync().ConfigureAwait(false) - ); - } - - return JsonSerializer.Deserialize( - await response.Content.ReadAsStreamAsync().ConfigureAwait(false), - ModelBase.SerializerOptions - ) ?? throw new NullReferenceException(); - } - - public async Task> List(OriginListParams? parameters = null) - { - parameters ??= new(); - - using HttpRequestMessage request = new(HttpMethod.Get, parameters.Url(this._client)); - parameters.AddHeadersToRequest(request, this._client); - using HttpResponseMessage response = await this - ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) - .ConfigureAwait(false); - if (!response.IsSuccessStatusCode) - { - throw new HttpException( - response.StatusCode, - await response.Content.ReadAsStringAsync().ConfigureAwait(false) - ); - } - - return JsonSerializer.Deserialize>( - await response.Content.ReadAsStreamAsync().ConfigureAwait(false), - ModelBase.SerializerOptions - ) ?? throw new NullReferenceException(); - } - - public async Task Delete(OriginDeleteParams parameters) - { - using HttpRequestMessage request = new(HttpMethod.Delete, parameters.Url(this._client)); - parameters.AddHeadersToRequest(request, this._client); - using HttpResponseMessage response = await this - ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) - .ConfigureAwait(false); - if (!response.IsSuccessStatusCode) - { - throw new HttpException( - response.StatusCode, - await response.Content.ReadAsStringAsync().ConfigureAwait(false) - ); - } - } - - public async Task Get(OriginGetParams parameters) - { - using HttpRequestMessage request = new(HttpMethod.Get, parameters.Url(this._client)); - parameters.AddHeadersToRequest(request, this._client); - using HttpResponseMessage response = await this - ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) - .ConfigureAwait(false); - if (!response.IsSuccessStatusCode) - { - throw new HttpException( - response.StatusCode, - await response.Content.ReadAsStringAsync().ConfigureAwait(false) - ); - } - - return JsonSerializer.Deserialize( - await response.Content.ReadAsStreamAsync().ConfigureAwait(false), - ModelBase.SerializerOptions - ) ?? throw new NullReferenceException(); - } -} +using System.Collections.Generic; +using System.Net.Http; +using System.Threading.Tasks; +using Imagekit.Core; +using Imagekit.Models.Accounts.Origins; + +namespace Imagekit.Services.Accounts.Origins; + +public sealed class OriginService : IOriginService +{ + readonly IImageKitClient _client; + + public OriginService(IImageKitClient client) + { + _client = client; + } + + public async Task Create(OriginCreateParams parameters) + { + HttpRequest request = new() + { + Method = HttpMethod.Post, + Params = parameters, + }; + using var response = await this._client.Execute(request).ConfigureAwait(false); + var originResponse = await response.Deserialize().ConfigureAwait(false); + if (this._client.ResponseValidation) + { + originResponse.Validate(); + } + return originResponse; + } + + public async Task Update(OriginUpdateParams parameters) + { + HttpRequest request = new() + { + Method = HttpMethod.Put, + Params = parameters, + }; + using var response = await this._client.Execute(request).ConfigureAwait(false); + var originResponse = await response.Deserialize().ConfigureAwait(false); + if (this._client.ResponseValidation) + { + originResponse.Validate(); + } + return originResponse; + } + + public async Task> List(OriginListParams? parameters = null) + { + parameters ??= new(); + + HttpRequest request = new() + { + Method = HttpMethod.Get, + Params = parameters, + }; + using var response = await this._client.Execute(request).ConfigureAwait(false); + var originResponses = await response + .Deserialize>() + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + foreach (var item in originResponses) + { + item.Validate(); + } + } + return originResponses; + } + + public async Task Delete(OriginDeleteParams parameters) + { + HttpRequest request = new() + { + Method = HttpMethod.Delete, + Params = parameters, + }; + using var response = await this._client.Execute(request).ConfigureAwait(false); + } + + public async Task Get(OriginGetParams parameters) + { + HttpRequest request = new() + { + Method = HttpMethod.Get, + Params = parameters, + }; + using var response = await this._client.Execute(request).ConfigureAwait(false); + var originResponse = await response.Deserialize().ConfigureAwait(false); + if (this._client.ResponseValidation) + { + originResponse.Validate(); + } + return originResponse; + } +} diff --git a/src/Imagekit/Services/Accounts/URLEndpoints/URLEndpointService.cs b/src/Imagekit/Services/Accounts/URLEndpoints/URLEndpointService.cs index 319410cb..d74a8040 100644 --- a/src/Imagekit/Services/Accounts/URLEndpoints/URLEndpointService.cs +++ b/src/Imagekit/Services/Accounts/URLEndpoints/URLEndpointService.cs @@ -1,126 +1,104 @@ -using System; -using System.Collections.Generic; -using System.Net.Http; -using System.Text.Json; -using System.Threading.Tasks; -using Imagekit.Models.Accounts.URLEndpoints; - -namespace Imagekit.Services.Accounts.URLEndpoints; - -public sealed class URLEndpointService : IURLEndpointService -{ - readonly IImageKitClient _client; - - public URLEndpointService(IImageKitClient client) - { - _client = client; - } - - public async Task Create(URLEndpointCreateParams parameters) - { - using HttpRequestMessage request = new(HttpMethod.Post, parameters.Url(this._client)) - { - Content = parameters.BodyContent(), - }; - parameters.AddHeadersToRequest(request, this._client); - using HttpResponseMessage response = await this - ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) - .ConfigureAwait(false); - if (!response.IsSuccessStatusCode) - { - throw new HttpException( - response.StatusCode, - await response.Content.ReadAsStringAsync().ConfigureAwait(false) - ); - } - - return JsonSerializer.Deserialize( - await response.Content.ReadAsStreamAsync().ConfigureAwait(false), - ModelBase.SerializerOptions - ) ?? throw new NullReferenceException(); - } - - public async Task Update(URLEndpointUpdateParams parameters) - { - using HttpRequestMessage request = new(HttpMethod.Put, parameters.Url(this._client)) - { - Content = parameters.BodyContent(), - }; - parameters.AddHeadersToRequest(request, this._client); - using HttpResponseMessage response = await this - ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) - .ConfigureAwait(false); - if (!response.IsSuccessStatusCode) - { - throw new HttpException( - response.StatusCode, - await response.Content.ReadAsStringAsync().ConfigureAwait(false) - ); - } - - return JsonSerializer.Deserialize( - await response.Content.ReadAsStreamAsync().ConfigureAwait(false), - ModelBase.SerializerOptions - ) ?? throw new NullReferenceException(); - } - - public async Task> List(URLEndpointListParams? parameters = null) - { - parameters ??= new(); - - using HttpRequestMessage request = new(HttpMethod.Get, parameters.Url(this._client)); - parameters.AddHeadersToRequest(request, this._client); - using HttpResponseMessage response = await this - ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) - .ConfigureAwait(false); - if (!response.IsSuccessStatusCode) - { - throw new HttpException( - response.StatusCode, - await response.Content.ReadAsStringAsync().ConfigureAwait(false) - ); - } - - return JsonSerializer.Deserialize>( - await response.Content.ReadAsStreamAsync().ConfigureAwait(false), - ModelBase.SerializerOptions - ) ?? throw new NullReferenceException(); - } - - public async Task Delete(URLEndpointDeleteParams parameters) - { - using HttpRequestMessage request = new(HttpMethod.Delete, parameters.Url(this._client)); - parameters.AddHeadersToRequest(request, this._client); - using HttpResponseMessage response = await this - ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) - .ConfigureAwait(false); - if (!response.IsSuccessStatusCode) - { - throw new HttpException( - response.StatusCode, - await response.Content.ReadAsStringAsync().ConfigureAwait(false) - ); - } - } - - public async Task Get(URLEndpointGetParams parameters) - { - using HttpRequestMessage request = new(HttpMethod.Get, parameters.Url(this._client)); - parameters.AddHeadersToRequest(request, this._client); - using HttpResponseMessage response = await this - ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) - .ConfigureAwait(false); - if (!response.IsSuccessStatusCode) - { - throw new HttpException( - response.StatusCode, - await response.Content.ReadAsStringAsync().ConfigureAwait(false) - ); - } - - return JsonSerializer.Deserialize( - await response.Content.ReadAsStreamAsync().ConfigureAwait(false), - ModelBase.SerializerOptions - ) ?? throw new NullReferenceException(); - } -} +using System.Collections.Generic; +using System.Net.Http; +using System.Threading.Tasks; +using Imagekit.Core; +using Imagekit.Models.Accounts.URLEndpoints; + +namespace Imagekit.Services.Accounts.URLEndpoints; + +public sealed class URLEndpointService : IURLEndpointService +{ + readonly IImageKitClient _client; + + public URLEndpointService(IImageKitClient client) + { + _client = client; + } + + public async Task Create(URLEndpointCreateParams parameters) + { + HttpRequest request = new() + { + Method = HttpMethod.Post, + Params = parameters, + }; + using var response = await this._client.Execute(request).ConfigureAwait(false); + var urlEndpointResponse = await response + .Deserialize() + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + urlEndpointResponse.Validate(); + } + return urlEndpointResponse; + } + + public async Task Update(URLEndpointUpdateParams parameters) + { + HttpRequest request = new() + { + Method = HttpMethod.Put, + Params = parameters, + }; + using var response = await this._client.Execute(request).ConfigureAwait(false); + var urlEndpointResponse = await response + .Deserialize() + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + urlEndpointResponse.Validate(); + } + return urlEndpointResponse; + } + + public async Task> List(URLEndpointListParams? parameters = null) + { + parameters ??= new(); + + HttpRequest request = new() + { + Method = HttpMethod.Get, + Params = parameters, + }; + using var response = await this._client.Execute(request).ConfigureAwait(false); + var urlEndpointResponses = await response + .Deserialize>() + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + foreach (var item in urlEndpointResponses) + { + item.Validate(); + } + } + return urlEndpointResponses; + } + + public async Task Delete(URLEndpointDeleteParams parameters) + { + HttpRequest request = new() + { + Method = HttpMethod.Delete, + Params = parameters, + }; + using var response = await this._client.Execute(request).ConfigureAwait(false); + } + + public async Task Get(URLEndpointGetParams parameters) + { + HttpRequest request = new() + { + Method = HttpMethod.Get, + Params = parameters, + }; + using var response = await this._client.Execute(request).ConfigureAwait(false); + var urlEndpointResponse = await response + .Deserialize() + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + urlEndpointResponse.Validate(); + } + return urlEndpointResponse; + } +} diff --git a/src/Imagekit/Services/Accounts/Usage/UsageService.cs b/src/Imagekit/Services/Accounts/Usage/UsageService.cs index 7e95271c..040f859d 100644 --- a/src/Imagekit/Services/Accounts/Usage/UsageService.cs +++ b/src/Imagekit/Services/Accounts/Usage/UsageService.cs @@ -1,38 +1,32 @@ -using System; -using System.Net.Http; -using System.Text.Json; -using System.Threading.Tasks; -using Imagekit.Models.Accounts.Usage; - -namespace Imagekit.Services.Accounts.Usage; - -public sealed class UsageService : IUsageService -{ - readonly IImageKitClient _client; - - public UsageService(IImageKitClient client) - { - _client = client; - } - - public async Task Get(UsageGetParams parameters) - { - using HttpRequestMessage request = new(HttpMethod.Get, parameters.Url(this._client)); - parameters.AddHeadersToRequest(request, this._client); - using HttpResponseMessage response = await this - ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) - .ConfigureAwait(false); - if (!response.IsSuccessStatusCode) - { - throw new HttpException( - response.StatusCode, - await response.Content.ReadAsStringAsync().ConfigureAwait(false) - ); - } - - return JsonSerializer.Deserialize( - await response.Content.ReadAsStreamAsync().ConfigureAwait(false), - ModelBase.SerializerOptions - ) ?? throw new NullReferenceException(); - } -} +using System.Net.Http; +using System.Threading.Tasks; +using Imagekit.Core; +using Imagekit.Models.Accounts.Usage; + +namespace Imagekit.Services.Accounts.Usage; + +public sealed class UsageService : IUsageService +{ + readonly IImageKitClient _client; + + public UsageService(IImageKitClient client) + { + _client = client; + } + + public async Task Get(UsageGetParams parameters) + { + HttpRequest request = new() + { + Method = HttpMethod.Get, + Params = parameters, + }; + using var response = await this._client.Execute(request).ConfigureAwait(false); + var usage = await response.Deserialize().ConfigureAwait(false); + if (this._client.ResponseValidation) + { + usage.Validate(); + } + return usage; + } +} diff --git a/src/Imagekit/Services/Assets/AssetService.cs b/src/Imagekit/Services/Assets/AssetService.cs index 7f54faac..885d6eea 100644 --- a/src/Imagekit/Services/Assets/AssetService.cs +++ b/src/Imagekit/Services/Assets/AssetService.cs @@ -1,41 +1,38 @@ -using System; -using System.Collections.Generic; -using System.Net.Http; -using System.Text.Json; -using System.Threading.Tasks; -using Imagekit.Models.Assets; - -namespace Imagekit.Services.Assets; - -public sealed class AssetService : IAssetService -{ - readonly IImageKitClient _client; - - public AssetService(IImageKitClient client) - { - _client = client; - } - - public async Task> List(AssetListParams? parameters = null) - { - parameters ??= new(); - - using HttpRequestMessage request = new(HttpMethod.Get, parameters.Url(this._client)); - parameters.AddHeadersToRequest(request, this._client); - using HttpResponseMessage response = await this - ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) - .ConfigureAwait(false); - if (!response.IsSuccessStatusCode) - { - throw new HttpException( - response.StatusCode, - await response.Content.ReadAsStringAsync().ConfigureAwait(false) - ); - } - - return JsonSerializer.Deserialize>( - await response.Content.ReadAsStreamAsync().ConfigureAwait(false), - ModelBase.SerializerOptions - ) ?? throw new NullReferenceException(); - } -} +using System.Collections.Generic; +using System.Net.Http; +using System.Threading.Tasks; +using Imagekit.Core; +using Imagekit.Models.Assets; + +namespace Imagekit.Services.Assets; + +public sealed class AssetService : IAssetService +{ + readonly IImageKitClient _client; + + public AssetService(IImageKitClient client) + { + _client = client; + } + + public async Task> List(AssetListParams? parameters = null) + { + parameters ??= new(); + + HttpRequest request = new() + { + Method = HttpMethod.Get, + Params = parameters, + }; + using var response = await this._client.Execute(request).ConfigureAwait(false); + var assets = await response.Deserialize>().ConfigureAwait(false); + if (this._client.ResponseValidation) + { + foreach (var item in assets) + { + item.Validate(); + } + } + return assets; + } +} diff --git a/src/Imagekit/Services/Beta/V2/Files/FileService.cs b/src/Imagekit/Services/Beta/V2/Files/FileService.cs index cdc7fef3..7e02e1c9 100644 --- a/src/Imagekit/Services/Beta/V2/Files/FileService.cs +++ b/src/Imagekit/Services/Beta/V2/Files/FileService.cs @@ -1,41 +1,34 @@ -using System; -using System.Net.Http; -using System.Text.Json; -using System.Threading.Tasks; -using Imagekit.Models.Beta.V2.Files; - -namespace Imagekit.Services.Beta.V2.Files; - -public sealed class FileService : IFileService -{ - readonly IImageKitClient _client; - - public FileService(IImageKitClient client) - { - _client = client; - } - - public async Task Upload(FileUploadParams parameters) - { - using HttpRequestMessage request = new(HttpMethod.Post, parameters.Url(this._client)) - { - Content = parameters.BodyContent(), - }; - parameters.AddHeadersToRequest(request, this._client); - using HttpResponseMessage response = await this - ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) - .ConfigureAwait(false); - if (!response.IsSuccessStatusCode) - { - throw new HttpException( - response.StatusCode, - await response.Content.ReadAsStringAsync().ConfigureAwait(false) - ); - } - - return JsonSerializer.Deserialize( - await response.Content.ReadAsStreamAsync().ConfigureAwait(false), - ModelBase.SerializerOptions - ) ?? throw new NullReferenceException(); - } -} +using System.Net.Http; +using System.Threading.Tasks; +using Imagekit.Core; +using Imagekit.Models.Beta.V2.Files; + +namespace Imagekit.Services.Beta.V2.Files; + +public sealed class FileService : IFileService +{ + readonly IImageKitClient _client; + + public FileService(IImageKitClient client) + { + _client = client; + } + + public async Task Upload(FileUploadParams parameters) + { + HttpRequest request = new() + { + Method = HttpMethod.Post, + Params = parameters, + }; + using var response = await this._client.Execute(request).ConfigureAwait(false); + var deserializedResponse = await response + .Deserialize() + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + deserializedResponse.Validate(); + } + return deserializedResponse; + } +} diff --git a/src/Imagekit/Services/Cache/Invalidation/InvalidationService.cs b/src/Imagekit/Services/Cache/Invalidation/InvalidationService.cs index 2513605a..c6285146 100644 --- a/src/Imagekit/Services/Cache/Invalidation/InvalidationService.cs +++ b/src/Imagekit/Services/Cache/Invalidation/InvalidationService.cs @@ -1,62 +1,52 @@ -using System; -using System.Net.Http; -using System.Text.Json; -using System.Threading.Tasks; -using Imagekit.Models.Cache.Invalidation; - -namespace Imagekit.Services.Cache.Invalidation; - -public sealed class InvalidationService : IInvalidationService -{ - readonly IImageKitClient _client; - - public InvalidationService(IImageKitClient client) - { - _client = client; - } - - public async Task Create(InvalidationCreateParams parameters) - { - using HttpRequestMessage request = new(HttpMethod.Post, parameters.Url(this._client)) - { - Content = parameters.BodyContent(), - }; - parameters.AddHeadersToRequest(request, this._client); - using HttpResponseMessage response = await this - ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) - .ConfigureAwait(false); - if (!response.IsSuccessStatusCode) - { - throw new HttpException( - response.StatusCode, - await response.Content.ReadAsStringAsync().ConfigureAwait(false) - ); - } - - return JsonSerializer.Deserialize( - await response.Content.ReadAsStreamAsync().ConfigureAwait(false), - ModelBase.SerializerOptions - ) ?? throw new NullReferenceException(); - } - - public async Task Get(InvalidationGetParams parameters) - { - using HttpRequestMessage request = new(HttpMethod.Get, parameters.Url(this._client)); - parameters.AddHeadersToRequest(request, this._client); - using HttpResponseMessage response = await this - ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) - .ConfigureAwait(false); - if (!response.IsSuccessStatusCode) - { - throw new HttpException( - response.StatusCode, - await response.Content.ReadAsStringAsync().ConfigureAwait(false) - ); - } - - return JsonSerializer.Deserialize( - await response.Content.ReadAsStreamAsync().ConfigureAwait(false), - ModelBase.SerializerOptions - ) ?? throw new NullReferenceException(); - } -} +using System.Net.Http; +using System.Threading.Tasks; +using Imagekit.Core; +using Imagekit.Models.Cache.Invalidation; + +namespace Imagekit.Services.Cache.Invalidation; + +public sealed class InvalidationService : IInvalidationService +{ + readonly IImageKitClient _client; + + public InvalidationService(IImageKitClient client) + { + _client = client; + } + + public async Task Create(InvalidationCreateParams parameters) + { + HttpRequest request = new() + { + Method = HttpMethod.Post, + Params = parameters, + }; + using var response = await this._client.Execute(request).ConfigureAwait(false); + var invalidation = await response + .Deserialize() + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + invalidation.Validate(); + } + return invalidation; + } + + public async Task Get(InvalidationGetParams parameters) + { + HttpRequest request = new() + { + Method = HttpMethod.Get, + Params = parameters, + }; + using var response = await this._client.Execute(request).ConfigureAwait(false); + var invalidation = await response + .Deserialize() + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + invalidation.Validate(); + } + return invalidation; + } +} diff --git a/src/Imagekit/Services/CustomMetadataFields/CustomMetadataFieldService.cs b/src/Imagekit/Services/CustomMetadataFields/CustomMetadataFieldService.cs index b293386d..54aa6816 100644 --- a/src/Imagekit/Services/CustomMetadataFields/CustomMetadataFieldService.cs +++ b/src/Imagekit/Services/CustomMetadataFields/CustomMetadataFieldService.cs @@ -1,114 +1,98 @@ -using System; -using System.Collections.Generic; -using System.Net.Http; -using System.Text.Json; -using System.Threading.Tasks; -using Imagekit.Models.CustomMetadataFields; - -namespace Imagekit.Services.CustomMetadataFields; - -public sealed class CustomMetadataFieldService : ICustomMetadataFieldService -{ - readonly IImageKitClient _client; - - public CustomMetadataFieldService(IImageKitClient client) - { - _client = client; - } - - public async Task Create(CustomMetadataFieldCreateParams parameters) - { - using HttpRequestMessage request = new(HttpMethod.Post, parameters.Url(this._client)) - { - Content = parameters.BodyContent(), - }; - parameters.AddHeadersToRequest(request, this._client); - using HttpResponseMessage response = await this - ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) - .ConfigureAwait(false); - if (!response.IsSuccessStatusCode) - { - throw new HttpException( - response.StatusCode, - await response.Content.ReadAsStringAsync().ConfigureAwait(false) - ); - } - - return JsonSerializer.Deserialize( - await response.Content.ReadAsStreamAsync().ConfigureAwait(false), - ModelBase.SerializerOptions - ) ?? throw new NullReferenceException(); - } - - public async Task Update(CustomMetadataFieldUpdateParams parameters) - { - using HttpRequestMessage request = new(HttpMethod.Patch, parameters.Url(this._client)) - { - Content = parameters.BodyContent(), - }; - parameters.AddHeadersToRequest(request, this._client); - using HttpResponseMessage response = await this - ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) - .ConfigureAwait(false); - if (!response.IsSuccessStatusCode) - { - throw new HttpException( - response.StatusCode, - await response.Content.ReadAsStringAsync().ConfigureAwait(false) - ); - } - - return JsonSerializer.Deserialize( - await response.Content.ReadAsStreamAsync().ConfigureAwait(false), - ModelBase.SerializerOptions - ) ?? throw new NullReferenceException(); - } - - public async Task> List( - CustomMetadataFieldListParams? parameters = null - ) - { - parameters ??= new(); - - using HttpRequestMessage request = new(HttpMethod.Get, parameters.Url(this._client)); - parameters.AddHeadersToRequest(request, this._client); - using HttpResponseMessage response = await this - ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) - .ConfigureAwait(false); - if (!response.IsSuccessStatusCode) - { - throw new HttpException( - response.StatusCode, - await response.Content.ReadAsStringAsync().ConfigureAwait(false) - ); - } - - return JsonSerializer.Deserialize>( - await response.Content.ReadAsStreamAsync().ConfigureAwait(false), - ModelBase.SerializerOptions - ) ?? throw new NullReferenceException(); - } - - public async Task Delete( - CustomMetadataFieldDeleteParams parameters - ) - { - using HttpRequestMessage request = new(HttpMethod.Delete, parameters.Url(this._client)); - parameters.AddHeadersToRequest(request, this._client); - using HttpResponseMessage response = await this - ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) - .ConfigureAwait(false); - if (!response.IsSuccessStatusCode) - { - throw new HttpException( - response.StatusCode, - await response.Content.ReadAsStringAsync().ConfigureAwait(false) - ); - } - - return JsonSerializer.Deserialize( - await response.Content.ReadAsStreamAsync().ConfigureAwait(false), - ModelBase.SerializerOptions - ) ?? throw new NullReferenceException(); - } -} +using System.Collections.Generic; +using System.Net.Http; +using System.Threading.Tasks; +using Imagekit.Core; +using Imagekit.Models.CustomMetadataFields; + +namespace Imagekit.Services.CustomMetadataFields; + +public sealed class CustomMetadataFieldService : ICustomMetadataFieldService +{ + readonly IImageKitClient _client; + + public CustomMetadataFieldService(IImageKitClient client) + { + _client = client; + } + + public async Task Create(CustomMetadataFieldCreateParams parameters) + { + HttpRequest request = new() + { + Method = HttpMethod.Post, + Params = parameters, + }; + using var response = await this._client.Execute(request).ConfigureAwait(false); + var customMetadataField = await response + .Deserialize() + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + customMetadataField.Validate(); + } + return customMetadataField; + } + + public async Task Update(CustomMetadataFieldUpdateParams parameters) + { + HttpRequest request = new() + { + Method = HttpMethod.Patch, + Params = parameters, + }; + using var response = await this._client.Execute(request).ConfigureAwait(false); + var customMetadataField = await response + .Deserialize() + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + customMetadataField.Validate(); + } + return customMetadataField; + } + + public async Task> List( + CustomMetadataFieldListParams? parameters = null + ) + { + parameters ??= new(); + + HttpRequest request = new() + { + Method = HttpMethod.Get, + Params = parameters, + }; + using var response = await this._client.Execute(request).ConfigureAwait(false); + var customMetadataFields = await response + .Deserialize>() + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + foreach (var item in customMetadataFields) + { + item.Validate(); + } + } + return customMetadataFields; + } + + public async Task Delete( + CustomMetadataFieldDeleteParams parameters + ) + { + HttpRequest request = new() + { + Method = HttpMethod.Delete, + Params = parameters, + }; + using var response = await this._client.Execute(request).ConfigureAwait(false); + var customMetadataField = await response + .Deserialize() + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + customMetadataField.Validate(); + } + return customMetadataField; + } +} diff --git a/src/Imagekit/Services/Files/Bulk/BulkService.cs b/src/Imagekit/Services/Files/Bulk/BulkService.cs index a10d960d..72d82c5f 100644 --- a/src/Imagekit/Services/Files/Bulk/BulkService.cs +++ b/src/Imagekit/Services/Files/Bulk/BulkService.cs @@ -1,113 +1,86 @@ -using System; -using System.Net.Http; -using System.Text.Json; -using System.Threading.Tasks; -using Imagekit.Models.Files.Bulk; - -namespace Imagekit.Services.Files.Bulk; - -public sealed class BulkService : IBulkService -{ - readonly IImageKitClient _client; - - public BulkService(IImageKitClient client) - { - _client = client; - } - - public async Task Delete(BulkDeleteParams parameters) - { - using HttpRequestMessage request = new(HttpMethod.Post, parameters.Url(this._client)) - { - Content = parameters.BodyContent(), - }; - parameters.AddHeadersToRequest(request, this._client); - using HttpResponseMessage response = await this - ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) - .ConfigureAwait(false); - if (!response.IsSuccessStatusCode) - { - throw new HttpException( - response.StatusCode, - await response.Content.ReadAsStringAsync().ConfigureAwait(false) - ); - } - - return JsonSerializer.Deserialize( - await response.Content.ReadAsStreamAsync().ConfigureAwait(false), - ModelBase.SerializerOptions - ) ?? throw new NullReferenceException(); - } - - public async Task AddTags(BulkAddTagsParams parameters) - { - using HttpRequestMessage request = new(HttpMethod.Post, parameters.Url(this._client)) - { - Content = parameters.BodyContent(), - }; - parameters.AddHeadersToRequest(request, this._client); - using HttpResponseMessage response = await this - ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) - .ConfigureAwait(false); - if (!response.IsSuccessStatusCode) - { - throw new HttpException( - response.StatusCode, - await response.Content.ReadAsStringAsync().ConfigureAwait(false) - ); - } - - return JsonSerializer.Deserialize( - await response.Content.ReadAsStreamAsync().ConfigureAwait(false), - ModelBase.SerializerOptions - ) ?? throw new NullReferenceException(); - } - - public async Task RemoveAITags(BulkRemoveAITagsParams parameters) - { - using HttpRequestMessage request = new(HttpMethod.Post, parameters.Url(this._client)) - { - Content = parameters.BodyContent(), - }; - parameters.AddHeadersToRequest(request, this._client); - using HttpResponseMessage response = await this - ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) - .ConfigureAwait(false); - if (!response.IsSuccessStatusCode) - { - throw new HttpException( - response.StatusCode, - await response.Content.ReadAsStringAsync().ConfigureAwait(false) - ); - } - - return JsonSerializer.Deserialize( - await response.Content.ReadAsStreamAsync().ConfigureAwait(false), - ModelBase.SerializerOptions - ) ?? throw new NullReferenceException(); - } - - public async Task RemoveTags(BulkRemoveTagsParams parameters) - { - using HttpRequestMessage request = new(HttpMethod.Post, parameters.Url(this._client)) - { - Content = parameters.BodyContent(), - }; - parameters.AddHeadersToRequest(request, this._client); - using HttpResponseMessage response = await this - ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) - .ConfigureAwait(false); - if (!response.IsSuccessStatusCode) - { - throw new HttpException( - response.StatusCode, - await response.Content.ReadAsStringAsync().ConfigureAwait(false) - ); - } - - return JsonSerializer.Deserialize( - await response.Content.ReadAsStreamAsync().ConfigureAwait(false), - ModelBase.SerializerOptions - ) ?? throw new NullReferenceException(); - } -} +using System.Net.Http; +using System.Threading.Tasks; +using Imagekit.Core; +using Imagekit.Models.Files.Bulk; + +namespace Imagekit.Services.Files.Bulk; + +public sealed class BulkService : IBulkService +{ + readonly IImageKitClient _client; + + public BulkService(IImageKitClient client) + { + _client = client; + } + + public async Task Delete(BulkDeleteParams parameters) + { + HttpRequest request = new() + { + Method = HttpMethod.Post, + Params = parameters, + }; + using var response = await this._client.Execute(request).ConfigureAwait(false); + var bulk = await response.Deserialize().ConfigureAwait(false); + if (this._client.ResponseValidation) + { + bulk.Validate(); + } + return bulk; + } + + public async Task AddTags(BulkAddTagsParams parameters) + { + HttpRequest request = new() + { + Method = HttpMethod.Post, + Params = parameters, + }; + using var response = await this._client.Execute(request).ConfigureAwait(false); + var deserializedResponse = await response + .Deserialize() + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + deserializedResponse.Validate(); + } + return deserializedResponse; + } + + public async Task RemoveAITags(BulkRemoveAITagsParams parameters) + { + HttpRequest request = new() + { + Method = HttpMethod.Post, + Params = parameters, + }; + using var response = await this._client.Execute(request).ConfigureAwait(false); + var deserializedResponse = await response + .Deserialize() + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + deserializedResponse.Validate(); + } + return deserializedResponse; + } + + public async Task RemoveTags(BulkRemoveTagsParams parameters) + { + HttpRequest request = new() + { + Method = HttpMethod.Post, + Params = parameters, + }; + using var response = await this._client.Execute(request).ConfigureAwait(false); + var deserializedResponse = await response + .Deserialize() + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + deserializedResponse.Validate(); + } + return deserializedResponse; + } +} diff --git a/src/Imagekit/Services/Files/FileService.cs b/src/Imagekit/Services/Files/FileService.cs index 7ec98b70..adbbcd48 100644 --- a/src/Imagekit/Services/Files/FileService.cs +++ b/src/Imagekit/Services/Files/FileService.cs @@ -1,198 +1,151 @@ -using System; -using System.Net.Http; -using System.Text.Json; -using System.Threading.Tasks; -using Imagekit.Models.Files; -using Imagekit.Services.Files.Bulk; -using Imagekit.Services.Files.Metadata; -using Imagekit.Services.Files.Versions; - -namespace Imagekit.Services.Files; - -public sealed class FileService : IFileService -{ - readonly IImageKitClient _client; - - public FileService(IImageKitClient client) - { - _client = client; - _bulk = new(() => new BulkService(client)); - _versions = new(() => new VersionService(client)); - _metadata = new(() => new MetadataService(client)); - } - - readonly Lazy _bulk; - public IBulkService Bulk - { - get { return _bulk.Value; } - } - - readonly Lazy _versions; - public IVersionService Versions - { - get { return _versions.Value; } - } - - readonly Lazy _metadata; - public IMetadataService Metadata - { - get { return _metadata.Value; } - } - - public async Task Update(FileUpdateParams parameters) - { - using HttpRequestMessage request = new(HttpMethod.Patch, parameters.Url(this._client)) - { - Content = parameters.BodyContent(), - }; - parameters.AddHeadersToRequest(request, this._client); - using HttpResponseMessage response = await this - ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) - .ConfigureAwait(false); - if (!response.IsSuccessStatusCode) - { - throw new HttpException( - response.StatusCode, - await response.Content.ReadAsStringAsync().ConfigureAwait(false) - ); - } - - return JsonSerializer.Deserialize( - await response.Content.ReadAsStreamAsync().ConfigureAwait(false), - ModelBase.SerializerOptions - ) ?? throw new NullReferenceException(); - } - - public async Task Delete(FileDeleteParams parameters) - { - using HttpRequestMessage request = new(HttpMethod.Delete, parameters.Url(this._client)); - parameters.AddHeadersToRequest(request, this._client); - using HttpResponseMessage response = await this - ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) - .ConfigureAwait(false); - if (!response.IsSuccessStatusCode) - { - throw new HttpException( - response.StatusCode, - await response.Content.ReadAsStringAsync().ConfigureAwait(false) - ); - } - } - - public async Task Copy(FileCopyParams parameters) - { - using HttpRequestMessage request = new(HttpMethod.Post, parameters.Url(this._client)) - { - Content = parameters.BodyContent(), - }; - parameters.AddHeadersToRequest(request, this._client); - using HttpResponseMessage response = await this - ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) - .ConfigureAwait(false); - if (!response.IsSuccessStatusCode) - { - throw new HttpException( - response.StatusCode, - await response.Content.ReadAsStringAsync().ConfigureAwait(false) - ); - } - - return JsonSerializer.Deserialize( - await response.Content.ReadAsStreamAsync().ConfigureAwait(false), - ModelBase.SerializerOptions - ) ?? throw new NullReferenceException(); - } - - public async Task Get(FileGetParams parameters) - { - using HttpRequestMessage request = new(HttpMethod.Get, parameters.Url(this._client)); - parameters.AddHeadersToRequest(request, this._client); - using HttpResponseMessage response = await this - ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) - .ConfigureAwait(false); - if (!response.IsSuccessStatusCode) - { - throw new HttpException( - response.StatusCode, - await response.Content.ReadAsStringAsync().ConfigureAwait(false) - ); - } - - return JsonSerializer.Deserialize( - await response.Content.ReadAsStreamAsync().ConfigureAwait(false), - ModelBase.SerializerOptions - ) ?? throw new NullReferenceException(); - } - - public async Task Move(FileMoveParams parameters) - { - using HttpRequestMessage request = new(HttpMethod.Post, parameters.Url(this._client)) - { - Content = parameters.BodyContent(), - }; - parameters.AddHeadersToRequest(request, this._client); - using HttpResponseMessage response = await this - ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) - .ConfigureAwait(false); - if (!response.IsSuccessStatusCode) - { - throw new HttpException( - response.StatusCode, - await response.Content.ReadAsStringAsync().ConfigureAwait(false) - ); - } - - return JsonSerializer.Deserialize( - await response.Content.ReadAsStreamAsync().ConfigureAwait(false), - ModelBase.SerializerOptions - ) ?? throw new NullReferenceException(); - } - - public async Task Rename(FileRenameParams parameters) - { - using HttpRequestMessage request = new(HttpMethod.Put, parameters.Url(this._client)) - { - Content = parameters.BodyContent(), - }; - parameters.AddHeadersToRequest(request, this._client); - using HttpResponseMessage response = await this - ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) - .ConfigureAwait(false); - if (!response.IsSuccessStatusCode) - { - throw new HttpException( - response.StatusCode, - await response.Content.ReadAsStringAsync().ConfigureAwait(false) - ); - } - - return JsonSerializer.Deserialize( - await response.Content.ReadAsStreamAsync().ConfigureAwait(false), - ModelBase.SerializerOptions - ) ?? throw new NullReferenceException(); - } - - public async Task Upload(FileUploadParams parameters) - { - using HttpRequestMessage request = new(HttpMethod.Post, parameters.Url(this._client)) - { - Content = parameters.BodyContent(), - }; - parameters.AddHeadersToRequest(request, this._client); - using HttpResponseMessage response = await this - ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) - .ConfigureAwait(false); - if (!response.IsSuccessStatusCode) - { - throw new HttpException( - response.StatusCode, - await response.Content.ReadAsStringAsync().ConfigureAwait(false) - ); - } - - return JsonSerializer.Deserialize( - await response.Content.ReadAsStreamAsync().ConfigureAwait(false), - ModelBase.SerializerOptions - ) ?? throw new NullReferenceException(); - } -} +using System; +using System.Net.Http; +using System.Threading.Tasks; +using Imagekit.Core; +using Imagekit.Models.Files; +using Imagekit.Services.Files.Bulk; +using Imagekit.Services.Files.Metadata; +using Imagekit.Services.Files.Versions; + +namespace Imagekit.Services.Files; + +public sealed class FileService : IFileService +{ + readonly IImageKitClient _client; + + public FileService(IImageKitClient client) + { + _client = client; + _bulk = new(() => new BulkService(client)); + _versions = new(() => new VersionService(client)); + _metadata = new(() => new MetadataService(client)); + } + + readonly Lazy _bulk; + public IBulkService Bulk + { + get { return _bulk.Value; } + } + + readonly Lazy _versions; + public IVersionService Versions + { + get { return _versions.Value; } + } + + readonly Lazy _metadata; + public IMetadataService Metadata + { + get { return _metadata.Value; } + } + + public async Task Update(FileUpdateParams parameters) + { + HttpRequest request = new() + { + Method = HttpMethod.Patch, + Params = parameters, + }; + using var response = await this._client.Execute(request).ConfigureAwait(false); + var file = await response.Deserialize().ConfigureAwait(false); + if (this._client.ResponseValidation) + { + file.Validate(); + } + return file; + } + + public async Task Delete(FileDeleteParams parameters) + { + HttpRequest request = new() + { + Method = HttpMethod.Delete, + Params = parameters, + }; + using var response = await this._client.Execute(request).ConfigureAwait(false); + } + + public async Task Copy(FileCopyParams parameters) + { + HttpRequest request = new() + { + Method = HttpMethod.Post, + Params = parameters, + }; + using var response = await this._client.Execute(request).ConfigureAwait(false); + var deserializedResponse = await response + .Deserialize() + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + deserializedResponse.Validate(); + } + return deserializedResponse; + } + + public async Task Get(FileGetParams parameters) + { + HttpRequest request = new() { Method = HttpMethod.Get, Params = parameters }; + using var response = await this._client.Execute(request).ConfigureAwait(false); + var file = await response.Deserialize().ConfigureAwait(false); + if (this._client.ResponseValidation) + { + file.Validate(); + } + return file; + } + + public async Task Move(FileMoveParams parameters) + { + HttpRequest request = new() + { + Method = HttpMethod.Post, + Params = parameters, + }; + using var response = await this._client.Execute(request).ConfigureAwait(false); + var deserializedResponse = await response + .Deserialize() + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + deserializedResponse.Validate(); + } + return deserializedResponse; + } + + public async Task Rename(FileRenameParams parameters) + { + HttpRequest request = new() + { + Method = HttpMethod.Put, + Params = parameters, + }; + using var response = await this._client.Execute(request).ConfigureAwait(false); + var deserializedResponse = await response + .Deserialize() + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + deserializedResponse.Validate(); + } + return deserializedResponse; + } + + public async Task Upload(FileUploadParams parameters) + { + HttpRequest request = new() + { + Method = HttpMethod.Post, + Params = parameters, + }; + using var response = await this._client.Execute(request).ConfigureAwait(false); + var deserializedResponse = await response + .Deserialize() + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + deserializedResponse.Validate(); + } + return deserializedResponse; + } +} diff --git a/src/Imagekit/Services/Files/Metadata/MetadataService.cs b/src/Imagekit/Services/Files/Metadata/MetadataService.cs index 46110365..e0c1d703 100644 --- a/src/Imagekit/Services/Files/Metadata/MetadataService.cs +++ b/src/Imagekit/Services/Files/Metadata/MetadataService.cs @@ -1,60 +1,49 @@ -using System; -using System.Net.Http; -using System.Text.Json; -using System.Threading.Tasks; -using Imagekit.Models.Files.Metadata; -using Files = Imagekit.Models.Files; - -namespace Imagekit.Services.Files.Metadata; - -public sealed class MetadataService : IMetadataService -{ - readonly IImageKitClient _client; - - public MetadataService(IImageKitClient client) - { - _client = client; - } - - public async Task Get(MetadataGetParams parameters) - { - using HttpRequestMessage request = new(HttpMethod.Get, parameters.Url(this._client)); - parameters.AddHeadersToRequest(request, this._client); - using HttpResponseMessage response = await this - ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) - .ConfigureAwait(false); - if (!response.IsSuccessStatusCode) - { - throw new HttpException( - response.StatusCode, - await response.Content.ReadAsStringAsync().ConfigureAwait(false) - ); - } - - return JsonSerializer.Deserialize( - await response.Content.ReadAsStreamAsync().ConfigureAwait(false), - ModelBase.SerializerOptions - ) ?? throw new NullReferenceException(); - } - - public async Task GetFromURL(MetadataGetFromURLParams parameters) - { - using HttpRequestMessage request = new(HttpMethod.Get, parameters.Url(this._client)); - parameters.AddHeadersToRequest(request, this._client); - using HttpResponseMessage response = await this - ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) - .ConfigureAwait(false); - if (!response.IsSuccessStatusCode) - { - throw new HttpException( - response.StatusCode, - await response.Content.ReadAsStringAsync().ConfigureAwait(false) - ); - } - - return JsonSerializer.Deserialize( - await response.Content.ReadAsStreamAsync().ConfigureAwait(false), - ModelBase.SerializerOptions - ) ?? throw new NullReferenceException(); - } -} +using System.Net.Http; +using System.Threading.Tasks; +using Imagekit.Core; +using Imagekit.Models.Files.Metadata; +using Files = Imagekit.Models.Files; + +namespace Imagekit.Services.Files.Metadata; + +public sealed class MetadataService : IMetadataService +{ + readonly IImageKitClient _client; + + public MetadataService(IImageKitClient client) + { + _client = client; + } + + public async Task Get(MetadataGetParams parameters) + { + HttpRequest request = new() + { + Method = HttpMethod.Get, + Params = parameters, + }; + using var response = await this._client.Execute(request).ConfigureAwait(false); + var metadata = await response.Deserialize().ConfigureAwait(false); + if (this._client.ResponseValidation) + { + metadata.Validate(); + } + return metadata; + } + + public async Task GetFromURL(MetadataGetFromURLParams parameters) + { + HttpRequest request = new() + { + Method = HttpMethod.Get, + Params = parameters, + }; + using var response = await this._client.Execute(request).ConfigureAwait(false); + var metadata = await response.Deserialize().ConfigureAwait(false); + if (this._client.ResponseValidation) + { + metadata.Validate(); + } + return metadata; + } +} diff --git a/src/Imagekit/Services/Files/Versions/VersionService.cs b/src/Imagekit/Services/Files/Versions/VersionService.cs index e47cc714..83231194 100644 --- a/src/Imagekit/Services/Files/Versions/VersionService.cs +++ b/src/Imagekit/Services/Files/Versions/VersionService.cs @@ -1,103 +1,85 @@ -using System; -using System.Collections.Generic; -using System.Net.Http; -using System.Text.Json; -using System.Threading.Tasks; -using Imagekit.Models.Files; -using Imagekit.Models.Files.Versions; - -namespace Imagekit.Services.Files.Versions; - -public sealed class VersionService : IVersionService -{ - readonly IImageKitClient _client; - - public VersionService(IImageKitClient client) - { - _client = client; - } - - public async Task> List(VersionListParams parameters) - { - using HttpRequestMessage request = new(HttpMethod.Get, parameters.Url(this._client)); - parameters.AddHeadersToRequest(request, this._client); - using HttpResponseMessage response = await this - ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) - .ConfigureAwait(false); - if (!response.IsSuccessStatusCode) - { - throw new HttpException( - response.StatusCode, - await response.Content.ReadAsStringAsync().ConfigureAwait(false) - ); - } - - return JsonSerializer.Deserialize>( - await response.Content.ReadAsStreamAsync().ConfigureAwait(false), - ModelBase.SerializerOptions - ) ?? throw new NullReferenceException(); - } - - public async Task Delete(VersionDeleteParams parameters) - { - using HttpRequestMessage request = new(HttpMethod.Delete, parameters.Url(this._client)); - parameters.AddHeadersToRequest(request, this._client); - using HttpResponseMessage response = await this - ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) - .ConfigureAwait(false); - if (!response.IsSuccessStatusCode) - { - throw new HttpException( - response.StatusCode, - await response.Content.ReadAsStringAsync().ConfigureAwait(false) - ); - } - - return JsonSerializer.Deserialize( - await response.Content.ReadAsStreamAsync().ConfigureAwait(false), - ModelBase.SerializerOptions - ) ?? throw new NullReferenceException(); - } - - public async Task Get(VersionGetParams parameters) - { - using HttpRequestMessage request = new(HttpMethod.Get, parameters.Url(this._client)); - parameters.AddHeadersToRequest(request, this._client); - using HttpResponseMessage response = await this - ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) - .ConfigureAwait(false); - if (!response.IsSuccessStatusCode) - { - throw new HttpException( - response.StatusCode, - await response.Content.ReadAsStringAsync().ConfigureAwait(false) - ); - } - - return JsonSerializer.Deserialize( - await response.Content.ReadAsStreamAsync().ConfigureAwait(false), - ModelBase.SerializerOptions - ) ?? throw new NullReferenceException(); - } - - public async Task Restore(VersionRestoreParams parameters) - { - using HttpRequestMessage request = new(HttpMethod.Put, parameters.Url(this._client)); - parameters.AddHeadersToRequest(request, this._client); - using HttpResponseMessage response = await this - ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) - .ConfigureAwait(false); - if (!response.IsSuccessStatusCode) - { - throw new HttpException( - response.StatusCode, - await response.Content.ReadAsStringAsync().ConfigureAwait(false) - ); - } - - return JsonSerializer.Deserialize( - await response.Content.ReadAsStreamAsync().ConfigureAwait(false), - ModelBase.SerializerOptions - ) ?? throw new NullReferenceException(); - } -} +using System.Collections.Generic; +using System.Net.Http; +using System.Threading.Tasks; +using Imagekit.Core; +using Imagekit.Models.Files; +using Imagekit.Models.Files.Versions; + +namespace Imagekit.Services.Files.Versions; + +public sealed class VersionService : IVersionService +{ + readonly IImageKitClient _client; + + public VersionService(IImageKitClient client) + { + _client = client; + } + + public async Task> List(VersionListParams parameters) + { + HttpRequest request = new() + { + Method = HttpMethod.Get, + Params = parameters, + }; + using var response = await this._client.Execute(request).ConfigureAwait(false); + var files = await response.Deserialize>().ConfigureAwait(false); + if (this._client.ResponseValidation) + { + foreach (var item in files) + { + item.Validate(); + } + } + return files; + } + + public async Task Delete(VersionDeleteParams parameters) + { + HttpRequest request = new() + { + Method = HttpMethod.Delete, + Params = parameters, + }; + using var response = await this._client.Execute(request).ConfigureAwait(false); + var version = await response.Deserialize().ConfigureAwait(false); + if (this._client.ResponseValidation) + { + version.Validate(); + } + return version; + } + + public async Task Get(VersionGetParams parameters) + { + HttpRequest request = new() + { + Method = HttpMethod.Get, + Params = parameters, + }; + using var response = await this._client.Execute(request).ConfigureAwait(false); + var file = await response.Deserialize().ConfigureAwait(false); + if (this._client.ResponseValidation) + { + file.Validate(); + } + return file; + } + + public async Task Restore(VersionRestoreParams parameters) + { + HttpRequest request = new() + { + Method = HttpMethod.Put, + Params = parameters, + }; + using var response = await this._client.Execute(request).ConfigureAwait(false); + var file = await response.Deserialize().ConfigureAwait(false); + if (this._client.ResponseValidation) + { + file.Validate(); + } + return file; + } +} diff --git a/src/Imagekit/Services/Folders/FolderService.cs b/src/Imagekit/Services/Folders/FolderService.cs index 23f3bc3d..fb946edc 100644 --- a/src/Imagekit/Services/Folders/FolderService.cs +++ b/src/Imagekit/Services/Folders/FolderService.cs @@ -1,145 +1,111 @@ -using System; -using System.Net.Http; -using System.Text.Json; -using System.Threading.Tasks; -using Imagekit.Models.Folders; -using Imagekit.Services.Folders.Job; - -namespace Imagekit.Services.Folders; - -public sealed class FolderService : IFolderService -{ - readonly IImageKitClient _client; - - public FolderService(IImageKitClient client) - { - _client = client; - _job = new(() => new JobService(client)); - } - - readonly Lazy _job; - public IJobService Job - { - get { return _job.Value; } - } - - public async Task Create(FolderCreateParams parameters) - { - using HttpRequestMessage request = new(HttpMethod.Post, parameters.Url(this._client)) - { - Content = parameters.BodyContent(), - }; - parameters.AddHeadersToRequest(request, this._client); - using HttpResponseMessage response = await this - ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) - .ConfigureAwait(false); - if (!response.IsSuccessStatusCode) - { - throw new HttpException( - response.StatusCode, - await response.Content.ReadAsStringAsync().ConfigureAwait(false) - ); - } - - return JsonSerializer.Deserialize( - await response.Content.ReadAsStreamAsync().ConfigureAwait(false), - ModelBase.SerializerOptions - ) ?? throw new NullReferenceException(); - } - - public async Task Delete(FolderDeleteParams parameters) - { - using HttpRequestMessage request = new(HttpMethod.Delete, parameters.Url(this._client)) - { - Content = parameters.BodyContent(), - }; - parameters.AddHeadersToRequest(request, this._client); - using HttpResponseMessage response = await this - ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) - .ConfigureAwait(false); - if (!response.IsSuccessStatusCode) - { - throw new HttpException( - response.StatusCode, - await response.Content.ReadAsStringAsync().ConfigureAwait(false) - ); - } - - return JsonSerializer.Deserialize( - await response.Content.ReadAsStreamAsync().ConfigureAwait(false), - ModelBase.SerializerOptions - ) ?? throw new NullReferenceException(); - } - - public async Task Copy(FolderCopyParams parameters) - { - using HttpRequestMessage request = new(HttpMethod.Post, parameters.Url(this._client)) - { - Content = parameters.BodyContent(), - }; - parameters.AddHeadersToRequest(request, this._client); - using HttpResponseMessage response = await this - ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) - .ConfigureAwait(false); - if (!response.IsSuccessStatusCode) - { - throw new HttpException( - response.StatusCode, - await response.Content.ReadAsStringAsync().ConfigureAwait(false) - ); - } - - return JsonSerializer.Deserialize( - await response.Content.ReadAsStreamAsync().ConfigureAwait(false), - ModelBase.SerializerOptions - ) ?? throw new NullReferenceException(); - } - - public async Task Move(FolderMoveParams parameters) - { - using HttpRequestMessage request = new(HttpMethod.Post, parameters.Url(this._client)) - { - Content = parameters.BodyContent(), - }; - parameters.AddHeadersToRequest(request, this._client); - using HttpResponseMessage response = await this - ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) - .ConfigureAwait(false); - if (!response.IsSuccessStatusCode) - { - throw new HttpException( - response.StatusCode, - await response.Content.ReadAsStringAsync().ConfigureAwait(false) - ); - } - - return JsonSerializer.Deserialize( - await response.Content.ReadAsStreamAsync().ConfigureAwait(false), - ModelBase.SerializerOptions - ) ?? throw new NullReferenceException(); - } - - public async Task Rename(FolderRenameParams parameters) - { - using HttpRequestMessage request = new(HttpMethod.Post, parameters.Url(this._client)) - { - Content = parameters.BodyContent(), - }; - parameters.AddHeadersToRequest(request, this._client); - using HttpResponseMessage response = await this - ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) - .ConfigureAwait(false); - if (!response.IsSuccessStatusCode) - { - throw new HttpException( - response.StatusCode, - await response.Content.ReadAsStringAsync().ConfigureAwait(false) - ); - } - - return JsonSerializer.Deserialize( - await response.Content.ReadAsStreamAsync().ConfigureAwait(false), - ModelBase.SerializerOptions - ) ?? throw new NullReferenceException(); - } -} +using System; +using System.Net.Http; +using System.Threading.Tasks; +using Imagekit.Core; +using Imagekit.Models.Folders; +using Imagekit.Services.Folders.Job; + +namespace Imagekit.Services.Folders; + +public sealed class FolderService : IFolderService +{ + readonly IImageKitClient _client; + + public FolderService(IImageKitClient client) + { + _client = client; + _job = new(() => new JobService(client)); + } + + readonly Lazy _job; + public IJobService Job + { + get { return _job.Value; } + } + + public async Task Create(FolderCreateParams parameters) + { + HttpRequest request = new() + { + Method = HttpMethod.Post, + Params = parameters, + }; + using var response = await this._client.Execute(request).ConfigureAwait(false); + var folder = await response.Deserialize().ConfigureAwait(false); + if (this._client.ResponseValidation) + { + folder.Validate(); + } + return folder; + } + + public async Task Delete(FolderDeleteParams parameters) + { + HttpRequest request = new() + { + Method = HttpMethod.Delete, + Params = parameters, + }; + using var response = await this._client.Execute(request).ConfigureAwait(false); + var folder = await response.Deserialize().ConfigureAwait(false); + if (this._client.ResponseValidation) + { + folder.Validate(); + } + return folder; + } + + public async Task Copy(FolderCopyParams parameters) + { + HttpRequest request = new() + { + Method = HttpMethod.Post, + Params = parameters, + }; + using var response = await this._client.Execute(request).ConfigureAwait(false); + var deserializedResponse = await response + .Deserialize() + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + deserializedResponse.Validate(); + } + return deserializedResponse; + } + + public async Task Move(FolderMoveParams parameters) + { + HttpRequest request = new() + { + Method = HttpMethod.Post, + Params = parameters, + }; + using var response = await this._client.Execute(request).ConfigureAwait(false); + var deserializedResponse = await response + .Deserialize() + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + deserializedResponse.Validate(); + } + return deserializedResponse; + } + + public async Task Rename(FolderRenameParams parameters) + { + HttpRequest request = new() + { + Method = HttpMethod.Post, + Params = parameters, + }; + using var response = await this._client.Execute(request).ConfigureAwait(false); + var deserializedResponse = await response + .Deserialize() + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + deserializedResponse.Validate(); + } + return deserializedResponse; + } +} diff --git a/src/Imagekit/Services/Folders/Job/JobService.cs b/src/Imagekit/Services/Folders/Job/JobService.cs index 3530816f..1df036fe 100644 --- a/src/Imagekit/Services/Folders/Job/JobService.cs +++ b/src/Imagekit/Services/Folders/Job/JobService.cs @@ -1,38 +1,28 @@ -using System; -using System.Net.Http; -using System.Text.Json; -using System.Threading.Tasks; -using Imagekit.Models.Folders.Job; - -namespace Imagekit.Services.Folders.Job; - -public sealed class JobService : IJobService -{ - readonly IImageKitClient _client; - - public JobService(IImageKitClient client) - { - _client = client; - } - - public async Task Get(JobGetParams parameters) - { - using HttpRequestMessage request = new(HttpMethod.Get, parameters.Url(this._client)); - parameters.AddHeadersToRequest(request, this._client); - using HttpResponseMessage response = await this - ._client.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) - .ConfigureAwait(false); - if (!response.IsSuccessStatusCode) - { - throw new HttpException( - response.StatusCode, - await response.Content.ReadAsStringAsync().ConfigureAwait(false) - ); - } - - return JsonSerializer.Deserialize( - await response.Content.ReadAsStreamAsync().ConfigureAwait(false), - ModelBase.SerializerOptions - ) ?? throw new NullReferenceException(); - } -} +using System.Net.Http; +using System.Threading.Tasks; +using Imagekit.Core; +using Imagekit.Models.Folders.Job; + +namespace Imagekit.Services.Folders.Job; + +public sealed class JobService : IJobService +{ + readonly IImageKitClient _client; + + public JobService(IImageKitClient client) + { + _client = client; + } + + public async Task Get(JobGetParams parameters) + { + HttpRequest request = new() { Method = HttpMethod.Get, Params = parameters }; + using var response = await this._client.Execute(request).ConfigureAwait(false); + var job = await response.Deserialize().ConfigureAwait(false); + if (this._client.ResponseValidation) + { + job.Validate(); + } + return job; + } +} From 1eaf25047baf52e19b4a7d4650f725095e234857 Mon Sep 17 00:00:00 2001 From: meorphis Date: Wed, 28 Jan 2026 13:42:38 -0500 Subject: [PATCH 061/129] chore: revert custom code --- .config/dotnet-tools.json | 4 +- .csharpierignore | 2 + .devcontainer/devcontainer.json | 6 +- .editorconfig | 61 +- .github/workflows/ci.yml | 14 +- .gitignore | 3 + .stats.yml | 8 +- CONTRIBUTING.md | 37 + Imagekit.sln => ImageKit.sln | 15 +- LICENSE | 2 +- README.md | 181 +- .../ImagekitCsharpExample.csproj | 12 + scripts/lint | 3 + scripts/test | 4 + src/Directory.Build.props | 34 + src/ImageKit.Tests/Core/JsonDictionaryTest.cs | 406 + .../Core/MultipartJsonDictionaryTest.cs | 333 + src/ImageKit.Tests/ImageKit.Tests.csproj | 23 + .../Origins/OriginCreateParamsTest.cs | 82 + .../Origins/OriginDeleteParamsTest.cs | 37 + .../Accounts/Origins/OriginGetParamsTest.cs | 37 + .../Accounts/Origins/OriginListParamsTest.cs | 1 + .../Accounts/Origins/OriginRequestTest.cs | 1923 +++++ .../Accounts/Origins/OriginResponseTest.cs | 1863 +++++ .../Origins/OriginUpdateParamsTest.cs | 87 + .../UrlEndpointCreateParamsTest.cs | 433 + .../UrlEndpointDeleteParamsTest.cs | 37 + .../UrlEndpoints/UrlEndpointGetParamsTest.cs | 37 + .../UrlEndpoints/UrlEndpointListParamsTest.cs | 1 + .../UrlEndpoints/UrlEndpointRequestTest.cs | 570 ++ .../UrlEndpoints/UrlEndpointResponseTest.cs | 520 ++ .../UrlEndpointUpdateParamsTest.cs | 497 ++ .../Accounts/Usage/UsageGetParamsTest.cs | 44 + .../Accounts/Usage/UsageGetResponseTest.cs | 184 + .../Models/Assets/AssetListParamsTest.cs | 340 + .../Models/Assets/AssetListResponseTest.cs | 175 + src/ImageKit.Tests/Models/BaseOverlayTest.cs | 287 + .../Beta/V2/Files/FileUploadParamsTest.cs | 854 ++ .../Beta/V2/Files/FileUploadResponseTest.cs | 3377 ++++++++ .../InvalidationCreateParamsTest.cs | 46 + .../InvalidationCreateResponseTest.cs | 109 + .../Invalidation/InvalidationGetParamsTest.cs | 37 + .../InvalidationGetResponseTest.cs | 168 + .../CustomMetadataFieldCreateParamsTest.cs | 726 ++ .../CustomMetadataFieldDeleteParamsTest.cs | 37 + .../CustomMetadataFieldDeleteResponseTest.cs | 59 + .../CustomMetadataFieldListParamsTest.cs | 83 + .../CustomMetadataFieldTest.cs | 804 ++ .../CustomMetadataFieldUpdateParamsTest.cs | 663 ++ .../Models/ExtensionConfigTest.cs | 3145 ++++++++ .../Files/Bulk/BulkAddTagsParamsTest.cs | 60 + .../Files/Bulk/BulkAddTagsResponseTest.cs | 132 + .../Models/Files/Bulk/BulkDeleteParamsTest.cs | 51 + .../Files/Bulk/BulkDeleteResponseTest.cs | 132 + .../Files/Bulk/BulkRemoveAITagsParamsTest.cs | 60 + .../Bulk/BulkRemoveAITagsResponseTest.cs | 132 + .../Files/Bulk/BulkRemoveTagsParamsTest.cs | 60 + .../Files/Bulk/BulkRemoveTagsResponseTest.cs | 132 + .../Models/Files/FileCopyParamsTest.cs | 84 + .../Models/Files/FileCopyResponseTest.cs | 59 + .../Models/Files/FileDeleteParamsTest.cs | 37 + .../Models/Files/FileGetParamsTest.cs | 37 + .../Models/Files/FileMetadataTest.cs | 2552 ++++++ .../Models/Files/FileMoveParamsTest.cs | 51 + .../Models/Files/FileMoveResponseTest.cs | 59 + .../Models/Files/FileRenameParamsTest.cs | 84 + .../Models/Files/FileRenameResponseTest.cs | 109 + src/ImageKit.Tests/Models/Files/FileTest.cs | 1936 +++++ .../Models/Files/FileUpdateParamsTest.cs | 257 + .../Models/Files/FileUpdateResponseTest.cs | 1711 ++++ .../Models/Files/FileUploadParamsTest.cs | 869 ++ .../Models/Files/FileUploadResponseTest.cs | 3452 ++++++++ src/ImageKit.Tests/Models/Files/FolderTest.cs | 251 + .../Metadata/MetadataGetFromUrlParamsTest.cs | 40 + .../Files/Metadata/MetadataGetParamsTest.cs | 37 + .../Models/Files/UpdateFileRequestTest.cs | 1512 ++++ .../Files/Versions/VersionDeleteParamsTest.cs | 39 + .../Versions/VersionDeleteResponseTest.cs | 59 + .../Files/Versions/VersionGetParamsTest.cs | 39 + .../Files/Versions/VersionListParamsTest.cs | 37 + .../Versions/VersionRestoreParamsTest.cs | 42 + .../Models/Folders/FolderCopyParamsTest.cs | 84 + .../Models/Folders/FolderCopyResponseTest.cs | 67 + .../Models/Folders/FolderCreateParamsTest.cs | 51 + .../Folders/FolderCreateResponseTest.cs | 59 + .../Models/Folders/FolderDeleteParamsTest.cs | 37 + .../Folders/FolderDeleteResponseTest.cs | 59 + .../Models/Folders/FolderMoveParamsTest.cs | 51 + .../Models/Folders/FolderMoveResponseTest.cs | 67 + .../Models/Folders/FolderRenameParamsTest.cs | 84 + .../Folders/FolderRenameResponseTest.cs | 67 + .../Models/Folders/Job/JobGetParamsTest.cs | 37 + .../Models/Folders/Job/JobGetResponseTest.cs | 288 + .../Models/GetImageAttributesOptionsTest.cs | 1172 +++ src/ImageKit.Tests/Models/ImageOverlayTest.cs | 1834 +++++ .../Models/OverlayPositionTest.cs | 301 + src/ImageKit.Tests/Models/OverlayTest.cs | 748 ++ .../Models/OverlayTimingTest.cs | 271 + .../Models/ResponsiveImageAttributesTest.cs | 180 + .../SavedExtensionCreateParamsTest.cs | 94 + .../SavedExtensionDeleteParamsTest.cs | 37 + .../SavedExtensionGetParamsTest.cs | 37 + .../SavedExtensionListParamsTest.cs | 1 + .../SavedExtensionUpdateParamsTest.cs | 117 + .../Models/SharedSavedExtensionTest.cs | 265 + .../Models/SolidColorOverlayTest.cs | 567 ++ .../SolidColorOverlayTransformationTest.cs | 529 ++ src/ImageKit.Tests/Models/SrcOptionsTest.cs | 908 +++ .../Models/StreamingResolutionTest.cs | 74 + .../Models/SubtitleOverlayTest.cs | 672 ++ .../SubtitleOverlayTransformationTest.cs | 275 + src/ImageKit.Tests/Models/TextOverlayTest.cs | 756 ++ .../Models/TextOverlayTransformationTest.cs | 784 ++ .../Models/TransformationPositionTest.cs | 64 + .../Models/TransformationTest.cs | 3339 ++++++++ .../UnnamedSchemaWithArrayParent0Test.cs | 3479 ++++++++ src/ImageKit.Tests/Models/VideoOverlayTest.cs | 1834 +++++ .../Models/Webhooks/BaseWebhookEventTest.cs | 71 + .../Webhooks/UnsafeUnwrapWebhookEventTest.cs | 802 ++ .../Models/Webhooks/UnwrapWebhookEventTest.cs | 802 ++ .../UploadPostTransformErrorEventTest.cs | 1072 +++ .../UploadPostTransformSuccessEventTest.cs | 1048 +++ .../UploadPreTransformErrorEventTest.cs | 739 ++ .../UploadPreTransformSuccessEventTest.cs | 5746 ++++++++++++++ .../VideoTransformationAcceptedEventTest.cs | 1712 ++++ .../VideoTransformationErrorEventTest.cs | 2197 ++++++ .../VideoTransformationReadyEventTest.cs | 3167 ++++++++ .../Services/Accounts}/OriginServiceTest.cs | 37 +- .../Accounts/UrlEndpointServiceTest.cs | 61 + .../Services/Accounts}/UsageServiceTest.cs | 36 +- .../Services}/AssetServiceTest.cs | 32 +- .../Services/Beta/V2}/FileServiceTest.cs | 32 +- .../Cache}/InvalidationServiceTest.cs | 51 +- .../CustomMetadataFieldServiceTest.cs | 36 +- .../Services/FileServiceTest.cs | 142 + .../Services/Files}/BulkServiceTest.cs | 20 +- .../Services/Files/MetadataServiceTest.cs | 27 + .../Services/Files}/VersionServiceTest.cs | 96 +- .../Services}/FolderServiceTest.cs | 19 +- .../Services/Folders/JobServiceTest.cs | 17 + .../Services/SavedExtensionServiceTest.cs | 76 + .../TestBase.cs | 9 +- src/ImageKit/Core/ApiEnum.cs | 136 + src/ImageKit/Core/BinaryContent.cs | 25 + src/ImageKit/Core/ClientOptions.cs | 145 + src/ImageKit/Core/EnvironmentUrl.cs | 6 + .../Core/FrozenDictionaryConverterFactory.cs | 64 + src/ImageKit/Core/HttpRequest.cs | 26 + src/ImageKit/Core/HttpResponse.cs | 172 + src/ImageKit/Core/IPage.cs | 53 + src/ImageKit/Core/JsonDictionary.cs | 230 + src/ImageKit/Core/JsonModel.cs | 65 + src/ImageKit/Core/JsonModelConverter.cs | 32 + src/ImageKit/Core/ModelBase.cs | 180 + src/ImageKit/Core/MultipartJsonDictionary.cs | 208 + src/ImageKit/Core/MultipartJsonElement.cs | 293 + src/ImageKit/Core/MultipartJsonModel.cs | 56 + .../Core/MultipartJsonModelConverter.cs | 32 + src/{Imagekit => ImageKit}/Core/ParamsBase.cs | 137 +- .../Exceptions/ImageKit4xxException.cs | 2 +- .../Exceptions/ImageKit5xxException.cs | 2 +- .../Exceptions/ImageKitApiException.cs | 2 +- .../Exceptions/ImageKitBadRequestException.cs | 2 +- .../Exceptions/ImageKitException.cs | 2 +- .../Exceptions/ImageKitExceptionFactory.cs | 2 +- .../Exceptions/ImageKitForbiddenException.cs | 2 +- .../Exceptions/ImageKitIOException.cs | 2 +- .../ImageKitInvalidDataException.cs | 2 +- .../Exceptions/ImageKitNotFoundException.cs | 2 +- .../Exceptions/ImageKitRateLimitException.cs | 2 +- .../ImageKitUnauthorizedException.cs | 2 +- .../ImageKitUnexpectedStatusCodeException.cs | 2 +- .../ImageKitUnprocessableEntityException.cs | 2 +- src/ImageKit/IImageKitClient.cs | 162 + src/ImageKit/IPageExtensions.cs | 33 + src/ImageKit/ImageKit.csproj | 20 + src/ImageKit/ImageKitClient.cs | 512 ++ .../Accounts/Origins/OriginCreateParams.cs | 143 + .../Accounts/Origins/OriginDeleteParams.cs | 113 + .../Accounts/Origins/OriginGetParams.cs | 112 + .../Accounts/Origins/OriginListParams.cs | 103 + .../Models/Accounts/Origins/OriginRequest.cs | 2186 +++++ .../Models/Accounts/Origins/OriginResponse.cs | 2053 +++++ .../Accounts/Origins/OriginUpdateParams.cs | 152 + .../UrlEndpoints/UrlEndpointCreateParams.cs | 761 ++ .../UrlEndpoints/UrlEndpointDeleteParams.cs | 114 + .../UrlEndpoints/UrlEndpointGetParams.cs | 113 + .../UrlEndpoints/UrlEndpointListParams.cs | 105 + .../UrlEndpoints/UrlEndpointRequest.cs | 760 ++ .../UrlEndpoints/UrlEndpointResponse.cs | 756 ++ .../UrlEndpoints/UrlEndpointUpdateParams.cs | 839 ++ .../Models/Accounts/Usage/UsageGetParams.cs | 133 + .../Models/Accounts/Usage/UsageGetResponse.cs | 163 + src/ImageKit/Models/Assets/AssetListParams.cs | 463 ++ .../Models/Assets/AssetListResponse.cs | 297 + src/ImageKit/Models/BaseOverlay.cs | 203 + .../Models/Beta/V2/Files/FileUploadParams.cs | 1589 ++++ .../Beta/V2/Files/FileUploadResponse.cs | 2943 +++++++ .../Invalidation/InvalidationCreateParams.cs | 143 + .../InvalidationCreateResponse.cs | 79 + .../Invalidation/InvalidationGetParams.cs | 112 + .../Invalidation/InvalidationGetResponse.cs | 121 + .../CustomMetadataField.cs | 1806 +++++ .../CustomMetadataFieldCreateParams.cs | 1840 +++++ .../CustomMetadataFieldDeleteParams.cs | 115 + .../CustomMetadataFieldDeleteResponse.cs | 59 + .../CustomMetadataFieldListParams.cs | 156 + .../CustomMetadataFieldUpdateParams.cs | 1844 +++++ src/ImageKit/Models/ExtensionConfig.cs | 4763 +++++++++++ .../Models/Files/Bulk/BulkAddTagsParams.cs | 169 + .../Models/Files/Bulk/BulkAddTagsResponse.cs | 81 + .../Models/Files/Bulk/BulkDeleteParams.cs | 157 + .../Models/Files/Bulk/BulkDeleteResponse.cs | 81 + .../Files/Bulk/BulkRemoveAITagsParams.cs | 169 + .../Files/Bulk/BulkRemoveAITagsResponse.cs | 84 + .../Models/Files/Bulk/BulkRemoveTagsParams.cs | 169 + .../Files/Bulk/BulkRemoveTagsResponse.cs | 82 + src/ImageKit/Models/Files/File.cs | 2533 ++++++ src/ImageKit/Models/Files/FileCopyParams.cs | 182 + src/ImageKit/Models/Files/FileCopyResponse.cs | 51 + src/ImageKit/Models/Files/FileDeleteParams.cs | 115 + src/ImageKit/Models/Files/FileGetParams.cs | 113 + src/ImageKit/Models/Files/FileMetadata.cs | 1646 ++++ src/ImageKit/Models/Files/FileMoveParams.cs | 158 + src/ImageKit/Models/Files/FileMoveResponse.cs | 51 + src/ImageKit/Models/Files/FileRenameParams.cs | 199 + .../Models/Files/FileRenameResponse.cs | 76 + src/ImageKit/Models/Files/FileUpdateParams.cs | 153 + .../Models/Files/FileUpdateResponse.cs | 1068 +++ src/ImageKit/Models/Files/FileUploadParams.cs | 1667 ++++ .../Models/Files/FileUploadResponse.cs | 3073 ++++++++ src/ImageKit/Models/Files/Folder.cs | 234 + .../Metadata/MetadataGetFromUrlParams.cs | 117 + .../Files/Metadata/MetadataGetParams.cs | 116 + .../Models/Files/UpdateFileRequest.cs | 959 +++ .../Files/Versions/VersionDeleteParams.cs | 119 + .../Files/Versions/VersionDeleteResponse.cs | 52 + .../Models/Files/Versions/VersionGetParams.cs | 117 + .../Files/Versions/VersionListParams.cs | 112 + .../Files/Versions/VersionRestoreParams.cs | 117 + .../Models/Folders/FolderCopyParams.cs | 183 + .../Models/Folders/FolderCopyResponse.cs | 78 + .../Models/Folders/FolderCreateParams.cs | 166 + .../Models/Folders/FolderCreateResponse.cs | 52 + .../Models/Folders/FolderDeleteParams.cs | 143 + .../Models/Folders/FolderDeleteResponse.cs | 52 + .../Models/Folders/FolderMoveParams.cs | 159 + .../Models/Folders/FolderMoveResponse.cs | 78 + .../Models/Folders/FolderRenameParams.cs | 196 + .../Models/Folders/FolderRenameResponse.cs | 79 + .../Models/Folders/Job/JobGetParams.cs | 111 + .../Models/Folders/Job/JobGetResponse.cs | 237 + .../Models/GetImageAttributesOptions.cs | 527 ++ src/ImageKit/Models/ImageOverlay.cs | 444 ++ src/ImageKit/Models/Overlay.cs | 518 ++ src/ImageKit/Models/OverlayPosition.cs | 641 ++ src/ImageKit/Models/OverlayTiming.cs | 809 ++ .../Models/ResponsiveImageAttributes.cs | 149 + .../SavedExtensionCreateParams.cs | 173 + .../SavedExtensionDeleteParams.cs | 112 + .../SavedExtensionGetParams.cs | 112 + .../SavedExtensionListParams.cs | 104 + .../SavedExtensionUpdateParams.cs | 202 + src/ImageKit/Models/SharedSavedExtension.cs | 190 + src/ImageKit/Models/SolidColorOverlay.cs | 342 + .../Models/SolidColorOverlayTransformation.cs | 1301 +++ src/ImageKit/Models/SrcOptions.cs | 231 + .../Models/StreamingResolution.cs | 4 +- src/ImageKit/Models/SubtitleOverlay.cs | 449 ++ .../Models/SubtitleOverlayTransformation.cs | 296 + src/ImageKit/Models/TextOverlay.cs | 449 ++ .../Models/TextOverlayTransformation.cs | 1994 +++++ src/ImageKit/Models/Transformation.cs | 7002 +++++++++++++++++ .../Models/TransformationPosition.cs | 107 +- .../Models/UnnamedSchemaWithArrayParent0.cs | 5322 +++++++++++++ src/ImageKit/Models/VideoOverlay.cs | 451 ++ .../Models/Webhooks/BaseWebhookEvent.cs | 81 + .../Webhooks/UnsafeUnwrapWebhookEvent.cs | 652 ++ .../Models/Webhooks/UnwrapWebhookEvent.cs | 631 ++ .../Webhooks/UploadPostTransformErrorEvent.cs | 753 ++ .../UploadPostTransformSuccessEvent.cs | 725 ++ .../Webhooks/UploadPreTransformErrorEvent.cs | 608 ++ .../UploadPreTransformSuccessEvent.cs | 3306 ++++++++ .../VideoTransformationAcceptedEvent.cs | 1130 +++ .../Webhooks/VideoTransformationErrorEvent.cs | 1394 ++++ .../Webhooks/VideoTransformationReadyEvent.cs | 1580 ++++ src/ImageKit/Services/AccountService.cs | 92 + .../Services/Accounts/IOriginService.cs | 173 + .../Services/Accounts/IUrlEndpointService.cs | 174 + .../Services/Accounts/IUsageService.cs | 62 + .../Services/Accounts/OriginService.cs | 322 + .../Services/Accounts/UrlEndpointService.cs | 327 + .../Services/Accounts/UsageService.cs | 92 + src/ImageKit/Services/AssetService.cs | 98 + src/ImageKit/Services/Beta/IV2Service.cs | 44 + src/ImageKit/Services/Beta/V2/FileService.cs | 92 + src/ImageKit/Services/Beta/V2/IFileService.cs | 80 + src/ImageKit/Services/Beta/V2Service.cs | 64 + src/ImageKit/Services/BetaService.cs | 64 + .../Services/Cache/IInvalidationService.cs | 92 + .../Services/Cache/InvalidationService.cs | 166 + src/ImageKit/Services/CacheService.cs | 64 + .../Services/CustomMetadataFieldService.cs | 282 + src/ImageKit/Services/FileService.cs | 435 + src/ImageKit/Services/Files/BulkService.cs | 212 + src/ImageKit/Services/Files/IBulkService.cs | 119 + .../Services/Files/IMetadataService.cs | 96 + .../Services/Files/IVersionService.cs | 169 + .../Services/Files/MetadataService.cs | 163 + src/ImageKit/Services/Files/VersionService.cs | 316 + src/ImageKit/Services/FolderService.cs | 268 + src/ImageKit/Services/Folders/IJobService.cs | 73 + src/ImageKit/Services/Folders/JobService.cs | 116 + src/ImageKit/Services/IAccountService.cs | 52 + src/ImageKit/Services/IAssetService.cs | 63 + src/ImageKit/Services/IBetaService.cs | 44 + src/ImageKit/Services/ICacheService.cs | 44 + .../Services/ICustomMetadataFieldService.cs | 152 + src/ImageKit/Services/IFileService.cs | 249 + src/ImageKit/Services/IFolderService.cs | 143 + .../Services/ISavedExtensionService.cs | 179 + src/ImageKit/Services/IWebhookService.cs | 39 + .../Services/SavedExtensionService.cs | 334 + src/ImageKit/Services/WebhookService.cs | 48 + src/ImageKit/Shims.cs | 41 + src/Imagekit.Tests/Imagekit.Tests.csproj | 20 - .../Services/Accounts/AccountServiceTest.cs | 3 - .../URLEndpoints/URLEndpointServiceTest.cs | 47 - .../Services/Beta/BetaServiceTest.cs | 3 - .../Services/Beta/V2/V2ServiceTest.cs | 3 - .../Services/Cache/CacheServiceTest.cs | 3 - .../Services/Files/FileServiceTest.cs | 127 - .../Files/Metadata/MetadataServiceTest.cs | 22 - .../Services/Folders/Job/JobServiceTest.cs | 13 - .../Services/Webhooks/WebhookServiceTest.cs | 3 - src/Imagekit/Core/ApiEnum.cs | 56 - src/Imagekit/Core/ClientOptions.cs | 85 - src/Imagekit/Core/HttpRequest.cs | 11 - src/Imagekit/Core/HttpResponse.cs | 32 - src/Imagekit/Core/IVariant.cs | 8 - src/Imagekit/Core/ModelBase.cs | 212 - src/Imagekit/Core/ModelConverter.cs | 30 - src/Imagekit/HttpException.cs | 29 - src/Imagekit/IImageKitClient.cs | 63 - src/Imagekit/ImageKitClient.cs | 168 - src/Imagekit/Imagekit.csproj | 41 - .../Accounts/Origins/OriginCreateParams.cs | 64 - .../Accounts/Origins/OriginDeleteParams.cs | 34 - .../Accounts/Origins/OriginGetParams.cs | 33 - .../Accounts/Origins/OriginListParams.cs | 28 - .../Models/Accounts/Origins/OriginRequest.cs | 540 -- .../OriginRequestProperties/AkeneoPim.cs | 241 - .../AkeneoPimProperties/Type.cs | 47 - .../OriginRequestProperties/AzureBlob.cs | 205 - .../AzureBlobProperties/Type.cs | 47 - .../CloudinaryBackup.cs | 217 - .../CloudinaryBackupProperties/Type.cs | 47 - .../Origins/OriginRequestProperties/Gcs.cs | 205 - .../GcsProperties/Type.cs | 47 - .../Origins/OriginRequestProperties/S3.cs | 217 - .../OriginRequestProperties/S3Compatible.cs | 262 - .../S3CompatibleProperties/Type.cs | 47 - .../S3Properties/Type.cs | 47 - .../OriginRequestProperties/WebFolder.cs | 171 - .../WebFolderProperties/Type.cs | 47 - .../OriginRequestProperties/WebProxy.cs | 133 - .../WebProxyProperties/Type.cs | 47 - .../Origins/OriginRequestVariants/All.cs | 123 - .../Models/Accounts/Origins/OriginResponse.cs | 523 -- .../OriginResponseProperties/AkeneoPim.cs | 176 - .../AkeneoPimProperties/Type.cs | 47 - .../OriginResponseProperties/AzureBlob.cs | 213 - .../AzureBlobProperties/Type.cs | 47 - .../CloudinaryBackup.cs | 199 - .../CloudinaryBackupProperties/Type.cs | 47 - .../Origins/OriginResponseProperties/Gcs.cs | 213 - .../GcsProperties/Type.cs | 47 - .../Origins/OriginResponseProperties/S3.cs | 199 - .../OriginResponseProperties/S3Compatible.cs | 247 - .../S3CompatibleProperties/Type.cs | 47 - .../S3Properties/Type.cs | 47 - .../OriginResponseProperties/WebFolder.cs | 201 - .../WebFolderProperties/Type.cs | 47 - .../OriginResponseProperties/WebProxy.cs | 153 - .../WebProxyProperties/Type.cs | 47 - .../Origins/OriginResponseVariants/All.cs | 123 - .../Accounts/Origins/OriginUpdateParams.cs | 69 - .../URLEndpoints/URLEndpointCreateParams.cs | 131 - .../URLRewriter.cs | 204 - .../URLRewriterProperties/Akamai.cs | 51 - .../AkamaiProperties/Type.cs | 47 - .../URLRewriterProperties/Cloudinary.cs | 81 - .../CloudinaryProperties/Type.cs | 47 - .../URLRewriterProperties/Imgix.cs | 51 - .../ImgixProperties/Type.cs | 47 - .../URLRewriterVariants/All.cs | 39 - .../URLEndpoints/URLEndpointDeleteParams.cs | 34 - .../URLEndpoints/URLEndpointGetParams.cs | 33 - .../URLEndpoints/URLEndpointListParams.cs | 29 - .../URLEndpoints/URLEndpointRequest.cs | 133 - .../URLRewriter.cs | 204 - .../URLRewriterProperties/Akamai.cs | 51 - .../AkamaiProperties/Type.cs | 47 - .../URLRewriterProperties/Cloudinary.cs | 81 - .../CloudinaryProperties/Type.cs | 47 - .../URLRewriterProperties/Imgix.cs | 51 - .../ImgixProperties/Type.cs | 47 - .../URLRewriterVariants/All.cs | 39 - .../URLEndpoints/URLEndpointResponse.cs | 152 - .../URLRewriter.cs | 204 - .../URLRewriterProperties/Akamai.cs | 51 - .../AkamaiProperties/Type.cs | 47 - .../URLRewriterProperties/Cloudinary.cs | 91 - .../CloudinaryProperties/Type.cs | 47 - .../URLRewriterProperties/Imgix.cs | 51 - .../ImgixProperties/Type.cs | 47 - .../URLRewriterVariants/All.cs | 39 - .../URLEndpoints/URLEndpointUpdateParams.cs | 136 - .../URLRewriter.cs | 204 - .../URLRewriterProperties/Akamai.cs | 51 - .../AkamaiProperties/Type.cs | 47 - .../URLRewriterProperties/Cloudinary.cs | 81 - .../CloudinaryProperties/Type.cs | 47 - .../URLRewriterProperties/Imgix.cs | 51 - .../ImgixProperties/Type.cs | 47 - .../URLRewriterVariants/All.cs | 39 - .../Models/Accounts/Usage/UsageGetParams.cs | 75 - .../Models/Accounts/Usage/UsageGetResponse.cs | 139 - src/Imagekit/Models/Assets/AssetListParams.cs | 210 - .../AssetListParamsProperties/FileType.cs | 52 - .../Assets/AssetListParamsProperties/Sort.cs | 82 - .../Assets/AssetListParamsProperties/Type.cs | 56 - .../Models/Assets/AssetListResponse.cs | 181 - .../Assets/AssetListResponseVariants/All.cs | 34 - src/Imagekit/Models/BaseOverlay.cs | 70 - .../Models/Beta/V2/Files/FileUploadParams.cs | 575 -- .../FileUploadParamsProperties/Extension.cs | 177 - .../AutoTaggingExtension.cs | 100 - .../AutoTaggingExtensionProperties/Name.cs | 46 - .../ExtensionProperties/RemoveBg.cs | 74 - .../RemoveBgProperties/Options.cs | 122 - .../ExtensionVariants/All.cs | 46 - .../ResponseField.cs | 68 - .../Transformation.cs | 99 - .../TransformationProperties/Post.cs | 268 - .../PostProperties/Abs.cs | 111 - .../PostProperties/AbsProperties/Protocol.cs | 46 - .../PostProperties/AbsProperties/Type.cs | 50 - .../PostProperties/GifToVideo.cs | 85 - .../GifToVideoProperties/Type.cs | 50 - .../PostProperties/Thumbnail.cs | 84 - .../ThumbnailProperties/Type.cs | 50 - .../PostProperties/Transformation.cs | 99 - .../TransformationProperties/Type.cs | 50 - .../PostVariants/All.cs | 61 - .../Beta/V2/Files/FileUploadResponse.cs | 640 -- .../FileUploadResponseProperties/AITag.cs | 96 - .../ExtensionStatus.cs | 129 - .../AIAutoDescription.cs | 50 - .../AwsAutoTagging.cs | 50 - .../GoogleAutoTagging.cs | 50 - .../ExtensionStatusProperties/RemoveBg.cs | 46 - .../SelectedFieldsSchemaItem.cs | 290 - .../DefaultValue.cs | 214 - .../UnnamedSchemaWithArrayParent6.cs | 175 - .../MaxValue.cs | 136 - .../MinValue.cs | 136 - .../SelectOption.cs | 171 - .../Type.cs | 64 - .../VersionInfo.cs | 76 - .../Invalidation/InvalidationCreateParams.cs | 65 - .../InvalidationCreateResponse.cs | 56 - .../Invalidation/InvalidationGetParams.cs | 32 - .../Invalidation/InvalidationGetResponse.cs | 57 - .../Status.cs | 46 - .../CustomMetadataField.cs | 129 - .../CustomMetadataFieldCreateParams.cs | 111 - .../Schema.cs | 243 - .../SchemaProperties/DefaultValue.cs | 194 - .../UnnamedSchemaWithArrayParent2.cs | 154 - .../All.cs | 35 - .../DefaultValueVariants/All.cs | 50 - .../SchemaProperties/MaxValue.cs | 133 - .../SchemaProperties/MaxValueVariants/All.cs | 21 - .../SchemaProperties/MinValue.cs | 133 - .../SchemaProperties/MinValueVariants/All.cs | 21 - .../SchemaProperties/SelectOption.cs | 167 - .../SelectOptionVariants/All.cs | 31 - .../SchemaProperties/Type.cs | 61 - .../CustomMetadataFieldDeleteParams.cs | 33 - .../CustomMetadataFieldDeleteResponse.cs | 31 - .../CustomMetadataFieldListParams.cs | 81 - .../CustomMetadataFieldProperties/Schema.cs | 245 - .../SchemaProperties/DefaultValue.cs | 214 - .../UnnamedSchemaWithArrayParent1.cs | 171 - .../All.cs | 35 - .../DefaultValueVariants/All.cs | 50 - .../SchemaProperties/MaxValue.cs | 133 - .../SchemaProperties/MaxValueVariants/All.cs | 21 - .../SchemaProperties/MinValue.cs | 133 - .../SchemaProperties/MinValueVariants/All.cs | 21 - .../SchemaProperties/SelectOption.cs | 167 - .../SelectOptionVariants/All.cs | 31 - .../SchemaProperties/Type.cs | 61 - .../CustomMetadataFieldUpdateParams.cs | 95 - .../Schema.cs | 207 - .../SchemaProperties/DefaultValue.cs | 194 - .../UnnamedSchemaWithArrayParent3.cs | 155 - .../All.cs | 35 - .../DefaultValueVariants/All.cs | 50 - .../SchemaProperties/MaxValue.cs | 133 - .../SchemaProperties/MaxValueVariants/All.cs | 21 - .../SchemaProperties/MinValue.cs | 133 - .../SchemaProperties/MinValueVariants/All.cs | 21 - .../SchemaProperties/SelectOption.cs | 159 - .../SelectOptionVariants/All.cs | 31 - .../Models/Files/Bulk/BulkAddTagsParams.cs | 86 - .../Models/Files/Bulk/BulkAddTagsResponse.cs | 52 - .../Models/Files/Bulk/BulkDeleteParams.cs | 71 - .../Models/Files/Bulk/BulkDeleteResponse.cs | 52 - .../Files/Bulk/BulkRemoveAITagsParams.cs | 86 - .../Files/Bulk/BulkRemoveAITagsResponse.cs | 54 - .../Models/Files/Bulk/BulkRemoveTagsParams.cs | 86 - .../Files/Bulk/BulkRemoveTagsResponse.cs | 54 - src/Imagekit/Models/Files/File.cs | 580 -- src/Imagekit/Models/Files/FileCopyParams.cs | 118 - src/Imagekit/Models/Files/FileCopyResponse.cs | 27 - src/Imagekit/Models/Files/FileDeleteParams.cs | 35 - src/Imagekit/Models/Files/FileGetParams.cs | 33 - src/Imagekit/Models/Files/FileMoveParams.cs | 94 - src/Imagekit/Models/Files/FileMoveResponse.cs | 27 - .../Models/Files/FileProperties/AITag.cs | 95 - .../SelectedFieldsSchemaItem.cs | 290 - .../DefaultValue.cs | 214 - .../UnnamedSchemaWithArrayParent4.cs | 175 - .../MaxValue.cs | 136 - .../MinValue.cs | 136 - .../SelectOption.cs | 171 - .../Type.cs | 74 - .../Models/Files/FileProperties/Type.cs | 46 - .../Files/FileProperties/VersionInfo.cs | 76 - src/Imagekit/Models/Files/FileRenameParams.cs | 129 - .../Models/Files/FileRenameResponse.cs | 52 - src/Imagekit/Models/Files/FileUpdateParams.cs | 67 - .../FileUpdateParamsProperties/Update.cs | 123 - .../UpdateVariants/All.cs | 33 - .../Models/Files/FileUpdateResponse.cs | 631 -- .../IntersectionMember1.cs | 52 - .../ExtensionStatus.cs | 118 - .../AIAutoDescription.cs | 50 - .../AwsAutoTagging.cs | 50 - .../GoogleAutoTagging.cs | 50 - .../ExtensionStatusProperties/RemoveBg.cs | 46 - src/Imagekit/Models/Files/FileUploadParams.cs | 652 -- .../FileUploadParamsProperties/Extension.cs | 177 - .../ExtensionVariants/All.cs | 46 - .../ResponseField.cs | 68 - .../Transformation.cs | 99 - .../TransformationProperties/Post.cs | 268 - .../PostProperties/Abs.cs | 111 - .../PostProperties/AbsProperties/Protocol.cs | 46 - .../PostProperties/AbsProperties/Type.cs | 50 - .../PostProperties/GifToVideo.cs | 85 - .../GifToVideoProperties/Type.cs | 50 - .../PostProperties/Thumbnail.cs | 84 - .../ThumbnailProperties/Type.cs | 50 - .../PostProperties/Transformation.cs | 99 - .../TransformationProperties/Type.cs | 50 - .../PostVariants/All.cs | 61 - .../Models/Files/FileUploadResponse.cs | 636 -- .../FileUploadResponseProperties/AITag.cs | 96 - .../ExtensionStatus.cs | 129 - .../AIAutoDescription.cs | 50 - .../AwsAutoTagging.cs | 50 - .../GoogleAutoTagging.cs | 50 - .../ExtensionStatusProperties/RemoveBg.cs | 46 - .../SelectedFieldsSchemaItem.cs | 290 - .../DefaultValue.cs | 214 - .../UnnamedSchemaWithArrayParent5.cs | 175 - .../MaxValue.cs | 136 - .../MinValue.cs | 136 - .../SelectOption.cs | 171 - .../Type.cs | 64 - .../VersionInfo.cs | 76 - src/Imagekit/Models/Files/Folder.cs | 171 - .../Models/Files/FolderProperties/Type.cs | 43 - src/Imagekit/Models/Files/Metadata.cs | 338 - .../Metadata/MetadataGetFromURLParams.cs | 52 - .../Files/Metadata/MetadataGetParams.cs | 36 - .../Models/Files/MetadataProperties/Exif.cs | 178 - .../MetadataProperties/ExifProperties/Exif.cs | 533 -- .../MetadataProperties/ExifProperties/Gps.cs | 52 - .../ExifProperties/Image.cs | 241 - .../ExifProperties/Interoperability.cs | 70 - .../ExifProperties/Thumbnail.cs | 146 - .../ChangePublicationStatus.cs | 54 - .../Publish.cs | 85 - .../Models/Files/UpdateFileRequest.cs | 164 - .../ChangePublicationStatus.cs | 55 - .../Publish.cs | 90 - .../UpdateFileDetails.cs | 207 - .../UpdateFileDetailsProperties/Extension.cs | 177 - .../AutoTaggingExtension.cs | 100 - .../AutoTaggingExtensionProperties/Name.cs | 46 - .../ExtensionProperties/RemoveBg.cs | 74 - .../RemoveBgProperties/Options.cs | 122 - .../ExtensionVariants/All.cs | 46 - .../RemoveAITags.cs | 148 - .../RemoveAITagsProperties/UnionMember1.cs | 51 - .../RemoveAITagsVariants/All.cs | 26 - .../Files/Versions/VersionDeleteParams.cs | 36 - .../Files/Versions/VersionDeleteResponse.cs | 27 - .../Models/Files/Versions/VersionGetParams.cs | 34 - .../Files/Versions/VersionListParams.cs | 32 - .../Files/Versions/VersionRestoreParams.cs | 34 - .../Models/Folders/FolderCopyParams.cs | 120 - .../Models/Folders/FolderCopyResponse.cs | 64 - .../Models/Folders/FolderCreateParams.cs | 99 - .../Models/Folders/FolderCreateResponse.cs | 27 - .../Models/Folders/FolderDeleteParams.cs | 64 - .../Models/Folders/FolderDeleteResponse.cs | 27 - .../Models/Folders/FolderMoveParams.cs | 95 - .../Models/Folders/FolderMoveResponse.cs | 64 - .../Models/Folders/FolderRenameParams.cs | 126 - .../Models/Folders/FolderRenameResponse.cs | 64 - .../Models/Folders/Job/JobGetParams.cs | 31 - .../Models/Folders/Job/JobGetResponse.cs | 125 - .../Job/JobGetResponseProperties/Status.cs | 46 - .../Job/JobGetResponseProperties/Type.cs | 49 - .../Models/GetImageAttributesOptions.cs | 366 - .../IntersectionMember1.cs | 138 - src/Imagekit/Models/ImageOverlay.cs | 185 - .../IntersectionMember1.cs | 141 - .../IntersectionMember1Properties/Encoding.cs | 52 - src/Imagekit/Models/Overlay.cs | 342 - src/Imagekit/Models/OverlayPosition.cs | 106 - .../Models/OverlayPositionProperties/Focus.cs | 68 - .../Models/OverlayPositionProperties/X.cs | 134 - .../XVariants/All.cs | 21 - .../Models/OverlayPositionProperties/Y.cs | 134 - .../YVariants/All.cs | 21 - src/Imagekit/Models/OverlayTiming.cs | 106 - .../OverlayTimingProperties/Duration.cs | 134 - .../DurationVariants/All.cs | 21 - .../Models/OverlayTimingProperties/End.cs | 135 - .../EndVariants/All.cs | 21 - .../Models/OverlayTimingProperties/Start.cs | 134 - .../StartVariants/All.cs | 21 - src/Imagekit/Models/OverlayVariants/All.cs | 78 - .../Models/ResponsiveImageAttributes.cs | 144 - src/Imagekit/Models/SolidColorOverlay.cs | 159 - .../IntersectionMember1.cs | 115 - .../Models/SolidColorOverlayTransformation.cs | 174 - .../Gradient.cs | 138 - .../GradientProperties/UnionMember0.cs | 51 - .../GradientVariants/All.cs | 23 - .../Height.cs | 132 - .../HeightVariants/All.cs | 21 - .../Radius.cs | 133 - .../RadiusProperties/UnionMember1.cs | 51 - .../RadiusVariants/All.cs | 23 - .../Width.cs | 132 - .../WidthVariants/All.cs | 21 - src/Imagekit/Models/SrcOptions.cs | 224 - src/Imagekit/Models/SubtitleOverlay.cs | 183 - .../IntersectionMember1.cs | 139 - .../IntersectionMember1Properties/Encoding.cs | 52 - .../Models/SubtitleOverlayTransformation.cs | 220 - .../Typography.cs | 56 - src/Imagekit/Models/TextOverlay.cs | 184 - .../IntersectionMember1.cs | 140 - .../IntersectionMember1Properties/Encoding.cs | 52 - .../Models/TextOverlayTransformation.cs | 345 - .../Flip.cs | 52 - .../FontSize.cs | 131 - .../FontSizeVariants/All.cs | 21 - .../InnerAlignment.cs | 53 - .../LineHeight.cs | 137 - .../LineHeightVariants/All.cs | 21 - .../Padding.cs | 133 - .../PaddingVariants/All.cs | 21 - .../Radius.cs | 133 - .../RadiusProperties/UnionMember1.cs | 51 - .../RadiusVariants/All.cs | 23 - .../Rotation.cs | 132 - .../RotationVariants/All.cs | 21 - .../Width.cs | 134 - .../WidthVariants/All.cs | 21 - src/Imagekit/Models/Transformation.cs | 1320 ---- .../TransformationProperties/AIDropShadow.cs | 146 - .../AIDropShadowProperties/UnionMember0.cs | 51 - .../AIDropShadowVariants/All.cs | 23 - .../AIRemoveBackground.cs | 48 - .../AIRemoveBackgroundExternal.cs | 49 - .../TransformationProperties/AIRetouch.cs | 48 - .../TransformationProperties/AIUpscale.cs | 48 - .../TransformationProperties/AIVariation.cs | 50 - .../TransformationProperties/AspectRatio.cs | 137 - .../AspectRatioVariants/All.cs | 21 - .../TransformationProperties/AudioCodec.cs | 53 - .../ContrastStretch.cs | 48 - .../Models/TransformationProperties/Crop.cs | 55 - .../TransformationProperties/CropMode.cs | 49 - .../TransformationProperties/Duration.cs | 133 - .../DurationVariants/All.cs | 21 - .../TransformationProperties/EndOffset.cs | 137 - .../EndOffsetVariants/All.cs | 21 - .../Models/TransformationProperties/Flip.cs | 54 - .../Models/TransformationProperties/Format.cs | 78 - .../TransformationProperties/Gradient.cs | 137 - .../GradientProperties/UnionMember0.cs | 51 - .../GradientVariants/All.cs | 23 - .../TransformationProperties/Grayscale.cs | 47 - .../Models/TransformationProperties/Height.cs | 134 - .../HeightVariants/All.cs | 21 - .../Models/TransformationProperties/Page.cs | 248 - .../PageVariants/All.cs | 21 - .../Models/TransformationProperties/Radius.cs | 133 - .../RadiusProperties/UnionMember1.cs | 51 - .../RadiusVariants/All.cs | 23 - .../TransformationProperties/Rotation.cs | 134 - .../RotationVariants/All.cs | 21 - .../Models/TransformationProperties/Shadow.cs | 138 - .../ShadowProperties/UnionMember0.cs | 51 - .../ShadowVariants/All.cs | 23 - .../TransformationProperties/Sharpen.cs | 134 - .../SharpenProperties/UnionMember0.cs | 51 - .../SharpenVariants/All.cs | 23 - .../TransformationProperties/StartOffset.cs | 136 - .../StartOffsetVariants/All.cs | 21 - .../Models/TransformationProperties/Trim.cs | 134 - .../TrimProperties/UnionMember0.cs | 51 - .../TrimVariants/All.cs | 23 - .../TransformationProperties/UnsharpMask.cs | 142 - .../UnsharpMaskProperties/UnionMember0.cs | 51 - .../UnsharpMaskVariants/All.cs | 23 - .../TransformationProperties/VideoCodec.cs | 56 - .../Models/TransformationProperties/Width.cs | 134 - .../WidthVariants/All.cs | 21 - .../Models/TransformationProperties/X.cs | 131 - .../TransformationProperties/XCenter.cs | 132 - .../XCenterVariants/All.cs | 21 - .../TransformationProperties/XVariants/All.cs | 21 - .../Models/TransformationProperties/Y.cs | 131 - .../TransformationProperties/YCenter.cs | 132 - .../YCenterVariants/All.cs | 21 - .../TransformationProperties/YVariants/All.cs | 21 - .../Models/UnnamedSchemaWithArrayParent0.cs | 224 - .../AIAutoDescription.cs | 53 - .../AIAutoDescriptionProperties/Name.cs | 50 - .../AutoTaggingExtension.cs | 100 - .../AutoTaggingExtensionProperties/Name.cs | 46 - .../RemoveBg.cs | 79 - .../RemoveBgProperties/Name.cs | 50 - .../RemoveBgProperties/Options.cs | 122 - src/Imagekit/Models/VideoOverlay.cs | 184 - .../IntersectionMember1.cs | 140 - .../IntersectionMember1Properties/Encoding.cs | 52 - .../Models/Webhooks/BaseWebhookEvent.cs | 90 - .../Webhooks/UnsafeUnwrapWebhookEvent.cs | 423 - .../Models/Webhooks/UnwrapWebhookEvent.cs | 423 - .../Webhooks/UploadPostTransformErrorEvent.cs | 180 - .../IntersectionMember1.cs | 139 - .../IntersectionMember1Properties/Data.cs | 148 - .../DataProperties/Transformation.cs | 64 - .../TransformationProperties/Error.cs | 60 - .../IntersectionMember1Properties/Request.cs | 79 - .../RequestProperties/Transformation.cs | 116 - .../TransformationProperties/Protocol.cs | 46 - .../TransformationProperties/Type.cs | 52 - .../UploadPostTransformSuccessEvent.cs | 186 - .../IntersectionMember1.cs | 140 - .../IntersectionMember1Properties/Data.cs | 99 - .../IntersectionMember1Properties/Request.cs | 79 - .../RequestProperties/Transformation.cs | 116 - .../TransformationProperties/Protocol.cs | 46 - .../TransformationProperties/Type.cs | 52 - .../Webhooks/UploadPreTransformErrorEvent.cs | 180 - .../IntersectionMember1.cs | 139 - .../IntersectionMember1Properties/Data.cs | 102 - .../DataProperties/Transformation.cs | 64 - .../TransformationProperties/Error.cs | 60 - .../IntersectionMember1Properties/Request.cs | 79 - .../UploadPreTransformSuccessEvent.cs | 189 - .../IntersectionMember1.cs | 143 - .../IntersectionMember1Properties/Data.cs | 637 -- .../DataProperties/AITag.cs | 96 - .../DataProperties/ExtensionStatus.cs | 129 - .../AIAutoDescription.cs | 50 - .../AwsAutoTagging.cs | 50 - .../GoogleAutoTagging.cs | 50 - .../ExtensionStatusProperties/RemoveBg.cs | 46 - .../SelectedFieldsSchemaItem.cs | 290 - .../DefaultValue.cs | 214 - .../UnnamedSchemaWithArrayParent7.cs | 175 - .../MaxValue.cs | 136 - .../MinValue.cs | 136 - .../SelectOption.cs | 171 - .../Type.cs | 64 - .../DataProperties/VersionInfo.cs | 76 - .../IntersectionMember1Properties/Request.cs | 79 - .../VideoTransformationAcceptedEvent.cs | 189 - .../IntersectionMember1.cs | 143 - .../IntersectionMember1Properties/Data.cs | 84 - .../DataProperties/Asset.cs | 63 - .../DataProperties/Transformation.cs | 99 - .../TransformationProperties/Options.cs | 200 - .../OptionsProperties/AudioCodec.cs | 50 - .../OptionsProperties/Format.cs | 55 - .../OptionsProperties/StreamProtocol.cs | 50 - .../OptionsProperties/VideoCodec.cs | 53 - .../TransformationProperties/Type.cs | 51 - .../IntersectionMember1Properties/Request.cs | 101 - .../Webhooks/VideoTransformationErrorEvent.cs | 185 - .../IntersectionMember1.cs | 144 - .../IntersectionMember1Properties/Data.cs | 81 - .../DataProperties/Asset.cs | 63 - .../DataProperties/Transformation.cs | 121 - .../TransformationProperties/Error.cs | 71 - .../ErrorProperties/Reason.cs | 51 - .../TransformationProperties/Options.cs | 200 - .../OptionsProperties/AudioCodec.cs | 50 - .../OptionsProperties/Format.cs | 55 - .../OptionsProperties/StreamProtocol.cs | 50 - .../OptionsProperties/VideoCodec.cs | 53 - .../TransformationProperties/Type.cs | 51 - .../IntersectionMember1Properties/Request.cs | 101 - .../Webhooks/VideoTransformationReadyEvent.cs | 207 - .../IntersectionMember1.cs | 166 - .../IntersectionMember1Properties/Data.cs | 81 - .../DataProperties/Asset.cs | 63 - .../DataProperties/Transformation.cs | 121 - .../TransformationProperties/Options.cs | 200 - .../OptionsProperties/AudioCodec.cs | 50 - .../OptionsProperties/Format.cs | 55 - .../OptionsProperties/StreamProtocol.cs | 50 - .../OptionsProperties/VideoCodec.cs | 53 - .../TransformationProperties/Output.cs | 86 - .../OutputProperties/VideoMetadata.cs | 121 - .../TransformationProperties/Type.cs | 51 - .../IntersectionMember1Properties/Request.cs | 101 - .../IntersectionMember1Properties/Timings.cs | 77 - .../Services/Accounts/AccountService.cs | 34 - .../Services/Accounts/IAccountService.cs | 14 - .../Accounts/Origins/IOriginService.cs | 39 - .../Accounts/Origins/OriginService.cs | 98 - .../URLEndpoints/IURLEndpointService.cs | 40 - .../URLEndpoints/URLEndpointService.cs | 104 - .../Services/Accounts/Usage/IUsageService.cs | 15 - .../Services/Accounts/Usage/UsageService.cs | 32 - src/Imagekit/Services/Assets/AssetService.cs | 38 - src/Imagekit/Services/Assets/IAssetService.cs | 16 - src/Imagekit/Services/Beta/BetaService.cs | 18 - src/Imagekit/Services/Beta/IBetaService.cs | 8 - .../Services/Beta/V2/Files/FileService.cs | 34 - .../Services/Beta/V2/Files/IFileService.cs | 33 - src/Imagekit/Services/Beta/V2/IV2Service.cs | 8 - src/Imagekit/Services/Beta/V2/V2Service.cs | 18 - src/Imagekit/Services/Cache/CacheService.cs | 18 - src/Imagekit/Services/Cache/ICacheService.cs | 8 - .../Invalidation/IInvalidationService.cs | 19 - .../Cache/Invalidation/InvalidationService.cs | 52 - .../CustomMetadataFieldService.cs | 98 - .../ICustomMetadataFieldService.cs | 39 - .../Services/Files/Bulk/BulkService.cs | 86 - .../Services/Files/Bulk/IBulkService.cs | 36 - src/Imagekit/Services/Files/FileService.cs | 151 - src/Imagekit/Services/Files/IFileService.cs | 91 - .../Files/Metadata/IMetadataService.cs | 23 - .../Files/Metadata/MetadataService.cs | 49 - .../Files/Versions/IVersionService.cs | 32 - .../Services/Files/Versions/VersionService.cs | 85 - .../Services/Folders/FolderService.cs | 111 - .../Services/Folders/IFolderService.cs | 46 - .../Services/Folders/Job/IJobService.cs | 12 - .../Services/Folders/Job/JobService.cs | 28 - .../Services/Webhooks/IWebhookService.cs | 3 - .../Services/Webhooks/WebhookService.cs | 6 - 878 files changed, 151290 insertions(+), 56932 deletions(-) create mode 100644 .csharpierignore create mode 100644 CONTRIBUTING.md rename Imagekit.sln => ImageKit.sln (68%) create mode 100644 examples/ImagekitCsharpExample/ImagekitCsharpExample.csproj create mode 100644 src/Directory.Build.props create mode 100644 src/ImageKit.Tests/Core/JsonDictionaryTest.cs create mode 100644 src/ImageKit.Tests/Core/MultipartJsonDictionaryTest.cs create mode 100644 src/ImageKit.Tests/ImageKit.Tests.csproj create mode 100644 src/ImageKit.Tests/Models/Accounts/Origins/OriginCreateParamsTest.cs create mode 100644 src/ImageKit.Tests/Models/Accounts/Origins/OriginDeleteParamsTest.cs create mode 100644 src/ImageKit.Tests/Models/Accounts/Origins/OriginGetParamsTest.cs create mode 100644 src/ImageKit.Tests/Models/Accounts/Origins/OriginListParamsTest.cs create mode 100644 src/ImageKit.Tests/Models/Accounts/Origins/OriginRequestTest.cs create mode 100644 src/ImageKit.Tests/Models/Accounts/Origins/OriginResponseTest.cs create mode 100644 src/ImageKit.Tests/Models/Accounts/Origins/OriginUpdateParamsTest.cs create mode 100644 src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointCreateParamsTest.cs create mode 100644 src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointDeleteParamsTest.cs create mode 100644 src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointGetParamsTest.cs create mode 100644 src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointListParamsTest.cs create mode 100644 src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointRequestTest.cs create mode 100644 src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointResponseTest.cs create mode 100644 src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParamsTest.cs create mode 100644 src/ImageKit.Tests/Models/Accounts/Usage/UsageGetParamsTest.cs create mode 100644 src/ImageKit.Tests/Models/Accounts/Usage/UsageGetResponseTest.cs create mode 100644 src/ImageKit.Tests/Models/Assets/AssetListParamsTest.cs create mode 100644 src/ImageKit.Tests/Models/Assets/AssetListResponseTest.cs create mode 100644 src/ImageKit.Tests/Models/BaseOverlayTest.cs create mode 100644 src/ImageKit.Tests/Models/Beta/V2/Files/FileUploadParamsTest.cs create mode 100644 src/ImageKit.Tests/Models/Beta/V2/Files/FileUploadResponseTest.cs create mode 100644 src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationCreateParamsTest.cs create mode 100644 src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationCreateResponseTest.cs create mode 100644 src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationGetParamsTest.cs create mode 100644 src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationGetResponseTest.cs create mode 100644 src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsTest.cs create mode 100644 src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldDeleteParamsTest.cs create mode 100644 src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldDeleteResponseTest.cs create mode 100644 src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldListParamsTest.cs create mode 100644 src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldTest.cs create mode 100644 src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsTest.cs create mode 100644 src/ImageKit.Tests/Models/ExtensionConfigTest.cs create mode 100644 src/ImageKit.Tests/Models/Files/Bulk/BulkAddTagsParamsTest.cs create mode 100644 src/ImageKit.Tests/Models/Files/Bulk/BulkAddTagsResponseTest.cs create mode 100644 src/ImageKit.Tests/Models/Files/Bulk/BulkDeleteParamsTest.cs create mode 100644 src/ImageKit.Tests/Models/Files/Bulk/BulkDeleteResponseTest.cs create mode 100644 src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveAITagsParamsTest.cs create mode 100644 src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveAITagsResponseTest.cs create mode 100644 src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveTagsParamsTest.cs create mode 100644 src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveTagsResponseTest.cs create mode 100644 src/ImageKit.Tests/Models/Files/FileCopyParamsTest.cs create mode 100644 src/ImageKit.Tests/Models/Files/FileCopyResponseTest.cs create mode 100644 src/ImageKit.Tests/Models/Files/FileDeleteParamsTest.cs create mode 100644 src/ImageKit.Tests/Models/Files/FileGetParamsTest.cs create mode 100644 src/ImageKit.Tests/Models/Files/FileMetadataTest.cs create mode 100644 src/ImageKit.Tests/Models/Files/FileMoveParamsTest.cs create mode 100644 src/ImageKit.Tests/Models/Files/FileMoveResponseTest.cs create mode 100644 src/ImageKit.Tests/Models/Files/FileRenameParamsTest.cs create mode 100644 src/ImageKit.Tests/Models/Files/FileRenameResponseTest.cs create mode 100644 src/ImageKit.Tests/Models/Files/FileTest.cs create mode 100644 src/ImageKit.Tests/Models/Files/FileUpdateParamsTest.cs create mode 100644 src/ImageKit.Tests/Models/Files/FileUpdateResponseTest.cs create mode 100644 src/ImageKit.Tests/Models/Files/FileUploadParamsTest.cs create mode 100644 src/ImageKit.Tests/Models/Files/FileUploadResponseTest.cs create mode 100644 src/ImageKit.Tests/Models/Files/FolderTest.cs create mode 100644 src/ImageKit.Tests/Models/Files/Metadata/MetadataGetFromUrlParamsTest.cs create mode 100644 src/ImageKit.Tests/Models/Files/Metadata/MetadataGetParamsTest.cs create mode 100644 src/ImageKit.Tests/Models/Files/UpdateFileRequestTest.cs create mode 100644 src/ImageKit.Tests/Models/Files/Versions/VersionDeleteParamsTest.cs create mode 100644 src/ImageKit.Tests/Models/Files/Versions/VersionDeleteResponseTest.cs create mode 100644 src/ImageKit.Tests/Models/Files/Versions/VersionGetParamsTest.cs create mode 100644 src/ImageKit.Tests/Models/Files/Versions/VersionListParamsTest.cs create mode 100644 src/ImageKit.Tests/Models/Files/Versions/VersionRestoreParamsTest.cs create mode 100644 src/ImageKit.Tests/Models/Folders/FolderCopyParamsTest.cs create mode 100644 src/ImageKit.Tests/Models/Folders/FolderCopyResponseTest.cs create mode 100644 src/ImageKit.Tests/Models/Folders/FolderCreateParamsTest.cs create mode 100644 src/ImageKit.Tests/Models/Folders/FolderCreateResponseTest.cs create mode 100644 src/ImageKit.Tests/Models/Folders/FolderDeleteParamsTest.cs create mode 100644 src/ImageKit.Tests/Models/Folders/FolderDeleteResponseTest.cs create mode 100644 src/ImageKit.Tests/Models/Folders/FolderMoveParamsTest.cs create mode 100644 src/ImageKit.Tests/Models/Folders/FolderMoveResponseTest.cs create mode 100644 src/ImageKit.Tests/Models/Folders/FolderRenameParamsTest.cs create mode 100644 src/ImageKit.Tests/Models/Folders/FolderRenameResponseTest.cs create mode 100644 src/ImageKit.Tests/Models/Folders/Job/JobGetParamsTest.cs create mode 100644 src/ImageKit.Tests/Models/Folders/Job/JobGetResponseTest.cs create mode 100644 src/ImageKit.Tests/Models/GetImageAttributesOptionsTest.cs create mode 100644 src/ImageKit.Tests/Models/ImageOverlayTest.cs create mode 100644 src/ImageKit.Tests/Models/OverlayPositionTest.cs create mode 100644 src/ImageKit.Tests/Models/OverlayTest.cs create mode 100644 src/ImageKit.Tests/Models/OverlayTimingTest.cs create mode 100644 src/ImageKit.Tests/Models/ResponsiveImageAttributesTest.cs create mode 100644 src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionCreateParamsTest.cs create mode 100644 src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionDeleteParamsTest.cs create mode 100644 src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionGetParamsTest.cs create mode 100644 src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionListParamsTest.cs create mode 100644 src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionUpdateParamsTest.cs create mode 100644 src/ImageKit.Tests/Models/SharedSavedExtensionTest.cs create mode 100644 src/ImageKit.Tests/Models/SolidColorOverlayTest.cs create mode 100644 src/ImageKit.Tests/Models/SolidColorOverlayTransformationTest.cs create mode 100644 src/ImageKit.Tests/Models/SrcOptionsTest.cs create mode 100644 src/ImageKit.Tests/Models/StreamingResolutionTest.cs create mode 100644 src/ImageKit.Tests/Models/SubtitleOverlayTest.cs create mode 100644 src/ImageKit.Tests/Models/SubtitleOverlayTransformationTest.cs create mode 100644 src/ImageKit.Tests/Models/TextOverlayTest.cs create mode 100644 src/ImageKit.Tests/Models/TextOverlayTransformationTest.cs create mode 100644 src/ImageKit.Tests/Models/TransformationPositionTest.cs create mode 100644 src/ImageKit.Tests/Models/TransformationTest.cs create mode 100644 src/ImageKit.Tests/Models/UnnamedSchemaWithArrayParent0Test.cs create mode 100644 src/ImageKit.Tests/Models/VideoOverlayTest.cs create mode 100644 src/ImageKit.Tests/Models/Webhooks/BaseWebhookEventTest.cs create mode 100644 src/ImageKit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs create mode 100644 src/ImageKit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs create mode 100644 src/ImageKit.Tests/Models/Webhooks/UploadPostTransformErrorEventTest.cs create mode 100644 src/ImageKit.Tests/Models/Webhooks/UploadPostTransformSuccessEventTest.cs create mode 100644 src/ImageKit.Tests/Models/Webhooks/UploadPreTransformErrorEventTest.cs create mode 100644 src/ImageKit.Tests/Models/Webhooks/UploadPreTransformSuccessEventTest.cs create mode 100644 src/ImageKit.Tests/Models/Webhooks/VideoTransformationAcceptedEventTest.cs create mode 100644 src/ImageKit.Tests/Models/Webhooks/VideoTransformationErrorEventTest.cs create mode 100644 src/ImageKit.Tests/Models/Webhooks/VideoTransformationReadyEventTest.cs rename src/{Imagekit.Tests/Services/Accounts/Origins => ImageKit.Tests/Services/Accounts}/OriginServiceTest.cs (66%) create mode 100644 src/ImageKit.Tests/Services/Accounts/UrlEndpointServiceTest.cs rename src/{Imagekit.Tests/Services/Accounts/Usage => ImageKit.Tests/Services/Accounts}/UsageServiceTest.cs (54%) rename src/{Imagekit.Tests/Services/Assets => ImageKit.Tests/Services}/AssetServiceTest.cs (63%) rename src/{Imagekit.Tests/Services/Beta/V2/Files => ImageKit.Tests/Services/Beta/V2}/FileServiceTest.cs (56%) rename src/{Imagekit.Tests/Services/Cache/Invalidation => ImageKit.Tests/Services/Cache}/InvalidationServiceTest.cs (62%) rename src/{Imagekit.Tests/Services/CustomMetadataFields => ImageKit.Tests/Services}/CustomMetadataFieldServiceTest.cs (64%) create mode 100644 src/ImageKit.Tests/Services/FileServiceTest.cs rename src/{Imagekit.Tests/Services/Files/Bulk => ImageKit.Tests/Services/Files}/BulkServiceTest.cs (66%) create mode 100644 src/ImageKit.Tests/Services/Files/MetadataServiceTest.cs rename src/{Imagekit.Tests/Services/Files/Versions => ImageKit.Tests/Services/Files}/VersionServiceTest.cs (58%) rename src/{Imagekit.Tests/Services/Folders => ImageKit.Tests/Services}/FolderServiceTest.cs (71%) create mode 100644 src/ImageKit.Tests/Services/Folders/JobServiceTest.cs create mode 100644 src/ImageKit.Tests/Services/SavedExtensionServiceTest.cs rename src/{Imagekit.Tests => ImageKit.Tests}/TestBase.cs (68%) create mode 100644 src/ImageKit/Core/ApiEnum.cs create mode 100644 src/ImageKit/Core/BinaryContent.cs create mode 100644 src/ImageKit/Core/ClientOptions.cs create mode 100644 src/ImageKit/Core/EnvironmentUrl.cs create mode 100644 src/ImageKit/Core/FrozenDictionaryConverterFactory.cs create mode 100644 src/ImageKit/Core/HttpRequest.cs create mode 100644 src/ImageKit/Core/HttpResponse.cs create mode 100644 src/ImageKit/Core/IPage.cs create mode 100644 src/ImageKit/Core/JsonDictionary.cs create mode 100644 src/ImageKit/Core/JsonModel.cs create mode 100644 src/ImageKit/Core/JsonModelConverter.cs create mode 100644 src/ImageKit/Core/ModelBase.cs create mode 100644 src/ImageKit/Core/MultipartJsonDictionary.cs create mode 100644 src/ImageKit/Core/MultipartJsonElement.cs create mode 100644 src/ImageKit/Core/MultipartJsonModel.cs create mode 100644 src/ImageKit/Core/MultipartJsonModelConverter.cs rename src/{Imagekit => ImageKit}/Core/ParamsBase.cs (51%) rename src/{Imagekit => ImageKit}/Exceptions/ImageKit4xxException.cs (83%) rename src/{Imagekit => ImageKit}/Exceptions/ImageKit5xxException.cs (83%) rename src/{Imagekit => ImageKit}/Exceptions/ImageKitApiException.cs (93%) rename src/{Imagekit => ImageKit}/Exceptions/ImageKitBadRequestException.cs (84%) rename src/{Imagekit => ImageKit}/Exceptions/ImageKitException.cs (87%) rename src/{Imagekit => ImageKit}/Exceptions/ImageKitExceptionFactory.cs (95%) rename src/{Imagekit => ImageKit}/Exceptions/ImageKitForbiddenException.cs (84%) rename src/{Imagekit => ImageKit}/Exceptions/ImageKitIOException.cs (90%) rename src/{Imagekit => ImageKit}/Exceptions/ImageKitInvalidDataException.cs (84%) rename src/{Imagekit => ImageKit}/Exceptions/ImageKitNotFoundException.cs (83%) rename src/{Imagekit => ImageKit}/Exceptions/ImageKitRateLimitException.cs (84%) rename src/{Imagekit => ImageKit}/Exceptions/ImageKitUnauthorizedException.cs (84%) rename src/{Imagekit => ImageKit}/Exceptions/ImageKitUnexpectedStatusCodeException.cs (85%) rename src/{Imagekit => ImageKit}/Exceptions/ImageKitUnprocessableEntityException.cs (85%) create mode 100644 src/ImageKit/IImageKitClient.cs create mode 100644 src/ImageKit/IPageExtensions.cs create mode 100644 src/ImageKit/ImageKit.csproj create mode 100644 src/ImageKit/ImageKitClient.cs create mode 100644 src/ImageKit/Models/Accounts/Origins/OriginCreateParams.cs create mode 100644 src/ImageKit/Models/Accounts/Origins/OriginDeleteParams.cs create mode 100644 src/ImageKit/Models/Accounts/Origins/OriginGetParams.cs create mode 100644 src/ImageKit/Models/Accounts/Origins/OriginListParams.cs create mode 100644 src/ImageKit/Models/Accounts/Origins/OriginRequest.cs create mode 100644 src/ImageKit/Models/Accounts/Origins/OriginResponse.cs create mode 100644 src/ImageKit/Models/Accounts/Origins/OriginUpdateParams.cs create mode 100644 src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointCreateParams.cs create mode 100644 src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointDeleteParams.cs create mode 100644 src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointGetParams.cs create mode 100644 src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointListParams.cs create mode 100644 src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointRequest.cs create mode 100644 src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointResponse.cs create mode 100644 src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParams.cs create mode 100644 src/ImageKit/Models/Accounts/Usage/UsageGetParams.cs create mode 100644 src/ImageKit/Models/Accounts/Usage/UsageGetResponse.cs create mode 100644 src/ImageKit/Models/Assets/AssetListParams.cs create mode 100644 src/ImageKit/Models/Assets/AssetListResponse.cs create mode 100644 src/ImageKit/Models/BaseOverlay.cs create mode 100644 src/ImageKit/Models/Beta/V2/Files/FileUploadParams.cs create mode 100644 src/ImageKit/Models/Beta/V2/Files/FileUploadResponse.cs create mode 100644 src/ImageKit/Models/Cache/Invalidation/InvalidationCreateParams.cs create mode 100644 src/ImageKit/Models/Cache/Invalidation/InvalidationCreateResponse.cs create mode 100644 src/ImageKit/Models/Cache/Invalidation/InvalidationGetParams.cs create mode 100644 src/ImageKit/Models/Cache/Invalidation/InvalidationGetResponse.cs create mode 100644 src/ImageKit/Models/CustomMetadataFields/CustomMetadataField.cs create mode 100644 src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldCreateParams.cs create mode 100644 src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldDeleteParams.cs create mode 100644 src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldDeleteResponse.cs create mode 100644 src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldListParams.cs create mode 100644 src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParams.cs create mode 100644 src/ImageKit/Models/ExtensionConfig.cs create mode 100644 src/ImageKit/Models/Files/Bulk/BulkAddTagsParams.cs create mode 100644 src/ImageKit/Models/Files/Bulk/BulkAddTagsResponse.cs create mode 100644 src/ImageKit/Models/Files/Bulk/BulkDeleteParams.cs create mode 100644 src/ImageKit/Models/Files/Bulk/BulkDeleteResponse.cs create mode 100644 src/ImageKit/Models/Files/Bulk/BulkRemoveAITagsParams.cs create mode 100644 src/ImageKit/Models/Files/Bulk/BulkRemoveAITagsResponse.cs create mode 100644 src/ImageKit/Models/Files/Bulk/BulkRemoveTagsParams.cs create mode 100644 src/ImageKit/Models/Files/Bulk/BulkRemoveTagsResponse.cs create mode 100644 src/ImageKit/Models/Files/File.cs create mode 100644 src/ImageKit/Models/Files/FileCopyParams.cs create mode 100644 src/ImageKit/Models/Files/FileCopyResponse.cs create mode 100644 src/ImageKit/Models/Files/FileDeleteParams.cs create mode 100644 src/ImageKit/Models/Files/FileGetParams.cs create mode 100644 src/ImageKit/Models/Files/FileMetadata.cs create mode 100644 src/ImageKit/Models/Files/FileMoveParams.cs create mode 100644 src/ImageKit/Models/Files/FileMoveResponse.cs create mode 100644 src/ImageKit/Models/Files/FileRenameParams.cs create mode 100644 src/ImageKit/Models/Files/FileRenameResponse.cs create mode 100644 src/ImageKit/Models/Files/FileUpdateParams.cs create mode 100644 src/ImageKit/Models/Files/FileUpdateResponse.cs create mode 100644 src/ImageKit/Models/Files/FileUploadParams.cs create mode 100644 src/ImageKit/Models/Files/FileUploadResponse.cs create mode 100644 src/ImageKit/Models/Files/Folder.cs create mode 100644 src/ImageKit/Models/Files/Metadata/MetadataGetFromUrlParams.cs create mode 100644 src/ImageKit/Models/Files/Metadata/MetadataGetParams.cs create mode 100644 src/ImageKit/Models/Files/UpdateFileRequest.cs create mode 100644 src/ImageKit/Models/Files/Versions/VersionDeleteParams.cs create mode 100644 src/ImageKit/Models/Files/Versions/VersionDeleteResponse.cs create mode 100644 src/ImageKit/Models/Files/Versions/VersionGetParams.cs create mode 100644 src/ImageKit/Models/Files/Versions/VersionListParams.cs create mode 100644 src/ImageKit/Models/Files/Versions/VersionRestoreParams.cs create mode 100644 src/ImageKit/Models/Folders/FolderCopyParams.cs create mode 100644 src/ImageKit/Models/Folders/FolderCopyResponse.cs create mode 100644 src/ImageKit/Models/Folders/FolderCreateParams.cs create mode 100644 src/ImageKit/Models/Folders/FolderCreateResponse.cs create mode 100644 src/ImageKit/Models/Folders/FolderDeleteParams.cs create mode 100644 src/ImageKit/Models/Folders/FolderDeleteResponse.cs create mode 100644 src/ImageKit/Models/Folders/FolderMoveParams.cs create mode 100644 src/ImageKit/Models/Folders/FolderMoveResponse.cs create mode 100644 src/ImageKit/Models/Folders/FolderRenameParams.cs create mode 100644 src/ImageKit/Models/Folders/FolderRenameResponse.cs create mode 100644 src/ImageKit/Models/Folders/Job/JobGetParams.cs create mode 100644 src/ImageKit/Models/Folders/Job/JobGetResponse.cs create mode 100644 src/ImageKit/Models/GetImageAttributesOptions.cs create mode 100644 src/ImageKit/Models/ImageOverlay.cs create mode 100644 src/ImageKit/Models/Overlay.cs create mode 100644 src/ImageKit/Models/OverlayPosition.cs create mode 100644 src/ImageKit/Models/OverlayTiming.cs create mode 100644 src/ImageKit/Models/ResponsiveImageAttributes.cs create mode 100644 src/ImageKit/Models/SavedExtensions/SavedExtensionCreateParams.cs create mode 100644 src/ImageKit/Models/SavedExtensions/SavedExtensionDeleteParams.cs create mode 100644 src/ImageKit/Models/SavedExtensions/SavedExtensionGetParams.cs create mode 100644 src/ImageKit/Models/SavedExtensions/SavedExtensionListParams.cs create mode 100644 src/ImageKit/Models/SavedExtensions/SavedExtensionUpdateParams.cs create mode 100644 src/ImageKit/Models/SharedSavedExtension.cs create mode 100644 src/ImageKit/Models/SolidColorOverlay.cs create mode 100644 src/ImageKit/Models/SolidColorOverlayTransformation.cs create mode 100644 src/ImageKit/Models/SrcOptions.cs rename src/{Imagekit => ImageKit}/Models/StreamingResolution.cs (94%) create mode 100644 src/ImageKit/Models/SubtitleOverlay.cs create mode 100644 src/ImageKit/Models/SubtitleOverlayTransformation.cs create mode 100644 src/ImageKit/Models/TextOverlay.cs create mode 100644 src/ImageKit/Models/TextOverlayTransformation.cs create mode 100644 src/ImageKit/Models/Transformation.cs rename src/{Imagekit => ImageKit}/Models/TransformationPosition.cs (83%) create mode 100644 src/ImageKit/Models/UnnamedSchemaWithArrayParent0.cs create mode 100644 src/ImageKit/Models/VideoOverlay.cs create mode 100644 src/ImageKit/Models/Webhooks/BaseWebhookEvent.cs create mode 100644 src/ImageKit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs create mode 100644 src/ImageKit/Models/Webhooks/UnwrapWebhookEvent.cs create mode 100644 src/ImageKit/Models/Webhooks/UploadPostTransformErrorEvent.cs create mode 100644 src/ImageKit/Models/Webhooks/UploadPostTransformSuccessEvent.cs create mode 100644 src/ImageKit/Models/Webhooks/UploadPreTransformErrorEvent.cs create mode 100644 src/ImageKit/Models/Webhooks/UploadPreTransformSuccessEvent.cs create mode 100644 src/ImageKit/Models/Webhooks/VideoTransformationAcceptedEvent.cs create mode 100644 src/ImageKit/Models/Webhooks/VideoTransformationErrorEvent.cs create mode 100644 src/ImageKit/Models/Webhooks/VideoTransformationReadyEvent.cs create mode 100644 src/ImageKit/Services/AccountService.cs create mode 100644 src/ImageKit/Services/Accounts/IOriginService.cs create mode 100644 src/ImageKit/Services/Accounts/IUrlEndpointService.cs create mode 100644 src/ImageKit/Services/Accounts/IUsageService.cs create mode 100644 src/ImageKit/Services/Accounts/OriginService.cs create mode 100644 src/ImageKit/Services/Accounts/UrlEndpointService.cs create mode 100644 src/ImageKit/Services/Accounts/UsageService.cs create mode 100644 src/ImageKit/Services/AssetService.cs create mode 100644 src/ImageKit/Services/Beta/IV2Service.cs create mode 100644 src/ImageKit/Services/Beta/V2/FileService.cs create mode 100644 src/ImageKit/Services/Beta/V2/IFileService.cs create mode 100644 src/ImageKit/Services/Beta/V2Service.cs create mode 100644 src/ImageKit/Services/BetaService.cs create mode 100644 src/ImageKit/Services/Cache/IInvalidationService.cs create mode 100644 src/ImageKit/Services/Cache/InvalidationService.cs create mode 100644 src/ImageKit/Services/CacheService.cs create mode 100644 src/ImageKit/Services/CustomMetadataFieldService.cs create mode 100644 src/ImageKit/Services/FileService.cs create mode 100644 src/ImageKit/Services/Files/BulkService.cs create mode 100644 src/ImageKit/Services/Files/IBulkService.cs create mode 100644 src/ImageKit/Services/Files/IMetadataService.cs create mode 100644 src/ImageKit/Services/Files/IVersionService.cs create mode 100644 src/ImageKit/Services/Files/MetadataService.cs create mode 100644 src/ImageKit/Services/Files/VersionService.cs create mode 100644 src/ImageKit/Services/FolderService.cs create mode 100644 src/ImageKit/Services/Folders/IJobService.cs create mode 100644 src/ImageKit/Services/Folders/JobService.cs create mode 100644 src/ImageKit/Services/IAccountService.cs create mode 100644 src/ImageKit/Services/IAssetService.cs create mode 100644 src/ImageKit/Services/IBetaService.cs create mode 100644 src/ImageKit/Services/ICacheService.cs create mode 100644 src/ImageKit/Services/ICustomMetadataFieldService.cs create mode 100644 src/ImageKit/Services/IFileService.cs create mode 100644 src/ImageKit/Services/IFolderService.cs create mode 100644 src/ImageKit/Services/ISavedExtensionService.cs create mode 100644 src/ImageKit/Services/IWebhookService.cs create mode 100644 src/ImageKit/Services/SavedExtensionService.cs create mode 100644 src/ImageKit/Services/WebhookService.cs create mode 100644 src/ImageKit/Shims.cs delete mode 100644 src/Imagekit.Tests/Imagekit.Tests.csproj delete mode 100644 src/Imagekit.Tests/Services/Accounts/AccountServiceTest.cs delete mode 100644 src/Imagekit.Tests/Services/Accounts/URLEndpoints/URLEndpointServiceTest.cs delete mode 100644 src/Imagekit.Tests/Services/Beta/BetaServiceTest.cs delete mode 100644 src/Imagekit.Tests/Services/Beta/V2/V2ServiceTest.cs delete mode 100644 src/Imagekit.Tests/Services/Cache/CacheServiceTest.cs delete mode 100644 src/Imagekit.Tests/Services/Files/FileServiceTest.cs delete mode 100644 src/Imagekit.Tests/Services/Files/Metadata/MetadataServiceTest.cs delete mode 100644 src/Imagekit.Tests/Services/Folders/Job/JobServiceTest.cs delete mode 100644 src/Imagekit.Tests/Services/Webhooks/WebhookServiceTest.cs delete mode 100644 src/Imagekit/Core/ApiEnum.cs delete mode 100644 src/Imagekit/Core/ClientOptions.cs delete mode 100644 src/Imagekit/Core/HttpRequest.cs delete mode 100644 src/Imagekit/Core/HttpResponse.cs delete mode 100644 src/Imagekit/Core/IVariant.cs delete mode 100644 src/Imagekit/Core/ModelBase.cs delete mode 100644 src/Imagekit/Core/ModelConverter.cs delete mode 100644 src/Imagekit/HttpException.cs delete mode 100644 src/Imagekit/IImageKitClient.cs delete mode 100644 src/Imagekit/ImageKitClient.cs delete mode 100644 src/Imagekit/Imagekit.csproj delete mode 100644 src/Imagekit/Models/Accounts/Origins/OriginCreateParams.cs delete mode 100644 src/Imagekit/Models/Accounts/Origins/OriginDeleteParams.cs delete mode 100644 src/Imagekit/Models/Accounts/Origins/OriginGetParams.cs delete mode 100644 src/Imagekit/Models/Accounts/Origins/OriginListParams.cs delete mode 100644 src/Imagekit/Models/Accounts/Origins/OriginRequest.cs delete mode 100644 src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AkeneoPim.cs delete mode 100644 src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AkeneoPimProperties/Type.cs delete mode 100644 src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AzureBlob.cs delete mode 100644 src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AzureBlobProperties/Type.cs delete mode 100644 src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/CloudinaryBackup.cs delete mode 100644 src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/CloudinaryBackupProperties/Type.cs delete mode 100644 src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/Gcs.cs delete mode 100644 src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/GcsProperties/Type.cs delete mode 100644 src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3.cs delete mode 100644 src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3Compatible.cs delete mode 100644 src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3CompatibleProperties/Type.cs delete mode 100644 src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3Properties/Type.cs delete mode 100644 src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebFolder.cs delete mode 100644 src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebFolderProperties/Type.cs delete mode 100644 src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebProxy.cs delete mode 100644 src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebProxyProperties/Type.cs delete mode 100644 src/Imagekit/Models/Accounts/Origins/OriginRequestVariants/All.cs delete mode 100644 src/Imagekit/Models/Accounts/Origins/OriginResponse.cs delete mode 100644 src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AkeneoPim.cs delete mode 100644 src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AkeneoPimProperties/Type.cs delete mode 100644 src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AzureBlob.cs delete mode 100644 src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AzureBlobProperties/Type.cs delete mode 100644 src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/CloudinaryBackup.cs delete mode 100644 src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/CloudinaryBackupProperties/Type.cs delete mode 100644 src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/Gcs.cs delete mode 100644 src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/GcsProperties/Type.cs delete mode 100644 src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3.cs delete mode 100644 src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3Compatible.cs delete mode 100644 src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3CompatibleProperties/Type.cs delete mode 100644 src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3Properties/Type.cs delete mode 100644 src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebFolder.cs delete mode 100644 src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebFolderProperties/Type.cs delete mode 100644 src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebProxy.cs delete mode 100644 src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebProxyProperties/Type.cs delete mode 100644 src/Imagekit/Models/Accounts/Origins/OriginResponseVariants/All.cs delete mode 100644 src/Imagekit/Models/Accounts/Origins/OriginUpdateParams.cs delete mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParams.cs delete mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriter.cs delete mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/Akamai.cs delete mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/AkamaiProperties/Type.cs delete mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/Cloudinary.cs delete mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/CloudinaryProperties/Type.cs delete mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/Imgix.cs delete mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/ImgixProperties/Type.cs delete mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterVariants/All.cs delete mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointDeleteParams.cs delete mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointGetParams.cs delete mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointListParams.cs delete mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequest.cs delete mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriter.cs delete mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/Akamai.cs delete mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/AkamaiProperties/Type.cs delete mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/Cloudinary.cs delete mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/CloudinaryProperties/Type.cs delete mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/Imgix.cs delete mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/ImgixProperties/Type.cs delete mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterVariants/All.cs delete mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponse.cs delete mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriter.cs delete mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/Akamai.cs delete mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/AkamaiProperties/Type.cs delete mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/Cloudinary.cs delete mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/CloudinaryProperties/Type.cs delete mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/Imgix.cs delete mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/ImgixProperties/Type.cs delete mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterVariants/All.cs delete mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParams.cs delete mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriter.cs delete mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/Akamai.cs delete mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/AkamaiProperties/Type.cs delete mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/Cloudinary.cs delete mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/CloudinaryProperties/Type.cs delete mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/Imgix.cs delete mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/ImgixProperties/Type.cs delete mode 100644 src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterVariants/All.cs delete mode 100644 src/Imagekit/Models/Accounts/Usage/UsageGetParams.cs delete mode 100644 src/Imagekit/Models/Accounts/Usage/UsageGetResponse.cs delete mode 100644 src/Imagekit/Models/Assets/AssetListParams.cs delete mode 100644 src/Imagekit/Models/Assets/AssetListParamsProperties/FileType.cs delete mode 100644 src/Imagekit/Models/Assets/AssetListParamsProperties/Sort.cs delete mode 100644 src/Imagekit/Models/Assets/AssetListParamsProperties/Type.cs delete mode 100644 src/Imagekit/Models/Assets/AssetListResponse.cs delete mode 100644 src/Imagekit/Models/Assets/AssetListResponseVariants/All.cs delete mode 100644 src/Imagekit/Models/BaseOverlay.cs delete mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParams.cs delete mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/Extension.cs delete mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ExtensionProperties/AutoTaggingExtension.cs delete mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs delete mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ExtensionProperties/RemoveBg.cs delete mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ExtensionProperties/RemoveBgProperties/Options.cs delete mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ExtensionVariants/All.cs delete mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ResponseField.cs delete mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/Transformation.cs delete mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/Post.cs delete mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Abs.cs delete mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs delete mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/AbsProperties/Type.cs delete mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideo.cs delete mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideoProperties/Type.cs delete mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Thumbnail.cs delete mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/ThumbnailProperties/Type.cs delete mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Transformation.cs delete mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/TransformationProperties/Type.cs delete mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostVariants/All.cs delete mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadResponse.cs delete mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/AITag.cs delete mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/ExtensionStatus.cs delete mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/ExtensionStatusProperties/AIAutoDescription.cs delete mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/ExtensionStatusProperties/AwsAutoTagging.cs delete mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/ExtensionStatusProperties/GoogleAutoTagging.cs delete mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/ExtensionStatusProperties/RemoveBg.cs delete mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs delete mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs delete mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent6.cs delete mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs delete mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs delete mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs delete mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs delete mode 100644 src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/VersionInfo.cs delete mode 100644 src/Imagekit/Models/Cache/Invalidation/InvalidationCreateParams.cs delete mode 100644 src/Imagekit/Models/Cache/Invalidation/InvalidationCreateResponse.cs delete mode 100644 src/Imagekit/Models/Cache/Invalidation/InvalidationGetParams.cs delete mode 100644 src/Imagekit/Models/Cache/Invalidation/InvalidationGetResponse.cs delete mode 100644 src/Imagekit/Models/Cache/Invalidation/InvalidationGetResponseProperties/Status.cs delete mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataField.cs delete mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParams.cs delete mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/Schema.cs delete mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValue.cs delete mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent2.cs delete mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent2Variants/All.cs delete mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValueVariants/All.cs delete mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MaxValue.cs delete mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MaxValueVariants/All.cs delete mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MinValue.cs delete mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MinValueVariants/All.cs delete mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/SelectOption.cs delete mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/SelectOptionVariants/All.cs delete mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/Type.cs delete mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldDeleteParams.cs delete mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldDeleteResponse.cs delete mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldListParams.cs delete mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/Schema.cs delete mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValue.cs delete mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent1.cs delete mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent1Variants/All.cs delete mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValueVariants/All.cs delete mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MaxValue.cs delete mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MaxValueVariants/All.cs delete mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MinValue.cs delete mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MinValueVariants/All.cs delete mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/SelectOption.cs delete mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/SelectOptionVariants/All.cs delete mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/Type.cs delete mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParams.cs delete mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/Schema.cs delete mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValue.cs delete mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent3.cs delete mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent3Variants/All.cs delete mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValueVariants/All.cs delete mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MaxValue.cs delete mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MaxValueVariants/All.cs delete mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MinValue.cs delete mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MinValueVariants/All.cs delete mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/SelectOption.cs delete mode 100644 src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/SelectOptionVariants/All.cs delete mode 100644 src/Imagekit/Models/Files/Bulk/BulkAddTagsParams.cs delete mode 100644 src/Imagekit/Models/Files/Bulk/BulkAddTagsResponse.cs delete mode 100644 src/Imagekit/Models/Files/Bulk/BulkDeleteParams.cs delete mode 100644 src/Imagekit/Models/Files/Bulk/BulkDeleteResponse.cs delete mode 100644 src/Imagekit/Models/Files/Bulk/BulkRemoveAITagsParams.cs delete mode 100644 src/Imagekit/Models/Files/Bulk/BulkRemoveAITagsResponse.cs delete mode 100644 src/Imagekit/Models/Files/Bulk/BulkRemoveTagsParams.cs delete mode 100644 src/Imagekit/Models/Files/Bulk/BulkRemoveTagsResponse.cs delete mode 100644 src/Imagekit/Models/Files/File.cs delete mode 100644 src/Imagekit/Models/Files/FileCopyParams.cs delete mode 100644 src/Imagekit/Models/Files/FileCopyResponse.cs delete mode 100644 src/Imagekit/Models/Files/FileDeleteParams.cs delete mode 100644 src/Imagekit/Models/Files/FileGetParams.cs delete mode 100644 src/Imagekit/Models/Files/FileMoveParams.cs delete mode 100644 src/Imagekit/Models/Files/FileMoveResponse.cs delete mode 100644 src/Imagekit/Models/Files/FileProperties/AITag.cs delete mode 100644 src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs delete mode 100644 src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs delete mode 100644 src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent4.cs delete mode 100644 src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs delete mode 100644 src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs delete mode 100644 src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs delete mode 100644 src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs delete mode 100644 src/Imagekit/Models/Files/FileProperties/Type.cs delete mode 100644 src/Imagekit/Models/Files/FileProperties/VersionInfo.cs delete mode 100644 src/Imagekit/Models/Files/FileRenameParams.cs delete mode 100644 src/Imagekit/Models/Files/FileRenameResponse.cs delete mode 100644 src/Imagekit/Models/Files/FileUpdateParams.cs delete mode 100644 src/Imagekit/Models/Files/FileUpdateParamsProperties/Update.cs delete mode 100644 src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateVariants/All.cs delete mode 100644 src/Imagekit/Models/Files/FileUpdateResponse.cs delete mode 100644 src/Imagekit/Models/Files/FileUpdateResponseProperties/IntersectionMember1.cs delete mode 100644 src/Imagekit/Models/Files/FileUpdateResponseProperties/IntersectionMember1Properties/ExtensionStatus.cs delete mode 100644 src/Imagekit/Models/Files/FileUpdateResponseProperties/IntersectionMember1Properties/ExtensionStatusProperties/AIAutoDescription.cs delete mode 100644 src/Imagekit/Models/Files/FileUpdateResponseProperties/IntersectionMember1Properties/ExtensionStatusProperties/AwsAutoTagging.cs delete mode 100644 src/Imagekit/Models/Files/FileUpdateResponseProperties/IntersectionMember1Properties/ExtensionStatusProperties/GoogleAutoTagging.cs delete mode 100644 src/Imagekit/Models/Files/FileUpdateResponseProperties/IntersectionMember1Properties/ExtensionStatusProperties/RemoveBg.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParams.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/Extension.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionVariants/All.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/ResponseField.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/Transformation.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/Post.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Abs.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/AbsProperties/Type.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideo.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideoProperties/Type.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Thumbnail.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/ThumbnailProperties/Type.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Transformation.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/TransformationProperties/Type.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostVariants/All.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadResponse.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadResponseProperties/AITag.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadResponseProperties/ExtensionStatus.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadResponseProperties/ExtensionStatusProperties/AIAutoDescription.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadResponseProperties/ExtensionStatusProperties/AwsAutoTagging.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadResponseProperties/ExtensionStatusProperties/GoogleAutoTagging.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadResponseProperties/ExtensionStatusProperties/RemoveBg.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent5.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs delete mode 100644 src/Imagekit/Models/Files/FileUploadResponseProperties/VersionInfo.cs delete mode 100644 src/Imagekit/Models/Files/Folder.cs delete mode 100644 src/Imagekit/Models/Files/FolderProperties/Type.cs delete mode 100644 src/Imagekit/Models/Files/Metadata.cs delete mode 100644 src/Imagekit/Models/Files/Metadata/MetadataGetFromURLParams.cs delete mode 100644 src/Imagekit/Models/Files/Metadata/MetadataGetParams.cs delete mode 100644 src/Imagekit/Models/Files/MetadataProperties/Exif.cs delete mode 100644 src/Imagekit/Models/Files/MetadataProperties/ExifProperties/Exif.cs delete mode 100644 src/Imagekit/Models/Files/MetadataProperties/ExifProperties/Gps.cs delete mode 100644 src/Imagekit/Models/Files/MetadataProperties/ExifProperties/Image.cs delete mode 100644 src/Imagekit/Models/Files/MetadataProperties/ExifProperties/Interoperability.cs delete mode 100644 src/Imagekit/Models/Files/MetadataProperties/ExifProperties/Thumbnail.cs delete mode 100644 src/Imagekit/Models/Files/UpdateFileDetailsRequestProperties/ChangePublicationStatus.cs delete mode 100644 src/Imagekit/Models/Files/UpdateFileDetailsRequestProperties/ChangePublicationStatusProperties/Publish.cs delete mode 100644 src/Imagekit/Models/Files/UpdateFileRequest.cs delete mode 100644 src/Imagekit/Models/Files/UpdateFileRequestProperties/ChangePublicationStatus.cs delete mode 100644 src/Imagekit/Models/Files/UpdateFileRequestProperties/ChangePublicationStatusProperties/Publish.cs delete mode 100644 src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetails.cs delete mode 100644 src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/Extension.cs delete mode 100644 src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/ExtensionProperties/AutoTaggingExtension.cs delete mode 100644 src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs delete mode 100644 src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/ExtensionProperties/RemoveBg.cs delete mode 100644 src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/ExtensionProperties/RemoveBgProperties/Options.cs delete mode 100644 src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/ExtensionVariants/All.cs delete mode 100644 src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/RemoveAITags.cs delete mode 100644 src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/RemoveAITagsProperties/UnionMember1.cs delete mode 100644 src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/RemoveAITagsVariants/All.cs delete mode 100644 src/Imagekit/Models/Files/Versions/VersionDeleteParams.cs delete mode 100644 src/Imagekit/Models/Files/Versions/VersionDeleteResponse.cs delete mode 100644 src/Imagekit/Models/Files/Versions/VersionGetParams.cs delete mode 100644 src/Imagekit/Models/Files/Versions/VersionListParams.cs delete mode 100644 src/Imagekit/Models/Files/Versions/VersionRestoreParams.cs delete mode 100644 src/Imagekit/Models/Folders/FolderCopyParams.cs delete mode 100644 src/Imagekit/Models/Folders/FolderCopyResponse.cs delete mode 100644 src/Imagekit/Models/Folders/FolderCreateParams.cs delete mode 100644 src/Imagekit/Models/Folders/FolderCreateResponse.cs delete mode 100644 src/Imagekit/Models/Folders/FolderDeleteParams.cs delete mode 100644 src/Imagekit/Models/Folders/FolderDeleteResponse.cs delete mode 100644 src/Imagekit/Models/Folders/FolderMoveParams.cs delete mode 100644 src/Imagekit/Models/Folders/FolderMoveResponse.cs delete mode 100644 src/Imagekit/Models/Folders/FolderRenameParams.cs delete mode 100644 src/Imagekit/Models/Folders/FolderRenameResponse.cs delete mode 100644 src/Imagekit/Models/Folders/Job/JobGetParams.cs delete mode 100644 src/Imagekit/Models/Folders/Job/JobGetResponse.cs delete mode 100644 src/Imagekit/Models/Folders/Job/JobGetResponseProperties/Status.cs delete mode 100644 src/Imagekit/Models/Folders/Job/JobGetResponseProperties/Type.cs delete mode 100644 src/Imagekit/Models/GetImageAttributesOptions.cs delete mode 100644 src/Imagekit/Models/GetImageAttributesOptionsProperties/IntersectionMember1.cs delete mode 100644 src/Imagekit/Models/ImageOverlay.cs delete mode 100644 src/Imagekit/Models/ImageOverlayProperties/IntersectionMember1.cs delete mode 100644 src/Imagekit/Models/ImageOverlayProperties/IntersectionMember1Properties/Encoding.cs delete mode 100644 src/Imagekit/Models/Overlay.cs delete mode 100644 src/Imagekit/Models/OverlayPosition.cs delete mode 100644 src/Imagekit/Models/OverlayPositionProperties/Focus.cs delete mode 100644 src/Imagekit/Models/OverlayPositionProperties/X.cs delete mode 100644 src/Imagekit/Models/OverlayPositionProperties/XVariants/All.cs delete mode 100644 src/Imagekit/Models/OverlayPositionProperties/Y.cs delete mode 100644 src/Imagekit/Models/OverlayPositionProperties/YVariants/All.cs delete mode 100644 src/Imagekit/Models/OverlayTiming.cs delete mode 100644 src/Imagekit/Models/OverlayTimingProperties/Duration.cs delete mode 100644 src/Imagekit/Models/OverlayTimingProperties/DurationVariants/All.cs delete mode 100644 src/Imagekit/Models/OverlayTimingProperties/End.cs delete mode 100644 src/Imagekit/Models/OverlayTimingProperties/EndVariants/All.cs delete mode 100644 src/Imagekit/Models/OverlayTimingProperties/Start.cs delete mode 100644 src/Imagekit/Models/OverlayTimingProperties/StartVariants/All.cs delete mode 100644 src/Imagekit/Models/OverlayVariants/All.cs delete mode 100644 src/Imagekit/Models/ResponsiveImageAttributes.cs delete mode 100644 src/Imagekit/Models/SolidColorOverlay.cs delete mode 100644 src/Imagekit/Models/SolidColorOverlayProperties/IntersectionMember1.cs delete mode 100644 src/Imagekit/Models/SolidColorOverlayTransformation.cs delete mode 100644 src/Imagekit/Models/SolidColorOverlayTransformationProperties/Gradient.cs delete mode 100644 src/Imagekit/Models/SolidColorOverlayTransformationProperties/GradientProperties/UnionMember0.cs delete mode 100644 src/Imagekit/Models/SolidColorOverlayTransformationProperties/GradientVariants/All.cs delete mode 100644 src/Imagekit/Models/SolidColorOverlayTransformationProperties/Height.cs delete mode 100644 src/Imagekit/Models/SolidColorOverlayTransformationProperties/HeightVariants/All.cs delete mode 100644 src/Imagekit/Models/SolidColorOverlayTransformationProperties/Radius.cs delete mode 100644 src/Imagekit/Models/SolidColorOverlayTransformationProperties/RadiusProperties/UnionMember1.cs delete mode 100644 src/Imagekit/Models/SolidColorOverlayTransformationProperties/RadiusVariants/All.cs delete mode 100644 src/Imagekit/Models/SolidColorOverlayTransformationProperties/Width.cs delete mode 100644 src/Imagekit/Models/SolidColorOverlayTransformationProperties/WidthVariants/All.cs delete mode 100644 src/Imagekit/Models/SrcOptions.cs delete mode 100644 src/Imagekit/Models/SubtitleOverlay.cs delete mode 100644 src/Imagekit/Models/SubtitleOverlayProperties/IntersectionMember1.cs delete mode 100644 src/Imagekit/Models/SubtitleOverlayProperties/IntersectionMember1Properties/Encoding.cs delete mode 100644 src/Imagekit/Models/SubtitleOverlayTransformation.cs delete mode 100644 src/Imagekit/Models/SubtitleOverlayTransformationProperties/Typography.cs delete mode 100644 src/Imagekit/Models/TextOverlay.cs delete mode 100644 src/Imagekit/Models/TextOverlayProperties/IntersectionMember1.cs delete mode 100644 src/Imagekit/Models/TextOverlayProperties/IntersectionMember1Properties/Encoding.cs delete mode 100644 src/Imagekit/Models/TextOverlayTransformation.cs delete mode 100644 src/Imagekit/Models/TextOverlayTransformationProperties/Flip.cs delete mode 100644 src/Imagekit/Models/TextOverlayTransformationProperties/FontSize.cs delete mode 100644 src/Imagekit/Models/TextOverlayTransformationProperties/FontSizeVariants/All.cs delete mode 100644 src/Imagekit/Models/TextOverlayTransformationProperties/InnerAlignment.cs delete mode 100644 src/Imagekit/Models/TextOverlayTransformationProperties/LineHeight.cs delete mode 100644 src/Imagekit/Models/TextOverlayTransformationProperties/LineHeightVariants/All.cs delete mode 100644 src/Imagekit/Models/TextOverlayTransformationProperties/Padding.cs delete mode 100644 src/Imagekit/Models/TextOverlayTransformationProperties/PaddingVariants/All.cs delete mode 100644 src/Imagekit/Models/TextOverlayTransformationProperties/Radius.cs delete mode 100644 src/Imagekit/Models/TextOverlayTransformationProperties/RadiusProperties/UnionMember1.cs delete mode 100644 src/Imagekit/Models/TextOverlayTransformationProperties/RadiusVariants/All.cs delete mode 100644 src/Imagekit/Models/TextOverlayTransformationProperties/Rotation.cs delete mode 100644 src/Imagekit/Models/TextOverlayTransformationProperties/RotationVariants/All.cs delete mode 100644 src/Imagekit/Models/TextOverlayTransformationProperties/Width.cs delete mode 100644 src/Imagekit/Models/TextOverlayTransformationProperties/WidthVariants/All.cs delete mode 100644 src/Imagekit/Models/Transformation.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/AIDropShadow.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/AIDropShadowProperties/UnionMember0.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/AIDropShadowVariants/All.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/AIRemoveBackground.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/AIRemoveBackgroundExternal.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/AIRetouch.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/AIUpscale.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/AIVariation.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/AspectRatio.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/AspectRatioVariants/All.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/AudioCodec.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/ContrastStretch.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/Crop.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/CropMode.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/Duration.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/DurationVariants/All.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/EndOffset.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/EndOffsetVariants/All.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/Flip.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/Format.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/Gradient.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/GradientProperties/UnionMember0.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/GradientVariants/All.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/Grayscale.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/Height.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/HeightVariants/All.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/Page.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/PageVariants/All.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/Radius.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/RadiusProperties/UnionMember1.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/RadiusVariants/All.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/Rotation.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/RotationVariants/All.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/Shadow.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/ShadowProperties/UnionMember0.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/ShadowVariants/All.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/Sharpen.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/SharpenProperties/UnionMember0.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/SharpenVariants/All.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/StartOffset.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/StartOffsetVariants/All.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/Trim.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/TrimProperties/UnionMember0.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/TrimVariants/All.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/UnsharpMask.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/UnsharpMaskProperties/UnionMember0.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/UnsharpMaskVariants/All.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/VideoCodec.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/Width.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/WidthVariants/All.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/X.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/XCenter.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/XCenterVariants/All.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/XVariants/All.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/Y.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/YCenter.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/YCenterVariants/All.cs delete mode 100644 src/Imagekit/Models/TransformationProperties/YVariants/All.cs delete mode 100644 src/Imagekit/Models/UnnamedSchemaWithArrayParent0.cs delete mode 100644 src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/AIAutoDescription.cs delete mode 100644 src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/AIAutoDescriptionProperties/Name.cs delete mode 100644 src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/AutoTaggingExtension.cs delete mode 100644 src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/AutoTaggingExtensionProperties/Name.cs delete mode 100644 src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/RemoveBg.cs delete mode 100644 src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/RemoveBgProperties/Name.cs delete mode 100644 src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/RemoveBgProperties/Options.cs delete mode 100644 src/Imagekit/Models/VideoOverlay.cs delete mode 100644 src/Imagekit/Models/VideoOverlayProperties/IntersectionMember1.cs delete mode 100644 src/Imagekit/Models/VideoOverlayProperties/IntersectionMember1Properties/Encoding.cs delete mode 100644 src/Imagekit/Models/Webhooks/BaseWebhookEvent.cs delete mode 100644 src/Imagekit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs delete mode 100644 src/Imagekit/Models/Webhooks/UnwrapWebhookEvent.cs delete mode 100644 src/Imagekit/Models/Webhooks/UploadPostTransformErrorEvent.cs delete mode 100644 src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1.cs delete mode 100644 src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1Properties/Data.cs delete mode 100644 src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs delete mode 100644 src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Error.cs delete mode 100644 src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1Properties/Request.cs delete mode 100644 src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1Properties/RequestProperties/Transformation.cs delete mode 100644 src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1Properties/RequestProperties/TransformationProperties/Protocol.cs delete mode 100644 src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1Properties/RequestProperties/TransformationProperties/Type.cs delete mode 100644 src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEvent.cs delete mode 100644 src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1.cs delete mode 100644 src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1Properties/Data.cs delete mode 100644 src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1Properties/Request.cs delete mode 100644 src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1Properties/RequestProperties/Transformation.cs delete mode 100644 src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1Properties/RequestProperties/TransformationProperties/Protocol.cs delete mode 100644 src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1Properties/RequestProperties/TransformationProperties/Type.cs delete mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformErrorEvent.cs delete mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/IntersectionMember1.cs delete mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/IntersectionMember1Properties/Data.cs delete mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs delete mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Error.cs delete mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/IntersectionMember1Properties/Request.cs delete mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEvent.cs delete mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1.cs delete mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/Data.cs delete mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/AITag.cs delete mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/ExtensionStatus.cs delete mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/ExtensionStatusProperties/AIAutoDescription.cs delete mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/ExtensionStatusProperties/AwsAutoTagging.cs delete mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/ExtensionStatusProperties/GoogleAutoTagging.cs delete mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/ExtensionStatusProperties/RemoveBg.cs delete mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs delete mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs delete mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent7.cs delete mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs delete mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs delete mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs delete mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs delete mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/VersionInfo.cs delete mode 100644 src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/Request.cs delete mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEvent.cs delete mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1.cs delete mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/Data.cs delete mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/Asset.cs delete mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs delete mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Options.cs delete mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/AudioCodec.cs delete mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/Format.cs delete mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/StreamProtocol.cs delete mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/VideoCodec.cs delete mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Type.cs delete mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/Request.cs delete mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationErrorEvent.cs delete mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1.cs delete mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/Data.cs delete mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/Asset.cs delete mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs delete mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Error.cs delete mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/ErrorProperties/Reason.cs delete mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Options.cs delete mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/AudioCodec.cs delete mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/Format.cs delete mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/StreamProtocol.cs delete mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/VideoCodec.cs delete mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Type.cs delete mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/Request.cs delete mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationReadyEvent.cs delete mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1.cs delete mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/Data.cs delete mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/Asset.cs delete mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs delete mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Options.cs delete mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/AudioCodec.cs delete mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/Format.cs delete mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/StreamProtocol.cs delete mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/VideoCodec.cs delete mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Output.cs delete mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OutputProperties/VideoMetadata.cs delete mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Type.cs delete mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/Request.cs delete mode 100644 src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/Timings.cs delete mode 100644 src/Imagekit/Services/Accounts/AccountService.cs delete mode 100644 src/Imagekit/Services/Accounts/IAccountService.cs delete mode 100644 src/Imagekit/Services/Accounts/Origins/IOriginService.cs delete mode 100644 src/Imagekit/Services/Accounts/Origins/OriginService.cs delete mode 100644 src/Imagekit/Services/Accounts/URLEndpoints/IURLEndpointService.cs delete mode 100644 src/Imagekit/Services/Accounts/URLEndpoints/URLEndpointService.cs delete mode 100644 src/Imagekit/Services/Accounts/Usage/IUsageService.cs delete mode 100644 src/Imagekit/Services/Accounts/Usage/UsageService.cs delete mode 100644 src/Imagekit/Services/Assets/AssetService.cs delete mode 100644 src/Imagekit/Services/Assets/IAssetService.cs delete mode 100644 src/Imagekit/Services/Beta/BetaService.cs delete mode 100644 src/Imagekit/Services/Beta/IBetaService.cs delete mode 100644 src/Imagekit/Services/Beta/V2/Files/FileService.cs delete mode 100644 src/Imagekit/Services/Beta/V2/Files/IFileService.cs delete mode 100644 src/Imagekit/Services/Beta/V2/IV2Service.cs delete mode 100644 src/Imagekit/Services/Beta/V2/V2Service.cs delete mode 100644 src/Imagekit/Services/Cache/CacheService.cs delete mode 100644 src/Imagekit/Services/Cache/ICacheService.cs delete mode 100644 src/Imagekit/Services/Cache/Invalidation/IInvalidationService.cs delete mode 100644 src/Imagekit/Services/Cache/Invalidation/InvalidationService.cs delete mode 100644 src/Imagekit/Services/CustomMetadataFields/CustomMetadataFieldService.cs delete mode 100644 src/Imagekit/Services/CustomMetadataFields/ICustomMetadataFieldService.cs delete mode 100644 src/Imagekit/Services/Files/Bulk/BulkService.cs delete mode 100644 src/Imagekit/Services/Files/Bulk/IBulkService.cs delete mode 100644 src/Imagekit/Services/Files/FileService.cs delete mode 100644 src/Imagekit/Services/Files/IFileService.cs delete mode 100644 src/Imagekit/Services/Files/Metadata/IMetadataService.cs delete mode 100644 src/Imagekit/Services/Files/Metadata/MetadataService.cs delete mode 100644 src/Imagekit/Services/Files/Versions/IVersionService.cs delete mode 100644 src/Imagekit/Services/Files/Versions/VersionService.cs delete mode 100644 src/Imagekit/Services/Folders/FolderService.cs delete mode 100644 src/Imagekit/Services/Folders/IFolderService.cs delete mode 100644 src/Imagekit/Services/Folders/Job/IJobService.cs delete mode 100644 src/Imagekit/Services/Folders/Job/JobService.cs delete mode 100644 src/Imagekit/Services/Webhooks/IWebhookService.cs delete mode 100644 src/Imagekit/Services/Webhooks/WebhookService.cs diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index b9f69412..23d3744b 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,11 +3,11 @@ "isRoot": true, "tools": { "csharpier": { - "version": "1.0.1", + "version": "1.1.2", "commands": [ "csharpier" ], "rollForward": false } } -} \ No newline at end of file +} diff --git a/.csharpierignore b/.csharpierignore new file mode 100644 index 00000000..e69fe35c --- /dev/null +++ b/.csharpierignore @@ -0,0 +1,2 @@ +*.csproj +*.props diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index a503ddd5..00e36898 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -4,5 +4,9 @@ "name": "C# (.NET)", "image": "mcr.microsoft.com/devcontainers/dotnet:1-9.0-noble", "postAttachCommand": "cat .vscode/extensions.json | jq -r .recommendations[] | xargs -n 1 code --install-extension", - "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}" + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + "features": { + // For the Prism mock server. + "ghcr.io/devcontainers/features/node:1": {} + } } diff --git a/.editorconfig b/.editorconfig index 4287b5b4..e71d07f0 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,26 +1,35 @@ -root = true - -# All files -[*] -indent_style = space - -# Xml files -[*.xml] -indent_size = 2 - -# C# files -[*.cs] - -#### Core EditorConfig Options #### - -# Indentation and spacing -indent_size = 4 -tab_width = 4 - -# New line preferences -end_of_line = crlf -insert_final_newline = true - -dotnet_diagnostic.IDE0060.severity = none # Caused by resource with no methods and no subresources -dotnet_diagnostic.IDE1006.severity = none # Some names may not match up with C# conventions -dotnet_diagnostic.IDE0290.severity = none # Don't prefer primary constructors +root = true + +# All files +[*] +indent_style = space + +# Xml files +[*.xml] +indent_size = 2 + +# C# files +[*.cs] + +#### Core EditorConfig Options #### + +# Indentation and spacing +indent_size = 4 +tab_width = 4 + +# New line preferences +end_of_line = crlf +insert_final_newline = true + +dotnet_diagnostic.IDE0060.severity = none # Caused by resource with no methods and no subresources +dotnet_diagnostic.IDE1006.severity = none # Some names may not match up with C# conventions +dotnet_diagnostic.IDE0290.severity = none # Don't prefer primary constructors +dotnet_diagnostic.IDE0028.severity = none # "Collection initialization can be simplified" is a bit overzealous +dotnet_diagnostic.IDE0090.severity = none # "Simplify 'new' expression" is a bit overzealous +dotnet_diagnostic.IDE0059.severity = none # Sometimes we create "unnecessary" variables for clarity + +# For .NET Standard 2.0 support +dotnet_diagnostic.IDE0057.severity = none # Caused by use of `.Substring(...)` +dotnet_diagnostic.CA1866.severity = none # Caused by use of `.StartsWith(...)` with single character string +dotnet_diagnostic.CA1847.severity = none # Caused by use of `.Contains(...)` with single character string +dotnet_diagnostic.CA2263.severity = none # Caused by use of non-generic `Enum.IsDefined(...)` diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 34f30288..4157d2b7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,13 +20,16 @@ jobs: if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Set up .NET uses: actions/setup-dotnet@v3 with: dotnet-version: '8.0.x' + - name: Run bootstrap + run: ./scripts/bootstrap + - name: Run lints run: ./scripts/lint build: @@ -36,7 +39,7 @@ jobs: if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Set up .NET uses: actions/setup-dotnet@v3 @@ -49,15 +52,16 @@ jobs: test: timeout-minutes: 10 name: test - runs-on: ${{ github.repository == 'stainless-sdks/imagekit-csharp' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + runs-on: ${{ github.repository == 'stainless-sdks/imagekit-csharp' && 'depot-windows-2022' || 'windows-latest' }} if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Set up .NET - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v5 with: dotnet-version: '8.0.x' - name: Run tests run: ./scripts/test + shell: bash diff --git a/.gitignore b/.gitignore index cd42ee34..08a6d808 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ +.prism.log bin/ obj/ +.vs/ +.idea/ diff --git a/.stats.yml b/.stats.yml index ae3aead6..011cf609 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 42 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-9d184cb502ab32a85db2889c796cdfebe812f2a55a604df79c85dd4b5e7e2add.yml -openapi_spec_hash: a9aa620376fce66532c84f9364209b0b -config_hash: eb4cf65a4c6b26a2901076eff5810d5d +configured_endpoints: 47 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-84f0d75048a9268981a84800b4190e3691997ce57dcfc0876f38a5b3fce6bacd.yml +openapi_spec_hash: 35607d4e850c8a60524223ff632c83bb +config_hash: 47cb702ee2cb52c58d803ae39ade9b44 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..23a511cd --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,37 @@ +## Setting up the environment + +To set up the repository, run: + +```sh +$ ./scripts/bootstrap +$ ./scripts/build +``` + +This will install required dependencies and build the SDK. + +## Modifying/Adding code + +Most of the SDK is generated code. Modifications to code will be persisted between generations, but may +result in merge conflicts between manual patches and changes from the generator. The generator will never +modify the contents of the `examples/` directory. + +## Using the repository from source + +To use a local version of this library from source in another project, add it using a directory reference: + +```sh +$ dotnet add reference /path/to/sdk/src/ImageKit +``` + +## Formatting and linting + +```sh +$ ./scripts/format +$ ./scripts/lint +``` + +## Running tests + +```sh +$ ./scripts/test +``` diff --git a/Imagekit.sln b/ImageKit.sln similarity index 68% rename from Imagekit.sln rename to ImageKit.sln index 2e968497..65ff0d6f 100644 --- a/Imagekit.sln +++ b/ImageKit.sln @@ -2,9 +2,20 @@ # Visual Studio Version 17 VisualStudioVersion = 17.0.31903.59 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Imagekit", "src\Imagekit\Imagekit.csproj", "{5816A0C1-3BA1-454E-8D08-85B23DEF309D}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageKit", "src\ImageKit\ImageKit.csproj", "{5816A0C1-3BA1-454E-8D08-85B23DEF309D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Imagekit.Tests", "src\Imagekit.Tests\Imagekit.Tests.csproj", "{0732C8A6-7313-4C33-AE2E-FFAA82EFB481}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageKit.Tests", "src\ImageKit.Tests\ImageKit.Tests.csproj", "{0732C8A6-7313-4C33-AE2E-FFAA82EFB481}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{93E58BA5-CEFE-447E-AC0C-F2C5BC4C411D}" + ProjectSection(SolutionItems) = preProject + CHANGELOG.md + .csharpierignore + .editorconfig + .gitignore + LICENSE + README.md + SECURITY.md + EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/LICENSE b/LICENSE index e7a4d160..20278610 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2025 Image Kit + Copyright 2026 Image Kit Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/README.md b/README.md index d69a5379..b0446cda 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,5 @@ # Image Kit C# API Library -> [!NOTE] -> The Image Kit C# API Library is currently in **beta** and we're excited for you to experiment with it! -> -> This library has not yet been exhaustively tested in production environments and may be missing some features you'd expect in a stable release. As we continue development, there may be breaking changes that require updates to your code. -> -> **We'd love your feedback!** Please share any suggestions, bug reports, feature requests, or general thoughts by [filing an issue](https://www.github.com/stainless-sdks/imagekit-csharp/issues/new). - The Image Kit C# SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in C#. The REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). @@ -15,15 +8,12 @@ The REST API documentation can be found on [imagekit.io](https://imagekit.io/doc ```bash git clone git@github.com:stainless-sdks/imagekit-csharp.git -dotnet add reference imagekit-csharp/src/Imagekit +dotnet add reference imagekit-csharp/src/ImageKit ``` ## Requirements -This library requires .NET 8 or later. - -> [!NOTE] -> The library is currently in **beta**. The requirements will be lowered in the future. +This library requires .NET Standard 2.0 or later. ## Usage @@ -31,15 +21,15 @@ See the [`examples`](examples) directory for complete and runnable examples. ```csharp using System; -using Imagekit; -using Imagekit.Models.Files; +using System.Text; +using ImageKit; +using ImageKit.Models.Files; -// Configured using the IMAGEKIT_PRIVATE_KEY, OPTIONAL_IMAGEKIT_IGNORES_THIS, IMAGEKIT_WEBHOOK_SECRET and IMAGE_KIT_BASE_URL environment variables ImageKitClient client = new(); FileUploadParams parameters = new() { - File = "a value", + File = Encoding.UTF8.GetBytes("https://www.example.com/public-url.jpg"), FileName = "file-name.jpg", }; @@ -48,12 +38,12 @@ var response = await client.Files.Upload(parameters); Console.WriteLine(response); ``` -## Client Configuration +## Client configuration Configure the client using environment variables: ```csharp -using Imagekit; +using ImageKit; // Configured using the IMAGEKIT_PRIVATE_KEY, OPTIONAL_IMAGEKIT_IGNORES_THIS, IMAGEKIT_WEBHOOK_SECRET and IMAGE_KIT_BASE_URL environment variables ImageKitClient client = new(); @@ -62,7 +52,7 @@ ImageKitClient client = new(); Or manually: ```csharp -using Imagekit; +using ImageKit; ImageKitClient client = new() { @@ -82,12 +72,61 @@ See this table for the available options: | `WebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - | | `BaseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` | +### Modifying configuration + +To temporarily use a modified client configuration, while reusing the same connection and thread pools, call `WithOptions` on any client or service: + +```csharp +using System; + +var response = await client + .WithOptions(options => + options with + { + BaseUrl = "https://example.com", + Timeout = TimeSpan.FromSeconds(42), + } + ) + .Files.Upload(parameters); + +Console.WriteLine(response); +``` + +Using a [`with` expression](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/with-expression) makes it easy to construct the modified options. + +The `WithOptions` method does not affect the original client or service. + ## Requests and responses To send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a C# class. For example, `client.Files.Upload` should be called with an instance of `FileUploadParams`, and it will return an instance of `Task`. +## Raw responses + +The SDK defines methods that deserialize responses into instances of C# classes. However, these methods don't provide access to the response headers, status code, or the raw response body. + +To access this data, prefix any HTTP method call on a client or service with `WithRawResponse`: + +```csharp +var response = await client.WithRawResponse.Files.Upload(parameters); +var statusCode = response.StatusCode; +var headers = response.Headers; +``` + +The raw `HttpResponseMessage` can also be accessed through the `RawMessage` property. + +For non-streaming responses, you can deserialize the response into an instance of a C# class if needed: + +```csharp +using System; +using ImageKit.Models.Files; + +var response = await client.WithRawResponse.Files.Upload(parameters); +FileUploadResponse deserialized = await response.Deserialize(); +Console.WriteLine(deserialized); +``` + ## Error handling The SDK throws custom unchecked exception types: @@ -115,6 +154,110 @@ false - `ImageKitException`: Base class for all exceptions. +## Network options + +### Retries + +The SDK automatically retries 2 times by default, with a short exponential backoff between requests. + +Only the following error types are retried: + +- Connection errors (for example, due to a network connectivity problem) +- 408 Request Timeout +- 409 Conflict +- 429 Rate Limit +- 5xx Internal + +The API may also explicitly instruct the SDK to retry or not retry a request. + +To set a custom number of retries, configure the client using the `MaxRetries` method: + +```csharp +using ImageKit; + +ImageKitClient client = new() { MaxRetries = 3 }; +``` + +Or configure a single method call using [`WithOptions`](#modifying-configuration): + +```csharp +using System; + +var response = await client + .WithOptions(options => + options with { MaxRetries = 3 } + ) + .Files.Upload(parameters); + +Console.WriteLine(response); +``` + +### Timeouts + +Requests time out after 1 minute by default. + +To set a custom timeout, configure the client using the `Timeout` option: + +```csharp +using System; +using ImageKit; + +ImageKitClient client = new() { Timeout = TimeSpan.FromSeconds(42) }; +``` + +Or configure a single method call using [`WithOptions`](#modifying-configuration): + +```csharp +using System; + +var response = await client + .WithOptions(options => + options with { Timeout = TimeSpan.FromSeconds(42) } + ) + .Files.Upload(parameters); + +Console.WriteLine(response); +``` + +## Undocumented API functionality + +The SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API. + +### Response validation + +In rare cases, the API may return a response that doesn't match the expected type. For example, the SDK may expect a property to contain a `string`, but the API could return something else. + +By default, the SDK will not throw an exception in this case. It will throw `ImageKitInvalidDataException` only if you directly access the property. + +If you would prefer to check that the response is completely well-typed upfront, then either call `Validate`: + +```csharp +var response = client.Files.Upload(parameters); +response.Validate(); +``` + +Or configure the client using the `ResponseValidation` option: + +```csharp +using ImageKit; + +ImageKitClient client = new() { ResponseValidation = true }; +``` + +Or configure a single method call using [`WithOptions`](#modifying-configuration): + +```csharp +using System; + +var response = await client + .WithOptions(options => + options with { ResponseValidation = true } + ) + .Files.Upload(parameters); + +Console.WriteLine(response); +``` + ## Semantic versioning This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions: diff --git a/examples/ImagekitCsharpExample/ImagekitCsharpExample.csproj b/examples/ImagekitCsharpExample/ImagekitCsharpExample.csproj new file mode 100644 index 00000000..9f240fcd --- /dev/null +++ b/examples/ImagekitCsharpExample/ImagekitCsharpExample.csproj @@ -0,0 +1,12 @@ + + + + + + Exe + net8.0 + ImagekitCsharpExample + enable + disable + + diff --git a/scripts/lint b/scripts/lint index c7ef3cb9..8c2f26c7 100755 --- a/scripts/lint +++ b/scripts/lint @@ -4,6 +4,9 @@ set -e cd "$(dirname "$0")/.." +echo "==> Running dotnet csharpier check" +dotnet csharpier check . + echo "==> Running dotnet format" dotnet format style --severity info --verify-no-changes dotnet format analyzers --severity info --verify-no-changes diff --git a/scripts/test b/scripts/test index a562fa22..f47e4b7f 100755 --- a/scripts/test +++ b/scripts/test @@ -14,6 +14,10 @@ function prism_is_running() { } kill_server_on_port() { + if [ ! "$(which lsof)" ]; then + echo "Warning: lsof not found. Prism will not be killed." + return 0 + fi pids=$(lsof -t -i tcp:"$1" || echo "") if [ "$pids" != "" ]; then kill "$pids" diff --git a/src/Directory.Build.props b/src/Directory.Build.props new file mode 100644 index 00000000..0a76a1bb --- /dev/null +++ b/src/Directory.Build.props @@ -0,0 +1,34 @@ + + + Image Kit + Image Kit + sdk;api;http;library + Apache-2.0 + Copyright 2026 Image Kit + https://imagekit.io/docs/api-reference + https://www.github.com/stainless-sdks/imagekit-csharp + git + + + true + + $(NoWarn),1570,1573,1574,1591 + + + true + true + true + embedded + + net8.0;netstandard2.0 + 12 + Debug;Release + true + true + enable + true + disable + + $(NoWarn),0618 + + \ No newline at end of file diff --git a/src/ImageKit.Tests/Core/JsonDictionaryTest.cs b/src/ImageKit.Tests/Core/JsonDictionaryTest.cs new file mode 100644 index 00000000..45e37e97 --- /dev/null +++ b/src/ImageKit.Tests/Core/JsonDictionaryTest.cs @@ -0,0 +1,406 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Exceptions; + +namespace ImageKit.Tests.Core; + +public class JsonDictionaryTest : TestBase +{ + [Fact] + public void DefaultConstructor_CreatesEmptyDictionary() + { + var dict = new JsonDictionary(); + + Assert.Empty(dict.Freeze()); + } + + [Fact] + public void DictionaryConstructor_CopiesData() + { + var source = new Dictionary + { + ["foo"] = JsonSerializer.SerializeToElement("bar"), + ["bar"] = JsonSerializer.SerializeToElement(42), + }; + + var dict = new JsonDictionary(source); + + var frozen = dict.Freeze(); + Assert.Equal(2, frozen.Count); + Assert.Equal("bar", frozen["foo"].GetString()); + Assert.Equal(42, frozen["bar"].GetInt32()); + } + + [Fact] + public void FrozenDictionaryConstructor_UsesProvidedDictionary() + { + var source = FrozenDictionary.ToFrozenDictionary( + new Dictionary + { + ["foo"] = JsonSerializer.SerializeToElement("bar"), + } + ); + + var dict = new JsonDictionary(source); + + var frozen = dict.Freeze(); + Assert.Same(source, frozen); + } + + [Fact] + public void Set_AddsValueWhenUnfrozen() + { + var dict = new JsonDictionary(); + + dict.Set("name", "Alice"); + dict.Set("age", 30); + + var frozen = dict.Freeze(); + Assert.Equal("Alice", frozen["name"].GetString()); + Assert.Equal(30, frozen["age"].GetInt32()); + } + + [Fact] + public void Set_OverwritesExistingValue() + { + var dict = new JsonDictionary(); + + dict.Set("foo", "bar"); + dict.Set("foo", "baz"); + + var frozen = dict.Freeze(); + Assert.Equal("baz", frozen["foo"].GetString()); + } + + [Fact] + public void Set_ThrowsAfterFreezing() + { + var dict = new JsonDictionary(); + dict.Freeze(); + + Assert.Throws(() => dict.Set("foo", "bar")); + } + + [Fact] + public void Freeze_ReturnsFrozenDictionary() + { + var dict = new JsonDictionary(); + dict.Set("foo", "bar"); + + var frozen1 = dict.Freeze(); + var frozen2 = dict.Freeze(); + + Assert.Same(frozen1, frozen2); + } + + [Fact] + public void GetNotNullClass_ReturnsValue() + { + var dict = new JsonDictionary(); + dict.Set("name", "Alice"); + + Assert.Equal("Alice", dict.GetNotNullClass("name")); + } + + [Fact] + public void GetNotNullClass_CachesDeserializedValue() + { + var dict = new JsonDictionary(); + dict.Set("name", "Alice"); + + var first = dict.GetNotNullClass("name"); + var second = dict.GetNotNullClass("name"); + + Assert.Same(first, second); + } + + [Fact] + public void GetNotNullClass_ThrowsWhenKeyAbsent() + { + var dict = new JsonDictionary(); + + var exception = Assert.Throws(() => + dict.GetNotNullClass("missing") + ); + Assert.Contains("'missing' cannot be absent", exception.Message); + } + + [Fact] + public void GetNotNullClass_ThrowsWhenValueIsNull() + { + var dict = new JsonDictionary( + new Dictionary + { + ["nullable"] = JsonSerializer.SerializeToElement(null), + } + ); + + var exception = Assert.Throws(() => + dict.GetNotNullClass("nullable") + ); + Assert.Contains("'nullable' cannot be null", exception.Message); + } + + [Fact] + public void GetNotNullClass_ThrowsWhenTypeInvalid() + { + var dict = new JsonDictionary(); + dict.Set("number", 42); + + var exception = Assert.Throws(() => + dict.GetNotNullClass("number") + ); + Assert.Contains("'number' must be of type", exception.Message); + } + + [Fact] + public void GetNotNullStruct_ReturnsValue() + { + var dict = new JsonDictionary(); + dict.Set("age", 30); + + var age = dict.GetNotNullStruct("age"); + + Assert.Equal(30, age); + } + + [Fact] + public void GetNotNullStruct_ThrowsWhenKeyAbsent() + { + var dict = new JsonDictionary(); + + var exception = Assert.Throws(() => + dict.GetNotNullStruct("missing") + ); + Assert.Contains("'missing' cannot be absent", exception.Message); + } + + [Fact] + public void GetNotNullStruct_ThrowsWhenValueIsNull() + { + var dict = new JsonDictionary( + new Dictionary + { + ["nullable"] = JsonSerializer.SerializeToElement(null), + } + ); + + var exception = Assert.Throws(() => + dict.GetNotNullStruct("nullable") + ); + Assert.Contains("'nullable' cannot be null", exception.Message); + } + + [Fact] + public void GetNotNullStruct_ThrowsWhenTypeInvalid() + { + var dict = new JsonDictionary(); + dict.Set("text", "not a number"); + + var exception = Assert.Throws(() => + dict.GetNotNullStruct("text") + ); + Assert.Contains("'text' must be of type", exception.Message); + } + + [Fact] + public void GetNullableClass_ReturnsValueWhenPresent() + { + var dict = new JsonDictionary(); + dict.Set("name", "Alice"); + + var name = dict.GetNullableClass("name"); + + Assert.Equal("Alice", name); + } + + [Fact] + public void GetNullableClass_ReturnsNullWhenKeyAbsent() + { + var dict = new JsonDictionary(); + + var missing = dict.GetNullableClass("missing"); + + Assert.Null(missing); + } + + [Fact] + public void GetNullableClass_ReturnsNullWhenValueIsNull() + { + var dict = new JsonDictionary( + new Dictionary + { + ["nullable"] = JsonSerializer.SerializeToElement(null), + } + ); + + var nullable = dict.GetNullableClass("nullable"); + + Assert.Null(nullable); + } + + [Fact] + public void GetNullableClass_CachesDeserializedValue() + { + var dict = new JsonDictionary(); + dict.Set("name", "Alice"); + + var first = dict.GetNullableClass("name"); + var second = dict.GetNullableClass("name"); + + Assert.Same(first, second); + } + + [Fact] + public void GetNullableClass_ThrowsWhenTypeInvalid() + { + var dict = new JsonDictionary(); + dict.Set("number", 42); + + var exception = Assert.Throws(() => + dict.GetNullableClass("number") + ); + Assert.Contains("'number' must be of type", exception.Message); + } + + [Fact] + public void GetNullableStruct_ReturnsValueWhenPresent() + { + var dict = new JsonDictionary(); + dict.Set("age", 30); + + var age = dict.GetNullableStruct("age"); + + Assert.Equal(30, age); + } + + [Fact] + public void GetNullableStruct_ReturnsNullWhenKeyAbsent() + { + var dict = new JsonDictionary(); + + var missing = dict.GetNullableStruct("missing"); + + Assert.Null(missing); + } + + [Fact] + public void GetNullableStruct_ReturnsNullWhenValueIsNull() + { + var dict = new JsonDictionary( + new Dictionary + { + ["nullable"] = JsonSerializer.SerializeToElement(null), + } + ); + + var nullable = dict.GetNullableStruct("nullable"); + + Assert.Null(nullable); + } + + [Fact] + public void GetNullableStruct_ThrowsWhenTypeInvalid() + { + var dict = new JsonDictionary(); + dict.Set("text", "not a number"); + + var exception = Assert.Throws(() => + dict.GetNullableStruct("text") + ); + Assert.Contains("'text' must be of type", exception.Message); + } + + [Fact] + public void ComplexWorkflow_SetFreezeAndGet() + { + var dict = new JsonDictionary(); + dict.Set("name", "Alice"); + dict.Set("age", 30); + dict.Set("active", true); + + var frozen = dict.Freeze(); + + Assert.Equal("Alice", dict.GetNotNullClass("name")); + Assert.Equal(30, dict.GetNotNullStruct("age")); + Assert.True(dict.GetNotNullStruct("active")); + Assert.Null(dict.GetNullableClass("missing")); + + Assert.Throws(() => dict.Set("new", "value")); + } + + [Fact] + public void ToString_ContainsJsonValues() + { + var dict = new JsonDictionary(); + dict.Set("name", "Alice"); + dict.Set("age", 30); + + var json = dict.ToString(); + + Assert.Contains("\"name\"", json); + Assert.Contains("\"Alice\"", json); + Assert.Contains("\"age\"", json); + Assert.Contains("30", json); + } + + [Fact] + public void Equals_ReturnsTrueForSameContent() + { + var dict1 = new JsonDictionary(); + dict1.Set("name", "Alice"); + dict1.Set("age", 30); + + var dict2 = new JsonDictionary(); + dict2.Set("name", "Alice"); + dict2.Set("age", 30); + + Assert.True(dict1.Equals(dict2)); + } + + [Fact] + public void Equals_ReturnsFalseForDifferentContent() + { + var dict1 = new JsonDictionary(); + dict1.Set("name", "Alice"); + + var dict2 = new JsonDictionary(); + dict2.Set("name", "Bob"); + + Assert.False(dict1.Equals(dict2)); + } + + [Fact] + public void Equals_ReturnsFalseForDifferentCounts() + { + var dict1 = new JsonDictionary(); + dict1.Set("name", "Alice"); + dict1.Set("age", 30); + + var dict2 = new JsonDictionary(); + dict2.Set("name", "Alice"); + + Assert.False(dict1.Equals(dict2)); + } + + [Fact] + public void Equals_ReturnsFalseForNull() + { + var dict = new JsonDictionary(); + dict.Set("name", "Alice"); + + Assert.False(dict.Equals(null)); + } + + [Fact] + public void Equals_ReturnsFalseForDifferentType() + { + var dict = new JsonDictionary(); + dict.Set("name", "Alice"); + + Assert.False(dict.Equals("not a dictionary")); + } +} diff --git a/src/ImageKit.Tests/Core/MultipartJsonDictionaryTest.cs b/src/ImageKit.Tests/Core/MultipartJsonDictionaryTest.cs new file mode 100644 index 00000000..8c5c130c --- /dev/null +++ b/src/ImageKit.Tests/Core/MultipartJsonDictionaryTest.cs @@ -0,0 +1,333 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using ImageKit.Core; +using ImageKit.Exceptions; + +namespace ImageKit.Tests.Core; + +public class MultipartJsonDictionaryTest : TestBase +{ + [Fact] + public void DefaultConstructor_CreatesEmptyDictionary() + { + var dict = new MultipartJsonDictionary(); + + Assert.Empty(dict.Freeze()); + } + + [Fact] + public void DictionaryConstructor_CopiesData() + { + var source = new Dictionary + { + ["foo"] = MultipartJsonSerializer.SerializeToElement("bar"), + ["bar"] = MultipartJsonSerializer.SerializeToElement(42), + }; + + var dict = new MultipartJsonDictionary(source); + + var frozen = dict.Freeze(); + Assert.Equal(2, frozen.Count); + Assert.Equal("bar", frozen["foo"].Json.GetString()); + Assert.Equal(42, frozen["bar"].Json.GetInt32()); + } + + [Fact] + public void FrozenDictionaryConstructor_UsesProvidedDictionary() + { + var source = FrozenDictionary.ToFrozenDictionary( + new Dictionary + { + ["foo"] = MultipartJsonSerializer.SerializeToElement("bar"), + } + ); + + var dict = new MultipartJsonDictionary(source); + + var frozen = dict.Freeze(); + Assert.Same(source, frozen); + } + + [Fact] + public void Set_AddsValueWhenUnfrozen() + { + var dict = new MultipartJsonDictionary(); + + dict.Set("name", "Alice"); + dict.Set("age", 30); + + var frozen = dict.Freeze(); + Assert.Equal("Alice", frozen["name"].Json.GetString()); + Assert.Equal(30, frozen["age"].Json.GetInt32()); + } + + [Fact] + public void Set_OverwritesExistingValue() + { + var dict = new MultipartJsonDictionary(); + + dict.Set("foo", "bar"); + dict.Set("foo", "baz"); + + var frozen = dict.Freeze(); + Assert.Equal("baz", frozen["foo"].Json.GetString()); + } + + [Fact] + public void Set_ThrowsAfterFreezing() + { + var dict = new MultipartJsonDictionary(); + dict.Freeze(); + + Assert.Throws(() => dict.Set("foo", "bar")); + } + + [Fact] + public void Freeze_ReturnsFrozenDictionary() + { + var dict = new MultipartJsonDictionary(); + dict.Set("foo", "bar"); + + var frozen1 = dict.Freeze(); + var frozen2 = dict.Freeze(); + + Assert.Same(frozen1, frozen2); + } + + [Fact] + public void GetNotNullClass_ReturnsValue() + { + var dict = new MultipartJsonDictionary(); + dict.Set("name", "Alice"); + + Assert.Equal("Alice", dict.GetNotNullClass("name")); + } + + [Fact] + public void GetNotNullClass_CachesDeserializedValue() + { + var dict = new MultipartJsonDictionary(); + dict.Set("name", "Alice"); + + var first = dict.GetNotNullClass("name"); + var second = dict.GetNotNullClass("name"); + + Assert.Same(first, second); + } + + [Fact] + public void GetNotNullClass_ThrowsWhenKeyAbsent() + { + var dict = new MultipartJsonDictionary(); + + var exception = Assert.Throws(() => + dict.GetNotNullClass("missing") + ); + Assert.Contains("'missing' cannot be absent", exception.Message); + } + + [Fact] + public void GetNotNullClass_ThrowsWhenValueIsNull() + { + var dict = new MultipartJsonDictionary( + new Dictionary + { + ["nullable"] = MultipartJsonSerializer.SerializeToElement(null), + } + ); + + var exception = Assert.Throws(() => + dict.GetNotNullClass("nullable") + ); + Assert.Contains("'nullable' cannot be null", exception.Message); + } + + [Fact] + public void GetNotNullClass_ThrowsWhenTypeInvalid() + { + var dict = new MultipartJsonDictionary(); + dict.Set("number", 42); + + var exception = Assert.Throws(() => + dict.GetNotNullClass("number") + ); + Assert.Contains("'number' must be of type", exception.Message); + } + + [Fact] + public void GetNotNullStruct_ReturnsValue() + { + var dict = new MultipartJsonDictionary(); + dict.Set("age", 30); + + var age = dict.GetNotNullStruct("age"); + + Assert.Equal(30, age); + } + + [Fact] + public void GetNotNullStruct_ThrowsWhenKeyAbsent() + { + var dict = new MultipartJsonDictionary(); + + var exception = Assert.Throws(() => + dict.GetNotNullStruct("missing") + ); + Assert.Contains("'missing' cannot be absent", exception.Message); + } + + [Fact] + public void GetNotNullStruct_ThrowsWhenValueIsNull() + { + var dict = new MultipartJsonDictionary( + new Dictionary + { + ["nullable"] = MultipartJsonSerializer.SerializeToElement(null), + } + ); + + var exception = Assert.Throws(() => + dict.GetNotNullStruct("nullable") + ); + Assert.Contains("'nullable' cannot be null", exception.Message); + } + + [Fact] + public void GetNotNullStruct_ThrowsWhenTypeInvalid() + { + var dict = new MultipartJsonDictionary(); + dict.Set("text", "not a number"); + + var exception = Assert.Throws(() => + dict.GetNotNullStruct("text") + ); + Assert.Contains("'text' must be of type", exception.Message); + } + + [Fact] + public void GetNullableClass_ReturnsValueWhenPresent() + { + var dict = new MultipartJsonDictionary(); + dict.Set("name", "Alice"); + + var name = dict.GetNullableClass("name"); + + Assert.Equal("Alice", name); + } + + [Fact] + public void GetNullableClass_ReturnsNullWhenKeyAbsent() + { + var dict = new MultipartJsonDictionary(); + + var missing = dict.GetNullableClass("missing"); + + Assert.Null(missing); + } + + [Fact] + public void GetNullableClass_ReturnsNullWhenValueIsNull() + { + var dict = new MultipartJsonDictionary( + new Dictionary + { + ["nullable"] = MultipartJsonSerializer.SerializeToElement(null), + } + ); + + var nullable = dict.GetNullableClass("nullable"); + + Assert.Null(nullable); + } + + [Fact] + public void GetNullableClass_CachesDeserializedValue() + { + var dict = new MultipartJsonDictionary(); + dict.Set("name", "Alice"); + + var first = dict.GetNullableClass("name"); + var second = dict.GetNullableClass("name"); + + Assert.Same(first, second); + } + + [Fact] + public void GetNullableClass_ThrowsWhenTypeInvalid() + { + var dict = new MultipartJsonDictionary(); + dict.Set("number", 42); + + var exception = Assert.Throws(() => + dict.GetNullableClass("number") + ); + Assert.Contains("'number' must be of type", exception.Message); + } + + [Fact] + public void GetNullableStruct_ReturnsValueWhenPresent() + { + var dict = new MultipartJsonDictionary(); + dict.Set("age", 30); + + var age = dict.GetNullableStruct("age"); + + Assert.Equal(30, age); + } + + [Fact] + public void GetNullableStruct_ReturnsNullWhenKeyAbsent() + { + var dict = new MultipartJsonDictionary(); + + var missing = dict.GetNullableStruct("missing"); + + Assert.Null(missing); + } + + [Fact] + public void GetNullableStruct_ReturnsNullWhenValueIsNull() + { + var dict = new MultipartJsonDictionary( + new Dictionary + { + ["nullable"] = MultipartJsonSerializer.SerializeToElement(null), + } + ); + + var nullable = dict.GetNullableStruct("nullable"); + + Assert.Null(nullable); + } + + [Fact] + public void GetNullableStruct_ThrowsWhenTypeInvalid() + { + var dict = new MultipartJsonDictionary(); + dict.Set("text", "not a number"); + + var exception = Assert.Throws(() => + dict.GetNullableStruct("text") + ); + Assert.Contains("'text' must be of type", exception.Message); + } + + [Fact] + public void ComplexWorkflow_SetFreezeAndGet() + { + var dict = new MultipartJsonDictionary(); + dict.Set("name", "Alice"); + dict.Set("age", 30); + dict.Set("active", true); + + var frozen = dict.Freeze(); + + Assert.Equal("Alice", dict.GetNotNullClass("name")); + Assert.Equal(30, dict.GetNotNullStruct("age")); + Assert.True(dict.GetNotNullStruct("active")); + Assert.Null(dict.GetNullableClass("missing")); + + Assert.Throws(() => dict.Set("new", "value")); + } +} diff --git a/src/ImageKit.Tests/ImageKit.Tests.csproj b/src/ImageKit.Tests/ImageKit.Tests.csproj new file mode 100644 index 00000000..f631a267 --- /dev/null +++ b/src/ImageKit.Tests/ImageKit.Tests.csproj @@ -0,0 +1,23 @@ + + + true + false + Exe + + + net8.0;net472 + + + $(NoWarn),xUnit1004 + + + + + + + + + + + \ No newline at end of file diff --git a/src/ImageKit.Tests/Models/Accounts/Origins/OriginCreateParamsTest.cs b/src/ImageKit.Tests/Models/Accounts/Origins/OriginCreateParamsTest.cs new file mode 100644 index 00000000..cf8f0d31 --- /dev/null +++ b/src/ImageKit.Tests/Models/Accounts/Origins/OriginCreateParamsTest.cs @@ -0,0 +1,82 @@ +using System; +using ImageKit.Models.Accounts.Origins; + +namespace ImageKit.Tests.Models.Accounts.Origins; + +public class OriginCreateParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new OriginCreateParams + { + OriginRequest = new S3() + { + AccessKey = "AKIATEST123", + Bucket = "test-bucket", + Name = "My S3 Origin", + SecretKey = "secrettest123", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + Prefix = "images", + }, + }; + + OriginRequest expectedOriginRequest = new S3() + { + AccessKey = "AKIATEST123", + Bucket = "test-bucket", + Name = "My S3 Origin", + SecretKey = "secrettest123", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + Prefix = "images", + }; + + Assert.Equal(expectedOriginRequest, parameters.OriginRequest); + } + + [Fact] + public void Url_Works() + { + OriginCreateParams parameters = new() + { + OriginRequest = new S3() + { + AccessKey = "AKIATEST123", + Bucket = "test-bucket", + Name = "My S3 Origin", + SecretKey = "secrettest123", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + Prefix = "images", + }, + }; + + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + + Assert.Equal(new Uri("https://api.imagekit.io/v1/accounts/origins"), url); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new OriginCreateParams + { + OriginRequest = new S3() + { + AccessKey = "AKIATEST123", + Bucket = "test-bucket", + Name = "My S3 Origin", + SecretKey = "secrettest123", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + Prefix = "images", + }, + }; + + OriginCreateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Accounts/Origins/OriginDeleteParamsTest.cs b/src/ImageKit.Tests/Models/Accounts/Origins/OriginDeleteParamsTest.cs new file mode 100644 index 00000000..de154ad9 --- /dev/null +++ b/src/ImageKit.Tests/Models/Accounts/Origins/OriginDeleteParamsTest.cs @@ -0,0 +1,37 @@ +using System; +using ImageKit.Models.Accounts.Origins; + +namespace ImageKit.Tests.Models.Accounts.Origins; + +public class OriginDeleteParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new OriginDeleteParams { ID = "id" }; + + string expectedID = "id"; + + Assert.Equal(expectedID, parameters.ID); + } + + [Fact] + public void Url_Works() + { + OriginDeleteParams parameters = new() { ID = "id" }; + + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + + Assert.Equal(new Uri("https://api.imagekit.io/v1/accounts/origins/id"), url); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new OriginDeleteParams { ID = "id" }; + + OriginDeleteParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Accounts/Origins/OriginGetParamsTest.cs b/src/ImageKit.Tests/Models/Accounts/Origins/OriginGetParamsTest.cs new file mode 100644 index 00000000..51509129 --- /dev/null +++ b/src/ImageKit.Tests/Models/Accounts/Origins/OriginGetParamsTest.cs @@ -0,0 +1,37 @@ +using System; +using ImageKit.Models.Accounts.Origins; + +namespace ImageKit.Tests.Models.Accounts.Origins; + +public class OriginGetParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new OriginGetParams { ID = "id" }; + + string expectedID = "id"; + + Assert.Equal(expectedID, parameters.ID); + } + + [Fact] + public void Url_Works() + { + OriginGetParams parameters = new() { ID = "id" }; + + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + + Assert.Equal(new Uri("https://api.imagekit.io/v1/accounts/origins/id"), url); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new OriginGetParams { ID = "id" }; + + OriginGetParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Accounts/Origins/OriginListParamsTest.cs b/src/ImageKit.Tests/Models/Accounts/Origins/OriginListParamsTest.cs new file mode 100644 index 00000000..775ccd44 --- /dev/null +++ b/src/ImageKit.Tests/Models/Accounts/Origins/OriginListParamsTest.cs @@ -0,0 +1 @@ +namespace ImageKit.Tests.Models.Accounts.Origins; diff --git a/src/ImageKit.Tests/Models/Accounts/Origins/OriginRequestTest.cs b/src/ImageKit.Tests/Models/Accounts/Origins/OriginRequestTest.cs new file mode 100644 index 00000000..724dd897 --- /dev/null +++ b/src/ImageKit.Tests/Models/Accounts/Origins/OriginRequestTest.cs @@ -0,0 +1,1923 @@ +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Models.Accounts.Origins; + +namespace ImageKit.Tests.Models.Accounts.Origins; + +public class OriginRequestTest : TestBase +{ + [Fact] + public void S3ValidationWorks() + { + OriginRequest value = new S3() + { + AccessKey = "AKIAIOSFODNN7EXAMPLE", + Bucket = "product-images", + Name = "US S3 Storage", + SecretKey = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + Prefix = "raw-assets", + }; + value.Validate(); + } + + [Fact] + public void S3CompatibleValidationWorks() + { + OriginRequest value = new S3Compatible() + { + AccessKey = "AKIAIOSFODNN7EXAMPLE", + Bucket = "product-images", + Endpoint = "https://s3.eu-central-1.wasabisys.com", + Name = "US S3 Storage", + SecretKey = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + Prefix = "raw-assets", + S3ForcePathStyle = true, + }; + value.Validate(); + } + + [Fact] + public void CloudinaryBackupValidationWorks() + { + OriginRequest value = new CloudinaryBackup() + { + AccessKey = "AKIAIOSFODNN7EXAMPLE", + Bucket = "product-images", + Name = "US S3 Storage", + SecretKey = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + Prefix = "raw-assets", + }; + value.Validate(); + } + + [Fact] + public void WebFolderValidationWorks() + { + OriginRequest value = new WebFolder() + { + BaseUrl = "https://images.example.com/assets", + Name = "US S3 Storage", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + ForwardHostHeaderToOrigin = false, + IncludeCanonicalHeader = false, + }; + value.Validate(); + } + + [Fact] + public void WebProxyValidationWorks() + { + OriginRequest value = new WebProxy() + { + Name = "US S3 Storage", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + }; + value.Validate(); + } + + [Fact] + public void GcsValidationWorks() + { + OriginRequest value = new Gcs() + { + Bucket = "gcs-media", + ClientEmail = "service-account@project.iam.gserviceaccount.com", + Name = "US S3 Storage", + PrivateKey = "-----BEGIN PRIVATE KEY-----\\nMIIEv...", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + Prefix = "products", + }; + value.Validate(); + } + + [Fact] + public void AzureBlobValidationWorks() + { + OriginRequest value = new AzureBlob() + { + AccountName = "account123", + Container = "images", + Name = "US S3 Storage", + SasToken = "?sv=2023-01-03&sr=c&sig=abc123", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + Prefix = "uploads", + }; + value.Validate(); + } + + [Fact] + public void AkeneoPimValidationWorks() + { + OriginRequest value = new AkeneoPim() + { + BaseUrl = "https://akeneo.company.com", + ClientID = "akeneo-client-id", + ClientSecret = "akeneo-client-secret", + Name = "US S3 Storage", + Password = "strongpassword123", + Username = "integration-user", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + }; + value.Validate(); + } + + [Fact] + public void S3SerializationRoundtripWorks() + { + OriginRequest value = new S3() + { + AccessKey = "AKIAIOSFODNN7EXAMPLE", + Bucket = "product-images", + Name = "US S3 Storage", + SecretKey = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + Prefix = "raw-assets", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void S3CompatibleSerializationRoundtripWorks() + { + OriginRequest value = new S3Compatible() + { + AccessKey = "AKIAIOSFODNN7EXAMPLE", + Bucket = "product-images", + Endpoint = "https://s3.eu-central-1.wasabisys.com", + Name = "US S3 Storage", + SecretKey = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + Prefix = "raw-assets", + S3ForcePathStyle = true, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void CloudinaryBackupSerializationRoundtripWorks() + { + OriginRequest value = new CloudinaryBackup() + { + AccessKey = "AKIAIOSFODNN7EXAMPLE", + Bucket = "product-images", + Name = "US S3 Storage", + SecretKey = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + Prefix = "raw-assets", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void WebFolderSerializationRoundtripWorks() + { + OriginRequest value = new WebFolder() + { + BaseUrl = "https://images.example.com/assets", + Name = "US S3 Storage", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + ForwardHostHeaderToOrigin = false, + IncludeCanonicalHeader = false, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void WebProxySerializationRoundtripWorks() + { + OriginRequest value = new WebProxy() + { + Name = "US S3 Storage", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void GcsSerializationRoundtripWorks() + { + OriginRequest value = new Gcs() + { + Bucket = "gcs-media", + ClientEmail = "service-account@project.iam.gserviceaccount.com", + Name = "US S3 Storage", + PrivateKey = "-----BEGIN PRIVATE KEY-----\\nMIIEv...", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + Prefix = "products", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void AzureBlobSerializationRoundtripWorks() + { + OriginRequest value = new AzureBlob() + { + AccountName = "account123", + Container = "images", + Name = "US S3 Storage", + SasToken = "?sv=2023-01-03&sr=c&sig=abc123", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + Prefix = "uploads", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void AkeneoPimSerializationRoundtripWorks() + { + OriginRequest value = new AkeneoPim() + { + BaseUrl = "https://akeneo.company.com", + ClientID = "akeneo-client-id", + ClientSecret = "akeneo-client-secret", + Name = "US S3 Storage", + Password = "strongpassword123", + Username = "integration-user", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class S3Test : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new S3 + { + AccessKey = "AKIAIOSFODNN7EXAMPLE", + Bucket = "product-images", + Name = "US S3 Storage", + SecretKey = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + Prefix = "raw-assets", + }; + + string expectedAccessKey = "AKIAIOSFODNN7EXAMPLE"; + string expectedBucket = "product-images"; + string expectedName = "US S3 Storage"; + string expectedSecretKey = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"; + JsonElement expectedType = JsonSerializer.SerializeToElement("S3"); + string expectedBaseUrlForCanonicalHeader = "https://cdn.example.com"; + bool expectedIncludeCanonicalHeader = false; + string expectedPrefix = "raw-assets"; + + Assert.Equal(expectedAccessKey, model.AccessKey); + Assert.Equal(expectedBucket, model.Bucket); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedSecretKey, model.SecretKey); + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + Assert.Equal(expectedBaseUrlForCanonicalHeader, model.BaseUrlForCanonicalHeader); + Assert.Equal(expectedIncludeCanonicalHeader, model.IncludeCanonicalHeader); + Assert.Equal(expectedPrefix, model.Prefix); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new S3 + { + AccessKey = "AKIAIOSFODNN7EXAMPLE", + Bucket = "product-images", + Name = "US S3 Storage", + SecretKey = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + Prefix = "raw-assets", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new S3 + { + AccessKey = "AKIAIOSFODNN7EXAMPLE", + Bucket = "product-images", + Name = "US S3 Storage", + SecretKey = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + Prefix = "raw-assets", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + Assert.NotNull(deserialized); + + string expectedAccessKey = "AKIAIOSFODNN7EXAMPLE"; + string expectedBucket = "product-images"; + string expectedName = "US S3 Storage"; + string expectedSecretKey = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"; + JsonElement expectedType = JsonSerializer.SerializeToElement("S3"); + string expectedBaseUrlForCanonicalHeader = "https://cdn.example.com"; + bool expectedIncludeCanonicalHeader = false; + string expectedPrefix = "raw-assets"; + + Assert.Equal(expectedAccessKey, deserialized.AccessKey); + Assert.Equal(expectedBucket, deserialized.Bucket); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedSecretKey, deserialized.SecretKey); + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + Assert.Equal(expectedBaseUrlForCanonicalHeader, deserialized.BaseUrlForCanonicalHeader); + Assert.Equal(expectedIncludeCanonicalHeader, deserialized.IncludeCanonicalHeader); + Assert.Equal(expectedPrefix, deserialized.Prefix); + } + + [Fact] + public void Validation_Works() + { + var model = new S3 + { + AccessKey = "AKIAIOSFODNN7EXAMPLE", + Bucket = "product-images", + Name = "US S3 Storage", + SecretKey = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + Prefix = "raw-assets", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new S3 + { + AccessKey = "AKIAIOSFODNN7EXAMPLE", + Bucket = "product-images", + Name = "US S3 Storage", + SecretKey = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", + }; + + Assert.Null(model.BaseUrlForCanonicalHeader); + Assert.False(model.RawData.ContainsKey("baseUrlForCanonicalHeader")); + Assert.Null(model.IncludeCanonicalHeader); + Assert.False(model.RawData.ContainsKey("includeCanonicalHeader")); + Assert.Null(model.Prefix); + Assert.False(model.RawData.ContainsKey("prefix")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new S3 + { + AccessKey = "AKIAIOSFODNN7EXAMPLE", + Bucket = "product-images", + Name = "US S3 Storage", + SecretKey = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new S3 + { + AccessKey = "AKIAIOSFODNN7EXAMPLE", + Bucket = "product-images", + Name = "US S3 Storage", + SecretKey = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", + + // Null should be interpreted as omitted for these properties + BaseUrlForCanonicalHeader = null, + IncludeCanonicalHeader = null, + Prefix = null, + }; + + Assert.Null(model.BaseUrlForCanonicalHeader); + Assert.False(model.RawData.ContainsKey("baseUrlForCanonicalHeader")); + Assert.Null(model.IncludeCanonicalHeader); + Assert.False(model.RawData.ContainsKey("includeCanonicalHeader")); + Assert.Null(model.Prefix); + Assert.False(model.RawData.ContainsKey("prefix")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new S3 + { + AccessKey = "AKIAIOSFODNN7EXAMPLE", + Bucket = "product-images", + Name = "US S3 Storage", + SecretKey = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", + + // Null should be interpreted as omitted for these properties + BaseUrlForCanonicalHeader = null, + IncludeCanonicalHeader = null, + Prefix = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new S3 + { + AccessKey = "AKIAIOSFODNN7EXAMPLE", + Bucket = "product-images", + Name = "US S3 Storage", + SecretKey = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + Prefix = "raw-assets", + }; + + S3 copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class S3CompatibleTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new S3Compatible + { + AccessKey = "AKIAIOSFODNN7EXAMPLE", + Bucket = "product-images", + Endpoint = "https://s3.eu-central-1.wasabisys.com", + Name = "US S3 Storage", + SecretKey = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + Prefix = "raw-assets", + S3ForcePathStyle = true, + }; + + string expectedAccessKey = "AKIAIOSFODNN7EXAMPLE"; + string expectedBucket = "product-images"; + string expectedEndpoint = "https://s3.eu-central-1.wasabisys.com"; + string expectedName = "US S3 Storage"; + string expectedSecretKey = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"; + JsonElement expectedType = JsonSerializer.SerializeToElement("S3_COMPATIBLE"); + string expectedBaseUrlForCanonicalHeader = "https://cdn.example.com"; + bool expectedIncludeCanonicalHeader = false; + string expectedPrefix = "raw-assets"; + bool expectedS3ForcePathStyle = true; + + Assert.Equal(expectedAccessKey, model.AccessKey); + Assert.Equal(expectedBucket, model.Bucket); + Assert.Equal(expectedEndpoint, model.Endpoint); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedSecretKey, model.SecretKey); + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + Assert.Equal(expectedBaseUrlForCanonicalHeader, model.BaseUrlForCanonicalHeader); + Assert.Equal(expectedIncludeCanonicalHeader, model.IncludeCanonicalHeader); + Assert.Equal(expectedPrefix, model.Prefix); + Assert.Equal(expectedS3ForcePathStyle, model.S3ForcePathStyle); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new S3Compatible + { + AccessKey = "AKIAIOSFODNN7EXAMPLE", + Bucket = "product-images", + Endpoint = "https://s3.eu-central-1.wasabisys.com", + Name = "US S3 Storage", + SecretKey = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + Prefix = "raw-assets", + S3ForcePathStyle = true, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new S3Compatible + { + AccessKey = "AKIAIOSFODNN7EXAMPLE", + Bucket = "product-images", + Endpoint = "https://s3.eu-central-1.wasabisys.com", + Name = "US S3 Storage", + SecretKey = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + Prefix = "raw-assets", + S3ForcePathStyle = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAccessKey = "AKIAIOSFODNN7EXAMPLE"; + string expectedBucket = "product-images"; + string expectedEndpoint = "https://s3.eu-central-1.wasabisys.com"; + string expectedName = "US S3 Storage"; + string expectedSecretKey = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"; + JsonElement expectedType = JsonSerializer.SerializeToElement("S3_COMPATIBLE"); + string expectedBaseUrlForCanonicalHeader = "https://cdn.example.com"; + bool expectedIncludeCanonicalHeader = false; + string expectedPrefix = "raw-assets"; + bool expectedS3ForcePathStyle = true; + + Assert.Equal(expectedAccessKey, deserialized.AccessKey); + Assert.Equal(expectedBucket, deserialized.Bucket); + Assert.Equal(expectedEndpoint, deserialized.Endpoint); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedSecretKey, deserialized.SecretKey); + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + Assert.Equal(expectedBaseUrlForCanonicalHeader, deserialized.BaseUrlForCanonicalHeader); + Assert.Equal(expectedIncludeCanonicalHeader, deserialized.IncludeCanonicalHeader); + Assert.Equal(expectedPrefix, deserialized.Prefix); + Assert.Equal(expectedS3ForcePathStyle, deserialized.S3ForcePathStyle); + } + + [Fact] + public void Validation_Works() + { + var model = new S3Compatible + { + AccessKey = "AKIAIOSFODNN7EXAMPLE", + Bucket = "product-images", + Endpoint = "https://s3.eu-central-1.wasabisys.com", + Name = "US S3 Storage", + SecretKey = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + Prefix = "raw-assets", + S3ForcePathStyle = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new S3Compatible + { + AccessKey = "AKIAIOSFODNN7EXAMPLE", + Bucket = "product-images", + Endpoint = "https://s3.eu-central-1.wasabisys.com", + Name = "US S3 Storage", + SecretKey = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", + }; + + Assert.Null(model.BaseUrlForCanonicalHeader); + Assert.False(model.RawData.ContainsKey("baseUrlForCanonicalHeader")); + Assert.Null(model.IncludeCanonicalHeader); + Assert.False(model.RawData.ContainsKey("includeCanonicalHeader")); + Assert.Null(model.Prefix); + Assert.False(model.RawData.ContainsKey("prefix")); + Assert.Null(model.S3ForcePathStyle); + Assert.False(model.RawData.ContainsKey("s3ForcePathStyle")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new S3Compatible + { + AccessKey = "AKIAIOSFODNN7EXAMPLE", + Bucket = "product-images", + Endpoint = "https://s3.eu-central-1.wasabisys.com", + Name = "US S3 Storage", + SecretKey = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new S3Compatible + { + AccessKey = "AKIAIOSFODNN7EXAMPLE", + Bucket = "product-images", + Endpoint = "https://s3.eu-central-1.wasabisys.com", + Name = "US S3 Storage", + SecretKey = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", + + // Null should be interpreted as omitted for these properties + BaseUrlForCanonicalHeader = null, + IncludeCanonicalHeader = null, + Prefix = null, + S3ForcePathStyle = null, + }; + + Assert.Null(model.BaseUrlForCanonicalHeader); + Assert.False(model.RawData.ContainsKey("baseUrlForCanonicalHeader")); + Assert.Null(model.IncludeCanonicalHeader); + Assert.False(model.RawData.ContainsKey("includeCanonicalHeader")); + Assert.Null(model.Prefix); + Assert.False(model.RawData.ContainsKey("prefix")); + Assert.Null(model.S3ForcePathStyle); + Assert.False(model.RawData.ContainsKey("s3ForcePathStyle")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new S3Compatible + { + AccessKey = "AKIAIOSFODNN7EXAMPLE", + Bucket = "product-images", + Endpoint = "https://s3.eu-central-1.wasabisys.com", + Name = "US S3 Storage", + SecretKey = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", + + // Null should be interpreted as omitted for these properties + BaseUrlForCanonicalHeader = null, + IncludeCanonicalHeader = null, + Prefix = null, + S3ForcePathStyle = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new S3Compatible + { + AccessKey = "AKIAIOSFODNN7EXAMPLE", + Bucket = "product-images", + Endpoint = "https://s3.eu-central-1.wasabisys.com", + Name = "US S3 Storage", + SecretKey = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + Prefix = "raw-assets", + S3ForcePathStyle = true, + }; + + S3Compatible copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class CloudinaryBackupTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new CloudinaryBackup + { + AccessKey = "AKIAIOSFODNN7EXAMPLE", + Bucket = "product-images", + Name = "US S3 Storage", + SecretKey = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + Prefix = "raw-assets", + }; + + string expectedAccessKey = "AKIAIOSFODNN7EXAMPLE"; + string expectedBucket = "product-images"; + string expectedName = "US S3 Storage"; + string expectedSecretKey = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"; + JsonElement expectedType = JsonSerializer.SerializeToElement("CLOUDINARY_BACKUP"); + string expectedBaseUrlForCanonicalHeader = "https://cdn.example.com"; + bool expectedIncludeCanonicalHeader = false; + string expectedPrefix = "raw-assets"; + + Assert.Equal(expectedAccessKey, model.AccessKey); + Assert.Equal(expectedBucket, model.Bucket); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedSecretKey, model.SecretKey); + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + Assert.Equal(expectedBaseUrlForCanonicalHeader, model.BaseUrlForCanonicalHeader); + Assert.Equal(expectedIncludeCanonicalHeader, model.IncludeCanonicalHeader); + Assert.Equal(expectedPrefix, model.Prefix); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new CloudinaryBackup + { + AccessKey = "AKIAIOSFODNN7EXAMPLE", + Bucket = "product-images", + Name = "US S3 Storage", + SecretKey = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + Prefix = "raw-assets", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new CloudinaryBackup + { + AccessKey = "AKIAIOSFODNN7EXAMPLE", + Bucket = "product-images", + Name = "US S3 Storage", + SecretKey = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + Prefix = "raw-assets", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAccessKey = "AKIAIOSFODNN7EXAMPLE"; + string expectedBucket = "product-images"; + string expectedName = "US S3 Storage"; + string expectedSecretKey = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"; + JsonElement expectedType = JsonSerializer.SerializeToElement("CLOUDINARY_BACKUP"); + string expectedBaseUrlForCanonicalHeader = "https://cdn.example.com"; + bool expectedIncludeCanonicalHeader = false; + string expectedPrefix = "raw-assets"; + + Assert.Equal(expectedAccessKey, deserialized.AccessKey); + Assert.Equal(expectedBucket, deserialized.Bucket); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedSecretKey, deserialized.SecretKey); + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + Assert.Equal(expectedBaseUrlForCanonicalHeader, deserialized.BaseUrlForCanonicalHeader); + Assert.Equal(expectedIncludeCanonicalHeader, deserialized.IncludeCanonicalHeader); + Assert.Equal(expectedPrefix, deserialized.Prefix); + } + + [Fact] + public void Validation_Works() + { + var model = new CloudinaryBackup + { + AccessKey = "AKIAIOSFODNN7EXAMPLE", + Bucket = "product-images", + Name = "US S3 Storage", + SecretKey = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + Prefix = "raw-assets", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new CloudinaryBackup + { + AccessKey = "AKIAIOSFODNN7EXAMPLE", + Bucket = "product-images", + Name = "US S3 Storage", + SecretKey = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", + }; + + Assert.Null(model.BaseUrlForCanonicalHeader); + Assert.False(model.RawData.ContainsKey("baseUrlForCanonicalHeader")); + Assert.Null(model.IncludeCanonicalHeader); + Assert.False(model.RawData.ContainsKey("includeCanonicalHeader")); + Assert.Null(model.Prefix); + Assert.False(model.RawData.ContainsKey("prefix")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new CloudinaryBackup + { + AccessKey = "AKIAIOSFODNN7EXAMPLE", + Bucket = "product-images", + Name = "US S3 Storage", + SecretKey = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new CloudinaryBackup + { + AccessKey = "AKIAIOSFODNN7EXAMPLE", + Bucket = "product-images", + Name = "US S3 Storage", + SecretKey = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", + + // Null should be interpreted as omitted for these properties + BaseUrlForCanonicalHeader = null, + IncludeCanonicalHeader = null, + Prefix = null, + }; + + Assert.Null(model.BaseUrlForCanonicalHeader); + Assert.False(model.RawData.ContainsKey("baseUrlForCanonicalHeader")); + Assert.Null(model.IncludeCanonicalHeader); + Assert.False(model.RawData.ContainsKey("includeCanonicalHeader")); + Assert.Null(model.Prefix); + Assert.False(model.RawData.ContainsKey("prefix")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new CloudinaryBackup + { + AccessKey = "AKIAIOSFODNN7EXAMPLE", + Bucket = "product-images", + Name = "US S3 Storage", + SecretKey = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", + + // Null should be interpreted as omitted for these properties + BaseUrlForCanonicalHeader = null, + IncludeCanonicalHeader = null, + Prefix = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CloudinaryBackup + { + AccessKey = "AKIAIOSFODNN7EXAMPLE", + Bucket = "product-images", + Name = "US S3 Storage", + SecretKey = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + Prefix = "raw-assets", + }; + + CloudinaryBackup copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class WebFolderTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new WebFolder + { + BaseUrl = "https://images.example.com/assets", + Name = "US S3 Storage", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + ForwardHostHeaderToOrigin = false, + IncludeCanonicalHeader = false, + }; + + string expectedBaseUrl = "https://images.example.com/assets"; + string expectedName = "US S3 Storage"; + JsonElement expectedType = JsonSerializer.SerializeToElement("WEB_FOLDER"); + string expectedBaseUrlForCanonicalHeader = "https://cdn.example.com"; + bool expectedForwardHostHeaderToOrigin = false; + bool expectedIncludeCanonicalHeader = false; + + Assert.Equal(expectedBaseUrl, model.BaseUrl); + Assert.Equal(expectedName, model.Name); + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + Assert.Equal(expectedBaseUrlForCanonicalHeader, model.BaseUrlForCanonicalHeader); + Assert.Equal(expectedForwardHostHeaderToOrigin, model.ForwardHostHeaderToOrigin); + Assert.Equal(expectedIncludeCanonicalHeader, model.IncludeCanonicalHeader); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new WebFolder + { + BaseUrl = "https://images.example.com/assets", + Name = "US S3 Storage", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + ForwardHostHeaderToOrigin = false, + IncludeCanonicalHeader = false, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new WebFolder + { + BaseUrl = "https://images.example.com/assets", + Name = "US S3 Storage", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + ForwardHostHeaderToOrigin = false, + IncludeCanonicalHeader = false, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedBaseUrl = "https://images.example.com/assets"; + string expectedName = "US S3 Storage"; + JsonElement expectedType = JsonSerializer.SerializeToElement("WEB_FOLDER"); + string expectedBaseUrlForCanonicalHeader = "https://cdn.example.com"; + bool expectedForwardHostHeaderToOrigin = false; + bool expectedIncludeCanonicalHeader = false; + + Assert.Equal(expectedBaseUrl, deserialized.BaseUrl); + Assert.Equal(expectedName, deserialized.Name); + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + Assert.Equal(expectedBaseUrlForCanonicalHeader, deserialized.BaseUrlForCanonicalHeader); + Assert.Equal(expectedForwardHostHeaderToOrigin, deserialized.ForwardHostHeaderToOrigin); + Assert.Equal(expectedIncludeCanonicalHeader, deserialized.IncludeCanonicalHeader); + } + + [Fact] + public void Validation_Works() + { + var model = new WebFolder + { + BaseUrl = "https://images.example.com/assets", + Name = "US S3 Storage", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + ForwardHostHeaderToOrigin = false, + IncludeCanonicalHeader = false, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new WebFolder + { + BaseUrl = "https://images.example.com/assets", + Name = "US S3 Storage", + }; + + Assert.Null(model.BaseUrlForCanonicalHeader); + Assert.False(model.RawData.ContainsKey("baseUrlForCanonicalHeader")); + Assert.Null(model.ForwardHostHeaderToOrigin); + Assert.False(model.RawData.ContainsKey("forwardHostHeaderToOrigin")); + Assert.Null(model.IncludeCanonicalHeader); + Assert.False(model.RawData.ContainsKey("includeCanonicalHeader")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new WebFolder + { + BaseUrl = "https://images.example.com/assets", + Name = "US S3 Storage", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new WebFolder + { + BaseUrl = "https://images.example.com/assets", + Name = "US S3 Storage", + + // Null should be interpreted as omitted for these properties + BaseUrlForCanonicalHeader = null, + ForwardHostHeaderToOrigin = null, + IncludeCanonicalHeader = null, + }; + + Assert.Null(model.BaseUrlForCanonicalHeader); + Assert.False(model.RawData.ContainsKey("baseUrlForCanonicalHeader")); + Assert.Null(model.ForwardHostHeaderToOrigin); + Assert.False(model.RawData.ContainsKey("forwardHostHeaderToOrigin")); + Assert.Null(model.IncludeCanonicalHeader); + Assert.False(model.RawData.ContainsKey("includeCanonicalHeader")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new WebFolder + { + BaseUrl = "https://images.example.com/assets", + Name = "US S3 Storage", + + // Null should be interpreted as omitted for these properties + BaseUrlForCanonicalHeader = null, + ForwardHostHeaderToOrigin = null, + IncludeCanonicalHeader = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new WebFolder + { + BaseUrl = "https://images.example.com/assets", + Name = "US S3 Storage", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + ForwardHostHeaderToOrigin = false, + IncludeCanonicalHeader = false, + }; + + WebFolder copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class WebProxyTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new WebProxy + { + Name = "US S3 Storage", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + }; + + string expectedName = "US S3 Storage"; + JsonElement expectedType = JsonSerializer.SerializeToElement("WEB_PROXY"); + string expectedBaseUrlForCanonicalHeader = "https://cdn.example.com"; + bool expectedIncludeCanonicalHeader = false; + + Assert.Equal(expectedName, model.Name); + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + Assert.Equal(expectedBaseUrlForCanonicalHeader, model.BaseUrlForCanonicalHeader); + Assert.Equal(expectedIncludeCanonicalHeader, model.IncludeCanonicalHeader); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new WebProxy + { + Name = "US S3 Storage", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new WebProxy + { + Name = "US S3 Storage", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedName = "US S3 Storage"; + JsonElement expectedType = JsonSerializer.SerializeToElement("WEB_PROXY"); + string expectedBaseUrlForCanonicalHeader = "https://cdn.example.com"; + bool expectedIncludeCanonicalHeader = false; + + Assert.Equal(expectedName, deserialized.Name); + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + Assert.Equal(expectedBaseUrlForCanonicalHeader, deserialized.BaseUrlForCanonicalHeader); + Assert.Equal(expectedIncludeCanonicalHeader, deserialized.IncludeCanonicalHeader); + } + + [Fact] + public void Validation_Works() + { + var model = new WebProxy + { + Name = "US S3 Storage", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new WebProxy { Name = "US S3 Storage" }; + + Assert.Null(model.BaseUrlForCanonicalHeader); + Assert.False(model.RawData.ContainsKey("baseUrlForCanonicalHeader")); + Assert.Null(model.IncludeCanonicalHeader); + Assert.False(model.RawData.ContainsKey("includeCanonicalHeader")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new WebProxy { Name = "US S3 Storage" }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new WebProxy + { + Name = "US S3 Storage", + + // Null should be interpreted as omitted for these properties + BaseUrlForCanonicalHeader = null, + IncludeCanonicalHeader = null, + }; + + Assert.Null(model.BaseUrlForCanonicalHeader); + Assert.False(model.RawData.ContainsKey("baseUrlForCanonicalHeader")); + Assert.Null(model.IncludeCanonicalHeader); + Assert.False(model.RawData.ContainsKey("includeCanonicalHeader")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new WebProxy + { + Name = "US S3 Storage", + + // Null should be interpreted as omitted for these properties + BaseUrlForCanonicalHeader = null, + IncludeCanonicalHeader = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new WebProxy + { + Name = "US S3 Storage", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + }; + + WebProxy copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GcsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Gcs + { + Bucket = "gcs-media", + ClientEmail = "service-account@project.iam.gserviceaccount.com", + Name = "US S3 Storage", + PrivateKey = "-----BEGIN PRIVATE KEY-----\\nMIIEv...", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + Prefix = "products", + }; + + string expectedBucket = "gcs-media"; + string expectedClientEmail = "service-account@project.iam.gserviceaccount.com"; + string expectedName = "US S3 Storage"; + string expectedPrivateKey = "-----BEGIN PRIVATE KEY-----\\nMIIEv..."; + JsonElement expectedType = JsonSerializer.SerializeToElement("GCS"); + string expectedBaseUrlForCanonicalHeader = "https://cdn.example.com"; + bool expectedIncludeCanonicalHeader = false; + string expectedPrefix = "products"; + + Assert.Equal(expectedBucket, model.Bucket); + Assert.Equal(expectedClientEmail, model.ClientEmail); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedPrivateKey, model.PrivateKey); + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + Assert.Equal(expectedBaseUrlForCanonicalHeader, model.BaseUrlForCanonicalHeader); + Assert.Equal(expectedIncludeCanonicalHeader, model.IncludeCanonicalHeader); + Assert.Equal(expectedPrefix, model.Prefix); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Gcs + { + Bucket = "gcs-media", + ClientEmail = "service-account@project.iam.gserviceaccount.com", + Name = "US S3 Storage", + PrivateKey = "-----BEGIN PRIVATE KEY-----\\nMIIEv...", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + Prefix = "products", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Gcs + { + Bucket = "gcs-media", + ClientEmail = "service-account@project.iam.gserviceaccount.com", + Name = "US S3 Storage", + PrivateKey = "-----BEGIN PRIVATE KEY-----\\nMIIEv...", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + Prefix = "products", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + Assert.NotNull(deserialized); + + string expectedBucket = "gcs-media"; + string expectedClientEmail = "service-account@project.iam.gserviceaccount.com"; + string expectedName = "US S3 Storage"; + string expectedPrivateKey = "-----BEGIN PRIVATE KEY-----\\nMIIEv..."; + JsonElement expectedType = JsonSerializer.SerializeToElement("GCS"); + string expectedBaseUrlForCanonicalHeader = "https://cdn.example.com"; + bool expectedIncludeCanonicalHeader = false; + string expectedPrefix = "products"; + + Assert.Equal(expectedBucket, deserialized.Bucket); + Assert.Equal(expectedClientEmail, deserialized.ClientEmail); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedPrivateKey, deserialized.PrivateKey); + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + Assert.Equal(expectedBaseUrlForCanonicalHeader, deserialized.BaseUrlForCanonicalHeader); + Assert.Equal(expectedIncludeCanonicalHeader, deserialized.IncludeCanonicalHeader); + Assert.Equal(expectedPrefix, deserialized.Prefix); + } + + [Fact] + public void Validation_Works() + { + var model = new Gcs + { + Bucket = "gcs-media", + ClientEmail = "service-account@project.iam.gserviceaccount.com", + Name = "US S3 Storage", + PrivateKey = "-----BEGIN PRIVATE KEY-----\\nMIIEv...", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + Prefix = "products", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Gcs + { + Bucket = "gcs-media", + ClientEmail = "service-account@project.iam.gserviceaccount.com", + Name = "US S3 Storage", + PrivateKey = "-----BEGIN PRIVATE KEY-----\\nMIIEv...", + }; + + Assert.Null(model.BaseUrlForCanonicalHeader); + Assert.False(model.RawData.ContainsKey("baseUrlForCanonicalHeader")); + Assert.Null(model.IncludeCanonicalHeader); + Assert.False(model.RawData.ContainsKey("includeCanonicalHeader")); + Assert.Null(model.Prefix); + Assert.False(model.RawData.ContainsKey("prefix")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new Gcs + { + Bucket = "gcs-media", + ClientEmail = "service-account@project.iam.gserviceaccount.com", + Name = "US S3 Storage", + PrivateKey = "-----BEGIN PRIVATE KEY-----\\nMIIEv...", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new Gcs + { + Bucket = "gcs-media", + ClientEmail = "service-account@project.iam.gserviceaccount.com", + Name = "US S3 Storage", + PrivateKey = "-----BEGIN PRIVATE KEY-----\\nMIIEv...", + + // Null should be interpreted as omitted for these properties + BaseUrlForCanonicalHeader = null, + IncludeCanonicalHeader = null, + Prefix = null, + }; + + Assert.Null(model.BaseUrlForCanonicalHeader); + Assert.False(model.RawData.ContainsKey("baseUrlForCanonicalHeader")); + Assert.Null(model.IncludeCanonicalHeader); + Assert.False(model.RawData.ContainsKey("includeCanonicalHeader")); + Assert.Null(model.Prefix); + Assert.False(model.RawData.ContainsKey("prefix")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new Gcs + { + Bucket = "gcs-media", + ClientEmail = "service-account@project.iam.gserviceaccount.com", + Name = "US S3 Storage", + PrivateKey = "-----BEGIN PRIVATE KEY-----\\nMIIEv...", + + // Null should be interpreted as omitted for these properties + BaseUrlForCanonicalHeader = null, + IncludeCanonicalHeader = null, + Prefix = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Gcs + { + Bucket = "gcs-media", + ClientEmail = "service-account@project.iam.gserviceaccount.com", + Name = "US S3 Storage", + PrivateKey = "-----BEGIN PRIVATE KEY-----\\nMIIEv...", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + Prefix = "products", + }; + + Gcs copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class AzureBlobTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new AzureBlob + { + AccountName = "account123", + Container = "images", + Name = "US S3 Storage", + SasToken = "?sv=2023-01-03&sr=c&sig=abc123", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + Prefix = "uploads", + }; + + string expectedAccountName = "account123"; + string expectedContainer = "images"; + string expectedName = "US S3 Storage"; + string expectedSasToken = "?sv=2023-01-03&sr=c&sig=abc123"; + JsonElement expectedType = JsonSerializer.SerializeToElement("AZURE_BLOB"); + string expectedBaseUrlForCanonicalHeader = "https://cdn.example.com"; + bool expectedIncludeCanonicalHeader = false; + string expectedPrefix = "uploads"; + + Assert.Equal(expectedAccountName, model.AccountName); + Assert.Equal(expectedContainer, model.Container); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedSasToken, model.SasToken); + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + Assert.Equal(expectedBaseUrlForCanonicalHeader, model.BaseUrlForCanonicalHeader); + Assert.Equal(expectedIncludeCanonicalHeader, model.IncludeCanonicalHeader); + Assert.Equal(expectedPrefix, model.Prefix); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new AzureBlob + { + AccountName = "account123", + Container = "images", + Name = "US S3 Storage", + SasToken = "?sv=2023-01-03&sr=c&sig=abc123", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + Prefix = "uploads", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new AzureBlob + { + AccountName = "account123", + Container = "images", + Name = "US S3 Storage", + SasToken = "?sv=2023-01-03&sr=c&sig=abc123", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + Prefix = "uploads", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAccountName = "account123"; + string expectedContainer = "images"; + string expectedName = "US S3 Storage"; + string expectedSasToken = "?sv=2023-01-03&sr=c&sig=abc123"; + JsonElement expectedType = JsonSerializer.SerializeToElement("AZURE_BLOB"); + string expectedBaseUrlForCanonicalHeader = "https://cdn.example.com"; + bool expectedIncludeCanonicalHeader = false; + string expectedPrefix = "uploads"; + + Assert.Equal(expectedAccountName, deserialized.AccountName); + Assert.Equal(expectedContainer, deserialized.Container); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedSasToken, deserialized.SasToken); + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + Assert.Equal(expectedBaseUrlForCanonicalHeader, deserialized.BaseUrlForCanonicalHeader); + Assert.Equal(expectedIncludeCanonicalHeader, deserialized.IncludeCanonicalHeader); + Assert.Equal(expectedPrefix, deserialized.Prefix); + } + + [Fact] + public void Validation_Works() + { + var model = new AzureBlob + { + AccountName = "account123", + Container = "images", + Name = "US S3 Storage", + SasToken = "?sv=2023-01-03&sr=c&sig=abc123", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + Prefix = "uploads", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new AzureBlob + { + AccountName = "account123", + Container = "images", + Name = "US S3 Storage", + SasToken = "?sv=2023-01-03&sr=c&sig=abc123", + }; + + Assert.Null(model.BaseUrlForCanonicalHeader); + Assert.False(model.RawData.ContainsKey("baseUrlForCanonicalHeader")); + Assert.Null(model.IncludeCanonicalHeader); + Assert.False(model.RawData.ContainsKey("includeCanonicalHeader")); + Assert.Null(model.Prefix); + Assert.False(model.RawData.ContainsKey("prefix")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new AzureBlob + { + AccountName = "account123", + Container = "images", + Name = "US S3 Storage", + SasToken = "?sv=2023-01-03&sr=c&sig=abc123", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new AzureBlob + { + AccountName = "account123", + Container = "images", + Name = "US S3 Storage", + SasToken = "?sv=2023-01-03&sr=c&sig=abc123", + + // Null should be interpreted as omitted for these properties + BaseUrlForCanonicalHeader = null, + IncludeCanonicalHeader = null, + Prefix = null, + }; + + Assert.Null(model.BaseUrlForCanonicalHeader); + Assert.False(model.RawData.ContainsKey("baseUrlForCanonicalHeader")); + Assert.Null(model.IncludeCanonicalHeader); + Assert.False(model.RawData.ContainsKey("includeCanonicalHeader")); + Assert.Null(model.Prefix); + Assert.False(model.RawData.ContainsKey("prefix")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new AzureBlob + { + AccountName = "account123", + Container = "images", + Name = "US S3 Storage", + SasToken = "?sv=2023-01-03&sr=c&sig=abc123", + + // Null should be interpreted as omitted for these properties + BaseUrlForCanonicalHeader = null, + IncludeCanonicalHeader = null, + Prefix = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new AzureBlob + { + AccountName = "account123", + Container = "images", + Name = "US S3 Storage", + SasToken = "?sv=2023-01-03&sr=c&sig=abc123", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + Prefix = "uploads", + }; + + AzureBlob copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class AkeneoPimTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new AkeneoPim + { + BaseUrl = "https://akeneo.company.com", + ClientID = "akeneo-client-id", + ClientSecret = "akeneo-client-secret", + Name = "US S3 Storage", + Password = "strongpassword123", + Username = "integration-user", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + }; + + string expectedBaseUrl = "https://akeneo.company.com"; + string expectedClientID = "akeneo-client-id"; + string expectedClientSecret = "akeneo-client-secret"; + string expectedName = "US S3 Storage"; + string expectedPassword = "strongpassword123"; + JsonElement expectedType = JsonSerializer.SerializeToElement("AKENEO_PIM"); + string expectedUsername = "integration-user"; + string expectedBaseUrlForCanonicalHeader = "https://cdn.example.com"; + bool expectedIncludeCanonicalHeader = false; + + Assert.Equal(expectedBaseUrl, model.BaseUrl); + Assert.Equal(expectedClientID, model.ClientID); + Assert.Equal(expectedClientSecret, model.ClientSecret); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedPassword, model.Password); + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + Assert.Equal(expectedUsername, model.Username); + Assert.Equal(expectedBaseUrlForCanonicalHeader, model.BaseUrlForCanonicalHeader); + Assert.Equal(expectedIncludeCanonicalHeader, model.IncludeCanonicalHeader); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new AkeneoPim + { + BaseUrl = "https://akeneo.company.com", + ClientID = "akeneo-client-id", + ClientSecret = "akeneo-client-secret", + Name = "US S3 Storage", + Password = "strongpassword123", + Username = "integration-user", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new AkeneoPim + { + BaseUrl = "https://akeneo.company.com", + ClientID = "akeneo-client-id", + ClientSecret = "akeneo-client-secret", + Name = "US S3 Storage", + Password = "strongpassword123", + Username = "integration-user", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedBaseUrl = "https://akeneo.company.com"; + string expectedClientID = "akeneo-client-id"; + string expectedClientSecret = "akeneo-client-secret"; + string expectedName = "US S3 Storage"; + string expectedPassword = "strongpassword123"; + JsonElement expectedType = JsonSerializer.SerializeToElement("AKENEO_PIM"); + string expectedUsername = "integration-user"; + string expectedBaseUrlForCanonicalHeader = "https://cdn.example.com"; + bool expectedIncludeCanonicalHeader = false; + + Assert.Equal(expectedBaseUrl, deserialized.BaseUrl); + Assert.Equal(expectedClientID, deserialized.ClientID); + Assert.Equal(expectedClientSecret, deserialized.ClientSecret); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedPassword, deserialized.Password); + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + Assert.Equal(expectedUsername, deserialized.Username); + Assert.Equal(expectedBaseUrlForCanonicalHeader, deserialized.BaseUrlForCanonicalHeader); + Assert.Equal(expectedIncludeCanonicalHeader, deserialized.IncludeCanonicalHeader); + } + + [Fact] + public void Validation_Works() + { + var model = new AkeneoPim + { + BaseUrl = "https://akeneo.company.com", + ClientID = "akeneo-client-id", + ClientSecret = "akeneo-client-secret", + Name = "US S3 Storage", + Password = "strongpassword123", + Username = "integration-user", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new AkeneoPim + { + BaseUrl = "https://akeneo.company.com", + ClientID = "akeneo-client-id", + ClientSecret = "akeneo-client-secret", + Name = "US S3 Storage", + Password = "strongpassword123", + Username = "integration-user", + }; + + Assert.Null(model.BaseUrlForCanonicalHeader); + Assert.False(model.RawData.ContainsKey("baseUrlForCanonicalHeader")); + Assert.Null(model.IncludeCanonicalHeader); + Assert.False(model.RawData.ContainsKey("includeCanonicalHeader")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new AkeneoPim + { + BaseUrl = "https://akeneo.company.com", + ClientID = "akeneo-client-id", + ClientSecret = "akeneo-client-secret", + Name = "US S3 Storage", + Password = "strongpassword123", + Username = "integration-user", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new AkeneoPim + { + BaseUrl = "https://akeneo.company.com", + ClientID = "akeneo-client-id", + ClientSecret = "akeneo-client-secret", + Name = "US S3 Storage", + Password = "strongpassword123", + Username = "integration-user", + + // Null should be interpreted as omitted for these properties + BaseUrlForCanonicalHeader = null, + IncludeCanonicalHeader = null, + }; + + Assert.Null(model.BaseUrlForCanonicalHeader); + Assert.False(model.RawData.ContainsKey("baseUrlForCanonicalHeader")); + Assert.Null(model.IncludeCanonicalHeader); + Assert.False(model.RawData.ContainsKey("includeCanonicalHeader")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new AkeneoPim + { + BaseUrl = "https://akeneo.company.com", + ClientID = "akeneo-client-id", + ClientSecret = "akeneo-client-secret", + Name = "US S3 Storage", + Password = "strongpassword123", + Username = "integration-user", + + // Null should be interpreted as omitted for these properties + BaseUrlForCanonicalHeader = null, + IncludeCanonicalHeader = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new AkeneoPim + { + BaseUrl = "https://akeneo.company.com", + ClientID = "akeneo-client-id", + ClientSecret = "akeneo-client-secret", + Name = "US S3 Storage", + Password = "strongpassword123", + Username = "integration-user", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + }; + + AkeneoPim copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Accounts/Origins/OriginResponseTest.cs b/src/ImageKit.Tests/Models/Accounts/Origins/OriginResponseTest.cs new file mode 100644 index 00000000..4d321a75 --- /dev/null +++ b/src/ImageKit.Tests/Models/Accounts/Origins/OriginResponseTest.cs @@ -0,0 +1,1863 @@ +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Models.Accounts.Origins; + +namespace ImageKit.Tests.Models.Accounts.Origins; + +public class OriginResponseTest : TestBase +{ + [Fact] + public void S3ValidationWorks() + { + OriginResponse value = new OriginResponseS3() + { + ID = "id", + Bucket = "product-images", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "raw-assets", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + value.Validate(); + } + + [Fact] + public void S3CompatibleValidationWorks() + { + OriginResponse value = new OriginResponseS3Compatible() + { + ID = "id", + Bucket = "product-images", + Endpoint = "https://s3.eu-central-1.wasabisys.com", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "raw-assets", + S3ForcePathStyle = true, + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + value.Validate(); + } + + [Fact] + public void CloudinaryBackupValidationWorks() + { + OriginResponse value = new OriginResponseCloudinaryBackup() + { + ID = "id", + Bucket = "product-images", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "raw-assets", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + value.Validate(); + } + + [Fact] + public void WebFolderValidationWorks() + { + OriginResponse value = new OriginResponseWebFolder() + { + ID = "id", + BaseUrl = "https://images.example.com/assets", + ForwardHostHeaderToOrigin = false, + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + value.Validate(); + } + + [Fact] + public void WebProxyValidationWorks() + { + OriginResponse value = new OriginResponseWebProxy() + { + ID = "id", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + value.Validate(); + } + + [Fact] + public void GcsValidationWorks() + { + OriginResponse value = new OriginResponseGcs() + { + ID = "id", + Bucket = "gcs-media", + ClientEmail = "service-account@project.iam.gserviceaccount.com", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "products", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + value.Validate(); + } + + [Fact] + public void AzureBlobValidationWorks() + { + OriginResponse value = new OriginResponseAzureBlob() + { + ID = "id", + AccountName = "account123", + Container = "images", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "uploads", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + value.Validate(); + } + + [Fact] + public void AkeneoPimValidationWorks() + { + OriginResponse value = new OriginResponseAkeneoPim() + { + ID = "id", + BaseUrl = "https://akeneo.company.com", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + value.Validate(); + } + + [Fact] + public void S3SerializationRoundtripWorks() + { + OriginResponse value = new OriginResponseS3() + { + ID = "id", + Bucket = "product-images", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "raw-assets", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void S3CompatibleSerializationRoundtripWorks() + { + OriginResponse value = new OriginResponseS3Compatible() + { + ID = "id", + Bucket = "product-images", + Endpoint = "https://s3.eu-central-1.wasabisys.com", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "raw-assets", + S3ForcePathStyle = true, + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void CloudinaryBackupSerializationRoundtripWorks() + { + OriginResponse value = new OriginResponseCloudinaryBackup() + { + ID = "id", + Bucket = "product-images", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "raw-assets", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void WebFolderSerializationRoundtripWorks() + { + OriginResponse value = new OriginResponseWebFolder() + { + ID = "id", + BaseUrl = "https://images.example.com/assets", + ForwardHostHeaderToOrigin = false, + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void WebProxySerializationRoundtripWorks() + { + OriginResponse value = new OriginResponseWebProxy() + { + ID = "id", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void GcsSerializationRoundtripWorks() + { + OriginResponse value = new OriginResponseGcs() + { + ID = "id", + Bucket = "gcs-media", + ClientEmail = "service-account@project.iam.gserviceaccount.com", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "products", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void AzureBlobSerializationRoundtripWorks() + { + OriginResponse value = new OriginResponseAzureBlob() + { + ID = "id", + AccountName = "account123", + Container = "images", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "uploads", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void AkeneoPimSerializationRoundtripWorks() + { + OriginResponse value = new OriginResponseAkeneoPim() + { + ID = "id", + BaseUrl = "https://akeneo.company.com", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class OriginResponseS3Test : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new OriginResponseS3 + { + ID = "id", + Bucket = "product-images", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "raw-assets", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + + string expectedID = "id"; + string expectedBucket = "product-images"; + bool expectedIncludeCanonicalHeader = false; + string expectedName = "US S3 Storage"; + string expectedPrefix = "raw-assets"; + JsonElement expectedType = JsonSerializer.SerializeToElement("S3"); + string expectedBaseUrlForCanonicalHeader = "https://cdn.example.com"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedBucket, model.Bucket); + Assert.Equal(expectedIncludeCanonicalHeader, model.IncludeCanonicalHeader); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedPrefix, model.Prefix); + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + Assert.Equal(expectedBaseUrlForCanonicalHeader, model.BaseUrlForCanonicalHeader); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new OriginResponseS3 + { + ID = "id", + Bucket = "product-images", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "raw-assets", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new OriginResponseS3 + { + ID = "id", + Bucket = "product-images", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "raw-assets", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedBucket = "product-images"; + bool expectedIncludeCanonicalHeader = false; + string expectedName = "US S3 Storage"; + string expectedPrefix = "raw-assets"; + JsonElement expectedType = JsonSerializer.SerializeToElement("S3"); + string expectedBaseUrlForCanonicalHeader = "https://cdn.example.com"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedBucket, deserialized.Bucket); + Assert.Equal(expectedIncludeCanonicalHeader, deserialized.IncludeCanonicalHeader); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedPrefix, deserialized.Prefix); + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + Assert.Equal(expectedBaseUrlForCanonicalHeader, deserialized.BaseUrlForCanonicalHeader); + } + + [Fact] + public void Validation_Works() + { + var model = new OriginResponseS3 + { + ID = "id", + Bucket = "product-images", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "raw-assets", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new OriginResponseS3 + { + ID = "id", + Bucket = "product-images", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "raw-assets", + }; + + Assert.Null(model.BaseUrlForCanonicalHeader); + Assert.False(model.RawData.ContainsKey("baseUrlForCanonicalHeader")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new OriginResponseS3 + { + ID = "id", + Bucket = "product-images", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "raw-assets", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new OriginResponseS3 + { + ID = "id", + Bucket = "product-images", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "raw-assets", + + // Null should be interpreted as omitted for these properties + BaseUrlForCanonicalHeader = null, + }; + + Assert.Null(model.BaseUrlForCanonicalHeader); + Assert.False(model.RawData.ContainsKey("baseUrlForCanonicalHeader")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new OriginResponseS3 + { + ID = "id", + Bucket = "product-images", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "raw-assets", + + // Null should be interpreted as omitted for these properties + BaseUrlForCanonicalHeader = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new OriginResponseS3 + { + ID = "id", + Bucket = "product-images", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "raw-assets", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + + OriginResponseS3 copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class OriginResponseS3CompatibleTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new OriginResponseS3Compatible + { + ID = "id", + Bucket = "product-images", + Endpoint = "https://s3.eu-central-1.wasabisys.com", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "raw-assets", + S3ForcePathStyle = true, + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + + string expectedID = "id"; + string expectedBucket = "product-images"; + string expectedEndpoint = "https://s3.eu-central-1.wasabisys.com"; + bool expectedIncludeCanonicalHeader = false; + string expectedName = "US S3 Storage"; + string expectedPrefix = "raw-assets"; + bool expectedS3ForcePathStyle = true; + JsonElement expectedType = JsonSerializer.SerializeToElement("S3_COMPATIBLE"); + string expectedBaseUrlForCanonicalHeader = "https://cdn.example.com"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedBucket, model.Bucket); + Assert.Equal(expectedEndpoint, model.Endpoint); + Assert.Equal(expectedIncludeCanonicalHeader, model.IncludeCanonicalHeader); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedPrefix, model.Prefix); + Assert.Equal(expectedS3ForcePathStyle, model.S3ForcePathStyle); + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + Assert.Equal(expectedBaseUrlForCanonicalHeader, model.BaseUrlForCanonicalHeader); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new OriginResponseS3Compatible + { + ID = "id", + Bucket = "product-images", + Endpoint = "https://s3.eu-central-1.wasabisys.com", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "raw-assets", + S3ForcePathStyle = true, + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new OriginResponseS3Compatible + { + ID = "id", + Bucket = "product-images", + Endpoint = "https://s3.eu-central-1.wasabisys.com", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "raw-assets", + S3ForcePathStyle = true, + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedBucket = "product-images"; + string expectedEndpoint = "https://s3.eu-central-1.wasabisys.com"; + bool expectedIncludeCanonicalHeader = false; + string expectedName = "US S3 Storage"; + string expectedPrefix = "raw-assets"; + bool expectedS3ForcePathStyle = true; + JsonElement expectedType = JsonSerializer.SerializeToElement("S3_COMPATIBLE"); + string expectedBaseUrlForCanonicalHeader = "https://cdn.example.com"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedBucket, deserialized.Bucket); + Assert.Equal(expectedEndpoint, deserialized.Endpoint); + Assert.Equal(expectedIncludeCanonicalHeader, deserialized.IncludeCanonicalHeader); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedPrefix, deserialized.Prefix); + Assert.Equal(expectedS3ForcePathStyle, deserialized.S3ForcePathStyle); + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + Assert.Equal(expectedBaseUrlForCanonicalHeader, deserialized.BaseUrlForCanonicalHeader); + } + + [Fact] + public void Validation_Works() + { + var model = new OriginResponseS3Compatible + { + ID = "id", + Bucket = "product-images", + Endpoint = "https://s3.eu-central-1.wasabisys.com", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "raw-assets", + S3ForcePathStyle = true, + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new OriginResponseS3Compatible + { + ID = "id", + Bucket = "product-images", + Endpoint = "https://s3.eu-central-1.wasabisys.com", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "raw-assets", + S3ForcePathStyle = true, + }; + + Assert.Null(model.BaseUrlForCanonicalHeader); + Assert.False(model.RawData.ContainsKey("baseUrlForCanonicalHeader")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new OriginResponseS3Compatible + { + ID = "id", + Bucket = "product-images", + Endpoint = "https://s3.eu-central-1.wasabisys.com", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "raw-assets", + S3ForcePathStyle = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new OriginResponseS3Compatible + { + ID = "id", + Bucket = "product-images", + Endpoint = "https://s3.eu-central-1.wasabisys.com", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "raw-assets", + S3ForcePathStyle = true, + + // Null should be interpreted as omitted for these properties + BaseUrlForCanonicalHeader = null, + }; + + Assert.Null(model.BaseUrlForCanonicalHeader); + Assert.False(model.RawData.ContainsKey("baseUrlForCanonicalHeader")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new OriginResponseS3Compatible + { + ID = "id", + Bucket = "product-images", + Endpoint = "https://s3.eu-central-1.wasabisys.com", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "raw-assets", + S3ForcePathStyle = true, + + // Null should be interpreted as omitted for these properties + BaseUrlForCanonicalHeader = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new OriginResponseS3Compatible + { + ID = "id", + Bucket = "product-images", + Endpoint = "https://s3.eu-central-1.wasabisys.com", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "raw-assets", + S3ForcePathStyle = true, + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + + OriginResponseS3Compatible copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class OriginResponseCloudinaryBackupTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new OriginResponseCloudinaryBackup + { + ID = "id", + Bucket = "product-images", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "raw-assets", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + + string expectedID = "id"; + string expectedBucket = "product-images"; + bool expectedIncludeCanonicalHeader = false; + string expectedName = "US S3 Storage"; + string expectedPrefix = "raw-assets"; + JsonElement expectedType = JsonSerializer.SerializeToElement("CLOUDINARY_BACKUP"); + string expectedBaseUrlForCanonicalHeader = "https://cdn.example.com"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedBucket, model.Bucket); + Assert.Equal(expectedIncludeCanonicalHeader, model.IncludeCanonicalHeader); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedPrefix, model.Prefix); + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + Assert.Equal(expectedBaseUrlForCanonicalHeader, model.BaseUrlForCanonicalHeader); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new OriginResponseCloudinaryBackup + { + ID = "id", + Bucket = "product-images", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "raw-assets", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new OriginResponseCloudinaryBackup + { + ID = "id", + Bucket = "product-images", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "raw-assets", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedBucket = "product-images"; + bool expectedIncludeCanonicalHeader = false; + string expectedName = "US S3 Storage"; + string expectedPrefix = "raw-assets"; + JsonElement expectedType = JsonSerializer.SerializeToElement("CLOUDINARY_BACKUP"); + string expectedBaseUrlForCanonicalHeader = "https://cdn.example.com"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedBucket, deserialized.Bucket); + Assert.Equal(expectedIncludeCanonicalHeader, deserialized.IncludeCanonicalHeader); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedPrefix, deserialized.Prefix); + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + Assert.Equal(expectedBaseUrlForCanonicalHeader, deserialized.BaseUrlForCanonicalHeader); + } + + [Fact] + public void Validation_Works() + { + var model = new OriginResponseCloudinaryBackup + { + ID = "id", + Bucket = "product-images", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "raw-assets", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new OriginResponseCloudinaryBackup + { + ID = "id", + Bucket = "product-images", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "raw-assets", + }; + + Assert.Null(model.BaseUrlForCanonicalHeader); + Assert.False(model.RawData.ContainsKey("baseUrlForCanonicalHeader")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new OriginResponseCloudinaryBackup + { + ID = "id", + Bucket = "product-images", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "raw-assets", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new OriginResponseCloudinaryBackup + { + ID = "id", + Bucket = "product-images", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "raw-assets", + + // Null should be interpreted as omitted for these properties + BaseUrlForCanonicalHeader = null, + }; + + Assert.Null(model.BaseUrlForCanonicalHeader); + Assert.False(model.RawData.ContainsKey("baseUrlForCanonicalHeader")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new OriginResponseCloudinaryBackup + { + ID = "id", + Bucket = "product-images", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "raw-assets", + + // Null should be interpreted as omitted for these properties + BaseUrlForCanonicalHeader = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new OriginResponseCloudinaryBackup + { + ID = "id", + Bucket = "product-images", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "raw-assets", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + + OriginResponseCloudinaryBackup copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class OriginResponseWebFolderTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new OriginResponseWebFolder + { + ID = "id", + BaseUrl = "https://images.example.com/assets", + ForwardHostHeaderToOrigin = false, + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + + string expectedID = "id"; + string expectedBaseUrl = "https://images.example.com/assets"; + bool expectedForwardHostHeaderToOrigin = false; + bool expectedIncludeCanonicalHeader = false; + string expectedName = "US S3 Storage"; + JsonElement expectedType = JsonSerializer.SerializeToElement("WEB_FOLDER"); + string expectedBaseUrlForCanonicalHeader = "https://cdn.example.com"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedBaseUrl, model.BaseUrl); + Assert.Equal(expectedForwardHostHeaderToOrigin, model.ForwardHostHeaderToOrigin); + Assert.Equal(expectedIncludeCanonicalHeader, model.IncludeCanonicalHeader); + Assert.Equal(expectedName, model.Name); + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + Assert.Equal(expectedBaseUrlForCanonicalHeader, model.BaseUrlForCanonicalHeader); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new OriginResponseWebFolder + { + ID = "id", + BaseUrl = "https://images.example.com/assets", + ForwardHostHeaderToOrigin = false, + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new OriginResponseWebFolder + { + ID = "id", + BaseUrl = "https://images.example.com/assets", + ForwardHostHeaderToOrigin = false, + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedBaseUrl = "https://images.example.com/assets"; + bool expectedForwardHostHeaderToOrigin = false; + bool expectedIncludeCanonicalHeader = false; + string expectedName = "US S3 Storage"; + JsonElement expectedType = JsonSerializer.SerializeToElement("WEB_FOLDER"); + string expectedBaseUrlForCanonicalHeader = "https://cdn.example.com"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedBaseUrl, deserialized.BaseUrl); + Assert.Equal(expectedForwardHostHeaderToOrigin, deserialized.ForwardHostHeaderToOrigin); + Assert.Equal(expectedIncludeCanonicalHeader, deserialized.IncludeCanonicalHeader); + Assert.Equal(expectedName, deserialized.Name); + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + Assert.Equal(expectedBaseUrlForCanonicalHeader, deserialized.BaseUrlForCanonicalHeader); + } + + [Fact] + public void Validation_Works() + { + var model = new OriginResponseWebFolder + { + ID = "id", + BaseUrl = "https://images.example.com/assets", + ForwardHostHeaderToOrigin = false, + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new OriginResponseWebFolder + { + ID = "id", + BaseUrl = "https://images.example.com/assets", + ForwardHostHeaderToOrigin = false, + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + }; + + Assert.Null(model.BaseUrlForCanonicalHeader); + Assert.False(model.RawData.ContainsKey("baseUrlForCanonicalHeader")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new OriginResponseWebFolder + { + ID = "id", + BaseUrl = "https://images.example.com/assets", + ForwardHostHeaderToOrigin = false, + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new OriginResponseWebFolder + { + ID = "id", + BaseUrl = "https://images.example.com/assets", + ForwardHostHeaderToOrigin = false, + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + + // Null should be interpreted as omitted for these properties + BaseUrlForCanonicalHeader = null, + }; + + Assert.Null(model.BaseUrlForCanonicalHeader); + Assert.False(model.RawData.ContainsKey("baseUrlForCanonicalHeader")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new OriginResponseWebFolder + { + ID = "id", + BaseUrl = "https://images.example.com/assets", + ForwardHostHeaderToOrigin = false, + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + + // Null should be interpreted as omitted for these properties + BaseUrlForCanonicalHeader = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new OriginResponseWebFolder + { + ID = "id", + BaseUrl = "https://images.example.com/assets", + ForwardHostHeaderToOrigin = false, + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + + OriginResponseWebFolder copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class OriginResponseWebProxyTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new OriginResponseWebProxy + { + ID = "id", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + + string expectedID = "id"; + bool expectedIncludeCanonicalHeader = false; + string expectedName = "US S3 Storage"; + JsonElement expectedType = JsonSerializer.SerializeToElement("WEB_PROXY"); + string expectedBaseUrlForCanonicalHeader = "https://cdn.example.com"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedIncludeCanonicalHeader, model.IncludeCanonicalHeader); + Assert.Equal(expectedName, model.Name); + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + Assert.Equal(expectedBaseUrlForCanonicalHeader, model.BaseUrlForCanonicalHeader); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new OriginResponseWebProxy + { + ID = "id", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new OriginResponseWebProxy + { + ID = "id", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + bool expectedIncludeCanonicalHeader = false; + string expectedName = "US S3 Storage"; + JsonElement expectedType = JsonSerializer.SerializeToElement("WEB_PROXY"); + string expectedBaseUrlForCanonicalHeader = "https://cdn.example.com"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedIncludeCanonicalHeader, deserialized.IncludeCanonicalHeader); + Assert.Equal(expectedName, deserialized.Name); + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + Assert.Equal(expectedBaseUrlForCanonicalHeader, deserialized.BaseUrlForCanonicalHeader); + } + + [Fact] + public void Validation_Works() + { + var model = new OriginResponseWebProxy + { + ID = "id", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new OriginResponseWebProxy + { + ID = "id", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + }; + + Assert.Null(model.BaseUrlForCanonicalHeader); + Assert.False(model.RawData.ContainsKey("baseUrlForCanonicalHeader")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new OriginResponseWebProxy + { + ID = "id", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new OriginResponseWebProxy + { + ID = "id", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + + // Null should be interpreted as omitted for these properties + BaseUrlForCanonicalHeader = null, + }; + + Assert.Null(model.BaseUrlForCanonicalHeader); + Assert.False(model.RawData.ContainsKey("baseUrlForCanonicalHeader")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new OriginResponseWebProxy + { + ID = "id", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + + // Null should be interpreted as omitted for these properties + BaseUrlForCanonicalHeader = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new OriginResponseWebProxy + { + ID = "id", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + + OriginResponseWebProxy copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class OriginResponseGcsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new OriginResponseGcs + { + ID = "id", + Bucket = "gcs-media", + ClientEmail = "service-account@project.iam.gserviceaccount.com", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "products", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + + string expectedID = "id"; + string expectedBucket = "gcs-media"; + string expectedClientEmail = "service-account@project.iam.gserviceaccount.com"; + bool expectedIncludeCanonicalHeader = false; + string expectedName = "US S3 Storage"; + string expectedPrefix = "products"; + JsonElement expectedType = JsonSerializer.SerializeToElement("GCS"); + string expectedBaseUrlForCanonicalHeader = "https://cdn.example.com"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedBucket, model.Bucket); + Assert.Equal(expectedClientEmail, model.ClientEmail); + Assert.Equal(expectedIncludeCanonicalHeader, model.IncludeCanonicalHeader); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedPrefix, model.Prefix); + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + Assert.Equal(expectedBaseUrlForCanonicalHeader, model.BaseUrlForCanonicalHeader); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new OriginResponseGcs + { + ID = "id", + Bucket = "gcs-media", + ClientEmail = "service-account@project.iam.gserviceaccount.com", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "products", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new OriginResponseGcs + { + ID = "id", + Bucket = "gcs-media", + ClientEmail = "service-account@project.iam.gserviceaccount.com", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "products", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedBucket = "gcs-media"; + string expectedClientEmail = "service-account@project.iam.gserviceaccount.com"; + bool expectedIncludeCanonicalHeader = false; + string expectedName = "US S3 Storage"; + string expectedPrefix = "products"; + JsonElement expectedType = JsonSerializer.SerializeToElement("GCS"); + string expectedBaseUrlForCanonicalHeader = "https://cdn.example.com"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedBucket, deserialized.Bucket); + Assert.Equal(expectedClientEmail, deserialized.ClientEmail); + Assert.Equal(expectedIncludeCanonicalHeader, deserialized.IncludeCanonicalHeader); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedPrefix, deserialized.Prefix); + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + Assert.Equal(expectedBaseUrlForCanonicalHeader, deserialized.BaseUrlForCanonicalHeader); + } + + [Fact] + public void Validation_Works() + { + var model = new OriginResponseGcs + { + ID = "id", + Bucket = "gcs-media", + ClientEmail = "service-account@project.iam.gserviceaccount.com", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "products", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new OriginResponseGcs + { + ID = "id", + Bucket = "gcs-media", + ClientEmail = "service-account@project.iam.gserviceaccount.com", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "products", + }; + + Assert.Null(model.BaseUrlForCanonicalHeader); + Assert.False(model.RawData.ContainsKey("baseUrlForCanonicalHeader")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new OriginResponseGcs + { + ID = "id", + Bucket = "gcs-media", + ClientEmail = "service-account@project.iam.gserviceaccount.com", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "products", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new OriginResponseGcs + { + ID = "id", + Bucket = "gcs-media", + ClientEmail = "service-account@project.iam.gserviceaccount.com", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "products", + + // Null should be interpreted as omitted for these properties + BaseUrlForCanonicalHeader = null, + }; + + Assert.Null(model.BaseUrlForCanonicalHeader); + Assert.False(model.RawData.ContainsKey("baseUrlForCanonicalHeader")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new OriginResponseGcs + { + ID = "id", + Bucket = "gcs-media", + ClientEmail = "service-account@project.iam.gserviceaccount.com", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "products", + + // Null should be interpreted as omitted for these properties + BaseUrlForCanonicalHeader = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new OriginResponseGcs + { + ID = "id", + Bucket = "gcs-media", + ClientEmail = "service-account@project.iam.gserviceaccount.com", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "products", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + + OriginResponseGcs copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class OriginResponseAzureBlobTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new OriginResponseAzureBlob + { + ID = "id", + AccountName = "account123", + Container = "images", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "uploads", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + + string expectedID = "id"; + string expectedAccountName = "account123"; + string expectedContainer = "images"; + bool expectedIncludeCanonicalHeader = false; + string expectedName = "US S3 Storage"; + string expectedPrefix = "uploads"; + JsonElement expectedType = JsonSerializer.SerializeToElement("AZURE_BLOB"); + string expectedBaseUrlForCanonicalHeader = "https://cdn.example.com"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedAccountName, model.AccountName); + Assert.Equal(expectedContainer, model.Container); + Assert.Equal(expectedIncludeCanonicalHeader, model.IncludeCanonicalHeader); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedPrefix, model.Prefix); + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + Assert.Equal(expectedBaseUrlForCanonicalHeader, model.BaseUrlForCanonicalHeader); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new OriginResponseAzureBlob + { + ID = "id", + AccountName = "account123", + Container = "images", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "uploads", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new OriginResponseAzureBlob + { + ID = "id", + AccountName = "account123", + Container = "images", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "uploads", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedAccountName = "account123"; + string expectedContainer = "images"; + bool expectedIncludeCanonicalHeader = false; + string expectedName = "US S3 Storage"; + string expectedPrefix = "uploads"; + JsonElement expectedType = JsonSerializer.SerializeToElement("AZURE_BLOB"); + string expectedBaseUrlForCanonicalHeader = "https://cdn.example.com"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedAccountName, deserialized.AccountName); + Assert.Equal(expectedContainer, deserialized.Container); + Assert.Equal(expectedIncludeCanonicalHeader, deserialized.IncludeCanonicalHeader); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedPrefix, deserialized.Prefix); + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + Assert.Equal(expectedBaseUrlForCanonicalHeader, deserialized.BaseUrlForCanonicalHeader); + } + + [Fact] + public void Validation_Works() + { + var model = new OriginResponseAzureBlob + { + ID = "id", + AccountName = "account123", + Container = "images", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "uploads", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new OriginResponseAzureBlob + { + ID = "id", + AccountName = "account123", + Container = "images", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "uploads", + }; + + Assert.Null(model.BaseUrlForCanonicalHeader); + Assert.False(model.RawData.ContainsKey("baseUrlForCanonicalHeader")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new OriginResponseAzureBlob + { + ID = "id", + AccountName = "account123", + Container = "images", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "uploads", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new OriginResponseAzureBlob + { + ID = "id", + AccountName = "account123", + Container = "images", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "uploads", + + // Null should be interpreted as omitted for these properties + BaseUrlForCanonicalHeader = null, + }; + + Assert.Null(model.BaseUrlForCanonicalHeader); + Assert.False(model.RawData.ContainsKey("baseUrlForCanonicalHeader")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new OriginResponseAzureBlob + { + ID = "id", + AccountName = "account123", + Container = "images", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "uploads", + + // Null should be interpreted as omitted for these properties + BaseUrlForCanonicalHeader = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new OriginResponseAzureBlob + { + ID = "id", + AccountName = "account123", + Container = "images", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + Prefix = "uploads", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + + OriginResponseAzureBlob copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class OriginResponseAkeneoPimTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new OriginResponseAkeneoPim + { + ID = "id", + BaseUrl = "https://akeneo.company.com", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + + string expectedID = "id"; + string expectedBaseUrl = "https://akeneo.company.com"; + bool expectedIncludeCanonicalHeader = false; + string expectedName = "US S3 Storage"; + JsonElement expectedType = JsonSerializer.SerializeToElement("AKENEO_PIM"); + string expectedBaseUrlForCanonicalHeader = "https://cdn.example.com"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedBaseUrl, model.BaseUrl); + Assert.Equal(expectedIncludeCanonicalHeader, model.IncludeCanonicalHeader); + Assert.Equal(expectedName, model.Name); + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + Assert.Equal(expectedBaseUrlForCanonicalHeader, model.BaseUrlForCanonicalHeader); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new OriginResponseAkeneoPim + { + ID = "id", + BaseUrl = "https://akeneo.company.com", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new OriginResponseAkeneoPim + { + ID = "id", + BaseUrl = "https://akeneo.company.com", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedBaseUrl = "https://akeneo.company.com"; + bool expectedIncludeCanonicalHeader = false; + string expectedName = "US S3 Storage"; + JsonElement expectedType = JsonSerializer.SerializeToElement("AKENEO_PIM"); + string expectedBaseUrlForCanonicalHeader = "https://cdn.example.com"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedBaseUrl, deserialized.BaseUrl); + Assert.Equal(expectedIncludeCanonicalHeader, deserialized.IncludeCanonicalHeader); + Assert.Equal(expectedName, deserialized.Name); + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + Assert.Equal(expectedBaseUrlForCanonicalHeader, deserialized.BaseUrlForCanonicalHeader); + } + + [Fact] + public void Validation_Works() + { + var model = new OriginResponseAkeneoPim + { + ID = "id", + BaseUrl = "https://akeneo.company.com", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new OriginResponseAkeneoPim + { + ID = "id", + BaseUrl = "https://akeneo.company.com", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + }; + + Assert.Null(model.BaseUrlForCanonicalHeader); + Assert.False(model.RawData.ContainsKey("baseUrlForCanonicalHeader")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new OriginResponseAkeneoPim + { + ID = "id", + BaseUrl = "https://akeneo.company.com", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new OriginResponseAkeneoPim + { + ID = "id", + BaseUrl = "https://akeneo.company.com", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + + // Null should be interpreted as omitted for these properties + BaseUrlForCanonicalHeader = null, + }; + + Assert.Null(model.BaseUrlForCanonicalHeader); + Assert.False(model.RawData.ContainsKey("baseUrlForCanonicalHeader")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new OriginResponseAkeneoPim + { + ID = "id", + BaseUrl = "https://akeneo.company.com", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + + // Null should be interpreted as omitted for these properties + BaseUrlForCanonicalHeader = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new OriginResponseAkeneoPim + { + ID = "id", + BaseUrl = "https://akeneo.company.com", + IncludeCanonicalHeader = false, + Name = "US S3 Storage", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + }; + + OriginResponseAkeneoPim copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Accounts/Origins/OriginUpdateParamsTest.cs b/src/ImageKit.Tests/Models/Accounts/Origins/OriginUpdateParamsTest.cs new file mode 100644 index 00000000..6828eb88 --- /dev/null +++ b/src/ImageKit.Tests/Models/Accounts/Origins/OriginUpdateParamsTest.cs @@ -0,0 +1,87 @@ +using System; +using ImageKit.Models.Accounts.Origins; + +namespace ImageKit.Tests.Models.Accounts.Origins; + +public class OriginUpdateParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new OriginUpdateParams + { + ID = "id", + OriginRequest = new S3() + { + AccessKey = "AKIATEST123", + Bucket = "test-bucket", + Name = "My S3 Origin", + SecretKey = "secrettest123", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + Prefix = "images", + }, + }; + + string expectedID = "id"; + OriginRequest expectedOriginRequest = new S3() + { + AccessKey = "AKIATEST123", + Bucket = "test-bucket", + Name = "My S3 Origin", + SecretKey = "secrettest123", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + Prefix = "images", + }; + + Assert.Equal(expectedID, parameters.ID); + Assert.Equal(expectedOriginRequest, parameters.OriginRequest); + } + + [Fact] + public void Url_Works() + { + OriginUpdateParams parameters = new() + { + ID = "id", + OriginRequest = new S3() + { + AccessKey = "AKIATEST123", + Bucket = "test-bucket", + Name = "My S3 Origin", + SecretKey = "secrettest123", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + Prefix = "images", + }, + }; + + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + + Assert.Equal(new Uri("https://api.imagekit.io/v1/accounts/origins/id"), url); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new OriginUpdateParams + { + ID = "id", + OriginRequest = new S3() + { + AccessKey = "AKIATEST123", + Bucket = "test-bucket", + Name = "My S3 Origin", + SecretKey = "secrettest123", + BaseUrlForCanonicalHeader = "https://cdn.example.com", + IncludeCanonicalHeader = false, + Prefix = "images", + }, + }; + + OriginUpdateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointCreateParamsTest.cs b/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointCreateParamsTest.cs new file mode 100644 index 00000000..971baa20 --- /dev/null +++ b/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointCreateParamsTest.cs @@ -0,0 +1,433 @@ +using System; +using System.Collections.Generic; +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Exceptions; +using ImageKit.Models.Accounts.UrlEndpoints; + +namespace ImageKit.Tests.Models.Accounts.UrlEndpoints; + +public class UrlEndpointCreateParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new UrlEndpointCreateParams + { + Description = "My custom URL endpoint", + Origins = ["origin-id-1"], + UrlPrefix = "product-images", + UrlRewriter = new Cloudinary() { PreserveAssetDeliveryTypes = true }, + }; + + string expectedDescription = "My custom URL endpoint"; + List expectedOrigins = ["origin-id-1"]; + string expectedUrlPrefix = "product-images"; + UrlRewriter expectedUrlRewriter = new Cloudinary() { PreserveAssetDeliveryTypes = true }; + + Assert.Equal(expectedDescription, parameters.Description); + Assert.NotNull(parameters.Origins); + Assert.Equal(expectedOrigins.Count, parameters.Origins.Count); + for (int i = 0; i < expectedOrigins.Count; i++) + { + Assert.Equal(expectedOrigins[i], parameters.Origins[i]); + } + Assert.Equal(expectedUrlPrefix, parameters.UrlPrefix); + Assert.Equal(expectedUrlRewriter, parameters.UrlRewriter); + } + + [Fact] + public void OptionalNonNullableParamsUnsetAreNotSet_Works() + { + var parameters = new UrlEndpointCreateParams { Description = "My custom URL endpoint" }; + + Assert.Null(parameters.Origins); + Assert.False(parameters.RawBodyData.ContainsKey("origins")); + Assert.Null(parameters.UrlPrefix); + Assert.False(parameters.RawBodyData.ContainsKey("urlPrefix")); + Assert.Null(parameters.UrlRewriter); + Assert.False(parameters.RawBodyData.ContainsKey("urlRewriter")); + } + + [Fact] + public void OptionalNonNullableParamsSetToNullAreNotSet_Works() + { + var parameters = new UrlEndpointCreateParams + { + Description = "My custom URL endpoint", + + // Null should be interpreted as omitted for these properties + Origins = null, + UrlPrefix = null, + UrlRewriter = null, + }; + + Assert.Null(parameters.Origins); + Assert.False(parameters.RawBodyData.ContainsKey("origins")); + Assert.Null(parameters.UrlPrefix); + Assert.False(parameters.RawBodyData.ContainsKey("urlPrefix")); + Assert.Null(parameters.UrlRewriter); + Assert.False(parameters.RawBodyData.ContainsKey("urlRewriter")); + } + + [Fact] + public void Url_Works() + { + UrlEndpointCreateParams parameters = new() { Description = "My custom URL endpoint" }; + + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + + Assert.Equal(new Uri("https://api.imagekit.io/v1/accounts/url-endpoints"), url); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new UrlEndpointCreateParams + { + Description = "My custom URL endpoint", + Origins = ["origin-id-1"], + UrlPrefix = "product-images", + UrlRewriter = new Cloudinary() { PreserveAssetDeliveryTypes = true }, + }; + + UrlEndpointCreateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} + +public class UrlRewriterTest : TestBase +{ + [Fact] + public void CloudinaryValidationWorks() + { + UrlRewriter value = new Cloudinary() { PreserveAssetDeliveryTypes = true }; + value.Validate(); + } + + [Fact] + public void ImgixValidationWorks() + { + UrlRewriter value = new Imgix(); + value.Validate(); + } + + [Fact] + public void AkamaiValidationWorks() + { + UrlRewriter value = new Akamai(); + value.Validate(); + } + + [Fact] + public void CloudinarySerializationRoundtripWorks() + { + UrlRewriter value = new Cloudinary() { PreserveAssetDeliveryTypes = true }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void ImgixSerializationRoundtripWorks() + { + UrlRewriter value = new Imgix(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void AkamaiSerializationRoundtripWorks() + { + UrlRewriter value = new Akamai(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class CloudinaryTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Cloudinary { PreserveAssetDeliveryTypes = true }; + + JsonElement expectedType = JsonSerializer.SerializeToElement("CLOUDINARY"); + bool expectedPreserveAssetDeliveryTypes = true; + + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + Assert.Equal(expectedPreserveAssetDeliveryTypes, model.PreserveAssetDeliveryTypes); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Cloudinary { PreserveAssetDeliveryTypes = true }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Cloudinary { PreserveAssetDeliveryTypes = true }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + JsonElement expectedType = JsonSerializer.SerializeToElement("CLOUDINARY"); + bool expectedPreserveAssetDeliveryTypes = true; + + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + Assert.Equal(expectedPreserveAssetDeliveryTypes, deserialized.PreserveAssetDeliveryTypes); + } + + [Fact] + public void Validation_Works() + { + var model = new Cloudinary { PreserveAssetDeliveryTypes = true }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Cloudinary { }; + + Assert.Null(model.PreserveAssetDeliveryTypes); + Assert.False(model.RawData.ContainsKey("preserveAssetDeliveryTypes")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new Cloudinary { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new Cloudinary + { + // Null should be interpreted as omitted for these properties + PreserveAssetDeliveryTypes = null, + }; + + Assert.Null(model.PreserveAssetDeliveryTypes); + Assert.False(model.RawData.ContainsKey("preserveAssetDeliveryTypes")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new Cloudinary + { + // Null should be interpreted as omitted for these properties + PreserveAssetDeliveryTypes = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Cloudinary { PreserveAssetDeliveryTypes = true }; + + Cloudinary copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ImgixTest : TestBase +{ + [Fact] + public void DefaultValidation_Works() + { + var constant = new Imgix(); + constant.Validate(); + } + + [Fact] + public void ValidConstantValidation_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.Deserialize( + """ + { + "type": "IMGIX" + } + """ + ), + ModelBase.SerializerOptions + ); + + Assert.NotNull(constant); + constant.Validate(); + } + + [Fact] + public void InvalidConstantValidationThrows_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(constant); + Assert.Throws(() => constant.Validate()); + } + + [Fact] + public void DefaultRoundtrip_Works() + { + var constant = new Imgix(); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + + Assert.Equal(constant, deserialized); + } + + [Fact] + public void ValidConstantRoundtrip_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.Deserialize( + """ + { + "type": "IMGIX" + } + """ + ), + ModelBase.SerializerOptions + ); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + + Assert.Equal(constant, deserialized); + } + + [Fact] + public void InvalidConstantRoundtrip_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + + Assert.Equal(constant, deserialized); + } +} + +public class AkamaiTest : TestBase +{ + [Fact] + public void DefaultValidation_Works() + { + var constant = new Akamai(); + constant.Validate(); + } + + [Fact] + public void ValidConstantValidation_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.Deserialize( + """ + { + "type": "AKAMAI" + } + """ + ), + ModelBase.SerializerOptions + ); + + Assert.NotNull(constant); + constant.Validate(); + } + + [Fact] + public void InvalidConstantValidationThrows_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(constant); + Assert.Throws(() => constant.Validate()); + } + + [Fact] + public void DefaultRoundtrip_Works() + { + var constant = new Akamai(); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + + Assert.Equal(constant, deserialized); + } + + [Fact] + public void ValidConstantRoundtrip_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.Deserialize( + """ + { + "type": "AKAMAI" + } + """ + ), + ModelBase.SerializerOptions + ); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + + Assert.Equal(constant, deserialized); + } + + [Fact] + public void InvalidConstantRoundtrip_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + + Assert.Equal(constant, deserialized); + } +} diff --git a/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointDeleteParamsTest.cs b/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointDeleteParamsTest.cs new file mode 100644 index 00000000..f4dc5da0 --- /dev/null +++ b/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointDeleteParamsTest.cs @@ -0,0 +1,37 @@ +using System; +using ImageKit.Models.Accounts.UrlEndpoints; + +namespace ImageKit.Tests.Models.Accounts.UrlEndpoints; + +public class UrlEndpointDeleteParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new UrlEndpointDeleteParams { ID = "id" }; + + string expectedID = "id"; + + Assert.Equal(expectedID, parameters.ID); + } + + [Fact] + public void Url_Works() + { + UrlEndpointDeleteParams parameters = new() { ID = "id" }; + + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + + Assert.Equal(new Uri("https://api.imagekit.io/v1/accounts/url-endpoints/id"), url); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new UrlEndpointDeleteParams { ID = "id" }; + + UrlEndpointDeleteParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointGetParamsTest.cs b/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointGetParamsTest.cs new file mode 100644 index 00000000..cd8562ad --- /dev/null +++ b/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointGetParamsTest.cs @@ -0,0 +1,37 @@ +using System; +using ImageKit.Models.Accounts.UrlEndpoints; + +namespace ImageKit.Tests.Models.Accounts.UrlEndpoints; + +public class UrlEndpointGetParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new UrlEndpointGetParams { ID = "id" }; + + string expectedID = "id"; + + Assert.Equal(expectedID, parameters.ID); + } + + [Fact] + public void Url_Works() + { + UrlEndpointGetParams parameters = new() { ID = "id" }; + + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + + Assert.Equal(new Uri("https://api.imagekit.io/v1/accounts/url-endpoints/id"), url); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new UrlEndpointGetParams { ID = "id" }; + + UrlEndpointGetParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointListParamsTest.cs b/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointListParamsTest.cs new file mode 100644 index 00000000..3eac7fef --- /dev/null +++ b/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointListParamsTest.cs @@ -0,0 +1 @@ +namespace ImageKit.Tests.Models.Accounts.UrlEndpoints; diff --git a/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointRequestTest.cs b/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointRequestTest.cs new file mode 100644 index 00000000..53af2b8d --- /dev/null +++ b/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointRequestTest.cs @@ -0,0 +1,570 @@ +using System.Collections.Generic; +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Exceptions; +using ImageKit.Models.Accounts.UrlEndpoints; + +namespace ImageKit.Tests.Models.Accounts.UrlEndpoints; + +public class UrlEndpointRequestTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UrlEndpointRequest + { + Description = "My custom URL endpoint", + Origins = ["origin-id-1"], + UrlPrefix = "product-images", + UrlRewriter = new UrlEndpointRequestUrlRewriterCloudinary() + { + PreserveAssetDeliveryTypes = true, + }, + }; + + string expectedDescription = "My custom URL endpoint"; + List expectedOrigins = ["origin-id-1"]; + string expectedUrlPrefix = "product-images"; + UrlEndpointRequestUrlRewriter expectedUrlRewriter = + new UrlEndpointRequestUrlRewriterCloudinary() { PreserveAssetDeliveryTypes = true }; + + Assert.Equal(expectedDescription, model.Description); + Assert.NotNull(model.Origins); + Assert.Equal(expectedOrigins.Count, model.Origins.Count); + for (int i = 0; i < expectedOrigins.Count; i++) + { + Assert.Equal(expectedOrigins[i], model.Origins[i]); + } + Assert.Equal(expectedUrlPrefix, model.UrlPrefix); + Assert.Equal(expectedUrlRewriter, model.UrlRewriter); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UrlEndpointRequest + { + Description = "My custom URL endpoint", + Origins = ["origin-id-1"], + UrlPrefix = "product-images", + UrlRewriter = new UrlEndpointRequestUrlRewriterCloudinary() + { + PreserveAssetDeliveryTypes = true, + }, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new UrlEndpointRequest + { + Description = "My custom URL endpoint", + Origins = ["origin-id-1"], + UrlPrefix = "product-images", + UrlRewriter = new UrlEndpointRequestUrlRewriterCloudinary() + { + PreserveAssetDeliveryTypes = true, + }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedDescription = "My custom URL endpoint"; + List expectedOrigins = ["origin-id-1"]; + string expectedUrlPrefix = "product-images"; + UrlEndpointRequestUrlRewriter expectedUrlRewriter = + new UrlEndpointRequestUrlRewriterCloudinary() { PreserveAssetDeliveryTypes = true }; + + Assert.Equal(expectedDescription, deserialized.Description); + Assert.NotNull(deserialized.Origins); + Assert.Equal(expectedOrigins.Count, deserialized.Origins.Count); + for (int i = 0; i < expectedOrigins.Count; i++) + { + Assert.Equal(expectedOrigins[i], deserialized.Origins[i]); + } + Assert.Equal(expectedUrlPrefix, deserialized.UrlPrefix); + Assert.Equal(expectedUrlRewriter, deserialized.UrlRewriter); + } + + [Fact] + public void Validation_Works() + { + var model = new UrlEndpointRequest + { + Description = "My custom URL endpoint", + Origins = ["origin-id-1"], + UrlPrefix = "product-images", + UrlRewriter = new UrlEndpointRequestUrlRewriterCloudinary() + { + PreserveAssetDeliveryTypes = true, + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new UrlEndpointRequest { Description = "My custom URL endpoint" }; + + Assert.Null(model.Origins); + Assert.False(model.RawData.ContainsKey("origins")); + Assert.Null(model.UrlPrefix); + Assert.False(model.RawData.ContainsKey("urlPrefix")); + Assert.Null(model.UrlRewriter); + Assert.False(model.RawData.ContainsKey("urlRewriter")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new UrlEndpointRequest { Description = "My custom URL endpoint" }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new UrlEndpointRequest + { + Description = "My custom URL endpoint", + + // Null should be interpreted as omitted for these properties + Origins = null, + UrlPrefix = null, + UrlRewriter = null, + }; + + Assert.Null(model.Origins); + Assert.False(model.RawData.ContainsKey("origins")); + Assert.Null(model.UrlPrefix); + Assert.False(model.RawData.ContainsKey("urlPrefix")); + Assert.Null(model.UrlRewriter); + Assert.False(model.RawData.ContainsKey("urlRewriter")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new UrlEndpointRequest + { + Description = "My custom URL endpoint", + + // Null should be interpreted as omitted for these properties + Origins = null, + UrlPrefix = null, + UrlRewriter = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UrlEndpointRequest + { + Description = "My custom URL endpoint", + Origins = ["origin-id-1"], + UrlPrefix = "product-images", + UrlRewriter = new UrlEndpointRequestUrlRewriterCloudinary() + { + PreserveAssetDeliveryTypes = true, + }, + }; + + UrlEndpointRequest copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UrlEndpointRequestUrlRewriterTest : TestBase +{ + [Fact] + public void CloudinaryValidationWorks() + { + UrlEndpointRequestUrlRewriter value = new UrlEndpointRequestUrlRewriterCloudinary() + { + PreserveAssetDeliveryTypes = true, + }; + value.Validate(); + } + + [Fact] + public void ImgixValidationWorks() + { + UrlEndpointRequestUrlRewriter value = new UrlEndpointRequestUrlRewriterImgix(); + value.Validate(); + } + + [Fact] + public void AkamaiValidationWorks() + { + UrlEndpointRequestUrlRewriter value = new UrlEndpointRequestUrlRewriterAkamai(); + value.Validate(); + } + + [Fact] + public void CloudinarySerializationRoundtripWorks() + { + UrlEndpointRequestUrlRewriter value = new UrlEndpointRequestUrlRewriterCloudinary() + { + PreserveAssetDeliveryTypes = true, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void ImgixSerializationRoundtripWorks() + { + UrlEndpointRequestUrlRewriter value = new UrlEndpointRequestUrlRewriterImgix(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void AkamaiSerializationRoundtripWorks() + { + UrlEndpointRequestUrlRewriter value = new UrlEndpointRequestUrlRewriterAkamai(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class UrlEndpointRequestUrlRewriterCloudinaryTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UrlEndpointRequestUrlRewriterCloudinary + { + PreserveAssetDeliveryTypes = true, + }; + + JsonElement expectedType = JsonSerializer.SerializeToElement("CLOUDINARY"); + bool expectedPreserveAssetDeliveryTypes = true; + + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + Assert.Equal(expectedPreserveAssetDeliveryTypes, model.PreserveAssetDeliveryTypes); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UrlEndpointRequestUrlRewriterCloudinary + { + PreserveAssetDeliveryTypes = true, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new UrlEndpointRequestUrlRewriterCloudinary + { + PreserveAssetDeliveryTypes = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + JsonElement expectedType = JsonSerializer.SerializeToElement("CLOUDINARY"); + bool expectedPreserveAssetDeliveryTypes = true; + + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + Assert.Equal(expectedPreserveAssetDeliveryTypes, deserialized.PreserveAssetDeliveryTypes); + } + + [Fact] + public void Validation_Works() + { + var model = new UrlEndpointRequestUrlRewriterCloudinary + { + PreserveAssetDeliveryTypes = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new UrlEndpointRequestUrlRewriterCloudinary { }; + + Assert.Null(model.PreserveAssetDeliveryTypes); + Assert.False(model.RawData.ContainsKey("preserveAssetDeliveryTypes")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new UrlEndpointRequestUrlRewriterCloudinary { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new UrlEndpointRequestUrlRewriterCloudinary + { + // Null should be interpreted as omitted for these properties + PreserveAssetDeliveryTypes = null, + }; + + Assert.Null(model.PreserveAssetDeliveryTypes); + Assert.False(model.RawData.ContainsKey("preserveAssetDeliveryTypes")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new UrlEndpointRequestUrlRewriterCloudinary + { + // Null should be interpreted as omitted for these properties + PreserveAssetDeliveryTypes = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UrlEndpointRequestUrlRewriterCloudinary + { + PreserveAssetDeliveryTypes = true, + }; + + UrlEndpointRequestUrlRewriterCloudinary copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UrlEndpointRequestUrlRewriterImgixTest : TestBase +{ + [Fact] + public void DefaultValidation_Works() + { + var constant = new UrlEndpointRequestUrlRewriterImgix(); + constant.Validate(); + } + + [Fact] + public void ValidConstantValidation_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.Deserialize( + """ + { + "type": "IMGIX" + } + """ + ), + ModelBase.SerializerOptions + ); + + Assert.NotNull(constant); + constant.Validate(); + } + + [Fact] + public void InvalidConstantValidationThrows_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(constant); + Assert.Throws(() => constant.Validate()); + } + + [Fact] + public void DefaultRoundtrip_Works() + { + var constant = new UrlEndpointRequestUrlRewriterImgix(); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } + + [Fact] + public void ValidConstantRoundtrip_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.Deserialize( + """ + { + "type": "IMGIX" + } + """ + ), + ModelBase.SerializerOptions + ); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } + + [Fact] + public void InvalidConstantRoundtrip_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } +} + +public class UrlEndpointRequestUrlRewriterAkamaiTest : TestBase +{ + [Fact] + public void DefaultValidation_Works() + { + var constant = new UrlEndpointRequestUrlRewriterAkamai(); + constant.Validate(); + } + + [Fact] + public void ValidConstantValidation_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.Deserialize( + """ + { + "type": "AKAMAI" + } + """ + ), + ModelBase.SerializerOptions + ); + + Assert.NotNull(constant); + constant.Validate(); + } + + [Fact] + public void InvalidConstantValidationThrows_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(constant); + Assert.Throws(() => constant.Validate()); + } + + [Fact] + public void DefaultRoundtrip_Works() + { + var constant = new UrlEndpointRequestUrlRewriterAkamai(); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } + + [Fact] + public void ValidConstantRoundtrip_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.Deserialize( + """ + { + "type": "AKAMAI" + } + """ + ), + ModelBase.SerializerOptions + ); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } + + [Fact] + public void InvalidConstantRoundtrip_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } +} diff --git a/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointResponseTest.cs b/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointResponseTest.cs new file mode 100644 index 00000000..a55dec1a --- /dev/null +++ b/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointResponseTest.cs @@ -0,0 +1,520 @@ +using System.Collections.Generic; +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Exceptions; +using ImageKit.Models.Accounts.UrlEndpoints; + +namespace ImageKit.Tests.Models.Accounts.UrlEndpoints; + +public class UrlEndpointResponseTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UrlEndpointResponse + { + ID = "id", + Description = "My custom URL endpoint", + Origins = ["origin-id-1", "origin-id-2"], + UrlPrefix = "product-images", + UrlRewriter = new UrlEndpointResponseUrlRewriterCloudinary(true), + }; + + string expectedID = "id"; + string expectedDescription = "My custom URL endpoint"; + List expectedOrigins = ["origin-id-1", "origin-id-2"]; + string expectedUrlPrefix = "product-images"; + UrlEndpointResponseUrlRewriter expectedUrlRewriter = + new UrlEndpointResponseUrlRewriterCloudinary(true); + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedDescription, model.Description); + Assert.Equal(expectedOrigins.Count, model.Origins.Count); + for (int i = 0; i < expectedOrigins.Count; i++) + { + Assert.Equal(expectedOrigins[i], model.Origins[i]); + } + Assert.Equal(expectedUrlPrefix, model.UrlPrefix); + Assert.Equal(expectedUrlRewriter, model.UrlRewriter); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UrlEndpointResponse + { + ID = "id", + Description = "My custom URL endpoint", + Origins = ["origin-id-1", "origin-id-2"], + UrlPrefix = "product-images", + UrlRewriter = new UrlEndpointResponseUrlRewriterCloudinary(true), + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new UrlEndpointResponse + { + ID = "id", + Description = "My custom URL endpoint", + Origins = ["origin-id-1", "origin-id-2"], + UrlPrefix = "product-images", + UrlRewriter = new UrlEndpointResponseUrlRewriterCloudinary(true), + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedDescription = "My custom URL endpoint"; + List expectedOrigins = ["origin-id-1", "origin-id-2"]; + string expectedUrlPrefix = "product-images"; + UrlEndpointResponseUrlRewriter expectedUrlRewriter = + new UrlEndpointResponseUrlRewriterCloudinary(true); + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedDescription, deserialized.Description); + Assert.Equal(expectedOrigins.Count, deserialized.Origins.Count); + for (int i = 0; i < expectedOrigins.Count; i++) + { + Assert.Equal(expectedOrigins[i], deserialized.Origins[i]); + } + Assert.Equal(expectedUrlPrefix, deserialized.UrlPrefix); + Assert.Equal(expectedUrlRewriter, deserialized.UrlRewriter); + } + + [Fact] + public void Validation_Works() + { + var model = new UrlEndpointResponse + { + ID = "id", + Description = "My custom URL endpoint", + Origins = ["origin-id-1", "origin-id-2"], + UrlPrefix = "product-images", + UrlRewriter = new UrlEndpointResponseUrlRewriterCloudinary(true), + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new UrlEndpointResponse + { + ID = "id", + Description = "My custom URL endpoint", + Origins = ["origin-id-1", "origin-id-2"], + UrlPrefix = "product-images", + }; + + Assert.Null(model.UrlRewriter); + Assert.False(model.RawData.ContainsKey("urlRewriter")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new UrlEndpointResponse + { + ID = "id", + Description = "My custom URL endpoint", + Origins = ["origin-id-1", "origin-id-2"], + UrlPrefix = "product-images", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new UrlEndpointResponse + { + ID = "id", + Description = "My custom URL endpoint", + Origins = ["origin-id-1", "origin-id-2"], + UrlPrefix = "product-images", + + // Null should be interpreted as omitted for these properties + UrlRewriter = null, + }; + + Assert.Null(model.UrlRewriter); + Assert.False(model.RawData.ContainsKey("urlRewriter")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new UrlEndpointResponse + { + ID = "id", + Description = "My custom URL endpoint", + Origins = ["origin-id-1", "origin-id-2"], + UrlPrefix = "product-images", + + // Null should be interpreted as omitted for these properties + UrlRewriter = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UrlEndpointResponse + { + ID = "id", + Description = "My custom URL endpoint", + Origins = ["origin-id-1", "origin-id-2"], + UrlPrefix = "product-images", + UrlRewriter = new UrlEndpointResponseUrlRewriterCloudinary(true), + }; + + UrlEndpointResponse copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UrlEndpointResponseUrlRewriterTest : TestBase +{ + [Fact] + public void CloudinaryValidationWorks() + { + UrlEndpointResponseUrlRewriter value = new UrlEndpointResponseUrlRewriterCloudinary(true); + value.Validate(); + } + + [Fact] + public void ImgixValidationWorks() + { + UrlEndpointResponseUrlRewriter value = new UrlEndpointResponseUrlRewriterImgix(); + value.Validate(); + } + + [Fact] + public void AkamaiValidationWorks() + { + UrlEndpointResponseUrlRewriter value = new UrlEndpointResponseUrlRewriterAkamai(); + value.Validate(); + } + + [Fact] + public void CloudinarySerializationRoundtripWorks() + { + UrlEndpointResponseUrlRewriter value = new UrlEndpointResponseUrlRewriterCloudinary(true); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void ImgixSerializationRoundtripWorks() + { + UrlEndpointResponseUrlRewriter value = new UrlEndpointResponseUrlRewriterImgix(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void AkamaiSerializationRoundtripWorks() + { + UrlEndpointResponseUrlRewriter value = new UrlEndpointResponseUrlRewriterAkamai(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class UrlEndpointResponseUrlRewriterCloudinaryTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UrlEndpointResponseUrlRewriterCloudinary + { + PreserveAssetDeliveryTypes = true, + }; + + bool expectedPreserveAssetDeliveryTypes = true; + JsonElement expectedType = JsonSerializer.SerializeToElement("CLOUDINARY"); + + Assert.Equal(expectedPreserveAssetDeliveryTypes, model.PreserveAssetDeliveryTypes); + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UrlEndpointResponseUrlRewriterCloudinary + { + PreserveAssetDeliveryTypes = true, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new UrlEndpointResponseUrlRewriterCloudinary + { + PreserveAssetDeliveryTypes = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + bool expectedPreserveAssetDeliveryTypes = true; + JsonElement expectedType = JsonSerializer.SerializeToElement("CLOUDINARY"); + + Assert.Equal(expectedPreserveAssetDeliveryTypes, deserialized.PreserveAssetDeliveryTypes); + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + } + + [Fact] + public void Validation_Works() + { + var model = new UrlEndpointResponseUrlRewriterCloudinary + { + PreserveAssetDeliveryTypes = true, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UrlEndpointResponseUrlRewriterCloudinary + { + PreserveAssetDeliveryTypes = true, + }; + + UrlEndpointResponseUrlRewriterCloudinary copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UrlEndpointResponseUrlRewriterImgixTest : TestBase +{ + [Fact] + public void DefaultValidation_Works() + { + var constant = new UrlEndpointResponseUrlRewriterImgix(); + constant.Validate(); + } + + [Fact] + public void ValidConstantValidation_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.Deserialize( + """ + { + "type": "IMGIX" + } + """ + ), + ModelBase.SerializerOptions + ); + + Assert.NotNull(constant); + constant.Validate(); + } + + [Fact] + public void InvalidConstantValidationThrows_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(constant); + Assert.Throws(() => constant.Validate()); + } + + [Fact] + public void DefaultRoundtrip_Works() + { + var constant = new UrlEndpointResponseUrlRewriterImgix(); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } + + [Fact] + public void ValidConstantRoundtrip_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.Deserialize( + """ + { + "type": "IMGIX" + } + """ + ), + ModelBase.SerializerOptions + ); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } + + [Fact] + public void InvalidConstantRoundtrip_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } +} + +public class UrlEndpointResponseUrlRewriterAkamaiTest : TestBase +{ + [Fact] + public void DefaultValidation_Works() + { + var constant = new UrlEndpointResponseUrlRewriterAkamai(); + constant.Validate(); + } + + [Fact] + public void ValidConstantValidation_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.Deserialize( + """ + { + "type": "AKAMAI" + } + """ + ), + ModelBase.SerializerOptions + ); + + Assert.NotNull(constant); + constant.Validate(); + } + + [Fact] + public void InvalidConstantValidationThrows_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(constant); + Assert.Throws(() => constant.Validate()); + } + + [Fact] + public void DefaultRoundtrip_Works() + { + var constant = new UrlEndpointResponseUrlRewriterAkamai(); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } + + [Fact] + public void ValidConstantRoundtrip_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.Deserialize( + """ + { + "type": "AKAMAI" + } + """ + ), + ModelBase.SerializerOptions + ); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } + + [Fact] + public void InvalidConstantRoundtrip_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } +} diff --git a/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParamsTest.cs b/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParamsTest.cs new file mode 100644 index 00000000..552ee2f1 --- /dev/null +++ b/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParamsTest.cs @@ -0,0 +1,497 @@ +using System; +using System.Collections.Generic; +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Exceptions; +using ImageKit.Models.Accounts.UrlEndpoints; + +namespace ImageKit.Tests.Models.Accounts.UrlEndpoints; + +public class UrlEndpointUpdateParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new UrlEndpointUpdateParams + { + ID = "id", + Description = "My custom URL endpoint", + Origins = ["origin-id-1"], + UrlPrefix = "product-images", + UrlRewriter = new UrlEndpointUpdateParamsUrlRewriterCloudinary() + { + PreserveAssetDeliveryTypes = true, + }, + }; + + string expectedID = "id"; + string expectedDescription = "My custom URL endpoint"; + List expectedOrigins = ["origin-id-1"]; + string expectedUrlPrefix = "product-images"; + UrlEndpointUpdateParamsUrlRewriter expectedUrlRewriter = + new UrlEndpointUpdateParamsUrlRewriterCloudinary() + { + PreserveAssetDeliveryTypes = true, + }; + + Assert.Equal(expectedID, parameters.ID); + Assert.Equal(expectedDescription, parameters.Description); + Assert.NotNull(parameters.Origins); + Assert.Equal(expectedOrigins.Count, parameters.Origins.Count); + for (int i = 0; i < expectedOrigins.Count; i++) + { + Assert.Equal(expectedOrigins[i], parameters.Origins[i]); + } + Assert.Equal(expectedUrlPrefix, parameters.UrlPrefix); + Assert.Equal(expectedUrlRewriter, parameters.UrlRewriter); + } + + [Fact] + public void OptionalNonNullableParamsUnsetAreNotSet_Works() + { + var parameters = new UrlEndpointUpdateParams + { + ID = "id", + Description = "My custom URL endpoint", + }; + + Assert.Null(parameters.Origins); + Assert.False(parameters.RawBodyData.ContainsKey("origins")); + Assert.Null(parameters.UrlPrefix); + Assert.False(parameters.RawBodyData.ContainsKey("urlPrefix")); + Assert.Null(parameters.UrlRewriter); + Assert.False(parameters.RawBodyData.ContainsKey("urlRewriter")); + } + + [Fact] + public void OptionalNonNullableParamsSetToNullAreNotSet_Works() + { + var parameters = new UrlEndpointUpdateParams + { + ID = "id", + Description = "My custom URL endpoint", + + // Null should be interpreted as omitted for these properties + Origins = null, + UrlPrefix = null, + UrlRewriter = null, + }; + + Assert.Null(parameters.Origins); + Assert.False(parameters.RawBodyData.ContainsKey("origins")); + Assert.Null(parameters.UrlPrefix); + Assert.False(parameters.RawBodyData.ContainsKey("urlPrefix")); + Assert.Null(parameters.UrlRewriter); + Assert.False(parameters.RawBodyData.ContainsKey("urlRewriter")); + } + + [Fact] + public void Url_Works() + { + UrlEndpointUpdateParams parameters = new() + { + ID = "id", + Description = "My custom URL endpoint", + }; + + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + + Assert.Equal(new Uri("https://api.imagekit.io/v1/accounts/url-endpoints/id"), url); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new UrlEndpointUpdateParams + { + ID = "id", + Description = "My custom URL endpoint", + Origins = ["origin-id-1"], + UrlPrefix = "product-images", + UrlRewriter = new UrlEndpointUpdateParamsUrlRewriterCloudinary() + { + PreserveAssetDeliveryTypes = true, + }, + }; + + UrlEndpointUpdateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} + +public class UrlEndpointUpdateParamsUrlRewriterTest : TestBase +{ + [Fact] + public void CloudinaryValidationWorks() + { + UrlEndpointUpdateParamsUrlRewriter value = + new UrlEndpointUpdateParamsUrlRewriterCloudinary() + { + PreserveAssetDeliveryTypes = true, + }; + value.Validate(); + } + + [Fact] + public void ImgixValidationWorks() + { + UrlEndpointUpdateParamsUrlRewriter value = new UrlEndpointUpdateParamsUrlRewriterImgix(); + value.Validate(); + } + + [Fact] + public void AkamaiValidationWorks() + { + UrlEndpointUpdateParamsUrlRewriter value = new UrlEndpointUpdateParamsUrlRewriterAkamai(); + value.Validate(); + } + + [Fact] + public void CloudinarySerializationRoundtripWorks() + { + UrlEndpointUpdateParamsUrlRewriter value = + new UrlEndpointUpdateParamsUrlRewriterCloudinary() + { + PreserveAssetDeliveryTypes = true, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void ImgixSerializationRoundtripWorks() + { + UrlEndpointUpdateParamsUrlRewriter value = new UrlEndpointUpdateParamsUrlRewriterImgix(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void AkamaiSerializationRoundtripWorks() + { + UrlEndpointUpdateParamsUrlRewriter value = new UrlEndpointUpdateParamsUrlRewriterAkamai(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class UrlEndpointUpdateParamsUrlRewriterCloudinaryTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UrlEndpointUpdateParamsUrlRewriterCloudinary + { + PreserveAssetDeliveryTypes = true, + }; + + JsonElement expectedType = JsonSerializer.SerializeToElement("CLOUDINARY"); + bool expectedPreserveAssetDeliveryTypes = true; + + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + Assert.Equal(expectedPreserveAssetDeliveryTypes, model.PreserveAssetDeliveryTypes); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UrlEndpointUpdateParamsUrlRewriterCloudinary + { + PreserveAssetDeliveryTypes = true, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new UrlEndpointUpdateParamsUrlRewriterCloudinary + { + PreserveAssetDeliveryTypes = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + JsonElement expectedType = JsonSerializer.SerializeToElement("CLOUDINARY"); + bool expectedPreserveAssetDeliveryTypes = true; + + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + Assert.Equal(expectedPreserveAssetDeliveryTypes, deserialized.PreserveAssetDeliveryTypes); + } + + [Fact] + public void Validation_Works() + { + var model = new UrlEndpointUpdateParamsUrlRewriterCloudinary + { + PreserveAssetDeliveryTypes = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new UrlEndpointUpdateParamsUrlRewriterCloudinary { }; + + Assert.Null(model.PreserveAssetDeliveryTypes); + Assert.False(model.RawData.ContainsKey("preserveAssetDeliveryTypes")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new UrlEndpointUpdateParamsUrlRewriterCloudinary { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new UrlEndpointUpdateParamsUrlRewriterCloudinary + { + // Null should be interpreted as omitted for these properties + PreserveAssetDeliveryTypes = null, + }; + + Assert.Null(model.PreserveAssetDeliveryTypes); + Assert.False(model.RawData.ContainsKey("preserveAssetDeliveryTypes")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new UrlEndpointUpdateParamsUrlRewriterCloudinary + { + // Null should be interpreted as omitted for these properties + PreserveAssetDeliveryTypes = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UrlEndpointUpdateParamsUrlRewriterCloudinary + { + PreserveAssetDeliveryTypes = true, + }; + + UrlEndpointUpdateParamsUrlRewriterCloudinary copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UrlEndpointUpdateParamsUrlRewriterImgixTest : TestBase +{ + [Fact] + public void DefaultValidation_Works() + { + var constant = new UrlEndpointUpdateParamsUrlRewriterImgix(); + constant.Validate(); + } + + [Fact] + public void ValidConstantValidation_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.Deserialize( + """ + { + "type": "IMGIX" + } + """ + ), + ModelBase.SerializerOptions + ); + + Assert.NotNull(constant); + constant.Validate(); + } + + [Fact] + public void InvalidConstantValidationThrows_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(constant); + Assert.Throws(() => constant.Validate()); + } + + [Fact] + public void DefaultRoundtrip_Works() + { + var constant = new UrlEndpointUpdateParamsUrlRewriterImgix(); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } + + [Fact] + public void ValidConstantRoundtrip_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.Deserialize( + """ + { + "type": "IMGIX" + } + """ + ), + ModelBase.SerializerOptions + ); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } + + [Fact] + public void InvalidConstantRoundtrip_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } +} + +public class UrlEndpointUpdateParamsUrlRewriterAkamaiTest : TestBase +{ + [Fact] + public void DefaultValidation_Works() + { + var constant = new UrlEndpointUpdateParamsUrlRewriterAkamai(); + constant.Validate(); + } + + [Fact] + public void ValidConstantValidation_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.Deserialize( + """ + { + "type": "AKAMAI" + } + """ + ), + ModelBase.SerializerOptions + ); + + Assert.NotNull(constant); + constant.Validate(); + } + + [Fact] + public void InvalidConstantValidationThrows_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(constant); + Assert.Throws(() => constant.Validate()); + } + + [Fact] + public void DefaultRoundtrip_Works() + { + var constant = new UrlEndpointUpdateParamsUrlRewriterAkamai(); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } + + [Fact] + public void ValidConstantRoundtrip_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.Deserialize( + """ + { + "type": "AKAMAI" + } + """ + ), + ModelBase.SerializerOptions + ); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } + + [Fact] + public void InvalidConstantRoundtrip_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } +} diff --git a/src/ImageKit.Tests/Models/Accounts/Usage/UsageGetParamsTest.cs b/src/ImageKit.Tests/Models/Accounts/Usage/UsageGetParamsTest.cs new file mode 100644 index 00000000..d3f8003a --- /dev/null +++ b/src/ImageKit.Tests/Models/Accounts/Usage/UsageGetParamsTest.cs @@ -0,0 +1,44 @@ +using System; +using ImageKit.Models.Accounts.Usage; + +namespace ImageKit.Tests.Models.Accounts.Usage; + +public class UsageGetParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new UsageGetParams { EndDate = "2019-12-27", StartDate = "2019-12-27" }; + + string expectedEndDate = "2019-12-27"; + string expectedStartDate = "2019-12-27"; + + Assert.Equal(expectedEndDate, parameters.EndDate); + Assert.Equal(expectedStartDate, parameters.StartDate); + } + + [Fact] + public void Url_Works() + { + UsageGetParams parameters = new() { EndDate = "2019-12-27", StartDate = "2019-12-27" }; + + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + + Assert.Equal( + new Uri( + "https://api.imagekit.io/v1/accounts/usage?endDate=2019-12-27&startDate=2019-12-27" + ), + url + ); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new UsageGetParams { EndDate = "2019-12-27", StartDate = "2019-12-27" }; + + UsageGetParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Accounts/Usage/UsageGetResponseTest.cs b/src/ImageKit.Tests/Models/Accounts/Usage/UsageGetResponseTest.cs new file mode 100644 index 00000000..50dd64d8 --- /dev/null +++ b/src/ImageKit.Tests/Models/Accounts/Usage/UsageGetResponseTest.cs @@ -0,0 +1,184 @@ +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Models.Accounts.Usage; + +namespace ImageKit.Tests.Models.Accounts.Usage; + +public class UsageGetResponseTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UsageGetResponse + { + BandwidthBytes = 0, + ExtensionUnitsCount = 0, + MediaLibraryStorageBytes = 0, + OriginalCacheStorageBytes = 0, + VideoProcessingUnitsCount = 0, + }; + + long expectedBandwidthBytes = 0; + long expectedExtensionUnitsCount = 0; + long expectedMediaLibraryStorageBytes = 0; + long expectedOriginalCacheStorageBytes = 0; + long expectedVideoProcessingUnitsCount = 0; + + Assert.Equal(expectedBandwidthBytes, model.BandwidthBytes); + Assert.Equal(expectedExtensionUnitsCount, model.ExtensionUnitsCount); + Assert.Equal(expectedMediaLibraryStorageBytes, model.MediaLibraryStorageBytes); + Assert.Equal(expectedOriginalCacheStorageBytes, model.OriginalCacheStorageBytes); + Assert.Equal(expectedVideoProcessingUnitsCount, model.VideoProcessingUnitsCount); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UsageGetResponse + { + BandwidthBytes = 0, + ExtensionUnitsCount = 0, + MediaLibraryStorageBytes = 0, + OriginalCacheStorageBytes = 0, + VideoProcessingUnitsCount = 0, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new UsageGetResponse + { + BandwidthBytes = 0, + ExtensionUnitsCount = 0, + MediaLibraryStorageBytes = 0, + OriginalCacheStorageBytes = 0, + VideoProcessingUnitsCount = 0, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + long expectedBandwidthBytes = 0; + long expectedExtensionUnitsCount = 0; + long expectedMediaLibraryStorageBytes = 0; + long expectedOriginalCacheStorageBytes = 0; + long expectedVideoProcessingUnitsCount = 0; + + Assert.Equal(expectedBandwidthBytes, deserialized.BandwidthBytes); + Assert.Equal(expectedExtensionUnitsCount, deserialized.ExtensionUnitsCount); + Assert.Equal(expectedMediaLibraryStorageBytes, deserialized.MediaLibraryStorageBytes); + Assert.Equal(expectedOriginalCacheStorageBytes, deserialized.OriginalCacheStorageBytes); + Assert.Equal(expectedVideoProcessingUnitsCount, deserialized.VideoProcessingUnitsCount); + } + + [Fact] + public void Validation_Works() + { + var model = new UsageGetResponse + { + BandwidthBytes = 0, + ExtensionUnitsCount = 0, + MediaLibraryStorageBytes = 0, + OriginalCacheStorageBytes = 0, + VideoProcessingUnitsCount = 0, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new UsageGetResponse { }; + + Assert.Null(model.BandwidthBytes); + Assert.False(model.RawData.ContainsKey("bandwidthBytes")); + Assert.Null(model.ExtensionUnitsCount); + Assert.False(model.RawData.ContainsKey("extensionUnitsCount")); + Assert.Null(model.MediaLibraryStorageBytes); + Assert.False(model.RawData.ContainsKey("mediaLibraryStorageBytes")); + Assert.Null(model.OriginalCacheStorageBytes); + Assert.False(model.RawData.ContainsKey("originalCacheStorageBytes")); + Assert.Null(model.VideoProcessingUnitsCount); + Assert.False(model.RawData.ContainsKey("videoProcessingUnitsCount")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new UsageGetResponse { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new UsageGetResponse + { + // Null should be interpreted as omitted for these properties + BandwidthBytes = null, + ExtensionUnitsCount = null, + MediaLibraryStorageBytes = null, + OriginalCacheStorageBytes = null, + VideoProcessingUnitsCount = null, + }; + + Assert.Null(model.BandwidthBytes); + Assert.False(model.RawData.ContainsKey("bandwidthBytes")); + Assert.Null(model.ExtensionUnitsCount); + Assert.False(model.RawData.ContainsKey("extensionUnitsCount")); + Assert.Null(model.MediaLibraryStorageBytes); + Assert.False(model.RawData.ContainsKey("mediaLibraryStorageBytes")); + Assert.Null(model.OriginalCacheStorageBytes); + Assert.False(model.RawData.ContainsKey("originalCacheStorageBytes")); + Assert.Null(model.VideoProcessingUnitsCount); + Assert.False(model.RawData.ContainsKey("videoProcessingUnitsCount")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new UsageGetResponse + { + // Null should be interpreted as omitted for these properties + BandwidthBytes = null, + ExtensionUnitsCount = null, + MediaLibraryStorageBytes = null, + OriginalCacheStorageBytes = null, + VideoProcessingUnitsCount = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UsageGetResponse + { + BandwidthBytes = 0, + ExtensionUnitsCount = 0, + MediaLibraryStorageBytes = 0, + OriginalCacheStorageBytes = 0, + VideoProcessingUnitsCount = 0, + }; + + UsageGetResponse copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Assets/AssetListParamsTest.cs b/src/ImageKit.Tests/Models/Assets/AssetListParamsTest.cs new file mode 100644 index 00000000..9058639f --- /dev/null +++ b/src/ImageKit.Tests/Models/Assets/AssetListParamsTest.cs @@ -0,0 +1,340 @@ +using System; +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Exceptions; +using Assets = ImageKit.Models.Assets; + +namespace ImageKit.Tests.Models.Assets; + +public class AssetListParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new Assets::AssetListParams + { + FileType = Assets::FileType.All, + Limit = 1, + Path = "path", + SearchQuery = "searchQuery", + Skip = 0, + Sort = Assets::Sort.AscName, + Type = Assets::Type.File, + }; + + ApiEnum expectedFileType = Assets::FileType.All; + long expectedLimit = 1; + string expectedPath = "path"; + string expectedSearchQuery = "searchQuery"; + long expectedSkip = 0; + ApiEnum expectedSort = Assets::Sort.AscName; + ApiEnum expectedType = Assets::Type.File; + + Assert.Equal(expectedFileType, parameters.FileType); + Assert.Equal(expectedLimit, parameters.Limit); + Assert.Equal(expectedPath, parameters.Path); + Assert.Equal(expectedSearchQuery, parameters.SearchQuery); + Assert.Equal(expectedSkip, parameters.Skip); + Assert.Equal(expectedSort, parameters.Sort); + Assert.Equal(expectedType, parameters.Type); + } + + [Fact] + public void OptionalNonNullableParamsUnsetAreNotSet_Works() + { + var parameters = new Assets::AssetListParams { }; + + Assert.Null(parameters.FileType); + Assert.False(parameters.RawQueryData.ContainsKey("fileType")); + Assert.Null(parameters.Limit); + Assert.False(parameters.RawQueryData.ContainsKey("limit")); + Assert.Null(parameters.Path); + Assert.False(parameters.RawQueryData.ContainsKey("path")); + Assert.Null(parameters.SearchQuery); + Assert.False(parameters.RawQueryData.ContainsKey("searchQuery")); + Assert.Null(parameters.Skip); + Assert.False(parameters.RawQueryData.ContainsKey("skip")); + Assert.Null(parameters.Sort); + Assert.False(parameters.RawQueryData.ContainsKey("sort")); + Assert.Null(parameters.Type); + Assert.False(parameters.RawQueryData.ContainsKey("type")); + } + + [Fact] + public void OptionalNonNullableParamsSetToNullAreNotSet_Works() + { + var parameters = new Assets::AssetListParams + { + // Null should be interpreted as omitted for these properties + FileType = null, + Limit = null, + Path = null, + SearchQuery = null, + Skip = null, + Sort = null, + Type = null, + }; + + Assert.Null(parameters.FileType); + Assert.False(parameters.RawQueryData.ContainsKey("fileType")); + Assert.Null(parameters.Limit); + Assert.False(parameters.RawQueryData.ContainsKey("limit")); + Assert.Null(parameters.Path); + Assert.False(parameters.RawQueryData.ContainsKey("path")); + Assert.Null(parameters.SearchQuery); + Assert.False(parameters.RawQueryData.ContainsKey("searchQuery")); + Assert.Null(parameters.Skip); + Assert.False(parameters.RawQueryData.ContainsKey("skip")); + Assert.Null(parameters.Sort); + Assert.False(parameters.RawQueryData.ContainsKey("sort")); + Assert.Null(parameters.Type); + Assert.False(parameters.RawQueryData.ContainsKey("type")); + } + + [Fact] + public void Url_Works() + { + Assets::AssetListParams parameters = new() + { + FileType = Assets::FileType.All, + Limit = 1, + Path = "path", + SearchQuery = "searchQuery", + Skip = 0, + Sort = Assets::Sort.AscName, + Type = Assets::Type.File, + }; + + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + + Assert.Equal( + new Uri( + "https://api.imagekit.io/v1/files?fileType=all&limit=1&path=path&searchQuery=searchQuery&skip=0&sort=ASC_NAME&type=file" + ), + url + ); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new Assets::AssetListParams + { + FileType = Assets::FileType.All, + Limit = 1, + Path = "path", + SearchQuery = "searchQuery", + Skip = 0, + Sort = Assets::Sort.AscName, + Type = Assets::Type.File, + }; + + Assets::AssetListParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} + +public class FileTypeTest : TestBase +{ + [Theory] + [InlineData(Assets::FileType.All)] + [InlineData(Assets::FileType.Image)] + [InlineData(Assets::FileType.NonImage)] + public void Validation_Works(Assets::FileType rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(Assets::FileType.All)] + [InlineData(Assets::FileType.Image)] + [InlineData(Assets::FileType.NonImage)] + public void SerializationRoundtrip_Works(Assets::FileType rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class SortTest : TestBase +{ + [Theory] + [InlineData(Assets::Sort.AscName)] + [InlineData(Assets::Sort.DescName)] + [InlineData(Assets::Sort.AscCreated)] + [InlineData(Assets::Sort.DescCreated)] + [InlineData(Assets::Sort.AscUpdated)] + [InlineData(Assets::Sort.DescUpdated)] + [InlineData(Assets::Sort.AscHeight)] + [InlineData(Assets::Sort.DescHeight)] + [InlineData(Assets::Sort.AscWidth)] + [InlineData(Assets::Sort.DescWidth)] + [InlineData(Assets::Sort.AscSize)] + [InlineData(Assets::Sort.DescSize)] + [InlineData(Assets::Sort.AscRelevance)] + [InlineData(Assets::Sort.DescRelevance)] + public void Validation_Works(Assets::Sort rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(Assets::Sort.AscName)] + [InlineData(Assets::Sort.DescName)] + [InlineData(Assets::Sort.AscCreated)] + [InlineData(Assets::Sort.DescCreated)] + [InlineData(Assets::Sort.AscUpdated)] + [InlineData(Assets::Sort.DescUpdated)] + [InlineData(Assets::Sort.AscHeight)] + [InlineData(Assets::Sort.DescHeight)] + [InlineData(Assets::Sort.AscWidth)] + [InlineData(Assets::Sort.DescWidth)] + [InlineData(Assets::Sort.AscSize)] + [InlineData(Assets::Sort.DescSize)] + [InlineData(Assets::Sort.AscRelevance)] + [InlineData(Assets::Sort.DescRelevance)] + public void SerializationRoundtrip_Works(Assets::Sort rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class TypeTest : TestBase +{ + [Theory] + [InlineData(Assets::Type.File)] + [InlineData(Assets::Type.FileVersion)] + [InlineData(Assets::Type.Folder)] + [InlineData(Assets::Type.All)] + public void Validation_Works(Assets::Type rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(Assets::Type.File)] + [InlineData(Assets::Type.FileVersion)] + [InlineData(Assets::Type.Folder)] + [InlineData(Assets::Type.All)] + public void SerializationRoundtrip_Works(Assets::Type rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} diff --git a/src/ImageKit.Tests/Models/Assets/AssetListResponseTest.cs b/src/ImageKit.Tests/Models/Assets/AssetListResponseTest.cs new file mode 100644 index 00000000..54a0f19a --- /dev/null +++ b/src/ImageKit.Tests/Models/Assets/AssetListResponseTest.cs @@ -0,0 +1,175 @@ +using System; +using System.Collections.Generic; +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Models.Assets; +using Files = ImageKit.Models.Files; + +namespace ImageKit.Tests.Models.Assets; + +public class AssetListResponseTest : TestBase +{ + [Fact] + public void FileValidationWorks() + { + AssetListResponse value = new Files::File() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + Width = 0, + }; + value.Validate(); + } + + [Fact] + public void FolderValidationWorks() + { + AssetListResponse value = new Files::Folder() + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + FolderID = "folderId", + FolderPath = "folderPath", + Name = "name", + Type = Files::FolderType.Folder, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + value.Validate(); + } + + [Fact] + public void FileSerializationRoundtripWorks() + { + AssetListResponse value = new Files::File() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + Width = 0, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void FolderSerializationRoundtripWorks() + { + AssetListResponse value = new Files::Folder() + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + FolderID = "folderId", + FolderPath = "folderPath", + Name = "name", + Type = Files::FolderType.Folder, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} diff --git a/src/ImageKit.Tests/Models/BaseOverlayTest.cs b/src/ImageKit.Tests/Models/BaseOverlayTest.cs new file mode 100644 index 00000000..66b3f066 --- /dev/null +++ b/src/ImageKit.Tests/Models/BaseOverlayTest.cs @@ -0,0 +1,287 @@ +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Exceptions; +using ImageKit.Models; + +namespace ImageKit.Tests.Models; + +public class BaseOverlayTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new BaseOverlay + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + }; + + ApiEnum expectedLayerMode = LayerMode.Multiply; + OverlayPosition expectedPosition = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }; + OverlayTiming expectedTiming = new() + { + Duration = 0, + End = 0, + Start = 0, + }; + + Assert.Equal(expectedLayerMode, model.LayerMode); + Assert.Equal(expectedPosition, model.Position); + Assert.Equal(expectedTiming, model.Timing); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new BaseOverlay + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new BaseOverlay + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum expectedLayerMode = LayerMode.Multiply; + OverlayPosition expectedPosition = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }; + OverlayTiming expectedTiming = new() + { + Duration = 0, + End = 0, + Start = 0, + }; + + Assert.Equal(expectedLayerMode, deserialized.LayerMode); + Assert.Equal(expectedPosition, deserialized.Position); + Assert.Equal(expectedTiming, deserialized.Timing); + } + + [Fact] + public void Validation_Works() + { + var model = new BaseOverlay + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new BaseOverlay { }; + + Assert.Null(model.LayerMode); + Assert.False(model.RawData.ContainsKey("layerMode")); + Assert.Null(model.Position); + Assert.False(model.RawData.ContainsKey("position")); + Assert.Null(model.Timing); + Assert.False(model.RawData.ContainsKey("timing")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new BaseOverlay { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new BaseOverlay + { + // Null should be interpreted as omitted for these properties + LayerMode = null, + Position = null, + Timing = null, + }; + + Assert.Null(model.LayerMode); + Assert.False(model.RawData.ContainsKey("layerMode")); + Assert.Null(model.Position); + Assert.False(model.RawData.ContainsKey("position")); + Assert.Null(model.Timing); + Assert.False(model.RawData.ContainsKey("timing")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new BaseOverlay + { + // Null should be interpreted as omitted for these properties + LayerMode = null, + Position = null, + Timing = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BaseOverlay + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + }; + + BaseOverlay copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class LayerModeTest : TestBase +{ + [Theory] + [InlineData(LayerMode.Multiply)] + [InlineData(LayerMode.Cutter)] + [InlineData(LayerMode.Cutout)] + [InlineData(LayerMode.Displace)] + public void Validation_Works(LayerMode rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(LayerMode.Multiply)] + [InlineData(LayerMode.Cutter)] + [InlineData(LayerMode.Cutout)] + [InlineData(LayerMode.Displace)] + public void SerializationRoundtrip_Works(LayerMode rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} diff --git a/src/ImageKit.Tests/Models/Beta/V2/Files/FileUploadParamsTest.cs b/src/ImageKit.Tests/Models/Beta/V2/Files/FileUploadParamsTest.cs new file mode 100644 index 00000000..b9288e4f --- /dev/null +++ b/src/ImageKit.Tests/Models/Beta/V2/Files/FileUploadParamsTest.cs @@ -0,0 +1,854 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Exceptions; +using ImageKit.Models.Beta.V2.Files; + +namespace ImageKit.Tests.Models.Beta.V2.Files; + +public class FileUploadParamsTest : TestBase +{ + [Fact] + public void OptionalNonNullableParamsUnsetAreNotSet_Works() + { + var parameters = new FileUploadParams + { + File = Encoding.UTF8.GetBytes("text"), + FileName = "fileName", + }; + + Assert.Null(parameters.Token); + Assert.False(parameters.RawBodyData.ContainsKey("token")); + Assert.Null(parameters.Checks); + Assert.False(parameters.RawBodyData.ContainsKey("checks")); + Assert.Null(parameters.CustomCoordinates); + Assert.False(parameters.RawBodyData.ContainsKey("customCoordinates")); + Assert.Null(parameters.CustomMetadata); + Assert.False(parameters.RawBodyData.ContainsKey("customMetadata")); + Assert.Null(parameters.Description); + Assert.False(parameters.RawBodyData.ContainsKey("description")); + Assert.Null(parameters.Extensions); + Assert.False(parameters.RawBodyData.ContainsKey("extensions")); + Assert.Null(parameters.Folder); + Assert.False(parameters.RawBodyData.ContainsKey("folder")); + Assert.Null(parameters.IsPrivateFile); + Assert.False(parameters.RawBodyData.ContainsKey("isPrivateFile")); + Assert.Null(parameters.IsPublished); + Assert.False(parameters.RawBodyData.ContainsKey("isPublished")); + Assert.Null(parameters.OverwriteAITags); + Assert.False(parameters.RawBodyData.ContainsKey("overwriteAITags")); + Assert.Null(parameters.OverwriteCustomMetadata); + Assert.False(parameters.RawBodyData.ContainsKey("overwriteCustomMetadata")); + Assert.Null(parameters.OverwriteFile); + Assert.False(parameters.RawBodyData.ContainsKey("overwriteFile")); + Assert.Null(parameters.OverwriteTags); + Assert.False(parameters.RawBodyData.ContainsKey("overwriteTags")); + Assert.Null(parameters.ResponseFields); + Assert.False(parameters.RawBodyData.ContainsKey("responseFields")); + Assert.Null(parameters.Tags); + Assert.False(parameters.RawBodyData.ContainsKey("tags")); + Assert.Null(parameters.Transformation); + Assert.False(parameters.RawBodyData.ContainsKey("transformation")); + Assert.Null(parameters.UseUniqueFileName); + Assert.False(parameters.RawBodyData.ContainsKey("useUniqueFileName")); + Assert.Null(parameters.WebhookUrl); + Assert.False(parameters.RawBodyData.ContainsKey("webhookUrl")); + } + + [Fact] + public void OptionalNonNullableParamsSetToNullAreNotSet_Works() + { + var parameters = new FileUploadParams + { + File = Encoding.UTF8.GetBytes("text"), + FileName = "fileName", + + // Null should be interpreted as omitted for these properties + Token = null, + Checks = null, + CustomCoordinates = null, + CustomMetadata = null, + Description = null, + Extensions = null, + Folder = null, + IsPrivateFile = null, + IsPublished = null, + OverwriteAITags = null, + OverwriteCustomMetadata = null, + OverwriteFile = null, + OverwriteTags = null, + ResponseFields = null, + Tags = null, + Transformation = null, + UseUniqueFileName = null, + WebhookUrl = null, + }; + + Assert.Null(parameters.Token); + Assert.False(parameters.RawBodyData.ContainsKey("token")); + Assert.Null(parameters.Checks); + Assert.False(parameters.RawBodyData.ContainsKey("checks")); + Assert.Null(parameters.CustomCoordinates); + Assert.False(parameters.RawBodyData.ContainsKey("customCoordinates")); + Assert.Null(parameters.CustomMetadata); + Assert.False(parameters.RawBodyData.ContainsKey("customMetadata")); + Assert.Null(parameters.Description); + Assert.False(parameters.RawBodyData.ContainsKey("description")); + Assert.Null(parameters.Extensions); + Assert.False(parameters.RawBodyData.ContainsKey("extensions")); + Assert.Null(parameters.Folder); + Assert.False(parameters.RawBodyData.ContainsKey("folder")); + Assert.Null(parameters.IsPrivateFile); + Assert.False(parameters.RawBodyData.ContainsKey("isPrivateFile")); + Assert.Null(parameters.IsPublished); + Assert.False(parameters.RawBodyData.ContainsKey("isPublished")); + Assert.Null(parameters.OverwriteAITags); + Assert.False(parameters.RawBodyData.ContainsKey("overwriteAITags")); + Assert.Null(parameters.OverwriteCustomMetadata); + Assert.False(parameters.RawBodyData.ContainsKey("overwriteCustomMetadata")); + Assert.Null(parameters.OverwriteFile); + Assert.False(parameters.RawBodyData.ContainsKey("overwriteFile")); + Assert.Null(parameters.OverwriteTags); + Assert.False(parameters.RawBodyData.ContainsKey("overwriteTags")); + Assert.Null(parameters.ResponseFields); + Assert.False(parameters.RawBodyData.ContainsKey("responseFields")); + Assert.Null(parameters.Tags); + Assert.False(parameters.RawBodyData.ContainsKey("tags")); + Assert.Null(parameters.Transformation); + Assert.False(parameters.RawBodyData.ContainsKey("transformation")); + Assert.Null(parameters.UseUniqueFileName); + Assert.False(parameters.RawBodyData.ContainsKey("useUniqueFileName")); + Assert.Null(parameters.WebhookUrl); + Assert.False(parameters.RawBodyData.ContainsKey("webhookUrl")); + } + + [Fact] + public void Url_Works() + { + FileUploadParams parameters = new() + { + File = Encoding.UTF8.GetBytes("text"), + FileName = "fileName", + }; + + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + + Assert.Equal(new Uri("https://api.imagekit.io/api/v2/files/upload"), url); + } +} + +public class ResponseFieldTest : TestBase +{ + [Theory] + [InlineData(ResponseField.Tags)] + [InlineData(ResponseField.CustomCoordinates)] + [InlineData(ResponseField.IsPrivateFile)] + [InlineData(ResponseField.EmbeddedMetadata)] + [InlineData(ResponseField.IsPublished)] + [InlineData(ResponseField.CustomMetadata)] + [InlineData(ResponseField.Metadata)] + [InlineData(ResponseField.SelectedFieldsSchema)] + public void Validation_Works(ResponseField rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(ResponseField.Tags)] + [InlineData(ResponseField.CustomCoordinates)] + [InlineData(ResponseField.IsPrivateFile)] + [InlineData(ResponseField.EmbeddedMetadata)] + [InlineData(ResponseField.IsPublished)] + [InlineData(ResponseField.CustomMetadata)] + [InlineData(ResponseField.Metadata)] + [InlineData(ResponseField.SelectedFieldsSchema)] + public void SerializationRoundtrip_Works(ResponseField rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class TransformationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Transformation + { + Post = + [ + new Thumbnail() { Value = "w-150,h-150" }, + new Abs() { Protocol = Protocol.Dash, Value = "sr-240_360_480_720_1080" }, + ], + Pre = "w-300,h-300,q-80", + }; + + List expectedPost = + [ + new Thumbnail() { Value = "w-150,h-150" }, + new Abs() { Protocol = Protocol.Dash, Value = "sr-240_360_480_720_1080" }, + ]; + string expectedPre = "w-300,h-300,q-80"; + + Assert.NotNull(model.Post); + Assert.Equal(expectedPost.Count, model.Post.Count); + for (int i = 0; i < expectedPost.Count; i++) + { + Assert.Equal(expectedPost[i], model.Post[i]); + } + Assert.Equal(expectedPre, model.Pre); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Transformation + { + Post = + [ + new Thumbnail() { Value = "w-150,h-150" }, + new Abs() { Protocol = Protocol.Dash, Value = "sr-240_360_480_720_1080" }, + ], + Pre = "w-300,h-300,q-80", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Transformation + { + Post = + [ + new Thumbnail() { Value = "w-150,h-150" }, + new Abs() { Protocol = Protocol.Dash, Value = "sr-240_360_480_720_1080" }, + ], + Pre = "w-300,h-300,q-80", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedPost = + [ + new Thumbnail() { Value = "w-150,h-150" }, + new Abs() { Protocol = Protocol.Dash, Value = "sr-240_360_480_720_1080" }, + ]; + string expectedPre = "w-300,h-300,q-80"; + + Assert.NotNull(deserialized.Post); + Assert.Equal(expectedPost.Count, deserialized.Post.Count); + for (int i = 0; i < expectedPost.Count; i++) + { + Assert.Equal(expectedPost[i], deserialized.Post[i]); + } + Assert.Equal(expectedPre, deserialized.Pre); + } + + [Fact] + public void Validation_Works() + { + var model = new Transformation + { + Post = + [ + new Thumbnail() { Value = "w-150,h-150" }, + new Abs() { Protocol = Protocol.Dash, Value = "sr-240_360_480_720_1080" }, + ], + Pre = "w-300,h-300,q-80", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Transformation { }; + + Assert.Null(model.Post); + Assert.False(model.RawData.ContainsKey("post")); + Assert.Null(model.Pre); + Assert.False(model.RawData.ContainsKey("pre")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new Transformation { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new Transformation + { + // Null should be interpreted as omitted for these properties + Post = null, + Pre = null, + }; + + Assert.Null(model.Post); + Assert.False(model.RawData.ContainsKey("post")); + Assert.Null(model.Pre); + Assert.False(model.RawData.ContainsKey("pre")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new Transformation + { + // Null should be interpreted as omitted for these properties + Post = null, + Pre = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Transformation + { + Post = + [ + new Thumbnail() { Value = "w-150,h-150" }, + new Abs() { Protocol = Protocol.Dash, Value = "sr-240_360_480_720_1080" }, + ], + Pre = "w-300,h-300,q-80", + }; + + Transformation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PostTest : TestBase +{ + [Fact] + public void TransformationValidationWorks() + { + Post value = new PostTransformation("w-400,h-400,q-70"); + value.Validate(); + } + + [Fact] + public void GifToVideoValidationWorks() + { + Post value = new GifToVideo() { Value = "q-90" }; + value.Validate(); + } + + [Fact] + public void ThumbnailValidationWorks() + { + Post value = new Thumbnail() { Value = "w-150,h-150" }; + value.Validate(); + } + + [Fact] + public void AbsValidationWorks() + { + Post value = new Abs() { Protocol = Protocol.Hls, Value = "sr-240_360_480_720_1080" }; + value.Validate(); + } + + [Fact] + public void TransformationSerializationRoundtripWorks() + { + Post value = new PostTransformation("w-400,h-400,q-70"); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void GifToVideoSerializationRoundtripWorks() + { + Post value = new GifToVideo() { Value = "q-90" }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void ThumbnailSerializationRoundtripWorks() + { + Post value = new Thumbnail() { Value = "w-150,h-150" }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void AbsSerializationRoundtripWorks() + { + Post value = new Abs() { Protocol = Protocol.Hls, Value = "sr-240_360_480_720_1080" }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class PostTransformationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PostTransformation { Value = "w-400,h-400,q-70" }; + + JsonElement expectedType = JsonSerializer.SerializeToElement("transformation"); + string expectedValue = "w-400,h-400,q-70"; + + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + Assert.Equal(expectedValue, model.Value); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new PostTransformation { Value = "w-400,h-400,q-70" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new PostTransformation { Value = "w-400,h-400,q-70" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + JsonElement expectedType = JsonSerializer.SerializeToElement("transformation"); + string expectedValue = "w-400,h-400,q-70"; + + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + Assert.Equal(expectedValue, deserialized.Value); + } + + [Fact] + public void Validation_Works() + { + var model = new PostTransformation { Value = "w-400,h-400,q-70" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PostTransformation { Value = "w-400,h-400,q-70" }; + + PostTransformation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GifToVideoTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GifToVideo { Value = "q-90" }; + + JsonElement expectedType = JsonSerializer.SerializeToElement("gif-to-video"); + string expectedValue = "q-90"; + + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + Assert.Equal(expectedValue, model.Value); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new GifToVideo { Value = "q-90" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new GifToVideo { Value = "q-90" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + JsonElement expectedType = JsonSerializer.SerializeToElement("gif-to-video"); + string expectedValue = "q-90"; + + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + Assert.Equal(expectedValue, deserialized.Value); + } + + [Fact] + public void Validation_Works() + { + var model = new GifToVideo { Value = "q-90" }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new GifToVideo { }; + + Assert.Null(model.Value); + Assert.False(model.RawData.ContainsKey("value")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new GifToVideo { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new GifToVideo + { + // Null should be interpreted as omitted for these properties + Value = null, + }; + + Assert.Null(model.Value); + Assert.False(model.RawData.ContainsKey("value")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new GifToVideo + { + // Null should be interpreted as omitted for these properties + Value = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GifToVideo { Value = "q-90" }; + + GifToVideo copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ThumbnailTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Thumbnail { Value = "w-150,h-150" }; + + JsonElement expectedType = JsonSerializer.SerializeToElement("thumbnail"); + string expectedValue = "w-150,h-150"; + + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + Assert.Equal(expectedValue, model.Value); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Thumbnail { Value = "w-150,h-150" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Thumbnail { Value = "w-150,h-150" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + JsonElement expectedType = JsonSerializer.SerializeToElement("thumbnail"); + string expectedValue = "w-150,h-150"; + + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + Assert.Equal(expectedValue, deserialized.Value); + } + + [Fact] + public void Validation_Works() + { + var model = new Thumbnail { Value = "w-150,h-150" }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Thumbnail { }; + + Assert.Null(model.Value); + Assert.False(model.RawData.ContainsKey("value")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new Thumbnail { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new Thumbnail + { + // Null should be interpreted as omitted for these properties + Value = null, + }; + + Assert.Null(model.Value); + Assert.False(model.RawData.ContainsKey("value")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new Thumbnail + { + // Null should be interpreted as omitted for these properties + Value = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Thumbnail { Value = "w-150,h-150" }; + + Thumbnail copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class AbsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Abs { Protocol = Protocol.Hls, Value = "sr-240_360_480_720_1080" }; + + ApiEnum expectedProtocol = Protocol.Hls; + JsonElement expectedType = JsonSerializer.SerializeToElement("abs"); + string expectedValue = "sr-240_360_480_720_1080"; + + Assert.Equal(expectedProtocol, model.Protocol); + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + Assert.Equal(expectedValue, model.Value); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Abs { Protocol = Protocol.Hls, Value = "sr-240_360_480_720_1080" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Abs { Protocol = Protocol.Hls, Value = "sr-240_360_480_720_1080" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + Assert.NotNull(deserialized); + + ApiEnum expectedProtocol = Protocol.Hls; + JsonElement expectedType = JsonSerializer.SerializeToElement("abs"); + string expectedValue = "sr-240_360_480_720_1080"; + + Assert.Equal(expectedProtocol, deserialized.Protocol); + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + Assert.Equal(expectedValue, deserialized.Value); + } + + [Fact] + public void Validation_Works() + { + var model = new Abs { Protocol = Protocol.Hls, Value = "sr-240_360_480_720_1080" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Abs { Protocol = Protocol.Hls, Value = "sr-240_360_480_720_1080" }; + + Abs copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ProtocolTest : TestBase +{ + [Theory] + [InlineData(Protocol.Hls)] + [InlineData(Protocol.Dash)] + public void Validation_Works(Protocol rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(Protocol.Hls)] + [InlineData(Protocol.Dash)] + public void SerializationRoundtrip_Works(Protocol rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} diff --git a/src/ImageKit.Tests/Models/Beta/V2/Files/FileUploadResponseTest.cs b/src/ImageKit.Tests/Models/Beta/V2/Files/FileUploadResponseTest.cs new file mode 100644 index 00000000..306aee8e --- /dev/null +++ b/src/ImageKit.Tests/Models/Beta/V2/Files/FileUploadResponseTest.cs @@ -0,0 +1,3377 @@ +using System.Collections.Generic; +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Exceptions; +using ImageKit.Models.Beta.V2.Files; +using Files = ImageKit.Models.Files; + +namespace ImageKit.Tests.Models.Beta.V2.Files; + +public class FileUploadResponseTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new FileUploadResponse + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ExtensionStatus = new() + { + AIAutoDescription = AIAutoDescription.Success, + AITasks = AITasks.Success, + AwsAutoTagging = AwsAutoTagging.Success, + GoogleAutoTagging = GoogleAutoTagging.Success, + RemoveBg = RemoveBg.Success, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Metadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }, + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + ThumbnailUrl = "thumbnailUrl", + Url = "url", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }; + + List expectedAITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ]; + string expectedAudioCodec = "audioCodec"; + long expectedBitRate = 0; + string expectedCustomCoordinates = "customCoordinates"; + Dictionary expectedCustomMetadata = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; + string expectedDescription = "description"; + long expectedDuration = 0; + Dictionary expectedEmbeddedMetadata = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; + ExtensionStatus expectedExtensionStatus = new() + { + AIAutoDescription = AIAutoDescription.Success, + AITasks = AITasks.Success, + AwsAutoTagging = AwsAutoTagging.Success, + GoogleAutoTagging = GoogleAutoTagging.Success, + RemoveBg = RemoveBg.Success, + }; + string expectedFileID = "fileId"; + string expectedFilePath = "filePath"; + string expectedFileType = "fileType"; + double expectedHeight = 0; + bool expectedIsPrivateFile = true; + bool expectedIsPublished = true; + Files::FileMetadata expectedMetadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }; + string expectedName = "name"; + Dictionary expectedSelectedFieldsSchema = new() + { + { + "foo", + new() + { + Type = Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }; + double expectedSize = 0; + List expectedTags = ["string"]; + string expectedThumbnailUrl = "thumbnailUrl"; + string expectedUrl = "url"; + VersionInfo expectedVersionInfo = new() { ID = "id", Name = "name" }; + string expectedVideoCodec = "videoCodec"; + double expectedWidth = 0; + + Assert.NotNull(model.AITags); + Assert.Equal(expectedAITags.Count, model.AITags.Count); + for (int i = 0; i < expectedAITags.Count; i++) + { + Assert.Equal(expectedAITags[i], model.AITags[i]); + } + Assert.Equal(expectedAudioCodec, model.AudioCodec); + Assert.Equal(expectedBitRate, model.BitRate); + Assert.Equal(expectedCustomCoordinates, model.CustomCoordinates); + Assert.NotNull(model.CustomMetadata); + Assert.Equal(expectedCustomMetadata.Count, model.CustomMetadata.Count); + foreach (var item in expectedCustomMetadata) + { + Assert.True(model.CustomMetadata.TryGetValue(item.Key, out var value)); + + Assert.True(JsonElement.DeepEquals(value, model.CustomMetadata[item.Key])); + } + Assert.Equal(expectedDescription, model.Description); + Assert.Equal(expectedDuration, model.Duration); + Assert.NotNull(model.EmbeddedMetadata); + Assert.Equal(expectedEmbeddedMetadata.Count, model.EmbeddedMetadata.Count); + foreach (var item in expectedEmbeddedMetadata) + { + Assert.True(model.EmbeddedMetadata.TryGetValue(item.Key, out var value)); + + Assert.True(JsonElement.DeepEquals(value, model.EmbeddedMetadata[item.Key])); + } + Assert.Equal(expectedExtensionStatus, model.ExtensionStatus); + Assert.Equal(expectedFileID, model.FileID); + Assert.Equal(expectedFilePath, model.FilePath); + Assert.Equal(expectedFileType, model.FileType); + Assert.Equal(expectedHeight, model.Height); + Assert.Equal(expectedIsPrivateFile, model.IsPrivateFile); + Assert.Equal(expectedIsPublished, model.IsPublished); + Assert.Equal(expectedMetadata, model.Metadata); + Assert.Equal(expectedName, model.Name); + Assert.NotNull(model.SelectedFieldsSchema); + Assert.Equal(expectedSelectedFieldsSchema.Count, model.SelectedFieldsSchema.Count); + foreach (var item in expectedSelectedFieldsSchema) + { + Assert.True(model.SelectedFieldsSchema.TryGetValue(item.Key, out var value)); + + Assert.Equal(value, model.SelectedFieldsSchema[item.Key]); + } + Assert.Equal(expectedSize, model.Size); + Assert.NotNull(model.Tags); + Assert.Equal(expectedTags.Count, model.Tags.Count); + for (int i = 0; i < expectedTags.Count; i++) + { + Assert.Equal(expectedTags[i], model.Tags[i]); + } + Assert.Equal(expectedThumbnailUrl, model.ThumbnailUrl); + Assert.Equal(expectedUrl, model.Url); + Assert.Equal(expectedVersionInfo, model.VersionInfo); + Assert.Equal(expectedVideoCodec, model.VideoCodec); + Assert.Equal(expectedWidth, model.Width); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new FileUploadResponse + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ExtensionStatus = new() + { + AIAutoDescription = AIAutoDescription.Success, + AITasks = AITasks.Success, + AwsAutoTagging = AwsAutoTagging.Success, + GoogleAutoTagging = GoogleAutoTagging.Success, + RemoveBg = RemoveBg.Success, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Metadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }, + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + ThumbnailUrl = "thumbnailUrl", + Url = "url", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new FileUploadResponse + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ExtensionStatus = new() + { + AIAutoDescription = AIAutoDescription.Success, + AITasks = AITasks.Success, + AwsAutoTagging = AwsAutoTagging.Success, + GoogleAutoTagging = GoogleAutoTagging.Success, + RemoveBg = RemoveBg.Success, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Metadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }, + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + ThumbnailUrl = "thumbnailUrl", + Url = "url", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedAITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ]; + string expectedAudioCodec = "audioCodec"; + long expectedBitRate = 0; + string expectedCustomCoordinates = "customCoordinates"; + Dictionary expectedCustomMetadata = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; + string expectedDescription = "description"; + long expectedDuration = 0; + Dictionary expectedEmbeddedMetadata = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; + ExtensionStatus expectedExtensionStatus = new() + { + AIAutoDescription = AIAutoDescription.Success, + AITasks = AITasks.Success, + AwsAutoTagging = AwsAutoTagging.Success, + GoogleAutoTagging = GoogleAutoTagging.Success, + RemoveBg = RemoveBg.Success, + }; + string expectedFileID = "fileId"; + string expectedFilePath = "filePath"; + string expectedFileType = "fileType"; + double expectedHeight = 0; + bool expectedIsPrivateFile = true; + bool expectedIsPublished = true; + Files::FileMetadata expectedMetadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }; + string expectedName = "name"; + Dictionary expectedSelectedFieldsSchema = new() + { + { + "foo", + new() + { + Type = Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }; + double expectedSize = 0; + List expectedTags = ["string"]; + string expectedThumbnailUrl = "thumbnailUrl"; + string expectedUrl = "url"; + VersionInfo expectedVersionInfo = new() { ID = "id", Name = "name" }; + string expectedVideoCodec = "videoCodec"; + double expectedWidth = 0; + + Assert.NotNull(deserialized.AITags); + Assert.Equal(expectedAITags.Count, deserialized.AITags.Count); + for (int i = 0; i < expectedAITags.Count; i++) + { + Assert.Equal(expectedAITags[i], deserialized.AITags[i]); + } + Assert.Equal(expectedAudioCodec, deserialized.AudioCodec); + Assert.Equal(expectedBitRate, deserialized.BitRate); + Assert.Equal(expectedCustomCoordinates, deserialized.CustomCoordinates); + Assert.NotNull(deserialized.CustomMetadata); + Assert.Equal(expectedCustomMetadata.Count, deserialized.CustomMetadata.Count); + foreach (var item in expectedCustomMetadata) + { + Assert.True(deserialized.CustomMetadata.TryGetValue(item.Key, out var value)); + + Assert.True(JsonElement.DeepEquals(value, deserialized.CustomMetadata[item.Key])); + } + Assert.Equal(expectedDescription, deserialized.Description); + Assert.Equal(expectedDuration, deserialized.Duration); + Assert.NotNull(deserialized.EmbeddedMetadata); + Assert.Equal(expectedEmbeddedMetadata.Count, deserialized.EmbeddedMetadata.Count); + foreach (var item in expectedEmbeddedMetadata) + { + Assert.True(deserialized.EmbeddedMetadata.TryGetValue(item.Key, out var value)); + + Assert.True(JsonElement.DeepEquals(value, deserialized.EmbeddedMetadata[item.Key])); + } + Assert.Equal(expectedExtensionStatus, deserialized.ExtensionStatus); + Assert.Equal(expectedFileID, deserialized.FileID); + Assert.Equal(expectedFilePath, deserialized.FilePath); + Assert.Equal(expectedFileType, deserialized.FileType); + Assert.Equal(expectedHeight, deserialized.Height); + Assert.Equal(expectedIsPrivateFile, deserialized.IsPrivateFile); + Assert.Equal(expectedIsPublished, deserialized.IsPublished); + Assert.Equal(expectedMetadata, deserialized.Metadata); + Assert.Equal(expectedName, deserialized.Name); + Assert.NotNull(deserialized.SelectedFieldsSchema); + Assert.Equal(expectedSelectedFieldsSchema.Count, deserialized.SelectedFieldsSchema.Count); + foreach (var item in expectedSelectedFieldsSchema) + { + Assert.True(deserialized.SelectedFieldsSchema.TryGetValue(item.Key, out var value)); + + Assert.Equal(value, deserialized.SelectedFieldsSchema[item.Key]); + } + Assert.Equal(expectedSize, deserialized.Size); + Assert.NotNull(deserialized.Tags); + Assert.Equal(expectedTags.Count, deserialized.Tags.Count); + for (int i = 0; i < expectedTags.Count; i++) + { + Assert.Equal(expectedTags[i], deserialized.Tags[i]); + } + Assert.Equal(expectedThumbnailUrl, deserialized.ThumbnailUrl); + Assert.Equal(expectedUrl, deserialized.Url); + Assert.Equal(expectedVersionInfo, deserialized.VersionInfo); + Assert.Equal(expectedVideoCodec, deserialized.VideoCodec); + Assert.Equal(expectedWidth, deserialized.Width); + } + + [Fact] + public void Validation_Works() + { + var model = new FileUploadResponse + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ExtensionStatus = new() + { + AIAutoDescription = AIAutoDescription.Success, + AITasks = AITasks.Success, + AwsAutoTagging = AwsAutoTagging.Success, + GoogleAutoTagging = GoogleAutoTagging.Success, + RemoveBg = RemoveBg.Success, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Metadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }, + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + ThumbnailUrl = "thumbnailUrl", + Url = "url", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new FileUploadResponse + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + CustomCoordinates = "customCoordinates", + Tags = ["string"], + }; + + Assert.Null(model.AudioCodec); + Assert.False(model.RawData.ContainsKey("audioCodec")); + Assert.Null(model.BitRate); + Assert.False(model.RawData.ContainsKey("bitRate")); + Assert.Null(model.CustomMetadata); + Assert.False(model.RawData.ContainsKey("customMetadata")); + Assert.Null(model.Description); + Assert.False(model.RawData.ContainsKey("description")); + Assert.Null(model.Duration); + Assert.False(model.RawData.ContainsKey("duration")); + Assert.Null(model.EmbeddedMetadata); + Assert.False(model.RawData.ContainsKey("embeddedMetadata")); + Assert.Null(model.ExtensionStatus); + Assert.False(model.RawData.ContainsKey("extensionStatus")); + Assert.Null(model.FileID); + Assert.False(model.RawData.ContainsKey("fileId")); + Assert.Null(model.FilePath); + Assert.False(model.RawData.ContainsKey("filePath")); + Assert.Null(model.FileType); + Assert.False(model.RawData.ContainsKey("fileType")); + Assert.Null(model.Height); + Assert.False(model.RawData.ContainsKey("height")); + Assert.Null(model.IsPrivateFile); + Assert.False(model.RawData.ContainsKey("isPrivateFile")); + Assert.Null(model.IsPublished); + Assert.False(model.RawData.ContainsKey("isPublished")); + Assert.Null(model.Metadata); + Assert.False(model.RawData.ContainsKey("metadata")); + Assert.Null(model.Name); + Assert.False(model.RawData.ContainsKey("name")); + Assert.Null(model.SelectedFieldsSchema); + Assert.False(model.RawData.ContainsKey("selectedFieldsSchema")); + Assert.Null(model.Size); + Assert.False(model.RawData.ContainsKey("size")); + Assert.Null(model.ThumbnailUrl); + Assert.False(model.RawData.ContainsKey("thumbnailUrl")); + Assert.Null(model.Url); + Assert.False(model.RawData.ContainsKey("url")); + Assert.Null(model.VersionInfo); + Assert.False(model.RawData.ContainsKey("versionInfo")); + Assert.Null(model.VideoCodec); + Assert.False(model.RawData.ContainsKey("videoCodec")); + Assert.Null(model.Width); + Assert.False(model.RawData.ContainsKey("width")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new FileUploadResponse + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + CustomCoordinates = "customCoordinates", + Tags = ["string"], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new FileUploadResponse + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + CustomCoordinates = "customCoordinates", + Tags = ["string"], + + // Null should be interpreted as omitted for these properties + AudioCodec = null, + BitRate = null, + CustomMetadata = null, + Description = null, + Duration = null, + EmbeddedMetadata = null, + ExtensionStatus = null, + FileID = null, + FilePath = null, + FileType = null, + Height = null, + IsPrivateFile = null, + IsPublished = null, + Metadata = null, + Name = null, + SelectedFieldsSchema = null, + Size = null, + ThumbnailUrl = null, + Url = null, + VersionInfo = null, + VideoCodec = null, + Width = null, + }; + + Assert.Null(model.AudioCodec); + Assert.False(model.RawData.ContainsKey("audioCodec")); + Assert.Null(model.BitRate); + Assert.False(model.RawData.ContainsKey("bitRate")); + Assert.Null(model.CustomMetadata); + Assert.False(model.RawData.ContainsKey("customMetadata")); + Assert.Null(model.Description); + Assert.False(model.RawData.ContainsKey("description")); + Assert.Null(model.Duration); + Assert.False(model.RawData.ContainsKey("duration")); + Assert.Null(model.EmbeddedMetadata); + Assert.False(model.RawData.ContainsKey("embeddedMetadata")); + Assert.Null(model.ExtensionStatus); + Assert.False(model.RawData.ContainsKey("extensionStatus")); + Assert.Null(model.FileID); + Assert.False(model.RawData.ContainsKey("fileId")); + Assert.Null(model.FilePath); + Assert.False(model.RawData.ContainsKey("filePath")); + Assert.Null(model.FileType); + Assert.False(model.RawData.ContainsKey("fileType")); + Assert.Null(model.Height); + Assert.False(model.RawData.ContainsKey("height")); + Assert.Null(model.IsPrivateFile); + Assert.False(model.RawData.ContainsKey("isPrivateFile")); + Assert.Null(model.IsPublished); + Assert.False(model.RawData.ContainsKey("isPublished")); + Assert.Null(model.Metadata); + Assert.False(model.RawData.ContainsKey("metadata")); + Assert.Null(model.Name); + Assert.False(model.RawData.ContainsKey("name")); + Assert.Null(model.SelectedFieldsSchema); + Assert.False(model.RawData.ContainsKey("selectedFieldsSchema")); + Assert.Null(model.Size); + Assert.False(model.RawData.ContainsKey("size")); + Assert.Null(model.ThumbnailUrl); + Assert.False(model.RawData.ContainsKey("thumbnailUrl")); + Assert.Null(model.Url); + Assert.False(model.RawData.ContainsKey("url")); + Assert.Null(model.VersionInfo); + Assert.False(model.RawData.ContainsKey("versionInfo")); + Assert.Null(model.VideoCodec); + Assert.False(model.RawData.ContainsKey("videoCodec")); + Assert.Null(model.Width); + Assert.False(model.RawData.ContainsKey("width")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new FileUploadResponse + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + CustomCoordinates = "customCoordinates", + Tags = ["string"], + + // Null should be interpreted as omitted for these properties + AudioCodec = null, + BitRate = null, + CustomMetadata = null, + Description = null, + Duration = null, + EmbeddedMetadata = null, + ExtensionStatus = null, + FileID = null, + FilePath = null, + FileType = null, + Height = null, + IsPrivateFile = null, + IsPublished = null, + Metadata = null, + Name = null, + SelectedFieldsSchema = null, + Size = null, + ThumbnailUrl = null, + Url = null, + VersionInfo = null, + VideoCodec = null, + Width = null, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new FileUploadResponse + { + AudioCodec = "audioCodec", + BitRate = 0, + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ExtensionStatus = new() + { + AIAutoDescription = AIAutoDescription.Success, + AITasks = AITasks.Success, + AwsAutoTagging = AwsAutoTagging.Success, + GoogleAutoTagging = GoogleAutoTagging.Success, + RemoveBg = RemoveBg.Success, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Metadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }, + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + ThumbnailUrl = "thumbnailUrl", + Url = "url", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }; + + Assert.Null(model.AITags); + Assert.False(model.RawData.ContainsKey("AITags")); + Assert.Null(model.CustomCoordinates); + Assert.False(model.RawData.ContainsKey("customCoordinates")); + Assert.Null(model.Tags); + Assert.False(model.RawData.ContainsKey("tags")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new FileUploadResponse + { + AudioCodec = "audioCodec", + BitRate = 0, + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ExtensionStatus = new() + { + AIAutoDescription = AIAutoDescription.Success, + AITasks = AITasks.Success, + AwsAutoTagging = AwsAutoTagging.Success, + GoogleAutoTagging = GoogleAutoTagging.Success, + RemoveBg = RemoveBg.Success, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Metadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }, + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + ThumbnailUrl = "thumbnailUrl", + Url = "url", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new FileUploadResponse + { + AudioCodec = "audioCodec", + BitRate = 0, + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ExtensionStatus = new() + { + AIAutoDescription = AIAutoDescription.Success, + AITasks = AITasks.Success, + AwsAutoTagging = AwsAutoTagging.Success, + GoogleAutoTagging = GoogleAutoTagging.Success, + RemoveBg = RemoveBg.Success, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Metadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }, + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + ThumbnailUrl = "thumbnailUrl", + Url = "url", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + + AITags = null, + CustomCoordinates = null, + Tags = null, + }; + + Assert.Null(model.AITags); + Assert.True(model.RawData.ContainsKey("AITags")); + Assert.Null(model.CustomCoordinates); + Assert.True(model.RawData.ContainsKey("customCoordinates")); + Assert.Null(model.Tags); + Assert.True(model.RawData.ContainsKey("tags")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new FileUploadResponse + { + AudioCodec = "audioCodec", + BitRate = 0, + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ExtensionStatus = new() + { + AIAutoDescription = AIAutoDescription.Success, + AITasks = AITasks.Success, + AwsAutoTagging = AwsAutoTagging.Success, + GoogleAutoTagging = GoogleAutoTagging.Success, + RemoveBg = RemoveBg.Success, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Metadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }, + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + ThumbnailUrl = "thumbnailUrl", + Url = "url", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + + AITags = null, + CustomCoordinates = null, + Tags = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new FileUploadResponse + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ExtensionStatus = new() + { + AIAutoDescription = AIAutoDescription.Success, + AITasks = AITasks.Success, + AwsAutoTagging = AwsAutoTagging.Success, + GoogleAutoTagging = GoogleAutoTagging.Success, + RemoveBg = RemoveBg.Success, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Metadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }, + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + ThumbnailUrl = "thumbnailUrl", + Url = "url", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }; + + FileUploadResponse copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class AITagTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new AITag + { + Confidence = 0, + Name = "name", + Source = "source", + }; + + double expectedConfidence = 0; + string expectedName = "name"; + string expectedSource = "source"; + + Assert.Equal(expectedConfidence, model.Confidence); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedSource, model.Source); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new AITag + { + Confidence = 0, + Name = "name", + Source = "source", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new AITag + { + Confidence = 0, + Name = "name", + Source = "source", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + Assert.NotNull(deserialized); + + double expectedConfidence = 0; + string expectedName = "name"; + string expectedSource = "source"; + + Assert.Equal(expectedConfidence, deserialized.Confidence); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedSource, deserialized.Source); + } + + [Fact] + public void Validation_Works() + { + var model = new AITag + { + Confidence = 0, + Name = "name", + Source = "source", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new AITag { }; + + Assert.Null(model.Confidence); + Assert.False(model.RawData.ContainsKey("confidence")); + Assert.Null(model.Name); + Assert.False(model.RawData.ContainsKey("name")); + Assert.Null(model.Source); + Assert.False(model.RawData.ContainsKey("source")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new AITag { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new AITag + { + // Null should be interpreted as omitted for these properties + Confidence = null, + Name = null, + Source = null, + }; + + Assert.Null(model.Confidence); + Assert.False(model.RawData.ContainsKey("confidence")); + Assert.Null(model.Name); + Assert.False(model.RawData.ContainsKey("name")); + Assert.Null(model.Source); + Assert.False(model.RawData.ContainsKey("source")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new AITag + { + // Null should be interpreted as omitted for these properties + Confidence = null, + Name = null, + Source = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new AITag + { + Confidence = 0, + Name = "name", + Source = "source", + }; + + AITag copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ExtensionStatusTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ExtensionStatus + { + AIAutoDescription = AIAutoDescription.Success, + AITasks = AITasks.Success, + AwsAutoTagging = AwsAutoTagging.Success, + GoogleAutoTagging = GoogleAutoTagging.Success, + RemoveBg = RemoveBg.Success, + }; + + ApiEnum expectedAIAutoDescription = AIAutoDescription.Success; + ApiEnum expectedAITasks = AITasks.Success; + ApiEnum expectedAwsAutoTagging = AwsAutoTagging.Success; + ApiEnum expectedGoogleAutoTagging = GoogleAutoTagging.Success; + ApiEnum expectedRemoveBg = RemoveBg.Success; + + Assert.Equal(expectedAIAutoDescription, model.AIAutoDescription); + Assert.Equal(expectedAITasks, model.AITasks); + Assert.Equal(expectedAwsAutoTagging, model.AwsAutoTagging); + Assert.Equal(expectedGoogleAutoTagging, model.GoogleAutoTagging); + Assert.Equal(expectedRemoveBg, model.RemoveBg); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ExtensionStatus + { + AIAutoDescription = AIAutoDescription.Success, + AITasks = AITasks.Success, + AwsAutoTagging = AwsAutoTagging.Success, + GoogleAutoTagging = GoogleAutoTagging.Success, + RemoveBg = RemoveBg.Success, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new ExtensionStatus + { + AIAutoDescription = AIAutoDescription.Success, + AITasks = AITasks.Success, + AwsAutoTagging = AwsAutoTagging.Success, + GoogleAutoTagging = GoogleAutoTagging.Success, + RemoveBg = RemoveBg.Success, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum expectedAIAutoDescription = AIAutoDescription.Success; + ApiEnum expectedAITasks = AITasks.Success; + ApiEnum expectedAwsAutoTagging = AwsAutoTagging.Success; + ApiEnum expectedGoogleAutoTagging = GoogleAutoTagging.Success; + ApiEnum expectedRemoveBg = RemoveBg.Success; + + Assert.Equal(expectedAIAutoDescription, deserialized.AIAutoDescription); + Assert.Equal(expectedAITasks, deserialized.AITasks); + Assert.Equal(expectedAwsAutoTagging, deserialized.AwsAutoTagging); + Assert.Equal(expectedGoogleAutoTagging, deserialized.GoogleAutoTagging); + Assert.Equal(expectedRemoveBg, deserialized.RemoveBg); + } + + [Fact] + public void Validation_Works() + { + var model = new ExtensionStatus + { + AIAutoDescription = AIAutoDescription.Success, + AITasks = AITasks.Success, + AwsAutoTagging = AwsAutoTagging.Success, + GoogleAutoTagging = GoogleAutoTagging.Success, + RemoveBg = RemoveBg.Success, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ExtensionStatus { }; + + Assert.Null(model.AIAutoDescription); + Assert.False(model.RawData.ContainsKey("ai-auto-description")); + Assert.Null(model.AITasks); + Assert.False(model.RawData.ContainsKey("ai-tasks")); + Assert.Null(model.AwsAutoTagging); + Assert.False(model.RawData.ContainsKey("aws-auto-tagging")); + Assert.Null(model.GoogleAutoTagging); + Assert.False(model.RawData.ContainsKey("google-auto-tagging")); + Assert.Null(model.RemoveBg); + Assert.False(model.RawData.ContainsKey("remove-bg")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new ExtensionStatus { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new ExtensionStatus + { + // Null should be interpreted as omitted for these properties + AIAutoDescription = null, + AITasks = null, + AwsAutoTagging = null, + GoogleAutoTagging = null, + RemoveBg = null, + }; + + Assert.Null(model.AIAutoDescription); + Assert.False(model.RawData.ContainsKey("ai-auto-description")); + Assert.Null(model.AITasks); + Assert.False(model.RawData.ContainsKey("ai-tasks")); + Assert.Null(model.AwsAutoTagging); + Assert.False(model.RawData.ContainsKey("aws-auto-tagging")); + Assert.Null(model.GoogleAutoTagging); + Assert.False(model.RawData.ContainsKey("google-auto-tagging")); + Assert.Null(model.RemoveBg); + Assert.False(model.RawData.ContainsKey("remove-bg")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new ExtensionStatus + { + // Null should be interpreted as omitted for these properties + AIAutoDescription = null, + AITasks = null, + AwsAutoTagging = null, + GoogleAutoTagging = null, + RemoveBg = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ExtensionStatus + { + AIAutoDescription = AIAutoDescription.Success, + AITasks = AITasks.Success, + AwsAutoTagging = AwsAutoTagging.Success, + GoogleAutoTagging = GoogleAutoTagging.Success, + RemoveBg = RemoveBg.Success, + }; + + ExtensionStatus copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class AIAutoDescriptionTest : TestBase +{ + [Theory] + [InlineData(AIAutoDescription.Success)] + [InlineData(AIAutoDescription.Pending)] + [InlineData(AIAutoDescription.Failed)] + public void Validation_Works(AIAutoDescription rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(AIAutoDescription.Success)] + [InlineData(AIAutoDescription.Pending)] + [InlineData(AIAutoDescription.Failed)] + public void SerializationRoundtrip_Works(AIAutoDescription rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class AITasksTest : TestBase +{ + [Theory] + [InlineData(AITasks.Success)] + [InlineData(AITasks.Pending)] + [InlineData(AITasks.Failed)] + public void Validation_Works(AITasks rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(AITasks.Success)] + [InlineData(AITasks.Pending)] + [InlineData(AITasks.Failed)] + public void SerializationRoundtrip_Works(AITasks rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class AwsAutoTaggingTest : TestBase +{ + [Theory] + [InlineData(AwsAutoTagging.Success)] + [InlineData(AwsAutoTagging.Pending)] + [InlineData(AwsAutoTagging.Failed)] + public void Validation_Works(AwsAutoTagging rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(AwsAutoTagging.Success)] + [InlineData(AwsAutoTagging.Pending)] + [InlineData(AwsAutoTagging.Failed)] + public void SerializationRoundtrip_Works(AwsAutoTagging rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class GoogleAutoTaggingTest : TestBase +{ + [Theory] + [InlineData(GoogleAutoTagging.Success)] + [InlineData(GoogleAutoTagging.Pending)] + [InlineData(GoogleAutoTagging.Failed)] + public void Validation_Works(GoogleAutoTagging rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(GoogleAutoTagging.Success)] + [InlineData(GoogleAutoTagging.Pending)] + [InlineData(GoogleAutoTagging.Failed)] + public void SerializationRoundtrip_Works(GoogleAutoTagging rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class RemoveBgTest : TestBase +{ + [Theory] + [InlineData(RemoveBg.Success)] + [InlineData(RemoveBg.Pending)] + [InlineData(RemoveBg.Failed)] + public void Validation_Works(RemoveBg rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(RemoveBg.Success)] + [InlineData(RemoveBg.Pending)] + [InlineData(RemoveBg.Failed)] + public void SerializationRoundtrip_Works(RemoveBg rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class SelectedFieldsSchemaItemTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new SelectedFieldsSchemaItem + { + Type = Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + }; + + ApiEnum expectedType = Type.Text; + DefaultValue expectedDefaultValue = "string"; + bool expectedIsValueRequired = true; + double expectedMaxLength = 0; + MaxValue expectedMaxValue = "string"; + double expectedMinLength = 0; + MinValue expectedMinValue = "string"; + bool expectedReadOnly = true; + List expectedSelectOptions = ["small", "medium", "large", 30, 40, true]; + bool expectedSelectOptionsTruncated = true; + + Assert.Equal(expectedType, model.Type); + Assert.Equal(expectedDefaultValue, model.DefaultValue); + Assert.Equal(expectedIsValueRequired, model.IsValueRequired); + Assert.Equal(expectedMaxLength, model.MaxLength); + Assert.Equal(expectedMaxValue, model.MaxValue); + Assert.Equal(expectedMinLength, model.MinLength); + Assert.Equal(expectedMinValue, model.MinValue); + Assert.Equal(expectedReadOnly, model.ReadOnly); + Assert.NotNull(model.SelectOptions); + Assert.Equal(expectedSelectOptions.Count, model.SelectOptions.Count); + for (int i = 0; i < expectedSelectOptions.Count; i++) + { + Assert.Equal(expectedSelectOptions[i], model.SelectOptions[i]); + } + Assert.Equal(expectedSelectOptionsTruncated, model.SelectOptionsTruncated); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new SelectedFieldsSchemaItem + { + Type = Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new SelectedFieldsSchemaItem + { + Type = Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum expectedType = Type.Text; + DefaultValue expectedDefaultValue = "string"; + bool expectedIsValueRequired = true; + double expectedMaxLength = 0; + MaxValue expectedMaxValue = "string"; + double expectedMinLength = 0; + MinValue expectedMinValue = "string"; + bool expectedReadOnly = true; + List expectedSelectOptions = ["small", "medium", "large", 30, 40, true]; + bool expectedSelectOptionsTruncated = true; + + Assert.Equal(expectedType, deserialized.Type); + Assert.Equal(expectedDefaultValue, deserialized.DefaultValue); + Assert.Equal(expectedIsValueRequired, deserialized.IsValueRequired); + Assert.Equal(expectedMaxLength, deserialized.MaxLength); + Assert.Equal(expectedMaxValue, deserialized.MaxValue); + Assert.Equal(expectedMinLength, deserialized.MinLength); + Assert.Equal(expectedMinValue, deserialized.MinValue); + Assert.Equal(expectedReadOnly, deserialized.ReadOnly); + Assert.NotNull(deserialized.SelectOptions); + Assert.Equal(expectedSelectOptions.Count, deserialized.SelectOptions.Count); + for (int i = 0; i < expectedSelectOptions.Count; i++) + { + Assert.Equal(expectedSelectOptions[i], deserialized.SelectOptions[i]); + } + Assert.Equal(expectedSelectOptionsTruncated, deserialized.SelectOptionsTruncated); + } + + [Fact] + public void Validation_Works() + { + var model = new SelectedFieldsSchemaItem + { + Type = Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new SelectedFieldsSchemaItem { Type = Type.Text }; + + Assert.Null(model.DefaultValue); + Assert.False(model.RawData.ContainsKey("defaultValue")); + Assert.Null(model.IsValueRequired); + Assert.False(model.RawData.ContainsKey("isValueRequired")); + Assert.Null(model.MaxLength); + Assert.False(model.RawData.ContainsKey("maxLength")); + Assert.Null(model.MaxValue); + Assert.False(model.RawData.ContainsKey("maxValue")); + Assert.Null(model.MinLength); + Assert.False(model.RawData.ContainsKey("minLength")); + Assert.Null(model.MinValue); + Assert.False(model.RawData.ContainsKey("minValue")); + Assert.Null(model.ReadOnly); + Assert.False(model.RawData.ContainsKey("readOnly")); + Assert.Null(model.SelectOptions); + Assert.False(model.RawData.ContainsKey("selectOptions")); + Assert.Null(model.SelectOptionsTruncated); + Assert.False(model.RawData.ContainsKey("selectOptionsTruncated")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new SelectedFieldsSchemaItem { Type = Type.Text }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new SelectedFieldsSchemaItem + { + Type = Type.Text, + + // Null should be interpreted as omitted for these properties + DefaultValue = null, + IsValueRequired = null, + MaxLength = null, + MaxValue = null, + MinLength = null, + MinValue = null, + ReadOnly = null, + SelectOptions = null, + SelectOptionsTruncated = null, + }; + + Assert.Null(model.DefaultValue); + Assert.False(model.RawData.ContainsKey("defaultValue")); + Assert.Null(model.IsValueRequired); + Assert.False(model.RawData.ContainsKey("isValueRequired")); + Assert.Null(model.MaxLength); + Assert.False(model.RawData.ContainsKey("maxLength")); + Assert.Null(model.MaxValue); + Assert.False(model.RawData.ContainsKey("maxValue")); + Assert.Null(model.MinLength); + Assert.False(model.RawData.ContainsKey("minLength")); + Assert.Null(model.MinValue); + Assert.False(model.RawData.ContainsKey("minValue")); + Assert.Null(model.ReadOnly); + Assert.False(model.RawData.ContainsKey("readOnly")); + Assert.Null(model.SelectOptions); + Assert.False(model.RawData.ContainsKey("selectOptions")); + Assert.Null(model.SelectOptionsTruncated); + Assert.False(model.RawData.ContainsKey("selectOptionsTruncated")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new SelectedFieldsSchemaItem + { + Type = Type.Text, + + // Null should be interpreted as omitted for these properties + DefaultValue = null, + IsValueRequired = null, + MaxLength = null, + MaxValue = null, + MinLength = null, + MinValue = null, + ReadOnly = null, + SelectOptions = null, + SelectOptionsTruncated = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new SelectedFieldsSchemaItem + { + Type = Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + }; + + SelectedFieldsSchemaItem copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TypeTest : TestBase +{ + [Theory] + [InlineData(Type.Text)] + [InlineData(Type.Textarea)] + [InlineData(Type.Number)] + [InlineData(Type.Date)] + [InlineData(Type.Boolean)] + [InlineData(Type.SingleSelect)] + [InlineData(Type.MultiSelect)] + public void Validation_Works(Type rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(Type.Text)] + [InlineData(Type.Textarea)] + [InlineData(Type.Number)] + [InlineData(Type.Date)] + [InlineData(Type.Boolean)] + [InlineData(Type.SingleSelect)] + [InlineData(Type.MultiSelect)] + public void SerializationRoundtrip_Works(Type rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class DefaultValueTest : TestBase +{ + [Fact] + public void StringValidationWorks() + { + DefaultValue value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + DefaultValue value = 0; + value.Validate(); + } + + [Fact] + public void BoolValidationWorks() + { + DefaultValue value = true; + value.Validate(); + } + + [Fact] + public void MixedValidationWorks() + { + DefaultValue value = new( + [ + new UnnamedSchemaWithArrayParent12(true), + new UnnamedSchemaWithArrayParent12(10), + new UnnamedSchemaWithArrayParent12("Hello"), + ] + ); + value.Validate(); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + DefaultValue value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + DefaultValue value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void BoolSerializationRoundtripWorks() + { + DefaultValue value = true; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void MixedSerializationRoundtripWorks() + { + DefaultValue value = new( + [ + new UnnamedSchemaWithArrayParent12(true), + new UnnamedSchemaWithArrayParent12(10), + new UnnamedSchemaWithArrayParent12("Hello"), + ] + ); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class UnnamedSchemaWithArrayParent12Test : TestBase +{ + [Fact] + public void StringValidationWorks() + { + UnnamedSchemaWithArrayParent12 value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + UnnamedSchemaWithArrayParent12 value = 0; + value.Validate(); + } + + [Fact] + public void BoolValidationWorks() + { + UnnamedSchemaWithArrayParent12 value = true; + value.Validate(); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent12 value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent12 value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void BoolSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent12 value = true; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class MaxValueTest : TestBase +{ + [Fact] + public void StringValidationWorks() + { + MaxValue value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + MaxValue value = 0; + value.Validate(); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + MaxValue value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + MaxValue value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class MinValueTest : TestBase +{ + [Fact] + public void StringValidationWorks() + { + MinValue value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + MinValue value = 0; + value.Validate(); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + MinValue value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + MinValue value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class SelectOptionTest : TestBase +{ + [Fact] + public void StringValidationWorks() + { + SelectOption value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + SelectOption value = 0; + value.Validate(); + } + + [Fact] + public void BoolValidationWorks() + { + SelectOption value = true; + value.Validate(); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + SelectOption value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + SelectOption value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void BoolSerializationRoundtripWorks() + { + SelectOption value = true; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class VersionInfoTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new VersionInfo { ID = "id", Name = "name" }; + + string expectedID = "id"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new VersionInfo { ID = "id", Name = "name" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new VersionInfo { ID = "id", Name = "name" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new VersionInfo { ID = "id", Name = "name" }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new VersionInfo { }; + + Assert.Null(model.ID); + Assert.False(model.RawData.ContainsKey("id")); + Assert.Null(model.Name); + Assert.False(model.RawData.ContainsKey("name")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new VersionInfo { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new VersionInfo + { + // Null should be interpreted as omitted for these properties + ID = null, + Name = null, + }; + + Assert.Null(model.ID); + Assert.False(model.RawData.ContainsKey("id")); + Assert.Null(model.Name); + Assert.False(model.RawData.ContainsKey("name")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new VersionInfo + { + // Null should be interpreted as omitted for these properties + ID = null, + Name = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new VersionInfo { ID = "id", Name = "name" }; + + VersionInfo copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationCreateParamsTest.cs b/src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationCreateParamsTest.cs new file mode 100644 index 00000000..a42ee393 --- /dev/null +++ b/src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationCreateParamsTest.cs @@ -0,0 +1,46 @@ +using System; +using ImageKit.Models.Cache.Invalidation; + +namespace ImageKit.Tests.Models.Cache.Invalidation; + +public class InvalidationCreateParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new InvalidationCreateParams + { + UrlValue = "https://ik.imagekit.io/your_imagekit_id/default-image.jpg", + }; + + string expectedUrlValue = "https://ik.imagekit.io/your_imagekit_id/default-image.jpg"; + + Assert.Equal(expectedUrlValue, parameters.UrlValue); + } + + [Fact] + public void Url_Works() + { + InvalidationCreateParams parameters = new() + { + UrlValue = "https://ik.imagekit.io/your_imagekit_id/default-image.jpg", + }; + + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + + Assert.Equal(new Uri("https://api.imagekit.io/v1/files/purge"), url); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new InvalidationCreateParams + { + UrlValue = "https://ik.imagekit.io/your_imagekit_id/default-image.jpg", + }; + + InvalidationCreateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationCreateResponseTest.cs b/src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationCreateResponseTest.cs new file mode 100644 index 00000000..6276f333 --- /dev/null +++ b/src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationCreateResponseTest.cs @@ -0,0 +1,109 @@ +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Models.Cache.Invalidation; + +namespace ImageKit.Tests.Models.Cache.Invalidation; + +public class InvalidationCreateResponseTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new InvalidationCreateResponse { RequestID = "requestId" }; + + string expectedRequestID = "requestId"; + + Assert.Equal(expectedRequestID, model.RequestID); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new InvalidationCreateResponse { RequestID = "requestId" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new InvalidationCreateResponse { RequestID = "requestId" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedRequestID = "requestId"; + + Assert.Equal(expectedRequestID, deserialized.RequestID); + } + + [Fact] + public void Validation_Works() + { + var model = new InvalidationCreateResponse { RequestID = "requestId" }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new InvalidationCreateResponse { }; + + Assert.Null(model.RequestID); + Assert.False(model.RawData.ContainsKey("requestId")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new InvalidationCreateResponse { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new InvalidationCreateResponse + { + // Null should be interpreted as omitted for these properties + RequestID = null, + }; + + Assert.Null(model.RequestID); + Assert.False(model.RawData.ContainsKey("requestId")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new InvalidationCreateResponse + { + // Null should be interpreted as omitted for these properties + RequestID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new InvalidationCreateResponse { RequestID = "requestId" }; + + InvalidationCreateResponse copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationGetParamsTest.cs b/src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationGetParamsTest.cs new file mode 100644 index 00000000..60def5ee --- /dev/null +++ b/src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationGetParamsTest.cs @@ -0,0 +1,37 @@ +using System; +using ImageKit.Models.Cache.Invalidation; + +namespace ImageKit.Tests.Models.Cache.Invalidation; + +public class InvalidationGetParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new InvalidationGetParams { RequestID = "requestId" }; + + string expectedRequestID = "requestId"; + + Assert.Equal(expectedRequestID, parameters.RequestID); + } + + [Fact] + public void Url_Works() + { + InvalidationGetParams parameters = new() { RequestID = "requestId" }; + + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + + Assert.Equal(new Uri("https://api.imagekit.io/v1/files/purge/requestId"), url); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new InvalidationGetParams { RequestID = "requestId" }; + + InvalidationGetParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationGetResponseTest.cs b/src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationGetResponseTest.cs new file mode 100644 index 00000000..fe4e6a01 --- /dev/null +++ b/src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationGetResponseTest.cs @@ -0,0 +1,168 @@ +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Exceptions; +using ImageKit.Models.Cache.Invalidation; + +namespace ImageKit.Tests.Models.Cache.Invalidation; + +public class InvalidationGetResponseTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new InvalidationGetResponse { Status = Status.Completed }; + + ApiEnum expectedStatus = Status.Completed; + + Assert.Equal(expectedStatus, model.Status); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new InvalidationGetResponse { Status = Status.Completed }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new InvalidationGetResponse { Status = Status.Completed }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum expectedStatus = Status.Completed; + + Assert.Equal(expectedStatus, deserialized.Status); + } + + [Fact] + public void Validation_Works() + { + var model = new InvalidationGetResponse { Status = Status.Completed }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new InvalidationGetResponse { }; + + Assert.Null(model.Status); + Assert.False(model.RawData.ContainsKey("status")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new InvalidationGetResponse { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new InvalidationGetResponse + { + // Null should be interpreted as omitted for these properties + Status = null, + }; + + Assert.Null(model.Status); + Assert.False(model.RawData.ContainsKey("status")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new InvalidationGetResponse + { + // Null should be interpreted as omitted for these properties + Status = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new InvalidationGetResponse { Status = Status.Completed }; + + InvalidationGetResponse copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class StatusTest : TestBase +{ + [Theory] + [InlineData(Status.Pending)] + [InlineData(Status.Completed)] + public void Validation_Works(Status rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(Status.Pending)] + [InlineData(Status.Completed)] + public void SerializationRoundtrip_Works(Status rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} diff --git a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsTest.cs b/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsTest.cs new file mode 100644 index 00000000..cc1697df --- /dev/null +++ b/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsTest.cs @@ -0,0 +1,726 @@ +using System; +using System.Collections.Generic; +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Exceptions; +using CustomMetadataFields = ImageKit.Models.CustomMetadataFields; + +namespace ImageKit.Tests.Models.CustomMetadataFields; + +public class CustomMetadataFieldCreateParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new CustomMetadataFields::CustomMetadataFieldCreateParams + { + Label = "price", + Name = "price", + Schema = new() + { + Type = CustomMetadataFields::Type.Number, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = 3000, + MinLength = 0, + MinValue = 1000, + SelectOptions = ["small", "medium", "large", 30, 40, true], + }, + }; + + string expectedLabel = "price"; + string expectedName = "price"; + CustomMetadataFields::Schema expectedSchema = new() + { + Type = CustomMetadataFields::Type.Number, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = 3000, + MinLength = 0, + MinValue = 1000, + SelectOptions = ["small", "medium", "large", 30, 40, true], + }; + + Assert.Equal(expectedLabel, parameters.Label); + Assert.Equal(expectedName, parameters.Name); + Assert.Equal(expectedSchema, parameters.Schema); + } + + [Fact] + public void Url_Works() + { + CustomMetadataFields::CustomMetadataFieldCreateParams parameters = new() + { + Label = "price", + Name = "price", + Schema = new() + { + Type = CustomMetadataFields::Type.Number, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = 3000, + MinLength = 0, + MinValue = 1000, + SelectOptions = ["small", "medium", "large", 30, 40, true], + }, + }; + + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + + Assert.Equal(new Uri("https://api.imagekit.io/v1/customMetadataFields"), url); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new CustomMetadataFields::CustomMetadataFieldCreateParams + { + Label = "price", + Name = "price", + Schema = new() + { + Type = CustomMetadataFields::Type.Number, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = 3000, + MinLength = 0, + MinValue = 1000, + SelectOptions = ["small", "medium", "large", 30, 40, true], + }, + }; + + CustomMetadataFields::CustomMetadataFieldCreateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} + +public class SchemaTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new CustomMetadataFields::Schema + { + Type = CustomMetadataFields::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + SelectOptions = ["small", "medium", "large", 30, 40, true], + }; + + ApiEnum expectedType = CustomMetadataFields::Type.Text; + CustomMetadataFields::DefaultValue expectedDefaultValue = "string"; + bool expectedIsValueRequired = true; + double expectedMaxLength = 0; + CustomMetadataFields::MaxValue expectedMaxValue = "string"; + double expectedMinLength = 0; + CustomMetadataFields::MinValue expectedMinValue = "string"; + List expectedSelectOptions = + [ + "small", + "medium", + "large", + 30, + 40, + true, + ]; + + Assert.Equal(expectedType, model.Type); + Assert.Equal(expectedDefaultValue, model.DefaultValue); + Assert.Equal(expectedIsValueRequired, model.IsValueRequired); + Assert.Equal(expectedMaxLength, model.MaxLength); + Assert.Equal(expectedMaxValue, model.MaxValue); + Assert.Equal(expectedMinLength, model.MinLength); + Assert.Equal(expectedMinValue, model.MinValue); + Assert.NotNull(model.SelectOptions); + Assert.Equal(expectedSelectOptions.Count, model.SelectOptions.Count); + for (int i = 0; i < expectedSelectOptions.Count; i++) + { + Assert.Equal(expectedSelectOptions[i], model.SelectOptions[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new CustomMetadataFields::Schema + { + Type = CustomMetadataFields::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + SelectOptions = ["small", "medium", "large", 30, 40, true], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new CustomMetadataFields::Schema + { + Type = CustomMetadataFields::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + SelectOptions = ["small", "medium", "large", 30, 40, true], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum expectedType = CustomMetadataFields::Type.Text; + CustomMetadataFields::DefaultValue expectedDefaultValue = "string"; + bool expectedIsValueRequired = true; + double expectedMaxLength = 0; + CustomMetadataFields::MaxValue expectedMaxValue = "string"; + double expectedMinLength = 0; + CustomMetadataFields::MinValue expectedMinValue = "string"; + List expectedSelectOptions = + [ + "small", + "medium", + "large", + 30, + 40, + true, + ]; + + Assert.Equal(expectedType, deserialized.Type); + Assert.Equal(expectedDefaultValue, deserialized.DefaultValue); + Assert.Equal(expectedIsValueRequired, deserialized.IsValueRequired); + Assert.Equal(expectedMaxLength, deserialized.MaxLength); + Assert.Equal(expectedMaxValue, deserialized.MaxValue); + Assert.Equal(expectedMinLength, deserialized.MinLength); + Assert.Equal(expectedMinValue, deserialized.MinValue); + Assert.NotNull(deserialized.SelectOptions); + Assert.Equal(expectedSelectOptions.Count, deserialized.SelectOptions.Count); + for (int i = 0; i < expectedSelectOptions.Count; i++) + { + Assert.Equal(expectedSelectOptions[i], deserialized.SelectOptions[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new CustomMetadataFields::Schema + { + Type = CustomMetadataFields::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + SelectOptions = ["small", "medium", "large", 30, 40, true], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new CustomMetadataFields::Schema { Type = CustomMetadataFields::Type.Text }; + + Assert.Null(model.DefaultValue); + Assert.False(model.RawData.ContainsKey("defaultValue")); + Assert.Null(model.IsValueRequired); + Assert.False(model.RawData.ContainsKey("isValueRequired")); + Assert.Null(model.MaxLength); + Assert.False(model.RawData.ContainsKey("maxLength")); + Assert.Null(model.MaxValue); + Assert.False(model.RawData.ContainsKey("maxValue")); + Assert.Null(model.MinLength); + Assert.False(model.RawData.ContainsKey("minLength")); + Assert.Null(model.MinValue); + Assert.False(model.RawData.ContainsKey("minValue")); + Assert.Null(model.SelectOptions); + Assert.False(model.RawData.ContainsKey("selectOptions")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new CustomMetadataFields::Schema { Type = CustomMetadataFields::Type.Text }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new CustomMetadataFields::Schema + { + Type = CustomMetadataFields::Type.Text, + + // Null should be interpreted as omitted for these properties + DefaultValue = null, + IsValueRequired = null, + MaxLength = null, + MaxValue = null, + MinLength = null, + MinValue = null, + SelectOptions = null, + }; + + Assert.Null(model.DefaultValue); + Assert.False(model.RawData.ContainsKey("defaultValue")); + Assert.Null(model.IsValueRequired); + Assert.False(model.RawData.ContainsKey("isValueRequired")); + Assert.Null(model.MaxLength); + Assert.False(model.RawData.ContainsKey("maxLength")); + Assert.Null(model.MaxValue); + Assert.False(model.RawData.ContainsKey("maxValue")); + Assert.Null(model.MinLength); + Assert.False(model.RawData.ContainsKey("minLength")); + Assert.Null(model.MinValue); + Assert.False(model.RawData.ContainsKey("minValue")); + Assert.Null(model.SelectOptions); + Assert.False(model.RawData.ContainsKey("selectOptions")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new CustomMetadataFields::Schema + { + Type = CustomMetadataFields::Type.Text, + + // Null should be interpreted as omitted for these properties + DefaultValue = null, + IsValueRequired = null, + MaxLength = null, + MaxValue = null, + MinLength = null, + MinValue = null, + SelectOptions = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CustomMetadataFields::Schema + { + Type = CustomMetadataFields::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + SelectOptions = ["small", "medium", "large", 30, 40, true], + }; + + CustomMetadataFields::Schema copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TypeTest : TestBase +{ + [Theory] + [InlineData(CustomMetadataFields::Type.Text)] + [InlineData(CustomMetadataFields::Type.Textarea)] + [InlineData(CustomMetadataFields::Type.Number)] + [InlineData(CustomMetadataFields::Type.Date)] + [InlineData(CustomMetadataFields::Type.Boolean)] + [InlineData(CustomMetadataFields::Type.SingleSelect)] + [InlineData(CustomMetadataFields::Type.MultiSelect)] + public void Validation_Works(CustomMetadataFields::Type rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(CustomMetadataFields::Type.Text)] + [InlineData(CustomMetadataFields::Type.Textarea)] + [InlineData(CustomMetadataFields::Type.Number)] + [InlineData(CustomMetadataFields::Type.Date)] + [InlineData(CustomMetadataFields::Type.Boolean)] + [InlineData(CustomMetadataFields::Type.SingleSelect)] + [InlineData(CustomMetadataFields::Type.MultiSelect)] + public void SerializationRoundtrip_Works(CustomMetadataFields::Type rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class DefaultValueTest : TestBase +{ + [Fact] + public void StringValidationWorks() + { + CustomMetadataFields::DefaultValue value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + CustomMetadataFields::DefaultValue value = 0; + value.Validate(); + } + + [Fact] + public void BoolValidationWorks() + { + CustomMetadataFields::DefaultValue value = true; + value.Validate(); + } + + [Fact] + public void MixedValidationWorks() + { + CustomMetadataFields::DefaultValue value = new( + [ + new CustomMetadataFields::UnnamedSchemaWithArrayParent1(true), + new CustomMetadataFields::UnnamedSchemaWithArrayParent1(10), + new CustomMetadataFields::UnnamedSchemaWithArrayParent1("Hello"), + ] + ); + value.Validate(); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + CustomMetadataFields::DefaultValue value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + CustomMetadataFields::DefaultValue value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void BoolSerializationRoundtripWorks() + { + CustomMetadataFields::DefaultValue value = true; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void MixedSerializationRoundtripWorks() + { + CustomMetadataFields::DefaultValue value = new( + [ + new CustomMetadataFields::UnnamedSchemaWithArrayParent1(true), + new CustomMetadataFields::UnnamedSchemaWithArrayParent1(10), + new CustomMetadataFields::UnnamedSchemaWithArrayParent1("Hello"), + ] + ); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class UnnamedSchemaWithArrayParent1Test : TestBase +{ + [Fact] + public void StringValidationWorks() + { + CustomMetadataFields::UnnamedSchemaWithArrayParent1 value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + CustomMetadataFields::UnnamedSchemaWithArrayParent1 value = 0; + value.Validate(); + } + + [Fact] + public void BoolValidationWorks() + { + CustomMetadataFields::UnnamedSchemaWithArrayParent1 value = true; + value.Validate(); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + CustomMetadataFields::UnnamedSchemaWithArrayParent1 value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + CustomMetadataFields::UnnamedSchemaWithArrayParent1 value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void BoolSerializationRoundtripWorks() + { + CustomMetadataFields::UnnamedSchemaWithArrayParent1 value = true; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class MaxValueTest : TestBase +{ + [Fact] + public void StringValidationWorks() + { + CustomMetadataFields::MaxValue value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + CustomMetadataFields::MaxValue value = 0; + value.Validate(); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + CustomMetadataFields::MaxValue value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + CustomMetadataFields::MaxValue value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class MinValueTest : TestBase +{ + [Fact] + public void StringValidationWorks() + { + CustomMetadataFields::MinValue value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + CustomMetadataFields::MinValue value = 0; + value.Validate(); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + CustomMetadataFields::MinValue value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + CustomMetadataFields::MinValue value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class SelectOptionTest : TestBase +{ + [Fact] + public void StringValidationWorks() + { + CustomMetadataFields::SelectOption value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + CustomMetadataFields::SelectOption value = 0; + value.Validate(); + } + + [Fact] + public void BoolValidationWorks() + { + CustomMetadataFields::SelectOption value = true; + value.Validate(); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + CustomMetadataFields::SelectOption value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + CustomMetadataFields::SelectOption value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void BoolSerializationRoundtripWorks() + { + CustomMetadataFields::SelectOption value = true; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} diff --git a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldDeleteParamsTest.cs b/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldDeleteParamsTest.cs new file mode 100644 index 00000000..14045bf0 --- /dev/null +++ b/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldDeleteParamsTest.cs @@ -0,0 +1,37 @@ +using System; +using ImageKit.Models.CustomMetadataFields; + +namespace ImageKit.Tests.Models.CustomMetadataFields; + +public class CustomMetadataFieldDeleteParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new CustomMetadataFieldDeleteParams { ID = "id" }; + + string expectedID = "id"; + + Assert.Equal(expectedID, parameters.ID); + } + + [Fact] + public void Url_Works() + { + CustomMetadataFieldDeleteParams parameters = new() { ID = "id" }; + + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + + Assert.Equal(new Uri("https://api.imagekit.io/v1/customMetadataFields/id"), url); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new CustomMetadataFieldDeleteParams { ID = "id" }; + + CustomMetadataFieldDeleteParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldDeleteResponseTest.cs b/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldDeleteResponseTest.cs new file mode 100644 index 00000000..43f35106 --- /dev/null +++ b/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldDeleteResponseTest.cs @@ -0,0 +1,59 @@ +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Models.CustomMetadataFields; + +namespace ImageKit.Tests.Models.CustomMetadataFields; + +public class CustomMetadataFieldDeleteResponseTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new CustomMetadataFieldDeleteResponse { }; + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new CustomMetadataFieldDeleteResponse { }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new CustomMetadataFieldDeleteResponse { }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + } + + [Fact] + public void Validation_Works() + { + var model = new CustomMetadataFieldDeleteResponse { }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CustomMetadataFieldDeleteResponse { }; + + CustomMetadataFieldDeleteResponse copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldListParamsTest.cs b/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldListParamsTest.cs new file mode 100644 index 00000000..de7b0113 --- /dev/null +++ b/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldListParamsTest.cs @@ -0,0 +1,83 @@ +using System; +using ImageKit.Models.CustomMetadataFields; + +namespace ImageKit.Tests.Models.CustomMetadataFields; + +public class CustomMetadataFieldListParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new CustomMetadataFieldListParams + { + FolderPath = "folderPath", + IncludeDeleted = true, + }; + + string expectedFolderPath = "folderPath"; + bool expectedIncludeDeleted = true; + + Assert.Equal(expectedFolderPath, parameters.FolderPath); + Assert.Equal(expectedIncludeDeleted, parameters.IncludeDeleted); + } + + [Fact] + public void OptionalNonNullableParamsUnsetAreNotSet_Works() + { + var parameters = new CustomMetadataFieldListParams { }; + + Assert.Null(parameters.FolderPath); + Assert.False(parameters.RawQueryData.ContainsKey("folderPath")); + Assert.Null(parameters.IncludeDeleted); + Assert.False(parameters.RawQueryData.ContainsKey("includeDeleted")); + } + + [Fact] + public void OptionalNonNullableParamsSetToNullAreNotSet_Works() + { + var parameters = new CustomMetadataFieldListParams + { + // Null should be interpreted as omitted for these properties + FolderPath = null, + IncludeDeleted = null, + }; + + Assert.Null(parameters.FolderPath); + Assert.False(parameters.RawQueryData.ContainsKey("folderPath")); + Assert.Null(parameters.IncludeDeleted); + Assert.False(parameters.RawQueryData.ContainsKey("includeDeleted")); + } + + [Fact] + public void Url_Works() + { + CustomMetadataFieldListParams parameters = new() + { + FolderPath = "folderPath", + IncludeDeleted = true, + }; + + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + + Assert.Equal( + new Uri( + "https://api.imagekit.io/v1/customMetadataFields?folderPath=folderPath&includeDeleted=true" + ), + url + ); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new CustomMetadataFieldListParams + { + FolderPath = "folderPath", + IncludeDeleted = true, + }; + + CustomMetadataFieldListParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldTest.cs b/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldTest.cs new file mode 100644 index 00000000..7f085638 --- /dev/null +++ b/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldTest.cs @@ -0,0 +1,804 @@ +using System.Collections.Generic; +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Exceptions; +using ImageKit.Models.CustomMetadataFields; + +namespace ImageKit.Tests.Models.CustomMetadataFields; + +public class CustomMetadataFieldTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new CustomMetadataField + { + ID = "id", + Label = "label", + Name = "name", + Schema = new() + { + Type = CustomMetadataFieldSchemaType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + SelectOptions = ["small", "medium", "large", 30, 40, true], + }, + }; + + string expectedID = "id"; + string expectedLabel = "label"; + string expectedName = "name"; + CustomMetadataFieldSchema expectedSchema = new() + { + Type = CustomMetadataFieldSchemaType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + SelectOptions = ["small", "medium", "large", 30, 40, true], + }; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedLabel, model.Label); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedSchema, model.Schema); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new CustomMetadataField + { + ID = "id", + Label = "label", + Name = "name", + Schema = new() + { + Type = CustomMetadataFieldSchemaType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + SelectOptions = ["small", "medium", "large", 30, 40, true], + }, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new CustomMetadataField + { + ID = "id", + Label = "label", + Name = "name", + Schema = new() + { + Type = CustomMetadataFieldSchemaType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + SelectOptions = ["small", "medium", "large", 30, 40, true], + }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedLabel = "label"; + string expectedName = "name"; + CustomMetadataFieldSchema expectedSchema = new() + { + Type = CustomMetadataFieldSchemaType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + SelectOptions = ["small", "medium", "large", 30, 40, true], + }; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedLabel, deserialized.Label); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedSchema, deserialized.Schema); + } + + [Fact] + public void Validation_Works() + { + var model = new CustomMetadataField + { + ID = "id", + Label = "label", + Name = "name", + Schema = new() + { + Type = CustomMetadataFieldSchemaType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + SelectOptions = ["small", "medium", "large", 30, 40, true], + }, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CustomMetadataField + { + ID = "id", + Label = "label", + Name = "name", + Schema = new() + { + Type = CustomMetadataFieldSchemaType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + SelectOptions = ["small", "medium", "large", 30, 40, true], + }, + }; + + CustomMetadataField copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class CustomMetadataFieldSchemaTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new CustomMetadataFieldSchema + { + Type = CustomMetadataFieldSchemaType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + SelectOptions = ["small", "medium", "large", 30, 40, true], + }; + + ApiEnum expectedType = + CustomMetadataFieldSchemaType.Text; + CustomMetadataFieldSchemaDefaultValue expectedDefaultValue = "string"; + bool expectedIsValueRequired = true; + double expectedMaxLength = 0; + CustomMetadataFieldSchemaMaxValue expectedMaxValue = "string"; + double expectedMinLength = 0; + CustomMetadataFieldSchemaMinValue expectedMinValue = "string"; + List expectedSelectOptions = + [ + "small", + "medium", + "large", + 30, + 40, + true, + ]; + + Assert.Equal(expectedType, model.Type); + Assert.Equal(expectedDefaultValue, model.DefaultValue); + Assert.Equal(expectedIsValueRequired, model.IsValueRequired); + Assert.Equal(expectedMaxLength, model.MaxLength); + Assert.Equal(expectedMaxValue, model.MaxValue); + Assert.Equal(expectedMinLength, model.MinLength); + Assert.Equal(expectedMinValue, model.MinValue); + Assert.NotNull(model.SelectOptions); + Assert.Equal(expectedSelectOptions.Count, model.SelectOptions.Count); + for (int i = 0; i < expectedSelectOptions.Count; i++) + { + Assert.Equal(expectedSelectOptions[i], model.SelectOptions[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new CustomMetadataFieldSchema + { + Type = CustomMetadataFieldSchemaType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + SelectOptions = ["small", "medium", "large", 30, 40, true], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new CustomMetadataFieldSchema + { + Type = CustomMetadataFieldSchemaType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + SelectOptions = ["small", "medium", "large", 30, 40, true], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum expectedType = + CustomMetadataFieldSchemaType.Text; + CustomMetadataFieldSchemaDefaultValue expectedDefaultValue = "string"; + bool expectedIsValueRequired = true; + double expectedMaxLength = 0; + CustomMetadataFieldSchemaMaxValue expectedMaxValue = "string"; + double expectedMinLength = 0; + CustomMetadataFieldSchemaMinValue expectedMinValue = "string"; + List expectedSelectOptions = + [ + "small", + "medium", + "large", + 30, + 40, + true, + ]; + + Assert.Equal(expectedType, deserialized.Type); + Assert.Equal(expectedDefaultValue, deserialized.DefaultValue); + Assert.Equal(expectedIsValueRequired, deserialized.IsValueRequired); + Assert.Equal(expectedMaxLength, deserialized.MaxLength); + Assert.Equal(expectedMaxValue, deserialized.MaxValue); + Assert.Equal(expectedMinLength, deserialized.MinLength); + Assert.Equal(expectedMinValue, deserialized.MinValue); + Assert.NotNull(deserialized.SelectOptions); + Assert.Equal(expectedSelectOptions.Count, deserialized.SelectOptions.Count); + for (int i = 0; i < expectedSelectOptions.Count; i++) + { + Assert.Equal(expectedSelectOptions[i], deserialized.SelectOptions[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new CustomMetadataFieldSchema + { + Type = CustomMetadataFieldSchemaType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + SelectOptions = ["small", "medium", "large", 30, 40, true], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new CustomMetadataFieldSchema { Type = CustomMetadataFieldSchemaType.Text }; + + Assert.Null(model.DefaultValue); + Assert.False(model.RawData.ContainsKey("defaultValue")); + Assert.Null(model.IsValueRequired); + Assert.False(model.RawData.ContainsKey("isValueRequired")); + Assert.Null(model.MaxLength); + Assert.False(model.RawData.ContainsKey("maxLength")); + Assert.Null(model.MaxValue); + Assert.False(model.RawData.ContainsKey("maxValue")); + Assert.Null(model.MinLength); + Assert.False(model.RawData.ContainsKey("minLength")); + Assert.Null(model.MinValue); + Assert.False(model.RawData.ContainsKey("minValue")); + Assert.Null(model.SelectOptions); + Assert.False(model.RawData.ContainsKey("selectOptions")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new CustomMetadataFieldSchema { Type = CustomMetadataFieldSchemaType.Text }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new CustomMetadataFieldSchema + { + Type = CustomMetadataFieldSchemaType.Text, + + // Null should be interpreted as omitted for these properties + DefaultValue = null, + IsValueRequired = null, + MaxLength = null, + MaxValue = null, + MinLength = null, + MinValue = null, + SelectOptions = null, + }; + + Assert.Null(model.DefaultValue); + Assert.False(model.RawData.ContainsKey("defaultValue")); + Assert.Null(model.IsValueRequired); + Assert.False(model.RawData.ContainsKey("isValueRequired")); + Assert.Null(model.MaxLength); + Assert.False(model.RawData.ContainsKey("maxLength")); + Assert.Null(model.MaxValue); + Assert.False(model.RawData.ContainsKey("maxValue")); + Assert.Null(model.MinLength); + Assert.False(model.RawData.ContainsKey("minLength")); + Assert.Null(model.MinValue); + Assert.False(model.RawData.ContainsKey("minValue")); + Assert.Null(model.SelectOptions); + Assert.False(model.RawData.ContainsKey("selectOptions")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new CustomMetadataFieldSchema + { + Type = CustomMetadataFieldSchemaType.Text, + + // Null should be interpreted as omitted for these properties + DefaultValue = null, + IsValueRequired = null, + MaxLength = null, + MaxValue = null, + MinLength = null, + MinValue = null, + SelectOptions = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CustomMetadataFieldSchema + { + Type = CustomMetadataFieldSchemaType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + SelectOptions = ["small", "medium", "large", 30, 40, true], + }; + + CustomMetadataFieldSchema copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class CustomMetadataFieldSchemaTypeTest : TestBase +{ + [Theory] + [InlineData(CustomMetadataFieldSchemaType.Text)] + [InlineData(CustomMetadataFieldSchemaType.Textarea)] + [InlineData(CustomMetadataFieldSchemaType.Number)] + [InlineData(CustomMetadataFieldSchemaType.Date)] + [InlineData(CustomMetadataFieldSchemaType.Boolean)] + [InlineData(CustomMetadataFieldSchemaType.SingleSelect)] + [InlineData(CustomMetadataFieldSchemaType.MultiSelect)] + public void Validation_Works(CustomMetadataFieldSchemaType rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(CustomMetadataFieldSchemaType.Text)] + [InlineData(CustomMetadataFieldSchemaType.Textarea)] + [InlineData(CustomMetadataFieldSchemaType.Number)] + [InlineData(CustomMetadataFieldSchemaType.Date)] + [InlineData(CustomMetadataFieldSchemaType.Boolean)] + [InlineData(CustomMetadataFieldSchemaType.SingleSelect)] + [InlineData(CustomMetadataFieldSchemaType.MultiSelect)] + public void SerializationRoundtrip_Works(CustomMetadataFieldSchemaType rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class CustomMetadataFieldSchemaDefaultValueTest : TestBase +{ + [Fact] + public void StringValidationWorks() + { + CustomMetadataFieldSchemaDefaultValue value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + CustomMetadataFieldSchemaDefaultValue value = 0; + value.Validate(); + } + + [Fact] + public void BoolValidationWorks() + { + CustomMetadataFieldSchemaDefaultValue value = true; + value.Validate(); + } + + [Fact] + public void MixedValidationWorks() + { + CustomMetadataFieldSchemaDefaultValue value = new( + [ + new UnnamedSchemaWithArrayParent9(true), + new UnnamedSchemaWithArrayParent9(10), + new UnnamedSchemaWithArrayParent9("Hello"), + ] + ); + value.Validate(); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + CustomMetadataFieldSchemaDefaultValue value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + CustomMetadataFieldSchemaDefaultValue value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void BoolSerializationRoundtripWorks() + { + CustomMetadataFieldSchemaDefaultValue value = true; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void MixedSerializationRoundtripWorks() + { + CustomMetadataFieldSchemaDefaultValue value = new( + [ + new UnnamedSchemaWithArrayParent9(true), + new UnnamedSchemaWithArrayParent9(10), + new UnnamedSchemaWithArrayParent9("Hello"), + ] + ); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class UnnamedSchemaWithArrayParent9Test : TestBase +{ + [Fact] + public void StringValidationWorks() + { + UnnamedSchemaWithArrayParent9 value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + UnnamedSchemaWithArrayParent9 value = 0; + value.Validate(); + } + + [Fact] + public void BoolValidationWorks() + { + UnnamedSchemaWithArrayParent9 value = true; + value.Validate(); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent9 value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent9 value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void BoolSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent9 value = true; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class CustomMetadataFieldSchemaMaxValueTest : TestBase +{ + [Fact] + public void StringValidationWorks() + { + CustomMetadataFieldSchemaMaxValue value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + CustomMetadataFieldSchemaMaxValue value = 0; + value.Validate(); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + CustomMetadataFieldSchemaMaxValue value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + CustomMetadataFieldSchemaMaxValue value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class CustomMetadataFieldSchemaMinValueTest : TestBase +{ + [Fact] + public void StringValidationWorks() + { + CustomMetadataFieldSchemaMinValue value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + CustomMetadataFieldSchemaMinValue value = 0; + value.Validate(); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + CustomMetadataFieldSchemaMinValue value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + CustomMetadataFieldSchemaMinValue value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class CustomMetadataFieldSchemaSelectOptionTest : TestBase +{ + [Fact] + public void StringValidationWorks() + { + CustomMetadataFieldSchemaSelectOption value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + CustomMetadataFieldSchemaSelectOption value = 0; + value.Validate(); + } + + [Fact] + public void BoolValidationWorks() + { + CustomMetadataFieldSchemaSelectOption value = true; + value.Validate(); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + CustomMetadataFieldSchemaSelectOption value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + CustomMetadataFieldSchemaSelectOption value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void BoolSerializationRoundtripWorks() + { + CustomMetadataFieldSchemaSelectOption value = true; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} diff --git a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsTest.cs b/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsTest.cs new file mode 100644 index 00000000..7e969966 --- /dev/null +++ b/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsTest.cs @@ -0,0 +1,663 @@ +using System; +using System.Collections.Generic; +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Models.CustomMetadataFields; + +namespace ImageKit.Tests.Models.CustomMetadataFields; + +public class CustomMetadataFieldUpdateParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new CustomMetadataFieldUpdateParams + { + ID = "id", + Label = "price", + Schema = new() + { + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = 3000, + MinLength = 0, + MinValue = 1000, + SelectOptions = ["small", "medium", "large", 30, 40, true], + }, + }; + + string expectedID = "id"; + string expectedLabel = "price"; + CustomMetadataFieldUpdateParamsSchema expectedSchema = new() + { + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = 3000, + MinLength = 0, + MinValue = 1000, + SelectOptions = ["small", "medium", "large", 30, 40, true], + }; + + Assert.Equal(expectedID, parameters.ID); + Assert.Equal(expectedLabel, parameters.Label); + Assert.Equal(expectedSchema, parameters.Schema); + } + + [Fact] + public void OptionalNonNullableParamsUnsetAreNotSet_Works() + { + var parameters = new CustomMetadataFieldUpdateParams { ID = "id" }; + + Assert.Null(parameters.Label); + Assert.False(parameters.RawBodyData.ContainsKey("label")); + Assert.Null(parameters.Schema); + Assert.False(parameters.RawBodyData.ContainsKey("schema")); + } + + [Fact] + public void OptionalNonNullableParamsSetToNullAreNotSet_Works() + { + var parameters = new CustomMetadataFieldUpdateParams + { + ID = "id", + + // Null should be interpreted as omitted for these properties + Label = null, + Schema = null, + }; + + Assert.Null(parameters.Label); + Assert.False(parameters.RawBodyData.ContainsKey("label")); + Assert.Null(parameters.Schema); + Assert.False(parameters.RawBodyData.ContainsKey("schema")); + } + + [Fact] + public void Url_Works() + { + CustomMetadataFieldUpdateParams parameters = new() { ID = "id" }; + + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + + Assert.Equal(new Uri("https://api.imagekit.io/v1/customMetadataFields/id"), url); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new CustomMetadataFieldUpdateParams + { + ID = "id", + Label = "price", + Schema = new() + { + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = 3000, + MinLength = 0, + MinValue = 1000, + SelectOptions = ["small", "medium", "large", 30, 40, true], + }, + }; + + CustomMetadataFieldUpdateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} + +public class CustomMetadataFieldUpdateParamsSchemaTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new CustomMetadataFieldUpdateParamsSchema + { + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + SelectOptions = ["small", "medium", "large", 30, 40, true], + }; + + CustomMetadataFieldUpdateParamsSchemaDefaultValue expectedDefaultValue = "string"; + bool expectedIsValueRequired = true; + double expectedMaxLength = 0; + CustomMetadataFieldUpdateParamsSchemaMaxValue expectedMaxValue = "string"; + double expectedMinLength = 0; + CustomMetadataFieldUpdateParamsSchemaMinValue expectedMinValue = "string"; + List expectedSelectOptions = + [ + "small", + "medium", + "large", + 30, + 40, + true, + ]; + + Assert.Equal(expectedDefaultValue, model.DefaultValue); + Assert.Equal(expectedIsValueRequired, model.IsValueRequired); + Assert.Equal(expectedMaxLength, model.MaxLength); + Assert.Equal(expectedMaxValue, model.MaxValue); + Assert.Equal(expectedMinLength, model.MinLength); + Assert.Equal(expectedMinValue, model.MinValue); + Assert.NotNull(model.SelectOptions); + Assert.Equal(expectedSelectOptions.Count, model.SelectOptions.Count); + for (int i = 0; i < expectedSelectOptions.Count; i++) + { + Assert.Equal(expectedSelectOptions[i], model.SelectOptions[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new CustomMetadataFieldUpdateParamsSchema + { + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + SelectOptions = ["small", "medium", "large", 30, 40, true], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new CustomMetadataFieldUpdateParamsSchema + { + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + SelectOptions = ["small", "medium", "large", 30, 40, true], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + CustomMetadataFieldUpdateParamsSchemaDefaultValue expectedDefaultValue = "string"; + bool expectedIsValueRequired = true; + double expectedMaxLength = 0; + CustomMetadataFieldUpdateParamsSchemaMaxValue expectedMaxValue = "string"; + double expectedMinLength = 0; + CustomMetadataFieldUpdateParamsSchemaMinValue expectedMinValue = "string"; + List expectedSelectOptions = + [ + "small", + "medium", + "large", + 30, + 40, + true, + ]; + + Assert.Equal(expectedDefaultValue, deserialized.DefaultValue); + Assert.Equal(expectedIsValueRequired, deserialized.IsValueRequired); + Assert.Equal(expectedMaxLength, deserialized.MaxLength); + Assert.Equal(expectedMaxValue, deserialized.MaxValue); + Assert.Equal(expectedMinLength, deserialized.MinLength); + Assert.Equal(expectedMinValue, deserialized.MinValue); + Assert.NotNull(deserialized.SelectOptions); + Assert.Equal(expectedSelectOptions.Count, deserialized.SelectOptions.Count); + for (int i = 0; i < expectedSelectOptions.Count; i++) + { + Assert.Equal(expectedSelectOptions[i], deserialized.SelectOptions[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new CustomMetadataFieldUpdateParamsSchema + { + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + SelectOptions = ["small", "medium", "large", 30, 40, true], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new CustomMetadataFieldUpdateParamsSchema { }; + + Assert.Null(model.DefaultValue); + Assert.False(model.RawData.ContainsKey("defaultValue")); + Assert.Null(model.IsValueRequired); + Assert.False(model.RawData.ContainsKey("isValueRequired")); + Assert.Null(model.MaxLength); + Assert.False(model.RawData.ContainsKey("maxLength")); + Assert.Null(model.MaxValue); + Assert.False(model.RawData.ContainsKey("maxValue")); + Assert.Null(model.MinLength); + Assert.False(model.RawData.ContainsKey("minLength")); + Assert.Null(model.MinValue); + Assert.False(model.RawData.ContainsKey("minValue")); + Assert.Null(model.SelectOptions); + Assert.False(model.RawData.ContainsKey("selectOptions")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new CustomMetadataFieldUpdateParamsSchema { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new CustomMetadataFieldUpdateParamsSchema + { + // Null should be interpreted as omitted for these properties + DefaultValue = null, + IsValueRequired = null, + MaxLength = null, + MaxValue = null, + MinLength = null, + MinValue = null, + SelectOptions = null, + }; + + Assert.Null(model.DefaultValue); + Assert.False(model.RawData.ContainsKey("defaultValue")); + Assert.Null(model.IsValueRequired); + Assert.False(model.RawData.ContainsKey("isValueRequired")); + Assert.Null(model.MaxLength); + Assert.False(model.RawData.ContainsKey("maxLength")); + Assert.Null(model.MaxValue); + Assert.False(model.RawData.ContainsKey("maxValue")); + Assert.Null(model.MinLength); + Assert.False(model.RawData.ContainsKey("minLength")); + Assert.Null(model.MinValue); + Assert.False(model.RawData.ContainsKey("minValue")); + Assert.Null(model.SelectOptions); + Assert.False(model.RawData.ContainsKey("selectOptions")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new CustomMetadataFieldUpdateParamsSchema + { + // Null should be interpreted as omitted for these properties + DefaultValue = null, + IsValueRequired = null, + MaxLength = null, + MaxValue = null, + MinLength = null, + MinValue = null, + SelectOptions = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CustomMetadataFieldUpdateParamsSchema + { + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + SelectOptions = ["small", "medium", "large", 30, 40, true], + }; + + CustomMetadataFieldUpdateParamsSchema copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class CustomMetadataFieldUpdateParamsSchemaDefaultValueTest : TestBase +{ + [Fact] + public void StringValidationWorks() + { + CustomMetadataFieldUpdateParamsSchemaDefaultValue value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + CustomMetadataFieldUpdateParamsSchemaDefaultValue value = 0; + value.Validate(); + } + + [Fact] + public void BoolValidationWorks() + { + CustomMetadataFieldUpdateParamsSchemaDefaultValue value = true; + value.Validate(); + } + + [Fact] + public void MixedValidationWorks() + { + CustomMetadataFieldUpdateParamsSchemaDefaultValue value = new( + [ + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), + ] + ); + value.Validate(); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + CustomMetadataFieldUpdateParamsSchemaDefaultValue value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + CustomMetadataFieldUpdateParamsSchemaDefaultValue value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void BoolSerializationRoundtripWorks() + { + CustomMetadataFieldUpdateParamsSchemaDefaultValue value = true; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void MixedSerializationRoundtripWorks() + { + CustomMetadataFieldUpdateParamsSchemaDefaultValue value = new( + [ + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), + ] + ); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class UnnamedSchemaWithArrayParent2Test : TestBase +{ + [Fact] + public void StringValidationWorks() + { + UnnamedSchemaWithArrayParent2 value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + UnnamedSchemaWithArrayParent2 value = 0; + value.Validate(); + } + + [Fact] + public void BoolValidationWorks() + { + UnnamedSchemaWithArrayParent2 value = true; + value.Validate(); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent2 value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent2 value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void BoolSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent2 value = true; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class CustomMetadataFieldUpdateParamsSchemaMaxValueTest : TestBase +{ + [Fact] + public void StringValidationWorks() + { + CustomMetadataFieldUpdateParamsSchemaMaxValue value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + CustomMetadataFieldUpdateParamsSchemaMaxValue value = 0; + value.Validate(); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + CustomMetadataFieldUpdateParamsSchemaMaxValue value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + CustomMetadataFieldUpdateParamsSchemaMaxValue value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class CustomMetadataFieldUpdateParamsSchemaMinValueTest : TestBase +{ + [Fact] + public void StringValidationWorks() + { + CustomMetadataFieldUpdateParamsSchemaMinValue value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + CustomMetadataFieldUpdateParamsSchemaMinValue value = 0; + value.Validate(); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + CustomMetadataFieldUpdateParamsSchemaMinValue value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + CustomMetadataFieldUpdateParamsSchemaMinValue value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class CustomMetadataFieldUpdateParamsSchemaSelectOptionTest : TestBase +{ + [Fact] + public void StringValidationWorks() + { + CustomMetadataFieldUpdateParamsSchemaSelectOption value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + CustomMetadataFieldUpdateParamsSchemaSelectOption value = 0; + value.Validate(); + } + + [Fact] + public void BoolValidationWorks() + { + CustomMetadataFieldUpdateParamsSchemaSelectOption value = true; + value.Validate(); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + CustomMetadataFieldUpdateParamsSchemaSelectOption value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + CustomMetadataFieldUpdateParamsSchemaSelectOption value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void BoolSerializationRoundtripWorks() + { + CustomMetadataFieldUpdateParamsSchemaSelectOption value = true; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} diff --git a/src/ImageKit.Tests/Models/ExtensionConfigTest.cs b/src/ImageKit.Tests/Models/ExtensionConfigTest.cs new file mode 100644 index 00000000..62940855 --- /dev/null +++ b/src/ImageKit.Tests/Models/ExtensionConfigTest.cs @@ -0,0 +1,3145 @@ +using System.Collections.Generic; +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Exceptions; +using ImageKit.Models; + +namespace ImageKit.Tests.Models; + +public class ExtensionConfigTest : TestBase +{ + [Fact] + public void RemoveBgValidationWorks() + { + ExtensionConfig value = new RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }; + value.Validate(); + } + + [Fact] + public void AutoTaggingExtensionValidationWorks() + { + ExtensionConfig value = new AutoTaggingExtension() + { + MaxTags = 0, + MinConfidence = 0, + Name = Name.GoogleAutoTagging, + }; + value.Validate(); + } + + [Fact] + public void AIAutoDescriptionValidationWorks() + { + ExtensionConfig value = new AIAutoDescription(); + value.Validate(); + } + + [Fact] + public void AITasksValidationWorks() + { + ExtensionConfig value = new AITasks( + [ + new SelectTags() + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }, + ] + ); + value.Validate(); + } + + [Fact] + public void RemoveBgSerializationRoundtripWorks() + { + ExtensionConfig value = new RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void AutoTaggingExtensionSerializationRoundtripWorks() + { + ExtensionConfig value = new AutoTaggingExtension() + { + MaxTags = 0, + MinConfidence = 0, + Name = Name.GoogleAutoTagging, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void AIAutoDescriptionSerializationRoundtripWorks() + { + ExtensionConfig value = new AIAutoDescription(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void AITasksSerializationRoundtripWorks() + { + ExtensionConfig value = new AITasks( + [ + new SelectTags() + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }, + ] + ); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class RemoveBgTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new RemoveBg + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }; + + JsonElement expectedName = JsonSerializer.SerializeToElement("remove-bg"); + Options expectedOptions = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }; + + Assert.True(JsonElement.DeepEquals(expectedName, model.Name)); + Assert.Equal(expectedOptions, model.Options); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new RemoveBg + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new RemoveBg + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + JsonElement expectedName = JsonSerializer.SerializeToElement("remove-bg"); + Options expectedOptions = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }; + + Assert.True(JsonElement.DeepEquals(expectedName, deserialized.Name)); + Assert.Equal(expectedOptions, deserialized.Options); + } + + [Fact] + public void Validation_Works() + { + var model = new RemoveBg + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new RemoveBg { }; + + Assert.Null(model.Options); + Assert.False(model.RawData.ContainsKey("options")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new RemoveBg { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new RemoveBg + { + // Null should be interpreted as omitted for these properties + Options = null, + }; + + Assert.Null(model.Options); + Assert.False(model.RawData.ContainsKey("options")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new RemoveBg + { + // Null should be interpreted as omitted for these properties + Options = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new RemoveBg + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }; + + RemoveBg copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class OptionsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Options + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }; + + bool expectedAddShadow = true; + string expectedBgColor = "bg_color"; + string expectedBgImageUrl = "bg_image_url"; + bool expectedSemitransparency = true; + + Assert.Equal(expectedAddShadow, model.AddShadow); + Assert.Equal(expectedBgColor, model.BgColor); + Assert.Equal(expectedBgImageUrl, model.BgImageUrl); + Assert.Equal(expectedSemitransparency, model.Semitransparency); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Options + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Options + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + bool expectedAddShadow = true; + string expectedBgColor = "bg_color"; + string expectedBgImageUrl = "bg_image_url"; + bool expectedSemitransparency = true; + + Assert.Equal(expectedAddShadow, deserialized.AddShadow); + Assert.Equal(expectedBgColor, deserialized.BgColor); + Assert.Equal(expectedBgImageUrl, deserialized.BgImageUrl); + Assert.Equal(expectedSemitransparency, deserialized.Semitransparency); + } + + [Fact] + public void Validation_Works() + { + var model = new Options + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Options { }; + + Assert.Null(model.AddShadow); + Assert.False(model.RawData.ContainsKey("add_shadow")); + Assert.Null(model.BgColor); + Assert.False(model.RawData.ContainsKey("bg_color")); + Assert.Null(model.BgImageUrl); + Assert.False(model.RawData.ContainsKey("bg_image_url")); + Assert.Null(model.Semitransparency); + Assert.False(model.RawData.ContainsKey("semitransparency")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new Options { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new Options + { + // Null should be interpreted as omitted for these properties + AddShadow = null, + BgColor = null, + BgImageUrl = null, + Semitransparency = null, + }; + + Assert.Null(model.AddShadow); + Assert.False(model.RawData.ContainsKey("add_shadow")); + Assert.Null(model.BgColor); + Assert.False(model.RawData.ContainsKey("bg_color")); + Assert.Null(model.BgImageUrl); + Assert.False(model.RawData.ContainsKey("bg_image_url")); + Assert.Null(model.Semitransparency); + Assert.False(model.RawData.ContainsKey("semitransparency")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new Options + { + // Null should be interpreted as omitted for these properties + AddShadow = null, + BgColor = null, + BgImageUrl = null, + Semitransparency = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Options + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }; + + Options copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class AutoTaggingExtensionTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new AutoTaggingExtension + { + MaxTags = 0, + MinConfidence = 0, + Name = Name.GoogleAutoTagging, + }; + + long expectedMaxTags = 0; + long expectedMinConfidence = 0; + ApiEnum expectedName = Name.GoogleAutoTagging; + + Assert.Equal(expectedMaxTags, model.MaxTags); + Assert.Equal(expectedMinConfidence, model.MinConfidence); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new AutoTaggingExtension + { + MaxTags = 0, + MinConfidence = 0, + Name = Name.GoogleAutoTagging, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new AutoTaggingExtension + { + MaxTags = 0, + MinConfidence = 0, + Name = Name.GoogleAutoTagging, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + long expectedMaxTags = 0; + long expectedMinConfidence = 0; + ApiEnum expectedName = Name.GoogleAutoTagging; + + Assert.Equal(expectedMaxTags, deserialized.MaxTags); + Assert.Equal(expectedMinConfidence, deserialized.MinConfidence); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new AutoTaggingExtension + { + MaxTags = 0, + MinConfidence = 0, + Name = Name.GoogleAutoTagging, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new AutoTaggingExtension + { + MaxTags = 0, + MinConfidence = 0, + Name = Name.GoogleAutoTagging, + }; + + AutoTaggingExtension copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class NameTest : TestBase +{ + [Theory] + [InlineData(Name.GoogleAutoTagging)] + [InlineData(Name.AwsAutoTagging)] + public void Validation_Works(Name rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(Name.GoogleAutoTagging)] + [InlineData(Name.AwsAutoTagging)] + public void SerializationRoundtrip_Works(Name rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class AIAutoDescriptionTest : TestBase +{ + [Fact] + public void DefaultValidation_Works() + { + var constant = new AIAutoDescription(); + constant.Validate(); + } + + [Fact] + public void ValidConstantValidation_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.Deserialize( + """ + { + "name": "ai-auto-description" + } + """ + ), + ModelBase.SerializerOptions + ); + + Assert.NotNull(constant); + constant.Validate(); + } + + [Fact] + public void InvalidConstantValidationThrows_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(constant); + Assert.Throws(() => constant.Validate()); + } + + [Fact] + public void DefaultRoundtrip_Works() + { + var constant = new AIAutoDescription(); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } + + [Fact] + public void ValidConstantRoundtrip_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.Deserialize( + """ + { + "name": "ai-auto-description" + } + """ + ), + ModelBase.SerializerOptions + ); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } + + [Fact] + public void InvalidConstantRoundtrip_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } +} + +public class AITasksTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new AITasks + { + Tasks = + [ + new SelectTags() + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }, + ], + }; + + JsonElement expectedName = JsonSerializer.SerializeToElement("ai-tasks"); + List expectedTasks = + [ + new SelectTags() + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }, + ]; + + Assert.True(JsonElement.DeepEquals(expectedName, model.Name)); + Assert.Equal(expectedTasks.Count, model.Tasks.Count); + for (int i = 0; i < expectedTasks.Count; i++) + { + Assert.Equal(expectedTasks[i], model.Tasks[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new AITasks + { + Tasks = + [ + new SelectTags() + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }, + ], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new AITasks + { + Tasks = + [ + new SelectTags() + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + JsonElement expectedName = JsonSerializer.SerializeToElement("ai-tasks"); + List expectedTasks = + [ + new SelectTags() + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }, + ]; + + Assert.True(JsonElement.DeepEquals(expectedName, deserialized.Name)); + Assert.Equal(expectedTasks.Count, deserialized.Tasks.Count); + for (int i = 0; i < expectedTasks.Count; i++) + { + Assert.Equal(expectedTasks[i], deserialized.Tasks[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new AITasks + { + Tasks = + [ + new SelectTags() + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new AITasks + { + Tasks = + [ + new SelectTags() + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }, + ], + }; + + AITasks copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TaskTest : TestBase +{ + [Fact] + public void SelectTagsValidationWorks() + { + Task value = new SelectTags() + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }; + value.Validate(); + } + + [Fact] + public void SelectMetadataValidationWorks() + { + Task value = new SelectMetadata() + { + Field = "primary_color", + Instruction = "What is the primary color of the clothing?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["red", "blue", "green", "black", "white"], + }; + value.Validate(); + } + + [Fact] + public void YesNoValidationWorks() + { + Task value = new YesNo() + { + Instruction = "Is this a luxury or high-end fashion item?", + OnNo = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnUnknown = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnYes = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + }; + value.Validate(); + } + + [Fact] + public void SelectTagsSerializationRoundtripWorks() + { + Task value = new SelectTags() + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void SelectMetadataSerializationRoundtripWorks() + { + Task value = new SelectMetadata() + { + Field = "primary_color", + Instruction = "What is the primary color of the clothing?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["red", "blue", "green", "black", "white"], + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void YesNoSerializationRoundtripWorks() + { + Task value = new YesNo() + { + Instruction = "Is this a luxury or high-end fashion item?", + OnNo = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnUnknown = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnYes = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class SelectTagsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new SelectTags + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }; + + string expectedInstruction = "What types of clothing items are visible in this image?"; + JsonElement expectedType = JsonSerializer.SerializeToElement("select_tags"); + long expectedMaxSelections = 1; + long expectedMinSelections = 0; + List expectedVocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"]; + + Assert.Equal(expectedInstruction, model.Instruction); + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + Assert.Equal(expectedMaxSelections, model.MaxSelections); + Assert.Equal(expectedMinSelections, model.MinSelections); + Assert.NotNull(model.Vocabulary); + Assert.Equal(expectedVocabulary.Count, model.Vocabulary.Count); + for (int i = 0; i < expectedVocabulary.Count; i++) + { + Assert.Equal(expectedVocabulary[i], model.Vocabulary[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new SelectTags + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new SelectTags + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedInstruction = "What types of clothing items are visible in this image?"; + JsonElement expectedType = JsonSerializer.SerializeToElement("select_tags"); + long expectedMaxSelections = 1; + long expectedMinSelections = 0; + List expectedVocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"]; + + Assert.Equal(expectedInstruction, deserialized.Instruction); + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + Assert.Equal(expectedMaxSelections, deserialized.MaxSelections); + Assert.Equal(expectedMinSelections, deserialized.MinSelections); + Assert.NotNull(deserialized.Vocabulary); + Assert.Equal(expectedVocabulary.Count, deserialized.Vocabulary.Count); + for (int i = 0; i < expectedVocabulary.Count; i++) + { + Assert.Equal(expectedVocabulary[i], deserialized.Vocabulary[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new SelectTags + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new SelectTags + { + Instruction = "What types of clothing items are visible in this image?", + }; + + Assert.Null(model.MaxSelections); + Assert.False(model.RawData.ContainsKey("max_selections")); + Assert.Null(model.MinSelections); + Assert.False(model.RawData.ContainsKey("min_selections")); + Assert.Null(model.Vocabulary); + Assert.False(model.RawData.ContainsKey("vocabulary")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new SelectTags + { + Instruction = "What types of clothing items are visible in this image?", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new SelectTags + { + Instruction = "What types of clothing items are visible in this image?", + + // Null should be interpreted as omitted for these properties + MaxSelections = null, + MinSelections = null, + Vocabulary = null, + }; + + Assert.Null(model.MaxSelections); + Assert.False(model.RawData.ContainsKey("max_selections")); + Assert.Null(model.MinSelections); + Assert.False(model.RawData.ContainsKey("min_selections")); + Assert.Null(model.Vocabulary); + Assert.False(model.RawData.ContainsKey("vocabulary")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new SelectTags + { + Instruction = "What types of clothing items are visible in this image?", + + // Null should be interpreted as omitted for these properties + MaxSelections = null, + MinSelections = null, + Vocabulary = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new SelectTags + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }; + + SelectTags copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class SelectMetadataTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new SelectMetadata + { + Field = "primary_color", + Instruction = "What is the primary color of the clothing?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["red", "blue", "green", "black", "white"], + }; + + string expectedField = "primary_color"; + string expectedInstruction = "What is the primary color of the clothing?"; + JsonElement expectedType = JsonSerializer.SerializeToElement("select_metadata"); + long expectedMaxSelections = 1; + long expectedMinSelections = 0; + List expectedVocabulary = ["red", "blue", "green", "black", "white"]; + + Assert.Equal(expectedField, model.Field); + Assert.Equal(expectedInstruction, model.Instruction); + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + Assert.Equal(expectedMaxSelections, model.MaxSelections); + Assert.Equal(expectedMinSelections, model.MinSelections); + Assert.NotNull(model.Vocabulary); + Assert.Equal(expectedVocabulary.Count, model.Vocabulary.Count); + for (int i = 0; i < expectedVocabulary.Count; i++) + { + Assert.Equal(expectedVocabulary[i], model.Vocabulary[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new SelectMetadata + { + Field = "primary_color", + Instruction = "What is the primary color of the clothing?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["red", "blue", "green", "black", "white"], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new SelectMetadata + { + Field = "primary_color", + Instruction = "What is the primary color of the clothing?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["red", "blue", "green", "black", "white"], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedField = "primary_color"; + string expectedInstruction = "What is the primary color of the clothing?"; + JsonElement expectedType = JsonSerializer.SerializeToElement("select_metadata"); + long expectedMaxSelections = 1; + long expectedMinSelections = 0; + List expectedVocabulary = ["red", "blue", "green", "black", "white"]; + + Assert.Equal(expectedField, deserialized.Field); + Assert.Equal(expectedInstruction, deserialized.Instruction); + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + Assert.Equal(expectedMaxSelections, deserialized.MaxSelections); + Assert.Equal(expectedMinSelections, deserialized.MinSelections); + Assert.NotNull(deserialized.Vocabulary); + Assert.Equal(expectedVocabulary.Count, deserialized.Vocabulary.Count); + for (int i = 0; i < expectedVocabulary.Count; i++) + { + Assert.Equal(expectedVocabulary[i], deserialized.Vocabulary[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new SelectMetadata + { + Field = "primary_color", + Instruction = "What is the primary color of the clothing?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["red", "blue", "green", "black", "white"], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new SelectMetadata + { + Field = "primary_color", + Instruction = "What is the primary color of the clothing?", + }; + + Assert.Null(model.MaxSelections); + Assert.False(model.RawData.ContainsKey("max_selections")); + Assert.Null(model.MinSelections); + Assert.False(model.RawData.ContainsKey("min_selections")); + Assert.Null(model.Vocabulary); + Assert.False(model.RawData.ContainsKey("vocabulary")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new SelectMetadata + { + Field = "primary_color", + Instruction = "What is the primary color of the clothing?", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new SelectMetadata + { + Field = "primary_color", + Instruction = "What is the primary color of the clothing?", + + // Null should be interpreted as omitted for these properties + MaxSelections = null, + MinSelections = null, + Vocabulary = null, + }; + + Assert.Null(model.MaxSelections); + Assert.False(model.RawData.ContainsKey("max_selections")); + Assert.Null(model.MinSelections); + Assert.False(model.RawData.ContainsKey("min_selections")); + Assert.Null(model.Vocabulary); + Assert.False(model.RawData.ContainsKey("vocabulary")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new SelectMetadata + { + Field = "primary_color", + Instruction = "What is the primary color of the clothing?", + + // Null should be interpreted as omitted for these properties + MaxSelections = null, + MinSelections = null, + Vocabulary = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new SelectMetadata + { + Field = "primary_color", + Instruction = "What is the primary color of the clothing?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["red", "blue", "green", "black", "white"], + }; + + SelectMetadata copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class VocabularyTest : TestBase +{ + [Fact] + public void StringValidationWorks() + { + Vocabulary value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + Vocabulary value = 0; + value.Validate(); + } + + [Fact] + public void BoolValidationWorks() + { + Vocabulary value = true; + value.Validate(); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + Vocabulary value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + Vocabulary value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void BoolSerializationRoundtripWorks() + { + Vocabulary value = true; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class YesNoTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new YesNo + { + Instruction = "Is this a luxury or high-end fashion item?", + OnNo = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnUnknown = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnYes = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + }; + + string expectedInstruction = "Is this a luxury or high-end fashion item?"; + JsonElement expectedType = JsonSerializer.SerializeToElement("yes_no"); + OnNo expectedOnNo = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }; + OnUnknown expectedOnUnknown = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }; + OnYes expectedOnYes = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }; + + Assert.Equal(expectedInstruction, model.Instruction); + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + Assert.Equal(expectedOnNo, model.OnNo); + Assert.Equal(expectedOnUnknown, model.OnUnknown); + Assert.Equal(expectedOnYes, model.OnYes); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new YesNo + { + Instruction = "Is this a luxury or high-end fashion item?", + OnNo = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnUnknown = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnYes = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new YesNo + { + Instruction = "Is this a luxury or high-end fashion item?", + OnNo = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnUnknown = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnYes = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + Assert.NotNull(deserialized); + + string expectedInstruction = "Is this a luxury or high-end fashion item?"; + JsonElement expectedType = JsonSerializer.SerializeToElement("yes_no"); + OnNo expectedOnNo = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }; + OnUnknown expectedOnUnknown = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }; + OnYes expectedOnYes = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }; + + Assert.Equal(expectedInstruction, deserialized.Instruction); + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + Assert.Equal(expectedOnNo, deserialized.OnNo); + Assert.Equal(expectedOnUnknown, deserialized.OnUnknown); + Assert.Equal(expectedOnYes, deserialized.OnYes); + } + + [Fact] + public void Validation_Works() + { + var model = new YesNo + { + Instruction = "Is this a luxury or high-end fashion item?", + OnNo = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnUnknown = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnYes = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new YesNo { Instruction = "Is this a luxury or high-end fashion item?" }; + + Assert.Null(model.OnNo); + Assert.False(model.RawData.ContainsKey("on_no")); + Assert.Null(model.OnUnknown); + Assert.False(model.RawData.ContainsKey("on_unknown")); + Assert.Null(model.OnYes); + Assert.False(model.RawData.ContainsKey("on_yes")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new YesNo { Instruction = "Is this a luxury or high-end fashion item?" }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new YesNo + { + Instruction = "Is this a luxury or high-end fashion item?", + + // Null should be interpreted as omitted for these properties + OnNo = null, + OnUnknown = null, + OnYes = null, + }; + + Assert.Null(model.OnNo); + Assert.False(model.RawData.ContainsKey("on_no")); + Assert.Null(model.OnUnknown); + Assert.False(model.RawData.ContainsKey("on_unknown")); + Assert.Null(model.OnYes); + Assert.False(model.RawData.ContainsKey("on_yes")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new YesNo + { + Instruction = "Is this a luxury or high-end fashion item?", + + // Null should be interpreted as omitted for these properties + OnNo = null, + OnUnknown = null, + OnYes = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new YesNo + { + Instruction = "Is this a luxury or high-end fashion item?", + OnNo = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnUnknown = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnYes = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + }; + + YesNo copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class OnNoTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new OnNo + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }; + + List expectedAddTags = ["luxury", "premium"]; + List expectedRemoveTags = ["budget", "affordable"]; + List expectedSetMetadata = + [ + new() { Field = "price_range", Value = "premium" }, + ]; + List expectedUnsetMetadata = [new("price_range")]; + + Assert.NotNull(model.AddTags); + Assert.Equal(expectedAddTags.Count, model.AddTags.Count); + for (int i = 0; i < expectedAddTags.Count; i++) + { + Assert.Equal(expectedAddTags[i], model.AddTags[i]); + } + Assert.NotNull(model.RemoveTags); + Assert.Equal(expectedRemoveTags.Count, model.RemoveTags.Count); + for (int i = 0; i < expectedRemoveTags.Count; i++) + { + Assert.Equal(expectedRemoveTags[i], model.RemoveTags[i]); + } + Assert.NotNull(model.SetMetadata); + Assert.Equal(expectedSetMetadata.Count, model.SetMetadata.Count); + for (int i = 0; i < expectedSetMetadata.Count; i++) + { + Assert.Equal(expectedSetMetadata[i], model.SetMetadata[i]); + } + Assert.NotNull(model.UnsetMetadata); + Assert.Equal(expectedUnsetMetadata.Count, model.UnsetMetadata.Count); + for (int i = 0; i < expectedUnsetMetadata.Count; i++) + { + Assert.Equal(expectedUnsetMetadata[i], model.UnsetMetadata[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new OnNo + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new OnNo + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + Assert.NotNull(deserialized); + + List expectedAddTags = ["luxury", "premium"]; + List expectedRemoveTags = ["budget", "affordable"]; + List expectedSetMetadata = + [ + new() { Field = "price_range", Value = "premium" }, + ]; + List expectedUnsetMetadata = [new("price_range")]; + + Assert.NotNull(deserialized.AddTags); + Assert.Equal(expectedAddTags.Count, deserialized.AddTags.Count); + for (int i = 0; i < expectedAddTags.Count; i++) + { + Assert.Equal(expectedAddTags[i], deserialized.AddTags[i]); + } + Assert.NotNull(deserialized.RemoveTags); + Assert.Equal(expectedRemoveTags.Count, deserialized.RemoveTags.Count); + for (int i = 0; i < expectedRemoveTags.Count; i++) + { + Assert.Equal(expectedRemoveTags[i], deserialized.RemoveTags[i]); + } + Assert.NotNull(deserialized.SetMetadata); + Assert.Equal(expectedSetMetadata.Count, deserialized.SetMetadata.Count); + for (int i = 0; i < expectedSetMetadata.Count; i++) + { + Assert.Equal(expectedSetMetadata[i], deserialized.SetMetadata[i]); + } + Assert.NotNull(deserialized.UnsetMetadata); + Assert.Equal(expectedUnsetMetadata.Count, deserialized.UnsetMetadata.Count); + for (int i = 0; i < expectedUnsetMetadata.Count; i++) + { + Assert.Equal(expectedUnsetMetadata[i], deserialized.UnsetMetadata[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new OnNo + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new OnNo { }; + + Assert.Null(model.AddTags); + Assert.False(model.RawData.ContainsKey("add_tags")); + Assert.Null(model.RemoveTags); + Assert.False(model.RawData.ContainsKey("remove_tags")); + Assert.Null(model.SetMetadata); + Assert.False(model.RawData.ContainsKey("set_metadata")); + Assert.Null(model.UnsetMetadata); + Assert.False(model.RawData.ContainsKey("unset_metadata")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new OnNo { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new OnNo + { + // Null should be interpreted as omitted for these properties + AddTags = null, + RemoveTags = null, + SetMetadata = null, + UnsetMetadata = null, + }; + + Assert.Null(model.AddTags); + Assert.False(model.RawData.ContainsKey("add_tags")); + Assert.Null(model.RemoveTags); + Assert.False(model.RawData.ContainsKey("remove_tags")); + Assert.Null(model.SetMetadata); + Assert.False(model.RawData.ContainsKey("set_metadata")); + Assert.Null(model.UnsetMetadata); + Assert.False(model.RawData.ContainsKey("unset_metadata")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new OnNo + { + // Null should be interpreted as omitted for these properties + AddTags = null, + RemoveTags = null, + SetMetadata = null, + UnsetMetadata = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new OnNo + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }; + + OnNo copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class SetMetadataTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new SetMetadata { Field = "field", Value = "string" }; + + string expectedField = "field"; + SetMetadataValue expectedValue = "string"; + + Assert.Equal(expectedField, model.Field); + Assert.Equal(expectedValue, model.Value); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new SetMetadata { Field = "field", Value = "string" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new SetMetadata { Field = "field", Value = "string" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedField = "field"; + SetMetadataValue expectedValue = "string"; + + Assert.Equal(expectedField, deserialized.Field); + Assert.Equal(expectedValue, deserialized.Value); + } + + [Fact] + public void Validation_Works() + { + var model = new SetMetadata { Field = "field", Value = "string" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new SetMetadata { Field = "field", Value = "string" }; + + SetMetadata copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class SetMetadataValueTest : TestBase +{ + [Fact] + public void StringValidationWorks() + { + SetMetadataValue value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + SetMetadataValue value = 0; + value.Validate(); + } + + [Fact] + public void BoolValidationWorks() + { + SetMetadataValue value = true; + value.Validate(); + } + + [Fact] + public void MixedValidationWorks() + { + SetMetadataValue value = new([new UnnamedSchemaWithArrayParent3("string")]); + value.Validate(); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + SetMetadataValue value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + SetMetadataValue value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void BoolSerializationRoundtripWorks() + { + SetMetadataValue value = true; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void MixedSerializationRoundtripWorks() + { + SetMetadataValue value = new([new UnnamedSchemaWithArrayParent3("string")]); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class UnnamedSchemaWithArrayParent3Test : TestBase +{ + [Fact] + public void StringValidationWorks() + { + UnnamedSchemaWithArrayParent3 value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + UnnamedSchemaWithArrayParent3 value = 0; + value.Validate(); + } + + [Fact] + public void BoolValidationWorks() + { + UnnamedSchemaWithArrayParent3 value = true; + value.Validate(); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent3 value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent3 value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void BoolSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent3 value = true; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class UnsetMetadataTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UnsetMetadata { Field = "field" }; + + string expectedField = "field"; + + Assert.Equal(expectedField, model.Field); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UnsetMetadata { Field = "field" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new UnsetMetadata { Field = "field" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedField = "field"; + + Assert.Equal(expectedField, deserialized.Field); + } + + [Fact] + public void Validation_Works() + { + var model = new UnsetMetadata { Field = "field" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnsetMetadata { Field = "field" }; + + UnsetMetadata copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class OnUnknownTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new OnUnknown + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }; + + List expectedAddTags = ["luxury", "premium"]; + List expectedRemoveTags = ["budget", "affordable"]; + List expectedSetMetadata = + [ + new() { Field = "price_range", Value = "premium" }, + ]; + List expectedUnsetMetadata = [new("price_range")]; + + Assert.NotNull(model.AddTags); + Assert.Equal(expectedAddTags.Count, model.AddTags.Count); + for (int i = 0; i < expectedAddTags.Count; i++) + { + Assert.Equal(expectedAddTags[i], model.AddTags[i]); + } + Assert.NotNull(model.RemoveTags); + Assert.Equal(expectedRemoveTags.Count, model.RemoveTags.Count); + for (int i = 0; i < expectedRemoveTags.Count; i++) + { + Assert.Equal(expectedRemoveTags[i], model.RemoveTags[i]); + } + Assert.NotNull(model.SetMetadata); + Assert.Equal(expectedSetMetadata.Count, model.SetMetadata.Count); + for (int i = 0; i < expectedSetMetadata.Count; i++) + { + Assert.Equal(expectedSetMetadata[i], model.SetMetadata[i]); + } + Assert.NotNull(model.UnsetMetadata); + Assert.Equal(expectedUnsetMetadata.Count, model.UnsetMetadata.Count); + for (int i = 0; i < expectedUnsetMetadata.Count; i++) + { + Assert.Equal(expectedUnsetMetadata[i], model.UnsetMetadata[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new OnUnknown + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new OnUnknown + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedAddTags = ["luxury", "premium"]; + List expectedRemoveTags = ["budget", "affordable"]; + List expectedSetMetadata = + [ + new() { Field = "price_range", Value = "premium" }, + ]; + List expectedUnsetMetadata = [new("price_range")]; + + Assert.NotNull(deserialized.AddTags); + Assert.Equal(expectedAddTags.Count, deserialized.AddTags.Count); + for (int i = 0; i < expectedAddTags.Count; i++) + { + Assert.Equal(expectedAddTags[i], deserialized.AddTags[i]); + } + Assert.NotNull(deserialized.RemoveTags); + Assert.Equal(expectedRemoveTags.Count, deserialized.RemoveTags.Count); + for (int i = 0; i < expectedRemoveTags.Count; i++) + { + Assert.Equal(expectedRemoveTags[i], deserialized.RemoveTags[i]); + } + Assert.NotNull(deserialized.SetMetadata); + Assert.Equal(expectedSetMetadata.Count, deserialized.SetMetadata.Count); + for (int i = 0; i < expectedSetMetadata.Count; i++) + { + Assert.Equal(expectedSetMetadata[i], deserialized.SetMetadata[i]); + } + Assert.NotNull(deserialized.UnsetMetadata); + Assert.Equal(expectedUnsetMetadata.Count, deserialized.UnsetMetadata.Count); + for (int i = 0; i < expectedUnsetMetadata.Count; i++) + { + Assert.Equal(expectedUnsetMetadata[i], deserialized.UnsetMetadata[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new OnUnknown + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new OnUnknown { }; + + Assert.Null(model.AddTags); + Assert.False(model.RawData.ContainsKey("add_tags")); + Assert.Null(model.RemoveTags); + Assert.False(model.RawData.ContainsKey("remove_tags")); + Assert.Null(model.SetMetadata); + Assert.False(model.RawData.ContainsKey("set_metadata")); + Assert.Null(model.UnsetMetadata); + Assert.False(model.RawData.ContainsKey("unset_metadata")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new OnUnknown { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new OnUnknown + { + // Null should be interpreted as omitted for these properties + AddTags = null, + RemoveTags = null, + SetMetadata = null, + UnsetMetadata = null, + }; + + Assert.Null(model.AddTags); + Assert.False(model.RawData.ContainsKey("add_tags")); + Assert.Null(model.RemoveTags); + Assert.False(model.RawData.ContainsKey("remove_tags")); + Assert.Null(model.SetMetadata); + Assert.False(model.RawData.ContainsKey("set_metadata")); + Assert.Null(model.UnsetMetadata); + Assert.False(model.RawData.ContainsKey("unset_metadata")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new OnUnknown + { + // Null should be interpreted as omitted for these properties + AddTags = null, + RemoveTags = null, + SetMetadata = null, + UnsetMetadata = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new OnUnknown + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }; + + OnUnknown copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class OnUnknownSetMetadataTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new OnUnknownSetMetadata { Field = "field", Value = "string" }; + + string expectedField = "field"; + OnUnknownSetMetadataValue expectedValue = "string"; + + Assert.Equal(expectedField, model.Field); + Assert.Equal(expectedValue, model.Value); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new OnUnknownSetMetadata { Field = "field", Value = "string" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new OnUnknownSetMetadata { Field = "field", Value = "string" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedField = "field"; + OnUnknownSetMetadataValue expectedValue = "string"; + + Assert.Equal(expectedField, deserialized.Field); + Assert.Equal(expectedValue, deserialized.Value); + } + + [Fact] + public void Validation_Works() + { + var model = new OnUnknownSetMetadata { Field = "field", Value = "string" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new OnUnknownSetMetadata { Field = "field", Value = "string" }; + + OnUnknownSetMetadata copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class OnUnknownSetMetadataValueTest : TestBase +{ + [Fact] + public void StringValidationWorks() + { + OnUnknownSetMetadataValue value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + OnUnknownSetMetadataValue value = 0; + value.Validate(); + } + + [Fact] + public void BoolValidationWorks() + { + OnUnknownSetMetadataValue value = true; + value.Validate(); + } + + [Fact] + public void MixedValidationWorks() + { + OnUnknownSetMetadataValue value = new([new UnnamedSchemaWithArrayParent4("string")]); + value.Validate(); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + OnUnknownSetMetadataValue value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + OnUnknownSetMetadataValue value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void BoolSerializationRoundtripWorks() + { + OnUnknownSetMetadataValue value = true; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void MixedSerializationRoundtripWorks() + { + OnUnknownSetMetadataValue value = new([new UnnamedSchemaWithArrayParent4("string")]); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class UnnamedSchemaWithArrayParent4Test : TestBase +{ + [Fact] + public void StringValidationWorks() + { + UnnamedSchemaWithArrayParent4 value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + UnnamedSchemaWithArrayParent4 value = 0; + value.Validate(); + } + + [Fact] + public void BoolValidationWorks() + { + UnnamedSchemaWithArrayParent4 value = true; + value.Validate(); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent4 value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent4 value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void BoolSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent4 value = true; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class OnUnknownUnsetMetadataTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new OnUnknownUnsetMetadata { Field = "field" }; + + string expectedField = "field"; + + Assert.Equal(expectedField, model.Field); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new OnUnknownUnsetMetadata { Field = "field" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new OnUnknownUnsetMetadata { Field = "field" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedField = "field"; + + Assert.Equal(expectedField, deserialized.Field); + } + + [Fact] + public void Validation_Works() + { + var model = new OnUnknownUnsetMetadata { Field = "field" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new OnUnknownUnsetMetadata { Field = "field" }; + + OnUnknownUnsetMetadata copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class OnYesTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new OnYes + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }; + + List expectedAddTags = ["luxury", "premium"]; + List expectedRemoveTags = ["budget", "affordable"]; + List expectedSetMetadata = + [ + new() { Field = "price_range", Value = "premium" }, + ]; + List expectedUnsetMetadata = [new("price_range")]; + + Assert.NotNull(model.AddTags); + Assert.Equal(expectedAddTags.Count, model.AddTags.Count); + for (int i = 0; i < expectedAddTags.Count; i++) + { + Assert.Equal(expectedAddTags[i], model.AddTags[i]); + } + Assert.NotNull(model.RemoveTags); + Assert.Equal(expectedRemoveTags.Count, model.RemoveTags.Count); + for (int i = 0; i < expectedRemoveTags.Count; i++) + { + Assert.Equal(expectedRemoveTags[i], model.RemoveTags[i]); + } + Assert.NotNull(model.SetMetadata); + Assert.Equal(expectedSetMetadata.Count, model.SetMetadata.Count); + for (int i = 0; i < expectedSetMetadata.Count; i++) + { + Assert.Equal(expectedSetMetadata[i], model.SetMetadata[i]); + } + Assert.NotNull(model.UnsetMetadata); + Assert.Equal(expectedUnsetMetadata.Count, model.UnsetMetadata.Count); + for (int i = 0; i < expectedUnsetMetadata.Count; i++) + { + Assert.Equal(expectedUnsetMetadata[i], model.UnsetMetadata[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new OnYes + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new OnYes + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + Assert.NotNull(deserialized); + + List expectedAddTags = ["luxury", "premium"]; + List expectedRemoveTags = ["budget", "affordable"]; + List expectedSetMetadata = + [ + new() { Field = "price_range", Value = "premium" }, + ]; + List expectedUnsetMetadata = [new("price_range")]; + + Assert.NotNull(deserialized.AddTags); + Assert.Equal(expectedAddTags.Count, deserialized.AddTags.Count); + for (int i = 0; i < expectedAddTags.Count; i++) + { + Assert.Equal(expectedAddTags[i], deserialized.AddTags[i]); + } + Assert.NotNull(deserialized.RemoveTags); + Assert.Equal(expectedRemoveTags.Count, deserialized.RemoveTags.Count); + for (int i = 0; i < expectedRemoveTags.Count; i++) + { + Assert.Equal(expectedRemoveTags[i], deserialized.RemoveTags[i]); + } + Assert.NotNull(deserialized.SetMetadata); + Assert.Equal(expectedSetMetadata.Count, deserialized.SetMetadata.Count); + for (int i = 0; i < expectedSetMetadata.Count; i++) + { + Assert.Equal(expectedSetMetadata[i], deserialized.SetMetadata[i]); + } + Assert.NotNull(deserialized.UnsetMetadata); + Assert.Equal(expectedUnsetMetadata.Count, deserialized.UnsetMetadata.Count); + for (int i = 0; i < expectedUnsetMetadata.Count; i++) + { + Assert.Equal(expectedUnsetMetadata[i], deserialized.UnsetMetadata[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new OnYes + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new OnYes { }; + + Assert.Null(model.AddTags); + Assert.False(model.RawData.ContainsKey("add_tags")); + Assert.Null(model.RemoveTags); + Assert.False(model.RawData.ContainsKey("remove_tags")); + Assert.Null(model.SetMetadata); + Assert.False(model.RawData.ContainsKey("set_metadata")); + Assert.Null(model.UnsetMetadata); + Assert.False(model.RawData.ContainsKey("unset_metadata")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new OnYes { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new OnYes + { + // Null should be interpreted as omitted for these properties + AddTags = null, + RemoveTags = null, + SetMetadata = null, + UnsetMetadata = null, + }; + + Assert.Null(model.AddTags); + Assert.False(model.RawData.ContainsKey("add_tags")); + Assert.Null(model.RemoveTags); + Assert.False(model.RawData.ContainsKey("remove_tags")); + Assert.Null(model.SetMetadata); + Assert.False(model.RawData.ContainsKey("set_metadata")); + Assert.Null(model.UnsetMetadata); + Assert.False(model.RawData.ContainsKey("unset_metadata")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new OnYes + { + // Null should be interpreted as omitted for these properties + AddTags = null, + RemoveTags = null, + SetMetadata = null, + UnsetMetadata = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new OnYes + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }; + + OnYes copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class OnYesSetMetadataTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new OnYesSetMetadata { Field = "field", Value = "string" }; + + string expectedField = "field"; + OnYesSetMetadataValue expectedValue = "string"; + + Assert.Equal(expectedField, model.Field); + Assert.Equal(expectedValue, model.Value); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new OnYesSetMetadata { Field = "field", Value = "string" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new OnYesSetMetadata { Field = "field", Value = "string" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedField = "field"; + OnYesSetMetadataValue expectedValue = "string"; + + Assert.Equal(expectedField, deserialized.Field); + Assert.Equal(expectedValue, deserialized.Value); + } + + [Fact] + public void Validation_Works() + { + var model = new OnYesSetMetadata { Field = "field", Value = "string" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new OnYesSetMetadata { Field = "field", Value = "string" }; + + OnYesSetMetadata copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class OnYesSetMetadataValueTest : TestBase +{ + [Fact] + public void StringValidationWorks() + { + OnYesSetMetadataValue value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + OnYesSetMetadataValue value = 0; + value.Validate(); + } + + [Fact] + public void BoolValidationWorks() + { + OnYesSetMetadataValue value = true; + value.Validate(); + } + + [Fact] + public void MixedValidationWorks() + { + OnYesSetMetadataValue value = new([new UnnamedSchemaWithArrayParent5("string")]); + value.Validate(); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + OnYesSetMetadataValue value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + OnYesSetMetadataValue value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void BoolSerializationRoundtripWorks() + { + OnYesSetMetadataValue value = true; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void MixedSerializationRoundtripWorks() + { + OnYesSetMetadataValue value = new([new UnnamedSchemaWithArrayParent5("string")]); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class UnnamedSchemaWithArrayParent5Test : TestBase +{ + [Fact] + public void StringValidationWorks() + { + UnnamedSchemaWithArrayParent5 value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + UnnamedSchemaWithArrayParent5 value = 0; + value.Validate(); + } + + [Fact] + public void BoolValidationWorks() + { + UnnamedSchemaWithArrayParent5 value = true; + value.Validate(); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent5 value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent5 value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void BoolSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent5 value = true; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class OnYesUnsetMetadataTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new OnYesUnsetMetadata { Field = "field" }; + + string expectedField = "field"; + + Assert.Equal(expectedField, model.Field); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new OnYesUnsetMetadata { Field = "field" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new OnYesUnsetMetadata { Field = "field" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedField = "field"; + + Assert.Equal(expectedField, deserialized.Field); + } + + [Fact] + public void Validation_Works() + { + var model = new OnYesUnsetMetadata { Field = "field" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new OnYesUnsetMetadata { Field = "field" }; + + OnYesUnsetMetadata copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Files/Bulk/BulkAddTagsParamsTest.cs b/src/ImageKit.Tests/Models/Files/Bulk/BulkAddTagsParamsTest.cs new file mode 100644 index 00000000..ee0c224e --- /dev/null +++ b/src/ImageKit.Tests/Models/Files/Bulk/BulkAddTagsParamsTest.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using ImageKit.Models.Files.Bulk; + +namespace ImageKit.Tests.Models.Files.Bulk; + +public class BulkAddTagsParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new BulkAddTagsParams + { + FileIds = ["598821f949c0a938d57563bd", "598821f949c0a938d57563be"], + Tags = ["t-shirt", "round-neck", "sale2019"], + }; + + List expectedFileIds = ["598821f949c0a938d57563bd", "598821f949c0a938d57563be"]; + List expectedTags = ["t-shirt", "round-neck", "sale2019"]; + + Assert.Equal(expectedFileIds.Count, parameters.FileIds.Count); + for (int i = 0; i < expectedFileIds.Count; i++) + { + Assert.Equal(expectedFileIds[i], parameters.FileIds[i]); + } + Assert.Equal(expectedTags.Count, parameters.Tags.Count); + for (int i = 0; i < expectedTags.Count; i++) + { + Assert.Equal(expectedTags[i], parameters.Tags[i]); + } + } + + [Fact] + public void Url_Works() + { + BulkAddTagsParams parameters = new() + { + FileIds = ["598821f949c0a938d57563bd", "598821f949c0a938d57563be"], + Tags = ["t-shirt", "round-neck", "sale2019"], + }; + + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + + Assert.Equal(new Uri("https://api.imagekit.io/v1/files/addTags"), url); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new BulkAddTagsParams + { + FileIds = ["598821f949c0a938d57563bd", "598821f949c0a938d57563be"], + Tags = ["t-shirt", "round-neck", "sale2019"], + }; + + BulkAddTagsParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Files/Bulk/BulkAddTagsResponseTest.cs b/src/ImageKit.Tests/Models/Files/Bulk/BulkAddTagsResponseTest.cs new file mode 100644 index 00000000..04a9a306 --- /dev/null +++ b/src/ImageKit.Tests/Models/Files/Bulk/BulkAddTagsResponseTest.cs @@ -0,0 +1,132 @@ +using System.Collections.Generic; +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Models.Files.Bulk; + +namespace ImageKit.Tests.Models.Files.Bulk; + +public class BulkAddTagsResponseTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new BulkAddTagsResponse { SuccessfullyUpdatedFileIds = ["string"] }; + + List expectedSuccessfullyUpdatedFileIds = ["string"]; + + Assert.NotNull(model.SuccessfullyUpdatedFileIds); + Assert.Equal( + expectedSuccessfullyUpdatedFileIds.Count, + model.SuccessfullyUpdatedFileIds.Count + ); + for (int i = 0; i < expectedSuccessfullyUpdatedFileIds.Count; i++) + { + Assert.Equal( + expectedSuccessfullyUpdatedFileIds[i], + model.SuccessfullyUpdatedFileIds[i] + ); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new BulkAddTagsResponse { SuccessfullyUpdatedFileIds = ["string"] }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new BulkAddTagsResponse { SuccessfullyUpdatedFileIds = ["string"] }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedSuccessfullyUpdatedFileIds = ["string"]; + + Assert.NotNull(deserialized.SuccessfullyUpdatedFileIds); + Assert.Equal( + expectedSuccessfullyUpdatedFileIds.Count, + deserialized.SuccessfullyUpdatedFileIds.Count + ); + for (int i = 0; i < expectedSuccessfullyUpdatedFileIds.Count; i++) + { + Assert.Equal( + expectedSuccessfullyUpdatedFileIds[i], + deserialized.SuccessfullyUpdatedFileIds[i] + ); + } + } + + [Fact] + public void Validation_Works() + { + var model = new BulkAddTagsResponse { SuccessfullyUpdatedFileIds = ["string"] }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new BulkAddTagsResponse { }; + + Assert.Null(model.SuccessfullyUpdatedFileIds); + Assert.False(model.RawData.ContainsKey("successfullyUpdatedFileIds")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new BulkAddTagsResponse { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new BulkAddTagsResponse + { + // Null should be interpreted as omitted for these properties + SuccessfullyUpdatedFileIds = null, + }; + + Assert.Null(model.SuccessfullyUpdatedFileIds); + Assert.False(model.RawData.ContainsKey("successfullyUpdatedFileIds")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new BulkAddTagsResponse + { + // Null should be interpreted as omitted for these properties + SuccessfullyUpdatedFileIds = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BulkAddTagsResponse { SuccessfullyUpdatedFileIds = ["string"] }; + + BulkAddTagsResponse copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Files/Bulk/BulkDeleteParamsTest.cs b/src/ImageKit.Tests/Models/Files/Bulk/BulkDeleteParamsTest.cs new file mode 100644 index 00000000..5b8d87a7 --- /dev/null +++ b/src/ImageKit.Tests/Models/Files/Bulk/BulkDeleteParamsTest.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using ImageKit.Models.Files.Bulk; + +namespace ImageKit.Tests.Models.Files.Bulk; + +public class BulkDeleteParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new BulkDeleteParams + { + FileIds = ["598821f949c0a938d57563bd", "598821f949c0a938d57563be"], + }; + + List expectedFileIds = ["598821f949c0a938d57563bd", "598821f949c0a938d57563be"]; + + Assert.Equal(expectedFileIds.Count, parameters.FileIds.Count); + for (int i = 0; i < expectedFileIds.Count; i++) + { + Assert.Equal(expectedFileIds[i], parameters.FileIds[i]); + } + } + + [Fact] + public void Url_Works() + { + BulkDeleteParams parameters = new() + { + FileIds = ["598821f949c0a938d57563bd", "598821f949c0a938d57563be"], + }; + + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + + Assert.Equal(new Uri("https://api.imagekit.io/v1/files/batch/deleteByFileIds"), url); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new BulkDeleteParams + { + FileIds = ["598821f949c0a938d57563bd", "598821f949c0a938d57563be"], + }; + + BulkDeleteParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Files/Bulk/BulkDeleteResponseTest.cs b/src/ImageKit.Tests/Models/Files/Bulk/BulkDeleteResponseTest.cs new file mode 100644 index 00000000..f3592a5c --- /dev/null +++ b/src/ImageKit.Tests/Models/Files/Bulk/BulkDeleteResponseTest.cs @@ -0,0 +1,132 @@ +using System.Collections.Generic; +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Models.Files.Bulk; + +namespace ImageKit.Tests.Models.Files.Bulk; + +public class BulkDeleteResponseTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new BulkDeleteResponse { SuccessfullyDeletedFileIds = ["string"] }; + + List expectedSuccessfullyDeletedFileIds = ["string"]; + + Assert.NotNull(model.SuccessfullyDeletedFileIds); + Assert.Equal( + expectedSuccessfullyDeletedFileIds.Count, + model.SuccessfullyDeletedFileIds.Count + ); + for (int i = 0; i < expectedSuccessfullyDeletedFileIds.Count; i++) + { + Assert.Equal( + expectedSuccessfullyDeletedFileIds[i], + model.SuccessfullyDeletedFileIds[i] + ); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new BulkDeleteResponse { SuccessfullyDeletedFileIds = ["string"] }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new BulkDeleteResponse { SuccessfullyDeletedFileIds = ["string"] }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedSuccessfullyDeletedFileIds = ["string"]; + + Assert.NotNull(deserialized.SuccessfullyDeletedFileIds); + Assert.Equal( + expectedSuccessfullyDeletedFileIds.Count, + deserialized.SuccessfullyDeletedFileIds.Count + ); + for (int i = 0; i < expectedSuccessfullyDeletedFileIds.Count; i++) + { + Assert.Equal( + expectedSuccessfullyDeletedFileIds[i], + deserialized.SuccessfullyDeletedFileIds[i] + ); + } + } + + [Fact] + public void Validation_Works() + { + var model = new BulkDeleteResponse { SuccessfullyDeletedFileIds = ["string"] }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new BulkDeleteResponse { }; + + Assert.Null(model.SuccessfullyDeletedFileIds); + Assert.False(model.RawData.ContainsKey("successfullyDeletedFileIds")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new BulkDeleteResponse { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new BulkDeleteResponse + { + // Null should be interpreted as omitted for these properties + SuccessfullyDeletedFileIds = null, + }; + + Assert.Null(model.SuccessfullyDeletedFileIds); + Assert.False(model.RawData.ContainsKey("successfullyDeletedFileIds")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new BulkDeleteResponse + { + // Null should be interpreted as omitted for these properties + SuccessfullyDeletedFileIds = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BulkDeleteResponse { SuccessfullyDeletedFileIds = ["string"] }; + + BulkDeleteResponse copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveAITagsParamsTest.cs b/src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveAITagsParamsTest.cs new file mode 100644 index 00000000..391cf465 --- /dev/null +++ b/src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveAITagsParamsTest.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using ImageKit.Models.Files.Bulk; + +namespace ImageKit.Tests.Models.Files.Bulk; + +public class BulkRemoveAITagsParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new BulkRemoveAITagsParams + { + AITags = ["t-shirt", "round-neck", "sale2019"], + FileIds = ["598821f949c0a938d57563bd", "598821f949c0a938d57563be"], + }; + + List expectedAITags = ["t-shirt", "round-neck", "sale2019"]; + List expectedFileIds = ["598821f949c0a938d57563bd", "598821f949c0a938d57563be"]; + + Assert.Equal(expectedAITags.Count, parameters.AITags.Count); + for (int i = 0; i < expectedAITags.Count; i++) + { + Assert.Equal(expectedAITags[i], parameters.AITags[i]); + } + Assert.Equal(expectedFileIds.Count, parameters.FileIds.Count); + for (int i = 0; i < expectedFileIds.Count; i++) + { + Assert.Equal(expectedFileIds[i], parameters.FileIds[i]); + } + } + + [Fact] + public void Url_Works() + { + BulkRemoveAITagsParams parameters = new() + { + AITags = ["t-shirt", "round-neck", "sale2019"], + FileIds = ["598821f949c0a938d57563bd", "598821f949c0a938d57563be"], + }; + + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + + Assert.Equal(new Uri("https://api.imagekit.io/v1/files/removeAITags"), url); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new BulkRemoveAITagsParams + { + AITags = ["t-shirt", "round-neck", "sale2019"], + FileIds = ["598821f949c0a938d57563bd", "598821f949c0a938d57563be"], + }; + + BulkRemoveAITagsParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveAITagsResponseTest.cs b/src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveAITagsResponseTest.cs new file mode 100644 index 00000000..495618da --- /dev/null +++ b/src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveAITagsResponseTest.cs @@ -0,0 +1,132 @@ +using System.Collections.Generic; +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Models.Files.Bulk; + +namespace ImageKit.Tests.Models.Files.Bulk; + +public class BulkRemoveAITagsResponseTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new BulkRemoveAITagsResponse { SuccessfullyUpdatedFileIds = ["string"] }; + + List expectedSuccessfullyUpdatedFileIds = ["string"]; + + Assert.NotNull(model.SuccessfullyUpdatedFileIds); + Assert.Equal( + expectedSuccessfullyUpdatedFileIds.Count, + model.SuccessfullyUpdatedFileIds.Count + ); + for (int i = 0; i < expectedSuccessfullyUpdatedFileIds.Count; i++) + { + Assert.Equal( + expectedSuccessfullyUpdatedFileIds[i], + model.SuccessfullyUpdatedFileIds[i] + ); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new BulkRemoveAITagsResponse { SuccessfullyUpdatedFileIds = ["string"] }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new BulkRemoveAITagsResponse { SuccessfullyUpdatedFileIds = ["string"] }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedSuccessfullyUpdatedFileIds = ["string"]; + + Assert.NotNull(deserialized.SuccessfullyUpdatedFileIds); + Assert.Equal( + expectedSuccessfullyUpdatedFileIds.Count, + deserialized.SuccessfullyUpdatedFileIds.Count + ); + for (int i = 0; i < expectedSuccessfullyUpdatedFileIds.Count; i++) + { + Assert.Equal( + expectedSuccessfullyUpdatedFileIds[i], + deserialized.SuccessfullyUpdatedFileIds[i] + ); + } + } + + [Fact] + public void Validation_Works() + { + var model = new BulkRemoveAITagsResponse { SuccessfullyUpdatedFileIds = ["string"] }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new BulkRemoveAITagsResponse { }; + + Assert.Null(model.SuccessfullyUpdatedFileIds); + Assert.False(model.RawData.ContainsKey("successfullyUpdatedFileIds")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new BulkRemoveAITagsResponse { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new BulkRemoveAITagsResponse + { + // Null should be interpreted as omitted for these properties + SuccessfullyUpdatedFileIds = null, + }; + + Assert.Null(model.SuccessfullyUpdatedFileIds); + Assert.False(model.RawData.ContainsKey("successfullyUpdatedFileIds")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new BulkRemoveAITagsResponse + { + // Null should be interpreted as omitted for these properties + SuccessfullyUpdatedFileIds = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BulkRemoveAITagsResponse { SuccessfullyUpdatedFileIds = ["string"] }; + + BulkRemoveAITagsResponse copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveTagsParamsTest.cs b/src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveTagsParamsTest.cs new file mode 100644 index 00000000..49f93c1f --- /dev/null +++ b/src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveTagsParamsTest.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using ImageKit.Models.Files.Bulk; + +namespace ImageKit.Tests.Models.Files.Bulk; + +public class BulkRemoveTagsParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new BulkRemoveTagsParams + { + FileIds = ["598821f949c0a938d57563bd", "598821f949c0a938d57563be"], + Tags = ["t-shirt", "round-neck", "sale2019"], + }; + + List expectedFileIds = ["598821f949c0a938d57563bd", "598821f949c0a938d57563be"]; + List expectedTags = ["t-shirt", "round-neck", "sale2019"]; + + Assert.Equal(expectedFileIds.Count, parameters.FileIds.Count); + for (int i = 0; i < expectedFileIds.Count; i++) + { + Assert.Equal(expectedFileIds[i], parameters.FileIds[i]); + } + Assert.Equal(expectedTags.Count, parameters.Tags.Count); + for (int i = 0; i < expectedTags.Count; i++) + { + Assert.Equal(expectedTags[i], parameters.Tags[i]); + } + } + + [Fact] + public void Url_Works() + { + BulkRemoveTagsParams parameters = new() + { + FileIds = ["598821f949c0a938d57563bd", "598821f949c0a938d57563be"], + Tags = ["t-shirt", "round-neck", "sale2019"], + }; + + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + + Assert.Equal(new Uri("https://api.imagekit.io/v1/files/removeTags"), url); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new BulkRemoveTagsParams + { + FileIds = ["598821f949c0a938d57563bd", "598821f949c0a938d57563be"], + Tags = ["t-shirt", "round-neck", "sale2019"], + }; + + BulkRemoveTagsParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveTagsResponseTest.cs b/src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveTagsResponseTest.cs new file mode 100644 index 00000000..49816be4 --- /dev/null +++ b/src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveTagsResponseTest.cs @@ -0,0 +1,132 @@ +using System.Collections.Generic; +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Models.Files.Bulk; + +namespace ImageKit.Tests.Models.Files.Bulk; + +public class BulkRemoveTagsResponseTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new BulkRemoveTagsResponse { SuccessfullyUpdatedFileIds = ["string"] }; + + List expectedSuccessfullyUpdatedFileIds = ["string"]; + + Assert.NotNull(model.SuccessfullyUpdatedFileIds); + Assert.Equal( + expectedSuccessfullyUpdatedFileIds.Count, + model.SuccessfullyUpdatedFileIds.Count + ); + for (int i = 0; i < expectedSuccessfullyUpdatedFileIds.Count; i++) + { + Assert.Equal( + expectedSuccessfullyUpdatedFileIds[i], + model.SuccessfullyUpdatedFileIds[i] + ); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new BulkRemoveTagsResponse { SuccessfullyUpdatedFileIds = ["string"] }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new BulkRemoveTagsResponse { SuccessfullyUpdatedFileIds = ["string"] }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedSuccessfullyUpdatedFileIds = ["string"]; + + Assert.NotNull(deserialized.SuccessfullyUpdatedFileIds); + Assert.Equal( + expectedSuccessfullyUpdatedFileIds.Count, + deserialized.SuccessfullyUpdatedFileIds.Count + ); + for (int i = 0; i < expectedSuccessfullyUpdatedFileIds.Count; i++) + { + Assert.Equal( + expectedSuccessfullyUpdatedFileIds[i], + deserialized.SuccessfullyUpdatedFileIds[i] + ); + } + } + + [Fact] + public void Validation_Works() + { + var model = new BulkRemoveTagsResponse { SuccessfullyUpdatedFileIds = ["string"] }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new BulkRemoveTagsResponse { }; + + Assert.Null(model.SuccessfullyUpdatedFileIds); + Assert.False(model.RawData.ContainsKey("successfullyUpdatedFileIds")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new BulkRemoveTagsResponse { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new BulkRemoveTagsResponse + { + // Null should be interpreted as omitted for these properties + SuccessfullyUpdatedFileIds = null, + }; + + Assert.Null(model.SuccessfullyUpdatedFileIds); + Assert.False(model.RawData.ContainsKey("successfullyUpdatedFileIds")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new BulkRemoveTagsResponse + { + // Null should be interpreted as omitted for these properties + SuccessfullyUpdatedFileIds = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BulkRemoveTagsResponse { SuccessfullyUpdatedFileIds = ["string"] }; + + BulkRemoveTagsResponse copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Files/FileCopyParamsTest.cs b/src/ImageKit.Tests/Models/Files/FileCopyParamsTest.cs new file mode 100644 index 00000000..3a52f2cb --- /dev/null +++ b/src/ImageKit.Tests/Models/Files/FileCopyParamsTest.cs @@ -0,0 +1,84 @@ +using System; +using ImageKit.Models.Files; + +namespace ImageKit.Tests.Models.Files; + +public class FileCopyParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new FileCopyParams + { + DestinationPath = "/folder/to/copy/into/", + SourceFilePath = "/path/to/file.jpg", + IncludeFileVersions = false, + }; + + string expectedDestinationPath = "/folder/to/copy/into/"; + string expectedSourceFilePath = "/path/to/file.jpg"; + bool expectedIncludeFileVersions = false; + + Assert.Equal(expectedDestinationPath, parameters.DestinationPath); + Assert.Equal(expectedSourceFilePath, parameters.SourceFilePath); + Assert.Equal(expectedIncludeFileVersions, parameters.IncludeFileVersions); + } + + [Fact] + public void OptionalNonNullableParamsUnsetAreNotSet_Works() + { + var parameters = new FileCopyParams + { + DestinationPath = "/folder/to/copy/into/", + SourceFilePath = "/path/to/file.jpg", + }; + + Assert.Null(parameters.IncludeFileVersions); + Assert.False(parameters.RawBodyData.ContainsKey("includeFileVersions")); + } + + [Fact] + public void OptionalNonNullableParamsSetToNullAreNotSet_Works() + { + var parameters = new FileCopyParams + { + DestinationPath = "/folder/to/copy/into/", + SourceFilePath = "/path/to/file.jpg", + + // Null should be interpreted as omitted for these properties + IncludeFileVersions = null, + }; + + Assert.Null(parameters.IncludeFileVersions); + Assert.False(parameters.RawBodyData.ContainsKey("includeFileVersions")); + } + + [Fact] + public void Url_Works() + { + FileCopyParams parameters = new() + { + DestinationPath = "/folder/to/copy/into/", + SourceFilePath = "/path/to/file.jpg", + }; + + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + + Assert.Equal(new Uri("https://api.imagekit.io/v1/files/copy"), url); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new FileCopyParams + { + DestinationPath = "/folder/to/copy/into/", + SourceFilePath = "/path/to/file.jpg", + IncludeFileVersions = false, + }; + + FileCopyParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Files/FileCopyResponseTest.cs b/src/ImageKit.Tests/Models/Files/FileCopyResponseTest.cs new file mode 100644 index 00000000..b13c67e6 --- /dev/null +++ b/src/ImageKit.Tests/Models/Files/FileCopyResponseTest.cs @@ -0,0 +1,59 @@ +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Models.Files; + +namespace ImageKit.Tests.Models.Files; + +public class FileCopyResponseTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new FileCopyResponse { }; + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new FileCopyResponse { }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new FileCopyResponse { }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + } + + [Fact] + public void Validation_Works() + { + var model = new FileCopyResponse { }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new FileCopyResponse { }; + + FileCopyResponse copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Files/FileDeleteParamsTest.cs b/src/ImageKit.Tests/Models/Files/FileDeleteParamsTest.cs new file mode 100644 index 00000000..65107f82 --- /dev/null +++ b/src/ImageKit.Tests/Models/Files/FileDeleteParamsTest.cs @@ -0,0 +1,37 @@ +using System; +using ImageKit.Models.Files; + +namespace ImageKit.Tests.Models.Files; + +public class FileDeleteParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new FileDeleteParams { FileID = "fileId" }; + + string expectedFileID = "fileId"; + + Assert.Equal(expectedFileID, parameters.FileID); + } + + [Fact] + public void Url_Works() + { + FileDeleteParams parameters = new() { FileID = "fileId" }; + + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + + Assert.Equal(new Uri("https://api.imagekit.io/v1/files/fileId"), url); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new FileDeleteParams { FileID = "fileId" }; + + FileDeleteParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Files/FileGetParamsTest.cs b/src/ImageKit.Tests/Models/Files/FileGetParamsTest.cs new file mode 100644 index 00000000..d2372359 --- /dev/null +++ b/src/ImageKit.Tests/Models/Files/FileGetParamsTest.cs @@ -0,0 +1,37 @@ +using System; +using ImageKit.Models.Files; + +namespace ImageKit.Tests.Models.Files; + +public class FileGetParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new FileGetParams { FileID = "fileId" }; + + string expectedFileID = "fileId"; + + Assert.Equal(expectedFileID, parameters.FileID); + } + + [Fact] + public void Url_Works() + { + FileGetParams parameters = new() { FileID = "fileId" }; + + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + + Assert.Equal(new Uri("https://api.imagekit.io/v1/files/fileId/details"), url); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new FileGetParams { FileID = "fileId" }; + + FileGetParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Files/FileMetadataTest.cs b/src/ImageKit.Tests/Models/Files/FileMetadataTest.cs new file mode 100644 index 00000000..a81fec89 --- /dev/null +++ b/src/ImageKit.Tests/Models/Files/FileMetadataTest.cs @@ -0,0 +1,2552 @@ +using System.Collections.Generic; +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Models.Files; + +namespace ImageKit.Tests.Models.Files; + +public class FileMetadataTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new FileMetadata + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }; + + string expectedAudioCodec = "audioCodec"; + long expectedBitRate = 0; + long expectedDensity = 0; + long expectedDuration = 0; + Exif expectedExif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }; + string expectedFormat = "format"; + bool expectedHasColorProfile = true; + bool expectedHasTransparency = true; + long expectedHeight = 0; + string expectedPHash = "pHash"; + long expectedQuality = 0; + long expectedSize = 0; + string expectedVideoCodec = "videoCodec"; + long expectedWidth = 0; + + Assert.Equal(expectedAudioCodec, model.AudioCodec); + Assert.Equal(expectedBitRate, model.BitRate); + Assert.Equal(expectedDensity, model.Density); + Assert.Equal(expectedDuration, model.Duration); + Assert.Equal(expectedExif, model.Exif); + Assert.Equal(expectedFormat, model.Format); + Assert.Equal(expectedHasColorProfile, model.HasColorProfile); + Assert.Equal(expectedHasTransparency, model.HasTransparency); + Assert.Equal(expectedHeight, model.Height); + Assert.Equal(expectedPHash, model.PHash); + Assert.Equal(expectedQuality, model.Quality); + Assert.Equal(expectedSize, model.Size); + Assert.Equal(expectedVideoCodec, model.VideoCodec); + Assert.Equal(expectedWidth, model.Width); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new FileMetadata + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new FileMetadata + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAudioCodec = "audioCodec"; + long expectedBitRate = 0; + long expectedDensity = 0; + long expectedDuration = 0; + Exif expectedExif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }; + string expectedFormat = "format"; + bool expectedHasColorProfile = true; + bool expectedHasTransparency = true; + long expectedHeight = 0; + string expectedPHash = "pHash"; + long expectedQuality = 0; + long expectedSize = 0; + string expectedVideoCodec = "videoCodec"; + long expectedWidth = 0; + + Assert.Equal(expectedAudioCodec, deserialized.AudioCodec); + Assert.Equal(expectedBitRate, deserialized.BitRate); + Assert.Equal(expectedDensity, deserialized.Density); + Assert.Equal(expectedDuration, deserialized.Duration); + Assert.Equal(expectedExif, deserialized.Exif); + Assert.Equal(expectedFormat, deserialized.Format); + Assert.Equal(expectedHasColorProfile, deserialized.HasColorProfile); + Assert.Equal(expectedHasTransparency, deserialized.HasTransparency); + Assert.Equal(expectedHeight, deserialized.Height); + Assert.Equal(expectedPHash, deserialized.PHash); + Assert.Equal(expectedQuality, deserialized.Quality); + Assert.Equal(expectedSize, deserialized.Size); + Assert.Equal(expectedVideoCodec, deserialized.VideoCodec); + Assert.Equal(expectedWidth, deserialized.Width); + } + + [Fact] + public void Validation_Works() + { + var model = new FileMetadata + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new FileMetadata { }; + + Assert.Null(model.AudioCodec); + Assert.False(model.RawData.ContainsKey("audioCodec")); + Assert.Null(model.BitRate); + Assert.False(model.RawData.ContainsKey("bitRate")); + Assert.Null(model.Density); + Assert.False(model.RawData.ContainsKey("density")); + Assert.Null(model.Duration); + Assert.False(model.RawData.ContainsKey("duration")); + Assert.Null(model.Exif); + Assert.False(model.RawData.ContainsKey("exif")); + Assert.Null(model.Format); + Assert.False(model.RawData.ContainsKey("format")); + Assert.Null(model.HasColorProfile); + Assert.False(model.RawData.ContainsKey("hasColorProfile")); + Assert.Null(model.HasTransparency); + Assert.False(model.RawData.ContainsKey("hasTransparency")); + Assert.Null(model.Height); + Assert.False(model.RawData.ContainsKey("height")); + Assert.Null(model.PHash); + Assert.False(model.RawData.ContainsKey("pHash")); + Assert.Null(model.Quality); + Assert.False(model.RawData.ContainsKey("quality")); + Assert.Null(model.Size); + Assert.False(model.RawData.ContainsKey("size")); + Assert.Null(model.VideoCodec); + Assert.False(model.RawData.ContainsKey("videoCodec")); + Assert.Null(model.Width); + Assert.False(model.RawData.ContainsKey("width")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new FileMetadata { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new FileMetadata + { + // Null should be interpreted as omitted for these properties + AudioCodec = null, + BitRate = null, + Density = null, + Duration = null, + Exif = null, + Format = null, + HasColorProfile = null, + HasTransparency = null, + Height = null, + PHash = null, + Quality = null, + Size = null, + VideoCodec = null, + Width = null, + }; + + Assert.Null(model.AudioCodec); + Assert.False(model.RawData.ContainsKey("audioCodec")); + Assert.Null(model.BitRate); + Assert.False(model.RawData.ContainsKey("bitRate")); + Assert.Null(model.Density); + Assert.False(model.RawData.ContainsKey("density")); + Assert.Null(model.Duration); + Assert.False(model.RawData.ContainsKey("duration")); + Assert.Null(model.Exif); + Assert.False(model.RawData.ContainsKey("exif")); + Assert.Null(model.Format); + Assert.False(model.RawData.ContainsKey("format")); + Assert.Null(model.HasColorProfile); + Assert.False(model.RawData.ContainsKey("hasColorProfile")); + Assert.Null(model.HasTransparency); + Assert.False(model.RawData.ContainsKey("hasTransparency")); + Assert.Null(model.Height); + Assert.False(model.RawData.ContainsKey("height")); + Assert.Null(model.PHash); + Assert.False(model.RawData.ContainsKey("pHash")); + Assert.Null(model.Quality); + Assert.False(model.RawData.ContainsKey("quality")); + Assert.Null(model.Size); + Assert.False(model.RawData.ContainsKey("size")); + Assert.Null(model.VideoCodec); + Assert.False(model.RawData.ContainsKey("videoCodec")); + Assert.Null(model.Width); + Assert.False(model.RawData.ContainsKey("width")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new FileMetadata + { + // Null should be interpreted as omitted for these properties + AudioCodec = null, + BitRate = null, + Density = null, + Duration = null, + Exif = null, + Format = null, + HasColorProfile = null, + HasTransparency = null, + Height = null, + PHash = null, + Quality = null, + Size = null, + VideoCodec = null, + Width = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new FileMetadata + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }; + + FileMetadata copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ExifTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Exif + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }; + + ExifExif expectedExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }; + Gps expectedGps = new() { GpsVersionID = [0] }; + Image expectedImage = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }; + Interoperability expectedInteroperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }; + Dictionary expectedMakernote = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; + ExifThumbnail expectedThumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }; + + Assert.Equal(expectedExifValue, model.ExifValue); + Assert.Equal(expectedGps, model.Gps); + Assert.Equal(expectedImage, model.Image); + Assert.Equal(expectedInteroperability, model.Interoperability); + Assert.NotNull(model.Makernote); + Assert.Equal(expectedMakernote.Count, model.Makernote.Count); + foreach (var item in expectedMakernote) + { + Assert.True(model.Makernote.TryGetValue(item.Key, out var value)); + + Assert.True(JsonElement.DeepEquals(value, model.Makernote[item.Key])); + } + Assert.Equal(expectedThumbnail, model.Thumbnail); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Exif + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Exif + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + Assert.NotNull(deserialized); + + ExifExif expectedExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }; + Gps expectedGps = new() { GpsVersionID = [0] }; + Image expectedImage = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }; + Interoperability expectedInteroperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }; + Dictionary expectedMakernote = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; + ExifThumbnail expectedThumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }; + + Assert.Equal(expectedExifValue, deserialized.ExifValue); + Assert.Equal(expectedGps, deserialized.Gps); + Assert.Equal(expectedImage, deserialized.Image); + Assert.Equal(expectedInteroperability, deserialized.Interoperability); + Assert.NotNull(deserialized.Makernote); + Assert.Equal(expectedMakernote.Count, deserialized.Makernote.Count); + foreach (var item in expectedMakernote) + { + Assert.True(deserialized.Makernote.TryGetValue(item.Key, out var value)); + + Assert.True(JsonElement.DeepEquals(value, deserialized.Makernote[item.Key])); + } + Assert.Equal(expectedThumbnail, deserialized.Thumbnail); + } + + [Fact] + public void Validation_Works() + { + var model = new Exif + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Exif { }; + + Assert.Null(model.ExifValue); + Assert.False(model.RawData.ContainsKey("exif")); + Assert.Null(model.Gps); + Assert.False(model.RawData.ContainsKey("gps")); + Assert.Null(model.Image); + Assert.False(model.RawData.ContainsKey("image")); + Assert.Null(model.Interoperability); + Assert.False(model.RawData.ContainsKey("interoperability")); + Assert.Null(model.Makernote); + Assert.False(model.RawData.ContainsKey("makernote")); + Assert.Null(model.Thumbnail); + Assert.False(model.RawData.ContainsKey("thumbnail")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new Exif { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new Exif + { + // Null should be interpreted as omitted for these properties + ExifValue = null, + Gps = null, + Image = null, + Interoperability = null, + Makernote = null, + Thumbnail = null, + }; + + Assert.Null(model.ExifValue); + Assert.False(model.RawData.ContainsKey("exif")); + Assert.Null(model.Gps); + Assert.False(model.RawData.ContainsKey("gps")); + Assert.Null(model.Image); + Assert.False(model.RawData.ContainsKey("image")); + Assert.Null(model.Interoperability); + Assert.False(model.RawData.ContainsKey("interoperability")); + Assert.Null(model.Makernote); + Assert.False(model.RawData.ContainsKey("makernote")); + Assert.Null(model.Thumbnail); + Assert.False(model.RawData.ContainsKey("thumbnail")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new Exif + { + // Null should be interpreted as omitted for these properties + ExifValue = null, + Gps = null, + Image = null, + Interoperability = null, + Makernote = null, + Thumbnail = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Exif + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }; + + Exif copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ExifExifTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ExifExif + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }; + + double expectedApertureValue = 0; + long expectedColorSpace = 0; + string expectedCreateDate = "CreateDate"; + long expectedCustomRendered = 0; + string expectedDateTimeOriginal = "DateTimeOriginal"; + long expectedExifImageHeight = 0; + long expectedExifImageWidth = 0; + string expectedExifVersion = "ExifVersion"; + double expectedExposureCompensation = 0; + long expectedExposureMode = 0; + long expectedExposureProgram = 0; + double expectedExposureTime = 0; + long expectedFlash = 0; + string expectedFlashpixVersion = "FlashpixVersion"; + double expectedFNumber = 0; + long expectedFocalLength = 0; + long expectedFocalPlaneResolutionUnit = 0; + double expectedFocalPlaneXResolution = 0; + double expectedFocalPlaneYResolution = 0; + long expectedInteropOffset = 0; + long expectedIso = 0; + long expectedMeteringMode = 0; + long expectedSceneCaptureType = 0; + double expectedShutterSpeedValue = 0; + string expectedSubSecTime = "SubSecTime"; + long expectedWhiteBalance = 0; + + Assert.Equal(expectedApertureValue, model.ApertureValue); + Assert.Equal(expectedColorSpace, model.ColorSpace); + Assert.Equal(expectedCreateDate, model.CreateDate); + Assert.Equal(expectedCustomRendered, model.CustomRendered); + Assert.Equal(expectedDateTimeOriginal, model.DateTimeOriginal); + Assert.Equal(expectedExifImageHeight, model.ExifImageHeight); + Assert.Equal(expectedExifImageWidth, model.ExifImageWidth); + Assert.Equal(expectedExifVersion, model.ExifVersion); + Assert.Equal(expectedExposureCompensation, model.ExposureCompensation); + Assert.Equal(expectedExposureMode, model.ExposureMode); + Assert.Equal(expectedExposureProgram, model.ExposureProgram); + Assert.Equal(expectedExposureTime, model.ExposureTime); + Assert.Equal(expectedFlash, model.Flash); + Assert.Equal(expectedFlashpixVersion, model.FlashpixVersion); + Assert.Equal(expectedFNumber, model.FNumber); + Assert.Equal(expectedFocalLength, model.FocalLength); + Assert.Equal(expectedFocalPlaneResolutionUnit, model.FocalPlaneResolutionUnit); + Assert.Equal(expectedFocalPlaneXResolution, model.FocalPlaneXResolution); + Assert.Equal(expectedFocalPlaneYResolution, model.FocalPlaneYResolution); + Assert.Equal(expectedInteropOffset, model.InteropOffset); + Assert.Equal(expectedIso, model.Iso); + Assert.Equal(expectedMeteringMode, model.MeteringMode); + Assert.Equal(expectedSceneCaptureType, model.SceneCaptureType); + Assert.Equal(expectedShutterSpeedValue, model.ShutterSpeedValue); + Assert.Equal(expectedSubSecTime, model.SubSecTime); + Assert.Equal(expectedWhiteBalance, model.WhiteBalance); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ExifExif + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new ExifExif + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + double expectedApertureValue = 0; + long expectedColorSpace = 0; + string expectedCreateDate = "CreateDate"; + long expectedCustomRendered = 0; + string expectedDateTimeOriginal = "DateTimeOriginal"; + long expectedExifImageHeight = 0; + long expectedExifImageWidth = 0; + string expectedExifVersion = "ExifVersion"; + double expectedExposureCompensation = 0; + long expectedExposureMode = 0; + long expectedExposureProgram = 0; + double expectedExposureTime = 0; + long expectedFlash = 0; + string expectedFlashpixVersion = "FlashpixVersion"; + double expectedFNumber = 0; + long expectedFocalLength = 0; + long expectedFocalPlaneResolutionUnit = 0; + double expectedFocalPlaneXResolution = 0; + double expectedFocalPlaneYResolution = 0; + long expectedInteropOffset = 0; + long expectedIso = 0; + long expectedMeteringMode = 0; + long expectedSceneCaptureType = 0; + double expectedShutterSpeedValue = 0; + string expectedSubSecTime = "SubSecTime"; + long expectedWhiteBalance = 0; + + Assert.Equal(expectedApertureValue, deserialized.ApertureValue); + Assert.Equal(expectedColorSpace, deserialized.ColorSpace); + Assert.Equal(expectedCreateDate, deserialized.CreateDate); + Assert.Equal(expectedCustomRendered, deserialized.CustomRendered); + Assert.Equal(expectedDateTimeOriginal, deserialized.DateTimeOriginal); + Assert.Equal(expectedExifImageHeight, deserialized.ExifImageHeight); + Assert.Equal(expectedExifImageWidth, deserialized.ExifImageWidth); + Assert.Equal(expectedExifVersion, deserialized.ExifVersion); + Assert.Equal(expectedExposureCompensation, deserialized.ExposureCompensation); + Assert.Equal(expectedExposureMode, deserialized.ExposureMode); + Assert.Equal(expectedExposureProgram, deserialized.ExposureProgram); + Assert.Equal(expectedExposureTime, deserialized.ExposureTime); + Assert.Equal(expectedFlash, deserialized.Flash); + Assert.Equal(expectedFlashpixVersion, deserialized.FlashpixVersion); + Assert.Equal(expectedFNumber, deserialized.FNumber); + Assert.Equal(expectedFocalLength, deserialized.FocalLength); + Assert.Equal(expectedFocalPlaneResolutionUnit, deserialized.FocalPlaneResolutionUnit); + Assert.Equal(expectedFocalPlaneXResolution, deserialized.FocalPlaneXResolution); + Assert.Equal(expectedFocalPlaneYResolution, deserialized.FocalPlaneYResolution); + Assert.Equal(expectedInteropOffset, deserialized.InteropOffset); + Assert.Equal(expectedIso, deserialized.Iso); + Assert.Equal(expectedMeteringMode, deserialized.MeteringMode); + Assert.Equal(expectedSceneCaptureType, deserialized.SceneCaptureType); + Assert.Equal(expectedShutterSpeedValue, deserialized.ShutterSpeedValue); + Assert.Equal(expectedSubSecTime, deserialized.SubSecTime); + Assert.Equal(expectedWhiteBalance, deserialized.WhiteBalance); + } + + [Fact] + public void Validation_Works() + { + var model = new ExifExif + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ExifExif { }; + + Assert.Null(model.ApertureValue); + Assert.False(model.RawData.ContainsKey("ApertureValue")); + Assert.Null(model.ColorSpace); + Assert.False(model.RawData.ContainsKey("ColorSpace")); + Assert.Null(model.CreateDate); + Assert.False(model.RawData.ContainsKey("CreateDate")); + Assert.Null(model.CustomRendered); + Assert.False(model.RawData.ContainsKey("CustomRendered")); + Assert.Null(model.DateTimeOriginal); + Assert.False(model.RawData.ContainsKey("DateTimeOriginal")); + Assert.Null(model.ExifImageHeight); + Assert.False(model.RawData.ContainsKey("ExifImageHeight")); + Assert.Null(model.ExifImageWidth); + Assert.False(model.RawData.ContainsKey("ExifImageWidth")); + Assert.Null(model.ExifVersion); + Assert.False(model.RawData.ContainsKey("ExifVersion")); + Assert.Null(model.ExposureCompensation); + Assert.False(model.RawData.ContainsKey("ExposureCompensation")); + Assert.Null(model.ExposureMode); + Assert.False(model.RawData.ContainsKey("ExposureMode")); + Assert.Null(model.ExposureProgram); + Assert.False(model.RawData.ContainsKey("ExposureProgram")); + Assert.Null(model.ExposureTime); + Assert.False(model.RawData.ContainsKey("ExposureTime")); + Assert.Null(model.Flash); + Assert.False(model.RawData.ContainsKey("Flash")); + Assert.Null(model.FlashpixVersion); + Assert.False(model.RawData.ContainsKey("FlashpixVersion")); + Assert.Null(model.FNumber); + Assert.False(model.RawData.ContainsKey("FNumber")); + Assert.Null(model.FocalLength); + Assert.False(model.RawData.ContainsKey("FocalLength")); + Assert.Null(model.FocalPlaneResolutionUnit); + Assert.False(model.RawData.ContainsKey("FocalPlaneResolutionUnit")); + Assert.Null(model.FocalPlaneXResolution); + Assert.False(model.RawData.ContainsKey("FocalPlaneXResolution")); + Assert.Null(model.FocalPlaneYResolution); + Assert.False(model.RawData.ContainsKey("FocalPlaneYResolution")); + Assert.Null(model.InteropOffset); + Assert.False(model.RawData.ContainsKey("InteropOffset")); + Assert.Null(model.Iso); + Assert.False(model.RawData.ContainsKey("ISO")); + Assert.Null(model.MeteringMode); + Assert.False(model.RawData.ContainsKey("MeteringMode")); + Assert.Null(model.SceneCaptureType); + Assert.False(model.RawData.ContainsKey("SceneCaptureType")); + Assert.Null(model.ShutterSpeedValue); + Assert.False(model.RawData.ContainsKey("ShutterSpeedValue")); + Assert.Null(model.SubSecTime); + Assert.False(model.RawData.ContainsKey("SubSecTime")); + Assert.Null(model.WhiteBalance); + Assert.False(model.RawData.ContainsKey("WhiteBalance")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new ExifExif { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new ExifExif + { + // Null should be interpreted as omitted for these properties + ApertureValue = null, + ColorSpace = null, + CreateDate = null, + CustomRendered = null, + DateTimeOriginal = null, + ExifImageHeight = null, + ExifImageWidth = null, + ExifVersion = null, + ExposureCompensation = null, + ExposureMode = null, + ExposureProgram = null, + ExposureTime = null, + Flash = null, + FlashpixVersion = null, + FNumber = null, + FocalLength = null, + FocalPlaneResolutionUnit = null, + FocalPlaneXResolution = null, + FocalPlaneYResolution = null, + InteropOffset = null, + Iso = null, + MeteringMode = null, + SceneCaptureType = null, + ShutterSpeedValue = null, + SubSecTime = null, + WhiteBalance = null, + }; + + Assert.Null(model.ApertureValue); + Assert.False(model.RawData.ContainsKey("ApertureValue")); + Assert.Null(model.ColorSpace); + Assert.False(model.RawData.ContainsKey("ColorSpace")); + Assert.Null(model.CreateDate); + Assert.False(model.RawData.ContainsKey("CreateDate")); + Assert.Null(model.CustomRendered); + Assert.False(model.RawData.ContainsKey("CustomRendered")); + Assert.Null(model.DateTimeOriginal); + Assert.False(model.RawData.ContainsKey("DateTimeOriginal")); + Assert.Null(model.ExifImageHeight); + Assert.False(model.RawData.ContainsKey("ExifImageHeight")); + Assert.Null(model.ExifImageWidth); + Assert.False(model.RawData.ContainsKey("ExifImageWidth")); + Assert.Null(model.ExifVersion); + Assert.False(model.RawData.ContainsKey("ExifVersion")); + Assert.Null(model.ExposureCompensation); + Assert.False(model.RawData.ContainsKey("ExposureCompensation")); + Assert.Null(model.ExposureMode); + Assert.False(model.RawData.ContainsKey("ExposureMode")); + Assert.Null(model.ExposureProgram); + Assert.False(model.RawData.ContainsKey("ExposureProgram")); + Assert.Null(model.ExposureTime); + Assert.False(model.RawData.ContainsKey("ExposureTime")); + Assert.Null(model.Flash); + Assert.False(model.RawData.ContainsKey("Flash")); + Assert.Null(model.FlashpixVersion); + Assert.False(model.RawData.ContainsKey("FlashpixVersion")); + Assert.Null(model.FNumber); + Assert.False(model.RawData.ContainsKey("FNumber")); + Assert.Null(model.FocalLength); + Assert.False(model.RawData.ContainsKey("FocalLength")); + Assert.Null(model.FocalPlaneResolutionUnit); + Assert.False(model.RawData.ContainsKey("FocalPlaneResolutionUnit")); + Assert.Null(model.FocalPlaneXResolution); + Assert.False(model.RawData.ContainsKey("FocalPlaneXResolution")); + Assert.Null(model.FocalPlaneYResolution); + Assert.False(model.RawData.ContainsKey("FocalPlaneYResolution")); + Assert.Null(model.InteropOffset); + Assert.False(model.RawData.ContainsKey("InteropOffset")); + Assert.Null(model.Iso); + Assert.False(model.RawData.ContainsKey("ISO")); + Assert.Null(model.MeteringMode); + Assert.False(model.RawData.ContainsKey("MeteringMode")); + Assert.Null(model.SceneCaptureType); + Assert.False(model.RawData.ContainsKey("SceneCaptureType")); + Assert.Null(model.ShutterSpeedValue); + Assert.False(model.RawData.ContainsKey("ShutterSpeedValue")); + Assert.Null(model.SubSecTime); + Assert.False(model.RawData.ContainsKey("SubSecTime")); + Assert.Null(model.WhiteBalance); + Assert.False(model.RawData.ContainsKey("WhiteBalance")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new ExifExif + { + // Null should be interpreted as omitted for these properties + ApertureValue = null, + ColorSpace = null, + CreateDate = null, + CustomRendered = null, + DateTimeOriginal = null, + ExifImageHeight = null, + ExifImageWidth = null, + ExifVersion = null, + ExposureCompensation = null, + ExposureMode = null, + ExposureProgram = null, + ExposureTime = null, + Flash = null, + FlashpixVersion = null, + FNumber = null, + FocalLength = null, + FocalPlaneResolutionUnit = null, + FocalPlaneXResolution = null, + FocalPlaneYResolution = null, + InteropOffset = null, + Iso = null, + MeteringMode = null, + SceneCaptureType = null, + ShutterSpeedValue = null, + SubSecTime = null, + WhiteBalance = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ExifExif + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }; + + ExifExif copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GpsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Gps { GpsVersionID = [0] }; + + List expectedGpsVersionID = [0]; + + Assert.NotNull(model.GpsVersionID); + Assert.Equal(expectedGpsVersionID.Count, model.GpsVersionID.Count); + for (int i = 0; i < expectedGpsVersionID.Count; i++) + { + Assert.Equal(expectedGpsVersionID[i], model.GpsVersionID[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Gps { GpsVersionID = [0] }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Gps { GpsVersionID = [0] }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + Assert.NotNull(deserialized); + + List expectedGpsVersionID = [0]; + + Assert.NotNull(deserialized.GpsVersionID); + Assert.Equal(expectedGpsVersionID.Count, deserialized.GpsVersionID.Count); + for (int i = 0; i < expectedGpsVersionID.Count; i++) + { + Assert.Equal(expectedGpsVersionID[i], deserialized.GpsVersionID[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new Gps { GpsVersionID = [0] }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Gps { }; + + Assert.Null(model.GpsVersionID); + Assert.False(model.RawData.ContainsKey("GPSVersionID")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new Gps { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new Gps + { + // Null should be interpreted as omitted for these properties + GpsVersionID = null, + }; + + Assert.Null(model.GpsVersionID); + Assert.False(model.RawData.ContainsKey("GPSVersionID")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new Gps + { + // Null should be interpreted as omitted for these properties + GpsVersionID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Gps { GpsVersionID = [0] }; + + Gps copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ImageTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Image + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }; + + long expectedExifOffset = 0; + long expectedGpsInfo = 0; + string expectedMake = "Make"; + string expectedModel = "Model"; + string expectedModifyDate = "ModifyDate"; + long expectedOrientation = 0; + long expectedResolutionUnit = 0; + string expectedSoftware = "Software"; + long expectedXResolution = 0; + long expectedYCbCrPositioning = 0; + long expectedYResolution = 0; + + Assert.Equal(expectedExifOffset, model.ExifOffset); + Assert.Equal(expectedGpsInfo, model.GpsInfo); + Assert.Equal(expectedMake, model.Make); + Assert.Equal(expectedModel, model.Model); + Assert.Equal(expectedModifyDate, model.ModifyDate); + Assert.Equal(expectedOrientation, model.Orientation); + Assert.Equal(expectedResolutionUnit, model.ResolutionUnit); + Assert.Equal(expectedSoftware, model.Software); + Assert.Equal(expectedXResolution, model.XResolution); + Assert.Equal(expectedYCbCrPositioning, model.YCbCrPositioning); + Assert.Equal(expectedYResolution, model.YResolution); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Image + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Image + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + Assert.NotNull(deserialized); + + long expectedExifOffset = 0; + long expectedGpsInfo = 0; + string expectedMake = "Make"; + string expectedModel = "Model"; + string expectedModifyDate = "ModifyDate"; + long expectedOrientation = 0; + long expectedResolutionUnit = 0; + string expectedSoftware = "Software"; + long expectedXResolution = 0; + long expectedYCbCrPositioning = 0; + long expectedYResolution = 0; + + Assert.Equal(expectedExifOffset, deserialized.ExifOffset); + Assert.Equal(expectedGpsInfo, deserialized.GpsInfo); + Assert.Equal(expectedMake, deserialized.Make); + Assert.Equal(expectedModel, deserialized.Model); + Assert.Equal(expectedModifyDate, deserialized.ModifyDate); + Assert.Equal(expectedOrientation, deserialized.Orientation); + Assert.Equal(expectedResolutionUnit, deserialized.ResolutionUnit); + Assert.Equal(expectedSoftware, deserialized.Software); + Assert.Equal(expectedXResolution, deserialized.XResolution); + Assert.Equal(expectedYCbCrPositioning, deserialized.YCbCrPositioning); + Assert.Equal(expectedYResolution, deserialized.YResolution); + } + + [Fact] + public void Validation_Works() + { + var model = new Image + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Image { }; + + Assert.Null(model.ExifOffset); + Assert.False(model.RawData.ContainsKey("ExifOffset")); + Assert.Null(model.GpsInfo); + Assert.False(model.RawData.ContainsKey("GPSInfo")); + Assert.Null(model.Make); + Assert.False(model.RawData.ContainsKey("Make")); + Assert.Null(model.Model); + Assert.False(model.RawData.ContainsKey("Model")); + Assert.Null(model.ModifyDate); + Assert.False(model.RawData.ContainsKey("ModifyDate")); + Assert.Null(model.Orientation); + Assert.False(model.RawData.ContainsKey("Orientation")); + Assert.Null(model.ResolutionUnit); + Assert.False(model.RawData.ContainsKey("ResolutionUnit")); + Assert.Null(model.Software); + Assert.False(model.RawData.ContainsKey("Software")); + Assert.Null(model.XResolution); + Assert.False(model.RawData.ContainsKey("XResolution")); + Assert.Null(model.YCbCrPositioning); + Assert.False(model.RawData.ContainsKey("YCbCrPositioning")); + Assert.Null(model.YResolution); + Assert.False(model.RawData.ContainsKey("YResolution")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new Image { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new Image + { + // Null should be interpreted as omitted for these properties + ExifOffset = null, + GpsInfo = null, + Make = null, + Model = null, + ModifyDate = null, + Orientation = null, + ResolutionUnit = null, + Software = null, + XResolution = null, + YCbCrPositioning = null, + YResolution = null, + }; + + Assert.Null(model.ExifOffset); + Assert.False(model.RawData.ContainsKey("ExifOffset")); + Assert.Null(model.GpsInfo); + Assert.False(model.RawData.ContainsKey("GPSInfo")); + Assert.Null(model.Make); + Assert.False(model.RawData.ContainsKey("Make")); + Assert.Null(model.Model); + Assert.False(model.RawData.ContainsKey("Model")); + Assert.Null(model.ModifyDate); + Assert.False(model.RawData.ContainsKey("ModifyDate")); + Assert.Null(model.Orientation); + Assert.False(model.RawData.ContainsKey("Orientation")); + Assert.Null(model.ResolutionUnit); + Assert.False(model.RawData.ContainsKey("ResolutionUnit")); + Assert.Null(model.Software); + Assert.False(model.RawData.ContainsKey("Software")); + Assert.Null(model.XResolution); + Assert.False(model.RawData.ContainsKey("XResolution")); + Assert.Null(model.YCbCrPositioning); + Assert.False(model.RawData.ContainsKey("YCbCrPositioning")); + Assert.Null(model.YResolution); + Assert.False(model.RawData.ContainsKey("YResolution")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new Image + { + // Null should be interpreted as omitted for these properties + ExifOffset = null, + GpsInfo = null, + Make = null, + Model = null, + ModifyDate = null, + Orientation = null, + ResolutionUnit = null, + Software = null, + XResolution = null, + YCbCrPositioning = null, + YResolution = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Image + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }; + + Image copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class InteroperabilityTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Interoperability + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }; + + string expectedInteropIndex = "InteropIndex"; + string expectedInteropVersion = "InteropVersion"; + + Assert.Equal(expectedInteropIndex, model.InteropIndex); + Assert.Equal(expectedInteropVersion, model.InteropVersion); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Interoperability + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Interoperability + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedInteropIndex = "InteropIndex"; + string expectedInteropVersion = "InteropVersion"; + + Assert.Equal(expectedInteropIndex, deserialized.InteropIndex); + Assert.Equal(expectedInteropVersion, deserialized.InteropVersion); + } + + [Fact] + public void Validation_Works() + { + var model = new Interoperability + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Interoperability { }; + + Assert.Null(model.InteropIndex); + Assert.False(model.RawData.ContainsKey("InteropIndex")); + Assert.Null(model.InteropVersion); + Assert.False(model.RawData.ContainsKey("InteropVersion")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new Interoperability { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new Interoperability + { + // Null should be interpreted as omitted for these properties + InteropIndex = null, + InteropVersion = null, + }; + + Assert.Null(model.InteropIndex); + Assert.False(model.RawData.ContainsKey("InteropIndex")); + Assert.Null(model.InteropVersion); + Assert.False(model.RawData.ContainsKey("InteropVersion")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new Interoperability + { + // Null should be interpreted as omitted for these properties + InteropIndex = null, + InteropVersion = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Interoperability + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }; + + Interoperability copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ExifThumbnailTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ExifThumbnail + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }; + + long expectedCompression = 0; + long expectedResolutionUnit = 0; + long expectedThumbnailLength = 0; + long expectedThumbnailOffset = 0; + long expectedXResolution = 0; + long expectedYResolution = 0; + + Assert.Equal(expectedCompression, model.Compression); + Assert.Equal(expectedResolutionUnit, model.ResolutionUnit); + Assert.Equal(expectedThumbnailLength, model.ThumbnailLength); + Assert.Equal(expectedThumbnailOffset, model.ThumbnailOffset); + Assert.Equal(expectedXResolution, model.XResolution); + Assert.Equal(expectedYResolution, model.YResolution); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ExifThumbnail + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new ExifThumbnail + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + long expectedCompression = 0; + long expectedResolutionUnit = 0; + long expectedThumbnailLength = 0; + long expectedThumbnailOffset = 0; + long expectedXResolution = 0; + long expectedYResolution = 0; + + Assert.Equal(expectedCompression, deserialized.Compression); + Assert.Equal(expectedResolutionUnit, deserialized.ResolutionUnit); + Assert.Equal(expectedThumbnailLength, deserialized.ThumbnailLength); + Assert.Equal(expectedThumbnailOffset, deserialized.ThumbnailOffset); + Assert.Equal(expectedXResolution, deserialized.XResolution); + Assert.Equal(expectedYResolution, deserialized.YResolution); + } + + [Fact] + public void Validation_Works() + { + var model = new ExifThumbnail + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ExifThumbnail { }; + + Assert.Null(model.Compression); + Assert.False(model.RawData.ContainsKey("Compression")); + Assert.Null(model.ResolutionUnit); + Assert.False(model.RawData.ContainsKey("ResolutionUnit")); + Assert.Null(model.ThumbnailLength); + Assert.False(model.RawData.ContainsKey("ThumbnailLength")); + Assert.Null(model.ThumbnailOffset); + Assert.False(model.RawData.ContainsKey("ThumbnailOffset")); + Assert.Null(model.XResolution); + Assert.False(model.RawData.ContainsKey("XResolution")); + Assert.Null(model.YResolution); + Assert.False(model.RawData.ContainsKey("YResolution")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new ExifThumbnail { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new ExifThumbnail + { + // Null should be interpreted as omitted for these properties + Compression = null, + ResolutionUnit = null, + ThumbnailLength = null, + ThumbnailOffset = null, + XResolution = null, + YResolution = null, + }; + + Assert.Null(model.Compression); + Assert.False(model.RawData.ContainsKey("Compression")); + Assert.Null(model.ResolutionUnit); + Assert.False(model.RawData.ContainsKey("ResolutionUnit")); + Assert.Null(model.ThumbnailLength); + Assert.False(model.RawData.ContainsKey("ThumbnailLength")); + Assert.Null(model.ThumbnailOffset); + Assert.False(model.RawData.ContainsKey("ThumbnailOffset")); + Assert.Null(model.XResolution); + Assert.False(model.RawData.ContainsKey("XResolution")); + Assert.Null(model.YResolution); + Assert.False(model.RawData.ContainsKey("YResolution")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new ExifThumbnail + { + // Null should be interpreted as omitted for these properties + Compression = null, + ResolutionUnit = null, + ThumbnailLength = null, + ThumbnailOffset = null, + XResolution = null, + YResolution = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ExifThumbnail + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }; + + ExifThumbnail copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Files/FileMoveParamsTest.cs b/src/ImageKit.Tests/Models/Files/FileMoveParamsTest.cs new file mode 100644 index 00000000..2f134efc --- /dev/null +++ b/src/ImageKit.Tests/Models/Files/FileMoveParamsTest.cs @@ -0,0 +1,51 @@ +using System; +using ImageKit.Models.Files; + +namespace ImageKit.Tests.Models.Files; + +public class FileMoveParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new FileMoveParams + { + DestinationPath = "/folder/to/move/into/", + SourceFilePath = "/path/to/file.jpg", + }; + + string expectedDestinationPath = "/folder/to/move/into/"; + string expectedSourceFilePath = "/path/to/file.jpg"; + + Assert.Equal(expectedDestinationPath, parameters.DestinationPath); + Assert.Equal(expectedSourceFilePath, parameters.SourceFilePath); + } + + [Fact] + public void Url_Works() + { + FileMoveParams parameters = new() + { + DestinationPath = "/folder/to/move/into/", + SourceFilePath = "/path/to/file.jpg", + }; + + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + + Assert.Equal(new Uri("https://api.imagekit.io/v1/files/move"), url); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new FileMoveParams + { + DestinationPath = "/folder/to/move/into/", + SourceFilePath = "/path/to/file.jpg", + }; + + FileMoveParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Files/FileMoveResponseTest.cs b/src/ImageKit.Tests/Models/Files/FileMoveResponseTest.cs new file mode 100644 index 00000000..52448343 --- /dev/null +++ b/src/ImageKit.Tests/Models/Files/FileMoveResponseTest.cs @@ -0,0 +1,59 @@ +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Models.Files; + +namespace ImageKit.Tests.Models.Files; + +public class FileMoveResponseTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new FileMoveResponse { }; + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new FileMoveResponse { }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new FileMoveResponse { }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + } + + [Fact] + public void Validation_Works() + { + var model = new FileMoveResponse { }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new FileMoveResponse { }; + + FileMoveResponse copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Files/FileRenameParamsTest.cs b/src/ImageKit.Tests/Models/Files/FileRenameParamsTest.cs new file mode 100644 index 00000000..e8cf12d8 --- /dev/null +++ b/src/ImageKit.Tests/Models/Files/FileRenameParamsTest.cs @@ -0,0 +1,84 @@ +using System; +using ImageKit.Models.Files; + +namespace ImageKit.Tests.Models.Files; + +public class FileRenameParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new FileRenameParams + { + FilePath = "/path/to/file.jpg", + NewFileName = "newFileName.jpg", + PurgeCache = true, + }; + + string expectedFilePath = "/path/to/file.jpg"; + string expectedNewFileName = "newFileName.jpg"; + bool expectedPurgeCache = true; + + Assert.Equal(expectedFilePath, parameters.FilePath); + Assert.Equal(expectedNewFileName, parameters.NewFileName); + Assert.Equal(expectedPurgeCache, parameters.PurgeCache); + } + + [Fact] + public void OptionalNonNullableParamsUnsetAreNotSet_Works() + { + var parameters = new FileRenameParams + { + FilePath = "/path/to/file.jpg", + NewFileName = "newFileName.jpg", + }; + + Assert.Null(parameters.PurgeCache); + Assert.False(parameters.RawBodyData.ContainsKey("purgeCache")); + } + + [Fact] + public void OptionalNonNullableParamsSetToNullAreNotSet_Works() + { + var parameters = new FileRenameParams + { + FilePath = "/path/to/file.jpg", + NewFileName = "newFileName.jpg", + + // Null should be interpreted as omitted for these properties + PurgeCache = null, + }; + + Assert.Null(parameters.PurgeCache); + Assert.False(parameters.RawBodyData.ContainsKey("purgeCache")); + } + + [Fact] + public void Url_Works() + { + FileRenameParams parameters = new() + { + FilePath = "/path/to/file.jpg", + NewFileName = "newFileName.jpg", + }; + + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + + Assert.Equal(new Uri("https://api.imagekit.io/v1/files/rename"), url); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new FileRenameParams + { + FilePath = "/path/to/file.jpg", + NewFileName = "newFileName.jpg", + PurgeCache = true, + }; + + FileRenameParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Files/FileRenameResponseTest.cs b/src/ImageKit.Tests/Models/Files/FileRenameResponseTest.cs new file mode 100644 index 00000000..706bdc9b --- /dev/null +++ b/src/ImageKit.Tests/Models/Files/FileRenameResponseTest.cs @@ -0,0 +1,109 @@ +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Models.Files; + +namespace ImageKit.Tests.Models.Files; + +public class FileRenameResponseTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new FileRenameResponse { PurgeRequestID = "purgeRequestId" }; + + string expectedPurgeRequestID = "purgeRequestId"; + + Assert.Equal(expectedPurgeRequestID, model.PurgeRequestID); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new FileRenameResponse { PurgeRequestID = "purgeRequestId" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new FileRenameResponse { PurgeRequestID = "purgeRequestId" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedPurgeRequestID = "purgeRequestId"; + + Assert.Equal(expectedPurgeRequestID, deserialized.PurgeRequestID); + } + + [Fact] + public void Validation_Works() + { + var model = new FileRenameResponse { PurgeRequestID = "purgeRequestId" }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new FileRenameResponse { }; + + Assert.Null(model.PurgeRequestID); + Assert.False(model.RawData.ContainsKey("purgeRequestId")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new FileRenameResponse { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new FileRenameResponse + { + // Null should be interpreted as omitted for these properties + PurgeRequestID = null, + }; + + Assert.Null(model.PurgeRequestID); + Assert.False(model.RawData.ContainsKey("purgeRequestId")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new FileRenameResponse + { + // Null should be interpreted as omitted for these properties + PurgeRequestID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new FileRenameResponse { PurgeRequestID = "purgeRequestId" }; + + FileRenameResponse copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Files/FileTest.cs b/src/ImageKit.Tests/Models/Files/FileTest.cs new file mode 100644 index 00000000..1ef33ac1 --- /dev/null +++ b/src/ImageKit.Tests/Models/Files/FileTest.cs @@ -0,0 +1,1936 @@ +using System; +using System.Collections.Generic; +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Exceptions; +using Files = ImageKit.Models.Files; + +namespace ImageKit.Tests.Models.Files; + +public class FileTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Files::File + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + Width = 0, + }; + + List expectedAITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ]; + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + string expectedCustomCoordinates = "customCoordinates"; + Dictionary expectedCustomMetadata = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; + string expectedDescription = "description"; + string expectedFileID = "fileId"; + string expectedFilePath = "filePath"; + string expectedFileType = "fileType"; + bool expectedHasAlpha = true; + double expectedHeight = 0; + bool expectedIsPrivateFile = true; + bool expectedIsPublished = true; + string expectedMime = "mime"; + string expectedName = "name"; + Dictionary expectedSelectedFieldsSchema = new() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }; + double expectedSize = 0; + List expectedTags = ["string"]; + string expectedThumbnail = "https://example.com"; + ApiEnum expectedType = Files::FileType.File; + DateTimeOffset expectedUpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + string expectedUrl = "https://example.com"; + Files::VersionInfo expectedVersionInfo = new() { ID = "id", Name = "name" }; + double expectedWidth = 0; + + Assert.NotNull(model.AITags); + Assert.Equal(expectedAITags.Count, model.AITags.Count); + for (int i = 0; i < expectedAITags.Count; i++) + { + Assert.Equal(expectedAITags[i], model.AITags[i]); + } + Assert.Equal(expectedCreatedAt, model.CreatedAt); + Assert.Equal(expectedCustomCoordinates, model.CustomCoordinates); + Assert.NotNull(model.CustomMetadata); + Assert.Equal(expectedCustomMetadata.Count, model.CustomMetadata.Count); + foreach (var item in expectedCustomMetadata) + { + Assert.True(model.CustomMetadata.TryGetValue(item.Key, out var value)); + + Assert.True(JsonElement.DeepEquals(value, model.CustomMetadata[item.Key])); + } + Assert.Equal(expectedDescription, model.Description); + Assert.Equal(expectedFileID, model.FileID); + Assert.Equal(expectedFilePath, model.FilePath); + Assert.Equal(expectedFileType, model.FileType); + Assert.Equal(expectedHasAlpha, model.HasAlpha); + Assert.Equal(expectedHeight, model.Height); + Assert.Equal(expectedIsPrivateFile, model.IsPrivateFile); + Assert.Equal(expectedIsPublished, model.IsPublished); + Assert.Equal(expectedMime, model.Mime); + Assert.Equal(expectedName, model.Name); + Assert.NotNull(model.SelectedFieldsSchema); + Assert.Equal(expectedSelectedFieldsSchema.Count, model.SelectedFieldsSchema.Count); + foreach (var item in expectedSelectedFieldsSchema) + { + Assert.True(model.SelectedFieldsSchema.TryGetValue(item.Key, out var value)); + + Assert.Equal(value, model.SelectedFieldsSchema[item.Key]); + } + Assert.Equal(expectedSize, model.Size); + Assert.NotNull(model.Tags); + Assert.Equal(expectedTags.Count, model.Tags.Count); + for (int i = 0; i < expectedTags.Count; i++) + { + Assert.Equal(expectedTags[i], model.Tags[i]); + } + Assert.Equal(expectedThumbnail, model.Thumbnail); + Assert.Equal(expectedType, model.Type); + Assert.Equal(expectedUpdatedAt, model.UpdatedAt); + Assert.Equal(expectedUrl, model.Url); + Assert.Equal(expectedVersionInfo, model.VersionInfo); + Assert.Equal(expectedWidth, model.Width); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Files::File + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + Width = 0, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Files::File + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + Width = 0, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedAITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ]; + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + string expectedCustomCoordinates = "customCoordinates"; + Dictionary expectedCustomMetadata = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; + string expectedDescription = "description"; + string expectedFileID = "fileId"; + string expectedFilePath = "filePath"; + string expectedFileType = "fileType"; + bool expectedHasAlpha = true; + double expectedHeight = 0; + bool expectedIsPrivateFile = true; + bool expectedIsPublished = true; + string expectedMime = "mime"; + string expectedName = "name"; + Dictionary expectedSelectedFieldsSchema = new() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }; + double expectedSize = 0; + List expectedTags = ["string"]; + string expectedThumbnail = "https://example.com"; + ApiEnum expectedType = Files::FileType.File; + DateTimeOffset expectedUpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + string expectedUrl = "https://example.com"; + Files::VersionInfo expectedVersionInfo = new() { ID = "id", Name = "name" }; + double expectedWidth = 0; + + Assert.NotNull(deserialized.AITags); + Assert.Equal(expectedAITags.Count, deserialized.AITags.Count); + for (int i = 0; i < expectedAITags.Count; i++) + { + Assert.Equal(expectedAITags[i], deserialized.AITags[i]); + } + Assert.Equal(expectedCreatedAt, deserialized.CreatedAt); + Assert.Equal(expectedCustomCoordinates, deserialized.CustomCoordinates); + Assert.NotNull(deserialized.CustomMetadata); + Assert.Equal(expectedCustomMetadata.Count, deserialized.CustomMetadata.Count); + foreach (var item in expectedCustomMetadata) + { + Assert.True(deserialized.CustomMetadata.TryGetValue(item.Key, out var value)); + + Assert.True(JsonElement.DeepEquals(value, deserialized.CustomMetadata[item.Key])); + } + Assert.Equal(expectedDescription, deserialized.Description); + Assert.Equal(expectedFileID, deserialized.FileID); + Assert.Equal(expectedFilePath, deserialized.FilePath); + Assert.Equal(expectedFileType, deserialized.FileType); + Assert.Equal(expectedHasAlpha, deserialized.HasAlpha); + Assert.Equal(expectedHeight, deserialized.Height); + Assert.Equal(expectedIsPrivateFile, deserialized.IsPrivateFile); + Assert.Equal(expectedIsPublished, deserialized.IsPublished); + Assert.Equal(expectedMime, deserialized.Mime); + Assert.Equal(expectedName, deserialized.Name); + Assert.NotNull(deserialized.SelectedFieldsSchema); + Assert.Equal(expectedSelectedFieldsSchema.Count, deserialized.SelectedFieldsSchema.Count); + foreach (var item in expectedSelectedFieldsSchema) + { + Assert.True(deserialized.SelectedFieldsSchema.TryGetValue(item.Key, out var value)); + + Assert.Equal(value, deserialized.SelectedFieldsSchema[item.Key]); + } + Assert.Equal(expectedSize, deserialized.Size); + Assert.NotNull(deserialized.Tags); + Assert.Equal(expectedTags.Count, deserialized.Tags.Count); + for (int i = 0; i < expectedTags.Count; i++) + { + Assert.Equal(expectedTags[i], deserialized.Tags[i]); + } + Assert.Equal(expectedThumbnail, deserialized.Thumbnail); + Assert.Equal(expectedType, deserialized.Type); + Assert.Equal(expectedUpdatedAt, deserialized.UpdatedAt); + Assert.Equal(expectedUrl, deserialized.Url); + Assert.Equal(expectedVersionInfo, deserialized.VersionInfo); + Assert.Equal(expectedWidth, deserialized.Width); + } + + [Fact] + public void Validation_Works() + { + var model = new Files::File + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + Width = 0, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Files::File + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + CustomCoordinates = "customCoordinates", + Tags = ["string"], + }; + + Assert.Null(model.CreatedAt); + Assert.False(model.RawData.ContainsKey("createdAt")); + Assert.Null(model.CustomMetadata); + Assert.False(model.RawData.ContainsKey("customMetadata")); + Assert.Null(model.Description); + Assert.False(model.RawData.ContainsKey("description")); + Assert.Null(model.FileID); + Assert.False(model.RawData.ContainsKey("fileId")); + Assert.Null(model.FilePath); + Assert.False(model.RawData.ContainsKey("filePath")); + Assert.Null(model.FileType); + Assert.False(model.RawData.ContainsKey("fileType")); + Assert.Null(model.HasAlpha); + Assert.False(model.RawData.ContainsKey("hasAlpha")); + Assert.Null(model.Height); + Assert.False(model.RawData.ContainsKey("height")); + Assert.Null(model.IsPrivateFile); + Assert.False(model.RawData.ContainsKey("isPrivateFile")); + Assert.Null(model.IsPublished); + Assert.False(model.RawData.ContainsKey("isPublished")); + Assert.Null(model.Mime); + Assert.False(model.RawData.ContainsKey("mime")); + Assert.Null(model.Name); + Assert.False(model.RawData.ContainsKey("name")); + Assert.Null(model.SelectedFieldsSchema); + Assert.False(model.RawData.ContainsKey("selectedFieldsSchema")); + Assert.Null(model.Size); + Assert.False(model.RawData.ContainsKey("size")); + Assert.Null(model.Thumbnail); + Assert.False(model.RawData.ContainsKey("thumbnail")); + Assert.Null(model.Type); + Assert.False(model.RawData.ContainsKey("type")); + Assert.Null(model.UpdatedAt); + Assert.False(model.RawData.ContainsKey("updatedAt")); + Assert.Null(model.Url); + Assert.False(model.RawData.ContainsKey("url")); + Assert.Null(model.VersionInfo); + Assert.False(model.RawData.ContainsKey("versionInfo")); + Assert.Null(model.Width); + Assert.False(model.RawData.ContainsKey("width")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new Files::File + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + CustomCoordinates = "customCoordinates", + Tags = ["string"], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new Files::File + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + CustomCoordinates = "customCoordinates", + Tags = ["string"], + + // Null should be interpreted as omitted for these properties + CreatedAt = null, + CustomMetadata = null, + Description = null, + FileID = null, + FilePath = null, + FileType = null, + HasAlpha = null, + Height = null, + IsPrivateFile = null, + IsPublished = null, + Mime = null, + Name = null, + SelectedFieldsSchema = null, + Size = null, + Thumbnail = null, + Type = null, + UpdatedAt = null, + Url = null, + VersionInfo = null, + Width = null, + }; + + Assert.Null(model.CreatedAt); + Assert.False(model.RawData.ContainsKey("createdAt")); + Assert.Null(model.CustomMetadata); + Assert.False(model.RawData.ContainsKey("customMetadata")); + Assert.Null(model.Description); + Assert.False(model.RawData.ContainsKey("description")); + Assert.Null(model.FileID); + Assert.False(model.RawData.ContainsKey("fileId")); + Assert.Null(model.FilePath); + Assert.False(model.RawData.ContainsKey("filePath")); + Assert.Null(model.FileType); + Assert.False(model.RawData.ContainsKey("fileType")); + Assert.Null(model.HasAlpha); + Assert.False(model.RawData.ContainsKey("hasAlpha")); + Assert.Null(model.Height); + Assert.False(model.RawData.ContainsKey("height")); + Assert.Null(model.IsPrivateFile); + Assert.False(model.RawData.ContainsKey("isPrivateFile")); + Assert.Null(model.IsPublished); + Assert.False(model.RawData.ContainsKey("isPublished")); + Assert.Null(model.Mime); + Assert.False(model.RawData.ContainsKey("mime")); + Assert.Null(model.Name); + Assert.False(model.RawData.ContainsKey("name")); + Assert.Null(model.SelectedFieldsSchema); + Assert.False(model.RawData.ContainsKey("selectedFieldsSchema")); + Assert.Null(model.Size); + Assert.False(model.RawData.ContainsKey("size")); + Assert.Null(model.Thumbnail); + Assert.False(model.RawData.ContainsKey("thumbnail")); + Assert.Null(model.Type); + Assert.False(model.RawData.ContainsKey("type")); + Assert.Null(model.UpdatedAt); + Assert.False(model.RawData.ContainsKey("updatedAt")); + Assert.Null(model.Url); + Assert.False(model.RawData.ContainsKey("url")); + Assert.Null(model.VersionInfo); + Assert.False(model.RawData.ContainsKey("versionInfo")); + Assert.Null(model.Width); + Assert.False(model.RawData.ContainsKey("width")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new Files::File + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + CustomCoordinates = "customCoordinates", + Tags = ["string"], + + // Null should be interpreted as omitted for these properties + CreatedAt = null, + CustomMetadata = null, + Description = null, + FileID = null, + FilePath = null, + FileType = null, + HasAlpha = null, + Height = null, + IsPrivateFile = null, + IsPublished = null, + Mime = null, + Name = null, + SelectedFieldsSchema = null, + Size = null, + Thumbnail = null, + Type = null, + UpdatedAt = null, + Url = null, + VersionInfo = null, + Width = null, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Files::File + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + Width = 0, + }; + + Assert.Null(model.AITags); + Assert.False(model.RawData.ContainsKey("AITags")); + Assert.Null(model.CustomCoordinates); + Assert.False(model.RawData.ContainsKey("customCoordinates")); + Assert.Null(model.Tags); + Assert.False(model.RawData.ContainsKey("tags")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new Files::File + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + Width = 0, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new Files::File + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + Width = 0, + + AITags = null, + CustomCoordinates = null, + Tags = null, + }; + + Assert.Null(model.AITags); + Assert.True(model.RawData.ContainsKey("AITags")); + Assert.Null(model.CustomCoordinates); + Assert.True(model.RawData.ContainsKey("customCoordinates")); + Assert.Null(model.Tags); + Assert.True(model.RawData.ContainsKey("tags")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new Files::File + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + Width = 0, + + AITags = null, + CustomCoordinates = null, + Tags = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Files::File + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + Width = 0, + }; + + Files::File copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class AITagTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Files::AITag + { + Confidence = 0, + Name = "name", + Source = "source", + }; + + double expectedConfidence = 0; + string expectedName = "name"; + string expectedSource = "source"; + + Assert.Equal(expectedConfidence, model.Confidence); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedSource, model.Source); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Files::AITag + { + Confidence = 0, + Name = "name", + Source = "source", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Files::AITag + { + Confidence = 0, + Name = "name", + Source = "source", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + double expectedConfidence = 0; + string expectedName = "name"; + string expectedSource = "source"; + + Assert.Equal(expectedConfidence, deserialized.Confidence); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedSource, deserialized.Source); + } + + [Fact] + public void Validation_Works() + { + var model = new Files::AITag + { + Confidence = 0, + Name = "name", + Source = "source", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Files::AITag { }; + + Assert.Null(model.Confidence); + Assert.False(model.RawData.ContainsKey("confidence")); + Assert.Null(model.Name); + Assert.False(model.RawData.ContainsKey("name")); + Assert.Null(model.Source); + Assert.False(model.RawData.ContainsKey("source")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new Files::AITag { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new Files::AITag + { + // Null should be interpreted as omitted for these properties + Confidence = null, + Name = null, + Source = null, + }; + + Assert.Null(model.Confidence); + Assert.False(model.RawData.ContainsKey("confidence")); + Assert.Null(model.Name); + Assert.False(model.RawData.ContainsKey("name")); + Assert.Null(model.Source); + Assert.False(model.RawData.ContainsKey("source")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new Files::AITag + { + // Null should be interpreted as omitted for these properties + Confidence = null, + Name = null, + Source = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Files::AITag + { + Confidence = 0, + Name = "name", + Source = "source", + }; + + Files::AITag copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class SelectedFieldsSchemaItemTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Files::SelectedFieldsSchemaItem + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + }; + + ApiEnum expectedType = Files::Type.Text; + Files::DefaultValue expectedDefaultValue = "string"; + bool expectedIsValueRequired = true; + double expectedMaxLength = 0; + Files::MaxValue expectedMaxValue = "string"; + double expectedMinLength = 0; + Files::MinValue expectedMinValue = "string"; + bool expectedReadOnly = true; + List expectedSelectOptions = + [ + "small", + "medium", + "large", + 30, + 40, + true, + ]; + bool expectedSelectOptionsTruncated = true; + + Assert.Equal(expectedType, model.Type); + Assert.Equal(expectedDefaultValue, model.DefaultValue); + Assert.Equal(expectedIsValueRequired, model.IsValueRequired); + Assert.Equal(expectedMaxLength, model.MaxLength); + Assert.Equal(expectedMaxValue, model.MaxValue); + Assert.Equal(expectedMinLength, model.MinLength); + Assert.Equal(expectedMinValue, model.MinValue); + Assert.Equal(expectedReadOnly, model.ReadOnly); + Assert.NotNull(model.SelectOptions); + Assert.Equal(expectedSelectOptions.Count, model.SelectOptions.Count); + for (int i = 0; i < expectedSelectOptions.Count; i++) + { + Assert.Equal(expectedSelectOptions[i], model.SelectOptions[i]); + } + Assert.Equal(expectedSelectOptionsTruncated, model.SelectOptionsTruncated); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Files::SelectedFieldsSchemaItem + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Files::SelectedFieldsSchemaItem + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum expectedType = Files::Type.Text; + Files::DefaultValue expectedDefaultValue = "string"; + bool expectedIsValueRequired = true; + double expectedMaxLength = 0; + Files::MaxValue expectedMaxValue = "string"; + double expectedMinLength = 0; + Files::MinValue expectedMinValue = "string"; + bool expectedReadOnly = true; + List expectedSelectOptions = + [ + "small", + "medium", + "large", + 30, + 40, + true, + ]; + bool expectedSelectOptionsTruncated = true; + + Assert.Equal(expectedType, deserialized.Type); + Assert.Equal(expectedDefaultValue, deserialized.DefaultValue); + Assert.Equal(expectedIsValueRequired, deserialized.IsValueRequired); + Assert.Equal(expectedMaxLength, deserialized.MaxLength); + Assert.Equal(expectedMaxValue, deserialized.MaxValue); + Assert.Equal(expectedMinLength, deserialized.MinLength); + Assert.Equal(expectedMinValue, deserialized.MinValue); + Assert.Equal(expectedReadOnly, deserialized.ReadOnly); + Assert.NotNull(deserialized.SelectOptions); + Assert.Equal(expectedSelectOptions.Count, deserialized.SelectOptions.Count); + for (int i = 0; i < expectedSelectOptions.Count; i++) + { + Assert.Equal(expectedSelectOptions[i], deserialized.SelectOptions[i]); + } + Assert.Equal(expectedSelectOptionsTruncated, deserialized.SelectOptionsTruncated); + } + + [Fact] + public void Validation_Works() + { + var model = new Files::SelectedFieldsSchemaItem + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Files::SelectedFieldsSchemaItem { Type = Files::Type.Text }; + + Assert.Null(model.DefaultValue); + Assert.False(model.RawData.ContainsKey("defaultValue")); + Assert.Null(model.IsValueRequired); + Assert.False(model.RawData.ContainsKey("isValueRequired")); + Assert.Null(model.MaxLength); + Assert.False(model.RawData.ContainsKey("maxLength")); + Assert.Null(model.MaxValue); + Assert.False(model.RawData.ContainsKey("maxValue")); + Assert.Null(model.MinLength); + Assert.False(model.RawData.ContainsKey("minLength")); + Assert.Null(model.MinValue); + Assert.False(model.RawData.ContainsKey("minValue")); + Assert.Null(model.ReadOnly); + Assert.False(model.RawData.ContainsKey("readOnly")); + Assert.Null(model.SelectOptions); + Assert.False(model.RawData.ContainsKey("selectOptions")); + Assert.Null(model.SelectOptionsTruncated); + Assert.False(model.RawData.ContainsKey("selectOptionsTruncated")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new Files::SelectedFieldsSchemaItem { Type = Files::Type.Text }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new Files::SelectedFieldsSchemaItem + { + Type = Files::Type.Text, + + // Null should be interpreted as omitted for these properties + DefaultValue = null, + IsValueRequired = null, + MaxLength = null, + MaxValue = null, + MinLength = null, + MinValue = null, + ReadOnly = null, + SelectOptions = null, + SelectOptionsTruncated = null, + }; + + Assert.Null(model.DefaultValue); + Assert.False(model.RawData.ContainsKey("defaultValue")); + Assert.Null(model.IsValueRequired); + Assert.False(model.RawData.ContainsKey("isValueRequired")); + Assert.Null(model.MaxLength); + Assert.False(model.RawData.ContainsKey("maxLength")); + Assert.Null(model.MaxValue); + Assert.False(model.RawData.ContainsKey("maxValue")); + Assert.Null(model.MinLength); + Assert.False(model.RawData.ContainsKey("minLength")); + Assert.Null(model.MinValue); + Assert.False(model.RawData.ContainsKey("minValue")); + Assert.Null(model.ReadOnly); + Assert.False(model.RawData.ContainsKey("readOnly")); + Assert.Null(model.SelectOptions); + Assert.False(model.RawData.ContainsKey("selectOptions")); + Assert.Null(model.SelectOptionsTruncated); + Assert.False(model.RawData.ContainsKey("selectOptionsTruncated")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new Files::SelectedFieldsSchemaItem + { + Type = Files::Type.Text, + + // Null should be interpreted as omitted for these properties + DefaultValue = null, + IsValueRequired = null, + MaxLength = null, + MaxValue = null, + MinLength = null, + MinValue = null, + ReadOnly = null, + SelectOptions = null, + SelectOptionsTruncated = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Files::SelectedFieldsSchemaItem + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + }; + + Files::SelectedFieldsSchemaItem copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TypeTest : TestBase +{ + [Theory] + [InlineData(Files::Type.Text)] + [InlineData(Files::Type.Textarea)] + [InlineData(Files::Type.Number)] + [InlineData(Files::Type.Date)] + [InlineData(Files::Type.Boolean)] + [InlineData(Files::Type.SingleSelect)] + [InlineData(Files::Type.MultiSelect)] + public void Validation_Works(Files::Type rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(Files::Type.Text)] + [InlineData(Files::Type.Textarea)] + [InlineData(Files::Type.Number)] + [InlineData(Files::Type.Date)] + [InlineData(Files::Type.Boolean)] + [InlineData(Files::Type.SingleSelect)] + [InlineData(Files::Type.MultiSelect)] + public void SerializationRoundtrip_Works(Files::Type rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class DefaultValueTest : TestBase +{ + [Fact] + public void StringValidationWorks() + { + Files::DefaultValue value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + Files::DefaultValue value = 0; + value.Validate(); + } + + [Fact] + public void BoolValidationWorks() + { + Files::DefaultValue value = true; + value.Validate(); + } + + [Fact] + public void MixedValidationWorks() + { + Files::DefaultValue value = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ); + value.Validate(); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + Files::DefaultValue value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + Files::DefaultValue value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void BoolSerializationRoundtripWorks() + { + Files::DefaultValue value = true; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void MixedSerializationRoundtripWorks() + { + Files::DefaultValue value = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class UnnamedSchemaWithArrayParent10Test : TestBase +{ + [Fact] + public void StringValidationWorks() + { + Files::UnnamedSchemaWithArrayParent10 value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + Files::UnnamedSchemaWithArrayParent10 value = 0; + value.Validate(); + } + + [Fact] + public void BoolValidationWorks() + { + Files::UnnamedSchemaWithArrayParent10 value = true; + value.Validate(); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + Files::UnnamedSchemaWithArrayParent10 value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + Files::UnnamedSchemaWithArrayParent10 value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void BoolSerializationRoundtripWorks() + { + Files::UnnamedSchemaWithArrayParent10 value = true; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class MaxValueTest : TestBase +{ + [Fact] + public void StringValidationWorks() + { + Files::MaxValue value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + Files::MaxValue value = 0; + value.Validate(); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + Files::MaxValue value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + Files::MaxValue value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class MinValueTest : TestBase +{ + [Fact] + public void StringValidationWorks() + { + Files::MinValue value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + Files::MinValue value = 0; + value.Validate(); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + Files::MinValue value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + Files::MinValue value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class SelectOptionTest : TestBase +{ + [Fact] + public void StringValidationWorks() + { + Files::SelectOption value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + Files::SelectOption value = 0; + value.Validate(); + } + + [Fact] + public void BoolValidationWorks() + { + Files::SelectOption value = true; + value.Validate(); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + Files::SelectOption value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + Files::SelectOption value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void BoolSerializationRoundtripWorks() + { + Files::SelectOption value = true; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class FileTypeTest : TestBase +{ + [Theory] + [InlineData(Files::FileType.File)] + [InlineData(Files::FileType.FileVersion)] + public void Validation_Works(Files::FileType rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(Files::FileType.File)] + [InlineData(Files::FileType.FileVersion)] + public void SerializationRoundtrip_Works(Files::FileType rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class VersionInfoTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Files::VersionInfo { ID = "id", Name = "name" }; + + string expectedID = "id"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Files::VersionInfo { ID = "id", Name = "name" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Files::VersionInfo { ID = "id", Name = "name" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new Files::VersionInfo { ID = "id", Name = "name" }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Files::VersionInfo { }; + + Assert.Null(model.ID); + Assert.False(model.RawData.ContainsKey("id")); + Assert.Null(model.Name); + Assert.False(model.RawData.ContainsKey("name")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new Files::VersionInfo { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new Files::VersionInfo + { + // Null should be interpreted as omitted for these properties + ID = null, + Name = null, + }; + + Assert.Null(model.ID); + Assert.False(model.RawData.ContainsKey("id")); + Assert.Null(model.Name); + Assert.False(model.RawData.ContainsKey("name")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new Files::VersionInfo + { + // Null should be interpreted as omitted for these properties + ID = null, + Name = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Files::VersionInfo { ID = "id", Name = "name" }; + + Files::VersionInfo copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Files/FileUpdateParamsTest.cs b/src/ImageKit.Tests/Models/Files/FileUpdateParamsTest.cs new file mode 100644 index 00000000..093b5533 --- /dev/null +++ b/src/ImageKit.Tests/Models/Files/FileUpdateParamsTest.cs @@ -0,0 +1,257 @@ +using System; +using System.Collections.Generic; +using System.Text.Json; +using ImageKit.Models; +using ImageKit.Models.Files; + +namespace ImageKit.Tests.Models.Files; + +public class FileUpdateParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new FileUpdateParams + { + FileID = "fileId", + UpdateFileRequest = new UpdateFileDetails() + { + CustomCoordinates = "10,10,100,100", + CustomMetadata = new Dictionary() + { + { "brand", JsonSerializer.SerializeToElement("bar") }, + { "color", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Extensions = + [ + new UnnamedSchemaWithArrayParent0RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }, + new UnnamedSchemaWithArrayParent0AutoTaggingExtension() + { + MaxTags = 10, + MinConfidence = 80, + Name = + UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + }, + new UnnamedSchemaWithArrayParent0AutoTaggingExtension() + { + MaxTags = 10, + MinConfidence = 80, + Name = UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.AwsAutoTagging, + }, + new UnnamedSchemaWithArrayParent0AIAutoDescription(), + new UnnamedSchemaWithArrayParent0AITasks( + [ + new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + { + Instruction = "What types of clothing items are visible?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "dress", "jacket"], + }, + ] + ), + new SavedExtension("ext_abc123"), + ], + RemoveAITags = new(["car", "vehicle", "motorsports"]), + Tags = ["tag1", "tag2"], + WebhookUrl = "https://webhook.site/0d6b6c7a-8e5a-4b3a-8b7c-0d6b6c7a8e5a", + }, + }; + + string expectedFileID = "fileId"; + UpdateFileRequest expectedUpdateFileRequest = new UpdateFileDetails() + { + CustomCoordinates = "10,10,100,100", + CustomMetadata = new Dictionary() + { + { "brand", JsonSerializer.SerializeToElement("bar") }, + { "color", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Extensions = + [ + new UnnamedSchemaWithArrayParent0RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }, + new UnnamedSchemaWithArrayParent0AutoTaggingExtension() + { + MaxTags = 10, + MinConfidence = 80, + Name = UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + }, + new UnnamedSchemaWithArrayParent0AutoTaggingExtension() + { + MaxTags = 10, + MinConfidence = 80, + Name = UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.AwsAutoTagging, + }, + new UnnamedSchemaWithArrayParent0AIAutoDescription(), + new UnnamedSchemaWithArrayParent0AITasks( + [ + new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + { + Instruction = "What types of clothing items are visible?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "dress", "jacket"], + }, + ] + ), + new SavedExtension("ext_abc123"), + ], + RemoveAITags = new(["car", "vehicle", "motorsports"]), + Tags = ["tag1", "tag2"], + WebhookUrl = "https://webhook.site/0d6b6c7a-8e5a-4b3a-8b7c-0d6b6c7a8e5a", + }; + + Assert.Equal(expectedFileID, parameters.FileID); + Assert.Equal(expectedUpdateFileRequest, parameters.UpdateFileRequest); + } + + [Fact] + public void Url_Works() + { + FileUpdateParams parameters = new() + { + FileID = "fileId", + UpdateFileRequest = new UpdateFileDetails() + { + CustomCoordinates = "10,10,100,100", + CustomMetadata = new Dictionary() + { + { "brand", JsonSerializer.SerializeToElement("bar") }, + { "color", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Extensions = + [ + new UnnamedSchemaWithArrayParent0RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }, + new UnnamedSchemaWithArrayParent0AutoTaggingExtension() + { + MaxTags = 10, + MinConfidence = 80, + Name = + UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + }, + new UnnamedSchemaWithArrayParent0AutoTaggingExtension() + { + MaxTags = 10, + MinConfidence = 80, + Name = UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.AwsAutoTagging, + }, + new UnnamedSchemaWithArrayParent0AIAutoDescription(), + new UnnamedSchemaWithArrayParent0AITasks( + [ + new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + { + Instruction = "What types of clothing items are visible?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "dress", "jacket"], + }, + ] + ), + new SavedExtension("ext_abc123"), + ], + RemoveAITags = new(["car", "vehicle", "motorsports"]), + Tags = ["tag1", "tag2"], + WebhookUrl = "https://webhook.site/0d6b6c7a-8e5a-4b3a-8b7c-0d6b6c7a8e5a", + }, + }; + + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + + Assert.Equal(new Uri("https://api.imagekit.io/v1/files/fileId/details"), url); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new FileUpdateParams + { + FileID = "fileId", + UpdateFileRequest = new UpdateFileDetails() + { + CustomCoordinates = "10,10,100,100", + CustomMetadata = new Dictionary() + { + { "brand", JsonSerializer.SerializeToElement("bar") }, + { "color", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Extensions = + [ + new UnnamedSchemaWithArrayParent0RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }, + new UnnamedSchemaWithArrayParent0AutoTaggingExtension() + { + MaxTags = 10, + MinConfidence = 80, + Name = + UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + }, + new UnnamedSchemaWithArrayParent0AutoTaggingExtension() + { + MaxTags = 10, + MinConfidence = 80, + Name = UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.AwsAutoTagging, + }, + new UnnamedSchemaWithArrayParent0AIAutoDescription(), + new UnnamedSchemaWithArrayParent0AITasks( + [ + new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + { + Instruction = "What types of clothing items are visible?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "dress", "jacket"], + }, + ] + ), + new SavedExtension("ext_abc123"), + ], + RemoveAITags = new(["car", "vehicle", "motorsports"]), + Tags = ["tag1", "tag2"], + WebhookUrl = "https://webhook.site/0d6b6c7a-8e5a-4b3a-8b7c-0d6b6c7a8e5a", + }, + }; + + FileUpdateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Files/FileUpdateResponseTest.cs b/src/ImageKit.Tests/Models/Files/FileUpdateResponseTest.cs new file mode 100644 index 00000000..54743c5a --- /dev/null +++ b/src/ImageKit.Tests/Models/Files/FileUpdateResponseTest.cs @@ -0,0 +1,1711 @@ +using System; +using System.Collections.Generic; +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Exceptions; +using Files = ImageKit.Models.Files; + +namespace ImageKit.Tests.Models.Files; + +public class FileUpdateResponseTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Files::FileUpdateResponse + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + Width = 0, + ExtensionStatus = new() + { + AIAutoDescription = Files::AIAutoDescription.Success, + AITasks = Files::AITasks.Success, + AwsAutoTagging = Files::AwsAutoTagging.Success, + GoogleAutoTagging = Files::GoogleAutoTagging.Success, + RemoveBg = Files::RemoveBg.Success, + }, + }; + + List expectedAITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ]; + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + string expectedCustomCoordinates = "customCoordinates"; + Dictionary expectedCustomMetadata = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; + string expectedDescription = "description"; + string expectedFileID = "fileId"; + string expectedFilePath = "filePath"; + string expectedFileType = "fileType"; + bool expectedHasAlpha = true; + double expectedHeight = 0; + bool expectedIsPrivateFile = true; + bool expectedIsPublished = true; + string expectedMime = "mime"; + string expectedName = "name"; + Dictionary expectedSelectedFieldsSchema = new() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }; + double expectedSize = 0; + List expectedTags = ["string"]; + string expectedThumbnail = "https://example.com"; + ApiEnum expectedType = Files::FileType.File; + DateTimeOffset expectedUpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + string expectedUrl = "https://example.com"; + Files::VersionInfo expectedVersionInfo = new() { ID = "id", Name = "name" }; + double expectedWidth = 0; + Files::ExtensionStatus expectedExtensionStatus = new() + { + AIAutoDescription = Files::AIAutoDescription.Success, + AITasks = Files::AITasks.Success, + AwsAutoTagging = Files::AwsAutoTagging.Success, + GoogleAutoTagging = Files::GoogleAutoTagging.Success, + RemoveBg = Files::RemoveBg.Success, + }; + + Assert.NotNull(model.AITags); + Assert.Equal(expectedAITags.Count, model.AITags.Count); + for (int i = 0; i < expectedAITags.Count; i++) + { + Assert.Equal(expectedAITags[i], model.AITags[i]); + } + Assert.Equal(expectedCreatedAt, model.CreatedAt); + Assert.Equal(expectedCustomCoordinates, model.CustomCoordinates); + Assert.NotNull(model.CustomMetadata); + Assert.Equal(expectedCustomMetadata.Count, model.CustomMetadata.Count); + foreach (var item in expectedCustomMetadata) + { + Assert.True(model.CustomMetadata.TryGetValue(item.Key, out var value)); + + Assert.True(JsonElement.DeepEquals(value, model.CustomMetadata[item.Key])); + } + Assert.Equal(expectedDescription, model.Description); + Assert.Equal(expectedFileID, model.FileID); + Assert.Equal(expectedFilePath, model.FilePath); + Assert.Equal(expectedFileType, model.FileType); + Assert.Equal(expectedHasAlpha, model.HasAlpha); + Assert.Equal(expectedHeight, model.Height); + Assert.Equal(expectedIsPrivateFile, model.IsPrivateFile); + Assert.Equal(expectedIsPublished, model.IsPublished); + Assert.Equal(expectedMime, model.Mime); + Assert.Equal(expectedName, model.Name); + Assert.NotNull(model.SelectedFieldsSchema); + Assert.Equal(expectedSelectedFieldsSchema.Count, model.SelectedFieldsSchema.Count); + foreach (var item in expectedSelectedFieldsSchema) + { + Assert.True(model.SelectedFieldsSchema.TryGetValue(item.Key, out var value)); + + Assert.Equal(value, model.SelectedFieldsSchema[item.Key]); + } + Assert.Equal(expectedSize, model.Size); + Assert.NotNull(model.Tags); + Assert.Equal(expectedTags.Count, model.Tags.Count); + for (int i = 0; i < expectedTags.Count; i++) + { + Assert.Equal(expectedTags[i], model.Tags[i]); + } + Assert.Equal(expectedThumbnail, model.Thumbnail); + Assert.Equal(expectedType, model.Type); + Assert.Equal(expectedUpdatedAt, model.UpdatedAt); + Assert.Equal(expectedUrl, model.Url); + Assert.Equal(expectedVersionInfo, model.VersionInfo); + Assert.Equal(expectedWidth, model.Width); + Assert.Equal(expectedExtensionStatus, model.ExtensionStatus); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Files::FileUpdateResponse + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + Width = 0, + ExtensionStatus = new() + { + AIAutoDescription = Files::AIAutoDescription.Success, + AITasks = Files::AITasks.Success, + AwsAutoTagging = Files::AwsAutoTagging.Success, + GoogleAutoTagging = Files::GoogleAutoTagging.Success, + RemoveBg = Files::RemoveBg.Success, + }, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Files::FileUpdateResponse + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + Width = 0, + ExtensionStatus = new() + { + AIAutoDescription = Files::AIAutoDescription.Success, + AITasks = Files::AITasks.Success, + AwsAutoTagging = Files::AwsAutoTagging.Success, + GoogleAutoTagging = Files::GoogleAutoTagging.Success, + RemoveBg = Files::RemoveBg.Success, + }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedAITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ]; + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + string expectedCustomCoordinates = "customCoordinates"; + Dictionary expectedCustomMetadata = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; + string expectedDescription = "description"; + string expectedFileID = "fileId"; + string expectedFilePath = "filePath"; + string expectedFileType = "fileType"; + bool expectedHasAlpha = true; + double expectedHeight = 0; + bool expectedIsPrivateFile = true; + bool expectedIsPublished = true; + string expectedMime = "mime"; + string expectedName = "name"; + Dictionary expectedSelectedFieldsSchema = new() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }; + double expectedSize = 0; + List expectedTags = ["string"]; + string expectedThumbnail = "https://example.com"; + ApiEnum expectedType = Files::FileType.File; + DateTimeOffset expectedUpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + string expectedUrl = "https://example.com"; + Files::VersionInfo expectedVersionInfo = new() { ID = "id", Name = "name" }; + double expectedWidth = 0; + Files::ExtensionStatus expectedExtensionStatus = new() + { + AIAutoDescription = Files::AIAutoDescription.Success, + AITasks = Files::AITasks.Success, + AwsAutoTagging = Files::AwsAutoTagging.Success, + GoogleAutoTagging = Files::GoogleAutoTagging.Success, + RemoveBg = Files::RemoveBg.Success, + }; + + Assert.NotNull(deserialized.AITags); + Assert.Equal(expectedAITags.Count, deserialized.AITags.Count); + for (int i = 0; i < expectedAITags.Count; i++) + { + Assert.Equal(expectedAITags[i], deserialized.AITags[i]); + } + Assert.Equal(expectedCreatedAt, deserialized.CreatedAt); + Assert.Equal(expectedCustomCoordinates, deserialized.CustomCoordinates); + Assert.NotNull(deserialized.CustomMetadata); + Assert.Equal(expectedCustomMetadata.Count, deserialized.CustomMetadata.Count); + foreach (var item in expectedCustomMetadata) + { + Assert.True(deserialized.CustomMetadata.TryGetValue(item.Key, out var value)); + + Assert.True(JsonElement.DeepEquals(value, deserialized.CustomMetadata[item.Key])); + } + Assert.Equal(expectedDescription, deserialized.Description); + Assert.Equal(expectedFileID, deserialized.FileID); + Assert.Equal(expectedFilePath, deserialized.FilePath); + Assert.Equal(expectedFileType, deserialized.FileType); + Assert.Equal(expectedHasAlpha, deserialized.HasAlpha); + Assert.Equal(expectedHeight, deserialized.Height); + Assert.Equal(expectedIsPrivateFile, deserialized.IsPrivateFile); + Assert.Equal(expectedIsPublished, deserialized.IsPublished); + Assert.Equal(expectedMime, deserialized.Mime); + Assert.Equal(expectedName, deserialized.Name); + Assert.NotNull(deserialized.SelectedFieldsSchema); + Assert.Equal(expectedSelectedFieldsSchema.Count, deserialized.SelectedFieldsSchema.Count); + foreach (var item in expectedSelectedFieldsSchema) + { + Assert.True(deserialized.SelectedFieldsSchema.TryGetValue(item.Key, out var value)); + + Assert.Equal(value, deserialized.SelectedFieldsSchema[item.Key]); + } + Assert.Equal(expectedSize, deserialized.Size); + Assert.NotNull(deserialized.Tags); + Assert.Equal(expectedTags.Count, deserialized.Tags.Count); + for (int i = 0; i < expectedTags.Count; i++) + { + Assert.Equal(expectedTags[i], deserialized.Tags[i]); + } + Assert.Equal(expectedThumbnail, deserialized.Thumbnail); + Assert.Equal(expectedType, deserialized.Type); + Assert.Equal(expectedUpdatedAt, deserialized.UpdatedAt); + Assert.Equal(expectedUrl, deserialized.Url); + Assert.Equal(expectedVersionInfo, deserialized.VersionInfo); + Assert.Equal(expectedWidth, deserialized.Width); + Assert.Equal(expectedExtensionStatus, deserialized.ExtensionStatus); + } + + [Fact] + public void Validation_Works() + { + var model = new Files::FileUpdateResponse + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + Width = 0, + ExtensionStatus = new() + { + AIAutoDescription = Files::AIAutoDescription.Success, + AITasks = Files::AITasks.Success, + AwsAutoTagging = Files::AwsAutoTagging.Success, + GoogleAutoTagging = Files::GoogleAutoTagging.Success, + RemoveBg = Files::RemoveBg.Success, + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Files::FileUpdateResponse + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + CustomCoordinates = "customCoordinates", + Tags = ["string"], + }; + + Assert.Null(model.CreatedAt); + Assert.False(model.RawData.ContainsKey("createdAt")); + Assert.Null(model.CustomMetadata); + Assert.False(model.RawData.ContainsKey("customMetadata")); + Assert.Null(model.Description); + Assert.False(model.RawData.ContainsKey("description")); + Assert.Null(model.FileID); + Assert.False(model.RawData.ContainsKey("fileId")); + Assert.Null(model.FilePath); + Assert.False(model.RawData.ContainsKey("filePath")); + Assert.Null(model.FileType); + Assert.False(model.RawData.ContainsKey("fileType")); + Assert.Null(model.HasAlpha); + Assert.False(model.RawData.ContainsKey("hasAlpha")); + Assert.Null(model.Height); + Assert.False(model.RawData.ContainsKey("height")); + Assert.Null(model.IsPrivateFile); + Assert.False(model.RawData.ContainsKey("isPrivateFile")); + Assert.Null(model.IsPublished); + Assert.False(model.RawData.ContainsKey("isPublished")); + Assert.Null(model.Mime); + Assert.False(model.RawData.ContainsKey("mime")); + Assert.Null(model.Name); + Assert.False(model.RawData.ContainsKey("name")); + Assert.Null(model.SelectedFieldsSchema); + Assert.False(model.RawData.ContainsKey("selectedFieldsSchema")); + Assert.Null(model.Size); + Assert.False(model.RawData.ContainsKey("size")); + Assert.Null(model.Thumbnail); + Assert.False(model.RawData.ContainsKey("thumbnail")); + Assert.Null(model.Type); + Assert.False(model.RawData.ContainsKey("type")); + Assert.Null(model.UpdatedAt); + Assert.False(model.RawData.ContainsKey("updatedAt")); + Assert.Null(model.Url); + Assert.False(model.RawData.ContainsKey("url")); + Assert.Null(model.VersionInfo); + Assert.False(model.RawData.ContainsKey("versionInfo")); + Assert.Null(model.Width); + Assert.False(model.RawData.ContainsKey("width")); + Assert.Null(model.ExtensionStatus); + Assert.False(model.RawData.ContainsKey("extensionStatus")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new Files::FileUpdateResponse + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + CustomCoordinates = "customCoordinates", + Tags = ["string"], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new Files::FileUpdateResponse + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + CustomCoordinates = "customCoordinates", + Tags = ["string"], + + // Null should be interpreted as omitted for these properties + CreatedAt = null, + CustomMetadata = null, + Description = null, + FileID = null, + FilePath = null, + FileType = null, + HasAlpha = null, + Height = null, + IsPrivateFile = null, + IsPublished = null, + Mime = null, + Name = null, + SelectedFieldsSchema = null, + Size = null, + Thumbnail = null, + Type = null, + UpdatedAt = null, + Url = null, + VersionInfo = null, + Width = null, + ExtensionStatus = null, + }; + + Assert.Null(model.CreatedAt); + Assert.False(model.RawData.ContainsKey("createdAt")); + Assert.Null(model.CustomMetadata); + Assert.False(model.RawData.ContainsKey("customMetadata")); + Assert.Null(model.Description); + Assert.False(model.RawData.ContainsKey("description")); + Assert.Null(model.FileID); + Assert.False(model.RawData.ContainsKey("fileId")); + Assert.Null(model.FilePath); + Assert.False(model.RawData.ContainsKey("filePath")); + Assert.Null(model.FileType); + Assert.False(model.RawData.ContainsKey("fileType")); + Assert.Null(model.HasAlpha); + Assert.False(model.RawData.ContainsKey("hasAlpha")); + Assert.Null(model.Height); + Assert.False(model.RawData.ContainsKey("height")); + Assert.Null(model.IsPrivateFile); + Assert.False(model.RawData.ContainsKey("isPrivateFile")); + Assert.Null(model.IsPublished); + Assert.False(model.RawData.ContainsKey("isPublished")); + Assert.Null(model.Mime); + Assert.False(model.RawData.ContainsKey("mime")); + Assert.Null(model.Name); + Assert.False(model.RawData.ContainsKey("name")); + Assert.Null(model.SelectedFieldsSchema); + Assert.False(model.RawData.ContainsKey("selectedFieldsSchema")); + Assert.Null(model.Size); + Assert.False(model.RawData.ContainsKey("size")); + Assert.Null(model.Thumbnail); + Assert.False(model.RawData.ContainsKey("thumbnail")); + Assert.Null(model.Type); + Assert.False(model.RawData.ContainsKey("type")); + Assert.Null(model.UpdatedAt); + Assert.False(model.RawData.ContainsKey("updatedAt")); + Assert.Null(model.Url); + Assert.False(model.RawData.ContainsKey("url")); + Assert.Null(model.VersionInfo); + Assert.False(model.RawData.ContainsKey("versionInfo")); + Assert.Null(model.Width); + Assert.False(model.RawData.ContainsKey("width")); + Assert.Null(model.ExtensionStatus); + Assert.False(model.RawData.ContainsKey("extensionStatus")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new Files::FileUpdateResponse + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + CustomCoordinates = "customCoordinates", + Tags = ["string"], + + // Null should be interpreted as omitted for these properties + CreatedAt = null, + CustomMetadata = null, + Description = null, + FileID = null, + FilePath = null, + FileType = null, + HasAlpha = null, + Height = null, + IsPrivateFile = null, + IsPublished = null, + Mime = null, + Name = null, + SelectedFieldsSchema = null, + Size = null, + Thumbnail = null, + Type = null, + UpdatedAt = null, + Url = null, + VersionInfo = null, + Width = null, + ExtensionStatus = null, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Files::FileUpdateResponse + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + Width = 0, + ExtensionStatus = new() + { + AIAutoDescription = Files::AIAutoDescription.Success, + AITasks = Files::AITasks.Success, + AwsAutoTagging = Files::AwsAutoTagging.Success, + GoogleAutoTagging = Files::GoogleAutoTagging.Success, + RemoveBg = Files::RemoveBg.Success, + }, + }; + + Assert.Null(model.AITags); + Assert.False(model.RawData.ContainsKey("AITags")); + Assert.Null(model.CustomCoordinates); + Assert.False(model.RawData.ContainsKey("customCoordinates")); + Assert.Null(model.Tags); + Assert.False(model.RawData.ContainsKey("tags")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new Files::FileUpdateResponse + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + Width = 0, + ExtensionStatus = new() + { + AIAutoDescription = Files::AIAutoDescription.Success, + AITasks = Files::AITasks.Success, + AwsAutoTagging = Files::AwsAutoTagging.Success, + GoogleAutoTagging = Files::GoogleAutoTagging.Success, + RemoveBg = Files::RemoveBg.Success, + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new Files::FileUpdateResponse + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + Width = 0, + ExtensionStatus = new() + { + AIAutoDescription = Files::AIAutoDescription.Success, + AITasks = Files::AITasks.Success, + AwsAutoTagging = Files::AwsAutoTagging.Success, + GoogleAutoTagging = Files::GoogleAutoTagging.Success, + RemoveBg = Files::RemoveBg.Success, + }, + + AITags = null, + CustomCoordinates = null, + Tags = null, + }; + + Assert.Null(model.AITags); + Assert.True(model.RawData.ContainsKey("AITags")); + Assert.Null(model.CustomCoordinates); + Assert.True(model.RawData.ContainsKey("customCoordinates")); + Assert.Null(model.Tags); + Assert.True(model.RawData.ContainsKey("tags")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new Files::FileUpdateResponse + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + Width = 0, + ExtensionStatus = new() + { + AIAutoDescription = Files::AIAutoDescription.Success, + AITasks = Files::AITasks.Success, + AwsAutoTagging = Files::AwsAutoTagging.Success, + GoogleAutoTagging = Files::GoogleAutoTagging.Success, + RemoveBg = Files::RemoveBg.Success, + }, + + AITags = null, + CustomCoordinates = null, + Tags = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Files::FileUpdateResponse + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + Width = 0, + ExtensionStatus = new() + { + AIAutoDescription = Files::AIAutoDescription.Success, + AITasks = Files::AITasks.Success, + AwsAutoTagging = Files::AwsAutoTagging.Success, + GoogleAutoTagging = Files::GoogleAutoTagging.Success, + RemoveBg = Files::RemoveBg.Success, + }, + }; + + Files::FileUpdateResponse copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class IntersectionMember1Test : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Files::IntersectionMember1 + { + ExtensionStatus = new() + { + AIAutoDescription = Files::AIAutoDescription.Success, + AITasks = Files::AITasks.Success, + AwsAutoTagging = Files::AwsAutoTagging.Success, + GoogleAutoTagging = Files::GoogleAutoTagging.Success, + RemoveBg = Files::RemoveBg.Success, + }, + }; + + Files::ExtensionStatus expectedExtensionStatus = new() + { + AIAutoDescription = Files::AIAutoDescription.Success, + AITasks = Files::AITasks.Success, + AwsAutoTagging = Files::AwsAutoTagging.Success, + GoogleAutoTagging = Files::GoogleAutoTagging.Success, + RemoveBg = Files::RemoveBg.Success, + }; + + Assert.Equal(expectedExtensionStatus, model.ExtensionStatus); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Files::IntersectionMember1 + { + ExtensionStatus = new() + { + AIAutoDescription = Files::AIAutoDescription.Success, + AITasks = Files::AITasks.Success, + AwsAutoTagging = Files::AwsAutoTagging.Success, + GoogleAutoTagging = Files::GoogleAutoTagging.Success, + RemoveBg = Files::RemoveBg.Success, + }, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Files::IntersectionMember1 + { + ExtensionStatus = new() + { + AIAutoDescription = Files::AIAutoDescription.Success, + AITasks = Files::AITasks.Success, + AwsAutoTagging = Files::AwsAutoTagging.Success, + GoogleAutoTagging = Files::GoogleAutoTagging.Success, + RemoveBg = Files::RemoveBg.Success, + }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + Files::ExtensionStatus expectedExtensionStatus = new() + { + AIAutoDescription = Files::AIAutoDescription.Success, + AITasks = Files::AITasks.Success, + AwsAutoTagging = Files::AwsAutoTagging.Success, + GoogleAutoTagging = Files::GoogleAutoTagging.Success, + RemoveBg = Files::RemoveBg.Success, + }; + + Assert.Equal(expectedExtensionStatus, deserialized.ExtensionStatus); + } + + [Fact] + public void Validation_Works() + { + var model = new Files::IntersectionMember1 + { + ExtensionStatus = new() + { + AIAutoDescription = Files::AIAutoDescription.Success, + AITasks = Files::AITasks.Success, + AwsAutoTagging = Files::AwsAutoTagging.Success, + GoogleAutoTagging = Files::GoogleAutoTagging.Success, + RemoveBg = Files::RemoveBg.Success, + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Files::IntersectionMember1 { }; + + Assert.Null(model.ExtensionStatus); + Assert.False(model.RawData.ContainsKey("extensionStatus")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new Files::IntersectionMember1 { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new Files::IntersectionMember1 + { + // Null should be interpreted as omitted for these properties + ExtensionStatus = null, + }; + + Assert.Null(model.ExtensionStatus); + Assert.False(model.RawData.ContainsKey("extensionStatus")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new Files::IntersectionMember1 + { + // Null should be interpreted as omitted for these properties + ExtensionStatus = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Files::IntersectionMember1 + { + ExtensionStatus = new() + { + AIAutoDescription = Files::AIAutoDescription.Success, + AITasks = Files::AITasks.Success, + AwsAutoTagging = Files::AwsAutoTagging.Success, + GoogleAutoTagging = Files::GoogleAutoTagging.Success, + RemoveBg = Files::RemoveBg.Success, + }, + }; + + Files::IntersectionMember1 copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ExtensionStatusTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Files::ExtensionStatus + { + AIAutoDescription = Files::AIAutoDescription.Success, + AITasks = Files::AITasks.Success, + AwsAutoTagging = Files::AwsAutoTagging.Success, + GoogleAutoTagging = Files::GoogleAutoTagging.Success, + RemoveBg = Files::RemoveBg.Success, + }; + + ApiEnum expectedAIAutoDescription = + Files::AIAutoDescription.Success; + ApiEnum expectedAITasks = Files::AITasks.Success; + ApiEnum expectedAwsAutoTagging = + Files::AwsAutoTagging.Success; + ApiEnum expectedGoogleAutoTagging = + Files::GoogleAutoTagging.Success; + ApiEnum expectedRemoveBg = Files::RemoveBg.Success; + + Assert.Equal(expectedAIAutoDescription, model.AIAutoDescription); + Assert.Equal(expectedAITasks, model.AITasks); + Assert.Equal(expectedAwsAutoTagging, model.AwsAutoTagging); + Assert.Equal(expectedGoogleAutoTagging, model.GoogleAutoTagging); + Assert.Equal(expectedRemoveBg, model.RemoveBg); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Files::ExtensionStatus + { + AIAutoDescription = Files::AIAutoDescription.Success, + AITasks = Files::AITasks.Success, + AwsAutoTagging = Files::AwsAutoTagging.Success, + GoogleAutoTagging = Files::GoogleAutoTagging.Success, + RemoveBg = Files::RemoveBg.Success, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Files::ExtensionStatus + { + AIAutoDescription = Files::AIAutoDescription.Success, + AITasks = Files::AITasks.Success, + AwsAutoTagging = Files::AwsAutoTagging.Success, + GoogleAutoTagging = Files::GoogleAutoTagging.Success, + RemoveBg = Files::RemoveBg.Success, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum expectedAIAutoDescription = + Files::AIAutoDescription.Success; + ApiEnum expectedAITasks = Files::AITasks.Success; + ApiEnum expectedAwsAutoTagging = + Files::AwsAutoTagging.Success; + ApiEnum expectedGoogleAutoTagging = + Files::GoogleAutoTagging.Success; + ApiEnum expectedRemoveBg = Files::RemoveBg.Success; + + Assert.Equal(expectedAIAutoDescription, deserialized.AIAutoDescription); + Assert.Equal(expectedAITasks, deserialized.AITasks); + Assert.Equal(expectedAwsAutoTagging, deserialized.AwsAutoTagging); + Assert.Equal(expectedGoogleAutoTagging, deserialized.GoogleAutoTagging); + Assert.Equal(expectedRemoveBg, deserialized.RemoveBg); + } + + [Fact] + public void Validation_Works() + { + var model = new Files::ExtensionStatus + { + AIAutoDescription = Files::AIAutoDescription.Success, + AITasks = Files::AITasks.Success, + AwsAutoTagging = Files::AwsAutoTagging.Success, + GoogleAutoTagging = Files::GoogleAutoTagging.Success, + RemoveBg = Files::RemoveBg.Success, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Files::ExtensionStatus { }; + + Assert.Null(model.AIAutoDescription); + Assert.False(model.RawData.ContainsKey("ai-auto-description")); + Assert.Null(model.AITasks); + Assert.False(model.RawData.ContainsKey("ai-tasks")); + Assert.Null(model.AwsAutoTagging); + Assert.False(model.RawData.ContainsKey("aws-auto-tagging")); + Assert.Null(model.GoogleAutoTagging); + Assert.False(model.RawData.ContainsKey("google-auto-tagging")); + Assert.Null(model.RemoveBg); + Assert.False(model.RawData.ContainsKey("remove-bg")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new Files::ExtensionStatus { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new Files::ExtensionStatus + { + // Null should be interpreted as omitted for these properties + AIAutoDescription = null, + AITasks = null, + AwsAutoTagging = null, + GoogleAutoTagging = null, + RemoveBg = null, + }; + + Assert.Null(model.AIAutoDescription); + Assert.False(model.RawData.ContainsKey("ai-auto-description")); + Assert.Null(model.AITasks); + Assert.False(model.RawData.ContainsKey("ai-tasks")); + Assert.Null(model.AwsAutoTagging); + Assert.False(model.RawData.ContainsKey("aws-auto-tagging")); + Assert.Null(model.GoogleAutoTagging); + Assert.False(model.RawData.ContainsKey("google-auto-tagging")); + Assert.Null(model.RemoveBg); + Assert.False(model.RawData.ContainsKey("remove-bg")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new Files::ExtensionStatus + { + // Null should be interpreted as omitted for these properties + AIAutoDescription = null, + AITasks = null, + AwsAutoTagging = null, + GoogleAutoTagging = null, + RemoveBg = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Files::ExtensionStatus + { + AIAutoDescription = Files::AIAutoDescription.Success, + AITasks = Files::AITasks.Success, + AwsAutoTagging = Files::AwsAutoTagging.Success, + GoogleAutoTagging = Files::GoogleAutoTagging.Success, + RemoveBg = Files::RemoveBg.Success, + }; + + Files::ExtensionStatus copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class AIAutoDescriptionTest : TestBase +{ + [Theory] + [InlineData(Files::AIAutoDescription.Success)] + [InlineData(Files::AIAutoDescription.Pending)] + [InlineData(Files::AIAutoDescription.Failed)] + public void Validation_Works(Files::AIAutoDescription rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(Files::AIAutoDescription.Success)] + [InlineData(Files::AIAutoDescription.Pending)] + [InlineData(Files::AIAutoDescription.Failed)] + public void SerializationRoundtrip_Works(Files::AIAutoDescription rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class AITasksTest : TestBase +{ + [Theory] + [InlineData(Files::AITasks.Success)] + [InlineData(Files::AITasks.Pending)] + [InlineData(Files::AITasks.Failed)] + public void Validation_Works(Files::AITasks rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(Files::AITasks.Success)] + [InlineData(Files::AITasks.Pending)] + [InlineData(Files::AITasks.Failed)] + public void SerializationRoundtrip_Works(Files::AITasks rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class AwsAutoTaggingTest : TestBase +{ + [Theory] + [InlineData(Files::AwsAutoTagging.Success)] + [InlineData(Files::AwsAutoTagging.Pending)] + [InlineData(Files::AwsAutoTagging.Failed)] + public void Validation_Works(Files::AwsAutoTagging rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(Files::AwsAutoTagging.Success)] + [InlineData(Files::AwsAutoTagging.Pending)] + [InlineData(Files::AwsAutoTagging.Failed)] + public void SerializationRoundtrip_Works(Files::AwsAutoTagging rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class GoogleAutoTaggingTest : TestBase +{ + [Theory] + [InlineData(Files::GoogleAutoTagging.Success)] + [InlineData(Files::GoogleAutoTagging.Pending)] + [InlineData(Files::GoogleAutoTagging.Failed)] + public void Validation_Works(Files::GoogleAutoTagging rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(Files::GoogleAutoTagging.Success)] + [InlineData(Files::GoogleAutoTagging.Pending)] + [InlineData(Files::GoogleAutoTagging.Failed)] + public void SerializationRoundtrip_Works(Files::GoogleAutoTagging rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class RemoveBgTest : TestBase +{ + [Theory] + [InlineData(Files::RemoveBg.Success)] + [InlineData(Files::RemoveBg.Pending)] + [InlineData(Files::RemoveBg.Failed)] + public void Validation_Works(Files::RemoveBg rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(Files::RemoveBg.Success)] + [InlineData(Files::RemoveBg.Pending)] + [InlineData(Files::RemoveBg.Failed)] + public void SerializationRoundtrip_Works(Files::RemoveBg rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} diff --git a/src/ImageKit.Tests/Models/Files/FileUploadParamsTest.cs b/src/ImageKit.Tests/Models/Files/FileUploadParamsTest.cs new file mode 100644 index 00000000..cecbe038 --- /dev/null +++ b/src/ImageKit.Tests/Models/Files/FileUploadParamsTest.cs @@ -0,0 +1,869 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Exceptions; +using ImageKit.Models.Files; + +namespace ImageKit.Tests.Models.Files; + +public class FileUploadParamsTest : TestBase +{ + [Fact] + public void OptionalNonNullableParamsUnsetAreNotSet_Works() + { + var parameters = new FileUploadParams + { + File = Encoding.UTF8.GetBytes("text"), + FileName = "fileName", + }; + + Assert.Null(parameters.Token); + Assert.False(parameters.RawBodyData.ContainsKey("token")); + Assert.Null(parameters.Checks); + Assert.False(parameters.RawBodyData.ContainsKey("checks")); + Assert.Null(parameters.CustomCoordinates); + Assert.False(parameters.RawBodyData.ContainsKey("customCoordinates")); + Assert.Null(parameters.CustomMetadata); + Assert.False(parameters.RawBodyData.ContainsKey("customMetadata")); + Assert.Null(parameters.Description); + Assert.False(parameters.RawBodyData.ContainsKey("description")); + Assert.Null(parameters.Expire); + Assert.False(parameters.RawBodyData.ContainsKey("expire")); + Assert.Null(parameters.Extensions); + Assert.False(parameters.RawBodyData.ContainsKey("extensions")); + Assert.Null(parameters.Folder); + Assert.False(parameters.RawBodyData.ContainsKey("folder")); + Assert.Null(parameters.IsPrivateFile); + Assert.False(parameters.RawBodyData.ContainsKey("isPrivateFile")); + Assert.Null(parameters.IsPublished); + Assert.False(parameters.RawBodyData.ContainsKey("isPublished")); + Assert.Null(parameters.OverwriteAITags); + Assert.False(parameters.RawBodyData.ContainsKey("overwriteAITags")); + Assert.Null(parameters.OverwriteCustomMetadata); + Assert.False(parameters.RawBodyData.ContainsKey("overwriteCustomMetadata")); + Assert.Null(parameters.OverwriteFile); + Assert.False(parameters.RawBodyData.ContainsKey("overwriteFile")); + Assert.Null(parameters.OverwriteTags); + Assert.False(parameters.RawBodyData.ContainsKey("overwriteTags")); + Assert.Null(parameters.PublicKey); + Assert.False(parameters.RawBodyData.ContainsKey("publicKey")); + Assert.Null(parameters.ResponseFields); + Assert.False(parameters.RawBodyData.ContainsKey("responseFields")); + Assert.Null(parameters.Signature); + Assert.False(parameters.RawBodyData.ContainsKey("signature")); + Assert.Null(parameters.Tags); + Assert.False(parameters.RawBodyData.ContainsKey("tags")); + Assert.Null(parameters.Transformation); + Assert.False(parameters.RawBodyData.ContainsKey("transformation")); + Assert.Null(parameters.UseUniqueFileName); + Assert.False(parameters.RawBodyData.ContainsKey("useUniqueFileName")); + Assert.Null(parameters.WebhookUrl); + Assert.False(parameters.RawBodyData.ContainsKey("webhookUrl")); + } + + [Fact] + public void OptionalNonNullableParamsSetToNullAreNotSet_Works() + { + var parameters = new FileUploadParams + { + File = Encoding.UTF8.GetBytes("text"), + FileName = "fileName", + + // Null should be interpreted as omitted for these properties + Token = null, + Checks = null, + CustomCoordinates = null, + CustomMetadata = null, + Description = null, + Expire = null, + Extensions = null, + Folder = null, + IsPrivateFile = null, + IsPublished = null, + OverwriteAITags = null, + OverwriteCustomMetadata = null, + OverwriteFile = null, + OverwriteTags = null, + PublicKey = null, + ResponseFields = null, + Signature = null, + Tags = null, + Transformation = null, + UseUniqueFileName = null, + WebhookUrl = null, + }; + + Assert.Null(parameters.Token); + Assert.False(parameters.RawBodyData.ContainsKey("token")); + Assert.Null(parameters.Checks); + Assert.False(parameters.RawBodyData.ContainsKey("checks")); + Assert.Null(parameters.CustomCoordinates); + Assert.False(parameters.RawBodyData.ContainsKey("customCoordinates")); + Assert.Null(parameters.CustomMetadata); + Assert.False(parameters.RawBodyData.ContainsKey("customMetadata")); + Assert.Null(parameters.Description); + Assert.False(parameters.RawBodyData.ContainsKey("description")); + Assert.Null(parameters.Expire); + Assert.False(parameters.RawBodyData.ContainsKey("expire")); + Assert.Null(parameters.Extensions); + Assert.False(parameters.RawBodyData.ContainsKey("extensions")); + Assert.Null(parameters.Folder); + Assert.False(parameters.RawBodyData.ContainsKey("folder")); + Assert.Null(parameters.IsPrivateFile); + Assert.False(parameters.RawBodyData.ContainsKey("isPrivateFile")); + Assert.Null(parameters.IsPublished); + Assert.False(parameters.RawBodyData.ContainsKey("isPublished")); + Assert.Null(parameters.OverwriteAITags); + Assert.False(parameters.RawBodyData.ContainsKey("overwriteAITags")); + Assert.Null(parameters.OverwriteCustomMetadata); + Assert.False(parameters.RawBodyData.ContainsKey("overwriteCustomMetadata")); + Assert.Null(parameters.OverwriteFile); + Assert.False(parameters.RawBodyData.ContainsKey("overwriteFile")); + Assert.Null(parameters.OverwriteTags); + Assert.False(parameters.RawBodyData.ContainsKey("overwriteTags")); + Assert.Null(parameters.PublicKey); + Assert.False(parameters.RawBodyData.ContainsKey("publicKey")); + Assert.Null(parameters.ResponseFields); + Assert.False(parameters.RawBodyData.ContainsKey("responseFields")); + Assert.Null(parameters.Signature); + Assert.False(parameters.RawBodyData.ContainsKey("signature")); + Assert.Null(parameters.Tags); + Assert.False(parameters.RawBodyData.ContainsKey("tags")); + Assert.Null(parameters.Transformation); + Assert.False(parameters.RawBodyData.ContainsKey("transformation")); + Assert.Null(parameters.UseUniqueFileName); + Assert.False(parameters.RawBodyData.ContainsKey("useUniqueFileName")); + Assert.Null(parameters.WebhookUrl); + Assert.False(parameters.RawBodyData.ContainsKey("webhookUrl")); + } + + [Fact] + public void Url_Works() + { + FileUploadParams parameters = new() + { + File = Encoding.UTF8.GetBytes("text"), + FileName = "fileName", + }; + + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + + Assert.Equal(new Uri("https://api.imagekit.io/api/v1/files/upload"), url); + } +} + +public class ResponseFieldTest : TestBase +{ + [Theory] + [InlineData(ResponseField.Tags)] + [InlineData(ResponseField.CustomCoordinates)] + [InlineData(ResponseField.IsPrivateFile)] + [InlineData(ResponseField.EmbeddedMetadata)] + [InlineData(ResponseField.IsPublished)] + [InlineData(ResponseField.CustomMetadata)] + [InlineData(ResponseField.Metadata)] + [InlineData(ResponseField.SelectedFieldsSchema)] + public void Validation_Works(ResponseField rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(ResponseField.Tags)] + [InlineData(ResponseField.CustomCoordinates)] + [InlineData(ResponseField.IsPrivateFile)] + [InlineData(ResponseField.EmbeddedMetadata)] + [InlineData(ResponseField.IsPublished)] + [InlineData(ResponseField.CustomMetadata)] + [InlineData(ResponseField.Metadata)] + [InlineData(ResponseField.SelectedFieldsSchema)] + public void SerializationRoundtrip_Works(ResponseField rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class TransformationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Transformation + { + Post = + [ + new Thumbnail() { Value = "w-150,h-150" }, + new Abs() { Protocol = Protocol.Dash, Value = "sr-240_360_480_720_1080" }, + ], + Pre = "w-300,h-300,q-80", + }; + + List expectedPost = + [ + new Thumbnail() { Value = "w-150,h-150" }, + new Abs() { Protocol = Protocol.Dash, Value = "sr-240_360_480_720_1080" }, + ]; + string expectedPre = "w-300,h-300,q-80"; + + Assert.NotNull(model.Post); + Assert.Equal(expectedPost.Count, model.Post.Count); + for (int i = 0; i < expectedPost.Count; i++) + { + Assert.Equal(expectedPost[i], model.Post[i]); + } + Assert.Equal(expectedPre, model.Pre); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Transformation + { + Post = + [ + new Thumbnail() { Value = "w-150,h-150" }, + new Abs() { Protocol = Protocol.Dash, Value = "sr-240_360_480_720_1080" }, + ], + Pre = "w-300,h-300,q-80", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Transformation + { + Post = + [ + new Thumbnail() { Value = "w-150,h-150" }, + new Abs() { Protocol = Protocol.Dash, Value = "sr-240_360_480_720_1080" }, + ], + Pre = "w-300,h-300,q-80", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedPost = + [ + new Thumbnail() { Value = "w-150,h-150" }, + new Abs() { Protocol = Protocol.Dash, Value = "sr-240_360_480_720_1080" }, + ]; + string expectedPre = "w-300,h-300,q-80"; + + Assert.NotNull(deserialized.Post); + Assert.Equal(expectedPost.Count, deserialized.Post.Count); + for (int i = 0; i < expectedPost.Count; i++) + { + Assert.Equal(expectedPost[i], deserialized.Post[i]); + } + Assert.Equal(expectedPre, deserialized.Pre); + } + + [Fact] + public void Validation_Works() + { + var model = new Transformation + { + Post = + [ + new Thumbnail() { Value = "w-150,h-150" }, + new Abs() { Protocol = Protocol.Dash, Value = "sr-240_360_480_720_1080" }, + ], + Pre = "w-300,h-300,q-80", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Transformation { }; + + Assert.Null(model.Post); + Assert.False(model.RawData.ContainsKey("post")); + Assert.Null(model.Pre); + Assert.False(model.RawData.ContainsKey("pre")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new Transformation { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new Transformation + { + // Null should be interpreted as omitted for these properties + Post = null, + Pre = null, + }; + + Assert.Null(model.Post); + Assert.False(model.RawData.ContainsKey("post")); + Assert.Null(model.Pre); + Assert.False(model.RawData.ContainsKey("pre")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new Transformation + { + // Null should be interpreted as omitted for these properties + Post = null, + Pre = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Transformation + { + Post = + [ + new Thumbnail() { Value = "w-150,h-150" }, + new Abs() { Protocol = Protocol.Dash, Value = "sr-240_360_480_720_1080" }, + ], + Pre = "w-300,h-300,q-80", + }; + + Transformation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PostTest : TestBase +{ + [Fact] + public void TransformationValidationWorks() + { + Post value = new PostTransformation("w-400,h-400,q-70"); + value.Validate(); + } + + [Fact] + public void GifToVideoValidationWorks() + { + Post value = new GifToVideo() { Value = "q-90" }; + value.Validate(); + } + + [Fact] + public void ThumbnailValidationWorks() + { + Post value = new Thumbnail() { Value = "w-150,h-150" }; + value.Validate(); + } + + [Fact] + public void AbsValidationWorks() + { + Post value = new Abs() { Protocol = Protocol.Hls, Value = "sr-240_360_480_720_1080" }; + value.Validate(); + } + + [Fact] + public void TransformationSerializationRoundtripWorks() + { + Post value = new PostTransformation("w-400,h-400,q-70"); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void GifToVideoSerializationRoundtripWorks() + { + Post value = new GifToVideo() { Value = "q-90" }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void ThumbnailSerializationRoundtripWorks() + { + Post value = new Thumbnail() { Value = "w-150,h-150" }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void AbsSerializationRoundtripWorks() + { + Post value = new Abs() { Protocol = Protocol.Hls, Value = "sr-240_360_480_720_1080" }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class PostTransformationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PostTransformation { Value = "w-400,h-400,q-70" }; + + JsonElement expectedType = JsonSerializer.SerializeToElement("transformation"); + string expectedValue = "w-400,h-400,q-70"; + + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + Assert.Equal(expectedValue, model.Value); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new PostTransformation { Value = "w-400,h-400,q-70" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new PostTransformation { Value = "w-400,h-400,q-70" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + JsonElement expectedType = JsonSerializer.SerializeToElement("transformation"); + string expectedValue = "w-400,h-400,q-70"; + + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + Assert.Equal(expectedValue, deserialized.Value); + } + + [Fact] + public void Validation_Works() + { + var model = new PostTransformation { Value = "w-400,h-400,q-70" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PostTransformation { Value = "w-400,h-400,q-70" }; + + PostTransformation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GifToVideoTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GifToVideo { Value = "q-90" }; + + JsonElement expectedType = JsonSerializer.SerializeToElement("gif-to-video"); + string expectedValue = "q-90"; + + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + Assert.Equal(expectedValue, model.Value); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new GifToVideo { Value = "q-90" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new GifToVideo { Value = "q-90" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + JsonElement expectedType = JsonSerializer.SerializeToElement("gif-to-video"); + string expectedValue = "q-90"; + + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + Assert.Equal(expectedValue, deserialized.Value); + } + + [Fact] + public void Validation_Works() + { + var model = new GifToVideo { Value = "q-90" }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new GifToVideo { }; + + Assert.Null(model.Value); + Assert.False(model.RawData.ContainsKey("value")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new GifToVideo { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new GifToVideo + { + // Null should be interpreted as omitted for these properties + Value = null, + }; + + Assert.Null(model.Value); + Assert.False(model.RawData.ContainsKey("value")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new GifToVideo + { + // Null should be interpreted as omitted for these properties + Value = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GifToVideo { Value = "q-90" }; + + GifToVideo copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ThumbnailTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Thumbnail { Value = "w-150,h-150" }; + + JsonElement expectedType = JsonSerializer.SerializeToElement("thumbnail"); + string expectedValue = "w-150,h-150"; + + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + Assert.Equal(expectedValue, model.Value); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Thumbnail { Value = "w-150,h-150" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Thumbnail { Value = "w-150,h-150" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + JsonElement expectedType = JsonSerializer.SerializeToElement("thumbnail"); + string expectedValue = "w-150,h-150"; + + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + Assert.Equal(expectedValue, deserialized.Value); + } + + [Fact] + public void Validation_Works() + { + var model = new Thumbnail { Value = "w-150,h-150" }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Thumbnail { }; + + Assert.Null(model.Value); + Assert.False(model.RawData.ContainsKey("value")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new Thumbnail { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new Thumbnail + { + // Null should be interpreted as omitted for these properties + Value = null, + }; + + Assert.Null(model.Value); + Assert.False(model.RawData.ContainsKey("value")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new Thumbnail + { + // Null should be interpreted as omitted for these properties + Value = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Thumbnail { Value = "w-150,h-150" }; + + Thumbnail copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class AbsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Abs { Protocol = Protocol.Hls, Value = "sr-240_360_480_720_1080" }; + + ApiEnum expectedProtocol = Protocol.Hls; + JsonElement expectedType = JsonSerializer.SerializeToElement("abs"); + string expectedValue = "sr-240_360_480_720_1080"; + + Assert.Equal(expectedProtocol, model.Protocol); + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + Assert.Equal(expectedValue, model.Value); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Abs { Protocol = Protocol.Hls, Value = "sr-240_360_480_720_1080" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Abs { Protocol = Protocol.Hls, Value = "sr-240_360_480_720_1080" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + Assert.NotNull(deserialized); + + ApiEnum expectedProtocol = Protocol.Hls; + JsonElement expectedType = JsonSerializer.SerializeToElement("abs"); + string expectedValue = "sr-240_360_480_720_1080"; + + Assert.Equal(expectedProtocol, deserialized.Protocol); + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + Assert.Equal(expectedValue, deserialized.Value); + } + + [Fact] + public void Validation_Works() + { + var model = new Abs { Protocol = Protocol.Hls, Value = "sr-240_360_480_720_1080" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Abs { Protocol = Protocol.Hls, Value = "sr-240_360_480_720_1080" }; + + Abs copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ProtocolTest : TestBase +{ + [Theory] + [InlineData(Protocol.Hls)] + [InlineData(Protocol.Dash)] + public void Validation_Works(Protocol rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(Protocol.Hls)] + [InlineData(Protocol.Dash)] + public void SerializationRoundtrip_Works(Protocol rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} diff --git a/src/ImageKit.Tests/Models/Files/FileUploadResponseTest.cs b/src/ImageKit.Tests/Models/Files/FileUploadResponseTest.cs new file mode 100644 index 00000000..a88a2210 --- /dev/null +++ b/src/ImageKit.Tests/Models/Files/FileUploadResponseTest.cs @@ -0,0 +1,3452 @@ +using System.Collections.Generic; +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Exceptions; +using ImageKit.Models.Files; + +namespace ImageKit.Tests.Models.Files; + +public class FileUploadResponseTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new FileUploadResponse + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ExtensionStatus = new() + { + AIAutoDescription = FileUploadResponseExtensionStatusAIAutoDescription.Success, + AITasks = FileUploadResponseExtensionStatusAITasks.Success, + AwsAutoTagging = FileUploadResponseExtensionStatusAwsAutoTagging.Success, + GoogleAutoTagging = FileUploadResponseExtensionStatusGoogleAutoTagging.Success, + RemoveBg = FileUploadResponseExtensionStatusRemoveBg.Success, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Metadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }, + Name = "name", + SelectedFieldsSchema = new Dictionary< + string, + FileUploadResponseSelectedFieldsSchemaItem + >() + { + { + "foo", + new() + { + Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + ThumbnailUrl = "thumbnailUrl", + Url = "url", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }; + + List expectedAITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ]; + string expectedAudioCodec = "audioCodec"; + long expectedBitRate = 0; + string expectedCustomCoordinates = "customCoordinates"; + Dictionary expectedCustomMetadata = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; + string expectedDescription = "description"; + long expectedDuration = 0; + Dictionary expectedEmbeddedMetadata = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; + FileUploadResponseExtensionStatus expectedExtensionStatus = new() + { + AIAutoDescription = FileUploadResponseExtensionStatusAIAutoDescription.Success, + AITasks = FileUploadResponseExtensionStatusAITasks.Success, + AwsAutoTagging = FileUploadResponseExtensionStatusAwsAutoTagging.Success, + GoogleAutoTagging = FileUploadResponseExtensionStatusGoogleAutoTagging.Success, + RemoveBg = FileUploadResponseExtensionStatusRemoveBg.Success, + }; + string expectedFileID = "fileId"; + string expectedFilePath = "filePath"; + string expectedFileType = "fileType"; + double expectedHeight = 0; + bool expectedIsPrivateFile = true; + bool expectedIsPublished = true; + FileMetadata expectedMetadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }; + string expectedName = "name"; + Dictionary< + string, + FileUploadResponseSelectedFieldsSchemaItem + > expectedSelectedFieldsSchema = new() + { + { + "foo", + new() + { + Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }; + double expectedSize = 0; + List expectedTags = ["string"]; + string expectedThumbnailUrl = "thumbnailUrl"; + string expectedUrl = "url"; + FileUploadResponseVersionInfo expectedVersionInfo = new() { ID = "id", Name = "name" }; + string expectedVideoCodec = "videoCodec"; + double expectedWidth = 0; + + Assert.NotNull(model.AITags); + Assert.Equal(expectedAITags.Count, model.AITags.Count); + for (int i = 0; i < expectedAITags.Count; i++) + { + Assert.Equal(expectedAITags[i], model.AITags[i]); + } + Assert.Equal(expectedAudioCodec, model.AudioCodec); + Assert.Equal(expectedBitRate, model.BitRate); + Assert.Equal(expectedCustomCoordinates, model.CustomCoordinates); + Assert.NotNull(model.CustomMetadata); + Assert.Equal(expectedCustomMetadata.Count, model.CustomMetadata.Count); + foreach (var item in expectedCustomMetadata) + { + Assert.True(model.CustomMetadata.TryGetValue(item.Key, out var value)); + + Assert.True(JsonElement.DeepEquals(value, model.CustomMetadata[item.Key])); + } + Assert.Equal(expectedDescription, model.Description); + Assert.Equal(expectedDuration, model.Duration); + Assert.NotNull(model.EmbeddedMetadata); + Assert.Equal(expectedEmbeddedMetadata.Count, model.EmbeddedMetadata.Count); + foreach (var item in expectedEmbeddedMetadata) + { + Assert.True(model.EmbeddedMetadata.TryGetValue(item.Key, out var value)); + + Assert.True(JsonElement.DeepEquals(value, model.EmbeddedMetadata[item.Key])); + } + Assert.Equal(expectedExtensionStatus, model.ExtensionStatus); + Assert.Equal(expectedFileID, model.FileID); + Assert.Equal(expectedFilePath, model.FilePath); + Assert.Equal(expectedFileType, model.FileType); + Assert.Equal(expectedHeight, model.Height); + Assert.Equal(expectedIsPrivateFile, model.IsPrivateFile); + Assert.Equal(expectedIsPublished, model.IsPublished); + Assert.Equal(expectedMetadata, model.Metadata); + Assert.Equal(expectedName, model.Name); + Assert.NotNull(model.SelectedFieldsSchema); + Assert.Equal(expectedSelectedFieldsSchema.Count, model.SelectedFieldsSchema.Count); + foreach (var item in expectedSelectedFieldsSchema) + { + Assert.True(model.SelectedFieldsSchema.TryGetValue(item.Key, out var value)); + + Assert.Equal(value, model.SelectedFieldsSchema[item.Key]); + } + Assert.Equal(expectedSize, model.Size); + Assert.NotNull(model.Tags); + Assert.Equal(expectedTags.Count, model.Tags.Count); + for (int i = 0; i < expectedTags.Count; i++) + { + Assert.Equal(expectedTags[i], model.Tags[i]); + } + Assert.Equal(expectedThumbnailUrl, model.ThumbnailUrl); + Assert.Equal(expectedUrl, model.Url); + Assert.Equal(expectedVersionInfo, model.VersionInfo); + Assert.Equal(expectedVideoCodec, model.VideoCodec); + Assert.Equal(expectedWidth, model.Width); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new FileUploadResponse + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ExtensionStatus = new() + { + AIAutoDescription = FileUploadResponseExtensionStatusAIAutoDescription.Success, + AITasks = FileUploadResponseExtensionStatusAITasks.Success, + AwsAutoTagging = FileUploadResponseExtensionStatusAwsAutoTagging.Success, + GoogleAutoTagging = FileUploadResponseExtensionStatusGoogleAutoTagging.Success, + RemoveBg = FileUploadResponseExtensionStatusRemoveBg.Success, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Metadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }, + Name = "name", + SelectedFieldsSchema = new Dictionary< + string, + FileUploadResponseSelectedFieldsSchemaItem + >() + { + { + "foo", + new() + { + Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + ThumbnailUrl = "thumbnailUrl", + Url = "url", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new FileUploadResponse + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ExtensionStatus = new() + { + AIAutoDescription = FileUploadResponseExtensionStatusAIAutoDescription.Success, + AITasks = FileUploadResponseExtensionStatusAITasks.Success, + AwsAutoTagging = FileUploadResponseExtensionStatusAwsAutoTagging.Success, + GoogleAutoTagging = FileUploadResponseExtensionStatusGoogleAutoTagging.Success, + RemoveBg = FileUploadResponseExtensionStatusRemoveBg.Success, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Metadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }, + Name = "name", + SelectedFieldsSchema = new Dictionary< + string, + FileUploadResponseSelectedFieldsSchemaItem + >() + { + { + "foo", + new() + { + Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + ThumbnailUrl = "thumbnailUrl", + Url = "url", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedAITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ]; + string expectedAudioCodec = "audioCodec"; + long expectedBitRate = 0; + string expectedCustomCoordinates = "customCoordinates"; + Dictionary expectedCustomMetadata = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; + string expectedDescription = "description"; + long expectedDuration = 0; + Dictionary expectedEmbeddedMetadata = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; + FileUploadResponseExtensionStatus expectedExtensionStatus = new() + { + AIAutoDescription = FileUploadResponseExtensionStatusAIAutoDescription.Success, + AITasks = FileUploadResponseExtensionStatusAITasks.Success, + AwsAutoTagging = FileUploadResponseExtensionStatusAwsAutoTagging.Success, + GoogleAutoTagging = FileUploadResponseExtensionStatusGoogleAutoTagging.Success, + RemoveBg = FileUploadResponseExtensionStatusRemoveBg.Success, + }; + string expectedFileID = "fileId"; + string expectedFilePath = "filePath"; + string expectedFileType = "fileType"; + double expectedHeight = 0; + bool expectedIsPrivateFile = true; + bool expectedIsPublished = true; + FileMetadata expectedMetadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }; + string expectedName = "name"; + Dictionary< + string, + FileUploadResponseSelectedFieldsSchemaItem + > expectedSelectedFieldsSchema = new() + { + { + "foo", + new() + { + Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }; + double expectedSize = 0; + List expectedTags = ["string"]; + string expectedThumbnailUrl = "thumbnailUrl"; + string expectedUrl = "url"; + FileUploadResponseVersionInfo expectedVersionInfo = new() { ID = "id", Name = "name" }; + string expectedVideoCodec = "videoCodec"; + double expectedWidth = 0; + + Assert.NotNull(deserialized.AITags); + Assert.Equal(expectedAITags.Count, deserialized.AITags.Count); + for (int i = 0; i < expectedAITags.Count; i++) + { + Assert.Equal(expectedAITags[i], deserialized.AITags[i]); + } + Assert.Equal(expectedAudioCodec, deserialized.AudioCodec); + Assert.Equal(expectedBitRate, deserialized.BitRate); + Assert.Equal(expectedCustomCoordinates, deserialized.CustomCoordinates); + Assert.NotNull(deserialized.CustomMetadata); + Assert.Equal(expectedCustomMetadata.Count, deserialized.CustomMetadata.Count); + foreach (var item in expectedCustomMetadata) + { + Assert.True(deserialized.CustomMetadata.TryGetValue(item.Key, out var value)); + + Assert.True(JsonElement.DeepEquals(value, deserialized.CustomMetadata[item.Key])); + } + Assert.Equal(expectedDescription, deserialized.Description); + Assert.Equal(expectedDuration, deserialized.Duration); + Assert.NotNull(deserialized.EmbeddedMetadata); + Assert.Equal(expectedEmbeddedMetadata.Count, deserialized.EmbeddedMetadata.Count); + foreach (var item in expectedEmbeddedMetadata) + { + Assert.True(deserialized.EmbeddedMetadata.TryGetValue(item.Key, out var value)); + + Assert.True(JsonElement.DeepEquals(value, deserialized.EmbeddedMetadata[item.Key])); + } + Assert.Equal(expectedExtensionStatus, deserialized.ExtensionStatus); + Assert.Equal(expectedFileID, deserialized.FileID); + Assert.Equal(expectedFilePath, deserialized.FilePath); + Assert.Equal(expectedFileType, deserialized.FileType); + Assert.Equal(expectedHeight, deserialized.Height); + Assert.Equal(expectedIsPrivateFile, deserialized.IsPrivateFile); + Assert.Equal(expectedIsPublished, deserialized.IsPublished); + Assert.Equal(expectedMetadata, deserialized.Metadata); + Assert.Equal(expectedName, deserialized.Name); + Assert.NotNull(deserialized.SelectedFieldsSchema); + Assert.Equal(expectedSelectedFieldsSchema.Count, deserialized.SelectedFieldsSchema.Count); + foreach (var item in expectedSelectedFieldsSchema) + { + Assert.True(deserialized.SelectedFieldsSchema.TryGetValue(item.Key, out var value)); + + Assert.Equal(value, deserialized.SelectedFieldsSchema[item.Key]); + } + Assert.Equal(expectedSize, deserialized.Size); + Assert.NotNull(deserialized.Tags); + Assert.Equal(expectedTags.Count, deserialized.Tags.Count); + for (int i = 0; i < expectedTags.Count; i++) + { + Assert.Equal(expectedTags[i], deserialized.Tags[i]); + } + Assert.Equal(expectedThumbnailUrl, deserialized.ThumbnailUrl); + Assert.Equal(expectedUrl, deserialized.Url); + Assert.Equal(expectedVersionInfo, deserialized.VersionInfo); + Assert.Equal(expectedVideoCodec, deserialized.VideoCodec); + Assert.Equal(expectedWidth, deserialized.Width); + } + + [Fact] + public void Validation_Works() + { + var model = new FileUploadResponse + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ExtensionStatus = new() + { + AIAutoDescription = FileUploadResponseExtensionStatusAIAutoDescription.Success, + AITasks = FileUploadResponseExtensionStatusAITasks.Success, + AwsAutoTagging = FileUploadResponseExtensionStatusAwsAutoTagging.Success, + GoogleAutoTagging = FileUploadResponseExtensionStatusGoogleAutoTagging.Success, + RemoveBg = FileUploadResponseExtensionStatusRemoveBg.Success, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Metadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }, + Name = "name", + SelectedFieldsSchema = new Dictionary< + string, + FileUploadResponseSelectedFieldsSchemaItem + >() + { + { + "foo", + new() + { + Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + ThumbnailUrl = "thumbnailUrl", + Url = "url", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new FileUploadResponse + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + CustomCoordinates = "customCoordinates", + Tags = ["string"], + }; + + Assert.Null(model.AudioCodec); + Assert.False(model.RawData.ContainsKey("audioCodec")); + Assert.Null(model.BitRate); + Assert.False(model.RawData.ContainsKey("bitRate")); + Assert.Null(model.CustomMetadata); + Assert.False(model.RawData.ContainsKey("customMetadata")); + Assert.Null(model.Description); + Assert.False(model.RawData.ContainsKey("description")); + Assert.Null(model.Duration); + Assert.False(model.RawData.ContainsKey("duration")); + Assert.Null(model.EmbeddedMetadata); + Assert.False(model.RawData.ContainsKey("embeddedMetadata")); + Assert.Null(model.ExtensionStatus); + Assert.False(model.RawData.ContainsKey("extensionStatus")); + Assert.Null(model.FileID); + Assert.False(model.RawData.ContainsKey("fileId")); + Assert.Null(model.FilePath); + Assert.False(model.RawData.ContainsKey("filePath")); + Assert.Null(model.FileType); + Assert.False(model.RawData.ContainsKey("fileType")); + Assert.Null(model.Height); + Assert.False(model.RawData.ContainsKey("height")); + Assert.Null(model.IsPrivateFile); + Assert.False(model.RawData.ContainsKey("isPrivateFile")); + Assert.Null(model.IsPublished); + Assert.False(model.RawData.ContainsKey("isPublished")); + Assert.Null(model.Metadata); + Assert.False(model.RawData.ContainsKey("metadata")); + Assert.Null(model.Name); + Assert.False(model.RawData.ContainsKey("name")); + Assert.Null(model.SelectedFieldsSchema); + Assert.False(model.RawData.ContainsKey("selectedFieldsSchema")); + Assert.Null(model.Size); + Assert.False(model.RawData.ContainsKey("size")); + Assert.Null(model.ThumbnailUrl); + Assert.False(model.RawData.ContainsKey("thumbnailUrl")); + Assert.Null(model.Url); + Assert.False(model.RawData.ContainsKey("url")); + Assert.Null(model.VersionInfo); + Assert.False(model.RawData.ContainsKey("versionInfo")); + Assert.Null(model.VideoCodec); + Assert.False(model.RawData.ContainsKey("videoCodec")); + Assert.Null(model.Width); + Assert.False(model.RawData.ContainsKey("width")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new FileUploadResponse + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + CustomCoordinates = "customCoordinates", + Tags = ["string"], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new FileUploadResponse + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + CustomCoordinates = "customCoordinates", + Tags = ["string"], + + // Null should be interpreted as omitted for these properties + AudioCodec = null, + BitRate = null, + CustomMetadata = null, + Description = null, + Duration = null, + EmbeddedMetadata = null, + ExtensionStatus = null, + FileID = null, + FilePath = null, + FileType = null, + Height = null, + IsPrivateFile = null, + IsPublished = null, + Metadata = null, + Name = null, + SelectedFieldsSchema = null, + Size = null, + ThumbnailUrl = null, + Url = null, + VersionInfo = null, + VideoCodec = null, + Width = null, + }; + + Assert.Null(model.AudioCodec); + Assert.False(model.RawData.ContainsKey("audioCodec")); + Assert.Null(model.BitRate); + Assert.False(model.RawData.ContainsKey("bitRate")); + Assert.Null(model.CustomMetadata); + Assert.False(model.RawData.ContainsKey("customMetadata")); + Assert.Null(model.Description); + Assert.False(model.RawData.ContainsKey("description")); + Assert.Null(model.Duration); + Assert.False(model.RawData.ContainsKey("duration")); + Assert.Null(model.EmbeddedMetadata); + Assert.False(model.RawData.ContainsKey("embeddedMetadata")); + Assert.Null(model.ExtensionStatus); + Assert.False(model.RawData.ContainsKey("extensionStatus")); + Assert.Null(model.FileID); + Assert.False(model.RawData.ContainsKey("fileId")); + Assert.Null(model.FilePath); + Assert.False(model.RawData.ContainsKey("filePath")); + Assert.Null(model.FileType); + Assert.False(model.RawData.ContainsKey("fileType")); + Assert.Null(model.Height); + Assert.False(model.RawData.ContainsKey("height")); + Assert.Null(model.IsPrivateFile); + Assert.False(model.RawData.ContainsKey("isPrivateFile")); + Assert.Null(model.IsPublished); + Assert.False(model.RawData.ContainsKey("isPublished")); + Assert.Null(model.Metadata); + Assert.False(model.RawData.ContainsKey("metadata")); + Assert.Null(model.Name); + Assert.False(model.RawData.ContainsKey("name")); + Assert.Null(model.SelectedFieldsSchema); + Assert.False(model.RawData.ContainsKey("selectedFieldsSchema")); + Assert.Null(model.Size); + Assert.False(model.RawData.ContainsKey("size")); + Assert.Null(model.ThumbnailUrl); + Assert.False(model.RawData.ContainsKey("thumbnailUrl")); + Assert.Null(model.Url); + Assert.False(model.RawData.ContainsKey("url")); + Assert.Null(model.VersionInfo); + Assert.False(model.RawData.ContainsKey("versionInfo")); + Assert.Null(model.VideoCodec); + Assert.False(model.RawData.ContainsKey("videoCodec")); + Assert.Null(model.Width); + Assert.False(model.RawData.ContainsKey("width")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new FileUploadResponse + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + CustomCoordinates = "customCoordinates", + Tags = ["string"], + + // Null should be interpreted as omitted for these properties + AudioCodec = null, + BitRate = null, + CustomMetadata = null, + Description = null, + Duration = null, + EmbeddedMetadata = null, + ExtensionStatus = null, + FileID = null, + FilePath = null, + FileType = null, + Height = null, + IsPrivateFile = null, + IsPublished = null, + Metadata = null, + Name = null, + SelectedFieldsSchema = null, + Size = null, + ThumbnailUrl = null, + Url = null, + VersionInfo = null, + VideoCodec = null, + Width = null, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new FileUploadResponse + { + AudioCodec = "audioCodec", + BitRate = 0, + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ExtensionStatus = new() + { + AIAutoDescription = FileUploadResponseExtensionStatusAIAutoDescription.Success, + AITasks = FileUploadResponseExtensionStatusAITasks.Success, + AwsAutoTagging = FileUploadResponseExtensionStatusAwsAutoTagging.Success, + GoogleAutoTagging = FileUploadResponseExtensionStatusGoogleAutoTagging.Success, + RemoveBg = FileUploadResponseExtensionStatusRemoveBg.Success, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Metadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }, + Name = "name", + SelectedFieldsSchema = new Dictionary< + string, + FileUploadResponseSelectedFieldsSchemaItem + >() + { + { + "foo", + new() + { + Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + ThumbnailUrl = "thumbnailUrl", + Url = "url", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }; + + Assert.Null(model.AITags); + Assert.False(model.RawData.ContainsKey("AITags")); + Assert.Null(model.CustomCoordinates); + Assert.False(model.RawData.ContainsKey("customCoordinates")); + Assert.Null(model.Tags); + Assert.False(model.RawData.ContainsKey("tags")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new FileUploadResponse + { + AudioCodec = "audioCodec", + BitRate = 0, + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ExtensionStatus = new() + { + AIAutoDescription = FileUploadResponseExtensionStatusAIAutoDescription.Success, + AITasks = FileUploadResponseExtensionStatusAITasks.Success, + AwsAutoTagging = FileUploadResponseExtensionStatusAwsAutoTagging.Success, + GoogleAutoTagging = FileUploadResponseExtensionStatusGoogleAutoTagging.Success, + RemoveBg = FileUploadResponseExtensionStatusRemoveBg.Success, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Metadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }, + Name = "name", + SelectedFieldsSchema = new Dictionary< + string, + FileUploadResponseSelectedFieldsSchemaItem + >() + { + { + "foo", + new() + { + Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + ThumbnailUrl = "thumbnailUrl", + Url = "url", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new FileUploadResponse + { + AudioCodec = "audioCodec", + BitRate = 0, + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ExtensionStatus = new() + { + AIAutoDescription = FileUploadResponseExtensionStatusAIAutoDescription.Success, + AITasks = FileUploadResponseExtensionStatusAITasks.Success, + AwsAutoTagging = FileUploadResponseExtensionStatusAwsAutoTagging.Success, + GoogleAutoTagging = FileUploadResponseExtensionStatusGoogleAutoTagging.Success, + RemoveBg = FileUploadResponseExtensionStatusRemoveBg.Success, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Metadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }, + Name = "name", + SelectedFieldsSchema = new Dictionary< + string, + FileUploadResponseSelectedFieldsSchemaItem + >() + { + { + "foo", + new() + { + Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + ThumbnailUrl = "thumbnailUrl", + Url = "url", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + + AITags = null, + CustomCoordinates = null, + Tags = null, + }; + + Assert.Null(model.AITags); + Assert.True(model.RawData.ContainsKey("AITags")); + Assert.Null(model.CustomCoordinates); + Assert.True(model.RawData.ContainsKey("customCoordinates")); + Assert.Null(model.Tags); + Assert.True(model.RawData.ContainsKey("tags")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new FileUploadResponse + { + AudioCodec = "audioCodec", + BitRate = 0, + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ExtensionStatus = new() + { + AIAutoDescription = FileUploadResponseExtensionStatusAIAutoDescription.Success, + AITasks = FileUploadResponseExtensionStatusAITasks.Success, + AwsAutoTagging = FileUploadResponseExtensionStatusAwsAutoTagging.Success, + GoogleAutoTagging = FileUploadResponseExtensionStatusGoogleAutoTagging.Success, + RemoveBg = FileUploadResponseExtensionStatusRemoveBg.Success, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Metadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }, + Name = "name", + SelectedFieldsSchema = new Dictionary< + string, + FileUploadResponseSelectedFieldsSchemaItem + >() + { + { + "foo", + new() + { + Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + ThumbnailUrl = "thumbnailUrl", + Url = "url", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + + AITags = null, + CustomCoordinates = null, + Tags = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new FileUploadResponse + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ExtensionStatus = new() + { + AIAutoDescription = FileUploadResponseExtensionStatusAIAutoDescription.Success, + AITasks = FileUploadResponseExtensionStatusAITasks.Success, + AwsAutoTagging = FileUploadResponseExtensionStatusAwsAutoTagging.Success, + GoogleAutoTagging = FileUploadResponseExtensionStatusGoogleAutoTagging.Success, + RemoveBg = FileUploadResponseExtensionStatusRemoveBg.Success, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Metadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }, + Name = "name", + SelectedFieldsSchema = new Dictionary< + string, + FileUploadResponseSelectedFieldsSchemaItem + >() + { + { + "foo", + new() + { + Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + ThumbnailUrl = "thumbnailUrl", + Url = "url", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }; + + FileUploadResponse copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class FileUploadResponseAITagTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new FileUploadResponseAITag + { + Confidence = 0, + Name = "name", + Source = "source", + }; + + double expectedConfidence = 0; + string expectedName = "name"; + string expectedSource = "source"; + + Assert.Equal(expectedConfidence, model.Confidence); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedSource, model.Source); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new FileUploadResponseAITag + { + Confidence = 0, + Name = "name", + Source = "source", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new FileUploadResponseAITag + { + Confidence = 0, + Name = "name", + Source = "source", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + double expectedConfidence = 0; + string expectedName = "name"; + string expectedSource = "source"; + + Assert.Equal(expectedConfidence, deserialized.Confidence); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedSource, deserialized.Source); + } + + [Fact] + public void Validation_Works() + { + var model = new FileUploadResponseAITag + { + Confidence = 0, + Name = "name", + Source = "source", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new FileUploadResponseAITag { }; + + Assert.Null(model.Confidence); + Assert.False(model.RawData.ContainsKey("confidence")); + Assert.Null(model.Name); + Assert.False(model.RawData.ContainsKey("name")); + Assert.Null(model.Source); + Assert.False(model.RawData.ContainsKey("source")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new FileUploadResponseAITag { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new FileUploadResponseAITag + { + // Null should be interpreted as omitted for these properties + Confidence = null, + Name = null, + Source = null, + }; + + Assert.Null(model.Confidence); + Assert.False(model.RawData.ContainsKey("confidence")); + Assert.Null(model.Name); + Assert.False(model.RawData.ContainsKey("name")); + Assert.Null(model.Source); + Assert.False(model.RawData.ContainsKey("source")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new FileUploadResponseAITag + { + // Null should be interpreted as omitted for these properties + Confidence = null, + Name = null, + Source = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new FileUploadResponseAITag + { + Confidence = 0, + Name = "name", + Source = "source", + }; + + FileUploadResponseAITag copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class FileUploadResponseExtensionStatusTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new FileUploadResponseExtensionStatus + { + AIAutoDescription = FileUploadResponseExtensionStatusAIAutoDescription.Success, + AITasks = FileUploadResponseExtensionStatusAITasks.Success, + AwsAutoTagging = FileUploadResponseExtensionStatusAwsAutoTagging.Success, + GoogleAutoTagging = FileUploadResponseExtensionStatusGoogleAutoTagging.Success, + RemoveBg = FileUploadResponseExtensionStatusRemoveBg.Success, + }; + + ApiEnum< + string, + FileUploadResponseExtensionStatusAIAutoDescription + > expectedAIAutoDescription = FileUploadResponseExtensionStatusAIAutoDescription.Success; + ApiEnum expectedAITasks = + FileUploadResponseExtensionStatusAITasks.Success; + ApiEnum expectedAwsAutoTagging = + FileUploadResponseExtensionStatusAwsAutoTagging.Success; + ApiEnum< + string, + FileUploadResponseExtensionStatusGoogleAutoTagging + > expectedGoogleAutoTagging = FileUploadResponseExtensionStatusGoogleAutoTagging.Success; + ApiEnum expectedRemoveBg = + FileUploadResponseExtensionStatusRemoveBg.Success; + + Assert.Equal(expectedAIAutoDescription, model.AIAutoDescription); + Assert.Equal(expectedAITasks, model.AITasks); + Assert.Equal(expectedAwsAutoTagging, model.AwsAutoTagging); + Assert.Equal(expectedGoogleAutoTagging, model.GoogleAutoTagging); + Assert.Equal(expectedRemoveBg, model.RemoveBg); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new FileUploadResponseExtensionStatus + { + AIAutoDescription = FileUploadResponseExtensionStatusAIAutoDescription.Success, + AITasks = FileUploadResponseExtensionStatusAITasks.Success, + AwsAutoTagging = FileUploadResponseExtensionStatusAwsAutoTagging.Success, + GoogleAutoTagging = FileUploadResponseExtensionStatusGoogleAutoTagging.Success, + RemoveBg = FileUploadResponseExtensionStatusRemoveBg.Success, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new FileUploadResponseExtensionStatus + { + AIAutoDescription = FileUploadResponseExtensionStatusAIAutoDescription.Success, + AITasks = FileUploadResponseExtensionStatusAITasks.Success, + AwsAutoTagging = FileUploadResponseExtensionStatusAwsAutoTagging.Success, + GoogleAutoTagging = FileUploadResponseExtensionStatusGoogleAutoTagging.Success, + RemoveBg = FileUploadResponseExtensionStatusRemoveBg.Success, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum< + string, + FileUploadResponseExtensionStatusAIAutoDescription + > expectedAIAutoDescription = FileUploadResponseExtensionStatusAIAutoDescription.Success; + ApiEnum expectedAITasks = + FileUploadResponseExtensionStatusAITasks.Success; + ApiEnum expectedAwsAutoTagging = + FileUploadResponseExtensionStatusAwsAutoTagging.Success; + ApiEnum< + string, + FileUploadResponseExtensionStatusGoogleAutoTagging + > expectedGoogleAutoTagging = FileUploadResponseExtensionStatusGoogleAutoTagging.Success; + ApiEnum expectedRemoveBg = + FileUploadResponseExtensionStatusRemoveBg.Success; + + Assert.Equal(expectedAIAutoDescription, deserialized.AIAutoDescription); + Assert.Equal(expectedAITasks, deserialized.AITasks); + Assert.Equal(expectedAwsAutoTagging, deserialized.AwsAutoTagging); + Assert.Equal(expectedGoogleAutoTagging, deserialized.GoogleAutoTagging); + Assert.Equal(expectedRemoveBg, deserialized.RemoveBg); + } + + [Fact] + public void Validation_Works() + { + var model = new FileUploadResponseExtensionStatus + { + AIAutoDescription = FileUploadResponseExtensionStatusAIAutoDescription.Success, + AITasks = FileUploadResponseExtensionStatusAITasks.Success, + AwsAutoTagging = FileUploadResponseExtensionStatusAwsAutoTagging.Success, + GoogleAutoTagging = FileUploadResponseExtensionStatusGoogleAutoTagging.Success, + RemoveBg = FileUploadResponseExtensionStatusRemoveBg.Success, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new FileUploadResponseExtensionStatus { }; + + Assert.Null(model.AIAutoDescription); + Assert.False(model.RawData.ContainsKey("ai-auto-description")); + Assert.Null(model.AITasks); + Assert.False(model.RawData.ContainsKey("ai-tasks")); + Assert.Null(model.AwsAutoTagging); + Assert.False(model.RawData.ContainsKey("aws-auto-tagging")); + Assert.Null(model.GoogleAutoTagging); + Assert.False(model.RawData.ContainsKey("google-auto-tagging")); + Assert.Null(model.RemoveBg); + Assert.False(model.RawData.ContainsKey("remove-bg")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new FileUploadResponseExtensionStatus { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new FileUploadResponseExtensionStatus + { + // Null should be interpreted as omitted for these properties + AIAutoDescription = null, + AITasks = null, + AwsAutoTagging = null, + GoogleAutoTagging = null, + RemoveBg = null, + }; + + Assert.Null(model.AIAutoDescription); + Assert.False(model.RawData.ContainsKey("ai-auto-description")); + Assert.Null(model.AITasks); + Assert.False(model.RawData.ContainsKey("ai-tasks")); + Assert.Null(model.AwsAutoTagging); + Assert.False(model.RawData.ContainsKey("aws-auto-tagging")); + Assert.Null(model.GoogleAutoTagging); + Assert.False(model.RawData.ContainsKey("google-auto-tagging")); + Assert.Null(model.RemoveBg); + Assert.False(model.RawData.ContainsKey("remove-bg")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new FileUploadResponseExtensionStatus + { + // Null should be interpreted as omitted for these properties + AIAutoDescription = null, + AITasks = null, + AwsAutoTagging = null, + GoogleAutoTagging = null, + RemoveBg = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new FileUploadResponseExtensionStatus + { + AIAutoDescription = FileUploadResponseExtensionStatusAIAutoDescription.Success, + AITasks = FileUploadResponseExtensionStatusAITasks.Success, + AwsAutoTagging = FileUploadResponseExtensionStatusAwsAutoTagging.Success, + GoogleAutoTagging = FileUploadResponseExtensionStatusGoogleAutoTagging.Success, + RemoveBg = FileUploadResponseExtensionStatusRemoveBg.Success, + }; + + FileUploadResponseExtensionStatus copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class FileUploadResponseExtensionStatusAIAutoDescriptionTest : TestBase +{ + [Theory] + [InlineData(FileUploadResponseExtensionStatusAIAutoDescription.Success)] + [InlineData(FileUploadResponseExtensionStatusAIAutoDescription.Pending)] + [InlineData(FileUploadResponseExtensionStatusAIAutoDescription.Failed)] + public void Validation_Works(FileUploadResponseExtensionStatusAIAutoDescription rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(FileUploadResponseExtensionStatusAIAutoDescription.Success)] + [InlineData(FileUploadResponseExtensionStatusAIAutoDescription.Pending)] + [InlineData(FileUploadResponseExtensionStatusAIAutoDescription.Failed)] + public void SerializationRoundtrip_Works( + FileUploadResponseExtensionStatusAIAutoDescription rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class FileUploadResponseExtensionStatusAITasksTest : TestBase +{ + [Theory] + [InlineData(FileUploadResponseExtensionStatusAITasks.Success)] + [InlineData(FileUploadResponseExtensionStatusAITasks.Pending)] + [InlineData(FileUploadResponseExtensionStatusAITasks.Failed)] + public void Validation_Works(FileUploadResponseExtensionStatusAITasks rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(FileUploadResponseExtensionStatusAITasks.Success)] + [InlineData(FileUploadResponseExtensionStatusAITasks.Pending)] + [InlineData(FileUploadResponseExtensionStatusAITasks.Failed)] + public void SerializationRoundtrip_Works(FileUploadResponseExtensionStatusAITasks rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class FileUploadResponseExtensionStatusAwsAutoTaggingTest : TestBase +{ + [Theory] + [InlineData(FileUploadResponseExtensionStatusAwsAutoTagging.Success)] + [InlineData(FileUploadResponseExtensionStatusAwsAutoTagging.Pending)] + [InlineData(FileUploadResponseExtensionStatusAwsAutoTagging.Failed)] + public void Validation_Works(FileUploadResponseExtensionStatusAwsAutoTagging rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(FileUploadResponseExtensionStatusAwsAutoTagging.Success)] + [InlineData(FileUploadResponseExtensionStatusAwsAutoTagging.Pending)] + [InlineData(FileUploadResponseExtensionStatusAwsAutoTagging.Failed)] + public void SerializationRoundtrip_Works( + FileUploadResponseExtensionStatusAwsAutoTagging rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class FileUploadResponseExtensionStatusGoogleAutoTaggingTest : TestBase +{ + [Theory] + [InlineData(FileUploadResponseExtensionStatusGoogleAutoTagging.Success)] + [InlineData(FileUploadResponseExtensionStatusGoogleAutoTagging.Pending)] + [InlineData(FileUploadResponseExtensionStatusGoogleAutoTagging.Failed)] + public void Validation_Works(FileUploadResponseExtensionStatusGoogleAutoTagging rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(FileUploadResponseExtensionStatusGoogleAutoTagging.Success)] + [InlineData(FileUploadResponseExtensionStatusGoogleAutoTagging.Pending)] + [InlineData(FileUploadResponseExtensionStatusGoogleAutoTagging.Failed)] + public void SerializationRoundtrip_Works( + FileUploadResponseExtensionStatusGoogleAutoTagging rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class FileUploadResponseExtensionStatusRemoveBgTest : TestBase +{ + [Theory] + [InlineData(FileUploadResponseExtensionStatusRemoveBg.Success)] + [InlineData(FileUploadResponseExtensionStatusRemoveBg.Pending)] + [InlineData(FileUploadResponseExtensionStatusRemoveBg.Failed)] + public void Validation_Works(FileUploadResponseExtensionStatusRemoveBg rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(FileUploadResponseExtensionStatusRemoveBg.Success)] + [InlineData(FileUploadResponseExtensionStatusRemoveBg.Pending)] + [InlineData(FileUploadResponseExtensionStatusRemoveBg.Failed)] + public void SerializationRoundtrip_Works(FileUploadResponseExtensionStatusRemoveBg rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class FileUploadResponseSelectedFieldsSchemaItemTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new FileUploadResponseSelectedFieldsSchemaItem + { + Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + }; + + ApiEnum expectedType = + FileUploadResponseSelectedFieldsSchemaItemType.Text; + FileUploadResponseSelectedFieldsSchemaItemDefaultValue expectedDefaultValue = "string"; + bool expectedIsValueRequired = true; + double expectedMaxLength = 0; + FileUploadResponseSelectedFieldsSchemaItemMaxValue expectedMaxValue = "string"; + double expectedMinLength = 0; + FileUploadResponseSelectedFieldsSchemaItemMinValue expectedMinValue = "string"; + bool expectedReadOnly = true; + List expectedSelectOptions = + [ + "small", + "medium", + "large", + 30, + 40, + true, + ]; + bool expectedSelectOptionsTruncated = true; + + Assert.Equal(expectedType, model.Type); + Assert.Equal(expectedDefaultValue, model.DefaultValue); + Assert.Equal(expectedIsValueRequired, model.IsValueRequired); + Assert.Equal(expectedMaxLength, model.MaxLength); + Assert.Equal(expectedMaxValue, model.MaxValue); + Assert.Equal(expectedMinLength, model.MinLength); + Assert.Equal(expectedMinValue, model.MinValue); + Assert.Equal(expectedReadOnly, model.ReadOnly); + Assert.NotNull(model.SelectOptions); + Assert.Equal(expectedSelectOptions.Count, model.SelectOptions.Count); + for (int i = 0; i < expectedSelectOptions.Count; i++) + { + Assert.Equal(expectedSelectOptions[i], model.SelectOptions[i]); + } + Assert.Equal(expectedSelectOptionsTruncated, model.SelectOptionsTruncated); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new FileUploadResponseSelectedFieldsSchemaItem + { + Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new FileUploadResponseSelectedFieldsSchemaItem + { + Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum expectedType = + FileUploadResponseSelectedFieldsSchemaItemType.Text; + FileUploadResponseSelectedFieldsSchemaItemDefaultValue expectedDefaultValue = "string"; + bool expectedIsValueRequired = true; + double expectedMaxLength = 0; + FileUploadResponseSelectedFieldsSchemaItemMaxValue expectedMaxValue = "string"; + double expectedMinLength = 0; + FileUploadResponseSelectedFieldsSchemaItemMinValue expectedMinValue = "string"; + bool expectedReadOnly = true; + List expectedSelectOptions = + [ + "small", + "medium", + "large", + 30, + 40, + true, + ]; + bool expectedSelectOptionsTruncated = true; + + Assert.Equal(expectedType, deserialized.Type); + Assert.Equal(expectedDefaultValue, deserialized.DefaultValue); + Assert.Equal(expectedIsValueRequired, deserialized.IsValueRequired); + Assert.Equal(expectedMaxLength, deserialized.MaxLength); + Assert.Equal(expectedMaxValue, deserialized.MaxValue); + Assert.Equal(expectedMinLength, deserialized.MinLength); + Assert.Equal(expectedMinValue, deserialized.MinValue); + Assert.Equal(expectedReadOnly, deserialized.ReadOnly); + Assert.NotNull(deserialized.SelectOptions); + Assert.Equal(expectedSelectOptions.Count, deserialized.SelectOptions.Count); + for (int i = 0; i < expectedSelectOptions.Count; i++) + { + Assert.Equal(expectedSelectOptions[i], deserialized.SelectOptions[i]); + } + Assert.Equal(expectedSelectOptionsTruncated, deserialized.SelectOptionsTruncated); + } + + [Fact] + public void Validation_Works() + { + var model = new FileUploadResponseSelectedFieldsSchemaItem + { + Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new FileUploadResponseSelectedFieldsSchemaItem + { + Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, + }; + + Assert.Null(model.DefaultValue); + Assert.False(model.RawData.ContainsKey("defaultValue")); + Assert.Null(model.IsValueRequired); + Assert.False(model.RawData.ContainsKey("isValueRequired")); + Assert.Null(model.MaxLength); + Assert.False(model.RawData.ContainsKey("maxLength")); + Assert.Null(model.MaxValue); + Assert.False(model.RawData.ContainsKey("maxValue")); + Assert.Null(model.MinLength); + Assert.False(model.RawData.ContainsKey("minLength")); + Assert.Null(model.MinValue); + Assert.False(model.RawData.ContainsKey("minValue")); + Assert.Null(model.ReadOnly); + Assert.False(model.RawData.ContainsKey("readOnly")); + Assert.Null(model.SelectOptions); + Assert.False(model.RawData.ContainsKey("selectOptions")); + Assert.Null(model.SelectOptionsTruncated); + Assert.False(model.RawData.ContainsKey("selectOptionsTruncated")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new FileUploadResponseSelectedFieldsSchemaItem + { + Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new FileUploadResponseSelectedFieldsSchemaItem + { + Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, + + // Null should be interpreted as omitted for these properties + DefaultValue = null, + IsValueRequired = null, + MaxLength = null, + MaxValue = null, + MinLength = null, + MinValue = null, + ReadOnly = null, + SelectOptions = null, + SelectOptionsTruncated = null, + }; + + Assert.Null(model.DefaultValue); + Assert.False(model.RawData.ContainsKey("defaultValue")); + Assert.Null(model.IsValueRequired); + Assert.False(model.RawData.ContainsKey("isValueRequired")); + Assert.Null(model.MaxLength); + Assert.False(model.RawData.ContainsKey("maxLength")); + Assert.Null(model.MaxValue); + Assert.False(model.RawData.ContainsKey("maxValue")); + Assert.Null(model.MinLength); + Assert.False(model.RawData.ContainsKey("minLength")); + Assert.Null(model.MinValue); + Assert.False(model.RawData.ContainsKey("minValue")); + Assert.Null(model.ReadOnly); + Assert.False(model.RawData.ContainsKey("readOnly")); + Assert.Null(model.SelectOptions); + Assert.False(model.RawData.ContainsKey("selectOptions")); + Assert.Null(model.SelectOptionsTruncated); + Assert.False(model.RawData.ContainsKey("selectOptionsTruncated")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new FileUploadResponseSelectedFieldsSchemaItem + { + Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, + + // Null should be interpreted as omitted for these properties + DefaultValue = null, + IsValueRequired = null, + MaxLength = null, + MaxValue = null, + MinLength = null, + MinValue = null, + ReadOnly = null, + SelectOptions = null, + SelectOptionsTruncated = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new FileUploadResponseSelectedFieldsSchemaItem + { + Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + }; + + FileUploadResponseSelectedFieldsSchemaItem copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class FileUploadResponseSelectedFieldsSchemaItemTypeTest : TestBase +{ + [Theory] + [InlineData(FileUploadResponseSelectedFieldsSchemaItemType.Text)] + [InlineData(FileUploadResponseSelectedFieldsSchemaItemType.Textarea)] + [InlineData(FileUploadResponseSelectedFieldsSchemaItemType.Number)] + [InlineData(FileUploadResponseSelectedFieldsSchemaItemType.Date)] + [InlineData(FileUploadResponseSelectedFieldsSchemaItemType.Boolean)] + [InlineData(FileUploadResponseSelectedFieldsSchemaItemType.SingleSelect)] + [InlineData(FileUploadResponseSelectedFieldsSchemaItemType.MultiSelect)] + public void Validation_Works(FileUploadResponseSelectedFieldsSchemaItemType rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(FileUploadResponseSelectedFieldsSchemaItemType.Text)] + [InlineData(FileUploadResponseSelectedFieldsSchemaItemType.Textarea)] + [InlineData(FileUploadResponseSelectedFieldsSchemaItemType.Number)] + [InlineData(FileUploadResponseSelectedFieldsSchemaItemType.Date)] + [InlineData(FileUploadResponseSelectedFieldsSchemaItemType.Boolean)] + [InlineData(FileUploadResponseSelectedFieldsSchemaItemType.SingleSelect)] + [InlineData(FileUploadResponseSelectedFieldsSchemaItemType.MultiSelect)] + public void SerializationRoundtrip_Works( + FileUploadResponseSelectedFieldsSchemaItemType rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class FileUploadResponseSelectedFieldsSchemaItemDefaultValueTest : TestBase +{ + [Fact] + public void StringValidationWorks() + { + FileUploadResponseSelectedFieldsSchemaItemDefaultValue value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + FileUploadResponseSelectedFieldsSchemaItemDefaultValue value = 0; + value.Validate(); + } + + [Fact] + public void BoolValidationWorks() + { + FileUploadResponseSelectedFieldsSchemaItemDefaultValue value = true; + value.Validate(); + } + + [Fact] + public void MixedValidationWorks() + { + FileUploadResponseSelectedFieldsSchemaItemDefaultValue value = new( + [ + new UnnamedSchemaWithArrayParent11(true), + new UnnamedSchemaWithArrayParent11(10), + new UnnamedSchemaWithArrayParent11("Hello"), + ] + ); + value.Validate(); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + FileUploadResponseSelectedFieldsSchemaItemDefaultValue value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + FileUploadResponseSelectedFieldsSchemaItemDefaultValue value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void BoolSerializationRoundtripWorks() + { + FileUploadResponseSelectedFieldsSchemaItemDefaultValue value = true; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void MixedSerializationRoundtripWorks() + { + FileUploadResponseSelectedFieldsSchemaItemDefaultValue value = new( + [ + new UnnamedSchemaWithArrayParent11(true), + new UnnamedSchemaWithArrayParent11(10), + new UnnamedSchemaWithArrayParent11("Hello"), + ] + ); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class UnnamedSchemaWithArrayParent11Test : TestBase +{ + [Fact] + public void StringValidationWorks() + { + UnnamedSchemaWithArrayParent11 value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + UnnamedSchemaWithArrayParent11 value = 0; + value.Validate(); + } + + [Fact] + public void BoolValidationWorks() + { + UnnamedSchemaWithArrayParent11 value = true; + value.Validate(); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent11 value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent11 value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void BoolSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent11 value = true; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class FileUploadResponseSelectedFieldsSchemaItemMaxValueTest : TestBase +{ + [Fact] + public void StringValidationWorks() + { + FileUploadResponseSelectedFieldsSchemaItemMaxValue value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + FileUploadResponseSelectedFieldsSchemaItemMaxValue value = 0; + value.Validate(); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + FileUploadResponseSelectedFieldsSchemaItemMaxValue value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + FileUploadResponseSelectedFieldsSchemaItemMaxValue value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class FileUploadResponseSelectedFieldsSchemaItemMinValueTest : TestBase +{ + [Fact] + public void StringValidationWorks() + { + FileUploadResponseSelectedFieldsSchemaItemMinValue value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + FileUploadResponseSelectedFieldsSchemaItemMinValue value = 0; + value.Validate(); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + FileUploadResponseSelectedFieldsSchemaItemMinValue value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + FileUploadResponseSelectedFieldsSchemaItemMinValue value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class FileUploadResponseSelectedFieldsSchemaItemSelectOptionTest : TestBase +{ + [Fact] + public void StringValidationWorks() + { + FileUploadResponseSelectedFieldsSchemaItemSelectOption value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + FileUploadResponseSelectedFieldsSchemaItemSelectOption value = 0; + value.Validate(); + } + + [Fact] + public void BoolValidationWorks() + { + FileUploadResponseSelectedFieldsSchemaItemSelectOption value = true; + value.Validate(); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + FileUploadResponseSelectedFieldsSchemaItemSelectOption value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + FileUploadResponseSelectedFieldsSchemaItemSelectOption value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void BoolSerializationRoundtripWorks() + { + FileUploadResponseSelectedFieldsSchemaItemSelectOption value = true; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class FileUploadResponseVersionInfoTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new FileUploadResponseVersionInfo { ID = "id", Name = "name" }; + + string expectedID = "id"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new FileUploadResponseVersionInfo { ID = "id", Name = "name" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new FileUploadResponseVersionInfo { ID = "id", Name = "name" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new FileUploadResponseVersionInfo { ID = "id", Name = "name" }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new FileUploadResponseVersionInfo { }; + + Assert.Null(model.ID); + Assert.False(model.RawData.ContainsKey("id")); + Assert.Null(model.Name); + Assert.False(model.RawData.ContainsKey("name")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new FileUploadResponseVersionInfo { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new FileUploadResponseVersionInfo + { + // Null should be interpreted as omitted for these properties + ID = null, + Name = null, + }; + + Assert.Null(model.ID); + Assert.False(model.RawData.ContainsKey("id")); + Assert.Null(model.Name); + Assert.False(model.RawData.ContainsKey("name")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new FileUploadResponseVersionInfo + { + // Null should be interpreted as omitted for these properties + ID = null, + Name = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new FileUploadResponseVersionInfo { ID = "id", Name = "name" }; + + FileUploadResponseVersionInfo copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Files/FolderTest.cs b/src/ImageKit.Tests/Models/Files/FolderTest.cs new file mode 100644 index 00000000..d8d2018d --- /dev/null +++ b/src/ImageKit.Tests/Models/Files/FolderTest.cs @@ -0,0 +1,251 @@ +using System; +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Exceptions; +using ImageKit.Models.Files; + +namespace ImageKit.Tests.Models.Files; + +public class FolderTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Folder + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + FolderID = "folderId", + FolderPath = "folderPath", + Name = "name", + Type = FolderType.Folder, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + string expectedFolderID = "folderId"; + string expectedFolderPath = "folderPath"; + string expectedName = "name"; + ApiEnum expectedType = FolderType.Folder; + DateTimeOffset expectedUpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + + Assert.Equal(expectedCreatedAt, model.CreatedAt); + Assert.Equal(expectedFolderID, model.FolderID); + Assert.Equal(expectedFolderPath, model.FolderPath); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedType, model.Type); + Assert.Equal(expectedUpdatedAt, model.UpdatedAt); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Folder + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + FolderID = "folderId", + FolderPath = "folderPath", + Name = "name", + Type = FolderType.Folder, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Folder + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + FolderID = "folderId", + FolderPath = "folderPath", + Name = "name", + Type = FolderType.Folder, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + Assert.NotNull(deserialized); + + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + string expectedFolderID = "folderId"; + string expectedFolderPath = "folderPath"; + string expectedName = "name"; + ApiEnum expectedType = FolderType.Folder; + DateTimeOffset expectedUpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + + Assert.Equal(expectedCreatedAt, deserialized.CreatedAt); + Assert.Equal(expectedFolderID, deserialized.FolderID); + Assert.Equal(expectedFolderPath, deserialized.FolderPath); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedType, deserialized.Type); + Assert.Equal(expectedUpdatedAt, deserialized.UpdatedAt); + } + + [Fact] + public void Validation_Works() + { + var model = new Folder + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + FolderID = "folderId", + FolderPath = "folderPath", + Name = "name", + Type = FolderType.Folder, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Folder { }; + + Assert.Null(model.CreatedAt); + Assert.False(model.RawData.ContainsKey("createdAt")); + Assert.Null(model.FolderID); + Assert.False(model.RawData.ContainsKey("folderId")); + Assert.Null(model.FolderPath); + Assert.False(model.RawData.ContainsKey("folderPath")); + Assert.Null(model.Name); + Assert.False(model.RawData.ContainsKey("name")); + Assert.Null(model.Type); + Assert.False(model.RawData.ContainsKey("type")); + Assert.Null(model.UpdatedAt); + Assert.False(model.RawData.ContainsKey("updatedAt")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new Folder { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new Folder + { + // Null should be interpreted as omitted for these properties + CreatedAt = null, + FolderID = null, + FolderPath = null, + Name = null, + Type = null, + UpdatedAt = null, + }; + + Assert.Null(model.CreatedAt); + Assert.False(model.RawData.ContainsKey("createdAt")); + Assert.Null(model.FolderID); + Assert.False(model.RawData.ContainsKey("folderId")); + Assert.Null(model.FolderPath); + Assert.False(model.RawData.ContainsKey("folderPath")); + Assert.Null(model.Name); + Assert.False(model.RawData.ContainsKey("name")); + Assert.Null(model.Type); + Assert.False(model.RawData.ContainsKey("type")); + Assert.Null(model.UpdatedAt); + Assert.False(model.RawData.ContainsKey("updatedAt")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new Folder + { + // Null should be interpreted as omitted for these properties + CreatedAt = null, + FolderID = null, + FolderPath = null, + Name = null, + Type = null, + UpdatedAt = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Folder + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + FolderID = "folderId", + FolderPath = "folderPath", + Name = "name", + Type = FolderType.Folder, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + Folder copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class FolderTypeTest : TestBase +{ + [Theory] + [InlineData(FolderType.Folder)] + public void Validation_Works(FolderType rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(FolderType.Folder)] + public void SerializationRoundtrip_Works(FolderType rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} diff --git a/src/ImageKit.Tests/Models/Files/Metadata/MetadataGetFromUrlParamsTest.cs b/src/ImageKit.Tests/Models/Files/Metadata/MetadataGetFromUrlParamsTest.cs new file mode 100644 index 00000000..41155870 --- /dev/null +++ b/src/ImageKit.Tests/Models/Files/Metadata/MetadataGetFromUrlParamsTest.cs @@ -0,0 +1,40 @@ +using System; +using ImageKit.Models.Files.Metadata; + +namespace ImageKit.Tests.Models.Files.Metadata; + +public class MetadataGetFromUrlParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new MetadataGetFromUrlParams { UrlValue = "https://example.com" }; + + string expectedUrlValue = "https://example.com"; + + Assert.Equal(expectedUrlValue, parameters.UrlValue); + } + + [Fact] + public void Url_Works() + { + MetadataGetFromUrlParams parameters = new() { UrlValue = "https://example.com" }; + + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + + Assert.Equal( + new Uri("https://api.imagekit.io/v1/metadata?url=https%3a%2f%2fexample.com"), + url + ); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new MetadataGetFromUrlParams { UrlValue = "https://example.com" }; + + MetadataGetFromUrlParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Files/Metadata/MetadataGetParamsTest.cs b/src/ImageKit.Tests/Models/Files/Metadata/MetadataGetParamsTest.cs new file mode 100644 index 00000000..d80a0a72 --- /dev/null +++ b/src/ImageKit.Tests/Models/Files/Metadata/MetadataGetParamsTest.cs @@ -0,0 +1,37 @@ +using System; +using ImageKit.Models.Files.Metadata; + +namespace ImageKit.Tests.Models.Files.Metadata; + +public class MetadataGetParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new MetadataGetParams { FileID = "fileId" }; + + string expectedFileID = "fileId"; + + Assert.Equal(expectedFileID, parameters.FileID); + } + + [Fact] + public void Url_Works() + { + MetadataGetParams parameters = new() { FileID = "fileId" }; + + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + + Assert.Equal(new Uri("https://api.imagekit.io/v1/files/fileId/metadata"), url); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new MetadataGetParams { FileID = "fileId" }; + + MetadataGetParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Files/UpdateFileRequestTest.cs b/src/ImageKit.Tests/Models/Files/UpdateFileRequestTest.cs new file mode 100644 index 00000000..dd12727e --- /dev/null +++ b/src/ImageKit.Tests/Models/Files/UpdateFileRequestTest.cs @@ -0,0 +1,1512 @@ +using System.Collections.Generic; +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Exceptions; +using ImageKit.Models; +using Files = ImageKit.Models.Files; + +namespace ImageKit.Tests.Models.Files; + +public class UpdateFileRequestTest : TestBase +{ + [Fact] + public void DetailsValidationWorks() + { + Files::UpdateFileRequest value = new Files::UpdateFileDetails() + { + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Extensions = + [ + new UnnamedSchemaWithArrayParent0RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }, + new UnnamedSchemaWithArrayParent0AutoTaggingExtension() + { + MaxTags = 5, + MinConfidence = 95, + Name = UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + }, + new UnnamedSchemaWithArrayParent0AIAutoDescription(), + new UnnamedSchemaWithArrayParent0AITasks( + [ + new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }, + new UnnamedSchemaWithArrayParent0AITasksTaskYesNo() + { + Instruction = "Is this a luxury or high-end fashion item?", + OnNo = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnUnknown = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnYes = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + }, + ] + ), + new SavedExtension("ext_abc123"), + ], + RemoveAITags = new(["string"]), + Tags = ["tag1", "tag2"], + WebhookUrl = "https://example.com", + }; + value.Validate(); + } + + [Fact] + public void ChangePublicationStatusValidationWorks() + { + Files::UpdateFileRequest value = new Files::ChangePublicationStatus() + { + Publish = new() { IsPublished = true, IncludeFileVersions = true }, + }; + value.Validate(); + } + + [Fact] + public void DetailsSerializationRoundtripWorks() + { + Files::UpdateFileRequest value = new Files::UpdateFileDetails() + { + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Extensions = + [ + new UnnamedSchemaWithArrayParent0RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }, + new UnnamedSchemaWithArrayParent0AutoTaggingExtension() + { + MaxTags = 5, + MinConfidence = 95, + Name = UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + }, + new UnnamedSchemaWithArrayParent0AIAutoDescription(), + new UnnamedSchemaWithArrayParent0AITasks( + [ + new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }, + new UnnamedSchemaWithArrayParent0AITasksTaskYesNo() + { + Instruction = "Is this a luxury or high-end fashion item?", + OnNo = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnUnknown = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnYes = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + }, + ] + ), + new SavedExtension("ext_abc123"), + ], + RemoveAITags = new(["string"]), + Tags = ["tag1", "tag2"], + WebhookUrl = "https://example.com", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void ChangePublicationStatusSerializationRoundtripWorks() + { + Files::UpdateFileRequest value = new Files::ChangePublicationStatus() + { + Publish = new() { IsPublished = true, IncludeFileVersions = true }, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class UpdateFileDetailsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Files::UpdateFileDetails + { + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Extensions = + [ + new UnnamedSchemaWithArrayParent0RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }, + new UnnamedSchemaWithArrayParent0AutoTaggingExtension() + { + MaxTags = 5, + MinConfidence = 95, + Name = UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + }, + new UnnamedSchemaWithArrayParent0AIAutoDescription(), + new UnnamedSchemaWithArrayParent0AITasks( + [ + new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }, + new UnnamedSchemaWithArrayParent0AITasksTaskYesNo() + { + Instruction = "Is this a luxury or high-end fashion item?", + OnNo = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnUnknown = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnYes = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + }, + ] + ), + new SavedExtension("ext_abc123"), + ], + RemoveAITags = new(["string"]), + Tags = ["tag1", "tag2"], + WebhookUrl = "https://example.com", + }; + + string expectedCustomCoordinates = "customCoordinates"; + Dictionary expectedCustomMetadata = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; + string expectedDescription = "description"; + List expectedExtensions = + [ + new UnnamedSchemaWithArrayParent0RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }, + new UnnamedSchemaWithArrayParent0AutoTaggingExtension() + { + MaxTags = 5, + MinConfidence = 95, + Name = UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + }, + new UnnamedSchemaWithArrayParent0AIAutoDescription(), + new UnnamedSchemaWithArrayParent0AITasks( + [ + new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }, + new UnnamedSchemaWithArrayParent0AITasksTaskYesNo() + { + Instruction = "Is this a luxury or high-end fashion item?", + OnNo = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnUnknown = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnYes = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + }, + ] + ), + new SavedExtension("ext_abc123"), + ]; + Files::RemoveAITags expectedRemoveAITags = new(["string"]); + List expectedTags = ["tag1", "tag2"]; + string expectedWebhookUrl = "https://example.com"; + + Assert.Equal(expectedCustomCoordinates, model.CustomCoordinates); + Assert.NotNull(model.CustomMetadata); + Assert.Equal(expectedCustomMetadata.Count, model.CustomMetadata.Count); + foreach (var item in expectedCustomMetadata) + { + Assert.True(model.CustomMetadata.TryGetValue(item.Key, out var value)); + + Assert.True(JsonElement.DeepEquals(value, model.CustomMetadata[item.Key])); + } + Assert.Equal(expectedDescription, model.Description); + Assert.NotNull(model.Extensions); + Assert.Equal(expectedExtensions.Count, model.Extensions.Count); + for (int i = 0; i < expectedExtensions.Count; i++) + { + Assert.Equal(expectedExtensions[i], model.Extensions[i]); + } + Assert.Equal(expectedRemoveAITags, model.RemoveAITags); + Assert.NotNull(model.Tags); + Assert.Equal(expectedTags.Count, model.Tags.Count); + for (int i = 0; i < expectedTags.Count; i++) + { + Assert.Equal(expectedTags[i], model.Tags[i]); + } + Assert.Equal(expectedWebhookUrl, model.WebhookUrl); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Files::UpdateFileDetails + { + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Extensions = + [ + new UnnamedSchemaWithArrayParent0RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }, + new UnnamedSchemaWithArrayParent0AutoTaggingExtension() + { + MaxTags = 5, + MinConfidence = 95, + Name = UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + }, + new UnnamedSchemaWithArrayParent0AIAutoDescription(), + new UnnamedSchemaWithArrayParent0AITasks( + [ + new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }, + new UnnamedSchemaWithArrayParent0AITasksTaskYesNo() + { + Instruction = "Is this a luxury or high-end fashion item?", + OnNo = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnUnknown = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnYes = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + }, + ] + ), + new SavedExtension("ext_abc123"), + ], + RemoveAITags = new(["string"]), + Tags = ["tag1", "tag2"], + WebhookUrl = "https://example.com", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Files::UpdateFileDetails + { + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Extensions = + [ + new UnnamedSchemaWithArrayParent0RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }, + new UnnamedSchemaWithArrayParent0AutoTaggingExtension() + { + MaxTags = 5, + MinConfidence = 95, + Name = UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + }, + new UnnamedSchemaWithArrayParent0AIAutoDescription(), + new UnnamedSchemaWithArrayParent0AITasks( + [ + new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }, + new UnnamedSchemaWithArrayParent0AITasksTaskYesNo() + { + Instruction = "Is this a luxury or high-end fashion item?", + OnNo = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnUnknown = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnYes = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + }, + ] + ), + new SavedExtension("ext_abc123"), + ], + RemoveAITags = new(["string"]), + Tags = ["tag1", "tag2"], + WebhookUrl = "https://example.com", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedCustomCoordinates = "customCoordinates"; + Dictionary expectedCustomMetadata = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; + string expectedDescription = "description"; + List expectedExtensions = + [ + new UnnamedSchemaWithArrayParent0RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }, + new UnnamedSchemaWithArrayParent0AutoTaggingExtension() + { + MaxTags = 5, + MinConfidence = 95, + Name = UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + }, + new UnnamedSchemaWithArrayParent0AIAutoDescription(), + new UnnamedSchemaWithArrayParent0AITasks( + [ + new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }, + new UnnamedSchemaWithArrayParent0AITasksTaskYesNo() + { + Instruction = "Is this a luxury or high-end fashion item?", + OnNo = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnUnknown = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnYes = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + }, + ] + ), + new SavedExtension("ext_abc123"), + ]; + Files::RemoveAITags expectedRemoveAITags = new(["string"]); + List expectedTags = ["tag1", "tag2"]; + string expectedWebhookUrl = "https://example.com"; + + Assert.Equal(expectedCustomCoordinates, deserialized.CustomCoordinates); + Assert.NotNull(deserialized.CustomMetadata); + Assert.Equal(expectedCustomMetadata.Count, deserialized.CustomMetadata.Count); + foreach (var item in expectedCustomMetadata) + { + Assert.True(deserialized.CustomMetadata.TryGetValue(item.Key, out var value)); + + Assert.True(JsonElement.DeepEquals(value, deserialized.CustomMetadata[item.Key])); + } + Assert.Equal(expectedDescription, deserialized.Description); + Assert.NotNull(deserialized.Extensions); + Assert.Equal(expectedExtensions.Count, deserialized.Extensions.Count); + for (int i = 0; i < expectedExtensions.Count; i++) + { + Assert.Equal(expectedExtensions[i], deserialized.Extensions[i]); + } + Assert.Equal(expectedRemoveAITags, deserialized.RemoveAITags); + Assert.NotNull(deserialized.Tags); + Assert.Equal(expectedTags.Count, deserialized.Tags.Count); + for (int i = 0; i < expectedTags.Count; i++) + { + Assert.Equal(expectedTags[i], deserialized.Tags[i]); + } + Assert.Equal(expectedWebhookUrl, deserialized.WebhookUrl); + } + + [Fact] + public void Validation_Works() + { + var model = new Files::UpdateFileDetails + { + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Extensions = + [ + new UnnamedSchemaWithArrayParent0RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }, + new UnnamedSchemaWithArrayParent0AutoTaggingExtension() + { + MaxTags = 5, + MinConfidence = 95, + Name = UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + }, + new UnnamedSchemaWithArrayParent0AIAutoDescription(), + new UnnamedSchemaWithArrayParent0AITasks( + [ + new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }, + new UnnamedSchemaWithArrayParent0AITasksTaskYesNo() + { + Instruction = "Is this a luxury or high-end fashion item?", + OnNo = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnUnknown = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnYes = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + }, + ] + ), + new SavedExtension("ext_abc123"), + ], + RemoveAITags = new(["string"]), + Tags = ["tag1", "tag2"], + WebhookUrl = "https://example.com", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Files::UpdateFileDetails + { + CustomCoordinates = "customCoordinates", + Tags = ["tag1", "tag2"], + }; + + Assert.Null(model.CustomMetadata); + Assert.False(model.RawData.ContainsKey("customMetadata")); + Assert.Null(model.Description); + Assert.False(model.RawData.ContainsKey("description")); + Assert.Null(model.Extensions); + Assert.False(model.RawData.ContainsKey("extensions")); + Assert.Null(model.RemoveAITags); + Assert.False(model.RawData.ContainsKey("removeAITags")); + Assert.Null(model.WebhookUrl); + Assert.False(model.RawData.ContainsKey("webhookUrl")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new Files::UpdateFileDetails + { + CustomCoordinates = "customCoordinates", + Tags = ["tag1", "tag2"], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new Files::UpdateFileDetails + { + CustomCoordinates = "customCoordinates", + Tags = ["tag1", "tag2"], + + // Null should be interpreted as omitted for these properties + CustomMetadata = null, + Description = null, + Extensions = null, + RemoveAITags = null, + WebhookUrl = null, + }; + + Assert.Null(model.CustomMetadata); + Assert.False(model.RawData.ContainsKey("customMetadata")); + Assert.Null(model.Description); + Assert.False(model.RawData.ContainsKey("description")); + Assert.Null(model.Extensions); + Assert.False(model.RawData.ContainsKey("extensions")); + Assert.Null(model.RemoveAITags); + Assert.False(model.RawData.ContainsKey("removeAITags")); + Assert.Null(model.WebhookUrl); + Assert.False(model.RawData.ContainsKey("webhookUrl")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new Files::UpdateFileDetails + { + CustomCoordinates = "customCoordinates", + Tags = ["tag1", "tag2"], + + // Null should be interpreted as omitted for these properties + CustomMetadata = null, + Description = null, + Extensions = null, + RemoveAITags = null, + WebhookUrl = null, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Files::UpdateFileDetails + { + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Extensions = + [ + new UnnamedSchemaWithArrayParent0RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }, + new UnnamedSchemaWithArrayParent0AutoTaggingExtension() + { + MaxTags = 5, + MinConfidence = 95, + Name = UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + }, + new UnnamedSchemaWithArrayParent0AIAutoDescription(), + new UnnamedSchemaWithArrayParent0AITasks( + [ + new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }, + new UnnamedSchemaWithArrayParent0AITasksTaskYesNo() + { + Instruction = "Is this a luxury or high-end fashion item?", + OnNo = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnUnknown = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnYes = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + }, + ] + ), + new SavedExtension("ext_abc123"), + ], + RemoveAITags = new(["string"]), + WebhookUrl = "https://example.com", + }; + + Assert.Null(model.CustomCoordinates); + Assert.False(model.RawData.ContainsKey("customCoordinates")); + Assert.Null(model.Tags); + Assert.False(model.RawData.ContainsKey("tags")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new Files::UpdateFileDetails + { + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Extensions = + [ + new UnnamedSchemaWithArrayParent0RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }, + new UnnamedSchemaWithArrayParent0AutoTaggingExtension() + { + MaxTags = 5, + MinConfidence = 95, + Name = UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + }, + new UnnamedSchemaWithArrayParent0AIAutoDescription(), + new UnnamedSchemaWithArrayParent0AITasks( + [ + new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }, + new UnnamedSchemaWithArrayParent0AITasksTaskYesNo() + { + Instruction = "Is this a luxury or high-end fashion item?", + OnNo = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnUnknown = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnYes = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + }, + ] + ), + new SavedExtension("ext_abc123"), + ], + RemoveAITags = new(["string"]), + WebhookUrl = "https://example.com", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new Files::UpdateFileDetails + { + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Extensions = + [ + new UnnamedSchemaWithArrayParent0RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }, + new UnnamedSchemaWithArrayParent0AutoTaggingExtension() + { + MaxTags = 5, + MinConfidence = 95, + Name = UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + }, + new UnnamedSchemaWithArrayParent0AIAutoDescription(), + new UnnamedSchemaWithArrayParent0AITasks( + [ + new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }, + new UnnamedSchemaWithArrayParent0AITasksTaskYesNo() + { + Instruction = "Is this a luxury or high-end fashion item?", + OnNo = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnUnknown = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnYes = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + }, + ] + ), + new SavedExtension("ext_abc123"), + ], + RemoveAITags = new(["string"]), + WebhookUrl = "https://example.com", + + CustomCoordinates = null, + Tags = null, + }; + + Assert.Null(model.CustomCoordinates); + Assert.True(model.RawData.ContainsKey("customCoordinates")); + Assert.Null(model.Tags); + Assert.True(model.RawData.ContainsKey("tags")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new Files::UpdateFileDetails + { + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Extensions = + [ + new UnnamedSchemaWithArrayParent0RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }, + new UnnamedSchemaWithArrayParent0AutoTaggingExtension() + { + MaxTags = 5, + MinConfidence = 95, + Name = UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + }, + new UnnamedSchemaWithArrayParent0AIAutoDescription(), + new UnnamedSchemaWithArrayParent0AITasks( + [ + new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }, + new UnnamedSchemaWithArrayParent0AITasksTaskYesNo() + { + Instruction = "Is this a luxury or high-end fashion item?", + OnNo = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnUnknown = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnYes = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + }, + ] + ), + new SavedExtension("ext_abc123"), + ], + RemoveAITags = new(["string"]), + WebhookUrl = "https://example.com", + + CustomCoordinates = null, + Tags = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Files::UpdateFileDetails + { + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Extensions = + [ + new UnnamedSchemaWithArrayParent0RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }, + new UnnamedSchemaWithArrayParent0AutoTaggingExtension() + { + MaxTags = 5, + MinConfidence = 95, + Name = UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + }, + new UnnamedSchemaWithArrayParent0AIAutoDescription(), + new UnnamedSchemaWithArrayParent0AITasks( + [ + new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }, + new UnnamedSchemaWithArrayParent0AITasksTaskYesNo() + { + Instruction = "Is this a luxury or high-end fashion item?", + OnNo = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnUnknown = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnYes = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + }, + ] + ), + new SavedExtension("ext_abc123"), + ], + RemoveAITags = new(["string"]), + Tags = ["tag1", "tag2"], + WebhookUrl = "https://example.com", + }; + + Files::UpdateFileDetails copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class RemoveAITagsTest : TestBase +{ + [Fact] + public void StringsValidationWorks() + { + Files::RemoveAITags value = new(["string"]); + value.Validate(); + } + + [Fact] + public void AllValidationWorks() + { + Files::RemoveAITags value = new Files::UnionMember1(); + value.Validate(); + } + + [Fact] + public void StringsSerializationRoundtripWorks() + { + Files::RemoveAITags value = new(["string"]); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void AllSerializationRoundtripWorks() + { + Files::RemoveAITags value = new Files::UnionMember1(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class UnionMember1Test : TestBase +{ + [Fact] + public void DefaultValidation_Works() + { + var constant = new Files::UnionMember1(); + constant.Validate(); + } + + [Fact] + public void ValidConstantValidation_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement("all"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(constant); + constant.Validate(); + } + + [Fact] + public void InvalidConstantValidationThrows_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(constant); + Assert.Throws(() => constant.Validate()); + } + + [Fact] + public void DefaultRoundtrip_Works() + { + var constant = new Files::UnionMember1(); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } + + [Fact] + public void ValidConstantRoundtrip_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement("all"), + ModelBase.SerializerOptions + ); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } + + [Fact] + public void InvalidConstantRoundtrip_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } +} + +public class ChangePublicationStatusTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Files::ChangePublicationStatus + { + Publish = new() { IsPublished = true, IncludeFileVersions = true }, + }; + + Files::Publish expectedPublish = new() { IsPublished = true, IncludeFileVersions = true }; + + Assert.Equal(expectedPublish, model.Publish); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Files::ChangePublicationStatus + { + Publish = new() { IsPublished = true, IncludeFileVersions = true }, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Files::ChangePublicationStatus + { + Publish = new() { IsPublished = true, IncludeFileVersions = true }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + Files::Publish expectedPublish = new() { IsPublished = true, IncludeFileVersions = true }; + + Assert.Equal(expectedPublish, deserialized.Publish); + } + + [Fact] + public void Validation_Works() + { + var model = new Files::ChangePublicationStatus + { + Publish = new() { IsPublished = true, IncludeFileVersions = true }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Files::ChangePublicationStatus { }; + + Assert.Null(model.Publish); + Assert.False(model.RawData.ContainsKey("publish")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new Files::ChangePublicationStatus { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new Files::ChangePublicationStatus + { + // Null should be interpreted as omitted for these properties + Publish = null, + }; + + Assert.Null(model.Publish); + Assert.False(model.RawData.ContainsKey("publish")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new Files::ChangePublicationStatus + { + // Null should be interpreted as omitted for these properties + Publish = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Files::ChangePublicationStatus + { + Publish = new() { IsPublished = true, IncludeFileVersions = true }, + }; + + Files::ChangePublicationStatus copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PublishTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Files::Publish { IsPublished = true, IncludeFileVersions = true }; + + bool expectedIsPublished = true; + bool expectedIncludeFileVersions = true; + + Assert.Equal(expectedIsPublished, model.IsPublished); + Assert.Equal(expectedIncludeFileVersions, model.IncludeFileVersions); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Files::Publish { IsPublished = true, IncludeFileVersions = true }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Files::Publish { IsPublished = true, IncludeFileVersions = true }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + bool expectedIsPublished = true; + bool expectedIncludeFileVersions = true; + + Assert.Equal(expectedIsPublished, deserialized.IsPublished); + Assert.Equal(expectedIncludeFileVersions, deserialized.IncludeFileVersions); + } + + [Fact] + public void Validation_Works() + { + var model = new Files::Publish { IsPublished = true, IncludeFileVersions = true }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Files::Publish { IsPublished = true }; + + Assert.Null(model.IncludeFileVersions); + Assert.False(model.RawData.ContainsKey("includeFileVersions")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new Files::Publish { IsPublished = true }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new Files::Publish + { + IsPublished = true, + + // Null should be interpreted as omitted for these properties + IncludeFileVersions = null, + }; + + Assert.Null(model.IncludeFileVersions); + Assert.False(model.RawData.ContainsKey("includeFileVersions")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new Files::Publish + { + IsPublished = true, + + // Null should be interpreted as omitted for these properties + IncludeFileVersions = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Files::Publish { IsPublished = true, IncludeFileVersions = true }; + + Files::Publish copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Files/Versions/VersionDeleteParamsTest.cs b/src/ImageKit.Tests/Models/Files/Versions/VersionDeleteParamsTest.cs new file mode 100644 index 00000000..105270a8 --- /dev/null +++ b/src/ImageKit.Tests/Models/Files/Versions/VersionDeleteParamsTest.cs @@ -0,0 +1,39 @@ +using System; +using ImageKit.Models.Files.Versions; + +namespace ImageKit.Tests.Models.Files.Versions; + +public class VersionDeleteParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new VersionDeleteParams { FileID = "fileId", VersionID = "versionId" }; + + string expectedFileID = "fileId"; + string expectedVersionID = "versionId"; + + Assert.Equal(expectedFileID, parameters.FileID); + Assert.Equal(expectedVersionID, parameters.VersionID); + } + + [Fact] + public void Url_Works() + { + VersionDeleteParams parameters = new() { FileID = "fileId", VersionID = "versionId" }; + + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + + Assert.Equal(new Uri("https://api.imagekit.io/v1/files/fileId/versions/versionId"), url); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new VersionDeleteParams { FileID = "fileId", VersionID = "versionId" }; + + VersionDeleteParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Files/Versions/VersionDeleteResponseTest.cs b/src/ImageKit.Tests/Models/Files/Versions/VersionDeleteResponseTest.cs new file mode 100644 index 00000000..88378f09 --- /dev/null +++ b/src/ImageKit.Tests/Models/Files/Versions/VersionDeleteResponseTest.cs @@ -0,0 +1,59 @@ +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Models.Files.Versions; + +namespace ImageKit.Tests.Models.Files.Versions; + +public class VersionDeleteResponseTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new VersionDeleteResponse { }; + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new VersionDeleteResponse { }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new VersionDeleteResponse { }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + } + + [Fact] + public void Validation_Works() + { + var model = new VersionDeleteResponse { }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new VersionDeleteResponse { }; + + VersionDeleteResponse copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Files/Versions/VersionGetParamsTest.cs b/src/ImageKit.Tests/Models/Files/Versions/VersionGetParamsTest.cs new file mode 100644 index 00000000..e189bc4c --- /dev/null +++ b/src/ImageKit.Tests/Models/Files/Versions/VersionGetParamsTest.cs @@ -0,0 +1,39 @@ +using System; +using ImageKit.Models.Files.Versions; + +namespace ImageKit.Tests.Models.Files.Versions; + +public class VersionGetParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new VersionGetParams { FileID = "fileId", VersionID = "versionId" }; + + string expectedFileID = "fileId"; + string expectedVersionID = "versionId"; + + Assert.Equal(expectedFileID, parameters.FileID); + Assert.Equal(expectedVersionID, parameters.VersionID); + } + + [Fact] + public void Url_Works() + { + VersionGetParams parameters = new() { FileID = "fileId", VersionID = "versionId" }; + + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + + Assert.Equal(new Uri("https://api.imagekit.io/v1/files/fileId/versions/versionId"), url); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new VersionGetParams { FileID = "fileId", VersionID = "versionId" }; + + VersionGetParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Files/Versions/VersionListParamsTest.cs b/src/ImageKit.Tests/Models/Files/Versions/VersionListParamsTest.cs new file mode 100644 index 00000000..c6826fb4 --- /dev/null +++ b/src/ImageKit.Tests/Models/Files/Versions/VersionListParamsTest.cs @@ -0,0 +1,37 @@ +using System; +using ImageKit.Models.Files.Versions; + +namespace ImageKit.Tests.Models.Files.Versions; + +public class VersionListParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new VersionListParams { FileID = "fileId" }; + + string expectedFileID = "fileId"; + + Assert.Equal(expectedFileID, parameters.FileID); + } + + [Fact] + public void Url_Works() + { + VersionListParams parameters = new() { FileID = "fileId" }; + + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + + Assert.Equal(new Uri("https://api.imagekit.io/v1/files/fileId/versions"), url); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new VersionListParams { FileID = "fileId" }; + + VersionListParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Files/Versions/VersionRestoreParamsTest.cs b/src/ImageKit.Tests/Models/Files/Versions/VersionRestoreParamsTest.cs new file mode 100644 index 00000000..a6b785d9 --- /dev/null +++ b/src/ImageKit.Tests/Models/Files/Versions/VersionRestoreParamsTest.cs @@ -0,0 +1,42 @@ +using System; +using ImageKit.Models.Files.Versions; + +namespace ImageKit.Tests.Models.Files.Versions; + +public class VersionRestoreParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new VersionRestoreParams { FileID = "fileId", VersionID = "versionId" }; + + string expectedFileID = "fileId"; + string expectedVersionID = "versionId"; + + Assert.Equal(expectedFileID, parameters.FileID); + Assert.Equal(expectedVersionID, parameters.VersionID); + } + + [Fact] + public void Url_Works() + { + VersionRestoreParams parameters = new() { FileID = "fileId", VersionID = "versionId" }; + + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + + Assert.Equal( + new Uri("https://api.imagekit.io/v1/files/fileId/versions/versionId/restore"), + url + ); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new VersionRestoreParams { FileID = "fileId", VersionID = "versionId" }; + + VersionRestoreParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Folders/FolderCopyParamsTest.cs b/src/ImageKit.Tests/Models/Folders/FolderCopyParamsTest.cs new file mode 100644 index 00000000..9027c155 --- /dev/null +++ b/src/ImageKit.Tests/Models/Folders/FolderCopyParamsTest.cs @@ -0,0 +1,84 @@ +using System; +using ImageKit.Models.Folders; + +namespace ImageKit.Tests.Models.Folders; + +public class FolderCopyParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new FolderCopyParams + { + DestinationPath = "/path/of/destination/folder", + SourceFolderPath = "/path/of/source/folder", + IncludeVersions = true, + }; + + string expectedDestinationPath = "/path/of/destination/folder"; + string expectedSourceFolderPath = "/path/of/source/folder"; + bool expectedIncludeVersions = true; + + Assert.Equal(expectedDestinationPath, parameters.DestinationPath); + Assert.Equal(expectedSourceFolderPath, parameters.SourceFolderPath); + Assert.Equal(expectedIncludeVersions, parameters.IncludeVersions); + } + + [Fact] + public void OptionalNonNullableParamsUnsetAreNotSet_Works() + { + var parameters = new FolderCopyParams + { + DestinationPath = "/path/of/destination/folder", + SourceFolderPath = "/path/of/source/folder", + }; + + Assert.Null(parameters.IncludeVersions); + Assert.False(parameters.RawBodyData.ContainsKey("includeVersions")); + } + + [Fact] + public void OptionalNonNullableParamsSetToNullAreNotSet_Works() + { + var parameters = new FolderCopyParams + { + DestinationPath = "/path/of/destination/folder", + SourceFolderPath = "/path/of/source/folder", + + // Null should be interpreted as omitted for these properties + IncludeVersions = null, + }; + + Assert.Null(parameters.IncludeVersions); + Assert.False(parameters.RawBodyData.ContainsKey("includeVersions")); + } + + [Fact] + public void Url_Works() + { + FolderCopyParams parameters = new() + { + DestinationPath = "/path/of/destination/folder", + SourceFolderPath = "/path/of/source/folder", + }; + + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + + Assert.Equal(new Uri("https://api.imagekit.io/v1/bulkJobs/copyFolder"), url); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new FolderCopyParams + { + DestinationPath = "/path/of/destination/folder", + SourceFolderPath = "/path/of/source/folder", + IncludeVersions = true, + }; + + FolderCopyParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Folders/FolderCopyResponseTest.cs b/src/ImageKit.Tests/Models/Folders/FolderCopyResponseTest.cs new file mode 100644 index 00000000..b2656bce --- /dev/null +++ b/src/ImageKit.Tests/Models/Folders/FolderCopyResponseTest.cs @@ -0,0 +1,67 @@ +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Models.Folders; + +namespace ImageKit.Tests.Models.Folders; + +public class FolderCopyResponseTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new FolderCopyResponse { JobID = "jobId" }; + + string expectedJobID = "jobId"; + + Assert.Equal(expectedJobID, model.JobID); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new FolderCopyResponse { JobID = "jobId" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new FolderCopyResponse { JobID = "jobId" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedJobID = "jobId"; + + Assert.Equal(expectedJobID, deserialized.JobID); + } + + [Fact] + public void Validation_Works() + { + var model = new FolderCopyResponse { JobID = "jobId" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new FolderCopyResponse { JobID = "jobId" }; + + FolderCopyResponse copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Folders/FolderCreateParamsTest.cs b/src/ImageKit.Tests/Models/Folders/FolderCreateParamsTest.cs new file mode 100644 index 00000000..ef6278aa --- /dev/null +++ b/src/ImageKit.Tests/Models/Folders/FolderCreateParamsTest.cs @@ -0,0 +1,51 @@ +using System; +using ImageKit.Models.Folders; + +namespace ImageKit.Tests.Models.Folders; + +public class FolderCreateParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new FolderCreateParams + { + FolderName = "summer", + ParentFolderPath = "/product/images/", + }; + + string expectedFolderName = "summer"; + string expectedParentFolderPath = "/product/images/"; + + Assert.Equal(expectedFolderName, parameters.FolderName); + Assert.Equal(expectedParentFolderPath, parameters.ParentFolderPath); + } + + [Fact] + public void Url_Works() + { + FolderCreateParams parameters = new() + { + FolderName = "summer", + ParentFolderPath = "/product/images/", + }; + + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + + Assert.Equal(new Uri("https://api.imagekit.io/v1/folder"), url); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new FolderCreateParams + { + FolderName = "summer", + ParentFolderPath = "/product/images/", + }; + + FolderCreateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Folders/FolderCreateResponseTest.cs b/src/ImageKit.Tests/Models/Folders/FolderCreateResponseTest.cs new file mode 100644 index 00000000..2eb390aa --- /dev/null +++ b/src/ImageKit.Tests/Models/Folders/FolderCreateResponseTest.cs @@ -0,0 +1,59 @@ +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Models.Folders; + +namespace ImageKit.Tests.Models.Folders; + +public class FolderCreateResponseTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new FolderCreateResponse { }; + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new FolderCreateResponse { }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new FolderCreateResponse { }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + } + + [Fact] + public void Validation_Works() + { + var model = new FolderCreateResponse { }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new FolderCreateResponse { }; + + FolderCreateResponse copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Folders/FolderDeleteParamsTest.cs b/src/ImageKit.Tests/Models/Folders/FolderDeleteParamsTest.cs new file mode 100644 index 00000000..ec79dff4 --- /dev/null +++ b/src/ImageKit.Tests/Models/Folders/FolderDeleteParamsTest.cs @@ -0,0 +1,37 @@ +using System; +using ImageKit.Models.Folders; + +namespace ImageKit.Tests.Models.Folders; + +public class FolderDeleteParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new FolderDeleteParams { FolderPath = "/folder/to/delete/" }; + + string expectedFolderPath = "/folder/to/delete/"; + + Assert.Equal(expectedFolderPath, parameters.FolderPath); + } + + [Fact] + public void Url_Works() + { + FolderDeleteParams parameters = new() { FolderPath = "/folder/to/delete/" }; + + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + + Assert.Equal(new Uri("https://api.imagekit.io/v1/folder"), url); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new FolderDeleteParams { FolderPath = "/folder/to/delete/" }; + + FolderDeleteParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Folders/FolderDeleteResponseTest.cs b/src/ImageKit.Tests/Models/Folders/FolderDeleteResponseTest.cs new file mode 100644 index 00000000..6a952f2d --- /dev/null +++ b/src/ImageKit.Tests/Models/Folders/FolderDeleteResponseTest.cs @@ -0,0 +1,59 @@ +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Models.Folders; + +namespace ImageKit.Tests.Models.Folders; + +public class FolderDeleteResponseTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new FolderDeleteResponse { }; + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new FolderDeleteResponse { }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new FolderDeleteResponse { }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + } + + [Fact] + public void Validation_Works() + { + var model = new FolderDeleteResponse { }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new FolderDeleteResponse { }; + + FolderDeleteResponse copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Folders/FolderMoveParamsTest.cs b/src/ImageKit.Tests/Models/Folders/FolderMoveParamsTest.cs new file mode 100644 index 00000000..453c9468 --- /dev/null +++ b/src/ImageKit.Tests/Models/Folders/FolderMoveParamsTest.cs @@ -0,0 +1,51 @@ +using System; +using ImageKit.Models.Folders; + +namespace ImageKit.Tests.Models.Folders; + +public class FolderMoveParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new FolderMoveParams + { + DestinationPath = "/path/of/destination/folder", + SourceFolderPath = "/path/of/source/folder", + }; + + string expectedDestinationPath = "/path/of/destination/folder"; + string expectedSourceFolderPath = "/path/of/source/folder"; + + Assert.Equal(expectedDestinationPath, parameters.DestinationPath); + Assert.Equal(expectedSourceFolderPath, parameters.SourceFolderPath); + } + + [Fact] + public void Url_Works() + { + FolderMoveParams parameters = new() + { + DestinationPath = "/path/of/destination/folder", + SourceFolderPath = "/path/of/source/folder", + }; + + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + + Assert.Equal(new Uri("https://api.imagekit.io/v1/bulkJobs/moveFolder"), url); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new FolderMoveParams + { + DestinationPath = "/path/of/destination/folder", + SourceFolderPath = "/path/of/source/folder", + }; + + FolderMoveParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Folders/FolderMoveResponseTest.cs b/src/ImageKit.Tests/Models/Folders/FolderMoveResponseTest.cs new file mode 100644 index 00000000..f65cdd5d --- /dev/null +++ b/src/ImageKit.Tests/Models/Folders/FolderMoveResponseTest.cs @@ -0,0 +1,67 @@ +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Models.Folders; + +namespace ImageKit.Tests.Models.Folders; + +public class FolderMoveResponseTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new FolderMoveResponse { JobID = "jobId" }; + + string expectedJobID = "jobId"; + + Assert.Equal(expectedJobID, model.JobID); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new FolderMoveResponse { JobID = "jobId" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new FolderMoveResponse { JobID = "jobId" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedJobID = "jobId"; + + Assert.Equal(expectedJobID, deserialized.JobID); + } + + [Fact] + public void Validation_Works() + { + var model = new FolderMoveResponse { JobID = "jobId" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new FolderMoveResponse { JobID = "jobId" }; + + FolderMoveResponse copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Folders/FolderRenameParamsTest.cs b/src/ImageKit.Tests/Models/Folders/FolderRenameParamsTest.cs new file mode 100644 index 00000000..f52fa209 --- /dev/null +++ b/src/ImageKit.Tests/Models/Folders/FolderRenameParamsTest.cs @@ -0,0 +1,84 @@ +using System; +using ImageKit.Models.Folders; + +namespace ImageKit.Tests.Models.Folders; + +public class FolderRenameParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new FolderRenameParams + { + FolderPath = "/path/of/folder", + NewFolderName = "new-folder-name", + PurgeCache = true, + }; + + string expectedFolderPath = "/path/of/folder"; + string expectedNewFolderName = "new-folder-name"; + bool expectedPurgeCache = true; + + Assert.Equal(expectedFolderPath, parameters.FolderPath); + Assert.Equal(expectedNewFolderName, parameters.NewFolderName); + Assert.Equal(expectedPurgeCache, parameters.PurgeCache); + } + + [Fact] + public void OptionalNonNullableParamsUnsetAreNotSet_Works() + { + var parameters = new FolderRenameParams + { + FolderPath = "/path/of/folder", + NewFolderName = "new-folder-name", + }; + + Assert.Null(parameters.PurgeCache); + Assert.False(parameters.RawBodyData.ContainsKey("purgeCache")); + } + + [Fact] + public void OptionalNonNullableParamsSetToNullAreNotSet_Works() + { + var parameters = new FolderRenameParams + { + FolderPath = "/path/of/folder", + NewFolderName = "new-folder-name", + + // Null should be interpreted as omitted for these properties + PurgeCache = null, + }; + + Assert.Null(parameters.PurgeCache); + Assert.False(parameters.RawBodyData.ContainsKey("purgeCache")); + } + + [Fact] + public void Url_Works() + { + FolderRenameParams parameters = new() + { + FolderPath = "/path/of/folder", + NewFolderName = "new-folder-name", + }; + + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + + Assert.Equal(new Uri("https://api.imagekit.io/v1/bulkJobs/renameFolder"), url); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new FolderRenameParams + { + FolderPath = "/path/of/folder", + NewFolderName = "new-folder-name", + PurgeCache = true, + }; + + FolderRenameParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Folders/FolderRenameResponseTest.cs b/src/ImageKit.Tests/Models/Folders/FolderRenameResponseTest.cs new file mode 100644 index 00000000..a1de9b35 --- /dev/null +++ b/src/ImageKit.Tests/Models/Folders/FolderRenameResponseTest.cs @@ -0,0 +1,67 @@ +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Models.Folders; + +namespace ImageKit.Tests.Models.Folders; + +public class FolderRenameResponseTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new FolderRenameResponse { JobID = "jobId" }; + + string expectedJobID = "jobId"; + + Assert.Equal(expectedJobID, model.JobID); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new FolderRenameResponse { JobID = "jobId" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new FolderRenameResponse { JobID = "jobId" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedJobID = "jobId"; + + Assert.Equal(expectedJobID, deserialized.JobID); + } + + [Fact] + public void Validation_Works() + { + var model = new FolderRenameResponse { JobID = "jobId" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new FolderRenameResponse { JobID = "jobId" }; + + FolderRenameResponse copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Folders/Job/JobGetParamsTest.cs b/src/ImageKit.Tests/Models/Folders/Job/JobGetParamsTest.cs new file mode 100644 index 00000000..110cb8b1 --- /dev/null +++ b/src/ImageKit.Tests/Models/Folders/Job/JobGetParamsTest.cs @@ -0,0 +1,37 @@ +using System; +using ImageKit.Models.Folders.Job; + +namespace ImageKit.Tests.Models.Folders.Job; + +public class JobGetParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new JobGetParams { JobID = "jobId" }; + + string expectedJobID = "jobId"; + + Assert.Equal(expectedJobID, parameters.JobID); + } + + [Fact] + public void Url_Works() + { + JobGetParams parameters = new() { JobID = "jobId" }; + + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + + Assert.Equal(new Uri("https://api.imagekit.io/v1/bulkJobs/jobId"), url); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new JobGetParams { JobID = "jobId" }; + + JobGetParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Folders/Job/JobGetResponseTest.cs b/src/ImageKit.Tests/Models/Folders/Job/JobGetResponseTest.cs new file mode 100644 index 00000000..90b968da --- /dev/null +++ b/src/ImageKit.Tests/Models/Folders/Job/JobGetResponseTest.cs @@ -0,0 +1,288 @@ +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Exceptions; +using ImageKit.Models.Folders.Job; + +namespace ImageKit.Tests.Models.Folders.Job; + +public class JobGetResponseTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new JobGetResponse + { + JobID = "5d5b1a9b4c8c4c0001f3e4a2", + PurgeRequestID = "purgeRequestId", + Status = Status.Completed, + Type = Type.CopyFolder, + }; + + string expectedJobID = "5d5b1a9b4c8c4c0001f3e4a2"; + string expectedPurgeRequestID = "purgeRequestId"; + ApiEnum expectedStatus = Status.Completed; + ApiEnum expectedType = Type.CopyFolder; + + Assert.Equal(expectedJobID, model.JobID); + Assert.Equal(expectedPurgeRequestID, model.PurgeRequestID); + Assert.Equal(expectedStatus, model.Status); + Assert.Equal(expectedType, model.Type); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new JobGetResponse + { + JobID = "5d5b1a9b4c8c4c0001f3e4a2", + PurgeRequestID = "purgeRequestId", + Status = Status.Completed, + Type = Type.CopyFolder, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new JobGetResponse + { + JobID = "5d5b1a9b4c8c4c0001f3e4a2", + PurgeRequestID = "purgeRequestId", + Status = Status.Completed, + Type = Type.CopyFolder, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedJobID = "5d5b1a9b4c8c4c0001f3e4a2"; + string expectedPurgeRequestID = "purgeRequestId"; + ApiEnum expectedStatus = Status.Completed; + ApiEnum expectedType = Type.CopyFolder; + + Assert.Equal(expectedJobID, deserialized.JobID); + Assert.Equal(expectedPurgeRequestID, deserialized.PurgeRequestID); + Assert.Equal(expectedStatus, deserialized.Status); + Assert.Equal(expectedType, deserialized.Type); + } + + [Fact] + public void Validation_Works() + { + var model = new JobGetResponse + { + JobID = "5d5b1a9b4c8c4c0001f3e4a2", + PurgeRequestID = "purgeRequestId", + Status = Status.Completed, + Type = Type.CopyFolder, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new JobGetResponse { }; + + Assert.Null(model.JobID); + Assert.False(model.RawData.ContainsKey("jobId")); + Assert.Null(model.PurgeRequestID); + Assert.False(model.RawData.ContainsKey("purgeRequestId")); + Assert.Null(model.Status); + Assert.False(model.RawData.ContainsKey("status")); + Assert.Null(model.Type); + Assert.False(model.RawData.ContainsKey("type")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new JobGetResponse { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new JobGetResponse + { + // Null should be interpreted as omitted for these properties + JobID = null, + PurgeRequestID = null, + Status = null, + Type = null, + }; + + Assert.Null(model.JobID); + Assert.False(model.RawData.ContainsKey("jobId")); + Assert.Null(model.PurgeRequestID); + Assert.False(model.RawData.ContainsKey("purgeRequestId")); + Assert.Null(model.Status); + Assert.False(model.RawData.ContainsKey("status")); + Assert.Null(model.Type); + Assert.False(model.RawData.ContainsKey("type")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new JobGetResponse + { + // Null should be interpreted as omitted for these properties + JobID = null, + PurgeRequestID = null, + Status = null, + Type = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new JobGetResponse + { + JobID = "5d5b1a9b4c8c4c0001f3e4a2", + PurgeRequestID = "purgeRequestId", + Status = Status.Completed, + Type = Type.CopyFolder, + }; + + JobGetResponse copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class StatusTest : TestBase +{ + [Theory] + [InlineData(Status.Pending)] + [InlineData(Status.Completed)] + public void Validation_Works(Status rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(Status.Pending)] + [InlineData(Status.Completed)] + public void SerializationRoundtrip_Works(Status rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class TypeTest : TestBase +{ + [Theory] + [InlineData(Type.CopyFolder)] + [InlineData(Type.MoveFolder)] + [InlineData(Type.RenameFolder)] + public void Validation_Works(Type rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(Type.CopyFolder)] + [InlineData(Type.MoveFolder)] + [InlineData(Type.RenameFolder)] + public void SerializationRoundtrip_Works(Type rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} diff --git a/src/ImageKit.Tests/Models/GetImageAttributesOptionsTest.cs b/src/ImageKit.Tests/Models/GetImageAttributesOptionsTest.cs new file mode 100644 index 00000000..f38eddfe --- /dev/null +++ b/src/ImageKit.Tests/Models/GetImageAttributesOptionsTest.cs @@ -0,0 +1,1172 @@ +using System.Collections.Generic; +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Models; + +namespace ImageKit.Tests.Models; + +public class GetImageAttributesOptionsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GetImageAttributesOptions + { + Src = "/my-image.jpg", + UrlEndpoint = "https://ik.imagekit.io/demo", + ExpiresIn = 0, + QueryParameters = new Dictionary() { { "foo", "string" } }, + Signed = true, + Transformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ], + TransformationPosition = TransformationPosition.Path, + DeviceBreakpoints = [640, 750, 828, 1080, 1200, 1920, 2048, 3840], + ImageBreakpoints = [16, 32, 48, 64, 96, 128, 256, 384], + Sizes = "(min-width: 768px) 50vw, 100vw", + Width = 400, + }; + + string expectedSrc = "/my-image.jpg"; + string expectedUrlEndpoint = "https://ik.imagekit.io/demo"; + double expectedExpiresIn = 0; + Dictionary expectedQueryParameters = new() { { "foo", "string" } }; + bool expectedSigned = true; + List expectedTransformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ]; + ApiEnum expectedTransformationPosition = + TransformationPosition.Path; + List expectedDeviceBreakpoints = [640, 750, 828, 1080, 1200, 1920, 2048, 3840]; + List expectedImageBreakpoints = [16, 32, 48, 64, 96, 128, 256, 384]; + string expectedSizes = "(min-width: 768px) 50vw, 100vw"; + double expectedWidth = 400; + + Assert.Equal(expectedSrc, model.Src); + Assert.Equal(expectedUrlEndpoint, model.UrlEndpoint); + Assert.Equal(expectedExpiresIn, model.ExpiresIn); + Assert.NotNull(model.QueryParameters); + Assert.Equal(expectedQueryParameters.Count, model.QueryParameters.Count); + foreach (var item in expectedQueryParameters) + { + Assert.True(model.QueryParameters.TryGetValue(item.Key, out var value)); + + Assert.Equal(value, model.QueryParameters[item.Key]); + } + Assert.Equal(expectedSigned, model.Signed); + Assert.NotNull(model.Transformation); + Assert.Equal(expectedTransformation.Count, model.Transformation.Count); + for (int i = 0; i < expectedTransformation.Count; i++) + { + Assert.Equal(expectedTransformation[i], model.Transformation[i]); + } + Assert.Equal(expectedTransformationPosition, model.TransformationPosition); + Assert.NotNull(model.DeviceBreakpoints); + Assert.Equal(expectedDeviceBreakpoints.Count, model.DeviceBreakpoints.Count); + for (int i = 0; i < expectedDeviceBreakpoints.Count; i++) + { + Assert.Equal(expectedDeviceBreakpoints[i], model.DeviceBreakpoints[i]); + } + Assert.NotNull(model.ImageBreakpoints); + Assert.Equal(expectedImageBreakpoints.Count, model.ImageBreakpoints.Count); + for (int i = 0; i < expectedImageBreakpoints.Count; i++) + { + Assert.Equal(expectedImageBreakpoints[i], model.ImageBreakpoints[i]); + } + Assert.Equal(expectedSizes, model.Sizes); + Assert.Equal(expectedWidth, model.Width); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new GetImageAttributesOptions + { + Src = "/my-image.jpg", + UrlEndpoint = "https://ik.imagekit.io/demo", + ExpiresIn = 0, + QueryParameters = new Dictionary() { { "foo", "string" } }, + Signed = true, + Transformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ], + TransformationPosition = TransformationPosition.Path, + DeviceBreakpoints = [640, 750, 828, 1080, 1200, 1920, 2048, 3840], + ImageBreakpoints = [16, 32, 48, 64, 96, 128, 256, 384], + Sizes = "(min-width: 768px) 50vw, 100vw", + Width = 400, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new GetImageAttributesOptions + { + Src = "/my-image.jpg", + UrlEndpoint = "https://ik.imagekit.io/demo", + ExpiresIn = 0, + QueryParameters = new Dictionary() { { "foo", "string" } }, + Signed = true, + Transformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ], + TransformationPosition = TransformationPosition.Path, + DeviceBreakpoints = [640, 750, 828, 1080, 1200, 1920, 2048, 3840], + ImageBreakpoints = [16, 32, 48, 64, 96, 128, 256, 384], + Sizes = "(min-width: 768px) 50vw, 100vw", + Width = 400, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedSrc = "/my-image.jpg"; + string expectedUrlEndpoint = "https://ik.imagekit.io/demo"; + double expectedExpiresIn = 0; + Dictionary expectedQueryParameters = new() { { "foo", "string" } }; + bool expectedSigned = true; + List expectedTransformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ]; + ApiEnum expectedTransformationPosition = + TransformationPosition.Path; + List expectedDeviceBreakpoints = [640, 750, 828, 1080, 1200, 1920, 2048, 3840]; + List expectedImageBreakpoints = [16, 32, 48, 64, 96, 128, 256, 384]; + string expectedSizes = "(min-width: 768px) 50vw, 100vw"; + double expectedWidth = 400; + + Assert.Equal(expectedSrc, deserialized.Src); + Assert.Equal(expectedUrlEndpoint, deserialized.UrlEndpoint); + Assert.Equal(expectedExpiresIn, deserialized.ExpiresIn); + Assert.NotNull(deserialized.QueryParameters); + Assert.Equal(expectedQueryParameters.Count, deserialized.QueryParameters.Count); + foreach (var item in expectedQueryParameters) + { + Assert.True(deserialized.QueryParameters.TryGetValue(item.Key, out var value)); + + Assert.Equal(value, deserialized.QueryParameters[item.Key]); + } + Assert.Equal(expectedSigned, deserialized.Signed); + Assert.NotNull(deserialized.Transformation); + Assert.Equal(expectedTransformation.Count, deserialized.Transformation.Count); + for (int i = 0; i < expectedTransformation.Count; i++) + { + Assert.Equal(expectedTransformation[i], deserialized.Transformation[i]); + } + Assert.Equal(expectedTransformationPosition, deserialized.TransformationPosition); + Assert.NotNull(deserialized.DeviceBreakpoints); + Assert.Equal(expectedDeviceBreakpoints.Count, deserialized.DeviceBreakpoints.Count); + for (int i = 0; i < expectedDeviceBreakpoints.Count; i++) + { + Assert.Equal(expectedDeviceBreakpoints[i], deserialized.DeviceBreakpoints[i]); + } + Assert.NotNull(deserialized.ImageBreakpoints); + Assert.Equal(expectedImageBreakpoints.Count, deserialized.ImageBreakpoints.Count); + for (int i = 0; i < expectedImageBreakpoints.Count; i++) + { + Assert.Equal(expectedImageBreakpoints[i], deserialized.ImageBreakpoints[i]); + } + Assert.Equal(expectedSizes, deserialized.Sizes); + Assert.Equal(expectedWidth, deserialized.Width); + } + + [Fact] + public void Validation_Works() + { + var model = new GetImageAttributesOptions + { + Src = "/my-image.jpg", + UrlEndpoint = "https://ik.imagekit.io/demo", + ExpiresIn = 0, + QueryParameters = new Dictionary() { { "foo", "string" } }, + Signed = true, + Transformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ], + TransformationPosition = TransformationPosition.Path, + DeviceBreakpoints = [640, 750, 828, 1080, 1200, 1920, 2048, 3840], + ImageBreakpoints = [16, 32, 48, 64, 96, 128, 256, 384], + Sizes = "(min-width: 768px) 50vw, 100vw", + Width = 400, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new GetImageAttributesOptions + { + Src = "/my-image.jpg", + UrlEndpoint = "https://ik.imagekit.io/demo", + }; + + Assert.Null(model.ExpiresIn); + Assert.False(model.RawData.ContainsKey("expiresIn")); + Assert.Null(model.QueryParameters); + Assert.False(model.RawData.ContainsKey("queryParameters")); + Assert.Null(model.Signed); + Assert.False(model.RawData.ContainsKey("signed")); + Assert.Null(model.Transformation); + Assert.False(model.RawData.ContainsKey("transformation")); + Assert.Null(model.TransformationPosition); + Assert.False(model.RawData.ContainsKey("transformationPosition")); + Assert.Null(model.DeviceBreakpoints); + Assert.False(model.RawData.ContainsKey("deviceBreakpoints")); + Assert.Null(model.ImageBreakpoints); + Assert.False(model.RawData.ContainsKey("imageBreakpoints")); + Assert.Null(model.Sizes); + Assert.False(model.RawData.ContainsKey("sizes")); + Assert.Null(model.Width); + Assert.False(model.RawData.ContainsKey("width")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new GetImageAttributesOptions + { + Src = "/my-image.jpg", + UrlEndpoint = "https://ik.imagekit.io/demo", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new GetImageAttributesOptions + { + Src = "/my-image.jpg", + UrlEndpoint = "https://ik.imagekit.io/demo", + + // Null should be interpreted as omitted for these properties + ExpiresIn = null, + QueryParameters = null, + Signed = null, + Transformation = null, + TransformationPosition = null, + DeviceBreakpoints = null, + ImageBreakpoints = null, + Sizes = null, + Width = null, + }; + + Assert.Null(model.ExpiresIn); + Assert.False(model.RawData.ContainsKey("expiresIn")); + Assert.Null(model.QueryParameters); + Assert.False(model.RawData.ContainsKey("queryParameters")); + Assert.Null(model.Signed); + Assert.False(model.RawData.ContainsKey("signed")); + Assert.Null(model.Transformation); + Assert.False(model.RawData.ContainsKey("transformation")); + Assert.Null(model.TransformationPosition); + Assert.False(model.RawData.ContainsKey("transformationPosition")); + Assert.Null(model.DeviceBreakpoints); + Assert.False(model.RawData.ContainsKey("deviceBreakpoints")); + Assert.Null(model.ImageBreakpoints); + Assert.False(model.RawData.ContainsKey("imageBreakpoints")); + Assert.Null(model.Sizes); + Assert.False(model.RawData.ContainsKey("sizes")); + Assert.Null(model.Width); + Assert.False(model.RawData.ContainsKey("width")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new GetImageAttributesOptions + { + Src = "/my-image.jpg", + UrlEndpoint = "https://ik.imagekit.io/demo", + + // Null should be interpreted as omitted for these properties + ExpiresIn = null, + QueryParameters = null, + Signed = null, + Transformation = null, + TransformationPosition = null, + DeviceBreakpoints = null, + ImageBreakpoints = null, + Sizes = null, + Width = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GetImageAttributesOptions + { + Src = "/my-image.jpg", + UrlEndpoint = "https://ik.imagekit.io/demo", + ExpiresIn = 0, + QueryParameters = new Dictionary() { { "foo", "string" } }, + Signed = true, + Transformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ], + TransformationPosition = TransformationPosition.Path, + DeviceBreakpoints = [640, 750, 828, 1080, 1200, 1920, 2048, 3840], + ImageBreakpoints = [16, 32, 48, 64, 96, 128, 256, 384], + Sizes = "(min-width: 768px) 50vw, 100vw", + Width = 400, + }; + + GetImageAttributesOptions copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class IntersectionMember1Test : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new IntersectionMember1 + { + DeviceBreakpoints = [640, 750, 828, 1080, 1200, 1920, 2048, 3840], + ImageBreakpoints = [16, 32, 48, 64, 96, 128, 256, 384], + Sizes = "(min-width: 768px) 50vw, 100vw", + Width = 400, + }; + + List expectedDeviceBreakpoints = [640, 750, 828, 1080, 1200, 1920, 2048, 3840]; + List expectedImageBreakpoints = [16, 32, 48, 64, 96, 128, 256, 384]; + string expectedSizes = "(min-width: 768px) 50vw, 100vw"; + double expectedWidth = 400; + + Assert.NotNull(model.DeviceBreakpoints); + Assert.Equal(expectedDeviceBreakpoints.Count, model.DeviceBreakpoints.Count); + for (int i = 0; i < expectedDeviceBreakpoints.Count; i++) + { + Assert.Equal(expectedDeviceBreakpoints[i], model.DeviceBreakpoints[i]); + } + Assert.NotNull(model.ImageBreakpoints); + Assert.Equal(expectedImageBreakpoints.Count, model.ImageBreakpoints.Count); + for (int i = 0; i < expectedImageBreakpoints.Count; i++) + { + Assert.Equal(expectedImageBreakpoints[i], model.ImageBreakpoints[i]); + } + Assert.Equal(expectedSizes, model.Sizes); + Assert.Equal(expectedWidth, model.Width); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new IntersectionMember1 + { + DeviceBreakpoints = [640, 750, 828, 1080, 1200, 1920, 2048, 3840], + ImageBreakpoints = [16, 32, 48, 64, 96, 128, 256, 384], + Sizes = "(min-width: 768px) 50vw, 100vw", + Width = 400, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new IntersectionMember1 + { + DeviceBreakpoints = [640, 750, 828, 1080, 1200, 1920, 2048, 3840], + ImageBreakpoints = [16, 32, 48, 64, 96, 128, 256, 384], + Sizes = "(min-width: 768px) 50vw, 100vw", + Width = 400, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedDeviceBreakpoints = [640, 750, 828, 1080, 1200, 1920, 2048, 3840]; + List expectedImageBreakpoints = [16, 32, 48, 64, 96, 128, 256, 384]; + string expectedSizes = "(min-width: 768px) 50vw, 100vw"; + double expectedWidth = 400; + + Assert.NotNull(deserialized.DeviceBreakpoints); + Assert.Equal(expectedDeviceBreakpoints.Count, deserialized.DeviceBreakpoints.Count); + for (int i = 0; i < expectedDeviceBreakpoints.Count; i++) + { + Assert.Equal(expectedDeviceBreakpoints[i], deserialized.DeviceBreakpoints[i]); + } + Assert.NotNull(deserialized.ImageBreakpoints); + Assert.Equal(expectedImageBreakpoints.Count, deserialized.ImageBreakpoints.Count); + for (int i = 0; i < expectedImageBreakpoints.Count; i++) + { + Assert.Equal(expectedImageBreakpoints[i], deserialized.ImageBreakpoints[i]); + } + Assert.Equal(expectedSizes, deserialized.Sizes); + Assert.Equal(expectedWidth, deserialized.Width); + } + + [Fact] + public void Validation_Works() + { + var model = new IntersectionMember1 + { + DeviceBreakpoints = [640, 750, 828, 1080, 1200, 1920, 2048, 3840], + ImageBreakpoints = [16, 32, 48, 64, 96, 128, 256, 384], + Sizes = "(min-width: 768px) 50vw, 100vw", + Width = 400, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new IntersectionMember1 { }; + + Assert.Null(model.DeviceBreakpoints); + Assert.False(model.RawData.ContainsKey("deviceBreakpoints")); + Assert.Null(model.ImageBreakpoints); + Assert.False(model.RawData.ContainsKey("imageBreakpoints")); + Assert.Null(model.Sizes); + Assert.False(model.RawData.ContainsKey("sizes")); + Assert.Null(model.Width); + Assert.False(model.RawData.ContainsKey("width")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new IntersectionMember1 { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new IntersectionMember1 + { + // Null should be interpreted as omitted for these properties + DeviceBreakpoints = null, + ImageBreakpoints = null, + Sizes = null, + Width = null, + }; + + Assert.Null(model.DeviceBreakpoints); + Assert.False(model.RawData.ContainsKey("deviceBreakpoints")); + Assert.Null(model.ImageBreakpoints); + Assert.False(model.RawData.ContainsKey("imageBreakpoints")); + Assert.Null(model.Sizes); + Assert.False(model.RawData.ContainsKey("sizes")); + Assert.Null(model.Width); + Assert.False(model.RawData.ContainsKey("width")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new IntersectionMember1 + { + // Null should be interpreted as omitted for these properties + DeviceBreakpoints = null, + ImageBreakpoints = null, + Sizes = null, + Width = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new IntersectionMember1 + { + DeviceBreakpoints = [640, 750, 828, 1080, 1200, 1920, 2048, 3840], + ImageBreakpoints = [16, 32, 48, 64, 96, 128, 256, 384], + Sizes = "(min-width: 768px) 50vw, 100vw", + Width = 400, + }; + + IntersectionMember1 copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/ImageKit.Tests/Models/ImageOverlayTest.cs b/src/ImageKit.Tests/Models/ImageOverlayTest.cs new file mode 100644 index 00000000..06c31fcf --- /dev/null +++ b/src/ImageKit.Tests/Models/ImageOverlayTest.cs @@ -0,0 +1,1834 @@ +using System.Collections.Generic; +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Exceptions; +using ImageKit.Models; + +namespace ImageKit.Tests.Models; + +public class ImageOverlayTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ImageOverlay + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Input = "input", + Encoding = Encoding.Auto, + Transformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ], + }; + + ApiEnum expectedLayerMode = LayerMode.Multiply; + OverlayPosition expectedPosition = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }; + OverlayTiming expectedTiming = new() + { + Duration = 0, + End = 0, + Start = 0, + }; + string expectedInput = "input"; + JsonElement expectedType = JsonSerializer.SerializeToElement("image"); + ApiEnum expectedEncoding = Encoding.Auto; + List expectedTransformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ]; + + Assert.Equal(expectedLayerMode, model.LayerMode); + Assert.Equal(expectedPosition, model.Position); + Assert.Equal(expectedTiming, model.Timing); + Assert.Equal(expectedInput, model.Input); + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + Assert.Equal(expectedEncoding, model.Encoding); + Assert.NotNull(model.Transformation); + Assert.Equal(expectedTransformation.Count, model.Transformation.Count); + for (int i = 0; i < expectedTransformation.Count; i++) + { + Assert.Equal(expectedTransformation[i], model.Transformation[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ImageOverlay + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Input = "input", + Encoding = Encoding.Auto, + Transformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new ImageOverlay + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Input = "input", + Encoding = Encoding.Auto, + Transformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum expectedLayerMode = LayerMode.Multiply; + OverlayPosition expectedPosition = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }; + OverlayTiming expectedTiming = new() + { + Duration = 0, + End = 0, + Start = 0, + }; + string expectedInput = "input"; + JsonElement expectedType = JsonSerializer.SerializeToElement("image"); + ApiEnum expectedEncoding = Encoding.Auto; + List expectedTransformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ]; + + Assert.Equal(expectedLayerMode, deserialized.LayerMode); + Assert.Equal(expectedPosition, deserialized.Position); + Assert.Equal(expectedTiming, deserialized.Timing); + Assert.Equal(expectedInput, deserialized.Input); + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + Assert.Equal(expectedEncoding, deserialized.Encoding); + Assert.NotNull(deserialized.Transformation); + Assert.Equal(expectedTransformation.Count, deserialized.Transformation.Count); + for (int i = 0; i < expectedTransformation.Count; i++) + { + Assert.Equal(expectedTransformation[i], deserialized.Transformation[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new ImageOverlay + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Input = "input", + Encoding = Encoding.Auto, + Transformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ImageOverlay { Input = "input" }; + + Assert.Null(model.LayerMode); + Assert.False(model.RawData.ContainsKey("layerMode")); + Assert.Null(model.Position); + Assert.False(model.RawData.ContainsKey("position")); + Assert.Null(model.Timing); + Assert.False(model.RawData.ContainsKey("timing")); + Assert.Null(model.Encoding); + Assert.False(model.RawData.ContainsKey("encoding")); + Assert.Null(model.Transformation); + Assert.False(model.RawData.ContainsKey("transformation")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new ImageOverlay { Input = "input" }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new ImageOverlay + { + Input = "input", + + // Null should be interpreted as omitted for these properties + LayerMode = null, + Position = null, + Timing = null, + Encoding = null, + Transformation = null, + }; + + Assert.Null(model.LayerMode); + Assert.False(model.RawData.ContainsKey("layerMode")); + Assert.Null(model.Position); + Assert.False(model.RawData.ContainsKey("position")); + Assert.Null(model.Timing); + Assert.False(model.RawData.ContainsKey("timing")); + Assert.Null(model.Encoding); + Assert.False(model.RawData.ContainsKey("encoding")); + Assert.Null(model.Transformation); + Assert.False(model.RawData.ContainsKey("transformation")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new ImageOverlay + { + Input = "input", + + // Null should be interpreted as omitted for these properties + LayerMode = null, + Position = null, + Timing = null, + Encoding = null, + Transformation = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ImageOverlay + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Input = "input", + Encoding = Encoding.Auto, + Transformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ], + }; + + ImageOverlay copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ImageOverlayIntersectionMember1Test : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ImageOverlayIntersectionMember1 + { + Input = "input", + Encoding = Encoding.Auto, + Transformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ], + }; + + string expectedInput = "input"; + JsonElement expectedType = JsonSerializer.SerializeToElement("image"); + ApiEnum expectedEncoding = Encoding.Auto; + List expectedTransformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ]; + + Assert.Equal(expectedInput, model.Input); + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + Assert.Equal(expectedEncoding, model.Encoding); + Assert.NotNull(model.Transformation); + Assert.Equal(expectedTransformation.Count, model.Transformation.Count); + for (int i = 0; i < expectedTransformation.Count; i++) + { + Assert.Equal(expectedTransformation[i], model.Transformation[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ImageOverlayIntersectionMember1 + { + Input = "input", + Encoding = Encoding.Auto, + Transformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new ImageOverlayIntersectionMember1 + { + Input = "input", + Encoding = Encoding.Auto, + Transformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedInput = "input"; + JsonElement expectedType = JsonSerializer.SerializeToElement("image"); + ApiEnum expectedEncoding = Encoding.Auto; + List expectedTransformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ]; + + Assert.Equal(expectedInput, deserialized.Input); + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + Assert.Equal(expectedEncoding, deserialized.Encoding); + Assert.NotNull(deserialized.Transformation); + Assert.Equal(expectedTransformation.Count, deserialized.Transformation.Count); + for (int i = 0; i < expectedTransformation.Count; i++) + { + Assert.Equal(expectedTransformation[i], deserialized.Transformation[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new ImageOverlayIntersectionMember1 + { + Input = "input", + Encoding = Encoding.Auto, + Transformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ImageOverlayIntersectionMember1 { Input = "input" }; + + Assert.Null(model.Encoding); + Assert.False(model.RawData.ContainsKey("encoding")); + Assert.Null(model.Transformation); + Assert.False(model.RawData.ContainsKey("transformation")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new ImageOverlayIntersectionMember1 { Input = "input" }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new ImageOverlayIntersectionMember1 + { + Input = "input", + + // Null should be interpreted as omitted for these properties + Encoding = null, + Transformation = null, + }; + + Assert.Null(model.Encoding); + Assert.False(model.RawData.ContainsKey("encoding")); + Assert.Null(model.Transformation); + Assert.False(model.RawData.ContainsKey("transformation")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new ImageOverlayIntersectionMember1 + { + Input = "input", + + // Null should be interpreted as omitted for these properties + Encoding = null, + Transformation = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ImageOverlayIntersectionMember1 + { + Input = "input", + Encoding = Encoding.Auto, + Transformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ], + }; + + ImageOverlayIntersectionMember1 copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class EncodingTest : TestBase +{ + [Theory] + [InlineData(Encoding.Auto)] + [InlineData(Encoding.Plain)] + [InlineData(Encoding.Base64)] + public void Validation_Works(Encoding rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(Encoding.Auto)] + [InlineData(Encoding.Plain)] + [InlineData(Encoding.Base64)] + public void SerializationRoundtrip_Works(Encoding rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} diff --git a/src/ImageKit.Tests/Models/OverlayPositionTest.cs b/src/ImageKit.Tests/Models/OverlayPositionTest.cs new file mode 100644 index 00000000..f38eb42b --- /dev/null +++ b/src/ImageKit.Tests/Models/OverlayPositionTest.cs @@ -0,0 +1,301 @@ +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Exceptions; +using ImageKit.Models; + +namespace ImageKit.Tests.Models; + +public class OverlayPositionTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new OverlayPosition + { + Focus = Focus.Center, + X = 0, + Y = 0, + }; + + ApiEnum expectedFocus = Focus.Center; + X expectedX = 0; + Y expectedY = 0; + + Assert.Equal(expectedFocus, model.Focus); + Assert.Equal(expectedX, model.X); + Assert.Equal(expectedY, model.Y); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new OverlayPosition + { + Focus = Focus.Center, + X = 0, + Y = 0, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new OverlayPosition + { + Focus = Focus.Center, + X = 0, + Y = 0, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum expectedFocus = Focus.Center; + X expectedX = 0; + Y expectedY = 0; + + Assert.Equal(expectedFocus, deserialized.Focus); + Assert.Equal(expectedX, deserialized.X); + Assert.Equal(expectedY, deserialized.Y); + } + + [Fact] + public void Validation_Works() + { + var model = new OverlayPosition + { + Focus = Focus.Center, + X = 0, + Y = 0, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new OverlayPosition { }; + + Assert.Null(model.Focus); + Assert.False(model.RawData.ContainsKey("focus")); + Assert.Null(model.X); + Assert.False(model.RawData.ContainsKey("x")); + Assert.Null(model.Y); + Assert.False(model.RawData.ContainsKey("y")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new OverlayPosition { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new OverlayPosition + { + // Null should be interpreted as omitted for these properties + Focus = null, + X = null, + Y = null, + }; + + Assert.Null(model.Focus); + Assert.False(model.RawData.ContainsKey("focus")); + Assert.Null(model.X); + Assert.False(model.RawData.ContainsKey("x")); + Assert.Null(model.Y); + Assert.False(model.RawData.ContainsKey("y")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new OverlayPosition + { + // Null should be interpreted as omitted for these properties + Focus = null, + X = null, + Y = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new OverlayPosition + { + Focus = Focus.Center, + X = 0, + Y = 0, + }; + + OverlayPosition copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class FocusTest : TestBase +{ + [Theory] + [InlineData(Focus.Center)] + [InlineData(Focus.Top)] + [InlineData(Focus.Left)] + [InlineData(Focus.Bottom)] + [InlineData(Focus.Right)] + [InlineData(Focus.TopLeft)] + [InlineData(Focus.TopRight)] + [InlineData(Focus.BottomLeft)] + [InlineData(Focus.BottomRight)] + public void Validation_Works(Focus rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(Focus.Center)] + [InlineData(Focus.Top)] + [InlineData(Focus.Left)] + [InlineData(Focus.Bottom)] + [InlineData(Focus.Right)] + [InlineData(Focus.TopLeft)] + [InlineData(Focus.TopRight)] + [InlineData(Focus.BottomLeft)] + [InlineData(Focus.BottomRight)] + public void SerializationRoundtrip_Works(Focus rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class XTest : TestBase +{ + [Fact] + public void DoubleValidationWorks() + { + X value = 0; + value.Validate(); + } + + [Fact] + public void StringValidationWorks() + { + X value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + X value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + X value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class YTest : TestBase +{ + [Fact] + public void DoubleValidationWorks() + { + Y value = 0; + value.Validate(); + } + + [Fact] + public void StringValidationWorks() + { + Y value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + Y value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + Y value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} diff --git a/src/ImageKit.Tests/Models/OverlayTest.cs b/src/ImageKit.Tests/Models/OverlayTest.cs new file mode 100644 index 00000000..76d92332 --- /dev/null +++ b/src/ImageKit.Tests/Models/OverlayTest.cs @@ -0,0 +1,748 @@ +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Models; + +namespace ImageKit.Tests.Models; + +public class OverlayTest : TestBase +{ + [Fact] + public void TextValidationWorks() + { + Overlay value = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }; + value.Validate(); + } + + [Fact] + public void ImageValidationWorks() + { + Overlay value = new ImageOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Input = "input", + Encoding = Encoding.Auto, + Transformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ], + }; + value.Validate(); + } + + [Fact] + public void VideoValidationWorks() + { + Overlay value = new VideoOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Input = "input", + Encoding = VideoOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ], + }; + value.Validate(); + } + + [Fact] + public void SubtitleValidationWorks() + { + Overlay value = new SubtitleOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Input = "input", + Encoding = SubtitleOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Background = "background", + Color = "color", + FontFamily = "fontFamily", + FontOutline = "fontOutline", + FontShadow = "fontShadow", + FontSize = 0, + Typography = Typography.B, + }, + ], + }; + value.Validate(); + } + + [Fact] + public void SolidColorValidationWorks() + { + Overlay value = new SolidColorOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Color = "color", + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Gradient = new UnionMember0(), + Height = 0, + Radius = 0, + Width = 0, + }, + ], + }; + value.Validate(); + } + + [Fact] + public void TextSerializationRoundtripWorks() + { + Overlay value = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void ImageSerializationRoundtripWorks() + { + Overlay value = new ImageOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Input = "input", + Encoding = Encoding.Auto, + Transformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ], + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void VideoSerializationRoundtripWorks() + { + Overlay value = new VideoOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Input = "input", + Encoding = VideoOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ], + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void SubtitleSerializationRoundtripWorks() + { + Overlay value = new SubtitleOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Input = "input", + Encoding = SubtitleOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Background = "background", + Color = "color", + FontFamily = "fontFamily", + FontOutline = "fontOutline", + FontShadow = "fontShadow", + FontSize = 0, + Typography = Typography.B, + }, + ], + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void SolidColorSerializationRoundtripWorks() + { + Overlay value = new SolidColorOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Color = "color", + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Gradient = new UnionMember0(), + Height = 0, + Radius = 0, + Width = 0, + }, + ], + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} diff --git a/src/ImageKit.Tests/Models/OverlayTimingTest.cs b/src/ImageKit.Tests/Models/OverlayTimingTest.cs new file mode 100644 index 00000000..07c05f9b --- /dev/null +++ b/src/ImageKit.Tests/Models/OverlayTimingTest.cs @@ -0,0 +1,271 @@ +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Models; + +namespace ImageKit.Tests.Models; + +public class OverlayTimingTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new OverlayTiming + { + Duration = 0, + End = 0, + Start = 0, + }; + + Duration expectedDuration = 0; + End expectedEnd = 0; + Start expectedStart = 0; + + Assert.Equal(expectedDuration, model.Duration); + Assert.Equal(expectedEnd, model.End); + Assert.Equal(expectedStart, model.Start); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new OverlayTiming + { + Duration = 0, + End = 0, + Start = 0, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new OverlayTiming + { + Duration = 0, + End = 0, + Start = 0, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + Duration expectedDuration = 0; + End expectedEnd = 0; + Start expectedStart = 0; + + Assert.Equal(expectedDuration, deserialized.Duration); + Assert.Equal(expectedEnd, deserialized.End); + Assert.Equal(expectedStart, deserialized.Start); + } + + [Fact] + public void Validation_Works() + { + var model = new OverlayTiming + { + Duration = 0, + End = 0, + Start = 0, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new OverlayTiming { }; + + Assert.Null(model.Duration); + Assert.False(model.RawData.ContainsKey("duration")); + Assert.Null(model.End); + Assert.False(model.RawData.ContainsKey("end")); + Assert.Null(model.Start); + Assert.False(model.RawData.ContainsKey("start")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new OverlayTiming { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new OverlayTiming + { + // Null should be interpreted as omitted for these properties + Duration = null, + End = null, + Start = null, + }; + + Assert.Null(model.Duration); + Assert.False(model.RawData.ContainsKey("duration")); + Assert.Null(model.End); + Assert.False(model.RawData.ContainsKey("end")); + Assert.Null(model.Start); + Assert.False(model.RawData.ContainsKey("start")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new OverlayTiming + { + // Null should be interpreted as omitted for these properties + Duration = null, + End = null, + Start = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new OverlayTiming + { + Duration = 0, + End = 0, + Start = 0, + }; + + OverlayTiming copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class DurationTest : TestBase +{ + [Fact] + public void DoubleValidationWorks() + { + Duration value = 0; + value.Validate(); + } + + [Fact] + public void StringValidationWorks() + { + Duration value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + Duration value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + Duration value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class EndTest : TestBase +{ + [Fact] + public void DoubleValidationWorks() + { + End value = 0; + value.Validate(); + } + + [Fact] + public void StringValidationWorks() + { + End value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + End value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + End value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class StartTest : TestBase +{ + [Fact] + public void DoubleValidationWorks() + { + Start value = 0; + value.Validate(); + } + + [Fact] + public void StringValidationWorks() + { + Start value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + Start value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + Start value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} diff --git a/src/ImageKit.Tests/Models/ResponsiveImageAttributesTest.cs b/src/ImageKit.Tests/Models/ResponsiveImageAttributesTest.cs new file mode 100644 index 00000000..8d983592 --- /dev/null +++ b/src/ImageKit.Tests/Models/ResponsiveImageAttributesTest.cs @@ -0,0 +1,180 @@ +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Models; + +namespace ImageKit.Tests.Models; + +public class ResponsiveImageAttributesTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ResponsiveImageAttributes + { + Src = "https://ik.imagekit.io/demo/image.jpg?tr=w-3840", + Sizes = "100vw", + SrcSet = + "https://ik.imagekit.io/demo/image.jpg?tr=w-640 640w, https://ik.imagekit.io/demo/image.jpg?tr=w-1080 1080w, https://ik.imagekit.io/demo/image.jpg?tr=w-1920 1920w", + Width = 400, + }; + + string expectedSrc = "https://ik.imagekit.io/demo/image.jpg?tr=w-3840"; + string expectedSizes = "100vw"; + string expectedSrcSet = + "https://ik.imagekit.io/demo/image.jpg?tr=w-640 640w, https://ik.imagekit.io/demo/image.jpg?tr=w-1080 1080w, https://ik.imagekit.io/demo/image.jpg?tr=w-1920 1920w"; + double expectedWidth = 400; + + Assert.Equal(expectedSrc, model.Src); + Assert.Equal(expectedSizes, model.Sizes); + Assert.Equal(expectedSrcSet, model.SrcSet); + Assert.Equal(expectedWidth, model.Width); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ResponsiveImageAttributes + { + Src = "https://ik.imagekit.io/demo/image.jpg?tr=w-3840", + Sizes = "100vw", + SrcSet = + "https://ik.imagekit.io/demo/image.jpg?tr=w-640 640w, https://ik.imagekit.io/demo/image.jpg?tr=w-1080 1080w, https://ik.imagekit.io/demo/image.jpg?tr=w-1920 1920w", + Width = 400, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new ResponsiveImageAttributes + { + Src = "https://ik.imagekit.io/demo/image.jpg?tr=w-3840", + Sizes = "100vw", + SrcSet = + "https://ik.imagekit.io/demo/image.jpg?tr=w-640 640w, https://ik.imagekit.io/demo/image.jpg?tr=w-1080 1080w, https://ik.imagekit.io/demo/image.jpg?tr=w-1920 1920w", + Width = 400, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedSrc = "https://ik.imagekit.io/demo/image.jpg?tr=w-3840"; + string expectedSizes = "100vw"; + string expectedSrcSet = + "https://ik.imagekit.io/demo/image.jpg?tr=w-640 640w, https://ik.imagekit.io/demo/image.jpg?tr=w-1080 1080w, https://ik.imagekit.io/demo/image.jpg?tr=w-1920 1920w"; + double expectedWidth = 400; + + Assert.Equal(expectedSrc, deserialized.Src); + Assert.Equal(expectedSizes, deserialized.Sizes); + Assert.Equal(expectedSrcSet, deserialized.SrcSet); + Assert.Equal(expectedWidth, deserialized.Width); + } + + [Fact] + public void Validation_Works() + { + var model = new ResponsiveImageAttributes + { + Src = "https://ik.imagekit.io/demo/image.jpg?tr=w-3840", + Sizes = "100vw", + SrcSet = + "https://ik.imagekit.io/demo/image.jpg?tr=w-640 640w, https://ik.imagekit.io/demo/image.jpg?tr=w-1080 1080w, https://ik.imagekit.io/demo/image.jpg?tr=w-1920 1920w", + Width = 400, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ResponsiveImageAttributes + { + Src = "https://ik.imagekit.io/demo/image.jpg?tr=w-3840", + }; + + Assert.Null(model.Sizes); + Assert.False(model.RawData.ContainsKey("sizes")); + Assert.Null(model.SrcSet); + Assert.False(model.RawData.ContainsKey("srcSet")); + Assert.Null(model.Width); + Assert.False(model.RawData.ContainsKey("width")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new ResponsiveImageAttributes + { + Src = "https://ik.imagekit.io/demo/image.jpg?tr=w-3840", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new ResponsiveImageAttributes + { + Src = "https://ik.imagekit.io/demo/image.jpg?tr=w-3840", + + // Null should be interpreted as omitted for these properties + Sizes = null, + SrcSet = null, + Width = null, + }; + + Assert.Null(model.Sizes); + Assert.False(model.RawData.ContainsKey("sizes")); + Assert.Null(model.SrcSet); + Assert.False(model.RawData.ContainsKey("srcSet")); + Assert.Null(model.Width); + Assert.False(model.RawData.ContainsKey("width")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new ResponsiveImageAttributes + { + Src = "https://ik.imagekit.io/demo/image.jpg?tr=w-3840", + + // Null should be interpreted as omitted for these properties + Sizes = null, + SrcSet = null, + Width = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ResponsiveImageAttributes + { + Src = "https://ik.imagekit.io/demo/image.jpg?tr=w-3840", + Sizes = "100vw", + SrcSet = + "https://ik.imagekit.io/demo/image.jpg?tr=w-640 640w, https://ik.imagekit.io/demo/image.jpg?tr=w-1080 1080w, https://ik.imagekit.io/demo/image.jpg?tr=w-1920 1920w", + Width = 400, + }; + + ResponsiveImageAttributes copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionCreateParamsTest.cs b/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionCreateParamsTest.cs new file mode 100644 index 00000000..168e5dad --- /dev/null +++ b/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionCreateParamsTest.cs @@ -0,0 +1,94 @@ +using System; +using ImageKit.Models; +using ImageKit.Models.SavedExtensions; + +namespace ImageKit.Tests.Models.SavedExtensions; + +public class SavedExtensionCreateParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new SavedExtensionCreateParams + { + Config = new RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }, + Description = "Analyzes vehicle images for type, condition, and quality assessment", + Name = "Car Quality Analysis", + }; + + ExtensionConfig expectedConfig = new RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }; + string expectedDescription = + "Analyzes vehicle images for type, condition, and quality assessment"; + string expectedName = "Car Quality Analysis"; + + Assert.Equal(expectedConfig, parameters.Config); + Assert.Equal(expectedDescription, parameters.Description); + Assert.Equal(expectedName, parameters.Name); + } + + [Fact] + public void Url_Works() + { + SavedExtensionCreateParams parameters = new() + { + Config = new RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }, + Description = "Analyzes vehicle images for type, condition, and quality assessment", + Name = "Car Quality Analysis", + }; + + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + + Assert.Equal(new Uri("https://api.imagekit.io/v1/saved-extensions"), url); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new SavedExtensionCreateParams + { + Config = new RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }, + Description = "Analyzes vehicle images for type, condition, and quality assessment", + Name = "Car Quality Analysis", + }; + + SavedExtensionCreateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionDeleteParamsTest.cs b/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionDeleteParamsTest.cs new file mode 100644 index 00000000..8c6831cd --- /dev/null +++ b/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionDeleteParamsTest.cs @@ -0,0 +1,37 @@ +using System; +using ImageKit.Models.SavedExtensions; + +namespace ImageKit.Tests.Models.SavedExtensions; + +public class SavedExtensionDeleteParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new SavedExtensionDeleteParams { ID = "id" }; + + string expectedID = "id"; + + Assert.Equal(expectedID, parameters.ID); + } + + [Fact] + public void Url_Works() + { + SavedExtensionDeleteParams parameters = new() { ID = "id" }; + + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + + Assert.Equal(new Uri("https://api.imagekit.io/v1/saved-extensions/id"), url); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new SavedExtensionDeleteParams { ID = "id" }; + + SavedExtensionDeleteParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionGetParamsTest.cs b/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionGetParamsTest.cs new file mode 100644 index 00000000..016a46cc --- /dev/null +++ b/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionGetParamsTest.cs @@ -0,0 +1,37 @@ +using System; +using ImageKit.Models.SavedExtensions; + +namespace ImageKit.Tests.Models.SavedExtensions; + +public class SavedExtensionGetParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new SavedExtensionGetParams { ID = "id" }; + + string expectedID = "id"; + + Assert.Equal(expectedID, parameters.ID); + } + + [Fact] + public void Url_Works() + { + SavedExtensionGetParams parameters = new() { ID = "id" }; + + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + + Assert.Equal(new Uri("https://api.imagekit.io/v1/saved-extensions/id"), url); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new SavedExtensionGetParams { ID = "id" }; + + SavedExtensionGetParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionListParamsTest.cs b/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionListParamsTest.cs new file mode 100644 index 00000000..26d90cac --- /dev/null +++ b/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionListParamsTest.cs @@ -0,0 +1 @@ +namespace ImageKit.Tests.Models.SavedExtensions; diff --git a/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionUpdateParamsTest.cs b/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionUpdateParamsTest.cs new file mode 100644 index 00000000..1a4fb0ee --- /dev/null +++ b/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionUpdateParamsTest.cs @@ -0,0 +1,117 @@ +using System; +using ImageKit.Models; +using ImageKit.Models.SavedExtensions; + +namespace ImageKit.Tests.Models.SavedExtensions; + +public class SavedExtensionUpdateParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new SavedExtensionUpdateParams + { + ID = "id", + Config = new RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }, + Description = "x", + Name = "x", + }; + + string expectedID = "id"; + ExtensionConfig expectedConfig = new RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }; + string expectedDescription = "x"; + string expectedName = "x"; + + Assert.Equal(expectedID, parameters.ID); + Assert.Equal(expectedConfig, parameters.Config); + Assert.Equal(expectedDescription, parameters.Description); + Assert.Equal(expectedName, parameters.Name); + } + + [Fact] + public void OptionalNonNullableParamsUnsetAreNotSet_Works() + { + var parameters = new SavedExtensionUpdateParams { ID = "id" }; + + Assert.Null(parameters.Config); + Assert.False(parameters.RawBodyData.ContainsKey("config")); + Assert.Null(parameters.Description); + Assert.False(parameters.RawBodyData.ContainsKey("description")); + Assert.Null(parameters.Name); + Assert.False(parameters.RawBodyData.ContainsKey("name")); + } + + [Fact] + public void OptionalNonNullableParamsSetToNullAreNotSet_Works() + { + var parameters = new SavedExtensionUpdateParams + { + ID = "id", + + // Null should be interpreted as omitted for these properties + Config = null, + Description = null, + Name = null, + }; + + Assert.Null(parameters.Config); + Assert.False(parameters.RawBodyData.ContainsKey("config")); + Assert.Null(parameters.Description); + Assert.False(parameters.RawBodyData.ContainsKey("description")); + Assert.Null(parameters.Name); + Assert.False(parameters.RawBodyData.ContainsKey("name")); + } + + [Fact] + public void Url_Works() + { + SavedExtensionUpdateParams parameters = new() { ID = "id" }; + + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + + Assert.Equal(new Uri("https://api.imagekit.io/v1/saved-extensions/id"), url); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new SavedExtensionUpdateParams + { + ID = "id", + Config = new RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }, + Description = "x", + Name = "x", + }; + + SavedExtensionUpdateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/ImageKit.Tests/Models/SharedSavedExtensionTest.cs b/src/ImageKit.Tests/Models/SharedSavedExtensionTest.cs new file mode 100644 index 00000000..fde971c5 --- /dev/null +++ b/src/ImageKit.Tests/Models/SharedSavedExtensionTest.cs @@ -0,0 +1,265 @@ +using System; +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Models; + +namespace ImageKit.Tests.Models; + +public class SharedSavedExtensionTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new SharedSavedExtension + { + ID = "ext_abc123", + Config = new RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Description = "Analyzes vehicle images for type, condition, and quality assessment", + Name = "Car Quality Analysis", + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + string expectedID = "ext_abc123"; + ExtensionConfig expectedConfig = new RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }; + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + string expectedDescription = + "Analyzes vehicle images for type, condition, and quality assessment"; + string expectedName = "Car Quality Analysis"; + DateTimeOffset expectedUpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedConfig, model.Config); + Assert.Equal(expectedCreatedAt, model.CreatedAt); + Assert.Equal(expectedDescription, model.Description); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedUpdatedAt, model.UpdatedAt); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new SharedSavedExtension + { + ID = "ext_abc123", + Config = new RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Description = "Analyzes vehicle images for type, condition, and quality assessment", + Name = "Car Quality Analysis", + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new SharedSavedExtension + { + ID = "ext_abc123", + Config = new RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Description = "Analyzes vehicle images for type, condition, and quality assessment", + Name = "Car Quality Analysis", + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "ext_abc123"; + ExtensionConfig expectedConfig = new RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }; + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + string expectedDescription = + "Analyzes vehicle images for type, condition, and quality assessment"; + string expectedName = "Car Quality Analysis"; + DateTimeOffset expectedUpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedConfig, deserialized.Config); + Assert.Equal(expectedCreatedAt, deserialized.CreatedAt); + Assert.Equal(expectedDescription, deserialized.Description); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedUpdatedAt, deserialized.UpdatedAt); + } + + [Fact] + public void Validation_Works() + { + var model = new SharedSavedExtension + { + ID = "ext_abc123", + Config = new RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Description = "Analyzes vehicle images for type, condition, and quality assessment", + Name = "Car Quality Analysis", + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new SharedSavedExtension { }; + + Assert.Null(model.ID); + Assert.False(model.RawData.ContainsKey("id")); + Assert.Null(model.Config); + Assert.False(model.RawData.ContainsKey("config")); + Assert.Null(model.CreatedAt); + Assert.False(model.RawData.ContainsKey("createdAt")); + Assert.Null(model.Description); + Assert.False(model.RawData.ContainsKey("description")); + Assert.Null(model.Name); + Assert.False(model.RawData.ContainsKey("name")); + Assert.Null(model.UpdatedAt); + Assert.False(model.RawData.ContainsKey("updatedAt")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new SharedSavedExtension { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new SharedSavedExtension + { + // Null should be interpreted as omitted for these properties + ID = null, + Config = null, + CreatedAt = null, + Description = null, + Name = null, + UpdatedAt = null, + }; + + Assert.Null(model.ID); + Assert.False(model.RawData.ContainsKey("id")); + Assert.Null(model.Config); + Assert.False(model.RawData.ContainsKey("config")); + Assert.Null(model.CreatedAt); + Assert.False(model.RawData.ContainsKey("createdAt")); + Assert.Null(model.Description); + Assert.False(model.RawData.ContainsKey("description")); + Assert.Null(model.Name); + Assert.False(model.RawData.ContainsKey("name")); + Assert.Null(model.UpdatedAt); + Assert.False(model.RawData.ContainsKey("updatedAt")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new SharedSavedExtension + { + // Null should be interpreted as omitted for these properties + ID = null, + Config = null, + CreatedAt = null, + Description = null, + Name = null, + UpdatedAt = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new SharedSavedExtension + { + ID = "ext_abc123", + Config = new RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Description = "Analyzes vehicle images for type, condition, and quality assessment", + Name = "Car Quality Analysis", + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + SharedSavedExtension copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/ImageKit.Tests/Models/SolidColorOverlayTest.cs b/src/ImageKit.Tests/Models/SolidColorOverlayTest.cs new file mode 100644 index 00000000..7b9aa0bf --- /dev/null +++ b/src/ImageKit.Tests/Models/SolidColorOverlayTest.cs @@ -0,0 +1,567 @@ +using System.Collections.Generic; +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Models; + +namespace ImageKit.Tests.Models; + +public class SolidColorOverlayTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new SolidColorOverlay + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Color = "color", + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Gradient = new UnionMember0(), + Height = 0, + Radius = 0, + Width = 0, + }, + ], + }; + + ApiEnum expectedLayerMode = LayerMode.Multiply; + OverlayPosition expectedPosition = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }; + OverlayTiming expectedTiming = new() + { + Duration = 0, + End = 0, + Start = 0, + }; + string expectedColor = "color"; + JsonElement expectedType = JsonSerializer.SerializeToElement("solidColor"); + List expectedTransformation = + [ + new() + { + Alpha = 1, + Background = "background", + Gradient = new UnionMember0(), + Height = 0, + Radius = 0, + Width = 0, + }, + ]; + + Assert.Equal(expectedLayerMode, model.LayerMode); + Assert.Equal(expectedPosition, model.Position); + Assert.Equal(expectedTiming, model.Timing); + Assert.Equal(expectedColor, model.Color); + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + Assert.NotNull(model.Transformation); + Assert.Equal(expectedTransformation.Count, model.Transformation.Count); + for (int i = 0; i < expectedTransformation.Count; i++) + { + Assert.Equal(expectedTransformation[i], model.Transformation[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new SolidColorOverlay + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Color = "color", + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Gradient = new UnionMember0(), + Height = 0, + Radius = 0, + Width = 0, + }, + ], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new SolidColorOverlay + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Color = "color", + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Gradient = new UnionMember0(), + Height = 0, + Radius = 0, + Width = 0, + }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum expectedLayerMode = LayerMode.Multiply; + OverlayPosition expectedPosition = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }; + OverlayTiming expectedTiming = new() + { + Duration = 0, + End = 0, + Start = 0, + }; + string expectedColor = "color"; + JsonElement expectedType = JsonSerializer.SerializeToElement("solidColor"); + List expectedTransformation = + [ + new() + { + Alpha = 1, + Background = "background", + Gradient = new UnionMember0(), + Height = 0, + Radius = 0, + Width = 0, + }, + ]; + + Assert.Equal(expectedLayerMode, deserialized.LayerMode); + Assert.Equal(expectedPosition, deserialized.Position); + Assert.Equal(expectedTiming, deserialized.Timing); + Assert.Equal(expectedColor, deserialized.Color); + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + Assert.NotNull(deserialized.Transformation); + Assert.Equal(expectedTransformation.Count, deserialized.Transformation.Count); + for (int i = 0; i < expectedTransformation.Count; i++) + { + Assert.Equal(expectedTransformation[i], deserialized.Transformation[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new SolidColorOverlay + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Color = "color", + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Gradient = new UnionMember0(), + Height = 0, + Radius = 0, + Width = 0, + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new SolidColorOverlay { Color = "color" }; + + Assert.Null(model.LayerMode); + Assert.False(model.RawData.ContainsKey("layerMode")); + Assert.Null(model.Position); + Assert.False(model.RawData.ContainsKey("position")); + Assert.Null(model.Timing); + Assert.False(model.RawData.ContainsKey("timing")); + Assert.Null(model.Transformation); + Assert.False(model.RawData.ContainsKey("transformation")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new SolidColorOverlay { Color = "color" }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new SolidColorOverlay + { + Color = "color", + + // Null should be interpreted as omitted for these properties + LayerMode = null, + Position = null, + Timing = null, + Transformation = null, + }; + + Assert.Null(model.LayerMode); + Assert.False(model.RawData.ContainsKey("layerMode")); + Assert.Null(model.Position); + Assert.False(model.RawData.ContainsKey("position")); + Assert.Null(model.Timing); + Assert.False(model.RawData.ContainsKey("timing")); + Assert.Null(model.Transformation); + Assert.False(model.RawData.ContainsKey("transformation")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new SolidColorOverlay + { + Color = "color", + + // Null should be interpreted as omitted for these properties + LayerMode = null, + Position = null, + Timing = null, + Transformation = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new SolidColorOverlay + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Color = "color", + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Gradient = new UnionMember0(), + Height = 0, + Radius = 0, + Width = 0, + }, + ], + }; + + SolidColorOverlay copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class SolidColorOverlayIntersectionMember1Test : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new SolidColorOverlayIntersectionMember1 + { + Color = "color", + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Gradient = new UnionMember0(), + Height = 0, + Radius = 0, + Width = 0, + }, + ], + }; + + string expectedColor = "color"; + JsonElement expectedType = JsonSerializer.SerializeToElement("solidColor"); + List expectedTransformation = + [ + new() + { + Alpha = 1, + Background = "background", + Gradient = new UnionMember0(), + Height = 0, + Radius = 0, + Width = 0, + }, + ]; + + Assert.Equal(expectedColor, model.Color); + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + Assert.NotNull(model.Transformation); + Assert.Equal(expectedTransformation.Count, model.Transformation.Count); + for (int i = 0; i < expectedTransformation.Count; i++) + { + Assert.Equal(expectedTransformation[i], model.Transformation[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new SolidColorOverlayIntersectionMember1 + { + Color = "color", + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Gradient = new UnionMember0(), + Height = 0, + Radius = 0, + Width = 0, + }, + ], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new SolidColorOverlayIntersectionMember1 + { + Color = "color", + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Gradient = new UnionMember0(), + Height = 0, + Radius = 0, + Width = 0, + }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedColor = "color"; + JsonElement expectedType = JsonSerializer.SerializeToElement("solidColor"); + List expectedTransformation = + [ + new() + { + Alpha = 1, + Background = "background", + Gradient = new UnionMember0(), + Height = 0, + Radius = 0, + Width = 0, + }, + ]; + + Assert.Equal(expectedColor, deserialized.Color); + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + Assert.NotNull(deserialized.Transformation); + Assert.Equal(expectedTransformation.Count, deserialized.Transformation.Count); + for (int i = 0; i < expectedTransformation.Count; i++) + { + Assert.Equal(expectedTransformation[i], deserialized.Transformation[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new SolidColorOverlayIntersectionMember1 + { + Color = "color", + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Gradient = new UnionMember0(), + Height = 0, + Radius = 0, + Width = 0, + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new SolidColorOverlayIntersectionMember1 { Color = "color" }; + + Assert.Null(model.Transformation); + Assert.False(model.RawData.ContainsKey("transformation")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new SolidColorOverlayIntersectionMember1 { Color = "color" }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new SolidColorOverlayIntersectionMember1 + { + Color = "color", + + // Null should be interpreted as omitted for these properties + Transformation = null, + }; + + Assert.Null(model.Transformation); + Assert.False(model.RawData.ContainsKey("transformation")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new SolidColorOverlayIntersectionMember1 + { + Color = "color", + + // Null should be interpreted as omitted for these properties + Transformation = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new SolidColorOverlayIntersectionMember1 + { + Color = "color", + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Gradient = new UnionMember0(), + Height = 0, + Radius = 0, + Width = 0, + }, + ], + }; + + SolidColorOverlayIntersectionMember1 copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/ImageKit.Tests/Models/SolidColorOverlayTransformationTest.cs b/src/ImageKit.Tests/Models/SolidColorOverlayTransformationTest.cs new file mode 100644 index 00000000..c67cfb17 --- /dev/null +++ b/src/ImageKit.Tests/Models/SolidColorOverlayTransformationTest.cs @@ -0,0 +1,529 @@ +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Exceptions; +using ImageKit.Models; + +namespace ImageKit.Tests.Models; + +public class SolidColorOverlayTransformationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new SolidColorOverlayTransformation + { + Alpha = 1, + Background = "background", + Gradient = new UnionMember0(), + Height = 0, + Radius = 0, + Width = 0, + }; + + double expectedAlpha = 1; + string expectedBackground = "background"; + Gradient expectedGradient = new UnionMember0(); + Height expectedHeight = 0; + Radius expectedRadius = 0; + Width expectedWidth = 0; + + Assert.Equal(expectedAlpha, model.Alpha); + Assert.Equal(expectedBackground, model.Background); + Assert.Equal(expectedGradient, model.Gradient); + Assert.Equal(expectedHeight, model.Height); + Assert.Equal(expectedRadius, model.Radius); + Assert.Equal(expectedWidth, model.Width); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new SolidColorOverlayTransformation + { + Alpha = 1, + Background = "background", + Gradient = new UnionMember0(), + Height = 0, + Radius = 0, + Width = 0, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new SolidColorOverlayTransformation + { + Alpha = 1, + Background = "background", + Gradient = new UnionMember0(), + Height = 0, + Radius = 0, + Width = 0, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + double expectedAlpha = 1; + string expectedBackground = "background"; + Gradient expectedGradient = new UnionMember0(); + Height expectedHeight = 0; + Radius expectedRadius = 0; + Width expectedWidth = 0; + + Assert.Equal(expectedAlpha, deserialized.Alpha); + Assert.Equal(expectedBackground, deserialized.Background); + Assert.Equal(expectedGradient, deserialized.Gradient); + Assert.Equal(expectedHeight, deserialized.Height); + Assert.Equal(expectedRadius, deserialized.Radius); + Assert.Equal(expectedWidth, deserialized.Width); + } + + [Fact] + public void Validation_Works() + { + var model = new SolidColorOverlayTransformation + { + Alpha = 1, + Background = "background", + Gradient = new UnionMember0(), + Height = 0, + Radius = 0, + Width = 0, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new SolidColorOverlayTransformation { }; + + Assert.Null(model.Alpha); + Assert.False(model.RawData.ContainsKey("alpha")); + Assert.Null(model.Background); + Assert.False(model.RawData.ContainsKey("background")); + Assert.Null(model.Gradient); + Assert.False(model.RawData.ContainsKey("gradient")); + Assert.Null(model.Height); + Assert.False(model.RawData.ContainsKey("height")); + Assert.Null(model.Radius); + Assert.False(model.RawData.ContainsKey("radius")); + Assert.Null(model.Width); + Assert.False(model.RawData.ContainsKey("width")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new SolidColorOverlayTransformation { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new SolidColorOverlayTransformation + { + // Null should be interpreted as omitted for these properties + Alpha = null, + Background = null, + Gradient = null, + Height = null, + Radius = null, + Width = null, + }; + + Assert.Null(model.Alpha); + Assert.False(model.RawData.ContainsKey("alpha")); + Assert.Null(model.Background); + Assert.False(model.RawData.ContainsKey("background")); + Assert.Null(model.Gradient); + Assert.False(model.RawData.ContainsKey("gradient")); + Assert.Null(model.Height); + Assert.False(model.RawData.ContainsKey("height")); + Assert.Null(model.Radius); + Assert.False(model.RawData.ContainsKey("radius")); + Assert.Null(model.Width); + Assert.False(model.RawData.ContainsKey("width")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new SolidColorOverlayTransformation + { + // Null should be interpreted as omitted for these properties + Alpha = null, + Background = null, + Gradient = null, + Height = null, + Radius = null, + Width = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new SolidColorOverlayTransformation + { + Alpha = 1, + Background = "background", + Gradient = new UnionMember0(), + Height = 0, + Radius = 0, + Width = 0, + }; + + SolidColorOverlayTransformation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GradientTest : TestBase +{ + [Fact] + public void TrueValidationWorks() + { + Gradient value = new UnionMember0(); + value.Validate(); + } + + [Fact] + public void StringValidationWorks() + { + Gradient value = "string"; + value.Validate(); + } + + [Fact] + public void TrueSerializationRoundtripWorks() + { + Gradient value = new UnionMember0(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + Gradient value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class UnionMember0Test : TestBase +{ + [Fact] + public void DefaultValidation_Works() + { + var constant = new UnionMember0(); + constant.Validate(); + } + + [Fact] + public void ValidConstantValidation_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement(true), + ModelBase.SerializerOptions + ); + + Assert.NotNull(constant); + constant.Validate(); + } + + [Fact] + public void InvalidConstantValidationThrows_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(constant); + Assert.Throws(() => constant.Validate()); + } + + [Fact] + public void DefaultRoundtrip_Works() + { + var constant = new UnionMember0(); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } + + [Fact] + public void ValidConstantRoundtrip_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement(true), + ModelBase.SerializerOptions + ); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } + + [Fact] + public void InvalidConstantRoundtrip_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } +} + +public class HeightTest : TestBase +{ + [Fact] + public void DoubleValidationWorks() + { + Height value = 0; + value.Validate(); + } + + [Fact] + public void StringValidationWorks() + { + Height value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + Height value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + Height value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class RadiusTest : TestBase +{ + [Fact] + public void DoubleValidationWorks() + { + Radius value = 0; + value.Validate(); + } + + [Fact] + public void MaxValidationWorks() + { + Radius value = new UnionMember1(); + value.Validate(); + } + + [Fact] + public void StringValidationWorks() + { + Radius value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + Radius value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void MaxSerializationRoundtripWorks() + { + Radius value = new UnionMember1(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + Radius value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class UnionMember1Test : TestBase +{ + [Fact] + public void DefaultValidation_Works() + { + var constant = new UnionMember1(); + constant.Validate(); + } + + [Fact] + public void ValidConstantValidation_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement("max"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(constant); + constant.Validate(); + } + + [Fact] + public void InvalidConstantValidationThrows_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(constant); + Assert.Throws(() => constant.Validate()); + } + + [Fact] + public void DefaultRoundtrip_Works() + { + var constant = new UnionMember1(); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } + + [Fact] + public void ValidConstantRoundtrip_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement("max"), + ModelBase.SerializerOptions + ); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } + + [Fact] + public void InvalidConstantRoundtrip_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } +} + +public class WidthTest : TestBase +{ + [Fact] + public void DoubleValidationWorks() + { + Width value = 0; + value.Validate(); + } + + [Fact] + public void StringValidationWorks() + { + Width value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + Width value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + Width value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} diff --git a/src/ImageKit.Tests/Models/SrcOptionsTest.cs b/src/ImageKit.Tests/Models/SrcOptionsTest.cs new file mode 100644 index 00000000..33cb777e --- /dev/null +++ b/src/ImageKit.Tests/Models/SrcOptionsTest.cs @@ -0,0 +1,908 @@ +using System.Collections.Generic; +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Models; + +namespace ImageKit.Tests.Models; + +public class SrcOptionsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new SrcOptions + { + Src = "/my-image.jpg", + UrlEndpoint = "https://ik.imagekit.io/demo", + ExpiresIn = 0, + QueryParameters = new Dictionary() { { "foo", "string" } }, + Signed = true, + Transformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ], + TransformationPosition = TransformationPosition.Path, + }; + + string expectedSrc = "/my-image.jpg"; + string expectedUrlEndpoint = "https://ik.imagekit.io/demo"; + double expectedExpiresIn = 0; + Dictionary expectedQueryParameters = new() { { "foo", "string" } }; + bool expectedSigned = true; + List expectedTransformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ]; + ApiEnum expectedTransformationPosition = + TransformationPosition.Path; + + Assert.Equal(expectedSrc, model.Src); + Assert.Equal(expectedUrlEndpoint, model.UrlEndpoint); + Assert.Equal(expectedExpiresIn, model.ExpiresIn); + Assert.NotNull(model.QueryParameters); + Assert.Equal(expectedQueryParameters.Count, model.QueryParameters.Count); + foreach (var item in expectedQueryParameters) + { + Assert.True(model.QueryParameters.TryGetValue(item.Key, out var value)); + + Assert.Equal(value, model.QueryParameters[item.Key]); + } + Assert.Equal(expectedSigned, model.Signed); + Assert.NotNull(model.Transformation); + Assert.Equal(expectedTransformation.Count, model.Transformation.Count); + for (int i = 0; i < expectedTransformation.Count; i++) + { + Assert.Equal(expectedTransformation[i], model.Transformation[i]); + } + Assert.Equal(expectedTransformationPosition, model.TransformationPosition); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new SrcOptions + { + Src = "/my-image.jpg", + UrlEndpoint = "https://ik.imagekit.io/demo", + ExpiresIn = 0, + QueryParameters = new Dictionary() { { "foo", "string" } }, + Signed = true, + Transformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ], + TransformationPosition = TransformationPosition.Path, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new SrcOptions + { + Src = "/my-image.jpg", + UrlEndpoint = "https://ik.imagekit.io/demo", + ExpiresIn = 0, + QueryParameters = new Dictionary() { { "foo", "string" } }, + Signed = true, + Transformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ], + TransformationPosition = TransformationPosition.Path, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedSrc = "/my-image.jpg"; + string expectedUrlEndpoint = "https://ik.imagekit.io/demo"; + double expectedExpiresIn = 0; + Dictionary expectedQueryParameters = new() { { "foo", "string" } }; + bool expectedSigned = true; + List expectedTransformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ]; + ApiEnum expectedTransformationPosition = + TransformationPosition.Path; + + Assert.Equal(expectedSrc, deserialized.Src); + Assert.Equal(expectedUrlEndpoint, deserialized.UrlEndpoint); + Assert.Equal(expectedExpiresIn, deserialized.ExpiresIn); + Assert.NotNull(deserialized.QueryParameters); + Assert.Equal(expectedQueryParameters.Count, deserialized.QueryParameters.Count); + foreach (var item in expectedQueryParameters) + { + Assert.True(deserialized.QueryParameters.TryGetValue(item.Key, out var value)); + + Assert.Equal(value, deserialized.QueryParameters[item.Key]); + } + Assert.Equal(expectedSigned, deserialized.Signed); + Assert.NotNull(deserialized.Transformation); + Assert.Equal(expectedTransformation.Count, deserialized.Transformation.Count); + for (int i = 0; i < expectedTransformation.Count; i++) + { + Assert.Equal(expectedTransformation[i], deserialized.Transformation[i]); + } + Assert.Equal(expectedTransformationPosition, deserialized.TransformationPosition); + } + + [Fact] + public void Validation_Works() + { + var model = new SrcOptions + { + Src = "/my-image.jpg", + UrlEndpoint = "https://ik.imagekit.io/demo", + ExpiresIn = 0, + QueryParameters = new Dictionary() { { "foo", "string" } }, + Signed = true, + Transformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ], + TransformationPosition = TransformationPosition.Path, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new SrcOptions + { + Src = "/my-image.jpg", + UrlEndpoint = "https://ik.imagekit.io/demo", + }; + + Assert.Null(model.ExpiresIn); + Assert.False(model.RawData.ContainsKey("expiresIn")); + Assert.Null(model.QueryParameters); + Assert.False(model.RawData.ContainsKey("queryParameters")); + Assert.Null(model.Signed); + Assert.False(model.RawData.ContainsKey("signed")); + Assert.Null(model.Transformation); + Assert.False(model.RawData.ContainsKey("transformation")); + Assert.Null(model.TransformationPosition); + Assert.False(model.RawData.ContainsKey("transformationPosition")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new SrcOptions + { + Src = "/my-image.jpg", + UrlEndpoint = "https://ik.imagekit.io/demo", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new SrcOptions + { + Src = "/my-image.jpg", + UrlEndpoint = "https://ik.imagekit.io/demo", + + // Null should be interpreted as omitted for these properties + ExpiresIn = null, + QueryParameters = null, + Signed = null, + Transformation = null, + TransformationPosition = null, + }; + + Assert.Null(model.ExpiresIn); + Assert.False(model.RawData.ContainsKey("expiresIn")); + Assert.Null(model.QueryParameters); + Assert.False(model.RawData.ContainsKey("queryParameters")); + Assert.Null(model.Signed); + Assert.False(model.RawData.ContainsKey("signed")); + Assert.Null(model.Transformation); + Assert.False(model.RawData.ContainsKey("transformation")); + Assert.Null(model.TransformationPosition); + Assert.False(model.RawData.ContainsKey("transformationPosition")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new SrcOptions + { + Src = "/my-image.jpg", + UrlEndpoint = "https://ik.imagekit.io/demo", + + // Null should be interpreted as omitted for these properties + ExpiresIn = null, + QueryParameters = null, + Signed = null, + Transformation = null, + TransformationPosition = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new SrcOptions + { + Src = "/my-image.jpg", + UrlEndpoint = "https://ik.imagekit.io/demo", + ExpiresIn = 0, + QueryParameters = new Dictionary() { { "foo", "string" } }, + Signed = true, + Transformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ], + TransformationPosition = TransformationPosition.Path, + }; + + SrcOptions copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/ImageKit.Tests/Models/StreamingResolutionTest.cs b/src/ImageKit.Tests/Models/StreamingResolutionTest.cs new file mode 100644 index 00000000..9f127bb1 --- /dev/null +++ b/src/ImageKit.Tests/Models/StreamingResolutionTest.cs @@ -0,0 +1,74 @@ +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Exceptions; +using ImageKit.Models; + +namespace ImageKit.Tests.Models; + +public class StreamingResolutionTest : TestBase +{ + [Theory] + [InlineData(StreamingResolution.V240)] + [InlineData(StreamingResolution.V360)] + [InlineData(StreamingResolution.V480)] + [InlineData(StreamingResolution.V720)] + [InlineData(StreamingResolution.V1080)] + [InlineData(StreamingResolution.V1440)] + [InlineData(StreamingResolution.V2160)] + public void Validation_Works(StreamingResolution rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(StreamingResolution.V240)] + [InlineData(StreamingResolution.V360)] + [InlineData(StreamingResolution.V480)] + [InlineData(StreamingResolution.V720)] + [InlineData(StreamingResolution.V1080)] + [InlineData(StreamingResolution.V1440)] + [InlineData(StreamingResolution.V2160)] + public void SerializationRoundtrip_Works(StreamingResolution rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} diff --git a/src/ImageKit.Tests/Models/SubtitleOverlayTest.cs b/src/ImageKit.Tests/Models/SubtitleOverlayTest.cs new file mode 100644 index 00000000..882bbbc2 --- /dev/null +++ b/src/ImageKit.Tests/Models/SubtitleOverlayTest.cs @@ -0,0 +1,672 @@ +using System.Collections.Generic; +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Exceptions; +using ImageKit.Models; + +namespace ImageKit.Tests.Models; + +public class SubtitleOverlayTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new SubtitleOverlay + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Input = "input", + Encoding = SubtitleOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Background = "background", + Color = "color", + FontFamily = "fontFamily", + FontOutline = "fontOutline", + FontShadow = "fontShadow", + FontSize = 0, + Typography = Typography.B, + }, + ], + }; + + ApiEnum expectedLayerMode = LayerMode.Multiply; + OverlayPosition expectedPosition = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }; + OverlayTiming expectedTiming = new() + { + Duration = 0, + End = 0, + Start = 0, + }; + string expectedInput = "input"; + JsonElement expectedType = JsonSerializer.SerializeToElement("subtitle"); + ApiEnum expectedEncoding = + SubtitleOverlayIntersectionMember1Encoding.Auto; + List expectedTransformation = + [ + new() + { + Background = "background", + Color = "color", + FontFamily = "fontFamily", + FontOutline = "fontOutline", + FontShadow = "fontShadow", + FontSize = 0, + Typography = Typography.B, + }, + ]; + + Assert.Equal(expectedLayerMode, model.LayerMode); + Assert.Equal(expectedPosition, model.Position); + Assert.Equal(expectedTiming, model.Timing); + Assert.Equal(expectedInput, model.Input); + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + Assert.Equal(expectedEncoding, model.Encoding); + Assert.NotNull(model.Transformation); + Assert.Equal(expectedTransformation.Count, model.Transformation.Count); + for (int i = 0; i < expectedTransformation.Count; i++) + { + Assert.Equal(expectedTransformation[i], model.Transformation[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new SubtitleOverlay + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Input = "input", + Encoding = SubtitleOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Background = "background", + Color = "color", + FontFamily = "fontFamily", + FontOutline = "fontOutline", + FontShadow = "fontShadow", + FontSize = 0, + Typography = Typography.B, + }, + ], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new SubtitleOverlay + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Input = "input", + Encoding = SubtitleOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Background = "background", + Color = "color", + FontFamily = "fontFamily", + FontOutline = "fontOutline", + FontShadow = "fontShadow", + FontSize = 0, + Typography = Typography.B, + }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum expectedLayerMode = LayerMode.Multiply; + OverlayPosition expectedPosition = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }; + OverlayTiming expectedTiming = new() + { + Duration = 0, + End = 0, + Start = 0, + }; + string expectedInput = "input"; + JsonElement expectedType = JsonSerializer.SerializeToElement("subtitle"); + ApiEnum expectedEncoding = + SubtitleOverlayIntersectionMember1Encoding.Auto; + List expectedTransformation = + [ + new() + { + Background = "background", + Color = "color", + FontFamily = "fontFamily", + FontOutline = "fontOutline", + FontShadow = "fontShadow", + FontSize = 0, + Typography = Typography.B, + }, + ]; + + Assert.Equal(expectedLayerMode, deserialized.LayerMode); + Assert.Equal(expectedPosition, deserialized.Position); + Assert.Equal(expectedTiming, deserialized.Timing); + Assert.Equal(expectedInput, deserialized.Input); + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + Assert.Equal(expectedEncoding, deserialized.Encoding); + Assert.NotNull(deserialized.Transformation); + Assert.Equal(expectedTransformation.Count, deserialized.Transformation.Count); + for (int i = 0; i < expectedTransformation.Count; i++) + { + Assert.Equal(expectedTransformation[i], deserialized.Transformation[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new SubtitleOverlay + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Input = "input", + Encoding = SubtitleOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Background = "background", + Color = "color", + FontFamily = "fontFamily", + FontOutline = "fontOutline", + FontShadow = "fontShadow", + FontSize = 0, + Typography = Typography.B, + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new SubtitleOverlay { Input = "input" }; + + Assert.Null(model.LayerMode); + Assert.False(model.RawData.ContainsKey("layerMode")); + Assert.Null(model.Position); + Assert.False(model.RawData.ContainsKey("position")); + Assert.Null(model.Timing); + Assert.False(model.RawData.ContainsKey("timing")); + Assert.Null(model.Encoding); + Assert.False(model.RawData.ContainsKey("encoding")); + Assert.Null(model.Transformation); + Assert.False(model.RawData.ContainsKey("transformation")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new SubtitleOverlay { Input = "input" }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new SubtitleOverlay + { + Input = "input", + + // Null should be interpreted as omitted for these properties + LayerMode = null, + Position = null, + Timing = null, + Encoding = null, + Transformation = null, + }; + + Assert.Null(model.LayerMode); + Assert.False(model.RawData.ContainsKey("layerMode")); + Assert.Null(model.Position); + Assert.False(model.RawData.ContainsKey("position")); + Assert.Null(model.Timing); + Assert.False(model.RawData.ContainsKey("timing")); + Assert.Null(model.Encoding); + Assert.False(model.RawData.ContainsKey("encoding")); + Assert.Null(model.Transformation); + Assert.False(model.RawData.ContainsKey("transformation")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new SubtitleOverlay + { + Input = "input", + + // Null should be interpreted as omitted for these properties + LayerMode = null, + Position = null, + Timing = null, + Encoding = null, + Transformation = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new SubtitleOverlay + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Input = "input", + Encoding = SubtitleOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Background = "background", + Color = "color", + FontFamily = "fontFamily", + FontOutline = "fontOutline", + FontShadow = "fontShadow", + FontSize = 0, + Typography = Typography.B, + }, + ], + }; + + SubtitleOverlay copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class SubtitleOverlayIntersectionMember1Test : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new SubtitleOverlayIntersectionMember1 + { + Input = "input", + Encoding = SubtitleOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Background = "background", + Color = "color", + FontFamily = "fontFamily", + FontOutline = "fontOutline", + FontShadow = "fontShadow", + FontSize = 0, + Typography = Typography.B, + }, + ], + }; + + string expectedInput = "input"; + JsonElement expectedType = JsonSerializer.SerializeToElement("subtitle"); + ApiEnum expectedEncoding = + SubtitleOverlayIntersectionMember1Encoding.Auto; + List expectedTransformation = + [ + new() + { + Background = "background", + Color = "color", + FontFamily = "fontFamily", + FontOutline = "fontOutline", + FontShadow = "fontShadow", + FontSize = 0, + Typography = Typography.B, + }, + ]; + + Assert.Equal(expectedInput, model.Input); + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + Assert.Equal(expectedEncoding, model.Encoding); + Assert.NotNull(model.Transformation); + Assert.Equal(expectedTransformation.Count, model.Transformation.Count); + for (int i = 0; i < expectedTransformation.Count; i++) + { + Assert.Equal(expectedTransformation[i], model.Transformation[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new SubtitleOverlayIntersectionMember1 + { + Input = "input", + Encoding = SubtitleOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Background = "background", + Color = "color", + FontFamily = "fontFamily", + FontOutline = "fontOutline", + FontShadow = "fontShadow", + FontSize = 0, + Typography = Typography.B, + }, + ], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new SubtitleOverlayIntersectionMember1 + { + Input = "input", + Encoding = SubtitleOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Background = "background", + Color = "color", + FontFamily = "fontFamily", + FontOutline = "fontOutline", + FontShadow = "fontShadow", + FontSize = 0, + Typography = Typography.B, + }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedInput = "input"; + JsonElement expectedType = JsonSerializer.SerializeToElement("subtitle"); + ApiEnum expectedEncoding = + SubtitleOverlayIntersectionMember1Encoding.Auto; + List expectedTransformation = + [ + new() + { + Background = "background", + Color = "color", + FontFamily = "fontFamily", + FontOutline = "fontOutline", + FontShadow = "fontShadow", + FontSize = 0, + Typography = Typography.B, + }, + ]; + + Assert.Equal(expectedInput, deserialized.Input); + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + Assert.Equal(expectedEncoding, deserialized.Encoding); + Assert.NotNull(deserialized.Transformation); + Assert.Equal(expectedTransformation.Count, deserialized.Transformation.Count); + for (int i = 0; i < expectedTransformation.Count; i++) + { + Assert.Equal(expectedTransformation[i], deserialized.Transformation[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new SubtitleOverlayIntersectionMember1 + { + Input = "input", + Encoding = SubtitleOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Background = "background", + Color = "color", + FontFamily = "fontFamily", + FontOutline = "fontOutline", + FontShadow = "fontShadow", + FontSize = 0, + Typography = Typography.B, + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new SubtitleOverlayIntersectionMember1 { Input = "input" }; + + Assert.Null(model.Encoding); + Assert.False(model.RawData.ContainsKey("encoding")); + Assert.Null(model.Transformation); + Assert.False(model.RawData.ContainsKey("transformation")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new SubtitleOverlayIntersectionMember1 { Input = "input" }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new SubtitleOverlayIntersectionMember1 + { + Input = "input", + + // Null should be interpreted as omitted for these properties + Encoding = null, + Transformation = null, + }; + + Assert.Null(model.Encoding); + Assert.False(model.RawData.ContainsKey("encoding")); + Assert.Null(model.Transformation); + Assert.False(model.RawData.ContainsKey("transformation")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new SubtitleOverlayIntersectionMember1 + { + Input = "input", + + // Null should be interpreted as omitted for these properties + Encoding = null, + Transformation = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new SubtitleOverlayIntersectionMember1 + { + Input = "input", + Encoding = SubtitleOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Background = "background", + Color = "color", + FontFamily = "fontFamily", + FontOutline = "fontOutline", + FontShadow = "fontShadow", + FontSize = 0, + Typography = Typography.B, + }, + ], + }; + + SubtitleOverlayIntersectionMember1 copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class SubtitleOverlayIntersectionMember1EncodingTest : TestBase +{ + [Theory] + [InlineData(SubtitleOverlayIntersectionMember1Encoding.Auto)] + [InlineData(SubtitleOverlayIntersectionMember1Encoding.Plain)] + [InlineData(SubtitleOverlayIntersectionMember1Encoding.Base64)] + public void Validation_Works(SubtitleOverlayIntersectionMember1Encoding rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(SubtitleOverlayIntersectionMember1Encoding.Auto)] + [InlineData(SubtitleOverlayIntersectionMember1Encoding.Plain)] + [InlineData(SubtitleOverlayIntersectionMember1Encoding.Base64)] + public void SerializationRoundtrip_Works(SubtitleOverlayIntersectionMember1Encoding rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} diff --git a/src/ImageKit.Tests/Models/SubtitleOverlayTransformationTest.cs b/src/ImageKit.Tests/Models/SubtitleOverlayTransformationTest.cs new file mode 100644 index 00000000..81e75c92 --- /dev/null +++ b/src/ImageKit.Tests/Models/SubtitleOverlayTransformationTest.cs @@ -0,0 +1,275 @@ +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Exceptions; +using ImageKit.Models; + +namespace ImageKit.Tests.Models; + +public class SubtitleOverlayTransformationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new SubtitleOverlayTransformation + { + Background = "background", + Color = "color", + FontFamily = "fontFamily", + FontOutline = "fontOutline", + FontShadow = "fontShadow", + FontSize = 0, + Typography = Typography.B, + }; + + string expectedBackground = "background"; + string expectedColor = "color"; + string expectedFontFamily = "fontFamily"; + string expectedFontOutline = "fontOutline"; + string expectedFontShadow = "fontShadow"; + double expectedFontSize = 0; + ApiEnum expectedTypography = Typography.B; + + Assert.Equal(expectedBackground, model.Background); + Assert.Equal(expectedColor, model.Color); + Assert.Equal(expectedFontFamily, model.FontFamily); + Assert.Equal(expectedFontOutline, model.FontOutline); + Assert.Equal(expectedFontShadow, model.FontShadow); + Assert.Equal(expectedFontSize, model.FontSize); + Assert.Equal(expectedTypography, model.Typography); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new SubtitleOverlayTransformation + { + Background = "background", + Color = "color", + FontFamily = "fontFamily", + FontOutline = "fontOutline", + FontShadow = "fontShadow", + FontSize = 0, + Typography = Typography.B, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new SubtitleOverlayTransformation + { + Background = "background", + Color = "color", + FontFamily = "fontFamily", + FontOutline = "fontOutline", + FontShadow = "fontShadow", + FontSize = 0, + Typography = Typography.B, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedBackground = "background"; + string expectedColor = "color"; + string expectedFontFamily = "fontFamily"; + string expectedFontOutline = "fontOutline"; + string expectedFontShadow = "fontShadow"; + double expectedFontSize = 0; + ApiEnum expectedTypography = Typography.B; + + Assert.Equal(expectedBackground, deserialized.Background); + Assert.Equal(expectedColor, deserialized.Color); + Assert.Equal(expectedFontFamily, deserialized.FontFamily); + Assert.Equal(expectedFontOutline, deserialized.FontOutline); + Assert.Equal(expectedFontShadow, deserialized.FontShadow); + Assert.Equal(expectedFontSize, deserialized.FontSize); + Assert.Equal(expectedTypography, deserialized.Typography); + } + + [Fact] + public void Validation_Works() + { + var model = new SubtitleOverlayTransformation + { + Background = "background", + Color = "color", + FontFamily = "fontFamily", + FontOutline = "fontOutline", + FontShadow = "fontShadow", + FontSize = 0, + Typography = Typography.B, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new SubtitleOverlayTransformation { }; + + Assert.Null(model.Background); + Assert.False(model.RawData.ContainsKey("background")); + Assert.Null(model.Color); + Assert.False(model.RawData.ContainsKey("color")); + Assert.Null(model.FontFamily); + Assert.False(model.RawData.ContainsKey("fontFamily")); + Assert.Null(model.FontOutline); + Assert.False(model.RawData.ContainsKey("fontOutline")); + Assert.Null(model.FontShadow); + Assert.False(model.RawData.ContainsKey("fontShadow")); + Assert.Null(model.FontSize); + Assert.False(model.RawData.ContainsKey("fontSize")); + Assert.Null(model.Typography); + Assert.False(model.RawData.ContainsKey("typography")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new SubtitleOverlayTransformation { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new SubtitleOverlayTransformation + { + // Null should be interpreted as omitted for these properties + Background = null, + Color = null, + FontFamily = null, + FontOutline = null, + FontShadow = null, + FontSize = null, + Typography = null, + }; + + Assert.Null(model.Background); + Assert.False(model.RawData.ContainsKey("background")); + Assert.Null(model.Color); + Assert.False(model.RawData.ContainsKey("color")); + Assert.Null(model.FontFamily); + Assert.False(model.RawData.ContainsKey("fontFamily")); + Assert.Null(model.FontOutline); + Assert.False(model.RawData.ContainsKey("fontOutline")); + Assert.Null(model.FontShadow); + Assert.False(model.RawData.ContainsKey("fontShadow")); + Assert.Null(model.FontSize); + Assert.False(model.RawData.ContainsKey("fontSize")); + Assert.Null(model.Typography); + Assert.False(model.RawData.ContainsKey("typography")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new SubtitleOverlayTransformation + { + // Null should be interpreted as omitted for these properties + Background = null, + Color = null, + FontFamily = null, + FontOutline = null, + FontShadow = null, + FontSize = null, + Typography = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new SubtitleOverlayTransformation + { + Background = "background", + Color = "color", + FontFamily = "fontFamily", + FontOutline = "fontOutline", + FontShadow = "fontShadow", + FontSize = 0, + Typography = Typography.B, + }; + + SubtitleOverlayTransformation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TypographyTest : TestBase +{ + [Theory] + [InlineData(Typography.B)] + [InlineData(Typography.I)] + [InlineData(Typography.BI)] + public void Validation_Works(Typography rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(Typography.B)] + [InlineData(Typography.I)] + [InlineData(Typography.BI)] + public void SerializationRoundtrip_Works(Typography rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} diff --git a/src/ImageKit.Tests/Models/TextOverlayTest.cs b/src/ImageKit.Tests/Models/TextOverlayTest.cs new file mode 100644 index 00000000..b047d512 --- /dev/null +++ b/src/ImageKit.Tests/Models/TextOverlayTest.cs @@ -0,0 +1,756 @@ +using System.Collections.Generic; +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Exceptions; +using ImageKit.Models; + +namespace ImageKit.Tests.Models; + +public class TextOverlayTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TextOverlay + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }; + + ApiEnum expectedLayerMode = LayerMode.Multiply; + OverlayPosition expectedPosition = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }; + OverlayTiming expectedTiming = new() + { + Duration = 0, + End = 0, + Start = 0, + }; + string expectedText = "text"; + JsonElement expectedType = JsonSerializer.SerializeToElement("text"); + ApiEnum expectedEncoding = + TextOverlayIntersectionMember1Encoding.Auto; + List expectedTransformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ]; + + Assert.Equal(expectedLayerMode, model.LayerMode); + Assert.Equal(expectedPosition, model.Position); + Assert.Equal(expectedTiming, model.Timing); + Assert.Equal(expectedText, model.Text); + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + Assert.Equal(expectedEncoding, model.Encoding); + Assert.NotNull(model.Transformation); + Assert.Equal(expectedTransformation.Count, model.Transformation.Count); + for (int i = 0; i < expectedTransformation.Count; i++) + { + Assert.Equal(expectedTransformation[i], model.Transformation[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TextOverlay + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new TextOverlay + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum expectedLayerMode = LayerMode.Multiply; + OverlayPosition expectedPosition = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }; + OverlayTiming expectedTiming = new() + { + Duration = 0, + End = 0, + Start = 0, + }; + string expectedText = "text"; + JsonElement expectedType = JsonSerializer.SerializeToElement("text"); + ApiEnum expectedEncoding = + TextOverlayIntersectionMember1Encoding.Auto; + List expectedTransformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ]; + + Assert.Equal(expectedLayerMode, deserialized.LayerMode); + Assert.Equal(expectedPosition, deserialized.Position); + Assert.Equal(expectedTiming, deserialized.Timing); + Assert.Equal(expectedText, deserialized.Text); + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + Assert.Equal(expectedEncoding, deserialized.Encoding); + Assert.NotNull(deserialized.Transformation); + Assert.Equal(expectedTransformation.Count, deserialized.Transformation.Count); + for (int i = 0; i < expectedTransformation.Count; i++) + { + Assert.Equal(expectedTransformation[i], deserialized.Transformation[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new TextOverlay + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new TextOverlay { Text = "text" }; + + Assert.Null(model.LayerMode); + Assert.False(model.RawData.ContainsKey("layerMode")); + Assert.Null(model.Position); + Assert.False(model.RawData.ContainsKey("position")); + Assert.Null(model.Timing); + Assert.False(model.RawData.ContainsKey("timing")); + Assert.Null(model.Encoding); + Assert.False(model.RawData.ContainsKey("encoding")); + Assert.Null(model.Transformation); + Assert.False(model.RawData.ContainsKey("transformation")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new TextOverlay { Text = "text" }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new TextOverlay + { + Text = "text", + + // Null should be interpreted as omitted for these properties + LayerMode = null, + Position = null, + Timing = null, + Encoding = null, + Transformation = null, + }; + + Assert.Null(model.LayerMode); + Assert.False(model.RawData.ContainsKey("layerMode")); + Assert.Null(model.Position); + Assert.False(model.RawData.ContainsKey("position")); + Assert.Null(model.Timing); + Assert.False(model.RawData.ContainsKey("timing")); + Assert.Null(model.Encoding); + Assert.False(model.RawData.ContainsKey("encoding")); + Assert.Null(model.Transformation); + Assert.False(model.RawData.ContainsKey("transformation")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new TextOverlay + { + Text = "text", + + // Null should be interpreted as omitted for these properties + LayerMode = null, + Position = null, + Timing = null, + Encoding = null, + Transformation = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TextOverlay + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }; + + TextOverlay copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TextOverlayIntersectionMember1Test : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TextOverlayIntersectionMember1 + { + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }; + + string expectedText = "text"; + JsonElement expectedType = JsonSerializer.SerializeToElement("text"); + ApiEnum expectedEncoding = + TextOverlayIntersectionMember1Encoding.Auto; + List expectedTransformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ]; + + Assert.Equal(expectedText, model.Text); + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + Assert.Equal(expectedEncoding, model.Encoding); + Assert.NotNull(model.Transformation); + Assert.Equal(expectedTransformation.Count, model.Transformation.Count); + for (int i = 0; i < expectedTransformation.Count; i++) + { + Assert.Equal(expectedTransformation[i], model.Transformation[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TextOverlayIntersectionMember1 + { + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new TextOverlayIntersectionMember1 + { + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedText = "text"; + JsonElement expectedType = JsonSerializer.SerializeToElement("text"); + ApiEnum expectedEncoding = + TextOverlayIntersectionMember1Encoding.Auto; + List expectedTransformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ]; + + Assert.Equal(expectedText, deserialized.Text); + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + Assert.Equal(expectedEncoding, deserialized.Encoding); + Assert.NotNull(deserialized.Transformation); + Assert.Equal(expectedTransformation.Count, deserialized.Transformation.Count); + for (int i = 0; i < expectedTransformation.Count; i++) + { + Assert.Equal(expectedTransformation[i], deserialized.Transformation[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new TextOverlayIntersectionMember1 + { + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new TextOverlayIntersectionMember1 { Text = "text" }; + + Assert.Null(model.Encoding); + Assert.False(model.RawData.ContainsKey("encoding")); + Assert.Null(model.Transformation); + Assert.False(model.RawData.ContainsKey("transformation")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new TextOverlayIntersectionMember1 { Text = "text" }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new TextOverlayIntersectionMember1 + { + Text = "text", + + // Null should be interpreted as omitted for these properties + Encoding = null, + Transformation = null, + }; + + Assert.Null(model.Encoding); + Assert.False(model.RawData.ContainsKey("encoding")); + Assert.Null(model.Transformation); + Assert.False(model.RawData.ContainsKey("transformation")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new TextOverlayIntersectionMember1 + { + Text = "text", + + // Null should be interpreted as omitted for these properties + Encoding = null, + Transformation = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TextOverlayIntersectionMember1 + { + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }; + + TextOverlayIntersectionMember1 copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TextOverlayIntersectionMember1EncodingTest : TestBase +{ + [Theory] + [InlineData(TextOverlayIntersectionMember1Encoding.Auto)] + [InlineData(TextOverlayIntersectionMember1Encoding.Plain)] + [InlineData(TextOverlayIntersectionMember1Encoding.Base64)] + public void Validation_Works(TextOverlayIntersectionMember1Encoding rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(TextOverlayIntersectionMember1Encoding.Auto)] + [InlineData(TextOverlayIntersectionMember1Encoding.Plain)] + [InlineData(TextOverlayIntersectionMember1Encoding.Base64)] + public void SerializationRoundtrip_Works(TextOverlayIntersectionMember1Encoding rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} diff --git a/src/ImageKit.Tests/Models/TextOverlayTransformationTest.cs b/src/ImageKit.Tests/Models/TextOverlayTransformationTest.cs new file mode 100644 index 00000000..2a69266d --- /dev/null +++ b/src/ImageKit.Tests/Models/TextOverlayTransformationTest.cs @@ -0,0 +1,784 @@ +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Exceptions; +using ImageKit.Models; + +namespace ImageKit.Tests.Models; + +public class TextOverlayTransformationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TextOverlayTransformation + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }; + + double expectedAlpha = 1; + string expectedBackground = "background"; + ApiEnum expectedFlip = Flip.H; + string expectedFontColor = "fontColor"; + string expectedFontFamily = "fontFamily"; + FontSize expectedFontSize = 0; + ApiEnum expectedInnerAlignment = InnerAlignment.Left; + LineHeight expectedLineHeight = 0; + Padding expectedPadding = 0; + TextOverlayTransformationRadius expectedRadius = 0; + Rotation expectedRotation = 0; + string expectedTypography = "typography"; + TextOverlayTransformationWidth expectedWidth = 0; + + Assert.Equal(expectedAlpha, model.Alpha); + Assert.Equal(expectedBackground, model.Background); + Assert.Equal(expectedFlip, model.Flip); + Assert.Equal(expectedFontColor, model.FontColor); + Assert.Equal(expectedFontFamily, model.FontFamily); + Assert.Equal(expectedFontSize, model.FontSize); + Assert.Equal(expectedInnerAlignment, model.InnerAlignment); + Assert.Equal(expectedLineHeight, model.LineHeight); + Assert.Equal(expectedPadding, model.Padding); + Assert.Equal(expectedRadius, model.Radius); + Assert.Equal(expectedRotation, model.Rotation); + Assert.Equal(expectedTypography, model.Typography); + Assert.Equal(expectedWidth, model.Width); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TextOverlayTransformation + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new TextOverlayTransformation + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + double expectedAlpha = 1; + string expectedBackground = "background"; + ApiEnum expectedFlip = Flip.H; + string expectedFontColor = "fontColor"; + string expectedFontFamily = "fontFamily"; + FontSize expectedFontSize = 0; + ApiEnum expectedInnerAlignment = InnerAlignment.Left; + LineHeight expectedLineHeight = 0; + Padding expectedPadding = 0; + TextOverlayTransformationRadius expectedRadius = 0; + Rotation expectedRotation = 0; + string expectedTypography = "typography"; + TextOverlayTransformationWidth expectedWidth = 0; + + Assert.Equal(expectedAlpha, deserialized.Alpha); + Assert.Equal(expectedBackground, deserialized.Background); + Assert.Equal(expectedFlip, deserialized.Flip); + Assert.Equal(expectedFontColor, deserialized.FontColor); + Assert.Equal(expectedFontFamily, deserialized.FontFamily); + Assert.Equal(expectedFontSize, deserialized.FontSize); + Assert.Equal(expectedInnerAlignment, deserialized.InnerAlignment); + Assert.Equal(expectedLineHeight, deserialized.LineHeight); + Assert.Equal(expectedPadding, deserialized.Padding); + Assert.Equal(expectedRadius, deserialized.Radius); + Assert.Equal(expectedRotation, deserialized.Rotation); + Assert.Equal(expectedTypography, deserialized.Typography); + Assert.Equal(expectedWidth, deserialized.Width); + } + + [Fact] + public void Validation_Works() + { + var model = new TextOverlayTransformation + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new TextOverlayTransformation { }; + + Assert.Null(model.Alpha); + Assert.False(model.RawData.ContainsKey("alpha")); + Assert.Null(model.Background); + Assert.False(model.RawData.ContainsKey("background")); + Assert.Null(model.Flip); + Assert.False(model.RawData.ContainsKey("flip")); + Assert.Null(model.FontColor); + Assert.False(model.RawData.ContainsKey("fontColor")); + Assert.Null(model.FontFamily); + Assert.False(model.RawData.ContainsKey("fontFamily")); + Assert.Null(model.FontSize); + Assert.False(model.RawData.ContainsKey("fontSize")); + Assert.Null(model.InnerAlignment); + Assert.False(model.RawData.ContainsKey("innerAlignment")); + Assert.Null(model.LineHeight); + Assert.False(model.RawData.ContainsKey("lineHeight")); + Assert.Null(model.Padding); + Assert.False(model.RawData.ContainsKey("padding")); + Assert.Null(model.Radius); + Assert.False(model.RawData.ContainsKey("radius")); + Assert.Null(model.Rotation); + Assert.False(model.RawData.ContainsKey("rotation")); + Assert.Null(model.Typography); + Assert.False(model.RawData.ContainsKey("typography")); + Assert.Null(model.Width); + Assert.False(model.RawData.ContainsKey("width")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new TextOverlayTransformation { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new TextOverlayTransformation + { + // Null should be interpreted as omitted for these properties + Alpha = null, + Background = null, + Flip = null, + FontColor = null, + FontFamily = null, + FontSize = null, + InnerAlignment = null, + LineHeight = null, + Padding = null, + Radius = null, + Rotation = null, + Typography = null, + Width = null, + }; + + Assert.Null(model.Alpha); + Assert.False(model.RawData.ContainsKey("alpha")); + Assert.Null(model.Background); + Assert.False(model.RawData.ContainsKey("background")); + Assert.Null(model.Flip); + Assert.False(model.RawData.ContainsKey("flip")); + Assert.Null(model.FontColor); + Assert.False(model.RawData.ContainsKey("fontColor")); + Assert.Null(model.FontFamily); + Assert.False(model.RawData.ContainsKey("fontFamily")); + Assert.Null(model.FontSize); + Assert.False(model.RawData.ContainsKey("fontSize")); + Assert.Null(model.InnerAlignment); + Assert.False(model.RawData.ContainsKey("innerAlignment")); + Assert.Null(model.LineHeight); + Assert.False(model.RawData.ContainsKey("lineHeight")); + Assert.Null(model.Padding); + Assert.False(model.RawData.ContainsKey("padding")); + Assert.Null(model.Radius); + Assert.False(model.RawData.ContainsKey("radius")); + Assert.Null(model.Rotation); + Assert.False(model.RawData.ContainsKey("rotation")); + Assert.Null(model.Typography); + Assert.False(model.RawData.ContainsKey("typography")); + Assert.Null(model.Width); + Assert.False(model.RawData.ContainsKey("width")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new TextOverlayTransformation + { + // Null should be interpreted as omitted for these properties + Alpha = null, + Background = null, + Flip = null, + FontColor = null, + FontFamily = null, + FontSize = null, + InnerAlignment = null, + LineHeight = null, + Padding = null, + Radius = null, + Rotation = null, + Typography = null, + Width = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TextOverlayTransformation + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }; + + TextOverlayTransformation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class FlipTest : TestBase +{ + [Theory] + [InlineData(Flip.H)] + [InlineData(Flip.V)] + [InlineData(Flip.HV)] + [InlineData(Flip.VH)] + public void Validation_Works(Flip rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(Flip.H)] + [InlineData(Flip.V)] + [InlineData(Flip.HV)] + [InlineData(Flip.VH)] + public void SerializationRoundtrip_Works(Flip rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class FontSizeTest : TestBase +{ + [Fact] + public void DoubleValidationWorks() + { + FontSize value = 0; + value.Validate(); + } + + [Fact] + public void StringValidationWorks() + { + FontSize value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + FontSize value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + FontSize value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class InnerAlignmentTest : TestBase +{ + [Theory] + [InlineData(InnerAlignment.Left)] + [InlineData(InnerAlignment.Right)] + [InlineData(InnerAlignment.Center)] + public void Validation_Works(InnerAlignment rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(InnerAlignment.Left)] + [InlineData(InnerAlignment.Right)] + [InlineData(InnerAlignment.Center)] + public void SerializationRoundtrip_Works(InnerAlignment rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class LineHeightTest : TestBase +{ + [Fact] + public void DoubleValidationWorks() + { + LineHeight value = 0; + value.Validate(); + } + + [Fact] + public void StringValidationWorks() + { + LineHeight value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + LineHeight value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + LineHeight value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class PaddingTest : TestBase +{ + [Fact] + public void DoubleValidationWorks() + { + Padding value = 0; + value.Validate(); + } + + [Fact] + public void StringValidationWorks() + { + Padding value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + Padding value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + Padding value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class TextOverlayTransformationRadiusTest : TestBase +{ + [Fact] + public void DoubleValidationWorks() + { + TextOverlayTransformationRadius value = 0; + value.Validate(); + } + + [Fact] + public void MaxValidationWorks() + { + TextOverlayTransformationRadius value = new TextOverlayTransformationRadiusUnionMember1(); + value.Validate(); + } + + [Fact] + public void StringValidationWorks() + { + TextOverlayTransformationRadius value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + TextOverlayTransformationRadius value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void MaxSerializationRoundtripWorks() + { + TextOverlayTransformationRadius value = new TextOverlayTransformationRadiusUnionMember1(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + TextOverlayTransformationRadius value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class TextOverlayTransformationRadiusUnionMember1Test : TestBase +{ + [Fact] + public void DefaultValidation_Works() + { + var constant = new TextOverlayTransformationRadiusUnionMember1(); + constant.Validate(); + } + + [Fact] + public void ValidConstantValidation_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement("max"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(constant); + constant.Validate(); + } + + [Fact] + public void InvalidConstantValidationThrows_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(constant); + Assert.Throws(() => constant.Validate()); + } + + [Fact] + public void DefaultRoundtrip_Works() + { + var constant = new TextOverlayTransformationRadiusUnionMember1(); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } + + [Fact] + public void ValidConstantRoundtrip_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement("max"), + ModelBase.SerializerOptions + ); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } + + [Fact] + public void InvalidConstantRoundtrip_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } +} + +public class RotationTest : TestBase +{ + [Fact] + public void DoubleValidationWorks() + { + Rotation value = 0; + value.Validate(); + } + + [Fact] + public void StringValidationWorks() + { + Rotation value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + Rotation value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + Rotation value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class TextOverlayTransformationWidthTest : TestBase +{ + [Fact] + public void DoubleValidationWorks() + { + TextOverlayTransformationWidth value = 0; + value.Validate(); + } + + [Fact] + public void StringValidationWorks() + { + TextOverlayTransformationWidth value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + TextOverlayTransformationWidth value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + TextOverlayTransformationWidth value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} diff --git a/src/ImageKit.Tests/Models/TransformationPositionTest.cs b/src/ImageKit.Tests/Models/TransformationPositionTest.cs new file mode 100644 index 00000000..3e4b8b06 --- /dev/null +++ b/src/ImageKit.Tests/Models/TransformationPositionTest.cs @@ -0,0 +1,64 @@ +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Exceptions; +using ImageKit.Models; + +namespace ImageKit.Tests.Models; + +public class TransformationPositionTest : TestBase +{ + [Theory] + [InlineData(TransformationPosition.Path)] + [InlineData(TransformationPosition.Query)] + public void Validation_Works(TransformationPosition rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(TransformationPosition.Path)] + [InlineData(TransformationPosition.Query)] + public void SerializationRoundtrip_Works(TransformationPosition rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} diff --git a/src/ImageKit.Tests/Models/TransformationTest.cs b/src/ImageKit.Tests/Models/TransformationTest.cs new file mode 100644 index 00000000..cd08f493 --- /dev/null +++ b/src/ImageKit.Tests/Models/TransformationTest.cs @@ -0,0 +1,3339 @@ +using System.Collections.Generic; +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Exceptions; +using ImageKit.Models; + +namespace ImageKit.Tests.Models; + +public class TransformationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Transformation + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }; + + string expectedAIChangeBackground = "aiChangeBackground"; + AIDropShadow expectedAIDropShadow = new AIDropShadowUnionMember0(); + string expectedAIEdit = "aiEdit"; + ApiEnum expectedAIRemoveBackground = AIRemoveBackground.True; + ApiEnum expectedAIRemoveBackgroundExternal = + AIRemoveBackgroundExternal.True; + ApiEnum expectedAIRetouch = AIRetouch.True; + ApiEnum expectedAIUpscale = AIUpscale.True; + ApiEnum expectedAIVariation = AIVariation.True; + AspectRatio expectedAspectRatio = "4:3"; + ApiEnum expectedAudioCodec = AudioCodec.Aac; + string expectedBackground = "red"; + double expectedBlur = 10; + string expectedBorder = "5_FF0000"; + bool expectedColorProfile = true; + string expectedColorReplace = "colorReplace"; + ApiEnum expectedContrastStretch = ContrastStretch.True; + ApiEnum expectedCrop = Crop.Force; + ApiEnum expectedCropMode = CropMode.PadResize; + string expectedDefaultImage = "defaultImage"; + string expectedDistort = "distort"; + double expectedDpr = 2; + TransformationDuration expectedDuration = 0; + EndOffset expectedEndOffset = 0; + ApiEnum expectedFlip = TransformationFlip.H; + string expectedFocus = "center"; + ApiEnum expectedFormat = Format.Auto; + TransformationGradient expectedGradient = new TransformationGradientUnionMember0(); + ApiEnum expectedGrayscale = Grayscale.True; + TransformationHeight expectedHeight = 200; + bool expectedLossless = true; + bool expectedMetadata = true; + string expectedNamed = "named"; + double expectedOpacity = 0; + bool expectedOriginal = true; + Overlay expectedOverlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }; + Page expectedPage = 0; + bool expectedProgressive = true; + double expectedQuality = 80; + TransformationRadius expectedRadius = 20; + string expectedRaw = "raw"; + TransformationRotation expectedRotation = 90; + Shadow expectedShadow = new ShadowUnionMember0(); + Sharpen expectedSharpen = new SharpenUnionMember0(); + StartOffset expectedStartOffset = 0; + List> expectedStreamingResolutions = + [ + StreamingResolution.V240, + ]; + Trim expectedTrim = new TrimUnionMember0(); + UnsharpMask expectedUnsharpMask = new UnsharpMaskUnionMember0(); + ApiEnum expectedVideoCodec = VideoCodec.H264; + TransformationWidth expectedWidth = 300; + TransformationX expectedX = 0; + XCenter expectedXCenter = 0; + TransformationY expectedY = 0; + YCenter expectedYCenter = 0; + double expectedZoom = 0; + + Assert.Equal(expectedAIChangeBackground, model.AIChangeBackground); + Assert.Equal(expectedAIDropShadow, model.AIDropShadow); + Assert.Equal(expectedAIEdit, model.AIEdit); + Assert.Equal(expectedAIRemoveBackground, model.AIRemoveBackground); + Assert.Equal(expectedAIRemoveBackgroundExternal, model.AIRemoveBackgroundExternal); + Assert.Equal(expectedAIRetouch, model.AIRetouch); + Assert.Equal(expectedAIUpscale, model.AIUpscale); + Assert.Equal(expectedAIVariation, model.AIVariation); + Assert.Equal(expectedAspectRatio, model.AspectRatio); + Assert.Equal(expectedAudioCodec, model.AudioCodec); + Assert.Equal(expectedBackground, model.Background); + Assert.Equal(expectedBlur, model.Blur); + Assert.Equal(expectedBorder, model.Border); + Assert.Equal(expectedColorProfile, model.ColorProfile); + Assert.Equal(expectedColorReplace, model.ColorReplace); + Assert.Equal(expectedContrastStretch, model.ContrastStretch); + Assert.Equal(expectedCrop, model.Crop); + Assert.Equal(expectedCropMode, model.CropMode); + Assert.Equal(expectedDefaultImage, model.DefaultImage); + Assert.Equal(expectedDistort, model.Distort); + Assert.Equal(expectedDpr, model.Dpr); + Assert.Equal(expectedDuration, model.Duration); + Assert.Equal(expectedEndOffset, model.EndOffset); + Assert.Equal(expectedFlip, model.Flip); + Assert.Equal(expectedFocus, model.Focus); + Assert.Equal(expectedFormat, model.Format); + Assert.Equal(expectedGradient, model.Gradient); + Assert.Equal(expectedGrayscale, model.Grayscale); + Assert.Equal(expectedHeight, model.Height); + Assert.Equal(expectedLossless, model.Lossless); + Assert.Equal(expectedMetadata, model.Metadata); + Assert.Equal(expectedNamed, model.Named); + Assert.Equal(expectedOpacity, model.Opacity); + Assert.Equal(expectedOriginal, model.Original); + Assert.Equal(expectedOverlay, model.Overlay); + Assert.Equal(expectedPage, model.Page); + Assert.Equal(expectedProgressive, model.Progressive); + Assert.Equal(expectedQuality, model.Quality); + Assert.Equal(expectedRadius, model.Radius); + Assert.Equal(expectedRaw, model.Raw); + Assert.Equal(expectedRotation, model.Rotation); + Assert.Equal(expectedShadow, model.Shadow); + Assert.Equal(expectedSharpen, model.Sharpen); + Assert.Equal(expectedStartOffset, model.StartOffset); + Assert.NotNull(model.StreamingResolutions); + Assert.Equal(expectedStreamingResolutions.Count, model.StreamingResolutions.Count); + for (int i = 0; i < expectedStreamingResolutions.Count; i++) + { + Assert.Equal(expectedStreamingResolutions[i], model.StreamingResolutions[i]); + } + Assert.Equal(expectedTrim, model.Trim); + Assert.Equal(expectedUnsharpMask, model.UnsharpMask); + Assert.Equal(expectedVideoCodec, model.VideoCodec); + Assert.Equal(expectedWidth, model.Width); + Assert.Equal(expectedX, model.X); + Assert.Equal(expectedXCenter, model.XCenter); + Assert.Equal(expectedY, model.Y); + Assert.Equal(expectedYCenter, model.YCenter); + Assert.Equal(expectedZoom, model.Zoom); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Transformation + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Transformation + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAIChangeBackground = "aiChangeBackground"; + AIDropShadow expectedAIDropShadow = new AIDropShadowUnionMember0(); + string expectedAIEdit = "aiEdit"; + ApiEnum expectedAIRemoveBackground = AIRemoveBackground.True; + ApiEnum expectedAIRemoveBackgroundExternal = + AIRemoveBackgroundExternal.True; + ApiEnum expectedAIRetouch = AIRetouch.True; + ApiEnum expectedAIUpscale = AIUpscale.True; + ApiEnum expectedAIVariation = AIVariation.True; + AspectRatio expectedAspectRatio = "4:3"; + ApiEnum expectedAudioCodec = AudioCodec.Aac; + string expectedBackground = "red"; + double expectedBlur = 10; + string expectedBorder = "5_FF0000"; + bool expectedColorProfile = true; + string expectedColorReplace = "colorReplace"; + ApiEnum expectedContrastStretch = ContrastStretch.True; + ApiEnum expectedCrop = Crop.Force; + ApiEnum expectedCropMode = CropMode.PadResize; + string expectedDefaultImage = "defaultImage"; + string expectedDistort = "distort"; + double expectedDpr = 2; + TransformationDuration expectedDuration = 0; + EndOffset expectedEndOffset = 0; + ApiEnum expectedFlip = TransformationFlip.H; + string expectedFocus = "center"; + ApiEnum expectedFormat = Format.Auto; + TransformationGradient expectedGradient = new TransformationGradientUnionMember0(); + ApiEnum expectedGrayscale = Grayscale.True; + TransformationHeight expectedHeight = 200; + bool expectedLossless = true; + bool expectedMetadata = true; + string expectedNamed = "named"; + double expectedOpacity = 0; + bool expectedOriginal = true; + Overlay expectedOverlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }; + Page expectedPage = 0; + bool expectedProgressive = true; + double expectedQuality = 80; + TransformationRadius expectedRadius = 20; + string expectedRaw = "raw"; + TransformationRotation expectedRotation = 90; + Shadow expectedShadow = new ShadowUnionMember0(); + Sharpen expectedSharpen = new SharpenUnionMember0(); + StartOffset expectedStartOffset = 0; + List> expectedStreamingResolutions = + [ + StreamingResolution.V240, + ]; + Trim expectedTrim = new TrimUnionMember0(); + UnsharpMask expectedUnsharpMask = new UnsharpMaskUnionMember0(); + ApiEnum expectedVideoCodec = VideoCodec.H264; + TransformationWidth expectedWidth = 300; + TransformationX expectedX = 0; + XCenter expectedXCenter = 0; + TransformationY expectedY = 0; + YCenter expectedYCenter = 0; + double expectedZoom = 0; + + Assert.Equal(expectedAIChangeBackground, deserialized.AIChangeBackground); + Assert.Equal(expectedAIDropShadow, deserialized.AIDropShadow); + Assert.Equal(expectedAIEdit, deserialized.AIEdit); + Assert.Equal(expectedAIRemoveBackground, deserialized.AIRemoveBackground); + Assert.Equal(expectedAIRemoveBackgroundExternal, deserialized.AIRemoveBackgroundExternal); + Assert.Equal(expectedAIRetouch, deserialized.AIRetouch); + Assert.Equal(expectedAIUpscale, deserialized.AIUpscale); + Assert.Equal(expectedAIVariation, deserialized.AIVariation); + Assert.Equal(expectedAspectRatio, deserialized.AspectRatio); + Assert.Equal(expectedAudioCodec, deserialized.AudioCodec); + Assert.Equal(expectedBackground, deserialized.Background); + Assert.Equal(expectedBlur, deserialized.Blur); + Assert.Equal(expectedBorder, deserialized.Border); + Assert.Equal(expectedColorProfile, deserialized.ColorProfile); + Assert.Equal(expectedColorReplace, deserialized.ColorReplace); + Assert.Equal(expectedContrastStretch, deserialized.ContrastStretch); + Assert.Equal(expectedCrop, deserialized.Crop); + Assert.Equal(expectedCropMode, deserialized.CropMode); + Assert.Equal(expectedDefaultImage, deserialized.DefaultImage); + Assert.Equal(expectedDistort, deserialized.Distort); + Assert.Equal(expectedDpr, deserialized.Dpr); + Assert.Equal(expectedDuration, deserialized.Duration); + Assert.Equal(expectedEndOffset, deserialized.EndOffset); + Assert.Equal(expectedFlip, deserialized.Flip); + Assert.Equal(expectedFocus, deserialized.Focus); + Assert.Equal(expectedFormat, deserialized.Format); + Assert.Equal(expectedGradient, deserialized.Gradient); + Assert.Equal(expectedGrayscale, deserialized.Grayscale); + Assert.Equal(expectedHeight, deserialized.Height); + Assert.Equal(expectedLossless, deserialized.Lossless); + Assert.Equal(expectedMetadata, deserialized.Metadata); + Assert.Equal(expectedNamed, deserialized.Named); + Assert.Equal(expectedOpacity, deserialized.Opacity); + Assert.Equal(expectedOriginal, deserialized.Original); + Assert.Equal(expectedOverlay, deserialized.Overlay); + Assert.Equal(expectedPage, deserialized.Page); + Assert.Equal(expectedProgressive, deserialized.Progressive); + Assert.Equal(expectedQuality, deserialized.Quality); + Assert.Equal(expectedRadius, deserialized.Radius); + Assert.Equal(expectedRaw, deserialized.Raw); + Assert.Equal(expectedRotation, deserialized.Rotation); + Assert.Equal(expectedShadow, deserialized.Shadow); + Assert.Equal(expectedSharpen, deserialized.Sharpen); + Assert.Equal(expectedStartOffset, deserialized.StartOffset); + Assert.NotNull(deserialized.StreamingResolutions); + Assert.Equal(expectedStreamingResolutions.Count, deserialized.StreamingResolutions.Count); + for (int i = 0; i < expectedStreamingResolutions.Count; i++) + { + Assert.Equal(expectedStreamingResolutions[i], deserialized.StreamingResolutions[i]); + } + Assert.Equal(expectedTrim, deserialized.Trim); + Assert.Equal(expectedUnsharpMask, deserialized.UnsharpMask); + Assert.Equal(expectedVideoCodec, deserialized.VideoCodec); + Assert.Equal(expectedWidth, deserialized.Width); + Assert.Equal(expectedX, deserialized.X); + Assert.Equal(expectedXCenter, deserialized.XCenter); + Assert.Equal(expectedY, deserialized.Y); + Assert.Equal(expectedYCenter, deserialized.YCenter); + Assert.Equal(expectedZoom, deserialized.Zoom); + } + + [Fact] + public void Validation_Works() + { + var model = new Transformation + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Transformation { }; + + Assert.Null(model.AIChangeBackground); + Assert.False(model.RawData.ContainsKey("aiChangeBackground")); + Assert.Null(model.AIDropShadow); + Assert.False(model.RawData.ContainsKey("aiDropShadow")); + Assert.Null(model.AIEdit); + Assert.False(model.RawData.ContainsKey("aiEdit")); + Assert.Null(model.AIRemoveBackground); + Assert.False(model.RawData.ContainsKey("aiRemoveBackground")); + Assert.Null(model.AIRemoveBackgroundExternal); + Assert.False(model.RawData.ContainsKey("aiRemoveBackgroundExternal")); + Assert.Null(model.AIRetouch); + Assert.False(model.RawData.ContainsKey("aiRetouch")); + Assert.Null(model.AIUpscale); + Assert.False(model.RawData.ContainsKey("aiUpscale")); + Assert.Null(model.AIVariation); + Assert.False(model.RawData.ContainsKey("aiVariation")); + Assert.Null(model.AspectRatio); + Assert.False(model.RawData.ContainsKey("aspectRatio")); + Assert.Null(model.AudioCodec); + Assert.False(model.RawData.ContainsKey("audioCodec")); + Assert.Null(model.Background); + Assert.False(model.RawData.ContainsKey("background")); + Assert.Null(model.Blur); + Assert.False(model.RawData.ContainsKey("blur")); + Assert.Null(model.Border); + Assert.False(model.RawData.ContainsKey("border")); + Assert.Null(model.ColorProfile); + Assert.False(model.RawData.ContainsKey("colorProfile")); + Assert.Null(model.ColorReplace); + Assert.False(model.RawData.ContainsKey("colorReplace")); + Assert.Null(model.ContrastStretch); + Assert.False(model.RawData.ContainsKey("contrastStretch")); + Assert.Null(model.Crop); + Assert.False(model.RawData.ContainsKey("crop")); + Assert.Null(model.CropMode); + Assert.False(model.RawData.ContainsKey("cropMode")); + Assert.Null(model.DefaultImage); + Assert.False(model.RawData.ContainsKey("defaultImage")); + Assert.Null(model.Distort); + Assert.False(model.RawData.ContainsKey("distort")); + Assert.Null(model.Dpr); + Assert.False(model.RawData.ContainsKey("dpr")); + Assert.Null(model.Duration); + Assert.False(model.RawData.ContainsKey("duration")); + Assert.Null(model.EndOffset); + Assert.False(model.RawData.ContainsKey("endOffset")); + Assert.Null(model.Flip); + Assert.False(model.RawData.ContainsKey("flip")); + Assert.Null(model.Focus); + Assert.False(model.RawData.ContainsKey("focus")); + Assert.Null(model.Format); + Assert.False(model.RawData.ContainsKey("format")); + Assert.Null(model.Gradient); + Assert.False(model.RawData.ContainsKey("gradient")); + Assert.Null(model.Grayscale); + Assert.False(model.RawData.ContainsKey("grayscale")); + Assert.Null(model.Height); + Assert.False(model.RawData.ContainsKey("height")); + Assert.Null(model.Lossless); + Assert.False(model.RawData.ContainsKey("lossless")); + Assert.Null(model.Metadata); + Assert.False(model.RawData.ContainsKey("metadata")); + Assert.Null(model.Named); + Assert.False(model.RawData.ContainsKey("named")); + Assert.Null(model.Opacity); + Assert.False(model.RawData.ContainsKey("opacity")); + Assert.Null(model.Original); + Assert.False(model.RawData.ContainsKey("original")); + Assert.Null(model.Overlay); + Assert.False(model.RawData.ContainsKey("overlay")); + Assert.Null(model.Page); + Assert.False(model.RawData.ContainsKey("page")); + Assert.Null(model.Progressive); + Assert.False(model.RawData.ContainsKey("progressive")); + Assert.Null(model.Quality); + Assert.False(model.RawData.ContainsKey("quality")); + Assert.Null(model.Radius); + Assert.False(model.RawData.ContainsKey("radius")); + Assert.Null(model.Raw); + Assert.False(model.RawData.ContainsKey("raw")); + Assert.Null(model.Rotation); + Assert.False(model.RawData.ContainsKey("rotation")); + Assert.Null(model.Shadow); + Assert.False(model.RawData.ContainsKey("shadow")); + Assert.Null(model.Sharpen); + Assert.False(model.RawData.ContainsKey("sharpen")); + Assert.Null(model.StartOffset); + Assert.False(model.RawData.ContainsKey("startOffset")); + Assert.Null(model.StreamingResolutions); + Assert.False(model.RawData.ContainsKey("streamingResolutions")); + Assert.Null(model.Trim); + Assert.False(model.RawData.ContainsKey("trim")); + Assert.Null(model.UnsharpMask); + Assert.False(model.RawData.ContainsKey("unsharpMask")); + Assert.Null(model.VideoCodec); + Assert.False(model.RawData.ContainsKey("videoCodec")); + Assert.Null(model.Width); + Assert.False(model.RawData.ContainsKey("width")); + Assert.Null(model.X); + Assert.False(model.RawData.ContainsKey("x")); + Assert.Null(model.XCenter); + Assert.False(model.RawData.ContainsKey("xCenter")); + Assert.Null(model.Y); + Assert.False(model.RawData.ContainsKey("y")); + Assert.Null(model.YCenter); + Assert.False(model.RawData.ContainsKey("yCenter")); + Assert.Null(model.Zoom); + Assert.False(model.RawData.ContainsKey("zoom")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new Transformation { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new Transformation + { + // Null should be interpreted as omitted for these properties + AIChangeBackground = null, + AIDropShadow = null, + AIEdit = null, + AIRemoveBackground = null, + AIRemoveBackgroundExternal = null, + AIRetouch = null, + AIUpscale = null, + AIVariation = null, + AspectRatio = null, + AudioCodec = null, + Background = null, + Blur = null, + Border = null, + ColorProfile = null, + ColorReplace = null, + ContrastStretch = null, + Crop = null, + CropMode = null, + DefaultImage = null, + Distort = null, + Dpr = null, + Duration = null, + EndOffset = null, + Flip = null, + Focus = null, + Format = null, + Gradient = null, + Grayscale = null, + Height = null, + Lossless = null, + Metadata = null, + Named = null, + Opacity = null, + Original = null, + Overlay = null, + Page = null, + Progressive = null, + Quality = null, + Radius = null, + Raw = null, + Rotation = null, + Shadow = null, + Sharpen = null, + StartOffset = null, + StreamingResolutions = null, + Trim = null, + UnsharpMask = null, + VideoCodec = null, + Width = null, + X = null, + XCenter = null, + Y = null, + YCenter = null, + Zoom = null, + }; + + Assert.Null(model.AIChangeBackground); + Assert.False(model.RawData.ContainsKey("aiChangeBackground")); + Assert.Null(model.AIDropShadow); + Assert.False(model.RawData.ContainsKey("aiDropShadow")); + Assert.Null(model.AIEdit); + Assert.False(model.RawData.ContainsKey("aiEdit")); + Assert.Null(model.AIRemoveBackground); + Assert.False(model.RawData.ContainsKey("aiRemoveBackground")); + Assert.Null(model.AIRemoveBackgroundExternal); + Assert.False(model.RawData.ContainsKey("aiRemoveBackgroundExternal")); + Assert.Null(model.AIRetouch); + Assert.False(model.RawData.ContainsKey("aiRetouch")); + Assert.Null(model.AIUpscale); + Assert.False(model.RawData.ContainsKey("aiUpscale")); + Assert.Null(model.AIVariation); + Assert.False(model.RawData.ContainsKey("aiVariation")); + Assert.Null(model.AspectRatio); + Assert.False(model.RawData.ContainsKey("aspectRatio")); + Assert.Null(model.AudioCodec); + Assert.False(model.RawData.ContainsKey("audioCodec")); + Assert.Null(model.Background); + Assert.False(model.RawData.ContainsKey("background")); + Assert.Null(model.Blur); + Assert.False(model.RawData.ContainsKey("blur")); + Assert.Null(model.Border); + Assert.False(model.RawData.ContainsKey("border")); + Assert.Null(model.ColorProfile); + Assert.False(model.RawData.ContainsKey("colorProfile")); + Assert.Null(model.ColorReplace); + Assert.False(model.RawData.ContainsKey("colorReplace")); + Assert.Null(model.ContrastStretch); + Assert.False(model.RawData.ContainsKey("contrastStretch")); + Assert.Null(model.Crop); + Assert.False(model.RawData.ContainsKey("crop")); + Assert.Null(model.CropMode); + Assert.False(model.RawData.ContainsKey("cropMode")); + Assert.Null(model.DefaultImage); + Assert.False(model.RawData.ContainsKey("defaultImage")); + Assert.Null(model.Distort); + Assert.False(model.RawData.ContainsKey("distort")); + Assert.Null(model.Dpr); + Assert.False(model.RawData.ContainsKey("dpr")); + Assert.Null(model.Duration); + Assert.False(model.RawData.ContainsKey("duration")); + Assert.Null(model.EndOffset); + Assert.False(model.RawData.ContainsKey("endOffset")); + Assert.Null(model.Flip); + Assert.False(model.RawData.ContainsKey("flip")); + Assert.Null(model.Focus); + Assert.False(model.RawData.ContainsKey("focus")); + Assert.Null(model.Format); + Assert.False(model.RawData.ContainsKey("format")); + Assert.Null(model.Gradient); + Assert.False(model.RawData.ContainsKey("gradient")); + Assert.Null(model.Grayscale); + Assert.False(model.RawData.ContainsKey("grayscale")); + Assert.Null(model.Height); + Assert.False(model.RawData.ContainsKey("height")); + Assert.Null(model.Lossless); + Assert.False(model.RawData.ContainsKey("lossless")); + Assert.Null(model.Metadata); + Assert.False(model.RawData.ContainsKey("metadata")); + Assert.Null(model.Named); + Assert.False(model.RawData.ContainsKey("named")); + Assert.Null(model.Opacity); + Assert.False(model.RawData.ContainsKey("opacity")); + Assert.Null(model.Original); + Assert.False(model.RawData.ContainsKey("original")); + Assert.Null(model.Overlay); + Assert.False(model.RawData.ContainsKey("overlay")); + Assert.Null(model.Page); + Assert.False(model.RawData.ContainsKey("page")); + Assert.Null(model.Progressive); + Assert.False(model.RawData.ContainsKey("progressive")); + Assert.Null(model.Quality); + Assert.False(model.RawData.ContainsKey("quality")); + Assert.Null(model.Radius); + Assert.False(model.RawData.ContainsKey("radius")); + Assert.Null(model.Raw); + Assert.False(model.RawData.ContainsKey("raw")); + Assert.Null(model.Rotation); + Assert.False(model.RawData.ContainsKey("rotation")); + Assert.Null(model.Shadow); + Assert.False(model.RawData.ContainsKey("shadow")); + Assert.Null(model.Sharpen); + Assert.False(model.RawData.ContainsKey("sharpen")); + Assert.Null(model.StartOffset); + Assert.False(model.RawData.ContainsKey("startOffset")); + Assert.Null(model.StreamingResolutions); + Assert.False(model.RawData.ContainsKey("streamingResolutions")); + Assert.Null(model.Trim); + Assert.False(model.RawData.ContainsKey("trim")); + Assert.Null(model.UnsharpMask); + Assert.False(model.RawData.ContainsKey("unsharpMask")); + Assert.Null(model.VideoCodec); + Assert.False(model.RawData.ContainsKey("videoCodec")); + Assert.Null(model.Width); + Assert.False(model.RawData.ContainsKey("width")); + Assert.Null(model.X); + Assert.False(model.RawData.ContainsKey("x")); + Assert.Null(model.XCenter); + Assert.False(model.RawData.ContainsKey("xCenter")); + Assert.Null(model.Y); + Assert.False(model.RawData.ContainsKey("y")); + Assert.Null(model.YCenter); + Assert.False(model.RawData.ContainsKey("yCenter")); + Assert.Null(model.Zoom); + Assert.False(model.RawData.ContainsKey("zoom")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new Transformation + { + // Null should be interpreted as omitted for these properties + AIChangeBackground = null, + AIDropShadow = null, + AIEdit = null, + AIRemoveBackground = null, + AIRemoveBackgroundExternal = null, + AIRetouch = null, + AIUpscale = null, + AIVariation = null, + AspectRatio = null, + AudioCodec = null, + Background = null, + Blur = null, + Border = null, + ColorProfile = null, + ColorReplace = null, + ContrastStretch = null, + Crop = null, + CropMode = null, + DefaultImage = null, + Distort = null, + Dpr = null, + Duration = null, + EndOffset = null, + Flip = null, + Focus = null, + Format = null, + Gradient = null, + Grayscale = null, + Height = null, + Lossless = null, + Metadata = null, + Named = null, + Opacity = null, + Original = null, + Overlay = null, + Page = null, + Progressive = null, + Quality = null, + Radius = null, + Raw = null, + Rotation = null, + Shadow = null, + Sharpen = null, + StartOffset = null, + StreamingResolutions = null, + Trim = null, + UnsharpMask = null, + VideoCodec = null, + Width = null, + X = null, + XCenter = null, + Y = null, + YCenter = null, + Zoom = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Transformation + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }; + + Transformation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class AIDropShadowTest : TestBase +{ + [Fact] + public void TrueValidationWorks() + { + AIDropShadow value = new AIDropShadowUnionMember0(); + value.Validate(); + } + + [Fact] + public void StringValidationWorks() + { + AIDropShadow value = "string"; + value.Validate(); + } + + [Fact] + public void TrueSerializationRoundtripWorks() + { + AIDropShadow value = new AIDropShadowUnionMember0(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + AIDropShadow value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class AIDropShadowUnionMember0Test : TestBase +{ + [Fact] + public void DefaultValidation_Works() + { + var constant = new AIDropShadowUnionMember0(); + constant.Validate(); + } + + [Fact] + public void ValidConstantValidation_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement(true), + ModelBase.SerializerOptions + ); + + Assert.NotNull(constant); + constant.Validate(); + } + + [Fact] + public void InvalidConstantValidationThrows_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(constant); + Assert.Throws(() => constant.Validate()); + } + + [Fact] + public void DefaultRoundtrip_Works() + { + var constant = new AIDropShadowUnionMember0(); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } + + [Fact] + public void ValidConstantRoundtrip_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement(true), + ModelBase.SerializerOptions + ); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } + + [Fact] + public void InvalidConstantRoundtrip_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } +} + +public class AIRemoveBackgroundTest : TestBase +{ + [Theory] + [InlineData(AIRemoveBackground.True)] + public void Validation_Works(AIRemoveBackground rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(AIRemoveBackground.True)] + public void SerializationRoundtrip_Works(AIRemoveBackground rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class AIRemoveBackgroundExternalTest : TestBase +{ + [Theory] + [InlineData(AIRemoveBackgroundExternal.True)] + public void Validation_Works(AIRemoveBackgroundExternal rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(AIRemoveBackgroundExternal.True)] + public void SerializationRoundtrip_Works(AIRemoveBackgroundExternal rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class AIRetouchTest : TestBase +{ + [Theory] + [InlineData(AIRetouch.True)] + public void Validation_Works(AIRetouch rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(AIRetouch.True)] + public void SerializationRoundtrip_Works(AIRetouch rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class AIUpscaleTest : TestBase +{ + [Theory] + [InlineData(AIUpscale.True)] + public void Validation_Works(AIUpscale rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(AIUpscale.True)] + public void SerializationRoundtrip_Works(AIUpscale rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class AIVariationTest : TestBase +{ + [Theory] + [InlineData(AIVariation.True)] + public void Validation_Works(AIVariation rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(AIVariation.True)] + public void SerializationRoundtrip_Works(AIVariation rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class AspectRatioTest : TestBase +{ + [Fact] + public void DoubleValidationWorks() + { + AspectRatio value = 0; + value.Validate(); + } + + [Fact] + public void StringValidationWorks() + { + AspectRatio value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + AspectRatio value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + AspectRatio value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class AudioCodecTest : TestBase +{ + [Theory] + [InlineData(AudioCodec.Aac)] + [InlineData(AudioCodec.Opus)] + [InlineData(AudioCodec.None)] + public void Validation_Works(AudioCodec rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(AudioCodec.Aac)] + [InlineData(AudioCodec.Opus)] + [InlineData(AudioCodec.None)] + public void SerializationRoundtrip_Works(AudioCodec rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class ContrastStretchTest : TestBase +{ + [Theory] + [InlineData(ContrastStretch.True)] + public void Validation_Works(ContrastStretch rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(ContrastStretch.True)] + public void SerializationRoundtrip_Works(ContrastStretch rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class CropTest : TestBase +{ + [Theory] + [InlineData(Crop.Force)] + [InlineData(Crop.AtMax)] + [InlineData(Crop.AtMaxEnlarge)] + [InlineData(Crop.AtLeast)] + [InlineData(Crop.MaintainRatio)] + public void Validation_Works(Crop rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(Crop.Force)] + [InlineData(Crop.AtMax)] + [InlineData(Crop.AtMaxEnlarge)] + [InlineData(Crop.AtLeast)] + [InlineData(Crop.MaintainRatio)] + public void SerializationRoundtrip_Works(Crop rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class CropModeTest : TestBase +{ + [Theory] + [InlineData(CropMode.PadResize)] + [InlineData(CropMode.Extract)] + [InlineData(CropMode.PadExtract)] + public void Validation_Works(CropMode rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(CropMode.PadResize)] + [InlineData(CropMode.Extract)] + [InlineData(CropMode.PadExtract)] + public void SerializationRoundtrip_Works(CropMode rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class TransformationDurationTest : TestBase +{ + [Fact] + public void DoubleValidationWorks() + { + TransformationDuration value = 0; + value.Validate(); + } + + [Fact] + public void StringValidationWorks() + { + TransformationDuration value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + TransformationDuration value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + TransformationDuration value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class EndOffsetTest : TestBase +{ + [Fact] + public void DoubleValidationWorks() + { + EndOffset value = 0; + value.Validate(); + } + + [Fact] + public void StringValidationWorks() + { + EndOffset value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + EndOffset value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + EndOffset value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class TransformationFlipTest : TestBase +{ + [Theory] + [InlineData(TransformationFlip.H)] + [InlineData(TransformationFlip.V)] + [InlineData(TransformationFlip.HV)] + [InlineData(TransformationFlip.VH)] + public void Validation_Works(TransformationFlip rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(TransformationFlip.H)] + [InlineData(TransformationFlip.V)] + [InlineData(TransformationFlip.HV)] + [InlineData(TransformationFlip.VH)] + public void SerializationRoundtrip_Works(TransformationFlip rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class FormatTest : TestBase +{ + [Theory] + [InlineData(Format.Auto)] + [InlineData(Format.Webp)] + [InlineData(Format.Jpg)] + [InlineData(Format.Jpeg)] + [InlineData(Format.Png)] + [InlineData(Format.Gif)] + [InlineData(Format.Svg)] + [InlineData(Format.Mp4)] + [InlineData(Format.Webm)] + [InlineData(Format.Avif)] + [InlineData(Format.Orig)] + public void Validation_Works(Format rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(Format.Auto)] + [InlineData(Format.Webp)] + [InlineData(Format.Jpg)] + [InlineData(Format.Jpeg)] + [InlineData(Format.Png)] + [InlineData(Format.Gif)] + [InlineData(Format.Svg)] + [InlineData(Format.Mp4)] + [InlineData(Format.Webm)] + [InlineData(Format.Avif)] + [InlineData(Format.Orig)] + public void SerializationRoundtrip_Works(Format rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class TransformationGradientTest : TestBase +{ + [Fact] + public void TrueValidationWorks() + { + TransformationGradient value = new TransformationGradientUnionMember0(); + value.Validate(); + } + + [Fact] + public void StringValidationWorks() + { + TransformationGradient value = "string"; + value.Validate(); + } + + [Fact] + public void TrueSerializationRoundtripWorks() + { + TransformationGradient value = new TransformationGradientUnionMember0(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + TransformationGradient value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class TransformationGradientUnionMember0Test : TestBase +{ + [Fact] + public void DefaultValidation_Works() + { + var constant = new TransformationGradientUnionMember0(); + constant.Validate(); + } + + [Fact] + public void ValidConstantValidation_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement(true), + ModelBase.SerializerOptions + ); + + Assert.NotNull(constant); + constant.Validate(); + } + + [Fact] + public void InvalidConstantValidationThrows_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(constant); + Assert.Throws(() => constant.Validate()); + } + + [Fact] + public void DefaultRoundtrip_Works() + { + var constant = new TransformationGradientUnionMember0(); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } + + [Fact] + public void ValidConstantRoundtrip_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement(true), + ModelBase.SerializerOptions + ); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } + + [Fact] + public void InvalidConstantRoundtrip_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } +} + +public class GrayscaleTest : TestBase +{ + [Theory] + [InlineData(Grayscale.True)] + public void Validation_Works(Grayscale rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(Grayscale.True)] + public void SerializationRoundtrip_Works(Grayscale rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class TransformationHeightTest : TestBase +{ + [Fact] + public void DoubleValidationWorks() + { + TransformationHeight value = 0; + value.Validate(); + } + + [Fact] + public void StringValidationWorks() + { + TransformationHeight value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + TransformationHeight value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + TransformationHeight value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class PageTest : TestBase +{ + [Fact] + public void DoubleValidationWorks() + { + Page value = 0; + value.Validate(); + } + + [Fact] + public void StringValidationWorks() + { + Page value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + Page value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + Page value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class TransformationRadiusTest : TestBase +{ + [Fact] + public void DoubleValidationWorks() + { + TransformationRadius value = 0; + value.Validate(); + } + + [Fact] + public void MaxValidationWorks() + { + TransformationRadius value = new TransformationRadiusUnionMember1(); + value.Validate(); + } + + [Fact] + public void StringValidationWorks() + { + TransformationRadius value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + TransformationRadius value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void MaxSerializationRoundtripWorks() + { + TransformationRadius value = new TransformationRadiusUnionMember1(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + TransformationRadius value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class TransformationRadiusUnionMember1Test : TestBase +{ + [Fact] + public void DefaultValidation_Works() + { + var constant = new TransformationRadiusUnionMember1(); + constant.Validate(); + } + + [Fact] + public void ValidConstantValidation_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement("max"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(constant); + constant.Validate(); + } + + [Fact] + public void InvalidConstantValidationThrows_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(constant); + Assert.Throws(() => constant.Validate()); + } + + [Fact] + public void DefaultRoundtrip_Works() + { + var constant = new TransformationRadiusUnionMember1(); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } + + [Fact] + public void ValidConstantRoundtrip_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement("max"), + ModelBase.SerializerOptions + ); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } + + [Fact] + public void InvalidConstantRoundtrip_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } +} + +public class TransformationRotationTest : TestBase +{ + [Fact] + public void DoubleValidationWorks() + { + TransformationRotation value = 0; + value.Validate(); + } + + [Fact] + public void StringValidationWorks() + { + TransformationRotation value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + TransformationRotation value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + TransformationRotation value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class ShadowTest : TestBase +{ + [Fact] + public void TrueValidationWorks() + { + Shadow value = new ShadowUnionMember0(); + value.Validate(); + } + + [Fact] + public void StringValidationWorks() + { + Shadow value = "string"; + value.Validate(); + } + + [Fact] + public void TrueSerializationRoundtripWorks() + { + Shadow value = new ShadowUnionMember0(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + Shadow value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class ShadowUnionMember0Test : TestBase +{ + [Fact] + public void DefaultValidation_Works() + { + var constant = new ShadowUnionMember0(); + constant.Validate(); + } + + [Fact] + public void ValidConstantValidation_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement(true), + ModelBase.SerializerOptions + ); + + Assert.NotNull(constant); + constant.Validate(); + } + + [Fact] + public void InvalidConstantValidationThrows_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(constant); + Assert.Throws(() => constant.Validate()); + } + + [Fact] + public void DefaultRoundtrip_Works() + { + var constant = new ShadowUnionMember0(); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } + + [Fact] + public void ValidConstantRoundtrip_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement(true), + ModelBase.SerializerOptions + ); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } + + [Fact] + public void InvalidConstantRoundtrip_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } +} + +public class SharpenTest : TestBase +{ + [Fact] + public void TrueValidationWorks() + { + Sharpen value = new SharpenUnionMember0(); + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + Sharpen value = 0; + value.Validate(); + } + + [Fact] + public void TrueSerializationRoundtripWorks() + { + Sharpen value = new SharpenUnionMember0(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + Sharpen value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class SharpenUnionMember0Test : TestBase +{ + [Fact] + public void DefaultValidation_Works() + { + var constant = new SharpenUnionMember0(); + constant.Validate(); + } + + [Fact] + public void ValidConstantValidation_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement(true), + ModelBase.SerializerOptions + ); + + Assert.NotNull(constant); + constant.Validate(); + } + + [Fact] + public void InvalidConstantValidationThrows_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(constant); + Assert.Throws(() => constant.Validate()); + } + + [Fact] + public void DefaultRoundtrip_Works() + { + var constant = new SharpenUnionMember0(); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } + + [Fact] + public void ValidConstantRoundtrip_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement(true), + ModelBase.SerializerOptions + ); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } + + [Fact] + public void InvalidConstantRoundtrip_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } +} + +public class StartOffsetTest : TestBase +{ + [Fact] + public void DoubleValidationWorks() + { + StartOffset value = 0; + value.Validate(); + } + + [Fact] + public void StringValidationWorks() + { + StartOffset value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + StartOffset value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + StartOffset value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class TrimTest : TestBase +{ + [Fact] + public void TrueValidationWorks() + { + Trim value = new TrimUnionMember0(); + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + Trim value = 0; + value.Validate(); + } + + [Fact] + public void TrueSerializationRoundtripWorks() + { + Trim value = new TrimUnionMember0(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + Trim value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class TrimUnionMember0Test : TestBase +{ + [Fact] + public void DefaultValidation_Works() + { + var constant = new TrimUnionMember0(); + constant.Validate(); + } + + [Fact] + public void ValidConstantValidation_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement(true), + ModelBase.SerializerOptions + ); + + Assert.NotNull(constant); + constant.Validate(); + } + + [Fact] + public void InvalidConstantValidationThrows_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(constant); + Assert.Throws(() => constant.Validate()); + } + + [Fact] + public void DefaultRoundtrip_Works() + { + var constant = new TrimUnionMember0(); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } + + [Fact] + public void ValidConstantRoundtrip_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement(true), + ModelBase.SerializerOptions + ); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } + + [Fact] + public void InvalidConstantRoundtrip_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } +} + +public class UnsharpMaskTest : TestBase +{ + [Fact] + public void TrueValidationWorks() + { + UnsharpMask value = new UnsharpMaskUnionMember0(); + value.Validate(); + } + + [Fact] + public void StringValidationWorks() + { + UnsharpMask value = "string"; + value.Validate(); + } + + [Fact] + public void TrueSerializationRoundtripWorks() + { + UnsharpMask value = new UnsharpMaskUnionMember0(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + UnsharpMask value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class UnsharpMaskUnionMember0Test : TestBase +{ + [Fact] + public void DefaultValidation_Works() + { + var constant = new UnsharpMaskUnionMember0(); + constant.Validate(); + } + + [Fact] + public void ValidConstantValidation_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement(true), + ModelBase.SerializerOptions + ); + + Assert.NotNull(constant); + constant.Validate(); + } + + [Fact] + public void InvalidConstantValidationThrows_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(constant); + Assert.Throws(() => constant.Validate()); + } + + [Fact] + public void DefaultRoundtrip_Works() + { + var constant = new UnsharpMaskUnionMember0(); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } + + [Fact] + public void ValidConstantRoundtrip_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement(true), + ModelBase.SerializerOptions + ); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } + + [Fact] + public void InvalidConstantRoundtrip_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } +} + +public class VideoCodecTest : TestBase +{ + [Theory] + [InlineData(VideoCodec.H264)] + [InlineData(VideoCodec.Vp9)] + [InlineData(VideoCodec.Av1)] + [InlineData(VideoCodec.None)] + public void Validation_Works(VideoCodec rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(VideoCodec.H264)] + [InlineData(VideoCodec.Vp9)] + [InlineData(VideoCodec.Av1)] + [InlineData(VideoCodec.None)] + public void SerializationRoundtrip_Works(VideoCodec rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class TransformationWidthTest : TestBase +{ + [Fact] + public void DoubleValidationWorks() + { + TransformationWidth value = 0; + value.Validate(); + } + + [Fact] + public void StringValidationWorks() + { + TransformationWidth value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + TransformationWidth value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + TransformationWidth value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class TransformationXTest : TestBase +{ + [Fact] + public void DoubleValidationWorks() + { + TransformationX value = 0; + value.Validate(); + } + + [Fact] + public void StringValidationWorks() + { + TransformationX value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + TransformationX value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + TransformationX value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class XCenterTest : TestBase +{ + [Fact] + public void DoubleValidationWorks() + { + XCenter value = 0; + value.Validate(); + } + + [Fact] + public void StringValidationWorks() + { + XCenter value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + XCenter value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + XCenter value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class TransformationYTest : TestBase +{ + [Fact] + public void DoubleValidationWorks() + { + TransformationY value = 0; + value.Validate(); + } + + [Fact] + public void StringValidationWorks() + { + TransformationY value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + TransformationY value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + TransformationY value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class YCenterTest : TestBase +{ + [Fact] + public void DoubleValidationWorks() + { + YCenter value = 0; + value.Validate(); + } + + [Fact] + public void StringValidationWorks() + { + YCenter value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + YCenter value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + YCenter value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} diff --git a/src/ImageKit.Tests/Models/UnnamedSchemaWithArrayParent0Test.cs b/src/ImageKit.Tests/Models/UnnamedSchemaWithArrayParent0Test.cs new file mode 100644 index 00000000..27f3c47e --- /dev/null +++ b/src/ImageKit.Tests/Models/UnnamedSchemaWithArrayParent0Test.cs @@ -0,0 +1,3479 @@ +using System.Collections.Generic; +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Exceptions; +using ImageKit.Models; + +namespace ImageKit.Tests.Models; + +public class UnnamedSchemaWithArrayParent0Test : TestBase +{ + [Fact] + public void RemoveBgValidationWorks() + { + UnnamedSchemaWithArrayParent0 value = new UnnamedSchemaWithArrayParent0RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }; + value.Validate(); + } + + [Fact] + public void AutoTaggingExtensionValidationWorks() + { + UnnamedSchemaWithArrayParent0 value = + new UnnamedSchemaWithArrayParent0AutoTaggingExtension() + { + MaxTags = 0, + MinConfidence = 0, + Name = UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + }; + value.Validate(); + } + + [Fact] + public void AIAutoDescriptionValidationWorks() + { + UnnamedSchemaWithArrayParent0 value = new UnnamedSchemaWithArrayParent0AIAutoDescription(); + value.Validate(); + } + + [Fact] + public void AITasksValidationWorks() + { + UnnamedSchemaWithArrayParent0 value = new UnnamedSchemaWithArrayParent0AITasks( + [ + new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }, + ] + ); + value.Validate(); + } + + [Fact] + public void SavedExtensionValidationWorks() + { + UnnamedSchemaWithArrayParent0 value = new SavedExtension("ext_abc123"); + value.Validate(); + } + + [Fact] + public void RemoveBgSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent0 value = new UnnamedSchemaWithArrayParent0RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void AutoTaggingExtensionSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent0 value = + new UnnamedSchemaWithArrayParent0AutoTaggingExtension() + { + MaxTags = 0, + MinConfidence = 0, + Name = UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void AIAutoDescriptionSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent0 value = new UnnamedSchemaWithArrayParent0AIAutoDescription(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void AITasksSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent0 value = new UnnamedSchemaWithArrayParent0AITasks( + [ + new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }, + ] + ); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void SavedExtensionSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent0 value = new SavedExtension("ext_abc123"); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class UnnamedSchemaWithArrayParent0RemoveBgTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UnnamedSchemaWithArrayParent0RemoveBg + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }; + + JsonElement expectedName = JsonSerializer.SerializeToElement("remove-bg"); + UnnamedSchemaWithArrayParent0RemoveBgOptions expectedOptions = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }; + + Assert.True(JsonElement.DeepEquals(expectedName, model.Name)); + Assert.Equal(expectedOptions, model.Options); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UnnamedSchemaWithArrayParent0RemoveBg + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new UnnamedSchemaWithArrayParent0RemoveBg + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + JsonElement expectedName = JsonSerializer.SerializeToElement("remove-bg"); + UnnamedSchemaWithArrayParent0RemoveBgOptions expectedOptions = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }; + + Assert.True(JsonElement.DeepEquals(expectedName, deserialized.Name)); + Assert.Equal(expectedOptions, deserialized.Options); + } + + [Fact] + public void Validation_Works() + { + var model = new UnnamedSchemaWithArrayParent0RemoveBg + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new UnnamedSchemaWithArrayParent0RemoveBg { }; + + Assert.Null(model.Options); + Assert.False(model.RawData.ContainsKey("options")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new UnnamedSchemaWithArrayParent0RemoveBg { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new UnnamedSchemaWithArrayParent0RemoveBg + { + // Null should be interpreted as omitted for these properties + Options = null, + }; + + Assert.Null(model.Options); + Assert.False(model.RawData.ContainsKey("options")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new UnnamedSchemaWithArrayParent0RemoveBg + { + // Null should be interpreted as omitted for these properties + Options = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnnamedSchemaWithArrayParent0RemoveBg + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }; + + UnnamedSchemaWithArrayParent0RemoveBg copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UnnamedSchemaWithArrayParent0RemoveBgOptionsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UnnamedSchemaWithArrayParent0RemoveBgOptions + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }; + + bool expectedAddShadow = true; + string expectedBgColor = "bg_color"; + string expectedBgImageUrl = "bg_image_url"; + bool expectedSemitransparency = true; + + Assert.Equal(expectedAddShadow, model.AddShadow); + Assert.Equal(expectedBgColor, model.BgColor); + Assert.Equal(expectedBgImageUrl, model.BgImageUrl); + Assert.Equal(expectedSemitransparency, model.Semitransparency); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UnnamedSchemaWithArrayParent0RemoveBgOptions + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new UnnamedSchemaWithArrayParent0RemoveBgOptions + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + bool expectedAddShadow = true; + string expectedBgColor = "bg_color"; + string expectedBgImageUrl = "bg_image_url"; + bool expectedSemitransparency = true; + + Assert.Equal(expectedAddShadow, deserialized.AddShadow); + Assert.Equal(expectedBgColor, deserialized.BgColor); + Assert.Equal(expectedBgImageUrl, deserialized.BgImageUrl); + Assert.Equal(expectedSemitransparency, deserialized.Semitransparency); + } + + [Fact] + public void Validation_Works() + { + var model = new UnnamedSchemaWithArrayParent0RemoveBgOptions + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new UnnamedSchemaWithArrayParent0RemoveBgOptions { }; + + Assert.Null(model.AddShadow); + Assert.False(model.RawData.ContainsKey("add_shadow")); + Assert.Null(model.BgColor); + Assert.False(model.RawData.ContainsKey("bg_color")); + Assert.Null(model.BgImageUrl); + Assert.False(model.RawData.ContainsKey("bg_image_url")); + Assert.Null(model.Semitransparency); + Assert.False(model.RawData.ContainsKey("semitransparency")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new UnnamedSchemaWithArrayParent0RemoveBgOptions { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new UnnamedSchemaWithArrayParent0RemoveBgOptions + { + // Null should be interpreted as omitted for these properties + AddShadow = null, + BgColor = null, + BgImageUrl = null, + Semitransparency = null, + }; + + Assert.Null(model.AddShadow); + Assert.False(model.RawData.ContainsKey("add_shadow")); + Assert.Null(model.BgColor); + Assert.False(model.RawData.ContainsKey("bg_color")); + Assert.Null(model.BgImageUrl); + Assert.False(model.RawData.ContainsKey("bg_image_url")); + Assert.Null(model.Semitransparency); + Assert.False(model.RawData.ContainsKey("semitransparency")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new UnnamedSchemaWithArrayParent0RemoveBgOptions + { + // Null should be interpreted as omitted for these properties + AddShadow = null, + BgColor = null, + BgImageUrl = null, + Semitransparency = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnnamedSchemaWithArrayParent0RemoveBgOptions + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }; + + UnnamedSchemaWithArrayParent0RemoveBgOptions copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UnnamedSchemaWithArrayParent0AutoTaggingExtensionTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UnnamedSchemaWithArrayParent0AutoTaggingExtension + { + MaxTags = 0, + MinConfidence = 0, + Name = UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + }; + + long expectedMaxTags = 0; + long expectedMinConfidence = 0; + ApiEnum expectedName = + UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging; + + Assert.Equal(expectedMaxTags, model.MaxTags); + Assert.Equal(expectedMinConfidence, model.MinConfidence); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UnnamedSchemaWithArrayParent0AutoTaggingExtension + { + MaxTags = 0, + MinConfidence = 0, + Name = UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new UnnamedSchemaWithArrayParent0AutoTaggingExtension + { + MaxTags = 0, + MinConfidence = 0, + Name = UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + long expectedMaxTags = 0; + long expectedMinConfidence = 0; + ApiEnum expectedName = + UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging; + + Assert.Equal(expectedMaxTags, deserialized.MaxTags); + Assert.Equal(expectedMinConfidence, deserialized.MinConfidence); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new UnnamedSchemaWithArrayParent0AutoTaggingExtension + { + MaxTags = 0, + MinConfidence = 0, + Name = UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnnamedSchemaWithArrayParent0AutoTaggingExtension + { + MaxTags = 0, + MinConfidence = 0, + Name = UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + }; + + UnnamedSchemaWithArrayParent0AutoTaggingExtension copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UnnamedSchemaWithArrayParent0AutoTaggingExtensionNameTest : TestBase +{ + [Theory] + [InlineData(UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging)] + [InlineData(UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.AwsAutoTagging)] + public void Validation_Works(UnnamedSchemaWithArrayParent0AutoTaggingExtensionName rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging)] + [InlineData(UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.AwsAutoTagging)] + public void SerializationRoundtrip_Works( + UnnamedSchemaWithArrayParent0AutoTaggingExtensionName rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class UnnamedSchemaWithArrayParent0AIAutoDescriptionTest : TestBase +{ + [Fact] + public void DefaultValidation_Works() + { + var constant = new UnnamedSchemaWithArrayParent0AIAutoDescription(); + constant.Validate(); + } + + [Fact] + public void ValidConstantValidation_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.Deserialize( + """ + { + "name": "ai-auto-description" + } + """ + ), + ModelBase.SerializerOptions + ); + + Assert.NotNull(constant); + constant.Validate(); + } + + [Fact] + public void InvalidConstantValidationThrows_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(constant); + Assert.Throws(() => constant.Validate()); + } + + [Fact] + public void DefaultRoundtrip_Works() + { + var constant = new UnnamedSchemaWithArrayParent0AIAutoDescription(); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } + + [Fact] + public void ValidConstantRoundtrip_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.Deserialize( + """ + { + "name": "ai-auto-description" + } + """ + ), + ModelBase.SerializerOptions + ); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } + + [Fact] + public void InvalidConstantRoundtrip_Works() + { + var constant = JsonSerializer.Deserialize( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(constant, deserialized); + } +} + +public class UnnamedSchemaWithArrayParent0AITasksTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasks + { + Tasks = + [ + new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }, + ], + }; + + JsonElement expectedName = JsonSerializer.SerializeToElement("ai-tasks"); + List expectedTasks = + [ + new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }, + ]; + + Assert.True(JsonElement.DeepEquals(expectedName, model.Name)); + Assert.Equal(expectedTasks.Count, model.Tasks.Count); + for (int i = 0; i < expectedTasks.Count; i++) + { + Assert.Equal(expectedTasks[i], model.Tasks[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasks + { + Tasks = + [ + new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }, + ], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasks + { + Tasks = + [ + new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + JsonElement expectedName = JsonSerializer.SerializeToElement("ai-tasks"); + List expectedTasks = + [ + new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }, + ]; + + Assert.True(JsonElement.DeepEquals(expectedName, deserialized.Name)); + Assert.Equal(expectedTasks.Count, deserialized.Tasks.Count); + for (int i = 0; i < expectedTasks.Count; i++) + { + Assert.Equal(expectedTasks[i], deserialized.Tasks[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasks + { + Tasks = + [ + new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasks + { + Tasks = + [ + new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }, + ], + }; + + UnnamedSchemaWithArrayParent0AITasks copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UnnamedSchemaWithArrayParent0AITasksTaskTest : TestBase +{ + [Fact] + public void SelectTagsValidationWorks() + { + UnnamedSchemaWithArrayParent0AITasksTask value = + new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }; + value.Validate(); + } + + [Fact] + public void SelectMetadataValidationWorks() + { + UnnamedSchemaWithArrayParent0AITasksTask value = + new UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata() + { + Field = "primary_color", + Instruction = "What is the primary color of the clothing?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["red", "blue", "green", "black", "white"], + }; + value.Validate(); + } + + [Fact] + public void YesNoValidationWorks() + { + UnnamedSchemaWithArrayParent0AITasksTask value = + new UnnamedSchemaWithArrayParent0AITasksTaskYesNo() + { + Instruction = "Is this a luxury or high-end fashion item?", + OnNo = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnUnknown = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnYes = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + }; + value.Validate(); + } + + [Fact] + public void SelectTagsSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent0AITasksTask value = + new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void SelectMetadataSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent0AITasksTask value = + new UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata() + { + Field = "primary_color", + Instruction = "What is the primary color of the clothing?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["red", "blue", "green", "black", "white"], + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void YesNoSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent0AITasksTask value = + new UnnamedSchemaWithArrayParent0AITasksTaskYesNo() + { + Instruction = "Is this a luxury or high-end fashion item?", + OnNo = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnUnknown = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnYes = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class UnnamedSchemaWithArrayParent0AITasksTaskSelectTagsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }; + + string expectedInstruction = "What types of clothing items are visible in this image?"; + JsonElement expectedType = JsonSerializer.SerializeToElement("select_tags"); + long expectedMaxSelections = 1; + long expectedMinSelections = 0; + List expectedVocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"]; + + Assert.Equal(expectedInstruction, model.Instruction); + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + Assert.Equal(expectedMaxSelections, model.MaxSelections); + Assert.Equal(expectedMinSelections, model.MinSelections); + Assert.NotNull(model.Vocabulary); + Assert.Equal(expectedVocabulary.Count, model.Vocabulary.Count); + for (int i = 0; i < expectedVocabulary.Count; i++) + { + Assert.Equal(expectedVocabulary[i], model.Vocabulary[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedInstruction = "What types of clothing items are visible in this image?"; + JsonElement expectedType = JsonSerializer.SerializeToElement("select_tags"); + long expectedMaxSelections = 1; + long expectedMinSelections = 0; + List expectedVocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"]; + + Assert.Equal(expectedInstruction, deserialized.Instruction); + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + Assert.Equal(expectedMaxSelections, deserialized.MaxSelections); + Assert.Equal(expectedMinSelections, deserialized.MinSelections); + Assert.NotNull(deserialized.Vocabulary); + Assert.Equal(expectedVocabulary.Count, deserialized.Vocabulary.Count); + for (int i = 0; i < expectedVocabulary.Count; i++) + { + Assert.Equal(expectedVocabulary[i], deserialized.Vocabulary[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags + { + Instruction = "What types of clothing items are visible in this image?", + }; + + Assert.Null(model.MaxSelections); + Assert.False(model.RawData.ContainsKey("max_selections")); + Assert.Null(model.MinSelections); + Assert.False(model.RawData.ContainsKey("min_selections")); + Assert.Null(model.Vocabulary); + Assert.False(model.RawData.ContainsKey("vocabulary")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags + { + Instruction = "What types of clothing items are visible in this image?", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags + { + Instruction = "What types of clothing items are visible in this image?", + + // Null should be interpreted as omitted for these properties + MaxSelections = null, + MinSelections = null, + Vocabulary = null, + }; + + Assert.Null(model.MaxSelections); + Assert.False(model.RawData.ContainsKey("max_selections")); + Assert.Null(model.MinSelections); + Assert.False(model.RawData.ContainsKey("min_selections")); + Assert.Null(model.Vocabulary); + Assert.False(model.RawData.ContainsKey("vocabulary")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags + { + Instruction = "What types of clothing items are visible in this image?", + + // Null should be interpreted as omitted for these properties + MaxSelections = null, + MinSelections = null, + Vocabulary = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }; + + UnnamedSchemaWithArrayParent0AITasksTaskSelectTags copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata + { + Field = "primary_color", + Instruction = "What is the primary color of the clothing?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["red", "blue", "green", "black", "white"], + }; + + string expectedField = "primary_color"; + string expectedInstruction = "What is the primary color of the clothing?"; + JsonElement expectedType = JsonSerializer.SerializeToElement("select_metadata"); + long expectedMaxSelections = 1; + long expectedMinSelections = 0; + List expectedVocabulary = + [ + "red", + "blue", + "green", + "black", + "white", + ]; + + Assert.Equal(expectedField, model.Field); + Assert.Equal(expectedInstruction, model.Instruction); + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + Assert.Equal(expectedMaxSelections, model.MaxSelections); + Assert.Equal(expectedMinSelections, model.MinSelections); + Assert.NotNull(model.Vocabulary); + Assert.Equal(expectedVocabulary.Count, model.Vocabulary.Count); + for (int i = 0; i < expectedVocabulary.Count; i++) + { + Assert.Equal(expectedVocabulary[i], model.Vocabulary[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata + { + Field = "primary_color", + Instruction = "What is the primary color of the clothing?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["red", "blue", "green", "black", "white"], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata + { + Field = "primary_color", + Instruction = "What is the primary color of the clothing?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["red", "blue", "green", "black", "white"], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedField = "primary_color"; + string expectedInstruction = "What is the primary color of the clothing?"; + JsonElement expectedType = JsonSerializer.SerializeToElement("select_metadata"); + long expectedMaxSelections = 1; + long expectedMinSelections = 0; + List expectedVocabulary = + [ + "red", + "blue", + "green", + "black", + "white", + ]; + + Assert.Equal(expectedField, deserialized.Field); + Assert.Equal(expectedInstruction, deserialized.Instruction); + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + Assert.Equal(expectedMaxSelections, deserialized.MaxSelections); + Assert.Equal(expectedMinSelections, deserialized.MinSelections); + Assert.NotNull(deserialized.Vocabulary); + Assert.Equal(expectedVocabulary.Count, deserialized.Vocabulary.Count); + for (int i = 0; i < expectedVocabulary.Count; i++) + { + Assert.Equal(expectedVocabulary[i], deserialized.Vocabulary[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata + { + Field = "primary_color", + Instruction = "What is the primary color of the clothing?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["red", "blue", "green", "black", "white"], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata + { + Field = "primary_color", + Instruction = "What is the primary color of the clothing?", + }; + + Assert.Null(model.MaxSelections); + Assert.False(model.RawData.ContainsKey("max_selections")); + Assert.Null(model.MinSelections); + Assert.False(model.RawData.ContainsKey("min_selections")); + Assert.Null(model.Vocabulary); + Assert.False(model.RawData.ContainsKey("vocabulary")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata + { + Field = "primary_color", + Instruction = "What is the primary color of the clothing?", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata + { + Field = "primary_color", + Instruction = "What is the primary color of the clothing?", + + // Null should be interpreted as omitted for these properties + MaxSelections = null, + MinSelections = null, + Vocabulary = null, + }; + + Assert.Null(model.MaxSelections); + Assert.False(model.RawData.ContainsKey("max_selections")); + Assert.Null(model.MinSelections); + Assert.False(model.RawData.ContainsKey("min_selections")); + Assert.Null(model.Vocabulary); + Assert.False(model.RawData.ContainsKey("vocabulary")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata + { + Field = "primary_color", + Instruction = "What is the primary color of the clothing?", + + // Null should be interpreted as omitted for these properties + MaxSelections = null, + MinSelections = null, + Vocabulary = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata + { + Field = "primary_color", + Instruction = "What is the primary color of the clothing?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["red", "blue", "green", "black", "white"], + }; + + UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabularyTest : TestBase +{ + [Fact] + public void StringValidationWorks() + { + UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabulary value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabulary value = 0; + value.Validate(); + } + + [Fact] + public void BoolValidationWorks() + { + UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabulary value = true; + value.Validate(); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabulary value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabulary value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void BoolSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabulary value = true; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class UnnamedSchemaWithArrayParent0AITasksTaskYesNoTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNo + { + Instruction = "Is this a luxury or high-end fashion item?", + OnNo = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnUnknown = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnYes = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + }; + + string expectedInstruction = "Is this a luxury or high-end fashion item?"; + JsonElement expectedType = JsonSerializer.SerializeToElement("yes_no"); + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo expectedOnNo = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }; + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown expectedOnUnknown = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }; + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYes expectedOnYes = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }; + + Assert.Equal(expectedInstruction, model.Instruction); + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + Assert.Equal(expectedOnNo, model.OnNo); + Assert.Equal(expectedOnUnknown, model.OnUnknown); + Assert.Equal(expectedOnYes, model.OnYes); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNo + { + Instruction = "Is this a luxury or high-end fashion item?", + OnNo = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnUnknown = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnYes = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNo + { + Instruction = "Is this a luxury or high-end fashion item?", + OnNo = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnUnknown = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnYes = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedInstruction = "Is this a luxury or high-end fashion item?"; + JsonElement expectedType = JsonSerializer.SerializeToElement("yes_no"); + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo expectedOnNo = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }; + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown expectedOnUnknown = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }; + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYes expectedOnYes = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }; + + Assert.Equal(expectedInstruction, deserialized.Instruction); + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + Assert.Equal(expectedOnNo, deserialized.OnNo); + Assert.Equal(expectedOnUnknown, deserialized.OnUnknown); + Assert.Equal(expectedOnYes, deserialized.OnYes); + } + + [Fact] + public void Validation_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNo + { + Instruction = "Is this a luxury or high-end fashion item?", + OnNo = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnUnknown = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnYes = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNo + { + Instruction = "Is this a luxury or high-end fashion item?", + }; + + Assert.Null(model.OnNo); + Assert.False(model.RawData.ContainsKey("on_no")); + Assert.Null(model.OnUnknown); + Assert.False(model.RawData.ContainsKey("on_unknown")); + Assert.Null(model.OnYes); + Assert.False(model.RawData.ContainsKey("on_yes")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNo + { + Instruction = "Is this a luxury or high-end fashion item?", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNo + { + Instruction = "Is this a luxury or high-end fashion item?", + + // Null should be interpreted as omitted for these properties + OnNo = null, + OnUnknown = null, + OnYes = null, + }; + + Assert.Null(model.OnNo); + Assert.False(model.RawData.ContainsKey("on_no")); + Assert.Null(model.OnUnknown); + Assert.False(model.RawData.ContainsKey("on_unknown")); + Assert.Null(model.OnYes); + Assert.False(model.RawData.ContainsKey("on_yes")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNo + { + Instruction = "Is this a luxury or high-end fashion item?", + + // Null should be interpreted as omitted for these properties + OnNo = null, + OnUnknown = null, + OnYes = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNo + { + Instruction = "Is this a luxury or high-end fashion item?", + OnNo = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnUnknown = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnYes = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + }; + + UnnamedSchemaWithArrayParent0AITasksTaskYesNo copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }; + + List expectedAddTags = ["luxury", "premium"]; + List expectedRemoveTags = ["budget", "affordable"]; + List expectedSetMetadata = + [ + new() { Field = "price_range", Value = "premium" }, + ]; + List expectedUnsetMetadata = + [ + new("price_range"), + ]; + + Assert.NotNull(model.AddTags); + Assert.Equal(expectedAddTags.Count, model.AddTags.Count); + for (int i = 0; i < expectedAddTags.Count; i++) + { + Assert.Equal(expectedAddTags[i], model.AddTags[i]); + } + Assert.NotNull(model.RemoveTags); + Assert.Equal(expectedRemoveTags.Count, model.RemoveTags.Count); + for (int i = 0; i < expectedRemoveTags.Count; i++) + { + Assert.Equal(expectedRemoveTags[i], model.RemoveTags[i]); + } + Assert.NotNull(model.SetMetadata); + Assert.Equal(expectedSetMetadata.Count, model.SetMetadata.Count); + for (int i = 0; i < expectedSetMetadata.Count; i++) + { + Assert.Equal(expectedSetMetadata[i], model.SetMetadata[i]); + } + Assert.NotNull(model.UnsetMetadata); + Assert.Equal(expectedUnsetMetadata.Count, model.UnsetMetadata.Count); + for (int i = 0; i < expectedUnsetMetadata.Count; i++) + { + Assert.Equal(expectedUnsetMetadata[i], model.UnsetMetadata[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedAddTags = ["luxury", "premium"]; + List expectedRemoveTags = ["budget", "affordable"]; + List expectedSetMetadata = + [ + new() { Field = "price_range", Value = "premium" }, + ]; + List expectedUnsetMetadata = + [ + new("price_range"), + ]; + + Assert.NotNull(deserialized.AddTags); + Assert.Equal(expectedAddTags.Count, deserialized.AddTags.Count); + for (int i = 0; i < expectedAddTags.Count; i++) + { + Assert.Equal(expectedAddTags[i], deserialized.AddTags[i]); + } + Assert.NotNull(deserialized.RemoveTags); + Assert.Equal(expectedRemoveTags.Count, deserialized.RemoveTags.Count); + for (int i = 0; i < expectedRemoveTags.Count; i++) + { + Assert.Equal(expectedRemoveTags[i], deserialized.RemoveTags[i]); + } + Assert.NotNull(deserialized.SetMetadata); + Assert.Equal(expectedSetMetadata.Count, deserialized.SetMetadata.Count); + for (int i = 0; i < expectedSetMetadata.Count; i++) + { + Assert.Equal(expectedSetMetadata[i], deserialized.SetMetadata[i]); + } + Assert.NotNull(deserialized.UnsetMetadata); + Assert.Equal(expectedUnsetMetadata.Count, deserialized.UnsetMetadata.Count); + for (int i = 0; i < expectedUnsetMetadata.Count; i++) + { + Assert.Equal(expectedUnsetMetadata[i], deserialized.UnsetMetadata[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo { }; + + Assert.Null(model.AddTags); + Assert.False(model.RawData.ContainsKey("add_tags")); + Assert.Null(model.RemoveTags); + Assert.False(model.RawData.ContainsKey("remove_tags")); + Assert.Null(model.SetMetadata); + Assert.False(model.RawData.ContainsKey("set_metadata")); + Assert.Null(model.UnsetMetadata); + Assert.False(model.RawData.ContainsKey("unset_metadata")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo + { + // Null should be interpreted as omitted for these properties + AddTags = null, + RemoveTags = null, + SetMetadata = null, + UnsetMetadata = null, + }; + + Assert.Null(model.AddTags); + Assert.False(model.RawData.ContainsKey("add_tags")); + Assert.Null(model.RemoveTags); + Assert.False(model.RawData.ContainsKey("remove_tags")); + Assert.Null(model.SetMetadata); + Assert.False(model.RawData.ContainsKey("set_metadata")); + Assert.Null(model.UnsetMetadata); + Assert.False(model.RawData.ContainsKey("unset_metadata")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo + { + // Null should be interpreted as omitted for these properties + AddTags = null, + RemoveTags = null, + SetMetadata = null, + UnsetMetadata = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }; + + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadata + { + Field = "field", + Value = "string", + }; + + string expectedField = "field"; + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue expectedValue = "string"; + + Assert.Equal(expectedField, model.Field); + Assert.Equal(expectedValue, model.Value); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadata + { + Field = "field", + Value = "string", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadata + { + Field = "field", + Value = "string", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedField = "field"; + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue expectedValue = "string"; + + Assert.Equal(expectedField, deserialized.Field); + Assert.Equal(expectedValue, deserialized.Value); + } + + [Fact] + public void Validation_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadata + { + Field = "field", + Value = "string", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadata + { + Field = "field", + Value = "string", + }; + + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadata copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueTest : TestBase +{ + [Fact] + public void StringValidationWorks() + { + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue value = 0; + value.Validate(); + } + + [Fact] + public void BoolValidationWorks() + { + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue value = true; + value.Validate(); + } + + [Fact] + public void MixedValidationWorks() + { + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue value = new( + [new UnnamedSchemaWithArrayParent6("string")] + ); + value.Validate(); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void BoolSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue value = true; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void MixedSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue value = new( + [new UnnamedSchemaWithArrayParent6("string")] + ); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class UnnamedSchemaWithArrayParent6Test : TestBase +{ + [Fact] + public void StringValidationWorks() + { + UnnamedSchemaWithArrayParent6 value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + UnnamedSchemaWithArrayParent6 value = 0; + value.Validate(); + } + + [Fact] + public void BoolValidationWorks() + { + UnnamedSchemaWithArrayParent6 value = true; + value.Validate(); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent6 value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent6 value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void BoolSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent6 value = true; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoUnsetMetadataTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoUnsetMetadata + { + Field = "field", + }; + + string expectedField = "field"; + + Assert.Equal(expectedField, model.Field); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoUnsetMetadata + { + Field = "field", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoUnsetMetadata + { + Field = "field", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedField = "field"; + + Assert.Equal(expectedField, deserialized.Field); + } + + [Fact] + public void Validation_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoUnsetMetadata + { + Field = "field", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoUnsetMetadata + { + Field = "field", + }; + + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoUnsetMetadata copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }; + + List expectedAddTags = ["luxury", "premium"]; + List expectedRemoveTags = ["budget", "affordable"]; + List expectedSetMetadata = + [ + new() { Field = "price_range", Value = "premium" }, + ]; + List expectedUnsetMetadata = + [ + new("price_range"), + ]; + + Assert.NotNull(model.AddTags); + Assert.Equal(expectedAddTags.Count, model.AddTags.Count); + for (int i = 0; i < expectedAddTags.Count; i++) + { + Assert.Equal(expectedAddTags[i], model.AddTags[i]); + } + Assert.NotNull(model.RemoveTags); + Assert.Equal(expectedRemoveTags.Count, model.RemoveTags.Count); + for (int i = 0; i < expectedRemoveTags.Count; i++) + { + Assert.Equal(expectedRemoveTags[i], model.RemoveTags[i]); + } + Assert.NotNull(model.SetMetadata); + Assert.Equal(expectedSetMetadata.Count, model.SetMetadata.Count); + for (int i = 0; i < expectedSetMetadata.Count; i++) + { + Assert.Equal(expectedSetMetadata[i], model.SetMetadata[i]); + } + Assert.NotNull(model.UnsetMetadata); + Assert.Equal(expectedUnsetMetadata.Count, model.UnsetMetadata.Count); + for (int i = 0; i < expectedUnsetMetadata.Count; i++) + { + Assert.Equal(expectedUnsetMetadata[i], model.UnsetMetadata[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedAddTags = ["luxury", "premium"]; + List expectedRemoveTags = ["budget", "affordable"]; + List expectedSetMetadata = + [ + new() { Field = "price_range", Value = "premium" }, + ]; + List expectedUnsetMetadata = + [ + new("price_range"), + ]; + + Assert.NotNull(deserialized.AddTags); + Assert.Equal(expectedAddTags.Count, deserialized.AddTags.Count); + for (int i = 0; i < expectedAddTags.Count; i++) + { + Assert.Equal(expectedAddTags[i], deserialized.AddTags[i]); + } + Assert.NotNull(deserialized.RemoveTags); + Assert.Equal(expectedRemoveTags.Count, deserialized.RemoveTags.Count); + for (int i = 0; i < expectedRemoveTags.Count; i++) + { + Assert.Equal(expectedRemoveTags[i], deserialized.RemoveTags[i]); + } + Assert.NotNull(deserialized.SetMetadata); + Assert.Equal(expectedSetMetadata.Count, deserialized.SetMetadata.Count); + for (int i = 0; i < expectedSetMetadata.Count; i++) + { + Assert.Equal(expectedSetMetadata[i], deserialized.SetMetadata[i]); + } + Assert.NotNull(deserialized.UnsetMetadata); + Assert.Equal(expectedUnsetMetadata.Count, deserialized.UnsetMetadata.Count); + for (int i = 0; i < expectedUnsetMetadata.Count; i++) + { + Assert.Equal(expectedUnsetMetadata[i], deserialized.UnsetMetadata[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown { }; + + Assert.Null(model.AddTags); + Assert.False(model.RawData.ContainsKey("add_tags")); + Assert.Null(model.RemoveTags); + Assert.False(model.RawData.ContainsKey("remove_tags")); + Assert.Null(model.SetMetadata); + Assert.False(model.RawData.ContainsKey("set_metadata")); + Assert.Null(model.UnsetMetadata); + Assert.False(model.RawData.ContainsKey("unset_metadata")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown + { + // Null should be interpreted as omitted for these properties + AddTags = null, + RemoveTags = null, + SetMetadata = null, + UnsetMetadata = null, + }; + + Assert.Null(model.AddTags); + Assert.False(model.RawData.ContainsKey("add_tags")); + Assert.Null(model.RemoveTags); + Assert.False(model.RawData.ContainsKey("remove_tags")); + Assert.Null(model.SetMetadata); + Assert.False(model.RawData.ContainsKey("set_metadata")); + Assert.Null(model.UnsetMetadata); + Assert.False(model.RawData.ContainsKey("unset_metadata")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown + { + // Null should be interpreted as omitted for these properties + AddTags = null, + RemoveTags = null, + SetMetadata = null, + UnsetMetadata = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }; + + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadata + { + Field = "field", + Value = "string", + }; + + string expectedField = "field"; + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue expectedValue = + "string"; + + Assert.Equal(expectedField, model.Field); + Assert.Equal(expectedValue, model.Value); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadata + { + Field = "field", + Value = "string", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadata + { + Field = "field", + Value = "string", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedField = "field"; + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue expectedValue = + "string"; + + Assert.Equal(expectedField, deserialized.Field); + Assert.Equal(expectedValue, deserialized.Value); + } + + [Fact] + public void Validation_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadata + { + Field = "field", + Value = "string", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadata + { + Field = "field", + Value = "string", + }; + + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadata copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueTest : TestBase +{ + [Fact] + public void StringValidationWorks() + { + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue value = 0; + value.Validate(); + } + + [Fact] + public void BoolValidationWorks() + { + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue value = true; + value.Validate(); + } + + [Fact] + public void MixedValidationWorks() + { + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue value = new( + [new UnnamedSchemaWithArrayParent7("string")] + ); + value.Validate(); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void BoolSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue value = true; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void MixedSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue value = new( + [new UnnamedSchemaWithArrayParent7("string")] + ); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class UnnamedSchemaWithArrayParent7Test : TestBase +{ + [Fact] + public void StringValidationWorks() + { + UnnamedSchemaWithArrayParent7 value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + UnnamedSchemaWithArrayParent7 value = 0; + value.Validate(); + } + + [Fact] + public void BoolValidationWorks() + { + UnnamedSchemaWithArrayParent7 value = true; + value.Validate(); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent7 value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent7 value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void BoolSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent7 value = true; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownUnsetMetadataTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownUnsetMetadata + { + Field = "field", + }; + + string expectedField = "field"; + + Assert.Equal(expectedField, model.Field); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownUnsetMetadata + { + Field = "field", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownUnsetMetadata + { + Field = "field", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedField = "field"; + + Assert.Equal(expectedField, deserialized.Field); + } + + [Fact] + public void Validation_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownUnsetMetadata + { + Field = "field", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownUnsetMetadata + { + Field = "field", + }; + + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownUnsetMetadata copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYes + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }; + + List expectedAddTags = ["luxury", "premium"]; + List expectedRemoveTags = ["budget", "affordable"]; + List expectedSetMetadata = + [ + new() { Field = "price_range", Value = "premium" }, + ]; + List expectedUnsetMetadata = + [ + new("price_range"), + ]; + + Assert.NotNull(model.AddTags); + Assert.Equal(expectedAddTags.Count, model.AddTags.Count); + for (int i = 0; i < expectedAddTags.Count; i++) + { + Assert.Equal(expectedAddTags[i], model.AddTags[i]); + } + Assert.NotNull(model.RemoveTags); + Assert.Equal(expectedRemoveTags.Count, model.RemoveTags.Count); + for (int i = 0; i < expectedRemoveTags.Count; i++) + { + Assert.Equal(expectedRemoveTags[i], model.RemoveTags[i]); + } + Assert.NotNull(model.SetMetadata); + Assert.Equal(expectedSetMetadata.Count, model.SetMetadata.Count); + for (int i = 0; i < expectedSetMetadata.Count; i++) + { + Assert.Equal(expectedSetMetadata[i], model.SetMetadata[i]); + } + Assert.NotNull(model.UnsetMetadata); + Assert.Equal(expectedUnsetMetadata.Count, model.UnsetMetadata.Count); + for (int i = 0; i < expectedUnsetMetadata.Count; i++) + { + Assert.Equal(expectedUnsetMetadata[i], model.UnsetMetadata[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYes + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYes + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedAddTags = ["luxury", "premium"]; + List expectedRemoveTags = ["budget", "affordable"]; + List expectedSetMetadata = + [ + new() { Field = "price_range", Value = "premium" }, + ]; + List expectedUnsetMetadata = + [ + new("price_range"), + ]; + + Assert.NotNull(deserialized.AddTags); + Assert.Equal(expectedAddTags.Count, deserialized.AddTags.Count); + for (int i = 0; i < expectedAddTags.Count; i++) + { + Assert.Equal(expectedAddTags[i], deserialized.AddTags[i]); + } + Assert.NotNull(deserialized.RemoveTags); + Assert.Equal(expectedRemoveTags.Count, deserialized.RemoveTags.Count); + for (int i = 0; i < expectedRemoveTags.Count; i++) + { + Assert.Equal(expectedRemoveTags[i], deserialized.RemoveTags[i]); + } + Assert.NotNull(deserialized.SetMetadata); + Assert.Equal(expectedSetMetadata.Count, deserialized.SetMetadata.Count); + for (int i = 0; i < expectedSetMetadata.Count; i++) + { + Assert.Equal(expectedSetMetadata[i], deserialized.SetMetadata[i]); + } + Assert.NotNull(deserialized.UnsetMetadata); + Assert.Equal(expectedUnsetMetadata.Count, deserialized.UnsetMetadata.Count); + for (int i = 0; i < expectedUnsetMetadata.Count; i++) + { + Assert.Equal(expectedUnsetMetadata[i], deserialized.UnsetMetadata[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYes + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYes { }; + + Assert.Null(model.AddTags); + Assert.False(model.RawData.ContainsKey("add_tags")); + Assert.Null(model.RemoveTags); + Assert.False(model.RawData.ContainsKey("remove_tags")); + Assert.Null(model.SetMetadata); + Assert.False(model.RawData.ContainsKey("set_metadata")); + Assert.Null(model.UnsetMetadata); + Assert.False(model.RawData.ContainsKey("unset_metadata")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYes { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYes + { + // Null should be interpreted as omitted for these properties + AddTags = null, + RemoveTags = null, + SetMetadata = null, + UnsetMetadata = null, + }; + + Assert.Null(model.AddTags); + Assert.False(model.RawData.ContainsKey("add_tags")); + Assert.Null(model.RemoveTags); + Assert.False(model.RawData.ContainsKey("remove_tags")); + Assert.Null(model.SetMetadata); + Assert.False(model.RawData.ContainsKey("set_metadata")); + Assert.Null(model.UnsetMetadata); + Assert.False(model.RawData.ContainsKey("unset_metadata")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYes + { + // Null should be interpreted as omitted for these properties + AddTags = null, + RemoveTags = null, + SetMetadata = null, + UnsetMetadata = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYes + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }; + + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYes copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadata + { + Field = "field", + Value = "string", + }; + + string expectedField = "field"; + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue expectedValue = "string"; + + Assert.Equal(expectedField, model.Field); + Assert.Equal(expectedValue, model.Value); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadata + { + Field = "field", + Value = "string", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadata + { + Field = "field", + Value = "string", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedField = "field"; + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue expectedValue = "string"; + + Assert.Equal(expectedField, deserialized.Field); + Assert.Equal(expectedValue, deserialized.Value); + } + + [Fact] + public void Validation_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadata + { + Field = "field", + Value = "string", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadata + { + Field = "field", + Value = "string", + }; + + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadata copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueTest : TestBase +{ + [Fact] + public void StringValidationWorks() + { + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue value = 0; + value.Validate(); + } + + [Fact] + public void BoolValidationWorks() + { + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue value = true; + value.Validate(); + } + + [Fact] + public void MixedValidationWorks() + { + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue value = new( + [new UnnamedSchemaWithArrayParent8("string")] + ); + value.Validate(); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void BoolSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue value = true; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void MixedSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue value = new( + [new UnnamedSchemaWithArrayParent8("string")] + ); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class UnnamedSchemaWithArrayParent8Test : TestBase +{ + [Fact] + public void StringValidationWorks() + { + UnnamedSchemaWithArrayParent8 value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + UnnamedSchemaWithArrayParent8 value = 0; + value.Validate(); + } + + [Fact] + public void BoolValidationWorks() + { + UnnamedSchemaWithArrayParent8 value = true; + value.Validate(); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent8 value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent8 value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void BoolSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent8 value = true; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesUnsetMetadataTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesUnsetMetadata + { + Field = "field", + }; + + string expectedField = "field"; + + Assert.Equal(expectedField, model.Field); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesUnsetMetadata + { + Field = "field", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesUnsetMetadata + { + Field = "field", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedField = "field"; + + Assert.Equal(expectedField, deserialized.Field); + } + + [Fact] + public void Validation_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesUnsetMetadata + { + Field = "field", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesUnsetMetadata + { + Field = "field", + }; + + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesUnsetMetadata copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class SavedExtensionTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new SavedExtension { ID = "ext_abc123" }; + + string expectedID = "ext_abc123"; + JsonElement expectedName = JsonSerializer.SerializeToElement("saved-extension"); + + Assert.Equal(expectedID, model.ID); + Assert.True(JsonElement.DeepEquals(expectedName, model.Name)); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new SavedExtension { ID = "ext_abc123" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new SavedExtension { ID = "ext_abc123" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "ext_abc123"; + JsonElement expectedName = JsonSerializer.SerializeToElement("saved-extension"); + + Assert.Equal(expectedID, deserialized.ID); + Assert.True(JsonElement.DeepEquals(expectedName, deserialized.Name)); + } + + [Fact] + public void Validation_Works() + { + var model = new SavedExtension { ID = "ext_abc123" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new SavedExtension { ID = "ext_abc123" }; + + SavedExtension copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/ImageKit.Tests/Models/VideoOverlayTest.cs b/src/ImageKit.Tests/Models/VideoOverlayTest.cs new file mode 100644 index 00000000..60dc9c37 --- /dev/null +++ b/src/ImageKit.Tests/Models/VideoOverlayTest.cs @@ -0,0 +1,1834 @@ +using System.Collections.Generic; +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Exceptions; +using ImageKit.Models; + +namespace ImageKit.Tests.Models; + +public class VideoOverlayTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new VideoOverlay + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Input = "input", + Encoding = VideoOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ], + }; + + ApiEnum expectedLayerMode = LayerMode.Multiply; + OverlayPosition expectedPosition = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }; + OverlayTiming expectedTiming = new() + { + Duration = 0, + End = 0, + Start = 0, + }; + string expectedInput = "input"; + JsonElement expectedType = JsonSerializer.SerializeToElement("video"); + ApiEnum expectedEncoding = + VideoOverlayIntersectionMember1Encoding.Auto; + List expectedTransformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ]; + + Assert.Equal(expectedLayerMode, model.LayerMode); + Assert.Equal(expectedPosition, model.Position); + Assert.Equal(expectedTiming, model.Timing); + Assert.Equal(expectedInput, model.Input); + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + Assert.Equal(expectedEncoding, model.Encoding); + Assert.NotNull(model.Transformation); + Assert.Equal(expectedTransformation.Count, model.Transformation.Count); + for (int i = 0; i < expectedTransformation.Count; i++) + { + Assert.Equal(expectedTransformation[i], model.Transformation[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new VideoOverlay + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Input = "input", + Encoding = VideoOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new VideoOverlay + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Input = "input", + Encoding = VideoOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum expectedLayerMode = LayerMode.Multiply; + OverlayPosition expectedPosition = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }; + OverlayTiming expectedTiming = new() + { + Duration = 0, + End = 0, + Start = 0, + }; + string expectedInput = "input"; + JsonElement expectedType = JsonSerializer.SerializeToElement("video"); + ApiEnum expectedEncoding = + VideoOverlayIntersectionMember1Encoding.Auto; + List expectedTransformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ]; + + Assert.Equal(expectedLayerMode, deserialized.LayerMode); + Assert.Equal(expectedPosition, deserialized.Position); + Assert.Equal(expectedTiming, deserialized.Timing); + Assert.Equal(expectedInput, deserialized.Input); + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + Assert.Equal(expectedEncoding, deserialized.Encoding); + Assert.NotNull(deserialized.Transformation); + Assert.Equal(expectedTransformation.Count, deserialized.Transformation.Count); + for (int i = 0; i < expectedTransformation.Count; i++) + { + Assert.Equal(expectedTransformation[i], deserialized.Transformation[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new VideoOverlay + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Input = "input", + Encoding = VideoOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new VideoOverlay { Input = "input" }; + + Assert.Null(model.LayerMode); + Assert.False(model.RawData.ContainsKey("layerMode")); + Assert.Null(model.Position); + Assert.False(model.RawData.ContainsKey("position")); + Assert.Null(model.Timing); + Assert.False(model.RawData.ContainsKey("timing")); + Assert.Null(model.Encoding); + Assert.False(model.RawData.ContainsKey("encoding")); + Assert.Null(model.Transformation); + Assert.False(model.RawData.ContainsKey("transformation")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new VideoOverlay { Input = "input" }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new VideoOverlay + { + Input = "input", + + // Null should be interpreted as omitted for these properties + LayerMode = null, + Position = null, + Timing = null, + Encoding = null, + Transformation = null, + }; + + Assert.Null(model.LayerMode); + Assert.False(model.RawData.ContainsKey("layerMode")); + Assert.Null(model.Position); + Assert.False(model.RawData.ContainsKey("position")); + Assert.Null(model.Timing); + Assert.False(model.RawData.ContainsKey("timing")); + Assert.Null(model.Encoding); + Assert.False(model.RawData.ContainsKey("encoding")); + Assert.Null(model.Transformation); + Assert.False(model.RawData.ContainsKey("transformation")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new VideoOverlay + { + Input = "input", + + // Null should be interpreted as omitted for these properties + LayerMode = null, + Position = null, + Timing = null, + Encoding = null, + Transformation = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new VideoOverlay + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Input = "input", + Encoding = VideoOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ], + }; + + VideoOverlay copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class VideoOverlayIntersectionMember1Test : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new VideoOverlayIntersectionMember1 + { + Input = "input", + Encoding = VideoOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ], + }; + + string expectedInput = "input"; + JsonElement expectedType = JsonSerializer.SerializeToElement("video"); + ApiEnum expectedEncoding = + VideoOverlayIntersectionMember1Encoding.Auto; + List expectedTransformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ]; + + Assert.Equal(expectedInput, model.Input); + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + Assert.Equal(expectedEncoding, model.Encoding); + Assert.NotNull(model.Transformation); + Assert.Equal(expectedTransformation.Count, model.Transformation.Count); + for (int i = 0; i < expectedTransformation.Count; i++) + { + Assert.Equal(expectedTransformation[i], model.Transformation[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new VideoOverlayIntersectionMember1 + { + Input = "input", + Encoding = VideoOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new VideoOverlayIntersectionMember1 + { + Input = "input", + Encoding = VideoOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedInput = "input"; + JsonElement expectedType = JsonSerializer.SerializeToElement("video"); + ApiEnum expectedEncoding = + VideoOverlayIntersectionMember1Encoding.Auto; + List expectedTransformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ]; + + Assert.Equal(expectedInput, deserialized.Input); + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + Assert.Equal(expectedEncoding, deserialized.Encoding); + Assert.NotNull(deserialized.Transformation); + Assert.Equal(expectedTransformation.Count, deserialized.Transformation.Count); + for (int i = 0; i < expectedTransformation.Count; i++) + { + Assert.Equal(expectedTransformation[i], deserialized.Transformation[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new VideoOverlayIntersectionMember1 + { + Input = "input", + Encoding = VideoOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new VideoOverlayIntersectionMember1 { Input = "input" }; + + Assert.Null(model.Encoding); + Assert.False(model.RawData.ContainsKey("encoding")); + Assert.Null(model.Transformation); + Assert.False(model.RawData.ContainsKey("transformation")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new VideoOverlayIntersectionMember1 { Input = "input" }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new VideoOverlayIntersectionMember1 + { + Input = "input", + + // Null should be interpreted as omitted for these properties + Encoding = null, + Transformation = null, + }; + + Assert.Null(model.Encoding); + Assert.False(model.RawData.ContainsKey("encoding")); + Assert.Null(model.Transformation); + Assert.False(model.RawData.ContainsKey("transformation")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new VideoOverlayIntersectionMember1 + { + Input = "input", + + // Null should be interpreted as omitted for these properties + Encoding = null, + Transformation = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new VideoOverlayIntersectionMember1 + { + Input = "input", + Encoding = VideoOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + Focus = Focus.Center, + X = 0, + Y = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = 0, + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ], + }; + + VideoOverlayIntersectionMember1 copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class VideoOverlayIntersectionMember1EncodingTest : TestBase +{ + [Theory] + [InlineData(VideoOverlayIntersectionMember1Encoding.Auto)] + [InlineData(VideoOverlayIntersectionMember1Encoding.Plain)] + [InlineData(VideoOverlayIntersectionMember1Encoding.Base64)] + public void Validation_Works(VideoOverlayIntersectionMember1Encoding rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(VideoOverlayIntersectionMember1Encoding.Auto)] + [InlineData(VideoOverlayIntersectionMember1Encoding.Plain)] + [InlineData(VideoOverlayIntersectionMember1Encoding.Base64)] + public void SerializationRoundtrip_Works(VideoOverlayIntersectionMember1Encoding rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} diff --git a/src/ImageKit.Tests/Models/Webhooks/BaseWebhookEventTest.cs b/src/ImageKit.Tests/Models/Webhooks/BaseWebhookEventTest.cs new file mode 100644 index 00000000..a908a877 --- /dev/null +++ b/src/ImageKit.Tests/Models/Webhooks/BaseWebhookEventTest.cs @@ -0,0 +1,71 @@ +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Models.Webhooks; + +namespace ImageKit.Tests.Models.Webhooks; + +public class BaseWebhookEventTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new BaseWebhookEvent { ID = "id", Type = "type" }; + + string expectedID = "id"; + string expectedType = "type"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedType, model.Type); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new BaseWebhookEvent { ID = "id", Type = "type" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new BaseWebhookEvent { ID = "id", Type = "type" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedType = "type"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedType, deserialized.Type); + } + + [Fact] + public void Validation_Works() + { + var model = new BaseWebhookEvent { ID = "id", Type = "type" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BaseWebhookEvent { ID = "id", Type = "type" }; + + BaseWebhookEvent copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs b/src/ImageKit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs new file mode 100644 index 00000000..92c81f97 --- /dev/null +++ b/src/ImageKit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs @@ -0,0 +1,802 @@ +using System; +using System.Collections.Generic; +using System.Text.Json; +using ImageKit.Core; +using Webhooks = ImageKit.Models.Webhooks; + +namespace ImageKit.Tests.Models.Webhooks; + +public class UnsafeUnwrapWebhookEventTest : TestBase +{ + [Fact] + public void VideoTransformationAcceptedValidationWorks() + { + Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::VideoTransformationAcceptedEvent() + { + ID = "id", + Type = "video.transformation.accepted", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + Webhooks::VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = Webhooks::AudioCodec.Aac, + AutoRotate = true, + Format = Webhooks::Format.Mp4, + Quality = 0, + StreamProtocol = Webhooks::StreamProtocol.Hls, + Variants = ["string"], + VideoCodec = Webhooks::VideoCodec.H264, + }, + }, + }, + Request = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }, + }; + value.Validate(); + } + + [Fact] + public void VideoTransformationReadyValidationWorks() + { + Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::VideoTransformationReadyEvent() + { + ID = "id", + Type = "video.transformation.ready", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + Webhooks::VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = + Webhooks::VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + Webhooks::VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + Webhooks::VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + Webhooks::VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + Output = new() + { + Url = "https://example.com", + VideoMetadata = new() + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }, + }, + }, + }, + Request = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }, + Timings = new() { DownloadDuration = 0, EncodingDuration = 0 }, + }; + value.Validate(); + } + + [Fact] + public void VideoTransformationErrorValidationWorks() + { + Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::VideoTransformationErrorEvent() + { + ID = "id", + Type = "video.transformation.error", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + Webhooks::VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + Error = new(Webhooks::Reason.EncodingFailed), + Options = new() + { + AudioCodec = + Webhooks::VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + Webhooks::VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + Webhooks::VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + Webhooks::VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + }, + }, + Request = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }, + }; + value.Validate(); + } + + [Fact] + public void UploadPreTransformSuccessValidationWorks() + { + Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::UploadPreTransformSuccessEvent() + { + ID = "id", + Type = "upload.pre-transform.success", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ExtensionStatus = new() + { + AIAutoDescription = Webhooks::AIAutoDescription.Success, + AITasks = Webhooks::AITasks.Success, + AwsAutoTagging = Webhooks::AwsAutoTagging.Success, + GoogleAutoTagging = Webhooks::GoogleAutoTagging.Success, + RemoveBg = Webhooks::RemoveBg.Success, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Metadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }, + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Webhooks::SelectedFieldsSchemaItemType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + ThumbnailUrl = "thumbnailUrl", + Url = "url", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, + Request = new() { Transformation = "transformation", XRequestID = "x_request_id" }, + }; + value.Validate(); + } + + [Fact] + public void UploadPreTransformErrorValidationWorks() + { + Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::UploadPreTransformErrorEvent() + { + ID = "id", + Type = "upload.pre-transform.error", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Name = "name", + Path = "path", + Transformation = new( + new Webhooks::UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + "encoding_failed" + ) + ), + }, + Request = new() { Transformation = "transformation", XRequestID = "x_request_id" }, + }; + value.Validate(); + } + + [Fact] + public void UploadPostTransformSuccessValidationWorks() + { + Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::UploadPostTransformSuccessEvent() + { + ID = "id", + Type = "upload.post-transform.success", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + FileID = "fileId", + Name = "name", + Url = "https://example.com", + }, + Request = new() + { + Transformation = new() + { + Type = + Webhooks::UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + Protocol = + Webhooks::UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + Value = "value", + }, + XRequestID = "x_request_id", + }, + }; + value.Validate(); + } + + [Fact] + public void UploadPostTransformErrorValidationWorks() + { + Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::UploadPostTransformErrorEvent() + { + ID = "id", + Type = "upload.post-transform.error", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + FileID = "fileId", + Name = "name", + Path = "path", + Transformation = new(new Webhooks::Error("encoding_failed")), + Url = "https://example.com", + }, + Request = new() + { + Transformation = new() + { + Type = Webhooks::Type.Transformation, + Protocol = Webhooks::Protocol.Hls, + Value = "value", + }, + XRequestID = "x_request_id", + }, + }; + value.Validate(); + } + + [Fact] + public void VideoTransformationAcceptedSerializationRoundtripWorks() + { + Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::VideoTransformationAcceptedEvent() + { + ID = "id", + Type = "video.transformation.accepted", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + Webhooks::VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = Webhooks::AudioCodec.Aac, + AutoRotate = true, + Format = Webhooks::Format.Mp4, + Quality = 0, + StreamProtocol = Webhooks::StreamProtocol.Hls, + Variants = ["string"], + VideoCodec = Webhooks::VideoCodec.H264, + }, + }, + }, + Request = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void VideoTransformationReadySerializationRoundtripWorks() + { + Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::VideoTransformationReadyEvent() + { + ID = "id", + Type = "video.transformation.ready", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + Webhooks::VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = + Webhooks::VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + Webhooks::VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + Webhooks::VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + Webhooks::VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + Output = new() + { + Url = "https://example.com", + VideoMetadata = new() + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }, + }, + }, + }, + Request = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }, + Timings = new() { DownloadDuration = 0, EncodingDuration = 0 }, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void VideoTransformationErrorSerializationRoundtripWorks() + { + Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::VideoTransformationErrorEvent() + { + ID = "id", + Type = "video.transformation.error", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + Webhooks::VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + Error = new(Webhooks::Reason.EncodingFailed), + Options = new() + { + AudioCodec = + Webhooks::VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + Webhooks::VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + Webhooks::VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + Webhooks::VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + }, + }, + Request = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void UploadPreTransformSuccessSerializationRoundtripWorks() + { + Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::UploadPreTransformSuccessEvent() + { + ID = "id", + Type = "upload.pre-transform.success", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ExtensionStatus = new() + { + AIAutoDescription = Webhooks::AIAutoDescription.Success, + AITasks = Webhooks::AITasks.Success, + AwsAutoTagging = Webhooks::AwsAutoTagging.Success, + GoogleAutoTagging = Webhooks::GoogleAutoTagging.Success, + RemoveBg = Webhooks::RemoveBg.Success, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Metadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }, + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Webhooks::SelectedFieldsSchemaItemType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + ThumbnailUrl = "thumbnailUrl", + Url = "url", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, + Request = new() { Transformation = "transformation", XRequestID = "x_request_id" }, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void UploadPreTransformErrorSerializationRoundtripWorks() + { + Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::UploadPreTransformErrorEvent() + { + ID = "id", + Type = "upload.pre-transform.error", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Name = "name", + Path = "path", + Transformation = new( + new Webhooks::UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + "encoding_failed" + ) + ), + }, + Request = new() { Transformation = "transformation", XRequestID = "x_request_id" }, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void UploadPostTransformSuccessSerializationRoundtripWorks() + { + Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::UploadPostTransformSuccessEvent() + { + ID = "id", + Type = "upload.post-transform.success", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + FileID = "fileId", + Name = "name", + Url = "https://example.com", + }, + Request = new() + { + Transformation = new() + { + Type = + Webhooks::UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + Protocol = + Webhooks::UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + Value = "value", + }, + XRequestID = "x_request_id", + }, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void UploadPostTransformErrorSerializationRoundtripWorks() + { + Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::UploadPostTransformErrorEvent() + { + ID = "id", + Type = "upload.post-transform.error", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + FileID = "fileId", + Name = "name", + Path = "path", + Transformation = new(new Webhooks::Error("encoding_failed")), + Url = "https://example.com", + }, + Request = new() + { + Transformation = new() + { + Type = Webhooks::Type.Transformation, + Protocol = Webhooks::Protocol.Hls, + Value = "value", + }, + XRequestID = "x_request_id", + }, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} diff --git a/src/ImageKit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs b/src/ImageKit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs new file mode 100644 index 00000000..9ab16533 --- /dev/null +++ b/src/ImageKit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs @@ -0,0 +1,802 @@ +using System; +using System.Collections.Generic; +using System.Text.Json; +using ImageKit.Core; +using Webhooks = ImageKit.Models.Webhooks; + +namespace ImageKit.Tests.Models.Webhooks; + +public class UnwrapWebhookEventTest : TestBase +{ + [Fact] + public void VideoTransformationAcceptedValidationWorks() + { + Webhooks::UnwrapWebhookEvent value = new Webhooks::VideoTransformationAcceptedEvent() + { + ID = "id", + Type = "video.transformation.accepted", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + Webhooks::VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = Webhooks::AudioCodec.Aac, + AutoRotate = true, + Format = Webhooks::Format.Mp4, + Quality = 0, + StreamProtocol = Webhooks::StreamProtocol.Hls, + Variants = ["string"], + VideoCodec = Webhooks::VideoCodec.H264, + }, + }, + }, + Request = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }, + }; + value.Validate(); + } + + [Fact] + public void VideoTransformationReadyValidationWorks() + { + Webhooks::UnwrapWebhookEvent value = new Webhooks::VideoTransformationReadyEvent() + { + ID = "id", + Type = "video.transformation.ready", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + Webhooks::VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = + Webhooks::VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + Webhooks::VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + Webhooks::VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + Webhooks::VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + Output = new() + { + Url = "https://example.com", + VideoMetadata = new() + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }, + }, + }, + }, + Request = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }, + Timings = new() { DownloadDuration = 0, EncodingDuration = 0 }, + }; + value.Validate(); + } + + [Fact] + public void VideoTransformationErrorValidationWorks() + { + Webhooks::UnwrapWebhookEvent value = new Webhooks::VideoTransformationErrorEvent() + { + ID = "id", + Type = "video.transformation.error", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + Webhooks::VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + Error = new(Webhooks::Reason.EncodingFailed), + Options = new() + { + AudioCodec = + Webhooks::VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + Webhooks::VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + Webhooks::VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + Webhooks::VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + }, + }, + Request = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }, + }; + value.Validate(); + } + + [Fact] + public void UploadPreTransformSuccessValidationWorks() + { + Webhooks::UnwrapWebhookEvent value = new Webhooks::UploadPreTransformSuccessEvent() + { + ID = "id", + Type = "upload.pre-transform.success", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ExtensionStatus = new() + { + AIAutoDescription = Webhooks::AIAutoDescription.Success, + AITasks = Webhooks::AITasks.Success, + AwsAutoTagging = Webhooks::AwsAutoTagging.Success, + GoogleAutoTagging = Webhooks::GoogleAutoTagging.Success, + RemoveBg = Webhooks::RemoveBg.Success, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Metadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }, + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Webhooks::SelectedFieldsSchemaItemType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + ThumbnailUrl = "thumbnailUrl", + Url = "url", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, + Request = new() { Transformation = "transformation", XRequestID = "x_request_id" }, + }; + value.Validate(); + } + + [Fact] + public void UploadPreTransformErrorValidationWorks() + { + Webhooks::UnwrapWebhookEvent value = new Webhooks::UploadPreTransformErrorEvent() + { + ID = "id", + Type = "upload.pre-transform.error", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Name = "name", + Path = "path", + Transformation = new( + new Webhooks::UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + "encoding_failed" + ) + ), + }, + Request = new() { Transformation = "transformation", XRequestID = "x_request_id" }, + }; + value.Validate(); + } + + [Fact] + public void UploadPostTransformSuccessValidationWorks() + { + Webhooks::UnwrapWebhookEvent value = new Webhooks::UploadPostTransformSuccessEvent() + { + ID = "id", + Type = "upload.post-transform.success", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + FileID = "fileId", + Name = "name", + Url = "https://example.com", + }, + Request = new() + { + Transformation = new() + { + Type = + Webhooks::UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + Protocol = + Webhooks::UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + Value = "value", + }, + XRequestID = "x_request_id", + }, + }; + value.Validate(); + } + + [Fact] + public void UploadPostTransformErrorValidationWorks() + { + Webhooks::UnwrapWebhookEvent value = new Webhooks::UploadPostTransformErrorEvent() + { + ID = "id", + Type = "upload.post-transform.error", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + FileID = "fileId", + Name = "name", + Path = "path", + Transformation = new(new Webhooks::Error("encoding_failed")), + Url = "https://example.com", + }, + Request = new() + { + Transformation = new() + { + Type = Webhooks::Type.Transformation, + Protocol = Webhooks::Protocol.Hls, + Value = "value", + }, + XRequestID = "x_request_id", + }, + }; + value.Validate(); + } + + [Fact] + public void VideoTransformationAcceptedSerializationRoundtripWorks() + { + Webhooks::UnwrapWebhookEvent value = new Webhooks::VideoTransformationAcceptedEvent() + { + ID = "id", + Type = "video.transformation.accepted", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + Webhooks::VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = Webhooks::AudioCodec.Aac, + AutoRotate = true, + Format = Webhooks::Format.Mp4, + Quality = 0, + StreamProtocol = Webhooks::StreamProtocol.Hls, + Variants = ["string"], + VideoCodec = Webhooks::VideoCodec.H264, + }, + }, + }, + Request = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void VideoTransformationReadySerializationRoundtripWorks() + { + Webhooks::UnwrapWebhookEvent value = new Webhooks::VideoTransformationReadyEvent() + { + ID = "id", + Type = "video.transformation.ready", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + Webhooks::VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = + Webhooks::VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + Webhooks::VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + Webhooks::VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + Webhooks::VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + Output = new() + { + Url = "https://example.com", + VideoMetadata = new() + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }, + }, + }, + }, + Request = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }, + Timings = new() { DownloadDuration = 0, EncodingDuration = 0 }, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void VideoTransformationErrorSerializationRoundtripWorks() + { + Webhooks::UnwrapWebhookEvent value = new Webhooks::VideoTransformationErrorEvent() + { + ID = "id", + Type = "video.transformation.error", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + Webhooks::VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + Error = new(Webhooks::Reason.EncodingFailed), + Options = new() + { + AudioCodec = + Webhooks::VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + Webhooks::VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + Webhooks::VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + Webhooks::VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + }, + }, + Request = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void UploadPreTransformSuccessSerializationRoundtripWorks() + { + Webhooks::UnwrapWebhookEvent value = new Webhooks::UploadPreTransformSuccessEvent() + { + ID = "id", + Type = "upload.pre-transform.success", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ExtensionStatus = new() + { + AIAutoDescription = Webhooks::AIAutoDescription.Success, + AITasks = Webhooks::AITasks.Success, + AwsAutoTagging = Webhooks::AwsAutoTagging.Success, + GoogleAutoTagging = Webhooks::GoogleAutoTagging.Success, + RemoveBg = Webhooks::RemoveBg.Success, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Metadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }, + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Webhooks::SelectedFieldsSchemaItemType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + ThumbnailUrl = "thumbnailUrl", + Url = "url", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, + Request = new() { Transformation = "transformation", XRequestID = "x_request_id" }, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void UploadPreTransformErrorSerializationRoundtripWorks() + { + Webhooks::UnwrapWebhookEvent value = new Webhooks::UploadPreTransformErrorEvent() + { + ID = "id", + Type = "upload.pre-transform.error", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Name = "name", + Path = "path", + Transformation = new( + new Webhooks::UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + "encoding_failed" + ) + ), + }, + Request = new() { Transformation = "transformation", XRequestID = "x_request_id" }, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void UploadPostTransformSuccessSerializationRoundtripWorks() + { + Webhooks::UnwrapWebhookEvent value = new Webhooks::UploadPostTransformSuccessEvent() + { + ID = "id", + Type = "upload.post-transform.success", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + FileID = "fileId", + Name = "name", + Url = "https://example.com", + }, + Request = new() + { + Transformation = new() + { + Type = + Webhooks::UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + Protocol = + Webhooks::UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + Value = "value", + }, + XRequestID = "x_request_id", + }, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void UploadPostTransformErrorSerializationRoundtripWorks() + { + Webhooks::UnwrapWebhookEvent value = new Webhooks::UploadPostTransformErrorEvent() + { + ID = "id", + Type = "upload.post-transform.error", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + FileID = "fileId", + Name = "name", + Path = "path", + Transformation = new(new Webhooks::Error("encoding_failed")), + Url = "https://example.com", + }, + Request = new() + { + Transformation = new() + { + Type = Webhooks::Type.Transformation, + Protocol = Webhooks::Protocol.Hls, + Value = "value", + }, + XRequestID = "x_request_id", + }, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} diff --git a/src/ImageKit.Tests/Models/Webhooks/UploadPostTransformErrorEventTest.cs b/src/ImageKit.Tests/Models/Webhooks/UploadPostTransformErrorEventTest.cs new file mode 100644 index 00000000..bbdc932a --- /dev/null +++ b/src/ImageKit.Tests/Models/Webhooks/UploadPostTransformErrorEventTest.cs @@ -0,0 +1,1072 @@ +using System; +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Exceptions; +using Webhooks = ImageKit.Models.Webhooks; + +namespace ImageKit.Tests.Models.Webhooks; + +public class UploadPostTransformErrorEventTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Webhooks::UploadPostTransformErrorEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + FileID = "fileId", + Name = "name", + Path = "path", + Transformation = new(new Webhooks::Error("encoding_failed")), + Url = "https://example.com", + }, + Request = new() + { + Transformation = new() + { + Type = Webhooks::Type.Transformation, + Protocol = Webhooks::Protocol.Hls, + Value = "value", + }, + XRequestID = "x_request_id", + }, + }; + + string expectedID = "id"; + string expectedType = "type"; + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + Webhooks::Data expectedData = new() + { + FileID = "fileId", + Name = "name", + Path = "path", + Transformation = new(new Webhooks::Error("encoding_failed")), + Url = "https://example.com", + }; + Webhooks::Request expectedRequest = new() + { + Transformation = new() + { + Type = Webhooks::Type.Transformation, + Protocol = Webhooks::Protocol.Hls, + Value = "value", + }, + XRequestID = "x_request_id", + }; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedType, model.Type); + Assert.Equal(expectedCreatedAt, model.CreatedAt); + Assert.Equal(expectedData, model.Data); + Assert.Equal(expectedRequest, model.Request); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Webhooks::UploadPostTransformErrorEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + FileID = "fileId", + Name = "name", + Path = "path", + Transformation = new(new Webhooks::Error("encoding_failed")), + Url = "https://example.com", + }, + Request = new() + { + Transformation = new() + { + Type = Webhooks::Type.Transformation, + Protocol = Webhooks::Protocol.Hls, + Value = "value", + }, + XRequestID = "x_request_id", + }, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Webhooks::UploadPostTransformErrorEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + FileID = "fileId", + Name = "name", + Path = "path", + Transformation = new(new Webhooks::Error("encoding_failed")), + Url = "https://example.com", + }, + Request = new() + { + Transformation = new() + { + Type = Webhooks::Type.Transformation, + Protocol = Webhooks::Protocol.Hls, + Value = "value", + }, + XRequestID = "x_request_id", + }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedType = "type"; + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + Webhooks::Data expectedData = new() + { + FileID = "fileId", + Name = "name", + Path = "path", + Transformation = new(new Webhooks::Error("encoding_failed")), + Url = "https://example.com", + }; + Webhooks::Request expectedRequest = new() + { + Transformation = new() + { + Type = Webhooks::Type.Transformation, + Protocol = Webhooks::Protocol.Hls, + Value = "value", + }, + XRequestID = "x_request_id", + }; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedType, deserialized.Type); + Assert.Equal(expectedCreatedAt, deserialized.CreatedAt); + Assert.Equal(expectedData, deserialized.Data); + Assert.Equal(expectedRequest, deserialized.Request); + } + + [Fact] + public void Validation_Works() + { + var model = new Webhooks::UploadPostTransformErrorEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + FileID = "fileId", + Name = "name", + Path = "path", + Transformation = new(new Webhooks::Error("encoding_failed")), + Url = "https://example.com", + }, + Request = new() + { + Transformation = new() + { + Type = Webhooks::Type.Transformation, + Protocol = Webhooks::Protocol.Hls, + Value = "value", + }, + XRequestID = "x_request_id", + }, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Webhooks::UploadPostTransformErrorEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + FileID = "fileId", + Name = "name", + Path = "path", + Transformation = new(new Webhooks::Error("encoding_failed")), + Url = "https://example.com", + }, + Request = new() + { + Transformation = new() + { + Type = Webhooks::Type.Transformation, + Protocol = Webhooks::Protocol.Hls, + Value = "value", + }, + XRequestID = "x_request_id", + }, + }; + + Webhooks::UploadPostTransformErrorEvent copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class IntersectionMember1Test : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Webhooks::IntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + FileID = "fileId", + Name = "name", + Path = "path", + Transformation = new(new Webhooks::Error("encoding_failed")), + Url = "https://example.com", + }, + Request = new() + { + Transformation = new() + { + Type = Webhooks::Type.Transformation, + Protocol = Webhooks::Protocol.Hls, + Value = "value", + }, + XRequestID = "x_request_id", + }, + }; + + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + Webhooks::Data expectedData = new() + { + FileID = "fileId", + Name = "name", + Path = "path", + Transformation = new(new Webhooks::Error("encoding_failed")), + Url = "https://example.com", + }; + Webhooks::Request expectedRequest = new() + { + Transformation = new() + { + Type = Webhooks::Type.Transformation, + Protocol = Webhooks::Protocol.Hls, + Value = "value", + }, + XRequestID = "x_request_id", + }; + JsonElement expectedType = JsonSerializer.SerializeToElement("upload.post-transform.error"); + + Assert.Equal(expectedCreatedAt, model.CreatedAt); + Assert.Equal(expectedData, model.Data); + Assert.Equal(expectedRequest, model.Request); + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Webhooks::IntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + FileID = "fileId", + Name = "name", + Path = "path", + Transformation = new(new Webhooks::Error("encoding_failed")), + Url = "https://example.com", + }, + Request = new() + { + Transformation = new() + { + Type = Webhooks::Type.Transformation, + Protocol = Webhooks::Protocol.Hls, + Value = "value", + }, + XRequestID = "x_request_id", + }, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Webhooks::IntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + FileID = "fileId", + Name = "name", + Path = "path", + Transformation = new(new Webhooks::Error("encoding_failed")), + Url = "https://example.com", + }, + Request = new() + { + Transformation = new() + { + Type = Webhooks::Type.Transformation, + Protocol = Webhooks::Protocol.Hls, + Value = "value", + }, + XRequestID = "x_request_id", + }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + Webhooks::Data expectedData = new() + { + FileID = "fileId", + Name = "name", + Path = "path", + Transformation = new(new Webhooks::Error("encoding_failed")), + Url = "https://example.com", + }; + Webhooks::Request expectedRequest = new() + { + Transformation = new() + { + Type = Webhooks::Type.Transformation, + Protocol = Webhooks::Protocol.Hls, + Value = "value", + }, + XRequestID = "x_request_id", + }; + JsonElement expectedType = JsonSerializer.SerializeToElement("upload.post-transform.error"); + + Assert.Equal(expectedCreatedAt, deserialized.CreatedAt); + Assert.Equal(expectedData, deserialized.Data); + Assert.Equal(expectedRequest, deserialized.Request); + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + } + + [Fact] + public void Validation_Works() + { + var model = new Webhooks::IntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + FileID = "fileId", + Name = "name", + Path = "path", + Transformation = new(new Webhooks::Error("encoding_failed")), + Url = "https://example.com", + }, + Request = new() + { + Transformation = new() + { + Type = Webhooks::Type.Transformation, + Protocol = Webhooks::Protocol.Hls, + Value = "value", + }, + XRequestID = "x_request_id", + }, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Webhooks::IntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + FileID = "fileId", + Name = "name", + Path = "path", + Transformation = new(new Webhooks::Error("encoding_failed")), + Url = "https://example.com", + }, + Request = new() + { + Transformation = new() + { + Type = Webhooks::Type.Transformation, + Protocol = Webhooks::Protocol.Hls, + Value = "value", + }, + XRequestID = "x_request_id", + }, + }; + + Webhooks::IntersectionMember1 copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class DataTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Webhooks::Data + { + FileID = "fileId", + Name = "name", + Path = "path", + Transformation = new(new Webhooks::Error("encoding_failed")), + Url = "https://example.com", + }; + + string expectedFileID = "fileId"; + string expectedName = "name"; + string expectedPath = "path"; + Webhooks::Transformation expectedTransformation = new( + new Webhooks::Error("encoding_failed") + ); + string expectedUrl = "https://example.com"; + + Assert.Equal(expectedFileID, model.FileID); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedPath, model.Path); + Assert.Equal(expectedTransformation, model.Transformation); + Assert.Equal(expectedUrl, model.Url); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Webhooks::Data + { + FileID = "fileId", + Name = "name", + Path = "path", + Transformation = new(new Webhooks::Error("encoding_failed")), + Url = "https://example.com", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Webhooks::Data + { + FileID = "fileId", + Name = "name", + Path = "path", + Transformation = new(new Webhooks::Error("encoding_failed")), + Url = "https://example.com", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedFileID = "fileId"; + string expectedName = "name"; + string expectedPath = "path"; + Webhooks::Transformation expectedTransformation = new( + new Webhooks::Error("encoding_failed") + ); + string expectedUrl = "https://example.com"; + + Assert.Equal(expectedFileID, deserialized.FileID); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedPath, deserialized.Path); + Assert.Equal(expectedTransformation, deserialized.Transformation); + Assert.Equal(expectedUrl, deserialized.Url); + } + + [Fact] + public void Validation_Works() + { + var model = new Webhooks::Data + { + FileID = "fileId", + Name = "name", + Path = "path", + Transformation = new(new Webhooks::Error("encoding_failed")), + Url = "https://example.com", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Webhooks::Data + { + FileID = "fileId", + Name = "name", + Path = "path", + Transformation = new(new Webhooks::Error("encoding_failed")), + Url = "https://example.com", + }; + + Webhooks::Data copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TransformationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Webhooks::Transformation { Error = new("encoding_failed") }; + + Webhooks::Error expectedError = new("encoding_failed"); + + Assert.Equal(expectedError, model.Error); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Webhooks::Transformation { Error = new("encoding_failed") }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Webhooks::Transformation { Error = new("encoding_failed") }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + Webhooks::Error expectedError = new("encoding_failed"); + + Assert.Equal(expectedError, deserialized.Error); + } + + [Fact] + public void Validation_Works() + { + var model = new Webhooks::Transformation { Error = new("encoding_failed") }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Webhooks::Transformation { Error = new("encoding_failed") }; + + Webhooks::Transformation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ErrorTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Webhooks::Error { Reason = "encoding_failed" }; + + string expectedReason = "encoding_failed"; + + Assert.Equal(expectedReason, model.Reason); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Webhooks::Error { Reason = "encoding_failed" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Webhooks::Error { Reason = "encoding_failed" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedReason = "encoding_failed"; + + Assert.Equal(expectedReason, deserialized.Reason); + } + + [Fact] + public void Validation_Works() + { + var model = new Webhooks::Error { Reason = "encoding_failed" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Webhooks::Error { Reason = "encoding_failed" }; + + Webhooks::Error copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class RequestTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Webhooks::Request + { + Transformation = new() + { + Type = Webhooks::Type.Transformation, + Protocol = Webhooks::Protocol.Hls, + Value = "value", + }, + XRequestID = "x_request_id", + }; + + Webhooks::RequestTransformation expectedTransformation = new() + { + Type = Webhooks::Type.Transformation, + Protocol = Webhooks::Protocol.Hls, + Value = "value", + }; + string expectedXRequestID = "x_request_id"; + + Assert.Equal(expectedTransformation, model.Transformation); + Assert.Equal(expectedXRequestID, model.XRequestID); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Webhooks::Request + { + Transformation = new() + { + Type = Webhooks::Type.Transformation, + Protocol = Webhooks::Protocol.Hls, + Value = "value", + }, + XRequestID = "x_request_id", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Webhooks::Request + { + Transformation = new() + { + Type = Webhooks::Type.Transformation, + Protocol = Webhooks::Protocol.Hls, + Value = "value", + }, + XRequestID = "x_request_id", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + Webhooks::RequestTransformation expectedTransformation = new() + { + Type = Webhooks::Type.Transformation, + Protocol = Webhooks::Protocol.Hls, + Value = "value", + }; + string expectedXRequestID = "x_request_id"; + + Assert.Equal(expectedTransformation, deserialized.Transformation); + Assert.Equal(expectedXRequestID, deserialized.XRequestID); + } + + [Fact] + public void Validation_Works() + { + var model = new Webhooks::Request + { + Transformation = new() + { + Type = Webhooks::Type.Transformation, + Protocol = Webhooks::Protocol.Hls, + Value = "value", + }, + XRequestID = "x_request_id", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Webhooks::Request + { + Transformation = new() + { + Type = Webhooks::Type.Transformation, + Protocol = Webhooks::Protocol.Hls, + Value = "value", + }, + XRequestID = "x_request_id", + }; + + Webhooks::Request copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class RequestTransformationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Webhooks::RequestTransformation + { + Type = Webhooks::Type.Transformation, + Protocol = Webhooks::Protocol.Hls, + Value = "value", + }; + + ApiEnum expectedType = Webhooks::Type.Transformation; + ApiEnum expectedProtocol = Webhooks::Protocol.Hls; + string expectedValue = "value"; + + Assert.Equal(expectedType, model.Type); + Assert.Equal(expectedProtocol, model.Protocol); + Assert.Equal(expectedValue, model.Value); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Webhooks::RequestTransformation + { + Type = Webhooks::Type.Transformation, + Protocol = Webhooks::Protocol.Hls, + Value = "value", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Webhooks::RequestTransformation + { + Type = Webhooks::Type.Transformation, + Protocol = Webhooks::Protocol.Hls, + Value = "value", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum expectedType = Webhooks::Type.Transformation; + ApiEnum expectedProtocol = Webhooks::Protocol.Hls; + string expectedValue = "value"; + + Assert.Equal(expectedType, deserialized.Type); + Assert.Equal(expectedProtocol, deserialized.Protocol); + Assert.Equal(expectedValue, deserialized.Value); + } + + [Fact] + public void Validation_Works() + { + var model = new Webhooks::RequestTransformation + { + Type = Webhooks::Type.Transformation, + Protocol = Webhooks::Protocol.Hls, + Value = "value", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Webhooks::RequestTransformation { Type = Webhooks::Type.Transformation }; + + Assert.Null(model.Protocol); + Assert.False(model.RawData.ContainsKey("protocol")); + Assert.Null(model.Value); + Assert.False(model.RawData.ContainsKey("value")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new Webhooks::RequestTransformation { Type = Webhooks::Type.Transformation }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new Webhooks::RequestTransformation + { + Type = Webhooks::Type.Transformation, + + // Null should be interpreted as omitted for these properties + Protocol = null, + Value = null, + }; + + Assert.Null(model.Protocol); + Assert.False(model.RawData.ContainsKey("protocol")); + Assert.Null(model.Value); + Assert.False(model.RawData.ContainsKey("value")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new Webhooks::RequestTransformation + { + Type = Webhooks::Type.Transformation, + + // Null should be interpreted as omitted for these properties + Protocol = null, + Value = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Webhooks::RequestTransformation + { + Type = Webhooks::Type.Transformation, + Protocol = Webhooks::Protocol.Hls, + Value = "value", + }; + + Webhooks::RequestTransformation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TypeTest : TestBase +{ + [Theory] + [InlineData(Webhooks::Type.Transformation)] + [InlineData(Webhooks::Type.Abs)] + [InlineData(Webhooks::Type.GifToVideo)] + [InlineData(Webhooks::Type.Thumbnail)] + public void Validation_Works(Webhooks::Type rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(Webhooks::Type.Transformation)] + [InlineData(Webhooks::Type.Abs)] + [InlineData(Webhooks::Type.GifToVideo)] + [InlineData(Webhooks::Type.Thumbnail)] + public void SerializationRoundtrip_Works(Webhooks::Type rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class ProtocolTest : TestBase +{ + [Theory] + [InlineData(Webhooks::Protocol.Hls)] + [InlineData(Webhooks::Protocol.Dash)] + public void Validation_Works(Webhooks::Protocol rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(Webhooks::Protocol.Hls)] + [InlineData(Webhooks::Protocol.Dash)] + public void SerializationRoundtrip_Works(Webhooks::Protocol rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} diff --git a/src/ImageKit.Tests/Models/Webhooks/UploadPostTransformSuccessEventTest.cs b/src/ImageKit.Tests/Models/Webhooks/UploadPostTransformSuccessEventTest.cs new file mode 100644 index 00000000..1007f99c --- /dev/null +++ b/src/ImageKit.Tests/Models/Webhooks/UploadPostTransformSuccessEventTest.cs @@ -0,0 +1,1048 @@ +using System; +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Exceptions; +using ImageKit.Models.Webhooks; + +namespace ImageKit.Tests.Models.Webhooks; + +public class UploadPostTransformSuccessEventTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UploadPostTransformSuccessEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + FileID = "fileId", + Name = "name", + Url = "https://example.com", + }, + Request = new() + { + Transformation = new() + { + Type = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + Protocol = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + Value = "value", + }, + XRequestID = "x_request_id", + }, + }; + + string expectedID = "id"; + string expectedType = "type"; + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + UploadPostTransformSuccessEventIntersectionMember1Data expectedData = new() + { + FileID = "fileId", + Name = "name", + Url = "https://example.com", + }; + UploadPostTransformSuccessEventIntersectionMember1Request expectedRequest = new() + { + Transformation = new() + { + Type = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + Protocol = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + Value = "value", + }, + XRequestID = "x_request_id", + }; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedType, model.Type); + Assert.Equal(expectedCreatedAt, model.CreatedAt); + Assert.Equal(expectedData, model.Data); + Assert.Equal(expectedRequest, model.Request); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UploadPostTransformSuccessEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + FileID = "fileId", + Name = "name", + Url = "https://example.com", + }, + Request = new() + { + Transformation = new() + { + Type = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + Protocol = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + Value = "value", + }, + XRequestID = "x_request_id", + }, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new UploadPostTransformSuccessEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + FileID = "fileId", + Name = "name", + Url = "https://example.com", + }, + Request = new() + { + Transformation = new() + { + Type = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + Protocol = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + Value = "value", + }, + XRequestID = "x_request_id", + }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedType = "type"; + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + UploadPostTransformSuccessEventIntersectionMember1Data expectedData = new() + { + FileID = "fileId", + Name = "name", + Url = "https://example.com", + }; + UploadPostTransformSuccessEventIntersectionMember1Request expectedRequest = new() + { + Transformation = new() + { + Type = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + Protocol = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + Value = "value", + }, + XRequestID = "x_request_id", + }; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedType, deserialized.Type); + Assert.Equal(expectedCreatedAt, deserialized.CreatedAt); + Assert.Equal(expectedData, deserialized.Data); + Assert.Equal(expectedRequest, deserialized.Request); + } + + [Fact] + public void Validation_Works() + { + var model = new UploadPostTransformSuccessEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + FileID = "fileId", + Name = "name", + Url = "https://example.com", + }, + Request = new() + { + Transformation = new() + { + Type = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + Protocol = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + Value = "value", + }, + XRequestID = "x_request_id", + }, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UploadPostTransformSuccessEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + FileID = "fileId", + Name = "name", + Url = "https://example.com", + }, + Request = new() + { + Transformation = new() + { + Type = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + Protocol = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + Value = "value", + }, + XRequestID = "x_request_id", + }, + }; + + UploadPostTransformSuccessEvent copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UploadPostTransformSuccessEventIntersectionMember1Test : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UploadPostTransformSuccessEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + FileID = "fileId", + Name = "name", + Url = "https://example.com", + }, + Request = new() + { + Transformation = new() + { + Type = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + Protocol = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + Value = "value", + }, + XRequestID = "x_request_id", + }, + }; + + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + UploadPostTransformSuccessEventIntersectionMember1Data expectedData = new() + { + FileID = "fileId", + Name = "name", + Url = "https://example.com", + }; + UploadPostTransformSuccessEventIntersectionMember1Request expectedRequest = new() + { + Transformation = new() + { + Type = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + Protocol = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + Value = "value", + }, + XRequestID = "x_request_id", + }; + JsonElement expectedType = JsonSerializer.SerializeToElement( + "upload.post-transform.success" + ); + + Assert.Equal(expectedCreatedAt, model.CreatedAt); + Assert.Equal(expectedData, model.Data); + Assert.Equal(expectedRequest, model.Request); + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UploadPostTransformSuccessEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + FileID = "fileId", + Name = "name", + Url = "https://example.com", + }, + Request = new() + { + Transformation = new() + { + Type = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + Protocol = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + Value = "value", + }, + XRequestID = "x_request_id", + }, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new UploadPostTransformSuccessEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + FileID = "fileId", + Name = "name", + Url = "https://example.com", + }, + Request = new() + { + Transformation = new() + { + Type = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + Protocol = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + Value = "value", + }, + XRequestID = "x_request_id", + }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + UploadPostTransformSuccessEventIntersectionMember1Data expectedData = new() + { + FileID = "fileId", + Name = "name", + Url = "https://example.com", + }; + UploadPostTransformSuccessEventIntersectionMember1Request expectedRequest = new() + { + Transformation = new() + { + Type = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + Protocol = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + Value = "value", + }, + XRequestID = "x_request_id", + }; + JsonElement expectedType = JsonSerializer.SerializeToElement( + "upload.post-transform.success" + ); + + Assert.Equal(expectedCreatedAt, deserialized.CreatedAt); + Assert.Equal(expectedData, deserialized.Data); + Assert.Equal(expectedRequest, deserialized.Request); + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + } + + [Fact] + public void Validation_Works() + { + var model = new UploadPostTransformSuccessEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + FileID = "fileId", + Name = "name", + Url = "https://example.com", + }, + Request = new() + { + Transformation = new() + { + Type = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + Protocol = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + Value = "value", + }, + XRequestID = "x_request_id", + }, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UploadPostTransformSuccessEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + FileID = "fileId", + Name = "name", + Url = "https://example.com", + }, + Request = new() + { + Transformation = new() + { + Type = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + Protocol = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + Value = "value", + }, + XRequestID = "x_request_id", + }, + }; + + UploadPostTransformSuccessEventIntersectionMember1 copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UploadPostTransformSuccessEventIntersectionMember1DataTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UploadPostTransformSuccessEventIntersectionMember1Data + { + FileID = "fileId", + Name = "name", + Url = "https://example.com", + }; + + string expectedFileID = "fileId"; + string expectedName = "name"; + string expectedUrl = "https://example.com"; + + Assert.Equal(expectedFileID, model.FileID); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedUrl, model.Url); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UploadPostTransformSuccessEventIntersectionMember1Data + { + FileID = "fileId", + Name = "name", + Url = "https://example.com", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new UploadPostTransformSuccessEventIntersectionMember1Data + { + FileID = "fileId", + Name = "name", + Url = "https://example.com", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedFileID = "fileId"; + string expectedName = "name"; + string expectedUrl = "https://example.com"; + + Assert.Equal(expectedFileID, deserialized.FileID); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedUrl, deserialized.Url); + } + + [Fact] + public void Validation_Works() + { + var model = new UploadPostTransformSuccessEventIntersectionMember1Data + { + FileID = "fileId", + Name = "name", + Url = "https://example.com", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UploadPostTransformSuccessEventIntersectionMember1Data + { + FileID = "fileId", + Name = "name", + Url = "https://example.com", + }; + + UploadPostTransformSuccessEventIntersectionMember1Data copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UploadPostTransformSuccessEventIntersectionMember1RequestTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UploadPostTransformSuccessEventIntersectionMember1Request + { + Transformation = new() + { + Type = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + Protocol = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + Value = "value", + }, + XRequestID = "x_request_id", + }; + + UploadPostTransformSuccessEventIntersectionMember1RequestTransformation expectedTransformation = + new() + { + Type = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + Protocol = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + Value = "value", + }; + string expectedXRequestID = "x_request_id"; + + Assert.Equal(expectedTransformation, model.Transformation); + Assert.Equal(expectedXRequestID, model.XRequestID); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UploadPostTransformSuccessEventIntersectionMember1Request + { + Transformation = new() + { + Type = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + Protocol = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + Value = "value", + }, + XRequestID = "x_request_id", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new UploadPostTransformSuccessEventIntersectionMember1Request + { + Transformation = new() + { + Type = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + Protocol = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + Value = "value", + }, + XRequestID = "x_request_id", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + UploadPostTransformSuccessEventIntersectionMember1RequestTransformation expectedTransformation = + new() + { + Type = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + Protocol = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + Value = "value", + }; + string expectedXRequestID = "x_request_id"; + + Assert.Equal(expectedTransformation, deserialized.Transformation); + Assert.Equal(expectedXRequestID, deserialized.XRequestID); + } + + [Fact] + public void Validation_Works() + { + var model = new UploadPostTransformSuccessEventIntersectionMember1Request + { + Transformation = new() + { + Type = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + Protocol = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + Value = "value", + }, + XRequestID = "x_request_id", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UploadPostTransformSuccessEventIntersectionMember1Request + { + Transformation = new() + { + Type = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + Protocol = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + Value = "value", + }, + XRequestID = "x_request_id", + }; + + UploadPostTransformSuccessEventIntersectionMember1Request copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UploadPostTransformSuccessEventIntersectionMember1RequestTransformationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UploadPostTransformSuccessEventIntersectionMember1RequestTransformation + { + Type = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + Protocol = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + Value = "value", + }; + + ApiEnum< + string, + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType + > expectedType = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation; + ApiEnum< + string, + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol + > expectedProtocol = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls; + string expectedValue = "value"; + + Assert.Equal(expectedType, model.Type); + Assert.Equal(expectedProtocol, model.Protocol); + Assert.Equal(expectedValue, model.Value); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UploadPostTransformSuccessEventIntersectionMember1RequestTransformation + { + Type = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + Protocol = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + Value = "value", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new UploadPostTransformSuccessEventIntersectionMember1RequestTransformation + { + Type = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + Protocol = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + Value = "value", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum< + string, + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType + > expectedType = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation; + ApiEnum< + string, + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol + > expectedProtocol = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls; + string expectedValue = "value"; + + Assert.Equal(expectedType, deserialized.Type); + Assert.Equal(expectedProtocol, deserialized.Protocol); + Assert.Equal(expectedValue, deserialized.Value); + } + + [Fact] + public void Validation_Works() + { + var model = new UploadPostTransformSuccessEventIntersectionMember1RequestTransformation + { + Type = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + Protocol = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + Value = "value", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new UploadPostTransformSuccessEventIntersectionMember1RequestTransformation + { + Type = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + }; + + Assert.Null(model.Protocol); + Assert.False(model.RawData.ContainsKey("protocol")); + Assert.Null(model.Value); + Assert.False(model.RawData.ContainsKey("value")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new UploadPostTransformSuccessEventIntersectionMember1RequestTransformation + { + Type = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new UploadPostTransformSuccessEventIntersectionMember1RequestTransformation + { + Type = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + + // Null should be interpreted as omitted for these properties + Protocol = null, + Value = null, + }; + + Assert.Null(model.Protocol); + Assert.False(model.RawData.ContainsKey("protocol")); + Assert.Null(model.Value); + Assert.False(model.RawData.ContainsKey("value")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new UploadPostTransformSuccessEventIntersectionMember1RequestTransformation + { + Type = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + + // Null should be interpreted as omitted for these properties + Protocol = null, + Value = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UploadPostTransformSuccessEventIntersectionMember1RequestTransformation + { + Type = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + Protocol = + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + Value = "value", + }; + + UploadPostTransformSuccessEventIntersectionMember1RequestTransformation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UploadPostTransformSuccessEventIntersectionMember1RequestTransformationTypeTest + : TestBase +{ + [Theory] + [InlineData( + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation + )] + [InlineData(UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Abs)] + [InlineData( + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.GifToVideo + )] + [InlineData( + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Thumbnail + )] + public void Validation_Works( + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType + > value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum< + string, + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType + > + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData( + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation + )] + [InlineData(UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Abs)] + [InlineData( + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.GifToVideo + )] + [InlineData( + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Thumbnail + )] + public void SerializationRoundtrip_Works( + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType + > value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum< + string, + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType + > + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum< + string, + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType + > + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum< + string, + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType + > + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocolTest + : TestBase +{ + [Theory] + [InlineData( + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls + )] + [InlineData( + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Dash + )] + public void Validation_Works( + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol + > value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum< + string, + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol + > + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData( + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls + )] + [InlineData( + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Dash + )] + public void SerializationRoundtrip_Works( + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol + > value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum< + string, + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol + > + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum< + string, + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol + > + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum< + string, + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol + > + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} diff --git a/src/ImageKit.Tests/Models/Webhooks/UploadPreTransformErrorEventTest.cs b/src/ImageKit.Tests/Models/Webhooks/UploadPreTransformErrorEventTest.cs new file mode 100644 index 00000000..5e282a35 --- /dev/null +++ b/src/ImageKit.Tests/Models/Webhooks/UploadPreTransformErrorEventTest.cs @@ -0,0 +1,739 @@ +using System; +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Models.Webhooks; + +namespace ImageKit.Tests.Models.Webhooks; + +public class UploadPreTransformErrorEventTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UploadPreTransformErrorEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Name = "name", + Path = "path", + Transformation = new( + new UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + "encoding_failed" + ) + ), + }, + Request = new() { Transformation = "transformation", XRequestID = "x_request_id" }, + }; + + string expectedID = "id"; + string expectedType = "type"; + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + UploadPreTransformErrorEventIntersectionMember1Data expectedData = new() + { + Name = "name", + Path = "path", + Transformation = new( + new UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + "encoding_failed" + ) + ), + }; + UploadPreTransformErrorEventIntersectionMember1Request expectedRequest = new() + { + Transformation = "transformation", + XRequestID = "x_request_id", + }; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedType, model.Type); + Assert.Equal(expectedCreatedAt, model.CreatedAt); + Assert.Equal(expectedData, model.Data); + Assert.Equal(expectedRequest, model.Request); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UploadPreTransformErrorEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Name = "name", + Path = "path", + Transformation = new( + new UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + "encoding_failed" + ) + ), + }, + Request = new() { Transformation = "transformation", XRequestID = "x_request_id" }, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new UploadPreTransformErrorEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Name = "name", + Path = "path", + Transformation = new( + new UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + "encoding_failed" + ) + ), + }, + Request = new() { Transformation = "transformation", XRequestID = "x_request_id" }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedType = "type"; + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + UploadPreTransformErrorEventIntersectionMember1Data expectedData = new() + { + Name = "name", + Path = "path", + Transformation = new( + new UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + "encoding_failed" + ) + ), + }; + UploadPreTransformErrorEventIntersectionMember1Request expectedRequest = new() + { + Transformation = "transformation", + XRequestID = "x_request_id", + }; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedType, deserialized.Type); + Assert.Equal(expectedCreatedAt, deserialized.CreatedAt); + Assert.Equal(expectedData, deserialized.Data); + Assert.Equal(expectedRequest, deserialized.Request); + } + + [Fact] + public void Validation_Works() + { + var model = new UploadPreTransformErrorEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Name = "name", + Path = "path", + Transformation = new( + new UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + "encoding_failed" + ) + ), + }, + Request = new() { Transformation = "transformation", XRequestID = "x_request_id" }, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UploadPreTransformErrorEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Name = "name", + Path = "path", + Transformation = new( + new UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + "encoding_failed" + ) + ), + }, + Request = new() { Transformation = "transformation", XRequestID = "x_request_id" }, + }; + + UploadPreTransformErrorEvent copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UploadPreTransformErrorEventIntersectionMember1Test : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UploadPreTransformErrorEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Name = "name", + Path = "path", + Transformation = new( + new UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + "encoding_failed" + ) + ), + }, + Request = new() { Transformation = "transformation", XRequestID = "x_request_id" }, + }; + + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + UploadPreTransformErrorEventIntersectionMember1Data expectedData = new() + { + Name = "name", + Path = "path", + Transformation = new( + new UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + "encoding_failed" + ) + ), + }; + UploadPreTransformErrorEventIntersectionMember1Request expectedRequest = new() + { + Transformation = "transformation", + XRequestID = "x_request_id", + }; + JsonElement expectedType = JsonSerializer.SerializeToElement("upload.pre-transform.error"); + + Assert.Equal(expectedCreatedAt, model.CreatedAt); + Assert.Equal(expectedData, model.Data); + Assert.Equal(expectedRequest, model.Request); + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UploadPreTransformErrorEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Name = "name", + Path = "path", + Transformation = new( + new UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + "encoding_failed" + ) + ), + }, + Request = new() { Transformation = "transformation", XRequestID = "x_request_id" }, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new UploadPreTransformErrorEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Name = "name", + Path = "path", + Transformation = new( + new UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + "encoding_failed" + ) + ), + }, + Request = new() { Transformation = "transformation", XRequestID = "x_request_id" }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + UploadPreTransformErrorEventIntersectionMember1Data expectedData = new() + { + Name = "name", + Path = "path", + Transformation = new( + new UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + "encoding_failed" + ) + ), + }; + UploadPreTransformErrorEventIntersectionMember1Request expectedRequest = new() + { + Transformation = "transformation", + XRequestID = "x_request_id", + }; + JsonElement expectedType = JsonSerializer.SerializeToElement("upload.pre-transform.error"); + + Assert.Equal(expectedCreatedAt, deserialized.CreatedAt); + Assert.Equal(expectedData, deserialized.Data); + Assert.Equal(expectedRequest, deserialized.Request); + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + } + + [Fact] + public void Validation_Works() + { + var model = new UploadPreTransformErrorEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Name = "name", + Path = "path", + Transformation = new( + new UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + "encoding_failed" + ) + ), + }, + Request = new() { Transformation = "transformation", XRequestID = "x_request_id" }, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UploadPreTransformErrorEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Name = "name", + Path = "path", + Transformation = new( + new UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + "encoding_failed" + ) + ), + }, + Request = new() { Transformation = "transformation", XRequestID = "x_request_id" }, + }; + + UploadPreTransformErrorEventIntersectionMember1 copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UploadPreTransformErrorEventIntersectionMember1DataTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UploadPreTransformErrorEventIntersectionMember1Data + { + Name = "name", + Path = "path", + Transformation = new( + new UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + "encoding_failed" + ) + ), + }; + + string expectedName = "name"; + string expectedPath = "path"; + UploadPreTransformErrorEventIntersectionMember1DataTransformation expectedTransformation = + new( + new UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + "encoding_failed" + ) + ); + + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedPath, model.Path); + Assert.Equal(expectedTransformation, model.Transformation); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UploadPreTransformErrorEventIntersectionMember1Data + { + Name = "name", + Path = "path", + Transformation = new( + new UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + "encoding_failed" + ) + ), + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new UploadPreTransformErrorEventIntersectionMember1Data + { + Name = "name", + Path = "path", + Transformation = new( + new UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + "encoding_failed" + ) + ), + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedName = "name"; + string expectedPath = "path"; + UploadPreTransformErrorEventIntersectionMember1DataTransformation expectedTransformation = + new( + new UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + "encoding_failed" + ) + ); + + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedPath, deserialized.Path); + Assert.Equal(expectedTransformation, deserialized.Transformation); + } + + [Fact] + public void Validation_Works() + { + var model = new UploadPreTransformErrorEventIntersectionMember1Data + { + Name = "name", + Path = "path", + Transformation = new( + new UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + "encoding_failed" + ) + ), + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UploadPreTransformErrorEventIntersectionMember1Data + { + Name = "name", + Path = "path", + Transformation = new( + new UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + "encoding_failed" + ) + ), + }; + + UploadPreTransformErrorEventIntersectionMember1Data copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UploadPreTransformErrorEventIntersectionMember1DataTransformationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UploadPreTransformErrorEventIntersectionMember1DataTransformation + { + Error = new("encoding_failed"), + }; + + UploadPreTransformErrorEventIntersectionMember1DataTransformationError expectedError = new( + "encoding_failed" + ); + + Assert.Equal(expectedError, model.Error); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UploadPreTransformErrorEventIntersectionMember1DataTransformation + { + Error = new("encoding_failed"), + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new UploadPreTransformErrorEventIntersectionMember1DataTransformation + { + Error = new("encoding_failed"), + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + UploadPreTransformErrorEventIntersectionMember1DataTransformationError expectedError = new( + "encoding_failed" + ); + + Assert.Equal(expectedError, deserialized.Error); + } + + [Fact] + public void Validation_Works() + { + var model = new UploadPreTransformErrorEventIntersectionMember1DataTransformation + { + Error = new("encoding_failed"), + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UploadPreTransformErrorEventIntersectionMember1DataTransformation + { + Error = new("encoding_failed"), + }; + + UploadPreTransformErrorEventIntersectionMember1DataTransformation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UploadPreTransformErrorEventIntersectionMember1DataTransformationErrorTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UploadPreTransformErrorEventIntersectionMember1DataTransformationError + { + Reason = "encoding_failed", + }; + + string expectedReason = "encoding_failed"; + + Assert.Equal(expectedReason, model.Reason); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UploadPreTransformErrorEventIntersectionMember1DataTransformationError + { + Reason = "encoding_failed", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new UploadPreTransformErrorEventIntersectionMember1DataTransformationError + { + Reason = "encoding_failed", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedReason = "encoding_failed"; + + Assert.Equal(expectedReason, deserialized.Reason); + } + + [Fact] + public void Validation_Works() + { + var model = new UploadPreTransformErrorEventIntersectionMember1DataTransformationError + { + Reason = "encoding_failed", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UploadPreTransformErrorEventIntersectionMember1DataTransformationError + { + Reason = "encoding_failed", + }; + + UploadPreTransformErrorEventIntersectionMember1DataTransformationError copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UploadPreTransformErrorEventIntersectionMember1RequestTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UploadPreTransformErrorEventIntersectionMember1Request + { + Transformation = "transformation", + XRequestID = "x_request_id", + }; + + string expectedTransformation = "transformation"; + string expectedXRequestID = "x_request_id"; + + Assert.Equal(expectedTransformation, model.Transformation); + Assert.Equal(expectedXRequestID, model.XRequestID); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UploadPreTransformErrorEventIntersectionMember1Request + { + Transformation = "transformation", + XRequestID = "x_request_id", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new UploadPreTransformErrorEventIntersectionMember1Request + { + Transformation = "transformation", + XRequestID = "x_request_id", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedTransformation = "transformation"; + string expectedXRequestID = "x_request_id"; + + Assert.Equal(expectedTransformation, deserialized.Transformation); + Assert.Equal(expectedXRequestID, deserialized.XRequestID); + } + + [Fact] + public void Validation_Works() + { + var model = new UploadPreTransformErrorEventIntersectionMember1Request + { + Transformation = "transformation", + XRequestID = "x_request_id", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UploadPreTransformErrorEventIntersectionMember1Request + { + Transformation = "transformation", + XRequestID = "x_request_id", + }; + + UploadPreTransformErrorEventIntersectionMember1Request copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Webhooks/UploadPreTransformSuccessEventTest.cs b/src/ImageKit.Tests/Models/Webhooks/UploadPreTransformSuccessEventTest.cs new file mode 100644 index 00000000..3990d21f --- /dev/null +++ b/src/ImageKit.Tests/Models/Webhooks/UploadPreTransformSuccessEventTest.cs @@ -0,0 +1,5746 @@ +using System; +using System.Collections.Generic; +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Exceptions; +using ImageKit.Models.Webhooks; +using Files = ImageKit.Models.Files; + +namespace ImageKit.Tests.Models.Webhooks; + +public class UploadPreTransformSuccessEventTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UploadPreTransformSuccessEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ExtensionStatus = new() + { + AIAutoDescription = AIAutoDescription.Success, + AITasks = AITasks.Success, + AwsAutoTagging = AwsAutoTagging.Success, + GoogleAutoTagging = GoogleAutoTagging.Success, + RemoveBg = RemoveBg.Success, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Metadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }, + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = SelectedFieldsSchemaItemType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + ThumbnailUrl = "thumbnailUrl", + Url = "url", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, + Request = new() { Transformation = "transformation", XRequestID = "x_request_id" }, + }; + + string expectedID = "id"; + string expectedType = "type"; + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + UploadPreTransformSuccessEventIntersectionMember1Data expectedData = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ExtensionStatus = new() + { + AIAutoDescription = AIAutoDescription.Success, + AITasks = AITasks.Success, + AwsAutoTagging = AwsAutoTagging.Success, + GoogleAutoTagging = GoogleAutoTagging.Success, + RemoveBg = RemoveBg.Success, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Metadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }, + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = SelectedFieldsSchemaItemType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + ThumbnailUrl = "thumbnailUrl", + Url = "url", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }; + UploadPreTransformSuccessEventIntersectionMember1Request expectedRequest = new() + { + Transformation = "transformation", + XRequestID = "x_request_id", + }; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedType, model.Type); + Assert.Equal(expectedCreatedAt, model.CreatedAt); + Assert.Equal(expectedData, model.Data); + Assert.Equal(expectedRequest, model.Request); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UploadPreTransformSuccessEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ExtensionStatus = new() + { + AIAutoDescription = AIAutoDescription.Success, + AITasks = AITasks.Success, + AwsAutoTagging = AwsAutoTagging.Success, + GoogleAutoTagging = GoogleAutoTagging.Success, + RemoveBg = RemoveBg.Success, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Metadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }, + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = SelectedFieldsSchemaItemType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + ThumbnailUrl = "thumbnailUrl", + Url = "url", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, + Request = new() { Transformation = "transformation", XRequestID = "x_request_id" }, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new UploadPreTransformSuccessEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ExtensionStatus = new() + { + AIAutoDescription = AIAutoDescription.Success, + AITasks = AITasks.Success, + AwsAutoTagging = AwsAutoTagging.Success, + GoogleAutoTagging = GoogleAutoTagging.Success, + RemoveBg = RemoveBg.Success, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Metadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }, + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = SelectedFieldsSchemaItemType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + ThumbnailUrl = "thumbnailUrl", + Url = "url", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, + Request = new() { Transformation = "transformation", XRequestID = "x_request_id" }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedType = "type"; + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + UploadPreTransformSuccessEventIntersectionMember1Data expectedData = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ExtensionStatus = new() + { + AIAutoDescription = AIAutoDescription.Success, + AITasks = AITasks.Success, + AwsAutoTagging = AwsAutoTagging.Success, + GoogleAutoTagging = GoogleAutoTagging.Success, + RemoveBg = RemoveBg.Success, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Metadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }, + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = SelectedFieldsSchemaItemType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + ThumbnailUrl = "thumbnailUrl", + Url = "url", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }; + UploadPreTransformSuccessEventIntersectionMember1Request expectedRequest = new() + { + Transformation = "transformation", + XRequestID = "x_request_id", + }; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedType, deserialized.Type); + Assert.Equal(expectedCreatedAt, deserialized.CreatedAt); + Assert.Equal(expectedData, deserialized.Data); + Assert.Equal(expectedRequest, deserialized.Request); + } + + [Fact] + public void Validation_Works() + { + var model = new UploadPreTransformSuccessEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ExtensionStatus = new() + { + AIAutoDescription = AIAutoDescription.Success, + AITasks = AITasks.Success, + AwsAutoTagging = AwsAutoTagging.Success, + GoogleAutoTagging = GoogleAutoTagging.Success, + RemoveBg = RemoveBg.Success, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Metadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }, + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = SelectedFieldsSchemaItemType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + ThumbnailUrl = "thumbnailUrl", + Url = "url", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, + Request = new() { Transformation = "transformation", XRequestID = "x_request_id" }, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UploadPreTransformSuccessEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ExtensionStatus = new() + { + AIAutoDescription = AIAutoDescription.Success, + AITasks = AITasks.Success, + AwsAutoTagging = AwsAutoTagging.Success, + GoogleAutoTagging = GoogleAutoTagging.Success, + RemoveBg = RemoveBg.Success, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Metadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }, + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = SelectedFieldsSchemaItemType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + ThumbnailUrl = "thumbnailUrl", + Url = "url", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, + Request = new() { Transformation = "transformation", XRequestID = "x_request_id" }, + }; + + UploadPreTransformSuccessEvent copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UploadPreTransformSuccessEventIntersectionMember1Test : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UploadPreTransformSuccessEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ExtensionStatus = new() + { + AIAutoDescription = AIAutoDescription.Success, + AITasks = AITasks.Success, + AwsAutoTagging = AwsAutoTagging.Success, + GoogleAutoTagging = GoogleAutoTagging.Success, + RemoveBg = RemoveBg.Success, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Metadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }, + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = SelectedFieldsSchemaItemType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + ThumbnailUrl = "thumbnailUrl", + Url = "url", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, + Request = new() { Transformation = "transformation", XRequestID = "x_request_id" }, + }; + + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + UploadPreTransformSuccessEventIntersectionMember1Data expectedData = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ExtensionStatus = new() + { + AIAutoDescription = AIAutoDescription.Success, + AITasks = AITasks.Success, + AwsAutoTagging = AwsAutoTagging.Success, + GoogleAutoTagging = GoogleAutoTagging.Success, + RemoveBg = RemoveBg.Success, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Metadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }, + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = SelectedFieldsSchemaItemType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + ThumbnailUrl = "thumbnailUrl", + Url = "url", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }; + UploadPreTransformSuccessEventIntersectionMember1Request expectedRequest = new() + { + Transformation = "transformation", + XRequestID = "x_request_id", + }; + JsonElement expectedType = JsonSerializer.SerializeToElement( + "upload.pre-transform.success" + ); + + Assert.Equal(expectedCreatedAt, model.CreatedAt); + Assert.Equal(expectedData, model.Data); + Assert.Equal(expectedRequest, model.Request); + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UploadPreTransformSuccessEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ExtensionStatus = new() + { + AIAutoDescription = AIAutoDescription.Success, + AITasks = AITasks.Success, + AwsAutoTagging = AwsAutoTagging.Success, + GoogleAutoTagging = GoogleAutoTagging.Success, + RemoveBg = RemoveBg.Success, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Metadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }, + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = SelectedFieldsSchemaItemType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + ThumbnailUrl = "thumbnailUrl", + Url = "url", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, + Request = new() { Transformation = "transformation", XRequestID = "x_request_id" }, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new UploadPreTransformSuccessEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ExtensionStatus = new() + { + AIAutoDescription = AIAutoDescription.Success, + AITasks = AITasks.Success, + AwsAutoTagging = AwsAutoTagging.Success, + GoogleAutoTagging = GoogleAutoTagging.Success, + RemoveBg = RemoveBg.Success, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Metadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }, + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = SelectedFieldsSchemaItemType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + ThumbnailUrl = "thumbnailUrl", + Url = "url", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, + Request = new() { Transformation = "transformation", XRequestID = "x_request_id" }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + UploadPreTransformSuccessEventIntersectionMember1Data expectedData = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ExtensionStatus = new() + { + AIAutoDescription = AIAutoDescription.Success, + AITasks = AITasks.Success, + AwsAutoTagging = AwsAutoTagging.Success, + GoogleAutoTagging = GoogleAutoTagging.Success, + RemoveBg = RemoveBg.Success, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Metadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }, + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = SelectedFieldsSchemaItemType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + ThumbnailUrl = "thumbnailUrl", + Url = "url", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }; + UploadPreTransformSuccessEventIntersectionMember1Request expectedRequest = new() + { + Transformation = "transformation", + XRequestID = "x_request_id", + }; + JsonElement expectedType = JsonSerializer.SerializeToElement( + "upload.pre-transform.success" + ); + + Assert.Equal(expectedCreatedAt, deserialized.CreatedAt); + Assert.Equal(expectedData, deserialized.Data); + Assert.Equal(expectedRequest, deserialized.Request); + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + } + + [Fact] + public void Validation_Works() + { + var model = new UploadPreTransformSuccessEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ExtensionStatus = new() + { + AIAutoDescription = AIAutoDescription.Success, + AITasks = AITasks.Success, + AwsAutoTagging = AwsAutoTagging.Success, + GoogleAutoTagging = GoogleAutoTagging.Success, + RemoveBg = RemoveBg.Success, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Metadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }, + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = SelectedFieldsSchemaItemType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + ThumbnailUrl = "thumbnailUrl", + Url = "url", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, + Request = new() { Transformation = "transformation", XRequestID = "x_request_id" }, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UploadPreTransformSuccessEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ExtensionStatus = new() + { + AIAutoDescription = AIAutoDescription.Success, + AITasks = AITasks.Success, + AwsAutoTagging = AwsAutoTagging.Success, + GoogleAutoTagging = GoogleAutoTagging.Success, + RemoveBg = RemoveBg.Success, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Metadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }, + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = SelectedFieldsSchemaItemType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + ThumbnailUrl = "thumbnailUrl", + Url = "url", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, + Request = new() { Transformation = "transformation", XRequestID = "x_request_id" }, + }; + + UploadPreTransformSuccessEventIntersectionMember1 copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UploadPreTransformSuccessEventIntersectionMember1DataTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UploadPreTransformSuccessEventIntersectionMember1Data + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ExtensionStatus = new() + { + AIAutoDescription = AIAutoDescription.Success, + AITasks = AITasks.Success, + AwsAutoTagging = AwsAutoTagging.Success, + GoogleAutoTagging = GoogleAutoTagging.Success, + RemoveBg = RemoveBg.Success, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Metadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }, + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = SelectedFieldsSchemaItemType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + ThumbnailUrl = "thumbnailUrl", + Url = "url", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }; + + List expectedAITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ]; + string expectedAudioCodec = "audioCodec"; + long expectedBitRate = 0; + string expectedCustomCoordinates = "customCoordinates"; + Dictionary expectedCustomMetadata = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; + string expectedDescription = "description"; + long expectedDuration = 0; + Dictionary expectedEmbeddedMetadata = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; + ExtensionStatus expectedExtensionStatus = new() + { + AIAutoDescription = AIAutoDescription.Success, + AITasks = AITasks.Success, + AwsAutoTagging = AwsAutoTagging.Success, + GoogleAutoTagging = GoogleAutoTagging.Success, + RemoveBg = RemoveBg.Success, + }; + string expectedFileID = "fileId"; + string expectedFilePath = "filePath"; + string expectedFileType = "fileType"; + double expectedHeight = 0; + bool expectedIsPrivateFile = true; + bool expectedIsPublished = true; + Files::FileMetadata expectedMetadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }; + string expectedName = "name"; + Dictionary expectedSelectedFieldsSchema = new() + { + { + "foo", + new() + { + Type = SelectedFieldsSchemaItemType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }; + double expectedSize = 0; + List expectedTags = ["string"]; + string expectedThumbnailUrl = "thumbnailUrl"; + string expectedUrl = "url"; + VersionInfo expectedVersionInfo = new() { ID = "id", Name = "name" }; + string expectedVideoCodec = "videoCodec"; + double expectedWidth = 0; + + Assert.NotNull(model.AITags); + Assert.Equal(expectedAITags.Count, model.AITags.Count); + for (int i = 0; i < expectedAITags.Count; i++) + { + Assert.Equal(expectedAITags[i], model.AITags[i]); + } + Assert.Equal(expectedAudioCodec, model.AudioCodec); + Assert.Equal(expectedBitRate, model.BitRate); + Assert.Equal(expectedCustomCoordinates, model.CustomCoordinates); + Assert.NotNull(model.CustomMetadata); + Assert.Equal(expectedCustomMetadata.Count, model.CustomMetadata.Count); + foreach (var item in expectedCustomMetadata) + { + Assert.True(model.CustomMetadata.TryGetValue(item.Key, out var value)); + + Assert.True(JsonElement.DeepEquals(value, model.CustomMetadata[item.Key])); + } + Assert.Equal(expectedDescription, model.Description); + Assert.Equal(expectedDuration, model.Duration); + Assert.NotNull(model.EmbeddedMetadata); + Assert.Equal(expectedEmbeddedMetadata.Count, model.EmbeddedMetadata.Count); + foreach (var item in expectedEmbeddedMetadata) + { + Assert.True(model.EmbeddedMetadata.TryGetValue(item.Key, out var value)); + + Assert.True(JsonElement.DeepEquals(value, model.EmbeddedMetadata[item.Key])); + } + Assert.Equal(expectedExtensionStatus, model.ExtensionStatus); + Assert.Equal(expectedFileID, model.FileID); + Assert.Equal(expectedFilePath, model.FilePath); + Assert.Equal(expectedFileType, model.FileType); + Assert.Equal(expectedHeight, model.Height); + Assert.Equal(expectedIsPrivateFile, model.IsPrivateFile); + Assert.Equal(expectedIsPublished, model.IsPublished); + Assert.Equal(expectedMetadata, model.Metadata); + Assert.Equal(expectedName, model.Name); + Assert.NotNull(model.SelectedFieldsSchema); + Assert.Equal(expectedSelectedFieldsSchema.Count, model.SelectedFieldsSchema.Count); + foreach (var item in expectedSelectedFieldsSchema) + { + Assert.True(model.SelectedFieldsSchema.TryGetValue(item.Key, out var value)); + + Assert.Equal(value, model.SelectedFieldsSchema[item.Key]); + } + Assert.Equal(expectedSize, model.Size); + Assert.NotNull(model.Tags); + Assert.Equal(expectedTags.Count, model.Tags.Count); + for (int i = 0; i < expectedTags.Count; i++) + { + Assert.Equal(expectedTags[i], model.Tags[i]); + } + Assert.Equal(expectedThumbnailUrl, model.ThumbnailUrl); + Assert.Equal(expectedUrl, model.Url); + Assert.Equal(expectedVersionInfo, model.VersionInfo); + Assert.Equal(expectedVideoCodec, model.VideoCodec); + Assert.Equal(expectedWidth, model.Width); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UploadPreTransformSuccessEventIntersectionMember1Data + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ExtensionStatus = new() + { + AIAutoDescription = AIAutoDescription.Success, + AITasks = AITasks.Success, + AwsAutoTagging = AwsAutoTagging.Success, + GoogleAutoTagging = GoogleAutoTagging.Success, + RemoveBg = RemoveBg.Success, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Metadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }, + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = SelectedFieldsSchemaItemType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + ThumbnailUrl = "thumbnailUrl", + Url = "url", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new UploadPreTransformSuccessEventIntersectionMember1Data + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ExtensionStatus = new() + { + AIAutoDescription = AIAutoDescription.Success, + AITasks = AITasks.Success, + AwsAutoTagging = AwsAutoTagging.Success, + GoogleAutoTagging = GoogleAutoTagging.Success, + RemoveBg = RemoveBg.Success, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Metadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }, + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = SelectedFieldsSchemaItemType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + ThumbnailUrl = "thumbnailUrl", + Url = "url", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedAITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ]; + string expectedAudioCodec = "audioCodec"; + long expectedBitRate = 0; + string expectedCustomCoordinates = "customCoordinates"; + Dictionary expectedCustomMetadata = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; + string expectedDescription = "description"; + long expectedDuration = 0; + Dictionary expectedEmbeddedMetadata = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; + ExtensionStatus expectedExtensionStatus = new() + { + AIAutoDescription = AIAutoDescription.Success, + AITasks = AITasks.Success, + AwsAutoTagging = AwsAutoTagging.Success, + GoogleAutoTagging = GoogleAutoTagging.Success, + RemoveBg = RemoveBg.Success, + }; + string expectedFileID = "fileId"; + string expectedFilePath = "filePath"; + string expectedFileType = "fileType"; + double expectedHeight = 0; + bool expectedIsPrivateFile = true; + bool expectedIsPublished = true; + Files::FileMetadata expectedMetadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }; + string expectedName = "name"; + Dictionary expectedSelectedFieldsSchema = new() + { + { + "foo", + new() + { + Type = SelectedFieldsSchemaItemType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }; + double expectedSize = 0; + List expectedTags = ["string"]; + string expectedThumbnailUrl = "thumbnailUrl"; + string expectedUrl = "url"; + VersionInfo expectedVersionInfo = new() { ID = "id", Name = "name" }; + string expectedVideoCodec = "videoCodec"; + double expectedWidth = 0; + + Assert.NotNull(deserialized.AITags); + Assert.Equal(expectedAITags.Count, deserialized.AITags.Count); + for (int i = 0; i < expectedAITags.Count; i++) + { + Assert.Equal(expectedAITags[i], deserialized.AITags[i]); + } + Assert.Equal(expectedAudioCodec, deserialized.AudioCodec); + Assert.Equal(expectedBitRate, deserialized.BitRate); + Assert.Equal(expectedCustomCoordinates, deserialized.CustomCoordinates); + Assert.NotNull(deserialized.CustomMetadata); + Assert.Equal(expectedCustomMetadata.Count, deserialized.CustomMetadata.Count); + foreach (var item in expectedCustomMetadata) + { + Assert.True(deserialized.CustomMetadata.TryGetValue(item.Key, out var value)); + + Assert.True(JsonElement.DeepEquals(value, deserialized.CustomMetadata[item.Key])); + } + Assert.Equal(expectedDescription, deserialized.Description); + Assert.Equal(expectedDuration, deserialized.Duration); + Assert.NotNull(deserialized.EmbeddedMetadata); + Assert.Equal(expectedEmbeddedMetadata.Count, deserialized.EmbeddedMetadata.Count); + foreach (var item in expectedEmbeddedMetadata) + { + Assert.True(deserialized.EmbeddedMetadata.TryGetValue(item.Key, out var value)); + + Assert.True(JsonElement.DeepEquals(value, deserialized.EmbeddedMetadata[item.Key])); + } + Assert.Equal(expectedExtensionStatus, deserialized.ExtensionStatus); + Assert.Equal(expectedFileID, deserialized.FileID); + Assert.Equal(expectedFilePath, deserialized.FilePath); + Assert.Equal(expectedFileType, deserialized.FileType); + Assert.Equal(expectedHeight, deserialized.Height); + Assert.Equal(expectedIsPrivateFile, deserialized.IsPrivateFile); + Assert.Equal(expectedIsPublished, deserialized.IsPublished); + Assert.Equal(expectedMetadata, deserialized.Metadata); + Assert.Equal(expectedName, deserialized.Name); + Assert.NotNull(deserialized.SelectedFieldsSchema); + Assert.Equal(expectedSelectedFieldsSchema.Count, deserialized.SelectedFieldsSchema.Count); + foreach (var item in expectedSelectedFieldsSchema) + { + Assert.True(deserialized.SelectedFieldsSchema.TryGetValue(item.Key, out var value)); + + Assert.Equal(value, deserialized.SelectedFieldsSchema[item.Key]); + } + Assert.Equal(expectedSize, deserialized.Size); + Assert.NotNull(deserialized.Tags); + Assert.Equal(expectedTags.Count, deserialized.Tags.Count); + for (int i = 0; i < expectedTags.Count; i++) + { + Assert.Equal(expectedTags[i], deserialized.Tags[i]); + } + Assert.Equal(expectedThumbnailUrl, deserialized.ThumbnailUrl); + Assert.Equal(expectedUrl, deserialized.Url); + Assert.Equal(expectedVersionInfo, deserialized.VersionInfo); + Assert.Equal(expectedVideoCodec, deserialized.VideoCodec); + Assert.Equal(expectedWidth, deserialized.Width); + } + + [Fact] + public void Validation_Works() + { + var model = new UploadPreTransformSuccessEventIntersectionMember1Data + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ExtensionStatus = new() + { + AIAutoDescription = AIAutoDescription.Success, + AITasks = AITasks.Success, + AwsAutoTagging = AwsAutoTagging.Success, + GoogleAutoTagging = GoogleAutoTagging.Success, + RemoveBg = RemoveBg.Success, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Metadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }, + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = SelectedFieldsSchemaItemType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + ThumbnailUrl = "thumbnailUrl", + Url = "url", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new UploadPreTransformSuccessEventIntersectionMember1Data + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + CustomCoordinates = "customCoordinates", + Tags = ["string"], + }; + + Assert.Null(model.AudioCodec); + Assert.False(model.RawData.ContainsKey("audioCodec")); + Assert.Null(model.BitRate); + Assert.False(model.RawData.ContainsKey("bitRate")); + Assert.Null(model.CustomMetadata); + Assert.False(model.RawData.ContainsKey("customMetadata")); + Assert.Null(model.Description); + Assert.False(model.RawData.ContainsKey("description")); + Assert.Null(model.Duration); + Assert.False(model.RawData.ContainsKey("duration")); + Assert.Null(model.EmbeddedMetadata); + Assert.False(model.RawData.ContainsKey("embeddedMetadata")); + Assert.Null(model.ExtensionStatus); + Assert.False(model.RawData.ContainsKey("extensionStatus")); + Assert.Null(model.FileID); + Assert.False(model.RawData.ContainsKey("fileId")); + Assert.Null(model.FilePath); + Assert.False(model.RawData.ContainsKey("filePath")); + Assert.Null(model.FileType); + Assert.False(model.RawData.ContainsKey("fileType")); + Assert.Null(model.Height); + Assert.False(model.RawData.ContainsKey("height")); + Assert.Null(model.IsPrivateFile); + Assert.False(model.RawData.ContainsKey("isPrivateFile")); + Assert.Null(model.IsPublished); + Assert.False(model.RawData.ContainsKey("isPublished")); + Assert.Null(model.Metadata); + Assert.False(model.RawData.ContainsKey("metadata")); + Assert.Null(model.Name); + Assert.False(model.RawData.ContainsKey("name")); + Assert.Null(model.SelectedFieldsSchema); + Assert.False(model.RawData.ContainsKey("selectedFieldsSchema")); + Assert.Null(model.Size); + Assert.False(model.RawData.ContainsKey("size")); + Assert.Null(model.ThumbnailUrl); + Assert.False(model.RawData.ContainsKey("thumbnailUrl")); + Assert.Null(model.Url); + Assert.False(model.RawData.ContainsKey("url")); + Assert.Null(model.VersionInfo); + Assert.False(model.RawData.ContainsKey("versionInfo")); + Assert.Null(model.VideoCodec); + Assert.False(model.RawData.ContainsKey("videoCodec")); + Assert.Null(model.Width); + Assert.False(model.RawData.ContainsKey("width")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new UploadPreTransformSuccessEventIntersectionMember1Data + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + CustomCoordinates = "customCoordinates", + Tags = ["string"], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new UploadPreTransformSuccessEventIntersectionMember1Data + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + CustomCoordinates = "customCoordinates", + Tags = ["string"], + + // Null should be interpreted as omitted for these properties + AudioCodec = null, + BitRate = null, + CustomMetadata = null, + Description = null, + Duration = null, + EmbeddedMetadata = null, + ExtensionStatus = null, + FileID = null, + FilePath = null, + FileType = null, + Height = null, + IsPrivateFile = null, + IsPublished = null, + Metadata = null, + Name = null, + SelectedFieldsSchema = null, + Size = null, + ThumbnailUrl = null, + Url = null, + VersionInfo = null, + VideoCodec = null, + Width = null, + }; + + Assert.Null(model.AudioCodec); + Assert.False(model.RawData.ContainsKey("audioCodec")); + Assert.Null(model.BitRate); + Assert.False(model.RawData.ContainsKey("bitRate")); + Assert.Null(model.CustomMetadata); + Assert.False(model.RawData.ContainsKey("customMetadata")); + Assert.Null(model.Description); + Assert.False(model.RawData.ContainsKey("description")); + Assert.Null(model.Duration); + Assert.False(model.RawData.ContainsKey("duration")); + Assert.Null(model.EmbeddedMetadata); + Assert.False(model.RawData.ContainsKey("embeddedMetadata")); + Assert.Null(model.ExtensionStatus); + Assert.False(model.RawData.ContainsKey("extensionStatus")); + Assert.Null(model.FileID); + Assert.False(model.RawData.ContainsKey("fileId")); + Assert.Null(model.FilePath); + Assert.False(model.RawData.ContainsKey("filePath")); + Assert.Null(model.FileType); + Assert.False(model.RawData.ContainsKey("fileType")); + Assert.Null(model.Height); + Assert.False(model.RawData.ContainsKey("height")); + Assert.Null(model.IsPrivateFile); + Assert.False(model.RawData.ContainsKey("isPrivateFile")); + Assert.Null(model.IsPublished); + Assert.False(model.RawData.ContainsKey("isPublished")); + Assert.Null(model.Metadata); + Assert.False(model.RawData.ContainsKey("metadata")); + Assert.Null(model.Name); + Assert.False(model.RawData.ContainsKey("name")); + Assert.Null(model.SelectedFieldsSchema); + Assert.False(model.RawData.ContainsKey("selectedFieldsSchema")); + Assert.Null(model.Size); + Assert.False(model.RawData.ContainsKey("size")); + Assert.Null(model.ThumbnailUrl); + Assert.False(model.RawData.ContainsKey("thumbnailUrl")); + Assert.Null(model.Url); + Assert.False(model.RawData.ContainsKey("url")); + Assert.Null(model.VersionInfo); + Assert.False(model.RawData.ContainsKey("versionInfo")); + Assert.Null(model.VideoCodec); + Assert.False(model.RawData.ContainsKey("videoCodec")); + Assert.Null(model.Width); + Assert.False(model.RawData.ContainsKey("width")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new UploadPreTransformSuccessEventIntersectionMember1Data + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + CustomCoordinates = "customCoordinates", + Tags = ["string"], + + // Null should be interpreted as omitted for these properties + AudioCodec = null, + BitRate = null, + CustomMetadata = null, + Description = null, + Duration = null, + EmbeddedMetadata = null, + ExtensionStatus = null, + FileID = null, + FilePath = null, + FileType = null, + Height = null, + IsPrivateFile = null, + IsPublished = null, + Metadata = null, + Name = null, + SelectedFieldsSchema = null, + Size = null, + ThumbnailUrl = null, + Url = null, + VersionInfo = null, + VideoCodec = null, + Width = null, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new UploadPreTransformSuccessEventIntersectionMember1Data + { + AudioCodec = "audioCodec", + BitRate = 0, + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ExtensionStatus = new() + { + AIAutoDescription = AIAutoDescription.Success, + AITasks = AITasks.Success, + AwsAutoTagging = AwsAutoTagging.Success, + GoogleAutoTagging = GoogleAutoTagging.Success, + RemoveBg = RemoveBg.Success, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Metadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }, + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = SelectedFieldsSchemaItemType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + ThumbnailUrl = "thumbnailUrl", + Url = "url", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }; + + Assert.Null(model.AITags); + Assert.False(model.RawData.ContainsKey("AITags")); + Assert.Null(model.CustomCoordinates); + Assert.False(model.RawData.ContainsKey("customCoordinates")); + Assert.Null(model.Tags); + Assert.False(model.RawData.ContainsKey("tags")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new UploadPreTransformSuccessEventIntersectionMember1Data + { + AudioCodec = "audioCodec", + BitRate = 0, + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ExtensionStatus = new() + { + AIAutoDescription = AIAutoDescription.Success, + AITasks = AITasks.Success, + AwsAutoTagging = AwsAutoTagging.Success, + GoogleAutoTagging = GoogleAutoTagging.Success, + RemoveBg = RemoveBg.Success, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Metadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }, + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = SelectedFieldsSchemaItemType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + ThumbnailUrl = "thumbnailUrl", + Url = "url", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new UploadPreTransformSuccessEventIntersectionMember1Data + { + AudioCodec = "audioCodec", + BitRate = 0, + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ExtensionStatus = new() + { + AIAutoDescription = AIAutoDescription.Success, + AITasks = AITasks.Success, + AwsAutoTagging = AwsAutoTagging.Success, + GoogleAutoTagging = GoogleAutoTagging.Success, + RemoveBg = RemoveBg.Success, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Metadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }, + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = SelectedFieldsSchemaItemType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + ThumbnailUrl = "thumbnailUrl", + Url = "url", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + + AITags = null, + CustomCoordinates = null, + Tags = null, + }; + + Assert.Null(model.AITags); + Assert.True(model.RawData.ContainsKey("AITags")); + Assert.Null(model.CustomCoordinates); + Assert.True(model.RawData.ContainsKey("customCoordinates")); + Assert.Null(model.Tags); + Assert.True(model.RawData.ContainsKey("tags")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new UploadPreTransformSuccessEventIntersectionMember1Data + { + AudioCodec = "audioCodec", + BitRate = 0, + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ExtensionStatus = new() + { + AIAutoDescription = AIAutoDescription.Success, + AITasks = AITasks.Success, + AwsAutoTagging = AwsAutoTagging.Success, + GoogleAutoTagging = GoogleAutoTagging.Success, + RemoveBg = RemoveBg.Success, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Metadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }, + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = SelectedFieldsSchemaItemType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + ThumbnailUrl = "thumbnailUrl", + Url = "url", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + + AITags = null, + CustomCoordinates = null, + Tags = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UploadPreTransformSuccessEventIntersectionMember1Data + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ExtensionStatus = new() + { + AIAutoDescription = AIAutoDescription.Success, + AITasks = AITasks.Success, + AwsAutoTagging = AwsAutoTagging.Success, + GoogleAutoTagging = GoogleAutoTagging.Success, + RemoveBg = RemoveBg.Success, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Metadata = new() + { + AudioCodec = "audioCodec", + BitRate = 0, + Density = 0, + Duration = 0, + Exif = new() + { + ExifValue = new() + { + ApertureValue = 0, + ColorSpace = 0, + CreateDate = "CreateDate", + CustomRendered = 0, + DateTimeOriginal = "DateTimeOriginal", + ExifImageHeight = 0, + ExifImageWidth = 0, + ExifVersion = "ExifVersion", + ExposureCompensation = 0, + ExposureMode = 0, + ExposureProgram = 0, + ExposureTime = 0, + Flash = 0, + FlashpixVersion = "FlashpixVersion", + FNumber = 0, + FocalLength = 0, + FocalPlaneResolutionUnit = 0, + FocalPlaneXResolution = 0, + FocalPlaneYResolution = 0, + InteropOffset = 0, + Iso = 0, + MeteringMode = 0, + SceneCaptureType = 0, + ShutterSpeedValue = 0, + SubSecTime = "SubSecTime", + WhiteBalance = 0, + }, + Gps = new() { GpsVersionID = [0] }, + Image = new() + { + ExifOffset = 0, + GpsInfo = 0, + Make = "Make", + Model = "Model", + ModifyDate = "ModifyDate", + Orientation = 0, + ResolutionUnit = 0, + Software = "Software", + XResolution = 0, + YCbCrPositioning = 0, + YResolution = 0, + }, + Interoperability = new() + { + InteropIndex = "InteropIndex", + InteropVersion = "InteropVersion", + }, + Makernote = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Thumbnail = new() + { + Compression = 0, + ResolutionUnit = 0, + ThumbnailLength = 0, + ThumbnailOffset = 0, + XResolution = 0, + YResolution = 0, + }, + }, + Format = "format", + HasColorProfile = true, + HasTransparency = true, + Height = 0, + PHash = "pHash", + Quality = 0, + Size = 0, + VideoCodec = "videoCodec", + Width = 0, + }, + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = SelectedFieldsSchemaItemType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + ThumbnailUrl = "thumbnailUrl", + Url = "url", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }; + + UploadPreTransformSuccessEventIntersectionMember1Data copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class AITagTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new AITag + { + Confidence = 0, + Name = "name", + Source = "source", + }; + + double expectedConfidence = 0; + string expectedName = "name"; + string expectedSource = "source"; + + Assert.Equal(expectedConfidence, model.Confidence); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedSource, model.Source); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new AITag + { + Confidence = 0, + Name = "name", + Source = "source", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new AITag + { + Confidence = 0, + Name = "name", + Source = "source", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + Assert.NotNull(deserialized); + + double expectedConfidence = 0; + string expectedName = "name"; + string expectedSource = "source"; + + Assert.Equal(expectedConfidence, deserialized.Confidence); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedSource, deserialized.Source); + } + + [Fact] + public void Validation_Works() + { + var model = new AITag + { + Confidence = 0, + Name = "name", + Source = "source", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new AITag { }; + + Assert.Null(model.Confidence); + Assert.False(model.RawData.ContainsKey("confidence")); + Assert.Null(model.Name); + Assert.False(model.RawData.ContainsKey("name")); + Assert.Null(model.Source); + Assert.False(model.RawData.ContainsKey("source")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new AITag { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new AITag + { + // Null should be interpreted as omitted for these properties + Confidence = null, + Name = null, + Source = null, + }; + + Assert.Null(model.Confidence); + Assert.False(model.RawData.ContainsKey("confidence")); + Assert.Null(model.Name); + Assert.False(model.RawData.ContainsKey("name")); + Assert.Null(model.Source); + Assert.False(model.RawData.ContainsKey("source")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new AITag + { + // Null should be interpreted as omitted for these properties + Confidence = null, + Name = null, + Source = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new AITag + { + Confidence = 0, + Name = "name", + Source = "source", + }; + + AITag copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ExtensionStatusTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ExtensionStatus + { + AIAutoDescription = AIAutoDescription.Success, + AITasks = AITasks.Success, + AwsAutoTagging = AwsAutoTagging.Success, + GoogleAutoTagging = GoogleAutoTagging.Success, + RemoveBg = RemoveBg.Success, + }; + + ApiEnum expectedAIAutoDescription = AIAutoDescription.Success; + ApiEnum expectedAITasks = AITasks.Success; + ApiEnum expectedAwsAutoTagging = AwsAutoTagging.Success; + ApiEnum expectedGoogleAutoTagging = GoogleAutoTagging.Success; + ApiEnum expectedRemoveBg = RemoveBg.Success; + + Assert.Equal(expectedAIAutoDescription, model.AIAutoDescription); + Assert.Equal(expectedAITasks, model.AITasks); + Assert.Equal(expectedAwsAutoTagging, model.AwsAutoTagging); + Assert.Equal(expectedGoogleAutoTagging, model.GoogleAutoTagging); + Assert.Equal(expectedRemoveBg, model.RemoveBg); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ExtensionStatus + { + AIAutoDescription = AIAutoDescription.Success, + AITasks = AITasks.Success, + AwsAutoTagging = AwsAutoTagging.Success, + GoogleAutoTagging = GoogleAutoTagging.Success, + RemoveBg = RemoveBg.Success, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new ExtensionStatus + { + AIAutoDescription = AIAutoDescription.Success, + AITasks = AITasks.Success, + AwsAutoTagging = AwsAutoTagging.Success, + GoogleAutoTagging = GoogleAutoTagging.Success, + RemoveBg = RemoveBg.Success, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum expectedAIAutoDescription = AIAutoDescription.Success; + ApiEnum expectedAITasks = AITasks.Success; + ApiEnum expectedAwsAutoTagging = AwsAutoTagging.Success; + ApiEnum expectedGoogleAutoTagging = GoogleAutoTagging.Success; + ApiEnum expectedRemoveBg = RemoveBg.Success; + + Assert.Equal(expectedAIAutoDescription, deserialized.AIAutoDescription); + Assert.Equal(expectedAITasks, deserialized.AITasks); + Assert.Equal(expectedAwsAutoTagging, deserialized.AwsAutoTagging); + Assert.Equal(expectedGoogleAutoTagging, deserialized.GoogleAutoTagging); + Assert.Equal(expectedRemoveBg, deserialized.RemoveBg); + } + + [Fact] + public void Validation_Works() + { + var model = new ExtensionStatus + { + AIAutoDescription = AIAutoDescription.Success, + AITasks = AITasks.Success, + AwsAutoTagging = AwsAutoTagging.Success, + GoogleAutoTagging = GoogleAutoTagging.Success, + RemoveBg = RemoveBg.Success, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ExtensionStatus { }; + + Assert.Null(model.AIAutoDescription); + Assert.False(model.RawData.ContainsKey("ai-auto-description")); + Assert.Null(model.AITasks); + Assert.False(model.RawData.ContainsKey("ai-tasks")); + Assert.Null(model.AwsAutoTagging); + Assert.False(model.RawData.ContainsKey("aws-auto-tagging")); + Assert.Null(model.GoogleAutoTagging); + Assert.False(model.RawData.ContainsKey("google-auto-tagging")); + Assert.Null(model.RemoveBg); + Assert.False(model.RawData.ContainsKey("remove-bg")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new ExtensionStatus { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new ExtensionStatus + { + // Null should be interpreted as omitted for these properties + AIAutoDescription = null, + AITasks = null, + AwsAutoTagging = null, + GoogleAutoTagging = null, + RemoveBg = null, + }; + + Assert.Null(model.AIAutoDescription); + Assert.False(model.RawData.ContainsKey("ai-auto-description")); + Assert.Null(model.AITasks); + Assert.False(model.RawData.ContainsKey("ai-tasks")); + Assert.Null(model.AwsAutoTagging); + Assert.False(model.RawData.ContainsKey("aws-auto-tagging")); + Assert.Null(model.GoogleAutoTagging); + Assert.False(model.RawData.ContainsKey("google-auto-tagging")); + Assert.Null(model.RemoveBg); + Assert.False(model.RawData.ContainsKey("remove-bg")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new ExtensionStatus + { + // Null should be interpreted as omitted for these properties + AIAutoDescription = null, + AITasks = null, + AwsAutoTagging = null, + GoogleAutoTagging = null, + RemoveBg = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ExtensionStatus + { + AIAutoDescription = AIAutoDescription.Success, + AITasks = AITasks.Success, + AwsAutoTagging = AwsAutoTagging.Success, + GoogleAutoTagging = GoogleAutoTagging.Success, + RemoveBg = RemoveBg.Success, + }; + + ExtensionStatus copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class AIAutoDescriptionTest : TestBase +{ + [Theory] + [InlineData(AIAutoDescription.Success)] + [InlineData(AIAutoDescription.Pending)] + [InlineData(AIAutoDescription.Failed)] + public void Validation_Works(AIAutoDescription rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(AIAutoDescription.Success)] + [InlineData(AIAutoDescription.Pending)] + [InlineData(AIAutoDescription.Failed)] + public void SerializationRoundtrip_Works(AIAutoDescription rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class AITasksTest : TestBase +{ + [Theory] + [InlineData(AITasks.Success)] + [InlineData(AITasks.Pending)] + [InlineData(AITasks.Failed)] + public void Validation_Works(AITasks rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(AITasks.Success)] + [InlineData(AITasks.Pending)] + [InlineData(AITasks.Failed)] + public void SerializationRoundtrip_Works(AITasks rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class AwsAutoTaggingTest : TestBase +{ + [Theory] + [InlineData(AwsAutoTagging.Success)] + [InlineData(AwsAutoTagging.Pending)] + [InlineData(AwsAutoTagging.Failed)] + public void Validation_Works(AwsAutoTagging rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(AwsAutoTagging.Success)] + [InlineData(AwsAutoTagging.Pending)] + [InlineData(AwsAutoTagging.Failed)] + public void SerializationRoundtrip_Works(AwsAutoTagging rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class GoogleAutoTaggingTest : TestBase +{ + [Theory] + [InlineData(GoogleAutoTagging.Success)] + [InlineData(GoogleAutoTagging.Pending)] + [InlineData(GoogleAutoTagging.Failed)] + public void Validation_Works(GoogleAutoTagging rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(GoogleAutoTagging.Success)] + [InlineData(GoogleAutoTagging.Pending)] + [InlineData(GoogleAutoTagging.Failed)] + public void SerializationRoundtrip_Works(GoogleAutoTagging rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class RemoveBgTest : TestBase +{ + [Theory] + [InlineData(RemoveBg.Success)] + [InlineData(RemoveBg.Pending)] + [InlineData(RemoveBg.Failed)] + public void Validation_Works(RemoveBg rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(RemoveBg.Success)] + [InlineData(RemoveBg.Pending)] + [InlineData(RemoveBg.Failed)] + public void SerializationRoundtrip_Works(RemoveBg rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class SelectedFieldsSchemaItemTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new SelectedFieldsSchemaItem + { + Type = SelectedFieldsSchemaItemType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + }; + + ApiEnum expectedType = + SelectedFieldsSchemaItemType.Text; + DefaultValue expectedDefaultValue = "string"; + bool expectedIsValueRequired = true; + double expectedMaxLength = 0; + MaxValue expectedMaxValue = "string"; + double expectedMinLength = 0; + MinValue expectedMinValue = "string"; + bool expectedReadOnly = true; + List expectedSelectOptions = ["small", "medium", "large", 30, 40, true]; + bool expectedSelectOptionsTruncated = true; + + Assert.Equal(expectedType, model.Type); + Assert.Equal(expectedDefaultValue, model.DefaultValue); + Assert.Equal(expectedIsValueRequired, model.IsValueRequired); + Assert.Equal(expectedMaxLength, model.MaxLength); + Assert.Equal(expectedMaxValue, model.MaxValue); + Assert.Equal(expectedMinLength, model.MinLength); + Assert.Equal(expectedMinValue, model.MinValue); + Assert.Equal(expectedReadOnly, model.ReadOnly); + Assert.NotNull(model.SelectOptions); + Assert.Equal(expectedSelectOptions.Count, model.SelectOptions.Count); + for (int i = 0; i < expectedSelectOptions.Count; i++) + { + Assert.Equal(expectedSelectOptions[i], model.SelectOptions[i]); + } + Assert.Equal(expectedSelectOptionsTruncated, model.SelectOptionsTruncated); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new SelectedFieldsSchemaItem + { + Type = SelectedFieldsSchemaItemType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new SelectedFieldsSchemaItem + { + Type = SelectedFieldsSchemaItemType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum expectedType = + SelectedFieldsSchemaItemType.Text; + DefaultValue expectedDefaultValue = "string"; + bool expectedIsValueRequired = true; + double expectedMaxLength = 0; + MaxValue expectedMaxValue = "string"; + double expectedMinLength = 0; + MinValue expectedMinValue = "string"; + bool expectedReadOnly = true; + List expectedSelectOptions = ["small", "medium", "large", 30, 40, true]; + bool expectedSelectOptionsTruncated = true; + + Assert.Equal(expectedType, deserialized.Type); + Assert.Equal(expectedDefaultValue, deserialized.DefaultValue); + Assert.Equal(expectedIsValueRequired, deserialized.IsValueRequired); + Assert.Equal(expectedMaxLength, deserialized.MaxLength); + Assert.Equal(expectedMaxValue, deserialized.MaxValue); + Assert.Equal(expectedMinLength, deserialized.MinLength); + Assert.Equal(expectedMinValue, deserialized.MinValue); + Assert.Equal(expectedReadOnly, deserialized.ReadOnly); + Assert.NotNull(deserialized.SelectOptions); + Assert.Equal(expectedSelectOptions.Count, deserialized.SelectOptions.Count); + for (int i = 0; i < expectedSelectOptions.Count; i++) + { + Assert.Equal(expectedSelectOptions[i], deserialized.SelectOptions[i]); + } + Assert.Equal(expectedSelectOptionsTruncated, deserialized.SelectOptionsTruncated); + } + + [Fact] + public void Validation_Works() + { + var model = new SelectedFieldsSchemaItem + { + Type = SelectedFieldsSchemaItemType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new SelectedFieldsSchemaItem { Type = SelectedFieldsSchemaItemType.Text }; + + Assert.Null(model.DefaultValue); + Assert.False(model.RawData.ContainsKey("defaultValue")); + Assert.Null(model.IsValueRequired); + Assert.False(model.RawData.ContainsKey("isValueRequired")); + Assert.Null(model.MaxLength); + Assert.False(model.RawData.ContainsKey("maxLength")); + Assert.Null(model.MaxValue); + Assert.False(model.RawData.ContainsKey("maxValue")); + Assert.Null(model.MinLength); + Assert.False(model.RawData.ContainsKey("minLength")); + Assert.Null(model.MinValue); + Assert.False(model.RawData.ContainsKey("minValue")); + Assert.Null(model.ReadOnly); + Assert.False(model.RawData.ContainsKey("readOnly")); + Assert.Null(model.SelectOptions); + Assert.False(model.RawData.ContainsKey("selectOptions")); + Assert.Null(model.SelectOptionsTruncated); + Assert.False(model.RawData.ContainsKey("selectOptionsTruncated")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new SelectedFieldsSchemaItem { Type = SelectedFieldsSchemaItemType.Text }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new SelectedFieldsSchemaItem + { + Type = SelectedFieldsSchemaItemType.Text, + + // Null should be interpreted as omitted for these properties + DefaultValue = null, + IsValueRequired = null, + MaxLength = null, + MaxValue = null, + MinLength = null, + MinValue = null, + ReadOnly = null, + SelectOptions = null, + SelectOptionsTruncated = null, + }; + + Assert.Null(model.DefaultValue); + Assert.False(model.RawData.ContainsKey("defaultValue")); + Assert.Null(model.IsValueRequired); + Assert.False(model.RawData.ContainsKey("isValueRequired")); + Assert.Null(model.MaxLength); + Assert.False(model.RawData.ContainsKey("maxLength")); + Assert.Null(model.MaxValue); + Assert.False(model.RawData.ContainsKey("maxValue")); + Assert.Null(model.MinLength); + Assert.False(model.RawData.ContainsKey("minLength")); + Assert.Null(model.MinValue); + Assert.False(model.RawData.ContainsKey("minValue")); + Assert.Null(model.ReadOnly); + Assert.False(model.RawData.ContainsKey("readOnly")); + Assert.Null(model.SelectOptions); + Assert.False(model.RawData.ContainsKey("selectOptions")); + Assert.Null(model.SelectOptionsTruncated); + Assert.False(model.RawData.ContainsKey("selectOptionsTruncated")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new SelectedFieldsSchemaItem + { + Type = SelectedFieldsSchemaItemType.Text, + + // Null should be interpreted as omitted for these properties + DefaultValue = null, + IsValueRequired = null, + MaxLength = null, + MaxValue = null, + MinLength = null, + MinValue = null, + ReadOnly = null, + SelectOptions = null, + SelectOptionsTruncated = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new SelectedFieldsSchemaItem + { + Type = SelectedFieldsSchemaItemType.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + }; + + SelectedFieldsSchemaItem copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class SelectedFieldsSchemaItemTypeTest : TestBase +{ + [Theory] + [InlineData(SelectedFieldsSchemaItemType.Text)] + [InlineData(SelectedFieldsSchemaItemType.Textarea)] + [InlineData(SelectedFieldsSchemaItemType.Number)] + [InlineData(SelectedFieldsSchemaItemType.Date)] + [InlineData(SelectedFieldsSchemaItemType.Boolean)] + [InlineData(SelectedFieldsSchemaItemType.SingleSelect)] + [InlineData(SelectedFieldsSchemaItemType.MultiSelect)] + public void Validation_Works(SelectedFieldsSchemaItemType rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(SelectedFieldsSchemaItemType.Text)] + [InlineData(SelectedFieldsSchemaItemType.Textarea)] + [InlineData(SelectedFieldsSchemaItemType.Number)] + [InlineData(SelectedFieldsSchemaItemType.Date)] + [InlineData(SelectedFieldsSchemaItemType.Boolean)] + [InlineData(SelectedFieldsSchemaItemType.SingleSelect)] + [InlineData(SelectedFieldsSchemaItemType.MultiSelect)] + public void SerializationRoundtrip_Works(SelectedFieldsSchemaItemType rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class DefaultValueTest : TestBase +{ + [Fact] + public void StringValidationWorks() + { + DefaultValue value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + DefaultValue value = 0; + value.Validate(); + } + + [Fact] + public void BoolValidationWorks() + { + DefaultValue value = true; + value.Validate(); + } + + [Fact] + public void MixedValidationWorks() + { + DefaultValue value = new( + [ + new UnnamedSchemaWithArrayParent13(true), + new UnnamedSchemaWithArrayParent13(10), + new UnnamedSchemaWithArrayParent13("Hello"), + ] + ); + value.Validate(); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + DefaultValue value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + DefaultValue value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void BoolSerializationRoundtripWorks() + { + DefaultValue value = true; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void MixedSerializationRoundtripWorks() + { + DefaultValue value = new( + [ + new UnnamedSchemaWithArrayParent13(true), + new UnnamedSchemaWithArrayParent13(10), + new UnnamedSchemaWithArrayParent13("Hello"), + ] + ); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class UnnamedSchemaWithArrayParent13Test : TestBase +{ + [Fact] + public void StringValidationWorks() + { + UnnamedSchemaWithArrayParent13 value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + UnnamedSchemaWithArrayParent13 value = 0; + value.Validate(); + } + + [Fact] + public void BoolValidationWorks() + { + UnnamedSchemaWithArrayParent13 value = true; + value.Validate(); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent13 value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent13 value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void BoolSerializationRoundtripWorks() + { + UnnamedSchemaWithArrayParent13 value = true; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class MaxValueTest : TestBase +{ + [Fact] + public void StringValidationWorks() + { + MaxValue value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + MaxValue value = 0; + value.Validate(); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + MaxValue value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + MaxValue value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class MinValueTest : TestBase +{ + [Fact] + public void StringValidationWorks() + { + MinValue value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + MinValue value = 0; + value.Validate(); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + MinValue value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + MinValue value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class SelectOptionTest : TestBase +{ + [Fact] + public void StringValidationWorks() + { + SelectOption value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleValidationWorks() + { + SelectOption value = 0; + value.Validate(); + } + + [Fact] + public void BoolValidationWorks() + { + SelectOption value = true; + value.Validate(); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + SelectOption value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + SelectOption value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void BoolSerializationRoundtripWorks() + { + SelectOption value = true; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class VersionInfoTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new VersionInfo { ID = "id", Name = "name" }; + + string expectedID = "id"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new VersionInfo { ID = "id", Name = "name" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new VersionInfo { ID = "id", Name = "name" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new VersionInfo { ID = "id", Name = "name" }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new VersionInfo { }; + + Assert.Null(model.ID); + Assert.False(model.RawData.ContainsKey("id")); + Assert.Null(model.Name); + Assert.False(model.RawData.ContainsKey("name")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new VersionInfo { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new VersionInfo + { + // Null should be interpreted as omitted for these properties + ID = null, + Name = null, + }; + + Assert.Null(model.ID); + Assert.False(model.RawData.ContainsKey("id")); + Assert.Null(model.Name); + Assert.False(model.RawData.ContainsKey("name")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new VersionInfo + { + // Null should be interpreted as omitted for these properties + ID = null, + Name = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new VersionInfo { ID = "id", Name = "name" }; + + VersionInfo copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UploadPreTransformSuccessEventIntersectionMember1RequestTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UploadPreTransformSuccessEventIntersectionMember1Request + { + Transformation = "transformation", + XRequestID = "x_request_id", + }; + + string expectedTransformation = "transformation"; + string expectedXRequestID = "x_request_id"; + + Assert.Equal(expectedTransformation, model.Transformation); + Assert.Equal(expectedXRequestID, model.XRequestID); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UploadPreTransformSuccessEventIntersectionMember1Request + { + Transformation = "transformation", + XRequestID = "x_request_id", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new UploadPreTransformSuccessEventIntersectionMember1Request + { + Transformation = "transformation", + XRequestID = "x_request_id", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedTransformation = "transformation"; + string expectedXRequestID = "x_request_id"; + + Assert.Equal(expectedTransformation, deserialized.Transformation); + Assert.Equal(expectedXRequestID, deserialized.XRequestID); + } + + [Fact] + public void Validation_Works() + { + var model = new UploadPreTransformSuccessEventIntersectionMember1Request + { + Transformation = "transformation", + XRequestID = "x_request_id", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UploadPreTransformSuccessEventIntersectionMember1Request + { + Transformation = "transformation", + XRequestID = "x_request_id", + }; + + UploadPreTransformSuccessEventIntersectionMember1Request copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Webhooks/VideoTransformationAcceptedEventTest.cs b/src/ImageKit.Tests/Models/Webhooks/VideoTransformationAcceptedEventTest.cs new file mode 100644 index 00000000..9f85e687 --- /dev/null +++ b/src/ImageKit.Tests/Models/Webhooks/VideoTransformationAcceptedEventTest.cs @@ -0,0 +1,1712 @@ +using System; +using System.Collections.Generic; +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Exceptions; +using ImageKit.Models.Webhooks; + +namespace ImageKit.Tests.Models.Webhooks; + +public class VideoTransformationAcceptedEventTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new VideoTransformationAcceptedEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = AudioCodec.Aac, + AutoRotate = true, + Format = Format.Mp4, + Quality = 0, + StreamProtocol = StreamProtocol.Hls, + Variants = ["string"], + VideoCodec = VideoCodec.H264, + }, + }, + }, + Request = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }, + }; + + string expectedID = "id"; + string expectedType = "type"; + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + VideoTransformationAcceptedEventIntersectionMember1Data expectedData = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = AudioCodec.Aac, + AutoRotate = true, + Format = Format.Mp4, + Quality = 0, + StreamProtocol = StreamProtocol.Hls, + Variants = ["string"], + VideoCodec = VideoCodec.H264, + }, + }, + }; + VideoTransformationAcceptedEventIntersectionMember1Request expectedRequest = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedType, model.Type); + Assert.Equal(expectedCreatedAt, model.CreatedAt); + Assert.Equal(expectedData, model.Data); + Assert.Equal(expectedRequest, model.Request); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new VideoTransformationAcceptedEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = AudioCodec.Aac, + AutoRotate = true, + Format = Format.Mp4, + Quality = 0, + StreamProtocol = StreamProtocol.Hls, + Variants = ["string"], + VideoCodec = VideoCodec.H264, + }, + }, + }, + Request = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new VideoTransformationAcceptedEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = AudioCodec.Aac, + AutoRotate = true, + Format = Format.Mp4, + Quality = 0, + StreamProtocol = StreamProtocol.Hls, + Variants = ["string"], + VideoCodec = VideoCodec.H264, + }, + }, + }, + Request = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedType = "type"; + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + VideoTransformationAcceptedEventIntersectionMember1Data expectedData = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = AudioCodec.Aac, + AutoRotate = true, + Format = Format.Mp4, + Quality = 0, + StreamProtocol = StreamProtocol.Hls, + Variants = ["string"], + VideoCodec = VideoCodec.H264, + }, + }, + }; + VideoTransformationAcceptedEventIntersectionMember1Request expectedRequest = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedType, deserialized.Type); + Assert.Equal(expectedCreatedAt, deserialized.CreatedAt); + Assert.Equal(expectedData, deserialized.Data); + Assert.Equal(expectedRequest, deserialized.Request); + } + + [Fact] + public void Validation_Works() + { + var model = new VideoTransformationAcceptedEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = AudioCodec.Aac, + AutoRotate = true, + Format = Format.Mp4, + Quality = 0, + StreamProtocol = StreamProtocol.Hls, + Variants = ["string"], + VideoCodec = VideoCodec.H264, + }, + }, + }, + Request = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new VideoTransformationAcceptedEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = AudioCodec.Aac, + AutoRotate = true, + Format = Format.Mp4, + Quality = 0, + StreamProtocol = StreamProtocol.Hls, + Variants = ["string"], + VideoCodec = VideoCodec.H264, + }, + }, + }, + Request = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }, + }; + + VideoTransformationAcceptedEvent copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class VideoTransformationAcceptedEventIntersectionMember1Test : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new VideoTransformationAcceptedEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = AudioCodec.Aac, + AutoRotate = true, + Format = Format.Mp4, + Quality = 0, + StreamProtocol = StreamProtocol.Hls, + Variants = ["string"], + VideoCodec = VideoCodec.H264, + }, + }, + }, + Request = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }, + }; + + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + VideoTransformationAcceptedEventIntersectionMember1Data expectedData = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = AudioCodec.Aac, + AutoRotate = true, + Format = Format.Mp4, + Quality = 0, + StreamProtocol = StreamProtocol.Hls, + Variants = ["string"], + VideoCodec = VideoCodec.H264, + }, + }, + }; + VideoTransformationAcceptedEventIntersectionMember1Request expectedRequest = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }; + JsonElement expectedType = JsonSerializer.SerializeToElement( + "video.transformation.accepted" + ); + + Assert.Equal(expectedCreatedAt, model.CreatedAt); + Assert.Equal(expectedData, model.Data); + Assert.Equal(expectedRequest, model.Request); + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new VideoTransformationAcceptedEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = AudioCodec.Aac, + AutoRotate = true, + Format = Format.Mp4, + Quality = 0, + StreamProtocol = StreamProtocol.Hls, + Variants = ["string"], + VideoCodec = VideoCodec.H264, + }, + }, + }, + Request = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new VideoTransformationAcceptedEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = AudioCodec.Aac, + AutoRotate = true, + Format = Format.Mp4, + Quality = 0, + StreamProtocol = StreamProtocol.Hls, + Variants = ["string"], + VideoCodec = VideoCodec.H264, + }, + }, + }, + Request = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + VideoTransformationAcceptedEventIntersectionMember1Data expectedData = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = AudioCodec.Aac, + AutoRotate = true, + Format = Format.Mp4, + Quality = 0, + StreamProtocol = StreamProtocol.Hls, + Variants = ["string"], + VideoCodec = VideoCodec.H264, + }, + }, + }; + VideoTransformationAcceptedEventIntersectionMember1Request expectedRequest = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }; + JsonElement expectedType = JsonSerializer.SerializeToElement( + "video.transformation.accepted" + ); + + Assert.Equal(expectedCreatedAt, deserialized.CreatedAt); + Assert.Equal(expectedData, deserialized.Data); + Assert.Equal(expectedRequest, deserialized.Request); + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + } + + [Fact] + public void Validation_Works() + { + var model = new VideoTransformationAcceptedEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = AudioCodec.Aac, + AutoRotate = true, + Format = Format.Mp4, + Quality = 0, + StreamProtocol = StreamProtocol.Hls, + Variants = ["string"], + VideoCodec = VideoCodec.H264, + }, + }, + }, + Request = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new VideoTransformationAcceptedEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = AudioCodec.Aac, + AutoRotate = true, + Format = Format.Mp4, + Quality = 0, + StreamProtocol = StreamProtocol.Hls, + Variants = ["string"], + VideoCodec = VideoCodec.H264, + }, + }, + }, + Request = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }, + }; + + VideoTransformationAcceptedEventIntersectionMember1 copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class VideoTransformationAcceptedEventIntersectionMember1DataTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new VideoTransformationAcceptedEventIntersectionMember1Data + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = AudioCodec.Aac, + AutoRotate = true, + Format = Format.Mp4, + Quality = 0, + StreamProtocol = StreamProtocol.Hls, + Variants = ["string"], + VideoCodec = VideoCodec.H264, + }, + }, + }; + + Asset expectedAsset = new("https://example.com"); + VideoTransformationAcceptedEventIntersectionMember1DataTransformation expectedTransformation = + new() + { + Type = + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = AudioCodec.Aac, + AutoRotate = true, + Format = Format.Mp4, + Quality = 0, + StreamProtocol = StreamProtocol.Hls, + Variants = ["string"], + VideoCodec = VideoCodec.H264, + }, + }; + + Assert.Equal(expectedAsset, model.Asset); + Assert.Equal(expectedTransformation, model.Transformation); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new VideoTransformationAcceptedEventIntersectionMember1Data + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = AudioCodec.Aac, + AutoRotate = true, + Format = Format.Mp4, + Quality = 0, + StreamProtocol = StreamProtocol.Hls, + Variants = ["string"], + VideoCodec = VideoCodec.H264, + }, + }, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new VideoTransformationAcceptedEventIntersectionMember1Data + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = AudioCodec.Aac, + AutoRotate = true, + Format = Format.Mp4, + Quality = 0, + StreamProtocol = StreamProtocol.Hls, + Variants = ["string"], + VideoCodec = VideoCodec.H264, + }, + }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + Asset expectedAsset = new("https://example.com"); + VideoTransformationAcceptedEventIntersectionMember1DataTransformation expectedTransformation = + new() + { + Type = + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = AudioCodec.Aac, + AutoRotate = true, + Format = Format.Mp4, + Quality = 0, + StreamProtocol = StreamProtocol.Hls, + Variants = ["string"], + VideoCodec = VideoCodec.H264, + }, + }; + + Assert.Equal(expectedAsset, deserialized.Asset); + Assert.Equal(expectedTransformation, deserialized.Transformation); + } + + [Fact] + public void Validation_Works() + { + var model = new VideoTransformationAcceptedEventIntersectionMember1Data + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = AudioCodec.Aac, + AutoRotate = true, + Format = Format.Mp4, + Quality = 0, + StreamProtocol = StreamProtocol.Hls, + Variants = ["string"], + VideoCodec = VideoCodec.H264, + }, + }, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new VideoTransformationAcceptedEventIntersectionMember1Data + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = AudioCodec.Aac, + AutoRotate = true, + Format = Format.Mp4, + Quality = 0, + StreamProtocol = StreamProtocol.Hls, + Variants = ["string"], + VideoCodec = VideoCodec.H264, + }, + }, + }; + + VideoTransformationAcceptedEventIntersectionMember1Data copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class AssetTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Asset { Url = "https://example.com" }; + + string expectedUrl = "https://example.com"; + + Assert.Equal(expectedUrl, model.Url); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Asset { Url = "https://example.com" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Asset { Url = "https://example.com" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + Assert.NotNull(deserialized); + + string expectedUrl = "https://example.com"; + + Assert.Equal(expectedUrl, deserialized.Url); + } + + [Fact] + public void Validation_Works() + { + var model = new Asset { Url = "https://example.com" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Asset { Url = "https://example.com" }; + + Asset copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class VideoTransformationAcceptedEventIntersectionMember1DataTransformationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new VideoTransformationAcceptedEventIntersectionMember1DataTransformation + { + Type = + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = AudioCodec.Aac, + AutoRotate = true, + Format = Format.Mp4, + Quality = 0, + StreamProtocol = StreamProtocol.Hls, + Variants = ["string"], + VideoCodec = VideoCodec.H264, + }, + }; + + ApiEnum< + string, + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType + > expectedType = + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation; + Options expectedOptions = new() + { + AudioCodec = AudioCodec.Aac, + AutoRotate = true, + Format = Format.Mp4, + Quality = 0, + StreamProtocol = StreamProtocol.Hls, + Variants = ["string"], + VideoCodec = VideoCodec.H264, + }; + + Assert.Equal(expectedType, model.Type); + Assert.Equal(expectedOptions, model.Options); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new VideoTransformationAcceptedEventIntersectionMember1DataTransformation + { + Type = + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = AudioCodec.Aac, + AutoRotate = true, + Format = Format.Mp4, + Quality = 0, + StreamProtocol = StreamProtocol.Hls, + Variants = ["string"], + VideoCodec = VideoCodec.H264, + }, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new VideoTransformationAcceptedEventIntersectionMember1DataTransformation + { + Type = + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = AudioCodec.Aac, + AutoRotate = true, + Format = Format.Mp4, + Quality = 0, + StreamProtocol = StreamProtocol.Hls, + Variants = ["string"], + VideoCodec = VideoCodec.H264, + }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum< + string, + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType + > expectedType = + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation; + Options expectedOptions = new() + { + AudioCodec = AudioCodec.Aac, + AutoRotate = true, + Format = Format.Mp4, + Quality = 0, + StreamProtocol = StreamProtocol.Hls, + Variants = ["string"], + VideoCodec = VideoCodec.H264, + }; + + Assert.Equal(expectedType, deserialized.Type); + Assert.Equal(expectedOptions, deserialized.Options); + } + + [Fact] + public void Validation_Works() + { + var model = new VideoTransformationAcceptedEventIntersectionMember1DataTransformation + { + Type = + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = AudioCodec.Aac, + AutoRotate = true, + Format = Format.Mp4, + Quality = 0, + StreamProtocol = StreamProtocol.Hls, + Variants = ["string"], + VideoCodec = VideoCodec.H264, + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new VideoTransformationAcceptedEventIntersectionMember1DataTransformation + { + Type = + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + }; + + Assert.Null(model.Options); + Assert.False(model.RawData.ContainsKey("options")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new VideoTransformationAcceptedEventIntersectionMember1DataTransformation + { + Type = + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new VideoTransformationAcceptedEventIntersectionMember1DataTransformation + { + Type = + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + + // Null should be interpreted as omitted for these properties + Options = null, + }; + + Assert.Null(model.Options); + Assert.False(model.RawData.ContainsKey("options")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new VideoTransformationAcceptedEventIntersectionMember1DataTransformation + { + Type = + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + + // Null should be interpreted as omitted for these properties + Options = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new VideoTransformationAcceptedEventIntersectionMember1DataTransformation + { + Type = + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = AudioCodec.Aac, + AutoRotate = true, + Format = Format.Mp4, + Quality = 0, + StreamProtocol = StreamProtocol.Hls, + Variants = ["string"], + VideoCodec = VideoCodec.H264, + }, + }; + + VideoTransformationAcceptedEventIntersectionMember1DataTransformation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class VideoTransformationAcceptedEventIntersectionMember1DataTransformationTypeTest + : TestBase +{ + [Theory] + [InlineData( + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation + )] + [InlineData( + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.GifToVideo + )] + [InlineData( + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoThumbnail + )] + public void Validation_Works( + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType + > value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum< + string, + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType + > + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData( + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation + )] + [InlineData( + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.GifToVideo + )] + [InlineData( + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoThumbnail + )] + public void SerializationRoundtrip_Works( + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType + > value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum< + string, + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType + > + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum< + string, + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType + > + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum< + string, + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType + > + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class OptionsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Options + { + AudioCodec = AudioCodec.Aac, + AutoRotate = true, + Format = Format.Mp4, + Quality = 0, + StreamProtocol = StreamProtocol.Hls, + Variants = ["string"], + VideoCodec = VideoCodec.H264, + }; + + ApiEnum expectedAudioCodec = AudioCodec.Aac; + bool expectedAutoRotate = true; + ApiEnum expectedFormat = Format.Mp4; + long expectedQuality = 0; + ApiEnum expectedStreamProtocol = StreamProtocol.Hls; + List expectedVariants = ["string"]; + ApiEnum expectedVideoCodec = VideoCodec.H264; + + Assert.Equal(expectedAudioCodec, model.AudioCodec); + Assert.Equal(expectedAutoRotate, model.AutoRotate); + Assert.Equal(expectedFormat, model.Format); + Assert.Equal(expectedQuality, model.Quality); + Assert.Equal(expectedStreamProtocol, model.StreamProtocol); + Assert.NotNull(model.Variants); + Assert.Equal(expectedVariants.Count, model.Variants.Count); + for (int i = 0; i < expectedVariants.Count; i++) + { + Assert.Equal(expectedVariants[i], model.Variants[i]); + } + Assert.Equal(expectedVideoCodec, model.VideoCodec); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Options + { + AudioCodec = AudioCodec.Aac, + AutoRotate = true, + Format = Format.Mp4, + Quality = 0, + StreamProtocol = StreamProtocol.Hls, + Variants = ["string"], + VideoCodec = VideoCodec.H264, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Options + { + AudioCodec = AudioCodec.Aac, + AutoRotate = true, + Format = Format.Mp4, + Quality = 0, + StreamProtocol = StreamProtocol.Hls, + Variants = ["string"], + VideoCodec = VideoCodec.H264, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum expectedAudioCodec = AudioCodec.Aac; + bool expectedAutoRotate = true; + ApiEnum expectedFormat = Format.Mp4; + long expectedQuality = 0; + ApiEnum expectedStreamProtocol = StreamProtocol.Hls; + List expectedVariants = ["string"]; + ApiEnum expectedVideoCodec = VideoCodec.H264; + + Assert.Equal(expectedAudioCodec, deserialized.AudioCodec); + Assert.Equal(expectedAutoRotate, deserialized.AutoRotate); + Assert.Equal(expectedFormat, deserialized.Format); + Assert.Equal(expectedQuality, deserialized.Quality); + Assert.Equal(expectedStreamProtocol, deserialized.StreamProtocol); + Assert.NotNull(deserialized.Variants); + Assert.Equal(expectedVariants.Count, deserialized.Variants.Count); + for (int i = 0; i < expectedVariants.Count; i++) + { + Assert.Equal(expectedVariants[i], deserialized.Variants[i]); + } + Assert.Equal(expectedVideoCodec, deserialized.VideoCodec); + } + + [Fact] + public void Validation_Works() + { + var model = new Options + { + AudioCodec = AudioCodec.Aac, + AutoRotate = true, + Format = Format.Mp4, + Quality = 0, + StreamProtocol = StreamProtocol.Hls, + Variants = ["string"], + VideoCodec = VideoCodec.H264, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Options { }; + + Assert.Null(model.AudioCodec); + Assert.False(model.RawData.ContainsKey("audio_codec")); + Assert.Null(model.AutoRotate); + Assert.False(model.RawData.ContainsKey("auto_rotate")); + Assert.Null(model.Format); + Assert.False(model.RawData.ContainsKey("format")); + Assert.Null(model.Quality); + Assert.False(model.RawData.ContainsKey("quality")); + Assert.Null(model.StreamProtocol); + Assert.False(model.RawData.ContainsKey("stream_protocol")); + Assert.Null(model.Variants); + Assert.False(model.RawData.ContainsKey("variants")); + Assert.Null(model.VideoCodec); + Assert.False(model.RawData.ContainsKey("video_codec")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new Options { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new Options + { + // Null should be interpreted as omitted for these properties + AudioCodec = null, + AutoRotate = null, + Format = null, + Quality = null, + StreamProtocol = null, + Variants = null, + VideoCodec = null, + }; + + Assert.Null(model.AudioCodec); + Assert.False(model.RawData.ContainsKey("audio_codec")); + Assert.Null(model.AutoRotate); + Assert.False(model.RawData.ContainsKey("auto_rotate")); + Assert.Null(model.Format); + Assert.False(model.RawData.ContainsKey("format")); + Assert.Null(model.Quality); + Assert.False(model.RawData.ContainsKey("quality")); + Assert.Null(model.StreamProtocol); + Assert.False(model.RawData.ContainsKey("stream_protocol")); + Assert.Null(model.Variants); + Assert.False(model.RawData.ContainsKey("variants")); + Assert.Null(model.VideoCodec); + Assert.False(model.RawData.ContainsKey("video_codec")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new Options + { + // Null should be interpreted as omitted for these properties + AudioCodec = null, + AutoRotate = null, + Format = null, + Quality = null, + StreamProtocol = null, + Variants = null, + VideoCodec = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Options + { + AudioCodec = AudioCodec.Aac, + AutoRotate = true, + Format = Format.Mp4, + Quality = 0, + StreamProtocol = StreamProtocol.Hls, + Variants = ["string"], + VideoCodec = VideoCodec.H264, + }; + + Options copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class AudioCodecTest : TestBase +{ + [Theory] + [InlineData(AudioCodec.Aac)] + [InlineData(AudioCodec.Opus)] + public void Validation_Works(AudioCodec rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(AudioCodec.Aac)] + [InlineData(AudioCodec.Opus)] + public void SerializationRoundtrip_Works(AudioCodec rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class FormatTest : TestBase +{ + [Theory] + [InlineData(Format.Mp4)] + [InlineData(Format.Webm)] + [InlineData(Format.Jpg)] + [InlineData(Format.Png)] + [InlineData(Format.Webp)] + public void Validation_Works(Format rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(Format.Mp4)] + [InlineData(Format.Webm)] + [InlineData(Format.Jpg)] + [InlineData(Format.Png)] + [InlineData(Format.Webp)] + public void SerializationRoundtrip_Works(Format rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class StreamProtocolTest : TestBase +{ + [Theory] + [InlineData(StreamProtocol.Hls)] + [InlineData(StreamProtocol.Dash)] + public void Validation_Works(StreamProtocol rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(StreamProtocol.Hls)] + [InlineData(StreamProtocol.Dash)] + public void SerializationRoundtrip_Works(StreamProtocol rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class VideoCodecTest : TestBase +{ + [Theory] + [InlineData(VideoCodec.H264)] + [InlineData(VideoCodec.Vp9)] + [InlineData(VideoCodec.Av1)] + public void Validation_Works(VideoCodec rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(VideoCodec.H264)] + [InlineData(VideoCodec.Vp9)] + [InlineData(VideoCodec.Av1)] + public void SerializationRoundtrip_Works(VideoCodec rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class VideoTransformationAcceptedEventIntersectionMember1RequestTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new VideoTransformationAcceptedEventIntersectionMember1Request + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }; + + string expectedUrl = "https://example.com"; + string expectedXRequestID = "x_request_id"; + string expectedUserAgent = "user_agent"; + + Assert.Equal(expectedUrl, model.Url); + Assert.Equal(expectedXRequestID, model.XRequestID); + Assert.Equal(expectedUserAgent, model.UserAgent); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new VideoTransformationAcceptedEventIntersectionMember1Request + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new VideoTransformationAcceptedEventIntersectionMember1Request + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedUrl = "https://example.com"; + string expectedXRequestID = "x_request_id"; + string expectedUserAgent = "user_agent"; + + Assert.Equal(expectedUrl, deserialized.Url); + Assert.Equal(expectedXRequestID, deserialized.XRequestID); + Assert.Equal(expectedUserAgent, deserialized.UserAgent); + } + + [Fact] + public void Validation_Works() + { + var model = new VideoTransformationAcceptedEventIntersectionMember1Request + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new VideoTransformationAcceptedEventIntersectionMember1Request + { + Url = "https://example.com", + XRequestID = "x_request_id", + }; + + Assert.Null(model.UserAgent); + Assert.False(model.RawData.ContainsKey("user_agent")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new VideoTransformationAcceptedEventIntersectionMember1Request + { + Url = "https://example.com", + XRequestID = "x_request_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new VideoTransformationAcceptedEventIntersectionMember1Request + { + Url = "https://example.com", + XRequestID = "x_request_id", + + // Null should be interpreted as omitted for these properties + UserAgent = null, + }; + + Assert.Null(model.UserAgent); + Assert.False(model.RawData.ContainsKey("user_agent")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new VideoTransformationAcceptedEventIntersectionMember1Request + { + Url = "https://example.com", + XRequestID = "x_request_id", + + // Null should be interpreted as omitted for these properties + UserAgent = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new VideoTransformationAcceptedEventIntersectionMember1Request + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }; + + VideoTransformationAcceptedEventIntersectionMember1Request copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Webhooks/VideoTransformationErrorEventTest.cs b/src/ImageKit.Tests/Models/Webhooks/VideoTransformationErrorEventTest.cs new file mode 100644 index 00000000..f3069341 --- /dev/null +++ b/src/ImageKit.Tests/Models/Webhooks/VideoTransformationErrorEventTest.cs @@ -0,0 +1,2197 @@ +using System; +using System.Collections.Generic; +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Exceptions; +using ImageKit.Models.Webhooks; + +namespace ImageKit.Tests.Models.Webhooks; + +public class VideoTransformationErrorEventTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new VideoTransformationErrorEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + Error = new(Reason.EncodingFailed), + Options = new() + { + AudioCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + }, + }, + Request = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }, + }; + + string expectedID = "id"; + string expectedType = "type"; + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + VideoTransformationErrorEventIntersectionMember1Data expectedData = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + Error = new(Reason.EncodingFailed), + Options = new() + { + AudioCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + }, + }; + VideoTransformationErrorEventIntersectionMember1Request expectedRequest = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedType, model.Type); + Assert.Equal(expectedCreatedAt, model.CreatedAt); + Assert.Equal(expectedData, model.Data); + Assert.Equal(expectedRequest, model.Request); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new VideoTransformationErrorEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + Error = new(Reason.EncodingFailed), + Options = new() + { + AudioCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + }, + }, + Request = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new VideoTransformationErrorEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + Error = new(Reason.EncodingFailed), + Options = new() + { + AudioCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + }, + }, + Request = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedType = "type"; + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + VideoTransformationErrorEventIntersectionMember1Data expectedData = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + Error = new(Reason.EncodingFailed), + Options = new() + { + AudioCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + }, + }; + VideoTransformationErrorEventIntersectionMember1Request expectedRequest = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedType, deserialized.Type); + Assert.Equal(expectedCreatedAt, deserialized.CreatedAt); + Assert.Equal(expectedData, deserialized.Data); + Assert.Equal(expectedRequest, deserialized.Request); + } + + [Fact] + public void Validation_Works() + { + var model = new VideoTransformationErrorEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + Error = new(Reason.EncodingFailed), + Options = new() + { + AudioCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + }, + }, + Request = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new VideoTransformationErrorEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + Error = new(Reason.EncodingFailed), + Options = new() + { + AudioCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + }, + }, + Request = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }, + }; + + VideoTransformationErrorEvent copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class VideoTransformationErrorEventIntersectionMember1Test : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new VideoTransformationErrorEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + Error = new(Reason.EncodingFailed), + Options = new() + { + AudioCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + }, + }, + Request = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }, + }; + + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + VideoTransformationErrorEventIntersectionMember1Data expectedData = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + Error = new(Reason.EncodingFailed), + Options = new() + { + AudioCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + }, + }; + VideoTransformationErrorEventIntersectionMember1Request expectedRequest = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }; + JsonElement expectedType = JsonSerializer.SerializeToElement("video.transformation.error"); + + Assert.Equal(expectedCreatedAt, model.CreatedAt); + Assert.Equal(expectedData, model.Data); + Assert.Equal(expectedRequest, model.Request); + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new VideoTransformationErrorEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + Error = new(Reason.EncodingFailed), + Options = new() + { + AudioCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + }, + }, + Request = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new VideoTransformationErrorEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + Error = new(Reason.EncodingFailed), + Options = new() + { + AudioCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + }, + }, + Request = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + VideoTransformationErrorEventIntersectionMember1Data expectedData = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + Error = new(Reason.EncodingFailed), + Options = new() + { + AudioCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + }, + }; + VideoTransformationErrorEventIntersectionMember1Request expectedRequest = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }; + JsonElement expectedType = JsonSerializer.SerializeToElement("video.transformation.error"); + + Assert.Equal(expectedCreatedAt, deserialized.CreatedAt); + Assert.Equal(expectedData, deserialized.Data); + Assert.Equal(expectedRequest, deserialized.Request); + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + } + + [Fact] + public void Validation_Works() + { + var model = new VideoTransformationErrorEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + Error = new(Reason.EncodingFailed), + Options = new() + { + AudioCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + }, + }, + Request = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new VideoTransformationErrorEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + Error = new(Reason.EncodingFailed), + Options = new() + { + AudioCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + }, + }, + Request = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }, + }; + + VideoTransformationErrorEventIntersectionMember1 copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class VideoTransformationErrorEventIntersectionMember1DataTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new VideoTransformationErrorEventIntersectionMember1Data + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + Error = new(Reason.EncodingFailed), + Options = new() + { + AudioCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + }, + }; + + VideoTransformationErrorEventIntersectionMember1DataAsset expectedAsset = new( + "https://example.com" + ); + VideoTransformationErrorEventIntersectionMember1DataTransformation expectedTransformation = + new() + { + Type = + VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + Error = new(Reason.EncodingFailed), + Options = new() + { + AudioCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + }; + + Assert.Equal(expectedAsset, model.Asset); + Assert.Equal(expectedTransformation, model.Transformation); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new VideoTransformationErrorEventIntersectionMember1Data + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + Error = new(Reason.EncodingFailed), + Options = new() + { + AudioCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + }, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new VideoTransformationErrorEventIntersectionMember1Data + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + Error = new(Reason.EncodingFailed), + Options = new() + { + AudioCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + VideoTransformationErrorEventIntersectionMember1DataAsset expectedAsset = new( + "https://example.com" + ); + VideoTransformationErrorEventIntersectionMember1DataTransformation expectedTransformation = + new() + { + Type = + VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + Error = new(Reason.EncodingFailed), + Options = new() + { + AudioCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + }; + + Assert.Equal(expectedAsset, deserialized.Asset); + Assert.Equal(expectedTransformation, deserialized.Transformation); + } + + [Fact] + public void Validation_Works() + { + var model = new VideoTransformationErrorEventIntersectionMember1Data + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + Error = new(Reason.EncodingFailed), + Options = new() + { + AudioCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + }, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new VideoTransformationErrorEventIntersectionMember1Data + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + Error = new(Reason.EncodingFailed), + Options = new() + { + AudioCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + }, + }; + + VideoTransformationErrorEventIntersectionMember1Data copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class VideoTransformationErrorEventIntersectionMember1DataAssetTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new VideoTransformationErrorEventIntersectionMember1DataAsset + { + Url = "https://example.com", + }; + + string expectedUrl = "https://example.com"; + + Assert.Equal(expectedUrl, model.Url); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new VideoTransformationErrorEventIntersectionMember1DataAsset + { + Url = "https://example.com", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new VideoTransformationErrorEventIntersectionMember1DataAsset + { + Url = "https://example.com", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedUrl = "https://example.com"; + + Assert.Equal(expectedUrl, deserialized.Url); + } + + [Fact] + public void Validation_Works() + { + var model = new VideoTransformationErrorEventIntersectionMember1DataAsset + { + Url = "https://example.com", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new VideoTransformationErrorEventIntersectionMember1DataAsset + { + Url = "https://example.com", + }; + + VideoTransformationErrorEventIntersectionMember1DataAsset copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class VideoTransformationErrorEventIntersectionMember1DataTransformationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new VideoTransformationErrorEventIntersectionMember1DataTransformation + { + Type = + VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + Error = new(Reason.EncodingFailed), + Options = new() + { + AudioCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + }; + + ApiEnum< + string, + VideoTransformationErrorEventIntersectionMember1DataTransformationType + > expectedType = + VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation; + VideoTransformationErrorEventIntersectionMember1DataTransformationError expectedError = new( + Reason.EncodingFailed + ); + VideoTransformationErrorEventIntersectionMember1DataTransformationOptions expectedOptions = + new() + { + AudioCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }; + + Assert.Equal(expectedType, model.Type); + Assert.Equal(expectedError, model.Error); + Assert.Equal(expectedOptions, model.Options); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new VideoTransformationErrorEventIntersectionMember1DataTransformation + { + Type = + VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + Error = new(Reason.EncodingFailed), + Options = new() + { + AudioCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new VideoTransformationErrorEventIntersectionMember1DataTransformation + { + Type = + VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + Error = new(Reason.EncodingFailed), + Options = new() + { + AudioCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum< + string, + VideoTransformationErrorEventIntersectionMember1DataTransformationType + > expectedType = + VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation; + VideoTransformationErrorEventIntersectionMember1DataTransformationError expectedError = new( + Reason.EncodingFailed + ); + VideoTransformationErrorEventIntersectionMember1DataTransformationOptions expectedOptions = + new() + { + AudioCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }; + + Assert.Equal(expectedType, deserialized.Type); + Assert.Equal(expectedError, deserialized.Error); + Assert.Equal(expectedOptions, deserialized.Options); + } + + [Fact] + public void Validation_Works() + { + var model = new VideoTransformationErrorEventIntersectionMember1DataTransformation + { + Type = + VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + Error = new(Reason.EncodingFailed), + Options = new() + { + AudioCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new VideoTransformationErrorEventIntersectionMember1DataTransformation + { + Type = + VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + }; + + Assert.Null(model.Error); + Assert.False(model.RawData.ContainsKey("error")); + Assert.Null(model.Options); + Assert.False(model.RawData.ContainsKey("options")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new VideoTransformationErrorEventIntersectionMember1DataTransformation + { + Type = + VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new VideoTransformationErrorEventIntersectionMember1DataTransformation + { + Type = + VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + + // Null should be interpreted as omitted for these properties + Error = null, + Options = null, + }; + + Assert.Null(model.Error); + Assert.False(model.RawData.ContainsKey("error")); + Assert.Null(model.Options); + Assert.False(model.RawData.ContainsKey("options")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new VideoTransformationErrorEventIntersectionMember1DataTransformation + { + Type = + VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + + // Null should be interpreted as omitted for these properties + Error = null, + Options = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new VideoTransformationErrorEventIntersectionMember1DataTransformation + { + Type = + VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + Error = new(Reason.EncodingFailed), + Options = new() + { + AudioCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + }; + + VideoTransformationErrorEventIntersectionMember1DataTransformation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class VideoTransformationErrorEventIntersectionMember1DataTransformationTypeTest : TestBase +{ + [Theory] + [InlineData( + VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation + )] + [InlineData(VideoTransformationErrorEventIntersectionMember1DataTransformationType.GifToVideo)] + [InlineData( + VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoThumbnail + )] + public void Validation_Works( + VideoTransformationErrorEventIntersectionMember1DataTransformationType rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + VideoTransformationErrorEventIntersectionMember1DataTransformationType + > value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData( + VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation + )] + [InlineData(VideoTransformationErrorEventIntersectionMember1DataTransformationType.GifToVideo)] + [InlineData( + VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoThumbnail + )] + public void SerializationRoundtrip_Works( + VideoTransformationErrorEventIntersectionMember1DataTransformationType rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + VideoTransformationErrorEventIntersectionMember1DataTransformationType + > value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class VideoTransformationErrorEventIntersectionMember1DataTransformationErrorTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new VideoTransformationErrorEventIntersectionMember1DataTransformationError + { + Reason = Reason.EncodingFailed, + }; + + ApiEnum expectedReason = Reason.EncodingFailed; + + Assert.Equal(expectedReason, model.Reason); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new VideoTransformationErrorEventIntersectionMember1DataTransformationError + { + Reason = Reason.EncodingFailed, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new VideoTransformationErrorEventIntersectionMember1DataTransformationError + { + Reason = Reason.EncodingFailed, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum expectedReason = Reason.EncodingFailed; + + Assert.Equal(expectedReason, deserialized.Reason); + } + + [Fact] + public void Validation_Works() + { + var model = new VideoTransformationErrorEventIntersectionMember1DataTransformationError + { + Reason = Reason.EncodingFailed, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new VideoTransformationErrorEventIntersectionMember1DataTransformationError + { + Reason = Reason.EncodingFailed, + }; + + VideoTransformationErrorEventIntersectionMember1DataTransformationError copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReasonTest : TestBase +{ + [Theory] + [InlineData(Reason.EncodingFailed)] + [InlineData(Reason.DownloadFailed)] + [InlineData(Reason.InternalServerError)] + public void Validation_Works(Reason rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(Reason.EncodingFailed)] + [InlineData(Reason.DownloadFailed)] + [InlineData(Reason.InternalServerError)] + public void SerializationRoundtrip_Works(Reason rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new VideoTransformationErrorEventIntersectionMember1DataTransformationOptions + { + AudioCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }; + + ApiEnum< + string, + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec + > expectedAudioCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac; + bool expectedAutoRotate = true; + ApiEnum< + string, + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat + > expectedFormat = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4; + long expectedQuality = 0; + ApiEnum< + string, + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol + > expectedStreamProtocol = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls; + List expectedVariants = ["string"]; + ApiEnum< + string, + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec + > expectedVideoCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264; + + Assert.Equal(expectedAudioCodec, model.AudioCodec); + Assert.Equal(expectedAutoRotate, model.AutoRotate); + Assert.Equal(expectedFormat, model.Format); + Assert.Equal(expectedQuality, model.Quality); + Assert.Equal(expectedStreamProtocol, model.StreamProtocol); + Assert.NotNull(model.Variants); + Assert.Equal(expectedVariants.Count, model.Variants.Count); + for (int i = 0; i < expectedVariants.Count; i++) + { + Assert.Equal(expectedVariants[i], model.Variants[i]); + } + Assert.Equal(expectedVideoCodec, model.VideoCodec); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new VideoTransformationErrorEventIntersectionMember1DataTransformationOptions + { + AudioCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new VideoTransformationErrorEventIntersectionMember1DataTransformationOptions + { + AudioCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum< + string, + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec + > expectedAudioCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac; + bool expectedAutoRotate = true; + ApiEnum< + string, + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat + > expectedFormat = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4; + long expectedQuality = 0; + ApiEnum< + string, + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol + > expectedStreamProtocol = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls; + List expectedVariants = ["string"]; + ApiEnum< + string, + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec + > expectedVideoCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264; + + Assert.Equal(expectedAudioCodec, deserialized.AudioCodec); + Assert.Equal(expectedAutoRotate, deserialized.AutoRotate); + Assert.Equal(expectedFormat, deserialized.Format); + Assert.Equal(expectedQuality, deserialized.Quality); + Assert.Equal(expectedStreamProtocol, deserialized.StreamProtocol); + Assert.NotNull(deserialized.Variants); + Assert.Equal(expectedVariants.Count, deserialized.Variants.Count); + for (int i = 0; i < expectedVariants.Count; i++) + { + Assert.Equal(expectedVariants[i], deserialized.Variants[i]); + } + Assert.Equal(expectedVideoCodec, deserialized.VideoCodec); + } + + [Fact] + public void Validation_Works() + { + var model = new VideoTransformationErrorEventIntersectionMember1DataTransformationOptions + { + AudioCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new VideoTransformationErrorEventIntersectionMember1DataTransformationOptions + { }; + + Assert.Null(model.AudioCodec); + Assert.False(model.RawData.ContainsKey("audio_codec")); + Assert.Null(model.AutoRotate); + Assert.False(model.RawData.ContainsKey("auto_rotate")); + Assert.Null(model.Format); + Assert.False(model.RawData.ContainsKey("format")); + Assert.Null(model.Quality); + Assert.False(model.RawData.ContainsKey("quality")); + Assert.Null(model.StreamProtocol); + Assert.False(model.RawData.ContainsKey("stream_protocol")); + Assert.Null(model.Variants); + Assert.False(model.RawData.ContainsKey("variants")); + Assert.Null(model.VideoCodec); + Assert.False(model.RawData.ContainsKey("video_codec")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new VideoTransformationErrorEventIntersectionMember1DataTransformationOptions + { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new VideoTransformationErrorEventIntersectionMember1DataTransformationOptions + { + // Null should be interpreted as omitted for these properties + AudioCodec = null, + AutoRotate = null, + Format = null, + Quality = null, + StreamProtocol = null, + Variants = null, + VideoCodec = null, + }; + + Assert.Null(model.AudioCodec); + Assert.False(model.RawData.ContainsKey("audio_codec")); + Assert.Null(model.AutoRotate); + Assert.False(model.RawData.ContainsKey("auto_rotate")); + Assert.Null(model.Format); + Assert.False(model.RawData.ContainsKey("format")); + Assert.Null(model.Quality); + Assert.False(model.RawData.ContainsKey("quality")); + Assert.Null(model.StreamProtocol); + Assert.False(model.RawData.ContainsKey("stream_protocol")); + Assert.Null(model.Variants); + Assert.False(model.RawData.ContainsKey("variants")); + Assert.Null(model.VideoCodec); + Assert.False(model.RawData.ContainsKey("video_codec")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new VideoTransformationErrorEventIntersectionMember1DataTransformationOptions + { + // Null should be interpreted as omitted for these properties + AudioCodec = null, + AutoRotate = null, + Format = null, + Quality = null, + StreamProtocol = null, + Variants = null, + VideoCodec = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new VideoTransformationErrorEventIntersectionMember1DataTransformationOptions + { + AudioCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }; + + VideoTransformationErrorEventIntersectionMember1DataTransformationOptions copied = new( + model + ); + + Assert.Equal(model, copied); + } +} + +public class VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodecTest + : TestBase +{ + [Theory] + [InlineData( + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac + )] + [InlineData( + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Opus + )] + public void Validation_Works( + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec + > value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum< + string, + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec + > + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData( + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac + )] + [InlineData( + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Opus + )] + public void SerializationRoundtrip_Works( + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec + > value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum< + string, + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec + > + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum< + string, + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec + > + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum< + string, + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec + > + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormatTest + : TestBase +{ + [Theory] + [InlineData( + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4 + )] + [InlineData( + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Webm + )] + [InlineData( + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Jpg + )] + [InlineData( + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Png + )] + [InlineData( + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Webp + )] + public void Validation_Works( + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat + > value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum< + string, + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat + > + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData( + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4 + )] + [InlineData( + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Webm + )] + [InlineData( + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Jpg + )] + [InlineData( + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Png + )] + [InlineData( + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Webp + )] + public void SerializationRoundtrip_Works( + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat + > value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum< + string, + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat + > + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum< + string, + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat + > + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum< + string, + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat + > + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocolTest + : TestBase +{ + [Theory] + [InlineData( + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls + )] + [InlineData( + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Dash + )] + public void Validation_Works( + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol + > value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum< + string, + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol + > + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData( + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls + )] + [InlineData( + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Dash + )] + public void SerializationRoundtrip_Works( + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol + > value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum< + string, + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol + > + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum< + string, + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol + > + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum< + string, + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol + > + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodecTest + : TestBase +{ + [Theory] + [InlineData( + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264 + )] + [InlineData( + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.Vp9 + )] + [InlineData( + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.Av1 + )] + public void Validation_Works( + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec + > value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum< + string, + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec + > + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData( + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264 + )] + [InlineData( + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.Vp9 + )] + [InlineData( + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.Av1 + )] + public void SerializationRoundtrip_Works( + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec + > value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum< + string, + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec + > + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum< + string, + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec + > + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum< + string, + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec + > + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class VideoTransformationErrorEventIntersectionMember1RequestTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new VideoTransformationErrorEventIntersectionMember1Request + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }; + + string expectedUrl = "https://example.com"; + string expectedXRequestID = "x_request_id"; + string expectedUserAgent = "user_agent"; + + Assert.Equal(expectedUrl, model.Url); + Assert.Equal(expectedXRequestID, model.XRequestID); + Assert.Equal(expectedUserAgent, model.UserAgent); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new VideoTransformationErrorEventIntersectionMember1Request + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new VideoTransformationErrorEventIntersectionMember1Request + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedUrl = "https://example.com"; + string expectedXRequestID = "x_request_id"; + string expectedUserAgent = "user_agent"; + + Assert.Equal(expectedUrl, deserialized.Url); + Assert.Equal(expectedXRequestID, deserialized.XRequestID); + Assert.Equal(expectedUserAgent, deserialized.UserAgent); + } + + [Fact] + public void Validation_Works() + { + var model = new VideoTransformationErrorEventIntersectionMember1Request + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new VideoTransformationErrorEventIntersectionMember1Request + { + Url = "https://example.com", + XRequestID = "x_request_id", + }; + + Assert.Null(model.UserAgent); + Assert.False(model.RawData.ContainsKey("user_agent")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new VideoTransformationErrorEventIntersectionMember1Request + { + Url = "https://example.com", + XRequestID = "x_request_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new VideoTransformationErrorEventIntersectionMember1Request + { + Url = "https://example.com", + XRequestID = "x_request_id", + + // Null should be interpreted as omitted for these properties + UserAgent = null, + }; + + Assert.Null(model.UserAgent); + Assert.False(model.RawData.ContainsKey("user_agent")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new VideoTransformationErrorEventIntersectionMember1Request + { + Url = "https://example.com", + XRequestID = "x_request_id", + + // Null should be interpreted as omitted for these properties + UserAgent = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new VideoTransformationErrorEventIntersectionMember1Request + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }; + + VideoTransformationErrorEventIntersectionMember1Request copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Webhooks/VideoTransformationReadyEventTest.cs b/src/ImageKit.Tests/Models/Webhooks/VideoTransformationReadyEventTest.cs new file mode 100644 index 00000000..7cd8086e --- /dev/null +++ b/src/ImageKit.Tests/Models/Webhooks/VideoTransformationReadyEventTest.cs @@ -0,0 +1,3167 @@ +using System; +using System.Collections.Generic; +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Exceptions; +using ImageKit.Models.Webhooks; + +namespace ImageKit.Tests.Models.Webhooks; + +public class VideoTransformationReadyEventTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new VideoTransformationReadyEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + Output = new() + { + Url = "https://example.com", + VideoMetadata = new() + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }, + }, + }, + }, + Request = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }, + Timings = new() { DownloadDuration = 0, EncodingDuration = 0 }, + }; + + string expectedID = "id"; + string expectedType = "type"; + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + VideoTransformationReadyEventIntersectionMember1Data expectedData = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + Output = new() + { + Url = "https://example.com", + VideoMetadata = new() + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }, + }, + }, + }; + VideoTransformationReadyEventIntersectionMember1Request expectedRequest = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }; + Timings expectedTimings = new() { DownloadDuration = 0, EncodingDuration = 0 }; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedType, model.Type); + Assert.Equal(expectedCreatedAt, model.CreatedAt); + Assert.Equal(expectedData, model.Data); + Assert.Equal(expectedRequest, model.Request); + Assert.Equal(expectedTimings, model.Timings); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new VideoTransformationReadyEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + Output = new() + { + Url = "https://example.com", + VideoMetadata = new() + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }, + }, + }, + }, + Request = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }, + Timings = new() { DownloadDuration = 0, EncodingDuration = 0 }, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new VideoTransformationReadyEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + Output = new() + { + Url = "https://example.com", + VideoMetadata = new() + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }, + }, + }, + }, + Request = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }, + Timings = new() { DownloadDuration = 0, EncodingDuration = 0 }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedType = "type"; + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + VideoTransformationReadyEventIntersectionMember1Data expectedData = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + Output = new() + { + Url = "https://example.com", + VideoMetadata = new() + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }, + }, + }, + }; + VideoTransformationReadyEventIntersectionMember1Request expectedRequest = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }; + Timings expectedTimings = new() { DownloadDuration = 0, EncodingDuration = 0 }; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedType, deserialized.Type); + Assert.Equal(expectedCreatedAt, deserialized.CreatedAt); + Assert.Equal(expectedData, deserialized.Data); + Assert.Equal(expectedRequest, deserialized.Request); + Assert.Equal(expectedTimings, deserialized.Timings); + } + + [Fact] + public void Validation_Works() + { + var model = new VideoTransformationReadyEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + Output = new() + { + Url = "https://example.com", + VideoMetadata = new() + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }, + }, + }, + }, + Request = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }, + Timings = new() { DownloadDuration = 0, EncodingDuration = 0 }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new VideoTransformationReadyEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + Output = new() + { + Url = "https://example.com", + VideoMetadata = new() + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }, + }, + }, + }, + Request = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }, + }; + + Assert.Null(model.Timings); + Assert.False(model.RawData.ContainsKey("timings")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new VideoTransformationReadyEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + Output = new() + { + Url = "https://example.com", + VideoMetadata = new() + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }, + }, + }, + }, + Request = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new VideoTransformationReadyEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + Output = new() + { + Url = "https://example.com", + VideoMetadata = new() + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }, + }, + }, + }, + Request = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }, + + // Null should be interpreted as omitted for these properties + Timings = null, + }; + + Assert.Null(model.Timings); + Assert.False(model.RawData.ContainsKey("timings")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new VideoTransformationReadyEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + Output = new() + { + Url = "https://example.com", + VideoMetadata = new() + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }, + }, + }, + }, + Request = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }, + + // Null should be interpreted as omitted for these properties + Timings = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new VideoTransformationReadyEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + Output = new() + { + Url = "https://example.com", + VideoMetadata = new() + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }, + }, + }, + }, + Request = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }, + Timings = new() { DownloadDuration = 0, EncodingDuration = 0 }, + }; + + VideoTransformationReadyEvent copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class VideoTransformationReadyEventIntersectionMember1Test : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new VideoTransformationReadyEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + Output = new() + { + Url = "https://example.com", + VideoMetadata = new() + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }, + }, + }, + }, + Request = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }, + Timings = new() { DownloadDuration = 0, EncodingDuration = 0 }, + }; + + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + VideoTransformationReadyEventIntersectionMember1Data expectedData = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + Output = new() + { + Url = "https://example.com", + VideoMetadata = new() + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }, + }, + }, + }; + VideoTransformationReadyEventIntersectionMember1Request expectedRequest = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }; + JsonElement expectedType = JsonSerializer.SerializeToElement("video.transformation.ready"); + Timings expectedTimings = new() { DownloadDuration = 0, EncodingDuration = 0 }; + + Assert.Equal(expectedCreatedAt, model.CreatedAt); + Assert.Equal(expectedData, model.Data); + Assert.Equal(expectedRequest, model.Request); + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + Assert.Equal(expectedTimings, model.Timings); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new VideoTransformationReadyEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + Output = new() + { + Url = "https://example.com", + VideoMetadata = new() + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }, + }, + }, + }, + Request = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }, + Timings = new() { DownloadDuration = 0, EncodingDuration = 0 }, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new VideoTransformationReadyEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + Output = new() + { + Url = "https://example.com", + VideoMetadata = new() + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }, + }, + }, + }, + Request = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }, + Timings = new() { DownloadDuration = 0, EncodingDuration = 0 }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + VideoTransformationReadyEventIntersectionMember1Data expectedData = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + Output = new() + { + Url = "https://example.com", + VideoMetadata = new() + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }, + }, + }, + }; + VideoTransformationReadyEventIntersectionMember1Request expectedRequest = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }; + JsonElement expectedType = JsonSerializer.SerializeToElement("video.transformation.ready"); + Timings expectedTimings = new() { DownloadDuration = 0, EncodingDuration = 0 }; + + Assert.Equal(expectedCreatedAt, deserialized.CreatedAt); + Assert.Equal(expectedData, deserialized.Data); + Assert.Equal(expectedRequest, deserialized.Request); + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + Assert.Equal(expectedTimings, deserialized.Timings); + } + + [Fact] + public void Validation_Works() + { + var model = new VideoTransformationReadyEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + Output = new() + { + Url = "https://example.com", + VideoMetadata = new() + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }, + }, + }, + }, + Request = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }, + Timings = new() { DownloadDuration = 0, EncodingDuration = 0 }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new VideoTransformationReadyEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + Output = new() + { + Url = "https://example.com", + VideoMetadata = new() + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }, + }, + }, + }, + Request = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }, + }; + + Assert.Null(model.Timings); + Assert.False(model.RawData.ContainsKey("timings")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new VideoTransformationReadyEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + Output = new() + { + Url = "https://example.com", + VideoMetadata = new() + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }, + }, + }, + }, + Request = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new VideoTransformationReadyEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + Output = new() + { + Url = "https://example.com", + VideoMetadata = new() + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }, + }, + }, + }, + Request = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }, + + // Null should be interpreted as omitted for these properties + Timings = null, + }; + + Assert.Null(model.Timings); + Assert.False(model.RawData.ContainsKey("timings")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new VideoTransformationReadyEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + Output = new() + { + Url = "https://example.com", + VideoMetadata = new() + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }, + }, + }, + }, + Request = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }, + + // Null should be interpreted as omitted for these properties + Timings = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new VideoTransformationReadyEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + Output = new() + { + Url = "https://example.com", + VideoMetadata = new() + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }, + }, + }, + }, + Request = new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }, + Timings = new() { DownloadDuration = 0, EncodingDuration = 0 }, + }; + + VideoTransformationReadyEventIntersectionMember1 copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class VideoTransformationReadyEventIntersectionMember1DataTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new VideoTransformationReadyEventIntersectionMember1Data + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + Output = new() + { + Url = "https://example.com", + VideoMetadata = new() + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }, + }, + }, + }; + + VideoTransformationReadyEventIntersectionMember1DataAsset expectedAsset = new( + "https://example.com" + ); + VideoTransformationReadyEventIntersectionMember1DataTransformation expectedTransformation = + new() + { + Type = + VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + Output = new() + { + Url = "https://example.com", + VideoMetadata = new() + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }, + }, + }; + + Assert.Equal(expectedAsset, model.Asset); + Assert.Equal(expectedTransformation, model.Transformation); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new VideoTransformationReadyEventIntersectionMember1Data + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + Output = new() + { + Url = "https://example.com", + VideoMetadata = new() + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }, + }, + }, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new VideoTransformationReadyEventIntersectionMember1Data + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + Output = new() + { + Url = "https://example.com", + VideoMetadata = new() + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }, + }, + }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + VideoTransformationReadyEventIntersectionMember1DataAsset expectedAsset = new( + "https://example.com" + ); + VideoTransformationReadyEventIntersectionMember1DataTransformation expectedTransformation = + new() + { + Type = + VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + Output = new() + { + Url = "https://example.com", + VideoMetadata = new() + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }, + }, + }; + + Assert.Equal(expectedAsset, deserialized.Asset); + Assert.Equal(expectedTransformation, deserialized.Transformation); + } + + [Fact] + public void Validation_Works() + { + var model = new VideoTransformationReadyEventIntersectionMember1Data + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + Output = new() + { + Url = "https://example.com", + VideoMetadata = new() + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }, + }, + }, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new VideoTransformationReadyEventIntersectionMember1Data + { + Asset = new("https://example.com"), + Transformation = new() + { + Type = + VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + Output = new() + { + Url = "https://example.com", + VideoMetadata = new() + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }, + }, + }, + }; + + VideoTransformationReadyEventIntersectionMember1Data copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class VideoTransformationReadyEventIntersectionMember1DataAssetTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new VideoTransformationReadyEventIntersectionMember1DataAsset + { + Url = "https://example.com", + }; + + string expectedUrl = "https://example.com"; + + Assert.Equal(expectedUrl, model.Url); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new VideoTransformationReadyEventIntersectionMember1DataAsset + { + Url = "https://example.com", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new VideoTransformationReadyEventIntersectionMember1DataAsset + { + Url = "https://example.com", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedUrl = "https://example.com"; + + Assert.Equal(expectedUrl, deserialized.Url); + } + + [Fact] + public void Validation_Works() + { + var model = new VideoTransformationReadyEventIntersectionMember1DataAsset + { + Url = "https://example.com", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new VideoTransformationReadyEventIntersectionMember1DataAsset + { + Url = "https://example.com", + }; + + VideoTransformationReadyEventIntersectionMember1DataAsset copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class VideoTransformationReadyEventIntersectionMember1DataTransformationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new VideoTransformationReadyEventIntersectionMember1DataTransformation + { + Type = + VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + Output = new() + { + Url = "https://example.com", + VideoMetadata = new() + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }, + }, + }; + + ApiEnum< + string, + VideoTransformationReadyEventIntersectionMember1DataTransformationType + > expectedType = + VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation; + VideoTransformationReadyEventIntersectionMember1DataTransformationOptions expectedOptions = + new() + { + AudioCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }; + Output expectedOutput = new() + { + Url = "https://example.com", + VideoMetadata = new() + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }, + }; + + Assert.Equal(expectedType, model.Type); + Assert.Equal(expectedOptions, model.Options); + Assert.Equal(expectedOutput, model.Output); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new VideoTransformationReadyEventIntersectionMember1DataTransformation + { + Type = + VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + Output = new() + { + Url = "https://example.com", + VideoMetadata = new() + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }, + }, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new VideoTransformationReadyEventIntersectionMember1DataTransformation + { + Type = + VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + Output = new() + { + Url = "https://example.com", + VideoMetadata = new() + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }, + }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum< + string, + VideoTransformationReadyEventIntersectionMember1DataTransformationType + > expectedType = + VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation; + VideoTransformationReadyEventIntersectionMember1DataTransformationOptions expectedOptions = + new() + { + AudioCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }; + Output expectedOutput = new() + { + Url = "https://example.com", + VideoMetadata = new() + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }, + }; + + Assert.Equal(expectedType, deserialized.Type); + Assert.Equal(expectedOptions, deserialized.Options); + Assert.Equal(expectedOutput, deserialized.Output); + } + + [Fact] + public void Validation_Works() + { + var model = new VideoTransformationReadyEventIntersectionMember1DataTransformation + { + Type = + VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + Output = new() + { + Url = "https://example.com", + VideoMetadata = new() + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }, + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new VideoTransformationReadyEventIntersectionMember1DataTransformation + { + Type = + VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + }; + + Assert.Null(model.Options); + Assert.False(model.RawData.ContainsKey("options")); + Assert.Null(model.Output); + Assert.False(model.RawData.ContainsKey("output")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new VideoTransformationReadyEventIntersectionMember1DataTransformation + { + Type = + VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new VideoTransformationReadyEventIntersectionMember1DataTransformation + { + Type = + VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + + // Null should be interpreted as omitted for these properties + Options = null, + Output = null, + }; + + Assert.Null(model.Options); + Assert.False(model.RawData.ContainsKey("options")); + Assert.Null(model.Output); + Assert.False(model.RawData.ContainsKey("output")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new VideoTransformationReadyEventIntersectionMember1DataTransformation + { + Type = + VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + + // Null should be interpreted as omitted for these properties + Options = null, + Output = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new VideoTransformationReadyEventIntersectionMember1DataTransformation + { + Type = + VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }, + Output = new() + { + Url = "https://example.com", + VideoMetadata = new() + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }, + }, + }; + + VideoTransformationReadyEventIntersectionMember1DataTransformation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class VideoTransformationReadyEventIntersectionMember1DataTransformationTypeTest : TestBase +{ + [Theory] + [InlineData( + VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation + )] + [InlineData(VideoTransformationReadyEventIntersectionMember1DataTransformationType.GifToVideo)] + [InlineData( + VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoThumbnail + )] + public void Validation_Works( + VideoTransformationReadyEventIntersectionMember1DataTransformationType rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + VideoTransformationReadyEventIntersectionMember1DataTransformationType + > value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData( + VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation + )] + [InlineData(VideoTransformationReadyEventIntersectionMember1DataTransformationType.GifToVideo)] + [InlineData( + VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoThumbnail + )] + public void SerializationRoundtrip_Works( + VideoTransformationReadyEventIntersectionMember1DataTransformationType rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + VideoTransformationReadyEventIntersectionMember1DataTransformationType + > value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new VideoTransformationReadyEventIntersectionMember1DataTransformationOptions + { + AudioCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }; + + ApiEnum< + string, + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec + > expectedAudioCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac; + bool expectedAutoRotate = true; + ApiEnum< + string, + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat + > expectedFormat = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4; + long expectedQuality = 0; + ApiEnum< + string, + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol + > expectedStreamProtocol = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls; + List expectedVariants = ["string"]; + ApiEnum< + string, + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec + > expectedVideoCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264; + + Assert.Equal(expectedAudioCodec, model.AudioCodec); + Assert.Equal(expectedAutoRotate, model.AutoRotate); + Assert.Equal(expectedFormat, model.Format); + Assert.Equal(expectedQuality, model.Quality); + Assert.Equal(expectedStreamProtocol, model.StreamProtocol); + Assert.NotNull(model.Variants); + Assert.Equal(expectedVariants.Count, model.Variants.Count); + for (int i = 0; i < expectedVariants.Count; i++) + { + Assert.Equal(expectedVariants[i], model.Variants[i]); + } + Assert.Equal(expectedVideoCodec, model.VideoCodec); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new VideoTransformationReadyEventIntersectionMember1DataTransformationOptions + { + AudioCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new VideoTransformationReadyEventIntersectionMember1DataTransformationOptions + { + AudioCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum< + string, + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec + > expectedAudioCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac; + bool expectedAutoRotate = true; + ApiEnum< + string, + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat + > expectedFormat = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4; + long expectedQuality = 0; + ApiEnum< + string, + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol + > expectedStreamProtocol = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls; + List expectedVariants = ["string"]; + ApiEnum< + string, + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec + > expectedVideoCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264; + + Assert.Equal(expectedAudioCodec, deserialized.AudioCodec); + Assert.Equal(expectedAutoRotate, deserialized.AutoRotate); + Assert.Equal(expectedFormat, deserialized.Format); + Assert.Equal(expectedQuality, deserialized.Quality); + Assert.Equal(expectedStreamProtocol, deserialized.StreamProtocol); + Assert.NotNull(deserialized.Variants); + Assert.Equal(expectedVariants.Count, deserialized.Variants.Count); + for (int i = 0; i < expectedVariants.Count; i++) + { + Assert.Equal(expectedVariants[i], deserialized.Variants[i]); + } + Assert.Equal(expectedVideoCodec, deserialized.VideoCodec); + } + + [Fact] + public void Validation_Works() + { + var model = new VideoTransformationReadyEventIntersectionMember1DataTransformationOptions + { + AudioCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new VideoTransformationReadyEventIntersectionMember1DataTransformationOptions + { }; + + Assert.Null(model.AudioCodec); + Assert.False(model.RawData.ContainsKey("audio_codec")); + Assert.Null(model.AutoRotate); + Assert.False(model.RawData.ContainsKey("auto_rotate")); + Assert.Null(model.Format); + Assert.False(model.RawData.ContainsKey("format")); + Assert.Null(model.Quality); + Assert.False(model.RawData.ContainsKey("quality")); + Assert.Null(model.StreamProtocol); + Assert.False(model.RawData.ContainsKey("stream_protocol")); + Assert.Null(model.Variants); + Assert.False(model.RawData.ContainsKey("variants")); + Assert.Null(model.VideoCodec); + Assert.False(model.RawData.ContainsKey("video_codec")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new VideoTransformationReadyEventIntersectionMember1DataTransformationOptions + { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new VideoTransformationReadyEventIntersectionMember1DataTransformationOptions + { + // Null should be interpreted as omitted for these properties + AudioCodec = null, + AutoRotate = null, + Format = null, + Quality = null, + StreamProtocol = null, + Variants = null, + VideoCodec = null, + }; + + Assert.Null(model.AudioCodec); + Assert.False(model.RawData.ContainsKey("audio_codec")); + Assert.Null(model.AutoRotate); + Assert.False(model.RawData.ContainsKey("auto_rotate")); + Assert.Null(model.Format); + Assert.False(model.RawData.ContainsKey("format")); + Assert.Null(model.Quality); + Assert.False(model.RawData.ContainsKey("quality")); + Assert.Null(model.StreamProtocol); + Assert.False(model.RawData.ContainsKey("stream_protocol")); + Assert.Null(model.Variants); + Assert.False(model.RawData.ContainsKey("variants")); + Assert.Null(model.VideoCodec); + Assert.False(model.RawData.ContainsKey("video_codec")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new VideoTransformationReadyEventIntersectionMember1DataTransformationOptions + { + // Null should be interpreted as omitted for these properties + AudioCodec = null, + AutoRotate = null, + Format = null, + Quality = null, + StreamProtocol = null, + Variants = null, + VideoCodec = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new VideoTransformationReadyEventIntersectionMember1DataTransformationOptions + { + AudioCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + }; + + VideoTransformationReadyEventIntersectionMember1DataTransformationOptions copied = new( + model + ); + + Assert.Equal(model, copied); + } +} + +public class VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodecTest + : TestBase +{ + [Theory] + [InlineData( + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac + )] + [InlineData( + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Opus + )] + public void Validation_Works( + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec + > value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum< + string, + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec + > + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData( + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac + )] + [InlineData( + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Opus + )] + public void SerializationRoundtrip_Works( + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec + > value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum< + string, + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec + > + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum< + string, + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec + > + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum< + string, + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec + > + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormatTest + : TestBase +{ + [Theory] + [InlineData( + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4 + )] + [InlineData( + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Webm + )] + [InlineData( + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Jpg + )] + [InlineData( + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Png + )] + [InlineData( + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Webp + )] + public void Validation_Works( + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat + > value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum< + string, + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat + > + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData( + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4 + )] + [InlineData( + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Webm + )] + [InlineData( + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Jpg + )] + [InlineData( + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Png + )] + [InlineData( + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Webp + )] + public void SerializationRoundtrip_Works( + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat + > value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum< + string, + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat + > + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum< + string, + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat + > + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum< + string, + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat + > + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocolTest + : TestBase +{ + [Theory] + [InlineData( + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls + )] + [InlineData( + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Dash + )] + public void Validation_Works( + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol + > value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum< + string, + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol + > + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData( + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls + )] + [InlineData( + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Dash + )] + public void SerializationRoundtrip_Works( + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol + > value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum< + string, + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol + > + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum< + string, + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol + > + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum< + string, + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol + > + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodecTest + : TestBase +{ + [Theory] + [InlineData( + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264 + )] + [InlineData( + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.Vp9 + )] + [InlineData( + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.Av1 + )] + public void Validation_Works( + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec + > value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum< + string, + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec + > + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData( + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264 + )] + [InlineData( + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.Vp9 + )] + [InlineData( + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.Av1 + )] + public void SerializationRoundtrip_Works( + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec + > value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum< + string, + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec + > + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum< + string, + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec + > + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum< + string, + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec + > + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class OutputTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Output + { + Url = "https://example.com", + VideoMetadata = new() + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }, + }; + + string expectedUrl = "https://example.com"; + VideoMetadata expectedVideoMetadata = new() + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }; + + Assert.Equal(expectedUrl, model.Url); + Assert.Equal(expectedVideoMetadata, model.VideoMetadata); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Output + { + Url = "https://example.com", + VideoMetadata = new() + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Output + { + Url = "https://example.com", + VideoMetadata = new() + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + Assert.NotNull(deserialized); + + string expectedUrl = "https://example.com"; + VideoMetadata expectedVideoMetadata = new() + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }; + + Assert.Equal(expectedUrl, deserialized.Url); + Assert.Equal(expectedVideoMetadata, deserialized.VideoMetadata); + } + + [Fact] + public void Validation_Works() + { + var model = new Output + { + Url = "https://example.com", + VideoMetadata = new() + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Output { Url = "https://example.com" }; + + Assert.Null(model.VideoMetadata); + Assert.False(model.RawData.ContainsKey("video_metadata")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new Output { Url = "https://example.com" }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new Output + { + Url = "https://example.com", + + // Null should be interpreted as omitted for these properties + VideoMetadata = null, + }; + + Assert.Null(model.VideoMetadata); + Assert.False(model.RawData.ContainsKey("video_metadata")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new Output + { + Url = "https://example.com", + + // Null should be interpreted as omitted for these properties + VideoMetadata = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Output + { + Url = "https://example.com", + VideoMetadata = new() + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }, + }; + + Output copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class VideoMetadataTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new VideoMetadata + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }; + + long expectedBitrate = 0; + double expectedDuration = 0; + long expectedHeight = 0; + long expectedWidth = 0; + + Assert.Equal(expectedBitrate, model.Bitrate); + Assert.Equal(expectedDuration, model.Duration); + Assert.Equal(expectedHeight, model.Height); + Assert.Equal(expectedWidth, model.Width); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new VideoMetadata + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new VideoMetadata + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + long expectedBitrate = 0; + double expectedDuration = 0; + long expectedHeight = 0; + long expectedWidth = 0; + + Assert.Equal(expectedBitrate, deserialized.Bitrate); + Assert.Equal(expectedDuration, deserialized.Duration); + Assert.Equal(expectedHeight, deserialized.Height); + Assert.Equal(expectedWidth, deserialized.Width); + } + + [Fact] + public void Validation_Works() + { + var model = new VideoMetadata + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new VideoMetadata + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }; + + VideoMetadata copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class VideoTransformationReadyEventIntersectionMember1RequestTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new VideoTransformationReadyEventIntersectionMember1Request + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }; + + string expectedUrl = "https://example.com"; + string expectedXRequestID = "x_request_id"; + string expectedUserAgent = "user_agent"; + + Assert.Equal(expectedUrl, model.Url); + Assert.Equal(expectedXRequestID, model.XRequestID); + Assert.Equal(expectedUserAgent, model.UserAgent); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new VideoTransformationReadyEventIntersectionMember1Request + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new VideoTransformationReadyEventIntersectionMember1Request + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedUrl = "https://example.com"; + string expectedXRequestID = "x_request_id"; + string expectedUserAgent = "user_agent"; + + Assert.Equal(expectedUrl, deserialized.Url); + Assert.Equal(expectedXRequestID, deserialized.XRequestID); + Assert.Equal(expectedUserAgent, deserialized.UserAgent); + } + + [Fact] + public void Validation_Works() + { + var model = new VideoTransformationReadyEventIntersectionMember1Request + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new VideoTransformationReadyEventIntersectionMember1Request + { + Url = "https://example.com", + XRequestID = "x_request_id", + }; + + Assert.Null(model.UserAgent); + Assert.False(model.RawData.ContainsKey("user_agent")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new VideoTransformationReadyEventIntersectionMember1Request + { + Url = "https://example.com", + XRequestID = "x_request_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new VideoTransformationReadyEventIntersectionMember1Request + { + Url = "https://example.com", + XRequestID = "x_request_id", + + // Null should be interpreted as omitted for these properties + UserAgent = null, + }; + + Assert.Null(model.UserAgent); + Assert.False(model.RawData.ContainsKey("user_agent")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new VideoTransformationReadyEventIntersectionMember1Request + { + Url = "https://example.com", + XRequestID = "x_request_id", + + // Null should be interpreted as omitted for these properties + UserAgent = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new VideoTransformationReadyEventIntersectionMember1Request + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }; + + VideoTransformationReadyEventIntersectionMember1Request copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TimingsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Timings { DownloadDuration = 0, EncodingDuration = 0 }; + + long expectedDownloadDuration = 0; + long expectedEncodingDuration = 0; + + Assert.Equal(expectedDownloadDuration, model.DownloadDuration); + Assert.Equal(expectedEncodingDuration, model.EncodingDuration); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Timings { DownloadDuration = 0, EncodingDuration = 0 }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Timings { DownloadDuration = 0, EncodingDuration = 0 }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + long expectedDownloadDuration = 0; + long expectedEncodingDuration = 0; + + Assert.Equal(expectedDownloadDuration, deserialized.DownloadDuration); + Assert.Equal(expectedEncodingDuration, deserialized.EncodingDuration); + } + + [Fact] + public void Validation_Works() + { + var model = new Timings { DownloadDuration = 0, EncodingDuration = 0 }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Timings { }; + + Assert.Null(model.DownloadDuration); + Assert.False(model.RawData.ContainsKey("download_duration")); + Assert.Null(model.EncodingDuration); + Assert.False(model.RawData.ContainsKey("encoding_duration")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new Timings { }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new Timings + { + // Null should be interpreted as omitted for these properties + DownloadDuration = null, + EncodingDuration = null, + }; + + Assert.Null(model.DownloadDuration); + Assert.False(model.RawData.ContainsKey("download_duration")); + Assert.Null(model.EncodingDuration); + Assert.False(model.RawData.ContainsKey("encoding_duration")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new Timings + { + // Null should be interpreted as omitted for these properties + DownloadDuration = null, + EncodingDuration = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Timings { DownloadDuration = 0, EncodingDuration = 0 }; + + Timings copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/Imagekit.Tests/Services/Accounts/Origins/OriginServiceTest.cs b/src/ImageKit.Tests/Services/Accounts/OriginServiceTest.cs similarity index 66% rename from src/Imagekit.Tests/Services/Accounts/Origins/OriginServiceTest.cs rename to src/ImageKit.Tests/Services/Accounts/OriginServiceTest.cs index b377895e..0aee0d61 100644 --- a/src/Imagekit.Tests/Services/Accounts/Origins/OriginServiceTest.cs +++ b/src/ImageKit.Tests/Services/Accounts/OriginServiceTest.cs @@ -1,7 +1,7 @@ using System.Threading.Tasks; -using Imagekit.Models.Accounts.Origins.OriginRequestProperties; +using ImageKit.Models.Accounts.Origins; -namespace Imagekit.Tests.Services.Accounts.Origins; +namespace ImageKit.Tests.Services.Accounts; public class OriginServiceTest : TestBase { @@ -11,17 +11,18 @@ public async Task Create_Works() var originResponse = await this.client.Accounts.Origins.Create( new() { - Origin = new S3() + OriginRequest = new S3() { AccessKey = "AKIATEST123", Bucket = "test-bucket", Name = "My S3 Origin", SecretKey = "secrettest123", - BaseURLForCanonicalHeader = "https://cdn.example.com", + BaseUrlForCanonicalHeader = "https://cdn.example.com", IncludeCanonicalHeader = false, Prefix = "images", }, - } + }, + TestContext.Current.CancellationToken ); originResponse.Validate(); } @@ -30,20 +31,21 @@ public async Task Create_Works() public async Task Update_Works() { var originResponse = await this.client.Accounts.Origins.Update( + "id", new() { - ID = "id", - Origin = new S3() + OriginRequest = new S3() { AccessKey = "AKIATEST123", Bucket = "test-bucket", Name = "My S3 Origin", SecretKey = "secrettest123", - BaseURLForCanonicalHeader = "https://cdn.example.com", + BaseUrlForCanonicalHeader = "https://cdn.example.com", IncludeCanonicalHeader = false, Prefix = "images", }, - } + }, + TestContext.Current.CancellationToken ); originResponse.Validate(); } @@ -51,7 +53,10 @@ public async Task Update_Works() [Fact(Skip = "Prism tests are disabled")] public async Task List_Works() { - var originResponses = await this.client.Accounts.Origins.List(); + var originResponses = await this.client.Accounts.Origins.List( + new(), + TestContext.Current.CancellationToken + ); foreach (var item in originResponses) { item.Validate(); @@ -61,13 +66,21 @@ public async Task List_Works() [Fact(Skip = "Prism tests are disabled")] public async Task Delete_Works() { - await this.client.Accounts.Origins.Delete(new() { ID = "id" }); + await this.client.Accounts.Origins.Delete( + "id", + new(), + TestContext.Current.CancellationToken + ); } [Fact(Skip = "Prism tests are disabled")] public async Task Get_Works() { - var originResponse = await this.client.Accounts.Origins.Get(new() { ID = "id" }); + var originResponse = await this.client.Accounts.Origins.Get( + "id", + new(), + TestContext.Current.CancellationToken + ); originResponse.Validate(); } } diff --git a/src/ImageKit.Tests/Services/Accounts/UrlEndpointServiceTest.cs b/src/ImageKit.Tests/Services/Accounts/UrlEndpointServiceTest.cs new file mode 100644 index 00000000..2ab59468 --- /dev/null +++ b/src/ImageKit.Tests/Services/Accounts/UrlEndpointServiceTest.cs @@ -0,0 +1,61 @@ +using System.Threading.Tasks; + +namespace ImageKit.Tests.Services.Accounts; + +public class UrlEndpointServiceTest : TestBase +{ + [Fact(Skip = "Prism tests are disabled")] + public async Task Create_Works() + { + var urlEndpointResponse = await this.client.Accounts.UrlEndpoints.Create( + new() { Description = "My custom URL endpoint" }, + TestContext.Current.CancellationToken + ); + urlEndpointResponse.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Update_Works() + { + var urlEndpointResponse = await this.client.Accounts.UrlEndpoints.Update( + "id", + new() { Description = "My custom URL endpoint" }, + TestContext.Current.CancellationToken + ); + urlEndpointResponse.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task List_Works() + { + var urlEndpointResponses = await this.client.Accounts.UrlEndpoints.List( + new(), + TestContext.Current.CancellationToken + ); + foreach (var item in urlEndpointResponses) + { + item.Validate(); + } + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Delete_Works() + { + await this.client.Accounts.UrlEndpoints.Delete( + "id", + new(), + TestContext.Current.CancellationToken + ); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Get_Works() + { + var urlEndpointResponse = await this.client.Accounts.UrlEndpoints.Get( + "id", + new(), + TestContext.Current.CancellationToken + ); + urlEndpointResponse.Validate(); + } +} diff --git a/src/Imagekit.Tests/Services/Accounts/Usage/UsageServiceTest.cs b/src/ImageKit.Tests/Services/Accounts/UsageServiceTest.cs similarity index 54% rename from src/Imagekit.Tests/Services/Accounts/Usage/UsageServiceTest.cs rename to src/ImageKit.Tests/Services/Accounts/UsageServiceTest.cs index 5c9fec8f..90f107d8 100644 --- a/src/Imagekit.Tests/Services/Accounts/Usage/UsageServiceTest.cs +++ b/src/ImageKit.Tests/Services/Accounts/UsageServiceTest.cs @@ -1,20 +1,16 @@ -using System; -using System.Threading.Tasks; - -namespace Imagekit.Tests.Services.Accounts.Usage; - -public class UsageServiceTest : TestBase -{ - [Fact(Skip = "Prism tests are disabled")] - public async Task Get_Works() - { - var usage = await this.client.Accounts.Usage.Get( - new() - { - EndDate = DateOnly.Parse("2019-12-27"), - StartDate = DateOnly.Parse("2019-12-27"), - } - ); - usage.Validate(); - } -} +using System.Threading.Tasks; + +namespace ImageKit.Tests.Services.Accounts; + +public class UsageServiceTest : TestBase +{ + [Fact(Skip = "Prism tests are disabled")] + public async Task Get_Works() + { + var usage = await this.client.Accounts.Usage.Get( + new() { EndDate = "2019-12-27", StartDate = "2019-12-27" }, + TestContext.Current.CancellationToken + ); + usage.Validate(); + } +} diff --git a/src/Imagekit.Tests/Services/Assets/AssetServiceTest.cs b/src/ImageKit.Tests/Services/AssetServiceTest.cs similarity index 63% rename from src/Imagekit.Tests/Services/Assets/AssetServiceTest.cs rename to src/ImageKit.Tests/Services/AssetServiceTest.cs index c069b40c..2ada0a28 100644 --- a/src/Imagekit.Tests/Services/Assets/AssetServiceTest.cs +++ b/src/ImageKit.Tests/Services/AssetServiceTest.cs @@ -1,16 +1,16 @@ -using System.Threading.Tasks; - -namespace Imagekit.Tests.Services.Assets; - -public class AssetServiceTest : TestBase -{ - [Fact(Skip = "Prism tests are disabled")] - public async Task List_Works() - { - var assets = await this.client.Assets.List(); - foreach (var item in assets) - { - item.Validate(); - } - } -} +using System.Threading.Tasks; + +namespace ImageKit.Tests.Services; + +public class AssetServiceTest : TestBase +{ + [Fact(Skip = "Prism tests are disabled")] + public async Task List_Works() + { + var assets = await this.client.Assets.List(new(), TestContext.Current.CancellationToken); + foreach (var item in assets) + { + item.Validate(); + } + } +} diff --git a/src/Imagekit.Tests/Services/Beta/V2/Files/FileServiceTest.cs b/src/ImageKit.Tests/Services/Beta/V2/FileServiceTest.cs similarity index 56% rename from src/Imagekit.Tests/Services/Beta/V2/Files/FileServiceTest.cs rename to src/ImageKit.Tests/Services/Beta/V2/FileServiceTest.cs index e37025dd..5f9e9c64 100644 --- a/src/Imagekit.Tests/Services/Beta/V2/Files/FileServiceTest.cs +++ b/src/ImageKit.Tests/Services/Beta/V2/FileServiceTest.cs @@ -1,15 +1,17 @@ -using System.Threading.Tasks; - -namespace Imagekit.Tests.Services.Beta.V2.Files; - -public class FileServiceTest : TestBase -{ - [Fact(Skip = "Prism tests are disabled")] - public async Task Upload_Works() - { - var response = await this.client.Beta.V2.Files.Upload( - new() { File = "a value", FileName = "fileName" } - ); - response.Validate(); - } -} +using System.Text; +using System.Threading.Tasks; + +namespace ImageKit.Tests.Services.Beta.V2; + +public class FileServiceTest : TestBase +{ + [Fact(Skip = "Prism tests are disabled")] + public async Task Upload_Works() + { + var response = await this.client.Beta.V2.Files.Upload( + new() { File = Encoding.UTF8.GetBytes("text"), FileName = "fileName" }, + TestContext.Current.CancellationToken + ); + response.Validate(); + } +} diff --git a/src/Imagekit.Tests/Services/Cache/Invalidation/InvalidationServiceTest.cs b/src/ImageKit.Tests/Services/Cache/InvalidationServiceTest.cs similarity index 62% rename from src/Imagekit.Tests/Services/Cache/Invalidation/InvalidationServiceTest.cs rename to src/ImageKit.Tests/Services/Cache/InvalidationServiceTest.cs index ef5f184f..de3319ba 100644 --- a/src/Imagekit.Tests/Services/Cache/Invalidation/InvalidationServiceTest.cs +++ b/src/ImageKit.Tests/Services/Cache/InvalidationServiceTest.cs @@ -1,24 +1,27 @@ -using System.Threading.Tasks; - -namespace Imagekit.Tests.Services.Cache.Invalidation; - -public class InvalidationServiceTest : TestBase -{ - [Fact(Skip = "Prism tests are disabled")] - public async Task Create_Works() - { - var invalidation = await this.client.Cache.Invalidation.Create( - new() { URL = "https://ik.imagekit.io/your_imagekit_id/default-image.jpg" } - ); - invalidation.Validate(); - } - - [Fact(Skip = "Prism tests are disabled")] - public async Task Get_Works() - { - var invalidation = await this.client.Cache.Invalidation.Get( - new() { RequestID = "requestId" } - ); - invalidation.Validate(); - } -} +using System.Threading.Tasks; + +namespace ImageKit.Tests.Services.Cache; + +public class InvalidationServiceTest : TestBase +{ + [Fact(Skip = "Prism tests are disabled")] + public async Task Create_Works() + { + var invalidation = await this.client.Cache.Invalidation.Create( + new() { UrlValue = "https://ik.imagekit.io/your_imagekit_id/default-image.jpg" }, + TestContext.Current.CancellationToken + ); + invalidation.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Get_Works() + { + var invalidation = await this.client.Cache.Invalidation.Get( + "requestId", + new(), + TestContext.Current.CancellationToken + ); + invalidation.Validate(); + } +} diff --git a/src/Imagekit.Tests/Services/CustomMetadataFields/CustomMetadataFieldServiceTest.cs b/src/ImageKit.Tests/Services/CustomMetadataFieldServiceTest.cs similarity index 64% rename from src/Imagekit.Tests/Services/CustomMetadataFields/CustomMetadataFieldServiceTest.cs rename to src/ImageKit.Tests/Services/CustomMetadataFieldServiceTest.cs index 86e41b54..fea3debc 100644 --- a/src/Imagekit.Tests/Services/CustomMetadataFields/CustomMetadataFieldServiceTest.cs +++ b/src/ImageKit.Tests/Services/CustomMetadataFieldServiceTest.cs @@ -1,7 +1,7 @@ using System.Threading.Tasks; -using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties; +using ImageKit.Models.CustomMetadataFields; -namespace Imagekit.Tests.Services.CustomMetadataFields; +namespace ImageKit.Tests.Services; public class CustomMetadataFieldServiceTest : TestBase { @@ -16,23 +16,16 @@ public async Task Create_Works() Schema = new() { Type = Type.Number, - DefaultValue = new("string"), + DefaultValue = "string", IsValueRequired = true, MaxLength = 0, - MaxValue = new(3000), + MaxValue = 3000, MinLength = 0, - MinValue = new(1000), - SelectOptions = - [ - new("small"), - new("medium"), - new("large"), - new(30), - new(40), - new(true), - ], + MinValue = 1000, + SelectOptions = ["small", "medium", "large", 30, 40, true], }, - } + }, + TestContext.Current.CancellationToken ); customMetadataField.Validate(); } @@ -41,7 +34,9 @@ public async Task Create_Works() public async Task Update_Works() { var customMetadataField = await this.client.CustomMetadataFields.Update( - new() { ID = "id" } + "id", + new(), + TestContext.Current.CancellationToken ); customMetadataField.Validate(); } @@ -49,7 +44,10 @@ public async Task Update_Works() [Fact(Skip = "Prism tests are disabled")] public async Task List_Works() { - var customMetadataFields = await this.client.CustomMetadataFields.List(); + var customMetadataFields = await this.client.CustomMetadataFields.List( + new(), + TestContext.Current.CancellationToken + ); foreach (var item in customMetadataFields) { item.Validate(); @@ -60,7 +58,9 @@ public async Task List_Works() public async Task Delete_Works() { var customMetadataField = await this.client.CustomMetadataFields.Delete( - new() { ID = "id" } + "id", + new(), + TestContext.Current.CancellationToken ); customMetadataField.Validate(); } diff --git a/src/ImageKit.Tests/Services/FileServiceTest.cs b/src/ImageKit.Tests/Services/FileServiceTest.cs new file mode 100644 index 00000000..dcf98c76 --- /dev/null +++ b/src/ImageKit.Tests/Services/FileServiceTest.cs @@ -0,0 +1,142 @@ +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using System.Threading.Tasks; +using ImageKit.Models.Files; +using Models = ImageKit.Models; + +namespace ImageKit.Tests.Services; + +public class FileServiceTest : TestBase +{ + [Fact(Skip = "Prism tests are disabled")] + public async Task Update_Works() + { + var file = await this.client.Files.Update( + "fileId", + new() + { + UpdateFileRequest = new UpdateFileDetails() + { + CustomCoordinates = "10,10,100,100", + CustomMetadata = new Dictionary() + { + { "brand", JsonSerializer.SerializeToElement("bar") }, + { "color", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Extensions = + [ + new Models::UnnamedSchemaWithArrayParent0RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }, + new Models::UnnamedSchemaWithArrayParent0AutoTaggingExtension() + { + MaxTags = 10, + MinConfidence = 80, + Name = + Models::UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + }, + new Models::UnnamedSchemaWithArrayParent0AutoTaggingExtension() + { + MaxTags = 10, + MinConfidence = 80, + Name = + Models::UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.AwsAutoTagging, + }, + new Models::UnnamedSchemaWithArrayParent0AIAutoDescription(), + new Models::UnnamedSchemaWithArrayParent0AITasks( + [ + new Models::UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + { + Instruction = "What types of clothing items are visible?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "dress", "jacket"], + }, + ] + ), + new Models::SavedExtension("ext_abc123"), + ], + RemoveAITags = new(["car", "vehicle", "motorsports"]), + Tags = ["tag1", "tag2"], + WebhookUrl = "https://webhook.site/0d6b6c7a-8e5a-4b3a-8b7c-0d6b6c7a8e5a", + }, + }, + TestContext.Current.CancellationToken + ); + file.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Delete_Works() + { + await this.client.Files.Delete("fileId", new(), TestContext.Current.CancellationToken); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Copy_Works() + { + var response = await this.client.Files.Copy( + new() + { + DestinationPath = "/folder/to/copy/into/", + SourceFilePath = "/path/to/file.jpg", + }, + TestContext.Current.CancellationToken + ); + response.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Get_Works() + { + var file = await this.client.Files.Get( + "fileId", + new(), + TestContext.Current.CancellationToken + ); + file.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Move_Works() + { + var response = await this.client.Files.Move( + new() + { + DestinationPath = "/folder/to/move/into/", + SourceFilePath = "/path/to/file.jpg", + }, + TestContext.Current.CancellationToken + ); + response.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Rename_Works() + { + var response = await this.client.Files.Rename( + new() { FilePath = "/path/to/file.jpg", NewFileName = "newFileName.jpg" }, + TestContext.Current.CancellationToken + ); + response.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Upload_Works() + { + var response = await this.client.Files.Upload( + new() { File = Encoding.UTF8.GetBytes("text"), FileName = "fileName" }, + TestContext.Current.CancellationToken + ); + response.Validate(); + } +} diff --git a/src/Imagekit.Tests/Services/Files/Bulk/BulkServiceTest.cs b/src/ImageKit.Tests/Services/Files/BulkServiceTest.cs similarity index 66% rename from src/Imagekit.Tests/Services/Files/Bulk/BulkServiceTest.cs rename to src/ImageKit.Tests/Services/Files/BulkServiceTest.cs index b7645de3..f8d7c213 100644 --- a/src/Imagekit.Tests/Services/Files/Bulk/BulkServiceTest.cs +++ b/src/ImageKit.Tests/Services/Files/BulkServiceTest.cs @@ -1,6 +1,6 @@ using System.Threading.Tasks; -namespace Imagekit.Tests.Services.Files.Bulk; +namespace ImageKit.Tests.Services.Files; public class BulkServiceTest : TestBase { @@ -8,7 +8,8 @@ public class BulkServiceTest : TestBase public async Task Delete_Works() { var bulk = await this.client.Files.Bulk.Delete( - new() { FileIDs = ["598821f949c0a938d57563bd", "598821f949c0a938d57563be"] } + new() { FileIds = ["598821f949c0a938d57563bd", "598821f949c0a938d57563be"] }, + TestContext.Current.CancellationToken ); bulk.Validate(); } @@ -19,9 +20,10 @@ public async Task AddTags_Works() var response = await this.client.Files.Bulk.AddTags( new() { - FileIDs = ["598821f949c0a938d57563bd", "598821f949c0a938d57563be"], + FileIds = ["598821f949c0a938d57563bd", "598821f949c0a938d57563be"], Tags = ["t-shirt", "round-neck", "sale2019"], - } + }, + TestContext.Current.CancellationToken ); response.Validate(); } @@ -33,8 +35,9 @@ public async Task RemoveAITags_Works() new() { AITags = ["t-shirt", "round-neck", "sale2019"], - FileIDs = ["598821f949c0a938d57563bd", "598821f949c0a938d57563be"], - } + FileIds = ["598821f949c0a938d57563bd", "598821f949c0a938d57563be"], + }, + TestContext.Current.CancellationToken ); response.Validate(); } @@ -45,9 +48,10 @@ public async Task RemoveTags_Works() var response = await this.client.Files.Bulk.RemoveTags( new() { - FileIDs = ["598821f949c0a938d57563bd", "598821f949c0a938d57563be"], + FileIds = ["598821f949c0a938d57563bd", "598821f949c0a938d57563be"], Tags = ["t-shirt", "round-neck", "sale2019"], - } + }, + TestContext.Current.CancellationToken ); response.Validate(); } diff --git a/src/ImageKit.Tests/Services/Files/MetadataServiceTest.cs b/src/ImageKit.Tests/Services/Files/MetadataServiceTest.cs new file mode 100644 index 00000000..834dfce5 --- /dev/null +++ b/src/ImageKit.Tests/Services/Files/MetadataServiceTest.cs @@ -0,0 +1,27 @@ +using System.Threading.Tasks; + +namespace ImageKit.Tests.Services.Files; + +public class MetadataServiceTest : TestBase +{ + [Fact(Skip = "Prism tests are disabled")] + public async Task Get_Works() + { + var metadata = await this.client.Files.Metadata.Get( + "fileId", + new(), + TestContext.Current.CancellationToken + ); + metadata.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task GetFromUrl_Works() + { + var metadata = await this.client.Files.Metadata.GetFromUrl( + new() { UrlValue = "https://example.com" }, + TestContext.Current.CancellationToken + ); + metadata.Validate(); + } +} diff --git a/src/Imagekit.Tests/Services/Files/Versions/VersionServiceTest.cs b/src/ImageKit.Tests/Services/Files/VersionServiceTest.cs similarity index 58% rename from src/Imagekit.Tests/Services/Files/Versions/VersionServiceTest.cs rename to src/ImageKit.Tests/Services/Files/VersionServiceTest.cs index a4ddfcdd..f25b2233 100644 --- a/src/Imagekit.Tests/Services/Files/Versions/VersionServiceTest.cs +++ b/src/ImageKit.Tests/Services/Files/VersionServiceTest.cs @@ -1,43 +1,53 @@ -using System.Threading.Tasks; - -namespace Imagekit.Tests.Services.Files.Versions; - -public class VersionServiceTest : TestBase -{ - [Fact(Skip = "Prism tests are disabled")] - public async Task List_Works() - { - var files = await this.client.Files.Versions.List(new() { FileID = "fileId" }); - foreach (var item in files) - { - item.Validate(); - } - } - - [Fact(Skip = "Prism tests are disabled")] - public async Task Delete_Works() - { - var version = await this.client.Files.Versions.Delete( - new() { FileID = "fileId", VersionID = "versionId" } - ); - version.Validate(); - } - - [Fact(Skip = "Prism tests are disabled")] - public async Task Get_Works() - { - var file = await this.client.Files.Versions.Get( - new() { FileID = "fileId", VersionID = "versionId" } - ); - file.Validate(); - } - - [Fact(Skip = "Prism tests are disabled")] - public async Task Restore_Works() - { - var file = await this.client.Files.Versions.Restore( - new() { FileID = "fileId", VersionID = "versionId" } - ); - file.Validate(); - } -} +using System.Threading.Tasks; + +namespace ImageKit.Tests.Services.Files; + +public class VersionServiceTest : TestBase +{ + [Fact(Skip = "Prism tests are disabled")] + public async Task List_Works() + { + var files = await this.client.Files.Versions.List( + "fileId", + new(), + TestContext.Current.CancellationToken + ); + foreach (var item in files) + { + item.Validate(); + } + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Delete_Works() + { + var version = await this.client.Files.Versions.Delete( + "versionId", + new() { FileID = "fileId" }, + TestContext.Current.CancellationToken + ); + version.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Get_Works() + { + var file = await this.client.Files.Versions.Get( + "versionId", + new() { FileID = "fileId" }, + TestContext.Current.CancellationToken + ); + file.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Restore_Works() + { + var file = await this.client.Files.Versions.Restore( + "versionId", + new() { FileID = "fileId" }, + TestContext.Current.CancellationToken + ); + file.Validate(); + } +} diff --git a/src/Imagekit.Tests/Services/Folders/FolderServiceTest.cs b/src/ImageKit.Tests/Services/FolderServiceTest.cs similarity index 71% rename from src/Imagekit.Tests/Services/Folders/FolderServiceTest.cs rename to src/ImageKit.Tests/Services/FolderServiceTest.cs index 99b33c2a..028bf06c 100644 --- a/src/Imagekit.Tests/Services/Folders/FolderServiceTest.cs +++ b/src/ImageKit.Tests/Services/FolderServiceTest.cs @@ -1,6 +1,6 @@ using System.Threading.Tasks; -namespace Imagekit.Tests.Services.Folders; +namespace ImageKit.Tests.Services; public class FolderServiceTest : TestBase { @@ -8,7 +8,8 @@ public class FolderServiceTest : TestBase public async Task Create_Works() { var folder = await this.client.Folders.Create( - new() { FolderName = "summer", ParentFolderPath = "/product/images/" } + new() { FolderName = "summer", ParentFolderPath = "/product/images/" }, + TestContext.Current.CancellationToken ); folder.Validate(); } @@ -16,7 +17,10 @@ public async Task Create_Works() [Fact(Skip = "Prism tests are disabled")] public async Task Delete_Works() { - var folder = await this.client.Folders.Delete(new() { FolderPath = "/folder/to/delete/" }); + var folder = await this.client.Folders.Delete( + new() { FolderPath = "/folder/to/delete/" }, + TestContext.Current.CancellationToken + ); folder.Validate(); } @@ -28,7 +32,8 @@ public async Task Copy_Works() { DestinationPath = "/path/of/destination/folder", SourceFolderPath = "/path/of/source/folder", - } + }, + TestContext.Current.CancellationToken ); response.Validate(); } @@ -41,7 +46,8 @@ public async Task Move_Works() { DestinationPath = "/path/of/destination/folder", SourceFolderPath = "/path/of/source/folder", - } + }, + TestContext.Current.CancellationToken ); response.Validate(); } @@ -50,7 +56,8 @@ public async Task Move_Works() public async Task Rename_Works() { var response = await this.client.Folders.Rename( - new() { FolderPath = "/path/of/folder", NewFolderName = "new-folder-name" } + new() { FolderPath = "/path/of/folder", NewFolderName = "new-folder-name" }, + TestContext.Current.CancellationToken ); response.Validate(); } diff --git a/src/ImageKit.Tests/Services/Folders/JobServiceTest.cs b/src/ImageKit.Tests/Services/Folders/JobServiceTest.cs new file mode 100644 index 00000000..4e324499 --- /dev/null +++ b/src/ImageKit.Tests/Services/Folders/JobServiceTest.cs @@ -0,0 +1,17 @@ +using System.Threading.Tasks; + +namespace ImageKit.Tests.Services.Folders; + +public class JobServiceTest : TestBase +{ + [Fact(Skip = "Prism tests are disabled")] + public async Task Get_Works() + { + var job = await this.client.Folders.Job.Get( + "jobId", + new(), + TestContext.Current.CancellationToken + ); + job.Validate(); + } +} diff --git a/src/ImageKit.Tests/Services/SavedExtensionServiceTest.cs b/src/ImageKit.Tests/Services/SavedExtensionServiceTest.cs new file mode 100644 index 00000000..cd76b445 --- /dev/null +++ b/src/ImageKit.Tests/Services/SavedExtensionServiceTest.cs @@ -0,0 +1,76 @@ +using System.Threading.Tasks; +using Models = ImageKit.Models; + +namespace ImageKit.Tests.Services; + +public class SavedExtensionServiceTest : TestBase +{ + [Fact(Skip = "Prism tests are disabled")] + public async Task Create_Works() + { + var savedExtension = await this.client.SavedExtensions.Create( + new() + { + Config = new Models::RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }, + Description = "Analyzes vehicle images for type, condition, and quality assessment", + Name = "Car Quality Analysis", + }, + TestContext.Current.CancellationToken + ); + savedExtension.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Update_Works() + { + var savedExtension = await this.client.SavedExtensions.Update( + "id", + new(), + TestContext.Current.CancellationToken + ); + savedExtension.Validate(); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task List_Works() + { + var savedExtensions = await this.client.SavedExtensions.List( + new(), + TestContext.Current.CancellationToken + ); + foreach (var item in savedExtensions) + { + item.Validate(); + } + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Delete_Works() + { + await this.client.SavedExtensions.Delete( + "id", + new(), + TestContext.Current.CancellationToken + ); + } + + [Fact(Skip = "Prism tests are disabled")] + public async Task Get_Works() + { + var savedExtension = await this.client.SavedExtensions.Get( + "id", + new(), + TestContext.Current.CancellationToken + ); + savedExtension.Validate(); + } +} diff --git a/src/Imagekit.Tests/TestBase.cs b/src/ImageKit.Tests/TestBase.cs similarity index 68% rename from src/Imagekit.Tests/TestBase.cs rename to src/ImageKit.Tests/TestBase.cs index 55cb514b..5153c17c 100644 --- a/src/Imagekit.Tests/TestBase.cs +++ b/src/ImageKit.Tests/TestBase.cs @@ -1,7 +1,7 @@ using System; -using Imagekit; +using ImageKit; -namespace Imagekit.Tests; +namespace ImageKit.Tests; public class TestBase { @@ -11,9 +11,8 @@ public TestBase() { client = new ImageKitClient() { - BaseUrl = new Uri( - Environment.GetEnvironmentVariable("TEST_API_BASE_URL") ?? "http://localhost:4010" - ), + BaseUrl = + Environment.GetEnvironmentVariable("TEST_API_BASE_URL") ?? "http://localhost:4010", PrivateKey = "My Private Key", Password = "My Password", }; diff --git a/src/ImageKit/Core/ApiEnum.cs b/src/ImageKit/Core/ApiEnum.cs new file mode 100644 index 00000000..d92c6ca3 --- /dev/null +++ b/src/ImageKit/Core/ApiEnum.cs @@ -0,0 +1,136 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Exceptions; + +namespace ImageKit.Core; + +/// +/// A serializable and deserializable enum wrapper type that handles the possibility of values outside the +/// range of known enum members. +/// +/// In most cases you don't have to worry about this type and can rely on its implicit operators to +/// wrap and unwrap enum values. +/// +/// +/// Returns this instance's raw value. +/// +/// This is usually only useful if this instance was deserialized from data that doesn't match the +/// expected type (), and you want to know that value. For example, if the +/// SDK is on an older version than the API, then the API may respond with new data types that the SDK is +/// unaware of. +/// +/// +public record class ApiEnum(JsonElement Json) + where TEnum : struct, Enum +{ + /// + /// Returns this instance's raw value. + /// + /// This is usually only useful if this instance was deserialized from data that doesn't match + /// any known enum member, and you want to know that value. For example, if the SDK is on an older + /// version than the API, then the API may respond with new members that the SDK is unaware of. + /// + /// + /// Thrown when this instance's raw value isn't of type . Use + /// to access the raw value. + /// + /// + public TRaw Raw() + { + try + { + return JsonSerializer.Deserialize(this.Json, ModelBase.SerializerOptions) + ?? throw new ImageKitInvalidDataException($"{nameof(this.Json)} cannot be null"); + } + catch (JsonException e) + { + throw new ImageKitInvalidDataException( + $"{this.Json} must be of type {typeof(TRaw).FullName}", + e + ); + } + } + + /// + /// Returns an enum member corresponding to this instance's value, or (TEnum)(-1) if the + /// class was instantiated with an unknown value. + /// + /// Use to access the raw value.. + /// + public TEnum Value() + { + try + { + return JsonSerializer.Deserialize(this.Json, ModelBase.SerializerOptions) + ?? throw new ImageKitInvalidDataException($"{nameof(this.Json)} cannot be null"); + } + catch (JsonException e) + { + throw new ImageKitInvalidDataException( + $"{this.Json} must be of type {typeof(TRaw).FullName}", + e + ); + } + } + + /// + /// Verifies that this instance's raw value is a member of . + /// + /// + /// Thrown when this instance's raw value isn't a member of . + /// + /// + public void Validate() + { + if (!Enum.IsDefined(typeof(TEnum), Value())) + { + throw new ImageKitInvalidDataException("Invalid enum value"); + } + } + + public virtual bool Equals(ApiEnum? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override string ToString() => + JsonSerializer.Serialize(this.Json, ModelBase.ToStringSerializerOptions); + + public override int GetHashCode() + { + return 0; + } + + public static implicit operator TRaw(ApiEnum value) => value.Raw(); + + public static implicit operator TEnum(ApiEnum value) => value.Value(); + + public static implicit operator ApiEnum(TRaw value) => + new(JsonSerializer.SerializeToElement(value, ModelBase.SerializerOptions)); + + public static implicit operator ApiEnum(TEnum value) => + new(JsonSerializer.SerializeToElement(value, ModelBase.SerializerOptions)); +} + +sealed class ApiEnumConverter : JsonConverter> + where TEnum : struct, Enum +{ + public override ApiEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write( + Utf8JsonWriter writer, + ApiEnum value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} diff --git a/src/ImageKit/Core/BinaryContent.cs b/src/ImageKit/Core/BinaryContent.cs new file mode 100644 index 00000000..a694d9e3 --- /dev/null +++ b/src/ImageKit/Core/BinaryContent.cs @@ -0,0 +1,25 @@ +using System.IO; +using System.Net.Http.Headers; + +namespace ImageKit.Core; + +/// +/// A class representing a binary stream of data with its associated (optional) file +/// name and content type. +/// +public sealed record class BinaryContent +{ + public required Stream Stream { get; init; } + public string? FileName { get; init; } + public MediaTypeHeaderValue ContentType { get; set; } = new("application/octet-stream"); + + public static implicit operator BinaryContent(Stream stream) => + new() + { + Stream = stream, + FileName = stream is FileStream fileStream ? Path.GetFileName(fileStream.Name) : null, + }; + + public static implicit operator BinaryContent(byte[] bytes) => + new() { Stream = new MemoryStream(bytes) }; +} diff --git a/src/ImageKit/Core/ClientOptions.cs b/src/ImageKit/Core/ClientOptions.cs new file mode 100644 index 00000000..af27e857 --- /dev/null +++ b/src/ImageKit/Core/ClientOptions.cs @@ -0,0 +1,145 @@ +using System; +using System.Net.Http; +using ImageKit.Exceptions; + +namespace ImageKit.Core; + +/// +/// A class representing the SDK client configuration. +/// +public record struct ClientOptions() +{ + /// + /// The default value used for . + /// + public static readonly int DefaultMaxRetries = 2; + + /// + /// The default value used for . + /// + public static readonly TimeSpan DefaultTimeout = TimeSpan.FromMinutes(1); + + /// + /// The HTTP client to use for making requests in the SDK. + /// + public HttpClient HttpClient { get; set; } = new(); + + Lazy _baseUrl = new(() => + Environment.GetEnvironmentVariable("IMAGE_KIT_BASE_URL") ?? EnvironmentUrl.Production + ); + + /// + /// The base URL to use for every request. + /// + /// Defaults to the production environment: + /// + public string BaseUrl + { + readonly get { return _baseUrl.Value; } + set { _baseUrl = new(() => value); } + } + + /// + /// Whether to validate response bodies before returning them. + /// + /// Defaults to false, which means the shape of the response body will not be validated upfront. + /// Instead, validation will only occur for the parts of the response body that are accessed. + /// + /// Note that when set to true, the response body is only validated if the response is + /// deserialized. Methods that don't eagerly deserialize the response, such as those on + /// , don't perform validation until deserialization + /// is triggered. + /// + public bool ResponseValidation { get; set; } = false; + + /// + /// The maximum number of times to retry failed requests, with a short exponential backoff between requests. + /// + /// + /// Only the following error types are retried: + /// + /// Connection errors (for example, due to a network connectivity problem) + /// 408 Request Timeout + /// 409 Conflict + /// 429 Rate Limit + /// 5xx Internal + /// + /// + /// + /// The API may also explicitly instruct the SDK to retry or not retry a request. + /// + /// Defaults to 2 when null. Set to 0 to + /// disable retries, which also ignores API instructions to retry. + /// + public int? MaxRetries { get; set; } + + /// + /// Sets the maximum time allowed for a complete HTTP call, not including retries. + /// + /// This includes resolving DNS, connecting, writing the request body, server processing, as + /// well as reading the response body. + /// + /// Defaults to TimeSpan.FromMinutes(1) when null. + /// + public TimeSpan? Timeout { get; set; } + + /// + /// Your ImageKit private API key (starts with `private_`). You can find this + /// in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/api-keys). + /// + Lazy _privateKey = new(() => + Environment.GetEnvironmentVariable("IMAGEKIT_PRIVATE_KEY") + ?? throw new ImageKitInvalidDataException( + string.Format("{0} cannot be null", nameof(PrivateKey)), + new ArgumentNullException(nameof(PrivateKey)) + ) + ); + + /// + /// Your ImageKit private API key (starts with `private_`). You can find this + /// in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/api-keys). + /// + public string PrivateKey + { + readonly get { return _privateKey.Value; } + set { _privateKey = new(() => value); } + } + + /// + /// ImageKit uses your API key as username and ignores the password. The SDK + /// sets a dummy value. You can ignore this field. + /// + Lazy _password = new(() => + Environment.GetEnvironmentVariable("OPTIONAL_IMAGEKIT_IGNORES_THIS") ?? "do_not_set" + ); + + /// + /// ImageKit uses your API key as username and ignores the password. The SDK + /// sets a dummy value. You can ignore this field. + /// + public string? Password + { + readonly get { return _password.Value; } + set { _password = new(() => value); } + } + + /// + /// Your ImageKit webhook secret for verifying webhook signatures (starts with + /// `whsec_`). You can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks). + /// Only required if you're using webhooks. + /// + Lazy _webhookSecret = new(() => + Environment.GetEnvironmentVariable("IMAGEKIT_WEBHOOK_SECRET") + ); + + /// + /// Your ImageKit webhook secret for verifying webhook signatures (starts with + /// `whsec_`). You can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks). + /// Only required if you're using webhooks. + /// + public string? WebhookSecret + { + readonly get { return _webhookSecret.Value; } + set { _webhookSecret = new(() => value); } + } +} diff --git a/src/ImageKit/Core/EnvironmentUrl.cs b/src/ImageKit/Core/EnvironmentUrl.cs new file mode 100644 index 00000000..0e4da612 --- /dev/null +++ b/src/ImageKit/Core/EnvironmentUrl.cs @@ -0,0 +1,6 @@ +namespace ImageKit.Core; + +public static class EnvironmentUrl +{ + public static readonly string Production = "https://api.imagekit.io"; +} diff --git a/src/ImageKit/Core/FrozenDictionaryConverterFactory.cs b/src/ImageKit/Core/FrozenDictionaryConverterFactory.cs new file mode 100644 index 00000000..186532d1 --- /dev/null +++ b/src/ImageKit/Core/FrozenDictionaryConverterFactory.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace ImageKit.Core; + +sealed class FrozenDictionaryConverterFactory : JsonConverterFactory +{ + public override bool CanConvert(Type typeToConvert) + { + if (!typeToConvert.IsGenericType) + { + return false; + } + + var genericTypeDefinition = typeToConvert.GetGenericTypeDefinition(); + return genericTypeDefinition == typeof(FrozenDictionary<,>); + } + + public override JsonConverter? CreateConverter( + Type typeToConvert, + JsonSerializerOptions options + ) + { + var keyType = typeToConvert.GetGenericArguments()[0]; + var valueType = typeToConvert.GetGenericArguments()[1]; + + var converterType = typeof(FrozenDictionaryConverter<,>).MakeGenericType( + keyType, + valueType + ); + return (JsonConverter?)Activator.CreateInstance(converterType); + } +} + +sealed class FrozenDictionaryConverter : JsonConverter> + where TKey : notnull +{ + public override FrozenDictionary? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var dictionary = JsonSerializer.Deserialize>(ref reader, options); + if (dictionary == null) + { + return null; + } + + return FrozenDictionary.ToFrozenDictionary(dictionary); + } + + public override void Write( + Utf8JsonWriter writer, + FrozenDictionary value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value, typeof(IReadOnlyDictionary), options); + } +} diff --git a/src/ImageKit/Core/HttpRequest.cs b/src/ImageKit/Core/HttpRequest.cs new file mode 100644 index 00000000..5017e843 --- /dev/null +++ b/src/ImageKit/Core/HttpRequest.cs @@ -0,0 +1,26 @@ +using System.Net.Http; + +namespace ImageKit.Core; + +public sealed class HttpRequest

+ where P : ParamsBase +{ + public required HttpMethod Method { get; init; } + + public required P Params { get; init; } + + public override string ToString() => + string.Format("Method: {0}\n{1}", this.Method.ToString(), this.Params.ToString()); + + public override bool Equals(object? obj) + { + if (obj is not HttpRequest

other) + { + return false; + } + + return this.Method.Equals(other.Method) && this.Params.Equals(other.Params); + } + + public override int GetHashCode() => 0; +} diff --git a/src/ImageKit/Core/HttpResponse.cs b/src/ImageKit/Core/HttpResponse.cs new file mode 100644 index 00000000..f64d9c0f --- /dev/null +++ b/src/ImageKit/Core/HttpResponse.cs @@ -0,0 +1,172 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.IO; +using System.Net; +using System.Net.Http; +using System.Text.Json; +using System.Threading.Tasks; +using ImageKit.Exceptions; +using Threading = System.Threading; + +namespace ImageKit.Core; + +public class HttpResponse : IDisposable +{ + public required HttpResponseMessage RawMessage { get; init; } + + public IEnumerable>> Headers + { + get { return RawMessage.Headers; } + } + + public bool IsSuccessStatusCode + { + get { return RawMessage.IsSuccessStatusCode; } + } + + public HttpStatusCode StatusCode + { + get { return RawMessage.StatusCode; } + } + + public Threading::CancellationToken CancellationToken { get; init; } = default; + + public IEnumerable GetHeaderValues(string name) => RawMessage.Headers.GetValues(name); + + public bool TryGetHeaderValues( + string name, + [NotNullWhen(true)] out IEnumerable? values + ) => RawMessage.Headers.TryGetValues(name, out values); + + public sealed override string ToString() => this.RawMessage.ToString(); + + public override bool Equals(object? obj) + { + if (obj is not HttpResponse other) + { + return false; + } + + return this.RawMessage.Equals(other.RawMessage); + } + + public override int GetHashCode() => this.RawMessage.GetHashCode(); + + public async Task Deserialize(Threading::CancellationToken cancellationToken = default) + { + using var cts = Threading::CancellationTokenSource.CreateLinkedTokenSource( + this.CancellationToken, + cancellationToken + ); + try + { + return await JsonSerializer + .DeserializeAsync( + await this.ReadAsStream(cts.Token).ConfigureAwait(false), + ModelBase.SerializerOptions, + cts.Token + ) + .ConfigureAwait(false) + ?? throw new ImageKitInvalidDataException("Response cannot be null"); + } + catch (HttpRequestException e) + { + throw new ImageKitIOException("I/O Exception", e); + } + } + + public async Task ReadAsStream(Threading::CancellationToken cancellationToken = default) + { + using var cts = Threading::CancellationTokenSource.CreateLinkedTokenSource( + this.CancellationToken, + cancellationToken + ); + return await RawMessage.Content.ReadAsStreamAsync( +#if NET + cts.Token +#endif + ).ConfigureAwait(false); + } + + public async Task ReadAsString(Threading::CancellationToken cancellationToken = default) + { + using var cts = Threading::CancellationTokenSource.CreateLinkedTokenSource( + this.CancellationToken, + cancellationToken + ); + return await RawMessage.Content.ReadAsStringAsync( +#if NET + cts.Token +#endif + ).ConfigureAwait(false); + } + + public void Dispose() + { + this.RawMessage.Dispose(); + GC.SuppressFinalize(this); + } +} + +public sealed class HttpResponse : HttpResponse +{ + readonly Func> _deserialize; + + internal HttpResponse(Func> deserialize) + { + this._deserialize = deserialize; + } + + [SetsRequiredMembers] + internal HttpResponse( + HttpResponse response, + Func> deserialize + ) + : this(deserialize) + { + this.RawMessage = response.RawMessage; + this.CancellationToken = response.CancellationToken; + } + + public Task Deserialize(Threading::CancellationToken cancellationToken = default) + { + using var cts = Threading::CancellationTokenSource.CreateLinkedTokenSource( + this.CancellationToken, + cancellationToken + ); + return this._deserialize(cts.Token); + } +} + +public sealed class StreamingHttpResponse : HttpResponse +{ + readonly Func> _enumerate; + + internal StreamingHttpResponse( + Func> enumerate + ) + { + this._enumerate = enumerate; + } + + [SetsRequiredMembers] + internal StreamingHttpResponse( + HttpResponse response, + Func> enumerate + ) + : this(enumerate) + { + this.RawMessage = response.RawMessage; + this.CancellationToken = response.CancellationToken; + } + + public IAsyncEnumerable Enumerate(Threading::CancellationToken cancellationToken = default) + { + using var cts = Threading::CancellationTokenSource.CreateLinkedTokenSource( + this.CancellationToken, + cancellationToken + ); + return this._enumerate(cts.Token); + } +} diff --git a/src/ImageKit/Core/IPage.cs b/src/ImageKit/Core/IPage.cs new file mode 100644 index 00000000..3ebcacdb --- /dev/null +++ b/src/ImageKit/Core/IPage.cs @@ -0,0 +1,53 @@ +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using ImageKit.Exceptions; + +namespace ImageKit.Core; + +///

+/// An interface representing a single page, with items of type , from a +/// paginated endpoint response. +/// +public interface IPage +{ + /// + /// The items in this page. + /// + IReadOnlyList Items { get; } + + /// + /// Returns whether there's another page after this one. + /// + /// The method doesn't make requests so the result depends entirely on the + /// data in this page. If a significant amount of time has passed between requesting + /// this page and calling this method, then the result could be stale. + /// + bool HasNext(); + + /// + /// Returns the page after this one by making another request. + /// + /// + /// Thrown when it's impossible to get the next page. This exception is avoidable by calling + /// first. + /// + /// + Task> Next(CancellationToken cancellationToken = default); + + /// + /// Validates that the page was constructed with a valid response (based on its own + /// Validate method). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + void Validate(); + +#if NET + /// + public IAsyncEnumerable Paginate(CancellationToken cancellationToken = default) => + IPageExtensions.Paginate(this, cancellationToken); +#endif +} diff --git a/src/ImageKit/Core/JsonDictionary.cs b/src/ImageKit/Core/JsonDictionary.cs new file mode 100644 index 00000000..b6b16140 --- /dev/null +++ b/src/ImageKit/Core/JsonDictionary.cs @@ -0,0 +1,230 @@ +using System; +using System.Collections.Concurrent; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Linq; +using System.Text.Json; +using ImageKit.Exceptions; + +namespace ImageKit.Core; + +/// +/// A dictionary that holds JSON data. +/// +/// It can be mutated and then frozen once no more mutations are expected. This +/// is useful for allowing the dictionary to be modified by a class's init +/// properties, but then preventing it from being modified afterwards. +/// +/// It also caches data deserialization for performance. +/// +sealed class JsonDictionary +{ + IDictionary _rawData; + + readonly ConcurrentDictionary _deserializedData; + + Dictionary MutableRawData + { + get + { + if (_rawData is Dictionary dictionary) + { + return dictionary; + } + throw new InvalidOperationException("Can't mutate after freezing."); + } + } + + public JsonDictionary() + { + _rawData = new Dictionary(); + _deserializedData = []; + } + + public JsonDictionary(IReadOnlyDictionary dictionary) + { + _rawData = Enumerable.ToDictionary(dictionary, (e) => e.Key, (e) => e.Value); + _deserializedData = []; + } + + public JsonDictionary(FrozenDictionary dictionary) + { + _rawData = dictionary; + _deserializedData = []; + } + + public JsonDictionary(JsonDictionary dictionary) + { + _rawData = Enumerable.ToDictionary(dictionary._rawData, (e) => e.Key, (e) => e.Value); + _deserializedData = new(dictionary._deserializedData); + } + + /// + /// Freezes this dictionary and returns a readonly view of it. + /// + /// Future calls to mutating methods on this class will throw + /// . + /// + public IReadOnlyDictionary Freeze() + { + if (_rawData is FrozenDictionary dictionary) + { + return dictionary; + } + + var frozenRawData = FrozenDictionary.ToFrozenDictionary(_rawData); + _rawData = frozenRawData; + return frozenRawData; + } + + public void Set(string key, T value) + { + MutableRawData[key] = JsonSerializer.SerializeToElement(value, ModelBase.SerializerOptions); + _deserializedData[key] = value; + } + + public T GetNotNullClass(string key) + where T : class + { + if (_deserializedData.TryGetValue(key, out var cached) && cached is T t) + { + return t; + } + if (!_rawData.TryGetValue(key, out JsonElement element)) + { + throw new ImageKitInvalidDataException($"'{key}' cannot be absent"); + } + T deserialized; + try + { + deserialized = + JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ImageKitInvalidDataException($"'{key}' cannot be null"); + } + catch (JsonException e) + { + throw new ImageKitInvalidDataException( + $"'{key}' must be of type {typeof(T).FullName}", + e + ); + } + _deserializedData[key] = deserialized; + return deserialized; + } + + public T GetNotNullStruct(string key) + where T : struct + { + if (_deserializedData.TryGetValue(key, out var cached) && cached is T t) + { + return t; + } + if (!_rawData.TryGetValue(key, out JsonElement element)) + { + throw new ImageKitInvalidDataException($"'{key}' cannot be absent"); + } + T deserialized; + try + { + deserialized = + JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ImageKitInvalidDataException($"'{key}' cannot be null"); + } + catch (JsonException e) + { + throw new ImageKitInvalidDataException( + $"'{key}' must be of type {typeof(T).FullName}", + e + ); + } + _deserializedData[key] = deserialized; + return deserialized; + } + + public T? GetNullableClass(string key) + where T : class + { + if (_deserializedData.TryGetValue(key, out var cached) && (cached == null || cached is T)) + { + return (T?)cached; + } + if (!_rawData.TryGetValue(key, out JsonElement element)) + { + _deserializedData[key] = null; + return null; + } + T? deserialized; + try + { + deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + catch (JsonException e) + { + throw new ImageKitInvalidDataException( + $"'{key}' must be of type {typeof(T).FullName}", + e + ); + } + _deserializedData[key] = deserialized; + return deserialized; + } + + public T? GetNullableStruct(string key) + where T : struct + { + if (_deserializedData.TryGetValue(key, out var cached) && (cached == null || cached is T)) + { + return (T?)cached; + } + if (!_rawData.TryGetValue(key, out JsonElement element)) + { + _deserializedData[key] = null; + return null; + } + T? deserialized; + try + { + deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + catch (JsonException e) + { + throw new ImageKitInvalidDataException( + $"'{key}' must be of type {typeof(T).FullName}", + e + ); + } + _deserializedData[key] = deserialized; + return deserialized; + } + + public override string ToString() => + JsonSerializer.Serialize(this._rawData, ModelBase.ToStringSerializerOptions); + + public override bool Equals(object? obj) + { + if (obj is not JsonDictionary other || _rawData.Count != other._rawData.Count) + { + return false; + } + + foreach (var item in _rawData) + { + if (!other._rawData.TryGetValue(item.Key, out var otherValue)) + { + return false; + } + + if (!JsonElement.DeepEquals(item.Value, otherValue)) + { + return false; + } + } + + return true; + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/ImageKit/Core/JsonModel.cs b/src/ImageKit/Core/JsonModel.cs new file mode 100644 index 00000000..5655c971 --- /dev/null +++ b/src/ImageKit/Core/JsonModel.cs @@ -0,0 +1,65 @@ +using System.Collections.Generic; +using System.Text.Json; + +namespace ImageKit.Core; + +/// +/// The base class for all API objects that are serialized as JSON objects. +/// +/// API objects such as enums and unions do not inherit from this class. +/// +public abstract record class JsonModel : ModelBase +{ + private protected JsonDictionary _rawData = new(); + + /// + /// The backing JSON properties of the instance. + /// + public IReadOnlyDictionary RawData + { + get { return this._rawData.Freeze(); } + } + + protected JsonModel(JsonModel jsonModel) + : base(jsonModel) + { + this._rawData = new(jsonModel._rawData); + } + + public sealed override string ToString() => this._rawData.ToString(); + + public virtual bool Equals(JsonModel? other) + { + if (other == null) + { + return false; + } + + return this._rawData.Equals(other._rawData); + } + + public override int GetHashCode() => this._rawData.GetHashCode(); +} + +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking +/// changes in non-major versions. We may add new methods in the future that cause +/// existing derived classes to break. +/// +/// NOTE: This interface is in the style of a factory instance instead of using +/// abstract static methods because .NET Standard 2.0 doesn't support abstract static methods. +/// +interface IFromRawJson +{ + /// + /// Returns an instance constructed from the given raw JSON properties. + /// + /// Required field and type mismatches are not checked. In these cases accessing + /// the relevant properties of the constructed instance may throw. + /// + /// This method is useful for constructing an instance from already serialized + /// data or for sending arbitrary data to the API (e.g. for undocumented or not + /// yet supported properties or values). + /// + T FromRawUnchecked(IReadOnlyDictionary rawData); +} diff --git a/src/ImageKit/Core/JsonModelConverter.cs b/src/ImageKit/Core/JsonModelConverter.cs new file mode 100644 index 00000000..acb8ed50 --- /dev/null +++ b/src/ImageKit/Core/JsonModelConverter.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace ImageKit.Core; + +sealed class JsonModelConverter : JsonConverter + where TModel : JsonModel + where TFromRaw : IFromRawJson, new() +{ + public override TModel? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var rawData = JsonSerializer.Deserialize>( + ref reader, + options + ); + if (rawData == null) + return null; + + return new TFromRaw().FromRawUnchecked(rawData); + } + + public override void Write(Utf8JsonWriter writer, TModel value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.RawData, options); + } +} diff --git a/src/ImageKit/Core/ModelBase.cs b/src/ImageKit/Core/ModelBase.cs new file mode 100644 index 00000000..7cc9e272 --- /dev/null +++ b/src/ImageKit/Core/ModelBase.cs @@ -0,0 +1,180 @@ +using System.Text.Json; +using ImageKit.Exceptions; +using ImageKit.Models; +using ImageKit.Models.Cache.Invalidation; +using ImageKit.Models.CustomMetadataFields; +using Assets = ImageKit.Models.Assets; +using Files = ImageKit.Models.Files; +using Job = ImageKit.Models.Folders.Job; +using V2Files = ImageKit.Models.Beta.V2.Files; +using Webhooks = ImageKit.Models.Webhooks; + +namespace ImageKit.Core; + +/// +/// The base class for all API objects with properties. +/// +/// API objects such as enums do not inherit from this class. +/// +public abstract record class ModelBase +{ + protected ModelBase(ModelBase modelBase) + { + // Nothing to copy. Just so that subclasses can define copy constructors. + } + + internal static readonly JsonSerializerOptions SerializerOptions = new() + { + Converters = + { + new FrozenDictionaryConverterFactory(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter< + string, + Files::FileUploadResponseExtensionStatusAIAutoDescription + >(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter< + string, + Files::FileUploadResponseExtensionStatusGoogleAutoTagging + >(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter< + string, + Webhooks::UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType + >(), + new ApiEnumConverter< + string, + Webhooks::UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol + >(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter< + string, + Webhooks::VideoTransformationAcceptedEventIntersectionMember1DataTransformationType + >(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter< + string, + Webhooks::VideoTransformationErrorEventIntersectionMember1DataTransformationType + >(), + new ApiEnumConverter(), + new ApiEnumConverter< + string, + Webhooks::VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec + >(), + new ApiEnumConverter< + string, + Webhooks::VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat + >(), + new ApiEnumConverter< + string, + Webhooks::VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol + >(), + new ApiEnumConverter< + string, + Webhooks::VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec + >(), + new ApiEnumConverter< + string, + Webhooks::VideoTransformationReadyEventIntersectionMember1DataTransformationType + >(), + new ApiEnumConverter< + string, + Webhooks::VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec + >(), + new ApiEnumConverter< + string, + Webhooks::VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat + >(), + new ApiEnumConverter< + string, + Webhooks::VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol + >(), + new ApiEnumConverter< + string, + Webhooks::VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec + >(), + }, + }; + + internal static readonly JsonSerializerOptions ToStringSerializerOptions = new( + SerializerOptions + ) + { + WriteIndented = true, + }; + + /// + /// Validates that all required fields are set and that each field's value is of the expected type. + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public abstract void Validate(); +} diff --git a/src/ImageKit/Core/MultipartJsonDictionary.cs b/src/ImageKit/Core/MultipartJsonDictionary.cs new file mode 100644 index 00000000..7d75c5a7 --- /dev/null +++ b/src/ImageKit/Core/MultipartJsonDictionary.cs @@ -0,0 +1,208 @@ +using System; +using System.Collections.Concurrent; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Linq; +using System.Text.Json; +using ImageKit.Exceptions; + +namespace ImageKit.Core; + +/// +/// A dictionary that holds mixed JSON and binary content. +/// +/// It can be mutated and then frozen once no more mutations are expected. This +/// is useful for allowing the dictionary to be modified by a class's init +/// properties, but then preventing it from being modified afterwards. +/// +/// It also caches data deserialization for performance. +/// +sealed class MultipartJsonDictionary +{ + IDictionary _rawData; + + readonly ConcurrentDictionary _deserializedData; + + Dictionary MutableRawData + { + get + { + if (_rawData is Dictionary dictionary) + { + return dictionary; + } + throw new InvalidOperationException("Can't mutate after freezing."); + } + } + + public MultipartJsonDictionary() + { + _rawData = new Dictionary(); + _deserializedData = []; + } + + public MultipartJsonDictionary(IReadOnlyDictionary dictionary) + { + _rawData = Enumerable.ToDictionary(dictionary, (e) => e.Key, (e) => e.Value); + _deserializedData = []; + } + + public MultipartJsonDictionary(FrozenDictionary dictionary) + { + _rawData = dictionary; + _deserializedData = []; + } + + public MultipartJsonDictionary(MultipartJsonDictionary dictionary) + { + _rawData = Enumerable.ToDictionary(dictionary._rawData, (e) => e.Key, (e) => e.Value); + _deserializedData = new(dictionary._deserializedData); + } + + /// + /// Freezes this dictionary and returns a readonly view of it. + /// + /// Future calls to mutating methods on this class will throw + /// . + /// + public IReadOnlyDictionary Freeze() + { + if (_rawData is FrozenDictionary dictionary) + { + return dictionary; + } + + var frozenRawData = FrozenDictionary.ToFrozenDictionary(_rawData); + _rawData = frozenRawData; + return frozenRawData; + } + + public void Set(string key, T value) + { + MutableRawData[key] = MultipartJsonSerializer.SerializeToElement( + value, + ModelBase.SerializerOptions + ); + _deserializedData[key] = value; + } + + public T GetNotNullClass(string key) + where T : class + { + if (_deserializedData.TryGetValue(key, out var cached) && cached is T t) + { + return t; + } + if (!_rawData.TryGetValue(key, out MultipartJsonElement element)) + { + throw new ImageKitInvalidDataException($"'{key}' cannot be absent"); + } + T deserialized; + try + { + deserialized = + MultipartJsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ImageKitInvalidDataException($"'{key}' cannot be null"); + } + catch (JsonException e) + { + throw new ImageKitInvalidDataException( + $"'{key}' must be of type {typeof(T).FullName}", + e + ); + } + _deserializedData[key] = deserialized; + return deserialized; + } + + public T GetNotNullStruct(string key) + where T : struct + { + if (_deserializedData.TryGetValue(key, out var cached) && cached is T t) + { + return t; + } + if (!_rawData.TryGetValue(key, out MultipartJsonElement element)) + { + throw new ImageKitInvalidDataException($"'{key}' cannot be absent"); + } + T deserialized; + try + { + deserialized = + MultipartJsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ImageKitInvalidDataException($"'{key}' cannot be null"); + } + catch (JsonException e) + { + throw new ImageKitInvalidDataException( + $"'{key}' must be of type {typeof(T).FullName}", + e + ); + } + _deserializedData[key] = deserialized; + return deserialized; + } + + public T? GetNullableClass(string key) + where T : class + { + if (_deserializedData.TryGetValue(key, out var cached) && (cached == null || cached is T)) + { + return (T?)cached; + } + if (!_rawData.TryGetValue(key, out MultipartJsonElement element)) + { + _deserializedData[key] = null; + return null; + } + T? deserialized; + try + { + deserialized = MultipartJsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + catch (JsonException e) + { + throw new ImageKitInvalidDataException( + $"'{key}' must be of type {typeof(T).FullName}", + e + ); + } + _deserializedData[key] = deserialized; + return deserialized; + } + + public T? GetNullableStruct(string key) + where T : struct + { + if (_deserializedData.TryGetValue(key, out var cached) && (cached == null || cached is T)) + { + return (T?)cached; + } + if (!_rawData.TryGetValue(key, out MultipartJsonElement element)) + { + _deserializedData[key] = null; + return null; + } + T? deserialized; + try + { + deserialized = MultipartJsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + catch (JsonException e) + { + throw new ImageKitInvalidDataException( + $"'{key}' must be of type {typeof(T).FullName}", + e + ); + } + _deserializedData[key] = deserialized; + return deserialized; + } +} diff --git a/src/ImageKit/Core/MultipartJsonElement.cs b/src/ImageKit/Core/MultipartJsonElement.cs new file mode 100644 index 00000000..3884a1a9 --- /dev/null +++ b/src/ImageKit/Core/MultipartJsonElement.cs @@ -0,0 +1,293 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net.Http; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.Threading; + +namespace ImageKit.Core; + +/// +/// A that can contain . +/// +/// Use to construct or read instances of this class. +/// +public readonly struct MultipartJsonElement() +{ + /// + /// A with placeholders + /// for . + /// + internal JsonElement Json { get; init; } + + /// + /// A dictionary from placeholder string in the JSON to + /// . + /// + internal IReadOnlyDictionary BinaryContents { get; init; } = + FrozenDictionary.ToFrozenDictionary(new Dictionary()); + + public static implicit operator MultipartJsonElement(JsonElement json) => new() { Json = json }; +} + +/// +/// A serializer for mixed JSON and binary content. +/// +public static class MultipartJsonSerializer +{ + /// + /// The current dictionary from placeholder string to to use for + /// serialization/deserialization. + /// + /// This isn't a local variable because we want to share + /// for performance. It's also a thread local to avoid data races between threads. + /// + static readonly ThreadLocal?> CurrentBinaryContents = new(() => + null + ); + + internal static Dictionary BinaryContents + { + get + { + return CurrentBinaryContents.Value + ?? throw new InvalidOperationException( + "Cannot convert BinaryContent without MultipartJsonSerializer" + ); + } + } + + static readonly ThreadLocal< + Dictionary + > MultipartSerializerOptionsCache = new(() => []); + + static readonly JsonSerializerOptions DefaultMultipartSerializerOptions = + MultipartSerializerOptions(new()); + + static JsonSerializerOptions MultipartSerializerOptions(JsonSerializerOptions? options = null) + { + if (options == null) + { + return DefaultMultipartSerializerOptions; + } + + if (!MultipartSerializerOptionsCache.Value!.TryGetValue(options, out var multipartOptions)) + { + multipartOptions = new(options); + multipartOptions.Converters.Add(new BinaryContentConverter()); + multipartOptions.Converters.Add(new MultipartJsonElementConverter()); + MultipartSerializerOptionsCache.Value![options] = multipartOptions; + } + + return multipartOptions; + } + + public static MultipartJsonElement SerializeToElement( + T value, + JsonSerializerOptions? options = null + ) + { + var previousBinaryContents = CurrentBinaryContents.Value; + try + { + CurrentBinaryContents.Value = []; + var element = JsonSerializer.SerializeToElement( + value, + MultipartSerializerOptions(options) + ); + return new() + { + Json = element, + BinaryContents = FrozenDictionary.ToFrozenDictionary(CurrentBinaryContents.Value!), + }; + } + finally + { + CurrentBinaryContents.Value = previousBinaryContents; + } + } + + public static T? Deserialize( + MultipartJsonElement element, + JsonSerializerOptions? options = null + ) + { + var previousBinaryContents = CurrentBinaryContents.Value; + try + { + CurrentBinaryContents.Value = Enumerable.ToDictionary( + element.BinaryContents, + (e) => e.Key, + (e) => e.Value + ); + return JsonSerializer.Deserialize(element.Json, MultipartSerializerOptions(options)); + } + finally + { + CurrentBinaryContents.Value = previousBinaryContents; + } + } + + public static MultipartFormDataContent Serialize( + T value, + JsonSerializerOptions? options = null + ) + { + MultipartFormDataContent formDataContent = []; + var multipartElement = MultipartJsonSerializer.SerializeToElement(value, options); + void SerializeParts(string name, JsonElement element) + { + HttpContent content; + string? fileName = null; + switch (element.ValueKind) + { + case JsonValueKind.Undefined: + case JsonValueKind.Null: + return; + case JsonValueKind.Number: + content = new StringContent(element.ToString()); + break; + case JsonValueKind.String: + if ( + element.TryGetGuid(out var guid) + && multipartElement.BinaryContents.TryGetValue(guid, out var binaryContent) + ) + { + content = new StreamContent(binaryContent.Stream); + content.Headers.ContentType = binaryContent.ContentType; + fileName = binaryContent.FileName; + } + else + { + content = new StringContent(element.ToString()); + } + break; + case JsonValueKind.True: + content = new StringContent("true"); + break; + case JsonValueKind.False: + content = new StringContent("false"); + break; + case JsonValueKind.Object: + foreach (var item in element.EnumerateObject()) + { + SerializeParts( + name == "" ? item.Name : string.Format("{0}[{1}]", name, item.Name), + item.Value + ); + } + return; + case JsonValueKind.Array: + content = new StringContent( + string.Join( + ",", + Enumerable.Select( + element.EnumerateArray(), + item => + item.ValueKind switch + { + JsonValueKind.Undefined or JsonValueKind.Null => "", + JsonValueKind.Number => item.GetString(), + JsonValueKind.True => "true", + JsonValueKind.False => "false", + JsonValueKind.String => item.TryGetGuid(out var guid1) + && multipartElement.BinaryContents.TryGetValue(guid1, out _) + ? throw new InvalidDataException( + "Unexpected binary content in array" + ) + : item.GetString(), + _ => throw new InvalidDataException( + "Unexpected element type in array" + ), + } + ) + ) + ); + break; + default: + throw new ArgumentOutOfRangeException(nameof(element)); + } + if (name == "") + { + formDataContent.Add(content); + } + else if (fileName == null) + { + formDataContent.Add(content, name); + } + else + { + formDataContent.Add(content, name, fileName); + } + } + SerializeParts("", multipartElement.Json); + return formDataContent; + } +} + +/// +/// A JSON converter that serializes/deserializes mixed JSON and binary content. +/// +/// It uses placeholder IDs (see ), which are written/read +/// to/from a thread-local dictionary, so it's expected that this converter is only invoked via +/// , which ensures the dictionary is set up correctly. +/// +sealed class MultipartJsonElementConverter : JsonConverter +{ + public override MultipartJsonElement Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) => + new() + { + Json = JsonSerializer.Deserialize(ref reader, options), + BinaryContents = MultipartJsonSerializer.BinaryContents, + }; + + public override void Write( + Utf8JsonWriter writer, + MultipartJsonElement value, + JsonSerializerOptions options + ) + { + foreach (var item in value.BinaryContents) + { + MultipartJsonSerializer.BinaryContents.Add(item.Key, item.Value); + } + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +/// +/// A JSON converter that serializes/deserializes binary content to/from placeholder IDs. +/// +/// The placeholder IDs are written/read to/from a thread-local dictionary, so it's expected that +/// this converter is only invoked via , which ensures the +/// dictionary is set up correctly. +/// +sealed class BinaryContentConverter : JsonConverter +{ + public override BinaryContent Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) => + MultipartJsonSerializer.BinaryContents[ + JsonSerializer.Deserialize(ref reader, options) + ]; + + public override void Write( + Utf8JsonWriter writer, + BinaryContent value, + JsonSerializerOptions options + ) + { + var guid = Guid.NewGuid(); + MultipartJsonSerializer.BinaryContents[guid] = value; + JsonSerializer.Serialize(writer, guid, options); + } +} diff --git a/src/ImageKit/Core/MultipartJsonModel.cs b/src/ImageKit/Core/MultipartJsonModel.cs new file mode 100644 index 00000000..653ca580 --- /dev/null +++ b/src/ImageKit/Core/MultipartJsonModel.cs @@ -0,0 +1,56 @@ +using System.Collections.Generic; + +namespace ImageKit.Core; + +/// +/// The base class for all API objects that are serialized as a mix of JSON objects +/// and binary content. +/// +/// API objects such as enums and unions do not inherit from this class. +/// +public abstract record class MultipartJsonModel : ModelBase +{ + private protected MultipartJsonDictionary _rawData = new(); + + protected MultipartJsonModel(MultipartJsonModel jsonModel) + : base(jsonModel) + { + this._rawData = new(jsonModel._rawData); + } + + /// + /// The backing mix of JSON and binary content properties of the instance. + /// + public IReadOnlyDictionary RawData + { + get { return this._rawData.Freeze(); } + } + + public override int GetHashCode() + { + return 0; + } +} + +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking +/// changes in non-major versions. We may add new methods in the future that cause +/// existing derived classes to break. +/// +/// NOTE: This interface is in the style of a factory instance instead of using +/// abstract static methods because .NET Standard 2.0 doesn't support abstract static methods. +/// +interface IFromRawMultipartJson +{ + /// + /// Returns an instance constructed from the given raw JSON properties. + /// + /// Required field and type mismatches are not checked. In these cases accessing + /// the relevant properties of the constructed instance may throw. + /// + /// This method is useful for constructing an instance from already serialized + /// data or for sending arbitrary data to the API (e.g. for undocumented or not + /// yet supported properties or values). + /// + T FromRawUnchecked(IReadOnlyDictionary rawData); +} diff --git a/src/ImageKit/Core/MultipartJsonModelConverter.cs b/src/ImageKit/Core/MultipartJsonModelConverter.cs new file mode 100644 index 00000000..c439d05f --- /dev/null +++ b/src/ImageKit/Core/MultipartJsonModelConverter.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace ImageKit.Core; + +sealed class MultipartJsonModelConverter : JsonConverter + where TModel : MultipartJsonModel + where TFromRaw : IFromRawMultipartJson, new() +{ + public override TModel? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var rawData = JsonSerializer.Deserialize>( + ref reader, + options + ); + if (rawData == null) + return null; + + return new TFromRaw().FromRawUnchecked(rawData); + } + + public override void Write(Utf8JsonWriter writer, TModel value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.RawData, options); + } +} diff --git a/src/Imagekit/Core/ParamsBase.cs b/src/ImageKit/Core/ParamsBase.cs similarity index 51% rename from src/Imagekit/Core/ParamsBase.cs rename to src/ImageKit/Core/ParamsBase.cs index 5e15b725..9173f70b 100644 --- a/src/Imagekit/Core/ParamsBase.cs +++ b/src/ImageKit/Core/ParamsBase.cs @@ -3,19 +3,54 @@ using System.Collections.Specialized; using System.Linq; using System.Net.Http; +using System.Reflection; +using System.Runtime.InteropServices; using System.Text; using System.Text.Json; -using Web = System.Web; +using System.Web; -namespace Imagekit.Core; +namespace ImageKit.Core; public abstract record class ParamsBase { - public Dictionary QueryProperties { get; set; } = []; + static readonly IReadOnlyDictionary defaultHeaders; - public Dictionary HeaderProperties { get; set; } = []; + static ParamsBase() + { + var runtime = GetRuntime(); + defaultHeaders = new Dictionary + { + ["User-Agent"] = GetUserAgent(), + ["X-Stainless-Arch"] = GetOSArch(), + ["X-Stainless-Lang"] = "csharp", + ["X-Stainless-OS"] = GetOS(), + ["X-Stainless-Package-Version"] = GetPackageVersion(), + ["X-Stainless-Runtime"] = runtime.Name, + ["X-Stainless-Runtime-Version"] = runtime.Version, + }; + } + + private protected JsonDictionary _rawQueryData = new(); + + private protected JsonDictionary _rawHeaderData = new(); - public abstract Uri Url(IImageKitClient client); + protected ParamsBase(ParamsBase paramsBase) + { + this._rawHeaderData = new(paramsBase._rawHeaderData); + this._rawQueryData = new(paramsBase._rawQueryData); + } + + public IReadOnlyDictionary RawQueryData + { + get { return this._rawQueryData.Freeze(); } + } + + public IReadOnlyDictionary RawHeaderData + { + get { return this._rawHeaderData.Freeze(); } + } + + public abstract Uri Url(ClientOptions options); protected static void AddQueryElementToCollection( NameValueCollection collection, @@ -121,10 +156,10 @@ JsonElement element } } - protected string QueryString(IImageKitClient client) + internal string QueryString(ClientOptions options) { NameValueCollection collection = []; - foreach (var item in this.QueryProperties) + foreach (var item in this.RawQueryData) { ParamsBase.AddQueryElementToCollection(collection, item.Key, item.Value); } @@ -139,24 +174,29 @@ protected string QueryString(IImageKitClient client) sb.Append('&'); } first = false; - sb.Append(Web::HttpUtility.UrlEncode(key)); + sb.Append(HttpUtility.UrlEncode(key)); sb.Append('='); - sb.Append(Web::HttpUtility.UrlEncode(value)); + sb.Append(HttpUtility.UrlEncode(value)); } } return sb.ToString(); } - internal abstract void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client); + internal abstract void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options); - internal virtual StringContent? BodyContent() + internal virtual HttpContent? BodyContent() { return null; } - protected static void AddDefaultHeaders(HttpRequestMessage request, IImageKitClient client) + internal static void AddDefaultHeaders(HttpRequestMessage request, ClientOptions options) { - if (client.PrivateKey != null && client.Password != null) + foreach (var header in defaultHeaders) + { + request.Headers.Add(header.Key, header.Value); + } + + if (options.PrivateKey != null && options.Password != null) { request.Headers.Add( "Authorization", @@ -165,10 +205,79 @@ protected static void AddDefaultHeaders(HttpRequestMessage request, IImageKitCli Convert.ToBase64String( Encoding .GetEncoding("ISO-8859-1") - .GetBytes(string.Format("{0}:{1}", client.PrivateKey, client.Password)) + .GetBytes( + string.Format("{0}:{1}", options.PrivateKey, options.Password) + ) ) ) ); } + request.Headers.Add( + "X-Stainless-Timeout", + (options.Timeout ?? ClientOptions.DefaultTimeout).TotalSeconds.ToString() + ); + } + + static string GetUserAgent() => $"{typeof(ImageKitClient).Name}/C# {GetPackageVersion()}"; + + static string GetOSArch() => + RuntimeInformation.OSArchitecture switch + { + Architecture.X86 => "x32", + Architecture.X64 => "x64", + Architecture.Arm => "arm", + Architecture.Arm64 => "arm64", +#if !NETSTANDARD2_0 + Architecture.Armv6 => "arm64", + Architecture.Wasm + or Architecture.S390x + or Architecture.LoongArch64 + or Architecture.Ppc64le => $"other:{RuntimeInformation.OSArchitecture}", +#endif + _ => "unknown", + }; + + static string GetOS() + { + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + return "Windows"; + } + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + return "MacOS"; + } + if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + { + return "Linux"; + } + return $"Other:{RuntimeInformation.OSDescription}"; } + + static string GetPackageVersion() => + Assembly + .GetExecutingAssembly() + .GetCustomAttribute() + ?.InformationalVersion + ?? "unknown"; + + static Runtime GetRuntime() + { + var runtimeDescription = RuntimeInformation.FrameworkDescription; + var lastSpaceIndex = runtimeDescription.LastIndexOf(' '); + if (lastSpaceIndex == -1) + { + return new() { Name = runtimeDescription, Version = "unknown" }; + } + + var name = runtimeDescription.Substring(0, lastSpaceIndex).Trim(); + var version = runtimeDescription.Substring(lastSpaceIndex + 1).Trim(); + return new() + { + Name = name.Length == 0 ? "unknown" : name, + Version = version.Length == 0 ? "unknown" : version, + }; + } + + readonly record struct Runtime(string Name, string Version); } diff --git a/src/Imagekit/Exceptions/ImageKit4xxException.cs b/src/ImageKit/Exceptions/ImageKit4xxException.cs similarity index 83% rename from src/Imagekit/Exceptions/ImageKit4xxException.cs rename to src/ImageKit/Exceptions/ImageKit4xxException.cs index fb904eee..a331b083 100644 --- a/src/Imagekit/Exceptions/ImageKit4xxException.cs +++ b/src/ImageKit/Exceptions/ImageKit4xxException.cs @@ -1,6 +1,6 @@ using System.Net.Http; -namespace Imagekit.Exceptions; +namespace ImageKit.Exceptions; public class ImageKit4xxException : ImageKitApiException { diff --git a/src/Imagekit/Exceptions/ImageKit5xxException.cs b/src/ImageKit/Exceptions/ImageKit5xxException.cs similarity index 83% rename from src/Imagekit/Exceptions/ImageKit5xxException.cs rename to src/ImageKit/Exceptions/ImageKit5xxException.cs index 5c3bf57b..ee25a2fb 100644 --- a/src/Imagekit/Exceptions/ImageKit5xxException.cs +++ b/src/ImageKit/Exceptions/ImageKit5xxException.cs @@ -1,6 +1,6 @@ using System.Net.Http; -namespace Imagekit.Exceptions; +namespace ImageKit.Exceptions; public class ImageKit5xxException : ImageKitApiException { diff --git a/src/Imagekit/Exceptions/ImageKitApiException.cs b/src/ImageKit/Exceptions/ImageKitApiException.cs similarity index 93% rename from src/Imagekit/Exceptions/ImageKitApiException.cs rename to src/ImageKit/Exceptions/ImageKitApiException.cs index 9ff6b86b..b9ddce4e 100644 --- a/src/Imagekit/Exceptions/ImageKitApiException.cs +++ b/src/ImageKit/Exceptions/ImageKitApiException.cs @@ -2,7 +2,7 @@ using System.Net; using System.Net.Http; -namespace Imagekit.Exceptions; +namespace ImageKit.Exceptions; public class ImageKitApiException : ImageKitException { diff --git a/src/Imagekit/Exceptions/ImageKitBadRequestException.cs b/src/ImageKit/Exceptions/ImageKitBadRequestException.cs similarity index 84% rename from src/Imagekit/Exceptions/ImageKitBadRequestException.cs rename to src/ImageKit/Exceptions/ImageKitBadRequestException.cs index 5c95d8d4..31948462 100644 --- a/src/Imagekit/Exceptions/ImageKitBadRequestException.cs +++ b/src/ImageKit/Exceptions/ImageKitBadRequestException.cs @@ -1,6 +1,6 @@ using System.Net.Http; -namespace Imagekit.Exceptions; +namespace ImageKit.Exceptions; public class ImageKitBadRequestException : ImageKit4xxException { diff --git a/src/Imagekit/Exceptions/ImageKitException.cs b/src/ImageKit/Exceptions/ImageKitException.cs similarity index 87% rename from src/Imagekit/Exceptions/ImageKitException.cs rename to src/ImageKit/Exceptions/ImageKitException.cs index bf964025..10e2743c 100644 --- a/src/Imagekit/Exceptions/ImageKitException.cs +++ b/src/ImageKit/Exceptions/ImageKitException.cs @@ -1,7 +1,7 @@ using System; using System.Net.Http; -namespace Imagekit.Exceptions; +namespace ImageKit.Exceptions; public class ImageKitException : Exception { diff --git a/src/Imagekit/Exceptions/ImageKitExceptionFactory.cs b/src/ImageKit/Exceptions/ImageKitExceptionFactory.cs similarity index 95% rename from src/Imagekit/Exceptions/ImageKitExceptionFactory.cs rename to src/ImageKit/Exceptions/ImageKitExceptionFactory.cs index 768f05e5..88c167e2 100644 --- a/src/Imagekit/Exceptions/ImageKitExceptionFactory.cs +++ b/src/ImageKit/Exceptions/ImageKitExceptionFactory.cs @@ -1,6 +1,6 @@ using System.Net; -namespace Imagekit.Exceptions; +namespace ImageKit.Exceptions; public class ImageKitExceptionFactory { diff --git a/src/Imagekit/Exceptions/ImageKitForbiddenException.cs b/src/ImageKit/Exceptions/ImageKitForbiddenException.cs similarity index 84% rename from src/Imagekit/Exceptions/ImageKitForbiddenException.cs rename to src/ImageKit/Exceptions/ImageKitForbiddenException.cs index fbd39380..511d899d 100644 --- a/src/Imagekit/Exceptions/ImageKitForbiddenException.cs +++ b/src/ImageKit/Exceptions/ImageKitForbiddenException.cs @@ -1,6 +1,6 @@ using System.Net.Http; -namespace Imagekit.Exceptions; +namespace ImageKit.Exceptions; public class ImageKitForbiddenException : ImageKit4xxException { diff --git a/src/Imagekit/Exceptions/ImageKitIOException.cs b/src/ImageKit/Exceptions/ImageKitIOException.cs similarity index 90% rename from src/Imagekit/Exceptions/ImageKitIOException.cs rename to src/ImageKit/Exceptions/ImageKitIOException.cs index bcfb380a..82ca6b37 100644 --- a/src/Imagekit/Exceptions/ImageKitIOException.cs +++ b/src/ImageKit/Exceptions/ImageKitIOException.cs @@ -1,7 +1,7 @@ using System; using System.Net.Http; -namespace Imagekit.Exceptions; +namespace ImageKit.Exceptions; public class ImageKitIOException : ImageKitException { diff --git a/src/Imagekit/Exceptions/ImageKitInvalidDataException.cs b/src/ImageKit/Exceptions/ImageKitInvalidDataException.cs similarity index 84% rename from src/Imagekit/Exceptions/ImageKitInvalidDataException.cs rename to src/ImageKit/Exceptions/ImageKitInvalidDataException.cs index eda54a08..d63552b6 100644 --- a/src/Imagekit/Exceptions/ImageKitInvalidDataException.cs +++ b/src/ImageKit/Exceptions/ImageKitInvalidDataException.cs @@ -1,6 +1,6 @@ using System; -namespace Imagekit.Exceptions; +namespace ImageKit.Exceptions; public class ImageKitInvalidDataException : ImageKitException { diff --git a/src/Imagekit/Exceptions/ImageKitNotFoundException.cs b/src/ImageKit/Exceptions/ImageKitNotFoundException.cs similarity index 83% rename from src/Imagekit/Exceptions/ImageKitNotFoundException.cs rename to src/ImageKit/Exceptions/ImageKitNotFoundException.cs index 70c81820..43369339 100644 --- a/src/Imagekit/Exceptions/ImageKitNotFoundException.cs +++ b/src/ImageKit/Exceptions/ImageKitNotFoundException.cs @@ -1,6 +1,6 @@ using System.Net.Http; -namespace Imagekit.Exceptions; +namespace ImageKit.Exceptions; public class ImageKitNotFoundException : ImageKit4xxException { diff --git a/src/Imagekit/Exceptions/ImageKitRateLimitException.cs b/src/ImageKit/Exceptions/ImageKitRateLimitException.cs similarity index 84% rename from src/Imagekit/Exceptions/ImageKitRateLimitException.cs rename to src/ImageKit/Exceptions/ImageKitRateLimitException.cs index b93fe95a..921e8a8b 100644 --- a/src/Imagekit/Exceptions/ImageKitRateLimitException.cs +++ b/src/ImageKit/Exceptions/ImageKitRateLimitException.cs @@ -1,6 +1,6 @@ using System.Net.Http; -namespace Imagekit.Exceptions; +namespace ImageKit.Exceptions; public class ImageKitRateLimitException : ImageKit4xxException { diff --git a/src/Imagekit/Exceptions/ImageKitUnauthorizedException.cs b/src/ImageKit/Exceptions/ImageKitUnauthorizedException.cs similarity index 84% rename from src/Imagekit/Exceptions/ImageKitUnauthorizedException.cs rename to src/ImageKit/Exceptions/ImageKitUnauthorizedException.cs index 0d360cc0..acb82679 100644 --- a/src/Imagekit/Exceptions/ImageKitUnauthorizedException.cs +++ b/src/ImageKit/Exceptions/ImageKitUnauthorizedException.cs @@ -1,6 +1,6 @@ using System.Net.Http; -namespace Imagekit.Exceptions; +namespace ImageKit.Exceptions; public class ImageKitUnauthorizedException : ImageKit4xxException { diff --git a/src/Imagekit/Exceptions/ImageKitUnexpectedStatusCodeException.cs b/src/ImageKit/Exceptions/ImageKitUnexpectedStatusCodeException.cs similarity index 85% rename from src/Imagekit/Exceptions/ImageKitUnexpectedStatusCodeException.cs rename to src/ImageKit/Exceptions/ImageKitUnexpectedStatusCodeException.cs index 155b0053..a0b0a24b 100644 --- a/src/Imagekit/Exceptions/ImageKitUnexpectedStatusCodeException.cs +++ b/src/ImageKit/Exceptions/ImageKitUnexpectedStatusCodeException.cs @@ -1,6 +1,6 @@ using System.Net.Http; -namespace Imagekit.Exceptions; +namespace ImageKit.Exceptions; public class ImageKitUnexpectedStatusCodeException : ImageKitApiException { diff --git a/src/Imagekit/Exceptions/ImageKitUnprocessableEntityException.cs b/src/ImageKit/Exceptions/ImageKitUnprocessableEntityException.cs similarity index 85% rename from src/Imagekit/Exceptions/ImageKitUnprocessableEntityException.cs rename to src/ImageKit/Exceptions/ImageKitUnprocessableEntityException.cs index bc4d6cb8..b4cb9bd1 100644 --- a/src/Imagekit/Exceptions/ImageKitUnprocessableEntityException.cs +++ b/src/ImageKit/Exceptions/ImageKitUnprocessableEntityException.cs @@ -1,6 +1,6 @@ using System.Net.Http; -namespace Imagekit.Exceptions; +namespace ImageKit.Exceptions; public class ImageKitUnprocessableEntityException : ImageKit4xxException { diff --git a/src/ImageKit/IImageKitClient.cs b/src/ImageKit/IImageKitClient.cs new file mode 100644 index 00000000..161fe068 --- /dev/null +++ b/src/ImageKit/IImageKitClient.cs @@ -0,0 +1,162 @@ +using System; +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; +using ImageKit.Core; +using ImageKit.Services; + +namespace ImageKit; + +/// +/// A client for interacting with the Image Kit REST API. +/// +/// This client performs best when you create a single instance and reuse it +/// for all interactions with the REST API. This is because each client holds its +/// own connection pool and thread pools. Reusing connections and threads reduces +/// latency and saves memory. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public interface IImageKitClient : IDisposable +{ + /// + HttpClient HttpClient { get; init; } + + /// + string BaseUrl { get; init; } + + /// + bool ResponseValidation { get; init; } + + /// + int? MaxRetries { get; init; } + + /// + TimeSpan? Timeout { get; init; } + + /// + /// Your ImageKit private API key (starts with `private_`). You can find this + /// in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/api-keys). + /// + string PrivateKey { get; init; } + + /// + /// ImageKit uses your API key as username and ignores the password. The SDK + /// sets a dummy value. You can ignore this field. + /// + string? Password { get; init; } + + /// + /// Your ImageKit webhook secret for verifying webhook signatures (starts with + /// `whsec_`). You can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks). + /// Only required if you're using webhooks. + /// + string? WebhookSecret { get; init; } + + /// + /// Returns a view of this service that provides access to raw HTTP responses + /// for each method. + /// + IImageKitClientWithRawResponse WithRawResponse { get; } + + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + IImageKitClient WithOptions(Func modifier); + + ICustomMetadataFieldService CustomMetadataFields { get; } + + IFileService Files { get; } + + ISavedExtensionService SavedExtensions { get; } + + IAssetService Assets { get; } + + ICacheService Cache { get; } + + IFolderService Folders { get; } + + IAccountService Accounts { get; } + + IBetaService Beta { get; } + + IWebhookService Webhooks { get; } +} + +/// +/// A view of that provides access to raw HTTP responses for each method. +/// +public interface IImageKitClientWithRawResponse : IDisposable +{ + /// + HttpClient HttpClient { get; init; } + + /// + string BaseUrl { get; init; } + + /// + bool ResponseValidation { get; init; } + + /// + int? MaxRetries { get; init; } + + /// + TimeSpan? Timeout { get; init; } + + /// + /// Your ImageKit private API key (starts with `private_`). You can find this + /// in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/api-keys). + /// + string PrivateKey { get; init; } + + /// + /// ImageKit uses your API key as username and ignores the password. The SDK + /// sets a dummy value. You can ignore this field. + /// + string? Password { get; init; } + + /// + /// Your ImageKit webhook secret for verifying webhook signatures (starts with + /// `whsec_`). You can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks). + /// Only required if you're using webhooks. + /// + string? WebhookSecret { get; init; } + + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + IImageKitClientWithRawResponse WithOptions(Func modifier); + + ICustomMetadataFieldServiceWithRawResponse CustomMetadataFields { get; } + + IFileServiceWithRawResponse Files { get; } + + ISavedExtensionServiceWithRawResponse SavedExtensions { get; } + + IAssetServiceWithRawResponse Assets { get; } + + ICacheServiceWithRawResponse Cache { get; } + + IFolderServiceWithRawResponse Folders { get; } + + IAccountServiceWithRawResponse Accounts { get; } + + IBetaServiceWithRawResponse Beta { get; } + + IWebhookServiceWithRawResponse Webhooks { get; } + + /// + /// Sends a request to the Image Kit REST API. + /// + Task Execute( + HttpRequest request, + CancellationToken cancellationToken = default + ) + where T : ParamsBase; +} diff --git a/src/ImageKit/IPageExtensions.cs b/src/ImageKit/IPageExtensions.cs new file mode 100644 index 00000000..50e2a12c --- /dev/null +++ b/src/ImageKit/IPageExtensions.cs @@ -0,0 +1,33 @@ +using System.Collections.Generic; +using System.Runtime.CompilerServices; +using System.Threading; +using ImageKit.Core; + +namespace ImageKit; + +public static class IPageExtensions +{ + /// + /// Returns a lazy async enumerable that auto-paginates by yielding the given + /// page's data and then requesting and yielding additional pages from the API. + /// + public static async IAsyncEnumerable Paginate( + this IPage page, + [EnumeratorCancellation] CancellationToken cancellationToken = default + ) + { + while (true) + { + foreach (var element in page.Items) + { + yield return element; + } + cancellationToken.ThrowIfCancellationRequested(); + if (!page.HasNext()) + { + break; + } + page = await page.Next(cancellationToken); + } + } +} diff --git a/src/ImageKit/ImageKit.csproj b/src/ImageKit/ImageKit.csproj new file mode 100644 index 00000000..9252fc47 --- /dev/null +++ b/src/ImageKit/ImageKit.csproj @@ -0,0 +1,20 @@ + + + + Image Kit C# + ImageKit + 0.0.1 + The official .NET library for the Image Kit API. + Library + README.md + + + + + + + + + + + \ No newline at end of file diff --git a/src/ImageKit/ImageKitClient.cs b/src/ImageKit/ImageKitClient.cs new file mode 100644 index 00000000..58b2634c --- /dev/null +++ b/src/ImageKit/ImageKitClient.cs @@ -0,0 +1,512 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; +using ImageKit.Core; +using ImageKit.Exceptions; +using ImageKit.Services; + +namespace ImageKit; + +/// +public sealed class ImageKitClient : IImageKitClient +{ + readonly ClientOptions _options; + + /// + public HttpClient HttpClient + { + get { return this._options.HttpClient; } + init { this._options.HttpClient = value; } + } + + /// + public string BaseUrl + { + get { return this._options.BaseUrl; } + init { this._options.BaseUrl = value; } + } + + /// + public bool ResponseValidation + { + get { return this._options.ResponseValidation; } + init { this._options.ResponseValidation = value; } + } + + /// + public int? MaxRetries + { + get { return this._options.MaxRetries; } + init { this._options.MaxRetries = value; } + } + + /// + public TimeSpan? Timeout + { + get { return this._options.Timeout; } + init { this._options.Timeout = value; } + } + + /// + public string PrivateKey + { + get { return this._options.PrivateKey; } + init { this._options.PrivateKey = value; } + } + + /// + public string? Password + { + get { return this._options.Password; } + init { this._options.Password = value; } + } + + /// + public string? WebhookSecret + { + get { return this._options.WebhookSecret; } + init { this._options.WebhookSecret = value; } + } + + readonly Lazy _withRawResponse; + + /// + public IImageKitClientWithRawResponse WithRawResponse + { + get { return _withRawResponse.Value; } + } + + /// + public IImageKitClient WithOptions(Func modifier) + { + return new ImageKitClient(modifier(this._options)); + } + + readonly Lazy _customMetadataFields; + public ICustomMetadataFieldService CustomMetadataFields + { + get { return _customMetadataFields.Value; } + } + + readonly Lazy _files; + public IFileService Files + { + get { return _files.Value; } + } + + readonly Lazy _savedExtensions; + public ISavedExtensionService SavedExtensions + { + get { return _savedExtensions.Value; } + } + + readonly Lazy _assets; + public IAssetService Assets + { + get { return _assets.Value; } + } + + readonly Lazy _cache; + public ICacheService Cache + { + get { return _cache.Value; } + } + + readonly Lazy _folders; + public IFolderService Folders + { + get { return _folders.Value; } + } + + readonly Lazy _accounts; + public IAccountService Accounts + { + get { return _accounts.Value; } + } + + readonly Lazy _beta; + public IBetaService Beta + { + get { return _beta.Value; } + } + + readonly Lazy _webhooks; + public IWebhookService Webhooks + { + get { return _webhooks.Value; } + } + + public void Dispose() => this.HttpClient.Dispose(); + + public ImageKitClient() + { + _options = new(); + + _withRawResponse = new(() => new ImageKitClientWithRawResponse(this._options)); + _customMetadataFields = new(() => new CustomMetadataFieldService(this)); + _files = new(() => new FileService(this)); + _savedExtensions = new(() => new SavedExtensionService(this)); + _assets = new(() => new AssetService(this)); + _cache = new(() => new CacheService(this)); + _folders = new(() => new FolderService(this)); + _accounts = new(() => new AccountService(this)); + _beta = new(() => new BetaService(this)); + _webhooks = new(() => new WebhookService(this)); + } + + public ImageKitClient(ClientOptions options) + : this() + { + _options = options; + } +} + +/// +public sealed class ImageKitClientWithRawResponse : IImageKitClientWithRawResponse +{ +#if NET + static readonly Random Random = Random.Shared; +#else + static readonly ThreadLocal _threadLocalRandom = new(() => new Random()); + + static Random Random + { + get { return _threadLocalRandom.Value!; } + } +#endif + + internal static HttpMethod PatchMethod = new("PATCH"); + + readonly ClientOptions _options; + + /// + public HttpClient HttpClient + { + get { return this._options.HttpClient; } + init { this._options.HttpClient = value; } + } + + /// + public string BaseUrl + { + get { return this._options.BaseUrl; } + init { this._options.BaseUrl = value; } + } + + /// + public bool ResponseValidation + { + get { return this._options.ResponseValidation; } + init { this._options.ResponseValidation = value; } + } + + /// + public int? MaxRetries + { + get { return this._options.MaxRetries; } + init { this._options.MaxRetries = value; } + } + + /// + public TimeSpan? Timeout + { + get { return this._options.Timeout; } + init { this._options.Timeout = value; } + } + + /// + public string PrivateKey + { + get { return this._options.PrivateKey; } + init { this._options.PrivateKey = value; } + } + + /// + public string? Password + { + get { return this._options.Password; } + init { this._options.Password = value; } + } + + /// + public string? WebhookSecret + { + get { return this._options.WebhookSecret; } + init { this._options.WebhookSecret = value; } + } + + /// + public IImageKitClientWithRawResponse WithOptions(Func modifier) + { + return new ImageKitClientWithRawResponse(modifier(this._options)); + } + + readonly Lazy _customMetadataFields; + public ICustomMetadataFieldServiceWithRawResponse CustomMetadataFields + { + get { return _customMetadataFields.Value; } + } + + readonly Lazy _files; + public IFileServiceWithRawResponse Files + { + get { return _files.Value; } + } + + readonly Lazy _savedExtensions; + public ISavedExtensionServiceWithRawResponse SavedExtensions + { + get { return _savedExtensions.Value; } + } + + readonly Lazy _assets; + public IAssetServiceWithRawResponse Assets + { + get { return _assets.Value; } + } + + readonly Lazy _cache; + public ICacheServiceWithRawResponse Cache + { + get { return _cache.Value; } + } + + readonly Lazy _folders; + public IFolderServiceWithRawResponse Folders + { + get { return _folders.Value; } + } + + readonly Lazy _accounts; + public IAccountServiceWithRawResponse Accounts + { + get { return _accounts.Value; } + } + + readonly Lazy _beta; + public IBetaServiceWithRawResponse Beta + { + get { return _beta.Value; } + } + + readonly Lazy _webhooks; + public IWebhookServiceWithRawResponse Webhooks + { + get { return _webhooks.Value; } + } + + /// + public async Task Execute( + HttpRequest request, + CancellationToken cancellationToken = default + ) + where T : ParamsBase + { + var maxRetries = this.MaxRetries ?? ClientOptions.DefaultMaxRetries; + var retries = 0; + while (true) + { + HttpResponse? response = null; + try + { + response = await ExecuteOnce(request, retries, cancellationToken) + .ConfigureAwait(false); + } + catch (Exception e) + { + if (++retries > maxRetries || !ShouldRetry(e)) + { + throw; + } + } + + if (response != null && (++retries > maxRetries || !ShouldRetry(response))) + { + if (response.IsSuccessStatusCode) + { + return response; + } + + try + { + throw ImageKitExceptionFactory.CreateApiException( + response.StatusCode, + await response.ReadAsString(cancellationToken).ConfigureAwait(false) + ); + } + catch (HttpRequestException e) + { + throw new ImageKitIOException("I/O Exception", e); + } + finally + { + response.Dispose(); + } + } + + var backoff = ComputeRetryBackoff(retries, response); + response?.Dispose(); + await Task.Delay(backoff, cancellationToken).ConfigureAwait(false); + } + } + + async Task ExecuteOnce( + HttpRequest request, + int retryCount, + CancellationToken cancellationToken = default + ) + where T : ParamsBase + { + using HttpRequestMessage requestMessage = new( + request.Method, + request.Params.Url(this._options) + ) + { + Content = request.Params.BodyContent(), + }; + request.Params.AddHeadersToRequest(requestMessage, this._options); + if (!requestMessage.Headers.Contains("x-stainless-retry-count")) + { + requestMessage.Headers.Add("x-stainless-retry-count", retryCount.ToString()); + } + using CancellationTokenSource timeoutCts = new( + this.Timeout ?? ClientOptions.DefaultTimeout + ); + using var cts = CancellationTokenSource.CreateLinkedTokenSource( + timeoutCts.Token, + cancellationToken + ); + HttpResponseMessage responseMessage; + try + { + responseMessage = await this + .HttpClient.SendAsync( + requestMessage, + HttpCompletionOption.ResponseHeadersRead, + cts.Token + ) + .ConfigureAwait(false); + } + catch (HttpRequestException e) + { + throw new ImageKitIOException("I/O exception", e); + } + return new() { RawMessage = responseMessage, CancellationToken = cts.Token }; + } + + static TimeSpan ComputeRetryBackoff(int retries, HttpResponse? response) + { + TimeSpan? apiBackoff = ParseRetryAfterMsHeader(response) ?? ParseRetryAfterHeader(response); + if (apiBackoff != null && apiBackoff < TimeSpan.FromMinutes(1)) + { + // If the API asks us to wait a certain amount of time (and it's a reasonable amount), then just + // do what it says. + return (TimeSpan)apiBackoff; + } + + // Apply exponential backoff, but not more than the max. + var backoffSeconds = Math.Min(0.5 * Math.Pow(2.0, retries - 1), 8.0); + var jitter = 1.0 - 0.25 * Random.NextDouble(); + return TimeSpan.FromSeconds(backoffSeconds * jitter); + } + + static TimeSpan? ParseRetryAfterMsHeader(HttpResponse? response) + { + IEnumerable? headerValues = null; + response?.TryGetHeaderValues("Retry-After-Ms", out headerValues); + var headerValue = headerValues == null ? null : Enumerable.FirstOrDefault(headerValues); + if (headerValue == null) + { + return null; + } + + if (float.TryParse(headerValue, out var retryAfterMs)) + { + return TimeSpan.FromMilliseconds(retryAfterMs); + } + + return null; + } + + static TimeSpan? ParseRetryAfterHeader(HttpResponse? response) + { + IEnumerable? headerValues = null; + response?.TryGetHeaderValues("Retry-After", out headerValues); + var headerValue = headerValues == null ? null : Enumerable.FirstOrDefault(headerValues); + if (headerValue == null) + { + return null; + } + + if (float.TryParse(headerValue, out var retryAfterSeconds)) + { + return TimeSpan.FromSeconds(retryAfterSeconds); + } + else if (DateTimeOffset.TryParse(headerValue, out var retryAfterDate)) + { + return retryAfterDate - DateTimeOffset.Now; + } + + return null; + } + + static bool ShouldRetry(HttpResponse response) + { + if ( + response.TryGetHeaderValues("X-Should-Retry", out var headerValues) + && bool.TryParse(Enumerable.FirstOrDefault(headerValues), out var shouldRetry) + ) + { + // If the server explicitly says whether to retry, then we obey. + return shouldRetry; + } + + return (int)response.StatusCode switch + { + // Retry on request timeouts + 408 + or + // Retry on lock timeouts + 409 + or + // Retry on rate limits + 429 + or + // Retry internal errors + >= 500 => true, + _ => false, + }; + } + + static bool ShouldRetry(Exception e) + { + return e is IOException || e is ImageKitIOException; + } + + public void Dispose() => this.HttpClient.Dispose(); + + public ImageKitClientWithRawResponse() + { + _options = new(); + + _customMetadataFields = new(() => new CustomMetadataFieldServiceWithRawResponse(this)); + _files = new(() => new FileServiceWithRawResponse(this)); + _savedExtensions = new(() => new SavedExtensionServiceWithRawResponse(this)); + _assets = new(() => new AssetServiceWithRawResponse(this)); + _cache = new(() => new CacheServiceWithRawResponse(this)); + _folders = new(() => new FolderServiceWithRawResponse(this)); + _accounts = new(() => new AccountServiceWithRawResponse(this)); + _beta = new(() => new BetaServiceWithRawResponse(this)); + _webhooks = new(() => new WebhookServiceWithRawResponse(this)); + } + + public ImageKitClientWithRawResponse(ClientOptions options) + : this() + { + _options = options; + } +} diff --git a/src/ImageKit/Models/Accounts/Origins/OriginCreateParams.cs b/src/ImageKit/Models/Accounts/Origins/OriginCreateParams.cs new file mode 100644 index 00000000..c0989dfd --- /dev/null +++ b/src/ImageKit/Models/Accounts/Origins/OriginCreateParams.cs @@ -0,0 +1,143 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using ImageKit.Core; +using Text = System.Text; + +namespace ImageKit.Models.Accounts.Origins; + +/// +/// **Note:** This API is currently in beta. Creates a new origin and returns the +/// origin object. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class OriginCreateParams : ParamsBase +{ + readonly JsonDictionary _rawBodyData = new(); + public IReadOnlyDictionary RawBodyData + { + get { return this._rawBodyData.Freeze(); } + } + + /// + /// Schema for origin request resources. + /// + public required OriginRequest OriginRequest + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullClass("OriginRequest"); + } + init { this._rawBodyData.Set("OriginRequest", value); } + } + + public OriginCreateParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public OriginCreateParams(OriginCreateParams originCreateParams) + : base(originCreateParams) + { + this._rawBodyData = new(originCreateParams._rawBodyData); + } +#pragma warning restore CS8618 + + public OriginCreateParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + OriginCreateParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData, + FrozenDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } +#pragma warning restore CS8618 + + /// + public static OriginCreateParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData), + FrozenDictionary.ToFrozenDictionary(rawBodyData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(OriginCreateParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/v1/accounts/origins") + { + Query = this.QueryString(options), + }.Uri; + } + + internal override HttpContent? BodyContent() + { + return new StringContent( + JsonSerializer.Serialize(this.RawBodyData, ModelBase.SerializerOptions), + Text::Encoding.UTF8, + "application/json" + ); + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/ImageKit/Models/Accounts/Origins/OriginDeleteParams.cs b/src/ImageKit/Models/Accounts/Origins/OriginDeleteParams.cs new file mode 100644 index 00000000..fde2e66e --- /dev/null +++ b/src/ImageKit/Models/Accounts/Origins/OriginDeleteParams.cs @@ -0,0 +1,113 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using ImageKit.Core; + +namespace ImageKit.Models.Accounts.Origins; + +/// +/// **Note:** This API is currently in beta. Permanently removes the origin identified +/// by `id`. If the origin is in use by any URL‑endpoints, the API will return an error. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class OriginDeleteParams : ParamsBase +{ + public string? ID { get; init; } + + public OriginDeleteParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public OriginDeleteParams(OriginDeleteParams originDeleteParams) + : base(originDeleteParams) + { + this.ID = originDeleteParams.ID; + } +#pragma warning restore CS8618 + + public OriginDeleteParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + OriginDeleteParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } +#pragma warning restore CS8618 + + /// + public static OriginDeleteParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["ID"] = this.ID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(OriginDeleteParams? other) + { + if (other == null) + { + return false; + } + return (this.ID?.Equals(other.ID) ?? other.ID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder( + options.BaseUrl.ToString().TrimEnd('/') + + string.Format("/v1/accounts/origins/{0}", this.ID) + ) + { + Query = this.QueryString(options), + }.Uri; + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/ImageKit/Models/Accounts/Origins/OriginGetParams.cs b/src/ImageKit/Models/Accounts/Origins/OriginGetParams.cs new file mode 100644 index 00000000..c555f537 --- /dev/null +++ b/src/ImageKit/Models/Accounts/Origins/OriginGetParams.cs @@ -0,0 +1,112 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using ImageKit.Core; + +namespace ImageKit.Models.Accounts.Origins; + +/// +/// **Note:** This API is currently in beta. Retrieves the origin identified by `id`. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class OriginGetParams : ParamsBase +{ + public string? ID { get; init; } + + public OriginGetParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public OriginGetParams(OriginGetParams originGetParams) + : base(originGetParams) + { + this.ID = originGetParams.ID; + } +#pragma warning restore CS8618 + + public OriginGetParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + OriginGetParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } +#pragma warning restore CS8618 + + /// + public static OriginGetParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["ID"] = this.ID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(OriginGetParams? other) + { + if (other == null) + { + return false; + } + return (this.ID?.Equals(other.ID) ?? other.ID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder( + options.BaseUrl.ToString().TrimEnd('/') + + string.Format("/v1/accounts/origins/{0}", this.ID) + ) + { + Query = this.QueryString(options), + }.Uri; + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/ImageKit/Models/Accounts/Origins/OriginListParams.cs b/src/ImageKit/Models/Accounts/Origins/OriginListParams.cs new file mode 100644 index 00000000..4655f09e --- /dev/null +++ b/src/ImageKit/Models/Accounts/Origins/OriginListParams.cs @@ -0,0 +1,103 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using ImageKit.Core; + +namespace ImageKit.Models.Accounts.Origins; + +/// +/// **Note:** This API is currently in beta. Returns an array of all configured +/// origins for the current account. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class OriginListParams : ParamsBase +{ + public OriginListParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public OriginListParams(OriginListParams originListParams) + : base(originListParams) { } +#pragma warning restore CS8618 + + public OriginListParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + OriginListParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } +#pragma warning restore CS8618 + + /// + public static OriginListParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(OriginListParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/v1/accounts/origins") + { + Query = this.QueryString(options), + }.Uri; + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/ImageKit/Models/Accounts/Origins/OriginRequest.cs b/src/ImageKit/Models/Accounts/Origins/OriginRequest.cs new file mode 100644 index 00000000..46e36d31 --- /dev/null +++ b/src/ImageKit/Models/Accounts/Origins/OriginRequest.cs @@ -0,0 +1,2186 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; +using ImageKit.Exceptions; + +namespace ImageKit.Models.Accounts.Origins; + +/// +/// Schema for origin request resources. +/// +[JsonConverter(typeof(OriginRequestConverter))] +public record class OriginRequest : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public string? AccessKey + { + get + { + return Match( + s3: (x) => x.AccessKey, + s3Compatible: (x) => x.AccessKey, + cloudinaryBackup: (x) => x.AccessKey, + webFolder: (_) => null, + webProxy: (_) => null, + gcs: (_) => null, + azureBlob: (_) => null, + akeneoPim: (_) => null + ); + } + } + + public string? Bucket + { + get + { + return Match( + s3: (x) => x.Bucket, + s3Compatible: (x) => x.Bucket, + cloudinaryBackup: (x) => x.Bucket, + webFolder: (_) => null, + webProxy: (_) => null, + gcs: (x) => x.Bucket, + azureBlob: (_) => null, + akeneoPim: (_) => null + ); + } + } + + public string Name + { + get + { + return Match( + s3: (x) => x.Name, + s3Compatible: (x) => x.Name, + cloudinaryBackup: (x) => x.Name, + webFolder: (x) => x.Name, + webProxy: (x) => x.Name, + gcs: (x) => x.Name, + azureBlob: (x) => x.Name, + akeneoPim: (x) => x.Name + ); + } + } + + public string? SecretKey + { + get + { + return Match( + s3: (x) => x.SecretKey, + s3Compatible: (x) => x.SecretKey, + cloudinaryBackup: (x) => x.SecretKey, + webFolder: (_) => null, + webProxy: (_) => null, + gcs: (_) => null, + azureBlob: (_) => null, + akeneoPim: (_) => null + ); + } + } + + public JsonElement Type + { + get + { + return Match( + s3: (x) => x.Type, + s3Compatible: (x) => x.Type, + cloudinaryBackup: (x) => x.Type, + webFolder: (x) => x.Type, + webProxy: (x) => x.Type, + gcs: (x) => x.Type, + azureBlob: (x) => x.Type, + akeneoPim: (x) => x.Type + ); + } + } + + public string? BaseUrlForCanonicalHeader + { + get + { + return Match( + s3: (x) => x.BaseUrlForCanonicalHeader, + s3Compatible: (x) => x.BaseUrlForCanonicalHeader, + cloudinaryBackup: (x) => x.BaseUrlForCanonicalHeader, + webFolder: (x) => x.BaseUrlForCanonicalHeader, + webProxy: (x) => x.BaseUrlForCanonicalHeader, + gcs: (x) => x.BaseUrlForCanonicalHeader, + azureBlob: (x) => x.BaseUrlForCanonicalHeader, + akeneoPim: (x) => x.BaseUrlForCanonicalHeader + ); + } + } + + public bool? IncludeCanonicalHeader + { + get + { + return Match( + s3: (x) => x.IncludeCanonicalHeader, + s3Compatible: (x) => x.IncludeCanonicalHeader, + cloudinaryBackup: (x) => x.IncludeCanonicalHeader, + webFolder: (x) => x.IncludeCanonicalHeader, + webProxy: (x) => x.IncludeCanonicalHeader, + gcs: (x) => x.IncludeCanonicalHeader, + azureBlob: (x) => x.IncludeCanonicalHeader, + akeneoPim: (x) => x.IncludeCanonicalHeader + ); + } + } + + public string? Prefix + { + get + { + return Match( + s3: (x) => x.Prefix, + s3Compatible: (x) => x.Prefix, + cloudinaryBackup: (x) => x.Prefix, + webFolder: (_) => null, + webProxy: (_) => null, + gcs: (x) => x.Prefix, + azureBlob: (x) => x.Prefix, + akeneoPim: (_) => null + ); + } + } + + public string? BaseUrl + { + get + { + return Match( + s3: (_) => null, + s3Compatible: (_) => null, + cloudinaryBackup: (_) => null, + webFolder: (x) => x.BaseUrl, + webProxy: (_) => null, + gcs: (_) => null, + azureBlob: (_) => null, + akeneoPim: (x) => x.BaseUrl + ); + } + } + + public OriginRequest(S3 value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public OriginRequest(S3Compatible value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public OriginRequest(CloudinaryBackup value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public OriginRequest(WebFolder value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public OriginRequest(WebProxy value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public OriginRequest(Gcs value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public OriginRequest(AzureBlob value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public OriginRequest(AkeneoPim value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public OriginRequest(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickS3(out var value)) { + /// // `value` is of type `S3` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickS3([NotNullWhen(true)] out S3? value) + { + value = this.Value as S3; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickS3Compatible(out var value)) { + /// // `value` is of type `S3Compatible` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickS3Compatible([NotNullWhen(true)] out S3Compatible? value) + { + value = this.Value as S3Compatible; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickCloudinaryBackup(out var value)) { + /// // `value` is of type `CloudinaryBackup` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickCloudinaryBackup([NotNullWhen(true)] out CloudinaryBackup? value) + { + value = this.Value as CloudinaryBackup; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickWebFolder(out var value)) { + /// // `value` is of type `WebFolder` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickWebFolder([NotNullWhen(true)] out WebFolder? value) + { + value = this.Value as WebFolder; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickWebProxy(out var value)) { + /// // `value` is of type `WebProxy` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickWebProxy([NotNullWhen(true)] out WebProxy? value) + { + value = this.Value as WebProxy; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickGcs(out var value)) { + /// // `value` is of type `Gcs` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickGcs([NotNullWhen(true)] out Gcs? value) + { + value = this.Value as Gcs; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickAzureBlob(out var value)) { + /// // `value` is of type `AzureBlob` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickAzureBlob([NotNullWhen(true)] out AzureBlob? value) + { + value = this.Value as AzureBlob; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickAkeneoPim(out var value)) { + /// // `value` is of type `AkeneoPim` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickAkeneoPim([NotNullWhen(true)] out AkeneoPim? value) + { + value = this.Value as AkeneoPim; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (S3 value) => {...}, + /// (S3Compatible value) => {...}, + /// (CloudinaryBackup value) => {...}, + /// (WebFolder value) => {...}, + /// (WebProxy value) => {...}, + /// (Gcs value) => {...}, + /// (AzureBlob value) => {...}, + /// (AkeneoPim value) => {...} + /// ); + /// + /// + /// + public void Switch( + Action s3, + Action s3Compatible, + Action cloudinaryBackup, + Action webFolder, + Action webProxy, + Action gcs, + Action azureBlob, + Action akeneoPim + ) + { + switch (this.Value) + { + case S3 value: + s3(value); + break; + case S3Compatible value: + s3Compatible(value); + break; + case CloudinaryBackup value: + cloudinaryBackup(value); + break; + case WebFolder value: + webFolder(value); + break; + case WebProxy value: + webProxy(value); + break; + case Gcs value: + gcs(value); + break; + case AzureBlob value: + azureBlob(value); + break; + case AkeneoPim value: + akeneoPim(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of OriginRequest" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (S3 value) => {...}, + /// (S3Compatible value) => {...}, + /// (CloudinaryBackup value) => {...}, + /// (WebFolder value) => {...}, + /// (WebProxy value) => {...}, + /// (Gcs value) => {...}, + /// (AzureBlob value) => {...}, + /// (AkeneoPim value) => {...} + /// ); + /// + /// + /// + public T Match( + Func s3, + Func s3Compatible, + Func cloudinaryBackup, + Func webFolder, + Func webProxy, + Func gcs, + Func azureBlob, + Func akeneoPim + ) + { + return this.Value switch + { + S3 value => s3(value), + S3Compatible value => s3Compatible(value), + CloudinaryBackup value => cloudinaryBackup(value), + WebFolder value => webFolder(value), + WebProxy value => webProxy(value), + Gcs value => gcs(value), + AzureBlob value => azureBlob(value), + AkeneoPim value => akeneoPim(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of OriginRequest" + ), + }; + } + + public static implicit operator OriginRequest(S3 value) => new(value); + + public static implicit operator OriginRequest(S3Compatible value) => new(value); + + public static implicit operator OriginRequest(CloudinaryBackup value) => new(value); + + public static implicit operator OriginRequest(WebFolder value) => new(value); + + public static implicit operator OriginRequest(WebProxy value) => new(value); + + public static implicit operator OriginRequest(Gcs value) => new(value); + + public static implicit operator OriginRequest(AzureBlob value) => new(value); + + public static implicit operator OriginRequest(AkeneoPim value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of OriginRequest" + ); + } + this.Switch( + (s3) => s3.Validate(), + (s3Compatible) => s3Compatible.Validate(), + (cloudinaryBackup) => cloudinaryBackup.Validate(), + (webFolder) => webFolder.Validate(), + (webProxy) => webProxy.Validate(), + (gcs) => gcs.Validate(), + (azureBlob) => azureBlob.Validate(), + (akeneoPim) => akeneoPim.Validate() + ); + } + + public virtual bool Equals(OriginRequest? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class OriginRequestConverter : JsonConverter +{ + public override OriginRequest? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + string? type; + try + { + type = element.GetProperty("type").GetString(); + } + catch + { + type = null; + } + + switch (type) + { + case "S3": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + case "S3_COMPATIBLE": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + case "CLOUDINARY_BACKUP": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + case "WEB_FOLDER": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + case "WEB_PROXY": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + case "GCS": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + case "AZURE_BLOB": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + case "AKENEO_PIM": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + default: + { + return new OriginRequest(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + OriginRequest value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class S3 : JsonModel +{ + /// + /// Access key for the bucket. + /// + public required string AccessKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("accessKey"); + } + init { this._rawData.Set("accessKey", value); } + } + + /// + /// S3 bucket name. + /// + public required string Bucket + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("bucket"); + } + init { this._rawData.Set("bucket", value); } + } + + /// + /// Display name of the origin. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + /// Secret key for the bucket. + /// + public required string SecretKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("secretKey"); + } + init { this._rawData.Set("secretKey", value); } + } + + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// URL used in the Canonical header (if enabled). + /// + public string? BaseUrlForCanonicalHeader + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("baseUrlForCanonicalHeader"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("baseUrlForCanonicalHeader", value); + } + } + + /// + /// Whether to send a Canonical header. + /// + public bool? IncludeCanonicalHeader + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("includeCanonicalHeader"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("includeCanonicalHeader", value); + } + } + + /// + /// Path prefix inside the bucket. + /// + public string? Prefix + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("prefix"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("prefix", value); + } + } + + /// + public override void Validate() + { + _ = this.AccessKey; + _ = this.Bucket; + _ = this.Name; + _ = this.SecretKey; + if (!JsonElement.DeepEquals(this.Type, JsonSerializer.SerializeToElement("S3"))) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + _ = this.BaseUrlForCanonicalHeader; + _ = this.IncludeCanonicalHeader; + _ = this.Prefix; + } + + public S3() + { + this.Type = JsonSerializer.SerializeToElement("S3"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public S3(S3 s3) + : base(s3) { } +#pragma warning restore CS8618 + + public S3(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("S3"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + S3(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static S3 FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class S3FromRaw : IFromRawJson +{ + /// + public S3 FromRawUnchecked(IReadOnlyDictionary rawData) => + S3.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class S3Compatible : JsonModel +{ + /// + /// Access key for the bucket. + /// + public required string AccessKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("accessKey"); + } + init { this._rawData.Set("accessKey", value); } + } + + /// + /// S3 bucket name. + /// + public required string Bucket + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("bucket"); + } + init { this._rawData.Set("bucket", value); } + } + + /// + /// Custom S3-compatible endpoint. + /// + public required string Endpoint + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("endpoint"); + } + init { this._rawData.Set("endpoint", value); } + } + + /// + /// Display name of the origin. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + /// Secret key for the bucket. + /// + public required string SecretKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("secretKey"); + } + init { this._rawData.Set("secretKey", value); } + } + + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// URL used in the Canonical header (if enabled). + /// + public string? BaseUrlForCanonicalHeader + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("baseUrlForCanonicalHeader"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("baseUrlForCanonicalHeader", value); + } + } + + /// + /// Whether to send a Canonical header. + /// + public bool? IncludeCanonicalHeader + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("includeCanonicalHeader"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("includeCanonicalHeader", value); + } + } + + /// + /// Path prefix inside the bucket. + /// + public string? Prefix + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("prefix"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("prefix", value); + } + } + + /// + /// Use path-style S3 URLs? + /// + public bool? S3ForcePathStyle + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("s3ForcePathStyle"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("s3ForcePathStyle", value); + } + } + + /// + public override void Validate() + { + _ = this.AccessKey; + _ = this.Bucket; + _ = this.Endpoint; + _ = this.Name; + _ = this.SecretKey; + if (!JsonElement.DeepEquals(this.Type, JsonSerializer.SerializeToElement("S3_COMPATIBLE"))) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + _ = this.BaseUrlForCanonicalHeader; + _ = this.IncludeCanonicalHeader; + _ = this.Prefix; + _ = this.S3ForcePathStyle; + } + + public S3Compatible() + { + this.Type = JsonSerializer.SerializeToElement("S3_COMPATIBLE"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public S3Compatible(S3Compatible s3Compatible) + : base(s3Compatible) { } +#pragma warning restore CS8618 + + public S3Compatible(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("S3_COMPATIBLE"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + S3Compatible(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static S3Compatible FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class S3CompatibleFromRaw : IFromRawJson +{ + /// + public S3Compatible FromRawUnchecked(IReadOnlyDictionary rawData) => + S3Compatible.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class CloudinaryBackup : JsonModel +{ + /// + /// Access key for the bucket. + /// + public required string AccessKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("accessKey"); + } + init { this._rawData.Set("accessKey", value); } + } + + /// + /// S3 bucket name. + /// + public required string Bucket + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("bucket"); + } + init { this._rawData.Set("bucket", value); } + } + + /// + /// Display name of the origin. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + /// Secret key for the bucket. + /// + public required string SecretKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("secretKey"); + } + init { this._rawData.Set("secretKey", value); } + } + + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// URL used in the Canonical header (if enabled). + /// + public string? BaseUrlForCanonicalHeader + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("baseUrlForCanonicalHeader"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("baseUrlForCanonicalHeader", value); + } + } + + /// + /// Whether to send a Canonical header. + /// + public bool? IncludeCanonicalHeader + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("includeCanonicalHeader"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("includeCanonicalHeader", value); + } + } + + /// + /// Path prefix inside the bucket. + /// + public string? Prefix + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("prefix"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("prefix", value); + } + } + + /// + public override void Validate() + { + _ = this.AccessKey; + _ = this.Bucket; + _ = this.Name; + _ = this.SecretKey; + if ( + !JsonElement.DeepEquals( + this.Type, + JsonSerializer.SerializeToElement("CLOUDINARY_BACKUP") + ) + ) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + _ = this.BaseUrlForCanonicalHeader; + _ = this.IncludeCanonicalHeader; + _ = this.Prefix; + } + + public CloudinaryBackup() + { + this.Type = JsonSerializer.SerializeToElement("CLOUDINARY_BACKUP"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CloudinaryBackup(CloudinaryBackup cloudinaryBackup) + : base(cloudinaryBackup) { } +#pragma warning restore CS8618 + + public CloudinaryBackup(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("CLOUDINARY_BACKUP"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + CloudinaryBackup(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static CloudinaryBackup FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class CloudinaryBackupFromRaw : IFromRawJson +{ + /// + public CloudinaryBackup FromRawUnchecked(IReadOnlyDictionary rawData) => + CloudinaryBackup.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class WebFolder : JsonModel +{ + /// + /// Root URL for the web folder origin. + /// + public required string BaseUrl + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("baseUrl"); + } + init { this._rawData.Set("baseUrl", value); } + } + + /// + /// Display name of the origin. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// URL used in the Canonical header (if enabled). + /// + public string? BaseUrlForCanonicalHeader + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("baseUrlForCanonicalHeader"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("baseUrlForCanonicalHeader", value); + } + } + + /// + /// Forward the Host header to origin? + /// + public bool? ForwardHostHeaderToOrigin + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("forwardHostHeaderToOrigin"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("forwardHostHeaderToOrigin", value); + } + } + + /// + /// Whether to send a Canonical header. + /// + public bool? IncludeCanonicalHeader + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("includeCanonicalHeader"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("includeCanonicalHeader", value); + } + } + + /// + public override void Validate() + { + _ = this.BaseUrl; + _ = this.Name; + if (!JsonElement.DeepEquals(this.Type, JsonSerializer.SerializeToElement("WEB_FOLDER"))) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + _ = this.BaseUrlForCanonicalHeader; + _ = this.ForwardHostHeaderToOrigin; + _ = this.IncludeCanonicalHeader; + } + + public WebFolder() + { + this.Type = JsonSerializer.SerializeToElement("WEB_FOLDER"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public WebFolder(WebFolder webFolder) + : base(webFolder) { } +#pragma warning restore CS8618 + + public WebFolder(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("WEB_FOLDER"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + WebFolder(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static WebFolder FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class WebFolderFromRaw : IFromRawJson +{ + /// + public WebFolder FromRawUnchecked(IReadOnlyDictionary rawData) => + WebFolder.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class WebProxy : JsonModel +{ + /// + /// Display name of the origin. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// URL used in the Canonical header (if enabled). + /// + public string? BaseUrlForCanonicalHeader + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("baseUrlForCanonicalHeader"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("baseUrlForCanonicalHeader", value); + } + } + + /// + /// Whether to send a Canonical header. + /// + public bool? IncludeCanonicalHeader + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("includeCanonicalHeader"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("includeCanonicalHeader", value); + } + } + + /// + public override void Validate() + { + _ = this.Name; + if (!JsonElement.DeepEquals(this.Type, JsonSerializer.SerializeToElement("WEB_PROXY"))) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + _ = this.BaseUrlForCanonicalHeader; + _ = this.IncludeCanonicalHeader; + } + + public WebProxy() + { + this.Type = JsonSerializer.SerializeToElement("WEB_PROXY"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public WebProxy(WebProxy webProxy) + : base(webProxy) { } +#pragma warning restore CS8618 + + public WebProxy(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("WEB_PROXY"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + WebProxy(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static WebProxy FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public WebProxy(string name) + : this() + { + this.Name = name; + } +} + +class WebProxyFromRaw : IFromRawJson +{ + /// + public WebProxy FromRawUnchecked(IReadOnlyDictionary rawData) => + WebProxy.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Gcs : JsonModel +{ + public required string Bucket + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("bucket"); + } + init { this._rawData.Set("bucket", value); } + } + + public required string ClientEmail + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("clientEmail"); + } + init { this._rawData.Set("clientEmail", value); } + } + + /// + /// Display name of the origin. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + public required string PrivateKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("privateKey"); + } + init { this._rawData.Set("privateKey", value); } + } + + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// URL used in the Canonical header (if enabled). + /// + public string? BaseUrlForCanonicalHeader + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("baseUrlForCanonicalHeader"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("baseUrlForCanonicalHeader", value); + } + } + + /// + /// Whether to send a Canonical header. + /// + public bool? IncludeCanonicalHeader + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("includeCanonicalHeader"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("includeCanonicalHeader", value); + } + } + + public string? Prefix + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("prefix"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("prefix", value); + } + } + + /// + public override void Validate() + { + _ = this.Bucket; + _ = this.ClientEmail; + _ = this.Name; + _ = this.PrivateKey; + if (!JsonElement.DeepEquals(this.Type, JsonSerializer.SerializeToElement("GCS"))) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + _ = this.BaseUrlForCanonicalHeader; + _ = this.IncludeCanonicalHeader; + _ = this.Prefix; + } + + public Gcs() + { + this.Type = JsonSerializer.SerializeToElement("GCS"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Gcs(Gcs gcs) + : base(gcs) { } +#pragma warning restore CS8618 + + public Gcs(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("GCS"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Gcs(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static Gcs FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GcsFromRaw : IFromRawJson +{ + /// + public Gcs FromRawUnchecked(IReadOnlyDictionary rawData) => + Gcs.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class AzureBlob : JsonModel +{ + public required string AccountName + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("accountName"); + } + init { this._rawData.Set("accountName", value); } + } + + public required string Container + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("container"); + } + init { this._rawData.Set("container", value); } + } + + /// + /// Display name of the origin. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + public required string SasToken + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("sasToken"); + } + init { this._rawData.Set("sasToken", value); } + } + + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// URL used in the Canonical header (if enabled). + /// + public string? BaseUrlForCanonicalHeader + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("baseUrlForCanonicalHeader"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("baseUrlForCanonicalHeader", value); + } + } + + /// + /// Whether to send a Canonical header. + /// + public bool? IncludeCanonicalHeader + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("includeCanonicalHeader"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("includeCanonicalHeader", value); + } + } + + public string? Prefix + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("prefix"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("prefix", value); + } + } + + /// + public override void Validate() + { + _ = this.AccountName; + _ = this.Container; + _ = this.Name; + _ = this.SasToken; + if (!JsonElement.DeepEquals(this.Type, JsonSerializer.SerializeToElement("AZURE_BLOB"))) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + _ = this.BaseUrlForCanonicalHeader; + _ = this.IncludeCanonicalHeader; + _ = this.Prefix; + } + + public AzureBlob() + { + this.Type = JsonSerializer.SerializeToElement("AZURE_BLOB"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public AzureBlob(AzureBlob azureBlob) + : base(azureBlob) { } +#pragma warning restore CS8618 + + public AzureBlob(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("AZURE_BLOB"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + AzureBlob(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static AzureBlob FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class AzureBlobFromRaw : IFromRawJson +{ + /// + public AzureBlob FromRawUnchecked(IReadOnlyDictionary rawData) => + AzureBlob.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class AkeneoPim : JsonModel +{ + /// + /// Akeneo instance base URL. + /// + public required string BaseUrl + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("baseUrl"); + } + init { this._rawData.Set("baseUrl", value); } + } + + /// + /// Akeneo API client ID. + /// + public required string ClientID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("clientId"); + } + init { this._rawData.Set("clientId", value); } + } + + /// + /// Akeneo API client secret. + /// + public required string ClientSecret + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("clientSecret"); + } + init { this._rawData.Set("clientSecret", value); } + } + + /// + /// Display name of the origin. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + /// Akeneo API password. + /// + public required string Password + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("password"); + } + init { this._rawData.Set("password", value); } + } + + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// Akeneo API username. + /// + public required string Username + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("username"); + } + init { this._rawData.Set("username", value); } + } + + /// + /// URL used in the Canonical header (if enabled). + /// + public string? BaseUrlForCanonicalHeader + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("baseUrlForCanonicalHeader"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("baseUrlForCanonicalHeader", value); + } + } + + /// + /// Whether to send a Canonical header. + /// + public bool? IncludeCanonicalHeader + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("includeCanonicalHeader"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("includeCanonicalHeader", value); + } + } + + /// + public override void Validate() + { + _ = this.BaseUrl; + _ = this.ClientID; + _ = this.ClientSecret; + _ = this.Name; + _ = this.Password; + if (!JsonElement.DeepEquals(this.Type, JsonSerializer.SerializeToElement("AKENEO_PIM"))) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + _ = this.Username; + _ = this.BaseUrlForCanonicalHeader; + _ = this.IncludeCanonicalHeader; + } + + public AkeneoPim() + { + this.Type = JsonSerializer.SerializeToElement("AKENEO_PIM"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public AkeneoPim(AkeneoPim akeneoPim) + : base(akeneoPim) { } +#pragma warning restore CS8618 + + public AkeneoPim(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("AKENEO_PIM"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + AkeneoPim(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static AkeneoPim FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class AkeneoPimFromRaw : IFromRawJson +{ + /// + public AkeneoPim FromRawUnchecked(IReadOnlyDictionary rawData) => + AkeneoPim.FromRawUnchecked(rawData); +} diff --git a/src/ImageKit/Models/Accounts/Origins/OriginResponse.cs b/src/ImageKit/Models/Accounts/Origins/OriginResponse.cs new file mode 100644 index 00000000..7e25f7e3 --- /dev/null +++ b/src/ImageKit/Models/Accounts/Origins/OriginResponse.cs @@ -0,0 +1,2053 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; +using ImageKit.Exceptions; + +namespace ImageKit.Models.Accounts.Origins; + +/// +/// Origin object as returned by the API (sensitive fields removed). +/// +[JsonConverter(typeof(OriginResponseConverter))] +public record class OriginResponse : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public string ID + { + get + { + return Match( + s3: (x) => x.ID, + s3Compatible: (x) => x.ID, + cloudinaryBackup: (x) => x.ID, + webFolder: (x) => x.ID, + webProxy: (x) => x.ID, + gcs: (x) => x.ID, + azureBlob: (x) => x.ID, + akeneoPim: (x) => x.ID + ); + } + } + + public string? Bucket + { + get + { + return Match( + s3: (x) => x.Bucket, + s3Compatible: (x) => x.Bucket, + cloudinaryBackup: (x) => x.Bucket, + webFolder: (_) => null, + webProxy: (_) => null, + gcs: (x) => x.Bucket, + azureBlob: (_) => null, + akeneoPim: (_) => null + ); + } + } + + public bool IncludeCanonicalHeader + { + get + { + return Match( + s3: (x) => x.IncludeCanonicalHeader, + s3Compatible: (x) => x.IncludeCanonicalHeader, + cloudinaryBackup: (x) => x.IncludeCanonicalHeader, + webFolder: (x) => x.IncludeCanonicalHeader, + webProxy: (x) => x.IncludeCanonicalHeader, + gcs: (x) => x.IncludeCanonicalHeader, + azureBlob: (x) => x.IncludeCanonicalHeader, + akeneoPim: (x) => x.IncludeCanonicalHeader + ); + } + } + + public string Name + { + get + { + return Match( + s3: (x) => x.Name, + s3Compatible: (x) => x.Name, + cloudinaryBackup: (x) => x.Name, + webFolder: (x) => x.Name, + webProxy: (x) => x.Name, + gcs: (x) => x.Name, + azureBlob: (x) => x.Name, + akeneoPim: (x) => x.Name + ); + } + } + + public string? Prefix + { + get + { + return Match( + s3: (x) => x.Prefix, + s3Compatible: (x) => x.Prefix, + cloudinaryBackup: (x) => x.Prefix, + webFolder: (_) => null, + webProxy: (_) => null, + gcs: (x) => x.Prefix, + azureBlob: (x) => x.Prefix, + akeneoPim: (_) => null + ); + } + } + + public JsonElement Type + { + get + { + return Match( + s3: (x) => x.Type, + s3Compatible: (x) => x.Type, + cloudinaryBackup: (x) => x.Type, + webFolder: (x) => x.Type, + webProxy: (x) => x.Type, + gcs: (x) => x.Type, + azureBlob: (x) => x.Type, + akeneoPim: (x) => x.Type + ); + } + } + + public string? BaseUrlForCanonicalHeader + { + get + { + return Match( + s3: (x) => x.BaseUrlForCanonicalHeader, + s3Compatible: (x) => x.BaseUrlForCanonicalHeader, + cloudinaryBackup: (x) => x.BaseUrlForCanonicalHeader, + webFolder: (x) => x.BaseUrlForCanonicalHeader, + webProxy: (x) => x.BaseUrlForCanonicalHeader, + gcs: (x) => x.BaseUrlForCanonicalHeader, + azureBlob: (x) => x.BaseUrlForCanonicalHeader, + akeneoPim: (x) => x.BaseUrlForCanonicalHeader + ); + } + } + + public string? BaseUrl + { + get + { + return Match( + s3: (_) => null, + s3Compatible: (_) => null, + cloudinaryBackup: (_) => null, + webFolder: (x) => x.BaseUrl, + webProxy: (_) => null, + gcs: (_) => null, + azureBlob: (_) => null, + akeneoPim: (x) => x.BaseUrl + ); + } + } + + public OriginResponse(OriginResponseS3 value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public OriginResponse(OriginResponseS3Compatible value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public OriginResponse(OriginResponseCloudinaryBackup value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public OriginResponse(OriginResponseWebFolder value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public OriginResponse(OriginResponseWebProxy value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public OriginResponse(OriginResponseGcs value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public OriginResponse(OriginResponseAzureBlob value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public OriginResponse(OriginResponseAkeneoPim value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public OriginResponse(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickS3(out var value)) { + /// // `value` is of type `OriginResponseS3` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickS3([NotNullWhen(true)] out OriginResponseS3? value) + { + value = this.Value as OriginResponseS3; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickS3Compatible(out var value)) { + /// // `value` is of type `OriginResponseS3Compatible` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickS3Compatible([NotNullWhen(true)] out OriginResponseS3Compatible? value) + { + value = this.Value as OriginResponseS3Compatible; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickCloudinaryBackup(out var value)) { + /// // `value` is of type `OriginResponseCloudinaryBackup` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickCloudinaryBackup( + [NotNullWhen(true)] out OriginResponseCloudinaryBackup? value + ) + { + value = this.Value as OriginResponseCloudinaryBackup; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickWebFolder(out var value)) { + /// // `value` is of type `OriginResponseWebFolder` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickWebFolder([NotNullWhen(true)] out OriginResponseWebFolder? value) + { + value = this.Value as OriginResponseWebFolder; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickWebProxy(out var value)) { + /// // `value` is of type `OriginResponseWebProxy` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickWebProxy([NotNullWhen(true)] out OriginResponseWebProxy? value) + { + value = this.Value as OriginResponseWebProxy; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickGcs(out var value)) { + /// // `value` is of type `OriginResponseGcs` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickGcs([NotNullWhen(true)] out OriginResponseGcs? value) + { + value = this.Value as OriginResponseGcs; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickAzureBlob(out var value)) { + /// // `value` is of type `OriginResponseAzureBlob` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickAzureBlob([NotNullWhen(true)] out OriginResponseAzureBlob? value) + { + value = this.Value as OriginResponseAzureBlob; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickAkeneoPim(out var value)) { + /// // `value` is of type `OriginResponseAkeneoPim` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickAkeneoPim([NotNullWhen(true)] out OriginResponseAkeneoPim? value) + { + value = this.Value as OriginResponseAkeneoPim; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (OriginResponseS3 value) => {...}, + /// (OriginResponseS3Compatible value) => {...}, + /// (OriginResponseCloudinaryBackup value) => {...}, + /// (OriginResponseWebFolder value) => {...}, + /// (OriginResponseWebProxy value) => {...}, + /// (OriginResponseGcs value) => {...}, + /// (OriginResponseAzureBlob value) => {...}, + /// (OriginResponseAkeneoPim value) => {...} + /// ); + /// + /// + /// + public void Switch( + Action s3, + Action s3Compatible, + Action cloudinaryBackup, + Action webFolder, + Action webProxy, + Action gcs, + Action azureBlob, + Action akeneoPim + ) + { + switch (this.Value) + { + case OriginResponseS3 value: + s3(value); + break; + case OriginResponseS3Compatible value: + s3Compatible(value); + break; + case OriginResponseCloudinaryBackup value: + cloudinaryBackup(value); + break; + case OriginResponseWebFolder value: + webFolder(value); + break; + case OriginResponseWebProxy value: + webProxy(value); + break; + case OriginResponseGcs value: + gcs(value); + break; + case OriginResponseAzureBlob value: + azureBlob(value); + break; + case OriginResponseAkeneoPim value: + akeneoPim(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of OriginResponse" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (OriginResponseS3 value) => {...}, + /// (OriginResponseS3Compatible value) => {...}, + /// (OriginResponseCloudinaryBackup value) => {...}, + /// (OriginResponseWebFolder value) => {...}, + /// (OriginResponseWebProxy value) => {...}, + /// (OriginResponseGcs value) => {...}, + /// (OriginResponseAzureBlob value) => {...}, + /// (OriginResponseAkeneoPim value) => {...} + /// ); + /// + /// + /// + public T Match( + Func s3, + Func s3Compatible, + Func cloudinaryBackup, + Func webFolder, + Func webProxy, + Func gcs, + Func azureBlob, + Func akeneoPim + ) + { + return this.Value switch + { + OriginResponseS3 value => s3(value), + OriginResponseS3Compatible value => s3Compatible(value), + OriginResponseCloudinaryBackup value => cloudinaryBackup(value), + OriginResponseWebFolder value => webFolder(value), + OriginResponseWebProxy value => webProxy(value), + OriginResponseGcs value => gcs(value), + OriginResponseAzureBlob value => azureBlob(value), + OriginResponseAkeneoPim value => akeneoPim(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of OriginResponse" + ), + }; + } + + public static implicit operator OriginResponse(OriginResponseS3 value) => new(value); + + public static implicit operator OriginResponse(OriginResponseS3Compatible value) => new(value); + + public static implicit operator OriginResponse(OriginResponseCloudinaryBackup value) => + new(value); + + public static implicit operator OriginResponse(OriginResponseWebFolder value) => new(value); + + public static implicit operator OriginResponse(OriginResponseWebProxy value) => new(value); + + public static implicit operator OriginResponse(OriginResponseGcs value) => new(value); + + public static implicit operator OriginResponse(OriginResponseAzureBlob value) => new(value); + + public static implicit operator OriginResponse(OriginResponseAkeneoPim value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of OriginResponse" + ); + } + this.Switch( + (s3) => s3.Validate(), + (s3Compatible) => s3Compatible.Validate(), + (cloudinaryBackup) => cloudinaryBackup.Validate(), + (webFolder) => webFolder.Validate(), + (webProxy) => webProxy.Validate(), + (gcs) => gcs.Validate(), + (azureBlob) => azureBlob.Validate(), + (akeneoPim) => akeneoPim.Validate() + ); + } + + public virtual bool Equals(OriginResponse? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class OriginResponseConverter : JsonConverter +{ + public override OriginResponse? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + string? type; + try + { + type = element.GetProperty("type").GetString(); + } + catch + { + type = null; + } + + switch (type) + { + case "S3": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + case "S3_COMPATIBLE": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + case "CLOUDINARY_BACKUP": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + case "WEB_FOLDER": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + case "WEB_PROXY": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + case "GCS": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + case "AZURE_BLOB": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + case "AKENEO_PIM": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + default: + { + return new OriginResponse(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + OriginResponse value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class OriginResponseS3 : JsonModel +{ + /// + /// Unique identifier for the origin. This is generated by ImageKit when you + /// create a new origin. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// S3 bucket name. + /// + public required string Bucket + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("bucket"); + } + init { this._rawData.Set("bucket", value); } + } + + /// + /// Whether to send a Canonical header. + /// + public required bool IncludeCanonicalHeader + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("includeCanonicalHeader"); + } + init { this._rawData.Set("includeCanonicalHeader", value); } + } + + /// + /// Display name of the origin. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + /// Path prefix inside the bucket. + /// + public required string Prefix + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("prefix"); + } + init { this._rawData.Set("prefix", value); } + } + + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// URL used in the Canonical header (if enabled). + /// + public string? BaseUrlForCanonicalHeader + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("baseUrlForCanonicalHeader"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("baseUrlForCanonicalHeader", value); + } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.Bucket; + _ = this.IncludeCanonicalHeader; + _ = this.Name; + _ = this.Prefix; + if (!JsonElement.DeepEquals(this.Type, JsonSerializer.SerializeToElement("S3"))) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + _ = this.BaseUrlForCanonicalHeader; + } + + public OriginResponseS3() + { + this.Type = JsonSerializer.SerializeToElement("S3"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public OriginResponseS3(OriginResponseS3 originResponseS3) + : base(originResponseS3) { } +#pragma warning restore CS8618 + + public OriginResponseS3(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("S3"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + OriginResponseS3(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static OriginResponseS3 FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class OriginResponseS3FromRaw : IFromRawJson +{ + /// + public OriginResponseS3 FromRawUnchecked(IReadOnlyDictionary rawData) => + OriginResponseS3.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class OriginResponseS3Compatible : JsonModel +{ + /// + /// Unique identifier for the origin. This is generated by ImageKit when you + /// create a new origin. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// S3 bucket name. + /// + public required string Bucket + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("bucket"); + } + init { this._rawData.Set("bucket", value); } + } + + /// + /// Custom S3-compatible endpoint. + /// + public required string Endpoint + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("endpoint"); + } + init { this._rawData.Set("endpoint", value); } + } + + /// + /// Whether to send a Canonical header. + /// + public required bool IncludeCanonicalHeader + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("includeCanonicalHeader"); + } + init { this._rawData.Set("includeCanonicalHeader", value); } + } + + /// + /// Display name of the origin. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + /// Path prefix inside the bucket. + /// + public required string Prefix + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("prefix"); + } + init { this._rawData.Set("prefix", value); } + } + + /// + /// Use path-style S3 URLs? + /// + public required bool S3ForcePathStyle + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("s3ForcePathStyle"); + } + init { this._rawData.Set("s3ForcePathStyle", value); } + } + + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// URL used in the Canonical header (if enabled). + /// + public string? BaseUrlForCanonicalHeader + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("baseUrlForCanonicalHeader"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("baseUrlForCanonicalHeader", value); + } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.Bucket; + _ = this.Endpoint; + _ = this.IncludeCanonicalHeader; + _ = this.Name; + _ = this.Prefix; + _ = this.S3ForcePathStyle; + if (!JsonElement.DeepEquals(this.Type, JsonSerializer.SerializeToElement("S3_COMPATIBLE"))) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + _ = this.BaseUrlForCanonicalHeader; + } + + public OriginResponseS3Compatible() + { + this.Type = JsonSerializer.SerializeToElement("S3_COMPATIBLE"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public OriginResponseS3Compatible(OriginResponseS3Compatible originResponseS3Compatible) + : base(originResponseS3Compatible) { } +#pragma warning restore CS8618 + + public OriginResponseS3Compatible(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("S3_COMPATIBLE"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + OriginResponseS3Compatible(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static OriginResponseS3Compatible FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class OriginResponseS3CompatibleFromRaw : IFromRawJson +{ + /// + public OriginResponseS3Compatible FromRawUnchecked( + IReadOnlyDictionary rawData + ) => OriginResponseS3Compatible.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + OriginResponseCloudinaryBackup, + OriginResponseCloudinaryBackupFromRaw + >) +)] +public sealed record class OriginResponseCloudinaryBackup : JsonModel +{ + /// + /// Unique identifier for the origin. This is generated by ImageKit when you + /// create a new origin. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// S3 bucket name. + /// + public required string Bucket + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("bucket"); + } + init { this._rawData.Set("bucket", value); } + } + + /// + /// Whether to send a Canonical header. + /// + public required bool IncludeCanonicalHeader + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("includeCanonicalHeader"); + } + init { this._rawData.Set("includeCanonicalHeader", value); } + } + + /// + /// Display name of the origin. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + /// Path prefix inside the bucket. + /// + public required string Prefix + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("prefix"); + } + init { this._rawData.Set("prefix", value); } + } + + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// URL used in the Canonical header (if enabled). + /// + public string? BaseUrlForCanonicalHeader + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("baseUrlForCanonicalHeader"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("baseUrlForCanonicalHeader", value); + } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.Bucket; + _ = this.IncludeCanonicalHeader; + _ = this.Name; + _ = this.Prefix; + if ( + !JsonElement.DeepEquals( + this.Type, + JsonSerializer.SerializeToElement("CLOUDINARY_BACKUP") + ) + ) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + _ = this.BaseUrlForCanonicalHeader; + } + + public OriginResponseCloudinaryBackup() + { + this.Type = JsonSerializer.SerializeToElement("CLOUDINARY_BACKUP"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public OriginResponseCloudinaryBackup( + OriginResponseCloudinaryBackup originResponseCloudinaryBackup + ) + : base(originResponseCloudinaryBackup) { } +#pragma warning restore CS8618 + + public OriginResponseCloudinaryBackup(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("CLOUDINARY_BACKUP"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + OriginResponseCloudinaryBackup(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static OriginResponseCloudinaryBackup FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class OriginResponseCloudinaryBackupFromRaw : IFromRawJson +{ + /// + public OriginResponseCloudinaryBackup FromRawUnchecked( + IReadOnlyDictionary rawData + ) => OriginResponseCloudinaryBackup.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class OriginResponseWebFolder : JsonModel +{ + /// + /// Unique identifier for the origin. This is generated by ImageKit when you + /// create a new origin. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// Root URL for the web folder origin. + /// + public required string BaseUrl + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("baseUrl"); + } + init { this._rawData.Set("baseUrl", value); } + } + + /// + /// Forward the Host header to origin? + /// + public required bool ForwardHostHeaderToOrigin + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("forwardHostHeaderToOrigin"); + } + init { this._rawData.Set("forwardHostHeaderToOrigin", value); } + } + + /// + /// Whether to send a Canonical header. + /// + public required bool IncludeCanonicalHeader + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("includeCanonicalHeader"); + } + init { this._rawData.Set("includeCanonicalHeader", value); } + } + + /// + /// Display name of the origin. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// URL used in the Canonical header (if enabled). + /// + public string? BaseUrlForCanonicalHeader + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("baseUrlForCanonicalHeader"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("baseUrlForCanonicalHeader", value); + } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.BaseUrl; + _ = this.ForwardHostHeaderToOrigin; + _ = this.IncludeCanonicalHeader; + _ = this.Name; + if (!JsonElement.DeepEquals(this.Type, JsonSerializer.SerializeToElement("WEB_FOLDER"))) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + _ = this.BaseUrlForCanonicalHeader; + } + + public OriginResponseWebFolder() + { + this.Type = JsonSerializer.SerializeToElement("WEB_FOLDER"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public OriginResponseWebFolder(OriginResponseWebFolder originResponseWebFolder) + : base(originResponseWebFolder) { } +#pragma warning restore CS8618 + + public OriginResponseWebFolder(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("WEB_FOLDER"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + OriginResponseWebFolder(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static OriginResponseWebFolder FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class OriginResponseWebFolderFromRaw : IFromRawJson +{ + /// + public OriginResponseWebFolder FromRawUnchecked( + IReadOnlyDictionary rawData + ) => OriginResponseWebFolder.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class OriginResponseWebProxy : JsonModel +{ + /// + /// Unique identifier for the origin. This is generated by ImageKit when you + /// create a new origin. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// Whether to send a Canonical header. + /// + public required bool IncludeCanonicalHeader + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("includeCanonicalHeader"); + } + init { this._rawData.Set("includeCanonicalHeader", value); } + } + + /// + /// Display name of the origin. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// URL used in the Canonical header (if enabled). + /// + public string? BaseUrlForCanonicalHeader + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("baseUrlForCanonicalHeader"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("baseUrlForCanonicalHeader", value); + } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.IncludeCanonicalHeader; + _ = this.Name; + if (!JsonElement.DeepEquals(this.Type, JsonSerializer.SerializeToElement("WEB_PROXY"))) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + _ = this.BaseUrlForCanonicalHeader; + } + + public OriginResponseWebProxy() + { + this.Type = JsonSerializer.SerializeToElement("WEB_PROXY"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public OriginResponseWebProxy(OriginResponseWebProxy originResponseWebProxy) + : base(originResponseWebProxy) { } +#pragma warning restore CS8618 + + public OriginResponseWebProxy(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("WEB_PROXY"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + OriginResponseWebProxy(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static OriginResponseWebProxy FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class OriginResponseWebProxyFromRaw : IFromRawJson +{ + /// + public OriginResponseWebProxy FromRawUnchecked( + IReadOnlyDictionary rawData + ) => OriginResponseWebProxy.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class OriginResponseGcs : JsonModel +{ + /// + /// Unique identifier for the origin. This is generated by ImageKit when you + /// create a new origin. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + public required string Bucket + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("bucket"); + } + init { this._rawData.Set("bucket", value); } + } + + public required string ClientEmail + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("clientEmail"); + } + init { this._rawData.Set("clientEmail", value); } + } + + /// + /// Whether to send a Canonical header. + /// + public required bool IncludeCanonicalHeader + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("includeCanonicalHeader"); + } + init { this._rawData.Set("includeCanonicalHeader", value); } + } + + /// + /// Display name of the origin. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + public required string Prefix + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("prefix"); + } + init { this._rawData.Set("prefix", value); } + } + + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// URL used in the Canonical header (if enabled). + /// + public string? BaseUrlForCanonicalHeader + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("baseUrlForCanonicalHeader"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("baseUrlForCanonicalHeader", value); + } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.Bucket; + _ = this.ClientEmail; + _ = this.IncludeCanonicalHeader; + _ = this.Name; + _ = this.Prefix; + if (!JsonElement.DeepEquals(this.Type, JsonSerializer.SerializeToElement("GCS"))) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + _ = this.BaseUrlForCanonicalHeader; + } + + public OriginResponseGcs() + { + this.Type = JsonSerializer.SerializeToElement("GCS"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public OriginResponseGcs(OriginResponseGcs originResponseGcs) + : base(originResponseGcs) { } +#pragma warning restore CS8618 + + public OriginResponseGcs(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("GCS"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + OriginResponseGcs(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static OriginResponseGcs FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class OriginResponseGcsFromRaw : IFromRawJson +{ + /// + public OriginResponseGcs FromRawUnchecked(IReadOnlyDictionary rawData) => + OriginResponseGcs.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class OriginResponseAzureBlob : JsonModel +{ + /// + /// Unique identifier for the origin. This is generated by ImageKit when you + /// create a new origin. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + public required string AccountName + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("accountName"); + } + init { this._rawData.Set("accountName", value); } + } + + public required string Container + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("container"); + } + init { this._rawData.Set("container", value); } + } + + /// + /// Whether to send a Canonical header. + /// + public required bool IncludeCanonicalHeader + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("includeCanonicalHeader"); + } + init { this._rawData.Set("includeCanonicalHeader", value); } + } + + /// + /// Display name of the origin. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + public required string Prefix + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("prefix"); + } + init { this._rawData.Set("prefix", value); } + } + + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// URL used in the Canonical header (if enabled). + /// + public string? BaseUrlForCanonicalHeader + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("baseUrlForCanonicalHeader"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("baseUrlForCanonicalHeader", value); + } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.AccountName; + _ = this.Container; + _ = this.IncludeCanonicalHeader; + _ = this.Name; + _ = this.Prefix; + if (!JsonElement.DeepEquals(this.Type, JsonSerializer.SerializeToElement("AZURE_BLOB"))) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + _ = this.BaseUrlForCanonicalHeader; + } + + public OriginResponseAzureBlob() + { + this.Type = JsonSerializer.SerializeToElement("AZURE_BLOB"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public OriginResponseAzureBlob(OriginResponseAzureBlob originResponseAzureBlob) + : base(originResponseAzureBlob) { } +#pragma warning restore CS8618 + + public OriginResponseAzureBlob(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("AZURE_BLOB"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + OriginResponseAzureBlob(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static OriginResponseAzureBlob FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class OriginResponseAzureBlobFromRaw : IFromRawJson +{ + /// + public OriginResponseAzureBlob FromRawUnchecked( + IReadOnlyDictionary rawData + ) => OriginResponseAzureBlob.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class OriginResponseAkeneoPim : JsonModel +{ + /// + /// Unique identifier for the origin. This is generated by ImageKit when you + /// create a new origin. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// Akeneo instance base URL. + /// + public required string BaseUrl + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("baseUrl"); + } + init { this._rawData.Set("baseUrl", value); } + } + + /// + /// Whether to send a Canonical header. + /// + public required bool IncludeCanonicalHeader + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("includeCanonicalHeader"); + } + init { this._rawData.Set("includeCanonicalHeader", value); } + } + + /// + /// Display name of the origin. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// URL used in the Canonical header (if enabled). + /// + public string? BaseUrlForCanonicalHeader + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("baseUrlForCanonicalHeader"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("baseUrlForCanonicalHeader", value); + } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.BaseUrl; + _ = this.IncludeCanonicalHeader; + _ = this.Name; + if (!JsonElement.DeepEquals(this.Type, JsonSerializer.SerializeToElement("AKENEO_PIM"))) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + _ = this.BaseUrlForCanonicalHeader; + } + + public OriginResponseAkeneoPim() + { + this.Type = JsonSerializer.SerializeToElement("AKENEO_PIM"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public OriginResponseAkeneoPim(OriginResponseAkeneoPim originResponseAkeneoPim) + : base(originResponseAkeneoPim) { } +#pragma warning restore CS8618 + + public OriginResponseAkeneoPim(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("AKENEO_PIM"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + OriginResponseAkeneoPim(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static OriginResponseAkeneoPim FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class OriginResponseAkeneoPimFromRaw : IFromRawJson +{ + /// + public OriginResponseAkeneoPim FromRawUnchecked( + IReadOnlyDictionary rawData + ) => OriginResponseAkeneoPim.FromRawUnchecked(rawData); +} diff --git a/src/ImageKit/Models/Accounts/Origins/OriginUpdateParams.cs b/src/ImageKit/Models/Accounts/Origins/OriginUpdateParams.cs new file mode 100644 index 00000000..b06f6f79 --- /dev/null +++ b/src/ImageKit/Models/Accounts/Origins/OriginUpdateParams.cs @@ -0,0 +1,152 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using ImageKit.Core; +using Text = System.Text; + +namespace ImageKit.Models.Accounts.Origins; + +/// +/// **Note:** This API is currently in beta. Updates the origin identified by `id` +/// and returns the updated origin object. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class OriginUpdateParams : ParamsBase +{ + readonly JsonDictionary _rawBodyData = new(); + public IReadOnlyDictionary RawBodyData + { + get { return this._rawBodyData.Freeze(); } + } + + public string? ID { get; init; } + + /// + /// Schema for origin request resources. + /// + public required OriginRequest OriginRequest + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullClass("OriginRequest"); + } + init { this._rawBodyData.Set("OriginRequest", value); } + } + + public OriginUpdateParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public OriginUpdateParams(OriginUpdateParams originUpdateParams) + : base(originUpdateParams) + { + this.ID = originUpdateParams.ID; + + this._rawBodyData = new(originUpdateParams._rawBodyData); + } +#pragma warning restore CS8618 + + public OriginUpdateParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + OriginUpdateParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData, + FrozenDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } +#pragma warning restore CS8618 + + /// + public static OriginUpdateParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData), + FrozenDictionary.ToFrozenDictionary(rawBodyData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["ID"] = this.ID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(OriginUpdateParams? other) + { + if (other == null) + { + return false; + } + return (this.ID?.Equals(other.ID) ?? other.ID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder( + options.BaseUrl.ToString().TrimEnd('/') + + string.Format("/v1/accounts/origins/{0}", this.ID) + ) + { + Query = this.QueryString(options), + }.Uri; + } + + internal override HttpContent? BodyContent() + { + return new StringContent( + JsonSerializer.Serialize(this.RawBodyData, ModelBase.SerializerOptions), + Text::Encoding.UTF8, + "application/json" + ); + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointCreateParams.cs b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointCreateParams.cs new file mode 100644 index 00000000..bda360c8 --- /dev/null +++ b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointCreateParams.cs @@ -0,0 +1,761 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; +using ImageKit.Exceptions; +using Text = System.Text; + +namespace ImageKit.Models.Accounts.UrlEndpoints; + +/// +/// **Note:** This API is currently in beta. Creates a new URL‑endpoint and returns +/// the resulting object. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class UrlEndpointCreateParams : ParamsBase +{ + readonly JsonDictionary _rawBodyData = new(); + public IReadOnlyDictionary RawBodyData + { + get { return this._rawBodyData.Freeze(); } + } + + /// + /// Description of the URL endpoint. + /// + public required string Description + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullClass("description"); + } + init { this._rawBodyData.Set("description", value); } + } + + /// + /// Ordered list of origin IDs to try when the file isn’t in the Media Library; + /// ImageKit checks them in the sequence provided. Origin must be created before + /// it can be used in a URL endpoint. + /// + public IReadOnlyList? Origins + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableStruct>("origins"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set?>( + "origins", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Path segment appended to your base URL to form the endpoint (letters, digits, + /// and hyphens only — or empty for the default endpoint). + /// + public string? UrlPrefix + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass("urlPrefix"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("urlPrefix", value); + } + } + + /// + /// Configuration for third-party URL rewriting. + /// + public UrlRewriter? UrlRewriter + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass("urlRewriter"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("urlRewriter", value); + } + } + + public UrlEndpointCreateParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UrlEndpointCreateParams(UrlEndpointCreateParams urlEndpointCreateParams) + : base(urlEndpointCreateParams) + { + this._rawBodyData = new(urlEndpointCreateParams._rawBodyData); + } +#pragma warning restore CS8618 + + public UrlEndpointCreateParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UrlEndpointCreateParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData, + FrozenDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } +#pragma warning restore CS8618 + + /// + public static UrlEndpointCreateParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData), + FrozenDictionary.ToFrozenDictionary(rawBodyData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(UrlEndpointCreateParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder( + options.BaseUrl.ToString().TrimEnd('/') + "/v1/accounts/url-endpoints" + ) + { + Query = this.QueryString(options), + }.Uri; + } + + internal override HttpContent? BodyContent() + { + return new StringContent( + JsonSerializer.Serialize(this.RawBodyData, ModelBase.SerializerOptions), + Text::Encoding.UTF8, + "application/json" + ); + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} + +/// +/// Configuration for third-party URL rewriting. +/// +[JsonConverter(typeof(UrlRewriterConverter))] +public record class UrlRewriter : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public UrlRewriter(Cloudinary value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UrlRewriter(Imgix value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UrlRewriter(Akamai value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UrlRewriter(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickCloudinary(out var value)) { + /// // `value` is of type `Cloudinary` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickCloudinary([NotNullWhen(true)] out Cloudinary? value) + { + value = this.Value as Cloudinary; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickImgix(out var value)) { + /// // `value` is of type `Imgix` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickImgix([NotNullWhen(true)] out Imgix? value) + { + value = this.Value as Imgix; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickAkamai(out var value)) { + /// // `value` is of type `Akamai` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickAkamai([NotNullWhen(true)] out Akamai? value) + { + value = this.Value as Akamai; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (Cloudinary value) => {...}, + /// (Imgix value) => {...}, + /// (Akamai value) => {...} + /// ); + /// + /// + /// + public void Switch(Action cloudinary, Action imgix, Action akamai) + { + switch (this.Value) + { + case Cloudinary value: + cloudinary(value); + break; + case Imgix value: + imgix(value); + break; + case Akamai value: + akamai(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of UrlRewriter" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (Cloudinary value) => {...}, + /// (Imgix value) => {...}, + /// (Akamai value) => {...} + /// ); + /// + /// + /// + public T Match(Func cloudinary, Func imgix, Func akamai) + { + return this.Value switch + { + Cloudinary value => cloudinary(value), + Imgix value => imgix(value), + Akamai value => akamai(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of UrlRewriter" + ), + }; + } + + public static implicit operator UrlRewriter(Cloudinary value) => new(value); + + public static implicit operator UrlRewriter(Imgix value) => new(value); + + public static implicit operator UrlRewriter(Akamai value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException("Data did not match any variant of UrlRewriter"); + } + this.Switch( + (cloudinary) => cloudinary.Validate(), + (imgix) => imgix.Validate(), + (akamai) => akamai.Validate() + ); + } + + public virtual bool Equals(UrlRewriter? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class UrlRewriterConverter : JsonConverter +{ + public override UrlRewriter? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + string? type; + try + { + type = element.GetProperty("type").GetString(); + } + catch + { + type = null; + } + + switch (type) + { + case "CLOUDINARY": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + case "IMGIX": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + case "AKAMAI": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + default: + { + return new UrlRewriter(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + UrlRewriter value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Cloudinary : JsonModel +{ + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// Whether to preserve `/` in the rewritten URL. + /// + public bool? PreserveAssetDeliveryTypes + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("preserveAssetDeliveryTypes"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("preserveAssetDeliveryTypes", value); + } + } + + /// + public override void Validate() + { + if (!JsonElement.DeepEquals(this.Type, JsonSerializer.SerializeToElement("CLOUDINARY"))) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + _ = this.PreserveAssetDeliveryTypes; + } + + public Cloudinary() + { + this.Type = JsonSerializer.SerializeToElement("CLOUDINARY"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Cloudinary(Cloudinary cloudinary) + : base(cloudinary) { } +#pragma warning restore CS8618 + + public Cloudinary(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("CLOUDINARY"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Cloudinary(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static Cloudinary FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class CloudinaryFromRaw : IFromRawJson +{ + /// + public Cloudinary FromRawUnchecked(IReadOnlyDictionary rawData) => + Cloudinary.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(ImgixConverter))] +public record class Imgix +{ + public JsonElement Element { get; private init; } + + public Imgix() + { + Element = JsonSerializer.Deserialize( + """ + { + "type": "IMGIX" + } + """ + ); + } + + internal Imgix(JsonElement element) + { + Element = element; + } + + /// + /// Validates that the instance's underlying value is the expected constant. + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public void Validate() + { + if (this != new Imgix()) + { + throw new ImageKitInvalidDataException("Invalid value given for 'Imgix'"); + } + } + + public override int GetHashCode() + { + return 0; + } + + public virtual bool Equals(Imgix? other) + { + if (other == null) + { + return false; + } + + return JsonElement.DeepEquals(this.Element, other.Element); + } +} + +class ImgixConverter : JsonConverter +{ + public override Imgix? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write(Utf8JsonWriter writer, Imgix value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Element, options); + } +} + +[JsonConverter(typeof(AkamaiConverter))] +public record class Akamai +{ + public JsonElement Element { get; private init; } + + public Akamai() + { + Element = JsonSerializer.Deserialize( + """ + { + "type": "AKAMAI" + } + """ + ); + } + + internal Akamai(JsonElement element) + { + Element = element; + } + + /// + /// Validates that the instance's underlying value is the expected constant. + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public void Validate() + { + if (this != new Akamai()) + { + throw new ImageKitInvalidDataException("Invalid value given for 'Akamai'"); + } + } + + public override int GetHashCode() + { + return 0; + } + + public virtual bool Equals(Akamai? other) + { + if (other == null) + { + return false; + } + + return JsonElement.DeepEquals(this.Element, other.Element); + } +} + +class AkamaiConverter : JsonConverter +{ + public override Akamai? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write(Utf8JsonWriter writer, Akamai value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Element, options); + } +} diff --git a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointDeleteParams.cs b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointDeleteParams.cs new file mode 100644 index 00000000..a73ce4af --- /dev/null +++ b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointDeleteParams.cs @@ -0,0 +1,114 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using ImageKit.Core; + +namespace ImageKit.Models.Accounts.UrlEndpoints; + +/// +/// **Note:** This API is currently in beta. Deletes the URL‑endpoint identified +/// by `id`. You cannot delete the default URL‑endpoint created by ImageKit during +/// account creation. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class UrlEndpointDeleteParams : ParamsBase +{ + public string? ID { get; init; } + + public UrlEndpointDeleteParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UrlEndpointDeleteParams(UrlEndpointDeleteParams urlEndpointDeleteParams) + : base(urlEndpointDeleteParams) + { + this.ID = urlEndpointDeleteParams.ID; + } +#pragma warning restore CS8618 + + public UrlEndpointDeleteParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UrlEndpointDeleteParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } +#pragma warning restore CS8618 + + /// + public static UrlEndpointDeleteParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["ID"] = this.ID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(UrlEndpointDeleteParams? other) + { + if (other == null) + { + return false; + } + return (this.ID?.Equals(other.ID) ?? other.ID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder( + options.BaseUrl.ToString().TrimEnd('/') + + string.Format("/v1/accounts/url-endpoints/{0}", this.ID) + ) + { + Query = this.QueryString(options), + }.Uri; + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointGetParams.cs b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointGetParams.cs new file mode 100644 index 00000000..4c0aa186 --- /dev/null +++ b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointGetParams.cs @@ -0,0 +1,113 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using ImageKit.Core; + +namespace ImageKit.Models.Accounts.UrlEndpoints; + +/// +/// **Note:** This API is currently in beta. Retrieves the URL‑endpoint identified +/// by `id`. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class UrlEndpointGetParams : ParamsBase +{ + public string? ID { get; init; } + + public UrlEndpointGetParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UrlEndpointGetParams(UrlEndpointGetParams urlEndpointGetParams) + : base(urlEndpointGetParams) + { + this.ID = urlEndpointGetParams.ID; + } +#pragma warning restore CS8618 + + public UrlEndpointGetParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UrlEndpointGetParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } +#pragma warning restore CS8618 + + /// + public static UrlEndpointGetParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["ID"] = this.ID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(UrlEndpointGetParams? other) + { + if (other == null) + { + return false; + } + return (this.ID?.Equals(other.ID) ?? other.ID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder( + options.BaseUrl.ToString().TrimEnd('/') + + string.Format("/v1/accounts/url-endpoints/{0}", this.ID) + ) + { + Query = this.QueryString(options), + }.Uri; + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointListParams.cs b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointListParams.cs new file mode 100644 index 00000000..3b9db351 --- /dev/null +++ b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointListParams.cs @@ -0,0 +1,105 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using ImageKit.Core; + +namespace ImageKit.Models.Accounts.UrlEndpoints; + +/// +/// **Note:** This API is currently in beta. Returns an array of all URL‑endpoints +/// configured including the default URL-endpoint generated by ImageKit during account creation. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class UrlEndpointListParams : ParamsBase +{ + public UrlEndpointListParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UrlEndpointListParams(UrlEndpointListParams urlEndpointListParams) + : base(urlEndpointListParams) { } +#pragma warning restore CS8618 + + public UrlEndpointListParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UrlEndpointListParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } +#pragma warning restore CS8618 + + /// + public static UrlEndpointListParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(UrlEndpointListParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder( + options.BaseUrl.ToString().TrimEnd('/') + "/v1/accounts/url-endpoints" + ) + { + Query = this.QueryString(options), + }.Uri; + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointRequest.cs b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointRequest.cs new file mode 100644 index 00000000..45522fe3 --- /dev/null +++ b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointRequest.cs @@ -0,0 +1,760 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; +using ImageKit.Exceptions; + +namespace ImageKit.Models.Accounts.UrlEndpoints; + +/// +/// Schema for URL endpoint resource. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class UrlEndpointRequest : JsonModel +{ + /// + /// Description of the URL endpoint. + /// + public required string Description + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("description"); + } + init { this._rawData.Set("description", value); } + } + + /// + /// Ordered list of origin IDs to try when the file isn’t in the Media Library; + /// ImageKit checks them in the sequence provided. Origin must be created before + /// it can be used in a URL endpoint. + /// + public IReadOnlyList? Origins + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>("origins"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "origins", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Path segment appended to your base URL to form the endpoint (letters, digits, + /// and hyphens only — or empty for the default endpoint). + /// + public string? UrlPrefix + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("urlPrefix"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("urlPrefix", value); + } + } + + /// + /// Configuration for third-party URL rewriting. + /// + public UrlEndpointRequestUrlRewriter? UrlRewriter + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("urlRewriter"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("urlRewriter", value); + } + } + + /// + public override void Validate() + { + _ = this.Description; + _ = this.Origins; + _ = this.UrlPrefix; + this.UrlRewriter?.Validate(); + } + + public UrlEndpointRequest() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UrlEndpointRequest(UrlEndpointRequest urlEndpointRequest) + : base(urlEndpointRequest) { } +#pragma warning restore CS8618 + + public UrlEndpointRequest(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UrlEndpointRequest(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UrlEndpointRequest FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public UrlEndpointRequest(string description) + : this() + { + this.Description = description; + } +} + +class UrlEndpointRequestFromRaw : IFromRawJson +{ + /// + public UrlEndpointRequest FromRawUnchecked(IReadOnlyDictionary rawData) => + UrlEndpointRequest.FromRawUnchecked(rawData); +} + +/// +/// Configuration for third-party URL rewriting. +/// +[JsonConverter(typeof(UrlEndpointRequestUrlRewriterConverter))] +public record class UrlEndpointRequestUrlRewriter : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public UrlEndpointRequestUrlRewriter( + UrlEndpointRequestUrlRewriterCloudinary value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public UrlEndpointRequestUrlRewriter( + UrlEndpointRequestUrlRewriterImgix value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public UrlEndpointRequestUrlRewriter( + UrlEndpointRequestUrlRewriterAkamai value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public UrlEndpointRequestUrlRewriter(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickCloudinary(out var value)) { + /// // `value` is of type `UrlEndpointRequestUrlRewriterCloudinary` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickCloudinary( + [NotNullWhen(true)] out UrlEndpointRequestUrlRewriterCloudinary? value + ) + { + value = this.Value as UrlEndpointRequestUrlRewriterCloudinary; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickImgix(out var value)) { + /// // `value` is of type `UrlEndpointRequestUrlRewriterImgix` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickImgix([NotNullWhen(true)] out UrlEndpointRequestUrlRewriterImgix? value) + { + value = this.Value as UrlEndpointRequestUrlRewriterImgix; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickAkamai(out var value)) { + /// // `value` is of type `UrlEndpointRequestUrlRewriterAkamai` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickAkamai([NotNullWhen(true)] out UrlEndpointRequestUrlRewriterAkamai? value) + { + value = this.Value as UrlEndpointRequestUrlRewriterAkamai; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (UrlEndpointRequestUrlRewriterCloudinary value) => {...}, + /// (UrlEndpointRequestUrlRewriterImgix value) => {...}, + /// (UrlEndpointRequestUrlRewriterAkamai value) => {...} + /// ); + /// + /// + /// + public void Switch( + Action cloudinary, + Action imgix, + Action akamai + ) + { + switch (this.Value) + { + case UrlEndpointRequestUrlRewriterCloudinary value: + cloudinary(value); + break; + case UrlEndpointRequestUrlRewriterImgix value: + imgix(value); + break; + case UrlEndpointRequestUrlRewriterAkamai value: + akamai(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of UrlEndpointRequestUrlRewriter" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (UrlEndpointRequestUrlRewriterCloudinary value) => {...}, + /// (UrlEndpointRequestUrlRewriterImgix value) => {...}, + /// (UrlEndpointRequestUrlRewriterAkamai value) => {...} + /// ); + /// + /// + /// + public T Match( + Func cloudinary, + Func imgix, + Func akamai + ) + { + return this.Value switch + { + UrlEndpointRequestUrlRewriterCloudinary value => cloudinary(value), + UrlEndpointRequestUrlRewriterImgix value => imgix(value), + UrlEndpointRequestUrlRewriterAkamai value => akamai(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of UrlEndpointRequestUrlRewriter" + ), + }; + } + + public static implicit operator UrlEndpointRequestUrlRewriter( + UrlEndpointRequestUrlRewriterCloudinary value + ) => new(value); + + public static implicit operator UrlEndpointRequestUrlRewriter( + UrlEndpointRequestUrlRewriterImgix value + ) => new(value); + + public static implicit operator UrlEndpointRequestUrlRewriter( + UrlEndpointRequestUrlRewriterAkamai value + ) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of UrlEndpointRequestUrlRewriter" + ); + } + this.Switch( + (cloudinary) => cloudinary.Validate(), + (imgix) => imgix.Validate(), + (akamai) => akamai.Validate() + ); + } + + public virtual bool Equals(UrlEndpointRequestUrlRewriter? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class UrlEndpointRequestUrlRewriterConverter : JsonConverter +{ + public override UrlEndpointRequestUrlRewriter? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + string? type; + try + { + type = element.GetProperty("type").GetString(); + } + catch + { + type = null; + } + + switch (type) + { + case "CLOUDINARY": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + case "IMGIX": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + case "AKAMAI": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + default: + { + return new UrlEndpointRequestUrlRewriter(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + UrlEndpointRequestUrlRewriter value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + UrlEndpointRequestUrlRewriterCloudinary, + UrlEndpointRequestUrlRewriterCloudinaryFromRaw + >) +)] +public sealed record class UrlEndpointRequestUrlRewriterCloudinary : JsonModel +{ + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// Whether to preserve `/` in the rewritten URL. + /// + public bool? PreserveAssetDeliveryTypes + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("preserveAssetDeliveryTypes"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("preserveAssetDeliveryTypes", value); + } + } + + /// + public override void Validate() + { + if (!JsonElement.DeepEquals(this.Type, JsonSerializer.SerializeToElement("CLOUDINARY"))) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + _ = this.PreserveAssetDeliveryTypes; + } + + public UrlEndpointRequestUrlRewriterCloudinary() + { + this.Type = JsonSerializer.SerializeToElement("CLOUDINARY"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UrlEndpointRequestUrlRewriterCloudinary( + UrlEndpointRequestUrlRewriterCloudinary urlEndpointRequestUrlRewriterCloudinary + ) + : base(urlEndpointRequestUrlRewriterCloudinary) { } +#pragma warning restore CS8618 + + public UrlEndpointRequestUrlRewriterCloudinary(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("CLOUDINARY"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UrlEndpointRequestUrlRewriterCloudinary(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UrlEndpointRequestUrlRewriterCloudinary FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UrlEndpointRequestUrlRewriterCloudinaryFromRaw + : IFromRawJson +{ + /// + public UrlEndpointRequestUrlRewriterCloudinary FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UrlEndpointRequestUrlRewriterCloudinary.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(UrlEndpointRequestUrlRewriterImgixConverter))] +public record class UrlEndpointRequestUrlRewriterImgix +{ + public JsonElement Element { get; private init; } + + public UrlEndpointRequestUrlRewriterImgix() + { + Element = JsonSerializer.Deserialize( + """ + { + "type": "IMGIX" + } + """ + ); + } + + internal UrlEndpointRequestUrlRewriterImgix(JsonElement element) + { + Element = element; + } + + /// + /// Validates that the instance's underlying value is the expected constant. + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public void Validate() + { + if (this != new UrlEndpointRequestUrlRewriterImgix()) + { + throw new ImageKitInvalidDataException( + "Invalid value given for 'UrlEndpointRequestUrlRewriterImgix'" + ); + } + } + + public override int GetHashCode() + { + return 0; + } + + public virtual bool Equals(UrlEndpointRequestUrlRewriterImgix? other) + { + if (other == null) + { + return false; + } + + return JsonElement.DeepEquals(this.Element, other.Element); + } +} + +class UrlEndpointRequestUrlRewriterImgixConverter + : JsonConverter +{ + public override UrlEndpointRequestUrlRewriterImgix? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write( + Utf8JsonWriter writer, + UrlEndpointRequestUrlRewriterImgix value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Element, options); + } +} + +[JsonConverter(typeof(UrlEndpointRequestUrlRewriterAkamaiConverter))] +public record class UrlEndpointRequestUrlRewriterAkamai +{ + public JsonElement Element { get; private init; } + + public UrlEndpointRequestUrlRewriterAkamai() + { + Element = JsonSerializer.Deserialize( + """ + { + "type": "AKAMAI" + } + """ + ); + } + + internal UrlEndpointRequestUrlRewriterAkamai(JsonElement element) + { + Element = element; + } + + /// + /// Validates that the instance's underlying value is the expected constant. + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public void Validate() + { + if (this != new UrlEndpointRequestUrlRewriterAkamai()) + { + throw new ImageKitInvalidDataException( + "Invalid value given for 'UrlEndpointRequestUrlRewriterAkamai'" + ); + } + } + + public override int GetHashCode() + { + return 0; + } + + public virtual bool Equals(UrlEndpointRequestUrlRewriterAkamai? other) + { + if (other == null) + { + return false; + } + + return JsonElement.DeepEquals(this.Element, other.Element); + } +} + +class UrlEndpointRequestUrlRewriterAkamaiConverter + : JsonConverter +{ + public override UrlEndpointRequestUrlRewriterAkamai? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write( + Utf8JsonWriter writer, + UrlEndpointRequestUrlRewriterAkamai value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Element, options); + } +} diff --git a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointResponse.cs b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointResponse.cs new file mode 100644 index 00000000..07d928a0 --- /dev/null +++ b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointResponse.cs @@ -0,0 +1,756 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; +using ImageKit.Exceptions; + +namespace ImageKit.Models.Accounts.UrlEndpoints; + +/// +/// URL‑endpoint object as returned by the API. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class UrlEndpointResponse : JsonModel +{ + /// + /// Unique identifier for the URL-endpoint. This is generated by ImageKit when + /// you create a new URL-endpoint. For the default URL-endpoint, this is always `default`. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// Description of the URL endpoint. + /// + public required string Description + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("description"); + } + init { this._rawData.Set("description", value); } + } + + /// + /// Ordered list of origin IDs to try when the file isn’t in the Media Library; + /// ImageKit checks them in the sequence provided. Origin must be created before + /// it can be used in a URL endpoint. + /// + public required IReadOnlyList Origins + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("origins"); + } + init + { + this._rawData.Set>( + "origins", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Path segment appended to your base URL to form the endpoint (letters, digits, + /// and hyphens only — or empty for the default endpoint). + /// + public required string UrlPrefix + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("urlPrefix"); + } + init { this._rawData.Set("urlPrefix", value); } + } + + /// + /// Configuration for third-party URL rewriting. + /// + public UrlEndpointResponseUrlRewriter? UrlRewriter + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("urlRewriter"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("urlRewriter", value); + } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.Description; + _ = this.Origins; + _ = this.UrlPrefix; + this.UrlRewriter?.Validate(); + } + + public UrlEndpointResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UrlEndpointResponse(UrlEndpointResponse urlEndpointResponse) + : base(urlEndpointResponse) { } +#pragma warning restore CS8618 + + public UrlEndpointResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UrlEndpointResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UrlEndpointResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UrlEndpointResponseFromRaw : IFromRawJson +{ + /// + public UrlEndpointResponse FromRawUnchecked(IReadOnlyDictionary rawData) => + UrlEndpointResponse.FromRawUnchecked(rawData); +} + +/// +/// Configuration for third-party URL rewriting. +/// +[JsonConverter(typeof(UrlEndpointResponseUrlRewriterConverter))] +public record class UrlEndpointResponseUrlRewriter : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public UrlEndpointResponseUrlRewriter( + UrlEndpointResponseUrlRewriterCloudinary value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public UrlEndpointResponseUrlRewriter( + UrlEndpointResponseUrlRewriterImgix value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public UrlEndpointResponseUrlRewriter( + UrlEndpointResponseUrlRewriterAkamai value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public UrlEndpointResponseUrlRewriter(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickCloudinary(out var value)) { + /// // `value` is of type `UrlEndpointResponseUrlRewriterCloudinary` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickCloudinary( + [NotNullWhen(true)] out UrlEndpointResponseUrlRewriterCloudinary? value + ) + { + value = this.Value as UrlEndpointResponseUrlRewriterCloudinary; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickImgix(out var value)) { + /// // `value` is of type `UrlEndpointResponseUrlRewriterImgix` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickImgix([NotNullWhen(true)] out UrlEndpointResponseUrlRewriterImgix? value) + { + value = this.Value as UrlEndpointResponseUrlRewriterImgix; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickAkamai(out var value)) { + /// // `value` is of type `UrlEndpointResponseUrlRewriterAkamai` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickAkamai([NotNullWhen(true)] out UrlEndpointResponseUrlRewriterAkamai? value) + { + value = this.Value as UrlEndpointResponseUrlRewriterAkamai; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (UrlEndpointResponseUrlRewriterCloudinary value) => {...}, + /// (UrlEndpointResponseUrlRewriterImgix value) => {...}, + /// (UrlEndpointResponseUrlRewriterAkamai value) => {...} + /// ); + /// + /// + /// + public void Switch( + Action cloudinary, + Action imgix, + Action akamai + ) + { + switch (this.Value) + { + case UrlEndpointResponseUrlRewriterCloudinary value: + cloudinary(value); + break; + case UrlEndpointResponseUrlRewriterImgix value: + imgix(value); + break; + case UrlEndpointResponseUrlRewriterAkamai value: + akamai(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of UrlEndpointResponseUrlRewriter" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (UrlEndpointResponseUrlRewriterCloudinary value) => {...}, + /// (UrlEndpointResponseUrlRewriterImgix value) => {...}, + /// (UrlEndpointResponseUrlRewriterAkamai value) => {...} + /// ); + /// + /// + /// + public T Match( + Func cloudinary, + Func imgix, + Func akamai + ) + { + return this.Value switch + { + UrlEndpointResponseUrlRewriterCloudinary value => cloudinary(value), + UrlEndpointResponseUrlRewriterImgix value => imgix(value), + UrlEndpointResponseUrlRewriterAkamai value => akamai(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of UrlEndpointResponseUrlRewriter" + ), + }; + } + + public static implicit operator UrlEndpointResponseUrlRewriter( + UrlEndpointResponseUrlRewriterCloudinary value + ) => new(value); + + public static implicit operator UrlEndpointResponseUrlRewriter( + UrlEndpointResponseUrlRewriterImgix value + ) => new(value); + + public static implicit operator UrlEndpointResponseUrlRewriter( + UrlEndpointResponseUrlRewriterAkamai value + ) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of UrlEndpointResponseUrlRewriter" + ); + } + this.Switch( + (cloudinary) => cloudinary.Validate(), + (imgix) => imgix.Validate(), + (akamai) => akamai.Validate() + ); + } + + public virtual bool Equals(UrlEndpointResponseUrlRewriter? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class UrlEndpointResponseUrlRewriterConverter : JsonConverter +{ + public override UrlEndpointResponseUrlRewriter? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + string? type; + try + { + type = element.GetProperty("type").GetString(); + } + catch + { + type = null; + } + + switch (type) + { + case "CLOUDINARY": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + case "IMGIX": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + case "AKAMAI": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + default: + { + return new UrlEndpointResponseUrlRewriter(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + UrlEndpointResponseUrlRewriter value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + UrlEndpointResponseUrlRewriterCloudinary, + UrlEndpointResponseUrlRewriterCloudinaryFromRaw + >) +)] +public sealed record class UrlEndpointResponseUrlRewriterCloudinary : JsonModel +{ + /// + /// Whether to preserve `/` in the rewritten URL. + /// + public required bool PreserveAssetDeliveryTypes + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("preserveAssetDeliveryTypes"); + } + init { this._rawData.Set("preserveAssetDeliveryTypes", value); } + } + + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + public override void Validate() + { + _ = this.PreserveAssetDeliveryTypes; + if (!JsonElement.DeepEquals(this.Type, JsonSerializer.SerializeToElement("CLOUDINARY"))) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + } + + public UrlEndpointResponseUrlRewriterCloudinary() + { + this.Type = JsonSerializer.SerializeToElement("CLOUDINARY"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UrlEndpointResponseUrlRewriterCloudinary( + UrlEndpointResponseUrlRewriterCloudinary urlEndpointResponseUrlRewriterCloudinary + ) + : base(urlEndpointResponseUrlRewriterCloudinary) { } +#pragma warning restore CS8618 + + public UrlEndpointResponseUrlRewriterCloudinary( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("CLOUDINARY"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UrlEndpointResponseUrlRewriterCloudinary(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UrlEndpointResponseUrlRewriterCloudinary FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public UrlEndpointResponseUrlRewriterCloudinary(bool preserveAssetDeliveryTypes) + : this() + { + this.PreserveAssetDeliveryTypes = preserveAssetDeliveryTypes; + } +} + +class UrlEndpointResponseUrlRewriterCloudinaryFromRaw + : IFromRawJson +{ + /// + public UrlEndpointResponseUrlRewriterCloudinary FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UrlEndpointResponseUrlRewriterCloudinary.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(UrlEndpointResponseUrlRewriterImgixConverter))] +public record class UrlEndpointResponseUrlRewriterImgix +{ + public JsonElement Element { get; private init; } + + public UrlEndpointResponseUrlRewriterImgix() + { + Element = JsonSerializer.Deserialize( + """ + { + "type": "IMGIX" + } + """ + ); + } + + internal UrlEndpointResponseUrlRewriterImgix(JsonElement element) + { + Element = element; + } + + /// + /// Validates that the instance's underlying value is the expected constant. + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public void Validate() + { + if (this != new UrlEndpointResponseUrlRewriterImgix()) + { + throw new ImageKitInvalidDataException( + "Invalid value given for 'UrlEndpointResponseUrlRewriterImgix'" + ); + } + } + + public override int GetHashCode() + { + return 0; + } + + public virtual bool Equals(UrlEndpointResponseUrlRewriterImgix? other) + { + if (other == null) + { + return false; + } + + return JsonElement.DeepEquals(this.Element, other.Element); + } +} + +class UrlEndpointResponseUrlRewriterImgixConverter + : JsonConverter +{ + public override UrlEndpointResponseUrlRewriterImgix? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write( + Utf8JsonWriter writer, + UrlEndpointResponseUrlRewriterImgix value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Element, options); + } +} + +[JsonConverter(typeof(UrlEndpointResponseUrlRewriterAkamaiConverter))] +public record class UrlEndpointResponseUrlRewriterAkamai +{ + public JsonElement Element { get; private init; } + + public UrlEndpointResponseUrlRewriterAkamai() + { + Element = JsonSerializer.Deserialize( + """ + { + "type": "AKAMAI" + } + """ + ); + } + + internal UrlEndpointResponseUrlRewriterAkamai(JsonElement element) + { + Element = element; + } + + /// + /// Validates that the instance's underlying value is the expected constant. + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public void Validate() + { + if (this != new UrlEndpointResponseUrlRewriterAkamai()) + { + throw new ImageKitInvalidDataException( + "Invalid value given for 'UrlEndpointResponseUrlRewriterAkamai'" + ); + } + } + + public override int GetHashCode() + { + return 0; + } + + public virtual bool Equals(UrlEndpointResponseUrlRewriterAkamai? other) + { + if (other == null) + { + return false; + } + + return JsonElement.DeepEquals(this.Element, other.Element); + } +} + +class UrlEndpointResponseUrlRewriterAkamaiConverter + : JsonConverter +{ + public override UrlEndpointResponseUrlRewriterAkamai? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write( + Utf8JsonWriter writer, + UrlEndpointResponseUrlRewriterAkamai value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Element, options); + } +} diff --git a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParams.cs b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParams.cs new file mode 100644 index 00000000..e550eaaf --- /dev/null +++ b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParams.cs @@ -0,0 +1,839 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; +using ImageKit.Exceptions; +using Text = System.Text; + +namespace ImageKit.Models.Accounts.UrlEndpoints; + +/// +/// **Note:** This API is currently in beta. Updates the URL‑endpoint identified +/// by `id` and returns the updated object. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class UrlEndpointUpdateParams : ParamsBase +{ + readonly JsonDictionary _rawBodyData = new(); + public IReadOnlyDictionary RawBodyData + { + get { return this._rawBodyData.Freeze(); } + } + + public string? ID { get; init; } + + /// + /// Description of the URL endpoint. + /// + public required string Description + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullClass("description"); + } + init { this._rawBodyData.Set("description", value); } + } + + /// + /// Ordered list of origin IDs to try when the file isn’t in the Media Library; + /// ImageKit checks them in the sequence provided. Origin must be created before + /// it can be used in a URL endpoint. + /// + public IReadOnlyList? Origins + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableStruct>("origins"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set?>( + "origins", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Path segment appended to your base URL to form the endpoint (letters, digits, + /// and hyphens only — or empty for the default endpoint). + /// + public string? UrlPrefix + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass("urlPrefix"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("urlPrefix", value); + } + } + + /// + /// Configuration for third-party URL rewriting. + /// + public UrlEndpointUpdateParamsUrlRewriter? UrlRewriter + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass( + "urlRewriter" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("urlRewriter", value); + } + } + + public UrlEndpointUpdateParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UrlEndpointUpdateParams(UrlEndpointUpdateParams urlEndpointUpdateParams) + : base(urlEndpointUpdateParams) + { + this.ID = urlEndpointUpdateParams.ID; + + this._rawBodyData = new(urlEndpointUpdateParams._rawBodyData); + } +#pragma warning restore CS8618 + + public UrlEndpointUpdateParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UrlEndpointUpdateParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData, + FrozenDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } +#pragma warning restore CS8618 + + /// + public static UrlEndpointUpdateParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData), + FrozenDictionary.ToFrozenDictionary(rawBodyData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["ID"] = this.ID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(UrlEndpointUpdateParams? other) + { + if (other == null) + { + return false; + } + return (this.ID?.Equals(other.ID) ?? other.ID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder( + options.BaseUrl.ToString().TrimEnd('/') + + string.Format("/v1/accounts/url-endpoints/{0}", this.ID) + ) + { + Query = this.QueryString(options), + }.Uri; + } + + internal override HttpContent? BodyContent() + { + return new StringContent( + JsonSerializer.Serialize(this.RawBodyData, ModelBase.SerializerOptions), + Text::Encoding.UTF8, + "application/json" + ); + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} + +/// +/// Configuration for third-party URL rewriting. +/// +[JsonConverter(typeof(UrlEndpointUpdateParamsUrlRewriterConverter))] +public record class UrlEndpointUpdateParamsUrlRewriter : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public UrlEndpointUpdateParamsUrlRewriter( + UrlEndpointUpdateParamsUrlRewriterCloudinary value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public UrlEndpointUpdateParamsUrlRewriter( + UrlEndpointUpdateParamsUrlRewriterImgix value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public UrlEndpointUpdateParamsUrlRewriter( + UrlEndpointUpdateParamsUrlRewriterAkamai value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public UrlEndpointUpdateParamsUrlRewriter(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickCloudinary(out var value)) { + /// // `value` is of type `UrlEndpointUpdateParamsUrlRewriterCloudinary` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickCloudinary( + [NotNullWhen(true)] out UrlEndpointUpdateParamsUrlRewriterCloudinary? value + ) + { + value = this.Value as UrlEndpointUpdateParamsUrlRewriterCloudinary; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickImgix(out var value)) { + /// // `value` is of type `UrlEndpointUpdateParamsUrlRewriterImgix` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickImgix([NotNullWhen(true)] out UrlEndpointUpdateParamsUrlRewriterImgix? value) + { + value = this.Value as UrlEndpointUpdateParamsUrlRewriterImgix; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickAkamai(out var value)) { + /// // `value` is of type `UrlEndpointUpdateParamsUrlRewriterAkamai` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickAkamai( + [NotNullWhen(true)] out UrlEndpointUpdateParamsUrlRewriterAkamai? value + ) + { + value = this.Value as UrlEndpointUpdateParamsUrlRewriterAkamai; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (UrlEndpointUpdateParamsUrlRewriterCloudinary value) => {...}, + /// (UrlEndpointUpdateParamsUrlRewriterImgix value) => {...}, + /// (UrlEndpointUpdateParamsUrlRewriterAkamai value) => {...} + /// ); + /// + /// + /// + public void Switch( + Action cloudinary, + Action imgix, + Action akamai + ) + { + switch (this.Value) + { + case UrlEndpointUpdateParamsUrlRewriterCloudinary value: + cloudinary(value); + break; + case UrlEndpointUpdateParamsUrlRewriterImgix value: + imgix(value); + break; + case UrlEndpointUpdateParamsUrlRewriterAkamai value: + akamai(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of UrlEndpointUpdateParamsUrlRewriter" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (UrlEndpointUpdateParamsUrlRewriterCloudinary value) => {...}, + /// (UrlEndpointUpdateParamsUrlRewriterImgix value) => {...}, + /// (UrlEndpointUpdateParamsUrlRewriterAkamai value) => {...} + /// ); + /// + /// + /// + public T Match( + Func cloudinary, + Func imgix, + Func akamai + ) + { + return this.Value switch + { + UrlEndpointUpdateParamsUrlRewriterCloudinary value => cloudinary(value), + UrlEndpointUpdateParamsUrlRewriterImgix value => imgix(value), + UrlEndpointUpdateParamsUrlRewriterAkamai value => akamai(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of UrlEndpointUpdateParamsUrlRewriter" + ), + }; + } + + public static implicit operator UrlEndpointUpdateParamsUrlRewriter( + UrlEndpointUpdateParamsUrlRewriterCloudinary value + ) => new(value); + + public static implicit operator UrlEndpointUpdateParamsUrlRewriter( + UrlEndpointUpdateParamsUrlRewriterImgix value + ) => new(value); + + public static implicit operator UrlEndpointUpdateParamsUrlRewriter( + UrlEndpointUpdateParamsUrlRewriterAkamai value + ) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of UrlEndpointUpdateParamsUrlRewriter" + ); + } + this.Switch( + (cloudinary) => cloudinary.Validate(), + (imgix) => imgix.Validate(), + (akamai) => akamai.Validate() + ); + } + + public virtual bool Equals(UrlEndpointUpdateParamsUrlRewriter? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class UrlEndpointUpdateParamsUrlRewriterConverter + : JsonConverter +{ + public override UrlEndpointUpdateParamsUrlRewriter? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + string? type; + try + { + type = element.GetProperty("type").GetString(); + } + catch + { + type = null; + } + + switch (type) + { + case "CLOUDINARY": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + case "IMGIX": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + case "AKAMAI": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + default: + { + return new UrlEndpointUpdateParamsUrlRewriter(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + UrlEndpointUpdateParamsUrlRewriter value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + UrlEndpointUpdateParamsUrlRewriterCloudinary, + UrlEndpointUpdateParamsUrlRewriterCloudinaryFromRaw + >) +)] +public sealed record class UrlEndpointUpdateParamsUrlRewriterCloudinary : JsonModel +{ + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// Whether to preserve `/` in the rewritten URL. + /// + public bool? PreserveAssetDeliveryTypes + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("preserveAssetDeliveryTypes"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("preserveAssetDeliveryTypes", value); + } + } + + /// + public override void Validate() + { + if (!JsonElement.DeepEquals(this.Type, JsonSerializer.SerializeToElement("CLOUDINARY"))) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + _ = this.PreserveAssetDeliveryTypes; + } + + public UrlEndpointUpdateParamsUrlRewriterCloudinary() + { + this.Type = JsonSerializer.SerializeToElement("CLOUDINARY"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UrlEndpointUpdateParamsUrlRewriterCloudinary( + UrlEndpointUpdateParamsUrlRewriterCloudinary urlEndpointUpdateParamsUrlRewriterCloudinary + ) + : base(urlEndpointUpdateParamsUrlRewriterCloudinary) { } +#pragma warning restore CS8618 + + public UrlEndpointUpdateParamsUrlRewriterCloudinary( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("CLOUDINARY"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UrlEndpointUpdateParamsUrlRewriterCloudinary(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UrlEndpointUpdateParamsUrlRewriterCloudinary FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UrlEndpointUpdateParamsUrlRewriterCloudinaryFromRaw + : IFromRawJson +{ + /// + public UrlEndpointUpdateParamsUrlRewriterCloudinary FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UrlEndpointUpdateParamsUrlRewriterCloudinary.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(UrlEndpointUpdateParamsUrlRewriterImgixConverter))] +public record class UrlEndpointUpdateParamsUrlRewriterImgix +{ + public JsonElement Element { get; private init; } + + public UrlEndpointUpdateParamsUrlRewriterImgix() + { + Element = JsonSerializer.Deserialize( + """ + { + "type": "IMGIX" + } + """ + ); + } + + internal UrlEndpointUpdateParamsUrlRewriterImgix(JsonElement element) + { + Element = element; + } + + /// + /// Validates that the instance's underlying value is the expected constant. + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public void Validate() + { + if (this != new UrlEndpointUpdateParamsUrlRewriterImgix()) + { + throw new ImageKitInvalidDataException( + "Invalid value given for 'UrlEndpointUpdateParamsUrlRewriterImgix'" + ); + } + } + + public override int GetHashCode() + { + return 0; + } + + public virtual bool Equals(UrlEndpointUpdateParamsUrlRewriterImgix? other) + { + if (other == null) + { + return false; + } + + return JsonElement.DeepEquals(this.Element, other.Element); + } +} + +class UrlEndpointUpdateParamsUrlRewriterImgixConverter + : JsonConverter +{ + public override UrlEndpointUpdateParamsUrlRewriterImgix? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write( + Utf8JsonWriter writer, + UrlEndpointUpdateParamsUrlRewriterImgix value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Element, options); + } +} + +[JsonConverter(typeof(UrlEndpointUpdateParamsUrlRewriterAkamaiConverter))] +public record class UrlEndpointUpdateParamsUrlRewriterAkamai +{ + public JsonElement Element { get; private init; } + + public UrlEndpointUpdateParamsUrlRewriterAkamai() + { + Element = JsonSerializer.Deserialize( + """ + { + "type": "AKAMAI" + } + """ + ); + } + + internal UrlEndpointUpdateParamsUrlRewriterAkamai(JsonElement element) + { + Element = element; + } + + /// + /// Validates that the instance's underlying value is the expected constant. + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public void Validate() + { + if (this != new UrlEndpointUpdateParamsUrlRewriterAkamai()) + { + throw new ImageKitInvalidDataException( + "Invalid value given for 'UrlEndpointUpdateParamsUrlRewriterAkamai'" + ); + } + } + + public override int GetHashCode() + { + return 0; + } + + public virtual bool Equals(UrlEndpointUpdateParamsUrlRewriterAkamai? other) + { + if (other == null) + { + return false; + } + + return JsonElement.DeepEquals(this.Element, other.Element); + } +} + +class UrlEndpointUpdateParamsUrlRewriterAkamaiConverter + : JsonConverter +{ + public override UrlEndpointUpdateParamsUrlRewriterAkamai? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write( + Utf8JsonWriter writer, + UrlEndpointUpdateParamsUrlRewriterAkamai value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Element, options); + } +} diff --git a/src/ImageKit/Models/Accounts/Usage/UsageGetParams.cs b/src/ImageKit/Models/Accounts/Usage/UsageGetParams.cs new file mode 100644 index 00000000..42f9e9da --- /dev/null +++ b/src/ImageKit/Models/Accounts/Usage/UsageGetParams.cs @@ -0,0 +1,133 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using ImageKit.Core; + +namespace ImageKit.Models.Accounts.Usage; + +/// +/// Get the account usage information between two dates. Note that the API response +/// includes data from the start date while excluding data from the end date. In other +/// words, the data covers the period starting from the specified start date up to, +/// but not including, the end date. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class UsageGetParams : ParamsBase +{ + /// + /// Specify a `endDate` in `YYYY-MM-DD` format. It should be after the `startDate`. + /// The difference between `startDate` and `endDate` should be less than 90 days. + /// + public required string EndDate + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNotNullClass("endDate"); + } + init { this._rawQueryData.Set("endDate", value); } + } + + /// + /// Specify a `startDate` in `YYYY-MM-DD` format. It should be before the `endDate`. + /// The difference between `startDate` and `endDate` should be less than 90 days. + /// + public required string StartDate + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNotNullClass("startDate"); + } + init { this._rawQueryData.Set("startDate", value); } + } + + public UsageGetParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UsageGetParams(UsageGetParams usageGetParams) + : base(usageGetParams) { } +#pragma warning restore CS8618 + + public UsageGetParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UsageGetParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } +#pragma warning restore CS8618 + + /// + public static UsageGetParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(UsageGetParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/v1/accounts/usage") + { + Query = this.QueryString(options), + }.Uri; + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/ImageKit/Models/Accounts/Usage/UsageGetResponse.cs b/src/ImageKit/Models/Accounts/Usage/UsageGetResponse.cs new file mode 100644 index 00000000..b365a3b2 --- /dev/null +++ b/src/ImageKit/Models/Accounts/Usage/UsageGetResponse.cs @@ -0,0 +1,163 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; + +namespace ImageKit.Models.Accounts.Usage; + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class UsageGetResponse : JsonModel +{ + /// + /// Amount of bandwidth used in bytes. + /// + public long? BandwidthBytes + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("bandwidthBytes"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("bandwidthBytes", value); + } + } + + /// + /// Number of extension units used. + /// + public long? ExtensionUnitsCount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("extensionUnitsCount"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("extensionUnitsCount", value); + } + } + + /// + /// Storage used by media library in bytes. + /// + public long? MediaLibraryStorageBytes + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("mediaLibraryStorageBytes"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("mediaLibraryStorageBytes", value); + } + } + + /// + /// Storage used by the original cache in bytes. + /// + public long? OriginalCacheStorageBytes + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("originalCacheStorageBytes"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("originalCacheStorageBytes", value); + } + } + + /// + /// Number of video processing units used. + /// + public long? VideoProcessingUnitsCount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("videoProcessingUnitsCount"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("videoProcessingUnitsCount", value); + } + } + + /// + public override void Validate() + { + _ = this.BandwidthBytes; + _ = this.ExtensionUnitsCount; + _ = this.MediaLibraryStorageBytes; + _ = this.OriginalCacheStorageBytes; + _ = this.VideoProcessingUnitsCount; + } + + public UsageGetResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UsageGetResponse(UsageGetResponse usageGetResponse) + : base(usageGetResponse) { } +#pragma warning restore CS8618 + + public UsageGetResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UsageGetResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UsageGetResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UsageGetResponseFromRaw : IFromRawJson +{ + /// + public UsageGetResponse FromRawUnchecked(IReadOnlyDictionary rawData) => + UsageGetResponse.FromRawUnchecked(rawData); +} diff --git a/src/ImageKit/Models/Assets/AssetListParams.cs b/src/ImageKit/Models/Assets/AssetListParams.cs new file mode 100644 index 00000000..d095f4e3 --- /dev/null +++ b/src/ImageKit/Models/Assets/AssetListParams.cs @@ -0,0 +1,463 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; +using ImageKit.Exceptions; +using System = System; + +namespace ImageKit.Models.Assets; + +/// +/// This API can list all the uploaded files and folders in your ImageKit.io media +/// library. In addition, you can fine-tune your query by specifying various filters +/// by generating a query string in a Lucene-like syntax and provide this generated +/// string as the value of the `searchQuery`. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class AssetListParams : ParamsBase +{ + /// + /// Filter results by file type. + /// + /// - `all` — include all file types - `image` — include only image files + /// - `non-image` — include only non-image files (e.g., JS, CSS, video) + /// + public ApiEnum? FileType + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableClass>("fileType"); + } + init + { + if (value == null) + { + return; + } + + this._rawQueryData.Set("fileType", value); + } + } + + /// + /// The maximum number of results to return in response. + /// + public long? Limit + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableStruct("limit"); + } + init + { + if (value == null) + { + return; + } + + this._rawQueryData.Set("limit", value); + } + } + + /// + /// Folder path if you want to limit the search within a specific folder. For + /// example, `/sales-banner/` will only search in folder sales-banner. + /// + /// Note : If your use case involves searching within a folder as well as + /// its subfolders, you can use `path` parameter in `searchQuery` with appropriate + /// operator. Checkout [Supported parameters](/docs/api-reference/digital-asset-management-dam/list-and-search-assets#supported-parameters) + /// for more information. + /// + public string? Path + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableClass("path"); + } + init + { + if (value == null) + { + return; + } + + this._rawQueryData.Set("path", value); + } + } + + /// + /// Query string in a Lucene-like query language e.g. `createdAt > "7d"`. + /// + /// Note : When the searchQuery parameter is present, the following query + /// parameters will have no effect on the result: + /// + /// 1. `tags` 2. `type` 3. `name` + /// + /// [Learn more](/docs/api-reference/digital-asset-management-dam/list-and-search-assets#advanced-search-queries) + /// from examples. + /// + public string? SearchQuery + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableClass("searchQuery"); + } + init + { + if (value == null) + { + return; + } + + this._rawQueryData.Set("searchQuery", value); + } + } + + /// + /// The number of results to skip before returning results. + /// + public long? Skip + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableStruct("skip"); + } + init + { + if (value == null) + { + return; + } + + this._rawQueryData.Set("skip", value); + } + } + + /// + /// Sort the results by one of the supported fields in ascending or descending + /// order. + /// + public ApiEnum? Sort + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableClass>("sort"); + } + init + { + if (value == null) + { + return; + } + + this._rawQueryData.Set("sort", value); + } + } + + /// + /// Filter results by asset type. + /// + /// - `file` — returns only files - `file-version` — returns specific + /// file versions - `folder` — returns only folders - `all` — returns both + /// files and folders (excludes `file-version`) + /// + public ApiEnum? Type + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableClass< + ApiEnum + >("type"); + } + init + { + if (value == null) + { + return; + } + + this._rawQueryData.Set("type", value); + } + } + + public AssetListParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public AssetListParams(AssetListParams assetListParams) + : base(assetListParams) { } +#pragma warning restore CS8618 + + public AssetListParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + AssetListParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } +#pragma warning restore CS8618 + + /// + public static AssetListParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(AssetListParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + + public override System::Uri Url(ClientOptions options) + { + return new System::UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/v1/files") + { + Query = this.QueryString(options), + }.Uri; + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} + +/// +/// Filter results by file type. +/// +/// - `all` — include all file types - `image` — include only image files +/// - `non-image` — include only non-image files (e.g., JS, CSS, video) +/// +[JsonConverter(typeof(FileTypeConverter))] +public enum FileType +{ + All, + Image, + NonImage, +} + +sealed class FileTypeConverter : JsonConverter +{ + public override FileType Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "all" => FileType.All, + "image" => FileType.Image, + "non-image" => FileType.NonImage, + _ => (FileType)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, FileType value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + FileType.All => "all", + FileType.Image => "image", + FileType.NonImage => "non-image", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Sort the results by one of the supported fields in ascending or descending order. +/// +[JsonConverter(typeof(SortConverter))] +public enum Sort +{ + AscName, + DescName, + AscCreated, + DescCreated, + AscUpdated, + DescUpdated, + AscHeight, + DescHeight, + AscWidth, + DescWidth, + AscSize, + DescSize, + AscRelevance, + DescRelevance, +} + +sealed class SortConverter : JsonConverter +{ + public override Sort Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "ASC_NAME" => Sort.AscName, + "DESC_NAME" => Sort.DescName, + "ASC_CREATED" => Sort.AscCreated, + "DESC_CREATED" => Sort.DescCreated, + "ASC_UPDATED" => Sort.AscUpdated, + "DESC_UPDATED" => Sort.DescUpdated, + "ASC_HEIGHT" => Sort.AscHeight, + "DESC_HEIGHT" => Sort.DescHeight, + "ASC_WIDTH" => Sort.AscWidth, + "DESC_WIDTH" => Sort.DescWidth, + "ASC_SIZE" => Sort.AscSize, + "DESC_SIZE" => Sort.DescSize, + "ASC_RELEVANCE" => Sort.AscRelevance, + "DESC_RELEVANCE" => Sort.DescRelevance, + _ => (Sort)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Sort value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + Sort.AscName => "ASC_NAME", + Sort.DescName => "DESC_NAME", + Sort.AscCreated => "ASC_CREATED", + Sort.DescCreated => "DESC_CREATED", + Sort.AscUpdated => "ASC_UPDATED", + Sort.DescUpdated => "DESC_UPDATED", + Sort.AscHeight => "ASC_HEIGHT", + Sort.DescHeight => "DESC_HEIGHT", + Sort.AscWidth => "ASC_WIDTH", + Sort.DescWidth => "DESC_WIDTH", + Sort.AscSize => "ASC_SIZE", + Sort.DescSize => "DESC_SIZE", + Sort.AscRelevance => "ASC_RELEVANCE", + Sort.DescRelevance => "DESC_RELEVANCE", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Filter results by asset type. +/// +/// - `file` — returns only files - `file-version` — returns specific file +/// versions - `folder` — returns only folders - `all` — returns both files and +/// folders (excludes `file-version`) +/// +[JsonConverter(typeof(TypeConverter))] +public enum Type +{ + File, + FileVersion, + Folder, + All, +} + +sealed class TypeConverter : JsonConverter +{ + public override global::ImageKit.Models.Assets.Type Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "file" => global::ImageKit.Models.Assets.Type.File, + "file-version" => global::ImageKit.Models.Assets.Type.FileVersion, + "folder" => global::ImageKit.Models.Assets.Type.Folder, + "all" => global::ImageKit.Models.Assets.Type.All, + _ => (global::ImageKit.Models.Assets.Type)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + global::ImageKit.Models.Assets.Type value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + global::ImageKit.Models.Assets.Type.File => "file", + global::ImageKit.Models.Assets.Type.FileVersion => "file-version", + global::ImageKit.Models.Assets.Type.Folder => "folder", + global::ImageKit.Models.Assets.Type.All => "all", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} diff --git a/src/ImageKit/Models/Assets/AssetListResponse.cs b/src/ImageKit/Models/Assets/AssetListResponse.cs new file mode 100644 index 00000000..5d0a812a --- /dev/null +++ b/src/ImageKit/Models/Assets/AssetListResponse.cs @@ -0,0 +1,297 @@ +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; +using ImageKit.Exceptions; +using ImageKit.Models.Files; +using System = System; + +namespace ImageKit.Models.Assets; + +/// +/// Object containing details of a file or file version. +/// +[JsonConverter(typeof(AssetListResponseConverter))] +public record class AssetListResponse : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public System::DateTimeOffset? CreatedAt + { + get + { + return Match( + file: (x) => x.CreatedAt, + folder: (x) => x.CreatedAt + ); + } + } + + public string? Name + { + get { return Match(file: (x) => x.Name, folder: (x) => x.Name); } + } + + public System::DateTimeOffset? UpdatedAt + { + get + { + return Match( + file: (x) => x.UpdatedAt, + folder: (x) => x.UpdatedAt + ); + } + } + + public AssetListResponse(File value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public AssetListResponse(Folder value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public AssetListResponse(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickFile(out var value)) { + /// // `value` is of type `File` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickFile([NotNullWhen(true)] out File? value) + { + value = this.Value as File; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickFolder(out var value)) { + /// // `value` is of type `Folder` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickFolder([NotNullWhen(true)] out Folder? value) + { + value = this.Value as Folder; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (File value) => {...}, + /// (Folder value) => {...} + /// ); + /// + /// + /// + public void Switch(System::Action file, System::Action folder) + { + switch (this.Value) + { + case File value: + file(value); + break; + case Folder value: + folder(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of AssetListResponse" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (File value) => {...}, + /// (Folder value) => {...} + /// ); + /// + /// + /// + public T Match(System::Func file, System::Func folder) + { + return this.Value switch + { + File value => file(value), + Folder value => folder(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of AssetListResponse" + ), + }; + } + + public static implicit operator AssetListResponse(File value) => new(value); + + public static implicit operator AssetListResponse(Folder value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of AssetListResponse" + ); + } + this.Switch((file) => file.Validate(), (folder) => folder.Validate()); + } + + public virtual bool Equals(AssetListResponse? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class AssetListResponseConverter : JsonConverter +{ + public override AssetListResponse? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + string? type; + try + { + type = element.GetProperty("type").GetString(); + } + catch + { + type = null; + } + + switch (type) + { + case "folder": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + default: + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + AssetListResponse value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} diff --git a/src/ImageKit/Models/BaseOverlay.cs b/src/ImageKit/Models/BaseOverlay.cs new file mode 100644 index 00000000..bc50fe4f --- /dev/null +++ b/src/ImageKit/Models/BaseOverlay.cs @@ -0,0 +1,203 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; +using ImageKit.Exceptions; + +namespace ImageKit.Models; + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class BaseOverlay : JsonModel +{ + /// + /// Controls how the layer blends with the base image or underlying content. + /// Maps to `lm` in the URL. By default, layers completely cover the base image + /// beneath them. Layer modes change this behavior: - `multiply`: Multiplies + /// the pixel values of the layer with the base image. The result is always darker + /// than the original images. This is ideal for applying shadows or color tints. + /// - `displace`: Uses the layer as a displacement map to distort pixels in the + /// base image. The red channel controls horizontal displacement, and the green + /// channel controls vertical displacement. Requires `x` or `y` parameter to control + /// displacement magnitude. - `cutout`: Acts as an inverse mask where opaque areas + /// of the layer turn the base image transparent, while transparent areas leave + /// the base image unchanged. This mode functions like a hole-punch, effectively + /// cutting the shape of the layer out of the underlying image. - `cutter`: Acts + /// as a shape mask where only the parts of the base image that fall inside the + /// opaque area of the layer are preserved. This mode functions like a cookie-cutter, + /// trimming the base image to match the specific dimensions and shape of the + /// layer. See [Layer modes](https://imagekit.io/docs/add-overlays-on-images#layer-modes). + /// + public ApiEnum? LayerMode + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("layerMode"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("layerMode", value); + } + } + + /// + /// Specifies the overlay's position relative to the parent asset. See [Position + /// of Layer](https://imagekit.io/docs/transformations#position-of-layer). + /// + public OverlayPosition? Position + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("position"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("position", value); + } + } + + /// + /// Specifies timing information for the overlay (only applicable if the base + /// asset is a video). See [Position of Layer](https://imagekit.io/docs/transformations#position-of-layer). + /// + public OverlayTiming? Timing + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("timing"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("timing", value); + } + } + + /// + public override void Validate() + { + this.LayerMode?.Validate(); + this.Position?.Validate(); + this.Timing?.Validate(); + } + + public BaseOverlay() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public BaseOverlay(BaseOverlay baseOverlay) + : base(baseOverlay) { } +#pragma warning restore CS8618 + + public BaseOverlay(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + BaseOverlay(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static BaseOverlay FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class BaseOverlayFromRaw : IFromRawJson +{ + /// + public BaseOverlay FromRawUnchecked(IReadOnlyDictionary rawData) => + BaseOverlay.FromRawUnchecked(rawData); +} + +/// +/// Controls how the layer blends with the base image or underlying content. Maps +/// to `lm` in the URL. By default, layers completely cover the base image beneath +/// them. Layer modes change this behavior: - `multiply`: Multiplies the pixel values +/// of the layer with the base image. The result is always darker than the original +/// images. This is ideal for applying shadows or color tints. - `displace`: Uses +/// the layer as a displacement map to distort pixels in the base image. The red +/// channel controls horizontal displacement, and the green channel controls vertical +/// displacement. Requires `x` or `y` parameter to control displacement magnitude. +/// - `cutout`: Acts as an inverse mask where opaque areas of the layer turn the base +/// image transparent, while transparent areas leave the base image unchanged. This +/// mode functions like a hole-punch, effectively cutting the shape of the layer out +/// of the underlying image. - `cutter`: Acts as a shape mask where only the parts +/// of the base image that fall inside the opaque area of the layer are preserved. +/// This mode functions like a cookie-cutter, trimming the base image to match the +/// specific dimensions and shape of the layer. See [Layer modes](https://imagekit.io/docs/add-overlays-on-images#layer-modes). +/// +[JsonConverter(typeof(LayerModeConverter))] +public enum LayerMode +{ + Multiply, + Cutter, + Cutout, + Displace, +} + +sealed class LayerModeConverter : JsonConverter +{ + public override LayerMode Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "multiply" => LayerMode.Multiply, + "cutter" => LayerMode.Cutter, + "cutout" => LayerMode.Cutout, + "displace" => LayerMode.Displace, + _ => (LayerMode)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + LayerMode value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + LayerMode.Multiply => "multiply", + LayerMode.Cutter => "cutter", + LayerMode.Cutout => "cutout", + LayerMode.Displace => "displace", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} diff --git a/src/ImageKit/Models/Beta/V2/Files/FileUploadParams.cs b/src/ImageKit/Models/Beta/V2/Files/FileUploadParams.cs new file mode 100644 index 00000000..6c7faead --- /dev/null +++ b/src/ImageKit/Models/Beta/V2/Files/FileUploadParams.cs @@ -0,0 +1,1589 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; +using ImageKit.Exceptions; +using System = System; + +namespace ImageKit.Models.Beta.V2.Files; + +/// +/// The V2 API enhances security by verifying the entire payload using JWT. This API +/// is in beta. +/// +/// ImageKit.io allows you to upload files directly from both the server and +/// client sides. For server-side uploads, private API key authentication is used. +/// For client-side uploads, generate a one-time `token` from your secure backend +/// using private API. [Learn more](/docs/api-reference/upload-file/upload-file-v2#how-to-implement-secure-client-side-file-upload) +/// about how to implement secure client-side file upload. +/// +/// **File size limit** \ On the free plan, the maximum upload file sizes are +/// 20MB for images, audio, and raw files, and 100MB for videos. On the paid plan, +/// these limits increase to 40MB for images, audio, and raw files, and 2GB for videos. +/// These limits can be further increased with higher-tier plans. +/// +/// **Version limit** \ A file can have a maximum of 100 versions. +/// +/// **Demo applications** +/// +/// - A full-fledged [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), +/// supporting file selections from local storage, URL, Dropbox, Google Drive, Instagram, +/// and more. - [Quick start guides](/docs/quick-start-guides) for various frameworks +/// and technologies. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class FileUploadParams : ParamsBase +{ + readonly MultipartJsonDictionary _rawBodyData = new(); + public IReadOnlyDictionary RawBodyData + { + get { return this._rawBodyData.Freeze(); } + } + + /// + /// The API accepts any of the following: + /// + /// - **Binary data** – send the raw bytes as `multipart/form-data`. - **HTTP + /// / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + /// - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + /// + /// When supplying a URL, the server must receive the response headers within + /// 8 seconds; otherwise the request fails with 400 Bad Request. + /// + public required BinaryContent File + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullClass("file"); + } + init { this._rawBodyData.Set("file", value); } + } + + /// + /// The name with which the file has to be uploaded. + /// + public required string FileName + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullClass("fileName"); + } + init { this._rawBodyData.Set("fileName", value); } + } + + /// + /// This is the client-generated JSON Web Token (JWT). The ImageKit.io server + /// uses it to authenticate and check that the upload request parameters have + /// not been tampered with after the token has been generated. Learn how to create + /// the token on the page below. This field is only required for authentication + /// when uploading a file from the client side. + /// + /// **Note**: Sending a JWT that has been used in the past will result in + /// a validation error. Even if your previous request resulted in an error, you + /// should always send a new token. + /// + /// **⚠️Warning**: JWT must be generated on the server-side because it + /// is generated using your account's private API key. This field is required + /// for authentication when uploading a file from the client-side. + /// + public string? Token + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass("token"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("token", value); + } + } + + /// + /// Server-side checks to run on the asset. Read more about [Upload API checks](/docs/api-reference/upload-file/upload-file-v2#upload-api-checks). + /// + public string? Checks + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass("checks"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("checks", value); + } + } + + /// + /// Define an important area in the image. This is only relevant for image type files. + /// + /// - To be passed as a string with the x and y coordinates of the top-left + /// corner, and width and height of the area of interest in the format `x,y,width,height`. + /// For example - `10,10,100,100` - Can be used with fo-customtransformation. + /// - If this field is not specified and the file is overwritten, then customCoordinates + /// will be removed. + /// + public string? CustomCoordinates + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass("customCoordinates"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("customCoordinates", value); + } + } + + /// + /// JSON key-value pairs to associate with the asset. Create the custom metadata + /// fields before setting these values. + /// + public IReadOnlyDictionary? CustomMetadata + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass>( + "customMetadata" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set?>( + "customMetadata", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + + /// + /// Optional text to describe the contents of the file. + /// + public string? Description + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass("description"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("description", value); + } + } + + /// + /// Array of extensions to be applied to the asset. Each extension can be configured + /// with specific parameters based on the extension type. + /// + public IReadOnlyList? Extensions + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableStruct< + ImmutableArray + >("extensions"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set?>( + "extensions", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// The folder path in which the image has to be uploaded. If the folder(s) didn't + /// exist before, a new folder(s) is created. Using multiple `/` creates a nested + /// folder. + /// + public string? Folder + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass("folder"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("folder", value); + } + } + + /// + /// Whether to mark the file as private or not. + /// + /// If `true`, the file is marked as private and is accessible only using + /// named transformation or signed URL. + /// + public bool? IsPrivateFile + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableStruct("isPrivateFile"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("isPrivateFile", value); + } + } + + /// + /// Whether to upload file as published or not. + /// + /// If `false`, the file is marked as unpublished, which restricts access + /// to the file only via the media library. Files in draft or unpublished state + /// can only be publicly accessed after being published. + /// + /// The option to upload in draft state is only available in custom enterprise + /// pricing plans. + /// + public bool? IsPublished + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableStruct("isPublished"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("isPublished", value); + } + } + + /// + /// If set to `true` and a file already exists at the exact location, its AITags + /// will be removed. Set `overwriteAITags` to `false` to preserve AITags. + /// + public bool? OverwriteAITags + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableStruct("overwriteAITags"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("overwriteAITags", value); + } + } + + /// + /// If the request does not have `customMetadata`, and a file already exists + /// at the exact location, existing customMetadata will be removed. + /// + public bool? OverwriteCustomMetadata + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableStruct("overwriteCustomMetadata"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("overwriteCustomMetadata", value); + } + } + + /// + /// If `false` and `useUniqueFileName` is also `false`, and a file already exists + /// at the exact location, upload API will return an error immediately. + /// + public bool? OverwriteFile + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableStruct("overwriteFile"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("overwriteFile", value); + } + } + + /// + /// If the request does not have `tags`, and a file already exists at the exact + /// location, existing tags will be removed. + /// + public bool? OverwriteTags + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableStruct("overwriteTags"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("overwriteTags", value); + } + } + + /// + /// Array of response field keys to include in the API response body. + /// + public IReadOnlyList>? ResponseFields + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableStruct< + ImmutableArray> + >("responseFields"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set>?>( + "responseFields", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Set the tags while uploading the file. Provide an array of tag strings (e.g. + /// `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must + /// not exceed 500, and the `%` character is not allowed. If this field is not + /// specified and the file is overwritten, the existing tags will be removed. + /// + public IReadOnlyList? Tags + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableStruct>("tags"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set?>( + "tags", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Configure pre-processing (`pre`) and post-processing (`post`) transformations. + /// + /// - `pre` — applied before the file is uploaded to the Media Library. + /// Useful for reducing file size or applying basic optimizations upfront + /// (e.g., resize, compress). + /// + /// - `post` — applied immediately after upload. Ideal for generating + /// transformed versions (like video encodes or thumbnails) in advance, so they're + /// ready for delivery without delay. + /// + /// You can mix and match any combination of post-processing types. + /// + public Transformation? Transformation + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass("transformation"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("transformation", value); + } + } + + /// + /// Whether to use a unique filename for this file or not. + /// + /// If `true`, ImageKit.io will add a unique suffix to the filename parameter + /// to get a unique filename. + /// + /// If `false`, then the image is uploaded with the provided filename parameter, + /// and any existing file with the same name is replaced. + /// + public bool? UseUniqueFileName + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableStruct("useUniqueFileName"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("useUniqueFileName", value); + } + } + + /// + /// The final status of extensions after they have completed execution will be + /// delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + /// about the webhook payload structure. + /// + public string? WebhookUrl + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass("webhookUrl"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("webhookUrl", value); + } + } + + public FileUploadParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public FileUploadParams(FileUploadParams fileUploadParams) + : base(fileUploadParams) + { + this._rawBodyData = new(fileUploadParams._rawBodyData); + } +#pragma warning restore CS8618 + + public FileUploadParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FileUploadParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData, + FrozenDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } +#pragma warning restore CS8618 + + /// + public static FileUploadParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData), + FrozenDictionary.ToFrozenDictionary(rawBodyData) + ); + } + + public override System::Uri Url(ClientOptions options) + { + return new System::UriBuilder( + options.BaseUrl.ToString().TrimEnd('/') + "/api/v2/files/upload" + ) + { + Query = this.QueryString(options), + }.Uri; + } + + internal override HttpContent? BodyContent() + { + return MultipartJsonSerializer.Serialize(RawBodyData); + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} + +[JsonConverter(typeof(ResponseFieldConverter))] +public enum ResponseField +{ + Tags, + CustomCoordinates, + IsPrivateFile, + EmbeddedMetadata, + IsPublished, + CustomMetadata, + Metadata, + SelectedFieldsSchema, +} + +sealed class ResponseFieldConverter : JsonConverter +{ + public override ResponseField Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "tags" => ResponseField.Tags, + "customCoordinates" => ResponseField.CustomCoordinates, + "isPrivateFile" => ResponseField.IsPrivateFile, + "embeddedMetadata" => ResponseField.EmbeddedMetadata, + "isPublished" => ResponseField.IsPublished, + "customMetadata" => ResponseField.CustomMetadata, + "metadata" => ResponseField.Metadata, + "selectedFieldsSchema" => ResponseField.SelectedFieldsSchema, + _ => (ResponseField)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ResponseField value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ResponseField.Tags => "tags", + ResponseField.CustomCoordinates => "customCoordinates", + ResponseField.IsPrivateFile => "isPrivateFile", + ResponseField.EmbeddedMetadata => "embeddedMetadata", + ResponseField.IsPublished => "isPublished", + ResponseField.CustomMetadata => "customMetadata", + ResponseField.Metadata => "metadata", + ResponseField.SelectedFieldsSchema => "selectedFieldsSchema", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configure pre-processing (`pre`) and post-processing (`post`) transformations. +/// +/// - `pre` — applied before the file is uploaded to the Media Library. +/// Useful for reducing file size or applying basic optimizations upfront (e.g., +/// resize, compress). +/// +/// - `post` — applied immediately after upload. Ideal for generating transformed +/// versions (like video encodes or thumbnails) in advance, so they're ready for delivery +/// without delay. +/// +/// You can mix and match any combination of post-processing types. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Transformation : JsonModel +{ + /// + /// List of transformations to apply *after* the file is uploaded. Each item + /// must match one of the following types: `transformation`, `gif-to-video`, `thumbnail`, + /// `abs`. + /// + public IReadOnlyList? Post + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>("post"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "post", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Transformation string to apply before uploading the file to the Media Library. + /// Useful for optimizing files at ingestion. + /// + public string? Pre + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("pre"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("pre", value); + } + } + + /// + public override void Validate() + { + foreach (var item in this.Post ?? []) + { + item.Validate(); + } + _ = this.Pre; + } + + public Transformation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Transformation(Transformation transformation) + : base(transformation) { } +#pragma warning restore CS8618 + + public Transformation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Transformation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static Transformation FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TransformationFromRaw : IFromRawJson +{ + /// + public Transformation FromRawUnchecked(IReadOnlyDictionary rawData) => + Transformation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(PostConverter))] +public record class Post : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + return Match( + transformation: (x) => x.Type, + gifToVideo: (x) => x.Type, + thumbnail: (x) => x.Type, + abs: (x) => x.Type + ); + } + } + + public string? Value1 + { + get + { + return Match( + transformation: (x) => x.Value, + gifToVideo: (x) => x.Value, + thumbnail: (x) => x.Value, + abs: (x) => x.Value + ); + } + } + + public Post(PostTransformation value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Post(GifToVideo value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Post(Thumbnail value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Post(Abs value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Post(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickTransformation(out var value)) { + /// // `value` is of type `PostTransformation` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTransformation([NotNullWhen(true)] out PostTransformation? value) + { + value = this.Value as PostTransformation; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickGifToVideo(out var value)) { + /// // `value` is of type `GifToVideo` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickGifToVideo([NotNullWhen(true)] out GifToVideo? value) + { + value = this.Value as GifToVideo; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickThumbnail(out var value)) { + /// // `value` is of type `Thumbnail` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickThumbnail([NotNullWhen(true)] out Thumbnail? value) + { + value = this.Value as Thumbnail; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickAbs(out var value)) { + /// // `value` is of type `Abs` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickAbs([NotNullWhen(true)] out Abs? value) + { + value = this.Value as Abs; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (PostTransformation value) => {...}, + /// (GifToVideo value) => {...}, + /// (Thumbnail value) => {...}, + /// (Abs value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action transformation, + System::Action gifToVideo, + System::Action thumbnail, + System::Action abs + ) + { + switch (this.Value) + { + case PostTransformation value: + transformation(value); + break; + case GifToVideo value: + gifToVideo(value); + break; + case Thumbnail value: + thumbnail(value); + break; + case Abs value: + abs(value); + break; + default: + throw new ImageKitInvalidDataException("Data did not match any variant of Post"); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (PostTransformation value) => {...}, + /// (GifToVideo value) => {...}, + /// (Thumbnail value) => {...}, + /// (Abs value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func transformation, + System::Func gifToVideo, + System::Func thumbnail, + System::Func abs + ) + { + return this.Value switch + { + PostTransformation value => transformation(value), + GifToVideo value => gifToVideo(value), + Thumbnail value => thumbnail(value), + Abs value => abs(value), + _ => throw new ImageKitInvalidDataException("Data did not match any variant of Post"), + }; + } + + public static implicit operator Post(PostTransformation value) => new(value); + + public static implicit operator Post(GifToVideo value) => new(value); + + public static implicit operator Post(Thumbnail value) => new(value); + + public static implicit operator Post(Abs value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException("Data did not match any variant of Post"); + } + this.Switch( + (transformation) => transformation.Validate(), + (gifToVideo) => gifToVideo.Validate(), + (thumbnail) => thumbnail.Validate(), + (abs) => abs.Validate() + ); + } + + public virtual bool Equals(Post? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class PostConverter : JsonConverter +{ + public override Post? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + string? type; + try + { + type = element.GetProperty("type").GetString(); + } + catch + { + type = null; + } + + switch (type) + { + case "transformation": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + case "gif-to-video": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + case "thumbnail": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + case "abs": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + default: + { + return new Post(element); + } + } + } + + public override void Write(Utf8JsonWriter writer, Post value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class PostTransformation : JsonModel +{ + /// + /// Transformation type. + /// + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// Transformation string (e.g. `w-200,h-200`). Same syntax as ImageKit URL-based + /// transformations. + /// + public required string Value + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("value"); + } + init { this._rawData.Set("value", value); } + } + + /// + public override void Validate() + { + if (!JsonElement.DeepEquals(this.Type, JsonSerializer.SerializeToElement("transformation"))) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + _ = this.Value; + } + + public PostTransformation() + { + this.Type = JsonSerializer.SerializeToElement("transformation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PostTransformation(PostTransformation postTransformation) + : base(postTransformation) { } +#pragma warning restore CS8618 + + public PostTransformation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("transformation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PostTransformation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PostTransformation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public PostTransformation(string value) + : this() + { + this.Value = value; + } +} + +class PostTransformationFromRaw : IFromRawJson +{ + /// + public PostTransformation FromRawUnchecked(IReadOnlyDictionary rawData) => + PostTransformation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class GifToVideo : JsonModel +{ + /// + /// Converts an animated GIF into an MP4. + /// + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// Optional transformation string to apply to the output video. **Example**: + /// `q-80` + /// + public string? Value + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("value"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("value", value); + } + } + + /// + public override void Validate() + { + if (!JsonElement.DeepEquals(this.Type, JsonSerializer.SerializeToElement("gif-to-video"))) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + _ = this.Value; + } + + public GifToVideo() + { + this.Type = JsonSerializer.SerializeToElement("gif-to-video"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GifToVideo(GifToVideo gifToVideo) + : base(gifToVideo) { } +#pragma warning restore CS8618 + + public GifToVideo(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("gif-to-video"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GifToVideo(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GifToVideo FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GifToVideoFromRaw : IFromRawJson +{ + /// + public GifToVideo FromRawUnchecked(IReadOnlyDictionary rawData) => + GifToVideo.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Thumbnail : JsonModel +{ + /// + /// Generates a thumbnail image. + /// + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// Optional transformation string. **Example**: `w-150,h-150` + /// + public string? Value + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("value"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("value", value); + } + } + + /// + public override void Validate() + { + if (!JsonElement.DeepEquals(this.Type, JsonSerializer.SerializeToElement("thumbnail"))) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + _ = this.Value; + } + + public Thumbnail() + { + this.Type = JsonSerializer.SerializeToElement("thumbnail"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Thumbnail(Thumbnail thumbnail) + : base(thumbnail) { } +#pragma warning restore CS8618 + + public Thumbnail(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("thumbnail"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Thumbnail(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static Thumbnail FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ThumbnailFromRaw : IFromRawJson +{ + /// + public Thumbnail FromRawUnchecked(IReadOnlyDictionary rawData) => + Thumbnail.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Abs : JsonModel +{ + /// + /// Streaming protocol to use (`hls` or `dash`). + /// + public required ApiEnum Protocol + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass>("protocol"); + } + init { this._rawData.Set("protocol", value); } + } + + /// + /// Adaptive Bitrate Streaming (ABS) setup. + /// + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// List of different representations you want to create separated by an underscore. + /// + public required string Value + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("value"); + } + init { this._rawData.Set("value", value); } + } + + /// + public override void Validate() + { + this.Protocol.Validate(); + if (!JsonElement.DeepEquals(this.Type, JsonSerializer.SerializeToElement("abs"))) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + _ = this.Value; + } + + public Abs() + { + this.Type = JsonSerializer.SerializeToElement("abs"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Abs(Abs abs) + : base(abs) { } +#pragma warning restore CS8618 + + public Abs(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("abs"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Abs(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static Abs FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class AbsFromRaw : IFromRawJson +{ + /// + public Abs FromRawUnchecked(IReadOnlyDictionary rawData) => + Abs.FromRawUnchecked(rawData); +} + +/// +/// Streaming protocol to use (`hls` or `dash`). +/// +[JsonConverter(typeof(ProtocolConverter))] +public enum Protocol +{ + Hls, + Dash, +} + +sealed class ProtocolConverter : JsonConverter +{ + public override Protocol Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "hls" => Protocol.Hls, + "dash" => Protocol.Dash, + _ => (Protocol)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Protocol value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + Protocol.Hls => "hls", + Protocol.Dash => "dash", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} diff --git a/src/ImageKit/Models/Beta/V2/Files/FileUploadResponse.cs b/src/ImageKit/Models/Beta/V2/Files/FileUploadResponse.cs new file mode 100644 index 00000000..ce4ed046 --- /dev/null +++ b/src/ImageKit/Models/Beta/V2/Files/FileUploadResponse.cs @@ -0,0 +1,2943 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; +using ImageKit.Exceptions; +using Files = ImageKit.Models.Files; +using System = System; + +namespace ImageKit.Models.Beta.V2.Files; + +/// +/// Object containing details of a successful upload. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class FileUploadResponse : JsonModel +{ + /// + /// An array of tags assigned to the uploaded file by auto tagging. + /// + public IReadOnlyList? AITags + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>("AITags"); + } + init + { + this._rawData.Set?>( + "AITags", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// The audio codec used in the video (only for video). + /// + public string? AudioCodec + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("audioCodec"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("audioCodec", value); + } + } + + /// + /// The bit rate of the video in kbps (only for video). + /// + public long? BitRate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("bitRate"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("bitRate", value); + } + } + + /// + /// Value of custom coordinates associated with the image in the format `x,y,width,height`. + /// If `customCoordinates` are not defined, then it is `null`. Send `customCoordinates` + /// in `responseFields` in API request to get the value of this field. + /// + public string? CustomCoordinates + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("customCoordinates"); + } + init { this._rawData.Set("customCoordinates", value); } + } + + /// + /// A key-value data associated with the asset. Use `responseField` in API request + /// to get `customMetadata` in the upload API response. Before setting any custom + /// metadata on an asset, you have to create the field using custom metadata fields + /// API. Send `customMetadata` in `responseFields` in API request to get the value + /// of this field. + /// + public IReadOnlyDictionary? CustomMetadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>( + "customMetadata" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "customMetadata", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + + /// + /// Optional text to describe the contents of the file. Can be set by the user + /// or the ai-auto-description extension. + /// + public string? Description + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("description"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("description", value); + } + } + + /// + /// The duration of the video in seconds (only for video). + /// + public long? Duration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("duration"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("duration", value); + } + } + + /// + /// Consolidated embedded metadata associated with the file. It includes exif, + /// iptc, and xmp data. Send `embeddedMetadata` in `responseFields` in API request + /// to get embeddedMetadata in the upload API response. + /// + public IReadOnlyDictionary? EmbeddedMetadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>( + "embeddedMetadata" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "embeddedMetadata", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + + /// + /// Extension names with their processing status at the time of completion of + /// the request. It could have one of the following status values: + /// + /// `success`: The extension has been successfully applied. `failed`: The + /// extension has failed and will not be retried. `pending`: The extension will + /// finish processing in some time. On completion, the final status (success + /// / failed) will be sent to the `webhookUrl` provided. + /// + /// If no extension was requested, then this parameter is not returned. + /// + public ExtensionStatus? ExtensionStatus + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("extensionStatus"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("extensionStatus", value); + } + } + + /// + /// Unique fileId. Store this fileld in your database, as this will be used to + /// perform update action on this file. + /// + public string? FileID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("fileId"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("fileId", value); + } + } + + /// + /// The relative path of the file in the media library e.g. `/marketing-assets/new-banner.jpg`. + /// + public string? FilePath + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("filePath"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("filePath", value); + } + } + + /// + /// Type of the uploaded file. Possible values are `image`, `non-image`. + /// + public string? FileType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("fileType"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("fileType", value); + } + } + + /// + /// Height of the image in pixels (Only for images) + /// + public double? Height + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("height"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("height", value); + } + } + + /// + /// Is the file marked as private. It can be either `true` or `false`. Send `isPrivateFile` + /// in `responseFields` in API request to get the value of this field. + /// + public bool? IsPrivateFile + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("isPrivateFile"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("isPrivateFile", value); + } + } + + /// + /// Is the file published or in draft state. It can be either `true` or `false`. + /// Send `isPublished` in `responseFields` in API request to get the value of + /// this field. + /// + public bool? IsPublished + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("isPublished"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("isPublished", value); + } + } + + /// + /// Legacy metadata. Send `metadata` in `responseFields` in API request to get + /// metadata in the upload API response. + /// + public Files::FileMetadata? Metadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("metadata"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("metadata", value); + } + } + + /// + /// Name of the asset. + /// + public string? Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("name"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("name", value); + } + } + + /// + /// This field is included in the response only if the Path policy feature is + /// available in the plan. It contains schema definitions for the custom metadata + /// fields selected for the specified file path. Field selection can only be + /// done when the Path policy feature is enabled. + /// + /// Keys are the names of the custom metadata fields; the value object + /// has details about the custom metadata schema. + /// + public IReadOnlyDictionary? SelectedFieldsSchema + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass< + FrozenDictionary + >("selectedFieldsSchema"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "selectedFieldsSchema", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + + /// + /// Size of the image file in Bytes. + /// + public double? Size + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("size"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("size", value); + } + } + + /// + /// The array of tags associated with the asset. If no tags are set, it will be + /// `null`. Send `tags` in `responseFields` in API request to get the value of + /// this field. + /// + public IReadOnlyList? Tags + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>("tags"); + } + init + { + this._rawData.Set?>( + "tags", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// In the case of an image, a small thumbnail URL. + /// + public string? ThumbnailUrl + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("thumbnailUrl"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("thumbnailUrl", value); + } + } + + /// + /// A publicly accessible URL of the file. + /// + public string? Url + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("url"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("url", value); + } + } + + /// + /// An object containing the file or file version's `id` (versionId) and `name`. + /// + public VersionInfo? VersionInfo + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("versionInfo"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("versionInfo", value); + } + } + + /// + /// The video codec used in the video (only for video). + /// + public string? VideoCodec + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("videoCodec"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("videoCodec", value); + } + } + + /// + /// Width of the image in pixels (Only for Images) + /// + public double? Width + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("width"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("width", value); + } + } + + /// + public override void Validate() + { + foreach (var item in this.AITags ?? []) + { + item.Validate(); + } + _ = this.AudioCodec; + _ = this.BitRate; + _ = this.CustomCoordinates; + _ = this.CustomMetadata; + _ = this.Description; + _ = this.Duration; + _ = this.EmbeddedMetadata; + this.ExtensionStatus?.Validate(); + _ = this.FileID; + _ = this.FilePath; + _ = this.FileType; + _ = this.Height; + _ = this.IsPrivateFile; + _ = this.IsPublished; + this.Metadata?.Validate(); + _ = this.Name; + if (this.SelectedFieldsSchema != null) + { + foreach (var item in this.SelectedFieldsSchema.Values) + { + item.Validate(); + } + } + _ = this.Size; + _ = this.Tags; + _ = this.ThumbnailUrl; + _ = this.Url; + this.VersionInfo?.Validate(); + _ = this.VideoCodec; + _ = this.Width; + } + + public FileUploadResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public FileUploadResponse(FileUploadResponse fileUploadResponse) + : base(fileUploadResponse) { } +#pragma warning restore CS8618 + + public FileUploadResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FileUploadResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static FileUploadResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class FileUploadResponseFromRaw : IFromRawJson +{ + /// + public FileUploadResponse FromRawUnchecked(IReadOnlyDictionary rawData) => + FileUploadResponse.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class AITag : JsonModel +{ + /// + /// Confidence score of the tag. + /// + public double? Confidence + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("confidence"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("confidence", value); + } + } + + /// + /// Name of the tag. + /// + public string? Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("name"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("name", value); + } + } + + /// + /// Array of `AITags` associated with the image. If no `AITags` are set, it will + /// be null. These tags can be added using the `google-auto-tagging` or `aws-auto-tagging` extensions. + /// + public string? Source + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("source"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("source", value); + } + } + + /// + public override void Validate() + { + _ = this.Confidence; + _ = this.Name; + _ = this.Source; + } + + public AITag() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public AITag(AITag aiTag) + : base(aiTag) { } +#pragma warning restore CS8618 + + public AITag(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + AITag(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static AITag FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class AITagFromRaw : IFromRawJson +{ + /// + public AITag FromRawUnchecked(IReadOnlyDictionary rawData) => + AITag.FromRawUnchecked(rawData); +} + +/// +/// Extension names with their processing status at the time of completion of the +/// request. It could have one of the following status values: +/// +/// `success`: The extension has been successfully applied. `failed`: The extension +/// has failed and will not be retried. `pending`: The extension will finish processing +/// in some time. On completion, the final status (success / failed) will be sent +/// to the `webhookUrl` provided. +/// +/// If no extension was requested, then this parameter is not returned. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class ExtensionStatus : JsonModel +{ + public ApiEnum? AIAutoDescription + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>( + "ai-auto-description" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("ai-auto-description", value); + } + } + + public ApiEnum? AITasks + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("ai-tasks"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("ai-tasks", value); + } + } + + public ApiEnum? AwsAutoTagging + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>( + "aws-auto-tagging" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("aws-auto-tagging", value); + } + } + + public ApiEnum? GoogleAutoTagging + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>( + "google-auto-tagging" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("google-auto-tagging", value); + } + } + + public ApiEnum? RemoveBg + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("remove-bg"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("remove-bg", value); + } + } + + /// + public override void Validate() + { + this.AIAutoDescription?.Validate(); + this.AITasks?.Validate(); + this.AwsAutoTagging?.Validate(); + this.GoogleAutoTagging?.Validate(); + this.RemoveBg?.Validate(); + } + + public ExtensionStatus() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ExtensionStatus(ExtensionStatus extensionStatus) + : base(extensionStatus) { } +#pragma warning restore CS8618 + + public ExtensionStatus(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ExtensionStatus(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ExtensionStatus FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ExtensionStatusFromRaw : IFromRawJson +{ + /// + public ExtensionStatus FromRawUnchecked(IReadOnlyDictionary rawData) => + ExtensionStatus.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(AIAutoDescriptionConverter))] +public enum AIAutoDescription +{ + Success, + Pending, + Failed, +} + +sealed class AIAutoDescriptionConverter : JsonConverter +{ + public override AIAutoDescription Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "success" => AIAutoDescription.Success, + "pending" => AIAutoDescription.Pending, + "failed" => AIAutoDescription.Failed, + _ => (AIAutoDescription)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + AIAutoDescription value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + AIAutoDescription.Success => "success", + AIAutoDescription.Pending => "pending", + AIAutoDescription.Failed => "failed", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter(typeof(AITasksConverter))] +public enum AITasks +{ + Success, + Pending, + Failed, +} + +sealed class AITasksConverter : JsonConverter +{ + public override AITasks Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "success" => AITasks.Success, + "pending" => AITasks.Pending, + "failed" => AITasks.Failed, + _ => (AITasks)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, AITasks value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + AITasks.Success => "success", + AITasks.Pending => "pending", + AITasks.Failed => "failed", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter(typeof(AwsAutoTaggingConverter))] +public enum AwsAutoTagging +{ + Success, + Pending, + Failed, +} + +sealed class AwsAutoTaggingConverter : JsonConverter +{ + public override AwsAutoTagging Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "success" => AwsAutoTagging.Success, + "pending" => AwsAutoTagging.Pending, + "failed" => AwsAutoTagging.Failed, + _ => (AwsAutoTagging)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + AwsAutoTagging value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + AwsAutoTagging.Success => "success", + AwsAutoTagging.Pending => "pending", + AwsAutoTagging.Failed => "failed", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter(typeof(GoogleAutoTaggingConverter))] +public enum GoogleAutoTagging +{ + Success, + Pending, + Failed, +} + +sealed class GoogleAutoTaggingConverter : JsonConverter +{ + public override GoogleAutoTagging Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "success" => GoogleAutoTagging.Success, + "pending" => GoogleAutoTagging.Pending, + "failed" => GoogleAutoTagging.Failed, + _ => (GoogleAutoTagging)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + GoogleAutoTagging value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + GoogleAutoTagging.Success => "success", + GoogleAutoTagging.Pending => "pending", + GoogleAutoTagging.Failed => "failed", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter(typeof(RemoveBgConverter))] +public enum RemoveBg +{ + Success, + Pending, + Failed, +} + +sealed class RemoveBgConverter : JsonConverter +{ + public override RemoveBg Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "success" => RemoveBg.Success, + "pending" => RemoveBg.Pending, + "failed" => RemoveBg.Failed, + _ => (RemoveBg)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, RemoveBg value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + RemoveBg.Success => "success", + RemoveBg.Pending => "pending", + RemoveBg.Failed => "failed", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class SelectedFieldsSchemaItem : JsonModel +{ + /// + /// Type of the custom metadata field. + /// + public required ApiEnum Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum + >("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// The default value for this custom metadata field. The value should match + /// the `type` of custom metadata field. + /// + public DefaultValue? DefaultValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("defaultValue"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("defaultValue", value); + } + } + + /// + /// Specifies if the custom metadata field is required or not. + /// + public bool? IsValueRequired + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("isValueRequired"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("isValueRequired", value); + } + } + + /// + /// Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. + /// + public double? MaxLength + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("maxLength"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("maxLength", value); + } + } + + /// + /// Maximum value of the field. Only set if field type is `Date` or `Number`. + /// For `Date` type field, the value will be in ISO8601 string format. For `Number` + /// type field, it will be a numeric value. + /// + public MaxValue? MaxValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("maxValue"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("maxValue", value); + } + } + + /// + /// Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. + /// + public double? MinLength + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("minLength"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("minLength", value); + } + } + + /// + /// Minimum value of the field. Only set if field type is `Date` or `Number`. + /// For `Date` type field, the value will be in ISO8601 string format. For `Number` + /// type field, it will be a numeric value. + /// + public MinValue? MinValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("minValue"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("minValue", value); + } + } + + /// + /// Indicates whether the custom metadata field is read only. A read only field + /// cannot be modified after being set. This field is configurable only via the + /// **Path policy** feature. + /// + public bool? ReadOnly + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("readOnly"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("readOnly", value); + } + } + + /// + /// An array of allowed values when field type is `SingleSelect` or `MultiSelect`. + /// + public IReadOnlyList? SelectOptions + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>("selectOptions"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "selectOptions", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Specifies if the selectOptions array is truncated. It is truncated when number + /// of options are > 100. + /// + public bool? SelectOptionsTruncated + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("selectOptionsTruncated"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("selectOptionsTruncated", value); + } + } + + /// + public override void Validate() + { + this.Type.Validate(); + this.DefaultValue?.Validate(); + _ = this.IsValueRequired; + _ = this.MaxLength; + this.MaxValue?.Validate(); + _ = this.MinLength; + this.MinValue?.Validate(); + _ = this.ReadOnly; + foreach (var item in this.SelectOptions ?? []) + { + item.Validate(); + } + _ = this.SelectOptionsTruncated; + } + + public SelectedFieldsSchemaItem() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SelectedFieldsSchemaItem(SelectedFieldsSchemaItem selectedFieldsSchemaItem) + : base(selectedFieldsSchemaItem) { } +#pragma warning restore CS8618 + + public SelectedFieldsSchemaItem(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + SelectedFieldsSchemaItem(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static SelectedFieldsSchemaItem FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public SelectedFieldsSchemaItem( + ApiEnum type + ) + : this() + { + this.Type = type; + } +} + +class SelectedFieldsSchemaItemFromRaw : IFromRawJson +{ + /// + public SelectedFieldsSchemaItem FromRawUnchecked( + IReadOnlyDictionary rawData + ) => SelectedFieldsSchemaItem.FromRawUnchecked(rawData); +} + +/// +/// Type of the custom metadata field. +/// +[JsonConverter(typeof(TypeConverter))] +public enum Type +{ + Text, + Textarea, + Number, + Date, + Boolean, + SingleSelect, + MultiSelect, +} + +sealed class TypeConverter : JsonConverter +{ + public override global::ImageKit.Models.Beta.V2.Files.Type Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "Text" => global::ImageKit.Models.Beta.V2.Files.Type.Text, + "Textarea" => global::ImageKit.Models.Beta.V2.Files.Type.Textarea, + "Number" => global::ImageKit.Models.Beta.V2.Files.Type.Number, + "Date" => global::ImageKit.Models.Beta.V2.Files.Type.Date, + "Boolean" => global::ImageKit.Models.Beta.V2.Files.Type.Boolean, + "SingleSelect" => global::ImageKit.Models.Beta.V2.Files.Type.SingleSelect, + "MultiSelect" => global::ImageKit.Models.Beta.V2.Files.Type.MultiSelect, + _ => (global::ImageKit.Models.Beta.V2.Files.Type)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + global::ImageKit.Models.Beta.V2.Files.Type value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + global::ImageKit.Models.Beta.V2.Files.Type.Text => "Text", + global::ImageKit.Models.Beta.V2.Files.Type.Textarea => "Textarea", + global::ImageKit.Models.Beta.V2.Files.Type.Number => "Number", + global::ImageKit.Models.Beta.V2.Files.Type.Date => "Date", + global::ImageKit.Models.Beta.V2.Files.Type.Boolean => "Boolean", + global::ImageKit.Models.Beta.V2.Files.Type.SingleSelect => "SingleSelect", + global::ImageKit.Models.Beta.V2.Files.Type.MultiSelect => "MultiSelect", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// The default value for this custom metadata field. The value should match the `type` +/// of custom metadata field. +/// +[JsonConverter(typeof(DefaultValueConverter))] +public record class DefaultValue : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public DefaultValue(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public DefaultValue(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public DefaultValue(bool value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public DefaultValue( + IReadOnlyList value, + JsonElement? element = null + ) + { + this.Value = ImmutableArray.ToImmutableArray(value); + this._element = element; + } + + public DefaultValue(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickBool(out var value)) { + /// // `value` is of type `bool` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = this.Value as bool?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickMixed(out var value)) { + /// // `value` is of type `IReadOnlyList` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMixed( + [NotNullWhen(true)] out IReadOnlyList? value + ) + { + value = this.Value as IReadOnlyList; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action @string, + System::Action @double, + System::Action @bool, + System::Action> mixed + ) + { + switch (this.Value) + { + case string value: + @string(value); + break; + case double value: + @double(value); + break; + case bool value: + @bool(value); + break; + case IReadOnlyList value: + mixed(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of DefaultValue" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func @string, + System::Func @double, + System::Func @bool, + System::Func, T> mixed + ) + { + return this.Value switch + { + string value => @string(value), + double value => @double(value), + bool value => @bool(value), + IReadOnlyList value => mixed(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of DefaultValue" + ), + }; + } + + public static implicit operator DefaultValue(string value) => new(value); + + public static implicit operator DefaultValue(double value) => new(value); + + public static implicit operator DefaultValue(bool value) => new(value); + + public static implicit operator DefaultValue(List value) => + new((IReadOnlyList)value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of DefaultValue" + ); + } + } + + public virtual bool Equals(DefaultValue? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class DefaultValueConverter : JsonConverter +{ + public override DefaultValue? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize>( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + DefaultValue value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(UnnamedSchemaWithArrayParent12Converter))] +public record class UnnamedSchemaWithArrayParent12 : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public UnnamedSchemaWithArrayParent12(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent12(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent12(bool value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent12(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickBool(out var value)) { + /// // `value` is of type `bool` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = this.Value as bool?; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action @string, + System::Action @double, + System::Action @bool + ) + { + switch (this.Value) + { + case string value: + @string(value); + break; + case double value: + @double(value); + break; + case bool value: + @bool(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent12" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func @string, + System::Func @double, + System::Func @bool + ) + { + return this.Value switch + { + string value => @string(value), + double value => @double(value), + bool value => @bool(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent12" + ), + }; + } + + public static implicit operator UnnamedSchemaWithArrayParent12(string value) => new(value); + + public static implicit operator UnnamedSchemaWithArrayParent12(double value) => new(value); + + public static implicit operator UnnamedSchemaWithArrayParent12(bool value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent12" + ); + } + } + + public virtual bool Equals(UnnamedSchemaWithArrayParent12? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class UnnamedSchemaWithArrayParent12Converter : JsonConverter +{ + public override UnnamedSchemaWithArrayParent12? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + UnnamedSchemaWithArrayParent12 value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +/// +/// Maximum value of the field. Only set if field type is `Date` or `Number`. For +/// `Date` type field, the value will be in ISO8601 string format. For `Number` type +/// field, it will be a numeric value. +/// +[JsonConverter(typeof(MaxValueConverter))] +public record class MaxValue : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public MaxValue(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public MaxValue(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public MaxValue(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (string value) => {...}, + /// (double value) => {...} + /// ); + /// + /// + /// + public void Switch(System::Action @string, System::Action @double) + { + switch (this.Value) + { + case string value: + @string(value); + break; + case double value: + @double(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of MaxValue" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (string value) => {...}, + /// (double value) => {...} + /// ); + /// + /// + /// + public T Match(System::Func @string, System::Func @double) + { + return this.Value switch + { + string value => @string(value), + double value => @double(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of MaxValue" + ), + }; + } + + public static implicit operator MaxValue(string value) => new(value); + + public static implicit operator MaxValue(double value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException("Data did not match any variant of MaxValue"); + } + } + + public virtual bool Equals(MaxValue? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class MaxValueConverter : JsonConverter +{ + public override MaxValue? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write(Utf8JsonWriter writer, MaxValue value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +/// +/// Minimum value of the field. Only set if field type is `Date` or `Number`. For +/// `Date` type field, the value will be in ISO8601 string format. For `Number` type +/// field, it will be a numeric value. +/// +[JsonConverter(typeof(MinValueConverter))] +public record class MinValue : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public MinValue(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public MinValue(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public MinValue(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (string value) => {...}, + /// (double value) => {...} + /// ); + /// + /// + /// + public void Switch(System::Action @string, System::Action @double) + { + switch (this.Value) + { + case string value: + @string(value); + break; + case double value: + @double(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of MinValue" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (string value) => {...}, + /// (double value) => {...} + /// ); + /// + /// + /// + public T Match(System::Func @string, System::Func @double) + { + return this.Value switch + { + string value => @string(value), + double value => @double(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of MinValue" + ), + }; + } + + public static implicit operator MinValue(string value) => new(value); + + public static implicit operator MinValue(double value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException("Data did not match any variant of MinValue"); + } + } + + public virtual bool Equals(MinValue? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class MinValueConverter : JsonConverter +{ + public override MinValue? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write(Utf8JsonWriter writer, MinValue value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(SelectOptionConverter))] +public record class SelectOption : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public SelectOption(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public SelectOption(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public SelectOption(bool value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public SelectOption(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickBool(out var value)) { + /// // `value` is of type `bool` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = this.Value as bool?; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action @string, + System::Action @double, + System::Action @bool + ) + { + switch (this.Value) + { + case string value: + @string(value); + break; + case double value: + @double(value); + break; + case bool value: + @bool(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of SelectOption" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func @string, + System::Func @double, + System::Func @bool + ) + { + return this.Value switch + { + string value => @string(value), + double value => @double(value), + bool value => @bool(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of SelectOption" + ), + }; + } + + public static implicit operator SelectOption(string value) => new(value); + + public static implicit operator SelectOption(double value) => new(value); + + public static implicit operator SelectOption(bool value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of SelectOption" + ); + } + } + + public virtual bool Equals(SelectOption? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class SelectOptionConverter : JsonConverter +{ + public override SelectOption? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + SelectOption value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +/// +/// An object containing the file or file version's `id` (versionId) and `name`. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class VersionInfo : JsonModel +{ + /// + /// Unique identifier of the file version. + /// + public string? ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("id"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("id", value); + } + } + + /// + /// Name of the file version. + /// + public string? Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("name"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("name", value); + } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.Name; + } + + public VersionInfo() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public VersionInfo(VersionInfo versionInfo) + : base(versionInfo) { } +#pragma warning restore CS8618 + + public VersionInfo(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + VersionInfo(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static VersionInfo FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class VersionInfoFromRaw : IFromRawJson +{ + /// + public VersionInfo FromRawUnchecked(IReadOnlyDictionary rawData) => + VersionInfo.FromRawUnchecked(rawData); +} diff --git a/src/ImageKit/Models/Cache/Invalidation/InvalidationCreateParams.cs b/src/ImageKit/Models/Cache/Invalidation/InvalidationCreateParams.cs new file mode 100644 index 00000000..dbb942e2 --- /dev/null +++ b/src/ImageKit/Models/Cache/Invalidation/InvalidationCreateParams.cs @@ -0,0 +1,143 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using ImageKit.Core; +using Text = System.Text; + +namespace ImageKit.Models.Cache.Invalidation; + +/// +/// This API will purge CDN cache and ImageKit.io's internal cache for a file. Note: +/// Purge cache is an asynchronous process and it may take some time to reflect the changes. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class InvalidationCreateParams : ParamsBase +{ + readonly JsonDictionary _rawBodyData = new(); + public IReadOnlyDictionary RawBodyData + { + get { return this._rawBodyData.Freeze(); } + } + + /// + /// The full URL of the file to be purged. + /// + public required string UrlValue + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullClass("url"); + } + init { this._rawBodyData.Set("url", value); } + } + + public InvalidationCreateParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public InvalidationCreateParams(InvalidationCreateParams invalidationCreateParams) + : base(invalidationCreateParams) + { + this._rawBodyData = new(invalidationCreateParams._rawBodyData); + } +#pragma warning restore CS8618 + + public InvalidationCreateParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + InvalidationCreateParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData, + FrozenDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } +#pragma warning restore CS8618 + + /// + public static InvalidationCreateParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData), + FrozenDictionary.ToFrozenDictionary(rawBodyData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(InvalidationCreateParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/v1/files/purge") + { + Query = this.QueryString(options), + }.Uri; + } + + internal override HttpContent? BodyContent() + { + return new StringContent( + JsonSerializer.Serialize(this.RawBodyData, ModelBase.SerializerOptions), + Text::Encoding.UTF8, + "application/json" + ); + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/ImageKit/Models/Cache/Invalidation/InvalidationCreateResponse.cs b/src/ImageKit/Models/Cache/Invalidation/InvalidationCreateResponse.cs new file mode 100644 index 00000000..c165154e --- /dev/null +++ b/src/ImageKit/Models/Cache/Invalidation/InvalidationCreateResponse.cs @@ -0,0 +1,79 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; + +namespace ImageKit.Models.Cache.Invalidation; + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class InvalidationCreateResponse : JsonModel +{ + /// + /// Unique identifier of the purge request. This can be used to check the status + /// of the purge request. + /// + public string? RequestID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("requestId"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("requestId", value); + } + } + + /// + public override void Validate() + { + _ = this.RequestID; + } + + public InvalidationCreateResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public InvalidationCreateResponse(InvalidationCreateResponse invalidationCreateResponse) + : base(invalidationCreateResponse) { } +#pragma warning restore CS8618 + + public InvalidationCreateResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + InvalidationCreateResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static InvalidationCreateResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class InvalidationCreateResponseFromRaw : IFromRawJson +{ + /// + public InvalidationCreateResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) => InvalidationCreateResponse.FromRawUnchecked(rawData); +} diff --git a/src/ImageKit/Models/Cache/Invalidation/InvalidationGetParams.cs b/src/ImageKit/Models/Cache/Invalidation/InvalidationGetParams.cs new file mode 100644 index 00000000..fe7a92f5 --- /dev/null +++ b/src/ImageKit/Models/Cache/Invalidation/InvalidationGetParams.cs @@ -0,0 +1,112 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using ImageKit.Core; + +namespace ImageKit.Models.Cache.Invalidation; + +/// +/// This API returns the status of a purge cache request. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class InvalidationGetParams : ParamsBase +{ + public string? RequestID { get; init; } + + public InvalidationGetParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public InvalidationGetParams(InvalidationGetParams invalidationGetParams) + : base(invalidationGetParams) + { + this.RequestID = invalidationGetParams.RequestID; + } +#pragma warning restore CS8618 + + public InvalidationGetParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + InvalidationGetParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } +#pragma warning restore CS8618 + + /// + public static InvalidationGetParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["RequestID"] = this.RequestID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(InvalidationGetParams? other) + { + if (other == null) + { + return false; + } + return (this.RequestID?.Equals(other.RequestID) ?? other.RequestID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder( + options.BaseUrl.ToString().TrimEnd('/') + + string.Format("/v1/files/purge/{0}", this.RequestID) + ) + { + Query = this.QueryString(options), + }.Uri; + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/ImageKit/Models/Cache/Invalidation/InvalidationGetResponse.cs b/src/ImageKit/Models/Cache/Invalidation/InvalidationGetResponse.cs new file mode 100644 index 00000000..9ffe4940 --- /dev/null +++ b/src/ImageKit/Models/Cache/Invalidation/InvalidationGetResponse.cs @@ -0,0 +1,121 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; +using ImageKit.Exceptions; + +namespace ImageKit.Models.Cache.Invalidation; + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class InvalidationGetResponse : JsonModel +{ + /// + /// Status of the purge request. + /// + public ApiEnum? Status + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("status"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("status", value); + } + } + + /// + public override void Validate() + { + this.Status?.Validate(); + } + + public InvalidationGetResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public InvalidationGetResponse(InvalidationGetResponse invalidationGetResponse) + : base(invalidationGetResponse) { } +#pragma warning restore CS8618 + + public InvalidationGetResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + InvalidationGetResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static InvalidationGetResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class InvalidationGetResponseFromRaw : IFromRawJson +{ + /// + public InvalidationGetResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) => InvalidationGetResponse.FromRawUnchecked(rawData); +} + +/// +/// Status of the purge request. +/// +[JsonConverter(typeof(StatusConverter))] +public enum Status +{ + Pending, + Completed, +} + +sealed class StatusConverter : JsonConverter +{ + public override Status Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "Pending" => Status.Pending, + "Completed" => Status.Completed, + _ => (Status)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Status value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + Status.Pending => "Pending", + Status.Completed => "Completed", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} diff --git a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataField.cs b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataField.cs new file mode 100644 index 00000000..c97842b7 --- /dev/null +++ b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataField.cs @@ -0,0 +1,1806 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; +using ImageKit.Exceptions; +using System = System; + +namespace ImageKit.Models.CustomMetadataFields; + +/// +/// Object containing details of a custom metadata field. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class CustomMetadataField : JsonModel +{ + /// + /// Unique identifier for the custom metadata field. Use this to update the field. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// Human readable name of the custom metadata field. This name is displayed + /// as form field label to the users while setting field value on the asset in + /// the media library UI. + /// + public required string Label + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("label"); + } + init { this._rawData.Set("label", value); } + } + + /// + /// API name of the custom metadata field. This becomes the key while setting + /// `customMetadata` (key-value object) for an asset using upload or update API. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + /// An object that describes the rules for the custom metadata field value. + /// + public required CustomMetadataFieldSchema Schema + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("schema"); + } + init { this._rawData.Set("schema", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.Label; + _ = this.Name; + this.Schema.Validate(); + } + + public CustomMetadataField() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CustomMetadataField(CustomMetadataField customMetadataField) + : base(customMetadataField) { } +#pragma warning restore CS8618 + + public CustomMetadataField(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + CustomMetadataField(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static CustomMetadataField FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class CustomMetadataFieldFromRaw : IFromRawJson +{ + /// + public CustomMetadataField FromRawUnchecked(IReadOnlyDictionary rawData) => + CustomMetadataField.FromRawUnchecked(rawData); +} + +/// +/// An object that describes the rules for the custom metadata field value. +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class CustomMetadataFieldSchema : JsonModel +{ + /// + /// Type of the custom metadata field. + /// + public required ApiEnum Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass>( + "type" + ); + } + init { this._rawData.Set("type", value); } + } + + /// + /// The default value for this custom metadata field. Data type of default value + /// depends on the field type. + /// + public CustomMetadataFieldSchemaDefaultValue? DefaultValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "defaultValue" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("defaultValue", value); + } + } + + /// + /// Specifies if the this custom metadata field is required or not. + /// + public bool? IsValueRequired + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("isValueRequired"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("isValueRequired", value); + } + } + + /// + /// Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. + /// + public double? MaxLength + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("maxLength"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("maxLength", value); + } + } + + /// + /// Maximum value of the field. Only set if field type is `Date` or `Number`. + /// For `Date` type field, the value will be in ISO8601 string format. For `Number` + /// type field, it will be a numeric value. + /// + public CustomMetadataFieldSchemaMaxValue? MaxValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("maxValue"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("maxValue", value); + } + } + + /// + /// Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. + /// + public double? MinLength + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("minLength"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("minLength", value); + } + } + + /// + /// Minimum value of the field. Only set if field type is `Date` or `Number`. + /// For `Date` type field, the value will be in ISO8601 string format. For `Number` + /// type field, it will be a numeric value. + /// + public CustomMetadataFieldSchemaMinValue? MinValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("minValue"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("minValue", value); + } + } + + /// + /// An array of allowed values when field type is `SingleSelect` or `MultiSelect`. + /// + public IReadOnlyList? SelectOptions + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct< + ImmutableArray + >("selectOptions"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "selectOptions", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + this.Type.Validate(); + this.DefaultValue?.Validate(); + _ = this.IsValueRequired; + _ = this.MaxLength; + this.MaxValue?.Validate(); + _ = this.MinLength; + this.MinValue?.Validate(); + foreach (var item in this.SelectOptions ?? []) + { + item.Validate(); + } + } + + public CustomMetadataFieldSchema() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CustomMetadataFieldSchema(CustomMetadataFieldSchema customMetadataFieldSchema) + : base(customMetadataFieldSchema) { } +#pragma warning restore CS8618 + + public CustomMetadataFieldSchema(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + CustomMetadataFieldSchema(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static CustomMetadataFieldSchema FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public CustomMetadataFieldSchema(ApiEnum type) + : this() + { + this.Type = type; + } +} + +class CustomMetadataFieldSchemaFromRaw : IFromRawJson +{ + /// + public CustomMetadataFieldSchema FromRawUnchecked( + IReadOnlyDictionary rawData + ) => CustomMetadataFieldSchema.FromRawUnchecked(rawData); +} + +/// +/// Type of the custom metadata field. +/// +[JsonConverter(typeof(CustomMetadataFieldSchemaTypeConverter))] +public enum CustomMetadataFieldSchemaType +{ + Text, + Textarea, + Number, + Date, + Boolean, + SingleSelect, + MultiSelect, +} + +sealed class CustomMetadataFieldSchemaTypeConverter : JsonConverter +{ + public override CustomMetadataFieldSchemaType Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "Text" => CustomMetadataFieldSchemaType.Text, + "Textarea" => CustomMetadataFieldSchemaType.Textarea, + "Number" => CustomMetadataFieldSchemaType.Number, + "Date" => CustomMetadataFieldSchemaType.Date, + "Boolean" => CustomMetadataFieldSchemaType.Boolean, + "SingleSelect" => CustomMetadataFieldSchemaType.SingleSelect, + "MultiSelect" => CustomMetadataFieldSchemaType.MultiSelect, + _ => (CustomMetadataFieldSchemaType)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + CustomMetadataFieldSchemaType value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + CustomMetadataFieldSchemaType.Text => "Text", + CustomMetadataFieldSchemaType.Textarea => "Textarea", + CustomMetadataFieldSchemaType.Number => "Number", + CustomMetadataFieldSchemaType.Date => "Date", + CustomMetadataFieldSchemaType.Boolean => "Boolean", + CustomMetadataFieldSchemaType.SingleSelect => "SingleSelect", + CustomMetadataFieldSchemaType.MultiSelect => "MultiSelect", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// The default value for this custom metadata field. Data type of default value depends +/// on the field type. +/// +[JsonConverter(typeof(CustomMetadataFieldSchemaDefaultValueConverter))] +public record class CustomMetadataFieldSchemaDefaultValue : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public CustomMetadataFieldSchemaDefaultValue(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public CustomMetadataFieldSchemaDefaultValue(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public CustomMetadataFieldSchemaDefaultValue(bool value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public CustomMetadataFieldSchemaDefaultValue( + IReadOnlyList value, + JsonElement? element = null + ) + { + this.Value = ImmutableArray.ToImmutableArray(value); + this._element = element; + } + + public CustomMetadataFieldSchemaDefaultValue(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickBool(out var value)) { + /// // `value` is of type `bool` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = this.Value as bool?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickMixed(out var value)) { + /// // `value` is of type `IReadOnlyList` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMixed( + [NotNullWhen(true)] out IReadOnlyList? value + ) + { + value = this.Value as IReadOnlyList; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action @string, + System::Action @double, + System::Action @bool, + System::Action> mixed + ) + { + switch (this.Value) + { + case string value: + @string(value); + break; + case double value: + @double(value); + break; + case bool value: + @bool(value); + break; + case IReadOnlyList value: + mixed(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of CustomMetadataFieldSchemaDefaultValue" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func @string, + System::Func @double, + System::Func @bool, + System::Func, T> mixed + ) + { + return this.Value switch + { + string value => @string(value), + double value => @double(value), + bool value => @bool(value), + IReadOnlyList value => mixed(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of CustomMetadataFieldSchemaDefaultValue" + ), + }; + } + + public static implicit operator CustomMetadataFieldSchemaDefaultValue(string value) => + new(value); + + public static implicit operator CustomMetadataFieldSchemaDefaultValue(double value) => + new(value); + + public static implicit operator CustomMetadataFieldSchemaDefaultValue(bool value) => new(value); + + public static implicit operator CustomMetadataFieldSchemaDefaultValue( + List value + ) => new((IReadOnlyList)value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of CustomMetadataFieldSchemaDefaultValue" + ); + } + } + + public virtual bool Equals(CustomMetadataFieldSchemaDefaultValue? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class CustomMetadataFieldSchemaDefaultValueConverter + : JsonConverter +{ + public override CustomMetadataFieldSchemaDefaultValue? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize>( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + CustomMetadataFieldSchemaDefaultValue value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(UnnamedSchemaWithArrayParent9Converter))] +public record class UnnamedSchemaWithArrayParent9 : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public UnnamedSchemaWithArrayParent9(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent9(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent9(bool value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent9(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickBool(out var value)) { + /// // `value` is of type `bool` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = this.Value as bool?; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action @string, + System::Action @double, + System::Action @bool + ) + { + switch (this.Value) + { + case string value: + @string(value); + break; + case double value: + @double(value); + break; + case bool value: + @bool(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent9" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func @string, + System::Func @double, + System::Func @bool + ) + { + return this.Value switch + { + string value => @string(value), + double value => @double(value), + bool value => @bool(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent9" + ), + }; + } + + public static implicit operator UnnamedSchemaWithArrayParent9(string value) => new(value); + + public static implicit operator UnnamedSchemaWithArrayParent9(double value) => new(value); + + public static implicit operator UnnamedSchemaWithArrayParent9(bool value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent9" + ); + } + } + + public virtual bool Equals(UnnamedSchemaWithArrayParent9? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class UnnamedSchemaWithArrayParent9Converter : JsonConverter +{ + public override UnnamedSchemaWithArrayParent9? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + UnnamedSchemaWithArrayParent9 value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +/// +/// Maximum value of the field. Only set if field type is `Date` or `Number`. For +/// `Date` type field, the value will be in ISO8601 string format. For `Number` type +/// field, it will be a numeric value. +/// +[JsonConverter(typeof(CustomMetadataFieldSchemaMaxValueConverter))] +public record class CustomMetadataFieldSchemaMaxValue : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public CustomMetadataFieldSchemaMaxValue(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public CustomMetadataFieldSchemaMaxValue(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public CustomMetadataFieldSchemaMaxValue(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (string value) => {...}, + /// (double value) => {...} + /// ); + /// + /// + /// + public void Switch(System::Action @string, System::Action @double) + { + switch (this.Value) + { + case string value: + @string(value); + break; + case double value: + @double(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of CustomMetadataFieldSchemaMaxValue" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (string value) => {...}, + /// (double value) => {...} + /// ); + /// + /// + /// + public T Match(System::Func @string, System::Func @double) + { + return this.Value switch + { + string value => @string(value), + double value => @double(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of CustomMetadataFieldSchemaMaxValue" + ), + }; + } + + public static implicit operator CustomMetadataFieldSchemaMaxValue(string value) => new(value); + + public static implicit operator CustomMetadataFieldSchemaMaxValue(double value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of CustomMetadataFieldSchemaMaxValue" + ); + } + } + + public virtual bool Equals(CustomMetadataFieldSchemaMaxValue? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class CustomMetadataFieldSchemaMaxValueConverter + : JsonConverter +{ + public override CustomMetadataFieldSchemaMaxValue? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + CustomMetadataFieldSchemaMaxValue value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +/// +/// Minimum value of the field. Only set if field type is `Date` or `Number`. For +/// `Date` type field, the value will be in ISO8601 string format. For `Number` type +/// field, it will be a numeric value. +/// +[JsonConverter(typeof(CustomMetadataFieldSchemaMinValueConverter))] +public record class CustomMetadataFieldSchemaMinValue : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public CustomMetadataFieldSchemaMinValue(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public CustomMetadataFieldSchemaMinValue(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public CustomMetadataFieldSchemaMinValue(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (string value) => {...}, + /// (double value) => {...} + /// ); + /// + /// + /// + public void Switch(System::Action @string, System::Action @double) + { + switch (this.Value) + { + case string value: + @string(value); + break; + case double value: + @double(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of CustomMetadataFieldSchemaMinValue" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (string value) => {...}, + /// (double value) => {...} + /// ); + /// + /// + /// + public T Match(System::Func @string, System::Func @double) + { + return this.Value switch + { + string value => @string(value), + double value => @double(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of CustomMetadataFieldSchemaMinValue" + ), + }; + } + + public static implicit operator CustomMetadataFieldSchemaMinValue(string value) => new(value); + + public static implicit operator CustomMetadataFieldSchemaMinValue(double value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of CustomMetadataFieldSchemaMinValue" + ); + } + } + + public virtual bool Equals(CustomMetadataFieldSchemaMinValue? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class CustomMetadataFieldSchemaMinValueConverter + : JsonConverter +{ + public override CustomMetadataFieldSchemaMinValue? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + CustomMetadataFieldSchemaMinValue value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(CustomMetadataFieldSchemaSelectOptionConverter))] +public record class CustomMetadataFieldSchemaSelectOption : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public CustomMetadataFieldSchemaSelectOption(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public CustomMetadataFieldSchemaSelectOption(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public CustomMetadataFieldSchemaSelectOption(bool value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public CustomMetadataFieldSchemaSelectOption(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickBool(out var value)) { + /// // `value` is of type `bool` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = this.Value as bool?; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action @string, + System::Action @double, + System::Action @bool + ) + { + switch (this.Value) + { + case string value: + @string(value); + break; + case double value: + @double(value); + break; + case bool value: + @bool(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of CustomMetadataFieldSchemaSelectOption" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func @string, + System::Func @double, + System::Func @bool + ) + { + return this.Value switch + { + string value => @string(value), + double value => @double(value), + bool value => @bool(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of CustomMetadataFieldSchemaSelectOption" + ), + }; + } + + public static implicit operator CustomMetadataFieldSchemaSelectOption(string value) => + new(value); + + public static implicit operator CustomMetadataFieldSchemaSelectOption(double value) => + new(value); + + public static implicit operator CustomMetadataFieldSchemaSelectOption(bool value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of CustomMetadataFieldSchemaSelectOption" + ); + } + } + + public virtual bool Equals(CustomMetadataFieldSchemaSelectOption? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class CustomMetadataFieldSchemaSelectOptionConverter + : JsonConverter +{ + public override CustomMetadataFieldSchemaSelectOption? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + CustomMetadataFieldSchemaSelectOption value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} diff --git a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldCreateParams.cs b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldCreateParams.cs new file mode 100644 index 00000000..4e1c6662 --- /dev/null +++ b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldCreateParams.cs @@ -0,0 +1,1840 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; +using ImageKit.Exceptions; +using System = System; +using Text = System.Text; + +namespace ImageKit.Models.CustomMetadataFields; + +/// +/// This API creates a new custom metadata field. Once a custom metadata field is +/// created either through this API or using the dashboard UI, its value can be set +/// on the assets. The value of a field for an asset can be set using the media library +/// UI or programmatically through upload or update assets API. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class CustomMetadataFieldCreateParams : ParamsBase +{ + readonly JsonDictionary _rawBodyData = new(); + public IReadOnlyDictionary RawBodyData + { + get { return this._rawBodyData.Freeze(); } + } + + /// + /// Human readable name of the custom metadata field. This should be unique across + /// all non deleted custom metadata fields. This name is displayed as form field + /// label to the users while setting field value on an asset in the media library UI. + /// + public required string Label + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullClass("label"); + } + init { this._rawBodyData.Set("label", value); } + } + + /// + /// API name of the custom metadata field. This should be unique across all (including + /// deleted) custom metadata fields. + /// + public required string Name + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullClass("name"); + } + init { this._rawBodyData.Set("name", value); } + } + + public required Schema Schema + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullClass("schema"); + } + init { this._rawBodyData.Set("schema", value); } + } + + public CustomMetadataFieldCreateParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CustomMetadataFieldCreateParams( + CustomMetadataFieldCreateParams customMetadataFieldCreateParams + ) + : base(customMetadataFieldCreateParams) + { + this._rawBodyData = new(customMetadataFieldCreateParams._rawBodyData); + } +#pragma warning restore CS8618 + + public CustomMetadataFieldCreateParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + CustomMetadataFieldCreateParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData, + FrozenDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } +#pragma warning restore CS8618 + + /// + public static CustomMetadataFieldCreateParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData), + FrozenDictionary.ToFrozenDictionary(rawBodyData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(CustomMetadataFieldCreateParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + + public override System::Uri Url(ClientOptions options) + { + return new System::UriBuilder( + options.BaseUrl.ToString().TrimEnd('/') + "/v1/customMetadataFields" + ) + { + Query = this.QueryString(options), + }.Uri; + } + + internal override HttpContent? BodyContent() + { + return new StringContent( + JsonSerializer.Serialize(this.RawBodyData, ModelBase.SerializerOptions), + Text::Encoding.UTF8, + "application/json" + ); + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Schema : JsonModel +{ + /// + /// Type of the custom metadata field. + /// + public required ApiEnum Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum + >("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// The default value for this custom metadata field. This property is only required + /// if `isValueRequired` property is set to `true`. The value should match the + /// `type` of custom metadata field. + /// + public DefaultValue? DefaultValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("defaultValue"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("defaultValue", value); + } + } + + /// + /// Sets this custom metadata field as required. Setting custom metadata fields + /// on an asset will throw error if the value for all required fields are not + /// present in upload or update asset API request body. + /// + public bool? IsValueRequired + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("isValueRequired"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("isValueRequired", value); + } + } + + /// + /// Maximum length of string. Only set this property if `type` is set to `Text` + /// or `Textarea`. + /// + public double? MaxLength + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("maxLength"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("maxLength", value); + } + } + + /// + /// Maximum value of the field. Only set this property if field type is `Date` + /// or `Number`. For `Date` type field, set the minimum date in ISO8601 string + /// format. For `Number` type field, set the minimum numeric value. + /// + public MaxValue? MaxValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("maxValue"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("maxValue", value); + } + } + + /// + /// Minimum length of string. Only set this property if `type` is set to `Text` + /// or `Textarea`. + /// + public double? MinLength + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("minLength"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("minLength", value); + } + } + + /// + /// Minimum value of the field. Only set this property if field type is `Date` + /// or `Number`. For `Date` type field, set the minimum date in ISO8601 string + /// format. For `Number` type field, set the minimum numeric value. + /// + public MinValue? MinValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("minValue"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("minValue", value); + } + } + + /// + /// An array of allowed values. This property is only required if `type` property + /// is set to `SingleSelect` or `MultiSelect`. + /// + public IReadOnlyList? SelectOptions + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>("selectOptions"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "selectOptions", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + this.Type.Validate(); + this.DefaultValue?.Validate(); + _ = this.IsValueRequired; + _ = this.MaxLength; + this.MaxValue?.Validate(); + _ = this.MinLength; + this.MinValue?.Validate(); + foreach (var item in this.SelectOptions ?? []) + { + item.Validate(); + } + } + + public Schema() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Schema(Schema schema) + : base(schema) { } +#pragma warning restore CS8618 + + public Schema(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Schema(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static Schema FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public Schema(ApiEnum type) + : this() + { + this.Type = type; + } +} + +class SchemaFromRaw : IFromRawJson +{ + /// + public Schema FromRawUnchecked(IReadOnlyDictionary rawData) => + Schema.FromRawUnchecked(rawData); +} + +/// +/// Type of the custom metadata field. +/// +[JsonConverter(typeof(TypeConverter))] +public enum Type +{ + Text, + Textarea, + Number, + Date, + Boolean, + SingleSelect, + MultiSelect, +} + +sealed class TypeConverter : JsonConverter +{ + public override global::ImageKit.Models.CustomMetadataFields.Type Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "Text" => global::ImageKit.Models.CustomMetadataFields.Type.Text, + "Textarea" => global::ImageKit.Models.CustomMetadataFields.Type.Textarea, + "Number" => global::ImageKit.Models.CustomMetadataFields.Type.Number, + "Date" => global::ImageKit.Models.CustomMetadataFields.Type.Date, + "Boolean" => global::ImageKit.Models.CustomMetadataFields.Type.Boolean, + "SingleSelect" => global::ImageKit.Models.CustomMetadataFields.Type.SingleSelect, + "MultiSelect" => global::ImageKit.Models.CustomMetadataFields.Type.MultiSelect, + _ => (global::ImageKit.Models.CustomMetadataFields.Type)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + global::ImageKit.Models.CustomMetadataFields.Type value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + global::ImageKit.Models.CustomMetadataFields.Type.Text => "Text", + global::ImageKit.Models.CustomMetadataFields.Type.Textarea => "Textarea", + global::ImageKit.Models.CustomMetadataFields.Type.Number => "Number", + global::ImageKit.Models.CustomMetadataFields.Type.Date => "Date", + global::ImageKit.Models.CustomMetadataFields.Type.Boolean => "Boolean", + global::ImageKit.Models.CustomMetadataFields.Type.SingleSelect => "SingleSelect", + global::ImageKit.Models.CustomMetadataFields.Type.MultiSelect => "MultiSelect", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// The default value for this custom metadata field. This property is only required +/// if `isValueRequired` property is set to `true`. The value should match the `type` +/// of custom metadata field. +/// +[JsonConverter(typeof(DefaultValueConverter))] +public record class DefaultValue : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public DefaultValue(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public DefaultValue(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public DefaultValue(bool value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public DefaultValue( + IReadOnlyList value, + JsonElement? element = null + ) + { + this.Value = ImmutableArray.ToImmutableArray(value); + this._element = element; + } + + public DefaultValue(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickBool(out var value)) { + /// // `value` is of type `bool` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = this.Value as bool?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickMixed(out var value)) { + /// // `value` is of type `IReadOnlyList` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMixed( + [NotNullWhen(true)] out IReadOnlyList? value + ) + { + value = this.Value as IReadOnlyList; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action @string, + System::Action @double, + System::Action @bool, + System::Action> mixed + ) + { + switch (this.Value) + { + case string value: + @string(value); + break; + case double value: + @double(value); + break; + case bool value: + @bool(value); + break; + case IReadOnlyList value: + mixed(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of DefaultValue" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func @string, + System::Func @double, + System::Func @bool, + System::Func, T> mixed + ) + { + return this.Value switch + { + string value => @string(value), + double value => @double(value), + bool value => @bool(value), + IReadOnlyList value => mixed(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of DefaultValue" + ), + }; + } + + public static implicit operator DefaultValue(string value) => new(value); + + public static implicit operator DefaultValue(double value) => new(value); + + public static implicit operator DefaultValue(bool value) => new(value); + + public static implicit operator DefaultValue(List value) => + new((IReadOnlyList)value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of DefaultValue" + ); + } + } + + public virtual bool Equals(DefaultValue? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class DefaultValueConverter : JsonConverter +{ + public override DefaultValue? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize>( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + DefaultValue value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(UnnamedSchemaWithArrayParent1Converter))] +public record class UnnamedSchemaWithArrayParent1 : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public UnnamedSchemaWithArrayParent1(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent1(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent1(bool value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent1(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickBool(out var value)) { + /// // `value` is of type `bool` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = this.Value as bool?; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action @string, + System::Action @double, + System::Action @bool + ) + { + switch (this.Value) + { + case string value: + @string(value); + break; + case double value: + @double(value); + break; + case bool value: + @bool(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent1" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func @string, + System::Func @double, + System::Func @bool + ) + { + return this.Value switch + { + string value => @string(value), + double value => @double(value), + bool value => @bool(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent1" + ), + }; + } + + public static implicit operator UnnamedSchemaWithArrayParent1(string value) => new(value); + + public static implicit operator UnnamedSchemaWithArrayParent1(double value) => new(value); + + public static implicit operator UnnamedSchemaWithArrayParent1(bool value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent1" + ); + } + } + + public virtual bool Equals(UnnamedSchemaWithArrayParent1? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class UnnamedSchemaWithArrayParent1Converter : JsonConverter +{ + public override UnnamedSchemaWithArrayParent1? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + UnnamedSchemaWithArrayParent1 value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +/// +/// Maximum value of the field. Only set this property if field type is `Date` or +/// `Number`. For `Date` type field, set the minimum date in ISO8601 string format. +/// For `Number` type field, set the minimum numeric value. +/// +[JsonConverter(typeof(MaxValueConverter))] +public record class MaxValue : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public MaxValue(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public MaxValue(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public MaxValue(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (string value) => {...}, + /// (double value) => {...} + /// ); + /// + /// + /// + public void Switch(System::Action @string, System::Action @double) + { + switch (this.Value) + { + case string value: + @string(value); + break; + case double value: + @double(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of MaxValue" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (string value) => {...}, + /// (double value) => {...} + /// ); + /// + /// + /// + public T Match(System::Func @string, System::Func @double) + { + return this.Value switch + { + string value => @string(value), + double value => @double(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of MaxValue" + ), + }; + } + + public static implicit operator MaxValue(string value) => new(value); + + public static implicit operator MaxValue(double value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException("Data did not match any variant of MaxValue"); + } + } + + public virtual bool Equals(MaxValue? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class MaxValueConverter : JsonConverter +{ + public override MaxValue? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write(Utf8JsonWriter writer, MaxValue value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +/// +/// Minimum value of the field. Only set this property if field type is `Date` or +/// `Number`. For `Date` type field, set the minimum date in ISO8601 string format. +/// For `Number` type field, set the minimum numeric value. +/// +[JsonConverter(typeof(MinValueConverter))] +public record class MinValue : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public MinValue(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public MinValue(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public MinValue(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (string value) => {...}, + /// (double value) => {...} + /// ); + /// + /// + /// + public void Switch(System::Action @string, System::Action @double) + { + switch (this.Value) + { + case string value: + @string(value); + break; + case double value: + @double(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of MinValue" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (string value) => {...}, + /// (double value) => {...} + /// ); + /// + /// + /// + public T Match(System::Func @string, System::Func @double) + { + return this.Value switch + { + string value => @string(value), + double value => @double(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of MinValue" + ), + }; + } + + public static implicit operator MinValue(string value) => new(value); + + public static implicit operator MinValue(double value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException("Data did not match any variant of MinValue"); + } + } + + public virtual bool Equals(MinValue? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class MinValueConverter : JsonConverter +{ + public override MinValue? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write(Utf8JsonWriter writer, MinValue value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(SelectOptionConverter))] +public record class SelectOption : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public SelectOption(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public SelectOption(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public SelectOption(bool value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public SelectOption(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickBool(out var value)) { + /// // `value` is of type `bool` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = this.Value as bool?; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action @string, + System::Action @double, + System::Action @bool + ) + { + switch (this.Value) + { + case string value: + @string(value); + break; + case double value: + @double(value); + break; + case bool value: + @bool(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of SelectOption" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func @string, + System::Func @double, + System::Func @bool + ) + { + return this.Value switch + { + string value => @string(value), + double value => @double(value), + bool value => @bool(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of SelectOption" + ), + }; + } + + public static implicit operator SelectOption(string value) => new(value); + + public static implicit operator SelectOption(double value) => new(value); + + public static implicit operator SelectOption(bool value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of SelectOption" + ); + } + } + + public virtual bool Equals(SelectOption? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class SelectOptionConverter : JsonConverter +{ + public override SelectOption? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + SelectOption value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} diff --git a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldDeleteParams.cs b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldDeleteParams.cs new file mode 100644 index 00000000..73631a62 --- /dev/null +++ b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldDeleteParams.cs @@ -0,0 +1,115 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using ImageKit.Core; + +namespace ImageKit.Models.CustomMetadataFields; + +/// +/// This API deletes a custom metadata field. Even after deleting a custom metadata +/// field, you cannot create any new custom metadata field with the same name. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class CustomMetadataFieldDeleteParams : ParamsBase +{ + public string? ID { get; init; } + + public CustomMetadataFieldDeleteParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CustomMetadataFieldDeleteParams( + CustomMetadataFieldDeleteParams customMetadataFieldDeleteParams + ) + : base(customMetadataFieldDeleteParams) + { + this.ID = customMetadataFieldDeleteParams.ID; + } +#pragma warning restore CS8618 + + public CustomMetadataFieldDeleteParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + CustomMetadataFieldDeleteParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } +#pragma warning restore CS8618 + + /// + public static CustomMetadataFieldDeleteParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["ID"] = this.ID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(CustomMetadataFieldDeleteParams? other) + { + if (other == null) + { + return false; + } + return (this.ID?.Equals(other.ID) ?? other.ID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder( + options.BaseUrl.ToString().TrimEnd('/') + + string.Format("/v1/customMetadataFields/{0}", this.ID) + ) + { + Query = this.QueryString(options), + }.Uri; + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldDeleteResponse.cs b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldDeleteResponse.cs new file mode 100644 index 00000000..25274811 --- /dev/null +++ b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldDeleteResponse.cs @@ -0,0 +1,59 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; + +namespace ImageKit.Models.CustomMetadataFields; + +[JsonConverter( + typeof(JsonModelConverter< + CustomMetadataFieldDeleteResponse, + CustomMetadataFieldDeleteResponseFromRaw + >) +)] +public sealed record class CustomMetadataFieldDeleteResponse : JsonModel +{ + /// + public override void Validate() { } + + public CustomMetadataFieldDeleteResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CustomMetadataFieldDeleteResponse( + CustomMetadataFieldDeleteResponse customMetadataFieldDeleteResponse + ) + : base(customMetadataFieldDeleteResponse) { } +#pragma warning restore CS8618 + + public CustomMetadataFieldDeleteResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + CustomMetadataFieldDeleteResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static CustomMetadataFieldDeleteResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class CustomMetadataFieldDeleteResponseFromRaw : IFromRawJson +{ + /// + public CustomMetadataFieldDeleteResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) => CustomMetadataFieldDeleteResponse.FromRawUnchecked(rawData); +} diff --git a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldListParams.cs b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldListParams.cs new file mode 100644 index 00000000..2252a1e2 --- /dev/null +++ b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldListParams.cs @@ -0,0 +1,156 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using ImageKit.Core; + +namespace ImageKit.Models.CustomMetadataFields; + +/// +/// This API returns the array of created custom metadata field objects. By default +/// the API returns only non deleted field objects, but you can include deleted fields +/// in the API response. +/// +/// You can also filter results by a specific folder path to retrieve custom +/// metadata fields applicable at that location. This path-specific filtering is useful +/// when using the **Path policy** feature to determine which custom metadata fields +/// are selected for a given path. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class CustomMetadataFieldListParams : ParamsBase +{ + /// + /// The folder path (e.g., `/path/to/folder`) for which to retrieve applicable + /// custom metadata fields. Useful for determining path-specific field selections + /// when the [Path policy](https://imagekit.io/docs/dam/path-policy) feature + /// is in use. + /// + public string? FolderPath + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableClass("folderPath"); + } + init + { + if (value == null) + { + return; + } + + this._rawQueryData.Set("folderPath", value); + } + } + + /// + /// Set it to `true` to include deleted field objects in the API response. + /// + public bool? IncludeDeleted + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableStruct("includeDeleted"); + } + init + { + if (value == null) + { + return; + } + + this._rawQueryData.Set("includeDeleted", value); + } + } + + public CustomMetadataFieldListParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CustomMetadataFieldListParams( + CustomMetadataFieldListParams customMetadataFieldListParams + ) + : base(customMetadataFieldListParams) { } +#pragma warning restore CS8618 + + public CustomMetadataFieldListParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + CustomMetadataFieldListParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } +#pragma warning restore CS8618 + + /// + public static CustomMetadataFieldListParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(CustomMetadataFieldListParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/v1/customMetadataFields") + { + Query = this.QueryString(options), + }.Uri; + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParams.cs b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParams.cs new file mode 100644 index 00000000..a19875b3 --- /dev/null +++ b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParams.cs @@ -0,0 +1,1844 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; +using ImageKit.Exceptions; +using System = System; +using Text = System.Text; + +namespace ImageKit.Models.CustomMetadataFields; + +/// +/// This API updates the label or schema of an existing custom metadata field. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class CustomMetadataFieldUpdateParams : ParamsBase +{ + readonly JsonDictionary _rawBodyData = new(); + public IReadOnlyDictionary RawBodyData + { + get { return this._rawBodyData.Freeze(); } + } + + public string? ID { get; init; } + + /// + /// Human readable name of the custom metadata field. This should be unique across + /// all non deleted custom metadata fields. This name is displayed as form field + /// label to the users while setting field value on an asset in the media library + /// UI. This parameter is required if `schema` is not provided. + /// + public string? Label + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass("label"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("label", value); + } + } + + /// + /// An object that describes the rules for the custom metadata key. This parameter + /// is required if `label` is not provided. Note: `type` cannot be updated and + /// will be ignored if sent with the `schema`. The schema will be validated as + /// per the existing `type`. + /// + public CustomMetadataFieldUpdateParamsSchema? Schema + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass( + "schema" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("schema", value); + } + } + + public CustomMetadataFieldUpdateParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CustomMetadataFieldUpdateParams( + CustomMetadataFieldUpdateParams customMetadataFieldUpdateParams + ) + : base(customMetadataFieldUpdateParams) + { + this.ID = customMetadataFieldUpdateParams.ID; + + this._rawBodyData = new(customMetadataFieldUpdateParams._rawBodyData); + } +#pragma warning restore CS8618 + + public CustomMetadataFieldUpdateParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + CustomMetadataFieldUpdateParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData, + FrozenDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } +#pragma warning restore CS8618 + + /// + public static CustomMetadataFieldUpdateParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData), + FrozenDictionary.ToFrozenDictionary(rawBodyData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["ID"] = this.ID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(CustomMetadataFieldUpdateParams? other) + { + if (other == null) + { + return false; + } + return (this.ID?.Equals(other.ID) ?? other.ID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + + public override System::Uri Url(ClientOptions options) + { + return new System::UriBuilder( + options.BaseUrl.ToString().TrimEnd('/') + + string.Format("/v1/customMetadataFields/{0}", this.ID) + ) + { + Query = this.QueryString(options), + }.Uri; + } + + internal override HttpContent? BodyContent() + { + return new StringContent( + JsonSerializer.Serialize(this.RawBodyData, ModelBase.SerializerOptions), + Text::Encoding.UTF8, + "application/json" + ); + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} + +/// +/// An object that describes the rules for the custom metadata key. This parameter +/// is required if `label` is not provided. Note: `type` cannot be updated and will +/// be ignored if sent with the `schema`. The schema will be validated as per the +/// existing `type`. +/// +[JsonConverter( + typeof(JsonModelConverter< + CustomMetadataFieldUpdateParamsSchema, + CustomMetadataFieldUpdateParamsSchemaFromRaw + >) +)] +public sealed record class CustomMetadataFieldUpdateParamsSchema : JsonModel +{ + /// + /// The default value for this custom metadata field. This property is only required + /// if `isValueRequired` property is set to `true`. The value should match the + /// `type` of custom metadata field. + /// + public CustomMetadataFieldUpdateParamsSchemaDefaultValue? DefaultValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "defaultValue" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("defaultValue", value); + } + } + + /// + /// Sets this custom metadata field as required. Setting custom metadata fields + /// on an asset will throw error if the value for all required fields are not + /// present in upload or update asset API request body. + /// + public bool? IsValueRequired + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("isValueRequired"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("isValueRequired", value); + } + } + + /// + /// Maximum length of string. Only set this property if `type` is set to `Text` + /// or `Textarea`. + /// + public double? MaxLength + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("maxLength"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("maxLength", value); + } + } + + /// + /// Maximum value of the field. Only set this property if field type is `Date` + /// or `Number`. For `Date` type field, set the minimum date in ISO8601 string + /// format. For `Number` type field, set the minimum numeric value. + /// + public CustomMetadataFieldUpdateParamsSchemaMaxValue? MaxValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "maxValue" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("maxValue", value); + } + } + + /// + /// Minimum length of string. Only set this property if `type` is set to `Text` + /// or `Textarea`. + /// + public double? MinLength + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("minLength"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("minLength", value); + } + } + + /// + /// Minimum value of the field. Only set this property if field type is `Date` + /// or `Number`. For `Date` type field, set the minimum date in ISO8601 string + /// format. For `Number` type field, set the minimum numeric value. + /// + public CustomMetadataFieldUpdateParamsSchemaMinValue? MinValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "minValue" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("minValue", value); + } + } + + /// + /// An array of allowed values. This property is only required if `type` property + /// is set to `SingleSelect` or `MultiSelect`. + /// + public IReadOnlyList? SelectOptions + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct< + ImmutableArray + >("selectOptions"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "selectOptions", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + this.DefaultValue?.Validate(); + _ = this.IsValueRequired; + _ = this.MaxLength; + this.MaxValue?.Validate(); + _ = this.MinLength; + this.MinValue?.Validate(); + foreach (var item in this.SelectOptions ?? []) + { + item.Validate(); + } + } + + public CustomMetadataFieldUpdateParamsSchema() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CustomMetadataFieldUpdateParamsSchema( + CustomMetadataFieldUpdateParamsSchema customMetadataFieldUpdateParamsSchema + ) + : base(customMetadataFieldUpdateParamsSchema) { } +#pragma warning restore CS8618 + + public CustomMetadataFieldUpdateParamsSchema(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + CustomMetadataFieldUpdateParamsSchema(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static CustomMetadataFieldUpdateParamsSchema FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class CustomMetadataFieldUpdateParamsSchemaFromRaw + : IFromRawJson +{ + /// + public CustomMetadataFieldUpdateParamsSchema FromRawUnchecked( + IReadOnlyDictionary rawData + ) => CustomMetadataFieldUpdateParamsSchema.FromRawUnchecked(rawData); +} + +/// +/// The default value for this custom metadata field. This property is only required +/// if `isValueRequired` property is set to `true`. The value should match the `type` +/// of custom metadata field. +/// +[JsonConverter(typeof(CustomMetadataFieldUpdateParamsSchemaDefaultValueConverter))] +public record class CustomMetadataFieldUpdateParamsSchemaDefaultValue : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public CustomMetadataFieldUpdateParamsSchemaDefaultValue( + string value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public CustomMetadataFieldUpdateParamsSchemaDefaultValue( + double value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public CustomMetadataFieldUpdateParamsSchemaDefaultValue( + bool value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public CustomMetadataFieldUpdateParamsSchemaDefaultValue( + IReadOnlyList value, + JsonElement? element = null + ) + { + this.Value = ImmutableArray.ToImmutableArray(value); + this._element = element; + } + + public CustomMetadataFieldUpdateParamsSchemaDefaultValue(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickBool(out var value)) { + /// // `value` is of type `bool` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = this.Value as bool?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickMixed(out var value)) { + /// // `value` is of type `IReadOnlyList` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMixed( + [NotNullWhen(true)] out IReadOnlyList? value + ) + { + value = this.Value as IReadOnlyList; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action @string, + System::Action @double, + System::Action @bool, + System::Action> mixed + ) + { + switch (this.Value) + { + case string value: + @string(value); + break; + case double value: + @double(value); + break; + case bool value: + @bool(value); + break; + case IReadOnlyList value: + mixed(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of CustomMetadataFieldUpdateParamsSchemaDefaultValue" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func @string, + System::Func @double, + System::Func @bool, + System::Func, T> mixed + ) + { + return this.Value switch + { + string value => @string(value), + double value => @double(value), + bool value => @bool(value), + IReadOnlyList value => mixed(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of CustomMetadataFieldUpdateParamsSchemaDefaultValue" + ), + }; + } + + public static implicit operator CustomMetadataFieldUpdateParamsSchemaDefaultValue( + string value + ) => new(value); + + public static implicit operator CustomMetadataFieldUpdateParamsSchemaDefaultValue( + double value + ) => new(value); + + public static implicit operator CustomMetadataFieldUpdateParamsSchemaDefaultValue(bool value) => + new(value); + + public static implicit operator CustomMetadataFieldUpdateParamsSchemaDefaultValue( + List value + ) => new((IReadOnlyList)value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of CustomMetadataFieldUpdateParamsSchemaDefaultValue" + ); + } + } + + public virtual bool Equals(CustomMetadataFieldUpdateParamsSchemaDefaultValue? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class CustomMetadataFieldUpdateParamsSchemaDefaultValueConverter + : JsonConverter +{ + public override CustomMetadataFieldUpdateParamsSchemaDefaultValue? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize>( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + CustomMetadataFieldUpdateParamsSchemaDefaultValue value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(UnnamedSchemaWithArrayParent2Converter))] +public record class UnnamedSchemaWithArrayParent2 : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public UnnamedSchemaWithArrayParent2(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent2(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent2(bool value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent2(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickBool(out var value)) { + /// // `value` is of type `bool` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = this.Value as bool?; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action @string, + System::Action @double, + System::Action @bool + ) + { + switch (this.Value) + { + case string value: + @string(value); + break; + case double value: + @double(value); + break; + case bool value: + @bool(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent2" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func @string, + System::Func @double, + System::Func @bool + ) + { + return this.Value switch + { + string value => @string(value), + double value => @double(value), + bool value => @bool(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent2" + ), + }; + } + + public static implicit operator UnnamedSchemaWithArrayParent2(string value) => new(value); + + public static implicit operator UnnamedSchemaWithArrayParent2(double value) => new(value); + + public static implicit operator UnnamedSchemaWithArrayParent2(bool value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent2" + ); + } + } + + public virtual bool Equals(UnnamedSchemaWithArrayParent2? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class UnnamedSchemaWithArrayParent2Converter : JsonConverter +{ + public override UnnamedSchemaWithArrayParent2? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + UnnamedSchemaWithArrayParent2 value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +/// +/// Maximum value of the field. Only set this property if field type is `Date` or +/// `Number`. For `Date` type field, set the minimum date in ISO8601 string format. +/// For `Number` type field, set the minimum numeric value. +/// +[JsonConverter(typeof(CustomMetadataFieldUpdateParamsSchemaMaxValueConverter))] +public record class CustomMetadataFieldUpdateParamsSchemaMaxValue : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public CustomMetadataFieldUpdateParamsSchemaMaxValue(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public CustomMetadataFieldUpdateParamsSchemaMaxValue(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public CustomMetadataFieldUpdateParamsSchemaMaxValue(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (string value) => {...}, + /// (double value) => {...} + /// ); + /// + /// + /// + public void Switch(System::Action @string, System::Action @double) + { + switch (this.Value) + { + case string value: + @string(value); + break; + case double value: + @double(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of CustomMetadataFieldUpdateParamsSchemaMaxValue" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (string value) => {...}, + /// (double value) => {...} + /// ); + /// + /// + /// + public T Match(System::Func @string, System::Func @double) + { + return this.Value switch + { + string value => @string(value), + double value => @double(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of CustomMetadataFieldUpdateParamsSchemaMaxValue" + ), + }; + } + + public static implicit operator CustomMetadataFieldUpdateParamsSchemaMaxValue(string value) => + new(value); + + public static implicit operator CustomMetadataFieldUpdateParamsSchemaMaxValue(double value) => + new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of CustomMetadataFieldUpdateParamsSchemaMaxValue" + ); + } + } + + public virtual bool Equals(CustomMetadataFieldUpdateParamsSchemaMaxValue? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class CustomMetadataFieldUpdateParamsSchemaMaxValueConverter + : JsonConverter +{ + public override CustomMetadataFieldUpdateParamsSchemaMaxValue? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + CustomMetadataFieldUpdateParamsSchemaMaxValue value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +/// +/// Minimum value of the field. Only set this property if field type is `Date` or +/// `Number`. For `Date` type field, set the minimum date in ISO8601 string format. +/// For `Number` type field, set the minimum numeric value. +/// +[JsonConverter(typeof(CustomMetadataFieldUpdateParamsSchemaMinValueConverter))] +public record class CustomMetadataFieldUpdateParamsSchemaMinValue : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public CustomMetadataFieldUpdateParamsSchemaMinValue(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public CustomMetadataFieldUpdateParamsSchemaMinValue(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public CustomMetadataFieldUpdateParamsSchemaMinValue(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (string value) => {...}, + /// (double value) => {...} + /// ); + /// + /// + /// + public void Switch(System::Action @string, System::Action @double) + { + switch (this.Value) + { + case string value: + @string(value); + break; + case double value: + @double(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of CustomMetadataFieldUpdateParamsSchemaMinValue" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (string value) => {...}, + /// (double value) => {...} + /// ); + /// + /// + /// + public T Match(System::Func @string, System::Func @double) + { + return this.Value switch + { + string value => @string(value), + double value => @double(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of CustomMetadataFieldUpdateParamsSchemaMinValue" + ), + }; + } + + public static implicit operator CustomMetadataFieldUpdateParamsSchemaMinValue(string value) => + new(value); + + public static implicit operator CustomMetadataFieldUpdateParamsSchemaMinValue(double value) => + new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of CustomMetadataFieldUpdateParamsSchemaMinValue" + ); + } + } + + public virtual bool Equals(CustomMetadataFieldUpdateParamsSchemaMinValue? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class CustomMetadataFieldUpdateParamsSchemaMinValueConverter + : JsonConverter +{ + public override CustomMetadataFieldUpdateParamsSchemaMinValue? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + CustomMetadataFieldUpdateParamsSchemaMinValue value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(CustomMetadataFieldUpdateParamsSchemaSelectOptionConverter))] +public record class CustomMetadataFieldUpdateParamsSchemaSelectOption : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public CustomMetadataFieldUpdateParamsSchemaSelectOption( + string value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public CustomMetadataFieldUpdateParamsSchemaSelectOption( + double value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public CustomMetadataFieldUpdateParamsSchemaSelectOption( + bool value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public CustomMetadataFieldUpdateParamsSchemaSelectOption(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickBool(out var value)) { + /// // `value` is of type `bool` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = this.Value as bool?; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action @string, + System::Action @double, + System::Action @bool + ) + { + switch (this.Value) + { + case string value: + @string(value); + break; + case double value: + @double(value); + break; + case bool value: + @bool(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of CustomMetadataFieldUpdateParamsSchemaSelectOption" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func @string, + System::Func @double, + System::Func @bool + ) + { + return this.Value switch + { + string value => @string(value), + double value => @double(value), + bool value => @bool(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of CustomMetadataFieldUpdateParamsSchemaSelectOption" + ), + }; + } + + public static implicit operator CustomMetadataFieldUpdateParamsSchemaSelectOption( + string value + ) => new(value); + + public static implicit operator CustomMetadataFieldUpdateParamsSchemaSelectOption( + double value + ) => new(value); + + public static implicit operator CustomMetadataFieldUpdateParamsSchemaSelectOption(bool value) => + new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of CustomMetadataFieldUpdateParamsSchemaSelectOption" + ); + } + } + + public virtual bool Equals(CustomMetadataFieldUpdateParamsSchemaSelectOption? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class CustomMetadataFieldUpdateParamsSchemaSelectOptionConverter + : JsonConverter +{ + public override CustomMetadataFieldUpdateParamsSchemaSelectOption? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + CustomMetadataFieldUpdateParamsSchemaSelectOption value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} diff --git a/src/ImageKit/Models/ExtensionConfig.cs b/src/ImageKit/Models/ExtensionConfig.cs new file mode 100644 index 00000000..c4a32235 --- /dev/null +++ b/src/ImageKit/Models/ExtensionConfig.cs @@ -0,0 +1,4763 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; +using ImageKit.Exceptions; + +namespace ImageKit.Models; + +/// +/// Configuration object for an extension (base extensions only, not saved extension references). +/// +[JsonConverter(typeof(ExtensionConfigConverter))] +public record class ExtensionConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ExtensionConfig(RemoveBg value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public ExtensionConfig(AutoTaggingExtension value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public ExtensionConfig(AIAutoDescription value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public ExtensionConfig(AITasks value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public ExtensionConfig(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickRemoveBg(out var value)) { + /// // `value` is of type `RemoveBg` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickRemoveBg([NotNullWhen(true)] out RemoveBg? value) + { + value = this.Value as RemoveBg; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickAutoTaggingExtension(out var value)) { + /// // `value` is of type `AutoTaggingExtension` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickAutoTaggingExtension([NotNullWhen(true)] out AutoTaggingExtension? value) + { + value = this.Value as AutoTaggingExtension; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickAIAutoDescription(out var value)) { + /// // `value` is of type `AIAutoDescription` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickAIAutoDescription([NotNullWhen(true)] out AIAutoDescription? value) + { + value = this.Value as AIAutoDescription; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickAITasks(out var value)) { + /// // `value` is of type `AITasks` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickAITasks([NotNullWhen(true)] out AITasks? value) + { + value = this.Value as AITasks; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (RemoveBg value) => {...}, + /// (AutoTaggingExtension value) => {...}, + /// (AIAutoDescription value) => {...}, + /// (AITasks value) => {...} + /// ); + /// + /// + /// + public void Switch( + Action removeBg, + Action autoTaggingExtension, + Action aiAutoDescription, + Action aiTasks + ) + { + switch (this.Value) + { + case RemoveBg value: + removeBg(value); + break; + case AutoTaggingExtension value: + autoTaggingExtension(value); + break; + case AIAutoDescription value: + aiAutoDescription(value); + break; + case AITasks value: + aiTasks(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of ExtensionConfig" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (RemoveBg value) => {...}, + /// (AutoTaggingExtension value) => {...}, + /// (AIAutoDescription value) => {...}, + /// (AITasks value) => {...} + /// ); + /// + /// + /// + public T Match( + Func removeBg, + Func autoTaggingExtension, + Func aiAutoDescription, + Func aiTasks + ) + { + return this.Value switch + { + RemoveBg value => removeBg(value), + AutoTaggingExtension value => autoTaggingExtension(value), + AIAutoDescription value => aiAutoDescription(value), + AITasks value => aiTasks(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of ExtensionConfig" + ), + }; + } + + public static implicit operator ExtensionConfig(RemoveBg value) => new(value); + + public static implicit operator ExtensionConfig(AutoTaggingExtension value) => new(value); + + public static implicit operator ExtensionConfig(AIAutoDescription value) => new(value); + + public static implicit operator ExtensionConfig(AITasks value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of ExtensionConfig" + ); + } + this.Switch( + (removeBg) => removeBg.Validate(), + (autoTaggingExtension) => autoTaggingExtension.Validate(), + (aiAutoDescription) => aiAutoDescription.Validate(), + (aiTasks) => aiTasks.Validate() + ); + } + + public virtual bool Equals(ExtensionConfig? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class ExtensionConfigConverter : JsonConverter +{ + public override ExtensionConfig? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + string? name; + try + { + name = element.GetProperty("name").GetString(); + } + catch + { + name = null; + } + + switch (name) + { + case "remove-bg": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + case "ai-auto-description": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + case "ai-tasks": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + default: + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ExtensionConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class RemoveBg : JsonModel +{ + /// + /// Specifies the background removal extension. + /// + public JsonElement Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("name"); + } + init { this._rawData.Set("name", value); } + } + + public Options? Options + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("options"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("options", value); + } + } + + /// + public override void Validate() + { + if (!JsonElement.DeepEquals(this.Name, JsonSerializer.SerializeToElement("remove-bg"))) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + this.Options?.Validate(); + } + + public RemoveBg() + { + this.Name = JsonSerializer.SerializeToElement("remove-bg"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public RemoveBg(RemoveBg removeBg) + : base(removeBg) { } +#pragma warning restore CS8618 + + public RemoveBg(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.Name = JsonSerializer.SerializeToElement("remove-bg"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + RemoveBg(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static RemoveBg FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class RemoveBgFromRaw : IFromRawJson +{ + /// + public RemoveBg FromRawUnchecked(IReadOnlyDictionary rawData) => + RemoveBg.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Options : JsonModel +{ + /// + /// Whether to add an artificial shadow to the result. Default is false. Note: + /// Adding shadows is currently only supported for car photos. + /// + public bool? AddShadow + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("add_shadow"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("add_shadow", value); + } + } + + /// + /// Specifies a solid color background using hex code (e.g., "81d4fa", "fff") + /// or color name (e.g., "green"). If this parameter is set, `bg_image_url` must + /// be empty. + /// + public string? BgColor + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("bg_color"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("bg_color", value); + } + } + + /// + /// Sets a background image from a URL. If this parameter is set, `bg_color` must + /// be empty. + /// + public string? BgImageUrl + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("bg_image_url"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("bg_image_url", value); + } + } + + /// + /// Allows semi-transparent regions in the result. Default is true. Note: Semitransparency + /// is currently only supported for car windows. + /// + public bool? Semitransparency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("semitransparency"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("semitransparency", value); + } + } + + /// + public override void Validate() + { + _ = this.AddShadow; + _ = this.BgColor; + _ = this.BgImageUrl; + _ = this.Semitransparency; + } + + public Options() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Options(Options options) + : base(options) { } +#pragma warning restore CS8618 + + public Options(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Options(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static Options FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class OptionsFromRaw : IFromRawJson +{ + /// + public Options FromRawUnchecked(IReadOnlyDictionary rawData) => + Options.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class AutoTaggingExtension : JsonModel +{ + /// + /// Maximum number of tags to attach to the asset. + /// + public required long MaxTags + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("maxTags"); + } + init { this._rawData.Set("maxTags", value); } + } + + /// + /// Minimum confidence level for tags to be considered valid. + /// + public required long MinConfidence + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("minConfidence"); + } + init { this._rawData.Set("minConfidence", value); } + } + + /// + /// Specifies the auto-tagging extension used. + /// + public required ApiEnum Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass>("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.MaxTags; + _ = this.MinConfidence; + this.Name.Validate(); + } + + public AutoTaggingExtension() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public AutoTaggingExtension(AutoTaggingExtension autoTaggingExtension) + : base(autoTaggingExtension) { } +#pragma warning restore CS8618 + + public AutoTaggingExtension(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + AutoTaggingExtension(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static AutoTaggingExtension FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class AutoTaggingExtensionFromRaw : IFromRawJson +{ + /// + public AutoTaggingExtension FromRawUnchecked( + IReadOnlyDictionary rawData + ) => AutoTaggingExtension.FromRawUnchecked(rawData); +} + +/// +/// Specifies the auto-tagging extension used. +/// +[JsonConverter(typeof(NameConverter))] +public enum Name +{ + GoogleAutoTagging, + AwsAutoTagging, +} + +sealed class NameConverter : JsonConverter +{ + public override Name Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "google-auto-tagging" => Name.GoogleAutoTagging, + "aws-auto-tagging" => Name.AwsAutoTagging, + _ => (Name)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Name value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + Name.GoogleAutoTagging => "google-auto-tagging", + Name.AwsAutoTagging => "aws-auto-tagging", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter(typeof(AIAutoDescriptionConverter))] +public record class AIAutoDescription +{ + public JsonElement Element { get; private init; } + + public AIAutoDescription() + { + Element = JsonSerializer.Deserialize( + """ + { + "name": "ai-auto-description" + } + """ + ); + } + + internal AIAutoDescription(JsonElement element) + { + Element = element; + } + + /// + /// Validates that the instance's underlying value is the expected constant. + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public void Validate() + { + if (this != new AIAutoDescription()) + { + throw new ImageKitInvalidDataException("Invalid value given for 'AIAutoDescription'"); + } + } + + public override int GetHashCode() + { + return 0; + } + + public virtual bool Equals(AIAutoDescription? other) + { + if (other == null) + { + return false; + } + + return JsonElement.DeepEquals(this.Element, other.Element); + } +} + +class AIAutoDescriptionConverter : JsonConverter +{ + public override AIAutoDescription? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write( + Utf8JsonWriter writer, + AIAutoDescription value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Element, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class AITasks : JsonModel +{ + /// + /// Specifies the AI tasks extension for automated image analysis using AI models. + /// + public JsonElement Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + /// Array of task objects defining AI operations to perform on the asset. + /// + public required IReadOnlyList Tasks + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("tasks"); + } + init + { + this._rawData.Set>( + "tasks", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + if (!JsonElement.DeepEquals(this.Name, JsonSerializer.SerializeToElement("ai-tasks"))) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + foreach (var item in this.Tasks) + { + item.Validate(); + } + } + + public AITasks() + { + this.Name = JsonSerializer.SerializeToElement("ai-tasks"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public AITasks(AITasks aiTasks) + : base(aiTasks) { } +#pragma warning restore CS8618 + + public AITasks(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.Name = JsonSerializer.SerializeToElement("ai-tasks"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + AITasks(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static AITasks FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public AITasks(IReadOnlyList tasks) + : this() + { + this.Tasks = tasks; + } +} + +class AITasksFromRaw : IFromRawJson +{ + /// + public AITasks FromRawUnchecked(IReadOnlyDictionary rawData) => + AITasks.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(TaskConverter))] +public record class Task : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public string Instruction + { + get + { + return Match( + selectTags: (x) => x.Instruction, + selectMetadata: (x) => x.Instruction, + yesNo: (x) => x.Instruction + ); + } + } + + public JsonElement Type + { + get + { + return Match( + selectTags: (x) => x.Type, + selectMetadata: (x) => x.Type, + yesNo: (x) => x.Type + ); + } + } + + public long? MaxSelections + { + get + { + return Match( + selectTags: (x) => x.MaxSelections, + selectMetadata: (x) => x.MaxSelections, + yesNo: (_) => null + ); + } + } + + public long? MinSelections + { + get + { + return Match( + selectTags: (x) => x.MinSelections, + selectMetadata: (x) => x.MinSelections, + yesNo: (_) => null + ); + } + } + + public Task(SelectTags value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Task(SelectMetadata value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Task(YesNo value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Task(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickSelectTags(out var value)) { + /// // `value` is of type `SelectTags` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickSelectTags([NotNullWhen(true)] out SelectTags? value) + { + value = this.Value as SelectTags; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickSelectMetadata(out var value)) { + /// // `value` is of type `SelectMetadata` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickSelectMetadata([NotNullWhen(true)] out SelectMetadata? value) + { + value = this.Value as SelectMetadata; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickYesNo(out var value)) { + /// // `value` is of type `YesNo` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickYesNo([NotNullWhen(true)] out YesNo? value) + { + value = this.Value as YesNo; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (SelectTags value) => {...}, + /// (SelectMetadata value) => {...}, + /// (YesNo value) => {...} + /// ); + /// + /// + /// + public void Switch( + Action selectTags, + Action selectMetadata, + Action yesNo + ) + { + switch (this.Value) + { + case SelectTags value: + selectTags(value); + break; + case SelectMetadata value: + selectMetadata(value); + break; + case YesNo value: + yesNo(value); + break; + default: + throw new ImageKitInvalidDataException("Data did not match any variant of Task"); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (SelectTags value) => {...}, + /// (SelectMetadata value) => {...}, + /// (YesNo value) => {...} + /// ); + /// + /// + /// + public T Match( + Func selectTags, + Func selectMetadata, + Func yesNo + ) + { + return this.Value switch + { + SelectTags value => selectTags(value), + SelectMetadata value => selectMetadata(value), + YesNo value => yesNo(value), + _ => throw new ImageKitInvalidDataException("Data did not match any variant of Task"), + }; + } + + public static implicit operator Task(SelectTags value) => new(value); + + public static implicit operator Task(SelectMetadata value) => new(value); + + public static implicit operator Task(YesNo value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException("Data did not match any variant of Task"); + } + this.Switch( + (selectTags) => selectTags.Validate(), + (selectMetadata) => selectMetadata.Validate(), + (yesNo) => yesNo.Validate() + ); + } + + public virtual bool Equals(Task? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class TaskConverter : JsonConverter +{ + public override Task? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + string? type; + try + { + type = element.GetProperty("type").GetString(); + } + catch + { + type = null; + } + + switch (type) + { + case "select_tags": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + case "select_metadata": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + case "yes_no": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + default: + { + return new Task(element); + } + } + } + + public override void Write(Utf8JsonWriter writer, Task value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class SelectTags : JsonModel +{ + /// + /// The question or instruction for the AI to analyze the image. + /// + public required string Instruction + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("instruction"); + } + init { this._rawData.Set("instruction", value); } + } + + /// + /// Task type that analyzes the image and adds matching tags from a vocabulary. + /// + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// Maximum number of tags to select from the vocabulary. + /// + public long? MaxSelections + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("max_selections"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("max_selections", value); + } + } + + /// + /// Minimum number of tags to select from the vocabulary. + /// + public long? MinSelections + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("min_selections"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("min_selections", value); + } + } + + /// + /// Array of possible tag values. Combined length of all strings must not exceed + /// 500 characters. Cannot contain the `%` character. + /// + public IReadOnlyList? Vocabulary + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>("vocabulary"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "vocabulary", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.Instruction; + if (!JsonElement.DeepEquals(this.Type, JsonSerializer.SerializeToElement("select_tags"))) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + _ = this.MaxSelections; + _ = this.MinSelections; + _ = this.Vocabulary; + } + + public SelectTags() + { + this.Type = JsonSerializer.SerializeToElement("select_tags"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SelectTags(SelectTags selectTags) + : base(selectTags) { } +#pragma warning restore CS8618 + + public SelectTags(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("select_tags"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + SelectTags(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static SelectTags FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public SelectTags(string instruction) + : this() + { + this.Instruction = instruction; + } +} + +class SelectTagsFromRaw : IFromRawJson +{ + /// + public SelectTags FromRawUnchecked(IReadOnlyDictionary rawData) => + SelectTags.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class SelectMetadata : JsonModel +{ + /// + /// Name of the custom metadata field to set. The field must exist in your account. + /// + public required string Field + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("field"); + } + init { this._rawData.Set("field", value); } + } + + /// + /// The question or instruction for the AI to analyze the image. + /// + public required string Instruction + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("instruction"); + } + init { this._rawData.Set("instruction", value); } + } + + /// + /// Task type that analyzes the image and sets a custom metadata field value from + /// a vocabulary. + /// + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// Maximum number of values to select from the vocabulary. + /// + public long? MaxSelections + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("max_selections"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("max_selections", value); + } + } + + /// + /// Minimum number of values to select from the vocabulary. + /// + public long? MinSelections + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("min_selections"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("min_selections", value); + } + } + + /// + /// Array of possible values matching the custom metadata field type. + /// + public IReadOnlyList? Vocabulary + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>("vocabulary"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "vocabulary", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.Field; + _ = this.Instruction; + if ( + !JsonElement.DeepEquals(this.Type, JsonSerializer.SerializeToElement("select_metadata")) + ) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + _ = this.MaxSelections; + _ = this.MinSelections; + foreach (var item in this.Vocabulary ?? []) + { + item.Validate(); + } + } + + public SelectMetadata() + { + this.Type = JsonSerializer.SerializeToElement("select_metadata"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SelectMetadata(SelectMetadata selectMetadata) + : base(selectMetadata) { } +#pragma warning restore CS8618 + + public SelectMetadata(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("select_metadata"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + SelectMetadata(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static SelectMetadata FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class SelectMetadataFromRaw : IFromRawJson +{ + /// + public SelectMetadata FromRawUnchecked(IReadOnlyDictionary rawData) => + SelectMetadata.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(VocabularyConverter))] +public record class Vocabulary : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public Vocabulary(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Vocabulary(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Vocabulary(bool value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Vocabulary(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickBool(out var value)) { + /// // `value` is of type `bool` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = this.Value as bool?; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} + /// ); + /// + /// + /// + public void Switch(Action @string, Action @double, Action @bool) + { + switch (this.Value) + { + case string value: + @string(value); + break; + case double value: + @double(value); + break; + case bool value: + @bool(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of Vocabulary" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} + /// ); + /// + /// + /// + public T Match(Func @string, Func @double, Func @bool) + { + return this.Value switch + { + string value => @string(value), + double value => @double(value), + bool value => @bool(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of Vocabulary" + ), + }; + } + + public static implicit operator Vocabulary(string value) => new(value); + + public static implicit operator Vocabulary(double value) => new(value); + + public static implicit operator Vocabulary(bool value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException("Data did not match any variant of Vocabulary"); + } + } + + public virtual bool Equals(Vocabulary? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class VocabularyConverter : JsonConverter +{ + public override Vocabulary? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + Vocabulary value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class YesNo : JsonModel +{ + /// + /// The yes/no question for the AI to answer about the image. + /// + public required string Instruction + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("instruction"); + } + init { this._rawData.Set("instruction", value); } + } + + /// + /// Task type that asks a yes/no question and executes actions based on the answer. + /// + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// Actions to execute if the AI answers no. + /// + public OnNo? OnNo + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("on_no"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("on_no", value); + } + } + + /// + /// Actions to execute if the AI cannot determine the answer. + /// + public OnUnknown? OnUnknown + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("on_unknown"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("on_unknown", value); + } + } + + /// + /// Actions to execute if the AI answers yes. + /// + public OnYes? OnYes + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("on_yes"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("on_yes", value); + } + } + + /// + public override void Validate() + { + _ = this.Instruction; + if (!JsonElement.DeepEquals(this.Type, JsonSerializer.SerializeToElement("yes_no"))) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + this.OnNo?.Validate(); + this.OnUnknown?.Validate(); + this.OnYes?.Validate(); + } + + public YesNo() + { + this.Type = JsonSerializer.SerializeToElement("yes_no"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public YesNo(YesNo yesNo) + : base(yesNo) { } +#pragma warning restore CS8618 + + public YesNo(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("yes_no"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + YesNo(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static YesNo FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public YesNo(string instruction) + : this() + { + this.Instruction = instruction; + } +} + +class YesNoFromRaw : IFromRawJson +{ + /// + public YesNo FromRawUnchecked(IReadOnlyDictionary rawData) => + YesNo.FromRawUnchecked(rawData); +} + +/// +/// Actions to execute if the AI answers no. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class OnNo : JsonModel +{ + /// + /// Array of tag strings to add to the asset. + /// + public IReadOnlyList? AddTags + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>("add_tags"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "add_tags", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Array of tag strings to remove from the asset. + /// + public IReadOnlyList? RemoveTags + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>("remove_tags"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "remove_tags", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Array of custom metadata field updates. + /// + public IReadOnlyList? SetMetadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>("set_metadata"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "set_metadata", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Array of custom metadata fields to remove. + /// + public IReadOnlyList? UnsetMetadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>("unset_metadata"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "unset_metadata", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.AddTags; + _ = this.RemoveTags; + foreach (var item in this.SetMetadata ?? []) + { + item.Validate(); + } + foreach (var item in this.UnsetMetadata ?? []) + { + item.Validate(); + } + } + + public OnNo() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public OnNo(OnNo onNo) + : base(onNo) { } +#pragma warning restore CS8618 + + public OnNo(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + OnNo(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static OnNo FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class OnNoFromRaw : IFromRawJson +{ + /// + public OnNo FromRawUnchecked(IReadOnlyDictionary rawData) => + OnNo.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class SetMetadata : JsonModel +{ + /// + /// Name of the custom metadata field to set. + /// + public required string Field + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("field"); + } + init { this._rawData.Set("field", value); } + } + + /// + /// Value to set for the custom metadata field. The value type should match the + /// custom metadata field type. + /// + public required SetMetadataValue Value + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("value"); + } + init { this._rawData.Set("value", value); } + } + + /// + public override void Validate() + { + _ = this.Field; + this.Value.Validate(); + } + + public SetMetadata() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SetMetadata(SetMetadata setMetadata) + : base(setMetadata) { } +#pragma warning restore CS8618 + + public SetMetadata(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + SetMetadata(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static SetMetadata FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class SetMetadataFromRaw : IFromRawJson +{ + /// + public SetMetadata FromRawUnchecked(IReadOnlyDictionary rawData) => + SetMetadata.FromRawUnchecked(rawData); +} + +/// +/// Value to set for the custom metadata field. The value type should match the custom +/// metadata field type. +/// +[JsonConverter(typeof(SetMetadataValueConverter))] +public record class SetMetadataValue : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public SetMetadataValue(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public SetMetadataValue(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public SetMetadataValue(bool value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public SetMetadataValue( + IReadOnlyList value, + JsonElement? element = null + ) + { + this.Value = ImmutableArray.ToImmutableArray(value); + this._element = element; + } + + public SetMetadataValue(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickBool(out var value)) { + /// // `value` is of type `bool` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = this.Value as bool?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickMixed(out var value)) { + /// // `value` is of type `IReadOnlyList` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMixed( + [NotNullWhen(true)] out IReadOnlyList? value + ) + { + value = this.Value as IReadOnlyList; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList value) => {...} + /// ); + /// + /// + /// + public void Switch( + Action @string, + Action @double, + Action @bool, + Action> mixed + ) + { + switch (this.Value) + { + case string value: + @string(value); + break; + case double value: + @double(value); + break; + case bool value: + @bool(value); + break; + case IReadOnlyList value: + mixed(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of SetMetadataValue" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList value) => {...} + /// ); + /// + /// + /// + public T Match( + Func @string, + Func @double, + Func @bool, + Func, T> mixed + ) + { + return this.Value switch + { + string value => @string(value), + double value => @double(value), + bool value => @bool(value), + IReadOnlyList value => mixed(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of SetMetadataValue" + ), + }; + } + + public static implicit operator SetMetadataValue(string value) => new(value); + + public static implicit operator SetMetadataValue(double value) => new(value); + + public static implicit operator SetMetadataValue(bool value) => new(value); + + public static implicit operator SetMetadataValue(List value) => + new((IReadOnlyList)value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of SetMetadataValue" + ); + } + } + + public virtual bool Equals(SetMetadataValue? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class SetMetadataValueConverter : JsonConverter +{ + public override SetMetadataValue? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize>( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + SetMetadataValue value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(UnnamedSchemaWithArrayParent3Converter))] +public record class UnnamedSchemaWithArrayParent3 : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public UnnamedSchemaWithArrayParent3(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent3(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent3(bool value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent3(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickBool(out var value)) { + /// // `value` is of type `bool` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = this.Value as bool?; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} + /// ); + /// + /// + /// + public void Switch(Action @string, Action @double, Action @bool) + { + switch (this.Value) + { + case string value: + @string(value); + break; + case double value: + @double(value); + break; + case bool value: + @bool(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent3" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} + /// ); + /// + /// + /// + public T Match(Func @string, Func @double, Func @bool) + { + return this.Value switch + { + string value => @string(value), + double value => @double(value), + bool value => @bool(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent3" + ), + }; + } + + public static implicit operator UnnamedSchemaWithArrayParent3(string value) => new(value); + + public static implicit operator UnnamedSchemaWithArrayParent3(double value) => new(value); + + public static implicit operator UnnamedSchemaWithArrayParent3(bool value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent3" + ); + } + } + + public virtual bool Equals(UnnamedSchemaWithArrayParent3? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class UnnamedSchemaWithArrayParent3Converter : JsonConverter +{ + public override UnnamedSchemaWithArrayParent3? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + UnnamedSchemaWithArrayParent3 value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class UnsetMetadata : JsonModel +{ + /// + /// Name of the custom metadata field to remove. + /// + public required string Field + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("field"); + } + init { this._rawData.Set("field", value); } + } + + /// + public override void Validate() + { + _ = this.Field; + } + + public UnsetMetadata() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UnsetMetadata(UnsetMetadata unsetMetadata) + : base(unsetMetadata) { } +#pragma warning restore CS8618 + + public UnsetMetadata(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UnsetMetadata(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UnsetMetadata FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public UnsetMetadata(string field) + : this() + { + this.Field = field; + } +} + +class UnsetMetadataFromRaw : IFromRawJson +{ + /// + public UnsetMetadata FromRawUnchecked(IReadOnlyDictionary rawData) => + UnsetMetadata.FromRawUnchecked(rawData); +} + +/// +/// Actions to execute if the AI cannot determine the answer. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class OnUnknown : JsonModel +{ + /// + /// Array of tag strings to add to the asset. + /// + public IReadOnlyList? AddTags + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>("add_tags"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "add_tags", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Array of tag strings to remove from the asset. + /// + public IReadOnlyList? RemoveTags + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>("remove_tags"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "remove_tags", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Array of custom metadata field updates. + /// + public IReadOnlyList? SetMetadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>( + "set_metadata" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "set_metadata", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Array of custom metadata fields to remove. + /// + public IReadOnlyList? UnsetMetadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>( + "unset_metadata" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "unset_metadata", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.AddTags; + _ = this.RemoveTags; + foreach (var item in this.SetMetadata ?? []) + { + item.Validate(); + } + foreach (var item in this.UnsetMetadata ?? []) + { + item.Validate(); + } + } + + public OnUnknown() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public OnUnknown(OnUnknown onUnknown) + : base(onUnknown) { } +#pragma warning restore CS8618 + + public OnUnknown(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + OnUnknown(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static OnUnknown FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class OnUnknownFromRaw : IFromRawJson +{ + /// + public OnUnknown FromRawUnchecked(IReadOnlyDictionary rawData) => + OnUnknown.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class OnUnknownSetMetadata : JsonModel +{ + /// + /// Name of the custom metadata field to set. + /// + public required string Field + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("field"); + } + init { this._rawData.Set("field", value); } + } + + /// + /// Value to set for the custom metadata field. The value type should match the + /// custom metadata field type. + /// + public required OnUnknownSetMetadataValue Value + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("value"); + } + init { this._rawData.Set("value", value); } + } + + /// + public override void Validate() + { + _ = this.Field; + this.Value.Validate(); + } + + public OnUnknownSetMetadata() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public OnUnknownSetMetadata(OnUnknownSetMetadata onUnknownSetMetadata) + : base(onUnknownSetMetadata) { } +#pragma warning restore CS8618 + + public OnUnknownSetMetadata(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + OnUnknownSetMetadata(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static OnUnknownSetMetadata FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class OnUnknownSetMetadataFromRaw : IFromRawJson +{ + /// + public OnUnknownSetMetadata FromRawUnchecked( + IReadOnlyDictionary rawData + ) => OnUnknownSetMetadata.FromRawUnchecked(rawData); +} + +/// +/// Value to set for the custom metadata field. The value type should match the custom +/// metadata field type. +/// +[JsonConverter(typeof(OnUnknownSetMetadataValueConverter))] +public record class OnUnknownSetMetadataValue : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public OnUnknownSetMetadataValue(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public OnUnknownSetMetadataValue(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public OnUnknownSetMetadataValue(bool value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public OnUnknownSetMetadataValue( + IReadOnlyList value, + JsonElement? element = null + ) + { + this.Value = ImmutableArray.ToImmutableArray(value); + this._element = element; + } + + public OnUnknownSetMetadataValue(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickBool(out var value)) { + /// // `value` is of type `bool` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = this.Value as bool?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickMixed(out var value)) { + /// // `value` is of type `IReadOnlyList` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMixed( + [NotNullWhen(true)] out IReadOnlyList? value + ) + { + value = this.Value as IReadOnlyList; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList value) => {...} + /// ); + /// + /// + /// + public void Switch( + Action @string, + Action @double, + Action @bool, + Action> mixed + ) + { + switch (this.Value) + { + case string value: + @string(value); + break; + case double value: + @double(value); + break; + case bool value: + @bool(value); + break; + case IReadOnlyList value: + mixed(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of OnUnknownSetMetadataValue" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList value) => {...} + /// ); + /// + /// + /// + public T Match( + Func @string, + Func @double, + Func @bool, + Func, T> mixed + ) + { + return this.Value switch + { + string value => @string(value), + double value => @double(value), + bool value => @bool(value), + IReadOnlyList value => mixed(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of OnUnknownSetMetadataValue" + ), + }; + } + + public static implicit operator OnUnknownSetMetadataValue(string value) => new(value); + + public static implicit operator OnUnknownSetMetadataValue(double value) => new(value); + + public static implicit operator OnUnknownSetMetadataValue(bool value) => new(value); + + public static implicit operator OnUnknownSetMetadataValue( + List value + ) => new((IReadOnlyList)value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of OnUnknownSetMetadataValue" + ); + } + } + + public virtual bool Equals(OnUnknownSetMetadataValue? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class OnUnknownSetMetadataValueConverter : JsonConverter +{ + public override OnUnknownSetMetadataValue? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize>( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + OnUnknownSetMetadataValue value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(UnnamedSchemaWithArrayParent4Converter))] +public record class UnnamedSchemaWithArrayParent4 : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public UnnamedSchemaWithArrayParent4(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent4(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent4(bool value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent4(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickBool(out var value)) { + /// // `value` is of type `bool` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = this.Value as bool?; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} + /// ); + /// + /// + /// + public void Switch(Action @string, Action @double, Action @bool) + { + switch (this.Value) + { + case string value: + @string(value); + break; + case double value: + @double(value); + break; + case bool value: + @bool(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent4" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} + /// ); + /// + /// + /// + public T Match(Func @string, Func @double, Func @bool) + { + return this.Value switch + { + string value => @string(value), + double value => @double(value), + bool value => @bool(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent4" + ), + }; + } + + public static implicit operator UnnamedSchemaWithArrayParent4(string value) => new(value); + + public static implicit operator UnnamedSchemaWithArrayParent4(double value) => new(value); + + public static implicit operator UnnamedSchemaWithArrayParent4(bool value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent4" + ); + } + } + + public virtual bool Equals(UnnamedSchemaWithArrayParent4? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class UnnamedSchemaWithArrayParent4Converter : JsonConverter +{ + public override UnnamedSchemaWithArrayParent4? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + UnnamedSchemaWithArrayParent4 value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class OnUnknownUnsetMetadata : JsonModel +{ + /// + /// Name of the custom metadata field to remove. + /// + public required string Field + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("field"); + } + init { this._rawData.Set("field", value); } + } + + /// + public override void Validate() + { + _ = this.Field; + } + + public OnUnknownUnsetMetadata() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public OnUnknownUnsetMetadata(OnUnknownUnsetMetadata onUnknownUnsetMetadata) + : base(onUnknownUnsetMetadata) { } +#pragma warning restore CS8618 + + public OnUnknownUnsetMetadata(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + OnUnknownUnsetMetadata(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static OnUnknownUnsetMetadata FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public OnUnknownUnsetMetadata(string field) + : this() + { + this.Field = field; + } +} + +class OnUnknownUnsetMetadataFromRaw : IFromRawJson +{ + /// + public OnUnknownUnsetMetadata FromRawUnchecked( + IReadOnlyDictionary rawData + ) => OnUnknownUnsetMetadata.FromRawUnchecked(rawData); +} + +/// +/// Actions to execute if the AI answers yes. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class OnYes : JsonModel +{ + /// + /// Array of tag strings to add to the asset. + /// + public IReadOnlyList? AddTags + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>("add_tags"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "add_tags", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Array of tag strings to remove from the asset. + /// + public IReadOnlyList? RemoveTags + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>("remove_tags"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "remove_tags", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Array of custom metadata field updates. + /// + public IReadOnlyList? SetMetadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>( + "set_metadata" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "set_metadata", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Array of custom metadata fields to remove. + /// + public IReadOnlyList? UnsetMetadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>( + "unset_metadata" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "unset_metadata", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.AddTags; + _ = this.RemoveTags; + foreach (var item in this.SetMetadata ?? []) + { + item.Validate(); + } + foreach (var item in this.UnsetMetadata ?? []) + { + item.Validate(); + } + } + + public OnYes() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public OnYes(OnYes onYes) + : base(onYes) { } +#pragma warning restore CS8618 + + public OnYes(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + OnYes(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static OnYes FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class OnYesFromRaw : IFromRawJson +{ + /// + public OnYes FromRawUnchecked(IReadOnlyDictionary rawData) => + OnYes.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class OnYesSetMetadata : JsonModel +{ + /// + /// Name of the custom metadata field to set. + /// + public required string Field + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("field"); + } + init { this._rawData.Set("field", value); } + } + + /// + /// Value to set for the custom metadata field. The value type should match the + /// custom metadata field type. + /// + public required OnYesSetMetadataValue Value + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("value"); + } + init { this._rawData.Set("value", value); } + } + + /// + public override void Validate() + { + _ = this.Field; + this.Value.Validate(); + } + + public OnYesSetMetadata() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public OnYesSetMetadata(OnYesSetMetadata onYesSetMetadata) + : base(onYesSetMetadata) { } +#pragma warning restore CS8618 + + public OnYesSetMetadata(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + OnYesSetMetadata(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static OnYesSetMetadata FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class OnYesSetMetadataFromRaw : IFromRawJson +{ + /// + public OnYesSetMetadata FromRawUnchecked(IReadOnlyDictionary rawData) => + OnYesSetMetadata.FromRawUnchecked(rawData); +} + +/// +/// Value to set for the custom metadata field. The value type should match the custom +/// metadata field type. +/// +[JsonConverter(typeof(OnYesSetMetadataValueConverter))] +public record class OnYesSetMetadataValue : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public OnYesSetMetadataValue(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public OnYesSetMetadataValue(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public OnYesSetMetadataValue(bool value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public OnYesSetMetadataValue( + IReadOnlyList value, + JsonElement? element = null + ) + { + this.Value = ImmutableArray.ToImmutableArray(value); + this._element = element; + } + + public OnYesSetMetadataValue(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickBool(out var value)) { + /// // `value` is of type `bool` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = this.Value as bool?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickMixed(out var value)) { + /// // `value` is of type `IReadOnlyList` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMixed( + [NotNullWhen(true)] out IReadOnlyList? value + ) + { + value = this.Value as IReadOnlyList; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList value) => {...} + /// ); + /// + /// + /// + public void Switch( + Action @string, + Action @double, + Action @bool, + Action> mixed + ) + { + switch (this.Value) + { + case string value: + @string(value); + break; + case double value: + @double(value); + break; + case bool value: + @bool(value); + break; + case IReadOnlyList value: + mixed(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of OnYesSetMetadataValue" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList value) => {...} + /// ); + /// + /// + /// + public T Match( + Func @string, + Func @double, + Func @bool, + Func, T> mixed + ) + { + return this.Value switch + { + string value => @string(value), + double value => @double(value), + bool value => @bool(value), + IReadOnlyList value => mixed(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of OnYesSetMetadataValue" + ), + }; + } + + public static implicit operator OnYesSetMetadataValue(string value) => new(value); + + public static implicit operator OnYesSetMetadataValue(double value) => new(value); + + public static implicit operator OnYesSetMetadataValue(bool value) => new(value); + + public static implicit operator OnYesSetMetadataValue( + List value + ) => new((IReadOnlyList)value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of OnYesSetMetadataValue" + ); + } + } + + public virtual bool Equals(OnYesSetMetadataValue? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class OnYesSetMetadataValueConverter : JsonConverter +{ + public override OnYesSetMetadataValue? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize>( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + OnYesSetMetadataValue value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(UnnamedSchemaWithArrayParent5Converter))] +public record class UnnamedSchemaWithArrayParent5 : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public UnnamedSchemaWithArrayParent5(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent5(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent5(bool value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent5(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickBool(out var value)) { + /// // `value` is of type `bool` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = this.Value as bool?; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} + /// ); + /// + /// + /// + public void Switch(Action @string, Action @double, Action @bool) + { + switch (this.Value) + { + case string value: + @string(value); + break; + case double value: + @double(value); + break; + case bool value: + @bool(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent5" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} + /// ); + /// + /// + /// + public T Match(Func @string, Func @double, Func @bool) + { + return this.Value switch + { + string value => @string(value), + double value => @double(value), + bool value => @bool(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent5" + ), + }; + } + + public static implicit operator UnnamedSchemaWithArrayParent5(string value) => new(value); + + public static implicit operator UnnamedSchemaWithArrayParent5(double value) => new(value); + + public static implicit operator UnnamedSchemaWithArrayParent5(bool value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent5" + ); + } + } + + public virtual bool Equals(UnnamedSchemaWithArrayParent5? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class UnnamedSchemaWithArrayParent5Converter : JsonConverter +{ + public override UnnamedSchemaWithArrayParent5? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + UnnamedSchemaWithArrayParent5 value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class OnYesUnsetMetadata : JsonModel +{ + /// + /// Name of the custom metadata field to remove. + /// + public required string Field + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("field"); + } + init { this._rawData.Set("field", value); } + } + + /// + public override void Validate() + { + _ = this.Field; + } + + public OnYesUnsetMetadata() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public OnYesUnsetMetadata(OnYesUnsetMetadata onYesUnsetMetadata) + : base(onYesUnsetMetadata) { } +#pragma warning restore CS8618 + + public OnYesUnsetMetadata(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + OnYesUnsetMetadata(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static OnYesUnsetMetadata FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public OnYesUnsetMetadata(string field) + : this() + { + this.Field = field; + } +} + +class OnYesUnsetMetadataFromRaw : IFromRawJson +{ + /// + public OnYesUnsetMetadata FromRawUnchecked(IReadOnlyDictionary rawData) => + OnYesUnsetMetadata.FromRawUnchecked(rawData); +} diff --git a/src/ImageKit/Models/Files/Bulk/BulkAddTagsParams.cs b/src/ImageKit/Models/Files/Bulk/BulkAddTagsParams.cs new file mode 100644 index 00000000..df283149 --- /dev/null +++ b/src/ImageKit/Models/Files/Bulk/BulkAddTagsParams.cs @@ -0,0 +1,169 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using ImageKit.Core; +using Text = System.Text; + +namespace ImageKit.Models.Files.Bulk; + +/// +/// This API adds tags to multiple files in bulk. A maximum of 50 files can be specified +/// at a time. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class BulkAddTagsParams : ParamsBase +{ + readonly JsonDictionary _rawBodyData = new(); + public IReadOnlyDictionary RawBodyData + { + get { return this._rawBodyData.Freeze(); } + } + + /// + /// An array of fileIds to which you want to add tags. + /// + public required IReadOnlyList FileIds + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullStruct>("fileIds"); + } + init + { + this._rawBodyData.Set>( + "fileIds", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// An array of tags that you want to add to the files. + /// + public required IReadOnlyList Tags + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullStruct>("tags"); + } + init + { + this._rawBodyData.Set>( + "tags", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + public BulkAddTagsParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public BulkAddTagsParams(BulkAddTagsParams bulkAddTagsParams) + : base(bulkAddTagsParams) + { + this._rawBodyData = new(bulkAddTagsParams._rawBodyData); + } +#pragma warning restore CS8618 + + public BulkAddTagsParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + BulkAddTagsParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData, + FrozenDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } +#pragma warning restore CS8618 + + /// + public static BulkAddTagsParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData), + FrozenDictionary.ToFrozenDictionary(rawBodyData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(BulkAddTagsParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/v1/files/addTags") + { + Query = this.QueryString(options), + }.Uri; + } + + internal override HttpContent? BodyContent() + { + return new StringContent( + JsonSerializer.Serialize(this.RawBodyData, ModelBase.SerializerOptions), + Text::Encoding.UTF8, + "application/json" + ); + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/ImageKit/Models/Files/Bulk/BulkAddTagsResponse.cs b/src/ImageKit/Models/Files/Bulk/BulkAddTagsResponse.cs new file mode 100644 index 00000000..2d2b5a8d --- /dev/null +++ b/src/ImageKit/Models/Files/Bulk/BulkAddTagsResponse.cs @@ -0,0 +1,81 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; + +namespace ImageKit.Models.Files.Bulk; + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class BulkAddTagsResponse : JsonModel +{ + /// + /// An array of fileIds that in which tags were successfully added. + /// + public IReadOnlyList? SuccessfullyUpdatedFileIds + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>( + "successfullyUpdatedFileIds" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "successfullyUpdatedFileIds", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.SuccessfullyUpdatedFileIds; + } + + public BulkAddTagsResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public BulkAddTagsResponse(BulkAddTagsResponse bulkAddTagsResponse) + : base(bulkAddTagsResponse) { } +#pragma warning restore CS8618 + + public BulkAddTagsResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + BulkAddTagsResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static BulkAddTagsResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class BulkAddTagsResponseFromRaw : IFromRawJson +{ + /// + public BulkAddTagsResponse FromRawUnchecked(IReadOnlyDictionary rawData) => + BulkAddTagsResponse.FromRawUnchecked(rawData); +} diff --git a/src/ImageKit/Models/Files/Bulk/BulkDeleteParams.cs b/src/ImageKit/Models/Files/Bulk/BulkDeleteParams.cs new file mode 100644 index 00000000..9b82c5e6 --- /dev/null +++ b/src/ImageKit/Models/Files/Bulk/BulkDeleteParams.cs @@ -0,0 +1,157 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using ImageKit.Core; +using Text = System.Text; + +namespace ImageKit.Models.Files.Bulk; + +/// +/// This API deletes multiple files and all their file versions permanently. +/// +/// Note: If a file or specific transformation has been requested in the past, +/// then the response is cached. Deleting a file does not purge the cache. You can +/// purge the cache using purge cache API. +/// +/// A maximum of 100 files can be deleted at a time. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class BulkDeleteParams : ParamsBase +{ + readonly JsonDictionary _rawBodyData = new(); + public IReadOnlyDictionary RawBodyData + { + get { return this._rawBodyData.Freeze(); } + } + + /// + /// An array of fileIds which you want to delete. + /// + public required IReadOnlyList FileIds + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullStruct>("fileIds"); + } + init + { + this._rawBodyData.Set>( + "fileIds", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + public BulkDeleteParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public BulkDeleteParams(BulkDeleteParams bulkDeleteParams) + : base(bulkDeleteParams) + { + this._rawBodyData = new(bulkDeleteParams._rawBodyData); + } +#pragma warning restore CS8618 + + public BulkDeleteParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + BulkDeleteParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData, + FrozenDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } +#pragma warning restore CS8618 + + /// + public static BulkDeleteParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData), + FrozenDictionary.ToFrozenDictionary(rawBodyData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(BulkDeleteParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder( + options.BaseUrl.ToString().TrimEnd('/') + "/v1/files/batch/deleteByFileIds" + ) + { + Query = this.QueryString(options), + }.Uri; + } + + internal override HttpContent? BodyContent() + { + return new StringContent( + JsonSerializer.Serialize(this.RawBodyData, ModelBase.SerializerOptions), + Text::Encoding.UTF8, + "application/json" + ); + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/ImageKit/Models/Files/Bulk/BulkDeleteResponse.cs b/src/ImageKit/Models/Files/Bulk/BulkDeleteResponse.cs new file mode 100644 index 00000000..2c603499 --- /dev/null +++ b/src/ImageKit/Models/Files/Bulk/BulkDeleteResponse.cs @@ -0,0 +1,81 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; + +namespace ImageKit.Models.Files.Bulk; + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class BulkDeleteResponse : JsonModel +{ + /// + /// An array of fileIds that were successfully deleted. + /// + public IReadOnlyList? SuccessfullyDeletedFileIds + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>( + "successfullyDeletedFileIds" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "successfullyDeletedFileIds", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.SuccessfullyDeletedFileIds; + } + + public BulkDeleteResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public BulkDeleteResponse(BulkDeleteResponse bulkDeleteResponse) + : base(bulkDeleteResponse) { } +#pragma warning restore CS8618 + + public BulkDeleteResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + BulkDeleteResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static BulkDeleteResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class BulkDeleteResponseFromRaw : IFromRawJson +{ + /// + public BulkDeleteResponse FromRawUnchecked(IReadOnlyDictionary rawData) => + BulkDeleteResponse.FromRawUnchecked(rawData); +} diff --git a/src/ImageKit/Models/Files/Bulk/BulkRemoveAITagsParams.cs b/src/ImageKit/Models/Files/Bulk/BulkRemoveAITagsParams.cs new file mode 100644 index 00000000..479864bb --- /dev/null +++ b/src/ImageKit/Models/Files/Bulk/BulkRemoveAITagsParams.cs @@ -0,0 +1,169 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using ImageKit.Core; +using Text = System.Text; + +namespace ImageKit.Models.Files.Bulk; + +/// +/// This API removes AITags from multiple files in bulk. A maximum of 50 files can +/// be specified at a time. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class BulkRemoveAITagsParams : ParamsBase +{ + readonly JsonDictionary _rawBodyData = new(); + public IReadOnlyDictionary RawBodyData + { + get { return this._rawBodyData.Freeze(); } + } + + /// + /// An array of AITags that you want to remove from the files. + /// + public required IReadOnlyList AITags + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullStruct>("AITags"); + } + init + { + this._rawBodyData.Set>( + "AITags", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// An array of fileIds from which you want to remove AITags. + /// + public required IReadOnlyList FileIds + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullStruct>("fileIds"); + } + init + { + this._rawBodyData.Set>( + "fileIds", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + public BulkRemoveAITagsParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public BulkRemoveAITagsParams(BulkRemoveAITagsParams bulkRemoveAITagsParams) + : base(bulkRemoveAITagsParams) + { + this._rawBodyData = new(bulkRemoveAITagsParams._rawBodyData); + } +#pragma warning restore CS8618 + + public BulkRemoveAITagsParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + BulkRemoveAITagsParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData, + FrozenDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } +#pragma warning restore CS8618 + + /// + public static BulkRemoveAITagsParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData), + FrozenDictionary.ToFrozenDictionary(rawBodyData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(BulkRemoveAITagsParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/v1/files/removeAITags") + { + Query = this.QueryString(options), + }.Uri; + } + + internal override HttpContent? BodyContent() + { + return new StringContent( + JsonSerializer.Serialize(this.RawBodyData, ModelBase.SerializerOptions), + Text::Encoding.UTF8, + "application/json" + ); + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/ImageKit/Models/Files/Bulk/BulkRemoveAITagsResponse.cs b/src/ImageKit/Models/Files/Bulk/BulkRemoveAITagsResponse.cs new file mode 100644 index 00000000..eab4bb25 --- /dev/null +++ b/src/ImageKit/Models/Files/Bulk/BulkRemoveAITagsResponse.cs @@ -0,0 +1,84 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; + +namespace ImageKit.Models.Files.Bulk; + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class BulkRemoveAITagsResponse : JsonModel +{ + /// + /// An array of fileIds that in which AITags were successfully removed. + /// + public IReadOnlyList? SuccessfullyUpdatedFileIds + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>( + "successfullyUpdatedFileIds" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "successfullyUpdatedFileIds", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.SuccessfullyUpdatedFileIds; + } + + public BulkRemoveAITagsResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public BulkRemoveAITagsResponse(BulkRemoveAITagsResponse bulkRemoveAITagsResponse) + : base(bulkRemoveAITagsResponse) { } +#pragma warning restore CS8618 + + public BulkRemoveAITagsResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + BulkRemoveAITagsResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static BulkRemoveAITagsResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class BulkRemoveAITagsResponseFromRaw : IFromRawJson +{ + /// + public BulkRemoveAITagsResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) => BulkRemoveAITagsResponse.FromRawUnchecked(rawData); +} diff --git a/src/ImageKit/Models/Files/Bulk/BulkRemoveTagsParams.cs b/src/ImageKit/Models/Files/Bulk/BulkRemoveTagsParams.cs new file mode 100644 index 00000000..e01166d5 --- /dev/null +++ b/src/ImageKit/Models/Files/Bulk/BulkRemoveTagsParams.cs @@ -0,0 +1,169 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using ImageKit.Core; +using Text = System.Text; + +namespace ImageKit.Models.Files.Bulk; + +/// +/// This API removes tags from multiple files in bulk. A maximum of 50 files can be +/// specified at a time. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class BulkRemoveTagsParams : ParamsBase +{ + readonly JsonDictionary _rawBodyData = new(); + public IReadOnlyDictionary RawBodyData + { + get { return this._rawBodyData.Freeze(); } + } + + /// + /// An array of fileIds from which you want to remove tags. + /// + public required IReadOnlyList FileIds + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullStruct>("fileIds"); + } + init + { + this._rawBodyData.Set>( + "fileIds", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// An array of tags that you want to remove from the files. + /// + public required IReadOnlyList Tags + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullStruct>("tags"); + } + init + { + this._rawBodyData.Set>( + "tags", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + public BulkRemoveTagsParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public BulkRemoveTagsParams(BulkRemoveTagsParams bulkRemoveTagsParams) + : base(bulkRemoveTagsParams) + { + this._rawBodyData = new(bulkRemoveTagsParams._rawBodyData); + } +#pragma warning restore CS8618 + + public BulkRemoveTagsParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + BulkRemoveTagsParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData, + FrozenDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } +#pragma warning restore CS8618 + + /// + public static BulkRemoveTagsParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData), + FrozenDictionary.ToFrozenDictionary(rawBodyData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(BulkRemoveTagsParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/v1/files/removeTags") + { + Query = this.QueryString(options), + }.Uri; + } + + internal override HttpContent? BodyContent() + { + return new StringContent( + JsonSerializer.Serialize(this.RawBodyData, ModelBase.SerializerOptions), + Text::Encoding.UTF8, + "application/json" + ); + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/ImageKit/Models/Files/Bulk/BulkRemoveTagsResponse.cs b/src/ImageKit/Models/Files/Bulk/BulkRemoveTagsResponse.cs new file mode 100644 index 00000000..efbe5d08 --- /dev/null +++ b/src/ImageKit/Models/Files/Bulk/BulkRemoveTagsResponse.cs @@ -0,0 +1,82 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; + +namespace ImageKit.Models.Files.Bulk; + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class BulkRemoveTagsResponse : JsonModel +{ + /// + /// An array of fileIds that in which tags were successfully removed. + /// + public IReadOnlyList? SuccessfullyUpdatedFileIds + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>( + "successfullyUpdatedFileIds" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "successfullyUpdatedFileIds", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.SuccessfullyUpdatedFileIds; + } + + public BulkRemoveTagsResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public BulkRemoveTagsResponse(BulkRemoveTagsResponse bulkRemoveTagsResponse) + : base(bulkRemoveTagsResponse) { } +#pragma warning restore CS8618 + + public BulkRemoveTagsResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + BulkRemoveTagsResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static BulkRemoveTagsResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class BulkRemoveTagsResponseFromRaw : IFromRawJson +{ + /// + public BulkRemoveTagsResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) => BulkRemoveTagsResponse.FromRawUnchecked(rawData); +} diff --git a/src/ImageKit/Models/Files/File.cs b/src/ImageKit/Models/Files/File.cs new file mode 100644 index 00000000..54788711 --- /dev/null +++ b/src/ImageKit/Models/Files/File.cs @@ -0,0 +1,2533 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; +using ImageKit.Exceptions; +using System = System; + +namespace ImageKit.Models.Files; + +/// +/// Object containing details of a file or file version. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class File : JsonModel +{ + /// + /// An array of tags assigned to the file by auto tagging. + /// + public IReadOnlyList? AITags + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>("AITags"); + } + init + { + this._rawData.Set?>( + "AITags", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Date and time when the file was uploaded. The date and time is in ISO8601 + /// format. + /// + public System::DateTimeOffset? CreatedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("createdAt"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("createdAt", value); + } + } + + /// + /// An string with custom coordinates of the file. + /// + public string? CustomCoordinates + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("customCoordinates"); + } + init { this._rawData.Set("customCoordinates", value); } + } + + /// + /// An object with custom metadata for the file. + /// + public IReadOnlyDictionary? CustomMetadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>( + "customMetadata" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "customMetadata", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + + /// + /// Optional text to describe the contents of the file. Can be set by the user + /// or the ai-auto-description extension. + /// + public string? Description + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("description"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("description", value); + } + } + + /// + /// Unique identifier of the asset. + /// + public string? FileID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("fileId"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("fileId", value); + } + } + + /// + /// Path of the file. This is the path you would use in the URL to access the + /// file. For example, if the file is at the root of the media library, the path + /// will be `/file.jpg`. If the file is inside a folder named `images`, the path + /// will be `/images/file.jpg`. + /// + public string? FilePath + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("filePath"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("filePath", value); + } + } + + /// + /// Type of the file. Possible values are `image`, `non-image`. + /// + public string? FileType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("fileType"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("fileType", value); + } + } + + /// + /// Specifies if the image has an alpha channel. + /// + public bool? HasAlpha + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("hasAlpha"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("hasAlpha", value); + } + } + + /// + /// Height of the file. + /// + public double? Height + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("height"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("height", value); + } + } + + /// + /// Specifies if the file is private or not. + /// + public bool? IsPrivateFile + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("isPrivateFile"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("isPrivateFile", value); + } + } + + /// + /// Specifies if the file is published or not. + /// + public bool? IsPublished + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("isPublished"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("isPublished", value); + } + } + + /// + /// MIME type of the file. + /// + public string? Mime + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("mime"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("mime", value); + } + } + + /// + /// Name of the asset. + /// + public string? Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("name"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("name", value); + } + } + + /// + /// This field is included in the response only if the Path policy feature is + /// available in the plan. It contains schema definitions for the custom metadata + /// fields selected for the specified file path. Field selection can only be + /// done when the Path policy feature is enabled. + /// + /// Keys are the names of the custom metadata fields; the value object + /// has details about the custom metadata schema. + /// + public IReadOnlyDictionary? SelectedFieldsSchema + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass< + FrozenDictionary + >("selectedFieldsSchema"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "selectedFieldsSchema", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + + /// + /// Size of the file in bytes. + /// + public double? Size + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("size"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("size", value); + } + } + + /// + /// An array of tags assigned to the file. Tags are used to search files in the + /// media library. + /// + public IReadOnlyList? Tags + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>("tags"); + } + init + { + this._rawData.Set?>( + "tags", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// URL of the thumbnail image. This URL is used to access the thumbnail image + /// of the file in the media library. + /// + public string? Thumbnail + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("thumbnail"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("thumbnail", value); + } + } + + /// + /// Type of the asset. + /// + public ApiEnum? Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("type"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("type", value); + } + } + + /// + /// Date and time when the file was last updated. The date and time is in ISO8601 + /// format. + /// + public System::DateTimeOffset? UpdatedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("updatedAt"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("updatedAt", value); + } + } + + /// + /// URL of the file. + /// + public string? Url + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("url"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("url", value); + } + } + + /// + /// An object with details of the file version. + /// + public VersionInfo? VersionInfo + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("versionInfo"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("versionInfo", value); + } + } + + /// + /// Width of the file. + /// + public double? Width + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("width"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("width", value); + } + } + + /// + public override void Validate() + { + foreach (var item in this.AITags ?? []) + { + item.Validate(); + } + _ = this.CreatedAt; + _ = this.CustomCoordinates; + _ = this.CustomMetadata; + _ = this.Description; + _ = this.FileID; + _ = this.FilePath; + _ = this.FileType; + _ = this.HasAlpha; + _ = this.Height; + _ = this.IsPrivateFile; + _ = this.IsPublished; + _ = this.Mime; + _ = this.Name; + if (this.SelectedFieldsSchema != null) + { + foreach (var item in this.SelectedFieldsSchema.Values) + { + item.Validate(); + } + } + _ = this.Size; + _ = this.Tags; + _ = this.Thumbnail; + this.Type?.Validate(); + _ = this.UpdatedAt; + _ = this.Url; + this.VersionInfo?.Validate(); + _ = this.Width; + } + + public File() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public File(File file) + : base(file) { } +#pragma warning restore CS8618 + + public File(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + File(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static File FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class FileFromRaw : IFromRawJson +{ + /// + public File FromRawUnchecked(IReadOnlyDictionary rawData) => + File.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class AITag : JsonModel +{ + /// + /// Confidence score of the tag. + /// + public double? Confidence + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("confidence"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("confidence", value); + } + } + + /// + /// Name of the tag. + /// + public string? Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("name"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("name", value); + } + } + + /// + /// Source of the tag. Possible values are `google-auto-tagging` and `aws-auto-tagging`. + /// + public string? Source + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("source"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("source", value); + } + } + + /// + public override void Validate() + { + _ = this.Confidence; + _ = this.Name; + _ = this.Source; + } + + public AITag() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public AITag(AITag aiTag) + : base(aiTag) { } +#pragma warning restore CS8618 + + public AITag(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + AITag(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static AITag FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class AITagFromRaw : IFromRawJson +{ + /// + public AITag FromRawUnchecked(IReadOnlyDictionary rawData) => + AITag.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class SelectedFieldsSchemaItem : JsonModel +{ + /// + /// Type of the custom metadata field. + /// + public required ApiEnum Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum + >("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// The default value for this custom metadata field. The value should match + /// the `type` of custom metadata field. + /// + public DefaultValue? DefaultValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("defaultValue"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("defaultValue", value); + } + } + + /// + /// Specifies if the custom metadata field is required or not. + /// + public bool? IsValueRequired + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("isValueRequired"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("isValueRequired", value); + } + } + + /// + /// Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. + /// + public double? MaxLength + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("maxLength"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("maxLength", value); + } + } + + /// + /// Maximum value of the field. Only set if field type is `Date` or `Number`. + /// For `Date` type field, the value will be in ISO8601 string format. For `Number` + /// type field, it will be a numeric value. + /// + public MaxValue? MaxValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("maxValue"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("maxValue", value); + } + } + + /// + /// Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. + /// + public double? MinLength + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("minLength"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("minLength", value); + } + } + + /// + /// Minimum value of the field. Only set if field type is `Date` or `Number`. + /// For `Date` type field, the value will be in ISO8601 string format. For `Number` + /// type field, it will be a numeric value. + /// + public MinValue? MinValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("minValue"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("minValue", value); + } + } + + /// + /// Indicates whether the custom metadata field is read only. A read only field + /// cannot be modified after being set. This field is configurable only via the + /// **Path policy** feature. + /// + public bool? ReadOnly + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("readOnly"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("readOnly", value); + } + } + + /// + /// An array of allowed values when field type is `SingleSelect` or `MultiSelect`. + /// + public IReadOnlyList? SelectOptions + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>("selectOptions"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "selectOptions", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Specifies if the selectOptions array is truncated. It is truncated when number + /// of options are > 100. + /// + public bool? SelectOptionsTruncated + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("selectOptionsTruncated"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("selectOptionsTruncated", value); + } + } + + /// + public override void Validate() + { + this.Type.Validate(); + this.DefaultValue?.Validate(); + _ = this.IsValueRequired; + _ = this.MaxLength; + this.MaxValue?.Validate(); + _ = this.MinLength; + this.MinValue?.Validate(); + _ = this.ReadOnly; + foreach (var item in this.SelectOptions ?? []) + { + item.Validate(); + } + _ = this.SelectOptionsTruncated; + } + + public SelectedFieldsSchemaItem() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SelectedFieldsSchemaItem(SelectedFieldsSchemaItem selectedFieldsSchemaItem) + : base(selectedFieldsSchemaItem) { } +#pragma warning restore CS8618 + + public SelectedFieldsSchemaItem(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + SelectedFieldsSchemaItem(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static SelectedFieldsSchemaItem FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public SelectedFieldsSchemaItem(ApiEnum type) + : this() + { + this.Type = type; + } +} + +class SelectedFieldsSchemaItemFromRaw : IFromRawJson +{ + /// + public SelectedFieldsSchemaItem FromRawUnchecked( + IReadOnlyDictionary rawData + ) => SelectedFieldsSchemaItem.FromRawUnchecked(rawData); +} + +/// +/// Type of the custom metadata field. +/// +[JsonConverter(typeof(TypeConverter))] +public enum Type +{ + Text, + Textarea, + Number, + Date, + Boolean, + SingleSelect, + MultiSelect, +} + +sealed class TypeConverter : JsonConverter +{ + public override global::ImageKit.Models.Files.Type Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "Text" => global::ImageKit.Models.Files.Type.Text, + "Textarea" => global::ImageKit.Models.Files.Type.Textarea, + "Number" => global::ImageKit.Models.Files.Type.Number, + "Date" => global::ImageKit.Models.Files.Type.Date, + "Boolean" => global::ImageKit.Models.Files.Type.Boolean, + "SingleSelect" => global::ImageKit.Models.Files.Type.SingleSelect, + "MultiSelect" => global::ImageKit.Models.Files.Type.MultiSelect, + _ => (global::ImageKit.Models.Files.Type)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + global::ImageKit.Models.Files.Type value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + global::ImageKit.Models.Files.Type.Text => "Text", + global::ImageKit.Models.Files.Type.Textarea => "Textarea", + global::ImageKit.Models.Files.Type.Number => "Number", + global::ImageKit.Models.Files.Type.Date => "Date", + global::ImageKit.Models.Files.Type.Boolean => "Boolean", + global::ImageKit.Models.Files.Type.SingleSelect => "SingleSelect", + global::ImageKit.Models.Files.Type.MultiSelect => "MultiSelect", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// The default value for this custom metadata field. The value should match the `type` +/// of custom metadata field. +/// +[JsonConverter(typeof(DefaultValueConverter))] +public record class DefaultValue : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public DefaultValue(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public DefaultValue(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public DefaultValue(bool value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public DefaultValue( + IReadOnlyList value, + JsonElement? element = null + ) + { + this.Value = ImmutableArray.ToImmutableArray(value); + this._element = element; + } + + public DefaultValue(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickBool(out var value)) { + /// // `value` is of type `bool` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = this.Value as bool?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickMixed(out var value)) { + /// // `value` is of type `IReadOnlyList` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMixed( + [NotNullWhen(true)] out IReadOnlyList? value + ) + { + value = this.Value as IReadOnlyList; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action @string, + System::Action @double, + System::Action @bool, + System::Action> mixed + ) + { + switch (this.Value) + { + case string value: + @string(value); + break; + case double value: + @double(value); + break; + case bool value: + @bool(value); + break; + case IReadOnlyList value: + mixed(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of DefaultValue" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func @string, + System::Func @double, + System::Func @bool, + System::Func, T> mixed + ) + { + return this.Value switch + { + string value => @string(value), + double value => @double(value), + bool value => @bool(value), + IReadOnlyList value => mixed(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of DefaultValue" + ), + }; + } + + public static implicit operator DefaultValue(string value) => new(value); + + public static implicit operator DefaultValue(double value) => new(value); + + public static implicit operator DefaultValue(bool value) => new(value); + + public static implicit operator DefaultValue(List value) => + new((IReadOnlyList)value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of DefaultValue" + ); + } + } + + public virtual bool Equals(DefaultValue? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class DefaultValueConverter : JsonConverter +{ + public override DefaultValue? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize>( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + DefaultValue value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(UnnamedSchemaWithArrayParent10Converter))] +public record class UnnamedSchemaWithArrayParent10 : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public UnnamedSchemaWithArrayParent10(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent10(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent10(bool value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent10(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickBool(out var value)) { + /// // `value` is of type `bool` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = this.Value as bool?; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action @string, + System::Action @double, + System::Action @bool + ) + { + switch (this.Value) + { + case string value: + @string(value); + break; + case double value: + @double(value); + break; + case bool value: + @bool(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent10" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func @string, + System::Func @double, + System::Func @bool + ) + { + return this.Value switch + { + string value => @string(value), + double value => @double(value), + bool value => @bool(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent10" + ), + }; + } + + public static implicit operator UnnamedSchemaWithArrayParent10(string value) => new(value); + + public static implicit operator UnnamedSchemaWithArrayParent10(double value) => new(value); + + public static implicit operator UnnamedSchemaWithArrayParent10(bool value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent10" + ); + } + } + + public virtual bool Equals(UnnamedSchemaWithArrayParent10? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class UnnamedSchemaWithArrayParent10Converter : JsonConverter +{ + public override UnnamedSchemaWithArrayParent10? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + UnnamedSchemaWithArrayParent10 value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +/// +/// Maximum value of the field. Only set if field type is `Date` or `Number`. For +/// `Date` type field, the value will be in ISO8601 string format. For `Number` type +/// field, it will be a numeric value. +/// +[JsonConverter(typeof(MaxValueConverter))] +public record class MaxValue : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public MaxValue(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public MaxValue(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public MaxValue(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (string value) => {...}, + /// (double value) => {...} + /// ); + /// + /// + /// + public void Switch(System::Action @string, System::Action @double) + { + switch (this.Value) + { + case string value: + @string(value); + break; + case double value: + @double(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of MaxValue" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (string value) => {...}, + /// (double value) => {...} + /// ); + /// + /// + /// + public T Match(System::Func @string, System::Func @double) + { + return this.Value switch + { + string value => @string(value), + double value => @double(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of MaxValue" + ), + }; + } + + public static implicit operator MaxValue(string value) => new(value); + + public static implicit operator MaxValue(double value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException("Data did not match any variant of MaxValue"); + } + } + + public virtual bool Equals(MaxValue? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class MaxValueConverter : JsonConverter +{ + public override MaxValue? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write(Utf8JsonWriter writer, MaxValue value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +/// +/// Minimum value of the field. Only set if field type is `Date` or `Number`. For +/// `Date` type field, the value will be in ISO8601 string format. For `Number` type +/// field, it will be a numeric value. +/// +[JsonConverter(typeof(MinValueConverter))] +public record class MinValue : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public MinValue(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public MinValue(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public MinValue(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (string value) => {...}, + /// (double value) => {...} + /// ); + /// + /// + /// + public void Switch(System::Action @string, System::Action @double) + { + switch (this.Value) + { + case string value: + @string(value); + break; + case double value: + @double(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of MinValue" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (string value) => {...}, + /// (double value) => {...} + /// ); + /// + /// + /// + public T Match(System::Func @string, System::Func @double) + { + return this.Value switch + { + string value => @string(value), + double value => @double(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of MinValue" + ), + }; + } + + public static implicit operator MinValue(string value) => new(value); + + public static implicit operator MinValue(double value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException("Data did not match any variant of MinValue"); + } + } + + public virtual bool Equals(MinValue? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class MinValueConverter : JsonConverter +{ + public override MinValue? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write(Utf8JsonWriter writer, MinValue value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(SelectOptionConverter))] +public record class SelectOption : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public SelectOption(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public SelectOption(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public SelectOption(bool value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public SelectOption(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickBool(out var value)) { + /// // `value` is of type `bool` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = this.Value as bool?; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action @string, + System::Action @double, + System::Action @bool + ) + { + switch (this.Value) + { + case string value: + @string(value); + break; + case double value: + @double(value); + break; + case bool value: + @bool(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of SelectOption" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func @string, + System::Func @double, + System::Func @bool + ) + { + return this.Value switch + { + string value => @string(value), + double value => @double(value), + bool value => @bool(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of SelectOption" + ), + }; + } + + public static implicit operator SelectOption(string value) => new(value); + + public static implicit operator SelectOption(double value) => new(value); + + public static implicit operator SelectOption(bool value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of SelectOption" + ); + } + } + + public virtual bool Equals(SelectOption? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class SelectOptionConverter : JsonConverter +{ + public override SelectOption? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + SelectOption value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +/// +/// Type of the asset. +/// +[JsonConverter(typeof(FileTypeConverter))] +public enum FileType +{ + File, + FileVersion, +} + +sealed class FileTypeConverter : JsonConverter +{ + public override FileType Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "file" => FileType.File, + "file-version" => FileType.FileVersion, + _ => (FileType)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, FileType value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + FileType.File => "file", + FileType.FileVersion => "file-version", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// An object with details of the file version. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class VersionInfo : JsonModel +{ + /// + /// Unique identifier of the file version. + /// + public string? ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("id"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("id", value); + } + } + + /// + /// Name of the file version. + /// + public string? Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("name"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("name", value); + } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.Name; + } + + public VersionInfo() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public VersionInfo(VersionInfo versionInfo) + : base(versionInfo) { } +#pragma warning restore CS8618 + + public VersionInfo(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + VersionInfo(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static VersionInfo FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class VersionInfoFromRaw : IFromRawJson +{ + /// + public VersionInfo FromRawUnchecked(IReadOnlyDictionary rawData) => + VersionInfo.FromRawUnchecked(rawData); +} diff --git a/src/ImageKit/Models/Files/FileCopyParams.cs b/src/ImageKit/Models/Files/FileCopyParams.cs new file mode 100644 index 00000000..1bfc5af9 --- /dev/null +++ b/src/ImageKit/Models/Files/FileCopyParams.cs @@ -0,0 +1,182 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using ImageKit.Core; +using Text = System.Text; + +namespace ImageKit.Models.Files; + +/// +/// This will copy a file from one folder to another. +/// +/// Note: If any file at the destination has the same name as the source file, +/// then the source file and its versions (if `includeFileVersions` is set to true) +/// will be appended to the destination file version history. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class FileCopyParams : ParamsBase +{ + readonly JsonDictionary _rawBodyData = new(); + public IReadOnlyDictionary RawBodyData + { + get { return this._rawBodyData.Freeze(); } + } + + /// + /// Full path to the folder you want to copy the above file into. + /// + public required string DestinationPath + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullClass("destinationPath"); + } + init { this._rawBodyData.Set("destinationPath", value); } + } + + /// + /// The full path of the file you want to copy. + /// + public required string SourceFilePath + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullClass("sourceFilePath"); + } + init { this._rawBodyData.Set("sourceFilePath", value); } + } + + /// + /// Option to copy all versions of a file. By default, only the current version + /// of the file is copied. When set to true, all versions of the file will be + /// copied. Default value - `false`. + /// + public bool? IncludeFileVersions + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableStruct("includeFileVersions"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("includeFileVersions", value); + } + } + + public FileCopyParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public FileCopyParams(FileCopyParams fileCopyParams) + : base(fileCopyParams) + { + this._rawBodyData = new(fileCopyParams._rawBodyData); + } +#pragma warning restore CS8618 + + public FileCopyParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FileCopyParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData, + FrozenDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } +#pragma warning restore CS8618 + + /// + public static FileCopyParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData), + FrozenDictionary.ToFrozenDictionary(rawBodyData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(FileCopyParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/v1/files/copy") + { + Query = this.QueryString(options), + }.Uri; + } + + internal override HttpContent? BodyContent() + { + return new StringContent( + JsonSerializer.Serialize(this.RawBodyData, ModelBase.SerializerOptions), + Text::Encoding.UTF8, + "application/json" + ); + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/ImageKit/Models/Files/FileCopyResponse.cs b/src/ImageKit/Models/Files/FileCopyResponse.cs new file mode 100644 index 00000000..d9045461 --- /dev/null +++ b/src/ImageKit/Models/Files/FileCopyResponse.cs @@ -0,0 +1,51 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; + +namespace ImageKit.Models.Files; + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class FileCopyResponse : JsonModel +{ + /// + public override void Validate() { } + + public FileCopyResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public FileCopyResponse(FileCopyResponse fileCopyResponse) + : base(fileCopyResponse) { } +#pragma warning restore CS8618 + + public FileCopyResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FileCopyResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static FileCopyResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class FileCopyResponseFromRaw : IFromRawJson +{ + /// + public FileCopyResponse FromRawUnchecked(IReadOnlyDictionary rawData) => + FileCopyResponse.FromRawUnchecked(rawData); +} diff --git a/src/ImageKit/Models/Files/FileDeleteParams.cs b/src/ImageKit/Models/Files/FileDeleteParams.cs new file mode 100644 index 00000000..e404bcdb --- /dev/null +++ b/src/ImageKit/Models/Files/FileDeleteParams.cs @@ -0,0 +1,115 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using ImageKit.Core; + +namespace ImageKit.Models.Files; + +/// +/// This API deletes the file and all its file versions permanently. +/// +/// Note: If a file or specific transformation has been requested in the past, +/// then the response is cached. Deleting a file does not purge the cache. You can +/// purge the cache using purge cache API. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class FileDeleteParams : ParamsBase +{ + public string? FileID { get; init; } + + public FileDeleteParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public FileDeleteParams(FileDeleteParams fileDeleteParams) + : base(fileDeleteParams) + { + this.FileID = fileDeleteParams.FileID; + } +#pragma warning restore CS8618 + + public FileDeleteParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FileDeleteParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } +#pragma warning restore CS8618 + + /// + public static FileDeleteParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["FileID"] = this.FileID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(FileDeleteParams? other) + { + if (other == null) + { + return false; + } + return (this.FileID?.Equals(other.FileID) ?? other.FileID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder( + options.BaseUrl.ToString().TrimEnd('/') + string.Format("/v1/files/{0}", this.FileID) + ) + { + Query = this.QueryString(options), + }.Uri; + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/ImageKit/Models/Files/FileGetParams.cs b/src/ImageKit/Models/Files/FileGetParams.cs new file mode 100644 index 00000000..0b454cee --- /dev/null +++ b/src/ImageKit/Models/Files/FileGetParams.cs @@ -0,0 +1,113 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using ImageKit.Core; + +namespace ImageKit.Models.Files; + +/// +/// This API returns an object with details or attributes about the current version +/// of the file. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class FileGetParams : ParamsBase +{ + public string? FileID { get; init; } + + public FileGetParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public FileGetParams(FileGetParams fileGetParams) + : base(fileGetParams) + { + this.FileID = fileGetParams.FileID; + } +#pragma warning restore CS8618 + + public FileGetParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FileGetParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } +#pragma warning restore CS8618 + + /// + public static FileGetParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["FileID"] = this.FileID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(FileGetParams? other) + { + if (other == null) + { + return false; + } + return (this.FileID?.Equals(other.FileID) ?? other.FileID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder( + options.BaseUrl.ToString().TrimEnd('/') + + string.Format("/v1/files/{0}/details", this.FileID) + ) + { + Query = this.QueryString(options), + }.Uri; + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/ImageKit/Models/Files/FileMetadata.cs b/src/ImageKit/Models/Files/FileMetadata.cs new file mode 100644 index 00000000..9a202f7c --- /dev/null +++ b/src/ImageKit/Models/Files/FileMetadata.cs @@ -0,0 +1,1646 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; + +namespace ImageKit.Models.Files; + +/// +/// JSON object containing metadata. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class FileMetadata : JsonModel +{ + /// + /// The audio codec used in the video (only for video). + /// + public string? AudioCodec + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("audioCodec"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("audioCodec", value); + } + } + + /// + /// The bit rate of the video in kbps (only for video). + /// + public long? BitRate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("bitRate"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("bitRate", value); + } + } + + /// + /// The density of the image in DPI. + /// + public long? Density + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("density"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("density", value); + } + } + + /// + /// The duration of the video in seconds (only for video). + /// + public long? Duration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("duration"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("duration", value); + } + } + + public Exif? Exif + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("exif"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("exif", value); + } + } + + /// + /// The format of the file (e.g., 'jpg', 'mp4'). + /// + public string? Format + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("format"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("format", value); + } + } + + /// + /// Indicates if the image has a color profile. + /// + public bool? HasColorProfile + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("hasColorProfile"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("hasColorProfile", value); + } + } + + /// + /// Indicates if the image contains transparent areas. + /// + public bool? HasTransparency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("hasTransparency"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("hasTransparency", value); + } + } + + /// + /// The height of the image or video in pixels. + /// + public long? Height + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("height"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("height", value); + } + } + + /// + /// Perceptual hash of the image. + /// + public string? PHash + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("pHash"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("pHash", value); + } + } + + /// + /// The quality indicator of the image. + /// + public long? Quality + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("quality"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("quality", value); + } + } + + /// + /// The file size in bytes. + /// + public long? Size + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("size"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("size", value); + } + } + + /// + /// The video codec used in the video (only for video). + /// + public string? VideoCodec + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("videoCodec"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("videoCodec", value); + } + } + + /// + /// The width of the image or video in pixels. + /// + public long? Width + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("width"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("width", value); + } + } + + /// + public override void Validate() + { + _ = this.AudioCodec; + _ = this.BitRate; + _ = this.Density; + _ = this.Duration; + this.Exif?.Validate(); + _ = this.Format; + _ = this.HasColorProfile; + _ = this.HasTransparency; + _ = this.Height; + _ = this.PHash; + _ = this.Quality; + _ = this.Size; + _ = this.VideoCodec; + _ = this.Width; + } + + public FileMetadata() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public FileMetadata(FileMetadata fileMetadata) + : base(fileMetadata) { } +#pragma warning restore CS8618 + + public FileMetadata(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FileMetadata(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static FileMetadata FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class FileMetadataFromRaw : IFromRawJson +{ + /// + public FileMetadata FromRawUnchecked(IReadOnlyDictionary rawData) => + FileMetadata.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Exif : JsonModel +{ + /// + /// Object containing Exif details. + /// + public ExifExif? ExifValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("exif"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("exif", value); + } + } + + /// + /// Object containing GPS information. + /// + public Gps? Gps + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("gps"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("gps", value); + } + } + + /// + /// Object containing EXIF image information. + /// + public Image? Image + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("image"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("image", value); + } + } + + /// + /// JSON object. + /// + public Interoperability? Interoperability + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("interoperability"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("interoperability", value); + } + } + + public IReadOnlyDictionary? Makernote + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>( + "makernote" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "makernote", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + + /// + /// Object containing Thumbnail information. + /// + public ExifThumbnail? Thumbnail + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("thumbnail"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("thumbnail", value); + } + } + + /// + public override void Validate() + { + this.ExifValue?.Validate(); + this.Gps?.Validate(); + this.Image?.Validate(); + this.Interoperability?.Validate(); + _ = this.Makernote; + this.Thumbnail?.Validate(); + } + + public Exif() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Exif(Exif exif) + : base(exif) { } +#pragma warning restore CS8618 + + public Exif(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Exif(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static Exif FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ExifFromRaw : IFromRawJson +{ + /// + public Exif FromRawUnchecked(IReadOnlyDictionary rawData) => + Exif.FromRawUnchecked(rawData); +} + +/// +/// Object containing Exif details. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class ExifExif : JsonModel +{ + public double? ApertureValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("ApertureValue"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("ApertureValue", value); + } + } + + public long? ColorSpace + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("ColorSpace"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("ColorSpace", value); + } + } + + public string? CreateDate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("CreateDate"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("CreateDate", value); + } + } + + public long? CustomRendered + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("CustomRendered"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("CustomRendered", value); + } + } + + public string? DateTimeOriginal + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("DateTimeOriginal"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("DateTimeOriginal", value); + } + } + + public long? ExifImageHeight + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("ExifImageHeight"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("ExifImageHeight", value); + } + } + + public long? ExifImageWidth + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("ExifImageWidth"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("ExifImageWidth", value); + } + } + + public string? ExifVersion + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("ExifVersion"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("ExifVersion", value); + } + } + + public double? ExposureCompensation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("ExposureCompensation"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("ExposureCompensation", value); + } + } + + public long? ExposureMode + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("ExposureMode"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("ExposureMode", value); + } + } + + public long? ExposureProgram + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("ExposureProgram"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("ExposureProgram", value); + } + } + + public double? ExposureTime + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("ExposureTime"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("ExposureTime", value); + } + } + + public long? Flash + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("Flash"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("Flash", value); + } + } + + public string? FlashpixVersion + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("FlashpixVersion"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("FlashpixVersion", value); + } + } + + public double? FNumber + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("FNumber"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("FNumber", value); + } + } + + public long? FocalLength + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("FocalLength"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("FocalLength", value); + } + } + + public long? FocalPlaneResolutionUnit + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("FocalPlaneResolutionUnit"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("FocalPlaneResolutionUnit", value); + } + } + + public double? FocalPlaneXResolution + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("FocalPlaneXResolution"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("FocalPlaneXResolution", value); + } + } + + public double? FocalPlaneYResolution + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("FocalPlaneYResolution"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("FocalPlaneYResolution", value); + } + } + + public long? InteropOffset + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("InteropOffset"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("InteropOffset", value); + } + } + + public long? Iso + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("ISO"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("ISO", value); + } + } + + public long? MeteringMode + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("MeteringMode"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("MeteringMode", value); + } + } + + public long? SceneCaptureType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("SceneCaptureType"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("SceneCaptureType", value); + } + } + + public double? ShutterSpeedValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("ShutterSpeedValue"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("ShutterSpeedValue", value); + } + } + + public string? SubSecTime + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("SubSecTime"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("SubSecTime", value); + } + } + + public long? WhiteBalance + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("WhiteBalance"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("WhiteBalance", value); + } + } + + /// + public override void Validate() + { + _ = this.ApertureValue; + _ = this.ColorSpace; + _ = this.CreateDate; + _ = this.CustomRendered; + _ = this.DateTimeOriginal; + _ = this.ExifImageHeight; + _ = this.ExifImageWidth; + _ = this.ExifVersion; + _ = this.ExposureCompensation; + _ = this.ExposureMode; + _ = this.ExposureProgram; + _ = this.ExposureTime; + _ = this.Flash; + _ = this.FlashpixVersion; + _ = this.FNumber; + _ = this.FocalLength; + _ = this.FocalPlaneResolutionUnit; + _ = this.FocalPlaneXResolution; + _ = this.FocalPlaneYResolution; + _ = this.InteropOffset; + _ = this.Iso; + _ = this.MeteringMode; + _ = this.SceneCaptureType; + _ = this.ShutterSpeedValue; + _ = this.SubSecTime; + _ = this.WhiteBalance; + } + + public ExifExif() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ExifExif(ExifExif exifExif) + : base(exifExif) { } +#pragma warning restore CS8618 + + public ExifExif(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ExifExif(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ExifExif FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ExifExifFromRaw : IFromRawJson +{ + /// + public ExifExif FromRawUnchecked(IReadOnlyDictionary rawData) => + ExifExif.FromRawUnchecked(rawData); +} + +/// +/// Object containing GPS information. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Gps : JsonModel +{ + public IReadOnlyList? GpsVersionID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>("GPSVersionID"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "GPSVersionID", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.GpsVersionID; + } + + public Gps() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Gps(Gps gps) + : base(gps) { } +#pragma warning restore CS8618 + + public Gps(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Gps(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static Gps FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GpsFromRaw : IFromRawJson +{ + /// + public Gps FromRawUnchecked(IReadOnlyDictionary rawData) => + Gps.FromRawUnchecked(rawData); +} + +/// +/// Object containing EXIF image information. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Image : JsonModel +{ + public long? ExifOffset + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("ExifOffset"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("ExifOffset", value); + } + } + + public long? GpsInfo + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("GPSInfo"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("GPSInfo", value); + } + } + + public string? Make + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("Make"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("Make", value); + } + } + + public string? Model + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("Model"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("Model", value); + } + } + + public string? ModifyDate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("ModifyDate"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("ModifyDate", value); + } + } + + public long? Orientation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("Orientation"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("Orientation", value); + } + } + + public long? ResolutionUnit + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("ResolutionUnit"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("ResolutionUnit", value); + } + } + + public string? Software + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("Software"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("Software", value); + } + } + + public long? XResolution + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("XResolution"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("XResolution", value); + } + } + + public long? YCbCrPositioning + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("YCbCrPositioning"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("YCbCrPositioning", value); + } + } + + public long? YResolution + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("YResolution"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("YResolution", value); + } + } + + /// + public override void Validate() + { + _ = this.ExifOffset; + _ = this.GpsInfo; + _ = this.Make; + _ = this.Model; + _ = this.ModifyDate; + _ = this.Orientation; + _ = this.ResolutionUnit; + _ = this.Software; + _ = this.XResolution; + _ = this.YCbCrPositioning; + _ = this.YResolution; + } + + public Image() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Image(Image image) + : base(image) { } +#pragma warning restore CS8618 + + public Image(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Image(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static Image FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ImageFromRaw : IFromRawJson +{ + /// + public Image FromRawUnchecked(IReadOnlyDictionary rawData) => + Image.FromRawUnchecked(rawData); +} + +/// +/// JSON object. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Interoperability : JsonModel +{ + public string? InteropIndex + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("InteropIndex"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("InteropIndex", value); + } + } + + public string? InteropVersion + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("InteropVersion"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("InteropVersion", value); + } + } + + /// + public override void Validate() + { + _ = this.InteropIndex; + _ = this.InteropVersion; + } + + public Interoperability() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Interoperability(Interoperability interoperability) + : base(interoperability) { } +#pragma warning restore CS8618 + + public Interoperability(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Interoperability(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static Interoperability FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class InteroperabilityFromRaw : IFromRawJson +{ + /// + public Interoperability FromRawUnchecked(IReadOnlyDictionary rawData) => + Interoperability.FromRawUnchecked(rawData); +} + +/// +/// Object containing Thumbnail information. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class ExifThumbnail : JsonModel +{ + public long? Compression + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("Compression"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("Compression", value); + } + } + + public long? ResolutionUnit + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("ResolutionUnit"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("ResolutionUnit", value); + } + } + + public long? ThumbnailLength + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("ThumbnailLength"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("ThumbnailLength", value); + } + } + + public long? ThumbnailOffset + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("ThumbnailOffset"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("ThumbnailOffset", value); + } + } + + public long? XResolution + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("XResolution"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("XResolution", value); + } + } + + public long? YResolution + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("YResolution"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("YResolution", value); + } + } + + /// + public override void Validate() + { + _ = this.Compression; + _ = this.ResolutionUnit; + _ = this.ThumbnailLength; + _ = this.ThumbnailOffset; + _ = this.XResolution; + _ = this.YResolution; + } + + public ExifThumbnail() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ExifThumbnail(ExifThumbnail exifThumbnail) + : base(exifThumbnail) { } +#pragma warning restore CS8618 + + public ExifThumbnail(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ExifThumbnail(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ExifThumbnail FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ExifThumbnailFromRaw : IFromRawJson +{ + /// + public ExifThumbnail FromRawUnchecked(IReadOnlyDictionary rawData) => + ExifThumbnail.FromRawUnchecked(rawData); +} diff --git a/src/ImageKit/Models/Files/FileMoveParams.cs b/src/ImageKit/Models/Files/FileMoveParams.cs new file mode 100644 index 00000000..3a44a747 --- /dev/null +++ b/src/ImageKit/Models/Files/FileMoveParams.cs @@ -0,0 +1,158 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using ImageKit.Core; +using Text = System.Text; + +namespace ImageKit.Models.Files; + +/// +/// This will move a file and all its versions from one folder to another. +/// +/// Note: If any file at the destination has the same name as the source file, +/// then the source file and its versions will be appended to the destination file. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class FileMoveParams : ParamsBase +{ + readonly JsonDictionary _rawBodyData = new(); + public IReadOnlyDictionary RawBodyData + { + get { return this._rawBodyData.Freeze(); } + } + + /// + /// Full path to the folder you want to move the above file into. + /// + public required string DestinationPath + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullClass("destinationPath"); + } + init { this._rawBodyData.Set("destinationPath", value); } + } + + /// + /// The full path of the file you want to move. + /// + public required string SourceFilePath + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullClass("sourceFilePath"); + } + init { this._rawBodyData.Set("sourceFilePath", value); } + } + + public FileMoveParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public FileMoveParams(FileMoveParams fileMoveParams) + : base(fileMoveParams) + { + this._rawBodyData = new(fileMoveParams._rawBodyData); + } +#pragma warning restore CS8618 + + public FileMoveParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FileMoveParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData, + FrozenDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } +#pragma warning restore CS8618 + + /// + public static FileMoveParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData), + FrozenDictionary.ToFrozenDictionary(rawBodyData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(FileMoveParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/v1/files/move") + { + Query = this.QueryString(options), + }.Uri; + } + + internal override HttpContent? BodyContent() + { + return new StringContent( + JsonSerializer.Serialize(this.RawBodyData, ModelBase.SerializerOptions), + Text::Encoding.UTF8, + "application/json" + ); + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/ImageKit/Models/Files/FileMoveResponse.cs b/src/ImageKit/Models/Files/FileMoveResponse.cs new file mode 100644 index 00000000..e97c3318 --- /dev/null +++ b/src/ImageKit/Models/Files/FileMoveResponse.cs @@ -0,0 +1,51 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; + +namespace ImageKit.Models.Files; + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class FileMoveResponse : JsonModel +{ + /// + public override void Validate() { } + + public FileMoveResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public FileMoveResponse(FileMoveResponse fileMoveResponse) + : base(fileMoveResponse) { } +#pragma warning restore CS8618 + + public FileMoveResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FileMoveResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static FileMoveResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class FileMoveResponseFromRaw : IFromRawJson +{ + /// + public FileMoveResponse FromRawUnchecked(IReadOnlyDictionary rawData) => + FileMoveResponse.FromRawUnchecked(rawData); +} diff --git a/src/ImageKit/Models/Files/FileRenameParams.cs b/src/ImageKit/Models/Files/FileRenameParams.cs new file mode 100644 index 00000000..ed99e9a6 --- /dev/null +++ b/src/ImageKit/Models/Files/FileRenameParams.cs @@ -0,0 +1,199 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using ImageKit.Core; +using Text = System.Text; + +namespace ImageKit.Models.Files; + +/// +/// You can rename an already existing file in the media library using rename file +/// API. This operation would rename all file versions of the file. +/// +/// Note: The old URLs will stop working. The file/file version URLs cached +/// on CDN will continue to work unless a purge is requested. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class FileRenameParams : ParamsBase +{ + readonly JsonDictionary _rawBodyData = new(); + public IReadOnlyDictionary RawBodyData + { + get { return this._rawBodyData.Freeze(); } + } + + /// + /// The full path of the file you want to rename. + /// + public required string FilePath + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullClass("filePath"); + } + init { this._rawBodyData.Set("filePath", value); } + } + + /// + /// The new name of the file. A filename can contain: + /// + /// Alphanumeric Characters: `a-z`, `A-Z`, `0-9` (including Unicode letters, + /// marks, and numerals in other languages). Special Characters: `.`, `_`, and `-`. + /// + /// Any other character, including space, will be replaced by `_`. + /// + public required string NewFileName + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullClass("newFileName"); + } + init { this._rawBodyData.Set("newFileName", value); } + } + + /// + /// Option to purge cache for the old file and its versions' URLs. + /// + /// When set to true, it will internally issue a purge cache request on + /// CDN to remove cached content of old file and its versions. This purge request + /// is counted against your monthly purge quota. + /// + /// Note: If the old file were accessible at `https://ik.imagekit.io/demo/old-filename.jpg`, + /// a purge cache request would be issued against `https://ik.imagekit.io/demo/old-filename.jpg*` + /// (with a wildcard at the end). It will remove the file and its versions' URLs + /// and any transformations made using query parameters on this file or its versions. + /// However, the cache for file transformations made using path parameters will + /// persist. You can purge them using the purge API. For more details, refer + /// to the purge API documentation. + /// + /// Default value - `false` + /// + public bool? PurgeCache + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableStruct("purgeCache"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("purgeCache", value); + } + } + + public FileRenameParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public FileRenameParams(FileRenameParams fileRenameParams) + : base(fileRenameParams) + { + this._rawBodyData = new(fileRenameParams._rawBodyData); + } +#pragma warning restore CS8618 + + public FileRenameParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FileRenameParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData, + FrozenDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } +#pragma warning restore CS8618 + + /// + public static FileRenameParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData), + FrozenDictionary.ToFrozenDictionary(rawBodyData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(FileRenameParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/v1/files/rename") + { + Query = this.QueryString(options), + }.Uri; + } + + internal override HttpContent? BodyContent() + { + return new StringContent( + JsonSerializer.Serialize(this.RawBodyData, ModelBase.SerializerOptions), + Text::Encoding.UTF8, + "application/json" + ); + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/ImageKit/Models/Files/FileRenameResponse.cs b/src/ImageKit/Models/Files/FileRenameResponse.cs new file mode 100644 index 00000000..f1e0e367 --- /dev/null +++ b/src/ImageKit/Models/Files/FileRenameResponse.cs @@ -0,0 +1,76 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; + +namespace ImageKit.Models.Files; + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class FileRenameResponse : JsonModel +{ + /// + /// Unique identifier of the purge request. This can be used to check the status + /// of the purge request. + /// + public string? PurgeRequestID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("purgeRequestId"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("purgeRequestId", value); + } + } + + /// + public override void Validate() + { + _ = this.PurgeRequestID; + } + + public FileRenameResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public FileRenameResponse(FileRenameResponse fileRenameResponse) + : base(fileRenameResponse) { } +#pragma warning restore CS8618 + + public FileRenameResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FileRenameResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static FileRenameResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class FileRenameResponseFromRaw : IFromRawJson +{ + /// + public FileRenameResponse FromRawUnchecked(IReadOnlyDictionary rawData) => + FileRenameResponse.FromRawUnchecked(rawData); +} diff --git a/src/ImageKit/Models/Files/FileUpdateParams.cs b/src/ImageKit/Models/Files/FileUpdateParams.cs new file mode 100644 index 00000000..88720d36 --- /dev/null +++ b/src/ImageKit/Models/Files/FileUpdateParams.cs @@ -0,0 +1,153 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using ImageKit.Core; +using Text = System.Text; + +namespace ImageKit.Models.Files; + +/// +/// This API updates the details or attributes of the current version of the file. +/// You can update `tags`, `customCoordinates`, `customMetadata`, publication status, +/// remove existing `AITags` and apply extensions using this API. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class FileUpdateParams : ParamsBase +{ + readonly JsonDictionary _rawBodyData = new(); + public IReadOnlyDictionary RawBodyData + { + get { return this._rawBodyData.Freeze(); } + } + + public string? FileID { get; init; } + + /// + /// Schema for update file update request. + /// + public required UpdateFileRequest UpdateFileRequest + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullClass("UpdateFileRequest"); + } + init { this._rawBodyData.Set("UpdateFileRequest", value); } + } + + public FileUpdateParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public FileUpdateParams(FileUpdateParams fileUpdateParams) + : base(fileUpdateParams) + { + this.FileID = fileUpdateParams.FileID; + + this._rawBodyData = new(fileUpdateParams._rawBodyData); + } +#pragma warning restore CS8618 + + public FileUpdateParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FileUpdateParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData, + FrozenDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } +#pragma warning restore CS8618 + + /// + public static FileUpdateParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData), + FrozenDictionary.ToFrozenDictionary(rawBodyData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["FileID"] = this.FileID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(FileUpdateParams? other) + { + if (other == null) + { + return false; + } + return (this.FileID?.Equals(other.FileID) ?? other.FileID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder( + options.BaseUrl.ToString().TrimEnd('/') + + string.Format("/v1/files/{0}/details", this.FileID) + ) + { + Query = this.QueryString(options), + }.Uri; + } + + internal override HttpContent? BodyContent() + { + return new StringContent( + JsonSerializer.Serialize(this.RawBodyData, ModelBase.SerializerOptions), + Text::Encoding.UTF8, + "application/json" + ); + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/ImageKit/Models/Files/FileUpdateResponse.cs b/src/ImageKit/Models/Files/FileUpdateResponse.cs new file mode 100644 index 00000000..de7b30ad --- /dev/null +++ b/src/ImageKit/Models/Files/FileUpdateResponse.cs @@ -0,0 +1,1068 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; +using ImageKit.Exceptions; +using System = System; + +namespace ImageKit.Models.Files; + +/// +/// Object containing details of a file or file version. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class FileUpdateResponse : JsonModel +{ + /// + /// An array of tags assigned to the file by auto tagging. + /// + public IReadOnlyList? AITags + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>("AITags"); + } + init + { + this._rawData.Set?>( + "AITags", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Date and time when the file was uploaded. The date and time is in ISO8601 + /// format. + /// + public System::DateTimeOffset? CreatedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("createdAt"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("createdAt", value); + } + } + + /// + /// An string with custom coordinates of the file. + /// + public string? CustomCoordinates + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("customCoordinates"); + } + init { this._rawData.Set("customCoordinates", value); } + } + + /// + /// An object with custom metadata for the file. + /// + public IReadOnlyDictionary? CustomMetadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>( + "customMetadata" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "customMetadata", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + + /// + /// Optional text to describe the contents of the file. Can be set by the user + /// or the ai-auto-description extension. + /// + public string? Description + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("description"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("description", value); + } + } + + /// + /// Unique identifier of the asset. + /// + public string? FileID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("fileId"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("fileId", value); + } + } + + /// + /// Path of the file. This is the path you would use in the URL to access the + /// file. For example, if the file is at the root of the media library, the path + /// will be `/file.jpg`. If the file is inside a folder named `images`, the path + /// will be `/images/file.jpg`. + /// + public string? FilePath + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("filePath"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("filePath", value); + } + } + + /// + /// Type of the file. Possible values are `image`, `non-image`. + /// + public string? FileType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("fileType"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("fileType", value); + } + } + + /// + /// Specifies if the image has an alpha channel. + /// + public bool? HasAlpha + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("hasAlpha"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("hasAlpha", value); + } + } + + /// + /// Height of the file. + /// + public double? Height + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("height"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("height", value); + } + } + + /// + /// Specifies if the file is private or not. + /// + public bool? IsPrivateFile + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("isPrivateFile"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("isPrivateFile", value); + } + } + + /// + /// Specifies if the file is published or not. + /// + public bool? IsPublished + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("isPublished"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("isPublished", value); + } + } + + /// + /// MIME type of the file. + /// + public string? Mime + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("mime"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("mime", value); + } + } + + /// + /// Name of the asset. + /// + public string? Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("name"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("name", value); + } + } + + /// + /// This field is included in the response only if the Path policy feature is + /// available in the plan. It contains schema definitions for the custom metadata + /// fields selected for the specified file path. Field selection can only be + /// done when the Path policy feature is enabled. + /// + /// Keys are the names of the custom metadata fields; the value object + /// has details about the custom metadata schema. + /// + public IReadOnlyDictionary? SelectedFieldsSchema + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass< + FrozenDictionary + >("selectedFieldsSchema"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "selectedFieldsSchema", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + + /// + /// Size of the file in bytes. + /// + public double? Size + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("size"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("size", value); + } + } + + /// + /// An array of tags assigned to the file. Tags are used to search files in the + /// media library. + /// + public IReadOnlyList? Tags + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>("tags"); + } + init + { + this._rawData.Set?>( + "tags", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// URL of the thumbnail image. This URL is used to access the thumbnail image + /// of the file in the media library. + /// + public string? Thumbnail + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("thumbnail"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("thumbnail", value); + } + } + + /// + /// Type of the asset. + /// + public ApiEnum? Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("type"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("type", value); + } + } + + /// + /// Date and time when the file was last updated. The date and time is in ISO8601 + /// format. + /// + public System::DateTimeOffset? UpdatedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("updatedAt"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("updatedAt", value); + } + } + + /// + /// URL of the file. + /// + public string? Url + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("url"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("url", value); + } + } + + /// + /// An object with details of the file version. + /// + public VersionInfo? VersionInfo + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("versionInfo"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("versionInfo", value); + } + } + + /// + /// Width of the file. + /// + public double? Width + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("width"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("width", value); + } + } + + public ExtensionStatus? ExtensionStatus + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("extensionStatus"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("extensionStatus", value); + } + } + + public static implicit operator File(FileUpdateResponse fileUpdateResponse) => + new() + { + AITags = fileUpdateResponse.AITags, + CreatedAt = fileUpdateResponse.CreatedAt, + CustomCoordinates = fileUpdateResponse.CustomCoordinates, + CustomMetadata = fileUpdateResponse.CustomMetadata, + Description = fileUpdateResponse.Description, + FileID = fileUpdateResponse.FileID, + FilePath = fileUpdateResponse.FilePath, + FileType = fileUpdateResponse.FileType, + HasAlpha = fileUpdateResponse.HasAlpha, + Height = fileUpdateResponse.Height, + IsPrivateFile = fileUpdateResponse.IsPrivateFile, + IsPublished = fileUpdateResponse.IsPublished, + Mime = fileUpdateResponse.Mime, + Name = fileUpdateResponse.Name, + SelectedFieldsSchema = fileUpdateResponse.SelectedFieldsSchema, + Size = fileUpdateResponse.Size, + Tags = fileUpdateResponse.Tags, + Thumbnail = fileUpdateResponse.Thumbnail, + Type = fileUpdateResponse.Type, + UpdatedAt = fileUpdateResponse.UpdatedAt, + Url = fileUpdateResponse.Url, + VersionInfo = fileUpdateResponse.VersionInfo, + Width = fileUpdateResponse.Width, + }; + + /// + public override void Validate() + { + foreach (var item in this.AITags ?? []) + { + item.Validate(); + } + _ = this.CreatedAt; + _ = this.CustomCoordinates; + _ = this.CustomMetadata; + _ = this.Description; + _ = this.FileID; + _ = this.FilePath; + _ = this.FileType; + _ = this.HasAlpha; + _ = this.Height; + _ = this.IsPrivateFile; + _ = this.IsPublished; + _ = this.Mime; + _ = this.Name; + if (this.SelectedFieldsSchema != null) + { + foreach (var item in this.SelectedFieldsSchema.Values) + { + item.Validate(); + } + } + _ = this.Size; + _ = this.Tags; + _ = this.Thumbnail; + this.Type?.Validate(); + _ = this.UpdatedAt; + _ = this.Url; + this.VersionInfo?.Validate(); + _ = this.Width; + this.ExtensionStatus?.Validate(); + } + + public FileUpdateResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public FileUpdateResponse(FileUpdateResponse fileUpdateResponse) + : base(fileUpdateResponse) { } +#pragma warning restore CS8618 + + public FileUpdateResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FileUpdateResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static FileUpdateResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class FileUpdateResponseFromRaw : IFromRawJson +{ + /// + public FileUpdateResponse FromRawUnchecked(IReadOnlyDictionary rawData) => + FileUpdateResponse.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class IntersectionMember1 : JsonModel +{ + public ExtensionStatus? ExtensionStatus + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("extensionStatus"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("extensionStatus", value); + } + } + + /// + public override void Validate() + { + this.ExtensionStatus?.Validate(); + } + + public IntersectionMember1() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public IntersectionMember1(IntersectionMember1 intersectionMember1) + : base(intersectionMember1) { } +#pragma warning restore CS8618 + + public IntersectionMember1(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + IntersectionMember1(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static IntersectionMember1 FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class IntersectionMember1FromRaw : IFromRawJson +{ + /// + public IntersectionMember1 FromRawUnchecked(IReadOnlyDictionary rawData) => + IntersectionMember1.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class ExtensionStatus : JsonModel +{ + public ApiEnum? AIAutoDescription + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>( + "ai-auto-description" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("ai-auto-description", value); + } + } + + public ApiEnum? AITasks + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("ai-tasks"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("ai-tasks", value); + } + } + + public ApiEnum? AwsAutoTagging + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>( + "aws-auto-tagging" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("aws-auto-tagging", value); + } + } + + public ApiEnum? GoogleAutoTagging + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>( + "google-auto-tagging" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("google-auto-tagging", value); + } + } + + public ApiEnum? RemoveBg + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("remove-bg"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("remove-bg", value); + } + } + + /// + public override void Validate() + { + this.AIAutoDescription?.Validate(); + this.AITasks?.Validate(); + this.AwsAutoTagging?.Validate(); + this.GoogleAutoTagging?.Validate(); + this.RemoveBg?.Validate(); + } + + public ExtensionStatus() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ExtensionStatus(ExtensionStatus extensionStatus) + : base(extensionStatus) { } +#pragma warning restore CS8618 + + public ExtensionStatus(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ExtensionStatus(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ExtensionStatus FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ExtensionStatusFromRaw : IFromRawJson +{ + /// + public ExtensionStatus FromRawUnchecked(IReadOnlyDictionary rawData) => + ExtensionStatus.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(AIAutoDescriptionConverter))] +public enum AIAutoDescription +{ + Success, + Pending, + Failed, +} + +sealed class AIAutoDescriptionConverter : JsonConverter +{ + public override AIAutoDescription Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "success" => AIAutoDescription.Success, + "pending" => AIAutoDescription.Pending, + "failed" => AIAutoDescription.Failed, + _ => (AIAutoDescription)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + AIAutoDescription value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + AIAutoDescription.Success => "success", + AIAutoDescription.Pending => "pending", + AIAutoDescription.Failed => "failed", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter(typeof(AITasksConverter))] +public enum AITasks +{ + Success, + Pending, + Failed, +} + +sealed class AITasksConverter : JsonConverter +{ + public override AITasks Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "success" => AITasks.Success, + "pending" => AITasks.Pending, + "failed" => AITasks.Failed, + _ => (AITasks)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, AITasks value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + AITasks.Success => "success", + AITasks.Pending => "pending", + AITasks.Failed => "failed", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter(typeof(AwsAutoTaggingConverter))] +public enum AwsAutoTagging +{ + Success, + Pending, + Failed, +} + +sealed class AwsAutoTaggingConverter : JsonConverter +{ + public override AwsAutoTagging Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "success" => AwsAutoTagging.Success, + "pending" => AwsAutoTagging.Pending, + "failed" => AwsAutoTagging.Failed, + _ => (AwsAutoTagging)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + AwsAutoTagging value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + AwsAutoTagging.Success => "success", + AwsAutoTagging.Pending => "pending", + AwsAutoTagging.Failed => "failed", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter(typeof(GoogleAutoTaggingConverter))] +public enum GoogleAutoTagging +{ + Success, + Pending, + Failed, +} + +sealed class GoogleAutoTaggingConverter : JsonConverter +{ + public override GoogleAutoTagging Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "success" => GoogleAutoTagging.Success, + "pending" => GoogleAutoTagging.Pending, + "failed" => GoogleAutoTagging.Failed, + _ => (GoogleAutoTagging)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + GoogleAutoTagging value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + GoogleAutoTagging.Success => "success", + GoogleAutoTagging.Pending => "pending", + GoogleAutoTagging.Failed => "failed", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter(typeof(RemoveBgConverter))] +public enum RemoveBg +{ + Success, + Pending, + Failed, +} + +sealed class RemoveBgConverter : JsonConverter +{ + public override RemoveBg Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "success" => RemoveBg.Success, + "pending" => RemoveBg.Pending, + "failed" => RemoveBg.Failed, + _ => (RemoveBg)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, RemoveBg value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + RemoveBg.Success => "success", + RemoveBg.Pending => "pending", + RemoveBg.Failed => "failed", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} diff --git a/src/ImageKit/Models/Files/FileUploadParams.cs b/src/ImageKit/Models/Files/FileUploadParams.cs new file mode 100644 index 00000000..844ad915 --- /dev/null +++ b/src/ImageKit/Models/Files/FileUploadParams.cs @@ -0,0 +1,1667 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; +using ImageKit.Exceptions; +using System = System; + +namespace ImageKit.Models.Files; + +/// +/// ImageKit.io allows you to upload files directly from both the server and client +/// sides. For server-side uploads, private API key authentication is used. For client-side +/// uploads, generate a one-time `token`, `signature`, and `expire` from your secure +/// backend using private API. [Learn more](/docs/api-reference/upload-file/upload-file#how-to-implement-client-side-file-upload) +/// about how to implement client-side file upload. +/// +/// The [V2 API](/docs/api-reference/upload-file/upload-file-v2) enhances security +/// by verifying the entire payload using JWT. +/// +/// **File size limit** \ On the free plan, the maximum upload file sizes are +/// 20MB for images, audio, and raw files and 100MB for videos. On the paid plan, +/// these limits increase to 40MB for images, audio, and raw files and 2GB for videos. +/// These limits can be further increased with higher-tier plans. +/// +/// **Version limit** \ A file can have a maximum of 100 versions. +/// +/// **Demo applications** +/// +/// - A full-fledged [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), +/// supporting file selections from local storage, URL, Dropbox, Google Drive, Instagram, +/// and more. - [Quick start guides](/docs/quick-start-guides) for various frameworks +/// and technologies. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class FileUploadParams : ParamsBase +{ + readonly MultipartJsonDictionary _rawBodyData = new(); + public IReadOnlyDictionary RawBodyData + { + get { return this._rawBodyData.Freeze(); } + } + + /// + /// The API accepts any of the following: + /// + /// - **Binary data** – send the raw bytes as `multipart/form-data`. - **HTTP + /// / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + /// - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + /// + /// When supplying a URL, the server must receive the response headers within + /// 8 seconds; otherwise the request fails with 400 Bad Request. + /// + public required BinaryContent File + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullClass("file"); + } + init { this._rawBodyData.Set("file", value); } + } + + /// + /// The name with which the file has to be uploaded. The file name can contain: + /// + /// - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. - Special Characters: + /// `.`, `-` + /// + /// Any other character including space will be replaced by `_` + /// + public required string FileName + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullClass("fileName"); + } + init { this._rawBodyData.Set("fileName", value); } + } + + /// + /// A unique value that the ImageKit.io server will use to recognize and prevent + /// subsequent retries for the same request. We suggest using V4 UUIDs, or another + /// random string with enough entropy to avoid collisions. This field is only + /// required for authentication when uploading a file from the client side. + /// + /// **Note**: Sending a value that has been used in the past will result + /// in a validation error. Even if your previous request resulted in an error, + /// you should always send a new value for this field. + /// + public string? Token + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass("token"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("token", value); + } + } + + /// + /// Server-side checks to run on the asset. Read more about [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). + /// + public string? Checks + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass("checks"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("checks", value); + } + } + + /// + /// Define an important area in the image. This is only relevant for image type files. + /// + /// - To be passed as a string with the x and y coordinates of the top-left + /// corner, and width and height of the area of interest in the format `x,y,width,height`. + /// For example - `10,10,100,100` - Can be used with fo-customtransformation. + /// - If this field is not specified and the file is overwritten, then customCoordinates + /// will be removed. + /// + public string? CustomCoordinates + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass("customCoordinates"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("customCoordinates", value); + } + } + + /// + /// JSON key-value pairs to associate with the asset. Create the custom metadata + /// fields before setting these values. + /// + public IReadOnlyDictionary? CustomMetadata + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass>( + "customMetadata" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set?>( + "customMetadata", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + + /// + /// Optional text to describe the contents of the file. + /// + public string? Description + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass("description"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("description", value); + } + } + + /// + /// The time until your signature is valid. It must be a [Unix time](https://en.wikipedia.org/wiki/Unix_time) + /// in less than 1 hour into the future. It should be in seconds. This field + /// is only required for authentication when uploading a file from the client + /// side. + /// + public long? Expire + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableStruct("expire"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("expire", value); + } + } + + /// + /// Array of extensions to be applied to the asset. Each extension can be configured + /// with specific parameters based on the extension type. + /// + public IReadOnlyList? Extensions + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableStruct< + ImmutableArray + >("extensions"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set?>( + "extensions", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// The folder path in which the image has to be uploaded. If the folder(s) didn't + /// exist before, a new folder(s) is created. + /// + /// The folder name can contain: + /// + /// - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` - Special Characters: + /// `/` , `_` , `-` + /// + /// Using multiple `/` creates a nested folder. + /// + public string? Folder + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass("folder"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("folder", value); + } + } + + /// + /// Whether to mark the file as private or not. + /// + /// If `true`, the file is marked as private and is accessible only using + /// named transformation or signed URL. + /// + public bool? IsPrivateFile + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableStruct("isPrivateFile"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("isPrivateFile", value); + } + } + + /// + /// Whether to upload file as published or not. + /// + /// If `false`, the file is marked as unpublished, which restricts access + /// to the file only via the media library. Files in draft or unpublished state + /// can only be publicly accessed after being published. + /// + /// The option to upload in draft state is only available in custom enterprise + /// pricing plans. + /// + public bool? IsPublished + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableStruct("isPublished"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("isPublished", value); + } + } + + /// + /// If set to `true` and a file already exists at the exact location, its AITags + /// will be removed. Set `overwriteAITags` to `false` to preserve AITags. + /// + public bool? OverwriteAITags + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableStruct("overwriteAITags"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("overwriteAITags", value); + } + } + + /// + /// If the request does not have `customMetadata`, and a file already exists + /// at the exact location, existing customMetadata will be removed. + /// + public bool? OverwriteCustomMetadata + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableStruct("overwriteCustomMetadata"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("overwriteCustomMetadata", value); + } + } + + /// + /// If `false` and `useUniqueFileName` is also `false`, and a file already exists + /// at the exact location, upload API will return an error immediately. + /// + public bool? OverwriteFile + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableStruct("overwriteFile"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("overwriteFile", value); + } + } + + /// + /// If the request does not have `tags`, and a file already exists at the exact + /// location, existing tags will be removed. + /// + public bool? OverwriteTags + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableStruct("overwriteTags"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("overwriteTags", value); + } + } + + /// + /// Your ImageKit.io public key. This field is only required for authentication + /// when uploading a file from the client side. + /// + public string? PublicKey + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass("publicKey"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("publicKey", value); + } + } + + /// + /// Array of response field keys to include in the API response body. + /// + public IReadOnlyList>? ResponseFields + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableStruct< + ImmutableArray> + >("responseFields"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set>?>( + "responseFields", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key + /// as a key. Learn how to create a signature on the page below. This should + /// be in lowercase. + /// + /// Signature must be calculated on the server-side. This field is only + /// required for authentication when uploading a file from the client side. + /// + public string? Signature + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass("signature"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("signature", value); + } + } + + /// + /// Set the tags while uploading the file. Provide an array of tag strings (e.g. + /// `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must + /// not exceed 500, and the `%` character is not allowed. If this field is not + /// specified and the file is overwritten, the existing tags will be removed. + /// + public IReadOnlyList? Tags + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableStruct>("tags"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set?>( + "tags", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Configure pre-processing (`pre`) and post-processing (`post`) transformations. + /// + /// - `pre` — applied before the file is uploaded to the Media Library. + /// Useful for reducing file size or applying basic optimizations upfront + /// (e.g., resize, compress). + /// + /// - `post` — applied immediately after upload. Ideal for generating + /// transformed versions (like video encodes or thumbnails) in advance, so they're + /// ready for delivery without delay. + /// + /// You can mix and match any combination of post-processing types. + /// + public Transformation? Transformation + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass("transformation"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("transformation", value); + } + } + + /// + /// Whether to use a unique filename for this file or not. + /// + /// If `true`, ImageKit.io will add a unique suffix to the filename parameter + /// to get a unique filename. + /// + /// If `false`, then the image is uploaded with the provided filename parameter, + /// and any existing file with the same name is replaced. + /// + public bool? UseUniqueFileName + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableStruct("useUniqueFileName"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("useUniqueFileName", value); + } + } + + /// + /// The final status of extensions after they have completed execution will be + /// delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + /// about the webhook payload structure. + /// + public string? WebhookUrl + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass("webhookUrl"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("webhookUrl", value); + } + } + + public FileUploadParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public FileUploadParams(FileUploadParams fileUploadParams) + : base(fileUploadParams) + { + this._rawBodyData = new(fileUploadParams._rawBodyData); + } +#pragma warning restore CS8618 + + public FileUploadParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FileUploadParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData, + FrozenDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } +#pragma warning restore CS8618 + + /// + public static FileUploadParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData), + FrozenDictionary.ToFrozenDictionary(rawBodyData) + ); + } + + public override System::Uri Url(ClientOptions options) + { + return new System::UriBuilder( + options.BaseUrl.ToString().TrimEnd('/') + "/api/v1/files/upload" + ) + { + Query = this.QueryString(options), + }.Uri; + } + + internal override HttpContent? BodyContent() + { + return MultipartJsonSerializer.Serialize(RawBodyData); + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} + +[JsonConverter(typeof(ResponseFieldConverter))] +public enum ResponseField +{ + Tags, + CustomCoordinates, + IsPrivateFile, + EmbeddedMetadata, + IsPublished, + CustomMetadata, + Metadata, + SelectedFieldsSchema, +} + +sealed class ResponseFieldConverter : JsonConverter +{ + public override ResponseField Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "tags" => ResponseField.Tags, + "customCoordinates" => ResponseField.CustomCoordinates, + "isPrivateFile" => ResponseField.IsPrivateFile, + "embeddedMetadata" => ResponseField.EmbeddedMetadata, + "isPublished" => ResponseField.IsPublished, + "customMetadata" => ResponseField.CustomMetadata, + "metadata" => ResponseField.Metadata, + "selectedFieldsSchema" => ResponseField.SelectedFieldsSchema, + _ => (ResponseField)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ResponseField value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ResponseField.Tags => "tags", + ResponseField.CustomCoordinates => "customCoordinates", + ResponseField.IsPrivateFile => "isPrivateFile", + ResponseField.EmbeddedMetadata => "embeddedMetadata", + ResponseField.IsPublished => "isPublished", + ResponseField.CustomMetadata => "customMetadata", + ResponseField.Metadata => "metadata", + ResponseField.SelectedFieldsSchema => "selectedFieldsSchema", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configure pre-processing (`pre`) and post-processing (`post`) transformations. +/// +/// - `pre` — applied before the file is uploaded to the Media Library. +/// Useful for reducing file size or applying basic optimizations upfront (e.g., +/// resize, compress). +/// +/// - `post` — applied immediately after upload. Ideal for generating transformed +/// versions (like video encodes or thumbnails) in advance, so they're ready for delivery +/// without delay. +/// +/// You can mix and match any combination of post-processing types. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Transformation : JsonModel +{ + /// + /// List of transformations to apply *after* the file is uploaded. Each item + /// must match one of the following types: `transformation`, `gif-to-video`, `thumbnail`, + /// `abs`. + /// + public IReadOnlyList? Post + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>("post"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "post", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Transformation string to apply before uploading the file to the Media Library. + /// Useful for optimizing files at ingestion. + /// + public string? Pre + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("pre"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("pre", value); + } + } + + /// + public override void Validate() + { + foreach (var item in this.Post ?? []) + { + item.Validate(); + } + _ = this.Pre; + } + + public Transformation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Transformation(Transformation transformation) + : base(transformation) { } +#pragma warning restore CS8618 + + public Transformation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Transformation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static Transformation FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TransformationFromRaw : IFromRawJson +{ + /// + public Transformation FromRawUnchecked(IReadOnlyDictionary rawData) => + Transformation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(PostConverter))] +public record class Post : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public JsonElement Type + { + get + { + return Match( + transformation: (x) => x.Type, + gifToVideo: (x) => x.Type, + thumbnail: (x) => x.Type, + abs: (x) => x.Type + ); + } + } + + public string? Value1 + { + get + { + return Match( + transformation: (x) => x.Value, + gifToVideo: (x) => x.Value, + thumbnail: (x) => x.Value, + abs: (x) => x.Value + ); + } + } + + public Post(PostTransformation value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Post(GifToVideo value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Post(Thumbnail value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Post(Abs value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Post(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickTransformation(out var value)) { + /// // `value` is of type `PostTransformation` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTransformation([NotNullWhen(true)] out PostTransformation? value) + { + value = this.Value as PostTransformation; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickGifToVideo(out var value)) { + /// // `value` is of type `GifToVideo` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickGifToVideo([NotNullWhen(true)] out GifToVideo? value) + { + value = this.Value as GifToVideo; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickThumbnail(out var value)) { + /// // `value` is of type `Thumbnail` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickThumbnail([NotNullWhen(true)] out Thumbnail? value) + { + value = this.Value as Thumbnail; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickAbs(out var value)) { + /// // `value` is of type `Abs` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickAbs([NotNullWhen(true)] out Abs? value) + { + value = this.Value as Abs; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (PostTransformation value) => {...}, + /// (GifToVideo value) => {...}, + /// (Thumbnail value) => {...}, + /// (Abs value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action transformation, + System::Action gifToVideo, + System::Action thumbnail, + System::Action abs + ) + { + switch (this.Value) + { + case PostTransformation value: + transformation(value); + break; + case GifToVideo value: + gifToVideo(value); + break; + case Thumbnail value: + thumbnail(value); + break; + case Abs value: + abs(value); + break; + default: + throw new ImageKitInvalidDataException("Data did not match any variant of Post"); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (PostTransformation value) => {...}, + /// (GifToVideo value) => {...}, + /// (Thumbnail value) => {...}, + /// (Abs value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func transformation, + System::Func gifToVideo, + System::Func thumbnail, + System::Func abs + ) + { + return this.Value switch + { + PostTransformation value => transformation(value), + GifToVideo value => gifToVideo(value), + Thumbnail value => thumbnail(value), + Abs value => abs(value), + _ => throw new ImageKitInvalidDataException("Data did not match any variant of Post"), + }; + } + + public static implicit operator Post(PostTransformation value) => new(value); + + public static implicit operator Post(GifToVideo value) => new(value); + + public static implicit operator Post(Thumbnail value) => new(value); + + public static implicit operator Post(Abs value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException("Data did not match any variant of Post"); + } + this.Switch( + (transformation) => transformation.Validate(), + (gifToVideo) => gifToVideo.Validate(), + (thumbnail) => thumbnail.Validate(), + (abs) => abs.Validate() + ); + } + + public virtual bool Equals(Post? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class PostConverter : JsonConverter +{ + public override Post? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + string? type; + try + { + type = element.GetProperty("type").GetString(); + } + catch + { + type = null; + } + + switch (type) + { + case "transformation": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + case "gif-to-video": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + case "thumbnail": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + case "abs": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + default: + { + return new Post(element); + } + } + } + + public override void Write(Utf8JsonWriter writer, Post value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class PostTransformation : JsonModel +{ + /// + /// Transformation type. + /// + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// Transformation string (e.g. `w-200,h-200`). Same syntax as ImageKit URL-based + /// transformations. + /// + public required string Value + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("value"); + } + init { this._rawData.Set("value", value); } + } + + /// + public override void Validate() + { + if (!JsonElement.DeepEquals(this.Type, JsonSerializer.SerializeToElement("transformation"))) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + _ = this.Value; + } + + public PostTransformation() + { + this.Type = JsonSerializer.SerializeToElement("transformation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PostTransformation(PostTransformation postTransformation) + : base(postTransformation) { } +#pragma warning restore CS8618 + + public PostTransformation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("transformation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PostTransformation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PostTransformation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public PostTransformation(string value) + : this() + { + this.Value = value; + } +} + +class PostTransformationFromRaw : IFromRawJson +{ + /// + public PostTransformation FromRawUnchecked(IReadOnlyDictionary rawData) => + PostTransformation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class GifToVideo : JsonModel +{ + /// + /// Converts an animated GIF into an MP4. + /// + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// Optional transformation string to apply to the output video. **Example**: + /// `q-80` + /// + public string? Value + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("value"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("value", value); + } + } + + /// + public override void Validate() + { + if (!JsonElement.DeepEquals(this.Type, JsonSerializer.SerializeToElement("gif-to-video"))) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + _ = this.Value; + } + + public GifToVideo() + { + this.Type = JsonSerializer.SerializeToElement("gif-to-video"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GifToVideo(GifToVideo gifToVideo) + : base(gifToVideo) { } +#pragma warning restore CS8618 + + public GifToVideo(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("gif-to-video"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GifToVideo(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GifToVideo FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GifToVideoFromRaw : IFromRawJson +{ + /// + public GifToVideo FromRawUnchecked(IReadOnlyDictionary rawData) => + GifToVideo.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Thumbnail : JsonModel +{ + /// + /// Generates a thumbnail image. + /// + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// Optional transformation string. **Example**: `w-150,h-150` + /// + public string? Value + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("value"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("value", value); + } + } + + /// + public override void Validate() + { + if (!JsonElement.DeepEquals(this.Type, JsonSerializer.SerializeToElement("thumbnail"))) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + _ = this.Value; + } + + public Thumbnail() + { + this.Type = JsonSerializer.SerializeToElement("thumbnail"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Thumbnail(Thumbnail thumbnail) + : base(thumbnail) { } +#pragma warning restore CS8618 + + public Thumbnail(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("thumbnail"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Thumbnail(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static Thumbnail FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ThumbnailFromRaw : IFromRawJson +{ + /// + public Thumbnail FromRawUnchecked(IReadOnlyDictionary rawData) => + Thumbnail.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Abs : JsonModel +{ + /// + /// Streaming protocol to use (`hls` or `dash`). + /// + public required ApiEnum Protocol + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass>("protocol"); + } + init { this._rawData.Set("protocol", value); } + } + + /// + /// Adaptive Bitrate Streaming (ABS) setup. + /// + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// List of different representations you want to create separated by an underscore. + /// + public required string Value + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("value"); + } + init { this._rawData.Set("value", value); } + } + + /// + public override void Validate() + { + this.Protocol.Validate(); + if (!JsonElement.DeepEquals(this.Type, JsonSerializer.SerializeToElement("abs"))) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + _ = this.Value; + } + + public Abs() + { + this.Type = JsonSerializer.SerializeToElement("abs"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Abs(Abs abs) + : base(abs) { } +#pragma warning restore CS8618 + + public Abs(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("abs"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Abs(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static Abs FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class AbsFromRaw : IFromRawJson +{ + /// + public Abs FromRawUnchecked(IReadOnlyDictionary rawData) => + Abs.FromRawUnchecked(rawData); +} + +/// +/// Streaming protocol to use (`hls` or `dash`). +/// +[JsonConverter(typeof(ProtocolConverter))] +public enum Protocol +{ + Hls, + Dash, +} + +sealed class ProtocolConverter : JsonConverter +{ + public override Protocol Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "hls" => Protocol.Hls, + "dash" => Protocol.Dash, + _ => (Protocol)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Protocol value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + Protocol.Hls => "hls", + Protocol.Dash => "dash", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} diff --git a/src/ImageKit/Models/Files/FileUploadResponse.cs b/src/ImageKit/Models/Files/FileUploadResponse.cs new file mode 100644 index 00000000..811012cc --- /dev/null +++ b/src/ImageKit/Models/Files/FileUploadResponse.cs @@ -0,0 +1,3073 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; +using ImageKit.Exceptions; +using System = System; + +namespace ImageKit.Models.Files; + +/// +/// Object containing details of a successful upload. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class FileUploadResponse : JsonModel +{ + /// + /// An array of tags assigned to the uploaded file by auto tagging. + /// + public IReadOnlyList? AITags + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>( + "AITags" + ); + } + init + { + this._rawData.Set?>( + "AITags", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// The audio codec used in the video (only for video). + /// + public string? AudioCodec + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("audioCodec"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("audioCodec", value); + } + } + + /// + /// The bit rate of the video in kbps (only for video). + /// + public long? BitRate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("bitRate"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("bitRate", value); + } + } + + /// + /// Value of custom coordinates associated with the image in the format `x,y,width,height`. + /// If `customCoordinates` are not defined, then it is `null`. Send `customCoordinates` + /// in `responseFields` in API request to get the value of this field. + /// + public string? CustomCoordinates + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("customCoordinates"); + } + init { this._rawData.Set("customCoordinates", value); } + } + + /// + /// A key-value data associated with the asset. Use `responseField` in API request + /// to get `customMetadata` in the upload API response. Before setting any custom + /// metadata on an asset, you have to create the field using custom metadata fields + /// API. Send `customMetadata` in `responseFields` in API request to get the value + /// of this field. + /// + public IReadOnlyDictionary? CustomMetadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>( + "customMetadata" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "customMetadata", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + + /// + /// Optional text to describe the contents of the file. Can be set by the user + /// or the ai-auto-description extension. + /// + public string? Description + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("description"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("description", value); + } + } + + /// + /// The duration of the video in seconds (only for video). + /// + public long? Duration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("duration"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("duration", value); + } + } + + /// + /// Consolidated embedded metadata associated with the file. It includes exif, + /// iptc, and xmp data. Send `embeddedMetadata` in `responseFields` in API request + /// to get embeddedMetadata in the upload API response. + /// + public IReadOnlyDictionary? EmbeddedMetadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>( + "embeddedMetadata" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "embeddedMetadata", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + + /// + /// Extension names with their processing status at the time of completion of + /// the request. It could have one of the following status values: + /// + /// `success`: The extension has been successfully applied. `failed`: The + /// extension has failed and will not be retried. `pending`: The extension will + /// finish processing in some time. On completion, the final status (success + /// / failed) will be sent to the `webhookUrl` provided. + /// + /// If no extension was requested, then this parameter is not returned. + /// + public FileUploadResponseExtensionStatus? ExtensionStatus + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "extensionStatus" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("extensionStatus", value); + } + } + + /// + /// Unique fileId. Store this fileld in your database, as this will be used to + /// perform update action on this file. + /// + public string? FileID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("fileId"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("fileId", value); + } + } + + /// + /// The relative path of the file in the media library e.g. `/marketing-assets/new-banner.jpg`. + /// + public string? FilePath + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("filePath"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("filePath", value); + } + } + + /// + /// Type of the uploaded file. Possible values are `image`, `non-image`. + /// + public string? FileType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("fileType"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("fileType", value); + } + } + + /// + /// Height of the image in pixels (Only for images) + /// + public double? Height + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("height"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("height", value); + } + } + + /// + /// Is the file marked as private. It can be either `true` or `false`. Send `isPrivateFile` + /// in `responseFields` in API request to get the value of this field. + /// + public bool? IsPrivateFile + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("isPrivateFile"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("isPrivateFile", value); + } + } + + /// + /// Is the file published or in draft state. It can be either `true` or `false`. + /// Send `isPublished` in `responseFields` in API request to get the value of + /// this field. + /// + public bool? IsPublished + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("isPublished"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("isPublished", value); + } + } + + /// + /// Legacy metadata. Send `metadata` in `responseFields` in API request to get + /// metadata in the upload API response. + /// + public FileMetadata? Metadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("metadata"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("metadata", value); + } + } + + /// + /// Name of the asset. + /// + public string? Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("name"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("name", value); + } + } + + /// + /// This field is included in the response only if the Path policy feature is + /// available in the plan. It contains schema definitions for the custom metadata + /// fields selected for the specified file path. Field selection can only be + /// done when the Path policy feature is enabled. + /// + /// Keys are the names of the custom metadata fields; the value object + /// has details about the custom metadata schema. + /// + public IReadOnlyDictionary< + string, + FileUploadResponseSelectedFieldsSchemaItem + >? SelectedFieldsSchema + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass< + FrozenDictionary + >("selectedFieldsSchema"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "selectedFieldsSchema", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + + /// + /// Size of the image file in Bytes. + /// + public double? Size + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("size"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("size", value); + } + } + + /// + /// The array of tags associated with the asset. If no tags are set, it will be + /// `null`. Send `tags` in `responseFields` in API request to get the value of + /// this field. + /// + public IReadOnlyList? Tags + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>("tags"); + } + init + { + this._rawData.Set?>( + "tags", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// In the case of an image, a small thumbnail URL. + /// + public string? ThumbnailUrl + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("thumbnailUrl"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("thumbnailUrl", value); + } + } + + /// + /// A publicly accessible URL of the file. + /// + public string? Url + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("url"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("url", value); + } + } + + /// + /// An object containing the file or file version's `id` (versionId) and `name`. + /// + public FileUploadResponseVersionInfo? VersionInfo + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("versionInfo"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("versionInfo", value); + } + } + + /// + /// The video codec used in the video (only for video). + /// + public string? VideoCodec + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("videoCodec"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("videoCodec", value); + } + } + + /// + /// Width of the image in pixels (Only for Images) + /// + public double? Width + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("width"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("width", value); + } + } + + /// + public override void Validate() + { + foreach (var item in this.AITags ?? []) + { + item.Validate(); + } + _ = this.AudioCodec; + _ = this.BitRate; + _ = this.CustomCoordinates; + _ = this.CustomMetadata; + _ = this.Description; + _ = this.Duration; + _ = this.EmbeddedMetadata; + this.ExtensionStatus?.Validate(); + _ = this.FileID; + _ = this.FilePath; + _ = this.FileType; + _ = this.Height; + _ = this.IsPrivateFile; + _ = this.IsPublished; + this.Metadata?.Validate(); + _ = this.Name; + if (this.SelectedFieldsSchema != null) + { + foreach (var item in this.SelectedFieldsSchema.Values) + { + item.Validate(); + } + } + _ = this.Size; + _ = this.Tags; + _ = this.ThumbnailUrl; + _ = this.Url; + this.VersionInfo?.Validate(); + _ = this.VideoCodec; + _ = this.Width; + } + + public FileUploadResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public FileUploadResponse(FileUploadResponse fileUploadResponse) + : base(fileUploadResponse) { } +#pragma warning restore CS8618 + + public FileUploadResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FileUploadResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static FileUploadResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class FileUploadResponseFromRaw : IFromRawJson +{ + /// + public FileUploadResponse FromRawUnchecked(IReadOnlyDictionary rawData) => + FileUploadResponse.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class FileUploadResponseAITag : JsonModel +{ + /// + /// Confidence score of the tag. + /// + public double? Confidence + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("confidence"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("confidence", value); + } + } + + /// + /// Name of the tag. + /// + public string? Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("name"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("name", value); + } + } + + /// + /// Array of `AITags` associated with the image. If no `AITags` are set, it will + /// be null. These tags can be added using the `google-auto-tagging` or `aws-auto-tagging` extensions. + /// + public string? Source + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("source"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("source", value); + } + } + + /// + public override void Validate() + { + _ = this.Confidence; + _ = this.Name; + _ = this.Source; + } + + public FileUploadResponseAITag() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public FileUploadResponseAITag(FileUploadResponseAITag fileUploadResponseAITag) + : base(fileUploadResponseAITag) { } +#pragma warning restore CS8618 + + public FileUploadResponseAITag(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FileUploadResponseAITag(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static FileUploadResponseAITag FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class FileUploadResponseAITagFromRaw : IFromRawJson +{ + /// + public FileUploadResponseAITag FromRawUnchecked( + IReadOnlyDictionary rawData + ) => FileUploadResponseAITag.FromRawUnchecked(rawData); +} + +/// +/// Extension names with their processing status at the time of completion of the +/// request. It could have one of the following status values: +/// +/// `success`: The extension has been successfully applied. `failed`: The extension +/// has failed and will not be retried. `pending`: The extension will finish processing +/// in some time. On completion, the final status (success / failed) will be sent +/// to the `webhookUrl` provided. +/// +/// If no extension was requested, then this parameter is not returned. +/// +[JsonConverter( + typeof(JsonModelConverter< + FileUploadResponseExtensionStatus, + FileUploadResponseExtensionStatusFromRaw + >) +)] +public sealed record class FileUploadResponseExtensionStatus : JsonModel +{ + public ApiEnum? AIAutoDescription + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass< + ApiEnum + >("ai-auto-description"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("ai-auto-description", value); + } + } + + public ApiEnum? AITasks + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass< + ApiEnum + >("ai-tasks"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("ai-tasks", value); + } + } + + public ApiEnum? AwsAutoTagging + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass< + ApiEnum + >("aws-auto-tagging"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("aws-auto-tagging", value); + } + } + + public ApiEnum? GoogleAutoTagging + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass< + ApiEnum + >("google-auto-tagging"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("google-auto-tagging", value); + } + } + + public ApiEnum? RemoveBg + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass< + ApiEnum + >("remove-bg"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("remove-bg", value); + } + } + + /// + public override void Validate() + { + this.AIAutoDescription?.Validate(); + this.AITasks?.Validate(); + this.AwsAutoTagging?.Validate(); + this.GoogleAutoTagging?.Validate(); + this.RemoveBg?.Validate(); + } + + public FileUploadResponseExtensionStatus() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public FileUploadResponseExtensionStatus( + FileUploadResponseExtensionStatus fileUploadResponseExtensionStatus + ) + : base(fileUploadResponseExtensionStatus) { } +#pragma warning restore CS8618 + + public FileUploadResponseExtensionStatus(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FileUploadResponseExtensionStatus(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static FileUploadResponseExtensionStatus FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class FileUploadResponseExtensionStatusFromRaw : IFromRawJson +{ + /// + public FileUploadResponseExtensionStatus FromRawUnchecked( + IReadOnlyDictionary rawData + ) => FileUploadResponseExtensionStatus.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(FileUploadResponseExtensionStatusAIAutoDescriptionConverter))] +public enum FileUploadResponseExtensionStatusAIAutoDescription +{ + Success, + Pending, + Failed, +} + +sealed class FileUploadResponseExtensionStatusAIAutoDescriptionConverter + : JsonConverter +{ + public override FileUploadResponseExtensionStatusAIAutoDescription Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "success" => FileUploadResponseExtensionStatusAIAutoDescription.Success, + "pending" => FileUploadResponseExtensionStatusAIAutoDescription.Pending, + "failed" => FileUploadResponseExtensionStatusAIAutoDescription.Failed, + _ => (FileUploadResponseExtensionStatusAIAutoDescription)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + FileUploadResponseExtensionStatusAIAutoDescription value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + FileUploadResponseExtensionStatusAIAutoDescription.Success => "success", + FileUploadResponseExtensionStatusAIAutoDescription.Pending => "pending", + FileUploadResponseExtensionStatusAIAutoDescription.Failed => "failed", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter(typeof(FileUploadResponseExtensionStatusAITasksConverter))] +public enum FileUploadResponseExtensionStatusAITasks +{ + Success, + Pending, + Failed, +} + +sealed class FileUploadResponseExtensionStatusAITasksConverter + : JsonConverter +{ + public override FileUploadResponseExtensionStatusAITasks Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "success" => FileUploadResponseExtensionStatusAITasks.Success, + "pending" => FileUploadResponseExtensionStatusAITasks.Pending, + "failed" => FileUploadResponseExtensionStatusAITasks.Failed, + _ => (FileUploadResponseExtensionStatusAITasks)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + FileUploadResponseExtensionStatusAITasks value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + FileUploadResponseExtensionStatusAITasks.Success => "success", + FileUploadResponseExtensionStatusAITasks.Pending => "pending", + FileUploadResponseExtensionStatusAITasks.Failed => "failed", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter(typeof(FileUploadResponseExtensionStatusAwsAutoTaggingConverter))] +public enum FileUploadResponseExtensionStatusAwsAutoTagging +{ + Success, + Pending, + Failed, +} + +sealed class FileUploadResponseExtensionStatusAwsAutoTaggingConverter + : JsonConverter +{ + public override FileUploadResponseExtensionStatusAwsAutoTagging Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "success" => FileUploadResponseExtensionStatusAwsAutoTagging.Success, + "pending" => FileUploadResponseExtensionStatusAwsAutoTagging.Pending, + "failed" => FileUploadResponseExtensionStatusAwsAutoTagging.Failed, + _ => (FileUploadResponseExtensionStatusAwsAutoTagging)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + FileUploadResponseExtensionStatusAwsAutoTagging value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + FileUploadResponseExtensionStatusAwsAutoTagging.Success => "success", + FileUploadResponseExtensionStatusAwsAutoTagging.Pending => "pending", + FileUploadResponseExtensionStatusAwsAutoTagging.Failed => "failed", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter(typeof(FileUploadResponseExtensionStatusGoogleAutoTaggingConverter))] +public enum FileUploadResponseExtensionStatusGoogleAutoTagging +{ + Success, + Pending, + Failed, +} + +sealed class FileUploadResponseExtensionStatusGoogleAutoTaggingConverter + : JsonConverter +{ + public override FileUploadResponseExtensionStatusGoogleAutoTagging Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "success" => FileUploadResponseExtensionStatusGoogleAutoTagging.Success, + "pending" => FileUploadResponseExtensionStatusGoogleAutoTagging.Pending, + "failed" => FileUploadResponseExtensionStatusGoogleAutoTagging.Failed, + _ => (FileUploadResponseExtensionStatusGoogleAutoTagging)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + FileUploadResponseExtensionStatusGoogleAutoTagging value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + FileUploadResponseExtensionStatusGoogleAutoTagging.Success => "success", + FileUploadResponseExtensionStatusGoogleAutoTagging.Pending => "pending", + FileUploadResponseExtensionStatusGoogleAutoTagging.Failed => "failed", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter(typeof(FileUploadResponseExtensionStatusRemoveBgConverter))] +public enum FileUploadResponseExtensionStatusRemoveBg +{ + Success, + Pending, + Failed, +} + +sealed class FileUploadResponseExtensionStatusRemoveBgConverter + : JsonConverter +{ + public override FileUploadResponseExtensionStatusRemoveBg Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "success" => FileUploadResponseExtensionStatusRemoveBg.Success, + "pending" => FileUploadResponseExtensionStatusRemoveBg.Pending, + "failed" => FileUploadResponseExtensionStatusRemoveBg.Failed, + _ => (FileUploadResponseExtensionStatusRemoveBg)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + FileUploadResponseExtensionStatusRemoveBg value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + FileUploadResponseExtensionStatusRemoveBg.Success => "success", + FileUploadResponseExtensionStatusRemoveBg.Pending => "pending", + FileUploadResponseExtensionStatusRemoveBg.Failed => "failed", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + FileUploadResponseSelectedFieldsSchemaItem, + FileUploadResponseSelectedFieldsSchemaItemFromRaw + >) +)] +public sealed record class FileUploadResponseSelectedFieldsSchemaItem : JsonModel +{ + /// + /// Type of the custom metadata field. + /// + public required ApiEnum Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum + >("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// The default value for this custom metadata field. The value should match + /// the `type` of custom metadata field. + /// + public FileUploadResponseSelectedFieldsSchemaItemDefaultValue? DefaultValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "defaultValue" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("defaultValue", value); + } + } + + /// + /// Specifies if the custom metadata field is required or not. + /// + public bool? IsValueRequired + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("isValueRequired"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("isValueRequired", value); + } + } + + /// + /// Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. + /// + public double? MaxLength + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("maxLength"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("maxLength", value); + } + } + + /// + /// Maximum value of the field. Only set if field type is `Date` or `Number`. + /// For `Date` type field, the value will be in ISO8601 string format. For `Number` + /// type field, it will be a numeric value. + /// + public FileUploadResponseSelectedFieldsSchemaItemMaxValue? MaxValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "maxValue" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("maxValue", value); + } + } + + /// + /// Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. + /// + public double? MinLength + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("minLength"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("minLength", value); + } + } + + /// + /// Minimum value of the field. Only set if field type is `Date` or `Number`. + /// For `Date` type field, the value will be in ISO8601 string format. For `Number` + /// type field, it will be a numeric value. + /// + public FileUploadResponseSelectedFieldsSchemaItemMinValue? MinValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "minValue" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("minValue", value); + } + } + + /// + /// Indicates whether the custom metadata field is read only. A read only field + /// cannot be modified after being set. This field is configurable only via the + /// **Path policy** feature. + /// + public bool? ReadOnly + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("readOnly"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("readOnly", value); + } + } + + /// + /// An array of allowed values when field type is `SingleSelect` or `MultiSelect`. + /// + public IReadOnlyList? SelectOptions + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct< + ImmutableArray + >("selectOptions"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "selectOptions", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Specifies if the selectOptions array is truncated. It is truncated when number + /// of options are > 100. + /// + public bool? SelectOptionsTruncated + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("selectOptionsTruncated"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("selectOptionsTruncated", value); + } + } + + /// + public override void Validate() + { + this.Type.Validate(); + this.DefaultValue?.Validate(); + _ = this.IsValueRequired; + _ = this.MaxLength; + this.MaxValue?.Validate(); + _ = this.MinLength; + this.MinValue?.Validate(); + _ = this.ReadOnly; + foreach (var item in this.SelectOptions ?? []) + { + item.Validate(); + } + _ = this.SelectOptionsTruncated; + } + + public FileUploadResponseSelectedFieldsSchemaItem() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public FileUploadResponseSelectedFieldsSchemaItem( + FileUploadResponseSelectedFieldsSchemaItem fileUploadResponseSelectedFieldsSchemaItem + ) + : base(fileUploadResponseSelectedFieldsSchemaItem) { } +#pragma warning restore CS8618 + + public FileUploadResponseSelectedFieldsSchemaItem( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FileUploadResponseSelectedFieldsSchemaItem(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static FileUploadResponseSelectedFieldsSchemaItem FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public FileUploadResponseSelectedFieldsSchemaItem( + ApiEnum type + ) + : this() + { + this.Type = type; + } +} + +class FileUploadResponseSelectedFieldsSchemaItemFromRaw + : IFromRawJson +{ + /// + public FileUploadResponseSelectedFieldsSchemaItem FromRawUnchecked( + IReadOnlyDictionary rawData + ) => FileUploadResponseSelectedFieldsSchemaItem.FromRawUnchecked(rawData); +} + +/// +/// Type of the custom metadata field. +/// +[JsonConverter(typeof(FileUploadResponseSelectedFieldsSchemaItemTypeConverter))] +public enum FileUploadResponseSelectedFieldsSchemaItemType +{ + Text, + Textarea, + Number, + Date, + Boolean, + SingleSelect, + MultiSelect, +} + +sealed class FileUploadResponseSelectedFieldsSchemaItemTypeConverter + : JsonConverter +{ + public override FileUploadResponseSelectedFieldsSchemaItemType Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "Text" => FileUploadResponseSelectedFieldsSchemaItemType.Text, + "Textarea" => FileUploadResponseSelectedFieldsSchemaItemType.Textarea, + "Number" => FileUploadResponseSelectedFieldsSchemaItemType.Number, + "Date" => FileUploadResponseSelectedFieldsSchemaItemType.Date, + "Boolean" => FileUploadResponseSelectedFieldsSchemaItemType.Boolean, + "SingleSelect" => FileUploadResponseSelectedFieldsSchemaItemType.SingleSelect, + "MultiSelect" => FileUploadResponseSelectedFieldsSchemaItemType.MultiSelect, + _ => (FileUploadResponseSelectedFieldsSchemaItemType)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + FileUploadResponseSelectedFieldsSchemaItemType value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + FileUploadResponseSelectedFieldsSchemaItemType.Text => "Text", + FileUploadResponseSelectedFieldsSchemaItemType.Textarea => "Textarea", + FileUploadResponseSelectedFieldsSchemaItemType.Number => "Number", + FileUploadResponseSelectedFieldsSchemaItemType.Date => "Date", + FileUploadResponseSelectedFieldsSchemaItemType.Boolean => "Boolean", + FileUploadResponseSelectedFieldsSchemaItemType.SingleSelect => "SingleSelect", + FileUploadResponseSelectedFieldsSchemaItemType.MultiSelect => "MultiSelect", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// The default value for this custom metadata field. The value should match the `type` +/// of custom metadata field. +/// +[JsonConverter(typeof(FileUploadResponseSelectedFieldsSchemaItemDefaultValueConverter))] +public record class FileUploadResponseSelectedFieldsSchemaItemDefaultValue : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public FileUploadResponseSelectedFieldsSchemaItemDefaultValue( + string value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public FileUploadResponseSelectedFieldsSchemaItemDefaultValue( + double value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public FileUploadResponseSelectedFieldsSchemaItemDefaultValue( + bool value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public FileUploadResponseSelectedFieldsSchemaItemDefaultValue( + IReadOnlyList value, + JsonElement? element = null + ) + { + this.Value = ImmutableArray.ToImmutableArray(value); + this._element = element; + } + + public FileUploadResponseSelectedFieldsSchemaItemDefaultValue(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickBool(out var value)) { + /// // `value` is of type `bool` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = this.Value as bool?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickMixed(out var value)) { + /// // `value` is of type `IReadOnlyList` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMixed( + [NotNullWhen(true)] out IReadOnlyList? value + ) + { + value = this.Value as IReadOnlyList; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action @string, + System::Action @double, + System::Action @bool, + System::Action> mixed + ) + { + switch (this.Value) + { + case string value: + @string(value); + break; + case double value: + @double(value); + break; + case bool value: + @bool(value); + break; + case IReadOnlyList value: + mixed(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of FileUploadResponseSelectedFieldsSchemaItemDefaultValue" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func @string, + System::Func @double, + System::Func @bool, + System::Func, T> mixed + ) + { + return this.Value switch + { + string value => @string(value), + double value => @double(value), + bool value => @bool(value), + IReadOnlyList value => mixed(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of FileUploadResponseSelectedFieldsSchemaItemDefaultValue" + ), + }; + } + + public static implicit operator FileUploadResponseSelectedFieldsSchemaItemDefaultValue( + string value + ) => new(value); + + public static implicit operator FileUploadResponseSelectedFieldsSchemaItemDefaultValue( + double value + ) => new(value); + + public static implicit operator FileUploadResponseSelectedFieldsSchemaItemDefaultValue( + bool value + ) => new(value); + + public static implicit operator FileUploadResponseSelectedFieldsSchemaItemDefaultValue( + List value + ) => new((IReadOnlyList)value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of FileUploadResponseSelectedFieldsSchemaItemDefaultValue" + ); + } + } + + public virtual bool Equals(FileUploadResponseSelectedFieldsSchemaItemDefaultValue? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class FileUploadResponseSelectedFieldsSchemaItemDefaultValueConverter + : JsonConverter +{ + public override FileUploadResponseSelectedFieldsSchemaItemDefaultValue? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize>( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + FileUploadResponseSelectedFieldsSchemaItemDefaultValue value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(UnnamedSchemaWithArrayParent11Converter))] +public record class UnnamedSchemaWithArrayParent11 : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public UnnamedSchemaWithArrayParent11(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent11(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent11(bool value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent11(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickBool(out var value)) { + /// // `value` is of type `bool` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = this.Value as bool?; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action @string, + System::Action @double, + System::Action @bool + ) + { + switch (this.Value) + { + case string value: + @string(value); + break; + case double value: + @double(value); + break; + case bool value: + @bool(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent11" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func @string, + System::Func @double, + System::Func @bool + ) + { + return this.Value switch + { + string value => @string(value), + double value => @double(value), + bool value => @bool(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent11" + ), + }; + } + + public static implicit operator UnnamedSchemaWithArrayParent11(string value) => new(value); + + public static implicit operator UnnamedSchemaWithArrayParent11(double value) => new(value); + + public static implicit operator UnnamedSchemaWithArrayParent11(bool value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent11" + ); + } + } + + public virtual bool Equals(UnnamedSchemaWithArrayParent11? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class UnnamedSchemaWithArrayParent11Converter : JsonConverter +{ + public override UnnamedSchemaWithArrayParent11? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + UnnamedSchemaWithArrayParent11 value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +/// +/// Maximum value of the field. Only set if field type is `Date` or `Number`. For +/// `Date` type field, the value will be in ISO8601 string format. For `Number` type +/// field, it will be a numeric value. +/// +[JsonConverter(typeof(FileUploadResponseSelectedFieldsSchemaItemMaxValueConverter))] +public record class FileUploadResponseSelectedFieldsSchemaItemMaxValue : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public FileUploadResponseSelectedFieldsSchemaItemMaxValue( + string value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public FileUploadResponseSelectedFieldsSchemaItemMaxValue( + double value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public FileUploadResponseSelectedFieldsSchemaItemMaxValue(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (string value) => {...}, + /// (double value) => {...} + /// ); + /// + /// + /// + public void Switch(System::Action @string, System::Action @double) + { + switch (this.Value) + { + case string value: + @string(value); + break; + case double value: + @double(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of FileUploadResponseSelectedFieldsSchemaItemMaxValue" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (string value) => {...}, + /// (double value) => {...} + /// ); + /// + /// + /// + public T Match(System::Func @string, System::Func @double) + { + return this.Value switch + { + string value => @string(value), + double value => @double(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of FileUploadResponseSelectedFieldsSchemaItemMaxValue" + ), + }; + } + + public static implicit operator FileUploadResponseSelectedFieldsSchemaItemMaxValue( + string value + ) => new(value); + + public static implicit operator FileUploadResponseSelectedFieldsSchemaItemMaxValue( + double value + ) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of FileUploadResponseSelectedFieldsSchemaItemMaxValue" + ); + } + } + + public virtual bool Equals(FileUploadResponseSelectedFieldsSchemaItemMaxValue? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class FileUploadResponseSelectedFieldsSchemaItemMaxValueConverter + : JsonConverter +{ + public override FileUploadResponseSelectedFieldsSchemaItemMaxValue? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + FileUploadResponseSelectedFieldsSchemaItemMaxValue value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +/// +/// Minimum value of the field. Only set if field type is `Date` or `Number`. For +/// `Date` type field, the value will be in ISO8601 string format. For `Number` type +/// field, it will be a numeric value. +/// +[JsonConverter(typeof(FileUploadResponseSelectedFieldsSchemaItemMinValueConverter))] +public record class FileUploadResponseSelectedFieldsSchemaItemMinValue : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public FileUploadResponseSelectedFieldsSchemaItemMinValue( + string value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public FileUploadResponseSelectedFieldsSchemaItemMinValue( + double value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public FileUploadResponseSelectedFieldsSchemaItemMinValue(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (string value) => {...}, + /// (double value) => {...} + /// ); + /// + /// + /// + public void Switch(System::Action @string, System::Action @double) + { + switch (this.Value) + { + case string value: + @string(value); + break; + case double value: + @double(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of FileUploadResponseSelectedFieldsSchemaItemMinValue" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (string value) => {...}, + /// (double value) => {...} + /// ); + /// + /// + /// + public T Match(System::Func @string, System::Func @double) + { + return this.Value switch + { + string value => @string(value), + double value => @double(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of FileUploadResponseSelectedFieldsSchemaItemMinValue" + ), + }; + } + + public static implicit operator FileUploadResponseSelectedFieldsSchemaItemMinValue( + string value + ) => new(value); + + public static implicit operator FileUploadResponseSelectedFieldsSchemaItemMinValue( + double value + ) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of FileUploadResponseSelectedFieldsSchemaItemMinValue" + ); + } + } + + public virtual bool Equals(FileUploadResponseSelectedFieldsSchemaItemMinValue? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class FileUploadResponseSelectedFieldsSchemaItemMinValueConverter + : JsonConverter +{ + public override FileUploadResponseSelectedFieldsSchemaItemMinValue? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + FileUploadResponseSelectedFieldsSchemaItemMinValue value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(FileUploadResponseSelectedFieldsSchemaItemSelectOptionConverter))] +public record class FileUploadResponseSelectedFieldsSchemaItemSelectOption : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public FileUploadResponseSelectedFieldsSchemaItemSelectOption( + string value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public FileUploadResponseSelectedFieldsSchemaItemSelectOption( + double value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public FileUploadResponseSelectedFieldsSchemaItemSelectOption( + bool value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public FileUploadResponseSelectedFieldsSchemaItemSelectOption(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickBool(out var value)) { + /// // `value` is of type `bool` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = this.Value as bool?; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action @string, + System::Action @double, + System::Action @bool + ) + { + switch (this.Value) + { + case string value: + @string(value); + break; + case double value: + @double(value); + break; + case bool value: + @bool(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of FileUploadResponseSelectedFieldsSchemaItemSelectOption" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func @string, + System::Func @double, + System::Func @bool + ) + { + return this.Value switch + { + string value => @string(value), + double value => @double(value), + bool value => @bool(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of FileUploadResponseSelectedFieldsSchemaItemSelectOption" + ), + }; + } + + public static implicit operator FileUploadResponseSelectedFieldsSchemaItemSelectOption( + string value + ) => new(value); + + public static implicit operator FileUploadResponseSelectedFieldsSchemaItemSelectOption( + double value + ) => new(value); + + public static implicit operator FileUploadResponseSelectedFieldsSchemaItemSelectOption( + bool value + ) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of FileUploadResponseSelectedFieldsSchemaItemSelectOption" + ); + } + } + + public virtual bool Equals(FileUploadResponseSelectedFieldsSchemaItemSelectOption? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class FileUploadResponseSelectedFieldsSchemaItemSelectOptionConverter + : JsonConverter +{ + public override FileUploadResponseSelectedFieldsSchemaItemSelectOption? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + FileUploadResponseSelectedFieldsSchemaItemSelectOption value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +/// +/// An object containing the file or file version's `id` (versionId) and `name`. +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class FileUploadResponseVersionInfo : JsonModel +{ + /// + /// Unique identifier of the file version. + /// + public string? ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("id"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("id", value); + } + } + + /// + /// Name of the file version. + /// + public string? Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("name"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("name", value); + } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.Name; + } + + public FileUploadResponseVersionInfo() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public FileUploadResponseVersionInfo( + FileUploadResponseVersionInfo fileUploadResponseVersionInfo + ) + : base(fileUploadResponseVersionInfo) { } +#pragma warning restore CS8618 + + public FileUploadResponseVersionInfo(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FileUploadResponseVersionInfo(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static FileUploadResponseVersionInfo FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class FileUploadResponseVersionInfoFromRaw : IFromRawJson +{ + /// + public FileUploadResponseVersionInfo FromRawUnchecked( + IReadOnlyDictionary rawData + ) => FileUploadResponseVersionInfo.FromRawUnchecked(rawData); +} diff --git a/src/ImageKit/Models/Files/Folder.cs b/src/ImageKit/Models/Files/Folder.cs new file mode 100644 index 00000000..c8592d26 --- /dev/null +++ b/src/ImageKit/Models/Files/Folder.cs @@ -0,0 +1,234 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; +using ImageKit.Exceptions; +using System = System; + +namespace ImageKit.Models.Files; + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Folder : JsonModel +{ + /// + /// Date and time when the folder was created. The date and time is in ISO8601 + /// format. + /// + public System::DateTimeOffset? CreatedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("createdAt"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("createdAt", value); + } + } + + /// + /// Unique identifier of the asset. + /// + public string? FolderID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("folderId"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("folderId", value); + } + } + + /// + /// Path of the folder. This is the path you would use in the URL to access the + /// folder. For example, if the folder is at the root of the media library, the + /// path will be /folder. If the folder is inside another folder named images, + /// the path will be /images/folder. + /// + public string? FolderPath + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("folderPath"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("folderPath", value); + } + } + + /// + /// Name of the asset. + /// + public string? Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("name"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("name", value); + } + } + + /// + /// Type of the asset. + /// + public ApiEnum? Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("type"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("type", value); + } + } + + /// + /// Date and time when the folder was last updated. The date and time is in ISO8601 + /// format. + /// + public System::DateTimeOffset? UpdatedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("updatedAt"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("updatedAt", value); + } + } + + /// + public override void Validate() + { + _ = this.CreatedAt; + _ = this.FolderID; + _ = this.FolderPath; + _ = this.Name; + this.Type?.Validate(); + _ = this.UpdatedAt; + } + + public Folder() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Folder(Folder folder) + : base(folder) { } +#pragma warning restore CS8618 + + public Folder(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Folder(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static Folder FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class FolderFromRaw : IFromRawJson +{ + /// + public Folder FromRawUnchecked(IReadOnlyDictionary rawData) => + Folder.FromRawUnchecked(rawData); +} + +/// +/// Type of the asset. +/// +[JsonConverter(typeof(FolderTypeConverter))] +public enum FolderType +{ + Folder, +} + +sealed class FolderTypeConverter : JsonConverter +{ + public override FolderType Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "folder" => FolderType.Folder, + _ => (FolderType)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + FolderType value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + FolderType.Folder => "folder", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} diff --git a/src/ImageKit/Models/Files/Metadata/MetadataGetFromUrlParams.cs b/src/ImageKit/Models/Files/Metadata/MetadataGetFromUrlParams.cs new file mode 100644 index 00000000..9b008d54 --- /dev/null +++ b/src/ImageKit/Models/Files/Metadata/MetadataGetFromUrlParams.cs @@ -0,0 +1,117 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using ImageKit.Core; + +namespace ImageKit.Models.Files.Metadata; + +/// +/// Get image EXIF, pHash, and other metadata from ImageKit.io powered remote URL +/// using this API. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class MetadataGetFromUrlParams : ParamsBase +{ + /// + /// Should be a valid file URL. It should be accessible using your ImageKit.io + /// account. + /// + public required string UrlValue + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNotNullClass("url"); + } + init { this._rawQueryData.Set("url", value); } + } + + public MetadataGetFromUrlParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MetadataGetFromUrlParams(MetadataGetFromUrlParams metadataGetFromUrlParams) + : base(metadataGetFromUrlParams) { } +#pragma warning restore CS8618 + + public MetadataGetFromUrlParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MetadataGetFromUrlParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } +#pragma warning restore CS8618 + + /// + public static MetadataGetFromUrlParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(MetadataGetFromUrlParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/v1/metadata") + { + Query = this.QueryString(options), + }.Uri; + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/ImageKit/Models/Files/Metadata/MetadataGetParams.cs b/src/ImageKit/Models/Files/Metadata/MetadataGetParams.cs new file mode 100644 index 00000000..e02fd2f2 --- /dev/null +++ b/src/ImageKit/Models/Files/Metadata/MetadataGetParams.cs @@ -0,0 +1,116 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using ImageKit.Core; + +namespace ImageKit.Models.Files.Metadata; + +/// +/// You can programmatically get image EXIF, pHash, and other metadata for uploaded +/// files in the ImageKit.io media library using this API. +/// +/// You can also get the metadata in upload API response by passing `metadata` +/// in `responseFields` parameter. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class MetadataGetParams : ParamsBase +{ + public string? FileID { get; init; } + + public MetadataGetParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MetadataGetParams(MetadataGetParams metadataGetParams) + : base(metadataGetParams) + { + this.FileID = metadataGetParams.FileID; + } +#pragma warning restore CS8618 + + public MetadataGetParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MetadataGetParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } +#pragma warning restore CS8618 + + /// + public static MetadataGetParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["FileID"] = this.FileID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(MetadataGetParams? other) + { + if (other == null) + { + return false; + } + return (this.FileID?.Equals(other.FileID) ?? other.FileID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder( + options.BaseUrl.ToString().TrimEnd('/') + + string.Format("/v1/files/{0}/metadata", this.FileID) + ) + { + Query = this.QueryString(options), + }.Uri; + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/ImageKit/Models/Files/UpdateFileRequest.cs b/src/ImageKit/Models/Files/UpdateFileRequest.cs new file mode 100644 index 00000000..7ff9612f --- /dev/null +++ b/src/ImageKit/Models/Files/UpdateFileRequest.cs @@ -0,0 +1,959 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; +using ImageKit.Exceptions; +using System = System; + +namespace ImageKit.Models.Files; + +/// +/// Schema for update file update request. +/// +[JsonConverter(typeof(UpdateFileRequestConverter))] +public record class UpdateFileRequest : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public UpdateFileRequest(UpdateFileDetails value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UpdateFileRequest(ChangePublicationStatus value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UpdateFileRequest(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDetails(out var value)) { + /// // `value` is of type `UpdateFileDetails` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDetails([NotNullWhen(true)] out UpdateFileDetails? value) + { + value = this.Value as UpdateFileDetails; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickChangePublicationStatus(out var value)) { + /// // `value` is of type `ChangePublicationStatus` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickChangePublicationStatus( + [NotNullWhen(true)] out ChangePublicationStatus? value + ) + { + value = this.Value as ChangePublicationStatus; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (UpdateFileDetails value) => {...}, + /// (ChangePublicationStatus value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action details, + System::Action changePublicationStatus + ) + { + switch (this.Value) + { + case UpdateFileDetails value: + details(value); + break; + case ChangePublicationStatus value: + changePublicationStatus(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of UpdateFileRequest" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (UpdateFileDetails value) => {...}, + /// (ChangePublicationStatus value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func details, + System::Func changePublicationStatus + ) + { + return this.Value switch + { + UpdateFileDetails value => details(value), + ChangePublicationStatus value => changePublicationStatus(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of UpdateFileRequest" + ), + }; + } + + public static implicit operator UpdateFileRequest(UpdateFileDetails value) => new(value); + + public static implicit operator UpdateFileRequest(ChangePublicationStatus value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of UpdateFileRequest" + ); + } + this.Switch( + (details) => details.Validate(), + (changePublicationStatus) => changePublicationStatus.Validate() + ); + } + + public virtual bool Equals(UpdateFileRequest? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class UpdateFileRequestConverter : JsonConverter +{ + public override UpdateFileRequest? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + UpdateFileRequest value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class UpdateFileDetails : JsonModel +{ + /// + /// Define an important area in the image in the format `x,y,width,height` e.g. + /// `10,10,100,100`. Send `null` to unset this value. + /// + public string? CustomCoordinates + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("customCoordinates"); + } + init { this._rawData.Set("customCoordinates", value); } + } + + /// + /// A key-value data to be associated with the asset. To unset a key, send `null` + /// value for that key. Before setting any custom metadata on an asset you have + /// to create the field using custom metadata fields API. + /// + public IReadOnlyDictionary? CustomMetadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>( + "customMetadata" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "customMetadata", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + + /// + /// Optional text to describe the contents of the file. + /// + public string? Description + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("description"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("description", value); + } + } + + /// + /// Array of extensions to be applied to the asset. Each extension can be configured + /// with specific parameters based on the extension type. + /// + public IReadOnlyList? Extensions + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>( + "extensions" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "extensions", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// An array of AITags associated with the file that you want to remove, e.g. + /// `["car", "vehicle", "motorsports"]`. + /// + /// If you want to remove all AITags associated with the file, send a string + /// - "all". + /// + /// Note: The remove operation for `AITags` executes before any of the `extensions` + /// are processed. + /// + public RemoveAITags? RemoveAITags + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("removeAITags"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("removeAITags", value); + } + } + + /// + /// An array of tags associated with the file, such as `["tag1", "tag2"]`. Send + /// `null` to unset all tags associated with the file. + /// + public IReadOnlyList? Tags + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>("tags"); + } + init + { + this._rawData.Set?>( + "tags", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// The final status of extensions after they have completed execution will be + /// delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + /// about the webhook payload structure. + /// + public string? WebhookUrl + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("webhookUrl"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("webhookUrl", value); + } + } + + /// + public override void Validate() + { + _ = this.CustomCoordinates; + _ = this.CustomMetadata; + _ = this.Description; + foreach (var item in this.Extensions ?? []) + { + item.Validate(); + } + this.RemoveAITags?.Validate(); + _ = this.Tags; + _ = this.WebhookUrl; + } + + public UpdateFileDetails() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UpdateFileDetails(UpdateFileDetails updateFileDetails) + : base(updateFileDetails) { } +#pragma warning restore CS8618 + + public UpdateFileDetails(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UpdateFileDetails(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UpdateFileDetails FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UpdateFileDetailsFromRaw : IFromRawJson +{ + /// + public UpdateFileDetails FromRawUnchecked(IReadOnlyDictionary rawData) => + UpdateFileDetails.FromRawUnchecked(rawData); +} + +/// +/// An array of AITags associated with the file that you want to remove, e.g. `["car", +/// "vehicle", "motorsports"]`. +/// +/// If you want to remove all AITags associated with the file, send a string +/// - "all". +/// +/// Note: The remove operation for `AITags` executes before any of the `extensions` +/// are processed. +/// +[JsonConverter(typeof(RemoveAITagsConverter))] +public record class RemoveAITags : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public RemoveAITags(IReadOnlyList value, JsonElement? element = null) + { + this.Value = ImmutableArray.ToImmutableArray(value); + this._element = element; + } + + public RemoveAITags(UnionMember1 value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public RemoveAITags(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickStrings(out var value)) { + /// // `value` is of type `IReadOnlyList` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickStrings([NotNullWhen(true)] out IReadOnlyList? value) + { + value = this.Value as IReadOnlyList; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickAll(out var value)) { + /// // `value` is of type `UnionMember1` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickAll([NotNullWhen(true)] out UnionMember1? value) + { + value = this.Value as UnionMember1; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (IReadOnlyList value) => {...}, + /// (UnionMember1 value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action> strings, + System::Action all + ) + { + switch (this.Value) + { + case IReadOnlyList value: + strings(value); + break; + case UnionMember1 value: + all(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of RemoveAITags" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (IReadOnlyList value) => {...}, + /// (UnionMember1 value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func, T> strings, + System::Func all + ) + { + return this.Value switch + { + IReadOnlyList value => strings(value), + UnionMember1 value => all(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of RemoveAITags" + ), + }; + } + + public static implicit operator RemoveAITags(List value) => + new((IReadOnlyList)value); + + public static implicit operator RemoveAITags(UnionMember1 value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of RemoveAITags" + ); + } + this.Switch((_) => { }, (all) => all.Validate()); + } + + public virtual bool Equals(RemoveAITags? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class RemoveAITagsConverter : JsonConverter +{ + public override RemoveAITags? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize>(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + RemoveAITags value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(UnionMember1Converter))] +public record class UnionMember1 +{ + public JsonElement Element { get; private init; } + + public UnionMember1() + { + Element = JsonSerializer.SerializeToElement("all"); + } + + internal UnionMember1(JsonElement element) + { + Element = element; + } + + /// + /// Validates that the instance's underlying value is the expected constant. + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public void Validate() + { + if (this != new UnionMember1()) + { + throw new ImageKitInvalidDataException("Invalid value given for 'UnionMember1'"); + } + } + + public override int GetHashCode() + { + return 0; + } + + public virtual bool Equals(UnionMember1? other) + { + if (other == null) + { + return false; + } + + return JsonElement.DeepEquals(this.Element, other.Element); + } +} + +class UnionMember1Converter : JsonConverter +{ + public override UnionMember1? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write( + Utf8JsonWriter writer, + UnionMember1 value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Element, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class ChangePublicationStatus : JsonModel +{ + /// + /// Configure the publication status of a file and its versions. + /// + public Publish? Publish + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("publish"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("publish", value); + } + } + + /// + public override void Validate() + { + this.Publish?.Validate(); + } + + public ChangePublicationStatus() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ChangePublicationStatus(ChangePublicationStatus changePublicationStatus) + : base(changePublicationStatus) { } +#pragma warning restore CS8618 + + public ChangePublicationStatus(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ChangePublicationStatus(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ChangePublicationStatus FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ChangePublicationStatusFromRaw : IFromRawJson +{ + /// + public ChangePublicationStatus FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ChangePublicationStatus.FromRawUnchecked(rawData); +} + +/// +/// Configure the publication status of a file and its versions. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Publish : JsonModel +{ + /// + /// Set to `true` to publish the file. Set to `false` to unpublish the file. + /// + public required bool IsPublished + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("isPublished"); + } + init { this._rawData.Set("isPublished", value); } + } + + /// + /// Set to `true` to publish/unpublish all versions of the file. Set to `false` + /// to publish/unpublish only the current version of the file. + /// + public bool? IncludeFileVersions + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("includeFileVersions"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("includeFileVersions", value); + } + } + + /// + public override void Validate() + { + _ = this.IsPublished; + _ = this.IncludeFileVersions; + } + + public Publish() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Publish(Publish publish) + : base(publish) { } +#pragma warning restore CS8618 + + public Publish(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Publish(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static Publish FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public Publish(bool isPublished) + : this() + { + this.IsPublished = isPublished; + } +} + +class PublishFromRaw : IFromRawJson +{ + /// + public Publish FromRawUnchecked(IReadOnlyDictionary rawData) => + Publish.FromRawUnchecked(rawData); +} diff --git a/src/ImageKit/Models/Files/Versions/VersionDeleteParams.cs b/src/ImageKit/Models/Files/Versions/VersionDeleteParams.cs new file mode 100644 index 00000000..89f04cdb --- /dev/null +++ b/src/ImageKit/Models/Files/Versions/VersionDeleteParams.cs @@ -0,0 +1,119 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using ImageKit.Core; + +namespace ImageKit.Models.Files.Versions; + +/// +/// This API deletes a non-current file version permanently. The API returns an empty response. +/// +/// Note: If you want to delete all versions of a file, use the delete file API. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class VersionDeleteParams : ParamsBase +{ + public required string FileID { get; init; } + + public string? VersionID { get; init; } + + public VersionDeleteParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public VersionDeleteParams(VersionDeleteParams versionDeleteParams) + : base(versionDeleteParams) + { + this.FileID = versionDeleteParams.FileID; + this.VersionID = versionDeleteParams.VersionID; + } +#pragma warning restore CS8618 + + public VersionDeleteParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + VersionDeleteParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } +#pragma warning restore CS8618 + + /// + public static VersionDeleteParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["FileID"] = this.FileID, + ["VersionID"] = this.VersionID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(VersionDeleteParams? other) + { + if (other == null) + { + return false; + } + return this.FileID.Equals(other.FileID) + && (this.VersionID?.Equals(other.VersionID) ?? other.VersionID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder( + options.BaseUrl.ToString().TrimEnd('/') + + string.Format("/v1/files/{0}/versions/{1}", this.FileID, this.VersionID) + ) + { + Query = this.QueryString(options), + }.Uri; + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/ImageKit/Models/Files/Versions/VersionDeleteResponse.cs b/src/ImageKit/Models/Files/Versions/VersionDeleteResponse.cs new file mode 100644 index 00000000..c1537f0e --- /dev/null +++ b/src/ImageKit/Models/Files/Versions/VersionDeleteResponse.cs @@ -0,0 +1,52 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; + +namespace ImageKit.Models.Files.Versions; + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class VersionDeleteResponse : JsonModel +{ + /// + public override void Validate() { } + + public VersionDeleteResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public VersionDeleteResponse(VersionDeleteResponse versionDeleteResponse) + : base(versionDeleteResponse) { } +#pragma warning restore CS8618 + + public VersionDeleteResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + VersionDeleteResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static VersionDeleteResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class VersionDeleteResponseFromRaw : IFromRawJson +{ + /// + public VersionDeleteResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) => VersionDeleteResponse.FromRawUnchecked(rawData); +} diff --git a/src/ImageKit/Models/Files/Versions/VersionGetParams.cs b/src/ImageKit/Models/Files/Versions/VersionGetParams.cs new file mode 100644 index 00000000..5af86762 --- /dev/null +++ b/src/ImageKit/Models/Files/Versions/VersionGetParams.cs @@ -0,0 +1,117 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using ImageKit.Core; + +namespace ImageKit.Models.Files.Versions; + +/// +/// This API returns an object with details or attributes of a file version. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class VersionGetParams : ParamsBase +{ + public required string FileID { get; init; } + + public string? VersionID { get; init; } + + public VersionGetParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public VersionGetParams(VersionGetParams versionGetParams) + : base(versionGetParams) + { + this.FileID = versionGetParams.FileID; + this.VersionID = versionGetParams.VersionID; + } +#pragma warning restore CS8618 + + public VersionGetParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + VersionGetParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } +#pragma warning restore CS8618 + + /// + public static VersionGetParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["FileID"] = this.FileID, + ["VersionID"] = this.VersionID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(VersionGetParams? other) + { + if (other == null) + { + return false; + } + return this.FileID.Equals(other.FileID) + && (this.VersionID?.Equals(other.VersionID) ?? other.VersionID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder( + options.BaseUrl.ToString().TrimEnd('/') + + string.Format("/v1/files/{0}/versions/{1}", this.FileID, this.VersionID) + ) + { + Query = this.QueryString(options), + }.Uri; + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/ImageKit/Models/Files/Versions/VersionListParams.cs b/src/ImageKit/Models/Files/Versions/VersionListParams.cs new file mode 100644 index 00000000..632da287 --- /dev/null +++ b/src/ImageKit/Models/Files/Versions/VersionListParams.cs @@ -0,0 +1,112 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using ImageKit.Core; + +namespace ImageKit.Models.Files.Versions; + +/// +/// This API returns details of all versions of a file. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class VersionListParams : ParamsBase +{ + public string? FileID { get; init; } + + public VersionListParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public VersionListParams(VersionListParams versionListParams) + : base(versionListParams) + { + this.FileID = versionListParams.FileID; + } +#pragma warning restore CS8618 + + public VersionListParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + VersionListParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } +#pragma warning restore CS8618 + + /// + public static VersionListParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["FileID"] = this.FileID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(VersionListParams? other) + { + if (other == null) + { + return false; + } + return (this.FileID?.Equals(other.FileID) ?? other.FileID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder( + options.BaseUrl.ToString().TrimEnd('/') + + string.Format("/v1/files/{0}/versions", this.FileID) + ) + { + Query = this.QueryString(options), + }.Uri; + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/ImageKit/Models/Files/Versions/VersionRestoreParams.cs b/src/ImageKit/Models/Files/Versions/VersionRestoreParams.cs new file mode 100644 index 00000000..cabd0070 --- /dev/null +++ b/src/ImageKit/Models/Files/Versions/VersionRestoreParams.cs @@ -0,0 +1,117 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using ImageKit.Core; + +namespace ImageKit.Models.Files.Versions; + +/// +/// This API restores a file version as the current file version. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class VersionRestoreParams : ParamsBase +{ + public required string FileID { get; init; } + + public string? VersionID { get; init; } + + public VersionRestoreParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public VersionRestoreParams(VersionRestoreParams versionRestoreParams) + : base(versionRestoreParams) + { + this.FileID = versionRestoreParams.FileID; + this.VersionID = versionRestoreParams.VersionID; + } +#pragma warning restore CS8618 + + public VersionRestoreParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + VersionRestoreParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } +#pragma warning restore CS8618 + + /// + public static VersionRestoreParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["FileID"] = this.FileID, + ["VersionID"] = this.VersionID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(VersionRestoreParams? other) + { + if (other == null) + { + return false; + } + return this.FileID.Equals(other.FileID) + && (this.VersionID?.Equals(other.VersionID) ?? other.VersionID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder( + options.BaseUrl.ToString().TrimEnd('/') + + string.Format("/v1/files/{0}/versions/{1}/restore", this.FileID, this.VersionID) + ) + { + Query = this.QueryString(options), + }.Uri; + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/ImageKit/Models/Folders/FolderCopyParams.cs b/src/ImageKit/Models/Folders/FolderCopyParams.cs new file mode 100644 index 00000000..f2c61c8b --- /dev/null +++ b/src/ImageKit/Models/Folders/FolderCopyParams.cs @@ -0,0 +1,183 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using ImageKit.Core; +using Text = System.Text; + +namespace ImageKit.Models.Folders; + +/// +/// This will copy one folder into another. The selected folder, its nested folders, +/// files, and their versions (in `includeVersions` is set to true) are copied in +/// this operation. Note: If any file at the destination has the same name as the +/// source file, then the source file and its versions will be appended to the destination +/// file version history. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class FolderCopyParams : ParamsBase +{ + readonly JsonDictionary _rawBodyData = new(); + public IReadOnlyDictionary RawBodyData + { + get { return this._rawBodyData.Freeze(); } + } + + /// + /// Full path to the destination folder where you want to copy the source folder + /// into. + /// + public required string DestinationPath + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullClass("destinationPath"); + } + init { this._rawBodyData.Set("destinationPath", value); } + } + + /// + /// The full path to the source folder you want to copy. + /// + public required string SourceFolderPath + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullClass("sourceFolderPath"); + } + init { this._rawBodyData.Set("sourceFolderPath", value); } + } + + /// + /// Option to copy all versions of files that are nested inside the selected folder. + /// By default, only the current version of each file will be copied. When set + /// to true, all versions of each file will be copied. Default value - `false`. + /// + public bool? IncludeVersions + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableStruct("includeVersions"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("includeVersions", value); + } + } + + public FolderCopyParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public FolderCopyParams(FolderCopyParams folderCopyParams) + : base(folderCopyParams) + { + this._rawBodyData = new(folderCopyParams._rawBodyData); + } +#pragma warning restore CS8618 + + public FolderCopyParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FolderCopyParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData, + FrozenDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } +#pragma warning restore CS8618 + + /// + public static FolderCopyParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData), + FrozenDictionary.ToFrozenDictionary(rawBodyData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(FolderCopyParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/v1/bulkJobs/copyFolder") + { + Query = this.QueryString(options), + }.Uri; + } + + internal override HttpContent? BodyContent() + { + return new StringContent( + JsonSerializer.Serialize(this.RawBodyData, ModelBase.SerializerOptions), + Text::Encoding.UTF8, + "application/json" + ); + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/ImageKit/Models/Folders/FolderCopyResponse.cs b/src/ImageKit/Models/Folders/FolderCopyResponse.cs new file mode 100644 index 00000000..8840cd5f --- /dev/null +++ b/src/ImageKit/Models/Folders/FolderCopyResponse.cs @@ -0,0 +1,78 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; + +namespace ImageKit.Models.Folders; + +/// +/// Job submitted successfully. A `jobId` will be returned. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class FolderCopyResponse : JsonModel +{ + /// + /// Unique identifier of the bulk job. This can be used to check the status of + /// the bulk job. + /// + public required string JobID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("jobId"); + } + init { this._rawData.Set("jobId", value); } + } + + /// + public override void Validate() + { + _ = this.JobID; + } + + public FolderCopyResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public FolderCopyResponse(FolderCopyResponse folderCopyResponse) + : base(folderCopyResponse) { } +#pragma warning restore CS8618 + + public FolderCopyResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FolderCopyResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static FolderCopyResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public FolderCopyResponse(string jobID) + : this() + { + this.JobID = jobID; + } +} + +class FolderCopyResponseFromRaw : IFromRawJson +{ + /// + public FolderCopyResponse FromRawUnchecked(IReadOnlyDictionary rawData) => + FolderCopyResponse.FromRawUnchecked(rawData); +} diff --git a/src/ImageKit/Models/Folders/FolderCreateParams.cs b/src/ImageKit/Models/Folders/FolderCreateParams.cs new file mode 100644 index 00000000..7e5fd4e0 --- /dev/null +++ b/src/ImageKit/Models/Folders/FolderCreateParams.cs @@ -0,0 +1,166 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using ImageKit.Core; +using Text = System.Text; + +namespace ImageKit.Models.Folders; + +/// +/// This will create a new folder. You can specify the folder name and location of +/// the parent folder where this new folder should be created. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class FolderCreateParams : ParamsBase +{ + readonly JsonDictionary _rawBodyData = new(); + public IReadOnlyDictionary RawBodyData + { + get { return this._rawBodyData.Freeze(); } + } + + /// + /// The folder will be created with this name. + /// + /// All characters except alphabets and numbers (inclusive of unicode letters, + /// marks, and numerals in other languages) will be replaced by an underscore + /// i.e. `_`. + /// + public required string FolderName + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullClass("folderName"); + } + init { this._rawBodyData.Set("folderName", value); } + } + + /// + /// The folder where the new folder should be created, for root use `/` else + /// the path e.g. `containing/folder/`. + /// + /// Note: If any folder(s) is not present in the parentFolderPath parameter, + /// it will be automatically created. For example, if you pass `/product/images/summer`, + /// then `product`, `images`, and `summer` folders will be created if they don't + /// already exist. + /// + public required string ParentFolderPath + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullClass("parentFolderPath"); + } + init { this._rawBodyData.Set("parentFolderPath", value); } + } + + public FolderCreateParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public FolderCreateParams(FolderCreateParams folderCreateParams) + : base(folderCreateParams) + { + this._rawBodyData = new(folderCreateParams._rawBodyData); + } +#pragma warning restore CS8618 + + public FolderCreateParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FolderCreateParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData, + FrozenDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } +#pragma warning restore CS8618 + + /// + public static FolderCreateParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData), + FrozenDictionary.ToFrozenDictionary(rawBodyData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(FolderCreateParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/v1/folder") + { + Query = this.QueryString(options), + }.Uri; + } + + internal override HttpContent? BodyContent() + { + return new StringContent( + JsonSerializer.Serialize(this.RawBodyData, ModelBase.SerializerOptions), + Text::Encoding.UTF8, + "application/json" + ); + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/ImageKit/Models/Folders/FolderCreateResponse.cs b/src/ImageKit/Models/Folders/FolderCreateResponse.cs new file mode 100644 index 00000000..d03e0ba2 --- /dev/null +++ b/src/ImageKit/Models/Folders/FolderCreateResponse.cs @@ -0,0 +1,52 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; + +namespace ImageKit.Models.Folders; + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class FolderCreateResponse : JsonModel +{ + /// + public override void Validate() { } + + public FolderCreateResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public FolderCreateResponse(FolderCreateResponse folderCreateResponse) + : base(folderCreateResponse) { } +#pragma warning restore CS8618 + + public FolderCreateResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FolderCreateResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static FolderCreateResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class FolderCreateResponseFromRaw : IFromRawJson +{ + /// + public FolderCreateResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) => FolderCreateResponse.FromRawUnchecked(rawData); +} diff --git a/src/ImageKit/Models/Folders/FolderDeleteParams.cs b/src/ImageKit/Models/Folders/FolderDeleteParams.cs new file mode 100644 index 00000000..e4767eb2 --- /dev/null +++ b/src/ImageKit/Models/Folders/FolderDeleteParams.cs @@ -0,0 +1,143 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using ImageKit.Core; +using Text = System.Text; + +namespace ImageKit.Models.Folders; + +/// +/// This will delete a folder and all its contents permanently. The API returns an +/// empty response. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class FolderDeleteParams : ParamsBase +{ + readonly JsonDictionary _rawBodyData = new(); + public IReadOnlyDictionary RawBodyData + { + get { return this._rawBodyData.Freeze(); } + } + + /// + /// Full path to the folder you want to delete. For example `/folder/to/delete/`. + /// + public required string FolderPath + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullClass("folderPath"); + } + init { this._rawBodyData.Set("folderPath", value); } + } + + public FolderDeleteParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public FolderDeleteParams(FolderDeleteParams folderDeleteParams) + : base(folderDeleteParams) + { + this._rawBodyData = new(folderDeleteParams._rawBodyData); + } +#pragma warning restore CS8618 + + public FolderDeleteParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FolderDeleteParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData, + FrozenDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } +#pragma warning restore CS8618 + + /// + public static FolderDeleteParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData), + FrozenDictionary.ToFrozenDictionary(rawBodyData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(FolderDeleteParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/v1/folder") + { + Query = this.QueryString(options), + }.Uri; + } + + internal override HttpContent? BodyContent() + { + return new StringContent( + JsonSerializer.Serialize(this.RawBodyData, ModelBase.SerializerOptions), + Text::Encoding.UTF8, + "application/json" + ); + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/ImageKit/Models/Folders/FolderDeleteResponse.cs b/src/ImageKit/Models/Folders/FolderDeleteResponse.cs new file mode 100644 index 00000000..08e19303 --- /dev/null +++ b/src/ImageKit/Models/Folders/FolderDeleteResponse.cs @@ -0,0 +1,52 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; + +namespace ImageKit.Models.Folders; + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class FolderDeleteResponse : JsonModel +{ + /// + public override void Validate() { } + + public FolderDeleteResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public FolderDeleteResponse(FolderDeleteResponse folderDeleteResponse) + : base(folderDeleteResponse) { } +#pragma warning restore CS8618 + + public FolderDeleteResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FolderDeleteResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static FolderDeleteResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class FolderDeleteResponseFromRaw : IFromRawJson +{ + /// + public FolderDeleteResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) => FolderDeleteResponse.FromRawUnchecked(rawData); +} diff --git a/src/ImageKit/Models/Folders/FolderMoveParams.cs b/src/ImageKit/Models/Folders/FolderMoveParams.cs new file mode 100644 index 00000000..c4f5833d --- /dev/null +++ b/src/ImageKit/Models/Folders/FolderMoveParams.cs @@ -0,0 +1,159 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using ImageKit.Core; +using Text = System.Text; + +namespace ImageKit.Models.Folders; + +/// +/// This will move one folder into another. The selected folder, its nested folders, +/// files, and their versions are moved in this operation. Note: If any file at the +/// destination has the same name as the source file, then the source file and its +/// versions will be appended to the destination file version history. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class FolderMoveParams : ParamsBase +{ + readonly JsonDictionary _rawBodyData = new(); + public IReadOnlyDictionary RawBodyData + { + get { return this._rawBodyData.Freeze(); } + } + + /// + /// Full path to the destination folder where you want to move the source folder + /// into. + /// + public required string DestinationPath + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullClass("destinationPath"); + } + init { this._rawBodyData.Set("destinationPath", value); } + } + + /// + /// The full path to the source folder you want to move. + /// + public required string SourceFolderPath + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullClass("sourceFolderPath"); + } + init { this._rawBodyData.Set("sourceFolderPath", value); } + } + + public FolderMoveParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public FolderMoveParams(FolderMoveParams folderMoveParams) + : base(folderMoveParams) + { + this._rawBodyData = new(folderMoveParams._rawBodyData); + } +#pragma warning restore CS8618 + + public FolderMoveParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FolderMoveParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData, + FrozenDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } +#pragma warning restore CS8618 + + /// + public static FolderMoveParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData), + FrozenDictionary.ToFrozenDictionary(rawBodyData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(FolderMoveParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/v1/bulkJobs/moveFolder") + { + Query = this.QueryString(options), + }.Uri; + } + + internal override HttpContent? BodyContent() + { + return new StringContent( + JsonSerializer.Serialize(this.RawBodyData, ModelBase.SerializerOptions), + Text::Encoding.UTF8, + "application/json" + ); + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/ImageKit/Models/Folders/FolderMoveResponse.cs b/src/ImageKit/Models/Folders/FolderMoveResponse.cs new file mode 100644 index 00000000..e9fc02c4 --- /dev/null +++ b/src/ImageKit/Models/Folders/FolderMoveResponse.cs @@ -0,0 +1,78 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; + +namespace ImageKit.Models.Folders; + +/// +/// Job submitted successfully. A `jobId` will be returned. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class FolderMoveResponse : JsonModel +{ + /// + /// Unique identifier of the bulk job. This can be used to check the status of + /// the bulk job. + /// + public required string JobID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("jobId"); + } + init { this._rawData.Set("jobId", value); } + } + + /// + public override void Validate() + { + _ = this.JobID; + } + + public FolderMoveResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public FolderMoveResponse(FolderMoveResponse folderMoveResponse) + : base(folderMoveResponse) { } +#pragma warning restore CS8618 + + public FolderMoveResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FolderMoveResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static FolderMoveResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public FolderMoveResponse(string jobID) + : this() + { + this.JobID = jobID; + } +} + +class FolderMoveResponseFromRaw : IFromRawJson +{ + /// + public FolderMoveResponse FromRawUnchecked(IReadOnlyDictionary rawData) => + FolderMoveResponse.FromRawUnchecked(rawData); +} diff --git a/src/ImageKit/Models/Folders/FolderRenameParams.cs b/src/ImageKit/Models/Folders/FolderRenameParams.cs new file mode 100644 index 00000000..3dcd63e1 --- /dev/null +++ b/src/ImageKit/Models/Folders/FolderRenameParams.cs @@ -0,0 +1,196 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using ImageKit.Core; +using Text = System.Text; + +namespace ImageKit.Models.Folders; + +/// +/// This API allows you to rename an existing folder. The folder and all its nested +/// assets and sub-folders will remain unchanged, but their paths will be updated +/// to reflect the new folder name. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class FolderRenameParams : ParamsBase +{ + readonly JsonDictionary _rawBodyData = new(); + public IReadOnlyDictionary RawBodyData + { + get { return this._rawBodyData.Freeze(); } + } + + /// + /// The full path to the folder you want to rename. + /// + public required string FolderPath + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullClass("folderPath"); + } + init { this._rawBodyData.Set("folderPath", value); } + } + + /// + /// The new name for the folder. + /// + /// All characters except alphabets and numbers (inclusive of unicode letters, + /// marks, and numerals in other languages) and `-` will be replaced by an underscore + /// i.e. `_`. + /// + public required string NewFolderName + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullClass("newFolderName"); + } + init { this._rawBodyData.Set("newFolderName", value); } + } + + /// + /// Option to purge cache for the old nested files and their versions' URLs. + /// + /// When set to true, it will internally issue a purge cache request on + /// CDN to remove the cached content of the old nested files and their versions. + /// There will only be one purge request for all the nested files, which will + /// be counted against your monthly purge quota. + /// + /// Note: A purge cache request will be issued against `https://ik.imagekit.io/old/folder/path*` + /// (with a wildcard at the end). This will remove all nested files, their versions' + /// URLs, and any transformations made using query parameters on these files or + /// their versions. However, the cache for file transformations made using path + /// parameters will persist. You can purge them using the purge API. For more + /// details, refer to the purge API documentation. + /// + /// Default value - `false` + /// + public bool? PurgeCache + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableStruct("purgeCache"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("purgeCache", value); + } + } + + public FolderRenameParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public FolderRenameParams(FolderRenameParams folderRenameParams) + : base(folderRenameParams) + { + this._rawBodyData = new(folderRenameParams._rawBodyData); + } +#pragma warning restore CS8618 + + public FolderRenameParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FolderRenameParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData, + FrozenDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } +#pragma warning restore CS8618 + + /// + public static FolderRenameParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData), + FrozenDictionary.ToFrozenDictionary(rawBodyData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(FolderRenameParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/v1/bulkJobs/renameFolder") + { + Query = this.QueryString(options), + }.Uri; + } + + internal override HttpContent? BodyContent() + { + return new StringContent( + JsonSerializer.Serialize(this.RawBodyData, ModelBase.SerializerOptions), + Text::Encoding.UTF8, + "application/json" + ); + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/ImageKit/Models/Folders/FolderRenameResponse.cs b/src/ImageKit/Models/Folders/FolderRenameResponse.cs new file mode 100644 index 00000000..c511f3c3 --- /dev/null +++ b/src/ImageKit/Models/Folders/FolderRenameResponse.cs @@ -0,0 +1,79 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; + +namespace ImageKit.Models.Folders; + +/// +/// Job submitted successfully. A `jobId` will be returned. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class FolderRenameResponse : JsonModel +{ + /// + /// Unique identifier of the bulk job. This can be used to check the status of + /// the bulk job. + /// + public required string JobID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("jobId"); + } + init { this._rawData.Set("jobId", value); } + } + + /// + public override void Validate() + { + _ = this.JobID; + } + + public FolderRenameResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public FolderRenameResponse(FolderRenameResponse folderRenameResponse) + : base(folderRenameResponse) { } +#pragma warning restore CS8618 + + public FolderRenameResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FolderRenameResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static FolderRenameResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public FolderRenameResponse(string jobID) + : this() + { + this.JobID = jobID; + } +} + +class FolderRenameResponseFromRaw : IFromRawJson +{ + /// + public FolderRenameResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) => FolderRenameResponse.FromRawUnchecked(rawData); +} diff --git a/src/ImageKit/Models/Folders/Job/JobGetParams.cs b/src/ImageKit/Models/Folders/Job/JobGetParams.cs new file mode 100644 index 00000000..41e49a54 --- /dev/null +++ b/src/ImageKit/Models/Folders/Job/JobGetParams.cs @@ -0,0 +1,111 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using ImageKit.Core; + +namespace ImageKit.Models.Folders.Job; + +/// +/// This API returns the status of a bulk job like copy and move folder operations. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class JobGetParams : ParamsBase +{ + public string? JobID { get; init; } + + public JobGetParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public JobGetParams(JobGetParams jobGetParams) + : base(jobGetParams) + { + this.JobID = jobGetParams.JobID; + } +#pragma warning restore CS8618 + + public JobGetParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + JobGetParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } +#pragma warning restore CS8618 + + /// + public static JobGetParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["JobID"] = this.JobID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(JobGetParams? other) + { + if (other == null) + { + return false; + } + return (this.JobID?.Equals(other.JobID) ?? other.JobID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder( + options.BaseUrl.ToString().TrimEnd('/') + string.Format("/v1/bulkJobs/{0}", this.JobID) + ) + { + Query = this.QueryString(options), + }.Uri; + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/ImageKit/Models/Folders/Job/JobGetResponse.cs b/src/ImageKit/Models/Folders/Job/JobGetResponse.cs new file mode 100644 index 00000000..0dfa7b74 --- /dev/null +++ b/src/ImageKit/Models/Folders/Job/JobGetResponse.cs @@ -0,0 +1,237 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; +using ImageKit.Exceptions; +using System = System; + +namespace ImageKit.Models.Folders.Job; + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class JobGetResponse : JsonModel +{ + /// + /// Unique identifier of the bulk job. + /// + public string? JobID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("jobId"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("jobId", value); + } + } + + /// + /// Unique identifier of the purge request. This will be present only if `purgeCache` + /// is set to `true` in the rename folder API request. + /// + public string? PurgeRequestID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("purgeRequestId"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("purgeRequestId", value); + } + } + + /// + /// Status of the bulk job. + /// + public ApiEnum? Status + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("status"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("status", value); + } + } + + /// + /// Type of the bulk job. + /// + public ApiEnum? Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass< + ApiEnum + >("type"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("type", value); + } + } + + /// + public override void Validate() + { + _ = this.JobID; + _ = this.PurgeRequestID; + this.Status?.Validate(); + this.Type?.Validate(); + } + + public JobGetResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public JobGetResponse(JobGetResponse jobGetResponse) + : base(jobGetResponse) { } +#pragma warning restore CS8618 + + public JobGetResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + JobGetResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static JobGetResponse FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class JobGetResponseFromRaw : IFromRawJson +{ + /// + public JobGetResponse FromRawUnchecked(IReadOnlyDictionary rawData) => + JobGetResponse.FromRawUnchecked(rawData); +} + +/// +/// Status of the bulk job. +/// +[JsonConverter(typeof(StatusConverter))] +public enum Status +{ + Pending, + Completed, +} + +sealed class StatusConverter : JsonConverter +{ + public override Status Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "Pending" => Status.Pending, + "Completed" => Status.Completed, + _ => (Status)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Status value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + Status.Pending => "Pending", + Status.Completed => "Completed", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Type of the bulk job. +/// +[JsonConverter(typeof(TypeConverter))] +public enum Type +{ + CopyFolder, + MoveFolder, + RenameFolder, +} + +sealed class TypeConverter : JsonConverter +{ + public override global::ImageKit.Models.Folders.Job.Type Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "COPY_FOLDER" => global::ImageKit.Models.Folders.Job.Type.CopyFolder, + "MOVE_FOLDER" => global::ImageKit.Models.Folders.Job.Type.MoveFolder, + "RENAME_FOLDER" => global::ImageKit.Models.Folders.Job.Type.RenameFolder, + _ => (global::ImageKit.Models.Folders.Job.Type)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + global::ImageKit.Models.Folders.Job.Type value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + global::ImageKit.Models.Folders.Job.Type.CopyFolder => "COPY_FOLDER", + global::ImageKit.Models.Folders.Job.Type.MoveFolder => "MOVE_FOLDER", + global::ImageKit.Models.Folders.Job.Type.RenameFolder => "RENAME_FOLDER", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} diff --git a/src/ImageKit/Models/GetImageAttributesOptions.cs b/src/ImageKit/Models/GetImageAttributesOptions.cs new file mode 100644 index 00000000..72a8fbed --- /dev/null +++ b/src/ImageKit/Models/GetImageAttributesOptions.cs @@ -0,0 +1,527 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; + +namespace ImageKit.Models; + +/// +/// Options for generating responsive image attributes including `src`, `srcSet`, +/// and `sizes` for HTML `` elements. This schema extends `SrcOptions` to add +/// support for responsive image generation with breakpoints. +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class GetImageAttributesOptions : JsonModel +{ + /// + /// Accepts a relative or absolute path of the resource. If a relative path is + /// provided, it is appended to the `urlEndpoint`. If an absolute path is provided, + /// `urlEndpoint` is ignored. + /// + public required string Src + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("src"); + } + init { this._rawData.Set("src", value); } + } + + /// + /// Get your urlEndpoint from the [ImageKit dashboard](https://imagekit.io/dashboard/url-endpoints). + /// + public required string UrlEndpoint + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("urlEndpoint"); + } + init { this._rawData.Set("urlEndpoint", value); } + } + + /// + /// When you want the signed URL to expire, specified in seconds. If `expiresIn` + /// is anything above 0, the URL will always be signed even if `signed` is set + /// to false. If not specified and `signed` is `true`, the signed URL will not + /// expire (valid indefinitely). + /// + /// Example: Setting `expiresIn: 3600` will make the URL expire 1 hour from + /// generation time. After the expiry time, the signed URL will no longer be valid + /// and ImageKit will return a 401 Unauthorized status code. + /// + /// [Learn more](https://imagekit.io/docs/media-delivery-basic-security#how-to-generate-signed-urls). + /// + public double? ExpiresIn + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("expiresIn"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("expiresIn", value); + } + } + + /// + /// These are additional query parameters that you want to add to the final URL. + /// They can be any query parameters and not necessarily related to ImageKit. + /// This is especially useful if you want to add a versioning parameter to your + /// URLs. + /// + public IReadOnlyDictionary? QueryParameters + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>( + "queryParameters" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "queryParameters", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + + /// + /// Whether to sign the URL or not. Set this to `true` if you want to generate + /// a signed URL. If `signed` is `true` and `expiresIn` is not specified, the + /// signed URL will not expire (valid indefinitely). Note: If `expiresIn` is + /// set to any value above 0, the URL will always be signed regardless of this + /// setting. [Learn more](https://imagekit.io/docs/media-delivery-basic-security#how-to-generate-signed-urls). + /// + public bool? Signed + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("signed"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("signed", value); + } + } + + /// + /// An array of objects specifying the transformations to be applied in the URL. + /// If more than one transformation is specified, they are applied in the order + /// they are specified as chained transformations. See [Chained transformations](https://imagekit.io/docs/transformations#chained-transformations). + /// + public IReadOnlyList? Transformation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>( + "transformation" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "transformation", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// By default, the transformation string is added as a query parameter in the + /// URL, e.g., `?tr=w-100,h-100`. If you want to add the transformation string + /// in the path of the URL, set this to `path`. Learn more in the [Transformations + /// guide](https://imagekit.io/docs/transformations). + /// + public ApiEnum? TransformationPosition + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>( + "transformationPosition" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("transformationPosition", value); + } + } + + /// + /// Custom list of **device-width breakpoints** in pixels. These define common + /// screen widths for responsive image generation. + /// + /// Defaults to `[640, 750, 828, 1080, 1200, 1920, 2048, 3840]`. Sorted + /// automatically. + /// + public IReadOnlyList? DeviceBreakpoints + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>("deviceBreakpoints"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "deviceBreakpoints", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Custom list of **image-specific breakpoints** in pixels. Useful for generating + /// small variants (e.g., placeholders or thumbnails). + /// + /// Merged with `deviceBreakpoints` before calculating `srcSet`. Defaults + /// to `[16, 32, 48, 64, 96, 128, 256, 384]`. Sorted automatically. + /// + public IReadOnlyList? ImageBreakpoints + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>("imageBreakpoints"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "imageBreakpoints", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// The value for the HTML `sizes` attribute (e.g., `"100vw"` or `"(min-width:768px) + /// 50vw, 100vw"`). + /// + /// - If it includes one or more `vw` units, breakpoints smaller than the + /// corresponding percentage of the smallest device width are excluded. - If + /// it contains no `vw` units, the full breakpoint list is used. + /// + /// Enables a width-based strategy and generates `w` descriptors in `srcSet`. + /// + public string? Sizes + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("sizes"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("sizes", value); + } + } + + /// + /// The intended display width of the image in pixels, used **only when the `sizes` + /// attribute is not provided**. + /// + /// Triggers a DPR-based strategy (1x and 2x variants) and generates `x` + /// descriptors in `srcSet`. + /// + /// Ignored if `sizes` is present. + /// + public double? Width + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("width"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("width", value); + } + } + + public static implicit operator SrcOptions( + GetImageAttributesOptions getImageAttributesOptions + ) => + new() + { + Src = getImageAttributesOptions.Src, + UrlEndpoint = getImageAttributesOptions.UrlEndpoint, + ExpiresIn = getImageAttributesOptions.ExpiresIn, + QueryParameters = getImageAttributesOptions.QueryParameters, + Signed = getImageAttributesOptions.Signed, + Transformation = getImageAttributesOptions.Transformation, + TransformationPosition = getImageAttributesOptions.TransformationPosition, + }; + + /// + public override void Validate() + { + _ = this.Src; + _ = this.UrlEndpoint; + _ = this.ExpiresIn; + _ = this.QueryParameters; + _ = this.Signed; + foreach (var item in this.Transformation ?? []) + { + item.Validate(); + } + this.TransformationPosition?.Validate(); + _ = this.DeviceBreakpoints; + _ = this.ImageBreakpoints; + _ = this.Sizes; + _ = this.Width; + } + + public GetImageAttributesOptions() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GetImageAttributesOptions(GetImageAttributesOptions getImageAttributesOptions) + : base(getImageAttributesOptions) { } +#pragma warning restore CS8618 + + public GetImageAttributesOptions(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GetImageAttributesOptions(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GetImageAttributesOptions FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GetImageAttributesOptionsFromRaw : IFromRawJson +{ + /// + public GetImageAttributesOptions FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GetImageAttributesOptions.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class IntersectionMember1 : JsonModel +{ + /// + /// Custom list of **device-width breakpoints** in pixels. These define common + /// screen widths for responsive image generation. + /// + /// Defaults to `[640, 750, 828, 1080, 1200, 1920, 2048, 3840]`. Sorted + /// automatically. + /// + public IReadOnlyList? DeviceBreakpoints + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>("deviceBreakpoints"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "deviceBreakpoints", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Custom list of **image-specific breakpoints** in pixels. Useful for generating + /// small variants (e.g., placeholders or thumbnails). + /// + /// Merged with `deviceBreakpoints` before calculating `srcSet`. Defaults + /// to `[16, 32, 48, 64, 96, 128, 256, 384]`. Sorted automatically. + /// + public IReadOnlyList? ImageBreakpoints + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>("imageBreakpoints"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "imageBreakpoints", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// The value for the HTML `sizes` attribute (e.g., `"100vw"` or `"(min-width:768px) + /// 50vw, 100vw"`). + /// + /// - If it includes one or more `vw` units, breakpoints smaller than the + /// corresponding percentage of the smallest device width are excluded. - If + /// it contains no `vw` units, the full breakpoint list is used. + /// + /// Enables a width-based strategy and generates `w` descriptors in `srcSet`. + /// + public string? Sizes + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("sizes"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("sizes", value); + } + } + + /// + /// The intended display width of the image in pixels, used **only when the `sizes` + /// attribute is not provided**. + /// + /// Triggers a DPR-based strategy (1x and 2x variants) and generates `x` + /// descriptors in `srcSet`. + /// + /// Ignored if `sizes` is present. + /// + public double? Width + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("width"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("width", value); + } + } + + /// + public override void Validate() + { + _ = this.DeviceBreakpoints; + _ = this.ImageBreakpoints; + _ = this.Sizes; + _ = this.Width; + } + + public IntersectionMember1() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public IntersectionMember1(IntersectionMember1 intersectionMember1) + : base(intersectionMember1) { } +#pragma warning restore CS8618 + + public IntersectionMember1(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + IntersectionMember1(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static IntersectionMember1 FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class IntersectionMember1FromRaw : IFromRawJson +{ + /// + public IntersectionMember1 FromRawUnchecked(IReadOnlyDictionary rawData) => + IntersectionMember1.FromRawUnchecked(rawData); +} diff --git a/src/ImageKit/Models/ImageOverlay.cs b/src/ImageKit/Models/ImageOverlay.cs new file mode 100644 index 00000000..91c5b716 --- /dev/null +++ b/src/ImageKit/Models/ImageOverlay.cs @@ -0,0 +1,444 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; +using ImageKit.Exceptions; + +namespace ImageKit.Models; + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class ImageOverlay : JsonModel +{ + /// + /// Controls how the layer blends with the base image or underlying content. + /// Maps to `lm` in the URL. By default, layers completely cover the base image + /// beneath them. Layer modes change this behavior: - `multiply`: Multiplies + /// the pixel values of the layer with the base image. The result is always darker + /// than the original images. This is ideal for applying shadows or color tints. + /// - `displace`: Uses the layer as a displacement map to distort pixels in the + /// base image. The red channel controls horizontal displacement, and the green + /// channel controls vertical displacement. Requires `x` or `y` parameter to control + /// displacement magnitude. - `cutout`: Acts as an inverse mask where opaque areas + /// of the layer turn the base image transparent, while transparent areas leave + /// the base image unchanged. This mode functions like a hole-punch, effectively + /// cutting the shape of the layer out of the underlying image. - `cutter`: Acts + /// as a shape mask where only the parts of the base image that fall inside the + /// opaque area of the layer are preserved. This mode functions like a cookie-cutter, + /// trimming the base image to match the specific dimensions and shape of the + /// layer. See [Layer modes](https://imagekit.io/docs/add-overlays-on-images#layer-modes). + /// + public ApiEnum? LayerMode + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("layerMode"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("layerMode", value); + } + } + + public OverlayPosition? Position + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("position"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("position", value); + } + } + + public OverlayTiming? Timing + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("timing"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("timing", value); + } + } + + /// + /// Specifies the relative path to the image used as an overlay. + /// + public required string Input + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("input"); + } + init { this._rawData.Set("input", value); } + } + + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// The input path can be included in the layer as either `i-{input}` or `ie-{base64_encoded_input}`. + /// By default, the SDK determines the appropriate format automatically. To + /// always use base64 encoding (`ie-{base64}`), set this parameter to `base64`. + /// To always use plain text (`i-{input}`), set it to `plain`. + /// + /// Regardless of the encoding method: - Leading and trailing slashes are + /// removed. - Remaining slashes within the path are replaced with `@@` when using + /// plain text. + /// + public ApiEnum? Encoding + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("encoding"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("encoding", value); + } + } + + /// + /// Array of transformations to be applied to the overlay image. Supported transformations + /// depends on the base/parent asset. See overlays on [Images](https://imagekit.io/docs/add-overlays-on-images#list-of-supported-image-transformations-in-image-layers) + /// and [Videos](https://imagekit.io/docs/add-overlays-on-videos#list-of-transformations-supported-on-image-overlay). + /// + public IReadOnlyList? Transformation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>( + "transformation" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "transformation", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + public static implicit operator BaseOverlay(ImageOverlay imageOverlay) => + new() + { + LayerMode = imageOverlay.LayerMode, + Position = imageOverlay.Position, + Timing = imageOverlay.Timing, + }; + + /// + public override void Validate() + { + this.LayerMode?.Validate(); + this.Position?.Validate(); + this.Timing?.Validate(); + _ = this.Input; + if (!JsonElement.DeepEquals(this.Type, JsonSerializer.SerializeToElement("image"))) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + this.Encoding?.Validate(); + foreach (var item in this.Transformation ?? []) + { + item.Validate(); + } + } + + public ImageOverlay() + { + this.Type = JsonSerializer.SerializeToElement("image"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ImageOverlay(ImageOverlay imageOverlay) + : base(imageOverlay) { } +#pragma warning restore CS8618 + + public ImageOverlay(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("image"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ImageOverlay(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ImageOverlay FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public ImageOverlay(string input) + : this() + { + this.Input = input; + } +} + +class ImageOverlayFromRaw : IFromRawJson +{ + /// + public ImageOverlay FromRawUnchecked(IReadOnlyDictionary rawData) => + ImageOverlay.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + ImageOverlayIntersectionMember1, + ImageOverlayIntersectionMember1FromRaw + >) +)] +public sealed record class ImageOverlayIntersectionMember1 : JsonModel +{ + /// + /// Specifies the relative path to the image used as an overlay. + /// + public required string Input + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("input"); + } + init { this._rawData.Set("input", value); } + } + + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// The input path can be included in the layer as either `i-{input}` or `ie-{base64_encoded_input}`. + /// By default, the SDK determines the appropriate format automatically. To + /// always use base64 encoding (`ie-{base64}`), set this parameter to `base64`. + /// To always use plain text (`i-{input}`), set it to `plain`. + /// + /// Regardless of the encoding method: - Leading and trailing slashes are + /// removed. - Remaining slashes within the path are replaced with `@@` when using + /// plain text. + /// + public ApiEnum? Encoding + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("encoding"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("encoding", value); + } + } + + /// + /// Array of transformations to be applied to the overlay image. Supported transformations + /// depends on the base/parent asset. See overlays on [Images](https://imagekit.io/docs/add-overlays-on-images#list-of-supported-image-transformations-in-image-layers) + /// and [Videos](https://imagekit.io/docs/add-overlays-on-videos#list-of-transformations-supported-on-image-overlay). + /// + public IReadOnlyList? Transformation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>( + "transformation" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "transformation", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.Input; + if (!JsonElement.DeepEquals(this.Type, JsonSerializer.SerializeToElement("image"))) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + this.Encoding?.Validate(); + foreach (var item in this.Transformation ?? []) + { + item.Validate(); + } + } + + public ImageOverlayIntersectionMember1() + { + this.Type = JsonSerializer.SerializeToElement("image"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ImageOverlayIntersectionMember1( + ImageOverlayIntersectionMember1 imageOverlayIntersectionMember1 + ) + : base(imageOverlayIntersectionMember1) { } +#pragma warning restore CS8618 + + public ImageOverlayIntersectionMember1(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("image"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ImageOverlayIntersectionMember1(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ImageOverlayIntersectionMember1 FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public ImageOverlayIntersectionMember1(string input) + : this() + { + this.Input = input; + } +} + +class ImageOverlayIntersectionMember1FromRaw : IFromRawJson +{ + /// + public ImageOverlayIntersectionMember1 FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ImageOverlayIntersectionMember1.FromRawUnchecked(rawData); +} + +/// +/// The input path can be included in the layer as either `i-{input}` or `ie-{base64_encoded_input}`. +/// By default, the SDK determines the appropriate format automatically. To always +/// use base64 encoding (`ie-{base64}`), set this parameter to `base64`. To always +/// use plain text (`i-{input}`), set it to `plain`. +/// +/// Regardless of the encoding method: - Leading and trailing slashes are removed. +/// - Remaining slashes within the path are replaced with `@@` when using plain text. +/// +[JsonConverter(typeof(EncodingConverter))] +public enum Encoding +{ + Auto, + Plain, + Base64, +} + +sealed class EncodingConverter : JsonConverter +{ + public override Encoding Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "auto" => Encoding.Auto, + "plain" => Encoding.Plain, + "base64" => Encoding.Base64, + _ => (Encoding)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Encoding value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + Encoding.Auto => "auto", + Encoding.Plain => "plain", + Encoding.Base64 => "base64", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} diff --git a/src/ImageKit/Models/Overlay.cs b/src/ImageKit/Models/Overlay.cs new file mode 100644 index 00000000..101c34b7 --- /dev/null +++ b/src/ImageKit/Models/Overlay.cs @@ -0,0 +1,518 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; +using ImageKit.Exceptions; + +namespace ImageKit.Models; + +/// +/// Specifies an overlay to be applied on the parent image or video. ImageKit supports +/// overlays including images, text, videos, subtitles, and solid colors. See [Overlay +/// using layers](https://imagekit.io/docs/transformations#overlay-using-layers). +/// +[JsonConverter(typeof(OverlayConverter))] +public record class Overlay : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ApiEnum? LayerMode + { + get + { + return Match?>( + text: (x) => x.LayerMode, + image: (x) => x.LayerMode, + video: (x) => x.LayerMode, + subtitle: (x) => x.LayerMode, + solidColor: (x) => x.LayerMode + ); + } + } + + public OverlayPosition? Position + { + get + { + return Match( + text: (x) => x.Position, + image: (x) => x.Position, + video: (x) => x.Position, + subtitle: (x) => x.Position, + solidColor: (x) => x.Position + ); + } + } + + public OverlayTiming? Timing + { + get + { + return Match( + text: (x) => x.Timing, + image: (x) => x.Timing, + video: (x) => x.Timing, + subtitle: (x) => x.Timing, + solidColor: (x) => x.Timing + ); + } + } + + public JsonElement Type + { + get + { + return Match( + text: (x) => x.Type, + image: (x) => x.Type, + video: (x) => x.Type, + subtitle: (x) => x.Type, + solidColor: (x) => x.Type + ); + } + } + + public string? Input + { + get + { + return Match( + text: (_) => null, + image: (x) => x.Input, + video: (x) => x.Input, + subtitle: (x) => x.Input, + solidColor: (_) => null + ); + } + } + + public Overlay(TextOverlay value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Overlay(ImageOverlay value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Overlay(VideoOverlay value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Overlay(SubtitleOverlay value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Overlay(SolidColorOverlay value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Overlay(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickText(out var value)) { + /// // `value` is of type `TextOverlay` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickText([NotNullWhen(true)] out TextOverlay? value) + { + value = this.Value as TextOverlay; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickImage(out var value)) { + /// // `value` is of type `ImageOverlay` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickImage([NotNullWhen(true)] out ImageOverlay? value) + { + value = this.Value as ImageOverlay; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickVideo(out var value)) { + /// // `value` is of type `VideoOverlay` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickVideo([NotNullWhen(true)] out VideoOverlay? value) + { + value = this.Value as VideoOverlay; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickSubtitle(out var value)) { + /// // `value` is of type `SubtitleOverlay` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickSubtitle([NotNullWhen(true)] out SubtitleOverlay? value) + { + value = this.Value as SubtitleOverlay; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickSolidColor(out var value)) { + /// // `value` is of type `SolidColorOverlay` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickSolidColor([NotNullWhen(true)] out SolidColorOverlay? value) + { + value = this.Value as SolidColorOverlay; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (TextOverlay value) => {...}, + /// (ImageOverlay value) => {...}, + /// (VideoOverlay value) => {...}, + /// (SubtitleOverlay value) => {...}, + /// (SolidColorOverlay value) => {...} + /// ); + /// + /// + /// + public void Switch( + Action text, + Action image, + Action video, + Action subtitle, + Action solidColor + ) + { + switch (this.Value) + { + case TextOverlay value: + text(value); + break; + case ImageOverlay value: + image(value); + break; + case VideoOverlay value: + video(value); + break; + case SubtitleOverlay value: + subtitle(value); + break; + case SolidColorOverlay value: + solidColor(value); + break; + default: + throw new ImageKitInvalidDataException("Data did not match any variant of Overlay"); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (TextOverlay value) => {...}, + /// (ImageOverlay value) => {...}, + /// (VideoOverlay value) => {...}, + /// (SubtitleOverlay value) => {...}, + /// (SolidColorOverlay value) => {...} + /// ); + /// + /// + /// + public T Match( + Func text, + Func image, + Func video, + Func subtitle, + Func solidColor + ) + { + return this.Value switch + { + TextOverlay value => text(value), + ImageOverlay value => image(value), + VideoOverlay value => video(value), + SubtitleOverlay value => subtitle(value), + SolidColorOverlay value => solidColor(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of Overlay" + ), + }; + } + + public static implicit operator Overlay(TextOverlay value) => new(value); + + public static implicit operator Overlay(ImageOverlay value) => new(value); + + public static implicit operator Overlay(VideoOverlay value) => new(value); + + public static implicit operator Overlay(SubtitleOverlay value) => new(value); + + public static implicit operator Overlay(SolidColorOverlay value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException("Data did not match any variant of Overlay"); + } + this.Switch( + (text) => text.Validate(), + (image) => image.Validate(), + (video) => video.Validate(), + (subtitle) => subtitle.Validate(), + (solidColor) => solidColor.Validate() + ); + } + + public virtual bool Equals(Overlay? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class OverlayConverter : JsonConverter +{ + public override Overlay? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + string? type; + try + { + type = element.GetProperty("type").GetString(); + } + catch + { + type = null; + } + + switch (type) + { + case "text": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + case "image": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + case "video": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + case "subtitle": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + case "solidColor": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + default: + { + return new Overlay(element); + } + } + } + + public override void Write(Utf8JsonWriter writer, Overlay value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} diff --git a/src/ImageKit/Models/OverlayPosition.cs b/src/ImageKit/Models/OverlayPosition.cs new file mode 100644 index 00000000..7274304e --- /dev/null +++ b/src/ImageKit/Models/OverlayPosition.cs @@ -0,0 +1,641 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; +using ImageKit.Exceptions; + +namespace ImageKit.Models; + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class OverlayPosition : JsonModel +{ + /// + /// Specifies the position of the overlay relative to the parent image or video. + /// Maps to `lfo` in the URL. + /// + public ApiEnum? Focus + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("focus"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("focus", value); + } + } + + /// + /// Specifies the x-coordinate of the top-left corner of the base asset where + /// the overlay's top-left corner will be positioned. It also accepts arithmetic + /// expressions such as `bw_mul_0.4` or `bw_sub_cw`. Maps to `lx` in the URL. + /// Learn about [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + /// + public X? X + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("x"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("x", value); + } + } + + /// + /// Specifies the y-coordinate of the top-left corner of the base asset where + /// the overlay's top-left corner will be positioned. It also accepts arithmetic + /// expressions such as `bh_mul_0.4` or `bh_sub_ch`. Maps to `ly` in the URL. + /// Learn about [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + /// + public Y? Y + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("y"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("y", value); + } + } + + /// + public override void Validate() + { + this.Focus?.Validate(); + this.X?.Validate(); + this.Y?.Validate(); + } + + public OverlayPosition() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public OverlayPosition(OverlayPosition overlayPosition) + : base(overlayPosition) { } +#pragma warning restore CS8618 + + public OverlayPosition(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + OverlayPosition(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static OverlayPosition FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class OverlayPositionFromRaw : IFromRawJson +{ + /// + public OverlayPosition FromRawUnchecked(IReadOnlyDictionary rawData) => + OverlayPosition.FromRawUnchecked(rawData); +} + +/// +/// Specifies the position of the overlay relative to the parent image or video. Maps +/// to `lfo` in the URL. +/// +[JsonConverter(typeof(FocusConverter))] +public enum Focus +{ + Center, + Top, + Left, + Bottom, + Right, + TopLeft, + TopRight, + BottomLeft, + BottomRight, +} + +sealed class FocusConverter : JsonConverter +{ + public override Focus Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "center" => Focus.Center, + "top" => Focus.Top, + "left" => Focus.Left, + "bottom" => Focus.Bottom, + "right" => Focus.Right, + "top_left" => Focus.TopLeft, + "top_right" => Focus.TopRight, + "bottom_left" => Focus.BottomLeft, + "bottom_right" => Focus.BottomRight, + _ => (Focus)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Focus value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + Focus.Center => "center", + Focus.Top => "top", + Focus.Left => "left", + Focus.Bottom => "bottom", + Focus.Right => "right", + Focus.TopLeft => "top_left", + Focus.TopRight => "top_right", + Focus.BottomLeft => "bottom_left", + Focus.BottomRight => "bottom_right", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Specifies the x-coordinate of the top-left corner of the base asset where the +/// overlay's top-left corner will be positioned. It also accepts arithmetic expressions +/// such as `bw_mul_0.4` or `bw_sub_cw`. Maps to `lx` in the URL. Learn about [Arithmetic +/// expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). +/// +[JsonConverter(typeof(XConverter))] +public record class X : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public X(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public X(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public X(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public void Switch(Action @double, Action @string) + { + switch (this.Value) + { + case double value: + @double(value); + break; + case string value: + @string(value); + break; + default: + throw new ImageKitInvalidDataException("Data did not match any variant of X"); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public T Match(Func @double, Func @string) + { + return this.Value switch + { + double value => @double(value), + string value => @string(value), + _ => throw new ImageKitInvalidDataException("Data did not match any variant of X"), + }; + } + + public static implicit operator X(double value) => new(value); + + public static implicit operator X(string value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException("Data did not match any variant of X"); + } + } + + public virtual bool Equals(X? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class XConverter : JsonConverter +{ + public override X? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write(Utf8JsonWriter writer, X value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +/// +/// Specifies the y-coordinate of the top-left corner of the base asset where the +/// overlay's top-left corner will be positioned. It also accepts arithmetic expressions +/// such as `bh_mul_0.4` or `bh_sub_ch`. Maps to `ly` in the URL. Learn about [Arithmetic +/// expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). +/// +[JsonConverter(typeof(YConverter))] +public record class Y : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public Y(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Y(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Y(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public void Switch(Action @double, Action @string) + { + switch (this.Value) + { + case double value: + @double(value); + break; + case string value: + @string(value); + break; + default: + throw new ImageKitInvalidDataException("Data did not match any variant of Y"); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public T Match(Func @double, Func @string) + { + return this.Value switch + { + double value => @double(value), + string value => @string(value), + _ => throw new ImageKitInvalidDataException("Data did not match any variant of Y"), + }; + } + + public static implicit operator Y(double value) => new(value); + + public static implicit operator Y(string value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException("Data did not match any variant of Y"); + } + } + + public virtual bool Equals(Y? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class YConverter : JsonConverter +{ + public override Y? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write(Utf8JsonWriter writer, Y value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} diff --git a/src/ImageKit/Models/OverlayTiming.cs b/src/ImageKit/Models/OverlayTiming.cs new file mode 100644 index 00000000..3cbfbaed --- /dev/null +++ b/src/ImageKit/Models/OverlayTiming.cs @@ -0,0 +1,809 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; +using ImageKit.Exceptions; + +namespace ImageKit.Models; + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class OverlayTiming : JsonModel +{ + /// + /// Specifies the duration (in seconds) during which the overlay should appear + /// on the base video. Accepts a positive number up to two decimal places (e.g., + /// `20` or `20.50`) and arithmetic expressions such as `bdu_mul_0.4` or `bdu_sub_idu`. + /// Applies only if the base asset is a video. Maps to `ldu` in the URL. + /// + public Duration? Duration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("duration"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("duration", value); + } + } + + /// + /// Specifies the end time (in seconds) for when the overlay should disappear + /// from the base video. If both end and duration are provided, duration is ignored. + /// Accepts a positive number up to two decimal places (e.g., `20` or `20.50`) + /// and arithmetic expressions such as `bdu_mul_0.4` or `bdu_sub_idu`. Applies + /// only if the base asset is a video. Maps to `leo` in the URL. + /// + public End? End + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("end"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("end", value); + } + } + + /// + /// Specifies the start time (in seconds) for when the overlay should appear + /// on the base video. Accepts a positive number up to two decimal places (e.g., + /// `20` or `20.50`) and arithmetic expressions such as `bdu_mul_0.4` or `bdu_sub_idu`. + /// Applies only if the base asset is a video. Maps to `lso` in the URL. + /// + public Start? Start + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("start"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("start", value); + } + } + + /// + public override void Validate() + { + this.Duration?.Validate(); + this.End?.Validate(); + this.Start?.Validate(); + } + + public OverlayTiming() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public OverlayTiming(OverlayTiming overlayTiming) + : base(overlayTiming) { } +#pragma warning restore CS8618 + + public OverlayTiming(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + OverlayTiming(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static OverlayTiming FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class OverlayTimingFromRaw : IFromRawJson +{ + /// + public OverlayTiming FromRawUnchecked(IReadOnlyDictionary rawData) => + OverlayTiming.FromRawUnchecked(rawData); +} + +/// +/// Specifies the duration (in seconds) during which the overlay should appear on +/// the base video. Accepts a positive number up to two decimal places (e.g., `20` +/// or `20.50`) and arithmetic expressions such as `bdu_mul_0.4` or `bdu_sub_idu`. +/// Applies only if the base asset is a video. Maps to `ldu` in the URL. +/// +[JsonConverter(typeof(DurationConverter))] +public record class Duration : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public Duration(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Duration(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Duration(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public void Switch(Action @double, Action @string) + { + switch (this.Value) + { + case double value: + @double(value); + break; + case string value: + @string(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of Duration" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public T Match(Func @double, Func @string) + { + return this.Value switch + { + double value => @double(value), + string value => @string(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of Duration" + ), + }; + } + + public static implicit operator Duration(double value) => new(value); + + public static implicit operator Duration(string value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException("Data did not match any variant of Duration"); + } + } + + public virtual bool Equals(Duration? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class DurationConverter : JsonConverter +{ + public override Duration? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write(Utf8JsonWriter writer, Duration value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +/// +/// Specifies the end time (in seconds) for when the overlay should disappear from +/// the base video. If both end and duration are provided, duration is ignored. Accepts +/// a positive number up to two decimal places (e.g., `20` or `20.50`) and arithmetic +/// expressions such as `bdu_mul_0.4` or `bdu_sub_idu`. Applies only if the base +/// asset is a video. Maps to `leo` in the URL. +/// +[JsonConverter(typeof(EndConverter))] +public record class End : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public End(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public End(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public End(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public void Switch(Action @double, Action @string) + { + switch (this.Value) + { + case double value: + @double(value); + break; + case string value: + @string(value); + break; + default: + throw new ImageKitInvalidDataException("Data did not match any variant of End"); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public T Match(Func @double, Func @string) + { + return this.Value switch + { + double value => @double(value), + string value => @string(value), + _ => throw new ImageKitInvalidDataException("Data did not match any variant of End"), + }; + } + + public static implicit operator End(double value) => new(value); + + public static implicit operator End(string value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException("Data did not match any variant of End"); + } + } + + public virtual bool Equals(End? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class EndConverter : JsonConverter +{ + public override End? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write(Utf8JsonWriter writer, End value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +/// +/// Specifies the start time (in seconds) for when the overlay should appear on the +/// base video. Accepts a positive number up to two decimal places (e.g., `20` or +/// `20.50`) and arithmetic expressions such as `bdu_mul_0.4` or `bdu_sub_idu`. Applies +/// only if the base asset is a video. Maps to `lso` in the URL. +/// +[JsonConverter(typeof(StartConverter))] +public record class Start : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public Start(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Start(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Start(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public void Switch(Action @double, Action @string) + { + switch (this.Value) + { + case double value: + @double(value); + break; + case string value: + @string(value); + break; + default: + throw new ImageKitInvalidDataException("Data did not match any variant of Start"); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public T Match(Func @double, Func @string) + { + return this.Value switch + { + double value => @double(value), + string value => @string(value), + _ => throw new ImageKitInvalidDataException("Data did not match any variant of Start"), + }; + } + + public static implicit operator Start(double value) => new(value); + + public static implicit operator Start(string value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException("Data did not match any variant of Start"); + } + } + + public virtual bool Equals(Start? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class StartConverter : JsonConverter +{ + public override Start? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write(Utf8JsonWriter writer, Start value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} diff --git a/src/ImageKit/Models/ResponsiveImageAttributes.cs b/src/ImageKit/Models/ResponsiveImageAttributes.cs new file mode 100644 index 00000000..33504439 --- /dev/null +++ b/src/ImageKit/Models/ResponsiveImageAttributes.cs @@ -0,0 +1,149 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; + +namespace ImageKit.Models; + +/// +/// Resulting set of attributes suitable for an HTML `` element. Useful for +/// enabling responsive image loading with `srcSet` and `sizes`. +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class ResponsiveImageAttributes : JsonModel +{ + /// + /// URL for the *largest* candidate (assigned to plain `src`). + /// + public required string Src + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("src"); + } + init { this._rawData.Set("src", value); } + } + + /// + /// `sizes` returned (or synthesised as `100vw`). The value for the HTML `sizes` + /// attribute. + /// + public string? Sizes + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("sizes"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("sizes", value); + } + } + + /// + /// Candidate set with `w` or `x` descriptors. Multiple image URLs separated + /// by commas, each with a descriptor. + /// + public string? SrcSet + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("srcSet"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("srcSet", value); + } + } + + /// + /// Width as a number (if `width` was provided in the input options). + /// + public double? Width + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("width"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("width", value); + } + } + + /// + public override void Validate() + { + _ = this.Src; + _ = this.Sizes; + _ = this.SrcSet; + _ = this.Width; + } + + public ResponsiveImageAttributes() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ResponsiveImageAttributes(ResponsiveImageAttributes responsiveImageAttributes) + : base(responsiveImageAttributes) { } +#pragma warning restore CS8618 + + public ResponsiveImageAttributes(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ResponsiveImageAttributes(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ResponsiveImageAttributes FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public ResponsiveImageAttributes(string src) + : this() + { + this.Src = src; + } +} + +class ResponsiveImageAttributesFromRaw : IFromRawJson +{ + /// + public ResponsiveImageAttributes FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ResponsiveImageAttributes.FromRawUnchecked(rawData); +} diff --git a/src/ImageKit/Models/SavedExtensions/SavedExtensionCreateParams.cs b/src/ImageKit/Models/SavedExtensions/SavedExtensionCreateParams.cs new file mode 100644 index 00000000..e26bcf0b --- /dev/null +++ b/src/ImageKit/Models/SavedExtensions/SavedExtensionCreateParams.cs @@ -0,0 +1,173 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using ImageKit.Core; +using Text = System.Text; + +namespace ImageKit.Models.SavedExtensions; + +/// +/// This API creates a new saved extension. Saved extensions allow you to save complex +/// extension configurations (like AI tasks) and reuse them by referencing the ID +/// in upload or update file APIs. +/// +/// **Saved extension limit** \ You can create a maximum of 100 saved extensions +/// per account. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class SavedExtensionCreateParams : ParamsBase +{ + readonly JsonDictionary _rawBodyData = new(); + public IReadOnlyDictionary RawBodyData + { + get { return this._rawBodyData.Freeze(); } + } + + /// + /// Configuration object for an extension (base extensions only, not saved extension references). + /// + public required ExtensionConfig Config + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullClass("config"); + } + init { this._rawBodyData.Set("config", value); } + } + + /// + /// Description of what the saved extension does. + /// + public required string Description + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullClass("description"); + } + init { this._rawBodyData.Set("description", value); } + } + + /// + /// Name of the saved extension. + /// + public required string Name + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullClass("name"); + } + init { this._rawBodyData.Set("name", value); } + } + + public SavedExtensionCreateParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SavedExtensionCreateParams(SavedExtensionCreateParams savedExtensionCreateParams) + : base(savedExtensionCreateParams) + { + this._rawBodyData = new(savedExtensionCreateParams._rawBodyData); + } +#pragma warning restore CS8618 + + public SavedExtensionCreateParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + SavedExtensionCreateParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData, + FrozenDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } +#pragma warning restore CS8618 + + /// + public static SavedExtensionCreateParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData), + FrozenDictionary.ToFrozenDictionary(rawBodyData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(SavedExtensionCreateParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/v1/saved-extensions") + { + Query = this.QueryString(options), + }.Uri; + } + + internal override HttpContent? BodyContent() + { + return new StringContent( + JsonSerializer.Serialize(this.RawBodyData, ModelBase.SerializerOptions), + Text::Encoding.UTF8, + "application/json" + ); + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/ImageKit/Models/SavedExtensions/SavedExtensionDeleteParams.cs b/src/ImageKit/Models/SavedExtensions/SavedExtensionDeleteParams.cs new file mode 100644 index 00000000..38beadc8 --- /dev/null +++ b/src/ImageKit/Models/SavedExtensions/SavedExtensionDeleteParams.cs @@ -0,0 +1,112 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using ImageKit.Core; + +namespace ImageKit.Models.SavedExtensions; + +/// +/// This API deletes a saved extension permanently. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class SavedExtensionDeleteParams : ParamsBase +{ + public string? ID { get; init; } + + public SavedExtensionDeleteParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SavedExtensionDeleteParams(SavedExtensionDeleteParams savedExtensionDeleteParams) + : base(savedExtensionDeleteParams) + { + this.ID = savedExtensionDeleteParams.ID; + } +#pragma warning restore CS8618 + + public SavedExtensionDeleteParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + SavedExtensionDeleteParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } +#pragma warning restore CS8618 + + /// + public static SavedExtensionDeleteParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["ID"] = this.ID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(SavedExtensionDeleteParams? other) + { + if (other == null) + { + return false; + } + return (this.ID?.Equals(other.ID) ?? other.ID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder( + options.BaseUrl.ToString().TrimEnd('/') + + string.Format("/v1/saved-extensions/{0}", this.ID) + ) + { + Query = this.QueryString(options), + }.Uri; + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/ImageKit/Models/SavedExtensions/SavedExtensionGetParams.cs b/src/ImageKit/Models/SavedExtensions/SavedExtensionGetParams.cs new file mode 100644 index 00000000..5bdf33e2 --- /dev/null +++ b/src/ImageKit/Models/SavedExtensions/SavedExtensionGetParams.cs @@ -0,0 +1,112 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using ImageKit.Core; + +namespace ImageKit.Models.SavedExtensions; + +/// +/// This API returns details of a specific saved extension by ID. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class SavedExtensionGetParams : ParamsBase +{ + public string? ID { get; init; } + + public SavedExtensionGetParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SavedExtensionGetParams(SavedExtensionGetParams savedExtensionGetParams) + : base(savedExtensionGetParams) + { + this.ID = savedExtensionGetParams.ID; + } +#pragma warning restore CS8618 + + public SavedExtensionGetParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + SavedExtensionGetParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } +#pragma warning restore CS8618 + + /// + public static SavedExtensionGetParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["ID"] = this.ID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(SavedExtensionGetParams? other) + { + if (other == null) + { + return false; + } + return (this.ID?.Equals(other.ID) ?? other.ID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder( + options.BaseUrl.ToString().TrimEnd('/') + + string.Format("/v1/saved-extensions/{0}", this.ID) + ) + { + Query = this.QueryString(options), + }.Uri; + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/ImageKit/Models/SavedExtensions/SavedExtensionListParams.cs b/src/ImageKit/Models/SavedExtensions/SavedExtensionListParams.cs new file mode 100644 index 00000000..795a8f36 --- /dev/null +++ b/src/ImageKit/Models/SavedExtensions/SavedExtensionListParams.cs @@ -0,0 +1,104 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using ImageKit.Core; + +namespace ImageKit.Models.SavedExtensions; + +/// +/// This API returns an array of all saved extensions for your account. Saved extensions +/// allow you to save complex extension configurations and reuse them by referencing +/// them by ID in upload or update file APIs. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class SavedExtensionListParams : ParamsBase +{ + public SavedExtensionListParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SavedExtensionListParams(SavedExtensionListParams savedExtensionListParams) + : base(savedExtensionListParams) { } +#pragma warning restore CS8618 + + public SavedExtensionListParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + SavedExtensionListParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } +#pragma warning restore CS8618 + + /// + public static SavedExtensionListParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(SavedExtensionListParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/v1/saved-extensions") + { + Query = this.QueryString(options), + }.Uri; + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/ImageKit/Models/SavedExtensions/SavedExtensionUpdateParams.cs b/src/ImageKit/Models/SavedExtensions/SavedExtensionUpdateParams.cs new file mode 100644 index 00000000..a5efcaa1 --- /dev/null +++ b/src/ImageKit/Models/SavedExtensions/SavedExtensionUpdateParams.cs @@ -0,0 +1,202 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using ImageKit.Core; +using Text = System.Text; + +namespace ImageKit.Models.SavedExtensions; + +/// +/// This API updates an existing saved extension. You can update the name, description, +/// or config. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class SavedExtensionUpdateParams : ParamsBase +{ + readonly JsonDictionary _rawBodyData = new(); + public IReadOnlyDictionary RawBodyData + { + get { return this._rawBodyData.Freeze(); } + } + + public string? ID { get; init; } + + /// + /// Configuration object for an extension (base extensions only, not saved extension references). + /// + public ExtensionConfig? Config + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass("config"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("config", value); + } + } + + /// + /// Updated description of the saved extension. + /// + public string? Description + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass("description"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("description", value); + } + } + + /// + /// Updated name of the saved extension. + /// + public string? Name + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass("name"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("name", value); + } + } + + public SavedExtensionUpdateParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SavedExtensionUpdateParams(SavedExtensionUpdateParams savedExtensionUpdateParams) + : base(savedExtensionUpdateParams) + { + this.ID = savedExtensionUpdateParams.ID; + + this._rawBodyData = new(savedExtensionUpdateParams._rawBodyData); + } +#pragma warning restore CS8618 + + public SavedExtensionUpdateParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + SavedExtensionUpdateParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData, + FrozenDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } +#pragma warning restore CS8618 + + /// + public static SavedExtensionUpdateParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData), + FrozenDictionary.ToFrozenDictionary(rawBodyData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["ID"] = this.ID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(SavedExtensionUpdateParams? other) + { + if (other == null) + { + return false; + } + return (this.ID?.Equals(other.ID) ?? other.ID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder( + options.BaseUrl.ToString().TrimEnd('/') + + string.Format("/v1/saved-extensions/{0}", this.ID) + ) + { + Query = this.QueryString(options), + }.Uri; + } + + internal override HttpContent? BodyContent() + { + return new StringContent( + JsonSerializer.Serialize(this.RawBodyData, ModelBase.SerializerOptions), + Text::Encoding.UTF8, + "application/json" + ); + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/ImageKit/Models/SharedSavedExtension.cs b/src/ImageKit/Models/SharedSavedExtension.cs new file mode 100644 index 00000000..3a79e38e --- /dev/null +++ b/src/ImageKit/Models/SharedSavedExtension.cs @@ -0,0 +1,190 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; + +namespace ImageKit.Models; + +/// +/// Saved extension object containing extension configuration. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class SharedSavedExtension : JsonModel +{ + /// + /// Unique identifier of the saved extension. + /// + public string? ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("id"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("id", value); + } + } + + /// + /// Configuration object for an extension (base extensions only, not saved extension references). + /// + public ExtensionConfig? Config + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("config"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("config", value); + } + } + + /// + /// Timestamp when the saved extension was created. + /// + public DateTimeOffset? CreatedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("createdAt"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("createdAt", value); + } + } + + /// + /// Description of the saved extension. + /// + public string? Description + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("description"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("description", value); + } + } + + /// + /// Name of the saved extension. + /// + public string? Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("name"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("name", value); + } + } + + /// + /// Timestamp when the saved extension was last updated. + /// + public DateTimeOffset? UpdatedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("updatedAt"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("updatedAt", value); + } + } + + /// + public override void Validate() + { + _ = this.ID; + this.Config?.Validate(); + _ = this.CreatedAt; + _ = this.Description; + _ = this.Name; + _ = this.UpdatedAt; + } + + public SharedSavedExtension() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SharedSavedExtension(SharedSavedExtension sharedSavedExtension) + : base(sharedSavedExtension) { } +#pragma warning restore CS8618 + + public SharedSavedExtension(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + SharedSavedExtension(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static SharedSavedExtension FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class SharedSavedExtensionFromRaw : IFromRawJson +{ + /// + public SharedSavedExtension FromRawUnchecked( + IReadOnlyDictionary rawData + ) => SharedSavedExtension.FromRawUnchecked(rawData); +} diff --git a/src/ImageKit/Models/SolidColorOverlay.cs b/src/ImageKit/Models/SolidColorOverlay.cs new file mode 100644 index 00000000..23164e36 --- /dev/null +++ b/src/ImageKit/Models/SolidColorOverlay.cs @@ -0,0 +1,342 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; +using ImageKit.Exceptions; + +namespace ImageKit.Models; + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class SolidColorOverlay : JsonModel +{ + /// + /// Controls how the layer blends with the base image or underlying content. + /// Maps to `lm` in the URL. By default, layers completely cover the base image + /// beneath them. Layer modes change this behavior: - `multiply`: Multiplies + /// the pixel values of the layer with the base image. The result is always darker + /// than the original images. This is ideal for applying shadows or color tints. + /// - `displace`: Uses the layer as a displacement map to distort pixels in the + /// base image. The red channel controls horizontal displacement, and the green + /// channel controls vertical displacement. Requires `x` or `y` parameter to control + /// displacement magnitude. - `cutout`: Acts as an inverse mask where opaque areas + /// of the layer turn the base image transparent, while transparent areas leave + /// the base image unchanged. This mode functions like a hole-punch, effectively + /// cutting the shape of the layer out of the underlying image. - `cutter`: Acts + /// as a shape mask where only the parts of the base image that fall inside the + /// opaque area of the layer are preserved. This mode functions like a cookie-cutter, + /// trimming the base image to match the specific dimensions and shape of the + /// layer. See [Layer modes](https://imagekit.io/docs/add-overlays-on-images#layer-modes). + /// + public ApiEnum? LayerMode + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("layerMode"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("layerMode", value); + } + } + + public OverlayPosition? Position + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("position"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("position", value); + } + } + + public OverlayTiming? Timing + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("timing"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("timing", value); + } + } + + /// + /// Specifies the color of the block using an RGB hex code (e.g., `FF0000`), an + /// RGBA code (e.g., `FFAABB50`), or a color name (e.g., `red`). If an 8-character + /// value is provided, the last two characters represent the opacity level (from + /// `00` for 0.00 to `99` for 0.99). + /// + public required string Color + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("color"); + } + init { this._rawData.Set("color", value); } + } + + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// Control width and height of the solid color overlay. Supported transformations + /// depend on the base/parent asset. See overlays on [Images](https://imagekit.io/docs/add-overlays-on-images#apply-transformation-on-solid-color-overlay) + /// and [Videos](https://imagekit.io/docs/add-overlays-on-videos#apply-transformations-on-solid-color-block-overlay). + /// + public IReadOnlyList? Transformation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>( + "transformation" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "transformation", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + public static implicit operator BaseOverlay(SolidColorOverlay solidColorOverlay) => + new() + { + LayerMode = solidColorOverlay.LayerMode, + Position = solidColorOverlay.Position, + Timing = solidColorOverlay.Timing, + }; + + /// + public override void Validate() + { + this.LayerMode?.Validate(); + this.Position?.Validate(); + this.Timing?.Validate(); + _ = this.Color; + if (!JsonElement.DeepEquals(this.Type, JsonSerializer.SerializeToElement("solidColor"))) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + foreach (var item in this.Transformation ?? []) + { + item.Validate(); + } + } + + public SolidColorOverlay() + { + this.Type = JsonSerializer.SerializeToElement("solidColor"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SolidColorOverlay(SolidColorOverlay solidColorOverlay) + : base(solidColorOverlay) { } +#pragma warning restore CS8618 + + public SolidColorOverlay(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("solidColor"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + SolidColorOverlay(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static SolidColorOverlay FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public SolidColorOverlay(string color) + : this() + { + this.Color = color; + } +} + +class SolidColorOverlayFromRaw : IFromRawJson +{ + /// + public SolidColorOverlay FromRawUnchecked(IReadOnlyDictionary rawData) => + SolidColorOverlay.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + SolidColorOverlayIntersectionMember1, + SolidColorOverlayIntersectionMember1FromRaw + >) +)] +public sealed record class SolidColorOverlayIntersectionMember1 : JsonModel +{ + /// + /// Specifies the color of the block using an RGB hex code (e.g., `FF0000`), an + /// RGBA code (e.g., `FFAABB50`), or a color name (e.g., `red`). If an 8-character + /// value is provided, the last two characters represent the opacity level (from + /// `00` for 0.00 to `99` for 0.99). + /// + public required string Color + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("color"); + } + init { this._rawData.Set("color", value); } + } + + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// Control width and height of the solid color overlay. Supported transformations + /// depend on the base/parent asset. See overlays on [Images](https://imagekit.io/docs/add-overlays-on-images#apply-transformation-on-solid-color-overlay) + /// and [Videos](https://imagekit.io/docs/add-overlays-on-videos#apply-transformations-on-solid-color-block-overlay). + /// + public IReadOnlyList? Transformation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>( + "transformation" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "transformation", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.Color; + if (!JsonElement.DeepEquals(this.Type, JsonSerializer.SerializeToElement("solidColor"))) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + foreach (var item in this.Transformation ?? []) + { + item.Validate(); + } + } + + public SolidColorOverlayIntersectionMember1() + { + this.Type = JsonSerializer.SerializeToElement("solidColor"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SolidColorOverlayIntersectionMember1( + SolidColorOverlayIntersectionMember1 solidColorOverlayIntersectionMember1 + ) + : base(solidColorOverlayIntersectionMember1) { } +#pragma warning restore CS8618 + + public SolidColorOverlayIntersectionMember1(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("solidColor"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + SolidColorOverlayIntersectionMember1(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static SolidColorOverlayIntersectionMember1 FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public SolidColorOverlayIntersectionMember1(string color) + : this() + { + this.Color = color; + } +} + +class SolidColorOverlayIntersectionMember1FromRaw + : IFromRawJson +{ + /// + public SolidColorOverlayIntersectionMember1 FromRawUnchecked( + IReadOnlyDictionary rawData + ) => SolidColorOverlayIntersectionMember1.FromRawUnchecked(rawData); +} diff --git a/src/ImageKit/Models/SolidColorOverlayTransformation.cs b/src/ImageKit/Models/SolidColorOverlayTransformation.cs new file mode 100644 index 00000000..19736040 --- /dev/null +++ b/src/ImageKit/Models/SolidColorOverlayTransformation.cs @@ -0,0 +1,1301 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; +using ImageKit.Exceptions; + +namespace ImageKit.Models; + +[JsonConverter( + typeof(JsonModelConverter< + SolidColorOverlayTransformation, + SolidColorOverlayTransformationFromRaw + >) +)] +public sealed record class SolidColorOverlayTransformation : JsonModel +{ + /// + /// Specifies the transparency level of the overlaid solid color layer. Supports + /// integers from `1` to `9`. + /// + public double? Alpha + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("alpha"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("alpha", value); + } + } + + /// + /// Specifies the background color of the solid color overlay. Accepts an RGB + /// hex code (e.g., `FF0000`), an RGBA code (e.g., `FFAABB50`), or a color name. + /// + public string? Background + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("background"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("background", value); + } + } + + /// + /// Creates a linear gradient with two colors. Pass `true` for a default gradient, + /// or provide a string for a custom gradient. Only works if the base asset is + /// an image. See [gradient](https://imagekit.io/docs/effects-and-enhancements#gradient---e-gradient). + /// + public Gradient? Gradient + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("gradient"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("gradient", value); + } + } + + /// + /// Controls the height of the solid color overlay. Accepts a numeric value or + /// an arithmetic expression. Learn about [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + /// + public Height? Height + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("height"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("height", value); + } + } + + /// + /// Specifies the corner radius of the solid color overlay. - Single value (positive + /// integer): Applied to all corners (e.g., `20`). - `max`: Creates a circular + /// or oval shape. - Per-corner array: Provide four underscore-separated values + /// representing top-left, top-right, bottom-right, and bottom-left corners respectively + /// (e.g., `10_20_30_40`). See [Radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). + /// + public Radius? Radius + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("radius"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("radius", value); + } + } + + /// + /// Controls the width of the solid color overlay. Accepts a numeric value or + /// an arithmetic expression (e.g., `bw_mul_0.2` or `bh_div_2`). Learn about + /// [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + /// + public Width? Width + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("width"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("width", value); + } + } + + /// + public override void Validate() + { + _ = this.Alpha; + _ = this.Background; + this.Gradient?.Validate(); + this.Height?.Validate(); + this.Radius?.Validate(); + this.Width?.Validate(); + } + + public SolidColorOverlayTransformation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SolidColorOverlayTransformation( + SolidColorOverlayTransformation solidColorOverlayTransformation + ) + : base(solidColorOverlayTransformation) { } +#pragma warning restore CS8618 + + public SolidColorOverlayTransformation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + SolidColorOverlayTransformation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static SolidColorOverlayTransformation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class SolidColorOverlayTransformationFromRaw : IFromRawJson +{ + /// + public SolidColorOverlayTransformation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => SolidColorOverlayTransformation.FromRawUnchecked(rawData); +} + +/// +/// Creates a linear gradient with two colors. Pass `true` for a default gradient, +/// or provide a string for a custom gradient. Only works if the base asset is an +/// image. See [gradient](https://imagekit.io/docs/effects-and-enhancements#gradient---e-gradient). +/// +[JsonConverter(typeof(GradientConverter))] +public record class Gradient : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public Gradient(UnionMember0 value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Gradient(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Gradient(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickTrue(out var value)) { + /// // `value` is of type `UnionMember0` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTrue([NotNullWhen(true)] out UnionMember0? value) + { + value = this.Value as UnionMember0; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (UnionMember0 value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public void Switch(Action true_, Action @string) + { + switch (this.Value) + { + case UnionMember0 value: + true_(value); + break; + case string value: + @string(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of Gradient" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (UnionMember0 value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public T Match(Func true_, Func @string) + { + return this.Value switch + { + UnionMember0 value => true_(value), + string value => @string(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of Gradient" + ), + }; + } + + public static implicit operator Gradient(UnionMember0 value) => new(value); + + public static implicit operator Gradient(string value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException("Data did not match any variant of Gradient"); + } + this.Switch((true_) => true_.Validate(), (_) => { }); + } + + public virtual bool Equals(Gradient? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class GradientConverter : JsonConverter +{ + public override Gradient? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write(Utf8JsonWriter writer, Gradient value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(UnionMember0Converter))] +public record class UnionMember0 +{ + public JsonElement Element { get; private init; } + + public UnionMember0() + { + Element = JsonSerializer.SerializeToElement(true); + } + + internal UnionMember0(JsonElement element) + { + Element = element; + } + + /// + /// Validates that the instance's underlying value is the expected constant. + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public void Validate() + { + if (this != new UnionMember0()) + { + throw new ImageKitInvalidDataException("Invalid value given for 'UnionMember0'"); + } + } + + public override int GetHashCode() + { + return 0; + } + + public virtual bool Equals(UnionMember0? other) + { + if (other == null) + { + return false; + } + + return JsonElement.DeepEquals(this.Element, other.Element); + } +} + +class UnionMember0Converter : JsonConverter +{ + public override UnionMember0? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write( + Utf8JsonWriter writer, + UnionMember0 value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Element, options); + } +} + +/// +/// Controls the height of the solid color overlay. Accepts a numeric value or an +/// arithmetic expression. Learn about [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). +/// +[JsonConverter(typeof(HeightConverter))] +public record class Height : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public Height(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Height(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Height(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public void Switch(Action @double, Action @string) + { + switch (this.Value) + { + case double value: + @double(value); + break; + case string value: + @string(value); + break; + default: + throw new ImageKitInvalidDataException("Data did not match any variant of Height"); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public T Match(Func @double, Func @string) + { + return this.Value switch + { + double value => @double(value), + string value => @string(value), + _ => throw new ImageKitInvalidDataException("Data did not match any variant of Height"), + }; + } + + public static implicit operator Height(double value) => new(value); + + public static implicit operator Height(string value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException("Data did not match any variant of Height"); + } + } + + public virtual bool Equals(Height? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class HeightConverter : JsonConverter +{ + public override Height? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write(Utf8JsonWriter writer, Height value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +/// +/// Specifies the corner radius of the solid color overlay. - Single value (positive +/// integer): Applied to all corners (e.g., `20`). - `max`: Creates a circular or +/// oval shape. - Per-corner array: Provide four underscore-separated values representing +/// top-left, top-right, bottom-right, and bottom-left corners respectively (e.g., +/// `10_20_30_40`). See [Radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). +/// +[JsonConverter(typeof(RadiusConverter))] +public record class Radius : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public Radius(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Radius(UnionMember1 value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Radius(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Radius(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickMax(out var value)) { + /// // `value` is of type `UnionMember1` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMax([NotNullWhen(true)] out UnionMember1? value) + { + value = this.Value as UnionMember1; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (double value) => {...}, + /// (UnionMember1 value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public void Switch(Action @double, Action max, Action @string) + { + switch (this.Value) + { + case double value: + @double(value); + break; + case UnionMember1 value: + max(value); + break; + case string value: + @string(value); + break; + default: + throw new ImageKitInvalidDataException("Data did not match any variant of Radius"); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (double value) => {...}, + /// (UnionMember1 value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public T Match(Func @double, Func max, Func @string) + { + return this.Value switch + { + double value => @double(value), + UnionMember1 value => max(value), + string value => @string(value), + _ => throw new ImageKitInvalidDataException("Data did not match any variant of Radius"), + }; + } + + public static implicit operator Radius(double value) => new(value); + + public static implicit operator Radius(UnionMember1 value) => new(value); + + public static implicit operator Radius(string value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException("Data did not match any variant of Radius"); + } + this.Switch((_) => { }, (max) => max.Validate(), (_) => { }); + } + + public virtual bool Equals(Radius? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class RadiusConverter : JsonConverter +{ + public override Radius? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write(Utf8JsonWriter writer, Radius value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(UnionMember1Converter))] +public record class UnionMember1 +{ + public JsonElement Element { get; private init; } + + public UnionMember1() + { + Element = JsonSerializer.SerializeToElement("max"); + } + + internal UnionMember1(JsonElement element) + { + Element = element; + } + + /// + /// Validates that the instance's underlying value is the expected constant. + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public void Validate() + { + if (this != new UnionMember1()) + { + throw new ImageKitInvalidDataException("Invalid value given for 'UnionMember1'"); + } + } + + public override int GetHashCode() + { + return 0; + } + + public virtual bool Equals(UnionMember1? other) + { + if (other == null) + { + return false; + } + + return JsonElement.DeepEquals(this.Element, other.Element); + } +} + +class UnionMember1Converter : JsonConverter +{ + public override UnionMember1? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write( + Utf8JsonWriter writer, + UnionMember1 value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Element, options); + } +} + +/// +/// Controls the width of the solid color overlay. Accepts a numeric value or an +/// arithmetic expression (e.g., `bw_mul_0.2` or `bh_div_2`). Learn about [arithmetic +/// expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). +/// +[JsonConverter(typeof(WidthConverter))] +public record class Width : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public Width(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Width(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Width(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public void Switch(Action @double, Action @string) + { + switch (this.Value) + { + case double value: + @double(value); + break; + case string value: + @string(value); + break; + default: + throw new ImageKitInvalidDataException("Data did not match any variant of Width"); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public T Match(Func @double, Func @string) + { + return this.Value switch + { + double value => @double(value), + string value => @string(value), + _ => throw new ImageKitInvalidDataException("Data did not match any variant of Width"), + }; + } + + public static implicit operator Width(double value) => new(value); + + public static implicit operator Width(string value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException("Data did not match any variant of Width"); + } + } + + public virtual bool Equals(Width? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class WidthConverter : JsonConverter +{ + public override Width? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write(Utf8JsonWriter writer, Width value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} diff --git a/src/ImageKit/Models/SrcOptions.cs b/src/ImageKit/Models/SrcOptions.cs new file mode 100644 index 00000000..808eed52 --- /dev/null +++ b/src/ImageKit/Models/SrcOptions.cs @@ -0,0 +1,231 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; + +namespace ImageKit.Models; + +/// +/// Options for generating ImageKit URLs with transformations. See the [Transformations guide](https://imagekit.io/docs/transformations). +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class SrcOptions : JsonModel +{ + /// + /// Accepts a relative or absolute path of the resource. If a relative path is + /// provided, it is appended to the `urlEndpoint`. If an absolute path is provided, + /// `urlEndpoint` is ignored. + /// + public required string Src + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("src"); + } + init { this._rawData.Set("src", value); } + } + + /// + /// Get your urlEndpoint from the [ImageKit dashboard](https://imagekit.io/dashboard/url-endpoints). + /// + public required string UrlEndpoint + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("urlEndpoint"); + } + init { this._rawData.Set("urlEndpoint", value); } + } + + /// + /// When you want the signed URL to expire, specified in seconds. If `expiresIn` + /// is anything above 0, the URL will always be signed even if `signed` is set + /// to false. If not specified and `signed` is `true`, the signed URL will not + /// expire (valid indefinitely). + /// + /// Example: Setting `expiresIn: 3600` will make the URL expire 1 hour from + /// generation time. After the expiry time, the signed URL will no longer be valid + /// and ImageKit will return a 401 Unauthorized status code. + /// + /// [Learn more](https://imagekit.io/docs/media-delivery-basic-security#how-to-generate-signed-urls). + /// + public double? ExpiresIn + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("expiresIn"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("expiresIn", value); + } + } + + /// + /// These are additional query parameters that you want to add to the final URL. + /// They can be any query parameters and not necessarily related to ImageKit. + /// This is especially useful if you want to add a versioning parameter to your + /// URLs. + /// + public IReadOnlyDictionary? QueryParameters + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>( + "queryParameters" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "queryParameters", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + + /// + /// Whether to sign the URL or not. Set this to `true` if you want to generate + /// a signed URL. If `signed` is `true` and `expiresIn` is not specified, the + /// signed URL will not expire (valid indefinitely). Note: If `expiresIn` is + /// set to any value above 0, the URL will always be signed regardless of this + /// setting. [Learn more](https://imagekit.io/docs/media-delivery-basic-security#how-to-generate-signed-urls). + /// + public bool? Signed + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("signed"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("signed", value); + } + } + + /// + /// An array of objects specifying the transformations to be applied in the URL. + /// If more than one transformation is specified, they are applied in the order + /// they are specified as chained transformations. See [Chained transformations](https://imagekit.io/docs/transformations#chained-transformations). + /// + public IReadOnlyList? Transformation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>( + "transformation" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "transformation", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// By default, the transformation string is added as a query parameter in the + /// URL, e.g., `?tr=w-100,h-100`. If you want to add the transformation string + /// in the path of the URL, set this to `path`. Learn more in the [Transformations + /// guide](https://imagekit.io/docs/transformations). + /// + public ApiEnum? TransformationPosition + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>( + "transformationPosition" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("transformationPosition", value); + } + } + + /// + public override void Validate() + { + _ = this.Src; + _ = this.UrlEndpoint; + _ = this.ExpiresIn; + _ = this.QueryParameters; + _ = this.Signed; + foreach (var item in this.Transformation ?? []) + { + item.Validate(); + } + this.TransformationPosition?.Validate(); + } + + public SrcOptions() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SrcOptions(SrcOptions srcOptions) + : base(srcOptions) { } +#pragma warning restore CS8618 + + public SrcOptions(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + SrcOptions(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static SrcOptions FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class SrcOptionsFromRaw : IFromRawJson +{ + /// + public SrcOptions FromRawUnchecked(IReadOnlyDictionary rawData) => + SrcOptions.FromRawUnchecked(rawData); +} diff --git a/src/Imagekit/Models/StreamingResolution.cs b/src/ImageKit/Models/StreamingResolution.cs similarity index 94% rename from src/Imagekit/Models/StreamingResolution.cs rename to src/ImageKit/Models/StreamingResolution.cs index 66591680..f6d8879a 100644 --- a/src/Imagekit/Models/StreamingResolution.cs +++ b/src/ImageKit/Models/StreamingResolution.cs @@ -1,9 +1,9 @@ using System; using System.Text.Json; using System.Text.Json.Serialization; -using Imagekit.Exceptions; +using ImageKit.Exceptions; -namespace Imagekit.Models; +namespace ImageKit.Models; /// /// Available streaming resolutions for [adaptive bitrate streaming](https://imagekit.io/docs/adaptive-bitrate-streaming) diff --git a/src/ImageKit/Models/SubtitleOverlay.cs b/src/ImageKit/Models/SubtitleOverlay.cs new file mode 100644 index 00000000..5facadaf --- /dev/null +++ b/src/ImageKit/Models/SubtitleOverlay.cs @@ -0,0 +1,449 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; +using ImageKit.Exceptions; + +namespace ImageKit.Models; + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class SubtitleOverlay : JsonModel +{ + /// + /// Controls how the layer blends with the base image or underlying content. + /// Maps to `lm` in the URL. By default, layers completely cover the base image + /// beneath them. Layer modes change this behavior: - `multiply`: Multiplies + /// the pixel values of the layer with the base image. The result is always darker + /// than the original images. This is ideal for applying shadows or color tints. + /// - `displace`: Uses the layer as a displacement map to distort pixels in the + /// base image. The red channel controls horizontal displacement, and the green + /// channel controls vertical displacement. Requires `x` or `y` parameter to control + /// displacement magnitude. - `cutout`: Acts as an inverse mask where opaque areas + /// of the layer turn the base image transparent, while transparent areas leave + /// the base image unchanged. This mode functions like a hole-punch, effectively + /// cutting the shape of the layer out of the underlying image. - `cutter`: Acts + /// as a shape mask where only the parts of the base image that fall inside the + /// opaque area of the layer are preserved. This mode functions like a cookie-cutter, + /// trimming the base image to match the specific dimensions and shape of the + /// layer. See [Layer modes](https://imagekit.io/docs/add-overlays-on-images#layer-modes). + /// + public ApiEnum? LayerMode + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("layerMode"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("layerMode", value); + } + } + + public OverlayPosition? Position + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("position"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("position", value); + } + } + + public OverlayTiming? Timing + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("timing"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("timing", value); + } + } + + /// + /// Specifies the relative path to the subtitle file used as an overlay. + /// + public required string Input + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("input"); + } + init { this._rawData.Set("input", value); } + } + + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// The input path can be included in the layer as either `i-{input}` or `ie-{base64_encoded_input}`. + /// By default, the SDK determines the appropriate format automatically. To + /// always use base64 encoding (`ie-{base64}`), set this parameter to `base64`. + /// To always use plain text (`i-{input}`), set it to `plain`. + /// + /// Regardless of the encoding method: - Leading and trailing slashes are + /// removed. - Remaining slashes within the path are replaced with `@@` when using + /// plain text. + /// + public ApiEnum? Encoding + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass< + ApiEnum + >("encoding"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("encoding", value); + } + } + + /// + /// Control styling of the subtitle. See [Styling subtitles](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer). + /// + public IReadOnlyList? Transformation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>( + "transformation" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "transformation", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + public static implicit operator BaseOverlay(SubtitleOverlay subtitleOverlay) => + new() + { + LayerMode = subtitleOverlay.LayerMode, + Position = subtitleOverlay.Position, + Timing = subtitleOverlay.Timing, + }; + + /// + public override void Validate() + { + this.LayerMode?.Validate(); + this.Position?.Validate(); + this.Timing?.Validate(); + _ = this.Input; + if (!JsonElement.DeepEquals(this.Type, JsonSerializer.SerializeToElement("subtitle"))) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + this.Encoding?.Validate(); + foreach (var item in this.Transformation ?? []) + { + item.Validate(); + } + } + + public SubtitleOverlay() + { + this.Type = JsonSerializer.SerializeToElement("subtitle"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubtitleOverlay(SubtitleOverlay subtitleOverlay) + : base(subtitleOverlay) { } +#pragma warning restore CS8618 + + public SubtitleOverlay(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("subtitle"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + SubtitleOverlay(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static SubtitleOverlay FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public SubtitleOverlay(string input) + : this() + { + this.Input = input; + } +} + +class SubtitleOverlayFromRaw : IFromRawJson +{ + /// + public SubtitleOverlay FromRawUnchecked(IReadOnlyDictionary rawData) => + SubtitleOverlay.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + SubtitleOverlayIntersectionMember1, + SubtitleOverlayIntersectionMember1FromRaw + >) +)] +public sealed record class SubtitleOverlayIntersectionMember1 : JsonModel +{ + /// + /// Specifies the relative path to the subtitle file used as an overlay. + /// + public required string Input + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("input"); + } + init { this._rawData.Set("input", value); } + } + + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// The input path can be included in the layer as either `i-{input}` or `ie-{base64_encoded_input}`. + /// By default, the SDK determines the appropriate format automatically. To + /// always use base64 encoding (`ie-{base64}`), set this parameter to `base64`. + /// To always use plain text (`i-{input}`), set it to `plain`. + /// + /// Regardless of the encoding method: - Leading and trailing slashes are + /// removed. - Remaining slashes within the path are replaced with `@@` when using + /// plain text. + /// + public ApiEnum? Encoding + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass< + ApiEnum + >("encoding"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("encoding", value); + } + } + + /// + /// Control styling of the subtitle. See [Styling subtitles](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer). + /// + public IReadOnlyList? Transformation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>( + "transformation" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "transformation", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.Input; + if (!JsonElement.DeepEquals(this.Type, JsonSerializer.SerializeToElement("subtitle"))) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + this.Encoding?.Validate(); + foreach (var item in this.Transformation ?? []) + { + item.Validate(); + } + } + + public SubtitleOverlayIntersectionMember1() + { + this.Type = JsonSerializer.SerializeToElement("subtitle"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubtitleOverlayIntersectionMember1( + SubtitleOverlayIntersectionMember1 subtitleOverlayIntersectionMember1 + ) + : base(subtitleOverlayIntersectionMember1) { } +#pragma warning restore CS8618 + + public SubtitleOverlayIntersectionMember1(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("subtitle"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + SubtitleOverlayIntersectionMember1(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static SubtitleOverlayIntersectionMember1 FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public SubtitleOverlayIntersectionMember1(string input) + : this() + { + this.Input = input; + } +} + +class SubtitleOverlayIntersectionMember1FromRaw : IFromRawJson +{ + /// + public SubtitleOverlayIntersectionMember1 FromRawUnchecked( + IReadOnlyDictionary rawData + ) => SubtitleOverlayIntersectionMember1.FromRawUnchecked(rawData); +} + +/// +/// The input path can be included in the layer as either `i-{input}` or `ie-{base64_encoded_input}`. +/// By default, the SDK determines the appropriate format automatically. To always +/// use base64 encoding (`ie-{base64}`), set this parameter to `base64`. To always +/// use plain text (`i-{input}`), set it to `plain`. +/// +/// Regardless of the encoding method: - Leading and trailing slashes are removed. +/// - Remaining slashes within the path are replaced with `@@` when using plain text. +/// +[JsonConverter(typeof(SubtitleOverlayIntersectionMember1EncodingConverter))] +public enum SubtitleOverlayIntersectionMember1Encoding +{ + Auto, + Plain, + Base64, +} + +sealed class SubtitleOverlayIntersectionMember1EncodingConverter + : JsonConverter +{ + public override SubtitleOverlayIntersectionMember1Encoding Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "auto" => SubtitleOverlayIntersectionMember1Encoding.Auto, + "plain" => SubtitleOverlayIntersectionMember1Encoding.Plain, + "base64" => SubtitleOverlayIntersectionMember1Encoding.Base64, + _ => (SubtitleOverlayIntersectionMember1Encoding)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + SubtitleOverlayIntersectionMember1Encoding value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + SubtitleOverlayIntersectionMember1Encoding.Auto => "auto", + SubtitleOverlayIntersectionMember1Encoding.Plain => "plain", + SubtitleOverlayIntersectionMember1Encoding.Base64 => "base64", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} diff --git a/src/ImageKit/Models/SubtitleOverlayTransformation.cs b/src/ImageKit/Models/SubtitleOverlayTransformation.cs new file mode 100644 index 00000000..9a012411 --- /dev/null +++ b/src/ImageKit/Models/SubtitleOverlayTransformation.cs @@ -0,0 +1,296 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; +using ImageKit.Exceptions; + +namespace ImageKit.Models; + +/// +/// Subtitle styling options. [Learn more](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) +/// from the docs. +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class SubtitleOverlayTransformation : JsonModel +{ + /// + /// Specifies the subtitle background color using a standard color name, an RGB + /// color code (e.g., FF0000), or an RGBA color code (e.g., FFAABB50). + /// + /// [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + /// + public string? Background + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("background"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("background", value); + } + } + + /// + /// Sets the font color of the subtitle text using a standard color name, an + /// RGB color code (e.g., FF0000), or an RGBA color code (e.g., FFAABB50). + /// + /// [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + /// + public string? Color + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("color"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("color", value); + } + } + + /// + /// Sets the font family of subtitle text. Refer to the [supported fonts documented](https://imagekit.io/docs/add-overlays-on-images#supported-text-font-list) + /// in the ImageKit transformations guide. + /// + public string? FontFamily + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("fontFamily"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("fontFamily", value); + } + } + + /// + /// Sets the font outline of the subtitle text. Requires the outline width (an + /// integer) and the outline color (as an RGB color code, RGBA color code, or + /// standard web color name) separated by an underscore. Example: `fol-2_blue` + /// (outline width of 2px and outline color blue), `fol-2_A1CCDD` (outline width + /// of 2px and outline color `#A1CCDD`) and `fol-2_A1CCDD50` (outline width of + /// 2px and outline color `#A1CCDD` at 50% opacity). + /// + /// [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + /// + public string? FontOutline + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("fontOutline"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("fontOutline", value); + } + } + + /// + /// Sets the font shadow for the subtitle text. Requires the shadow color (as + /// an RGB color code, RGBA color code, or standard web color name) and shadow + /// indent (an integer) separated by an underscore. Example: `fsh-blue_2` (shadow + /// color blue, indent of 2px), `fsh-A1CCDD_3` (shadow color `#A1CCDD`, indent + /// of 3px), `fsh-A1CCDD50_3` (shadow color `#A1CCDD` at 50% opacity, indent of 3px). + /// + /// [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + /// + public string? FontShadow + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("fontShadow"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("fontShadow", value); + } + } + + /// + /// Sets the font size of subtitle text. + /// + /// [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + /// + public double? FontSize + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("fontSize"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("fontSize", value); + } + } + + /// + /// Sets the typography style of the subtitle text. Supports values are `b` for + /// bold, `i` for italics, and `b_i` for bold with italics. + /// + /// [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + /// + public ApiEnum? Typography + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("typography"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("typography", value); + } + } + + /// + public override void Validate() + { + _ = this.Background; + _ = this.Color; + _ = this.FontFamily; + _ = this.FontOutline; + _ = this.FontShadow; + _ = this.FontSize; + this.Typography?.Validate(); + } + + public SubtitleOverlayTransformation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubtitleOverlayTransformation( + SubtitleOverlayTransformation subtitleOverlayTransformation + ) + : base(subtitleOverlayTransformation) { } +#pragma warning restore CS8618 + + public SubtitleOverlayTransformation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + SubtitleOverlayTransformation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static SubtitleOverlayTransformation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class SubtitleOverlayTransformationFromRaw : IFromRawJson +{ + /// + public SubtitleOverlayTransformation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => SubtitleOverlayTransformation.FromRawUnchecked(rawData); +} + +/// +/// Sets the typography style of the subtitle text. Supports values are `b` for bold, +/// `i` for italics, and `b_i` for bold with italics. +/// +/// [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) +/// +[JsonConverter(typeof(TypographyConverter))] +public enum Typography +{ + B, + I, + BI, +} + +sealed class TypographyConverter : JsonConverter +{ + public override Typography Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "b" => Typography.B, + "i" => Typography.I, + "b_i" => Typography.BI, + _ => (Typography)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + Typography value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + Typography.B => "b", + Typography.I => "i", + Typography.BI => "b_i", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} diff --git a/src/ImageKit/Models/TextOverlay.cs b/src/ImageKit/Models/TextOverlay.cs new file mode 100644 index 00000000..5fbad196 --- /dev/null +++ b/src/ImageKit/Models/TextOverlay.cs @@ -0,0 +1,449 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; +using ImageKit.Exceptions; + +namespace ImageKit.Models; + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class TextOverlay : JsonModel +{ + /// + /// Controls how the layer blends with the base image or underlying content. + /// Maps to `lm` in the URL. By default, layers completely cover the base image + /// beneath them. Layer modes change this behavior: - `multiply`: Multiplies + /// the pixel values of the layer with the base image. The result is always darker + /// than the original images. This is ideal for applying shadows or color tints. + /// - `displace`: Uses the layer as a displacement map to distort pixels in the + /// base image. The red channel controls horizontal displacement, and the green + /// channel controls vertical displacement. Requires `x` or `y` parameter to control + /// displacement magnitude. - `cutout`: Acts as an inverse mask where opaque areas + /// of the layer turn the base image transparent, while transparent areas leave + /// the base image unchanged. This mode functions like a hole-punch, effectively + /// cutting the shape of the layer out of the underlying image. - `cutter`: Acts + /// as a shape mask where only the parts of the base image that fall inside the + /// opaque area of the layer are preserved. This mode functions like a cookie-cutter, + /// trimming the base image to match the specific dimensions and shape of the + /// layer. See [Layer modes](https://imagekit.io/docs/add-overlays-on-images#layer-modes). + /// + public ApiEnum? LayerMode + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("layerMode"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("layerMode", value); + } + } + + public OverlayPosition? Position + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("position"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("position", value); + } + } + + public OverlayTiming? Timing + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("timing"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("timing", value); + } + } + + /// + /// Specifies the text to be displayed in the overlay. The SDK automatically + /// handles special characters and encoding. + /// + public required string Text + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("text"); + } + init { this._rawData.Set("text", value); } + } + + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// Text can be included in the layer as either `i-{input}` (plain text) or `ie-{base64_encoded_input}` + /// (base64). By default, the SDK selects the appropriate format based on the + /// input text. To always use base64 (`ie-{base64}`), set this parameter to `base64`. + /// To always use plain text (`i-{input}`), set it to `plain`. + /// + /// Regardless of the encoding method, the input text is always percent-encoded + /// to ensure it is URL-safe. + /// + public ApiEnum? Encoding + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass< + ApiEnum + >("encoding"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("encoding", value); + } + } + + /// + /// Control styling of the text overlay. See [Text overlays](https://imagekit.io/docs/add-overlays-on-images#text-overlay). + /// + public IReadOnlyList? Transformation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>( + "transformation" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "transformation", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + public static implicit operator BaseOverlay(TextOverlay textOverlay) => + new() + { + LayerMode = textOverlay.LayerMode, + Position = textOverlay.Position, + Timing = textOverlay.Timing, + }; + + /// + public override void Validate() + { + this.LayerMode?.Validate(); + this.Position?.Validate(); + this.Timing?.Validate(); + _ = this.Text; + if (!JsonElement.DeepEquals(this.Type, JsonSerializer.SerializeToElement("text"))) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + this.Encoding?.Validate(); + foreach (var item in this.Transformation ?? []) + { + item.Validate(); + } + } + + public TextOverlay() + { + this.Type = JsonSerializer.SerializeToElement("text"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TextOverlay(TextOverlay textOverlay) + : base(textOverlay) { } +#pragma warning restore CS8618 + + public TextOverlay(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("text"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TextOverlay(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TextOverlay FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public TextOverlay(string text) + : this() + { + this.Text = text; + } +} + +class TextOverlayFromRaw : IFromRawJson +{ + /// + public TextOverlay FromRawUnchecked(IReadOnlyDictionary rawData) => + TextOverlay.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + TextOverlayIntersectionMember1, + TextOverlayIntersectionMember1FromRaw + >) +)] +public sealed record class TextOverlayIntersectionMember1 : JsonModel +{ + /// + /// Specifies the text to be displayed in the overlay. The SDK automatically + /// handles special characters and encoding. + /// + public required string Text + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("text"); + } + init { this._rawData.Set("text", value); } + } + + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// Text can be included in the layer as either `i-{input}` (plain text) or `ie-{base64_encoded_input}` + /// (base64). By default, the SDK selects the appropriate format based on the + /// input text. To always use base64 (`ie-{base64}`), set this parameter to `base64`. + /// To always use plain text (`i-{input}`), set it to `plain`. + /// + /// Regardless of the encoding method, the input text is always percent-encoded + /// to ensure it is URL-safe. + /// + public ApiEnum? Encoding + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass< + ApiEnum + >("encoding"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("encoding", value); + } + } + + /// + /// Control styling of the text overlay. See [Text overlays](https://imagekit.io/docs/add-overlays-on-images#text-overlay). + /// + public IReadOnlyList? Transformation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>( + "transformation" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "transformation", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.Text; + if (!JsonElement.DeepEquals(this.Type, JsonSerializer.SerializeToElement("text"))) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + this.Encoding?.Validate(); + foreach (var item in this.Transformation ?? []) + { + item.Validate(); + } + } + + public TextOverlayIntersectionMember1() + { + this.Type = JsonSerializer.SerializeToElement("text"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TextOverlayIntersectionMember1( + TextOverlayIntersectionMember1 textOverlayIntersectionMember1 + ) + : base(textOverlayIntersectionMember1) { } +#pragma warning restore CS8618 + + public TextOverlayIntersectionMember1(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("text"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TextOverlayIntersectionMember1(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TextOverlayIntersectionMember1 FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public TextOverlayIntersectionMember1(string text) + : this() + { + this.Text = text; + } +} + +class TextOverlayIntersectionMember1FromRaw : IFromRawJson +{ + /// + public TextOverlayIntersectionMember1 FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TextOverlayIntersectionMember1.FromRawUnchecked(rawData); +} + +/// +/// Text can be included in the layer as either `i-{input}` (plain text) or `ie-{base64_encoded_input}` +/// (base64). By default, the SDK selects the appropriate format based on the input +/// text. To always use base64 (`ie-{base64}`), set this parameter to `base64`. +/// To always use plain text (`i-{input}`), set it to `plain`. +/// +/// Regardless of the encoding method, the input text is always percent-encoded +/// to ensure it is URL-safe. +/// +[JsonConverter(typeof(TextOverlayIntersectionMember1EncodingConverter))] +public enum TextOverlayIntersectionMember1Encoding +{ + Auto, + Plain, + Base64, +} + +sealed class TextOverlayIntersectionMember1EncodingConverter + : JsonConverter +{ + public override TextOverlayIntersectionMember1Encoding Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "auto" => TextOverlayIntersectionMember1Encoding.Auto, + "plain" => TextOverlayIntersectionMember1Encoding.Plain, + "base64" => TextOverlayIntersectionMember1Encoding.Base64, + _ => (TextOverlayIntersectionMember1Encoding)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + TextOverlayIntersectionMember1Encoding value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + TextOverlayIntersectionMember1Encoding.Auto => "auto", + TextOverlayIntersectionMember1Encoding.Plain => "plain", + TextOverlayIntersectionMember1Encoding.Base64 => "base64", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} diff --git a/src/ImageKit/Models/TextOverlayTransformation.cs b/src/ImageKit/Models/TextOverlayTransformation.cs new file mode 100644 index 00000000..5009a5e3 --- /dev/null +++ b/src/ImageKit/Models/TextOverlayTransformation.cs @@ -0,0 +1,1994 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; +using ImageKit.Exceptions; + +namespace ImageKit.Models; + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class TextOverlayTransformation : JsonModel +{ + /// + /// Specifies the transparency level of the text overlay. Accepts integers from + /// `1` to `9`. + /// + public double? Alpha + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("alpha"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("alpha", value); + } + } + + /// + /// Specifies the background color of the text overlay. Accepts an RGB hex code, + /// an RGBA code, or a color name. + /// + public string? Background + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("background"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("background", value); + } + } + + /// + /// Flip/mirror the text horizontally, vertically, or in both directions. Acceptable + /// values: `h` (horizontal), `v` (vertical), `h_v` (horizontal and vertical), + /// or `v_h`. + /// + public ApiEnum? Flip + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("flip"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("flip", value); + } + } + + /// + /// Specifies the font color of the overlaid text. Accepts an RGB hex code (e.g., + /// `FF0000`), an RGBA code (e.g., `FFAABB50`), or a color name. + /// + public string? FontColor + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("fontColor"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("fontColor", value); + } + } + + /// + /// Specifies the font family of the overlaid text. Choose from the supported + /// fonts list or use a custom font. See [Supported fonts](https://imagekit.io/docs/add-overlays-on-images#supported-text-font-list) + /// and [Custom font](https://imagekit.io/docs/add-overlays-on-images#change-font-family-in-text-overlay). + /// + public string? FontFamily + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("fontFamily"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("fontFamily", value); + } + } + + /// + /// Specifies the font size of the overlaid text. Accepts a numeric value or an + /// arithmetic expression. + /// + public FontSize? FontSize + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("fontSize"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("fontSize", value); + } + } + + /// + /// Specifies the inner alignment of the text when width is more than the text + /// length. + /// + public ApiEnum? InnerAlignment + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>( + "innerAlignment" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("innerAlignment", value); + } + } + + /// + /// Specifies the line height for multi-line text overlays. It will come into + /// effect only if the text wraps over multiple lines. Accepts either an integer + /// value or an arithmetic expression. + /// + public LineHeight? LineHeight + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("lineHeight"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("lineHeight", value); + } + } + + /// + /// Specifies the padding around the overlaid text. Can be provided as a single + /// positive integer or multiple values separated by underscores (following CSS + /// shorthand order). Arithmetic expressions are also accepted. + /// + public Padding? Padding + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("padding"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("padding", value); + } + } + + /// + /// Specifies the corner radius: - Single value (positive integer): Applied to + /// all corners (e.g., `20`). - `max`: Creates a circular or oval shape. - Per-corner + /// array: Provide four underscore-separated values representing top-left, top-right, + /// bottom-right, and bottom-left corners respectively (e.g., `10_20_30_40`). + /// See [Radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). + /// + public TextOverlayTransformationRadius? Radius + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("radius"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("radius", value); + } + } + + /// + /// Specifies the rotation angle of the text overlay. Accepts a numeric value + /// for clockwise rotation or a string prefixed with "N" for counter-clockwise + /// rotation. + /// + public Rotation? Rotation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("rotation"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("rotation", value); + } + } + + /// + /// Specifies the typography style of the text. Supported values: - Single + /// styles: `b` (bold), `i` (italic), `strikethrough`. - Combinations: Any + /// combination separated by underscores, e.g., `b_i`, `b_i_strikethrough`. + /// + public string? Typography + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("typography"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("typography", value); + } + } + + /// + /// Specifies the maximum width (in pixels) of the overlaid text. The text wraps + /// automatically, and arithmetic expressions (e.g., `bw_mul_0.2` or `bh_div_2`) + /// are supported. Useful when used in conjunction with the `background`. Learn + /// about [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + /// + public TextOverlayTransformationWidth? Width + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("width"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("width", value); + } + } + + /// + public override void Validate() + { + _ = this.Alpha; + _ = this.Background; + this.Flip?.Validate(); + _ = this.FontColor; + _ = this.FontFamily; + this.FontSize?.Validate(); + this.InnerAlignment?.Validate(); + this.LineHeight?.Validate(); + this.Padding?.Validate(); + this.Radius?.Validate(); + this.Rotation?.Validate(); + _ = this.Typography; + this.Width?.Validate(); + } + + public TextOverlayTransformation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TextOverlayTransformation(TextOverlayTransformation textOverlayTransformation) + : base(textOverlayTransformation) { } +#pragma warning restore CS8618 + + public TextOverlayTransformation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TextOverlayTransformation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TextOverlayTransformation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TextOverlayTransformationFromRaw : IFromRawJson +{ + /// + public TextOverlayTransformation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TextOverlayTransformation.FromRawUnchecked(rawData); +} + +/// +/// Flip/mirror the text horizontally, vertically, or in both directions. Acceptable +/// values: `h` (horizontal), `v` (vertical), `h_v` (horizontal and vertical), or +/// `v_h`. +/// +[JsonConverter(typeof(FlipConverter))] +public enum Flip +{ + H, + V, + HV, + VH, +} + +sealed class FlipConverter : JsonConverter +{ + public override Flip Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "h" => Flip.H, + "v" => Flip.V, + "h_v" => Flip.HV, + "v_h" => Flip.VH, + _ => (Flip)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Flip value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + Flip.H => "h", + Flip.V => "v", + Flip.HV => "h_v", + Flip.VH => "v_h", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Specifies the font size of the overlaid text. Accepts a numeric value or an arithmetic expression. +/// +[JsonConverter(typeof(FontSizeConverter))] +public record class FontSize : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public FontSize(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public FontSize(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public FontSize(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public void Switch(Action @double, Action @string) + { + switch (this.Value) + { + case double value: + @double(value); + break; + case string value: + @string(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of FontSize" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public T Match(Func @double, Func @string) + { + return this.Value switch + { + double value => @double(value), + string value => @string(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of FontSize" + ), + }; + } + + public static implicit operator FontSize(double value) => new(value); + + public static implicit operator FontSize(string value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException("Data did not match any variant of FontSize"); + } + } + + public virtual bool Equals(FontSize? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class FontSizeConverter : JsonConverter +{ + public override FontSize? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write(Utf8JsonWriter writer, FontSize value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +/// +/// Specifies the inner alignment of the text when width is more than the text length. +/// +[JsonConverter(typeof(InnerAlignmentConverter))] +public enum InnerAlignment +{ + Left, + Right, + Center, +} + +sealed class InnerAlignmentConverter : JsonConverter +{ + public override InnerAlignment Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "left" => InnerAlignment.Left, + "right" => InnerAlignment.Right, + "center" => InnerAlignment.Center, + _ => (InnerAlignment)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + InnerAlignment value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + InnerAlignment.Left => "left", + InnerAlignment.Right => "right", + InnerAlignment.Center => "center", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Specifies the line height for multi-line text overlays. It will come into effect +/// only if the text wraps over multiple lines. Accepts either an integer value or +/// an arithmetic expression. +/// +[JsonConverter(typeof(LineHeightConverter))] +public record class LineHeight : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public LineHeight(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public LineHeight(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public LineHeight(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public void Switch(Action @double, Action @string) + { + switch (this.Value) + { + case double value: + @double(value); + break; + case string value: + @string(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of LineHeight" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public T Match(Func @double, Func @string) + { + return this.Value switch + { + double value => @double(value), + string value => @string(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of LineHeight" + ), + }; + } + + public static implicit operator LineHeight(double value) => new(value); + + public static implicit operator LineHeight(string value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException("Data did not match any variant of LineHeight"); + } + } + + public virtual bool Equals(LineHeight? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class LineHeightConverter : JsonConverter +{ + public override LineHeight? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + LineHeight value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +/// +/// Specifies the padding around the overlaid text. Can be provided as a single positive +/// integer or multiple values separated by underscores (following CSS shorthand +/// order). Arithmetic expressions are also accepted. +/// +[JsonConverter(typeof(PaddingConverter))] +public record class Padding : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public Padding(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Padding(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Padding(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public void Switch(Action @double, Action @string) + { + switch (this.Value) + { + case double value: + @double(value); + break; + case string value: + @string(value); + break; + default: + throw new ImageKitInvalidDataException("Data did not match any variant of Padding"); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public T Match(Func @double, Func @string) + { + return this.Value switch + { + double value => @double(value), + string value => @string(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of Padding" + ), + }; + } + + public static implicit operator Padding(double value) => new(value); + + public static implicit operator Padding(string value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException("Data did not match any variant of Padding"); + } + } + + public virtual bool Equals(Padding? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class PaddingConverter : JsonConverter +{ + public override Padding? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write(Utf8JsonWriter writer, Padding value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +/// +/// Specifies the corner radius: - Single value (positive integer): Applied to all +/// corners (e.g., `20`). - `max`: Creates a circular or oval shape. - Per-corner +/// array: Provide four underscore-separated values representing top-left, top-right, +/// bottom-right, and bottom-left corners respectively (e.g., `10_20_30_40`). See +/// [Radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). +/// +[JsonConverter(typeof(TextOverlayTransformationRadiusConverter))] +public record class TextOverlayTransformationRadius : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public TextOverlayTransformationRadius(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public TextOverlayTransformationRadius( + TextOverlayTransformationRadiusUnionMember1 value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public TextOverlayTransformationRadius(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public TextOverlayTransformationRadius(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickMax(out var value)) { + /// // `value` is of type `TextOverlayTransformationRadiusUnionMember1` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMax( + [NotNullWhen(true)] out TextOverlayTransformationRadiusUnionMember1? value + ) + { + value = this.Value as TextOverlayTransformationRadiusUnionMember1; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (double value) => {...}, + /// (TextOverlayTransformationRadiusUnionMember1 value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public void Switch( + Action @double, + Action max, + Action @string + ) + { + switch (this.Value) + { + case double value: + @double(value); + break; + case TextOverlayTransformationRadiusUnionMember1 value: + max(value); + break; + case string value: + @string(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of TextOverlayTransformationRadius" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (double value) => {...}, + /// (TextOverlayTransformationRadiusUnionMember1 value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public T Match( + Func @double, + Func max, + Func @string + ) + { + return this.Value switch + { + double value => @double(value), + TextOverlayTransformationRadiusUnionMember1 value => max(value), + string value => @string(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of TextOverlayTransformationRadius" + ), + }; + } + + public static implicit operator TextOverlayTransformationRadius(double value) => new(value); + + public static implicit operator TextOverlayTransformationRadius( + TextOverlayTransformationRadiusUnionMember1 value + ) => new(value); + + public static implicit operator TextOverlayTransformationRadius(string value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of TextOverlayTransformationRadius" + ); + } + this.Switch((_) => { }, (max) => max.Validate(), (_) => { }); + } + + public virtual bool Equals(TextOverlayTransformationRadius? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class TextOverlayTransformationRadiusConverter + : JsonConverter +{ + public override TextOverlayTransformationRadius? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + TextOverlayTransformationRadius value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(TextOverlayTransformationRadiusUnionMember1Converter))] +public record class TextOverlayTransformationRadiusUnionMember1 +{ + public JsonElement Element { get; private init; } + + public TextOverlayTransformationRadiusUnionMember1() + { + Element = JsonSerializer.SerializeToElement("max"); + } + + internal TextOverlayTransformationRadiusUnionMember1(JsonElement element) + { + Element = element; + } + + /// + /// Validates that the instance's underlying value is the expected constant. + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public void Validate() + { + if (this != new TextOverlayTransformationRadiusUnionMember1()) + { + throw new ImageKitInvalidDataException( + "Invalid value given for 'TextOverlayTransformationRadiusUnionMember1'" + ); + } + } + + public override int GetHashCode() + { + return 0; + } + + public virtual bool Equals(TextOverlayTransformationRadiusUnionMember1? other) + { + if (other == null) + { + return false; + } + + return JsonElement.DeepEquals(this.Element, other.Element); + } +} + +class TextOverlayTransformationRadiusUnionMember1Converter + : JsonConverter +{ + public override TextOverlayTransformationRadiusUnionMember1? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write( + Utf8JsonWriter writer, + TextOverlayTransformationRadiusUnionMember1 value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Element, options); + } +} + +/// +/// Specifies the rotation angle of the text overlay. Accepts a numeric value for +/// clockwise rotation or a string prefixed with "N" for counter-clockwise rotation. +/// +[JsonConverter(typeof(RotationConverter))] +public record class Rotation : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public Rotation(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Rotation(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Rotation(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public void Switch(Action @double, Action @string) + { + switch (this.Value) + { + case double value: + @double(value); + break; + case string value: + @string(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of Rotation" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public T Match(Func @double, Func @string) + { + return this.Value switch + { + double value => @double(value), + string value => @string(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of Rotation" + ), + }; + } + + public static implicit operator Rotation(double value) => new(value); + + public static implicit operator Rotation(string value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException("Data did not match any variant of Rotation"); + } + } + + public virtual bool Equals(Rotation? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class RotationConverter : JsonConverter +{ + public override Rotation? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write(Utf8JsonWriter writer, Rotation value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +/// +/// Specifies the maximum width (in pixels) of the overlaid text. The text wraps automatically, +/// and arithmetic expressions (e.g., `bw_mul_0.2` or `bh_div_2`) are supported. Useful +/// when used in conjunction with the `background`. Learn about [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). +/// +[JsonConverter(typeof(TextOverlayTransformationWidthConverter))] +public record class TextOverlayTransformationWidth : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public TextOverlayTransformationWidth(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public TextOverlayTransformationWidth(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public TextOverlayTransformationWidth(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public void Switch(Action @double, Action @string) + { + switch (this.Value) + { + case double value: + @double(value); + break; + case string value: + @string(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of TextOverlayTransformationWidth" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public T Match(Func @double, Func @string) + { + return this.Value switch + { + double value => @double(value), + string value => @string(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of TextOverlayTransformationWidth" + ), + }; + } + + public static implicit operator TextOverlayTransformationWidth(double value) => new(value); + + public static implicit operator TextOverlayTransformationWidth(string value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of TextOverlayTransformationWidth" + ); + } + } + + public virtual bool Equals(TextOverlayTransformationWidth? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class TextOverlayTransformationWidthConverter : JsonConverter +{ + public override TextOverlayTransformationWidth? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + TextOverlayTransformationWidth value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} diff --git a/src/ImageKit/Models/Transformation.cs b/src/ImageKit/Models/Transformation.cs new file mode 100644 index 00000000..504f3bcd --- /dev/null +++ b/src/ImageKit/Models/Transformation.cs @@ -0,0 +1,7002 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; +using ImageKit.Exceptions; + +namespace ImageKit.Models; + +/// +/// The SDK provides easy-to-use names for transformations. These names are converted +/// to the corresponding transformation string before being added to the URL. SDKs +/// are updated regularly to support new transformations. If you want to use a transformation +/// that is not supported by the SDK, You can use the `raw` parameter to pass the +/// transformation string directly. See the [Transformations documentation](https://imagekit.io/docs/transformations). +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Transformation : JsonModel +{ + /// + /// Uses AI to change the background. Provide a text prompt or a base64-encoded + /// prompt, e.g., `prompt-snow road` or `prompte-[urlencoded_base64_encoded_text]`. + /// Not supported inside overlay. See [AI Change Background](https://imagekit.io/docs/ai-transformations#change-background-e-changebg). + /// + public string? AIChangeBackground + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("aiChangeBackground"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("aiChangeBackground", value); + } + } + + /// + /// Adds an AI-based drop shadow around a foreground object on a transparent + /// or removed background. Optionally, control the direction, elevation, and + /// saturation of the light source (e.g., `az-45` to change light direction). + /// Pass `true` for the default drop shadow, or provide a string for a custom + /// drop shadow. Supported inside overlay. See [AI Drop Shadow](https://imagekit.io/docs/ai-transformations#ai-drop-shadow-e-dropshadow). + /// + public AIDropShadow? AIDropShadow + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("aiDropShadow"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("aiDropShadow", value); + } + } + + /// + /// Uses AI to edit images based on a text prompt. Provide a text prompt or a + /// base64-encoded prompt, e.g., `prompt-snow road` or `prompte-[urlencoded_base64_encoded_text]`. + /// Not supported inside overlay. See [AI Edit](https://imagekit.io/docs/ai-transformations#edit-image-e-edit). + /// + public string? AIEdit + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("aiEdit"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("aiEdit", value); + } + } + + /// + /// Applies ImageKit's in-house background removal. Supported inside overlay. + /// See [AI Background Removal](https://imagekit.io/docs/ai-transformations#imagekit-background-removal-e-bgremove). + /// + public ApiEnum? AIRemoveBackground + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>( + "aiRemoveBackground" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("aiRemoveBackground", value); + } + } + + /// + /// Uses third-party background removal. Note: It is recommended to use aiRemoveBackground, + /// ImageKit's in-house solution, which is more cost-effective. Supported inside + /// overlay. See [External Background Removal](https://imagekit.io/docs/ai-transformations#background-removal-e-removedotbg). + /// + public ApiEnum? AIRemoveBackgroundExternal + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>( + "aiRemoveBackgroundExternal" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("aiRemoveBackgroundExternal", value); + } + } + + /// + /// Performs AI-based retouching to improve faces or product shots. Not supported + /// inside overlay. See [AI Retouch](https://imagekit.io/docs/ai-transformations#retouch-e-retouch). + /// + public ApiEnum? AIRetouch + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("aiRetouch"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("aiRetouch", value); + } + } + + /// + /// Upscales images beyond their original dimensions using AI. Not supported + /// inside overlay. See [AI Upscale](https://imagekit.io/docs/ai-transformations#upscale-e-upscale). + /// + public ApiEnum? AIUpscale + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("aiUpscale"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("aiUpscale", value); + } + } + + /// + /// Generates a variation of an image using AI. This produces a new image with + /// slight variations from the original, such as changes in color, texture, and + /// other visual elements, while preserving the structure and essence of the original + /// image. Not supported inside overlay. See [AI Generate Variations](https://imagekit.io/docs/ai-transformations#generate-variations-of-an-image-e-genvar). + /// + public ApiEnum? AIVariation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("aiVariation"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("aiVariation", value); + } + } + + /// + /// Specifies the aspect ratio for the output, e.g., "ar-4-3". Typically used + /// with either width or height (but not both). For example: aspectRatio = `4:3`, + /// `4_3`, or an expression like `iar_div_2`. See [Image resize and crop – Aspect + /// ratio](https://imagekit.io/docs/image-resize-and-crop#aspect-ratio---ar). + /// + public AspectRatio? AspectRatio + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("aspectRatio"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("aspectRatio", value); + } + } + + /// + /// Specifies the audio codec, e.g., `aac`, `opus`, or `none`. See [Audio codec](https://imagekit.io/docs/video-optimization#audio-codec---ac). + /// + public ApiEnum? AudioCodec + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("audioCodec"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("audioCodec", value); + } + } + + /// + /// Specifies the background to be used in conjunction with certain cropping strategies + /// when resizing an image. - A solid color: e.g., `red`, `F3F3F3`, `AAFF0010`. + /// See [Solid color background](https://imagekit.io/docs/effects-and-enhancements#solid-color-background). + /// - Dominant color: `dominant` extracts the dominant color from the image. See + /// [Dominant color background](https://imagekit.io/docs/effects-and-enhancements#dominant-color-background). + /// - Gradient: `gradient_dominant` or `gradient_dominant_2` creates a gradient + /// using the dominant colors. Optionally specify palette size (2 or 4), e.g., + /// `gradient_dominant_4`. See [Gradient background](https://imagekit.io/docs/effects-and-enhancements#gradient-background). + /// - A blurred background: e.g., `blurred`, `blurred_25_N15`, etc. See [Blurred + /// background](https://imagekit.io/docs/effects-and-enhancements#blurred-background). + /// - Expand the image boundaries using generative fill: `genfill`. Not supported + /// inside overlay. Optionally, control the background scene by passing a text + /// prompt: `genfill[:-prompt-${text}]` or `genfill[:-prompte-${urlencoded_base64_encoded_text}]`. + /// See [Generative fill background](https://imagekit.io/docs/ai-transformations#generative-fill-bg-genfill). + /// + public string? Background + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("background"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("background", value); + } + } + + /// + /// Specifies the Gaussian blur level. Accepts an integer value between 1 and + /// 100, or an expression like `bl-10`. See [Blur](https://imagekit.io/docs/effects-and-enhancements#blur---bl). + /// + public double? Blur + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("blur"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("blur", value); + } + } + + /// + /// Adds a border to the output media. Accepts a string in the format `_` + /// (e.g., `5_FFF000` for a 5px yellow border), or an expression like `ih_div_20_FF00FF`. + /// See [Border](https://imagekit.io/docs/effects-and-enhancements#border---b). + /// + public string? Border + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("border"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("border", value); + } + } + + /// + /// Indicates whether the output image should retain the original color profile. + /// See [Color profile](https://imagekit.io/docs/image-optimization#color-profile---cp). + /// + public bool? ColorProfile + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("colorProfile"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("colorProfile", value); + } + } + + /// + /// Replaces colors in the image. Supports three formats: - `toColor` - Replace + /// dominant color with the specified color. - `toColor_tolerance` - Replace + /// dominant color with specified tolerance (0-100). - `toColor_tolerance_fromColor` + /// - Replace a specific color with another within tolerance range. Colors can + /// be hex codes (e.g., `FF0022`) or names (e.g., `red`, `blue`). See [Color + /// replacement](https://imagekit.io/docs/effects-and-enhancements#color-replace---cr). + /// + public string? ColorReplace + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("colorReplace"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("colorReplace", value); + } + } + + /// + /// Automatically enhances the contrast of an image (contrast stretch). See [Contrast + /// Stretch](https://imagekit.io/docs/effects-and-enhancements#contrast-stretch---e-contrast). + /// + public ApiEnum? ContrastStretch + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>( + "contrastStretch" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("contrastStretch", value); + } + } + + /// + /// Crop modes for image resizing. See [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). + /// + public ApiEnum? Crop + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("crop"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("crop", value); + } + } + + /// + /// Additional crop modes for image resizing. See [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). + /// + public ApiEnum? CropMode + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("cropMode"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("cropMode", value); + } + } + + /// + /// Specifies a fallback image if the resource is not found, e.g., a URL or file + /// path. See [Default image](https://imagekit.io/docs/image-transformation#default-image---di). + /// + public string? DefaultImage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("defaultImage"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("defaultImage", value); + } + } + + /// + /// Distorts the shape of an image. Supports two modes: - Perspective distortion: + /// `p-x1_y1_x2_y2_x3_y3_x4_y4` changes the position of the four corners starting + /// clockwise from top-left. - Arc distortion: `a-degrees` curves the image upwards + /// (positive values) or downwards (negative values). See [Distort effect](https://imagekit.io/docs/effects-and-enhancements#distort---e-distort). + /// + public string? Distort + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("distort"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("distort", value); + } + } + + /// + /// Accepts values between 0.1 and 5, or `auto` for automatic device pixel ratio + /// (DPR) calculation. Also accepts arithmetic expressions. - Learn about [Arithmetic + /// expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + /// - See [DPR](https://imagekit.io/docs/image-resize-and-crop#dpr---dpr). + /// + public double? Dpr + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("dpr"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("dpr", value); + } + } + + /// + /// Specifies the duration (in seconds) for trimming videos, e.g., `5` or `10.5`. + /// Typically used with startOffset to indicate the length from the start offset. + /// Arithmetic expressions are supported. See [Trim videos – Duration](https://imagekit.io/docs/trim-videos#duration---du). + /// + public TransformationDuration? Duration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("duration"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("duration", value); + } + } + + /// + /// Specifies the end offset (in seconds) for trimming videos, e.g., `5` or `10.5`. + /// Typically used with startOffset to define a time window. Arithmetic expressions + /// are supported. See [Trim videos – End offset](https://imagekit.io/docs/trim-videos#end-offset---eo). + /// + public EndOffset? EndOffset + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("endOffset"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("endOffset", value); + } + } + + /// + /// Flips or mirrors an image either horizontally, vertically, or both. Acceptable + /// values: `h` (horizontal), `v` (vertical), `h_v` (horizontal and vertical), + /// or `v_h`. See [Flip](https://imagekit.io/docs/effects-and-enhancements#flip---fl). + /// + public ApiEnum? Flip + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("flip"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("flip", value); + } + } + + /// + /// Refines padding and cropping behavior for pad resize, maintain ratio, and + /// extract crop modes. Supports manual positions and coordinate-based focus. + /// With AI-based cropping, you can automatically keep key subjects in frame—such + /// as faces or detected objects (e.g., `fo-face`, `fo-person`, `fo-car`)— while + /// resizing. - See [Focus](https://imagekit.io/docs/image-resize-and-crop#focus---fo). + /// - [Object aware cropping](https://imagekit.io/docs/image-resize-and-crop#object-aware-cropping---fo-object-name) + /// + public string? Focus + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("focus"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("focus", value); + } + } + + /// + /// Specifies the output format for images or videos, e.g., `jpg`, `png`, `webp`, + /// `mp4`, or `auto`. You can also pass `orig` for images to return the original + /// format. ImageKit automatically delivers images and videos in the optimal + /// format based on device support unless overridden by the dashboard settings + /// or the format parameter. See [Image format](https://imagekit.io/docs/image-optimization#format---f) + /// and [Video format](https://imagekit.io/docs/video-optimization#format---f). + /// + public ApiEnum? Format + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("format"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("format", value); + } + } + + /// + /// Creates a linear gradient with two colors. Pass `true` for a default gradient, + /// or provide a string for a custom gradient. See [Gradient](https://imagekit.io/docs/effects-and-enhancements#gradient---e-gradient). + /// + public TransformationGradient? Gradient + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("gradient"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("gradient", value); + } + } + + /// + /// Enables a grayscale effect for images. See [Grayscale](https://imagekit.io/docs/effects-and-enhancements#grayscale---e-grayscale). + /// + public ApiEnum? Grayscale + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("grayscale"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("grayscale", value); + } + } + + /// + /// Specifies the height of the output. If a value between 0 and 1 is provided, + /// it is treated as a percentage (e.g., `0.5` represents 50% of the original + /// height). You can also supply arithmetic expressions (e.g., `ih_mul_0.5`). + /// Height transformation – [Images](https://imagekit.io/docs/image-resize-and-crop#height---h) + /// · [Videos](https://imagekit.io/docs/video-resize-and-crop#height---h) + /// + public TransformationHeight? Height + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("height"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("height", value); + } + } + + /// + /// Specifies whether the output image (in JPEG or PNG) should be compressed + /// losslessly. See [Lossless compression](https://imagekit.io/docs/image-optimization#lossless-webp-and-png---lo). + /// + public bool? Lossless + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("lossless"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("lossless", value); + } + } + + /// + /// By default, ImageKit removes all metadata during automatic image compression. + /// Set this to true to preserve metadata. See [Image metadata](https://imagekit.io/docs/image-optimization#image-metadata---md). + /// + public bool? Metadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("metadata"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("metadata", value); + } + } + + /// + /// Named transformation reference. See [Named transformations](https://imagekit.io/docs/transformations#named-transformations). + /// + public string? Named + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("named"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("named", value); + } + } + + /// + /// Specifies the opacity level of the output image. See [Opacity](https://imagekit.io/docs/effects-and-enhancements#opacity---o). + /// + public double? Opacity + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("opacity"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("opacity", value); + } + } + + /// + /// If set to true, serves the original file without applying any transformations. + /// See [Deliver original file as-is](https://imagekit.io/docs/core-delivery-features#deliver-original-file-as-is---orig-true). + /// + public bool? Original + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("original"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("original", value); + } + } + + /// + /// Specifies an overlay to be applied on the parent image or video. ImageKit + /// supports overlays including images, text, videos, subtitles, and solid colors. + /// See [Overlay using layers](https://imagekit.io/docs/transformations#overlay-using-layers). + /// + public Overlay? Overlay + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("overlay"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("overlay", value); + } + } + + /// + /// Extracts a specific page or frame from multi-page or layered files (PDF, + /// PSD, AI). For example, specify by number (e.g., `2`), a range (e.g., `3-4` + /// for the 2nd and 3rd layers), or by name (e.g., `name-layer-4` for a PSD layer). + /// See [Thumbnail extraction](https://imagekit.io/docs/vector-and-animated-images#get-thumbnail-from-psd-pdf-ai-eps-and-animated-files). + /// + public Page? Page + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("page"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("page", value); + } + } + + /// + /// Specifies whether the output JPEG image should be rendered progressively. + /// Progressive loading begins with a low-quality, pixelated version of the + /// full image, which gradually improves to provide a faster perceived load time. + /// See [Progressive images](https://imagekit.io/docs/image-optimization#progressive-image---pr). + /// + public bool? Progressive + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("progressive"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("progressive", value); + } + } + + /// + /// Specifies the quality of the output image for lossy formats such as JPEG, + /// WebP, and AVIF. A higher quality value results in a larger file size with + /// better quality, while a lower value produces a smaller file size with reduced + /// quality. See [Quality](https://imagekit.io/docs/image-optimization#quality---q). + /// + public double? Quality + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("quality"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("quality", value); + } + } + + /// + /// Specifies the corner radius for rounded corners. - Single value (positive + /// integer): Applied to all corners (e.g., `20`). - `max`: Creates a circular + /// or oval shape. - Per-corner array: Provide four underscore-separated values + /// representing top-left, top-right, bottom-right, and bottom-left corners respectively + /// (e.g., `10_20_30_40`). See [Radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). + /// + public TransformationRadius? Radius + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("radius"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("radius", value); + } + } + + /// + /// Pass any transformation not directly supported by the SDK. This transformation + /// string is appended to the URL as provided. + /// + public string? Raw + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("raw"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("raw", value); + } + } + + /// + /// Specifies the rotation angle in degrees. Positive values rotate the image + /// clockwise; you can also use, for example, `N40` for counterclockwise rotation + /// or `auto` to use the orientation specified in the image's EXIF data. For + /// videos, only the following values are supported: 0, 90, 180, 270, or 360. + /// See [Rotate](https://imagekit.io/docs/effects-and-enhancements#rotate---rt). + /// + public TransformationRotation? Rotation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("rotation"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("rotation", value); + } + } + + /// + /// Adds a shadow beneath solid objects in an image with a transparent background. + /// For AI-based drop shadows, refer to aiDropShadow. Pass `true` for a default + /// shadow, or provide a string for a custom shadow. See [Shadow](https://imagekit.io/docs/effects-and-enhancements#shadow---e-shadow). + /// + public Shadow? Shadow + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("shadow"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("shadow", value); + } + } + + /// + /// Sharpens the input image, highlighting edges and finer details. Pass `true` + /// for default sharpening, or provide a numeric value for custom sharpening. + /// See [Sharpen](https://imagekit.io/docs/effects-and-enhancements#sharpen---e-sharpen). + /// + public Sharpen? Sharpen + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("sharpen"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("sharpen", value); + } + } + + /// + /// Specifies the start offset (in seconds) for trimming videos, e.g., `5` or + /// `10.5`. Arithmetic expressions are also supported. See [Trim videos – Start + /// offset](https://imagekit.io/docs/trim-videos#start-offset---so). + /// + public StartOffset? StartOffset + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("startOffset"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("startOffset", value); + } + } + + /// + /// An array of resolutions for adaptive bitrate streaming, e.g., [`240`, `360`, + /// `480`, `720`, `1080`]. See [Adaptive Bitrate Streaming](https://imagekit.io/docs/adaptive-bitrate-streaming). + /// + public IReadOnlyList>? StreamingResolutions + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct< + ImmutableArray> + >("streamingResolutions"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set>?>( + "streamingResolutions", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Useful for images with a solid or nearly solid background and a central object. + /// This parameter trims the background, leaving only the central object in the + /// output image. See [Trim edges](https://imagekit.io/docs/effects-and-enhancements#trim-edges---t). + /// + public Trim? Trim + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("trim"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("trim", value); + } + } + + /// + /// Applies Unsharp Masking (USM), an image sharpening technique. Pass `true` + /// for a default unsharp mask, or provide a string for a custom unsharp mask. + /// See [Unsharp Mask](https://imagekit.io/docs/effects-and-enhancements#unsharp-mask---e-usm). + /// + public UnsharpMask? UnsharpMask + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("unsharpMask"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("unsharpMask", value); + } + } + + /// + /// Specifies the video codec, e.g., `h264`, `vp9`, `av1`, or `none`. See [Video codec](https://imagekit.io/docs/video-optimization#video-codec---vc). + /// + public ApiEnum? VideoCodec + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("videoCodec"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("videoCodec", value); + } + } + + /// + /// Specifies the width of the output. If a value between 0 and 1 is provided, + /// it is treated as a percentage (e.g., `0.4` represents 40% of the original + /// width). You can also supply arithmetic expressions (e.g., `iw_div_2`). Width + /// transformation – [Images](https://imagekit.io/docs/image-resize-and-crop#width---w) + /// · [Videos](https://imagekit.io/docs/video-resize-and-crop#width---w) + /// + public TransformationWidth? Width + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("width"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("width", value); + } + } + + /// + /// Focus using cropped image coordinates - X coordinate. See [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). + /// + public TransformationX? X + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("x"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("x", value); + } + } + + /// + /// Focus using cropped image coordinates - X center coordinate. See [Focus using + /// cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). + /// + public XCenter? XCenter + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("xCenter"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("xCenter", value); + } + } + + /// + /// Focus using cropped image coordinates - Y coordinate. See [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). + /// + public TransformationY? Y + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("y"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("y", value); + } + } + + /// + /// Focus using cropped image coordinates - Y center coordinate. See [Focus using + /// cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). + /// + public YCenter? YCenter + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("yCenter"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("yCenter", value); + } + } + + /// + /// Accepts a numeric value that determines how much to zoom in or out of the + /// cropped area. It should be used in conjunction with fo-face or fo-. + /// See [Zoom](https://imagekit.io/docs/image-resize-and-crop#zoom---z). + /// + public double? Zoom + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("zoom"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("zoom", value); + } + } + + /// + public override void Validate() + { + _ = this.AIChangeBackground; + this.AIDropShadow?.Validate(); + _ = this.AIEdit; + this.AIRemoveBackground?.Validate(); + this.AIRemoveBackgroundExternal?.Validate(); + this.AIRetouch?.Validate(); + this.AIUpscale?.Validate(); + this.AIVariation?.Validate(); + this.AspectRatio?.Validate(); + this.AudioCodec?.Validate(); + _ = this.Background; + _ = this.Blur; + _ = this.Border; + _ = this.ColorProfile; + _ = this.ColorReplace; + this.ContrastStretch?.Validate(); + this.Crop?.Validate(); + this.CropMode?.Validate(); + _ = this.DefaultImage; + _ = this.Distort; + _ = this.Dpr; + this.Duration?.Validate(); + this.EndOffset?.Validate(); + this.Flip?.Validate(); + _ = this.Focus; + this.Format?.Validate(); + this.Gradient?.Validate(); + this.Grayscale?.Validate(); + this.Height?.Validate(); + _ = this.Lossless; + _ = this.Metadata; + _ = this.Named; + _ = this.Opacity; + _ = this.Original; + this.Overlay?.Validate(); + this.Page?.Validate(); + _ = this.Progressive; + _ = this.Quality; + this.Radius?.Validate(); + _ = this.Raw; + this.Rotation?.Validate(); + this.Shadow?.Validate(); + this.Sharpen?.Validate(); + this.StartOffset?.Validate(); + foreach (var item in this.StreamingResolutions ?? []) + { + item.Validate(); + } + this.Trim?.Validate(); + this.UnsharpMask?.Validate(); + this.VideoCodec?.Validate(); + this.Width?.Validate(); + this.X?.Validate(); + this.XCenter?.Validate(); + this.Y?.Validate(); + this.YCenter?.Validate(); + _ = this.Zoom; + } + + public Transformation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Transformation(Transformation transformation) + : base(transformation) { } +#pragma warning restore CS8618 + + public Transformation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Transformation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static Transformation FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TransformationFromRaw : IFromRawJson +{ + /// + public Transformation FromRawUnchecked(IReadOnlyDictionary rawData) => + Transformation.FromRawUnchecked(rawData); +} + +/// +/// Adds an AI-based drop shadow around a foreground object on a transparent or removed +/// background. Optionally, control the direction, elevation, and saturation of the +/// light source (e.g., `az-45` to change light direction). Pass `true` for the default +/// drop shadow, or provide a string for a custom drop shadow. Supported inside overlay. +/// See [AI Drop Shadow](https://imagekit.io/docs/ai-transformations#ai-drop-shadow-e-dropshadow). +/// +[JsonConverter(typeof(AIDropShadowConverter))] +public record class AIDropShadow : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public AIDropShadow(AIDropShadowUnionMember0 value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public AIDropShadow(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public AIDropShadow(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickTrue(out var value)) { + /// // `value` is of type `AIDropShadowUnionMember0` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTrue([NotNullWhen(true)] out AIDropShadowUnionMember0? value) + { + value = this.Value as AIDropShadowUnionMember0; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (AIDropShadowUnionMember0 value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public void Switch(Action true_, Action @string) + { + switch (this.Value) + { + case AIDropShadowUnionMember0 value: + true_(value); + break; + case string value: + @string(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of AIDropShadow" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (AIDropShadowUnionMember0 value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public T Match(Func true_, Func @string) + { + return this.Value switch + { + AIDropShadowUnionMember0 value => true_(value), + string value => @string(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of AIDropShadow" + ), + }; + } + + public static implicit operator AIDropShadow(AIDropShadowUnionMember0 value) => new(value); + + public static implicit operator AIDropShadow(string value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of AIDropShadow" + ); + } + this.Switch((true_) => true_.Validate(), (_) => { }); + } + + public virtual bool Equals(AIDropShadow? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class AIDropShadowConverter : JsonConverter +{ + public override AIDropShadow? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + AIDropShadow value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(AIDropShadowUnionMember0Converter))] +public record class AIDropShadowUnionMember0 +{ + public JsonElement Element { get; private init; } + + public AIDropShadowUnionMember0() + { + Element = JsonSerializer.SerializeToElement(true); + } + + internal AIDropShadowUnionMember0(JsonElement element) + { + Element = element; + } + + /// + /// Validates that the instance's underlying value is the expected constant. + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public void Validate() + { + if (this != new AIDropShadowUnionMember0()) + { + throw new ImageKitInvalidDataException( + "Invalid value given for 'AIDropShadowUnionMember0'" + ); + } + } + + public override int GetHashCode() + { + return 0; + } + + public virtual bool Equals(AIDropShadowUnionMember0? other) + { + if (other == null) + { + return false; + } + + return JsonElement.DeepEquals(this.Element, other.Element); + } +} + +class AIDropShadowUnionMember0Converter : JsonConverter +{ + public override AIDropShadowUnionMember0? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write( + Utf8JsonWriter writer, + AIDropShadowUnionMember0 value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Element, options); + } +} + +/// +/// Applies ImageKit's in-house background removal. Supported inside overlay. See +/// [AI Background Removal](https://imagekit.io/docs/ai-transformations#imagekit-background-removal-e-bgremove). +/// +[JsonConverter(typeof(AIRemoveBackgroundConverter))] +public enum AIRemoveBackground +{ + True, +} + +sealed class AIRemoveBackgroundConverter : JsonConverter +{ + public override AIRemoveBackground Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + true => AIRemoveBackground.True, + _ => (AIRemoveBackground)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + AIRemoveBackground value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + AIRemoveBackground.True => true, + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Uses third-party background removal. Note: It is recommended to use aiRemoveBackground, +/// ImageKit's in-house solution, which is more cost-effective. Supported inside +/// overlay. See [External Background Removal](https://imagekit.io/docs/ai-transformations#background-removal-e-removedotbg). +/// +[JsonConverter(typeof(AIRemoveBackgroundExternalConverter))] +public enum AIRemoveBackgroundExternal +{ + True, +} + +sealed class AIRemoveBackgroundExternalConverter : JsonConverter +{ + public override AIRemoveBackgroundExternal Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + true => AIRemoveBackgroundExternal.True, + _ => (AIRemoveBackgroundExternal)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + AIRemoveBackgroundExternal value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + AIRemoveBackgroundExternal.True => true, + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Performs AI-based retouching to improve faces or product shots. Not supported +/// inside overlay. See [AI Retouch](https://imagekit.io/docs/ai-transformations#retouch-e-retouch). +/// +[JsonConverter(typeof(AIRetouchConverter))] +public enum AIRetouch +{ + True, +} + +sealed class AIRetouchConverter : JsonConverter +{ + public override AIRetouch Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + true => AIRetouch.True, + _ => (AIRetouch)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + AIRetouch value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + AIRetouch.True => true, + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Upscales images beyond their original dimensions using AI. Not supported inside +/// overlay. See [AI Upscale](https://imagekit.io/docs/ai-transformations#upscale-e-upscale). +/// +[JsonConverter(typeof(AIUpscaleConverter))] +public enum AIUpscale +{ + True, +} + +sealed class AIUpscaleConverter : JsonConverter +{ + public override AIUpscale Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + true => AIUpscale.True, + _ => (AIUpscale)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + AIUpscale value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + AIUpscale.True => true, + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Generates a variation of an image using AI. This produces a new image with slight +/// variations from the original, such as changes in color, texture, and other visual +/// elements, while preserving the structure and essence of the original image. Not +/// supported inside overlay. See [AI Generate Variations](https://imagekit.io/docs/ai-transformations#generate-variations-of-an-image-e-genvar). +/// +[JsonConverter(typeof(AIVariationConverter))] +public enum AIVariation +{ + True, +} + +sealed class AIVariationConverter : JsonConverter +{ + public override AIVariation Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + true => AIVariation.True, + _ => (AIVariation)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + AIVariation value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + AIVariation.True => true, + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Specifies the aspect ratio for the output, e.g., "ar-4-3". Typically used with +/// either width or height (but not both). For example: aspectRatio = `4:3`, `4_3`, +/// or an expression like `iar_div_2`. See [Image resize and crop – Aspect ratio](https://imagekit.io/docs/image-resize-and-crop#aspect-ratio---ar). +/// +[JsonConverter(typeof(AspectRatioConverter))] +public record class AspectRatio : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public AspectRatio(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public AspectRatio(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public AspectRatio(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public void Switch(Action @double, Action @string) + { + switch (this.Value) + { + case double value: + @double(value); + break; + case string value: + @string(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of AspectRatio" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public T Match(Func @double, Func @string) + { + return this.Value switch + { + double value => @double(value), + string value => @string(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of AspectRatio" + ), + }; + } + + public static implicit operator AspectRatio(double value) => new(value); + + public static implicit operator AspectRatio(string value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException("Data did not match any variant of AspectRatio"); + } + } + + public virtual bool Equals(AspectRatio? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class AspectRatioConverter : JsonConverter +{ + public override AspectRatio? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + AspectRatio value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +/// +/// Specifies the audio codec, e.g., `aac`, `opus`, or `none`. See [Audio codec](https://imagekit.io/docs/video-optimization#audio-codec---ac). +/// +[JsonConverter(typeof(AudioCodecConverter))] +public enum AudioCodec +{ + Aac, + Opus, + None, +} + +sealed class AudioCodecConverter : JsonConverter +{ + public override AudioCodec Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "aac" => AudioCodec.Aac, + "opus" => AudioCodec.Opus, + "none" => AudioCodec.None, + _ => (AudioCodec)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + AudioCodec value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + AudioCodec.Aac => "aac", + AudioCodec.Opus => "opus", + AudioCodec.None => "none", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Automatically enhances the contrast of an image (contrast stretch). See [Contrast +/// Stretch](https://imagekit.io/docs/effects-and-enhancements#contrast-stretch---e-contrast). +/// +[JsonConverter(typeof(ContrastStretchConverter))] +public enum ContrastStretch +{ + True, +} + +sealed class ContrastStretchConverter : JsonConverter +{ + public override ContrastStretch Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + true => ContrastStretch.True, + _ => (ContrastStretch)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ContrastStretch value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ContrastStretch.True => true, + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Crop modes for image resizing. See [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). +/// +[JsonConverter(typeof(CropConverter))] +public enum Crop +{ + Force, + AtMax, + AtMaxEnlarge, + AtLeast, + MaintainRatio, +} + +sealed class CropConverter : JsonConverter +{ + public override Crop Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "force" => Crop.Force, + "at_max" => Crop.AtMax, + "at_max_enlarge" => Crop.AtMaxEnlarge, + "at_least" => Crop.AtLeast, + "maintain_ratio" => Crop.MaintainRatio, + _ => (Crop)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Crop value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + Crop.Force => "force", + Crop.AtMax => "at_max", + Crop.AtMaxEnlarge => "at_max_enlarge", + Crop.AtLeast => "at_least", + Crop.MaintainRatio => "maintain_ratio", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Additional crop modes for image resizing. See [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). +/// +[JsonConverter(typeof(CropModeConverter))] +public enum CropMode +{ + PadResize, + Extract, + PadExtract, +} + +sealed class CropModeConverter : JsonConverter +{ + public override CropMode Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "pad_resize" => CropMode.PadResize, + "extract" => CropMode.Extract, + "pad_extract" => CropMode.PadExtract, + _ => (CropMode)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, CropMode value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + CropMode.PadResize => "pad_resize", + CropMode.Extract => "extract", + CropMode.PadExtract => "pad_extract", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Specifies the duration (in seconds) for trimming videos, e.g., `5` or `10.5`. +/// Typically used with startOffset to indicate the length from the start offset. +/// Arithmetic expressions are supported. See [Trim videos – Duration](https://imagekit.io/docs/trim-videos#duration---du). +/// +[JsonConverter(typeof(TransformationDurationConverter))] +public record class TransformationDuration : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public TransformationDuration(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public TransformationDuration(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public TransformationDuration(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public void Switch(Action @double, Action @string) + { + switch (this.Value) + { + case double value: + @double(value); + break; + case string value: + @string(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of TransformationDuration" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public T Match(Func @double, Func @string) + { + return this.Value switch + { + double value => @double(value), + string value => @string(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of TransformationDuration" + ), + }; + } + + public static implicit operator TransformationDuration(double value) => new(value); + + public static implicit operator TransformationDuration(string value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of TransformationDuration" + ); + } + } + + public virtual bool Equals(TransformationDuration? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class TransformationDurationConverter : JsonConverter +{ + public override TransformationDuration? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + TransformationDuration value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +/// +/// Specifies the end offset (in seconds) for trimming videos, e.g., `5` or `10.5`. +/// Typically used with startOffset to define a time window. Arithmetic expressions +/// are supported. See [Trim videos – End offset](https://imagekit.io/docs/trim-videos#end-offset---eo). +/// +[JsonConverter(typeof(EndOffsetConverter))] +public record class EndOffset : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public EndOffset(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public EndOffset(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public EndOffset(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public void Switch(Action @double, Action @string) + { + switch (this.Value) + { + case double value: + @double(value); + break; + case string value: + @string(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of EndOffset" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public T Match(Func @double, Func @string) + { + return this.Value switch + { + double value => @double(value), + string value => @string(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of EndOffset" + ), + }; + } + + public static implicit operator EndOffset(double value) => new(value); + + public static implicit operator EndOffset(string value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException("Data did not match any variant of EndOffset"); + } + } + + public virtual bool Equals(EndOffset? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class EndOffsetConverter : JsonConverter +{ + public override EndOffset? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + EndOffset value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +/// +/// Flips or mirrors an image either horizontally, vertically, or both. Acceptable +/// values: `h` (horizontal), `v` (vertical), `h_v` (horizontal and vertical), or +/// `v_h`. See [Flip](https://imagekit.io/docs/effects-and-enhancements#flip---fl). +/// +[JsonConverter(typeof(TransformationFlipConverter))] +public enum TransformationFlip +{ + H, + V, + HV, + VH, +} + +sealed class TransformationFlipConverter : JsonConverter +{ + public override TransformationFlip Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "h" => TransformationFlip.H, + "v" => TransformationFlip.V, + "h_v" => TransformationFlip.HV, + "v_h" => TransformationFlip.VH, + _ => (TransformationFlip)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + TransformationFlip value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + TransformationFlip.H => "h", + TransformationFlip.V => "v", + TransformationFlip.HV => "h_v", + TransformationFlip.VH => "v_h", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Specifies the output format for images or videos, e.g., `jpg`, `png`, `webp`, +/// `mp4`, or `auto`. You can also pass `orig` for images to return the original +/// format. ImageKit automatically delivers images and videos in the optimal format +/// based on device support unless overridden by the dashboard settings or the format +/// parameter. See [Image format](https://imagekit.io/docs/image-optimization#format---f) +/// and [Video format](https://imagekit.io/docs/video-optimization#format---f). +/// +[JsonConverter(typeof(FormatConverter))] +public enum Format +{ + Auto, + Webp, + Jpg, + Jpeg, + Png, + Gif, + Svg, + Mp4, + Webm, + Avif, + Orig, +} + +sealed class FormatConverter : JsonConverter +{ + public override Format Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "auto" => Format.Auto, + "webp" => Format.Webp, + "jpg" => Format.Jpg, + "jpeg" => Format.Jpeg, + "png" => Format.Png, + "gif" => Format.Gif, + "svg" => Format.Svg, + "mp4" => Format.Mp4, + "webm" => Format.Webm, + "avif" => Format.Avif, + "orig" => Format.Orig, + _ => (Format)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Format value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + Format.Auto => "auto", + Format.Webp => "webp", + Format.Jpg => "jpg", + Format.Jpeg => "jpeg", + Format.Png => "png", + Format.Gif => "gif", + Format.Svg => "svg", + Format.Mp4 => "mp4", + Format.Webm => "webm", + Format.Avif => "avif", + Format.Orig => "orig", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Creates a linear gradient with two colors. Pass `true` for a default gradient, +/// or provide a string for a custom gradient. See [Gradient](https://imagekit.io/docs/effects-and-enhancements#gradient---e-gradient). +/// +[JsonConverter(typeof(TransformationGradientConverter))] +public record class TransformationGradient : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public TransformationGradient( + TransformationGradientUnionMember0 value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public TransformationGradient(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public TransformationGradient(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickTrue(out var value)) { + /// // `value` is of type `TransformationGradientUnionMember0` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTrue([NotNullWhen(true)] out TransformationGradientUnionMember0? value) + { + value = this.Value as TransformationGradientUnionMember0; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (TransformationGradientUnionMember0 value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public void Switch(Action true_, Action @string) + { + switch (this.Value) + { + case TransformationGradientUnionMember0 value: + true_(value); + break; + case string value: + @string(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of TransformationGradient" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (TransformationGradientUnionMember0 value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public T Match(Func true_, Func @string) + { + return this.Value switch + { + TransformationGradientUnionMember0 value => true_(value), + string value => @string(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of TransformationGradient" + ), + }; + } + + public static implicit operator TransformationGradient( + TransformationGradientUnionMember0 value + ) => new(value); + + public static implicit operator TransformationGradient(string value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of TransformationGradient" + ); + } + this.Switch((true_) => true_.Validate(), (_) => { }); + } + + public virtual bool Equals(TransformationGradient? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class TransformationGradientConverter : JsonConverter +{ + public override TransformationGradient? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + TransformationGradient value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(TransformationGradientUnionMember0Converter))] +public record class TransformationGradientUnionMember0 +{ + public JsonElement Element { get; private init; } + + public TransformationGradientUnionMember0() + { + Element = JsonSerializer.SerializeToElement(true); + } + + internal TransformationGradientUnionMember0(JsonElement element) + { + Element = element; + } + + /// + /// Validates that the instance's underlying value is the expected constant. + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public void Validate() + { + if (this != new TransformationGradientUnionMember0()) + { + throw new ImageKitInvalidDataException( + "Invalid value given for 'TransformationGradientUnionMember0'" + ); + } + } + + public override int GetHashCode() + { + return 0; + } + + public virtual bool Equals(TransformationGradientUnionMember0? other) + { + if (other == null) + { + return false; + } + + return JsonElement.DeepEquals(this.Element, other.Element); + } +} + +class TransformationGradientUnionMember0Converter + : JsonConverter +{ + public override TransformationGradientUnionMember0? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write( + Utf8JsonWriter writer, + TransformationGradientUnionMember0 value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Element, options); + } +} + +/// +/// Enables a grayscale effect for images. See [Grayscale](https://imagekit.io/docs/effects-and-enhancements#grayscale---e-grayscale). +/// +[JsonConverter(typeof(GrayscaleConverter))] +public enum Grayscale +{ + True, +} + +sealed class GrayscaleConverter : JsonConverter +{ + public override Grayscale Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + true => Grayscale.True, + _ => (Grayscale)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + Grayscale value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + Grayscale.True => true, + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Specifies the height of the output. If a value between 0 and 1 is provided, it +/// is treated as a percentage (e.g., `0.5` represents 50% of the original height). +/// You can also supply arithmetic expressions (e.g., `ih_mul_0.5`). Height transformation +/// – [Images](https://imagekit.io/docs/image-resize-and-crop#height---h) · [Videos](https://imagekit.io/docs/video-resize-and-crop#height---h) +/// +[JsonConverter(typeof(TransformationHeightConverter))] +public record class TransformationHeight : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public TransformationHeight(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public TransformationHeight(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public TransformationHeight(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public void Switch(Action @double, Action @string) + { + switch (this.Value) + { + case double value: + @double(value); + break; + case string value: + @string(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of TransformationHeight" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public T Match(Func @double, Func @string) + { + return this.Value switch + { + double value => @double(value), + string value => @string(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of TransformationHeight" + ), + }; + } + + public static implicit operator TransformationHeight(double value) => new(value); + + public static implicit operator TransformationHeight(string value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of TransformationHeight" + ); + } + } + + public virtual bool Equals(TransformationHeight? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class TransformationHeightConverter : JsonConverter +{ + public override TransformationHeight? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + TransformationHeight value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +/// +/// Extracts a specific page or frame from multi-page or layered files (PDF, PSD, +/// AI). For example, specify by number (e.g., `2`), a range (e.g., `3-4` for the +/// 2nd and 3rd layers), or by name (e.g., `name-layer-4` for a PSD layer). See [Thumbnail +/// extraction](https://imagekit.io/docs/vector-and-animated-images#get-thumbnail-from-psd-pdf-ai-eps-and-animated-files). +/// +[JsonConverter(typeof(PageConverter))] +public record class Page : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public Page(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Page(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Page(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public void Switch(Action @double, Action @string) + { + switch (this.Value) + { + case double value: + @double(value); + break; + case string value: + @string(value); + break; + default: + throw new ImageKitInvalidDataException("Data did not match any variant of Page"); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public T Match(Func @double, Func @string) + { + return this.Value switch + { + double value => @double(value), + string value => @string(value), + _ => throw new ImageKitInvalidDataException("Data did not match any variant of Page"), + }; + } + + public static implicit operator Page(double value) => new(value); + + public static implicit operator Page(string value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException("Data did not match any variant of Page"); + } + } + + public virtual bool Equals(Page? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class PageConverter : JsonConverter +{ + public override Page? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write(Utf8JsonWriter writer, Page value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +/// +/// Specifies the corner radius for rounded corners. - Single value (positive integer): +/// Applied to all corners (e.g., `20`). - `max`: Creates a circular or oval shape. +/// - Per-corner array: Provide four underscore-separated values representing top-left, +/// top-right, bottom-right, and bottom-left corners respectively (e.g., `10_20_30_40`). +/// See [Radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). +/// +[JsonConverter(typeof(TransformationRadiusConverter))] +public record class TransformationRadius : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public TransformationRadius(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public TransformationRadius(TransformationRadiusUnionMember1 value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public TransformationRadius(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public TransformationRadius(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickMax(out var value)) { + /// // `value` is of type `TransformationRadiusUnionMember1` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMax([NotNullWhen(true)] out TransformationRadiusUnionMember1? value) + { + value = this.Value as TransformationRadiusUnionMember1; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (double value) => {...}, + /// (TransformationRadiusUnionMember1 value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public void Switch( + Action @double, + Action max, + Action @string + ) + { + switch (this.Value) + { + case double value: + @double(value); + break; + case TransformationRadiusUnionMember1 value: + max(value); + break; + case string value: + @string(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of TransformationRadius" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (double value) => {...}, + /// (TransformationRadiusUnionMember1 value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public T Match( + Func @double, + Func max, + Func @string + ) + { + return this.Value switch + { + double value => @double(value), + TransformationRadiusUnionMember1 value => max(value), + string value => @string(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of TransformationRadius" + ), + }; + } + + public static implicit operator TransformationRadius(double value) => new(value); + + public static implicit operator TransformationRadius(TransformationRadiusUnionMember1 value) => + new(value); + + public static implicit operator TransformationRadius(string value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of TransformationRadius" + ); + } + this.Switch((_) => { }, (max) => max.Validate(), (_) => { }); + } + + public virtual bool Equals(TransformationRadius? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class TransformationRadiusConverter : JsonConverter +{ + public override TransformationRadius? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + TransformationRadius value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(TransformationRadiusUnionMember1Converter))] +public record class TransformationRadiusUnionMember1 +{ + public JsonElement Element { get; private init; } + + public TransformationRadiusUnionMember1() + { + Element = JsonSerializer.SerializeToElement("max"); + } + + internal TransformationRadiusUnionMember1(JsonElement element) + { + Element = element; + } + + /// + /// Validates that the instance's underlying value is the expected constant. + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public void Validate() + { + if (this != new TransformationRadiusUnionMember1()) + { + throw new ImageKitInvalidDataException( + "Invalid value given for 'TransformationRadiusUnionMember1'" + ); + } + } + + public override int GetHashCode() + { + return 0; + } + + public virtual bool Equals(TransformationRadiusUnionMember1? other) + { + if (other == null) + { + return false; + } + + return JsonElement.DeepEquals(this.Element, other.Element); + } +} + +class TransformationRadiusUnionMember1Converter : JsonConverter +{ + public override TransformationRadiusUnionMember1? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write( + Utf8JsonWriter writer, + TransformationRadiusUnionMember1 value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Element, options); + } +} + +/// +/// Specifies the rotation angle in degrees. Positive values rotate the image clockwise; +/// you can also use, for example, `N40` for counterclockwise rotation or `auto` +/// to use the orientation specified in the image's EXIF data. For videos, only the +/// following values are supported: 0, 90, 180, 270, or 360. See [Rotate](https://imagekit.io/docs/effects-and-enhancements#rotate---rt). +/// +[JsonConverter(typeof(TransformationRotationConverter))] +public record class TransformationRotation : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public TransformationRotation(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public TransformationRotation(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public TransformationRotation(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public void Switch(Action @double, Action @string) + { + switch (this.Value) + { + case double value: + @double(value); + break; + case string value: + @string(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of TransformationRotation" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public T Match(Func @double, Func @string) + { + return this.Value switch + { + double value => @double(value), + string value => @string(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of TransformationRotation" + ), + }; + } + + public static implicit operator TransformationRotation(double value) => new(value); + + public static implicit operator TransformationRotation(string value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of TransformationRotation" + ); + } + } + + public virtual bool Equals(TransformationRotation? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class TransformationRotationConverter : JsonConverter +{ + public override TransformationRotation? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + TransformationRotation value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +/// +/// Adds a shadow beneath solid objects in an image with a transparent background. +/// For AI-based drop shadows, refer to aiDropShadow. Pass `true` for a default shadow, +/// or provide a string for a custom shadow. See [Shadow](https://imagekit.io/docs/effects-and-enhancements#shadow---e-shadow). +/// +[JsonConverter(typeof(ShadowConverter))] +public record class Shadow : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public Shadow(ShadowUnionMember0 value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Shadow(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Shadow(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickTrue(out var value)) { + /// // `value` is of type `ShadowUnionMember0` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTrue([NotNullWhen(true)] out ShadowUnionMember0? value) + { + value = this.Value as ShadowUnionMember0; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (ShadowUnionMember0 value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public void Switch(Action true_, Action @string) + { + switch (this.Value) + { + case ShadowUnionMember0 value: + true_(value); + break; + case string value: + @string(value); + break; + default: + throw new ImageKitInvalidDataException("Data did not match any variant of Shadow"); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (ShadowUnionMember0 value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public T Match(Func true_, Func @string) + { + return this.Value switch + { + ShadowUnionMember0 value => true_(value), + string value => @string(value), + _ => throw new ImageKitInvalidDataException("Data did not match any variant of Shadow"), + }; + } + + public static implicit operator Shadow(ShadowUnionMember0 value) => new(value); + + public static implicit operator Shadow(string value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException("Data did not match any variant of Shadow"); + } + this.Switch((true_) => true_.Validate(), (_) => { }); + } + + public virtual bool Equals(Shadow? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class ShadowConverter : JsonConverter +{ + public override Shadow? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write(Utf8JsonWriter writer, Shadow value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(ShadowUnionMember0Converter))] +public record class ShadowUnionMember0 +{ + public JsonElement Element { get; private init; } + + public ShadowUnionMember0() + { + Element = JsonSerializer.SerializeToElement(true); + } + + internal ShadowUnionMember0(JsonElement element) + { + Element = element; + } + + /// + /// Validates that the instance's underlying value is the expected constant. + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public void Validate() + { + if (this != new ShadowUnionMember0()) + { + throw new ImageKitInvalidDataException("Invalid value given for 'ShadowUnionMember0'"); + } + } + + public override int GetHashCode() + { + return 0; + } + + public virtual bool Equals(ShadowUnionMember0? other) + { + if (other == null) + { + return false; + } + + return JsonElement.DeepEquals(this.Element, other.Element); + } +} + +class ShadowUnionMember0Converter : JsonConverter +{ + public override ShadowUnionMember0? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write( + Utf8JsonWriter writer, + ShadowUnionMember0 value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Element, options); + } +} + +/// +/// Sharpens the input image, highlighting edges and finer details. Pass `true` for +/// default sharpening, or provide a numeric value for custom sharpening. See [Sharpen](https://imagekit.io/docs/effects-and-enhancements#sharpen---e-sharpen). +/// +[JsonConverter(typeof(SharpenConverter))] +public record class Sharpen : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public Sharpen(SharpenUnionMember0 value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Sharpen(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Sharpen(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickTrue(out var value)) { + /// // `value` is of type `SharpenUnionMember0` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTrue([NotNullWhen(true)] out SharpenUnionMember0? value) + { + value = this.Value as SharpenUnionMember0; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (SharpenUnionMember0 value) => {...}, + /// (double value) => {...} + /// ); + /// + /// + /// + public void Switch(Action true_, Action @double) + { + switch (this.Value) + { + case SharpenUnionMember0 value: + true_(value); + break; + case double value: + @double(value); + break; + default: + throw new ImageKitInvalidDataException("Data did not match any variant of Sharpen"); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (SharpenUnionMember0 value) => {...}, + /// (double value) => {...} + /// ); + /// + /// + /// + public T Match(Func true_, Func @double) + { + return this.Value switch + { + SharpenUnionMember0 value => true_(value), + double value => @double(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of Sharpen" + ), + }; + } + + public static implicit operator Sharpen(SharpenUnionMember0 value) => new(value); + + public static implicit operator Sharpen(double value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException("Data did not match any variant of Sharpen"); + } + this.Switch((true_) => true_.Validate(), (_) => { }); + } + + public virtual bool Equals(Sharpen? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class SharpenConverter : JsonConverter +{ + public override Sharpen? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write(Utf8JsonWriter writer, Sharpen value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(SharpenUnionMember0Converter))] +public record class SharpenUnionMember0 +{ + public JsonElement Element { get; private init; } + + public SharpenUnionMember0() + { + Element = JsonSerializer.SerializeToElement(true); + } + + internal SharpenUnionMember0(JsonElement element) + { + Element = element; + } + + /// + /// Validates that the instance's underlying value is the expected constant. + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public void Validate() + { + if (this != new SharpenUnionMember0()) + { + throw new ImageKitInvalidDataException("Invalid value given for 'SharpenUnionMember0'"); + } + } + + public override int GetHashCode() + { + return 0; + } + + public virtual bool Equals(SharpenUnionMember0? other) + { + if (other == null) + { + return false; + } + + return JsonElement.DeepEquals(this.Element, other.Element); + } +} + +class SharpenUnionMember0Converter : JsonConverter +{ + public override SharpenUnionMember0? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write( + Utf8JsonWriter writer, + SharpenUnionMember0 value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Element, options); + } +} + +/// +/// Specifies the start offset (in seconds) for trimming videos, e.g., `5` or `10.5`. +/// Arithmetic expressions are also supported. See [Trim videos – Start offset](https://imagekit.io/docs/trim-videos#start-offset---so). +/// +[JsonConverter(typeof(StartOffsetConverter))] +public record class StartOffset : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public StartOffset(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public StartOffset(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public StartOffset(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public void Switch(Action @double, Action @string) + { + switch (this.Value) + { + case double value: + @double(value); + break; + case string value: + @string(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of StartOffset" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public T Match(Func @double, Func @string) + { + return this.Value switch + { + double value => @double(value), + string value => @string(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of StartOffset" + ), + }; + } + + public static implicit operator StartOffset(double value) => new(value); + + public static implicit operator StartOffset(string value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException("Data did not match any variant of StartOffset"); + } + } + + public virtual bool Equals(StartOffset? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class StartOffsetConverter : JsonConverter +{ + public override StartOffset? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + StartOffset value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +/// +/// Useful for images with a solid or nearly solid background and a central object. +/// This parameter trims the background, leaving only the central object in the +/// output image. See [Trim edges](https://imagekit.io/docs/effects-and-enhancements#trim-edges---t). +/// +[JsonConverter(typeof(TrimConverter))] +public record class Trim : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public Trim(TrimUnionMember0 value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Trim(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Trim(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickTrue(out var value)) { + /// // `value` is of type `TrimUnionMember0` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTrue([NotNullWhen(true)] out TrimUnionMember0? value) + { + value = this.Value as TrimUnionMember0; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (TrimUnionMember0 value) => {...}, + /// (double value) => {...} + /// ); + /// + /// + /// + public void Switch(Action true_, Action @double) + { + switch (this.Value) + { + case TrimUnionMember0 value: + true_(value); + break; + case double value: + @double(value); + break; + default: + throw new ImageKitInvalidDataException("Data did not match any variant of Trim"); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (TrimUnionMember0 value) => {...}, + /// (double value) => {...} + /// ); + /// + /// + /// + public T Match(Func true_, Func @double) + { + return this.Value switch + { + TrimUnionMember0 value => true_(value), + double value => @double(value), + _ => throw new ImageKitInvalidDataException("Data did not match any variant of Trim"), + }; + } + + public static implicit operator Trim(TrimUnionMember0 value) => new(value); + + public static implicit operator Trim(double value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException("Data did not match any variant of Trim"); + } + this.Switch((true_) => true_.Validate(), (_) => { }); + } + + public virtual bool Equals(Trim? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class TrimConverter : JsonConverter +{ + public override Trim? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write(Utf8JsonWriter writer, Trim value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(TrimUnionMember0Converter))] +public record class TrimUnionMember0 +{ + public JsonElement Element { get; private init; } + + public TrimUnionMember0() + { + Element = JsonSerializer.SerializeToElement(true); + } + + internal TrimUnionMember0(JsonElement element) + { + Element = element; + } + + /// + /// Validates that the instance's underlying value is the expected constant. + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public void Validate() + { + if (this != new TrimUnionMember0()) + { + throw new ImageKitInvalidDataException("Invalid value given for 'TrimUnionMember0'"); + } + } + + public override int GetHashCode() + { + return 0; + } + + public virtual bool Equals(TrimUnionMember0? other) + { + if (other == null) + { + return false; + } + + return JsonElement.DeepEquals(this.Element, other.Element); + } +} + +class TrimUnionMember0Converter : JsonConverter +{ + public override TrimUnionMember0? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write( + Utf8JsonWriter writer, + TrimUnionMember0 value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Element, options); + } +} + +/// +/// Applies Unsharp Masking (USM), an image sharpening technique. Pass `true` for +/// a default unsharp mask, or provide a string for a custom unsharp mask. See [Unsharp +/// Mask](https://imagekit.io/docs/effects-and-enhancements#unsharp-mask---e-usm). +/// +[JsonConverter(typeof(UnsharpMaskConverter))] +public record class UnsharpMask : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public UnsharpMask(UnsharpMaskUnionMember0 value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnsharpMask(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnsharpMask(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickTrue(out var value)) { + /// // `value` is of type `UnsharpMaskUnionMember0` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTrue([NotNullWhen(true)] out UnsharpMaskUnionMember0? value) + { + value = this.Value as UnsharpMaskUnionMember0; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (UnsharpMaskUnionMember0 value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public void Switch(Action true_, Action @string) + { + switch (this.Value) + { + case UnsharpMaskUnionMember0 value: + true_(value); + break; + case string value: + @string(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnsharpMask" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (UnsharpMaskUnionMember0 value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public T Match(Func true_, Func @string) + { + return this.Value switch + { + UnsharpMaskUnionMember0 value => true_(value), + string value => @string(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of UnsharpMask" + ), + }; + } + + public static implicit operator UnsharpMask(UnsharpMaskUnionMember0 value) => new(value); + + public static implicit operator UnsharpMask(string value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException("Data did not match any variant of UnsharpMask"); + } + this.Switch((true_) => true_.Validate(), (_) => { }); + } + + public virtual bool Equals(UnsharpMask? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class UnsharpMaskConverter : JsonConverter +{ + public override UnsharpMask? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + UnsharpMask value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(UnsharpMaskUnionMember0Converter))] +public record class UnsharpMaskUnionMember0 +{ + public JsonElement Element { get; private init; } + + public UnsharpMaskUnionMember0() + { + Element = JsonSerializer.SerializeToElement(true); + } + + internal UnsharpMaskUnionMember0(JsonElement element) + { + Element = element; + } + + /// + /// Validates that the instance's underlying value is the expected constant. + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public void Validate() + { + if (this != new UnsharpMaskUnionMember0()) + { + throw new ImageKitInvalidDataException( + "Invalid value given for 'UnsharpMaskUnionMember0'" + ); + } + } + + public override int GetHashCode() + { + return 0; + } + + public virtual bool Equals(UnsharpMaskUnionMember0? other) + { + if (other == null) + { + return false; + } + + return JsonElement.DeepEquals(this.Element, other.Element); + } +} + +class UnsharpMaskUnionMember0Converter : JsonConverter +{ + public override UnsharpMaskUnionMember0? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write( + Utf8JsonWriter writer, + UnsharpMaskUnionMember0 value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Element, options); + } +} + +/// +/// Specifies the video codec, e.g., `h264`, `vp9`, `av1`, or `none`. See [Video codec](https://imagekit.io/docs/video-optimization#video-codec---vc). +/// +[JsonConverter(typeof(VideoCodecConverter))] +public enum VideoCodec +{ + H264, + Vp9, + Av1, + None, +} + +sealed class VideoCodecConverter : JsonConverter +{ + public override VideoCodec Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "h264" => VideoCodec.H264, + "vp9" => VideoCodec.Vp9, + "av1" => VideoCodec.Av1, + "none" => VideoCodec.None, + _ => (VideoCodec)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + VideoCodec value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + VideoCodec.H264 => "h264", + VideoCodec.Vp9 => "vp9", + VideoCodec.Av1 => "av1", + VideoCodec.None => "none", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Specifies the width of the output. If a value between 0 and 1 is provided, it +/// is treated as a percentage (e.g., `0.4` represents 40% of the original width). +/// You can also supply arithmetic expressions (e.g., `iw_div_2`). Width transformation +/// – [Images](https://imagekit.io/docs/image-resize-and-crop#width---w) · [Videos](https://imagekit.io/docs/video-resize-and-crop#width---w) +/// +[JsonConverter(typeof(TransformationWidthConverter))] +public record class TransformationWidth : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public TransformationWidth(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public TransformationWidth(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public TransformationWidth(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public void Switch(Action @double, Action @string) + { + switch (this.Value) + { + case double value: + @double(value); + break; + case string value: + @string(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of TransformationWidth" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public T Match(Func @double, Func @string) + { + return this.Value switch + { + double value => @double(value), + string value => @string(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of TransformationWidth" + ), + }; + } + + public static implicit operator TransformationWidth(double value) => new(value); + + public static implicit operator TransformationWidth(string value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of TransformationWidth" + ); + } + } + + public virtual bool Equals(TransformationWidth? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class TransformationWidthConverter : JsonConverter +{ + public override TransformationWidth? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + TransformationWidth value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +/// +/// Focus using cropped image coordinates - X coordinate. See [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). +/// +[JsonConverter(typeof(TransformationXConverter))] +public record class TransformationX : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public TransformationX(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public TransformationX(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public TransformationX(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public void Switch(Action @double, Action @string) + { + switch (this.Value) + { + case double value: + @double(value); + break; + case string value: + @string(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of TransformationX" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public T Match(Func @double, Func @string) + { + return this.Value switch + { + double value => @double(value), + string value => @string(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of TransformationX" + ), + }; + } + + public static implicit operator TransformationX(double value) => new(value); + + public static implicit operator TransformationX(string value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of TransformationX" + ); + } + } + + public virtual bool Equals(TransformationX? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class TransformationXConverter : JsonConverter +{ + public override TransformationX? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + TransformationX value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +/// +/// Focus using cropped image coordinates - X center coordinate. See [Focus using +/// cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). +/// +[JsonConverter(typeof(XCenterConverter))] +public record class XCenter : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public XCenter(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public XCenter(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public XCenter(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public void Switch(Action @double, Action @string) + { + switch (this.Value) + { + case double value: + @double(value); + break; + case string value: + @string(value); + break; + default: + throw new ImageKitInvalidDataException("Data did not match any variant of XCenter"); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public T Match(Func @double, Func @string) + { + return this.Value switch + { + double value => @double(value), + string value => @string(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of XCenter" + ), + }; + } + + public static implicit operator XCenter(double value) => new(value); + + public static implicit operator XCenter(string value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException("Data did not match any variant of XCenter"); + } + } + + public virtual bool Equals(XCenter? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class XCenterConverter : JsonConverter +{ + public override XCenter? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write(Utf8JsonWriter writer, XCenter value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +/// +/// Focus using cropped image coordinates - Y coordinate. See [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). +/// +[JsonConverter(typeof(TransformationYConverter))] +public record class TransformationY : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public TransformationY(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public TransformationY(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public TransformationY(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public void Switch(Action @double, Action @string) + { + switch (this.Value) + { + case double value: + @double(value); + break; + case string value: + @string(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of TransformationY" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public T Match(Func @double, Func @string) + { + return this.Value switch + { + double value => @double(value), + string value => @string(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of TransformationY" + ), + }; + } + + public static implicit operator TransformationY(double value) => new(value); + + public static implicit operator TransformationY(string value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of TransformationY" + ); + } + } + + public virtual bool Equals(TransformationY? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class TransformationYConverter : JsonConverter +{ + public override TransformationY? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + TransformationY value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +/// +/// Focus using cropped image coordinates - Y center coordinate. See [Focus using +/// cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). +/// +[JsonConverter(typeof(YCenterConverter))] +public record class YCenter : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public YCenter(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public YCenter(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public YCenter(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public void Switch(Action @double, Action @string) + { + switch (this.Value) + { + case double value: + @double(value); + break; + case string value: + @string(value); + break; + default: + throw new ImageKitInvalidDataException("Data did not match any variant of YCenter"); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public T Match(Func @double, Func @string) + { + return this.Value switch + { + double value => @double(value), + string value => @string(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of YCenter" + ), + }; + } + + public static implicit operator YCenter(double value) => new(value); + + public static implicit operator YCenter(string value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException("Data did not match any variant of YCenter"); + } + } + + public virtual bool Equals(YCenter? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class YCenterConverter : JsonConverter +{ + public override YCenter? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write(Utf8JsonWriter writer, YCenter value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} diff --git a/src/Imagekit/Models/TransformationPosition.cs b/src/ImageKit/Models/TransformationPosition.cs similarity index 83% rename from src/Imagekit/Models/TransformationPosition.cs rename to src/ImageKit/Models/TransformationPosition.cs index 2f6aba22..cc6dba91 100644 --- a/src/Imagekit/Models/TransformationPosition.cs +++ b/src/ImageKit/Models/TransformationPosition.cs @@ -1,52 +1,55 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models; - -/// -/// By default, the transformation string is added as a query parameter in the URL, -/// e.g., `?tr=w-100,h-100`. If you want to add the transformation string in the -/// path of the URL, set this to `path`. Learn more in the [Transformations guide](https://imagekit.io/docs/transformations). -/// -[JsonConverter(typeof(TransformationPositionConverter))] -public enum TransformationPosition -{ - Path, - Query, -} - -sealed class TransformationPositionConverter : JsonConverter -{ - public override TransformationPosition Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "path" => TransformationPosition.Path, - "query" => TransformationPosition.Query, - _ => (TransformationPosition)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - TransformationPosition value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - TransformationPosition.Path => "path", - TransformationPosition.Query => "query", - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} +using System; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Exceptions; + +namespace ImageKit.Models; + +/// +/// By default, the transformation string is added as a query parameter in the URL, +/// e.g., `?tr=w-100,h-100`. If you want to add the transformation string in the +/// path of the URL, set this to `path`. Learn more in the [Transformations guide](https://imagekit.io/docs/transformations). +/// +[JsonConverter(typeof(TransformationPositionConverter))] +public enum TransformationPosition +{ + Path, + Query, +} + +sealed class TransformationPositionConverter : JsonConverter +{ + public override TransformationPosition Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "path" => TransformationPosition.Path, + "query" => TransformationPosition.Query, + _ => (TransformationPosition)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + TransformationPosition value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + TransformationPosition.Path => "path", + TransformationPosition.Query => "query", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} diff --git a/src/ImageKit/Models/UnnamedSchemaWithArrayParent0.cs b/src/ImageKit/Models/UnnamedSchemaWithArrayParent0.cs new file mode 100644 index 00000000..488238d6 --- /dev/null +++ b/src/ImageKit/Models/UnnamedSchemaWithArrayParent0.cs @@ -0,0 +1,5322 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; +using ImageKit.Exceptions; + +namespace ImageKit.Models; + +[JsonConverter(typeof(UnnamedSchemaWithArrayParent0Converter))] +public record class UnnamedSchemaWithArrayParent0 : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public UnnamedSchemaWithArrayParent0( + UnnamedSchemaWithArrayParent0RemoveBg value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent0( + UnnamedSchemaWithArrayParent0AutoTaggingExtension value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent0( + UnnamedSchemaWithArrayParent0AIAutoDescription value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent0( + UnnamedSchemaWithArrayParent0AITasks value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent0(SavedExtension value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent0(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickRemoveBg(out var value)) { + /// // `value` is of type `UnnamedSchemaWithArrayParent0RemoveBg` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickRemoveBg( + [NotNullWhen(true)] out UnnamedSchemaWithArrayParent0RemoveBg? value + ) + { + value = this.Value as UnnamedSchemaWithArrayParent0RemoveBg; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickAutoTaggingExtension(out var value)) { + /// // `value` is of type `UnnamedSchemaWithArrayParent0AutoTaggingExtension` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickAutoTaggingExtension( + [NotNullWhen(true)] out UnnamedSchemaWithArrayParent0AutoTaggingExtension? value + ) + { + value = this.Value as UnnamedSchemaWithArrayParent0AutoTaggingExtension; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickAIAutoDescription(out var value)) { + /// // `value` is of type `UnnamedSchemaWithArrayParent0AIAutoDescription` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickAIAutoDescription( + [NotNullWhen(true)] out UnnamedSchemaWithArrayParent0AIAutoDescription? value + ) + { + value = this.Value as UnnamedSchemaWithArrayParent0AIAutoDescription; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickAITasks(out var value)) { + /// // `value` is of type `UnnamedSchemaWithArrayParent0AITasks` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickAITasks([NotNullWhen(true)] out UnnamedSchemaWithArrayParent0AITasks? value) + { + value = this.Value as UnnamedSchemaWithArrayParent0AITasks; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickSavedExtension(out var value)) { + /// // `value` is of type `SavedExtension` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickSavedExtension([NotNullWhen(true)] out SavedExtension? value) + { + value = this.Value as SavedExtension; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (UnnamedSchemaWithArrayParent0RemoveBg value) => {...}, + /// (UnnamedSchemaWithArrayParent0AutoTaggingExtension value) => {...}, + /// (UnnamedSchemaWithArrayParent0AIAutoDescription value) => {...}, + /// (UnnamedSchemaWithArrayParent0AITasks value) => {...}, + /// (SavedExtension value) => {...} + /// ); + /// + /// + /// + public void Switch( + Action removeBg, + Action autoTaggingExtension, + Action aiAutoDescription, + Action aiTasks, + Action savedExtension + ) + { + switch (this.Value) + { + case UnnamedSchemaWithArrayParent0RemoveBg value: + removeBg(value); + break; + case UnnamedSchemaWithArrayParent0AutoTaggingExtension value: + autoTaggingExtension(value); + break; + case UnnamedSchemaWithArrayParent0AIAutoDescription value: + aiAutoDescription(value); + break; + case UnnamedSchemaWithArrayParent0AITasks value: + aiTasks(value); + break; + case SavedExtension value: + savedExtension(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent0" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (UnnamedSchemaWithArrayParent0RemoveBg value) => {...}, + /// (UnnamedSchemaWithArrayParent0AutoTaggingExtension value) => {...}, + /// (UnnamedSchemaWithArrayParent0AIAutoDescription value) => {...}, + /// (UnnamedSchemaWithArrayParent0AITasks value) => {...}, + /// (SavedExtension value) => {...} + /// ); + /// + /// + /// + public T Match( + Func removeBg, + Func autoTaggingExtension, + Func aiAutoDescription, + Func aiTasks, + Func savedExtension + ) + { + return this.Value switch + { + UnnamedSchemaWithArrayParent0RemoveBg value => removeBg(value), + UnnamedSchemaWithArrayParent0AutoTaggingExtension value => autoTaggingExtension(value), + UnnamedSchemaWithArrayParent0AIAutoDescription value => aiAutoDescription(value), + UnnamedSchemaWithArrayParent0AITasks value => aiTasks(value), + SavedExtension value => savedExtension(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent0" + ), + }; + } + + public static implicit operator UnnamedSchemaWithArrayParent0( + UnnamedSchemaWithArrayParent0RemoveBg value + ) => new(value); + + public static implicit operator UnnamedSchemaWithArrayParent0( + UnnamedSchemaWithArrayParent0AutoTaggingExtension value + ) => new(value); + + public static implicit operator UnnamedSchemaWithArrayParent0( + UnnamedSchemaWithArrayParent0AIAutoDescription value + ) => new(value); + + public static implicit operator UnnamedSchemaWithArrayParent0( + UnnamedSchemaWithArrayParent0AITasks value + ) => new(value); + + public static implicit operator UnnamedSchemaWithArrayParent0(SavedExtension value) => + new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent0" + ); + } + this.Switch( + (removeBg) => removeBg.Validate(), + (autoTaggingExtension) => autoTaggingExtension.Validate(), + (aiAutoDescription) => aiAutoDescription.Validate(), + (aiTasks) => aiTasks.Validate(), + (savedExtension) => savedExtension.Validate() + ); + } + + public virtual bool Equals(UnnamedSchemaWithArrayParent0? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class UnnamedSchemaWithArrayParent0Converter : JsonConverter +{ + public override UnnamedSchemaWithArrayParent0? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + string? name; + try + { + name = element.GetProperty("name").GetString(); + } + catch + { + name = null; + } + + switch (name) + { + case "remove-bg": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + case "ai-auto-description": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + case "ai-tasks": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + case "saved-extension": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + default: + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + UnnamedSchemaWithArrayParent0 value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + UnnamedSchemaWithArrayParent0RemoveBg, + UnnamedSchemaWithArrayParent0RemoveBgFromRaw + >) +)] +public sealed record class UnnamedSchemaWithArrayParent0RemoveBg : JsonModel +{ + /// + /// Specifies the background removal extension. + /// + public JsonElement Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("name"); + } + init { this._rawData.Set("name", value); } + } + + public UnnamedSchemaWithArrayParent0RemoveBgOptions? Options + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "options" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("options", value); + } + } + + /// + public override void Validate() + { + if (!JsonElement.DeepEquals(this.Name, JsonSerializer.SerializeToElement("remove-bg"))) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + this.Options?.Validate(); + } + + public UnnamedSchemaWithArrayParent0RemoveBg() + { + this.Name = JsonSerializer.SerializeToElement("remove-bg"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UnnamedSchemaWithArrayParent0RemoveBg( + UnnamedSchemaWithArrayParent0RemoveBg unnamedSchemaWithArrayParent0RemoveBg + ) + : base(unnamedSchemaWithArrayParent0RemoveBg) { } +#pragma warning restore CS8618 + + public UnnamedSchemaWithArrayParent0RemoveBg(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.Name = JsonSerializer.SerializeToElement("remove-bg"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UnnamedSchemaWithArrayParent0RemoveBg(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UnnamedSchemaWithArrayParent0RemoveBg FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UnnamedSchemaWithArrayParent0RemoveBgFromRaw + : IFromRawJson +{ + /// + public UnnamedSchemaWithArrayParent0RemoveBg FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UnnamedSchemaWithArrayParent0RemoveBg.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + UnnamedSchemaWithArrayParent0RemoveBgOptions, + UnnamedSchemaWithArrayParent0RemoveBgOptionsFromRaw + >) +)] +public sealed record class UnnamedSchemaWithArrayParent0RemoveBgOptions : JsonModel +{ + /// + /// Whether to add an artificial shadow to the result. Default is false. Note: + /// Adding shadows is currently only supported for car photos. + /// + public bool? AddShadow + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("add_shadow"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("add_shadow", value); + } + } + + /// + /// Specifies a solid color background using hex code (e.g., "81d4fa", "fff") + /// or color name (e.g., "green"). If this parameter is set, `bg_image_url` must + /// be empty. + /// + public string? BgColor + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("bg_color"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("bg_color", value); + } + } + + /// + /// Sets a background image from a URL. If this parameter is set, `bg_color` must + /// be empty. + /// + public string? BgImageUrl + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("bg_image_url"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("bg_image_url", value); + } + } + + /// + /// Allows semi-transparent regions in the result. Default is true. Note: Semitransparency + /// is currently only supported for car windows. + /// + public bool? Semitransparency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("semitransparency"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("semitransparency", value); + } + } + + /// + public override void Validate() + { + _ = this.AddShadow; + _ = this.BgColor; + _ = this.BgImageUrl; + _ = this.Semitransparency; + } + + public UnnamedSchemaWithArrayParent0RemoveBgOptions() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UnnamedSchemaWithArrayParent0RemoveBgOptions( + UnnamedSchemaWithArrayParent0RemoveBgOptions unnamedSchemaWithArrayParent0RemoveBgOptions + ) + : base(unnamedSchemaWithArrayParent0RemoveBgOptions) { } +#pragma warning restore CS8618 + + public UnnamedSchemaWithArrayParent0RemoveBgOptions( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UnnamedSchemaWithArrayParent0RemoveBgOptions(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UnnamedSchemaWithArrayParent0RemoveBgOptions FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UnnamedSchemaWithArrayParent0RemoveBgOptionsFromRaw + : IFromRawJson +{ + /// + public UnnamedSchemaWithArrayParent0RemoveBgOptions FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UnnamedSchemaWithArrayParent0RemoveBgOptions.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + UnnamedSchemaWithArrayParent0AutoTaggingExtension, + UnnamedSchemaWithArrayParent0AutoTaggingExtensionFromRaw + >) +)] +public sealed record class UnnamedSchemaWithArrayParent0AutoTaggingExtension : JsonModel +{ + /// + /// Maximum number of tags to attach to the asset. + /// + public required long MaxTags + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("maxTags"); + } + init { this._rawData.Set("maxTags", value); } + } + + /// + /// Minimum confidence level for tags to be considered valid. + /// + public required long MinConfidence + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("minConfidence"); + } + init { this._rawData.Set("minConfidence", value); } + } + + /// + /// Specifies the auto-tagging extension used. + /// + public required ApiEnum Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum + >("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.MaxTags; + _ = this.MinConfidence; + this.Name.Validate(); + } + + public UnnamedSchemaWithArrayParent0AutoTaggingExtension() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UnnamedSchemaWithArrayParent0AutoTaggingExtension( + UnnamedSchemaWithArrayParent0AutoTaggingExtension unnamedSchemaWithArrayParent0AutoTaggingExtension + ) + : base(unnamedSchemaWithArrayParent0AutoTaggingExtension) { } +#pragma warning restore CS8618 + + public UnnamedSchemaWithArrayParent0AutoTaggingExtension( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UnnamedSchemaWithArrayParent0AutoTaggingExtension(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UnnamedSchemaWithArrayParent0AutoTaggingExtension FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UnnamedSchemaWithArrayParent0AutoTaggingExtensionFromRaw + : IFromRawJson +{ + /// + public UnnamedSchemaWithArrayParent0AutoTaggingExtension FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UnnamedSchemaWithArrayParent0AutoTaggingExtension.FromRawUnchecked(rawData); +} + +/// +/// Specifies the auto-tagging extension used. +/// +[JsonConverter(typeof(UnnamedSchemaWithArrayParent0AutoTaggingExtensionNameConverter))] +public enum UnnamedSchemaWithArrayParent0AutoTaggingExtensionName +{ + GoogleAutoTagging, + AwsAutoTagging, +} + +sealed class UnnamedSchemaWithArrayParent0AutoTaggingExtensionNameConverter + : JsonConverter +{ + public override UnnamedSchemaWithArrayParent0AutoTaggingExtensionName Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "google-auto-tagging" => + UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + "aws-auto-tagging" => + UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.AwsAutoTagging, + _ => (UnnamedSchemaWithArrayParent0AutoTaggingExtensionName)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + UnnamedSchemaWithArrayParent0AutoTaggingExtensionName value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging => + "google-auto-tagging", + UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.AwsAutoTagging => + "aws-auto-tagging", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter(typeof(UnnamedSchemaWithArrayParent0AIAutoDescriptionConverter))] +public record class UnnamedSchemaWithArrayParent0AIAutoDescription +{ + public JsonElement Element { get; private init; } + + public UnnamedSchemaWithArrayParent0AIAutoDescription() + { + Element = JsonSerializer.Deserialize( + """ + { + "name": "ai-auto-description" + } + """ + ); + } + + internal UnnamedSchemaWithArrayParent0AIAutoDescription(JsonElement element) + { + Element = element; + } + + /// + /// Validates that the instance's underlying value is the expected constant. + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public void Validate() + { + if (this != new UnnamedSchemaWithArrayParent0AIAutoDescription()) + { + throw new ImageKitInvalidDataException( + "Invalid value given for 'UnnamedSchemaWithArrayParent0AIAutoDescription'" + ); + } + } + + public override int GetHashCode() + { + return 0; + } + + public virtual bool Equals(UnnamedSchemaWithArrayParent0AIAutoDescription? other) + { + if (other == null) + { + return false; + } + + return JsonElement.DeepEquals(this.Element, other.Element); + } +} + +class UnnamedSchemaWithArrayParent0AIAutoDescriptionConverter + : JsonConverter +{ + public override UnnamedSchemaWithArrayParent0AIAutoDescription? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return new(JsonSerializer.Deserialize(ref reader, options)); + } + + public override void Write( + Utf8JsonWriter writer, + UnnamedSchemaWithArrayParent0AIAutoDescription value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Element, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + UnnamedSchemaWithArrayParent0AITasks, + UnnamedSchemaWithArrayParent0AITasksFromRaw + >) +)] +public sealed record class UnnamedSchemaWithArrayParent0AITasks : JsonModel +{ + /// + /// Specifies the AI tasks extension for automated image analysis using AI models. + /// + public JsonElement Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + /// Array of task objects defining AI operations to perform on the asset. + /// + public required IReadOnlyList Tasks + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("tasks"); + } + init + { + this._rawData.Set>( + "tasks", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + if (!JsonElement.DeepEquals(this.Name, JsonSerializer.SerializeToElement("ai-tasks"))) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + foreach (var item in this.Tasks) + { + item.Validate(); + } + } + + public UnnamedSchemaWithArrayParent0AITasks() + { + this.Name = JsonSerializer.SerializeToElement("ai-tasks"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UnnamedSchemaWithArrayParent0AITasks( + UnnamedSchemaWithArrayParent0AITasks unnamedSchemaWithArrayParent0AITasks + ) + : base(unnamedSchemaWithArrayParent0AITasks) { } +#pragma warning restore CS8618 + + public UnnamedSchemaWithArrayParent0AITasks(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.Name = JsonSerializer.SerializeToElement("ai-tasks"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UnnamedSchemaWithArrayParent0AITasks(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UnnamedSchemaWithArrayParent0AITasks FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public UnnamedSchemaWithArrayParent0AITasks( + IReadOnlyList tasks + ) + : this() + { + this.Tasks = tasks; + } +} + +class UnnamedSchemaWithArrayParent0AITasksFromRaw + : IFromRawJson +{ + /// + public UnnamedSchemaWithArrayParent0AITasks FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UnnamedSchemaWithArrayParent0AITasks.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(UnnamedSchemaWithArrayParent0AITasksTaskConverter))] +public record class UnnamedSchemaWithArrayParent0AITasksTask : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public string Instruction + { + get + { + return Match( + selectTags: (x) => x.Instruction, + selectMetadata: (x) => x.Instruction, + yesNo: (x) => x.Instruction + ); + } + } + + public JsonElement Type + { + get + { + return Match( + selectTags: (x) => x.Type, + selectMetadata: (x) => x.Type, + yesNo: (x) => x.Type + ); + } + } + + public long? MaxSelections + { + get + { + return Match( + selectTags: (x) => x.MaxSelections, + selectMetadata: (x) => x.MaxSelections, + yesNo: (_) => null + ); + } + } + + public long? MinSelections + { + get + { + return Match( + selectTags: (x) => x.MinSelections, + selectMetadata: (x) => x.MinSelections, + yesNo: (_) => null + ); + } + } + + public UnnamedSchemaWithArrayParent0AITasksTask( + UnnamedSchemaWithArrayParent0AITasksTaskSelectTags value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent0AITasksTask( + UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent0AITasksTask( + UnnamedSchemaWithArrayParent0AITasksTaskYesNo value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent0AITasksTask(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickSelectTags(out var value)) { + /// // `value` is of type `UnnamedSchemaWithArrayParent0AITasksTaskSelectTags` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickSelectTags( + [NotNullWhen(true)] out UnnamedSchemaWithArrayParent0AITasksTaskSelectTags? value + ) + { + value = this.Value as UnnamedSchemaWithArrayParent0AITasksTaskSelectTags; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickSelectMetadata(out var value)) { + /// // `value` is of type `UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickSelectMetadata( + [NotNullWhen(true)] out UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata? value + ) + { + value = this.Value as UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickYesNo(out var value)) { + /// // `value` is of type `UnnamedSchemaWithArrayParent0AITasksTaskYesNo` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickYesNo( + [NotNullWhen(true)] out UnnamedSchemaWithArrayParent0AITasksTaskYesNo? value + ) + { + value = this.Value as UnnamedSchemaWithArrayParent0AITasksTaskYesNo; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (UnnamedSchemaWithArrayParent0AITasksTaskSelectTags value) => {...}, + /// (UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata value) => {...}, + /// (UnnamedSchemaWithArrayParent0AITasksTaskYesNo value) => {...} + /// ); + /// + /// + /// + public void Switch( + Action selectTags, + Action selectMetadata, + Action yesNo + ) + { + switch (this.Value) + { + case UnnamedSchemaWithArrayParent0AITasksTaskSelectTags value: + selectTags(value); + break; + case UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata value: + selectMetadata(value); + break; + case UnnamedSchemaWithArrayParent0AITasksTaskYesNo value: + yesNo(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTask" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (UnnamedSchemaWithArrayParent0AITasksTaskSelectTags value) => {...}, + /// (UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata value) => {...}, + /// (UnnamedSchemaWithArrayParent0AITasksTaskYesNo value) => {...} + /// ); + /// + /// + /// + public T Match( + Func selectTags, + Func selectMetadata, + Func yesNo + ) + { + return this.Value switch + { + UnnamedSchemaWithArrayParent0AITasksTaskSelectTags value => selectTags(value), + UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata value => selectMetadata(value), + UnnamedSchemaWithArrayParent0AITasksTaskYesNo value => yesNo(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTask" + ), + }; + } + + public static implicit operator UnnamedSchemaWithArrayParent0AITasksTask( + UnnamedSchemaWithArrayParent0AITasksTaskSelectTags value + ) => new(value); + + public static implicit operator UnnamedSchemaWithArrayParent0AITasksTask( + UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata value + ) => new(value); + + public static implicit operator UnnamedSchemaWithArrayParent0AITasksTask( + UnnamedSchemaWithArrayParent0AITasksTaskYesNo value + ) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTask" + ); + } + this.Switch( + (selectTags) => selectTags.Validate(), + (selectMetadata) => selectMetadata.Validate(), + (yesNo) => yesNo.Validate() + ); + } + + public virtual bool Equals(UnnamedSchemaWithArrayParent0AITasksTask? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class UnnamedSchemaWithArrayParent0AITasksTaskConverter + : JsonConverter +{ + public override UnnamedSchemaWithArrayParent0AITasksTask? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + string? type; + try + { + type = element.GetProperty("type").GetString(); + } + catch + { + type = null; + } + + switch (type) + { + case "select_tags": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + case "select_metadata": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + case "yes_no": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + default: + { + return new UnnamedSchemaWithArrayParent0AITasksTask(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + UnnamedSchemaWithArrayParent0AITasksTask value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + UnnamedSchemaWithArrayParent0AITasksTaskSelectTags, + UnnamedSchemaWithArrayParent0AITasksTaskSelectTagsFromRaw + >) +)] +public sealed record class UnnamedSchemaWithArrayParent0AITasksTaskSelectTags : JsonModel +{ + /// + /// The question or instruction for the AI to analyze the image. + /// + public required string Instruction + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("instruction"); + } + init { this._rawData.Set("instruction", value); } + } + + /// + /// Task type that analyzes the image and adds matching tags from a vocabulary. + /// + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// Maximum number of tags to select from the vocabulary. + /// + public long? MaxSelections + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("max_selections"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("max_selections", value); + } + } + + /// + /// Minimum number of tags to select from the vocabulary. + /// + public long? MinSelections + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("min_selections"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("min_selections", value); + } + } + + /// + /// Array of possible tag values. Combined length of all strings must not exceed + /// 500 characters. Cannot contain the `%` character. + /// + public IReadOnlyList? Vocabulary + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>("vocabulary"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "vocabulary", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.Instruction; + if (!JsonElement.DeepEquals(this.Type, JsonSerializer.SerializeToElement("select_tags"))) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + _ = this.MaxSelections; + _ = this.MinSelections; + _ = this.Vocabulary; + } + + public UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + { + this.Type = JsonSerializer.SerializeToElement("select_tags"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UnnamedSchemaWithArrayParent0AITasksTaskSelectTags( + UnnamedSchemaWithArrayParent0AITasksTaskSelectTags unnamedSchemaWithArrayParent0AITasksTaskSelectTags + ) + : base(unnamedSchemaWithArrayParent0AITasksTaskSelectTags) { } +#pragma warning restore CS8618 + + public UnnamedSchemaWithArrayParent0AITasksTaskSelectTags( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("select_tags"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UnnamedSchemaWithArrayParent0AITasksTaskSelectTags( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UnnamedSchemaWithArrayParent0AITasksTaskSelectTags FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public UnnamedSchemaWithArrayParent0AITasksTaskSelectTags(string instruction) + : this() + { + this.Instruction = instruction; + } +} + +class UnnamedSchemaWithArrayParent0AITasksTaskSelectTagsFromRaw + : IFromRawJson +{ + /// + public UnnamedSchemaWithArrayParent0AITasksTaskSelectTags FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UnnamedSchemaWithArrayParent0AITasksTaskSelectTags.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata, + UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataFromRaw + >) +)] +public sealed record class UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata : JsonModel +{ + /// + /// Name of the custom metadata field to set. The field must exist in your account. + /// + public required string Field + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("field"); + } + init { this._rawData.Set("field", value); } + } + + /// + /// The question or instruction for the AI to analyze the image. + /// + public required string Instruction + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("instruction"); + } + init { this._rawData.Set("instruction", value); } + } + + /// + /// Task type that analyzes the image and sets a custom metadata field value from + /// a vocabulary. + /// + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// Maximum number of values to select from the vocabulary. + /// + public long? MaxSelections + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("max_selections"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("max_selections", value); + } + } + + /// + /// Minimum number of values to select from the vocabulary. + /// + public long? MinSelections + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("min_selections"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("min_selections", value); + } + } + + /// + /// Array of possible values matching the custom metadata field type. + /// + public IReadOnlyList? Vocabulary + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct< + ImmutableArray + >("vocabulary"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "vocabulary", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.Field; + _ = this.Instruction; + if ( + !JsonElement.DeepEquals(this.Type, JsonSerializer.SerializeToElement("select_metadata")) + ) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + _ = this.MaxSelections; + _ = this.MinSelections; + foreach (var item in this.Vocabulary ?? []) + { + item.Validate(); + } + } + + public UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata() + { + this.Type = JsonSerializer.SerializeToElement("select_metadata"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata( + UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata unnamedSchemaWithArrayParent0AITasksTaskSelectMetadata + ) + : base(unnamedSchemaWithArrayParent0AITasksTaskSelectMetadata) { } +#pragma warning restore CS8618 + + public UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("select_metadata"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataFromRaw + : IFromRawJson +{ + /// + public UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabularyConverter))] +public record class UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabulary : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabulary( + string value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabulary( + double value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabulary( + bool value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabulary(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickBool(out var value)) { + /// // `value` is of type `bool` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = this.Value as bool?; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} + /// ); + /// + /// + /// + public void Switch(Action @string, Action @double, Action @bool) + { + switch (this.Value) + { + case string value: + @string(value); + break; + case double value: + @double(value); + break; + case bool value: + @bool(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabulary" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} + /// ); + /// + /// + /// + public T Match(Func @string, Func @double, Func @bool) + { + return this.Value switch + { + string value => @string(value), + double value => @double(value), + bool value => @bool(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabulary" + ), + }; + } + + public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabulary( + string value + ) => new(value); + + public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabulary( + double value + ) => new(value); + + public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabulary( + bool value + ) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabulary" + ); + } + } + + public virtual bool Equals( + UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabulary? other + ) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabularyConverter + : JsonConverter +{ + public override UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabulary? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabulary value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + UnnamedSchemaWithArrayParent0AITasksTaskYesNo, + UnnamedSchemaWithArrayParent0AITasksTaskYesNoFromRaw + >) +)] +public sealed record class UnnamedSchemaWithArrayParent0AITasksTaskYesNo : JsonModel +{ + /// + /// The yes/no question for the AI to answer about the image. + /// + public required string Instruction + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("instruction"); + } + init { this._rawData.Set("instruction", value); } + } + + /// + /// Task type that asks a yes/no question and executes actions based on the answer. + /// + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// Actions to execute if the AI answers no. + /// + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo? OnNo + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "on_no" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("on_no", value); + } + } + + /// + /// Actions to execute if the AI cannot determine the answer. + /// + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown? OnUnknown + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "on_unknown" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("on_unknown", value); + } + } + + /// + /// Actions to execute if the AI answers yes. + /// + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYes? OnYes + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "on_yes" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("on_yes", value); + } + } + + /// + public override void Validate() + { + _ = this.Instruction; + if (!JsonElement.DeepEquals(this.Type, JsonSerializer.SerializeToElement("yes_no"))) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + this.OnNo?.Validate(); + this.OnUnknown?.Validate(); + this.OnYes?.Validate(); + } + + public UnnamedSchemaWithArrayParent0AITasksTaskYesNo() + { + this.Type = JsonSerializer.SerializeToElement("yes_no"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UnnamedSchemaWithArrayParent0AITasksTaskYesNo( + UnnamedSchemaWithArrayParent0AITasksTaskYesNo unnamedSchemaWithArrayParent0AITasksTaskYesNo + ) + : base(unnamedSchemaWithArrayParent0AITasksTaskYesNo) { } +#pragma warning restore CS8618 + + public UnnamedSchemaWithArrayParent0AITasksTaskYesNo( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("yes_no"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UnnamedSchemaWithArrayParent0AITasksTaskYesNo(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UnnamedSchemaWithArrayParent0AITasksTaskYesNo FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public UnnamedSchemaWithArrayParent0AITasksTaskYesNo(string instruction) + : this() + { + this.Instruction = instruction; + } +} + +class UnnamedSchemaWithArrayParent0AITasksTaskYesNoFromRaw + : IFromRawJson +{ + /// + public UnnamedSchemaWithArrayParent0AITasksTaskYesNo FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UnnamedSchemaWithArrayParent0AITasksTaskYesNo.FromRawUnchecked(rawData); +} + +/// +/// Actions to execute if the AI answers no. +/// +[JsonConverter( + typeof(JsonModelConverter< + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo, + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoFromRaw + >) +)] +public sealed record class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo : JsonModel +{ + /// + /// Array of tag strings to add to the asset. + /// + public IReadOnlyList? AddTags + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>("add_tags"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "add_tags", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Array of tag strings to remove from the asset. + /// + public IReadOnlyList? RemoveTags + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>("remove_tags"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "remove_tags", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Array of custom metadata field updates. + /// + public IReadOnlyList? SetMetadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct< + ImmutableArray + >("set_metadata"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "set_metadata", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Array of custom metadata fields to remove. + /// + public IReadOnlyList? UnsetMetadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct< + ImmutableArray + >("unset_metadata"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "unset_metadata", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.AddTags; + _ = this.RemoveTags; + foreach (var item in this.SetMetadata ?? []) + { + item.Validate(); + } + foreach (var item in this.UnsetMetadata ?? []) + { + item.Validate(); + } + } + + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo( + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo unnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo + ) + : base(unnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo) { } +#pragma warning restore CS8618 + + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoFromRaw + : IFromRawJson +{ + /// + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadata, + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataFromRaw + >) +)] +public sealed record class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadata : JsonModel +{ + /// + /// Name of the custom metadata field to set. + /// + public required string Field + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("field"); + } + init { this._rawData.Set("field", value); } + } + + /// + /// Value to set for the custom metadata field. The value type should match the + /// custom metadata field type. + /// + public required UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue Value + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "value" + ); + } + init { this._rawData.Set("value", value); } + } + + /// + public override void Validate() + { + _ = this.Field; + this.Value.Validate(); + } + + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadata() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadata( + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadata unnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadata + ) + : base(unnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadata) { } +#pragma warning restore CS8618 + + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadata( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadata( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadata FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataFromRaw + : IFromRawJson +{ + /// + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadata FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadata.FromRawUnchecked(rawData); +} + +/// +/// Value to set for the custom metadata field. The value type should match the custom +/// metadata field type. +/// +[JsonConverter(typeof(UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueConverter))] +public record class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue( + string value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue( + double value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue( + bool value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue( + IReadOnlyList value, + JsonElement? element = null + ) + { + this.Value = ImmutableArray.ToImmutableArray(value); + this._element = element; + } + + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickBool(out var value)) { + /// // `value` is of type `bool` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = this.Value as bool?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickMixed(out var value)) { + /// // `value` is of type `IReadOnlyList` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMixed( + [NotNullWhen(true)] out IReadOnlyList? value + ) + { + value = this.Value as IReadOnlyList; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList value) => {...} + /// ); + /// + /// + /// + public void Switch( + Action @string, + Action @double, + Action @bool, + Action> mixed + ) + { + switch (this.Value) + { + case string value: + @string(value); + break; + case double value: + @double(value); + break; + case bool value: + @bool(value); + break; + case IReadOnlyList value: + mixed(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList value) => {...} + /// ); + /// + /// + /// + public T Match( + Func @string, + Func @double, + Func @bool, + Func, T> mixed + ) + { + return this.Value switch + { + string value => @string(value), + double value => @double(value), + bool value => @bool(value), + IReadOnlyList value => mixed(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue" + ), + }; + } + + public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue( + string value + ) => new(value); + + public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue( + double value + ) => new(value); + + public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue( + bool value + ) => new(value); + + public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue( + List value + ) => new((IReadOnlyList)value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue" + ); + } + } + + public virtual bool Equals( + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue? other + ) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueConverter + : JsonConverter +{ + public override UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize>( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(UnnamedSchemaWithArrayParent6Converter))] +public record class UnnamedSchemaWithArrayParent6 : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public UnnamedSchemaWithArrayParent6(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent6(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent6(bool value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent6(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickBool(out var value)) { + /// // `value` is of type `bool` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = this.Value as bool?; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} + /// ); + /// + /// + /// + public void Switch(Action @string, Action @double, Action @bool) + { + switch (this.Value) + { + case string value: + @string(value); + break; + case double value: + @double(value); + break; + case bool value: + @bool(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent6" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} + /// ); + /// + /// + /// + public T Match(Func @string, Func @double, Func @bool) + { + return this.Value switch + { + string value => @string(value), + double value => @double(value), + bool value => @bool(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent6" + ), + }; + } + + public static implicit operator UnnamedSchemaWithArrayParent6(string value) => new(value); + + public static implicit operator UnnamedSchemaWithArrayParent6(double value) => new(value); + + public static implicit operator UnnamedSchemaWithArrayParent6(bool value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent6" + ); + } + } + + public virtual bool Equals(UnnamedSchemaWithArrayParent6? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class UnnamedSchemaWithArrayParent6Converter : JsonConverter +{ + public override UnnamedSchemaWithArrayParent6? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + UnnamedSchemaWithArrayParent6 value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoUnsetMetadata, + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoUnsetMetadataFromRaw + >) +)] +public sealed record class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoUnsetMetadata + : JsonModel +{ + /// + /// Name of the custom metadata field to remove. + /// + public required string Field + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("field"); + } + init { this._rawData.Set("field", value); } + } + + /// + public override void Validate() + { + _ = this.Field; + } + + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoUnsetMetadata() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoUnsetMetadata( + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoUnsetMetadata unnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoUnsetMetadata + ) + : base(unnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoUnsetMetadata) { } +#pragma warning restore CS8618 + + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoUnsetMetadata( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoUnsetMetadata( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoUnsetMetadata FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoUnsetMetadata(string field) + : this() + { + this.Field = field; + } +} + +class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoUnsetMetadataFromRaw + : IFromRawJson +{ + /// + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoUnsetMetadata FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoUnsetMetadata.FromRawUnchecked(rawData); +} + +/// +/// Actions to execute if the AI cannot determine the answer. +/// +[JsonConverter( + typeof(JsonModelConverter< + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown, + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownFromRaw + >) +)] +public sealed record class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown : JsonModel +{ + /// + /// Array of tag strings to add to the asset. + /// + public IReadOnlyList? AddTags + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>("add_tags"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "add_tags", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Array of tag strings to remove from the asset. + /// + public IReadOnlyList? RemoveTags + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>("remove_tags"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "remove_tags", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Array of custom metadata field updates. + /// + public IReadOnlyList? SetMetadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct< + ImmutableArray + >("set_metadata"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "set_metadata", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Array of custom metadata fields to remove. + /// + public IReadOnlyList? UnsetMetadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct< + ImmutableArray + >("unset_metadata"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "unset_metadata", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.AddTags; + _ = this.RemoveTags; + foreach (var item in this.SetMetadata ?? []) + { + item.Validate(); + } + foreach (var item in this.UnsetMetadata ?? []) + { + item.Validate(); + } + } + + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown( + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown unnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown + ) + : base(unnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown) { } +#pragma warning restore CS8618 + + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownFromRaw + : IFromRawJson +{ + /// + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadata, + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataFromRaw + >) +)] +public sealed record class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadata + : JsonModel +{ + /// + /// Name of the custom metadata field to set. + /// + public required string Field + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("field"); + } + init { this._rawData.Set("field", value); } + } + + /// + /// Value to set for the custom metadata field. The value type should match the + /// custom metadata field type. + /// + public required UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue Value + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "value" + ); + } + init { this._rawData.Set("value", value); } + } + + /// + public override void Validate() + { + _ = this.Field; + this.Value.Validate(); + } + + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadata() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadata( + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadata unnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadata + ) + : base(unnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadata) { } +#pragma warning restore CS8618 + + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadata( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadata( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadata FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataFromRaw + : IFromRawJson +{ + /// + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadata FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadata.FromRawUnchecked(rawData); +} + +/// +/// Value to set for the custom metadata field. The value type should match the custom +/// metadata field type. +/// +[JsonConverter( + typeof(UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueConverter) +)] +public record class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue( + string value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue( + double value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue( + bool value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue( + IReadOnlyList value, + JsonElement? element = null + ) + { + this.Value = ImmutableArray.ToImmutableArray(value); + this._element = element; + } + + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue( + JsonElement element + ) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickBool(out var value)) { + /// // `value` is of type `bool` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = this.Value as bool?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickMixed(out var value)) { + /// // `value` is of type `IReadOnlyList` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMixed( + [NotNullWhen(true)] out IReadOnlyList? value + ) + { + value = this.Value as IReadOnlyList; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList value) => {...} + /// ); + /// + /// + /// + public void Switch( + Action @string, + Action @double, + Action @bool, + Action> mixed + ) + { + switch (this.Value) + { + case string value: + @string(value); + break; + case double value: + @double(value); + break; + case bool value: + @bool(value); + break; + case IReadOnlyList value: + mixed(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList value) => {...} + /// ); + /// + /// + /// + public T Match( + Func @string, + Func @double, + Func @bool, + Func, T> mixed + ) + { + return this.Value switch + { + string value => @string(value), + double value => @double(value), + bool value => @bool(value), + IReadOnlyList value => mixed(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue" + ), + }; + } + + public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue( + string value + ) => new(value); + + public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue( + double value + ) => new(value); + + public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue( + bool value + ) => new(value); + + public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue( + List value + ) => new((IReadOnlyList)value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue" + ); + } + } + + public virtual bool Equals( + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue? other + ) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueConverter + : JsonConverter +{ + public override UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize>( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(UnnamedSchemaWithArrayParent7Converter))] +public record class UnnamedSchemaWithArrayParent7 : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public UnnamedSchemaWithArrayParent7(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent7(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent7(bool value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent7(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickBool(out var value)) { + /// // `value` is of type `bool` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = this.Value as bool?; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} + /// ); + /// + /// + /// + public void Switch(Action @string, Action @double, Action @bool) + { + switch (this.Value) + { + case string value: + @string(value); + break; + case double value: + @double(value); + break; + case bool value: + @bool(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent7" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} + /// ); + /// + /// + /// + public T Match(Func @string, Func @double, Func @bool) + { + return this.Value switch + { + string value => @string(value), + double value => @double(value), + bool value => @bool(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent7" + ), + }; + } + + public static implicit operator UnnamedSchemaWithArrayParent7(string value) => new(value); + + public static implicit operator UnnamedSchemaWithArrayParent7(double value) => new(value); + + public static implicit operator UnnamedSchemaWithArrayParent7(bool value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent7" + ); + } + } + + public virtual bool Equals(UnnamedSchemaWithArrayParent7? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class UnnamedSchemaWithArrayParent7Converter : JsonConverter +{ + public override UnnamedSchemaWithArrayParent7? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + UnnamedSchemaWithArrayParent7 value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownUnsetMetadata, + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownUnsetMetadataFromRaw + >) +)] +public sealed record class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownUnsetMetadata + : JsonModel +{ + /// + /// Name of the custom metadata field to remove. + /// + public required string Field + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("field"); + } + init { this._rawData.Set("field", value); } + } + + /// + public override void Validate() + { + _ = this.Field; + } + + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownUnsetMetadata() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownUnsetMetadata( + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownUnsetMetadata unnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownUnsetMetadata + ) + : base(unnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownUnsetMetadata) { } +#pragma warning restore CS8618 + + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownUnsetMetadata( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownUnsetMetadata( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownUnsetMetadata FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownUnsetMetadata(string field) + : this() + { + this.Field = field; + } +} + +class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownUnsetMetadataFromRaw + : IFromRawJson +{ + /// + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownUnsetMetadata FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownUnsetMetadata.FromRawUnchecked( + rawData + ); +} + +/// +/// Actions to execute if the AI answers yes. +/// +[JsonConverter( + typeof(JsonModelConverter< + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYes, + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesFromRaw + >) +)] +public sealed record class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYes : JsonModel +{ + /// + /// Array of tag strings to add to the asset. + /// + public IReadOnlyList? AddTags + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>("add_tags"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "add_tags", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Array of tag strings to remove from the asset. + /// + public IReadOnlyList? RemoveTags + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>("remove_tags"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "remove_tags", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Array of custom metadata field updates. + /// + public IReadOnlyList? SetMetadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct< + ImmutableArray + >("set_metadata"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "set_metadata", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Array of custom metadata fields to remove. + /// + public IReadOnlyList? UnsetMetadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct< + ImmutableArray + >("unset_metadata"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "unset_metadata", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.AddTags; + _ = this.RemoveTags; + foreach (var item in this.SetMetadata ?? []) + { + item.Validate(); + } + foreach (var item in this.UnsetMetadata ?? []) + { + item.Validate(); + } + } + + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYes() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYes( + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYes unnamedSchemaWithArrayParent0AITasksTaskYesNoOnYes + ) + : base(unnamedSchemaWithArrayParent0AITasksTaskYesNoOnYes) { } +#pragma warning restore CS8618 + + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYes( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYes( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYes FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesFromRaw + : IFromRawJson +{ + /// + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYes FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYes.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadata, + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataFromRaw + >) +)] +public sealed record class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadata : JsonModel +{ + /// + /// Name of the custom metadata field to set. + /// + public required string Field + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("field"); + } + init { this._rawData.Set("field", value); } + } + + /// + /// Value to set for the custom metadata field. The value type should match the + /// custom metadata field type. + /// + public required UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue Value + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "value" + ); + } + init { this._rawData.Set("value", value); } + } + + /// + public override void Validate() + { + _ = this.Field; + this.Value.Validate(); + } + + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadata() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadata( + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadata unnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadata + ) + : base(unnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadata) { } +#pragma warning restore CS8618 + + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadata( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadata( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadata FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataFromRaw + : IFromRawJson +{ + /// + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadata FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadata.FromRawUnchecked(rawData); +} + +/// +/// Value to set for the custom metadata field. The value type should match the custom +/// metadata field type. +/// +[JsonConverter(typeof(UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueConverter))] +public record class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue( + string value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue( + double value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue( + bool value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue( + IReadOnlyList value, + JsonElement? element = null + ) + { + this.Value = ImmutableArray.ToImmutableArray(value); + this._element = element; + } + + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickBool(out var value)) { + /// // `value` is of type `bool` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = this.Value as bool?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickMixed(out var value)) { + /// // `value` is of type `IReadOnlyList` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMixed( + [NotNullWhen(true)] out IReadOnlyList? value + ) + { + value = this.Value as IReadOnlyList; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList value) => {...} + /// ); + /// + /// + /// + public void Switch( + Action @string, + Action @double, + Action @bool, + Action> mixed + ) + { + switch (this.Value) + { + case string value: + @string(value); + break; + case double value: + @double(value); + break; + case bool value: + @bool(value); + break; + case IReadOnlyList value: + mixed(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList value) => {...} + /// ); + /// + /// + /// + public T Match( + Func @string, + Func @double, + Func @bool, + Func, T> mixed + ) + { + return this.Value switch + { + string value => @string(value), + double value => @double(value), + bool value => @bool(value), + IReadOnlyList value => mixed(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue" + ), + }; + } + + public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue( + string value + ) => new(value); + + public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue( + double value + ) => new(value); + + public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue( + bool value + ) => new(value); + + public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue( + List value + ) => new((IReadOnlyList)value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue" + ); + } + } + + public virtual bool Equals( + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue? other + ) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueConverter + : JsonConverter +{ + public override UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize>( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(UnnamedSchemaWithArrayParent8Converter))] +public record class UnnamedSchemaWithArrayParent8 : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public UnnamedSchemaWithArrayParent8(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent8(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent8(bool value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent8(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickBool(out var value)) { + /// // `value` is of type `bool` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = this.Value as bool?; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} + /// ); + /// + /// + /// + public void Switch(Action @string, Action @double, Action @bool) + { + switch (this.Value) + { + case string value: + @string(value); + break; + case double value: + @double(value); + break; + case bool value: + @bool(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent8" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} + /// ); + /// + /// + /// + public T Match(Func @string, Func @double, Func @bool) + { + return this.Value switch + { + string value => @string(value), + double value => @double(value), + bool value => @bool(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent8" + ), + }; + } + + public static implicit operator UnnamedSchemaWithArrayParent8(string value) => new(value); + + public static implicit operator UnnamedSchemaWithArrayParent8(double value) => new(value); + + public static implicit operator UnnamedSchemaWithArrayParent8(bool value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent8" + ); + } + } + + public virtual bool Equals(UnnamedSchemaWithArrayParent8? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class UnnamedSchemaWithArrayParent8Converter : JsonConverter +{ + public override UnnamedSchemaWithArrayParent8? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + UnnamedSchemaWithArrayParent8 value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesUnsetMetadata, + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesUnsetMetadataFromRaw + >) +)] +public sealed record class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesUnsetMetadata + : JsonModel +{ + /// + /// Name of the custom metadata field to remove. + /// + public required string Field + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("field"); + } + init { this._rawData.Set("field", value); } + } + + /// + public override void Validate() + { + _ = this.Field; + } + + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesUnsetMetadata() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesUnsetMetadata( + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesUnsetMetadata unnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesUnsetMetadata + ) + : base(unnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesUnsetMetadata) { } +#pragma warning restore CS8618 + + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesUnsetMetadata( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesUnsetMetadata( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesUnsetMetadata FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesUnsetMetadata(string field) + : this() + { + this.Field = field; + } +} + +class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesUnsetMetadataFromRaw + : IFromRawJson +{ + /// + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesUnsetMetadata FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesUnsetMetadata.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class SavedExtension : JsonModel +{ + /// + /// The unique ID of the saved extension to apply. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// Indicates this is a reference to a saved extension. + /// + public JsonElement Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + if ( + !JsonElement.DeepEquals(this.Name, JsonSerializer.SerializeToElement("saved-extension")) + ) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + } + + public SavedExtension() + { + this.Name = JsonSerializer.SerializeToElement("saved-extension"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SavedExtension(SavedExtension savedExtension) + : base(savedExtension) { } +#pragma warning restore CS8618 + + public SavedExtension(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.Name = JsonSerializer.SerializeToElement("saved-extension"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + SavedExtension(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static SavedExtension FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public SavedExtension(string id) + : this() + { + this.ID = id; + } +} + +class SavedExtensionFromRaw : IFromRawJson +{ + /// + public SavedExtension FromRawUnchecked(IReadOnlyDictionary rawData) => + SavedExtension.FromRawUnchecked(rawData); +} diff --git a/src/ImageKit/Models/VideoOverlay.cs b/src/ImageKit/Models/VideoOverlay.cs new file mode 100644 index 00000000..623b2ce0 --- /dev/null +++ b/src/ImageKit/Models/VideoOverlay.cs @@ -0,0 +1,451 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; +using ImageKit.Exceptions; + +namespace ImageKit.Models; + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class VideoOverlay : JsonModel +{ + /// + /// Controls how the layer blends with the base image or underlying content. + /// Maps to `lm` in the URL. By default, layers completely cover the base image + /// beneath them. Layer modes change this behavior: - `multiply`: Multiplies + /// the pixel values of the layer with the base image. The result is always darker + /// than the original images. This is ideal for applying shadows or color tints. + /// - `displace`: Uses the layer as a displacement map to distort pixels in the + /// base image. The red channel controls horizontal displacement, and the green + /// channel controls vertical displacement. Requires `x` or `y` parameter to control + /// displacement magnitude. - `cutout`: Acts as an inverse mask where opaque areas + /// of the layer turn the base image transparent, while transparent areas leave + /// the base image unchanged. This mode functions like a hole-punch, effectively + /// cutting the shape of the layer out of the underlying image. - `cutter`: Acts + /// as a shape mask where only the parts of the base image that fall inside the + /// opaque area of the layer are preserved. This mode functions like a cookie-cutter, + /// trimming the base image to match the specific dimensions and shape of the + /// layer. See [Layer modes](https://imagekit.io/docs/add-overlays-on-images#layer-modes). + /// + public ApiEnum? LayerMode + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("layerMode"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("layerMode", value); + } + } + + public OverlayPosition? Position + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("position"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("position", value); + } + } + + public OverlayTiming? Timing + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("timing"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("timing", value); + } + } + + /// + /// Specifies the relative path to the video used as an overlay. + /// + public required string Input + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("input"); + } + init { this._rawData.Set("input", value); } + } + + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// The input path can be included in the layer as either `i-{input}` or `ie-{base64_encoded_input}`. + /// By default, the SDK determines the appropriate format automatically. To + /// always use base64 encoding (`ie-{base64}`), set this parameter to `base64`. + /// To always use plain text (`i-{input}`), set it to `plain`. + /// + /// Regardless of the encoding method: - Leading and trailing slashes are + /// removed. - Remaining slashes within the path are replaced with `@@` when using + /// plain text. + /// + public ApiEnum? Encoding + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass< + ApiEnum + >("encoding"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("encoding", value); + } + } + + /// + /// Array of transformation to be applied to the overlay video. Except `streamingResolutions`, + /// all other video transformations are supported. See [Video transformations](https://imagekit.io/docs/video-transformation). + /// + public IReadOnlyList? Transformation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>( + "transformation" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "transformation", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + public static implicit operator BaseOverlay(VideoOverlay videoOverlay) => + new() + { + LayerMode = videoOverlay.LayerMode, + Position = videoOverlay.Position, + Timing = videoOverlay.Timing, + }; + + /// + public override void Validate() + { + this.LayerMode?.Validate(); + this.Position?.Validate(); + this.Timing?.Validate(); + _ = this.Input; + if (!JsonElement.DeepEquals(this.Type, JsonSerializer.SerializeToElement("video"))) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + this.Encoding?.Validate(); + foreach (var item in this.Transformation ?? []) + { + item.Validate(); + } + } + + public VideoOverlay() + { + this.Type = JsonSerializer.SerializeToElement("video"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public VideoOverlay(VideoOverlay videoOverlay) + : base(videoOverlay) { } +#pragma warning restore CS8618 + + public VideoOverlay(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("video"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + VideoOverlay(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static VideoOverlay FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public VideoOverlay(string input) + : this() + { + this.Input = input; + } +} + +class VideoOverlayFromRaw : IFromRawJson +{ + /// + public VideoOverlay FromRawUnchecked(IReadOnlyDictionary rawData) => + VideoOverlay.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + VideoOverlayIntersectionMember1, + VideoOverlayIntersectionMember1FromRaw + >) +)] +public sealed record class VideoOverlayIntersectionMember1 : JsonModel +{ + /// + /// Specifies the relative path to the video used as an overlay. + /// + public required string Input + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("input"); + } + init { this._rawData.Set("input", value); } + } + + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// The input path can be included in the layer as either `i-{input}` or `ie-{base64_encoded_input}`. + /// By default, the SDK determines the appropriate format automatically. To + /// always use base64 encoding (`ie-{base64}`), set this parameter to `base64`. + /// To always use plain text (`i-{input}`), set it to `plain`. + /// + /// Regardless of the encoding method: - Leading and trailing slashes are + /// removed. - Remaining slashes within the path are replaced with `@@` when using + /// plain text. + /// + public ApiEnum? Encoding + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass< + ApiEnum + >("encoding"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("encoding", value); + } + } + + /// + /// Array of transformation to be applied to the overlay video. Except `streamingResolutions`, + /// all other video transformations are supported. See [Video transformations](https://imagekit.io/docs/video-transformation). + /// + public IReadOnlyList? Transformation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>( + "transformation" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "transformation", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.Input; + if (!JsonElement.DeepEquals(this.Type, JsonSerializer.SerializeToElement("video"))) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + this.Encoding?.Validate(); + foreach (var item in this.Transformation ?? []) + { + item.Validate(); + } + } + + public VideoOverlayIntersectionMember1() + { + this.Type = JsonSerializer.SerializeToElement("video"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public VideoOverlayIntersectionMember1( + VideoOverlayIntersectionMember1 videoOverlayIntersectionMember1 + ) + : base(videoOverlayIntersectionMember1) { } +#pragma warning restore CS8618 + + public VideoOverlayIntersectionMember1(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("video"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + VideoOverlayIntersectionMember1(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static VideoOverlayIntersectionMember1 FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public VideoOverlayIntersectionMember1(string input) + : this() + { + this.Input = input; + } +} + +class VideoOverlayIntersectionMember1FromRaw : IFromRawJson +{ + /// + public VideoOverlayIntersectionMember1 FromRawUnchecked( + IReadOnlyDictionary rawData + ) => VideoOverlayIntersectionMember1.FromRawUnchecked(rawData); +} + +/// +/// The input path can be included in the layer as either `i-{input}` or `ie-{base64_encoded_input}`. +/// By default, the SDK determines the appropriate format automatically. To always +/// use base64 encoding (`ie-{base64}`), set this parameter to `base64`. To always +/// use plain text (`i-{input}`), set it to `plain`. +/// +/// Regardless of the encoding method: - Leading and trailing slashes are removed. +/// - Remaining slashes within the path are replaced with `@@` when using plain text. +/// +[JsonConverter(typeof(VideoOverlayIntersectionMember1EncodingConverter))] +public enum VideoOverlayIntersectionMember1Encoding +{ + Auto, + Plain, + Base64, +} + +sealed class VideoOverlayIntersectionMember1EncodingConverter + : JsonConverter +{ + public override VideoOverlayIntersectionMember1Encoding Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "auto" => VideoOverlayIntersectionMember1Encoding.Auto, + "plain" => VideoOverlayIntersectionMember1Encoding.Plain, + "base64" => VideoOverlayIntersectionMember1Encoding.Base64, + _ => (VideoOverlayIntersectionMember1Encoding)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + VideoOverlayIntersectionMember1Encoding value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + VideoOverlayIntersectionMember1Encoding.Auto => "auto", + VideoOverlayIntersectionMember1Encoding.Plain => "plain", + VideoOverlayIntersectionMember1Encoding.Base64 => "base64", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} diff --git a/src/ImageKit/Models/Webhooks/BaseWebhookEvent.cs b/src/ImageKit/Models/Webhooks/BaseWebhookEvent.cs new file mode 100644 index 00000000..5e455cc1 --- /dev/null +++ b/src/ImageKit/Models/Webhooks/BaseWebhookEvent.cs @@ -0,0 +1,81 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; + +namespace ImageKit.Models.Webhooks; + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class BaseWebhookEvent : JsonModel +{ + /// + /// Unique identifier for the event. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The type of webhook event. + /// + public required string Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.Type; + } + + public BaseWebhookEvent() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public BaseWebhookEvent(BaseWebhookEvent baseWebhookEvent) + : base(baseWebhookEvent) { } +#pragma warning restore CS8618 + + public BaseWebhookEvent(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + BaseWebhookEvent(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static BaseWebhookEvent FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class BaseWebhookEventFromRaw : IFromRawJson +{ + /// + public BaseWebhookEvent FromRawUnchecked(IReadOnlyDictionary rawData) => + BaseWebhookEvent.FromRawUnchecked(rawData); +} diff --git a/src/ImageKit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs b/src/ImageKit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs new file mode 100644 index 00000000..824708a5 --- /dev/null +++ b/src/ImageKit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs @@ -0,0 +1,652 @@ +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; +using ImageKit.Exceptions; +using System = System; + +namespace ImageKit.Models.Webhooks; + +/// +/// Triggered when a new video transformation request is accepted for processing. +/// This event confirms that ImageKit has received and queued your transformation +/// request. Use this for debugging and tracking transformation lifecycle. +/// +[JsonConverter(typeof(UnsafeUnwrapWebhookEventConverter))] +public record class UnsafeUnwrapWebhookEvent : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public string ID + { + get + { + return Match( + videoTransformationAccepted: (x) => x.ID, + videoTransformationReady: (x) => x.ID, + videoTransformationError: (x) => x.ID, + uploadPreTransformSuccess: (x) => x.ID, + uploadPreTransformError: (x) => x.ID, + uploadPostTransformSuccess: (x) => x.ID, + uploadPostTransformError: (x) => x.ID + ); + } + } + + public string Type + { + get + { + return Match( + videoTransformationAccepted: (x) => x.Type, + videoTransformationReady: (x) => x.Type, + videoTransformationError: (x) => x.Type, + uploadPreTransformSuccess: (x) => x.Type, + uploadPreTransformError: (x) => x.Type, + uploadPostTransformSuccess: (x) => x.Type, + uploadPostTransformError: (x) => x.Type + ); + } + } + + public System::DateTimeOffset CreatedAt + { + get + { + return Match( + videoTransformationAccepted: (x) => x.CreatedAt, + videoTransformationReady: (x) => x.CreatedAt, + videoTransformationError: (x) => x.CreatedAt, + uploadPreTransformSuccess: (x) => x.CreatedAt, + uploadPreTransformError: (x) => x.CreatedAt, + uploadPostTransformSuccess: (x) => x.CreatedAt, + uploadPostTransformError: (x) => x.CreatedAt + ); + } + } + + public UnsafeUnwrapWebhookEvent( + VideoTransformationAcceptedEvent value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public UnsafeUnwrapWebhookEvent( + VideoTransformationReadyEvent value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public UnsafeUnwrapWebhookEvent( + VideoTransformationErrorEvent value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public UnsafeUnwrapWebhookEvent( + UploadPreTransformSuccessEvent value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public UnsafeUnwrapWebhookEvent(UploadPreTransformErrorEvent value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnsafeUnwrapWebhookEvent( + UploadPostTransformSuccessEvent value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public UnsafeUnwrapWebhookEvent( + UploadPostTransformErrorEvent value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public UnsafeUnwrapWebhookEvent(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickVideoTransformationAccepted(out var value)) { + /// // `value` is of type `VideoTransformationAcceptedEvent` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickVideoTransformationAccepted( + [NotNullWhen(true)] out VideoTransformationAcceptedEvent? value + ) + { + value = this.Value as VideoTransformationAcceptedEvent; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickVideoTransformationReady(out var value)) { + /// // `value` is of type `VideoTransformationReadyEvent` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickVideoTransformationReady( + [NotNullWhen(true)] out VideoTransformationReadyEvent? value + ) + { + value = this.Value as VideoTransformationReadyEvent; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickVideoTransformationError(out var value)) { + /// // `value` is of type `VideoTransformationErrorEvent` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickVideoTransformationError( + [NotNullWhen(true)] out VideoTransformationErrorEvent? value + ) + { + value = this.Value as VideoTransformationErrorEvent; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickUploadPreTransformSuccess(out var value)) { + /// // `value` is of type `UploadPreTransformSuccessEvent` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickUploadPreTransformSuccess( + [NotNullWhen(true)] out UploadPreTransformSuccessEvent? value + ) + { + value = this.Value as UploadPreTransformSuccessEvent; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickUploadPreTransformError(out var value)) { + /// // `value` is of type `UploadPreTransformErrorEvent` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickUploadPreTransformError( + [NotNullWhen(true)] out UploadPreTransformErrorEvent? value + ) + { + value = this.Value as UploadPreTransformErrorEvent; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickUploadPostTransformSuccess(out var value)) { + /// // `value` is of type `UploadPostTransformSuccessEvent` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickUploadPostTransformSuccess( + [NotNullWhen(true)] out UploadPostTransformSuccessEvent? value + ) + { + value = this.Value as UploadPostTransformSuccessEvent; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickUploadPostTransformError(out var value)) { + /// // `value` is of type `UploadPostTransformErrorEvent` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickUploadPostTransformError( + [NotNullWhen(true)] out UploadPostTransformErrorEvent? value + ) + { + value = this.Value as UploadPostTransformErrorEvent; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (VideoTransformationAcceptedEvent value) => {...}, + /// (VideoTransformationReadyEvent value) => {...}, + /// (VideoTransformationErrorEvent value) => {...}, + /// (UploadPreTransformSuccessEvent value) => {...}, + /// (UploadPreTransformErrorEvent value) => {...}, + /// (UploadPostTransformSuccessEvent value) => {...}, + /// (UploadPostTransformErrorEvent value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action videoTransformationAccepted, + System::Action videoTransformationReady, + System::Action videoTransformationError, + System::Action uploadPreTransformSuccess, + System::Action uploadPreTransformError, + System::Action uploadPostTransformSuccess, + System::Action uploadPostTransformError + ) + { + switch (this.Value) + { + case VideoTransformationAcceptedEvent value: + videoTransformationAccepted(value); + break; + case VideoTransformationReadyEvent value: + videoTransformationReady(value); + break; + case VideoTransformationErrorEvent value: + videoTransformationError(value); + break; + case UploadPreTransformSuccessEvent value: + uploadPreTransformSuccess(value); + break; + case UploadPreTransformErrorEvent value: + uploadPreTransformError(value); + break; + case UploadPostTransformSuccessEvent value: + uploadPostTransformSuccess(value); + break; + case UploadPostTransformErrorEvent value: + uploadPostTransformError(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnsafeUnwrapWebhookEvent" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (VideoTransformationAcceptedEvent value) => {...}, + /// (VideoTransformationReadyEvent value) => {...}, + /// (VideoTransformationErrorEvent value) => {...}, + /// (UploadPreTransformSuccessEvent value) => {...}, + /// (UploadPreTransformErrorEvent value) => {...}, + /// (UploadPostTransformSuccessEvent value) => {...}, + /// (UploadPostTransformErrorEvent value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func videoTransformationAccepted, + System::Func videoTransformationReady, + System::Func videoTransformationError, + System::Func uploadPreTransformSuccess, + System::Func uploadPreTransformError, + System::Func uploadPostTransformSuccess, + System::Func uploadPostTransformError + ) + { + return this.Value switch + { + VideoTransformationAcceptedEvent value => videoTransformationAccepted(value), + VideoTransformationReadyEvent value => videoTransformationReady(value), + VideoTransformationErrorEvent value => videoTransformationError(value), + UploadPreTransformSuccessEvent value => uploadPreTransformSuccess(value), + UploadPreTransformErrorEvent value => uploadPreTransformError(value), + UploadPostTransformSuccessEvent value => uploadPostTransformSuccess(value), + UploadPostTransformErrorEvent value => uploadPostTransformError(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of UnsafeUnwrapWebhookEvent" + ), + }; + } + + public static implicit operator UnsafeUnwrapWebhookEvent( + VideoTransformationAcceptedEvent value + ) => new(value); + + public static implicit operator UnsafeUnwrapWebhookEvent(VideoTransformationReadyEvent value) => + new(value); + + public static implicit operator UnsafeUnwrapWebhookEvent(VideoTransformationErrorEvent value) => + new(value); + + public static implicit operator UnsafeUnwrapWebhookEvent( + UploadPreTransformSuccessEvent value + ) => new(value); + + public static implicit operator UnsafeUnwrapWebhookEvent(UploadPreTransformErrorEvent value) => + new(value); + + public static implicit operator UnsafeUnwrapWebhookEvent( + UploadPostTransformSuccessEvent value + ) => new(value); + + public static implicit operator UnsafeUnwrapWebhookEvent(UploadPostTransformErrorEvent value) => + new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnsafeUnwrapWebhookEvent" + ); + } + this.Switch( + (videoTransformationAccepted) => videoTransformationAccepted.Validate(), + (videoTransformationReady) => videoTransformationReady.Validate(), + (videoTransformationError) => videoTransformationError.Validate(), + (uploadPreTransformSuccess) => uploadPreTransformSuccess.Validate(), + (uploadPreTransformError) => uploadPreTransformError.Validate(), + (uploadPostTransformSuccess) => uploadPostTransformSuccess.Validate(), + (uploadPostTransformError) => uploadPostTransformError.Validate() + ); + } + + public virtual bool Equals(UnsafeUnwrapWebhookEvent? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class UnsafeUnwrapWebhookEventConverter : JsonConverter +{ + public override UnsafeUnwrapWebhookEvent? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + string? type; + try + { + type = element.GetProperty("type").GetString(); + } + catch + { + type = null; + } + + switch (type) + { + default: + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + UnsafeUnwrapWebhookEvent value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} diff --git a/src/ImageKit/Models/Webhooks/UnwrapWebhookEvent.cs b/src/ImageKit/Models/Webhooks/UnwrapWebhookEvent.cs new file mode 100644 index 00000000..8c29eace --- /dev/null +++ b/src/ImageKit/Models/Webhooks/UnwrapWebhookEvent.cs @@ -0,0 +1,631 @@ +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; +using ImageKit.Exceptions; +using System = System; + +namespace ImageKit.Models.Webhooks; + +/// +/// Triggered when a new video transformation request is accepted for processing. +/// This event confirms that ImageKit has received and queued your transformation +/// request. Use this for debugging and tracking transformation lifecycle. +/// +[JsonConverter(typeof(UnwrapWebhookEventConverter))] +public record class UnwrapWebhookEvent : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public string ID + { + get + { + return Match( + videoTransformationAccepted: (x) => x.ID, + videoTransformationReady: (x) => x.ID, + videoTransformationError: (x) => x.ID, + uploadPreTransformSuccess: (x) => x.ID, + uploadPreTransformError: (x) => x.ID, + uploadPostTransformSuccess: (x) => x.ID, + uploadPostTransformError: (x) => x.ID + ); + } + } + + public string Type + { + get + { + return Match( + videoTransformationAccepted: (x) => x.Type, + videoTransformationReady: (x) => x.Type, + videoTransformationError: (x) => x.Type, + uploadPreTransformSuccess: (x) => x.Type, + uploadPreTransformError: (x) => x.Type, + uploadPostTransformSuccess: (x) => x.Type, + uploadPostTransformError: (x) => x.Type + ); + } + } + + public System::DateTimeOffset CreatedAt + { + get + { + return Match( + videoTransformationAccepted: (x) => x.CreatedAt, + videoTransformationReady: (x) => x.CreatedAt, + videoTransformationError: (x) => x.CreatedAt, + uploadPreTransformSuccess: (x) => x.CreatedAt, + uploadPreTransformError: (x) => x.CreatedAt, + uploadPostTransformSuccess: (x) => x.CreatedAt, + uploadPostTransformError: (x) => x.CreatedAt + ); + } + } + + public UnwrapWebhookEvent(VideoTransformationAcceptedEvent value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnwrapWebhookEvent(VideoTransformationReadyEvent value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnwrapWebhookEvent(VideoTransformationErrorEvent value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnwrapWebhookEvent(UploadPreTransformSuccessEvent value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnwrapWebhookEvent(UploadPreTransformErrorEvent value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnwrapWebhookEvent(UploadPostTransformSuccessEvent value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnwrapWebhookEvent(UploadPostTransformErrorEvent value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnwrapWebhookEvent(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickVideoTransformationAccepted(out var value)) { + /// // `value` is of type `VideoTransformationAcceptedEvent` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickVideoTransformationAccepted( + [NotNullWhen(true)] out VideoTransformationAcceptedEvent? value + ) + { + value = this.Value as VideoTransformationAcceptedEvent; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickVideoTransformationReady(out var value)) { + /// // `value` is of type `VideoTransformationReadyEvent` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickVideoTransformationReady( + [NotNullWhen(true)] out VideoTransformationReadyEvent? value + ) + { + value = this.Value as VideoTransformationReadyEvent; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickVideoTransformationError(out var value)) { + /// // `value` is of type `VideoTransformationErrorEvent` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickVideoTransformationError( + [NotNullWhen(true)] out VideoTransformationErrorEvent? value + ) + { + value = this.Value as VideoTransformationErrorEvent; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickUploadPreTransformSuccess(out var value)) { + /// // `value` is of type `UploadPreTransformSuccessEvent` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickUploadPreTransformSuccess( + [NotNullWhen(true)] out UploadPreTransformSuccessEvent? value + ) + { + value = this.Value as UploadPreTransformSuccessEvent; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickUploadPreTransformError(out var value)) { + /// // `value` is of type `UploadPreTransformErrorEvent` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickUploadPreTransformError( + [NotNullWhen(true)] out UploadPreTransformErrorEvent? value + ) + { + value = this.Value as UploadPreTransformErrorEvent; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickUploadPostTransformSuccess(out var value)) { + /// // `value` is of type `UploadPostTransformSuccessEvent` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickUploadPostTransformSuccess( + [NotNullWhen(true)] out UploadPostTransformSuccessEvent? value + ) + { + value = this.Value as UploadPostTransformSuccessEvent; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickUploadPostTransformError(out var value)) { + /// // `value` is of type `UploadPostTransformErrorEvent` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickUploadPostTransformError( + [NotNullWhen(true)] out UploadPostTransformErrorEvent? value + ) + { + value = this.Value as UploadPostTransformErrorEvent; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (VideoTransformationAcceptedEvent value) => {...}, + /// (VideoTransformationReadyEvent value) => {...}, + /// (VideoTransformationErrorEvent value) => {...}, + /// (UploadPreTransformSuccessEvent value) => {...}, + /// (UploadPreTransformErrorEvent value) => {...}, + /// (UploadPostTransformSuccessEvent value) => {...}, + /// (UploadPostTransformErrorEvent value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action videoTransformationAccepted, + System::Action videoTransformationReady, + System::Action videoTransformationError, + System::Action uploadPreTransformSuccess, + System::Action uploadPreTransformError, + System::Action uploadPostTransformSuccess, + System::Action uploadPostTransformError + ) + { + switch (this.Value) + { + case VideoTransformationAcceptedEvent value: + videoTransformationAccepted(value); + break; + case VideoTransformationReadyEvent value: + videoTransformationReady(value); + break; + case VideoTransformationErrorEvent value: + videoTransformationError(value); + break; + case UploadPreTransformSuccessEvent value: + uploadPreTransformSuccess(value); + break; + case UploadPreTransformErrorEvent value: + uploadPreTransformError(value); + break; + case UploadPostTransformSuccessEvent value: + uploadPostTransformSuccess(value); + break; + case UploadPostTransformErrorEvent value: + uploadPostTransformError(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnwrapWebhookEvent" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (VideoTransformationAcceptedEvent value) => {...}, + /// (VideoTransformationReadyEvent value) => {...}, + /// (VideoTransformationErrorEvent value) => {...}, + /// (UploadPreTransformSuccessEvent value) => {...}, + /// (UploadPreTransformErrorEvent value) => {...}, + /// (UploadPostTransformSuccessEvent value) => {...}, + /// (UploadPostTransformErrorEvent value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func videoTransformationAccepted, + System::Func videoTransformationReady, + System::Func videoTransformationError, + System::Func uploadPreTransformSuccess, + System::Func uploadPreTransformError, + System::Func uploadPostTransformSuccess, + System::Func uploadPostTransformError + ) + { + return this.Value switch + { + VideoTransformationAcceptedEvent value => videoTransformationAccepted(value), + VideoTransformationReadyEvent value => videoTransformationReady(value), + VideoTransformationErrorEvent value => videoTransformationError(value), + UploadPreTransformSuccessEvent value => uploadPreTransformSuccess(value), + UploadPreTransformErrorEvent value => uploadPreTransformError(value), + UploadPostTransformSuccessEvent value => uploadPostTransformSuccess(value), + UploadPostTransformErrorEvent value => uploadPostTransformError(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of UnwrapWebhookEvent" + ), + }; + } + + public static implicit operator UnwrapWebhookEvent(VideoTransformationAcceptedEvent value) => + new(value); + + public static implicit operator UnwrapWebhookEvent(VideoTransformationReadyEvent value) => + new(value); + + public static implicit operator UnwrapWebhookEvent(VideoTransformationErrorEvent value) => + new(value); + + public static implicit operator UnwrapWebhookEvent(UploadPreTransformSuccessEvent value) => + new(value); + + public static implicit operator UnwrapWebhookEvent(UploadPreTransformErrorEvent value) => + new(value); + + public static implicit operator UnwrapWebhookEvent(UploadPostTransformSuccessEvent value) => + new(value); + + public static implicit operator UnwrapWebhookEvent(UploadPostTransformErrorEvent value) => + new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnwrapWebhookEvent" + ); + } + this.Switch( + (videoTransformationAccepted) => videoTransformationAccepted.Validate(), + (videoTransformationReady) => videoTransformationReady.Validate(), + (videoTransformationError) => videoTransformationError.Validate(), + (uploadPreTransformSuccess) => uploadPreTransformSuccess.Validate(), + (uploadPreTransformError) => uploadPreTransformError.Validate(), + (uploadPostTransformSuccess) => uploadPostTransformSuccess.Validate(), + (uploadPostTransformError) => uploadPostTransformError.Validate() + ); + } + + public virtual bool Equals(UnwrapWebhookEvent? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class UnwrapWebhookEventConverter : JsonConverter +{ + public override UnwrapWebhookEvent? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + string? type; + try + { + type = element.GetProperty("type").GetString(); + } + catch + { + type = null; + } + + switch (type) + { + default: + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + UnwrapWebhookEvent value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} diff --git a/src/ImageKit/Models/Webhooks/UploadPostTransformErrorEvent.cs b/src/ImageKit/Models/Webhooks/UploadPostTransformErrorEvent.cs new file mode 100644 index 00000000..5b5245f8 --- /dev/null +++ b/src/ImageKit/Models/Webhooks/UploadPostTransformErrorEvent.cs @@ -0,0 +1,753 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; +using ImageKit.Exceptions; +using System = System; + +namespace ImageKit.Models.Webhooks; + +/// +/// Triggered when a post-transformation fails. The original file remains available, +/// but the requested transformation could not be generated. +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class UploadPostTransformErrorEvent : JsonModel +{ + /// + /// Unique identifier for the event. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The type of webhook event. + /// + public required string Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// Timestamp of when the event occurred in ISO8601 format. + /// + public required System::DateTimeOffset CreatedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("created_at"); + } + init { this._rawData.Set("created_at", value); } + } + + public required Data Data + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("data"); + } + init { this._rawData.Set("data", value); } + } + + public required Request Request + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("request"); + } + init { this._rawData.Set("request", value); } + } + + public static implicit operator BaseWebhookEvent( + UploadPostTransformErrorEvent uploadPostTransformErrorEvent + ) => new() { ID = uploadPostTransformErrorEvent.ID, Type = uploadPostTransformErrorEvent.Type }; + + /// + public override void Validate() + { + _ = this.ID; + _ = this.Type; + _ = this.CreatedAt; + this.Data.Validate(); + this.Request.Validate(); + } + + public UploadPostTransformErrorEvent() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UploadPostTransformErrorEvent( + UploadPostTransformErrorEvent uploadPostTransformErrorEvent + ) + : base(uploadPostTransformErrorEvent) { } +#pragma warning restore CS8618 + + public UploadPostTransformErrorEvent(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UploadPostTransformErrorEvent(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UploadPostTransformErrorEvent FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UploadPostTransformErrorEventFromRaw : IFromRawJson +{ + /// + public UploadPostTransformErrorEvent FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UploadPostTransformErrorEvent.FromRawUnchecked(rawData); +} + +/// +/// Triggered when a post-transformation fails. The original file remains available, +/// but the requested transformation could not be generated. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class IntersectionMember1 : JsonModel +{ + /// + /// Timestamp of when the event occurred in ISO8601 format. + /// + public required System::DateTimeOffset CreatedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("created_at"); + } + init { this._rawData.Set("created_at", value); } + } + + public required Data Data + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("data"); + } + init { this._rawData.Set("data", value); } + } + + public required Request Request + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("request"); + } + init { this._rawData.Set("request", value); } + } + + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + public override void Validate() + { + _ = this.CreatedAt; + this.Data.Validate(); + this.Request.Validate(); + if ( + !JsonElement.DeepEquals( + this.Type, + JsonSerializer.SerializeToElement("upload.post-transform.error") + ) + ) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + } + + public IntersectionMember1() + { + this.Type = JsonSerializer.SerializeToElement("upload.post-transform.error"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public IntersectionMember1(IntersectionMember1 intersectionMember1) + : base(intersectionMember1) { } +#pragma warning restore CS8618 + + public IntersectionMember1(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("upload.post-transform.error"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + IntersectionMember1(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static IntersectionMember1 FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class IntersectionMember1FromRaw : IFromRawJson +{ + /// + public IntersectionMember1 FromRawUnchecked(IReadOnlyDictionary rawData) => + IntersectionMember1.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Data : JsonModel +{ + /// + /// Unique identifier of the originally uploaded file. + /// + public required string FileID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("fileId"); + } + init { this._rawData.Set("fileId", value); } + } + + /// + /// Name of the file. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + /// Path of the file. + /// + public required string Path + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("path"); + } + init { this._rawData.Set("path", value); } + } + + public required Transformation Transformation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("transformation"); + } + init { this._rawData.Set("transformation", value); } + } + + /// + /// URL of the attempted post-transformation. + /// + public required string Url + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("url"); + } + init { this._rawData.Set("url", value); } + } + + /// + public override void Validate() + { + _ = this.FileID; + _ = this.Name; + _ = this.Path; + this.Transformation.Validate(); + _ = this.Url; + } + + public Data() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Data(Data data) + : base(data) { } +#pragma warning restore CS8618 + + public Data(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Data(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static Data FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class DataFromRaw : IFromRawJson +{ + /// + public Data FromRawUnchecked(IReadOnlyDictionary rawData) => + Data.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Transformation : JsonModel +{ + public required Error Error + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("error"); + } + init { this._rawData.Set("error", value); } + } + + /// + public override void Validate() + { + this.Error.Validate(); + } + + public Transformation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Transformation(Transformation transformation) + : base(transformation) { } +#pragma warning restore CS8618 + + public Transformation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Transformation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static Transformation FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public Transformation(Error error) + : this() + { + this.Error = error; + } +} + +class TransformationFromRaw : IFromRawJson +{ + /// + public Transformation FromRawUnchecked(IReadOnlyDictionary rawData) => + Transformation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Error : JsonModel +{ + /// + /// Reason for the post-transformation failure. + /// + public required string Reason + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("reason"); + } + init { this._rawData.Set("reason", value); } + } + + /// + public override void Validate() + { + _ = this.Reason; + } + + public Error() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Error(Error error) + : base(error) { } +#pragma warning restore CS8618 + + public Error(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Error(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static Error FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public Error(string reason) + : this() + { + this.Reason = reason; + } +} + +class ErrorFromRaw : IFromRawJson +{ + /// + public Error FromRawUnchecked(IReadOnlyDictionary rawData) => + Error.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Request : JsonModel +{ + public required RequestTransformation Transformation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("transformation"); + } + init { this._rawData.Set("transformation", value); } + } + + /// + /// Unique identifier for the originating request. + /// + public required string XRequestID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("x_request_id"); + } + init { this._rawData.Set("x_request_id", value); } + } + + /// + public override void Validate() + { + this.Transformation.Validate(); + _ = this.XRequestID; + } + + public Request() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Request(Request request) + : base(request) { } +#pragma warning restore CS8618 + + public Request(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Request(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static Request FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class RequestFromRaw : IFromRawJson +{ + /// + public Request FromRawUnchecked(IReadOnlyDictionary rawData) => + Request.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class RequestTransformation : JsonModel +{ + /// + /// Type of the requested post-transformation. + /// + public required ApiEnum Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum + >("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// Only applicable if transformation type is 'abs'. Streaming protocol used. + /// + public ApiEnum? Protocol + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("protocol"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("protocol", value); + } + } + + /// + /// Value for the requested transformation type. + /// + public string? Value + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("value"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("value", value); + } + } + + /// + public override void Validate() + { + this.Type.Validate(); + this.Protocol?.Validate(); + _ = this.Value; + } + + public RequestTransformation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public RequestTransformation(RequestTransformation requestTransformation) + : base(requestTransformation) { } +#pragma warning restore CS8618 + + public RequestTransformation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + RequestTransformation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static RequestTransformation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public RequestTransformation(ApiEnum type) + : this() + { + this.Type = type; + } +} + +class RequestTransformationFromRaw : IFromRawJson +{ + /// + public RequestTransformation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => RequestTransformation.FromRawUnchecked(rawData); +} + +/// +/// Type of the requested post-transformation. +/// +[JsonConverter(typeof(TypeConverter))] +public enum Type +{ + Transformation, + Abs, + GifToVideo, + Thumbnail, +} + +sealed class TypeConverter : JsonConverter +{ + public override global::ImageKit.Models.Webhooks.Type Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "transformation" => global::ImageKit.Models.Webhooks.Type.Transformation, + "abs" => global::ImageKit.Models.Webhooks.Type.Abs, + "gif-to-video" => global::ImageKit.Models.Webhooks.Type.GifToVideo, + "thumbnail" => global::ImageKit.Models.Webhooks.Type.Thumbnail, + _ => (global::ImageKit.Models.Webhooks.Type)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + global::ImageKit.Models.Webhooks.Type value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + global::ImageKit.Models.Webhooks.Type.Transformation => "transformation", + global::ImageKit.Models.Webhooks.Type.Abs => "abs", + global::ImageKit.Models.Webhooks.Type.GifToVideo => "gif-to-video", + global::ImageKit.Models.Webhooks.Type.Thumbnail => "thumbnail", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Only applicable if transformation type is 'abs'. Streaming protocol used. +/// +[JsonConverter(typeof(ProtocolConverter))] +public enum Protocol +{ + Hls, + Dash, +} + +sealed class ProtocolConverter : JsonConverter +{ + public override Protocol Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "hls" => Protocol.Hls, + "dash" => Protocol.Dash, + _ => (Protocol)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Protocol value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + Protocol.Hls => "hls", + Protocol.Dash => "dash", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} diff --git a/src/ImageKit/Models/Webhooks/UploadPostTransformSuccessEvent.cs b/src/ImageKit/Models/Webhooks/UploadPostTransformSuccessEvent.cs new file mode 100644 index 00000000..fa66a659 --- /dev/null +++ b/src/ImageKit/Models/Webhooks/UploadPostTransformSuccessEvent.cs @@ -0,0 +1,725 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; +using ImageKit.Exceptions; +using System = System; + +namespace ImageKit.Models.Webhooks; + +/// +/// Triggered when a post-transformation completes successfully. The transformed +/// version of the file is now ready and can be accessed via the provided URL. Note +/// that each post-transformation generates a separate webhook event. +/// +[JsonConverter( + typeof(JsonModelConverter< + UploadPostTransformSuccessEvent, + UploadPostTransformSuccessEventFromRaw + >) +)] +public sealed record class UploadPostTransformSuccessEvent : JsonModel +{ + /// + /// Unique identifier for the event. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The type of webhook event. + /// + public required string Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// Timestamp of when the event occurred in ISO8601 format. + /// + public required System::DateTimeOffset CreatedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("created_at"); + } + init { this._rawData.Set("created_at", value); } + } + + public required UploadPostTransformSuccessEventIntersectionMember1Data Data + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "data" + ); + } + init { this._rawData.Set("data", value); } + } + + public required UploadPostTransformSuccessEventIntersectionMember1Request Request + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "request" + ); + } + init { this._rawData.Set("request", value); } + } + + public static implicit operator BaseWebhookEvent( + UploadPostTransformSuccessEvent uploadPostTransformSuccessEvent + ) => + new() + { + ID = uploadPostTransformSuccessEvent.ID, + Type = uploadPostTransformSuccessEvent.Type, + }; + + /// + public override void Validate() + { + _ = this.ID; + _ = this.Type; + _ = this.CreatedAt; + this.Data.Validate(); + this.Request.Validate(); + } + + public UploadPostTransformSuccessEvent() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UploadPostTransformSuccessEvent( + UploadPostTransformSuccessEvent uploadPostTransformSuccessEvent + ) + : base(uploadPostTransformSuccessEvent) { } +#pragma warning restore CS8618 + + public UploadPostTransformSuccessEvent(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UploadPostTransformSuccessEvent(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UploadPostTransformSuccessEvent FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UploadPostTransformSuccessEventFromRaw : IFromRawJson +{ + /// + public UploadPostTransformSuccessEvent FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UploadPostTransformSuccessEvent.FromRawUnchecked(rawData); +} + +/// +/// Triggered when a post-transformation completes successfully. The transformed +/// version of the file is now ready and can be accessed via the provided URL. Note +/// that each post-transformation generates a separate webhook event. +/// +[JsonConverter( + typeof(JsonModelConverter< + UploadPostTransformSuccessEventIntersectionMember1, + UploadPostTransformSuccessEventIntersectionMember1FromRaw + >) +)] +public sealed record class UploadPostTransformSuccessEventIntersectionMember1 : JsonModel +{ + /// + /// Timestamp of when the event occurred in ISO8601 format. + /// + public required System::DateTimeOffset CreatedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("created_at"); + } + init { this._rawData.Set("created_at", value); } + } + + public required UploadPostTransformSuccessEventIntersectionMember1Data Data + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "data" + ); + } + init { this._rawData.Set("data", value); } + } + + public required UploadPostTransformSuccessEventIntersectionMember1Request Request + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "request" + ); + } + init { this._rawData.Set("request", value); } + } + + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + public override void Validate() + { + _ = this.CreatedAt; + this.Data.Validate(); + this.Request.Validate(); + if ( + !JsonElement.DeepEquals( + this.Type, + JsonSerializer.SerializeToElement("upload.post-transform.success") + ) + ) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + } + + public UploadPostTransformSuccessEventIntersectionMember1() + { + this.Type = JsonSerializer.SerializeToElement("upload.post-transform.success"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UploadPostTransformSuccessEventIntersectionMember1( + UploadPostTransformSuccessEventIntersectionMember1 uploadPostTransformSuccessEventIntersectionMember1 + ) + : base(uploadPostTransformSuccessEventIntersectionMember1) { } +#pragma warning restore CS8618 + + public UploadPostTransformSuccessEventIntersectionMember1( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("upload.post-transform.success"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UploadPostTransformSuccessEventIntersectionMember1( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UploadPostTransformSuccessEventIntersectionMember1 FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UploadPostTransformSuccessEventIntersectionMember1FromRaw + : IFromRawJson +{ + /// + public UploadPostTransformSuccessEventIntersectionMember1 FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UploadPostTransformSuccessEventIntersectionMember1.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + UploadPostTransformSuccessEventIntersectionMember1Data, + UploadPostTransformSuccessEventIntersectionMember1DataFromRaw + >) +)] +public sealed record class UploadPostTransformSuccessEventIntersectionMember1Data : JsonModel +{ + /// + /// Unique identifier of the originally uploaded file. + /// + public required string FileID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("fileId"); + } + init { this._rawData.Set("fileId", value); } + } + + /// + /// Name of the file. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + /// URL of the generated post-transformation. + /// + public required string Url + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("url"); + } + init { this._rawData.Set("url", value); } + } + + /// + public override void Validate() + { + _ = this.FileID; + _ = this.Name; + _ = this.Url; + } + + public UploadPostTransformSuccessEventIntersectionMember1Data() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UploadPostTransformSuccessEventIntersectionMember1Data( + UploadPostTransformSuccessEventIntersectionMember1Data uploadPostTransformSuccessEventIntersectionMember1Data + ) + : base(uploadPostTransformSuccessEventIntersectionMember1Data) { } +#pragma warning restore CS8618 + + public UploadPostTransformSuccessEventIntersectionMember1Data( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UploadPostTransformSuccessEventIntersectionMember1Data( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UploadPostTransformSuccessEventIntersectionMember1Data FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UploadPostTransformSuccessEventIntersectionMember1DataFromRaw + : IFromRawJson +{ + /// + public UploadPostTransformSuccessEventIntersectionMember1Data FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UploadPostTransformSuccessEventIntersectionMember1Data.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + UploadPostTransformSuccessEventIntersectionMember1Request, + UploadPostTransformSuccessEventIntersectionMember1RequestFromRaw + >) +)] +public sealed record class UploadPostTransformSuccessEventIntersectionMember1Request : JsonModel +{ + public required UploadPostTransformSuccessEventIntersectionMember1RequestTransformation Transformation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "transformation" + ); + } + init { this._rawData.Set("transformation", value); } + } + + /// + /// Unique identifier for the originating request. + /// + public required string XRequestID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("x_request_id"); + } + init { this._rawData.Set("x_request_id", value); } + } + + /// + public override void Validate() + { + this.Transformation.Validate(); + _ = this.XRequestID; + } + + public UploadPostTransformSuccessEventIntersectionMember1Request() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UploadPostTransformSuccessEventIntersectionMember1Request( + UploadPostTransformSuccessEventIntersectionMember1Request uploadPostTransformSuccessEventIntersectionMember1Request + ) + : base(uploadPostTransformSuccessEventIntersectionMember1Request) { } +#pragma warning restore CS8618 + + public UploadPostTransformSuccessEventIntersectionMember1Request( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UploadPostTransformSuccessEventIntersectionMember1Request( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UploadPostTransformSuccessEventIntersectionMember1Request FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UploadPostTransformSuccessEventIntersectionMember1RequestFromRaw + : IFromRawJson +{ + /// + public UploadPostTransformSuccessEventIntersectionMember1Request FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UploadPostTransformSuccessEventIntersectionMember1Request.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + UploadPostTransformSuccessEventIntersectionMember1RequestTransformation, + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationFromRaw + >) +)] +public sealed record class UploadPostTransformSuccessEventIntersectionMember1RequestTransformation + : JsonModel +{ + /// + /// Type of the requested post-transformation. + /// + public required ApiEnum< + string, + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType + > Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum< + string, + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType + > + >("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// Only applicable if transformation type is 'abs'. Streaming protocol used. + /// + public ApiEnum< + string, + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol + >? Protocol + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass< + ApiEnum< + string, + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol + > + >("protocol"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("protocol", value); + } + } + + /// + /// Value for the requested transformation type. + /// + public string? Value + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("value"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("value", value); + } + } + + /// + public override void Validate() + { + this.Type.Validate(); + this.Protocol?.Validate(); + _ = this.Value; + } + + public UploadPostTransformSuccessEventIntersectionMember1RequestTransformation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UploadPostTransformSuccessEventIntersectionMember1RequestTransformation( + UploadPostTransformSuccessEventIntersectionMember1RequestTransformation uploadPostTransformSuccessEventIntersectionMember1RequestTransformation + ) + : base(uploadPostTransformSuccessEventIntersectionMember1RequestTransformation) { } +#pragma warning restore CS8618 + + public UploadPostTransformSuccessEventIntersectionMember1RequestTransformation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UploadPostTransformSuccessEventIntersectionMember1RequestTransformation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UploadPostTransformSuccessEventIntersectionMember1RequestTransformation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public UploadPostTransformSuccessEventIntersectionMember1RequestTransformation( + ApiEnum< + string, + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType + > type + ) + : this() + { + this.Type = type; + } +} + +class UploadPostTransformSuccessEventIntersectionMember1RequestTransformationFromRaw + : IFromRawJson +{ + /// + public UploadPostTransformSuccessEventIntersectionMember1RequestTransformation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + UploadPostTransformSuccessEventIntersectionMember1RequestTransformation.FromRawUnchecked( + rawData + ); +} + +/// +/// Type of the requested post-transformation. +/// +[JsonConverter( + typeof(UploadPostTransformSuccessEventIntersectionMember1RequestTransformationTypeConverter) +)] +public enum UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType +{ + Transformation, + Abs, + GifToVideo, + Thumbnail, +} + +sealed class UploadPostTransformSuccessEventIntersectionMember1RequestTransformationTypeConverter + : JsonConverter +{ + public override UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "transformation" => + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + "abs" => + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Abs, + "gif-to-video" => + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.GifToVideo, + "thumbnail" => + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Thumbnail, + _ => (UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation => + "transformation", + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Abs => + "abs", + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.GifToVideo => + "gif-to-video", + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Thumbnail => + "thumbnail", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Only applicable if transformation type is 'abs'. Streaming protocol used. +/// +[JsonConverter( + typeof(UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocolConverter) +)] +public enum UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol +{ + Hls, + Dash, +} + +sealed class UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocolConverter + : JsonConverter +{ + public override UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "hls" => + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + "dash" => + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Dash, + _ => (UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol)( + -1 + ), + }; + } + + public override void Write( + Utf8JsonWriter writer, + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls => + "hls", + UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Dash => + "dash", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} diff --git a/src/ImageKit/Models/Webhooks/UploadPreTransformErrorEvent.cs b/src/ImageKit/Models/Webhooks/UploadPreTransformErrorEvent.cs new file mode 100644 index 00000000..f6a98a39 --- /dev/null +++ b/src/ImageKit/Models/Webhooks/UploadPreTransformErrorEvent.cs @@ -0,0 +1,608 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; +using ImageKit.Exceptions; + +namespace ImageKit.Models.Webhooks; + +/// +/// Triggered when a pre-transformation fails. The file upload may have been accepted, +/// but the requested transformation could not be applied. +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class UploadPreTransformErrorEvent : JsonModel +{ + /// + /// Unique identifier for the event. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The type of webhook event. + /// + public required string Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// Timestamp of when the event occurred in ISO8601 format. + /// + public required DateTimeOffset CreatedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("created_at"); + } + init { this._rawData.Set("created_at", value); } + } + + public required UploadPreTransformErrorEventIntersectionMember1Data Data + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "data" + ); + } + init { this._rawData.Set("data", value); } + } + + public required UploadPreTransformErrorEventIntersectionMember1Request Request + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "request" + ); + } + init { this._rawData.Set("request", value); } + } + + public static implicit operator BaseWebhookEvent( + UploadPreTransformErrorEvent uploadPreTransformErrorEvent + ) => new() { ID = uploadPreTransformErrorEvent.ID, Type = uploadPreTransformErrorEvent.Type }; + + /// + public override void Validate() + { + _ = this.ID; + _ = this.Type; + _ = this.CreatedAt; + this.Data.Validate(); + this.Request.Validate(); + } + + public UploadPreTransformErrorEvent() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UploadPreTransformErrorEvent(UploadPreTransformErrorEvent uploadPreTransformErrorEvent) + : base(uploadPreTransformErrorEvent) { } +#pragma warning restore CS8618 + + public UploadPreTransformErrorEvent(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UploadPreTransformErrorEvent(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UploadPreTransformErrorEvent FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UploadPreTransformErrorEventFromRaw : IFromRawJson +{ + /// + public UploadPreTransformErrorEvent FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UploadPreTransformErrorEvent.FromRawUnchecked(rawData); +} + +/// +/// Triggered when a pre-transformation fails. The file upload may have been accepted, +/// but the requested transformation could not be applied. +/// +[JsonConverter( + typeof(JsonModelConverter< + UploadPreTransformErrorEventIntersectionMember1, + UploadPreTransformErrorEventIntersectionMember1FromRaw + >) +)] +public sealed record class UploadPreTransformErrorEventIntersectionMember1 : JsonModel +{ + /// + /// Timestamp of when the event occurred in ISO8601 format. + /// + public required DateTimeOffset CreatedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("created_at"); + } + init { this._rawData.Set("created_at", value); } + } + + public required UploadPreTransformErrorEventIntersectionMember1Data Data + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "data" + ); + } + init { this._rawData.Set("data", value); } + } + + public required UploadPreTransformErrorEventIntersectionMember1Request Request + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "request" + ); + } + init { this._rawData.Set("request", value); } + } + + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + public override void Validate() + { + _ = this.CreatedAt; + this.Data.Validate(); + this.Request.Validate(); + if ( + !JsonElement.DeepEquals( + this.Type, + JsonSerializer.SerializeToElement("upload.pre-transform.error") + ) + ) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + } + + public UploadPreTransformErrorEventIntersectionMember1() + { + this.Type = JsonSerializer.SerializeToElement("upload.pre-transform.error"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UploadPreTransformErrorEventIntersectionMember1( + UploadPreTransformErrorEventIntersectionMember1 uploadPreTransformErrorEventIntersectionMember1 + ) + : base(uploadPreTransformErrorEventIntersectionMember1) { } +#pragma warning restore CS8618 + + public UploadPreTransformErrorEventIntersectionMember1( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("upload.pre-transform.error"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UploadPreTransformErrorEventIntersectionMember1(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UploadPreTransformErrorEventIntersectionMember1 FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UploadPreTransformErrorEventIntersectionMember1FromRaw + : IFromRawJson +{ + /// + public UploadPreTransformErrorEventIntersectionMember1 FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UploadPreTransformErrorEventIntersectionMember1.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + UploadPreTransformErrorEventIntersectionMember1Data, + UploadPreTransformErrorEventIntersectionMember1DataFromRaw + >) +)] +public sealed record class UploadPreTransformErrorEventIntersectionMember1Data : JsonModel +{ + /// + /// Name of the file. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + /// Path of the file. + /// + public required string Path + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("path"); + } + init { this._rawData.Set("path", value); } + } + + public required UploadPreTransformErrorEventIntersectionMember1DataTransformation Transformation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "transformation" + ); + } + init { this._rawData.Set("transformation", value); } + } + + /// + public override void Validate() + { + _ = this.Name; + _ = this.Path; + this.Transformation.Validate(); + } + + public UploadPreTransformErrorEventIntersectionMember1Data() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UploadPreTransformErrorEventIntersectionMember1Data( + UploadPreTransformErrorEventIntersectionMember1Data uploadPreTransformErrorEventIntersectionMember1Data + ) + : base(uploadPreTransformErrorEventIntersectionMember1Data) { } +#pragma warning restore CS8618 + + public UploadPreTransformErrorEventIntersectionMember1Data( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UploadPreTransformErrorEventIntersectionMember1Data( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UploadPreTransformErrorEventIntersectionMember1Data FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UploadPreTransformErrorEventIntersectionMember1DataFromRaw + : IFromRawJson +{ + /// + public UploadPreTransformErrorEventIntersectionMember1Data FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UploadPreTransformErrorEventIntersectionMember1Data.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + UploadPreTransformErrorEventIntersectionMember1DataTransformation, + UploadPreTransformErrorEventIntersectionMember1DataTransformationFromRaw + >) +)] +public sealed record class UploadPreTransformErrorEventIntersectionMember1DataTransformation + : JsonModel +{ + public required UploadPreTransformErrorEventIntersectionMember1DataTransformationError Error + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "error" + ); + } + init { this._rawData.Set("error", value); } + } + + /// + public override void Validate() + { + this.Error.Validate(); + } + + public UploadPreTransformErrorEventIntersectionMember1DataTransformation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UploadPreTransformErrorEventIntersectionMember1DataTransformation( + UploadPreTransformErrorEventIntersectionMember1DataTransformation uploadPreTransformErrorEventIntersectionMember1DataTransformation + ) + : base(uploadPreTransformErrorEventIntersectionMember1DataTransformation) { } +#pragma warning restore CS8618 + + public UploadPreTransformErrorEventIntersectionMember1DataTransformation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UploadPreTransformErrorEventIntersectionMember1DataTransformation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UploadPreTransformErrorEventIntersectionMember1DataTransformation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public UploadPreTransformErrorEventIntersectionMember1DataTransformation( + UploadPreTransformErrorEventIntersectionMember1DataTransformationError error + ) + : this() + { + this.Error = error; + } +} + +class UploadPreTransformErrorEventIntersectionMember1DataTransformationFromRaw + : IFromRawJson +{ + /// + public UploadPreTransformErrorEventIntersectionMember1DataTransformation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + UploadPreTransformErrorEventIntersectionMember1DataTransformation.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + UploadPreTransformErrorEventIntersectionMember1DataTransformationError, + UploadPreTransformErrorEventIntersectionMember1DataTransformationErrorFromRaw + >) +)] +public sealed record class UploadPreTransformErrorEventIntersectionMember1DataTransformationError + : JsonModel +{ + /// + /// Reason for the pre-transformation failure. + /// + public required string Reason + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("reason"); + } + init { this._rawData.Set("reason", value); } + } + + /// + public override void Validate() + { + _ = this.Reason; + } + + public UploadPreTransformErrorEventIntersectionMember1DataTransformationError() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + UploadPreTransformErrorEventIntersectionMember1DataTransformationError uploadPreTransformErrorEventIntersectionMember1DataTransformationError + ) + : base(uploadPreTransformErrorEventIntersectionMember1DataTransformationError) { } +#pragma warning restore CS8618 + + public UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UploadPreTransformErrorEventIntersectionMember1DataTransformationError FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public UploadPreTransformErrorEventIntersectionMember1DataTransformationError(string reason) + : this() + { + this.Reason = reason; + } +} + +class UploadPreTransformErrorEventIntersectionMember1DataTransformationErrorFromRaw + : IFromRawJson +{ + /// + public UploadPreTransformErrorEventIntersectionMember1DataTransformationError FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + UploadPreTransformErrorEventIntersectionMember1DataTransformationError.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(JsonModelConverter< + UploadPreTransformErrorEventIntersectionMember1Request, + UploadPreTransformErrorEventIntersectionMember1RequestFromRaw + >) +)] +public sealed record class UploadPreTransformErrorEventIntersectionMember1Request : JsonModel +{ + /// + /// The requested pre-transformation string. + /// + public required string Transformation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("transformation"); + } + init { this._rawData.Set("transformation", value); } + } + + /// + /// Unique identifier for the originating request. + /// + public required string XRequestID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("x_request_id"); + } + init { this._rawData.Set("x_request_id", value); } + } + + /// + public override void Validate() + { + _ = this.Transformation; + _ = this.XRequestID; + } + + public UploadPreTransformErrorEventIntersectionMember1Request() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UploadPreTransformErrorEventIntersectionMember1Request( + UploadPreTransformErrorEventIntersectionMember1Request uploadPreTransformErrorEventIntersectionMember1Request + ) + : base(uploadPreTransformErrorEventIntersectionMember1Request) { } +#pragma warning restore CS8618 + + public UploadPreTransformErrorEventIntersectionMember1Request( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UploadPreTransformErrorEventIntersectionMember1Request( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UploadPreTransformErrorEventIntersectionMember1Request FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UploadPreTransformErrorEventIntersectionMember1RequestFromRaw + : IFromRawJson +{ + /// + public UploadPreTransformErrorEventIntersectionMember1Request FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UploadPreTransformErrorEventIntersectionMember1Request.FromRawUnchecked(rawData); +} diff --git a/src/ImageKit/Models/Webhooks/UploadPreTransformSuccessEvent.cs b/src/ImageKit/Models/Webhooks/UploadPreTransformSuccessEvent.cs new file mode 100644 index 00000000..ef37cb20 --- /dev/null +++ b/src/ImageKit/Models/Webhooks/UploadPreTransformSuccessEvent.cs @@ -0,0 +1,3306 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; +using ImageKit.Exceptions; +using Files = ImageKit.Models.Files; +using System = System; + +namespace ImageKit.Models.Webhooks; + +/// +/// Triggered when a pre-transformation completes successfully. The file has been +/// processed with the requested transformation and is now available in the Media +/// Library. +/// +[JsonConverter( + typeof(JsonModelConverter< + UploadPreTransformSuccessEvent, + UploadPreTransformSuccessEventFromRaw + >) +)] +public sealed record class UploadPreTransformSuccessEvent : JsonModel +{ + /// + /// Unique identifier for the event. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The type of webhook event. + /// + public required string Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// Timestamp of when the event occurred in ISO8601 format. + /// + public required System::DateTimeOffset CreatedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("created_at"); + } + init { this._rawData.Set("created_at", value); } + } + + /// + /// Object containing details of a successful upload. + /// + public required UploadPreTransformSuccessEventIntersectionMember1Data Data + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "data" + ); + } + init { this._rawData.Set("data", value); } + } + + public required UploadPreTransformSuccessEventIntersectionMember1Request Request + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "request" + ); + } + init { this._rawData.Set("request", value); } + } + + public static implicit operator BaseWebhookEvent( + UploadPreTransformSuccessEvent uploadPreTransformSuccessEvent + ) => + new() + { + ID = uploadPreTransformSuccessEvent.ID, + Type = uploadPreTransformSuccessEvent.Type, + }; + + /// + public override void Validate() + { + _ = this.ID; + _ = this.Type; + _ = this.CreatedAt; + this.Data.Validate(); + this.Request.Validate(); + } + + public UploadPreTransformSuccessEvent() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UploadPreTransformSuccessEvent( + UploadPreTransformSuccessEvent uploadPreTransformSuccessEvent + ) + : base(uploadPreTransformSuccessEvent) { } +#pragma warning restore CS8618 + + public UploadPreTransformSuccessEvent(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UploadPreTransformSuccessEvent(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UploadPreTransformSuccessEvent FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UploadPreTransformSuccessEventFromRaw : IFromRawJson +{ + /// + public UploadPreTransformSuccessEvent FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UploadPreTransformSuccessEvent.FromRawUnchecked(rawData); +} + +/// +/// Triggered when a pre-transformation completes successfully. The file has been +/// processed with the requested transformation and is now available in the Media +/// Library. +/// +[JsonConverter( + typeof(JsonModelConverter< + UploadPreTransformSuccessEventIntersectionMember1, + UploadPreTransformSuccessEventIntersectionMember1FromRaw + >) +)] +public sealed record class UploadPreTransformSuccessEventIntersectionMember1 : JsonModel +{ + /// + /// Timestamp of when the event occurred in ISO8601 format. + /// + public required System::DateTimeOffset CreatedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("created_at"); + } + init { this._rawData.Set("created_at", value); } + } + + /// + /// Object containing details of a successful upload. + /// + public required UploadPreTransformSuccessEventIntersectionMember1Data Data + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "data" + ); + } + init { this._rawData.Set("data", value); } + } + + public required UploadPreTransformSuccessEventIntersectionMember1Request Request + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "request" + ); + } + init { this._rawData.Set("request", value); } + } + + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + public override void Validate() + { + _ = this.CreatedAt; + this.Data.Validate(); + this.Request.Validate(); + if ( + !JsonElement.DeepEquals( + this.Type, + JsonSerializer.SerializeToElement("upload.pre-transform.success") + ) + ) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + } + + public UploadPreTransformSuccessEventIntersectionMember1() + { + this.Type = JsonSerializer.SerializeToElement("upload.pre-transform.success"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UploadPreTransformSuccessEventIntersectionMember1( + UploadPreTransformSuccessEventIntersectionMember1 uploadPreTransformSuccessEventIntersectionMember1 + ) + : base(uploadPreTransformSuccessEventIntersectionMember1) { } +#pragma warning restore CS8618 + + public UploadPreTransformSuccessEventIntersectionMember1( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("upload.pre-transform.success"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UploadPreTransformSuccessEventIntersectionMember1(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UploadPreTransformSuccessEventIntersectionMember1 FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UploadPreTransformSuccessEventIntersectionMember1FromRaw + : IFromRawJson +{ + /// + public UploadPreTransformSuccessEventIntersectionMember1 FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UploadPreTransformSuccessEventIntersectionMember1.FromRawUnchecked(rawData); +} + +/// +/// Object containing details of a successful upload. +/// +[JsonConverter( + typeof(JsonModelConverter< + UploadPreTransformSuccessEventIntersectionMember1Data, + UploadPreTransformSuccessEventIntersectionMember1DataFromRaw + >) +)] +public sealed record class UploadPreTransformSuccessEventIntersectionMember1Data : JsonModel +{ + /// + /// An array of tags assigned to the uploaded file by auto tagging. + /// + public IReadOnlyList? AITags + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>("AITags"); + } + init + { + this._rawData.Set?>( + "AITags", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// The audio codec used in the video (only for video). + /// + public string? AudioCodec + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("audioCodec"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("audioCodec", value); + } + } + + /// + /// The bit rate of the video in kbps (only for video). + /// + public long? BitRate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("bitRate"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("bitRate", value); + } + } + + /// + /// Value of custom coordinates associated with the image in the format `x,y,width,height`. + /// If `customCoordinates` are not defined, then it is `null`. Send `customCoordinates` + /// in `responseFields` in API request to get the value of this field. + /// + public string? CustomCoordinates + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("customCoordinates"); + } + init { this._rawData.Set("customCoordinates", value); } + } + + /// + /// A key-value data associated with the asset. Use `responseField` in API request + /// to get `customMetadata` in the upload API response. Before setting any custom + /// metadata on an asset, you have to create the field using custom metadata fields + /// API. Send `customMetadata` in `responseFields` in API request to get the value + /// of this field. + /// + public IReadOnlyDictionary? CustomMetadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>( + "customMetadata" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "customMetadata", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + + /// + /// Optional text to describe the contents of the file. Can be set by the user + /// or the ai-auto-description extension. + /// + public string? Description + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("description"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("description", value); + } + } + + /// + /// The duration of the video in seconds (only for video). + /// + public long? Duration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("duration"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("duration", value); + } + } + + /// + /// Consolidated embedded metadata associated with the file. It includes exif, + /// iptc, and xmp data. Send `embeddedMetadata` in `responseFields` in API request + /// to get embeddedMetadata in the upload API response. + /// + public IReadOnlyDictionary? EmbeddedMetadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>( + "embeddedMetadata" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "embeddedMetadata", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + + /// + /// Extension names with their processing status at the time of completion of + /// the request. It could have one of the following status values: + /// + /// `success`: The extension has been successfully applied. `failed`: The + /// extension has failed and will not be retried. `pending`: The extension will + /// finish processing in some time. On completion, the final status (success + /// / failed) will be sent to the `webhookUrl` provided. + /// + /// If no extension was requested, then this parameter is not returned. + /// + public ExtensionStatus? ExtensionStatus + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("extensionStatus"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("extensionStatus", value); + } + } + + /// + /// Unique fileId. Store this fileld in your database, as this will be used to + /// perform update action on this file. + /// + public string? FileID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("fileId"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("fileId", value); + } + } + + /// + /// The relative path of the file in the media library e.g. `/marketing-assets/new-banner.jpg`. + /// + public string? FilePath + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("filePath"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("filePath", value); + } + } + + /// + /// Type of the uploaded file. Possible values are `image`, `non-image`. + /// + public string? FileType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("fileType"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("fileType", value); + } + } + + /// + /// Height of the image in pixels (Only for images) + /// + public double? Height + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("height"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("height", value); + } + } + + /// + /// Is the file marked as private. It can be either `true` or `false`. Send `isPrivateFile` + /// in `responseFields` in API request to get the value of this field. + /// + public bool? IsPrivateFile + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("isPrivateFile"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("isPrivateFile", value); + } + } + + /// + /// Is the file published or in draft state. It can be either `true` or `false`. + /// Send `isPublished` in `responseFields` in API request to get the value of + /// this field. + /// + public bool? IsPublished + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("isPublished"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("isPublished", value); + } + } + + /// + /// Legacy metadata. Send `metadata` in `responseFields` in API request to get + /// metadata in the upload API response. + /// + public Files::FileMetadata? Metadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("metadata"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("metadata", value); + } + } + + /// + /// Name of the asset. + /// + public string? Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("name"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("name", value); + } + } + + /// + /// This field is included in the response only if the Path policy feature is + /// available in the plan. It contains schema definitions for the custom metadata + /// fields selected for the specified file path. Field selection can only be + /// done when the Path policy feature is enabled. + /// + /// Keys are the names of the custom metadata fields; the value object + /// has details about the custom metadata schema. + /// + public IReadOnlyDictionary? SelectedFieldsSchema + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass< + FrozenDictionary + >("selectedFieldsSchema"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "selectedFieldsSchema", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + + /// + /// Size of the image file in Bytes. + /// + public double? Size + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("size"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("size", value); + } + } + + /// + /// The array of tags associated with the asset. If no tags are set, it will be + /// `null`. Send `tags` in `responseFields` in API request to get the value of + /// this field. + /// + public IReadOnlyList? Tags + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>("tags"); + } + init + { + this._rawData.Set?>( + "tags", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// In the case of an image, a small thumbnail URL. + /// + public string? ThumbnailUrl + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("thumbnailUrl"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("thumbnailUrl", value); + } + } + + /// + /// A publicly accessible URL of the file. + /// + public string? Url + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("url"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("url", value); + } + } + + /// + /// An object containing the file or file version's `id` (versionId) and `name`. + /// + public VersionInfo? VersionInfo + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("versionInfo"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("versionInfo", value); + } + } + + /// + /// The video codec used in the video (only for video). + /// + public string? VideoCodec + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("videoCodec"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("videoCodec", value); + } + } + + /// + /// Width of the image in pixels (Only for Images) + /// + public double? Width + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("width"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("width", value); + } + } + + /// + public override void Validate() + { + foreach (var item in this.AITags ?? []) + { + item.Validate(); + } + _ = this.AudioCodec; + _ = this.BitRate; + _ = this.CustomCoordinates; + _ = this.CustomMetadata; + _ = this.Description; + _ = this.Duration; + _ = this.EmbeddedMetadata; + this.ExtensionStatus?.Validate(); + _ = this.FileID; + _ = this.FilePath; + _ = this.FileType; + _ = this.Height; + _ = this.IsPrivateFile; + _ = this.IsPublished; + this.Metadata?.Validate(); + _ = this.Name; + if (this.SelectedFieldsSchema != null) + { + foreach (var item in this.SelectedFieldsSchema.Values) + { + item.Validate(); + } + } + _ = this.Size; + _ = this.Tags; + _ = this.ThumbnailUrl; + _ = this.Url; + this.VersionInfo?.Validate(); + _ = this.VideoCodec; + _ = this.Width; + } + + public UploadPreTransformSuccessEventIntersectionMember1Data() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UploadPreTransformSuccessEventIntersectionMember1Data( + UploadPreTransformSuccessEventIntersectionMember1Data uploadPreTransformSuccessEventIntersectionMember1Data + ) + : base(uploadPreTransformSuccessEventIntersectionMember1Data) { } +#pragma warning restore CS8618 + + public UploadPreTransformSuccessEventIntersectionMember1Data( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UploadPreTransformSuccessEventIntersectionMember1Data( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UploadPreTransformSuccessEventIntersectionMember1Data FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UploadPreTransformSuccessEventIntersectionMember1DataFromRaw + : IFromRawJson +{ + /// + public UploadPreTransformSuccessEventIntersectionMember1Data FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UploadPreTransformSuccessEventIntersectionMember1Data.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class AITag : JsonModel +{ + /// + /// Confidence score of the tag. + /// + public double? Confidence + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("confidence"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("confidence", value); + } + } + + /// + /// Name of the tag. + /// + public string? Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("name"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("name", value); + } + } + + /// + /// Array of `AITags` associated with the image. If no `AITags` are set, it will + /// be null. These tags can be added using the `google-auto-tagging` or `aws-auto-tagging` extensions. + /// + public string? Source + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("source"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("source", value); + } + } + + /// + public override void Validate() + { + _ = this.Confidence; + _ = this.Name; + _ = this.Source; + } + + public AITag() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public AITag(AITag aiTag) + : base(aiTag) { } +#pragma warning restore CS8618 + + public AITag(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + AITag(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static AITag FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class AITagFromRaw : IFromRawJson +{ + /// + public AITag FromRawUnchecked(IReadOnlyDictionary rawData) => + AITag.FromRawUnchecked(rawData); +} + +/// +/// Extension names with their processing status at the time of completion of the +/// request. It could have one of the following status values: +/// +/// `success`: The extension has been successfully applied. `failed`: The extension +/// has failed and will not be retried. `pending`: The extension will finish processing +/// in some time. On completion, the final status (success / failed) will be sent +/// to the `webhookUrl` provided. +/// +/// If no extension was requested, then this parameter is not returned. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class ExtensionStatus : JsonModel +{ + public ApiEnum? AIAutoDescription + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>( + "ai-auto-description" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("ai-auto-description", value); + } + } + + public ApiEnum? AITasks + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("ai-tasks"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("ai-tasks", value); + } + } + + public ApiEnum? AwsAutoTagging + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>( + "aws-auto-tagging" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("aws-auto-tagging", value); + } + } + + public ApiEnum? GoogleAutoTagging + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>( + "google-auto-tagging" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("google-auto-tagging", value); + } + } + + public ApiEnum? RemoveBg + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("remove-bg"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("remove-bg", value); + } + } + + /// + public override void Validate() + { + this.AIAutoDescription?.Validate(); + this.AITasks?.Validate(); + this.AwsAutoTagging?.Validate(); + this.GoogleAutoTagging?.Validate(); + this.RemoveBg?.Validate(); + } + + public ExtensionStatus() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ExtensionStatus(ExtensionStatus extensionStatus) + : base(extensionStatus) { } +#pragma warning restore CS8618 + + public ExtensionStatus(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ExtensionStatus(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ExtensionStatus FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ExtensionStatusFromRaw : IFromRawJson +{ + /// + public ExtensionStatus FromRawUnchecked(IReadOnlyDictionary rawData) => + ExtensionStatus.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(AIAutoDescriptionConverter))] +public enum AIAutoDescription +{ + Success, + Pending, + Failed, +} + +sealed class AIAutoDescriptionConverter : JsonConverter +{ + public override AIAutoDescription Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "success" => AIAutoDescription.Success, + "pending" => AIAutoDescription.Pending, + "failed" => AIAutoDescription.Failed, + _ => (AIAutoDescription)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + AIAutoDescription value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + AIAutoDescription.Success => "success", + AIAutoDescription.Pending => "pending", + AIAutoDescription.Failed => "failed", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter(typeof(AITasksConverter))] +public enum AITasks +{ + Success, + Pending, + Failed, +} + +sealed class AITasksConverter : JsonConverter +{ + public override AITasks Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "success" => AITasks.Success, + "pending" => AITasks.Pending, + "failed" => AITasks.Failed, + _ => (AITasks)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, AITasks value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + AITasks.Success => "success", + AITasks.Pending => "pending", + AITasks.Failed => "failed", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter(typeof(AwsAutoTaggingConverter))] +public enum AwsAutoTagging +{ + Success, + Pending, + Failed, +} + +sealed class AwsAutoTaggingConverter : JsonConverter +{ + public override AwsAutoTagging Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "success" => AwsAutoTagging.Success, + "pending" => AwsAutoTagging.Pending, + "failed" => AwsAutoTagging.Failed, + _ => (AwsAutoTagging)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + AwsAutoTagging value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + AwsAutoTagging.Success => "success", + AwsAutoTagging.Pending => "pending", + AwsAutoTagging.Failed => "failed", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter(typeof(GoogleAutoTaggingConverter))] +public enum GoogleAutoTagging +{ + Success, + Pending, + Failed, +} + +sealed class GoogleAutoTaggingConverter : JsonConverter +{ + public override GoogleAutoTagging Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "success" => GoogleAutoTagging.Success, + "pending" => GoogleAutoTagging.Pending, + "failed" => GoogleAutoTagging.Failed, + _ => (GoogleAutoTagging)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + GoogleAutoTagging value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + GoogleAutoTagging.Success => "success", + GoogleAutoTagging.Pending => "pending", + GoogleAutoTagging.Failed => "failed", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter(typeof(RemoveBgConverter))] +public enum RemoveBg +{ + Success, + Pending, + Failed, +} + +sealed class RemoveBgConverter : JsonConverter +{ + public override RemoveBg Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "success" => RemoveBg.Success, + "pending" => RemoveBg.Pending, + "failed" => RemoveBg.Failed, + _ => (RemoveBg)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, RemoveBg value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + RemoveBg.Success => "success", + RemoveBg.Pending => "pending", + RemoveBg.Failed => "failed", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class SelectedFieldsSchemaItem : JsonModel +{ + /// + /// Type of the custom metadata field. + /// + public required ApiEnum Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass>( + "type" + ); + } + init { this._rawData.Set("type", value); } + } + + /// + /// The default value for this custom metadata field. The value should match + /// the `type` of custom metadata field. + /// + public DefaultValue? DefaultValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("defaultValue"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("defaultValue", value); + } + } + + /// + /// Specifies if the custom metadata field is required or not. + /// + public bool? IsValueRequired + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("isValueRequired"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("isValueRequired", value); + } + } + + /// + /// Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. + /// + public double? MaxLength + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("maxLength"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("maxLength", value); + } + } + + /// + /// Maximum value of the field. Only set if field type is `Date` or `Number`. + /// For `Date` type field, the value will be in ISO8601 string format. For `Number` + /// type field, it will be a numeric value. + /// + public MaxValue? MaxValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("maxValue"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("maxValue", value); + } + } + + /// + /// Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. + /// + public double? MinLength + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("minLength"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("minLength", value); + } + } + + /// + /// Minimum value of the field. Only set if field type is `Date` or `Number`. + /// For `Date` type field, the value will be in ISO8601 string format. For `Number` + /// type field, it will be a numeric value. + /// + public MinValue? MinValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("minValue"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("minValue", value); + } + } + + /// + /// Indicates whether the custom metadata field is read only. A read only field + /// cannot be modified after being set. This field is configurable only via the + /// **Path policy** feature. + /// + public bool? ReadOnly + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("readOnly"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("readOnly", value); + } + } + + /// + /// An array of allowed values when field type is `SingleSelect` or `MultiSelect`. + /// + public IReadOnlyList? SelectOptions + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>("selectOptions"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "selectOptions", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Specifies if the selectOptions array is truncated. It is truncated when number + /// of options are > 100. + /// + public bool? SelectOptionsTruncated + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("selectOptionsTruncated"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("selectOptionsTruncated", value); + } + } + + /// + public override void Validate() + { + this.Type.Validate(); + this.DefaultValue?.Validate(); + _ = this.IsValueRequired; + _ = this.MaxLength; + this.MaxValue?.Validate(); + _ = this.MinLength; + this.MinValue?.Validate(); + _ = this.ReadOnly; + foreach (var item in this.SelectOptions ?? []) + { + item.Validate(); + } + _ = this.SelectOptionsTruncated; + } + + public SelectedFieldsSchemaItem() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SelectedFieldsSchemaItem(SelectedFieldsSchemaItem selectedFieldsSchemaItem) + : base(selectedFieldsSchemaItem) { } +#pragma warning restore CS8618 + + public SelectedFieldsSchemaItem(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + SelectedFieldsSchemaItem(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static SelectedFieldsSchemaItem FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public SelectedFieldsSchemaItem(ApiEnum type) + : this() + { + this.Type = type; + } +} + +class SelectedFieldsSchemaItemFromRaw : IFromRawJson +{ + /// + public SelectedFieldsSchemaItem FromRawUnchecked( + IReadOnlyDictionary rawData + ) => SelectedFieldsSchemaItem.FromRawUnchecked(rawData); +} + +/// +/// Type of the custom metadata field. +/// +[JsonConverter(typeof(SelectedFieldsSchemaItemTypeConverter))] +public enum SelectedFieldsSchemaItemType +{ + Text, + Textarea, + Number, + Date, + Boolean, + SingleSelect, + MultiSelect, +} + +sealed class SelectedFieldsSchemaItemTypeConverter : JsonConverter +{ + public override SelectedFieldsSchemaItemType Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "Text" => SelectedFieldsSchemaItemType.Text, + "Textarea" => SelectedFieldsSchemaItemType.Textarea, + "Number" => SelectedFieldsSchemaItemType.Number, + "Date" => SelectedFieldsSchemaItemType.Date, + "Boolean" => SelectedFieldsSchemaItemType.Boolean, + "SingleSelect" => SelectedFieldsSchemaItemType.SingleSelect, + "MultiSelect" => SelectedFieldsSchemaItemType.MultiSelect, + _ => (SelectedFieldsSchemaItemType)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + SelectedFieldsSchemaItemType value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + SelectedFieldsSchemaItemType.Text => "Text", + SelectedFieldsSchemaItemType.Textarea => "Textarea", + SelectedFieldsSchemaItemType.Number => "Number", + SelectedFieldsSchemaItemType.Date => "Date", + SelectedFieldsSchemaItemType.Boolean => "Boolean", + SelectedFieldsSchemaItemType.SingleSelect => "SingleSelect", + SelectedFieldsSchemaItemType.MultiSelect => "MultiSelect", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// The default value for this custom metadata field. The value should match the `type` +/// of custom metadata field. +/// +[JsonConverter(typeof(DefaultValueConverter))] +public record class DefaultValue : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public DefaultValue(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public DefaultValue(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public DefaultValue(bool value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public DefaultValue( + IReadOnlyList value, + JsonElement? element = null + ) + { + this.Value = ImmutableArray.ToImmutableArray(value); + this._element = element; + } + + public DefaultValue(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickBool(out var value)) { + /// // `value` is of type `bool` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = this.Value as bool?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickMixed(out var value)) { + /// // `value` is of type `IReadOnlyList` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMixed( + [NotNullWhen(true)] out IReadOnlyList? value + ) + { + value = this.Value as IReadOnlyList; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action @string, + System::Action @double, + System::Action @bool, + System::Action> mixed + ) + { + switch (this.Value) + { + case string value: + @string(value); + break; + case double value: + @double(value); + break; + case bool value: + @bool(value); + break; + case IReadOnlyList value: + mixed(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of DefaultValue" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func @string, + System::Func @double, + System::Func @bool, + System::Func, T> mixed + ) + { + return this.Value switch + { + string value => @string(value), + double value => @double(value), + bool value => @bool(value), + IReadOnlyList value => mixed(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of DefaultValue" + ), + }; + } + + public static implicit operator DefaultValue(string value) => new(value); + + public static implicit operator DefaultValue(double value) => new(value); + + public static implicit operator DefaultValue(bool value) => new(value); + + public static implicit operator DefaultValue(List value) => + new((IReadOnlyList)value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of DefaultValue" + ); + } + } + + public virtual bool Equals(DefaultValue? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class DefaultValueConverter : JsonConverter +{ + public override DefaultValue? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize>( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + DefaultValue value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(UnnamedSchemaWithArrayParent13Converter))] +public record class UnnamedSchemaWithArrayParent13 : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public UnnamedSchemaWithArrayParent13(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent13(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent13(bool value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnnamedSchemaWithArrayParent13(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickBool(out var value)) { + /// // `value` is of type `bool` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = this.Value as bool?; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action @string, + System::Action @double, + System::Action @bool + ) + { + switch (this.Value) + { + case string value: + @string(value); + break; + case double value: + @double(value); + break; + case bool value: + @bool(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent13" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func @string, + System::Func @double, + System::Func @bool + ) + { + return this.Value switch + { + string value => @string(value), + double value => @double(value), + bool value => @bool(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent13" + ), + }; + } + + public static implicit operator UnnamedSchemaWithArrayParent13(string value) => new(value); + + public static implicit operator UnnamedSchemaWithArrayParent13(double value) => new(value); + + public static implicit operator UnnamedSchemaWithArrayParent13(bool value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of UnnamedSchemaWithArrayParent13" + ); + } + } + + public virtual bool Equals(UnnamedSchemaWithArrayParent13? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class UnnamedSchemaWithArrayParent13Converter : JsonConverter +{ + public override UnnamedSchemaWithArrayParent13? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + UnnamedSchemaWithArrayParent13 value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +/// +/// Maximum value of the field. Only set if field type is `Date` or `Number`. For +/// `Date` type field, the value will be in ISO8601 string format. For `Number` type +/// field, it will be a numeric value. +/// +[JsonConverter(typeof(MaxValueConverter))] +public record class MaxValue : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public MaxValue(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public MaxValue(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public MaxValue(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (string value) => {...}, + /// (double value) => {...} + /// ); + /// + /// + /// + public void Switch(System::Action @string, System::Action @double) + { + switch (this.Value) + { + case string value: + @string(value); + break; + case double value: + @double(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of MaxValue" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (string value) => {...}, + /// (double value) => {...} + /// ); + /// + /// + /// + public T Match(System::Func @string, System::Func @double) + { + return this.Value switch + { + string value => @string(value), + double value => @double(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of MaxValue" + ), + }; + } + + public static implicit operator MaxValue(string value) => new(value); + + public static implicit operator MaxValue(double value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException("Data did not match any variant of MaxValue"); + } + } + + public virtual bool Equals(MaxValue? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class MaxValueConverter : JsonConverter +{ + public override MaxValue? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write(Utf8JsonWriter writer, MaxValue value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +/// +/// Minimum value of the field. Only set if field type is `Date` or `Number`. For +/// `Date` type field, the value will be in ISO8601 string format. For `Number` type +/// field, it will be a numeric value. +/// +[JsonConverter(typeof(MinValueConverter))] +public record class MinValue : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public MinValue(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public MinValue(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public MinValue(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (string value) => {...}, + /// (double value) => {...} + /// ); + /// + /// + /// + public void Switch(System::Action @string, System::Action @double) + { + switch (this.Value) + { + case string value: + @string(value); + break; + case double value: + @double(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of MinValue" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (string value) => {...}, + /// (double value) => {...} + /// ); + /// + /// + /// + public T Match(System::Func @string, System::Func @double) + { + return this.Value switch + { + string value => @string(value), + double value => @double(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of MinValue" + ), + }; + } + + public static implicit operator MinValue(string value) => new(value); + + public static implicit operator MinValue(double value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException("Data did not match any variant of MinValue"); + } + } + + public virtual bool Equals(MinValue? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class MinValueConverter : JsonConverter +{ + public override MinValue? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write(Utf8JsonWriter writer, MinValue value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(SelectOptionConverter))] +public record class SelectOption : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public SelectOption(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public SelectOption(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public SelectOption(bool value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public SelectOption(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickBool(out var value)) { + /// // `value` is of type `bool` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBool([NotNullWhen(true)] out bool? value) + { + value = this.Value as bool?; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action @string, + System::Action @double, + System::Action @bool + ) + { + switch (this.Value) + { + case string value: + @string(value); + break; + case double value: + @double(value); + break; + case bool value: + @bool(value); + break; + default: + throw new ImageKitInvalidDataException( + "Data did not match any variant of SelectOption" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func @string, + System::Func @double, + System::Func @bool + ) + { + return this.Value switch + { + string value => @string(value), + double value => @double(value), + bool value => @bool(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of SelectOption" + ), + }; + } + + public static implicit operator SelectOption(string value) => new(value); + + public static implicit operator SelectOption(double value) => new(value); + + public static implicit operator SelectOption(bool value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException( + "Data did not match any variant of SelectOption" + ); + } + } + + public virtual bool Equals(SelectOption? other) + { + return other != null && JsonElement.DeepEquals(this.Json, other.Json); + } + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class SelectOptionConverter : JsonConverter +{ + public override SelectOption? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write( + Utf8JsonWriter writer, + SelectOption value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +/// +/// An object containing the file or file version's `id` (versionId) and `name`. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class VersionInfo : JsonModel +{ + /// + /// Unique identifier of the file version. + /// + public string? ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("id"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("id", value); + } + } + + /// + /// Name of the file version. + /// + public string? Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("name"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("name", value); + } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.Name; + } + + public VersionInfo() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public VersionInfo(VersionInfo versionInfo) + : base(versionInfo) { } +#pragma warning restore CS8618 + + public VersionInfo(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + VersionInfo(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static VersionInfo FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class VersionInfoFromRaw : IFromRawJson +{ + /// + public VersionInfo FromRawUnchecked(IReadOnlyDictionary rawData) => + VersionInfo.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + UploadPreTransformSuccessEventIntersectionMember1Request, + UploadPreTransformSuccessEventIntersectionMember1RequestFromRaw + >) +)] +public sealed record class UploadPreTransformSuccessEventIntersectionMember1Request : JsonModel +{ + /// + /// The requested pre-transformation string. + /// + public required string Transformation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("transformation"); + } + init { this._rawData.Set("transformation", value); } + } + + /// + /// Unique identifier for the originating request. + /// + public required string XRequestID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("x_request_id"); + } + init { this._rawData.Set("x_request_id", value); } + } + + /// + public override void Validate() + { + _ = this.Transformation; + _ = this.XRequestID; + } + + public UploadPreTransformSuccessEventIntersectionMember1Request() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UploadPreTransformSuccessEventIntersectionMember1Request( + UploadPreTransformSuccessEventIntersectionMember1Request uploadPreTransformSuccessEventIntersectionMember1Request + ) + : base(uploadPreTransformSuccessEventIntersectionMember1Request) { } +#pragma warning restore CS8618 + + public UploadPreTransformSuccessEventIntersectionMember1Request( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UploadPreTransformSuccessEventIntersectionMember1Request( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UploadPreTransformSuccessEventIntersectionMember1Request FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UploadPreTransformSuccessEventIntersectionMember1RequestFromRaw + : IFromRawJson +{ + /// + public UploadPreTransformSuccessEventIntersectionMember1Request FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UploadPreTransformSuccessEventIntersectionMember1Request.FromRawUnchecked(rawData); +} diff --git a/src/ImageKit/Models/Webhooks/VideoTransformationAcceptedEvent.cs b/src/ImageKit/Models/Webhooks/VideoTransformationAcceptedEvent.cs new file mode 100644 index 00000000..d7df40bb --- /dev/null +++ b/src/ImageKit/Models/Webhooks/VideoTransformationAcceptedEvent.cs @@ -0,0 +1,1130 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; +using ImageKit.Exceptions; +using System = System; + +namespace ImageKit.Models.Webhooks; + +/// +/// Triggered when a new video transformation request is accepted for processing. +/// This event confirms that ImageKit has received and queued your transformation +/// request. Use this for debugging and tracking transformation lifecycle. +/// +[JsonConverter( + typeof(JsonModelConverter< + VideoTransformationAcceptedEvent, + VideoTransformationAcceptedEventFromRaw + >) +)] +public sealed record class VideoTransformationAcceptedEvent : JsonModel +{ + /// + /// Unique identifier for the event. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The type of webhook event. + /// + public required string Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// Timestamp when the event was created in ISO8601 format. + /// + public required System::DateTimeOffset CreatedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("created_at"); + } + init { this._rawData.Set("created_at", value); } + } + + public required VideoTransformationAcceptedEventIntersectionMember1Data Data + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "data" + ); + } + init { this._rawData.Set("data", value); } + } + + /// + /// Information about the original request that triggered the video transformation. + /// + public required VideoTransformationAcceptedEventIntersectionMember1Request Request + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "request" + ); + } + init { this._rawData.Set("request", value); } + } + + public static implicit operator BaseWebhookEvent( + VideoTransformationAcceptedEvent videoTransformationAcceptedEvent + ) => + new() + { + ID = videoTransformationAcceptedEvent.ID, + Type = videoTransformationAcceptedEvent.Type, + }; + + /// + public override void Validate() + { + _ = this.ID; + _ = this.Type; + _ = this.CreatedAt; + this.Data.Validate(); + this.Request.Validate(); + } + + public VideoTransformationAcceptedEvent() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public VideoTransformationAcceptedEvent( + VideoTransformationAcceptedEvent videoTransformationAcceptedEvent + ) + : base(videoTransformationAcceptedEvent) { } +#pragma warning restore CS8618 + + public VideoTransformationAcceptedEvent(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + VideoTransformationAcceptedEvent(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static VideoTransformationAcceptedEvent FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class VideoTransformationAcceptedEventFromRaw : IFromRawJson +{ + /// + public VideoTransformationAcceptedEvent FromRawUnchecked( + IReadOnlyDictionary rawData + ) => VideoTransformationAcceptedEvent.FromRawUnchecked(rawData); +} + +/// +/// Triggered when a new video transformation request is accepted for processing. +/// This event confirms that ImageKit has received and queued your transformation +/// request. Use this for debugging and tracking transformation lifecycle. +/// +[JsonConverter( + typeof(JsonModelConverter< + VideoTransformationAcceptedEventIntersectionMember1, + VideoTransformationAcceptedEventIntersectionMember1FromRaw + >) +)] +public sealed record class VideoTransformationAcceptedEventIntersectionMember1 : JsonModel +{ + /// + /// Timestamp when the event was created in ISO8601 format. + /// + public required System::DateTimeOffset CreatedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("created_at"); + } + init { this._rawData.Set("created_at", value); } + } + + public required VideoTransformationAcceptedEventIntersectionMember1Data Data + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "data" + ); + } + init { this._rawData.Set("data", value); } + } + + /// + /// Information about the original request that triggered the video transformation. + /// + public required VideoTransformationAcceptedEventIntersectionMember1Request Request + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "request" + ); + } + init { this._rawData.Set("request", value); } + } + + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + public override void Validate() + { + _ = this.CreatedAt; + this.Data.Validate(); + this.Request.Validate(); + if ( + !JsonElement.DeepEquals( + this.Type, + JsonSerializer.SerializeToElement("video.transformation.accepted") + ) + ) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + } + + public VideoTransformationAcceptedEventIntersectionMember1() + { + this.Type = JsonSerializer.SerializeToElement("video.transformation.accepted"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public VideoTransformationAcceptedEventIntersectionMember1( + VideoTransformationAcceptedEventIntersectionMember1 videoTransformationAcceptedEventIntersectionMember1 + ) + : base(videoTransformationAcceptedEventIntersectionMember1) { } +#pragma warning restore CS8618 + + public VideoTransformationAcceptedEventIntersectionMember1( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("video.transformation.accepted"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + VideoTransformationAcceptedEventIntersectionMember1( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static VideoTransformationAcceptedEventIntersectionMember1 FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class VideoTransformationAcceptedEventIntersectionMember1FromRaw + : IFromRawJson +{ + /// + public VideoTransformationAcceptedEventIntersectionMember1 FromRawUnchecked( + IReadOnlyDictionary rawData + ) => VideoTransformationAcceptedEventIntersectionMember1.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + VideoTransformationAcceptedEventIntersectionMember1Data, + VideoTransformationAcceptedEventIntersectionMember1DataFromRaw + >) +)] +public sealed record class VideoTransformationAcceptedEventIntersectionMember1Data : JsonModel +{ + /// + /// Information about the source video asset being transformed. + /// + public required Asset Asset + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("asset"); + } + init { this._rawData.Set("asset", value); } + } + + /// + /// Base information about a video transformation request. + /// + public required VideoTransformationAcceptedEventIntersectionMember1DataTransformation Transformation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "transformation" + ); + } + init { this._rawData.Set("transformation", value); } + } + + /// + public override void Validate() + { + this.Asset.Validate(); + this.Transformation.Validate(); + } + + public VideoTransformationAcceptedEventIntersectionMember1Data() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public VideoTransformationAcceptedEventIntersectionMember1Data( + VideoTransformationAcceptedEventIntersectionMember1Data videoTransformationAcceptedEventIntersectionMember1Data + ) + : base(videoTransformationAcceptedEventIntersectionMember1Data) { } +#pragma warning restore CS8618 + + public VideoTransformationAcceptedEventIntersectionMember1Data( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + VideoTransformationAcceptedEventIntersectionMember1Data( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static VideoTransformationAcceptedEventIntersectionMember1Data FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class VideoTransformationAcceptedEventIntersectionMember1DataFromRaw + : IFromRawJson +{ + /// + public VideoTransformationAcceptedEventIntersectionMember1Data FromRawUnchecked( + IReadOnlyDictionary rawData + ) => VideoTransformationAcceptedEventIntersectionMember1Data.FromRawUnchecked(rawData); +} + +/// +/// Information about the source video asset being transformed. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Asset : JsonModel +{ + /// + /// URL to download or access the source video file. + /// + public required string Url + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("url"); + } + init { this._rawData.Set("url", value); } + } + + /// + public override void Validate() + { + _ = this.Url; + } + + public Asset() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Asset(Asset asset) + : base(asset) { } +#pragma warning restore CS8618 + + public Asset(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Asset(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static Asset FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public Asset(string url) + : this() + { + this.Url = url; + } +} + +class AssetFromRaw : IFromRawJson +{ + /// + public Asset FromRawUnchecked(IReadOnlyDictionary rawData) => + Asset.FromRawUnchecked(rawData); +} + +/// +/// Base information about a video transformation request. +/// +[JsonConverter( + typeof(JsonModelConverter< + VideoTransformationAcceptedEventIntersectionMember1DataTransformation, + VideoTransformationAcceptedEventIntersectionMember1DataTransformationFromRaw + >) +)] +public sealed record class VideoTransformationAcceptedEventIntersectionMember1DataTransformation + : JsonModel +{ + /// + /// Type of video transformation: - `video-transformation`: Standard video processing + /// (resize, format conversion, etc.) - `gif-to-video`: Convert animated GIF + /// to video format - `video-thumbnail`: Generate thumbnail image from video + /// + public required ApiEnum< + string, + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType + > Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum< + string, + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType + > + >("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// Configuration options for video transformations. + /// + public Options? Options + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("options"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("options", value); + } + } + + /// + public override void Validate() + { + this.Type.Validate(); + this.Options?.Validate(); + } + + public VideoTransformationAcceptedEventIntersectionMember1DataTransformation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public VideoTransformationAcceptedEventIntersectionMember1DataTransformation( + VideoTransformationAcceptedEventIntersectionMember1DataTransformation videoTransformationAcceptedEventIntersectionMember1DataTransformation + ) + : base(videoTransformationAcceptedEventIntersectionMember1DataTransformation) { } +#pragma warning restore CS8618 + + public VideoTransformationAcceptedEventIntersectionMember1DataTransformation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + VideoTransformationAcceptedEventIntersectionMember1DataTransformation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static VideoTransformationAcceptedEventIntersectionMember1DataTransformation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public VideoTransformationAcceptedEventIntersectionMember1DataTransformation( + ApiEnum< + string, + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType + > type + ) + : this() + { + this.Type = type; + } +} + +class VideoTransformationAcceptedEventIntersectionMember1DataTransformationFromRaw + : IFromRawJson +{ + /// + public VideoTransformationAcceptedEventIntersectionMember1DataTransformation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + VideoTransformationAcceptedEventIntersectionMember1DataTransformation.FromRawUnchecked( + rawData + ); +} + +/// +/// Type of video transformation: - `video-transformation`: Standard video processing +/// (resize, format conversion, etc.) - `gif-to-video`: Convert animated GIF to video +/// format - `video-thumbnail`: Generate thumbnail image from video +/// +[JsonConverter( + typeof(VideoTransformationAcceptedEventIntersectionMember1DataTransformationTypeConverter) +)] +public enum VideoTransformationAcceptedEventIntersectionMember1DataTransformationType +{ + VideoTransformation, + GifToVideo, + VideoThumbnail, +} + +sealed class VideoTransformationAcceptedEventIntersectionMember1DataTransformationTypeConverter + : JsonConverter +{ + public override VideoTransformationAcceptedEventIntersectionMember1DataTransformationType Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "video-transformation" => + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + "gif-to-video" => + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.GifToVideo, + "video-thumbnail" => + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoThumbnail, + _ => (VideoTransformationAcceptedEventIntersectionMember1DataTransformationType)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation => + "video-transformation", + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.GifToVideo => + "gif-to-video", + VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoThumbnail => + "video-thumbnail", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration options for video transformations. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Options : JsonModel +{ + /// + /// Audio codec used for encoding (aac or opus). + /// + public ApiEnum? AudioCodec + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("audio_codec"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("audio_codec", value); + } + } + + /// + /// Whether to automatically rotate the video based on metadata. + /// + public bool? AutoRotate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("auto_rotate"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("auto_rotate", value); + } + } + + /// + /// Output format for the transformed video or thumbnail. + /// + public ApiEnum? Format + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("format"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("format", value); + } + } + + /// + /// Quality setting for the output video. + /// + public long? Quality + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("quality"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("quality", value); + } + } + + /// + /// Streaming protocol for adaptive bitrate streaming. + /// + public ApiEnum? StreamProtocol + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>( + "stream_protocol" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("stream_protocol", value); + } + } + + /// + /// Array of quality representations for adaptive bitrate streaming. + /// + public IReadOnlyList? Variants + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>("variants"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "variants", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Video codec used for encoding (h264, vp9, or av1). + /// + public ApiEnum? VideoCodec + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("video_codec"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("video_codec", value); + } + } + + /// + public override void Validate() + { + this.AudioCodec?.Validate(); + _ = this.AutoRotate; + this.Format?.Validate(); + _ = this.Quality; + this.StreamProtocol?.Validate(); + _ = this.Variants; + this.VideoCodec?.Validate(); + } + + public Options() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Options(Options options) + : base(options) { } +#pragma warning restore CS8618 + + public Options(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Options(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static Options FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class OptionsFromRaw : IFromRawJson +{ + /// + public Options FromRawUnchecked(IReadOnlyDictionary rawData) => + Options.FromRawUnchecked(rawData); +} + +/// +/// Audio codec used for encoding (aac or opus). +/// +[JsonConverter(typeof(AudioCodecConverter))] +public enum AudioCodec +{ + Aac, + Opus, +} + +sealed class AudioCodecConverter : JsonConverter +{ + public override AudioCodec Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "aac" => AudioCodec.Aac, + "opus" => AudioCodec.Opus, + _ => (AudioCodec)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + AudioCodec value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + AudioCodec.Aac => "aac", + AudioCodec.Opus => "opus", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Output format for the transformed video or thumbnail. +/// +[JsonConverter(typeof(FormatConverter))] +public enum Format +{ + Mp4, + Webm, + Jpg, + Png, + Webp, +} + +sealed class FormatConverter : JsonConverter +{ + public override Format Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "mp4" => Format.Mp4, + "webm" => Format.Webm, + "jpg" => Format.Jpg, + "png" => Format.Png, + "webp" => Format.Webp, + _ => (Format)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Format value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + Format.Mp4 => "mp4", + Format.Webm => "webm", + Format.Jpg => "jpg", + Format.Png => "png", + Format.Webp => "webp", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Streaming protocol for adaptive bitrate streaming. +/// +[JsonConverter(typeof(StreamProtocolConverter))] +public enum StreamProtocol +{ + Hls, + Dash, +} + +sealed class StreamProtocolConverter : JsonConverter +{ + public override StreamProtocol Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "HLS" => StreamProtocol.Hls, + "DASH" => StreamProtocol.Dash, + _ => (StreamProtocol)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + StreamProtocol value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + StreamProtocol.Hls => "HLS", + StreamProtocol.Dash => "DASH", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Video codec used for encoding (h264, vp9, or av1). +/// +[JsonConverter(typeof(VideoCodecConverter))] +public enum VideoCodec +{ + H264, + Vp9, + Av1, +} + +sealed class VideoCodecConverter : JsonConverter +{ + public override VideoCodec Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "h264" => VideoCodec.H264, + "vp9" => VideoCodec.Vp9, + "av1" => VideoCodec.Av1, + _ => (VideoCodec)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + VideoCodec value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + VideoCodec.H264 => "h264", + VideoCodec.Vp9 => "vp9", + VideoCodec.Av1 => "av1", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Information about the original request that triggered the video transformation. +/// +[JsonConverter( + typeof(JsonModelConverter< + VideoTransformationAcceptedEventIntersectionMember1Request, + VideoTransformationAcceptedEventIntersectionMember1RequestFromRaw + >) +)] +public sealed record class VideoTransformationAcceptedEventIntersectionMember1Request : JsonModel +{ + /// + /// Full URL of the transformation request that was submitted. + /// + public required string Url + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("url"); + } + init { this._rawData.Set("url", value); } + } + + /// + /// Unique identifier for the originating transformation request. + /// + public required string XRequestID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("x_request_id"); + } + init { this._rawData.Set("x_request_id", value); } + } + + /// + /// User-Agent header from the original request that triggered the transformation. + /// + public string? UserAgent + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("user_agent"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("user_agent", value); + } + } + + /// + public override void Validate() + { + _ = this.Url; + _ = this.XRequestID; + _ = this.UserAgent; + } + + public VideoTransformationAcceptedEventIntersectionMember1Request() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public VideoTransformationAcceptedEventIntersectionMember1Request( + VideoTransformationAcceptedEventIntersectionMember1Request videoTransformationAcceptedEventIntersectionMember1Request + ) + : base(videoTransformationAcceptedEventIntersectionMember1Request) { } +#pragma warning restore CS8618 + + public VideoTransformationAcceptedEventIntersectionMember1Request( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + VideoTransformationAcceptedEventIntersectionMember1Request( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static VideoTransformationAcceptedEventIntersectionMember1Request FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class VideoTransformationAcceptedEventIntersectionMember1RequestFromRaw + : IFromRawJson +{ + /// + public VideoTransformationAcceptedEventIntersectionMember1Request FromRawUnchecked( + IReadOnlyDictionary rawData + ) => VideoTransformationAcceptedEventIntersectionMember1Request.FromRawUnchecked(rawData); +} diff --git a/src/ImageKit/Models/Webhooks/VideoTransformationErrorEvent.cs b/src/ImageKit/Models/Webhooks/VideoTransformationErrorEvent.cs new file mode 100644 index 00000000..5fb9a991 --- /dev/null +++ b/src/ImageKit/Models/Webhooks/VideoTransformationErrorEvent.cs @@ -0,0 +1,1394 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; +using ImageKit.Exceptions; +using System = System; + +namespace ImageKit.Models.Webhooks; + +/// +/// Triggered when an error occurs during video encoding. Listen to this webhook +/// to log error reasons and debug issues. Check your origin and URL endpoint settings +/// if the reason is related to download failure. For other errors, contact ImageKit +/// support. +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class VideoTransformationErrorEvent : JsonModel +{ + /// + /// Unique identifier for the event. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The type of webhook event. + /// + public required string Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// Timestamp when the event was created in ISO8601 format. + /// + public required System::DateTimeOffset CreatedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("created_at"); + } + init { this._rawData.Set("created_at", value); } + } + + public required VideoTransformationErrorEventIntersectionMember1Data Data + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "data" + ); + } + init { this._rawData.Set("data", value); } + } + + /// + /// Information about the original request that triggered the video transformation. + /// + public required VideoTransformationErrorEventIntersectionMember1Request Request + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "request" + ); + } + init { this._rawData.Set("request", value); } + } + + public static implicit operator BaseWebhookEvent( + VideoTransformationErrorEvent videoTransformationErrorEvent + ) => new() { ID = videoTransformationErrorEvent.ID, Type = videoTransformationErrorEvent.Type }; + + /// + public override void Validate() + { + _ = this.ID; + _ = this.Type; + _ = this.CreatedAt; + this.Data.Validate(); + this.Request.Validate(); + } + + public VideoTransformationErrorEvent() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public VideoTransformationErrorEvent( + VideoTransformationErrorEvent videoTransformationErrorEvent + ) + : base(videoTransformationErrorEvent) { } +#pragma warning restore CS8618 + + public VideoTransformationErrorEvent(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + VideoTransformationErrorEvent(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static VideoTransformationErrorEvent FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class VideoTransformationErrorEventFromRaw : IFromRawJson +{ + /// + public VideoTransformationErrorEvent FromRawUnchecked( + IReadOnlyDictionary rawData + ) => VideoTransformationErrorEvent.FromRawUnchecked(rawData); +} + +/// +/// Triggered when an error occurs during video encoding. Listen to this webhook +/// to log error reasons and debug issues. Check your origin and URL endpoint settings +/// if the reason is related to download failure. For other errors, contact ImageKit +/// support. +/// +[JsonConverter( + typeof(JsonModelConverter< + VideoTransformationErrorEventIntersectionMember1, + VideoTransformationErrorEventIntersectionMember1FromRaw + >) +)] +public sealed record class VideoTransformationErrorEventIntersectionMember1 : JsonModel +{ + /// + /// Timestamp when the event was created in ISO8601 format. + /// + public required System::DateTimeOffset CreatedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("created_at"); + } + init { this._rawData.Set("created_at", value); } + } + + public required VideoTransformationErrorEventIntersectionMember1Data Data + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "data" + ); + } + init { this._rawData.Set("data", value); } + } + + /// + /// Information about the original request that triggered the video transformation. + /// + public required VideoTransformationErrorEventIntersectionMember1Request Request + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "request" + ); + } + init { this._rawData.Set("request", value); } + } + + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + public override void Validate() + { + _ = this.CreatedAt; + this.Data.Validate(); + this.Request.Validate(); + if ( + !JsonElement.DeepEquals( + this.Type, + JsonSerializer.SerializeToElement("video.transformation.error") + ) + ) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + } + + public VideoTransformationErrorEventIntersectionMember1() + { + this.Type = JsonSerializer.SerializeToElement("video.transformation.error"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public VideoTransformationErrorEventIntersectionMember1( + VideoTransformationErrorEventIntersectionMember1 videoTransformationErrorEventIntersectionMember1 + ) + : base(videoTransformationErrorEventIntersectionMember1) { } +#pragma warning restore CS8618 + + public VideoTransformationErrorEventIntersectionMember1( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("video.transformation.error"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + VideoTransformationErrorEventIntersectionMember1(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static VideoTransformationErrorEventIntersectionMember1 FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class VideoTransformationErrorEventIntersectionMember1FromRaw + : IFromRawJson +{ + /// + public VideoTransformationErrorEventIntersectionMember1 FromRawUnchecked( + IReadOnlyDictionary rawData + ) => VideoTransformationErrorEventIntersectionMember1.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + VideoTransformationErrorEventIntersectionMember1Data, + VideoTransformationErrorEventIntersectionMember1DataFromRaw + >) +)] +public sealed record class VideoTransformationErrorEventIntersectionMember1Data : JsonModel +{ + /// + /// Information about the source video asset being transformed. + /// + public required VideoTransformationErrorEventIntersectionMember1DataAsset Asset + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "asset" + ); + } + init { this._rawData.Set("asset", value); } + } + + public required VideoTransformationErrorEventIntersectionMember1DataTransformation Transformation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "transformation" + ); + } + init { this._rawData.Set("transformation", value); } + } + + /// + public override void Validate() + { + this.Asset.Validate(); + this.Transformation.Validate(); + } + + public VideoTransformationErrorEventIntersectionMember1Data() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public VideoTransformationErrorEventIntersectionMember1Data( + VideoTransformationErrorEventIntersectionMember1Data videoTransformationErrorEventIntersectionMember1Data + ) + : base(videoTransformationErrorEventIntersectionMember1Data) { } +#pragma warning restore CS8618 + + public VideoTransformationErrorEventIntersectionMember1Data( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + VideoTransformationErrorEventIntersectionMember1Data( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static VideoTransformationErrorEventIntersectionMember1Data FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class VideoTransformationErrorEventIntersectionMember1DataFromRaw + : IFromRawJson +{ + /// + public VideoTransformationErrorEventIntersectionMember1Data FromRawUnchecked( + IReadOnlyDictionary rawData + ) => VideoTransformationErrorEventIntersectionMember1Data.FromRawUnchecked(rawData); +} + +/// +/// Information about the source video asset being transformed. +/// +[JsonConverter( + typeof(JsonModelConverter< + VideoTransformationErrorEventIntersectionMember1DataAsset, + VideoTransformationErrorEventIntersectionMember1DataAssetFromRaw + >) +)] +public sealed record class VideoTransformationErrorEventIntersectionMember1DataAsset : JsonModel +{ + /// + /// URL to download or access the source video file. + /// + public required string Url + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("url"); + } + init { this._rawData.Set("url", value); } + } + + /// + public override void Validate() + { + _ = this.Url; + } + + public VideoTransformationErrorEventIntersectionMember1DataAsset() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public VideoTransformationErrorEventIntersectionMember1DataAsset( + VideoTransformationErrorEventIntersectionMember1DataAsset videoTransformationErrorEventIntersectionMember1DataAsset + ) + : base(videoTransformationErrorEventIntersectionMember1DataAsset) { } +#pragma warning restore CS8618 + + public VideoTransformationErrorEventIntersectionMember1DataAsset( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + VideoTransformationErrorEventIntersectionMember1DataAsset( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static VideoTransformationErrorEventIntersectionMember1DataAsset FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public VideoTransformationErrorEventIntersectionMember1DataAsset(string url) + : this() + { + this.Url = url; + } +} + +class VideoTransformationErrorEventIntersectionMember1DataAssetFromRaw + : IFromRawJson +{ + /// + public VideoTransformationErrorEventIntersectionMember1DataAsset FromRawUnchecked( + IReadOnlyDictionary rawData + ) => VideoTransformationErrorEventIntersectionMember1DataAsset.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + VideoTransformationErrorEventIntersectionMember1DataTransformation, + VideoTransformationErrorEventIntersectionMember1DataTransformationFromRaw + >) +)] +public sealed record class VideoTransformationErrorEventIntersectionMember1DataTransformation + : JsonModel +{ + /// + /// Type of video transformation: - `video-transformation`: Standard video processing + /// (resize, format conversion, etc.) - `gif-to-video`: Convert animated GIF + /// to video format - `video-thumbnail`: Generate thumbnail image from video + /// + public required ApiEnum< + string, + VideoTransformationErrorEventIntersectionMember1DataTransformationType + > Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum< + string, + VideoTransformationErrorEventIntersectionMember1DataTransformationType + > + >("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// Details about the transformation error. + /// + public VideoTransformationErrorEventIntersectionMember1DataTransformationError? Error + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "error" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("error", value); + } + } + + /// + /// Configuration options for video transformations. + /// + public VideoTransformationErrorEventIntersectionMember1DataTransformationOptions? Options + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "options" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("options", value); + } + } + + /// + public override void Validate() + { + this.Type.Validate(); + this.Error?.Validate(); + this.Options?.Validate(); + } + + public VideoTransformationErrorEventIntersectionMember1DataTransformation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public VideoTransformationErrorEventIntersectionMember1DataTransformation( + VideoTransformationErrorEventIntersectionMember1DataTransformation videoTransformationErrorEventIntersectionMember1DataTransformation + ) + : base(videoTransformationErrorEventIntersectionMember1DataTransformation) { } +#pragma warning restore CS8618 + + public VideoTransformationErrorEventIntersectionMember1DataTransformation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + VideoTransformationErrorEventIntersectionMember1DataTransformation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static VideoTransformationErrorEventIntersectionMember1DataTransformation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public VideoTransformationErrorEventIntersectionMember1DataTransformation( + ApiEnum type + ) + : this() + { + this.Type = type; + } +} + +class VideoTransformationErrorEventIntersectionMember1DataTransformationFromRaw + : IFromRawJson +{ + /// + public VideoTransformationErrorEventIntersectionMember1DataTransformation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + VideoTransformationErrorEventIntersectionMember1DataTransformation.FromRawUnchecked( + rawData + ); +} + +/// +/// Type of video transformation: - `video-transformation`: Standard video processing +/// (resize, format conversion, etc.) - `gif-to-video`: Convert animated GIF to video +/// format - `video-thumbnail`: Generate thumbnail image from video +/// +[JsonConverter( + typeof(VideoTransformationErrorEventIntersectionMember1DataTransformationTypeConverter) +)] +public enum VideoTransformationErrorEventIntersectionMember1DataTransformationType +{ + VideoTransformation, + GifToVideo, + VideoThumbnail, +} + +sealed class VideoTransformationErrorEventIntersectionMember1DataTransformationTypeConverter + : JsonConverter +{ + public override VideoTransformationErrorEventIntersectionMember1DataTransformationType Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "video-transformation" => + VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + "gif-to-video" => + VideoTransformationErrorEventIntersectionMember1DataTransformationType.GifToVideo, + "video-thumbnail" => + VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoThumbnail, + _ => (VideoTransformationErrorEventIntersectionMember1DataTransformationType)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + VideoTransformationErrorEventIntersectionMember1DataTransformationType value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation => + "video-transformation", + VideoTransformationErrorEventIntersectionMember1DataTransformationType.GifToVideo => + "gif-to-video", + VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoThumbnail => + "video-thumbnail", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Details about the transformation error. +/// +[JsonConverter( + typeof(JsonModelConverter< + VideoTransformationErrorEventIntersectionMember1DataTransformationError, + VideoTransformationErrorEventIntersectionMember1DataTransformationErrorFromRaw + >) +)] +public sealed record class VideoTransformationErrorEventIntersectionMember1DataTransformationError + : JsonModel +{ + /// + /// Specific reason for the transformation failure: - `encoding_failed`: Error + /// during video encoding process - `download_failed`: Could not download source + /// video - `internal_server_error`: Unexpected server error + /// + public required ApiEnum Reason + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass>("reason"); + } + init { this._rawData.Set("reason", value); } + } + + /// + public override void Validate() + { + this.Reason.Validate(); + } + + public VideoTransformationErrorEventIntersectionMember1DataTransformationError() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public VideoTransformationErrorEventIntersectionMember1DataTransformationError( + VideoTransformationErrorEventIntersectionMember1DataTransformationError videoTransformationErrorEventIntersectionMember1DataTransformationError + ) + : base(videoTransformationErrorEventIntersectionMember1DataTransformationError) { } +#pragma warning restore CS8618 + + public VideoTransformationErrorEventIntersectionMember1DataTransformationError( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + VideoTransformationErrorEventIntersectionMember1DataTransformationError( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static VideoTransformationErrorEventIntersectionMember1DataTransformationError FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public VideoTransformationErrorEventIntersectionMember1DataTransformationError( + ApiEnum reason + ) + : this() + { + this.Reason = reason; + } +} + +class VideoTransformationErrorEventIntersectionMember1DataTransformationErrorFromRaw + : IFromRawJson +{ + /// + public VideoTransformationErrorEventIntersectionMember1DataTransformationError FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + VideoTransformationErrorEventIntersectionMember1DataTransformationError.FromRawUnchecked( + rawData + ); +} + +/// +/// Specific reason for the transformation failure: - `encoding_failed`: Error during +/// video encoding process - `download_failed`: Could not download source video - +/// `internal_server_error`: Unexpected server error +/// +[JsonConverter(typeof(ReasonConverter))] +public enum Reason +{ + EncodingFailed, + DownloadFailed, + InternalServerError, +} + +sealed class ReasonConverter : JsonConverter +{ + public override Reason Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "encoding_failed" => Reason.EncodingFailed, + "download_failed" => Reason.DownloadFailed, + "internal_server_error" => Reason.InternalServerError, + _ => (Reason)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Reason value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + Reason.EncodingFailed => "encoding_failed", + Reason.DownloadFailed => "download_failed", + Reason.InternalServerError => "internal_server_error", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration options for video transformations. +/// +[JsonConverter( + typeof(JsonModelConverter< + VideoTransformationErrorEventIntersectionMember1DataTransformationOptions, + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFromRaw + >) +)] +public sealed record class VideoTransformationErrorEventIntersectionMember1DataTransformationOptions + : JsonModel +{ + /// + /// Audio codec used for encoding (aac or opus). + /// + public ApiEnum< + string, + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec + >? AudioCodec + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass< + ApiEnum< + string, + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec + > + >("audio_codec"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("audio_codec", value); + } + } + + /// + /// Whether to automatically rotate the video based on metadata. + /// + public bool? AutoRotate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("auto_rotate"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("auto_rotate", value); + } + } + + /// + /// Output format for the transformed video or thumbnail. + /// + public ApiEnum< + string, + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat + >? Format + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass< + ApiEnum< + string, + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat + > + >("format"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("format", value); + } + } + + /// + /// Quality setting for the output video. + /// + public long? Quality + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("quality"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("quality", value); + } + } + + /// + /// Streaming protocol for adaptive bitrate streaming. + /// + public ApiEnum< + string, + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol + >? StreamProtocol + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass< + ApiEnum< + string, + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol + > + >("stream_protocol"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("stream_protocol", value); + } + } + + /// + /// Array of quality representations for adaptive bitrate streaming. + /// + public IReadOnlyList? Variants + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>("variants"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "variants", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Video codec used for encoding (h264, vp9, or av1). + /// + public ApiEnum< + string, + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec + >? VideoCodec + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass< + ApiEnum< + string, + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec + > + >("video_codec"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("video_codec", value); + } + } + + /// + public override void Validate() + { + this.AudioCodec?.Validate(); + _ = this.AutoRotate; + this.Format?.Validate(); + _ = this.Quality; + this.StreamProtocol?.Validate(); + _ = this.Variants; + this.VideoCodec?.Validate(); + } + + public VideoTransformationErrorEventIntersectionMember1DataTransformationOptions() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public VideoTransformationErrorEventIntersectionMember1DataTransformationOptions( + VideoTransformationErrorEventIntersectionMember1DataTransformationOptions videoTransformationErrorEventIntersectionMember1DataTransformationOptions + ) + : base(videoTransformationErrorEventIntersectionMember1DataTransformationOptions) { } +#pragma warning restore CS8618 + + public VideoTransformationErrorEventIntersectionMember1DataTransformationOptions( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + VideoTransformationErrorEventIntersectionMember1DataTransformationOptions( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static VideoTransformationErrorEventIntersectionMember1DataTransformationOptions FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFromRaw + : IFromRawJson +{ + /// + public VideoTransformationErrorEventIntersectionMember1DataTransformationOptions FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + VideoTransformationErrorEventIntersectionMember1DataTransformationOptions.FromRawUnchecked( + rawData + ); +} + +/// +/// Audio codec used for encoding (aac or opus). +/// +[JsonConverter( + typeof(VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodecConverter) +)] +public enum VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec +{ + Aac, + Opus, +} + +sealed class VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodecConverter + : JsonConverter +{ + public override VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "aac" => + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + "opus" => + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Opus, + _ => + (VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec)( + -1 + ), + }; + } + + public override void Write( + Utf8JsonWriter writer, + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac => + "aac", + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Opus => + "opus", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Output format for the transformed video or thumbnail. +/// +[JsonConverter( + typeof(VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormatConverter) +)] +public enum VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat +{ + Mp4, + Webm, + Jpg, + Png, + Webp, +} + +sealed class VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormatConverter + : JsonConverter +{ + public override VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "mp4" => + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + "webm" => + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Webm, + "jpg" => + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Jpg, + "png" => + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Png, + "webp" => + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Webp, + _ => (VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat)( + -1 + ), + }; + } + + public override void Write( + Utf8JsonWriter writer, + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4 => + "mp4", + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Webm => + "webm", + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Jpg => + "jpg", + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Png => + "png", + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Webp => + "webp", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Streaming protocol for adaptive bitrate streaming. +/// +[JsonConverter( + typeof(VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocolConverter) +)] +public enum VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol +{ + Hls, + Dash, +} + +sealed class VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocolConverter + : JsonConverter +{ + public override VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "HLS" => + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + "DASH" => + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Dash, + _ => + (VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol)( + -1 + ), + }; + } + + public override void Write( + Utf8JsonWriter writer, + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls => + "HLS", + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Dash => + "DASH", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Video codec used for encoding (h264, vp9, or av1). +/// +[JsonConverter( + typeof(VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodecConverter) +)] +public enum VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec +{ + H264, + Vp9, + Av1, +} + +sealed class VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodecConverter + : JsonConverter +{ + public override VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "h264" => + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + "vp9" => + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.Vp9, + "av1" => + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.Av1, + _ => + (VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec)( + -1 + ), + }; + } + + public override void Write( + Utf8JsonWriter writer, + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264 => + "h264", + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.Vp9 => + "vp9", + VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.Av1 => + "av1", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Information about the original request that triggered the video transformation. +/// +[JsonConverter( + typeof(JsonModelConverter< + VideoTransformationErrorEventIntersectionMember1Request, + VideoTransformationErrorEventIntersectionMember1RequestFromRaw + >) +)] +public sealed record class VideoTransformationErrorEventIntersectionMember1Request : JsonModel +{ + /// + /// Full URL of the transformation request that was submitted. + /// + public required string Url + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("url"); + } + init { this._rawData.Set("url", value); } + } + + /// + /// Unique identifier for the originating transformation request. + /// + public required string XRequestID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("x_request_id"); + } + init { this._rawData.Set("x_request_id", value); } + } + + /// + /// User-Agent header from the original request that triggered the transformation. + /// + public string? UserAgent + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("user_agent"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("user_agent", value); + } + } + + /// + public override void Validate() + { + _ = this.Url; + _ = this.XRequestID; + _ = this.UserAgent; + } + + public VideoTransformationErrorEventIntersectionMember1Request() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public VideoTransformationErrorEventIntersectionMember1Request( + VideoTransformationErrorEventIntersectionMember1Request videoTransformationErrorEventIntersectionMember1Request + ) + : base(videoTransformationErrorEventIntersectionMember1Request) { } +#pragma warning restore CS8618 + + public VideoTransformationErrorEventIntersectionMember1Request( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + VideoTransformationErrorEventIntersectionMember1Request( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static VideoTransformationErrorEventIntersectionMember1Request FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class VideoTransformationErrorEventIntersectionMember1RequestFromRaw + : IFromRawJson +{ + /// + public VideoTransformationErrorEventIntersectionMember1Request FromRawUnchecked( + IReadOnlyDictionary rawData + ) => VideoTransformationErrorEventIntersectionMember1Request.FromRawUnchecked(rawData); +} diff --git a/src/ImageKit/Models/Webhooks/VideoTransformationReadyEvent.cs b/src/ImageKit/Models/Webhooks/VideoTransformationReadyEvent.cs new file mode 100644 index 00000000..4196f204 --- /dev/null +++ b/src/ImageKit/Models/Webhooks/VideoTransformationReadyEvent.cs @@ -0,0 +1,1580 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; +using ImageKit.Exceptions; +using System = System; + +namespace ImageKit.Models.Webhooks; + +/// +/// Triggered when video encoding is finished and the transformed resource is ready +/// to be served. This is the key event to listen for - update your database or CMS +/// flags when you receive this so your application can start showing the transformed +/// video to users. +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class VideoTransformationReadyEvent : JsonModel +{ + /// + /// Unique identifier for the event. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The type of webhook event. + /// + public required string Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// Timestamp when the event was created in ISO8601 format. + /// + public required System::DateTimeOffset CreatedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("created_at"); + } + init { this._rawData.Set("created_at", value); } + } + + public required VideoTransformationReadyEventIntersectionMember1Data Data + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "data" + ); + } + init { this._rawData.Set("data", value); } + } + + /// + /// Information about the original request that triggered the video transformation. + /// + public required VideoTransformationReadyEventIntersectionMember1Request Request + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "request" + ); + } + init { this._rawData.Set("request", value); } + } + + /// + /// Performance metrics for the transformation process. + /// + public Timings? Timings + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("timings"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("timings", value); + } + } + + public static implicit operator BaseWebhookEvent( + VideoTransformationReadyEvent videoTransformationReadyEvent + ) => new() { ID = videoTransformationReadyEvent.ID, Type = videoTransformationReadyEvent.Type }; + + /// + public override void Validate() + { + _ = this.ID; + _ = this.Type; + _ = this.CreatedAt; + this.Data.Validate(); + this.Request.Validate(); + this.Timings?.Validate(); + } + + public VideoTransformationReadyEvent() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public VideoTransformationReadyEvent( + VideoTransformationReadyEvent videoTransformationReadyEvent + ) + : base(videoTransformationReadyEvent) { } +#pragma warning restore CS8618 + + public VideoTransformationReadyEvent(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + VideoTransformationReadyEvent(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static VideoTransformationReadyEvent FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class VideoTransformationReadyEventFromRaw : IFromRawJson +{ + /// + public VideoTransformationReadyEvent FromRawUnchecked( + IReadOnlyDictionary rawData + ) => VideoTransformationReadyEvent.FromRawUnchecked(rawData); +} + +/// +/// Triggered when video encoding is finished and the transformed resource is ready +/// to be served. This is the key event to listen for - update your database or CMS +/// flags when you receive this so your application can start showing the transformed +/// video to users. +/// +[JsonConverter( + typeof(JsonModelConverter< + VideoTransformationReadyEventIntersectionMember1, + VideoTransformationReadyEventIntersectionMember1FromRaw + >) +)] +public sealed record class VideoTransformationReadyEventIntersectionMember1 : JsonModel +{ + /// + /// Timestamp when the event was created in ISO8601 format. + /// + public required System::DateTimeOffset CreatedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("created_at"); + } + init { this._rawData.Set("created_at", value); } + } + + public required VideoTransformationReadyEventIntersectionMember1Data Data + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "data" + ); + } + init { this._rawData.Set("data", value); } + } + + /// + /// Information about the original request that triggered the video transformation. + /// + public required VideoTransformationReadyEventIntersectionMember1Request Request + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "request" + ); + } + init { this._rawData.Set("request", value); } + } + + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// Performance metrics for the transformation process. + /// + public Timings? Timings + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("timings"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("timings", value); + } + } + + /// + public override void Validate() + { + _ = this.CreatedAt; + this.Data.Validate(); + this.Request.Validate(); + if ( + !JsonElement.DeepEquals( + this.Type, + JsonSerializer.SerializeToElement("video.transformation.ready") + ) + ) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + this.Timings?.Validate(); + } + + public VideoTransformationReadyEventIntersectionMember1() + { + this.Type = JsonSerializer.SerializeToElement("video.transformation.ready"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public VideoTransformationReadyEventIntersectionMember1( + VideoTransformationReadyEventIntersectionMember1 videoTransformationReadyEventIntersectionMember1 + ) + : base(videoTransformationReadyEventIntersectionMember1) { } +#pragma warning restore CS8618 + + public VideoTransformationReadyEventIntersectionMember1( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("video.transformation.ready"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + VideoTransformationReadyEventIntersectionMember1(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static VideoTransformationReadyEventIntersectionMember1 FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class VideoTransformationReadyEventIntersectionMember1FromRaw + : IFromRawJson +{ + /// + public VideoTransformationReadyEventIntersectionMember1 FromRawUnchecked( + IReadOnlyDictionary rawData + ) => VideoTransformationReadyEventIntersectionMember1.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + VideoTransformationReadyEventIntersectionMember1Data, + VideoTransformationReadyEventIntersectionMember1DataFromRaw + >) +)] +public sealed record class VideoTransformationReadyEventIntersectionMember1Data : JsonModel +{ + /// + /// Information about the source video asset being transformed. + /// + public required VideoTransformationReadyEventIntersectionMember1DataAsset Asset + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "asset" + ); + } + init { this._rawData.Set("asset", value); } + } + + public required VideoTransformationReadyEventIntersectionMember1DataTransformation Transformation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "transformation" + ); + } + init { this._rawData.Set("transformation", value); } + } + + /// + public override void Validate() + { + this.Asset.Validate(); + this.Transformation.Validate(); + } + + public VideoTransformationReadyEventIntersectionMember1Data() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public VideoTransformationReadyEventIntersectionMember1Data( + VideoTransformationReadyEventIntersectionMember1Data videoTransformationReadyEventIntersectionMember1Data + ) + : base(videoTransformationReadyEventIntersectionMember1Data) { } +#pragma warning restore CS8618 + + public VideoTransformationReadyEventIntersectionMember1Data( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + VideoTransformationReadyEventIntersectionMember1Data( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static VideoTransformationReadyEventIntersectionMember1Data FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class VideoTransformationReadyEventIntersectionMember1DataFromRaw + : IFromRawJson +{ + /// + public VideoTransformationReadyEventIntersectionMember1Data FromRawUnchecked( + IReadOnlyDictionary rawData + ) => VideoTransformationReadyEventIntersectionMember1Data.FromRawUnchecked(rawData); +} + +/// +/// Information about the source video asset being transformed. +/// +[JsonConverter( + typeof(JsonModelConverter< + VideoTransformationReadyEventIntersectionMember1DataAsset, + VideoTransformationReadyEventIntersectionMember1DataAssetFromRaw + >) +)] +public sealed record class VideoTransformationReadyEventIntersectionMember1DataAsset : JsonModel +{ + /// + /// URL to download or access the source video file. + /// + public required string Url + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("url"); + } + init { this._rawData.Set("url", value); } + } + + /// + public override void Validate() + { + _ = this.Url; + } + + public VideoTransformationReadyEventIntersectionMember1DataAsset() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public VideoTransformationReadyEventIntersectionMember1DataAsset( + VideoTransformationReadyEventIntersectionMember1DataAsset videoTransformationReadyEventIntersectionMember1DataAsset + ) + : base(videoTransformationReadyEventIntersectionMember1DataAsset) { } +#pragma warning restore CS8618 + + public VideoTransformationReadyEventIntersectionMember1DataAsset( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + VideoTransformationReadyEventIntersectionMember1DataAsset( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static VideoTransformationReadyEventIntersectionMember1DataAsset FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public VideoTransformationReadyEventIntersectionMember1DataAsset(string url) + : this() + { + this.Url = url; + } +} + +class VideoTransformationReadyEventIntersectionMember1DataAssetFromRaw + : IFromRawJson +{ + /// + public VideoTransformationReadyEventIntersectionMember1DataAsset FromRawUnchecked( + IReadOnlyDictionary rawData + ) => VideoTransformationReadyEventIntersectionMember1DataAsset.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + VideoTransformationReadyEventIntersectionMember1DataTransformation, + VideoTransformationReadyEventIntersectionMember1DataTransformationFromRaw + >) +)] +public sealed record class VideoTransformationReadyEventIntersectionMember1DataTransformation + : JsonModel +{ + /// + /// Type of video transformation: - `video-transformation`: Standard video processing + /// (resize, format conversion, etc.) - `gif-to-video`: Convert animated GIF + /// to video format - `video-thumbnail`: Generate thumbnail image from video + /// + public required ApiEnum< + string, + VideoTransformationReadyEventIntersectionMember1DataTransformationType + > Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum< + string, + VideoTransformationReadyEventIntersectionMember1DataTransformationType + > + >("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// Configuration options for video transformations. + /// + public VideoTransformationReadyEventIntersectionMember1DataTransformationOptions? Options + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "options" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("options", value); + } + } + + /// + /// Information about the transformed output video. + /// + public Output? Output + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("output"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("output", value); + } + } + + /// + public override void Validate() + { + this.Type.Validate(); + this.Options?.Validate(); + this.Output?.Validate(); + } + + public VideoTransformationReadyEventIntersectionMember1DataTransformation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public VideoTransformationReadyEventIntersectionMember1DataTransformation( + VideoTransformationReadyEventIntersectionMember1DataTransformation videoTransformationReadyEventIntersectionMember1DataTransformation + ) + : base(videoTransformationReadyEventIntersectionMember1DataTransformation) { } +#pragma warning restore CS8618 + + public VideoTransformationReadyEventIntersectionMember1DataTransformation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + VideoTransformationReadyEventIntersectionMember1DataTransformation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static VideoTransformationReadyEventIntersectionMember1DataTransformation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public VideoTransformationReadyEventIntersectionMember1DataTransformation( + ApiEnum type + ) + : this() + { + this.Type = type; + } +} + +class VideoTransformationReadyEventIntersectionMember1DataTransformationFromRaw + : IFromRawJson +{ + /// + public VideoTransformationReadyEventIntersectionMember1DataTransformation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + VideoTransformationReadyEventIntersectionMember1DataTransformation.FromRawUnchecked( + rawData + ); +} + +/// +/// Type of video transformation: - `video-transformation`: Standard video processing +/// (resize, format conversion, etc.) - `gif-to-video`: Convert animated GIF to video +/// format - `video-thumbnail`: Generate thumbnail image from video +/// +[JsonConverter( + typeof(VideoTransformationReadyEventIntersectionMember1DataTransformationTypeConverter) +)] +public enum VideoTransformationReadyEventIntersectionMember1DataTransformationType +{ + VideoTransformation, + GifToVideo, + VideoThumbnail, +} + +sealed class VideoTransformationReadyEventIntersectionMember1DataTransformationTypeConverter + : JsonConverter +{ + public override VideoTransformationReadyEventIntersectionMember1DataTransformationType Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "video-transformation" => + VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + "gif-to-video" => + VideoTransformationReadyEventIntersectionMember1DataTransformationType.GifToVideo, + "video-thumbnail" => + VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoThumbnail, + _ => (VideoTransformationReadyEventIntersectionMember1DataTransformationType)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + VideoTransformationReadyEventIntersectionMember1DataTransformationType value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation => + "video-transformation", + VideoTransformationReadyEventIntersectionMember1DataTransformationType.GifToVideo => + "gif-to-video", + VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoThumbnail => + "video-thumbnail", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration options for video transformations. +/// +[JsonConverter( + typeof(JsonModelConverter< + VideoTransformationReadyEventIntersectionMember1DataTransformationOptions, + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFromRaw + >) +)] +public sealed record class VideoTransformationReadyEventIntersectionMember1DataTransformationOptions + : JsonModel +{ + /// + /// Audio codec used for encoding (aac or opus). + /// + public ApiEnum< + string, + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec + >? AudioCodec + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass< + ApiEnum< + string, + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec + > + >("audio_codec"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("audio_codec", value); + } + } + + /// + /// Whether to automatically rotate the video based on metadata. + /// + public bool? AutoRotate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("auto_rotate"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("auto_rotate", value); + } + } + + /// + /// Output format for the transformed video or thumbnail. + /// + public ApiEnum< + string, + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat + >? Format + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass< + ApiEnum< + string, + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat + > + >("format"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("format", value); + } + } + + /// + /// Quality setting for the output video. + /// + public long? Quality + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("quality"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("quality", value); + } + } + + /// + /// Streaming protocol for adaptive bitrate streaming. + /// + public ApiEnum< + string, + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol + >? StreamProtocol + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass< + ApiEnum< + string, + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol + > + >("stream_protocol"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("stream_protocol", value); + } + } + + /// + /// Array of quality representations for adaptive bitrate streaming. + /// + public IReadOnlyList? Variants + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>("variants"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "variants", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Video codec used for encoding (h264, vp9, or av1). + /// + public ApiEnum< + string, + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec + >? VideoCodec + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass< + ApiEnum< + string, + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec + > + >("video_codec"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("video_codec", value); + } + } + + /// + public override void Validate() + { + this.AudioCodec?.Validate(); + _ = this.AutoRotate; + this.Format?.Validate(); + _ = this.Quality; + this.StreamProtocol?.Validate(); + _ = this.Variants; + this.VideoCodec?.Validate(); + } + + public VideoTransformationReadyEventIntersectionMember1DataTransformationOptions() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public VideoTransformationReadyEventIntersectionMember1DataTransformationOptions( + VideoTransformationReadyEventIntersectionMember1DataTransformationOptions videoTransformationReadyEventIntersectionMember1DataTransformationOptions + ) + : base(videoTransformationReadyEventIntersectionMember1DataTransformationOptions) { } +#pragma warning restore CS8618 + + public VideoTransformationReadyEventIntersectionMember1DataTransformationOptions( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + VideoTransformationReadyEventIntersectionMember1DataTransformationOptions( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static VideoTransformationReadyEventIntersectionMember1DataTransformationOptions FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFromRaw + : IFromRawJson +{ + /// + public VideoTransformationReadyEventIntersectionMember1DataTransformationOptions FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + VideoTransformationReadyEventIntersectionMember1DataTransformationOptions.FromRawUnchecked( + rawData + ); +} + +/// +/// Audio codec used for encoding (aac or opus). +/// +[JsonConverter( + typeof(VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodecConverter) +)] +public enum VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec +{ + Aac, + Opus, +} + +sealed class VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodecConverter + : JsonConverter +{ + public override VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "aac" => + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + "opus" => + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Opus, + _ => + (VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec)( + -1 + ), + }; + } + + public override void Write( + Utf8JsonWriter writer, + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac => + "aac", + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Opus => + "opus", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Output format for the transformed video or thumbnail. +/// +[JsonConverter( + typeof(VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormatConverter) +)] +public enum VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat +{ + Mp4, + Webm, + Jpg, + Png, + Webp, +} + +sealed class VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormatConverter + : JsonConverter +{ + public override VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "mp4" => + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + "webm" => + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Webm, + "jpg" => + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Jpg, + "png" => + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Png, + "webp" => + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Webp, + _ => (VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat)( + -1 + ), + }; + } + + public override void Write( + Utf8JsonWriter writer, + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4 => + "mp4", + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Webm => + "webm", + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Jpg => + "jpg", + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Png => + "png", + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Webp => + "webp", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Streaming protocol for adaptive bitrate streaming. +/// +[JsonConverter( + typeof(VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocolConverter) +)] +public enum VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol +{ + Hls, + Dash, +} + +sealed class VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocolConverter + : JsonConverter +{ + public override VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "HLS" => + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + "DASH" => + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Dash, + _ => + (VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol)( + -1 + ), + }; + } + + public override void Write( + Utf8JsonWriter writer, + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls => + "HLS", + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Dash => + "DASH", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Video codec used for encoding (h264, vp9, or av1). +/// +[JsonConverter( + typeof(VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodecConverter) +)] +public enum VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec +{ + H264, + Vp9, + Av1, +} + +sealed class VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodecConverter + : JsonConverter +{ + public override VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "h264" => + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + "vp9" => + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.Vp9, + "av1" => + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.Av1, + _ => + (VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec)( + -1 + ), + }; + } + + public override void Write( + Utf8JsonWriter writer, + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264 => + "h264", + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.Vp9 => + "vp9", + VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.Av1 => + "av1", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Information about the transformed output video. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Output : JsonModel +{ + /// + /// URL to access the transformed video. + /// + public required string Url + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("url"); + } + init { this._rawData.Set("url", value); } + } + + /// + /// Metadata of the output video file. + /// + public VideoMetadata? VideoMetadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("video_metadata"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("video_metadata", value); + } + } + + /// + public override void Validate() + { + _ = this.Url; + this.VideoMetadata?.Validate(); + } + + public Output() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Output(Output output) + : base(output) { } +#pragma warning restore CS8618 + + public Output(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Output(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static Output FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public Output(string url) + : this() + { + this.Url = url; + } +} + +class OutputFromRaw : IFromRawJson +{ + /// + public Output FromRawUnchecked(IReadOnlyDictionary rawData) => + Output.FromRawUnchecked(rawData); +} + +/// +/// Metadata of the output video file. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class VideoMetadata : JsonModel +{ + /// + /// Bitrate of the output video in bits per second. + /// + public required long Bitrate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("bitrate"); + } + init { this._rawData.Set("bitrate", value); } + } + + /// + /// Duration of the output video in seconds. + /// + public required double Duration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("duration"); + } + init { this._rawData.Set("duration", value); } + } + + /// + /// Height of the output video in pixels. + /// + public required long Height + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("height"); + } + init { this._rawData.Set("height", value); } + } + + /// + /// Width of the output video in pixels. + /// + public required long Width + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("width"); + } + init { this._rawData.Set("width", value); } + } + + /// + public override void Validate() + { + _ = this.Bitrate; + _ = this.Duration; + _ = this.Height; + _ = this.Width; + } + + public VideoMetadata() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public VideoMetadata(VideoMetadata videoMetadata) + : base(videoMetadata) { } +#pragma warning restore CS8618 + + public VideoMetadata(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + VideoMetadata(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static VideoMetadata FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class VideoMetadataFromRaw : IFromRawJson +{ + /// + public VideoMetadata FromRawUnchecked(IReadOnlyDictionary rawData) => + VideoMetadata.FromRawUnchecked(rawData); +} + +/// +/// Information about the original request that triggered the video transformation. +/// +[JsonConverter( + typeof(JsonModelConverter< + VideoTransformationReadyEventIntersectionMember1Request, + VideoTransformationReadyEventIntersectionMember1RequestFromRaw + >) +)] +public sealed record class VideoTransformationReadyEventIntersectionMember1Request : JsonModel +{ + /// + /// Full URL of the transformation request that was submitted. + /// + public required string Url + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("url"); + } + init { this._rawData.Set("url", value); } + } + + /// + /// Unique identifier for the originating transformation request. + /// + public required string XRequestID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("x_request_id"); + } + init { this._rawData.Set("x_request_id", value); } + } + + /// + /// User-Agent header from the original request that triggered the transformation. + /// + public string? UserAgent + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("user_agent"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("user_agent", value); + } + } + + /// + public override void Validate() + { + _ = this.Url; + _ = this.XRequestID; + _ = this.UserAgent; + } + + public VideoTransformationReadyEventIntersectionMember1Request() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public VideoTransformationReadyEventIntersectionMember1Request( + VideoTransformationReadyEventIntersectionMember1Request videoTransformationReadyEventIntersectionMember1Request + ) + : base(videoTransformationReadyEventIntersectionMember1Request) { } +#pragma warning restore CS8618 + + public VideoTransformationReadyEventIntersectionMember1Request( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + VideoTransformationReadyEventIntersectionMember1Request( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static VideoTransformationReadyEventIntersectionMember1Request FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class VideoTransformationReadyEventIntersectionMember1RequestFromRaw + : IFromRawJson +{ + /// + public VideoTransformationReadyEventIntersectionMember1Request FromRawUnchecked( + IReadOnlyDictionary rawData + ) => VideoTransformationReadyEventIntersectionMember1Request.FromRawUnchecked(rawData); +} + +/// +/// Performance metrics for the transformation process. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Timings : JsonModel +{ + /// + /// Time spent downloading the source video from your origin or media library, + /// in milliseconds. + /// + public long? DownloadDuration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("download_duration"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("download_duration", value); + } + } + + /// + /// Time spent encoding the video, in milliseconds. + /// + public long? EncodingDuration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("encoding_duration"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("encoding_duration", value); + } + } + + /// + public override void Validate() + { + _ = this.DownloadDuration; + _ = this.EncodingDuration; + } + + public Timings() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Timings(Timings timings) + : base(timings) { } +#pragma warning restore CS8618 + + public Timings(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Timings(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static Timings FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TimingsFromRaw : IFromRawJson +{ + /// + public Timings FromRawUnchecked(IReadOnlyDictionary rawData) => + Timings.FromRawUnchecked(rawData); +} diff --git a/src/ImageKit/Services/AccountService.cs b/src/ImageKit/Services/AccountService.cs new file mode 100644 index 00000000..0e7a99b0 --- /dev/null +++ b/src/ImageKit/Services/AccountService.cs @@ -0,0 +1,92 @@ +using System; +using ImageKit.Core; +using ImageKit.Services.Accounts; + +namespace ImageKit.Services; + +/// +public sealed class AccountService : IAccountService +{ + readonly Lazy _withRawResponse; + + /// + public IAccountServiceWithRawResponse WithRawResponse + { + get { return _withRawResponse.Value; } + } + + readonly IImageKitClient _client; + + /// + public IAccountService WithOptions(Func modifier) + { + return new AccountService(this._client.WithOptions(modifier)); + } + + public AccountService(IImageKitClient client) + { + _client = client; + + _withRawResponse = new(() => new AccountServiceWithRawResponse(client.WithRawResponse)); + _usage = new(() => new UsageService(client)); + _origins = new(() => new OriginService(client)); + _urlEndpoints = new(() => new UrlEndpointService(client)); + } + + readonly Lazy _usage; + public IUsageService Usage + { + get { return _usage.Value; } + } + + readonly Lazy _origins; + public IOriginService Origins + { + get { return _origins.Value; } + } + + readonly Lazy _urlEndpoints; + public IUrlEndpointService UrlEndpoints + { + get { return _urlEndpoints.Value; } + } +} + +/// +public sealed class AccountServiceWithRawResponse : IAccountServiceWithRawResponse +{ + readonly IImageKitClientWithRawResponse _client; + + /// + public IAccountServiceWithRawResponse WithOptions(Func modifier) + { + return new AccountServiceWithRawResponse(this._client.WithOptions(modifier)); + } + + public AccountServiceWithRawResponse(IImageKitClientWithRawResponse client) + { + _client = client; + + _usage = new(() => new UsageServiceWithRawResponse(client)); + _origins = new(() => new OriginServiceWithRawResponse(client)); + _urlEndpoints = new(() => new UrlEndpointServiceWithRawResponse(client)); + } + + readonly Lazy _usage; + public IUsageServiceWithRawResponse Usage + { + get { return _usage.Value; } + } + + readonly Lazy _origins; + public IOriginServiceWithRawResponse Origins + { + get { return _origins.Value; } + } + + readonly Lazy _urlEndpoints; + public IUrlEndpointServiceWithRawResponse UrlEndpoints + { + get { return _urlEndpoints.Value; } + } +} diff --git a/src/ImageKit/Services/Accounts/IOriginService.cs b/src/ImageKit/Services/Accounts/IOriginService.cs new file mode 100644 index 00000000..d7bea064 --- /dev/null +++ b/src/ImageKit/Services/Accounts/IOriginService.cs @@ -0,0 +1,173 @@ +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using ImageKit.Core; +using ImageKit.Models.Accounts.Origins; + +namespace ImageKit.Services.Accounts; + +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking +/// changes in non-major versions. We may add new methods in the future that cause +/// existing derived classes to break. +/// +public interface IOriginService +{ + /// + /// Returns a view of this service that provides access to raw HTTP responses + /// for each method. + /// + IOriginServiceWithRawResponse WithRawResponse { get; } + + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + IOriginService WithOptions(Func modifier); + + /// + /// **Note:** This API is currently in beta. Creates a new origin and returns + /// the origin object. + /// + Task Create( + OriginCreateParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// **Note:** This API is currently in beta. Updates the origin identified by + /// `id` and returns the updated origin object. + /// + Task Update( + OriginUpdateParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task Update( + string id, + OriginUpdateParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// **Note:** This API is currently in beta. Returns an array of all configured + /// origins for the current account. + /// + Task> List( + OriginListParams? parameters = null, + CancellationToken cancellationToken = default + ); + + /// + /// **Note:** This API is currently in beta. Permanently removes the origin + /// identified by `id`. If the origin is in use by any URL‑endpoints, the API + /// will return an error. + /// + Task Delete(OriginDeleteParams parameters, CancellationToken cancellationToken = default); + + /// + Task Delete( + string id, + OriginDeleteParams? parameters = null, + CancellationToken cancellationToken = default + ); + + /// + /// **Note:** This API is currently in beta. Retrieves the origin identified + /// by `id`. + /// + Task Get( + OriginGetParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task Get( + string id, + OriginGetParams? parameters = null, + CancellationToken cancellationToken = default + ); +} + +/// +/// A view of that provides access to raw +/// HTTP responses for each method. +/// +public interface IOriginServiceWithRawResponse +{ + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + IOriginServiceWithRawResponse WithOptions(Func modifier); + + /// + /// Returns a raw HTTP response for `post /v1/accounts/origins`, but is otherwise the + /// same as . + /// + Task> Create( + OriginCreateParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// Returns a raw HTTP response for `put /v1/accounts/origins/{id}`, but is otherwise the + /// same as . + /// + Task> Update( + OriginUpdateParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task> Update( + string id, + OriginUpdateParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// Returns a raw HTTP response for `get /v1/accounts/origins`, but is otherwise the + /// same as . + /// + Task>> List( + OriginListParams? parameters = null, + CancellationToken cancellationToken = default + ); + + /// + /// Returns a raw HTTP response for `delete /v1/accounts/origins/{id}`, but is otherwise the + /// same as . + /// + Task Delete( + OriginDeleteParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task Delete( + string id, + OriginDeleteParams? parameters = null, + CancellationToken cancellationToken = default + ); + + /// + /// Returns a raw HTTP response for `get /v1/accounts/origins/{id}`, but is otherwise the + /// same as . + /// + Task> Get( + OriginGetParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task> Get( + string id, + OriginGetParams? parameters = null, + CancellationToken cancellationToken = default + ); +} diff --git a/src/ImageKit/Services/Accounts/IUrlEndpointService.cs b/src/ImageKit/Services/Accounts/IUrlEndpointService.cs new file mode 100644 index 00000000..3bce6320 --- /dev/null +++ b/src/ImageKit/Services/Accounts/IUrlEndpointService.cs @@ -0,0 +1,174 @@ +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using ImageKit.Core; +using ImageKit.Models.Accounts.UrlEndpoints; + +namespace ImageKit.Services.Accounts; + +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking +/// changes in non-major versions. We may add new methods in the future that cause +/// existing derived classes to break. +/// +public interface IUrlEndpointService +{ + /// + /// Returns a view of this service that provides access to raw HTTP responses + /// for each method. + /// + IUrlEndpointServiceWithRawResponse WithRawResponse { get; } + + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + IUrlEndpointService WithOptions(Func modifier); + + /// + /// **Note:** This API is currently in beta. Creates a new URL‑endpoint and + /// returns the resulting object. + /// + Task Create( + UrlEndpointCreateParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// **Note:** This API is currently in beta. Updates the URL‑endpoint identified + /// by `id` and returns the updated object. + /// + Task Update( + UrlEndpointUpdateParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task Update( + string id, + UrlEndpointUpdateParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// **Note:** This API is currently in beta. Returns an array of all URL‑endpoints + /// configured including the default URL-endpoint generated by ImageKit during + /// account creation. + /// + Task> List( + UrlEndpointListParams? parameters = null, + CancellationToken cancellationToken = default + ); + + /// + /// **Note:** This API is currently in beta. Deletes the URL‑endpoint identified + /// by `id`. You cannot delete the default URL‑endpoint created by ImageKit during + /// account creation. + /// + Task Delete(UrlEndpointDeleteParams parameters, CancellationToken cancellationToken = default); + + /// + Task Delete( + string id, + UrlEndpointDeleteParams? parameters = null, + CancellationToken cancellationToken = default + ); + + /// + /// **Note:** This API is currently in beta. Retrieves the URL‑endpoint identified + /// by `id`. + /// + Task Get( + UrlEndpointGetParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task Get( + string id, + UrlEndpointGetParams? parameters = null, + CancellationToken cancellationToken = default + ); +} + +/// +/// A view of that provides access to raw +/// HTTP responses for each method. +/// +public interface IUrlEndpointServiceWithRawResponse +{ + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + IUrlEndpointServiceWithRawResponse WithOptions(Func modifier); + + /// + /// Returns a raw HTTP response for `post /v1/accounts/url-endpoints`, but is otherwise the + /// same as . + /// + Task> Create( + UrlEndpointCreateParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// Returns a raw HTTP response for `put /v1/accounts/url-endpoints/{id}`, but is otherwise the + /// same as . + /// + Task> Update( + UrlEndpointUpdateParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task> Update( + string id, + UrlEndpointUpdateParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// Returns a raw HTTP response for `get /v1/accounts/url-endpoints`, but is otherwise the + /// same as . + /// + Task>> List( + UrlEndpointListParams? parameters = null, + CancellationToken cancellationToken = default + ); + + /// + /// Returns a raw HTTP response for `delete /v1/accounts/url-endpoints/{id}`, but is otherwise the + /// same as . + /// + Task Delete( + UrlEndpointDeleteParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task Delete( + string id, + UrlEndpointDeleteParams? parameters = null, + CancellationToken cancellationToken = default + ); + + /// + /// Returns a raw HTTP response for `get /v1/accounts/url-endpoints/{id}`, but is otherwise the + /// same as . + /// + Task> Get( + UrlEndpointGetParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task> Get( + string id, + UrlEndpointGetParams? parameters = null, + CancellationToken cancellationToken = default + ); +} diff --git a/src/ImageKit/Services/Accounts/IUsageService.cs b/src/ImageKit/Services/Accounts/IUsageService.cs new file mode 100644 index 00000000..dafe9f6b --- /dev/null +++ b/src/ImageKit/Services/Accounts/IUsageService.cs @@ -0,0 +1,62 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using ImageKit.Core; +using ImageKit.Models.Accounts.Usage; + +namespace ImageKit.Services.Accounts; + +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking +/// changes in non-major versions. We may add new methods in the future that cause +/// existing derived classes to break. +/// +public interface IUsageService +{ + /// + /// Returns a view of this service that provides access to raw HTTP responses + /// for each method. + /// + IUsageServiceWithRawResponse WithRawResponse { get; } + + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + IUsageService WithOptions(Func modifier); + + /// + /// Get the account usage information between two dates. Note that the API response + /// includes data from the start date while excluding data from the end date. + /// In other words, the data covers the period starting from the specified start + /// date up to, but not including, the end date. + /// + Task Get( + UsageGetParams parameters, + CancellationToken cancellationToken = default + ); +} + +/// +/// A view of that provides access to raw +/// HTTP responses for each method. +/// +public interface IUsageServiceWithRawResponse +{ + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + IUsageServiceWithRawResponse WithOptions(Func modifier); + + /// + /// Returns a raw HTTP response for `get /v1/accounts/usage`, but is otherwise the + /// same as . + /// + Task> Get( + UsageGetParams parameters, + CancellationToken cancellationToken = default + ); +} diff --git a/src/ImageKit/Services/Accounts/OriginService.cs b/src/ImageKit/Services/Accounts/OriginService.cs new file mode 100644 index 00000000..abb0fcd5 --- /dev/null +++ b/src/ImageKit/Services/Accounts/OriginService.cs @@ -0,0 +1,322 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; +using ImageKit.Core; +using ImageKit.Exceptions; +using ImageKit.Models.Accounts.Origins; + +namespace ImageKit.Services.Accounts; + +/// +public sealed class OriginService : IOriginService +{ + readonly Lazy _withRawResponse; + + /// + public IOriginServiceWithRawResponse WithRawResponse + { + get { return _withRawResponse.Value; } + } + + readonly IImageKitClient _client; + + /// + public IOriginService WithOptions(Func modifier) + { + return new OriginService(this._client.WithOptions(modifier)); + } + + public OriginService(IImageKitClient client) + { + _client = client; + + _withRawResponse = new(() => new OriginServiceWithRawResponse(client.WithRawResponse)); + } + + /// + public async Task Create( + OriginCreateParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.Create(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public async Task Update( + OriginUpdateParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.Update(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public Task Update( + string id, + OriginUpdateParams parameters, + CancellationToken cancellationToken = default + ) + { + return this.Update(parameters with { ID = id }, cancellationToken); + } + + /// + public async Task> List( + OriginListParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.List(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public Task Delete(OriginDeleteParams parameters, CancellationToken cancellationToken = default) + { + return this.WithRawResponse.Delete(parameters, cancellationToken); + } + + /// + public async Task Delete( + string id, + OriginDeleteParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + await this.Delete(parameters with { ID = id }, cancellationToken).ConfigureAwait(false); + } + + /// + public async Task Get( + OriginGetParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.Get(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public Task Get( + string id, + OriginGetParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + return this.Get(parameters with { ID = id }, cancellationToken); + } +} + +/// +public sealed class OriginServiceWithRawResponse : IOriginServiceWithRawResponse +{ + readonly IImageKitClientWithRawResponse _client; + + /// + public IOriginServiceWithRawResponse WithOptions(Func modifier) + { + return new OriginServiceWithRawResponse(this._client.WithOptions(modifier)); + } + + public OriginServiceWithRawResponse(IImageKitClientWithRawResponse client) + { + _client = client; + } + + /// + public async Task> Create( + OriginCreateParams parameters, + CancellationToken cancellationToken = default + ) + { + HttpRequest request = new() + { + Method = HttpMethod.Post, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var originResponse = await response + .Deserialize(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + originResponse.Validate(); + } + return originResponse; + } + ); + } + + /// + public async Task> Update( + OriginUpdateParams parameters, + CancellationToken cancellationToken = default + ) + { + if (parameters.ID == null) + { + throw new ImageKitInvalidDataException("'parameters.ID' cannot be null"); + } + + HttpRequest request = new() + { + Method = HttpMethod.Put, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var originResponse = await response + .Deserialize(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + originResponse.Validate(); + } + return originResponse; + } + ); + } + + /// + public Task> Update( + string id, + OriginUpdateParams parameters, + CancellationToken cancellationToken = default + ) + { + return this.Update(parameters with { ID = id }, cancellationToken); + } + + /// + public async Task>> List( + OriginListParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + HttpRequest request = new() + { + Method = HttpMethod.Get, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var originResponses = await response + .Deserialize>(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + foreach (var item in originResponses) + { + item.Validate(); + } + } + return originResponses; + } + ); + } + + /// + public Task Delete( + OriginDeleteParams parameters, + CancellationToken cancellationToken = default + ) + { + if (parameters.ID == null) + { + throw new ImageKitInvalidDataException("'parameters.ID' cannot be null"); + } + + HttpRequest request = new() + { + Method = HttpMethod.Delete, + Params = parameters, + }; + return this._client.Execute(request, cancellationToken); + } + + /// + public Task Delete( + string id, + OriginDeleteParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + return this.Delete(parameters with { ID = id }, cancellationToken); + } + + /// + public async Task> Get( + OriginGetParams parameters, + CancellationToken cancellationToken = default + ) + { + if (parameters.ID == null) + { + throw new ImageKitInvalidDataException("'parameters.ID' cannot be null"); + } + + HttpRequest request = new() + { + Method = HttpMethod.Get, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var originResponse = await response + .Deserialize(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + originResponse.Validate(); + } + return originResponse; + } + ); + } + + /// + public Task> Get( + string id, + OriginGetParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + return this.Get(parameters with { ID = id }, cancellationToken); + } +} diff --git a/src/ImageKit/Services/Accounts/UrlEndpointService.cs b/src/ImageKit/Services/Accounts/UrlEndpointService.cs new file mode 100644 index 00000000..a80a3bec --- /dev/null +++ b/src/ImageKit/Services/Accounts/UrlEndpointService.cs @@ -0,0 +1,327 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; +using ImageKit.Core; +using ImageKit.Exceptions; +using ImageKit.Models.Accounts.UrlEndpoints; + +namespace ImageKit.Services.Accounts; + +/// +public sealed class UrlEndpointService : IUrlEndpointService +{ + readonly Lazy _withRawResponse; + + /// + public IUrlEndpointServiceWithRawResponse WithRawResponse + { + get { return _withRawResponse.Value; } + } + + readonly IImageKitClient _client; + + /// + public IUrlEndpointService WithOptions(Func modifier) + { + return new UrlEndpointService(this._client.WithOptions(modifier)); + } + + public UrlEndpointService(IImageKitClient client) + { + _client = client; + + _withRawResponse = new(() => new UrlEndpointServiceWithRawResponse(client.WithRawResponse)); + } + + /// + public async Task Create( + UrlEndpointCreateParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.Create(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public async Task Update( + UrlEndpointUpdateParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.Update(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public Task Update( + string id, + UrlEndpointUpdateParams parameters, + CancellationToken cancellationToken = default + ) + { + return this.Update(parameters with { ID = id }, cancellationToken); + } + + /// + public async Task> List( + UrlEndpointListParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.List(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public Task Delete( + UrlEndpointDeleteParams parameters, + CancellationToken cancellationToken = default + ) + { + return this.WithRawResponse.Delete(parameters, cancellationToken); + } + + /// + public async Task Delete( + string id, + UrlEndpointDeleteParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + await this.Delete(parameters with { ID = id }, cancellationToken).ConfigureAwait(false); + } + + /// + public async Task Get( + UrlEndpointGetParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.Get(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public Task Get( + string id, + UrlEndpointGetParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + return this.Get(parameters with { ID = id }, cancellationToken); + } +} + +/// +public sealed class UrlEndpointServiceWithRawResponse : IUrlEndpointServiceWithRawResponse +{ + readonly IImageKitClientWithRawResponse _client; + + /// + public IUrlEndpointServiceWithRawResponse WithOptions( + Func modifier + ) + { + return new UrlEndpointServiceWithRawResponse(this._client.WithOptions(modifier)); + } + + public UrlEndpointServiceWithRawResponse(IImageKitClientWithRawResponse client) + { + _client = client; + } + + /// + public async Task> Create( + UrlEndpointCreateParams parameters, + CancellationToken cancellationToken = default + ) + { + HttpRequest request = new() + { + Method = HttpMethod.Post, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var urlEndpointResponse = await response + .Deserialize(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + urlEndpointResponse.Validate(); + } + return urlEndpointResponse; + } + ); + } + + /// + public async Task> Update( + UrlEndpointUpdateParams parameters, + CancellationToken cancellationToken = default + ) + { + if (parameters.ID == null) + { + throw new ImageKitInvalidDataException("'parameters.ID' cannot be null"); + } + + HttpRequest request = new() + { + Method = HttpMethod.Put, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var urlEndpointResponse = await response + .Deserialize(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + urlEndpointResponse.Validate(); + } + return urlEndpointResponse; + } + ); + } + + /// + public Task> Update( + string id, + UrlEndpointUpdateParams parameters, + CancellationToken cancellationToken = default + ) + { + return this.Update(parameters with { ID = id }, cancellationToken); + } + + /// + public async Task>> List( + UrlEndpointListParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + HttpRequest request = new() + { + Method = HttpMethod.Get, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var urlEndpointResponses = await response + .Deserialize>(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + foreach (var item in urlEndpointResponses) + { + item.Validate(); + } + } + return urlEndpointResponses; + } + ); + } + + /// + public Task Delete( + UrlEndpointDeleteParams parameters, + CancellationToken cancellationToken = default + ) + { + if (parameters.ID == null) + { + throw new ImageKitInvalidDataException("'parameters.ID' cannot be null"); + } + + HttpRequest request = new() + { + Method = HttpMethod.Delete, + Params = parameters, + }; + return this._client.Execute(request, cancellationToken); + } + + /// + public Task Delete( + string id, + UrlEndpointDeleteParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + return this.Delete(parameters with { ID = id }, cancellationToken); + } + + /// + public async Task> Get( + UrlEndpointGetParams parameters, + CancellationToken cancellationToken = default + ) + { + if (parameters.ID == null) + { + throw new ImageKitInvalidDataException("'parameters.ID' cannot be null"); + } + + HttpRequest request = new() + { + Method = HttpMethod.Get, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var urlEndpointResponse = await response + .Deserialize(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + urlEndpointResponse.Validate(); + } + return urlEndpointResponse; + } + ); + } + + /// + public Task> Get( + string id, + UrlEndpointGetParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + return this.Get(parameters with { ID = id }, cancellationToken); + } +} diff --git a/src/ImageKit/Services/Accounts/UsageService.cs b/src/ImageKit/Services/Accounts/UsageService.cs new file mode 100644 index 00000000..8fbec9c4 --- /dev/null +++ b/src/ImageKit/Services/Accounts/UsageService.cs @@ -0,0 +1,92 @@ +using System; +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; +using ImageKit.Core; +using ImageKit.Models.Accounts.Usage; + +namespace ImageKit.Services.Accounts; + +/// +public sealed class UsageService : IUsageService +{ + readonly Lazy _withRawResponse; + + /// + public IUsageServiceWithRawResponse WithRawResponse + { + get { return _withRawResponse.Value; } + } + + readonly IImageKitClient _client; + + /// + public IUsageService WithOptions(Func modifier) + { + return new UsageService(this._client.WithOptions(modifier)); + } + + public UsageService(IImageKitClient client) + { + _client = client; + + _withRawResponse = new(() => new UsageServiceWithRawResponse(client.WithRawResponse)); + } + + /// + public async Task Get( + UsageGetParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.Get(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } +} + +/// +public sealed class UsageServiceWithRawResponse : IUsageServiceWithRawResponse +{ + readonly IImageKitClientWithRawResponse _client; + + /// + public IUsageServiceWithRawResponse WithOptions(Func modifier) + { + return new UsageServiceWithRawResponse(this._client.WithOptions(modifier)); + } + + public UsageServiceWithRawResponse(IImageKitClientWithRawResponse client) + { + _client = client; + } + + /// + public async Task> Get( + UsageGetParams parameters, + CancellationToken cancellationToken = default + ) + { + HttpRequest request = new() + { + Method = HttpMethod.Get, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var usage = await response + .Deserialize(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + usage.Validate(); + } + return usage; + } + ); + } +} diff --git a/src/ImageKit/Services/AssetService.cs b/src/ImageKit/Services/AssetService.cs new file mode 100644 index 00000000..870e8bd5 --- /dev/null +++ b/src/ImageKit/Services/AssetService.cs @@ -0,0 +1,98 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; +using ImageKit.Core; +using ImageKit.Models.Assets; + +namespace ImageKit.Services; + +/// +public sealed class AssetService : IAssetService +{ + readonly Lazy _withRawResponse; + + /// + public IAssetServiceWithRawResponse WithRawResponse + { + get { return _withRawResponse.Value; } + } + + readonly IImageKitClient _client; + + /// + public IAssetService WithOptions(Func modifier) + { + return new AssetService(this._client.WithOptions(modifier)); + } + + public AssetService(IImageKitClient client) + { + _client = client; + + _withRawResponse = new(() => new AssetServiceWithRawResponse(client.WithRawResponse)); + } + + /// + public async Task> List( + AssetListParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.List(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } +} + +/// +public sealed class AssetServiceWithRawResponse : IAssetServiceWithRawResponse +{ + readonly IImageKitClientWithRawResponse _client; + + /// + public IAssetServiceWithRawResponse WithOptions(Func modifier) + { + return new AssetServiceWithRawResponse(this._client.WithOptions(modifier)); + } + + public AssetServiceWithRawResponse(IImageKitClientWithRawResponse client) + { + _client = client; + } + + /// + public async Task>> List( + AssetListParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + HttpRequest request = new() + { + Method = HttpMethod.Get, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var assets = await response + .Deserialize>(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + foreach (var item in assets) + { + item.Validate(); + } + } + return assets; + } + ); + } +} diff --git a/src/ImageKit/Services/Beta/IV2Service.cs b/src/ImageKit/Services/Beta/IV2Service.cs new file mode 100644 index 00000000..cf83670d --- /dev/null +++ b/src/ImageKit/Services/Beta/IV2Service.cs @@ -0,0 +1,44 @@ +using System; +using ImageKit.Core; +using V2 = ImageKit.Services.Beta.V2; + +namespace ImageKit.Services.Beta; + +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking +/// changes in non-major versions. We may add new methods in the future that cause +/// existing derived classes to break. +/// +public interface IV2Service +{ + /// + /// Returns a view of this service that provides access to raw HTTP responses + /// for each method. + /// + IV2ServiceWithRawResponse WithRawResponse { get; } + + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + IV2Service WithOptions(Func modifier); + + V2::IFileService Files { get; } +} + +/// +/// A view of that provides access to raw +/// HTTP responses for each method. +/// +public interface IV2ServiceWithRawResponse +{ + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + IV2ServiceWithRawResponse WithOptions(Func modifier); + + V2::IFileServiceWithRawResponse Files { get; } +} diff --git a/src/ImageKit/Services/Beta/V2/FileService.cs b/src/ImageKit/Services/Beta/V2/FileService.cs new file mode 100644 index 00000000..ccbe0a04 --- /dev/null +++ b/src/ImageKit/Services/Beta/V2/FileService.cs @@ -0,0 +1,92 @@ +using System; +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; +using ImageKit.Core; +using ImageKit.Models.Beta.V2.Files; + +namespace ImageKit.Services.Beta.V2; + +/// +public sealed class FileService : IFileService +{ + readonly Lazy _withRawResponse; + + /// + public IFileServiceWithRawResponse WithRawResponse + { + get { return _withRawResponse.Value; } + } + + readonly IImageKitClient _client; + + /// + public IFileService WithOptions(Func modifier) + { + return new FileService(this._client.WithOptions(modifier)); + } + + public FileService(IImageKitClient client) + { + _client = client; + + _withRawResponse = new(() => new FileServiceWithRawResponse(client.WithRawResponse)); + } + + /// + public async Task Upload( + FileUploadParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.Upload(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } +} + +/// +public sealed class FileServiceWithRawResponse : IFileServiceWithRawResponse +{ + readonly IImageKitClientWithRawResponse _client; + + /// + public IFileServiceWithRawResponse WithOptions(Func modifier) + { + return new FileServiceWithRawResponse(this._client.WithOptions(modifier)); + } + + public FileServiceWithRawResponse(IImageKitClientWithRawResponse client) + { + _client = client; + } + + /// + public async Task> Upload( + FileUploadParams parameters, + CancellationToken cancellationToken = default + ) + { + HttpRequest request = new() + { + Method = HttpMethod.Post, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var deserializedResponse = await response + .Deserialize(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + deserializedResponse.Validate(); + } + return deserializedResponse; + } + ); + } +} diff --git a/src/ImageKit/Services/Beta/V2/IFileService.cs b/src/ImageKit/Services/Beta/V2/IFileService.cs new file mode 100644 index 00000000..91af38d4 --- /dev/null +++ b/src/ImageKit/Services/Beta/V2/IFileService.cs @@ -0,0 +1,80 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using ImageKit.Core; +using ImageKit.Models.Beta.V2.Files; + +namespace ImageKit.Services.Beta.V2; + +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking +/// changes in non-major versions. We may add new methods in the future that cause +/// existing derived classes to break. +/// +public interface IFileService +{ + /// + /// Returns a view of this service that provides access to raw HTTP responses + /// for each method. + /// + IFileServiceWithRawResponse WithRawResponse { get; } + + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + IFileService WithOptions(Func modifier); + + /// + /// The V2 API enhances security by verifying the entire payload using JWT. This + /// API is in beta. + /// + /// ImageKit.io allows you to upload files directly from both the server + /// and client sides. For server-side uploads, private API key authentication + /// is used. For client-side uploads, generate a one-time `token` from your secure + /// backend using private API. [Learn more](/docs/api-reference/upload-file/upload-file-v2#how-to-implement-secure-client-side-file-upload) + /// about how to implement secure client-side file upload. + /// + /// **File size limit** \ On the free plan, the maximum upload file sizes + /// are 20MB for images, audio, and raw files, and 100MB for videos. On the paid + /// plan, these limits increase to 40MB for images, audio, and raw files, and + /// 2GB for videos. These limits can be further increased with higher-tier plans. + /// + /// **Version limit** \ A file can have a maximum of 100 versions. + /// + /// **Demo applications** + /// + /// - A full-fledged [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), + /// supporting file selections from local storage, URL, Dropbox, Google Drive, + /// Instagram, and more. - [Quick start guides](/docs/quick-start-guides) for + /// various frameworks and technologies. + /// + Task Upload( + FileUploadParams parameters, + CancellationToken cancellationToken = default + ); +} + +/// +/// A view of that provides access to raw +/// HTTP responses for each method. +/// +public interface IFileServiceWithRawResponse +{ + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + IFileServiceWithRawResponse WithOptions(Func modifier); + + /// + /// Returns a raw HTTP response for `post /api/v2/files/upload`, but is otherwise the + /// same as . + /// + Task> Upload( + FileUploadParams parameters, + CancellationToken cancellationToken = default + ); +} diff --git a/src/ImageKit/Services/Beta/V2Service.cs b/src/ImageKit/Services/Beta/V2Service.cs new file mode 100644 index 00000000..7e9ad558 --- /dev/null +++ b/src/ImageKit/Services/Beta/V2Service.cs @@ -0,0 +1,64 @@ +using System; +using ImageKit.Core; +using V2 = ImageKit.Services.Beta.V2; + +namespace ImageKit.Services.Beta; + +/// +public sealed class V2Service : IV2Service +{ + readonly Lazy _withRawResponse; + + /// + public IV2ServiceWithRawResponse WithRawResponse + { + get { return _withRawResponse.Value; } + } + + readonly IImageKitClient _client; + + /// + public IV2Service WithOptions(Func modifier) + { + return new V2Service(this._client.WithOptions(modifier)); + } + + public V2Service(IImageKitClient client) + { + _client = client; + + _withRawResponse = new(() => new V2ServiceWithRawResponse(client.WithRawResponse)); + _files = new(() => new V2::FileService(client)); + } + + readonly Lazy _files; + public V2::IFileService Files + { + get { return _files.Value; } + } +} + +/// +public sealed class V2ServiceWithRawResponse : IV2ServiceWithRawResponse +{ + readonly IImageKitClientWithRawResponse _client; + + /// + public IV2ServiceWithRawResponse WithOptions(Func modifier) + { + return new V2ServiceWithRawResponse(this._client.WithOptions(modifier)); + } + + public V2ServiceWithRawResponse(IImageKitClientWithRawResponse client) + { + _client = client; + + _files = new(() => new V2::FileServiceWithRawResponse(client)); + } + + readonly Lazy _files; + public V2::IFileServiceWithRawResponse Files + { + get { return _files.Value; } + } +} diff --git a/src/ImageKit/Services/BetaService.cs b/src/ImageKit/Services/BetaService.cs new file mode 100644 index 00000000..0221246f --- /dev/null +++ b/src/ImageKit/Services/BetaService.cs @@ -0,0 +1,64 @@ +using System; +using ImageKit.Core; +using ImageKit.Services.Beta; + +namespace ImageKit.Services; + +/// +public sealed class BetaService : IBetaService +{ + readonly Lazy _withRawResponse; + + /// + public IBetaServiceWithRawResponse WithRawResponse + { + get { return _withRawResponse.Value; } + } + + readonly IImageKitClient _client; + + /// + public IBetaService WithOptions(Func modifier) + { + return new BetaService(this._client.WithOptions(modifier)); + } + + public BetaService(IImageKitClient client) + { + _client = client; + + _withRawResponse = new(() => new BetaServiceWithRawResponse(client.WithRawResponse)); + _v2 = new(() => new V2Service(client)); + } + + readonly Lazy _v2; + public IV2Service V2 + { + get { return _v2.Value; } + } +} + +/// +public sealed class BetaServiceWithRawResponse : IBetaServiceWithRawResponse +{ + readonly IImageKitClientWithRawResponse _client; + + /// + public IBetaServiceWithRawResponse WithOptions(Func modifier) + { + return new BetaServiceWithRawResponse(this._client.WithOptions(modifier)); + } + + public BetaServiceWithRawResponse(IImageKitClientWithRawResponse client) + { + _client = client; + + _v2 = new(() => new V2ServiceWithRawResponse(client)); + } + + readonly Lazy _v2; + public IV2ServiceWithRawResponse V2 + { + get { return _v2.Value; } + } +} diff --git a/src/ImageKit/Services/Cache/IInvalidationService.cs b/src/ImageKit/Services/Cache/IInvalidationService.cs new file mode 100644 index 00000000..24c88e22 --- /dev/null +++ b/src/ImageKit/Services/Cache/IInvalidationService.cs @@ -0,0 +1,92 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using ImageKit.Core; +using ImageKit.Models.Cache.Invalidation; + +namespace ImageKit.Services.Cache; + +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking +/// changes in non-major versions. We may add new methods in the future that cause +/// existing derived classes to break. +/// +public interface IInvalidationService +{ + /// + /// Returns a view of this service that provides access to raw HTTP responses + /// for each method. + /// + IInvalidationServiceWithRawResponse WithRawResponse { get; } + + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + IInvalidationService WithOptions(Func modifier); + + /// + /// This API will purge CDN cache and ImageKit.io's internal cache for a file. + /// Note: Purge cache is an asynchronous process and it may take some time to + /// reflect the changes. + /// + Task Create( + InvalidationCreateParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// This API returns the status of a purge cache request. + /// + Task Get( + InvalidationGetParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task Get( + string requestID, + InvalidationGetParams? parameters = null, + CancellationToken cancellationToken = default + ); +} + +/// +/// A view of that provides access to raw +/// HTTP responses for each method. +/// +public interface IInvalidationServiceWithRawResponse +{ + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + IInvalidationServiceWithRawResponse WithOptions(Func modifier); + + /// + /// Returns a raw HTTP response for `post /v1/files/purge`, but is otherwise the + /// same as . + /// + Task> Create( + InvalidationCreateParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// Returns a raw HTTP response for `get /v1/files/purge/{requestId}`, but is otherwise the + /// same as . + /// + Task> Get( + InvalidationGetParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task> Get( + string requestID, + InvalidationGetParams? parameters = null, + CancellationToken cancellationToken = default + ); +} diff --git a/src/ImageKit/Services/Cache/InvalidationService.cs b/src/ImageKit/Services/Cache/InvalidationService.cs new file mode 100644 index 00000000..592264a0 --- /dev/null +++ b/src/ImageKit/Services/Cache/InvalidationService.cs @@ -0,0 +1,166 @@ +using System; +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; +using ImageKit.Core; +using ImageKit.Exceptions; +using ImageKit.Models.Cache.Invalidation; + +namespace ImageKit.Services.Cache; + +/// +public sealed class InvalidationService : IInvalidationService +{ + readonly Lazy _withRawResponse; + + /// + public IInvalidationServiceWithRawResponse WithRawResponse + { + get { return _withRawResponse.Value; } + } + + readonly IImageKitClient _client; + + /// + public IInvalidationService WithOptions(Func modifier) + { + return new InvalidationService(this._client.WithOptions(modifier)); + } + + public InvalidationService(IImageKitClient client) + { + _client = client; + + _withRawResponse = new(() => + new InvalidationServiceWithRawResponse(client.WithRawResponse) + ); + } + + /// + public async Task Create( + InvalidationCreateParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.Create(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public async Task Get( + InvalidationGetParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.Get(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public Task Get( + string requestID, + InvalidationGetParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + return this.Get(parameters with { RequestID = requestID }, cancellationToken); + } +} + +/// +public sealed class InvalidationServiceWithRawResponse : IInvalidationServiceWithRawResponse +{ + readonly IImageKitClientWithRawResponse _client; + + /// + public IInvalidationServiceWithRawResponse WithOptions( + Func modifier + ) + { + return new InvalidationServiceWithRawResponse(this._client.WithOptions(modifier)); + } + + public InvalidationServiceWithRawResponse(IImageKitClientWithRawResponse client) + { + _client = client; + } + + /// + public async Task> Create( + InvalidationCreateParams parameters, + CancellationToken cancellationToken = default + ) + { + HttpRequest request = new() + { + Method = HttpMethod.Post, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var invalidation = await response + .Deserialize(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + invalidation.Validate(); + } + return invalidation; + } + ); + } + + /// + public async Task> Get( + InvalidationGetParams parameters, + CancellationToken cancellationToken = default + ) + { + if (parameters.RequestID == null) + { + throw new ImageKitInvalidDataException("'parameters.RequestID' cannot be null"); + } + + HttpRequest request = new() + { + Method = HttpMethod.Get, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var invalidation = await response + .Deserialize(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + invalidation.Validate(); + } + return invalidation; + } + ); + } + + /// + public Task> Get( + string requestID, + InvalidationGetParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + return this.Get(parameters with { RequestID = requestID }, cancellationToken); + } +} diff --git a/src/ImageKit/Services/CacheService.cs b/src/ImageKit/Services/CacheService.cs new file mode 100644 index 00000000..84cf1d48 --- /dev/null +++ b/src/ImageKit/Services/CacheService.cs @@ -0,0 +1,64 @@ +using System; +using ImageKit.Core; +using ImageKit.Services.Cache; + +namespace ImageKit.Services; + +/// +public sealed class CacheService : ICacheService +{ + readonly Lazy _withRawResponse; + + /// + public ICacheServiceWithRawResponse WithRawResponse + { + get { return _withRawResponse.Value; } + } + + readonly IImageKitClient _client; + + /// + public ICacheService WithOptions(Func modifier) + { + return new CacheService(this._client.WithOptions(modifier)); + } + + public CacheService(IImageKitClient client) + { + _client = client; + + _withRawResponse = new(() => new CacheServiceWithRawResponse(client.WithRawResponse)); + _invalidation = new(() => new InvalidationService(client)); + } + + readonly Lazy _invalidation; + public IInvalidationService Invalidation + { + get { return _invalidation.Value; } + } +} + +/// +public sealed class CacheServiceWithRawResponse : ICacheServiceWithRawResponse +{ + readonly IImageKitClientWithRawResponse _client; + + /// + public ICacheServiceWithRawResponse WithOptions(Func modifier) + { + return new CacheServiceWithRawResponse(this._client.WithOptions(modifier)); + } + + public CacheServiceWithRawResponse(IImageKitClientWithRawResponse client) + { + _client = client; + + _invalidation = new(() => new InvalidationServiceWithRawResponse(client)); + } + + readonly Lazy _invalidation; + public IInvalidationServiceWithRawResponse Invalidation + { + get { return _invalidation.Value; } + } +} diff --git a/src/ImageKit/Services/CustomMetadataFieldService.cs b/src/ImageKit/Services/CustomMetadataFieldService.cs new file mode 100644 index 00000000..035bc598 --- /dev/null +++ b/src/ImageKit/Services/CustomMetadataFieldService.cs @@ -0,0 +1,282 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; +using ImageKit.Core; +using ImageKit.Exceptions; +using ImageKit.Models.CustomMetadataFields; + +namespace ImageKit.Services; + +/// +public sealed class CustomMetadataFieldService : ICustomMetadataFieldService +{ + readonly Lazy _withRawResponse; + + /// + public ICustomMetadataFieldServiceWithRawResponse WithRawResponse + { + get { return _withRawResponse.Value; } + } + + readonly IImageKitClient _client; + + /// + public ICustomMetadataFieldService WithOptions(Func modifier) + { + return new CustomMetadataFieldService(this._client.WithOptions(modifier)); + } + + public CustomMetadataFieldService(IImageKitClient client) + { + _client = client; + + _withRawResponse = new(() => + new CustomMetadataFieldServiceWithRawResponse(client.WithRawResponse) + ); + } + + /// + public async Task Create( + CustomMetadataFieldCreateParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.Create(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public async Task Update( + CustomMetadataFieldUpdateParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.Update(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public Task Update( + string id, + CustomMetadataFieldUpdateParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + return this.Update(parameters with { ID = id }, cancellationToken); + } + + /// + public async Task> List( + CustomMetadataFieldListParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.List(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public async Task Delete( + CustomMetadataFieldDeleteParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.Delete(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public Task Delete( + string id, + CustomMetadataFieldDeleteParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + return this.Delete(parameters with { ID = id }, cancellationToken); + } +} + +/// +public sealed class CustomMetadataFieldServiceWithRawResponse + : ICustomMetadataFieldServiceWithRawResponse +{ + readonly IImageKitClientWithRawResponse _client; + + /// + public ICustomMetadataFieldServiceWithRawResponse WithOptions( + Func modifier + ) + { + return new CustomMetadataFieldServiceWithRawResponse(this._client.WithOptions(modifier)); + } + + public CustomMetadataFieldServiceWithRawResponse(IImageKitClientWithRawResponse client) + { + _client = client; + } + + /// + public async Task> Create( + CustomMetadataFieldCreateParams parameters, + CancellationToken cancellationToken = default + ) + { + HttpRequest request = new() + { + Method = HttpMethod.Post, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var customMetadataField = await response + .Deserialize(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + customMetadataField.Validate(); + } + return customMetadataField; + } + ); + } + + /// + public async Task> Update( + CustomMetadataFieldUpdateParams parameters, + CancellationToken cancellationToken = default + ) + { + if (parameters.ID == null) + { + throw new ImageKitInvalidDataException("'parameters.ID' cannot be null"); + } + + HttpRequest request = new() + { + Method = ImageKitClientWithRawResponse.PatchMethod, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var customMetadataField = await response + .Deserialize(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + customMetadataField.Validate(); + } + return customMetadataField; + } + ); + } + + /// + public Task> Update( + string id, + CustomMetadataFieldUpdateParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + return this.Update(parameters with { ID = id }, cancellationToken); + } + + /// + public async Task>> List( + CustomMetadataFieldListParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + HttpRequest request = new() + { + Method = HttpMethod.Get, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var customMetadataFields = await response + .Deserialize>(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + foreach (var item in customMetadataFields) + { + item.Validate(); + } + } + return customMetadataFields; + } + ); + } + + /// + public async Task> Delete( + CustomMetadataFieldDeleteParams parameters, + CancellationToken cancellationToken = default + ) + { + if (parameters.ID == null) + { + throw new ImageKitInvalidDataException("'parameters.ID' cannot be null"); + } + + HttpRequest request = new() + { + Method = HttpMethod.Delete, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var customMetadataField = await response + .Deserialize(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + customMetadataField.Validate(); + } + return customMetadataField; + } + ); + } + + /// + public Task> Delete( + string id, + CustomMetadataFieldDeleteParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + return this.Delete(parameters with { ID = id }, cancellationToken); + } +} diff --git a/src/ImageKit/Services/FileService.cs b/src/ImageKit/Services/FileService.cs new file mode 100644 index 00000000..a06231d4 --- /dev/null +++ b/src/ImageKit/Services/FileService.cs @@ -0,0 +1,435 @@ +using System; +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; +using ImageKit.Core; +using ImageKit.Exceptions; +using ImageKit.Models.Files; +using ImageKit.Services.Files; + +namespace ImageKit.Services; + +/// +public sealed class FileService : IFileService +{ + readonly Lazy _withRawResponse; + + /// + public IFileServiceWithRawResponse WithRawResponse + { + get { return _withRawResponse.Value; } + } + + readonly IImageKitClient _client; + + /// + public IFileService WithOptions(Func modifier) + { + return new FileService(this._client.WithOptions(modifier)); + } + + public FileService(IImageKitClient client) + { + _client = client; + + _withRawResponse = new(() => new FileServiceWithRawResponse(client.WithRawResponse)); + _bulk = new(() => new BulkService(client)); + _versions = new(() => new VersionService(client)); + _metadata = new(() => new MetadataService(client)); + } + + readonly Lazy _bulk; + public IBulkService Bulk + { + get { return _bulk.Value; } + } + + readonly Lazy _versions; + public IVersionService Versions + { + get { return _versions.Value; } + } + + readonly Lazy _metadata; + public IMetadataService Metadata + { + get { return _metadata.Value; } + } + + /// + public async Task Update( + FileUpdateParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.Update(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public Task Update( + string fileID, + FileUpdateParams parameters, + CancellationToken cancellationToken = default + ) + { + return this.Update(parameters with { FileID = fileID }, cancellationToken); + } + + /// + public Task Delete(FileDeleteParams parameters, CancellationToken cancellationToken = default) + { + return this.WithRawResponse.Delete(parameters, cancellationToken); + } + + /// + public async Task Delete( + string fileID, + FileDeleteParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + await this.Delete(parameters with { FileID = fileID }, cancellationToken) + .ConfigureAwait(false); + } + + /// + public async Task Copy( + FileCopyParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.Copy(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public async Task Get( + FileGetParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.Get(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public Task Get( + string fileID, + FileGetParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + return this.Get(parameters with { FileID = fileID }, cancellationToken); + } + + /// + public async Task Move( + FileMoveParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.Move(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public async Task Rename( + FileRenameParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.Rename(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public async Task Upload( + FileUploadParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.Upload(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } +} + +/// +public sealed class FileServiceWithRawResponse : IFileServiceWithRawResponse +{ + readonly IImageKitClientWithRawResponse _client; + + /// + public IFileServiceWithRawResponse WithOptions(Func modifier) + { + return new FileServiceWithRawResponse(this._client.WithOptions(modifier)); + } + + public FileServiceWithRawResponse(IImageKitClientWithRawResponse client) + { + _client = client; + + _bulk = new(() => new BulkServiceWithRawResponse(client)); + _versions = new(() => new VersionServiceWithRawResponse(client)); + _metadata = new(() => new MetadataServiceWithRawResponse(client)); + } + + readonly Lazy _bulk; + public IBulkServiceWithRawResponse Bulk + { + get { return _bulk.Value; } + } + + readonly Lazy _versions; + public IVersionServiceWithRawResponse Versions + { + get { return _versions.Value; } + } + + readonly Lazy _metadata; + public IMetadataServiceWithRawResponse Metadata + { + get { return _metadata.Value; } + } + + /// + public async Task> Update( + FileUpdateParams parameters, + CancellationToken cancellationToken = default + ) + { + if (parameters.FileID == null) + { + throw new ImageKitInvalidDataException("'parameters.FileID' cannot be null"); + } + + HttpRequest request = new() + { + Method = ImageKitClientWithRawResponse.PatchMethod, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var file = await response + .Deserialize(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + file.Validate(); + } + return file; + } + ); + } + + /// + public Task> Update( + string fileID, + FileUpdateParams parameters, + CancellationToken cancellationToken = default + ) + { + return this.Update(parameters with { FileID = fileID }, cancellationToken); + } + + /// + public Task Delete( + FileDeleteParams parameters, + CancellationToken cancellationToken = default + ) + { + if (parameters.FileID == null) + { + throw new ImageKitInvalidDataException("'parameters.FileID' cannot be null"); + } + + HttpRequest request = new() + { + Method = HttpMethod.Delete, + Params = parameters, + }; + return this._client.Execute(request, cancellationToken); + } + + /// + public Task Delete( + string fileID, + FileDeleteParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + return this.Delete(parameters with { FileID = fileID }, cancellationToken); + } + + /// + public async Task> Copy( + FileCopyParams parameters, + CancellationToken cancellationToken = default + ) + { + HttpRequest request = new() + { + Method = HttpMethod.Post, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var deserializedResponse = await response + .Deserialize(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + deserializedResponse.Validate(); + } + return deserializedResponse; + } + ); + } + + /// + public async Task> Get( + FileGetParams parameters, + CancellationToken cancellationToken = default + ) + { + if (parameters.FileID == null) + { + throw new ImageKitInvalidDataException("'parameters.FileID' cannot be null"); + } + + HttpRequest request = new() { Method = HttpMethod.Get, Params = parameters }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var file = await response.Deserialize(token).ConfigureAwait(false); + if (this._client.ResponseValidation) + { + file.Validate(); + } + return file; + } + ); + } + + /// + public Task> Get( + string fileID, + FileGetParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + return this.Get(parameters with { FileID = fileID }, cancellationToken); + } + + /// + public async Task> Move( + FileMoveParams parameters, + CancellationToken cancellationToken = default + ) + { + HttpRequest request = new() + { + Method = HttpMethod.Post, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var deserializedResponse = await response + .Deserialize(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + deserializedResponse.Validate(); + } + return deserializedResponse; + } + ); + } + + /// + public async Task> Rename( + FileRenameParams parameters, + CancellationToken cancellationToken = default + ) + { + HttpRequest request = new() + { + Method = HttpMethod.Put, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var deserializedResponse = await response + .Deserialize(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + deserializedResponse.Validate(); + } + return deserializedResponse; + } + ); + } + + /// + public async Task> Upload( + FileUploadParams parameters, + CancellationToken cancellationToken = default + ) + { + HttpRequest request = new() + { + Method = HttpMethod.Post, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var deserializedResponse = await response + .Deserialize(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + deserializedResponse.Validate(); + } + return deserializedResponse; + } + ); + } +} diff --git a/src/ImageKit/Services/Files/BulkService.cs b/src/ImageKit/Services/Files/BulkService.cs new file mode 100644 index 00000000..ef0d821e --- /dev/null +++ b/src/ImageKit/Services/Files/BulkService.cs @@ -0,0 +1,212 @@ +using System; +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; +using ImageKit.Core; +using ImageKit.Models.Files.Bulk; + +namespace ImageKit.Services.Files; + +/// +public sealed class BulkService : IBulkService +{ + readonly Lazy _withRawResponse; + + /// + public IBulkServiceWithRawResponse WithRawResponse + { + get { return _withRawResponse.Value; } + } + + readonly IImageKitClient _client; + + /// + public IBulkService WithOptions(Func modifier) + { + return new BulkService(this._client.WithOptions(modifier)); + } + + public BulkService(IImageKitClient client) + { + _client = client; + + _withRawResponse = new(() => new BulkServiceWithRawResponse(client.WithRawResponse)); + } + + /// + public async Task Delete( + BulkDeleteParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.Delete(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public async Task AddTags( + BulkAddTagsParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.AddTags(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public async Task RemoveAITags( + BulkRemoveAITagsParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.RemoveAITags(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public async Task RemoveTags( + BulkRemoveTagsParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.RemoveTags(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } +} + +/// +public sealed class BulkServiceWithRawResponse : IBulkServiceWithRawResponse +{ + readonly IImageKitClientWithRawResponse _client; + + /// + public IBulkServiceWithRawResponse WithOptions(Func modifier) + { + return new BulkServiceWithRawResponse(this._client.WithOptions(modifier)); + } + + public BulkServiceWithRawResponse(IImageKitClientWithRawResponse client) + { + _client = client; + } + + /// + public async Task> Delete( + BulkDeleteParams parameters, + CancellationToken cancellationToken = default + ) + { + HttpRequest request = new() + { + Method = HttpMethod.Post, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var bulk = await response + .Deserialize(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + bulk.Validate(); + } + return bulk; + } + ); + } + + /// + public async Task> AddTags( + BulkAddTagsParams parameters, + CancellationToken cancellationToken = default + ) + { + HttpRequest request = new() + { + Method = HttpMethod.Post, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var deserializedResponse = await response + .Deserialize(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + deserializedResponse.Validate(); + } + return deserializedResponse; + } + ); + } + + /// + public async Task> RemoveAITags( + BulkRemoveAITagsParams parameters, + CancellationToken cancellationToken = default + ) + { + HttpRequest request = new() + { + Method = HttpMethod.Post, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var deserializedResponse = await response + .Deserialize(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + deserializedResponse.Validate(); + } + return deserializedResponse; + } + ); + } + + /// + public async Task> RemoveTags( + BulkRemoveTagsParams parameters, + CancellationToken cancellationToken = default + ) + { + HttpRequest request = new() + { + Method = HttpMethod.Post, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var deserializedResponse = await response + .Deserialize(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + deserializedResponse.Validate(); + } + return deserializedResponse; + } + ); + } +} diff --git a/src/ImageKit/Services/Files/IBulkService.cs b/src/ImageKit/Services/Files/IBulkService.cs new file mode 100644 index 00000000..0a410525 --- /dev/null +++ b/src/ImageKit/Services/Files/IBulkService.cs @@ -0,0 +1,119 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using ImageKit.Core; +using ImageKit.Models.Files.Bulk; + +namespace ImageKit.Services.Files; + +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking +/// changes in non-major versions. We may add new methods in the future that cause +/// existing derived classes to break. +/// +public interface IBulkService +{ + /// + /// Returns a view of this service that provides access to raw HTTP responses + /// for each method. + /// + IBulkServiceWithRawResponse WithRawResponse { get; } + + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + IBulkService WithOptions(Func modifier); + + /// + /// This API deletes multiple files and all their file versions permanently. + /// + /// Note: If a file or specific transformation has been requested in the + /// past, then the response is cached. Deleting a file does not purge the cache. + /// You can purge the cache using purge cache API. + /// + /// A maximum of 100 files can be deleted at a time. + /// + Task Delete( + BulkDeleteParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// This API adds tags to multiple files in bulk. A maximum of 50 files can be + /// specified at a time. + /// + Task AddTags( + BulkAddTagsParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// This API removes AITags from multiple files in bulk. A maximum of 50 files + /// can be specified at a time. + /// + Task RemoveAITags( + BulkRemoveAITagsParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// This API removes tags from multiple files in bulk. A maximum of 50 files + /// can be specified at a time. + /// + Task RemoveTags( + BulkRemoveTagsParams parameters, + CancellationToken cancellationToken = default + ); +} + +/// +/// A view of that provides access to raw +/// HTTP responses for each method. +/// +public interface IBulkServiceWithRawResponse +{ + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + IBulkServiceWithRawResponse WithOptions(Func modifier); + + /// + /// Returns a raw HTTP response for `post /v1/files/batch/deleteByFileIds`, but is otherwise the + /// same as . + /// + Task> Delete( + BulkDeleteParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// Returns a raw HTTP response for `post /v1/files/addTags`, but is otherwise the + /// same as . + /// + Task> AddTags( + BulkAddTagsParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// Returns a raw HTTP response for `post /v1/files/removeAITags`, but is otherwise the + /// same as . + /// + Task> RemoveAITags( + BulkRemoveAITagsParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// Returns a raw HTTP response for `post /v1/files/removeTags`, but is otherwise the + /// same as . + /// + Task> RemoveTags( + BulkRemoveTagsParams parameters, + CancellationToken cancellationToken = default + ); +} diff --git a/src/ImageKit/Services/Files/IMetadataService.cs b/src/ImageKit/Services/Files/IMetadataService.cs new file mode 100644 index 00000000..31b7c3da --- /dev/null +++ b/src/ImageKit/Services/Files/IMetadataService.cs @@ -0,0 +1,96 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using ImageKit.Core; +using ImageKit.Models.Files; +using ImageKit.Models.Files.Metadata; + +namespace ImageKit.Services.Files; + +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking +/// changes in non-major versions. We may add new methods in the future that cause +/// existing derived classes to break. +/// +public interface IMetadataService +{ + /// + /// Returns a view of this service that provides access to raw HTTP responses + /// for each method. + /// + IMetadataServiceWithRawResponse WithRawResponse { get; } + + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + IMetadataService WithOptions(Func modifier); + + /// + /// You can programmatically get image EXIF, pHash, and other metadata for uploaded + /// files in the ImageKit.io media library using this API. + /// + /// You can also get the metadata in upload API response by passing `metadata` + /// in `responseFields` parameter. + /// + Task Get( + MetadataGetParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task Get( + string fileID, + MetadataGetParams? parameters = null, + CancellationToken cancellationToken = default + ); + + /// + /// Get image EXIF, pHash, and other metadata from ImageKit.io powered remote + /// URL using this API. + /// + Task GetFromUrl( + MetadataGetFromUrlParams parameters, + CancellationToken cancellationToken = default + ); +} + +/// +/// A view of that provides access to raw +/// HTTP responses for each method. +/// +public interface IMetadataServiceWithRawResponse +{ + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + IMetadataServiceWithRawResponse WithOptions(Func modifier); + + /// + /// Returns a raw HTTP response for `get /v1/files/{fileId}/metadata`, but is otherwise the + /// same as . + /// + Task> Get( + MetadataGetParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task> Get( + string fileID, + MetadataGetParams? parameters = null, + CancellationToken cancellationToken = default + ); + + /// + /// Returns a raw HTTP response for `get /v1/metadata`, but is otherwise the + /// same as . + /// + Task> GetFromUrl( + MetadataGetFromUrlParams parameters, + CancellationToken cancellationToken = default + ); +} diff --git a/src/ImageKit/Services/Files/IVersionService.cs b/src/ImageKit/Services/Files/IVersionService.cs new file mode 100644 index 00000000..0f567cc9 --- /dev/null +++ b/src/ImageKit/Services/Files/IVersionService.cs @@ -0,0 +1,169 @@ +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using ImageKit.Core; +using ImageKit.Models.Files; +using ImageKit.Models.Files.Versions; + +namespace ImageKit.Services.Files; + +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking +/// changes in non-major versions. We may add new methods in the future that cause +/// existing derived classes to break. +/// +public interface IVersionService +{ + /// + /// Returns a view of this service that provides access to raw HTTP responses + /// for each method. + /// + IVersionServiceWithRawResponse WithRawResponse { get; } + + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + IVersionService WithOptions(Func modifier); + + /// + /// This API returns details of all versions of a file. + /// + Task> List( + VersionListParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task> List( + string fileID, + VersionListParams? parameters = null, + CancellationToken cancellationToken = default + ); + + /// + /// This API deletes a non-current file version permanently. The API returns an + /// empty response. + /// + /// Note: If you want to delete all versions of a file, use the delete + /// file API. + /// + Task Delete( + VersionDeleteParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task Delete( + string versionID, + VersionDeleteParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// This API returns an object with details or attributes of a file version. + /// + Task Get(VersionGetParams parameters, CancellationToken cancellationToken = default); + + /// + Task Get( + string versionID, + VersionGetParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// This API restores a file version as the current file version. + /// + Task Restore( + VersionRestoreParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task Restore( + string versionID, + VersionRestoreParams parameters, + CancellationToken cancellationToken = default + ); +} + +/// +/// A view of that provides access to raw +/// HTTP responses for each method. +/// +public interface IVersionServiceWithRawResponse +{ + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + IVersionServiceWithRawResponse WithOptions(Func modifier); + + /// + /// Returns a raw HTTP response for `get /v1/files/{fileId}/versions`, but is otherwise the + /// same as . + /// + Task>> List( + VersionListParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task>> List( + string fileID, + VersionListParams? parameters = null, + CancellationToken cancellationToken = default + ); + + /// + /// Returns a raw HTTP response for `delete /v1/files/{fileId}/versions/{versionId}`, but is otherwise the + /// same as . + /// + Task> Delete( + VersionDeleteParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task> Delete( + string versionID, + VersionDeleteParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// Returns a raw HTTP response for `get /v1/files/{fileId}/versions/{versionId}`, but is otherwise the + /// same as . + /// + Task> Get( + VersionGetParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task> Get( + string versionID, + VersionGetParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// Returns a raw HTTP response for `put /v1/files/{fileId}/versions/{versionId}/restore`, but is otherwise the + /// same as . + /// + Task> Restore( + VersionRestoreParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task> Restore( + string versionID, + VersionRestoreParams parameters, + CancellationToken cancellationToken = default + ); +} diff --git a/src/ImageKit/Services/Files/MetadataService.cs b/src/ImageKit/Services/Files/MetadataService.cs new file mode 100644 index 00000000..bcae4d76 --- /dev/null +++ b/src/ImageKit/Services/Files/MetadataService.cs @@ -0,0 +1,163 @@ +using System; +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; +using ImageKit.Core; +using ImageKit.Exceptions; +using ImageKit.Models.Files; +using ImageKit.Models.Files.Metadata; + +namespace ImageKit.Services.Files; + +/// +public sealed class MetadataService : IMetadataService +{ + readonly Lazy _withRawResponse; + + /// + public IMetadataServiceWithRawResponse WithRawResponse + { + get { return _withRawResponse.Value; } + } + + readonly IImageKitClient _client; + + /// + public IMetadataService WithOptions(Func modifier) + { + return new MetadataService(this._client.WithOptions(modifier)); + } + + public MetadataService(IImageKitClient client) + { + _client = client; + + _withRawResponse = new(() => new MetadataServiceWithRawResponse(client.WithRawResponse)); + } + + /// + public async Task Get( + MetadataGetParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.Get(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public Task Get( + string fileID, + MetadataGetParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + return this.Get(parameters with { FileID = fileID }, cancellationToken); + } + + /// + public async Task GetFromUrl( + MetadataGetFromUrlParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.GetFromUrl(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } +} + +/// +public sealed class MetadataServiceWithRawResponse : IMetadataServiceWithRawResponse +{ + readonly IImageKitClientWithRawResponse _client; + + /// + public IMetadataServiceWithRawResponse WithOptions(Func modifier) + { + return new MetadataServiceWithRawResponse(this._client.WithOptions(modifier)); + } + + public MetadataServiceWithRawResponse(IImageKitClientWithRawResponse client) + { + _client = client; + } + + /// + public async Task> Get( + MetadataGetParams parameters, + CancellationToken cancellationToken = default + ) + { + if (parameters.FileID == null) + { + throw new ImageKitInvalidDataException("'parameters.FileID' cannot be null"); + } + + HttpRequest request = new() + { + Method = HttpMethod.Get, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var metadata = await response + .Deserialize(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + metadata.Validate(); + } + return metadata; + } + ); + } + + /// + public Task> Get( + string fileID, + MetadataGetParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + return this.Get(parameters with { FileID = fileID }, cancellationToken); + } + + /// + public async Task> GetFromUrl( + MetadataGetFromUrlParams parameters, + CancellationToken cancellationToken = default + ) + { + HttpRequest request = new() + { + Method = HttpMethod.Get, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var metadata = await response + .Deserialize(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + metadata.Validate(); + } + return metadata; + } + ); + } +} diff --git a/src/ImageKit/Services/Files/VersionService.cs b/src/ImageKit/Services/Files/VersionService.cs new file mode 100644 index 00000000..5d4e68cd --- /dev/null +++ b/src/ImageKit/Services/Files/VersionService.cs @@ -0,0 +1,316 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; +using ImageKit.Core; +using ImageKit.Exceptions; +using ImageKit.Models.Files; +using ImageKit.Models.Files.Versions; + +namespace ImageKit.Services.Files; + +/// +public sealed class VersionService : IVersionService +{ + readonly Lazy _withRawResponse; + + /// + public IVersionServiceWithRawResponse WithRawResponse + { + get { return _withRawResponse.Value; } + } + + readonly IImageKitClient _client; + + /// + public IVersionService WithOptions(Func modifier) + { + return new VersionService(this._client.WithOptions(modifier)); + } + + public VersionService(IImageKitClient client) + { + _client = client; + + _withRawResponse = new(() => new VersionServiceWithRawResponse(client.WithRawResponse)); + } + + /// + public async Task> List( + VersionListParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.List(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public Task> List( + string fileID, + VersionListParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + return this.List(parameters with { FileID = fileID }, cancellationToken); + } + + /// + public async Task Delete( + VersionDeleteParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.Delete(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public Task Delete( + string versionID, + VersionDeleteParams parameters, + CancellationToken cancellationToken = default + ) + { + return this.Delete(parameters with { VersionID = versionID }, cancellationToken); + } + + /// + public async Task Get( + VersionGetParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.Get(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public Task Get( + string versionID, + VersionGetParams parameters, + CancellationToken cancellationToken = default + ) + { + return this.Get(parameters with { VersionID = versionID }, cancellationToken); + } + + /// + public async Task Restore( + VersionRestoreParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.Restore(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public Task Restore( + string versionID, + VersionRestoreParams parameters, + CancellationToken cancellationToken = default + ) + { + return this.Restore(parameters with { VersionID = versionID }, cancellationToken); + } +} + +/// +public sealed class VersionServiceWithRawResponse : IVersionServiceWithRawResponse +{ + readonly IImageKitClientWithRawResponse _client; + + /// + public IVersionServiceWithRawResponse WithOptions(Func modifier) + { + return new VersionServiceWithRawResponse(this._client.WithOptions(modifier)); + } + + public VersionServiceWithRawResponse(IImageKitClientWithRawResponse client) + { + _client = client; + } + + /// + public async Task>> List( + VersionListParams parameters, + CancellationToken cancellationToken = default + ) + { + if (parameters.FileID == null) + { + throw new ImageKitInvalidDataException("'parameters.FileID' cannot be null"); + } + + HttpRequest request = new() + { + Method = HttpMethod.Get, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var files = await response.Deserialize>(token).ConfigureAwait(false); + if (this._client.ResponseValidation) + { + foreach (var item in files) + { + item.Validate(); + } + } + return files; + } + ); + } + + /// + public Task>> List( + string fileID, + VersionListParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + return this.List(parameters with { FileID = fileID }, cancellationToken); + } + + /// + public async Task> Delete( + VersionDeleteParams parameters, + CancellationToken cancellationToken = default + ) + { + if (parameters.VersionID == null) + { + throw new ImageKitInvalidDataException("'parameters.VersionID' cannot be null"); + } + + HttpRequest request = new() + { + Method = HttpMethod.Delete, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var version = await response + .Deserialize(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + version.Validate(); + } + return version; + } + ); + } + + /// + public Task> Delete( + string versionID, + VersionDeleteParams parameters, + CancellationToken cancellationToken = default + ) + { + return this.Delete(parameters with { VersionID = versionID }, cancellationToken); + } + + /// + public async Task> Get( + VersionGetParams parameters, + CancellationToken cancellationToken = default + ) + { + if (parameters.VersionID == null) + { + throw new ImageKitInvalidDataException("'parameters.VersionID' cannot be null"); + } + + HttpRequest request = new() + { + Method = HttpMethod.Get, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var file = await response.Deserialize(token).ConfigureAwait(false); + if (this._client.ResponseValidation) + { + file.Validate(); + } + return file; + } + ); + } + + /// + public Task> Get( + string versionID, + VersionGetParams parameters, + CancellationToken cancellationToken = default + ) + { + return this.Get(parameters with { VersionID = versionID }, cancellationToken); + } + + /// + public async Task> Restore( + VersionRestoreParams parameters, + CancellationToken cancellationToken = default + ) + { + if (parameters.VersionID == null) + { + throw new ImageKitInvalidDataException("'parameters.VersionID' cannot be null"); + } + + HttpRequest request = new() + { + Method = HttpMethod.Put, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var file = await response.Deserialize(token).ConfigureAwait(false); + if (this._client.ResponseValidation) + { + file.Validate(); + } + return file; + } + ); + } + + /// + public Task> Restore( + string versionID, + VersionRestoreParams parameters, + CancellationToken cancellationToken = default + ) + { + return this.Restore(parameters with { VersionID = versionID }, cancellationToken); + } +} diff --git a/src/ImageKit/Services/FolderService.cs b/src/ImageKit/Services/FolderService.cs new file mode 100644 index 00000000..2c35a6e0 --- /dev/null +++ b/src/ImageKit/Services/FolderService.cs @@ -0,0 +1,268 @@ +using System; +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; +using ImageKit.Core; +using ImageKit.Models.Folders; +using ImageKit.Services.Folders; + +namespace ImageKit.Services; + +/// +public sealed class FolderService : IFolderService +{ + readonly Lazy _withRawResponse; + + /// + public IFolderServiceWithRawResponse WithRawResponse + { + get { return _withRawResponse.Value; } + } + + readonly IImageKitClient _client; + + /// + public IFolderService WithOptions(Func modifier) + { + return new FolderService(this._client.WithOptions(modifier)); + } + + public FolderService(IImageKitClient client) + { + _client = client; + + _withRawResponse = new(() => new FolderServiceWithRawResponse(client.WithRawResponse)); + _job = new(() => new JobService(client)); + } + + readonly Lazy _job; + public IJobService Job + { + get { return _job.Value; } + } + + /// + public async Task Create( + FolderCreateParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.Create(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public async Task Delete( + FolderDeleteParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.Delete(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public async Task Copy( + FolderCopyParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.Copy(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public async Task Move( + FolderMoveParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.Move(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public async Task Rename( + FolderRenameParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.Rename(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } +} + +/// +public sealed class FolderServiceWithRawResponse : IFolderServiceWithRawResponse +{ + readonly IImageKitClientWithRawResponse _client; + + /// + public IFolderServiceWithRawResponse WithOptions(Func modifier) + { + return new FolderServiceWithRawResponse(this._client.WithOptions(modifier)); + } + + public FolderServiceWithRawResponse(IImageKitClientWithRawResponse client) + { + _client = client; + + _job = new(() => new JobServiceWithRawResponse(client)); + } + + readonly Lazy _job; + public IJobServiceWithRawResponse Job + { + get { return _job.Value; } + } + + /// + public async Task> Create( + FolderCreateParams parameters, + CancellationToken cancellationToken = default + ) + { + HttpRequest request = new() + { + Method = HttpMethod.Post, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var folder = await response + .Deserialize(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + folder.Validate(); + } + return folder; + } + ); + } + + /// + public async Task> Delete( + FolderDeleteParams parameters, + CancellationToken cancellationToken = default + ) + { + HttpRequest request = new() + { + Method = HttpMethod.Delete, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var folder = await response + .Deserialize(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + folder.Validate(); + } + return folder; + } + ); + } + + /// + public async Task> Copy( + FolderCopyParams parameters, + CancellationToken cancellationToken = default + ) + { + HttpRequest request = new() + { + Method = HttpMethod.Post, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var deserializedResponse = await response + .Deserialize(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + deserializedResponse.Validate(); + } + return deserializedResponse; + } + ); + } + + /// + public async Task> Move( + FolderMoveParams parameters, + CancellationToken cancellationToken = default + ) + { + HttpRequest request = new() + { + Method = HttpMethod.Post, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var deserializedResponse = await response + .Deserialize(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + deserializedResponse.Validate(); + } + return deserializedResponse; + } + ); + } + + /// + public async Task> Rename( + FolderRenameParams parameters, + CancellationToken cancellationToken = default + ) + { + HttpRequest request = new() + { + Method = HttpMethod.Post, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var deserializedResponse = await response + .Deserialize(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + deserializedResponse.Validate(); + } + return deserializedResponse; + } + ); + } +} diff --git a/src/ImageKit/Services/Folders/IJobService.cs b/src/ImageKit/Services/Folders/IJobService.cs new file mode 100644 index 00000000..ca1a58cd --- /dev/null +++ b/src/ImageKit/Services/Folders/IJobService.cs @@ -0,0 +1,73 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using ImageKit.Core; +using ImageKit.Models.Folders.Job; + +namespace ImageKit.Services.Folders; + +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking +/// changes in non-major versions. We may add new methods in the future that cause +/// existing derived classes to break. +/// +public interface IJobService +{ + /// + /// Returns a view of this service that provides access to raw HTTP responses + /// for each method. + /// + IJobServiceWithRawResponse WithRawResponse { get; } + + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + IJobService WithOptions(Func modifier); + + /// + /// This API returns the status of a bulk job like copy and move folder operations. + /// + Task Get( + JobGetParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task Get( + string jobID, + JobGetParams? parameters = null, + CancellationToken cancellationToken = default + ); +} + +/// +/// A view of that provides access to raw +/// HTTP responses for each method. +/// +public interface IJobServiceWithRawResponse +{ + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + IJobServiceWithRawResponse WithOptions(Func modifier); + + /// + /// Returns a raw HTTP response for `get /v1/bulkJobs/{jobId}`, but is otherwise the + /// same as . + /// + Task> Get( + JobGetParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task> Get( + string jobID, + JobGetParams? parameters = null, + CancellationToken cancellationToken = default + ); +} diff --git a/src/ImageKit/Services/Folders/JobService.cs b/src/ImageKit/Services/Folders/JobService.cs new file mode 100644 index 00000000..65aa1ec8 --- /dev/null +++ b/src/ImageKit/Services/Folders/JobService.cs @@ -0,0 +1,116 @@ +using System; +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; +using ImageKit.Core; +using ImageKit.Exceptions; +using ImageKit.Models.Folders.Job; + +namespace ImageKit.Services.Folders; + +/// +public sealed class JobService : IJobService +{ + readonly Lazy _withRawResponse; + + /// + public IJobServiceWithRawResponse WithRawResponse + { + get { return _withRawResponse.Value; } + } + + readonly IImageKitClient _client; + + /// + public IJobService WithOptions(Func modifier) + { + return new JobService(this._client.WithOptions(modifier)); + } + + public JobService(IImageKitClient client) + { + _client = client; + + _withRawResponse = new(() => new JobServiceWithRawResponse(client.WithRawResponse)); + } + + /// + public async Task Get( + JobGetParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.Get(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public Task Get( + string jobID, + JobGetParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + return this.Get(parameters with { JobID = jobID }, cancellationToken); + } +} + +/// +public sealed class JobServiceWithRawResponse : IJobServiceWithRawResponse +{ + readonly IImageKitClientWithRawResponse _client; + + /// + public IJobServiceWithRawResponse WithOptions(Func modifier) + { + return new JobServiceWithRawResponse(this._client.WithOptions(modifier)); + } + + public JobServiceWithRawResponse(IImageKitClientWithRawResponse client) + { + _client = client; + } + + /// + public async Task> Get( + JobGetParams parameters, + CancellationToken cancellationToken = default + ) + { + if (parameters.JobID == null) + { + throw new ImageKitInvalidDataException("'parameters.JobID' cannot be null"); + } + + HttpRequest request = new() { Method = HttpMethod.Get, Params = parameters }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var job = await response.Deserialize(token).ConfigureAwait(false); + if (this._client.ResponseValidation) + { + job.Validate(); + } + return job; + } + ); + } + + /// + public Task> Get( + string jobID, + JobGetParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + return this.Get(parameters with { JobID = jobID }, cancellationToken); + } +} diff --git a/src/ImageKit/Services/IAccountService.cs b/src/ImageKit/Services/IAccountService.cs new file mode 100644 index 00000000..6925313c --- /dev/null +++ b/src/ImageKit/Services/IAccountService.cs @@ -0,0 +1,52 @@ +using System; +using ImageKit.Core; +using ImageKit.Services.Accounts; + +namespace ImageKit.Services; + +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking +/// changes in non-major versions. We may add new methods in the future that cause +/// existing derived classes to break. +/// +public interface IAccountService +{ + /// + /// Returns a view of this service that provides access to raw HTTP responses + /// for each method. + /// + IAccountServiceWithRawResponse WithRawResponse { get; } + + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + IAccountService WithOptions(Func modifier); + + IUsageService Usage { get; } + + IOriginService Origins { get; } + + IUrlEndpointService UrlEndpoints { get; } +} + +/// +/// A view of that provides access to raw +/// HTTP responses for each method. +/// +public interface IAccountServiceWithRawResponse +{ + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + IAccountServiceWithRawResponse WithOptions(Func modifier); + + IUsageServiceWithRawResponse Usage { get; } + + IOriginServiceWithRawResponse Origins { get; } + + IUrlEndpointServiceWithRawResponse UrlEndpoints { get; } +} diff --git a/src/ImageKit/Services/IAssetService.cs b/src/ImageKit/Services/IAssetService.cs new file mode 100644 index 00000000..32f55c02 --- /dev/null +++ b/src/ImageKit/Services/IAssetService.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using ImageKit.Core; +using ImageKit.Models.Assets; + +namespace ImageKit.Services; + +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking +/// changes in non-major versions. We may add new methods in the future that cause +/// existing derived classes to break. +/// +public interface IAssetService +{ + /// + /// Returns a view of this service that provides access to raw HTTP responses + /// for each method. + /// + IAssetServiceWithRawResponse WithRawResponse { get; } + + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + IAssetService WithOptions(Func modifier); + + /// + /// This API can list all the uploaded files and folders in your ImageKit.io media + /// library. In addition, you can fine-tune your query by specifying various filters + /// by generating a query string in a Lucene-like syntax and provide this generated + /// string as the value of the `searchQuery`. + /// + Task> List( + AssetListParams? parameters = null, + CancellationToken cancellationToken = default + ); +} + +/// +/// A view of that provides access to raw +/// HTTP responses for each method. +/// +public interface IAssetServiceWithRawResponse +{ + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + IAssetServiceWithRawResponse WithOptions(Func modifier); + + /// + /// Returns a raw HTTP response for `get /v1/files`, but is otherwise the + /// same as . + /// + Task>> List( + AssetListParams? parameters = null, + CancellationToken cancellationToken = default + ); +} diff --git a/src/ImageKit/Services/IBetaService.cs b/src/ImageKit/Services/IBetaService.cs new file mode 100644 index 00000000..81258ad6 --- /dev/null +++ b/src/ImageKit/Services/IBetaService.cs @@ -0,0 +1,44 @@ +using System; +using ImageKit.Core; +using ImageKit.Services.Beta; + +namespace ImageKit.Services; + +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking +/// changes in non-major versions. We may add new methods in the future that cause +/// existing derived classes to break. +/// +public interface IBetaService +{ + /// + /// Returns a view of this service that provides access to raw HTTP responses + /// for each method. + /// + IBetaServiceWithRawResponse WithRawResponse { get; } + + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + IBetaService WithOptions(Func modifier); + + IV2Service V2 { get; } +} + +/// +/// A view of that provides access to raw +/// HTTP responses for each method. +/// +public interface IBetaServiceWithRawResponse +{ + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + IBetaServiceWithRawResponse WithOptions(Func modifier); + + IV2ServiceWithRawResponse V2 { get; } +} diff --git a/src/ImageKit/Services/ICacheService.cs b/src/ImageKit/Services/ICacheService.cs new file mode 100644 index 00000000..8834db75 --- /dev/null +++ b/src/ImageKit/Services/ICacheService.cs @@ -0,0 +1,44 @@ +using System; +using ImageKit.Core; +using ImageKit.Services.Cache; + +namespace ImageKit.Services; + +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking +/// changes in non-major versions. We may add new methods in the future that cause +/// existing derived classes to break. +/// +public interface ICacheService +{ + /// + /// Returns a view of this service that provides access to raw HTTP responses + /// for each method. + /// + ICacheServiceWithRawResponse WithRawResponse { get; } + + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + ICacheService WithOptions(Func modifier); + + IInvalidationService Invalidation { get; } +} + +/// +/// A view of that provides access to raw +/// HTTP responses for each method. +/// +public interface ICacheServiceWithRawResponse +{ + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + ICacheServiceWithRawResponse WithOptions(Func modifier); + + IInvalidationServiceWithRawResponse Invalidation { get; } +} diff --git a/src/ImageKit/Services/ICustomMetadataFieldService.cs b/src/ImageKit/Services/ICustomMetadataFieldService.cs new file mode 100644 index 00000000..4c776b7b --- /dev/null +++ b/src/ImageKit/Services/ICustomMetadataFieldService.cs @@ -0,0 +1,152 @@ +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using ImageKit.Core; +using ImageKit.Models.CustomMetadataFields; + +namespace ImageKit.Services; + +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking +/// changes in non-major versions. We may add new methods in the future that cause +/// existing derived classes to break. +/// +public interface ICustomMetadataFieldService +{ + /// + /// Returns a view of this service that provides access to raw HTTP responses + /// for each method. + /// + ICustomMetadataFieldServiceWithRawResponse WithRawResponse { get; } + + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + ICustomMetadataFieldService WithOptions(Func modifier); + + /// + /// This API creates a new custom metadata field. Once a custom metadata field + /// is created either through this API or using the dashboard UI, its value can + /// be set on the assets. The value of a field for an asset can be set using + /// the media library UI or programmatically through upload or update assets API. + /// + Task Create( + CustomMetadataFieldCreateParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// This API updates the label or schema of an existing custom metadata field. + /// + Task Update( + CustomMetadataFieldUpdateParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task Update( + string id, + CustomMetadataFieldUpdateParams? parameters = null, + CancellationToken cancellationToken = default + ); + + /// + /// This API returns the array of created custom metadata field objects. By default + /// the API returns only non deleted field objects, but you can include deleted + /// fields in the API response. + /// + /// You can also filter results by a specific folder path to retrieve custom + /// metadata fields applicable at that location. This path-specific filtering + /// is useful when using the **Path policy** feature to determine which custom + /// metadata fields are selected for a given path. + /// + Task> List( + CustomMetadataFieldListParams? parameters = null, + CancellationToken cancellationToken = default + ); + + /// + /// This API deletes a custom metadata field. Even after deleting a custom metadata + /// field, you cannot create any new custom metadata field with the same name. + /// + Task Delete( + CustomMetadataFieldDeleteParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task Delete( + string id, + CustomMetadataFieldDeleteParams? parameters = null, + CancellationToken cancellationToken = default + ); +} + +/// +/// A view of that provides access to raw +/// HTTP responses for each method. +/// +public interface ICustomMetadataFieldServiceWithRawResponse +{ + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + ICustomMetadataFieldServiceWithRawResponse WithOptions( + Func modifier + ); + + /// + /// Returns a raw HTTP response for `post /v1/customMetadataFields`, but is otherwise the + /// same as . + /// + Task> Create( + CustomMetadataFieldCreateParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// Returns a raw HTTP response for `patch /v1/customMetadataFields/{id}`, but is otherwise the + /// same as . + /// + Task> Update( + CustomMetadataFieldUpdateParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task> Update( + string id, + CustomMetadataFieldUpdateParams? parameters = null, + CancellationToken cancellationToken = default + ); + + /// + /// Returns a raw HTTP response for `get /v1/customMetadataFields`, but is otherwise the + /// same as . + /// + Task>> List( + CustomMetadataFieldListParams? parameters = null, + CancellationToken cancellationToken = default + ); + + /// + /// Returns a raw HTTP response for `delete /v1/customMetadataFields/{id}`, but is otherwise the + /// same as . + /// + Task> Delete( + CustomMetadataFieldDeleteParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task> Delete( + string id, + CustomMetadataFieldDeleteParams? parameters = null, + CancellationToken cancellationToken = default + ); +} diff --git a/src/ImageKit/Services/IFileService.cs b/src/ImageKit/Services/IFileService.cs new file mode 100644 index 00000000..e347c72b --- /dev/null +++ b/src/ImageKit/Services/IFileService.cs @@ -0,0 +1,249 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using ImageKit.Core; +using ImageKit.Models.Files; +using ImageKit.Services.Files; + +namespace ImageKit.Services; + +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking +/// changes in non-major versions. We may add new methods in the future that cause +/// existing derived classes to break. +/// +public interface IFileService +{ + /// + /// Returns a view of this service that provides access to raw HTTP responses + /// for each method. + /// + IFileServiceWithRawResponse WithRawResponse { get; } + + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + IFileService WithOptions(Func modifier); + + IBulkService Bulk { get; } + + IVersionService Versions { get; } + + IMetadataService Metadata { get; } + + /// + /// This API updates the details or attributes of the current version of the file. + /// You can update `tags`, `customCoordinates`, `customMetadata`, publication + /// status, remove existing `AITags` and apply extensions using this API. + /// + Task Update( + FileUpdateParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task Update( + string fileID, + FileUpdateParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// This API deletes the file and all its file versions permanently. + /// + /// Note: If a file or specific transformation has been requested in the + /// past, then the response is cached. Deleting a file does not purge the cache. + /// You can purge the cache using purge cache API. + /// + Task Delete(FileDeleteParams parameters, CancellationToken cancellationToken = default); + + /// + Task Delete( + string fileID, + FileDeleteParams? parameters = null, + CancellationToken cancellationToken = default + ); + + /// + /// This will copy a file from one folder to another. + /// + /// Note: If any file at the destination has the same name as the source + /// file, then the source file and its versions (if `includeFileVersions` is set + /// to true) will be appended to the destination file version history. + /// + Task Copy( + FileCopyParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// This API returns an object with details or attributes about the current version + /// of the file. + /// + Task Get(FileGetParams parameters, CancellationToken cancellationToken = default); + + /// + Task Get( + string fileID, + FileGetParams? parameters = null, + CancellationToken cancellationToken = default + ); + + /// + /// This will move a file and all its versions from one folder to another. + /// + /// Note: If any file at the destination has the same name as the source + /// file, then the source file and its versions will be appended to the destination file. + /// + Task Move( + FileMoveParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// You can rename an already existing file in the media library using rename + /// file API. This operation would rename all file versions of the file. + /// + /// Note: The old URLs will stop working. The file/file version URLs cached + /// on CDN will continue to work unless a purge is requested. + /// + Task Rename( + FileRenameParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// ImageKit.io allows you to upload files directly from both the server and + /// client sides. For server-side uploads, private API key authentication is + /// used. For client-side uploads, generate a one-time `token`, `signature`, and + /// `expire` from your secure backend using private API. [Learn more](/docs/api-reference/upload-file/upload-file#how-to-implement-client-side-file-upload) + /// about how to implement client-side file upload. + /// + /// The [V2 API](/docs/api-reference/upload-file/upload-file-v2) enhances + /// security by verifying the entire payload using JWT. + /// + /// **File size limit** \ On the free plan, the maximum upload file sizes + /// are 20MB for images, audio, and raw files and 100MB for videos. On the paid + /// plan, these limits increase to 40MB for images, audio, and raw files and 2GB + /// for videos. These limits can be further increased with higher-tier plans. + /// + /// **Version limit** \ A file can have a maximum of 100 versions. + /// + /// **Demo applications** + /// + /// - A full-fledged [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), + /// supporting file selections from local storage, URL, Dropbox, Google Drive, + /// Instagram, and more. - [Quick start guides](/docs/quick-start-guides) for + /// various frameworks and technologies. + /// + Task Upload( + FileUploadParams parameters, + CancellationToken cancellationToken = default + ); +} + +/// +/// A view of that provides access to raw +/// HTTP responses for each method. +/// +public interface IFileServiceWithRawResponse +{ + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + IFileServiceWithRawResponse WithOptions(Func modifier); + + IBulkServiceWithRawResponse Bulk { get; } + + IVersionServiceWithRawResponse Versions { get; } + + IMetadataServiceWithRawResponse Metadata { get; } + + /// + /// Returns a raw HTTP response for `patch /v1/files/{fileId}/details`, but is otherwise the + /// same as . + /// + Task> Update( + FileUpdateParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task> Update( + string fileID, + FileUpdateParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// Returns a raw HTTP response for `delete /v1/files/{fileId}`, but is otherwise the + /// same as . + /// + Task Delete( + FileDeleteParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task Delete( + string fileID, + FileDeleteParams? parameters = null, + CancellationToken cancellationToken = default + ); + + /// + /// Returns a raw HTTP response for `post /v1/files/copy`, but is otherwise the + /// same as . + /// + Task> Copy( + FileCopyParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// Returns a raw HTTP response for `get /v1/files/{fileId}/details`, but is otherwise the + /// same as . + /// + Task> Get( + FileGetParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task> Get( + string fileID, + FileGetParams? parameters = null, + CancellationToken cancellationToken = default + ); + + /// + /// Returns a raw HTTP response for `post /v1/files/move`, but is otherwise the + /// same as . + /// + Task> Move( + FileMoveParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// Returns a raw HTTP response for `put /v1/files/rename`, but is otherwise the + /// same as . + /// + Task> Rename( + FileRenameParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// Returns a raw HTTP response for `post /api/v1/files/upload`, but is otherwise the + /// same as . + /// + Task> Upload( + FileUploadParams parameters, + CancellationToken cancellationToken = default + ); +} diff --git a/src/ImageKit/Services/IFolderService.cs b/src/ImageKit/Services/IFolderService.cs new file mode 100644 index 00000000..d63c2d7c --- /dev/null +++ b/src/ImageKit/Services/IFolderService.cs @@ -0,0 +1,143 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using ImageKit.Core; +using ImageKit.Models.Folders; +using ImageKit.Services.Folders; + +namespace ImageKit.Services; + +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking +/// changes in non-major versions. We may add new methods in the future that cause +/// existing derived classes to break. +/// +public interface IFolderService +{ + /// + /// Returns a view of this service that provides access to raw HTTP responses + /// for each method. + /// + IFolderServiceWithRawResponse WithRawResponse { get; } + + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + IFolderService WithOptions(Func modifier); + + IJobService Job { get; } + + /// + /// This will create a new folder. You can specify the folder name and location + /// of the parent folder where this new folder should be created. + /// + Task Create( + FolderCreateParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// This will delete a folder and all its contents permanently. The API returns + /// an empty response. + /// + Task Delete( + FolderDeleteParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// This will copy one folder into another. The selected folder, its nested folders, + /// files, and their versions (in `includeVersions` is set to true) are copied + /// in this operation. Note: If any file at the destination has the same name + /// as the source file, then the source file and its versions will be appended + /// to the destination file version history. + /// + Task Copy( + FolderCopyParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// This will move one folder into another. The selected folder, its nested folders, + /// files, and their versions are moved in this operation. Note: If any file + /// at the destination has the same name as the source file, then the source + /// file and its versions will be appended to the destination file version history. + /// + Task Move( + FolderMoveParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// This API allows you to rename an existing folder. The folder and all its + /// nested assets and sub-folders will remain unchanged, but their paths will + /// be updated to reflect the new folder name. + /// + Task Rename( + FolderRenameParams parameters, + CancellationToken cancellationToken = default + ); +} + +/// +/// A view of that provides access to raw +/// HTTP responses for each method. +/// +public interface IFolderServiceWithRawResponse +{ + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + IFolderServiceWithRawResponse WithOptions(Func modifier); + + IJobServiceWithRawResponse Job { get; } + + /// + /// Returns a raw HTTP response for `post /v1/folder`, but is otherwise the + /// same as . + /// + Task> Create( + FolderCreateParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// Returns a raw HTTP response for `delete /v1/folder`, but is otherwise the + /// same as . + /// + Task> Delete( + FolderDeleteParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// Returns a raw HTTP response for `post /v1/bulkJobs/copyFolder`, but is otherwise the + /// same as . + /// + Task> Copy( + FolderCopyParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// Returns a raw HTTP response for `post /v1/bulkJobs/moveFolder`, but is otherwise the + /// same as . + /// + Task> Move( + FolderMoveParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// Returns a raw HTTP response for `post /v1/bulkJobs/renameFolder`, but is otherwise the + /// same as . + /// + Task> Rename( + FolderRenameParams parameters, + CancellationToken cancellationToken = default + ); +} diff --git a/src/ImageKit/Services/ISavedExtensionService.cs b/src/ImageKit/Services/ISavedExtensionService.cs new file mode 100644 index 00000000..b2c783b9 --- /dev/null +++ b/src/ImageKit/Services/ISavedExtensionService.cs @@ -0,0 +1,179 @@ +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using ImageKit.Core; +using ImageKit.Models.SavedExtensions; +using Models = ImageKit.Models; + +namespace ImageKit.Services; + +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking +/// changes in non-major versions. We may add new methods in the future that cause +/// existing derived classes to break. +/// +public interface ISavedExtensionService +{ + /// + /// Returns a view of this service that provides access to raw HTTP responses + /// for each method. + /// + ISavedExtensionServiceWithRawResponse WithRawResponse { get; } + + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + ISavedExtensionService WithOptions(Func modifier); + + /// + /// This API creates a new saved extension. Saved extensions allow you to save + /// complex extension configurations (like AI tasks) and reuse them by referencing + /// the ID in upload or update file APIs. + /// + /// **Saved extension limit** \ You can create a maximum of 100 saved extensions + /// per account. + /// + Task Create( + SavedExtensionCreateParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// This API updates an existing saved extension. You can update the name, description, + /// or config. + /// + Task Update( + SavedExtensionUpdateParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task Update( + string id, + SavedExtensionUpdateParams? parameters = null, + CancellationToken cancellationToken = default + ); + + /// + /// This API returns an array of all saved extensions for your account. Saved + /// extensions allow you to save complex extension configurations and reuse them + /// by referencing them by ID in upload or update file APIs. + /// + Task> List( + SavedExtensionListParams? parameters = null, + CancellationToken cancellationToken = default + ); + + /// + /// This API deletes a saved extension permanently. + /// + Task Delete( + SavedExtensionDeleteParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task Delete( + string id, + SavedExtensionDeleteParams? parameters = null, + CancellationToken cancellationToken = default + ); + + /// + /// This API returns details of a specific saved extension by ID. + /// + Task Get( + SavedExtensionGetParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task Get( + string id, + SavedExtensionGetParams? parameters = null, + CancellationToken cancellationToken = default + ); +} + +/// +/// A view of that provides access to raw +/// HTTP responses for each method. +/// +public interface ISavedExtensionServiceWithRawResponse +{ + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + ISavedExtensionServiceWithRawResponse WithOptions(Func modifier); + + /// + /// Returns a raw HTTP response for `post /v1/saved-extensions`, but is otherwise the + /// same as . + /// + Task> Create( + SavedExtensionCreateParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// Returns a raw HTTP response for `patch /v1/saved-extensions/{id}`, but is otherwise the + /// same as . + /// + Task> Update( + SavedExtensionUpdateParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task> Update( + string id, + SavedExtensionUpdateParams? parameters = null, + CancellationToken cancellationToken = default + ); + + /// + /// Returns a raw HTTP response for `get /v1/saved-extensions`, but is otherwise the + /// same as . + /// + Task>> List( + SavedExtensionListParams? parameters = null, + CancellationToken cancellationToken = default + ); + + /// + /// Returns a raw HTTP response for `delete /v1/saved-extensions/{id}`, but is otherwise the + /// same as . + /// + Task Delete( + SavedExtensionDeleteParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task Delete( + string id, + SavedExtensionDeleteParams? parameters = null, + CancellationToken cancellationToken = default + ); + + /// + /// Returns a raw HTTP response for `get /v1/saved-extensions/{id}`, but is otherwise the + /// same as . + /// + Task> Get( + SavedExtensionGetParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task> Get( + string id, + SavedExtensionGetParams? parameters = null, + CancellationToken cancellationToken = default + ); +} diff --git a/src/ImageKit/Services/IWebhookService.cs b/src/ImageKit/Services/IWebhookService.cs new file mode 100644 index 00000000..befb6524 --- /dev/null +++ b/src/ImageKit/Services/IWebhookService.cs @@ -0,0 +1,39 @@ +using System; +using ImageKit.Core; + +namespace ImageKit.Services; + +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking +/// changes in non-major versions. We may add new methods in the future that cause +/// existing derived classes to break. +/// +public interface IWebhookService +{ + /// + /// Returns a view of this service that provides access to raw HTTP responses + /// for each method. + /// + IWebhookServiceWithRawResponse WithRawResponse { get; } + + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + IWebhookService WithOptions(Func modifier); +} + +/// +/// A view of that provides access to raw +/// HTTP responses for each method. +/// +public interface IWebhookServiceWithRawResponse +{ + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + IWebhookServiceWithRawResponse WithOptions(Func modifier); +} diff --git a/src/ImageKit/Services/SavedExtensionService.cs b/src/ImageKit/Services/SavedExtensionService.cs new file mode 100644 index 00000000..5ec770b5 --- /dev/null +++ b/src/ImageKit/Services/SavedExtensionService.cs @@ -0,0 +1,334 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; +using ImageKit.Core; +using ImageKit.Exceptions; +using ImageKit.Models.SavedExtensions; +using Models = ImageKit.Models; + +namespace ImageKit.Services; + +/// +public sealed class SavedExtensionService : ISavedExtensionService +{ + readonly Lazy _withRawResponse; + + /// + public ISavedExtensionServiceWithRawResponse WithRawResponse + { + get { return _withRawResponse.Value; } + } + + readonly IImageKitClient _client; + + /// + public ISavedExtensionService WithOptions(Func modifier) + { + return new SavedExtensionService(this._client.WithOptions(modifier)); + } + + public SavedExtensionService(IImageKitClient client) + { + _client = client; + + _withRawResponse = new(() => + new SavedExtensionServiceWithRawResponse(client.WithRawResponse) + ); + } + + /// + public async Task Create( + SavedExtensionCreateParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.Create(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public async Task Update( + SavedExtensionUpdateParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.Update(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public Task Update( + string id, + SavedExtensionUpdateParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + return this.Update(parameters with { ID = id }, cancellationToken); + } + + /// + public async Task> List( + SavedExtensionListParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.List(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public Task Delete( + SavedExtensionDeleteParams parameters, + CancellationToken cancellationToken = default + ) + { + return this.WithRawResponse.Delete(parameters, cancellationToken); + } + + /// + public async Task Delete( + string id, + SavedExtensionDeleteParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + await this.Delete(parameters with { ID = id }, cancellationToken).ConfigureAwait(false); + } + + /// + public async Task Get( + SavedExtensionGetParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.Get(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public Task Get( + string id, + SavedExtensionGetParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + return this.Get(parameters with { ID = id }, cancellationToken); + } +} + +/// +public sealed class SavedExtensionServiceWithRawResponse : ISavedExtensionServiceWithRawResponse +{ + readonly IImageKitClientWithRawResponse _client; + + /// + public ISavedExtensionServiceWithRawResponse WithOptions( + Func modifier + ) + { + return new SavedExtensionServiceWithRawResponse(this._client.WithOptions(modifier)); + } + + public SavedExtensionServiceWithRawResponse(IImageKitClientWithRawResponse client) + { + _client = client; + } + + /// + public async Task> Create( + SavedExtensionCreateParams parameters, + CancellationToken cancellationToken = default + ) + { + HttpRequest request = new() + { + Method = HttpMethod.Post, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var savedExtension = await response + .Deserialize(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + savedExtension.Validate(); + } + return savedExtension; + } + ); + } + + /// + public async Task> Update( + SavedExtensionUpdateParams parameters, + CancellationToken cancellationToken = default + ) + { + if (parameters.ID == null) + { + throw new ImageKitInvalidDataException("'parameters.ID' cannot be null"); + } + + HttpRequest request = new() + { + Method = ImageKitClientWithRawResponse.PatchMethod, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var savedExtension = await response + .Deserialize(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + savedExtension.Validate(); + } + return savedExtension; + } + ); + } + + /// + public Task> Update( + string id, + SavedExtensionUpdateParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + return this.Update(parameters with { ID = id }, cancellationToken); + } + + /// + public async Task>> List( + SavedExtensionListParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + HttpRequest request = new() + { + Method = HttpMethod.Get, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var savedExtensions = await response + .Deserialize>(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + foreach (var item in savedExtensions) + { + item.Validate(); + } + } + return savedExtensions; + } + ); + } + + /// + public Task Delete( + SavedExtensionDeleteParams parameters, + CancellationToken cancellationToken = default + ) + { + if (parameters.ID == null) + { + throw new ImageKitInvalidDataException("'parameters.ID' cannot be null"); + } + + HttpRequest request = new() + { + Method = HttpMethod.Delete, + Params = parameters, + }; + return this._client.Execute(request, cancellationToken); + } + + /// + public Task Delete( + string id, + SavedExtensionDeleteParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + return this.Delete(parameters with { ID = id }, cancellationToken); + } + + /// + public async Task> Get( + SavedExtensionGetParams parameters, + CancellationToken cancellationToken = default + ) + { + if (parameters.ID == null) + { + throw new ImageKitInvalidDataException("'parameters.ID' cannot be null"); + } + + HttpRequest request = new() + { + Method = HttpMethod.Get, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var savedExtension = await response + .Deserialize(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + savedExtension.Validate(); + } + return savedExtension; + } + ); + } + + /// + public Task> Get( + string id, + SavedExtensionGetParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + return this.Get(parameters with { ID = id }, cancellationToken); + } +} diff --git a/src/ImageKit/Services/WebhookService.cs b/src/ImageKit/Services/WebhookService.cs new file mode 100644 index 00000000..15f7aa9f --- /dev/null +++ b/src/ImageKit/Services/WebhookService.cs @@ -0,0 +1,48 @@ +using System; +using ImageKit.Core; + +namespace ImageKit.Services; + +/// +public sealed class WebhookService : IWebhookService +{ + readonly Lazy _withRawResponse; + + /// + public IWebhookServiceWithRawResponse WithRawResponse + { + get { return _withRawResponse.Value; } + } + + readonly IImageKitClient _client; + + /// + public IWebhookService WithOptions(Func modifier) + { + return new WebhookService(this._client.WithOptions(modifier)); + } + + public WebhookService(IImageKitClient client) + { + _client = client; + + _withRawResponse = new(() => new WebhookServiceWithRawResponse(client.WithRawResponse)); + } +} + +/// +public sealed class WebhookServiceWithRawResponse : IWebhookServiceWithRawResponse +{ + readonly IImageKitClientWithRawResponse _client; + + /// + public IWebhookServiceWithRawResponse WithOptions(Func modifier) + { + return new WebhookServiceWithRawResponse(this._client.WithOptions(modifier)); + } + + public WebhookServiceWithRawResponse(IImageKitClientWithRawResponse client) + { + _client = client; + } +} diff --git a/src/ImageKit/Shims.cs b/src/ImageKit/Shims.cs new file mode 100644 index 00000000..afd5582f --- /dev/null +++ b/src/ImageKit/Shims.cs @@ -0,0 +1,41 @@ +using System; + +#if !NET +#pragma warning disable IDE0130 // Namespace does not match folder structure +#pragma warning disable CS9113 // Unused parameters + +namespace System.Runtime.CompilerServices +{ + // Allow `required` to compile when targeting .NET Standard 2.0. + [AttributeUsage( + AttributeTargets.Class + | AttributeTargets.Struct + | AttributeTargets.Property + | AttributeTargets.Field, + AllowMultiple = false, + Inherited = false + )] + internal sealed class RequiredMemberAttribute : Attribute; + + [AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = false)] + internal sealed class CompilerFeatureRequiredAttribute(string feature) : Attribute; + + // Allow `init` to compile when targeting .NET Standard 2.0. + internal static class IsExternalInit; +} + +namespace System.Diagnostics.CodeAnalysis +{ + // Allow `[SetsRequiredMembers]` to compile when targeting .NET Standard 2.0. + [AttributeUsage(AttributeTargets.Constructor, AllowMultiple = false, Inherited = false)] + internal sealed class SetsRequiredMembersAttribute : Attribute; + + // Allow `[MaybeNullWhen(...)]` to compile when targeting .NET Standard 2.0. + [AttributeUsage(AttributeTargets.Parameter, Inherited = false)] + internal sealed class MaybeNullWhenAttribute(bool returnValue) : Attribute; + + // Allow `[NotNullWhen(...)]` to compile when targeting .NET Standard 2.0. + [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)] + internal sealed class NotNullWhenAttribute(bool returnValue) : Attribute; +} +#endif diff --git a/src/Imagekit.Tests/Imagekit.Tests.csproj b/src/Imagekit.Tests/Imagekit.Tests.csproj deleted file mode 100644 index cc370ddc..00000000 --- a/src/Imagekit.Tests/Imagekit.Tests.csproj +++ /dev/null @@ -1,20 +0,0 @@ - - - net8.0 - false - true - disable - - $(NoWarn),xUnit1004 - - - - - - - - - - - - diff --git a/src/Imagekit.Tests/Services/Accounts/AccountServiceTest.cs b/src/Imagekit.Tests/Services/Accounts/AccountServiceTest.cs deleted file mode 100644 index 7be4ff92..00000000 --- a/src/Imagekit.Tests/Services/Accounts/AccountServiceTest.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace Imagekit.Tests.Services.Accounts; - -public class AccountServiceTest : TestBase { } diff --git a/src/Imagekit.Tests/Services/Accounts/URLEndpoints/URLEndpointServiceTest.cs b/src/Imagekit.Tests/Services/Accounts/URLEndpoints/URLEndpointServiceTest.cs deleted file mode 100644 index e02ba52f..00000000 --- a/src/Imagekit.Tests/Services/Accounts/URLEndpoints/URLEndpointServiceTest.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System.Threading.Tasks; - -namespace Imagekit.Tests.Services.Accounts.URLEndpoints; - -public class URLEndpointServiceTest : TestBase -{ - [Fact(Skip = "Prism tests are disabled")] - public async Task Create_Works() - { - var urlEndpointResponse = await this.client.Accounts.URLEndpoints.Create( - new() { Description = "My custom URL endpoint" } - ); - urlEndpointResponse.Validate(); - } - - [Fact(Skip = "Prism tests are disabled")] - public async Task Update_Works() - { - var urlEndpointResponse = await this.client.Accounts.URLEndpoints.Update( - new() { ID = "id", Description = "My custom URL endpoint" } - ); - urlEndpointResponse.Validate(); - } - - [Fact(Skip = "Prism tests are disabled")] - public async Task List_Works() - { - var urlEndpointResponses = await this.client.Accounts.URLEndpoints.List(); - foreach (var item in urlEndpointResponses) - { - item.Validate(); - } - } - - [Fact(Skip = "Prism tests are disabled")] - public async Task Delete_Works() - { - await this.client.Accounts.URLEndpoints.Delete(new() { ID = "id" }); - } - - [Fact(Skip = "Prism tests are disabled")] - public async Task Get_Works() - { - var urlEndpointResponse = await this.client.Accounts.URLEndpoints.Get(new() { ID = "id" }); - urlEndpointResponse.Validate(); - } -} diff --git a/src/Imagekit.Tests/Services/Beta/BetaServiceTest.cs b/src/Imagekit.Tests/Services/Beta/BetaServiceTest.cs deleted file mode 100644 index df0194f8..00000000 --- a/src/Imagekit.Tests/Services/Beta/BetaServiceTest.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace Imagekit.Tests.Services.Beta; - -public class BetaServiceTest : TestBase { } diff --git a/src/Imagekit.Tests/Services/Beta/V2/V2ServiceTest.cs b/src/Imagekit.Tests/Services/Beta/V2/V2ServiceTest.cs deleted file mode 100644 index 1b31bb9d..00000000 --- a/src/Imagekit.Tests/Services/Beta/V2/V2ServiceTest.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace Imagekit.Tests.Services.Beta.V2; - -public class V2ServiceTest : TestBase { } diff --git a/src/Imagekit.Tests/Services/Cache/CacheServiceTest.cs b/src/Imagekit.Tests/Services/Cache/CacheServiceTest.cs deleted file mode 100644 index 879b9a6b..00000000 --- a/src/Imagekit.Tests/Services/Cache/CacheServiceTest.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace Imagekit.Tests.Services.Cache; - -public class CacheServiceTest : TestBase { } diff --git a/src/Imagekit.Tests/Services/Files/FileServiceTest.cs b/src/Imagekit.Tests/Services/Files/FileServiceTest.cs deleted file mode 100644 index ac839c40..00000000 --- a/src/Imagekit.Tests/Services/Files/FileServiceTest.cs +++ /dev/null @@ -1,127 +0,0 @@ -using System.Collections.Generic; -using System.Text.Json; -using System.Threading.Tasks; -using Imagekit.Models.Files.UpdateFileRequestProperties; -using Imagekit.Models.UnnamedSchemaWithArrayParent0Properties; -using Imagekit.Models.UnnamedSchemaWithArrayParent0Properties.AutoTaggingExtensionProperties; - -namespace Imagekit.Tests.Services.Files; - -public class FileServiceTest : TestBase -{ - [Fact(Skip = "Prism tests are disabled")] - public async Task Update_Works() - { - var file = await this.client.Files.Update( - new() - { - FileID = "fileId", - UpdateFileRequest = new( - new UpdateFileDetails() - { - CustomCoordinates = "10,10,100,100", - CustomMetadata = new Dictionary() - { - { "brand", JsonSerializer.SerializeToElement("bar") }, - { "color", JsonSerializer.SerializeToElement("bar") }, - }, - Description = "description", - Extensions = - [ - new( - new RemoveBg() - { - Options = new() - { - AddShadow = true, - BgColor = "bg_color", - BgImageURL = "bg_image_url", - Semitransparency = true, - }, - } - ), - new( - new AutoTaggingExtension() - { - MaxTags = 10, - MinConfidence = 80, - Name = Name.GoogleAutoTagging, - } - ), - new( - new AutoTaggingExtension() - { - MaxTags = 10, - MinConfidence = 80, - Name = Name.AwsAutoTagging, - } - ), - new(new()), - ], - RemoveAITags = new(["car", "vehicle", "motorsports"]), - Tags = ["tag1", "tag2"], - WebhookURL = "https://webhook.site/0d6b6c7a-8e5a-4b3a-8b7c-0d6b6c7a8e5a", - } - ), - } - ); - file.Validate(); - } - - [Fact(Skip = "Prism tests are disabled")] - public async Task Delete_Works() - { - await this.client.Files.Delete(new() { FileID = "fileId" }); - } - - [Fact(Skip = "Prism tests are disabled")] - public async Task Copy_Works() - { - var response = await this.client.Files.Copy( - new() - { - DestinationPath = "/folder/to/copy/into/", - SourceFilePath = "/path/to/file.jpg", - } - ); - response.Validate(); - } - - [Fact(Skip = "Prism tests are disabled")] - public async Task Get_Works() - { - var file = await this.client.Files.Get(new() { FileID = "fileId" }); - file.Validate(); - } - - [Fact(Skip = "Prism tests are disabled")] - public async Task Move_Works() - { - var response = await this.client.Files.Move( - new() - { - DestinationPath = "/folder/to/move/into/", - SourceFilePath = "/path/to/file.jpg", - } - ); - response.Validate(); - } - - [Fact(Skip = "Prism tests are disabled")] - public async Task Rename_Works() - { - var response = await this.client.Files.Rename( - new() { FilePath = "/path/to/file.jpg", NewFileName = "newFileName.jpg" } - ); - response.Validate(); - } - - [Fact(Skip = "Prism tests are disabled")] - public async Task Upload_Works() - { - var response = await this.client.Files.Upload( - new() { File = "a value", FileName = "fileName" } - ); - response.Validate(); - } -} diff --git a/src/Imagekit.Tests/Services/Files/Metadata/MetadataServiceTest.cs b/src/Imagekit.Tests/Services/Files/Metadata/MetadataServiceTest.cs deleted file mode 100644 index ae2f33d1..00000000 --- a/src/Imagekit.Tests/Services/Files/Metadata/MetadataServiceTest.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System.Threading.Tasks; - -namespace Imagekit.Tests.Services.Files.Metadata; - -public class MetadataServiceTest : TestBase -{ - [Fact(Skip = "Prism tests are disabled")] - public async Task Get_Works() - { - var metadata = await this.client.Files.Metadata.Get(new() { FileID = "fileId" }); - metadata.Validate(); - } - - [Fact(Skip = "Prism tests are disabled")] - public async Task GetFromURL_Works() - { - var metadata = await this.client.Files.Metadata.GetFromURL( - new() { URL = "https://example.com" } - ); - metadata.Validate(); - } -} diff --git a/src/Imagekit.Tests/Services/Folders/Job/JobServiceTest.cs b/src/Imagekit.Tests/Services/Folders/Job/JobServiceTest.cs deleted file mode 100644 index 9ec1497d..00000000 --- a/src/Imagekit.Tests/Services/Folders/Job/JobServiceTest.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Threading.Tasks; - -namespace Imagekit.Tests.Services.Folders.Job; - -public class JobServiceTest : TestBase -{ - [Fact(Skip = "Prism tests are disabled")] - public async Task Get_Works() - { - var job = await this.client.Folders.Job.Get(new() { JobID = "jobId" }); - job.Validate(); - } -} diff --git a/src/Imagekit.Tests/Services/Webhooks/WebhookServiceTest.cs b/src/Imagekit.Tests/Services/Webhooks/WebhookServiceTest.cs deleted file mode 100644 index 88914250..00000000 --- a/src/Imagekit.Tests/Services/Webhooks/WebhookServiceTest.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace Imagekit.Tests.Services.Webhooks; - -public class WebhookServiceTest : TestBase { } diff --git a/src/Imagekit/Core/ApiEnum.cs b/src/Imagekit/Core/ApiEnum.cs deleted file mode 100644 index 29b6a839..00000000 --- a/src/Imagekit/Core/ApiEnum.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit; - -public record struct ApiEnum(JsonElement Json) - where TEnum : struct, Enum -{ - public readonly TRaw Raw() => - JsonSerializer.Deserialize(this.Json, ModelBase.SerializerOptions) - ?? throw new NullReferenceException(nameof(this.Json)); - - public readonly TEnum Value() => - JsonSerializer.Deserialize(this.Json, ModelBase.SerializerOptions); - - public readonly void Validate() - { - if (!Enum.IsDefined(Value())) - { - throw new Exception(); - } - } - - public static implicit operator TRaw(ApiEnum value) => value.Raw(); - - public static implicit operator TEnum(ApiEnum value) => value.Value(); - - public static implicit operator ApiEnum(TRaw value) => - new(JsonSerializer.SerializeToElement(value, ModelBase.SerializerOptions)); - - public static implicit operator ApiEnum(TEnum value) => - new(JsonSerializer.SerializeToElement(value, ModelBase.SerializerOptions)); -} - -sealed class ApiEnumConverter : JsonConverter> - where TEnum : struct, Enum -{ - public override ApiEnum Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write( - Utf8JsonWriter writer, - ApiEnum value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize(writer, value.Json, options); - } -} diff --git a/src/Imagekit/Core/ClientOptions.cs b/src/Imagekit/Core/ClientOptions.cs deleted file mode 100644 index 1d8a8278..00000000 --- a/src/Imagekit/Core/ClientOptions.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System; -using System.Net.Http; -using Imagekit.Exceptions; - -namespace Imagekit.Core; - -public struct ClientOptions() -{ - public HttpClient HttpClient { get; set; } = new(); - - Lazy _baseUrl = new(() => - new Uri( - Environment.GetEnvironmentVariable("IMAGE_KIT_BASE_URL") ?? "https://api.imagekit.io" - ) - ); - public Uri BaseUrl - { - readonly get { return _baseUrl.Value; } - set { _baseUrl = new(() => value); } - } - - public bool ResponseValidation { get; set; } = false; - - public TimeSpan Timeout { get; set; } = TimeSpan.FromMinutes(1); - - /// - /// Your ImageKit private API key (starts with `private_`). You can find this - /// in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/api-keys). - /// - Lazy _privateKey = new(() => - Environment.GetEnvironmentVariable("IMAGEKIT_PRIVATE_KEY") - ?? throw new ImageKitInvalidDataException( - string.Format("{0} cannot be null", nameof(PrivateKey)), - new ArgumentNullException(nameof(PrivateKey)) - ) - ); - - /// - /// Your ImageKit private API key (starts with `private_`). You can find this - /// in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/api-keys). - /// - public string PrivateKey - { - readonly get { return _privateKey.Value; } - set { _privateKey = new(() => value); } - } - - /// - /// ImageKit uses your API key as username and ignores the password. The SDK - /// sets a dummy value. You can ignore this field. - /// - Lazy _password = new(() => - Environment.GetEnvironmentVariable("OPTIONAL_IMAGEKIT_IGNORES_THIS") ?? "do_not_set" - ); - - /// - /// ImageKit uses your API key as username and ignores the password. The SDK - /// sets a dummy value. You can ignore this field. - /// - public string? Password - { - readonly get { return _password.Value; } - set { _password = new(() => value); } - } - - /// - /// Your ImageKit webhook secret for verifying webhook signatures (starts with - /// `whsec_`). You can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks). - /// Only required if you're using webhooks. - /// - Lazy _webhookSecret = new(() => - Environment.GetEnvironmentVariable("IMAGEKIT_WEBHOOK_SECRET") - ); - - /// - /// Your ImageKit webhook secret for verifying webhook signatures (starts with - /// `whsec_`). You can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks). - /// Only required if you're using webhooks. - /// - public string? WebhookSecret - { - readonly get { return _webhookSecret.Value; } - set { _webhookSecret = new(() => value); } - } -} diff --git a/src/Imagekit/Core/HttpRequest.cs b/src/Imagekit/Core/HttpRequest.cs deleted file mode 100644 index f30f7039..00000000 --- a/src/Imagekit/Core/HttpRequest.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Net.Http; - -namespace Imagekit.Core; - -public sealed class HttpRequest

- where P : ParamsBase -{ - public required HttpMethod Method { get; init; } - - public required P Params { get; init; } -} diff --git a/src/Imagekit/Core/HttpResponse.cs b/src/Imagekit/Core/HttpResponse.cs deleted file mode 100644 index 7c2123b6..00000000 --- a/src/Imagekit/Core/HttpResponse.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using System.Net.Http; -using System.Text.Json; -using System.Threading.Tasks; -using Imagekit.Exceptions; - -namespace Imagekit.Core; - -public sealed class HttpResponse : IDisposable -{ - public required HttpResponseMessage Message { get; init; } - - public async Task Deserialize() - { - try - { - return JsonSerializer.Deserialize( - await Message.Content.ReadAsStreamAsync().ConfigureAwait(false), - ModelBase.SerializerOptions - ) ?? throw new ImageKitInvalidDataException("Response cannot be null"); - } - catch (HttpRequestException e) - { - throw new ImageKitIOException("I/O Exception", e); - } - } - - public void Dispose() - { - this.Message.Dispose(); - } -} diff --git a/src/Imagekit/Core/IVariant.cs b/src/Imagekit/Core/IVariant.cs deleted file mode 100644 index 1aebab56..00000000 --- a/src/Imagekit/Core/IVariant.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Imagekit; - -interface IVariant - where TVariant : IVariant -{ - static abstract TVariant From(TValue value); - TValue Value { get; } -} diff --git a/src/Imagekit/Core/ModelBase.cs b/src/Imagekit/Core/ModelBase.cs deleted file mode 100644 index 36549c63..00000000 --- a/src/Imagekit/Core/ModelBase.cs +++ /dev/null @@ -1,212 +0,0 @@ -using System.Collections.Generic; -using System.Text.Json; -using Imagekit.Models; -using Imagekit.Models.Cache.Invalidation.InvalidationGetResponseProperties; -using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties; -using Imagekit.Models.Files.FileUpdateResponseProperties.IntersectionMember1Properties.ExtensionStatusProperties; -using Imagekit.Models.ImageOverlayProperties.IntersectionMember1Properties; -using Imagekit.Models.OverlayPositionProperties; -using Imagekit.Models.SubtitleOverlayTransformationProperties; -using Imagekit.Models.TextOverlayTransformationProperties; -using Imagekit.Models.UnnamedSchemaWithArrayParent0Properties.AutoTaggingExtensionProperties; -using Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.IntersectionMember1Properties.DataProperties.TransformationProperties.OptionsProperties; -using Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.IntersectionMember1Properties.DataProperties.TransformationProperties.ErrorProperties; -using AbsProperties = Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.AbsProperties; -using AssetListParamsProperties = Imagekit.Models.Assets.AssetListParamsProperties; -using ExtensionStatusProperties = Imagekit.Models.Files.FileUploadResponseProperties.ExtensionStatusProperties; -using FileProperties = Imagekit.Models.Files.FileProperties; -using FileUploadParamsProperties = Imagekit.Models.Files.FileUploadParamsProperties; -using FolderProperties = Imagekit.Models.Files.FolderProperties; -using IntersectionMember1Properties = Imagekit.Models.SubtitleOverlayProperties.IntersectionMember1Properties; -using JobGetResponseProperties = Imagekit.Models.Folders.Job.JobGetResponseProperties; -using OptionsProperties = Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.IntersectionMember1Properties.DataProperties.TransformationProperties.OptionsProperties; -using SchemaProperties = Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties; -using SelectedFieldsSchemaItemProperties = Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; -using TransformationProperties = Imagekit.Models.TransformationProperties; - -namespace Imagekit.Core; - -public abstract record class ModelBase -{ - public Dictionary Properties { get; set; } = []; - - internal static readonly JsonSerializerOptions SerializerOptions = new() - { - Converters = - { - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter< - string, - global::Imagekit.Models.TextOverlayProperties.IntersectionMember1Properties.Encoding - >(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter< - string, - global::Imagekit.Models.VideoOverlayProperties.IntersectionMember1Properties.Encoding - >(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter< - string, - global::Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.Type - >(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter< - string, - global::Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.ExtensionStatusProperties.AIAutoDescription - >(), - new ApiEnumConverter< - string, - global::Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.ExtensionStatusProperties.AwsAutoTagging - >(), - new ApiEnumConverter< - string, - global::Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.ExtensionStatusProperties.GoogleAutoTagging - >(), - new ApiEnumConverter< - string, - global::Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.ExtensionStatusProperties.RemoveBg - >(), - new ApiEnumConverter< - string, - global::Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.Type - >(), - new ApiEnumConverter< - string, - global::Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.ResponseField - >(), - new ApiEnumConverter< - string, - global::Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.AbsProperties.Protocol - >(), - new ApiEnumConverter< - string, - global::Imagekit.Models.Webhooks.UploadPostTransformErrorEventProperties.IntersectionMember1Properties.RequestProperties.TransformationProperties.Type - >(), - new ApiEnumConverter< - string, - global::Imagekit.Models.Webhooks.UploadPostTransformErrorEventProperties.IntersectionMember1Properties.RequestProperties.TransformationProperties.Protocol - >(), - new ApiEnumConverter< - string, - global::Imagekit.Models.Webhooks.UploadPostTransformSuccessEventProperties.IntersectionMember1Properties.RequestProperties.TransformationProperties.Type - >(), - new ApiEnumConverter< - string, - global::Imagekit.Models.Webhooks.UploadPostTransformSuccessEventProperties.IntersectionMember1Properties.RequestProperties.TransformationProperties.Protocol - >(), - new ApiEnumConverter< - string, - global::Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.ExtensionStatusProperties.AIAutoDescription - >(), - new ApiEnumConverter< - string, - global::Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.ExtensionStatusProperties.AwsAutoTagging - >(), - new ApiEnumConverter< - string, - global::Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.ExtensionStatusProperties.GoogleAutoTagging - >(), - new ApiEnumConverter< - string, - global::Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.ExtensionStatusProperties.RemoveBg - >(), - new ApiEnumConverter< - string, - global::Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.Type - >(), - new ApiEnumConverter< - string, - global::Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.IntersectionMember1Properties.DataProperties.TransformationProperties.Type - >(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter< - string, - global::Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.IntersectionMember1Properties.DataProperties.TransformationProperties.Type - >(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter< - string, - global::Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.IntersectionMember1Properties.DataProperties.TransformationProperties.Type - >(), - new ApiEnumConverter< - string, - global::Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.IntersectionMember1Properties.DataProperties.TransformationProperties.OptionsProperties.AudioCodec - >(), - new ApiEnumConverter< - string, - global::Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.IntersectionMember1Properties.DataProperties.TransformationProperties.OptionsProperties.Format - >(), - new ApiEnumConverter< - string, - global::Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.IntersectionMember1Properties.DataProperties.TransformationProperties.OptionsProperties.StreamProtocol - >(), - new ApiEnumConverter< - string, - global::Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.IntersectionMember1Properties.DataProperties.TransformationProperties.OptionsProperties.VideoCodec - >(), - }, - }; - - static readonly JsonSerializerOptions _toStringSerializerOptions = new(SerializerOptions) - { - WriteIndented = true, - }; - - public sealed override string? ToString() - { - return JsonSerializer.Serialize(this.Properties, _toStringSerializerOptions); - } - - public abstract void Validate(); -} - -interface IFromRaw -{ - static abstract T FromRawUnchecked(Dictionary properties); -} diff --git a/src/Imagekit/Core/ModelConverter.cs b/src/Imagekit/Core/ModelConverter.cs deleted file mode 100644 index 0c40a8ef..00000000 --- a/src/Imagekit/Core/ModelConverter.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit; - -sealed class ModelConverter : JsonConverter - where TModel : ModelBase, IFromRaw -{ - public override TModel? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - Dictionary? properties = JsonSerializer.Deserialize< - Dictionary - >(ref reader, options); - if (properties == null) - return null; - - return TModel.FromRawUnchecked(properties); - } - - public override void Write(Utf8JsonWriter writer, TModel value, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, value.Properties, options); - } -} diff --git a/src/Imagekit/HttpException.cs b/src/Imagekit/HttpException.cs deleted file mode 100644 index 2986ea2c..00000000 --- a/src/Imagekit/HttpException.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Diagnostics.CodeAnalysis; -using System.Net; - -namespace Imagekit; - -public sealed class HttpException : Exception -{ - public required HttpStatusCode? StatusCode { get; set; } - public required string ResponseBody { get; set; } - public override string Message - { - get - { - return string.Format( - "Status Code: {0}\n{1}", - this.StatusCode?.ToString() ?? "Unknown", - this.ResponseBody - ); - } - } - - [SetsRequiredMembers] - public HttpException(HttpStatusCode? statusCode, string responseBody) - { - this.StatusCode = statusCode; - this.ResponseBody = responseBody; - } -} diff --git a/src/Imagekit/IImageKitClient.cs b/src/Imagekit/IImageKitClient.cs deleted file mode 100644 index c35bc65a..00000000 --- a/src/Imagekit/IImageKitClient.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System; -using System.Net.Http; -using System.Threading.Tasks; -using Imagekit.Core; -using Imagekit.Services.Accounts; -using Imagekit.Services.Assets; -using Imagekit.Services.Beta; -using Imagekit.Services.Cache; -using Imagekit.Services.CustomMetadataFields; -using Imagekit.Services.Files; -using Imagekit.Services.Folders; -using Imagekit.Services.Webhooks; - -namespace Imagekit; - -public interface IImageKitClient -{ - HttpClient HttpClient { get; init; } - - Uri BaseUrl { get; init; } - - bool ResponseValidation { get; init; } - - TimeSpan Timeout { get; init; } - - ///

- /// Your ImageKit private API key (starts with `private_`). You can find this - /// in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/api-keys). - /// - string PrivateKey { get; init; } - - /// - /// ImageKit uses your API key as username and ignores the password. The SDK - /// sets a dummy value. You can ignore this field. - /// - string? Password { get; init; } - - /// - /// Your ImageKit webhook secret for verifying webhook signatures (starts with - /// `whsec_`). You can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks). - /// Only required if you're using webhooks. - /// - string? WebhookSecret { get; init; } - - ICustomMetadataFieldService CustomMetadataFields { get; } - - IFileService Files { get; } - - IAssetService Assets { get; } - - ICacheService Cache { get; } - - IFolderService Folders { get; } - - IAccountService Accounts { get; } - - IBetaService Beta { get; } - - IWebhookService Webhooks { get; } - - Task Execute(HttpRequest request) - where T : ParamsBase; -} diff --git a/src/Imagekit/ImageKitClient.cs b/src/Imagekit/ImageKitClient.cs deleted file mode 100644 index 32ec1de6..00000000 --- a/src/Imagekit/ImageKitClient.cs +++ /dev/null @@ -1,168 +0,0 @@ -using System; -using System.Net.Http; -using System.Threading; -using System.Threading.Tasks; -using Imagekit.Core; -using Imagekit.Exceptions; -using Imagekit.Services.Accounts; -using Imagekit.Services.Assets; -using Imagekit.Services.Beta; -using Imagekit.Services.Cache; -using Imagekit.Services.CustomMetadataFields; -using Imagekit.Services.Files; -using Imagekit.Services.Folders; -using Imagekit.Services.Webhooks; - -namespace Imagekit; - -public sealed class ImageKitClient : IImageKitClient -{ - readonly ClientOptions _options = new(); - - public HttpClient HttpClient - { - get { return this._options.HttpClient; } - init { this._options.HttpClient = value; } - } - - public Uri BaseUrl - { - get { return this._options.BaseUrl; } - init { this._options.BaseUrl = value; } - } - - public bool ResponseValidation - { - get { return this._options.ResponseValidation; } - init { this._options.ResponseValidation = value; } - } - - public TimeSpan Timeout - { - get { return this._options.Timeout; } - init { this._options.Timeout = value; } - } - - public string PrivateKey - { - get { return this._options.PrivateKey; } - init { this._options.PrivateKey = value; } - } - - public string? Password - { - get { return this._options.Password; } - init { this._options.Password = value; } - } - - public string? WebhookSecret - { - get { return this._options.WebhookSecret; } - init { this._options.WebhookSecret = value; } - } - - readonly Lazy _customMetadataFields; - public ICustomMetadataFieldService CustomMetadataFields - { - get { return _customMetadataFields.Value; } - } - - readonly Lazy _files; - public IFileService Files - { - get { return _files.Value; } - } - - readonly Lazy _assets; - public IAssetService Assets - { - get { return _assets.Value; } - } - - readonly Lazy _cache; - public ICacheService Cache - { - get { return _cache.Value; } - } - - readonly Lazy _folders; - public IFolderService Folders - { - get { return _folders.Value; } - } - - readonly Lazy _accounts; - public IAccountService Accounts - { - get { return _accounts.Value; } - } - - readonly Lazy _beta; - public IBetaService Beta - { - get { return _beta.Value; } - } - - readonly Lazy _webhooks; - public IWebhookService Webhooks - { - get { return _webhooks.Value; } - } - - public async Task Execute(HttpRequest request) - where T : ParamsBase - { - using HttpRequestMessage requestMessage = new(request.Method, request.Params.Url(this)) - { - Content = request.Params.BodyContent(), - }; - request.Params.AddHeadersToRequest(requestMessage, this); - using CancellationTokenSource cts = new(this.Timeout); - HttpResponseMessage responseMessage; - try - { - responseMessage = await this - .HttpClient.SendAsync( - requestMessage, - HttpCompletionOption.ResponseHeadersRead, - cts.Token - ) - .ConfigureAwait(false); - } - catch (HttpRequestException e1) - { - throw new ImageKitIOException("I/O exception", e1); - } - if (!responseMessage.IsSuccessStatusCode) - { - try - { - throw ImageKitExceptionFactory.CreateApiException( - responseMessage.StatusCode, - await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false) - ); - } - catch (HttpRequestException e) - { - throw new ImageKitIOException("I/O Exception", e); - } - finally - { - responseMessage.Dispose(); - } - } - return new() { Message = responseMessage }; - } - - public ImageKitClient() - { - _customMetadataFields = new(() => new CustomMetadataFieldService(this)); - _files = new(() => new FileService(this)); - _assets = new(() => new AssetService(this)); - _cache = new(() => new CacheService(this)); - _folders = new(() => new FolderService(this)); - _accounts = new(() => new AccountService(this)); - _beta = new(() => new BetaService(this)); - _webhooks = new(() => new WebhookService(this)); - } -} diff --git a/src/Imagekit/Imagekit.csproj b/src/Imagekit/Imagekit.csproj deleted file mode 100644 index 577627ab..00000000 --- a/src/Imagekit/Imagekit.csproj +++ /dev/null @@ -1,41 +0,0 @@ - - - - The official .NET library for the Image Kit C# service API. - - SDK Code Generation Image Kit C# - Apache-2.0 - enable - 0.0.1 - net8.0 - latest - - true - README.md - https://www.github.com/stainless-sdks/imagekit-csharp - git - - true - true - - $(NoWarn),1570,1573,1574,1591 - - $(NoWarn),IL2026,IL3050 - Debug;Release - true - true - disable - - - - - - - - diff --git a/src/Imagekit/Models/Accounts/Origins/OriginCreateParams.cs b/src/Imagekit/Models/Accounts/Origins/OriginCreateParams.cs deleted file mode 100644 index 828bf691..00000000 --- a/src/Imagekit/Models/Accounts/Origins/OriginCreateParams.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Net.Http; -using System.Text; -using System.Text.Json; - -namespace Imagekit.Models.Accounts.Origins; - -/// -/// **Note:** This API is currently in beta. Creates a new origin and returns the -/// origin object. -/// -public sealed record class OriginCreateParams : ParamsBase -{ - public Dictionary BodyProperties { get; set; } = []; - - /// - /// Schema for origin request resources. - /// - public required OriginRequest Origin - { - get - { - if (!this.BodyProperties.TryGetValue("origin", out JsonElement element)) - throw new ArgumentOutOfRangeException("origin", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("origin"); - } - set - { - this.BodyProperties["origin"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override Uri Url(IImageKitClient client) - { - return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/accounts/origins") - { - Query = this.QueryString(client), - }.Uri; - } - - public StringContent BodyContent() - { - return new( - JsonSerializer.Serialize(this.BodyProperties), - Encoding.UTF8, - "application/json" - ); - } - - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginDeleteParams.cs b/src/Imagekit/Models/Accounts/Origins/OriginDeleteParams.cs deleted file mode 100644 index 826a127b..00000000 --- a/src/Imagekit/Models/Accounts/Origins/OriginDeleteParams.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using System.Net.Http; - -namespace Imagekit.Models.Accounts.Origins; - -/// -/// **Note:** This API is currently in beta. Permanently removes the origin identified -/// by `id`. If the origin is in use by any URL‑endpoints, the API will return an -/// error. -/// -public sealed record class OriginDeleteParams : ParamsBase -{ - public required string ID; - - public override Uri Url(IImageKitClient client) - { - return new UriBuilder( - client.BaseUrl.ToString().TrimEnd('/') - + string.Format("/v1/accounts/origins/{0}", this.ID) - ) - { - Query = this.QueryString(client), - }.Uri; - } - - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginGetParams.cs b/src/Imagekit/Models/Accounts/Origins/OriginGetParams.cs deleted file mode 100644 index 1387a2da..00000000 --- a/src/Imagekit/Models/Accounts/Origins/OriginGetParams.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using System.Net.Http; - -namespace Imagekit.Models.Accounts.Origins; - -/// -/// **Note:** This API is currently in beta. Retrieves the origin identified by -/// `id`. -/// -public sealed record class OriginGetParams : ParamsBase -{ - public required string ID; - - public override Uri Url(IImageKitClient client) - { - return new UriBuilder( - client.BaseUrl.ToString().TrimEnd('/') - + string.Format("/v1/accounts/origins/{0}", this.ID) - ) - { - Query = this.QueryString(client), - }.Uri; - } - - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginListParams.cs b/src/Imagekit/Models/Accounts/Origins/OriginListParams.cs deleted file mode 100644 index 29897449..00000000 --- a/src/Imagekit/Models/Accounts/Origins/OriginListParams.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Net.Http; - -namespace Imagekit.Models.Accounts.Origins; - -/// -/// **Note:** This API is currently in beta. Returns an array of all configured -/// origins for the current account. -/// -public sealed record class OriginListParams : ParamsBase -{ - public override Uri Url(IImageKitClient client) - { - return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/accounts/origins") - { - Query = this.QueryString(client), - }.Uri; - } - - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequest.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequest.cs deleted file mode 100644 index 7feca17f..00000000 --- a/src/Imagekit/Models/Accounts/Origins/OriginRequest.cs +++ /dev/null @@ -1,540 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Accounts.Origins.OriginRequestProperties; - -namespace Imagekit.Models.Accounts.Origins; - -/// -/// Schema for origin request resources. -/// -[JsonConverter(typeof(OriginRequestConverter))] -public record class OriginRequest -{ - public object Value { get; private init; } - - public string? AccessKey - { - get - { - return Match( - s3: (x) => x.AccessKey, - s3Compatible: (x) => x.AccessKey, - cloudinaryBackup: (x) => x.AccessKey, - webFolder: (_) => null, - webProxy: (_) => null, - gcs: (_) => null, - azureBlob: (_) => null, - akeneoPim: (_) => null - ); - } - } - - public string? Bucket - { - get - { - return Match( - s3: (x) => x.Bucket, - s3Compatible: (x) => x.Bucket, - cloudinaryBackup: (x) => x.Bucket, - webFolder: (_) => null, - webProxy: (_) => null, - gcs: (x) => x.Bucket, - azureBlob: (_) => null, - akeneoPim: (_) => null - ); - } - } - - public string Name - { - get - { - return Match( - s3: (x) => x.Name, - s3Compatible: (x) => x.Name, - cloudinaryBackup: (x) => x.Name, - webFolder: (x) => x.Name, - webProxy: (x) => x.Name, - gcs: (x) => x.Name, - azureBlob: (x) => x.Name, - akeneoPim: (x) => x.Name - ); - } - } - - public string? SecretKey - { - get - { - return Match( - s3: (x) => x.SecretKey, - s3Compatible: (x) => x.SecretKey, - cloudinaryBackup: (x) => x.SecretKey, - webFolder: (_) => null, - webProxy: (_) => null, - gcs: (_) => null, - azureBlob: (_) => null, - akeneoPim: (_) => null - ); - } - } - - public string? BaseURLForCanonicalHeader - { - get - { - return Match( - s3: (x) => x.BaseURLForCanonicalHeader, - s3Compatible: (x) => x.BaseURLForCanonicalHeader, - cloudinaryBackup: (x) => x.BaseURLForCanonicalHeader, - webFolder: (x) => x.BaseURLForCanonicalHeader, - webProxy: (x) => x.BaseURLForCanonicalHeader, - gcs: (x) => x.BaseURLForCanonicalHeader, - azureBlob: (x) => x.BaseURLForCanonicalHeader, - akeneoPim: (x) => x.BaseURLForCanonicalHeader - ); - } - } - - public bool? IncludeCanonicalHeader - { - get - { - return Match( - s3: (x) => x.IncludeCanonicalHeader, - s3Compatible: (x) => x.IncludeCanonicalHeader, - cloudinaryBackup: (x) => x.IncludeCanonicalHeader, - webFolder: (x) => x.IncludeCanonicalHeader, - webProxy: (x) => x.IncludeCanonicalHeader, - gcs: (x) => x.IncludeCanonicalHeader, - azureBlob: (x) => x.IncludeCanonicalHeader, - akeneoPim: (x) => x.IncludeCanonicalHeader - ); - } - } - - public string? Prefix - { - get - { - return Match( - s3: (x) => x.Prefix, - s3Compatible: (x) => x.Prefix, - cloudinaryBackup: (x) => x.Prefix, - webFolder: (_) => null, - webProxy: (_) => null, - gcs: (x) => x.Prefix, - azureBlob: (x) => x.Prefix, - akeneoPim: (_) => null - ); - } - } - - public string? BaseURL - { - get - { - return Match( - s3: (_) => null, - s3Compatible: (_) => null, - cloudinaryBackup: (_) => null, - webFolder: (x) => x.BaseURL, - webProxy: (_) => null, - gcs: (_) => null, - azureBlob: (_) => null, - akeneoPim: (x) => x.BaseURL - ); - } - } - - public OriginRequest(S3 value) - { - Value = value; - } - - public OriginRequest(S3Compatible value) - { - Value = value; - } - - public OriginRequest(CloudinaryBackup value) - { - Value = value; - } - - public OriginRequest(WebFolder value) - { - Value = value; - } - - public OriginRequest(WebProxy value) - { - Value = value; - } - - public OriginRequest(Gcs value) - { - Value = value; - } - - public OriginRequest(AzureBlob value) - { - Value = value; - } - - public OriginRequest(AkeneoPim value) - { - Value = value; - } - - OriginRequest(UnknownVariant value) - { - Value = value; - } - - public static OriginRequest CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickS3([NotNullWhen(true)] out S3? value) - { - value = this.Value as S3; - return value != null; - } - - public bool TryPickS3Compatible([NotNullWhen(true)] out S3Compatible? value) - { - value = this.Value as S3Compatible; - return value != null; - } - - public bool TryPickCloudinaryBackup([NotNullWhen(true)] out CloudinaryBackup? value) - { - value = this.Value as CloudinaryBackup; - return value != null; - } - - public bool TryPickWebFolder([NotNullWhen(true)] out WebFolder? value) - { - value = this.Value as WebFolder; - return value != null; - } - - public bool TryPickWebProxy([NotNullWhen(true)] out WebProxy? value) - { - value = this.Value as WebProxy; - return value != null; - } - - public bool TryPickGcs([NotNullWhen(true)] out Gcs? value) - { - value = this.Value as Gcs; - return value != null; - } - - public bool TryPickAzureBlob([NotNullWhen(true)] out AzureBlob? value) - { - value = this.Value as AzureBlob; - return value != null; - } - - public bool TryPickAkeneoPim([NotNullWhen(true)] out AkeneoPim? value) - { - value = this.Value as AkeneoPim; - return value != null; - } - - public void Switch( - Action s3, - Action s3Compatible, - Action cloudinaryBackup, - Action webFolder, - Action webProxy, - Action gcs, - Action azureBlob, - Action akeneoPim - ) - { - switch (this.Value) - { - case S3 value: - s3(value); - break; - case S3Compatible value: - s3Compatible(value); - break; - case CloudinaryBackup value: - cloudinaryBackup(value); - break; - case WebFolder value: - webFolder(value); - break; - case WebProxy value: - webProxy(value); - break; - case Gcs value: - gcs(value); - break; - case AzureBlob value: - azureBlob(value); - break; - case AkeneoPim value: - akeneoPim(value); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match( - Func s3, - Func s3Compatible, - Func cloudinaryBackup, - Func webFolder, - Func webProxy, - Func gcs, - Func azureBlob, - Func akeneoPim - ) - { - return this.Value switch - { - OriginRequestVariants::S3 inner => s3(inner), - OriginRequestVariants::S3Compatible inner => s3Compatible(inner), - OriginRequestVariants::CloudinaryBackup inner => cloudinaryBackup(inner), - OriginRequestVariants::WebFolder inner => webFolder(inner), - OriginRequestVariants::WebProxy inner => webProxy(inner), - OriginRequestVariants::Gcs inner => gcs(inner), - OriginRequestVariants::AzureBlob inner => azureBlob(inner), - OriginRequestVariants::AkeneoPim inner => akeneoPim(inner), - _ => throw new InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException( - "Data did not match any variant of OriginRequest" - ); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class OriginRequestConverter : JsonConverter -{ - public override OriginRequest? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - var json = JsonSerializer.Deserialize(ref reader, options); - string? type; - try - { - type = json.GetProperty("type").GetString(); - } - catch - { - type = null; - } - - switch (type) - { - case "S3": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - deserialized.Validate(); - return new OriginRequest(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "S3_COMPATIBLE": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - deserialized.Validate(); - return new OriginRequest(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "CLOUDINARY_BACKUP": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - deserialized.Validate(); - return new OriginRequest(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "WEB_FOLDER": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - deserialized.Validate(); - return new OriginRequest(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "WEB_PROXY": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - deserialized.Validate(); - return new OriginRequest(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "GCS": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - deserialized.Validate(); - return new OriginRequest(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "AZURE_BLOB": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - deserialized.Validate(); - return new OriginRequest(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "AKENEO_PIM": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - deserialized.Validate(); - return new OriginRequest(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - default: - { - throw new Exception(); - } - } - } - - public override void Write( - Utf8JsonWriter writer, - OriginRequest value, - JsonSerializerOptions options - ) - { - object variant = value switch - { - OriginRequestVariants::S3(var s3) => s3, - OriginRequestVariants::S3Compatible(var s3Compatible) => s3Compatible, - OriginRequestVariants::CloudinaryBackup(var cloudinaryBackup) => cloudinaryBackup, - OriginRequestVariants::WebFolder(var webFolder) => webFolder, - OriginRequestVariants::WebProxy(var webProxy) => webProxy, - OriginRequestVariants::Gcs(var gcs) => gcs, - OriginRequestVariants::AzureBlob(var azureBlob) => azureBlob, - OriginRequestVariants::AkeneoPim(var akeneoPim) => akeneoPim, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AkeneoPim.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AkeneoPim.cs deleted file mode 100644 index 1638783d..00000000 --- a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AkeneoPim.cs +++ /dev/null @@ -1,241 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Accounts.Origins.OriginRequestProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class AkeneoPim : ModelBase, IFromRaw -{ - /// - /// Akeneo instance base URL. - /// - public required string BaseURL - { - get - { - if (!this.Properties.TryGetValue("baseUrl", out JsonElement element)) - throw new ArgumentOutOfRangeException("baseUrl", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("baseUrl"); - } - set - { - this.Properties["baseUrl"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Akeneo API client ID. - /// - public required string ClientID - { - get - { - if (!this.Properties.TryGetValue("clientId", out JsonElement element)) - throw new ArgumentOutOfRangeException("clientId", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("clientId"); - } - set - { - this.Properties["clientId"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Akeneo API client secret. - /// - public required string ClientSecret - { - get - { - if (!this.Properties.TryGetValue("clientSecret", out JsonElement element)) - throw new ArgumentOutOfRangeException("clientSecret", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("clientSecret"); - } - set - { - this.Properties["clientSecret"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Display name of the origin. - /// - public required string Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - throw new ArgumentOutOfRangeException("name", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("name"); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Akeneo API password. - /// - public required string Password - { - get - { - if (!this.Properties.TryGetValue("password", out JsonElement element)) - throw new ArgumentOutOfRangeException("password", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("password"); - } - set - { - this.Properties["password"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public AkeneoPimProperties::Type Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ) - ?? throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentNullException("type") - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Akeneo API username. - /// - public required string Username - { - get - { - if (!this.Properties.TryGetValue("username", out JsonElement element)) - throw new ArgumentOutOfRangeException("username", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("username"); - } - set - { - this.Properties["username"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// URL used in the Canonical header (if enabled). - /// - public string? BaseURLForCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to send a Canonical header. - /// - public bool? IncludeCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.BaseURL; - _ = this.ClientID; - _ = this.ClientSecret; - _ = this.Name; - _ = this.Password; - this.Type.Validate(); - _ = this.Username; - _ = this.BaseURLForCanonicalHeader; - _ = this.IncludeCanonicalHeader; - } - - public AkeneoPim() - { - this.Type = new(); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - AkeneoPim(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static AkeneoPim FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AkeneoPimProperties/Type.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AkeneoPimProperties/Type.cs deleted file mode 100644 index 8e6ca00f..00000000 --- a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AkeneoPimProperties/Type.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Accounts.Origins.OriginRequestProperties.AkeneoPimProperties; - -[JsonConverter(typeof(Converter))] -public class Type -{ - public JsonElement Json { get; private init; } - - public Type() - { - Json = JsonSerializer.Deserialize("\"AKENEO_PIM\""); - } - - Type(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new Type().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); - } - } - - class Converter : JsonConverter - { - public override Type? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AzureBlob.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AzureBlob.cs deleted file mode 100644 index 12199139..00000000 --- a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AzureBlob.cs +++ /dev/null @@ -1,205 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Accounts.Origins.OriginRequestProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class AzureBlob : ModelBase, IFromRaw -{ - public required string AccountName - { - get - { - if (!this.Properties.TryGetValue("accountName", out JsonElement element)) - throw new ArgumentOutOfRangeException("accountName", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("accountName"); - } - set - { - this.Properties["accountName"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required string Container - { - get - { - if (!this.Properties.TryGetValue("container", out JsonElement element)) - throw new ArgumentOutOfRangeException("container", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("container"); - } - set - { - this.Properties["container"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Display name of the origin. - /// - public required string Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - throw new ArgumentOutOfRangeException("name", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("name"); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required string SasToken - { - get - { - if (!this.Properties.TryGetValue("sasToken", out JsonElement element)) - throw new ArgumentOutOfRangeException("sasToken", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("sasToken"); - } - set - { - this.Properties["sasToken"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public AzureBlobProperties::Type Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ) - ?? throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentNullException("type") - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// URL used in the Canonical header (if enabled). - /// - public string? BaseURLForCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to send a Canonical header. - /// - public bool? IncludeCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public string? Prefix - { - get - { - if (!this.Properties.TryGetValue("prefix", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["prefix"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.AccountName; - _ = this.Container; - _ = this.Name; - _ = this.SasToken; - this.Type.Validate(); - _ = this.BaseURLForCanonicalHeader; - _ = this.IncludeCanonicalHeader; - _ = this.Prefix; - } - - public AzureBlob() - { - this.Type = new(); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - AzureBlob(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static AzureBlob FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AzureBlobProperties/Type.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AzureBlobProperties/Type.cs deleted file mode 100644 index 95715670..00000000 --- a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/AzureBlobProperties/Type.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Accounts.Origins.OriginRequestProperties.AzureBlobProperties; - -[JsonConverter(typeof(Converter))] -public class Type -{ - public JsonElement Json { get; private init; } - - public Type() - { - Json = JsonSerializer.Deserialize("\"AZURE_BLOB\""); - } - - Type(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new Type().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); - } - } - - class Converter : JsonConverter - { - public override Type? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/CloudinaryBackup.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/CloudinaryBackup.cs deleted file mode 100644 index 5c214845..00000000 --- a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/CloudinaryBackup.cs +++ /dev/null @@ -1,217 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Accounts.Origins.OriginRequestProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class CloudinaryBackup : ModelBase, IFromRaw -{ - /// - /// Access key for the bucket. - /// - public required string AccessKey - { - get - { - if (!this.Properties.TryGetValue("accessKey", out JsonElement element)) - throw new ArgumentOutOfRangeException("accessKey", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("accessKey"); - } - set - { - this.Properties["accessKey"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// S3 bucket name. - /// - public required string Bucket - { - get - { - if (!this.Properties.TryGetValue("bucket", out JsonElement element)) - throw new ArgumentOutOfRangeException("bucket", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("bucket"); - } - set - { - this.Properties["bucket"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Display name of the origin. - /// - public required string Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - throw new ArgumentOutOfRangeException("name", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("name"); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Secret key for the bucket. - /// - public required string SecretKey - { - get - { - if (!this.Properties.TryGetValue("secretKey", out JsonElement element)) - throw new ArgumentOutOfRangeException("secretKey", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("secretKey"); - } - set - { - this.Properties["secretKey"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public CloudinaryBackupProperties::Type Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ) - ?? throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentNullException("type") - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// URL used in the Canonical header (if enabled). - /// - public string? BaseURLForCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to send a Canonical header. - /// - public bool? IncludeCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Path prefix inside the bucket. - /// - public string? Prefix - { - get - { - if (!this.Properties.TryGetValue("prefix", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["prefix"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.AccessKey; - _ = this.Bucket; - _ = this.Name; - _ = this.SecretKey; - this.Type.Validate(); - _ = this.BaseURLForCanonicalHeader; - _ = this.IncludeCanonicalHeader; - _ = this.Prefix; - } - - public CloudinaryBackup() - { - this.Type = new(); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - CloudinaryBackup(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static CloudinaryBackup FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/CloudinaryBackupProperties/Type.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/CloudinaryBackupProperties/Type.cs deleted file mode 100644 index 760556a4..00000000 --- a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/CloudinaryBackupProperties/Type.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Accounts.Origins.OriginRequestProperties.CloudinaryBackupProperties; - -[JsonConverter(typeof(Converter))] -public class Type -{ - public JsonElement Json { get; private init; } - - public Type() - { - Json = JsonSerializer.Deserialize("\"CLOUDINARY_BACKUP\""); - } - - Type(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new Type().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); - } - } - - class Converter : JsonConverter - { - public override Type? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/Gcs.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/Gcs.cs deleted file mode 100644 index 7c29c679..00000000 --- a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/Gcs.cs +++ /dev/null @@ -1,205 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Accounts.Origins.OriginRequestProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Gcs : ModelBase, IFromRaw -{ - public required string Bucket - { - get - { - if (!this.Properties.TryGetValue("bucket", out JsonElement element)) - throw new ArgumentOutOfRangeException("bucket", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("bucket"); - } - set - { - this.Properties["bucket"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required string ClientEmail - { - get - { - if (!this.Properties.TryGetValue("clientEmail", out JsonElement element)) - throw new ArgumentOutOfRangeException("clientEmail", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("clientEmail"); - } - set - { - this.Properties["clientEmail"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Display name of the origin. - /// - public required string Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - throw new ArgumentOutOfRangeException("name", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("name"); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required string PrivateKey - { - get - { - if (!this.Properties.TryGetValue("privateKey", out JsonElement element)) - throw new ArgumentOutOfRangeException("privateKey", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("privateKey"); - } - set - { - this.Properties["privateKey"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public GcsProperties::Type Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ) - ?? throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentNullException("type") - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// URL used in the Canonical header (if enabled). - /// - public string? BaseURLForCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to send a Canonical header. - /// - public bool? IncludeCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public string? Prefix - { - get - { - if (!this.Properties.TryGetValue("prefix", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["prefix"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.Bucket; - _ = this.ClientEmail; - _ = this.Name; - _ = this.PrivateKey; - this.Type.Validate(); - _ = this.BaseURLForCanonicalHeader; - _ = this.IncludeCanonicalHeader; - _ = this.Prefix; - } - - public Gcs() - { - this.Type = new(); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Gcs(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Gcs FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/GcsProperties/Type.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/GcsProperties/Type.cs deleted file mode 100644 index d989ede9..00000000 --- a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/GcsProperties/Type.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Accounts.Origins.OriginRequestProperties.GcsProperties; - -[JsonConverter(typeof(Converter))] -public class Type -{ - public JsonElement Json { get; private init; } - - public Type() - { - Json = JsonSerializer.Deserialize("\"GCS\""); - } - - Type(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new Type().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); - } - } - - class Converter : JsonConverter - { - public override Type? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3.cs deleted file mode 100644 index 792e8aac..00000000 --- a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3.cs +++ /dev/null @@ -1,217 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Accounts.Origins.OriginRequestProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class S3 : ModelBase, IFromRaw -{ - /// - /// Access key for the bucket. - /// - public required string AccessKey - { - get - { - if (!this.Properties.TryGetValue("accessKey", out JsonElement element)) - throw new ArgumentOutOfRangeException("accessKey", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("accessKey"); - } - set - { - this.Properties["accessKey"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// S3 bucket name. - /// - public required string Bucket - { - get - { - if (!this.Properties.TryGetValue("bucket", out JsonElement element)) - throw new ArgumentOutOfRangeException("bucket", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("bucket"); - } - set - { - this.Properties["bucket"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Display name of the origin. - /// - public required string Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - throw new ArgumentOutOfRangeException("name", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("name"); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Secret key for the bucket. - /// - public required string SecretKey - { - get - { - if (!this.Properties.TryGetValue("secretKey", out JsonElement element)) - throw new ArgumentOutOfRangeException("secretKey", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("secretKey"); - } - set - { - this.Properties["secretKey"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public S3Properties::Type Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ) - ?? throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentNullException("type") - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// URL used in the Canonical header (if enabled). - /// - public string? BaseURLForCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to send a Canonical header. - /// - public bool? IncludeCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Path prefix inside the bucket. - /// - public string? Prefix - { - get - { - if (!this.Properties.TryGetValue("prefix", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["prefix"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.AccessKey; - _ = this.Bucket; - _ = this.Name; - _ = this.SecretKey; - this.Type.Validate(); - _ = this.BaseURLForCanonicalHeader; - _ = this.IncludeCanonicalHeader; - _ = this.Prefix; - } - - public S3() - { - this.Type = new(); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - S3(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static S3 FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3Compatible.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3Compatible.cs deleted file mode 100644 index 006876e0..00000000 --- a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3Compatible.cs +++ /dev/null @@ -1,262 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Accounts.Origins.OriginRequestProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class S3Compatible : ModelBase, IFromRaw -{ - /// - /// Access key for the bucket. - /// - public required string AccessKey - { - get - { - if (!this.Properties.TryGetValue("accessKey", out JsonElement element)) - throw new ArgumentOutOfRangeException("accessKey", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("accessKey"); - } - set - { - this.Properties["accessKey"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// S3 bucket name. - /// - public required string Bucket - { - get - { - if (!this.Properties.TryGetValue("bucket", out JsonElement element)) - throw new ArgumentOutOfRangeException("bucket", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("bucket"); - } - set - { - this.Properties["bucket"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Custom S3-compatible endpoint. - /// - public required string Endpoint - { - get - { - if (!this.Properties.TryGetValue("endpoint", out JsonElement element)) - throw new ArgumentOutOfRangeException("endpoint", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("endpoint"); - } - set - { - this.Properties["endpoint"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Display name of the origin. - /// - public required string Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - throw new ArgumentOutOfRangeException("name", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("name"); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Secret key for the bucket. - /// - public required string SecretKey - { - get - { - if (!this.Properties.TryGetValue("secretKey", out JsonElement element)) - throw new ArgumentOutOfRangeException("secretKey", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("secretKey"); - } - set - { - this.Properties["secretKey"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public S3CompatibleProperties::Type Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ) - ?? throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentNullException("type") - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// URL used in the Canonical header (if enabled). - /// - public string? BaseURLForCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to send a Canonical header. - /// - public bool? IncludeCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Path prefix inside the bucket. - /// - public string? Prefix - { - get - { - if (!this.Properties.TryGetValue("prefix", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["prefix"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Use path-style S3 URLs? - /// - public bool? S3ForcePathStyle - { - get - { - if (!this.Properties.TryGetValue("s3ForcePathStyle", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["s3ForcePathStyle"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.AccessKey; - _ = this.Bucket; - _ = this.Endpoint; - _ = this.Name; - _ = this.SecretKey; - this.Type.Validate(); - _ = this.BaseURLForCanonicalHeader; - _ = this.IncludeCanonicalHeader; - _ = this.Prefix; - _ = this.S3ForcePathStyle; - } - - public S3Compatible() - { - this.Type = new(); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - S3Compatible(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static S3Compatible FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3CompatibleProperties/Type.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3CompatibleProperties/Type.cs deleted file mode 100644 index 3bb5fcc6..00000000 --- a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3CompatibleProperties/Type.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Accounts.Origins.OriginRequestProperties.S3CompatibleProperties; - -[JsonConverter(typeof(Converter))] -public class Type -{ - public JsonElement Json { get; private init; } - - public Type() - { - Json = JsonSerializer.Deserialize("\"S3_COMPATIBLE\""); - } - - Type(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new Type().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); - } - } - - class Converter : JsonConverter - { - public override Type? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3Properties/Type.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3Properties/Type.cs deleted file mode 100644 index dd05ded1..00000000 --- a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/S3Properties/Type.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Accounts.Origins.OriginRequestProperties.S3Properties; - -[JsonConverter(typeof(Converter))] -public class Type -{ - public JsonElement Json { get; private init; } - - public Type() - { - Json = JsonSerializer.Deserialize("\"S3\""); - } - - Type(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new Type().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); - } - } - - class Converter : JsonConverter - { - public override Type? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebFolder.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebFolder.cs deleted file mode 100644 index fb7d4142..00000000 --- a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebFolder.cs +++ /dev/null @@ -1,171 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Accounts.Origins.OriginRequestProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class WebFolder : ModelBase, IFromRaw -{ - /// - /// Root URL for the web folder origin. - /// - public required string BaseURL - { - get - { - if (!this.Properties.TryGetValue("baseUrl", out JsonElement element)) - throw new ArgumentOutOfRangeException("baseUrl", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("baseUrl"); - } - set - { - this.Properties["baseUrl"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Display name of the origin. - /// - public required string Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - throw new ArgumentOutOfRangeException("name", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("name"); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public WebFolderProperties::Type Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ) - ?? throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentNullException("type") - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// URL used in the Canonical header (if enabled). - /// - public string? BaseURLForCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Forward the Host header to origin? - /// - public bool? ForwardHostHeaderToOrigin - { - get - { - if (!this.Properties.TryGetValue("forwardHostHeaderToOrigin", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["forwardHostHeaderToOrigin"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to send a Canonical header. - /// - public bool? IncludeCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.BaseURL; - _ = this.Name; - this.Type.Validate(); - _ = this.BaseURLForCanonicalHeader; - _ = this.ForwardHostHeaderToOrigin; - _ = this.IncludeCanonicalHeader; - } - - public WebFolder() - { - this.Type = new(); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - WebFolder(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static WebFolder FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebFolderProperties/Type.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebFolderProperties/Type.cs deleted file mode 100644 index 742ea776..00000000 --- a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebFolderProperties/Type.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Accounts.Origins.OriginRequestProperties.WebFolderProperties; - -[JsonConverter(typeof(Converter))] -public class Type -{ - public JsonElement Json { get; private init; } - - public Type() - { - Json = JsonSerializer.Deserialize("\"WEB_FOLDER\""); - } - - Type(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new Type().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); - } - } - - class Converter : JsonConverter - { - public override Type? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebProxy.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebProxy.cs deleted file mode 100644 index 7f521700..00000000 --- a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebProxy.cs +++ /dev/null @@ -1,133 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Accounts.Origins.OriginRequestProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class WebProxy : ModelBase, IFromRaw -{ - /// - /// Display name of the origin. - /// - public required string Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - throw new ArgumentOutOfRangeException("name", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("name"); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public WebProxyProperties::Type Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ) - ?? throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentNullException("type") - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// URL used in the Canonical header (if enabled). - /// - public string? BaseURLForCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to send a Canonical header. - /// - public bool? IncludeCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.Name; - this.Type.Validate(); - _ = this.BaseURLForCanonicalHeader; - _ = this.IncludeCanonicalHeader; - } - - public WebProxy() - { - this.Type = new(); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - WebProxy(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static WebProxy FromRawUnchecked(Dictionary properties) - { - return new(properties); - } - - [SetsRequiredMembers] - public WebProxy(string name) - : this() - { - this.Name = name; - } -} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebProxyProperties/Type.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebProxyProperties/Type.cs deleted file mode 100644 index 190a2659..00000000 --- a/src/Imagekit/Models/Accounts/Origins/OriginRequestProperties/WebProxyProperties/Type.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Accounts.Origins.OriginRequestProperties.WebProxyProperties; - -[JsonConverter(typeof(Converter))] -public class Type -{ - public JsonElement Json { get; private init; } - - public Type() - { - Json = JsonSerializer.Deserialize("\"WEB_PROXY\""); - } - - Type(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new Type().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); - } - } - - class Converter : JsonConverter - { - public override Type? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginRequestVariants/All.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequestVariants/All.cs deleted file mode 100644 index bfaed1ab..00000000 --- a/src/Imagekit/Models/Accounts/Origins/OriginRequestVariants/All.cs +++ /dev/null @@ -1,123 +0,0 @@ -using OriginRequestProperties = Imagekit.Models.Accounts.Origins.OriginRequestProperties; - -namespace Imagekit.Models.Accounts.Origins.OriginRequestVariants; - -public sealed record class S3(OriginRequestProperties::S3 Value) - : OriginRequest, - IVariant -{ - public static S3 From(OriginRequestProperties::S3 value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class S3Compatible(OriginRequestProperties::S3Compatible Value) - : OriginRequest, - IVariant -{ - public static S3Compatible From(OriginRequestProperties::S3Compatible value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class CloudinaryBackup(OriginRequestProperties::CloudinaryBackup Value) - : OriginRequest, - IVariant -{ - public static CloudinaryBackup From(OriginRequestProperties::CloudinaryBackup value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class WebFolder(OriginRequestProperties::WebFolder Value) - : OriginRequest, - IVariant -{ - public static WebFolder From(OriginRequestProperties::WebFolder value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class WebProxy(OriginRequestProperties::WebProxy Value) - : OriginRequest, - IVariant -{ - public static WebProxy From(OriginRequestProperties::WebProxy value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class Gcs(OriginRequestProperties::Gcs Value) - : OriginRequest, - IVariant -{ - public static Gcs From(OriginRequestProperties::Gcs value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class AzureBlob(OriginRequestProperties::AzureBlob Value) - : OriginRequest, - IVariant -{ - public static AzureBlob From(OriginRequestProperties::AzureBlob value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class AkeneoPim(OriginRequestProperties::AkeneoPim Value) - : OriginRequest, - IVariant -{ - public static AkeneoPim From(OriginRequestProperties::AkeneoPim value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponse.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponse.cs deleted file mode 100644 index 78f9cfe7..00000000 --- a/src/Imagekit/Models/Accounts/Origins/OriginResponse.cs +++ /dev/null @@ -1,523 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Accounts.Origins.OriginResponseProperties; - -namespace Imagekit.Models.Accounts.Origins; - -/// -/// Origin object as returned by the API (sensitive fields removed). -/// -[JsonConverter(typeof(OriginResponseConverter))] -public record class OriginResponse -{ - public object Value { get; private init; } - - public string ID - { - get - { - return Match( - s3: (x) => x.ID, - s3Compatible: (x) => x.ID, - cloudinaryBackup: (x) => x.ID, - webFolder: (x) => x.ID, - webProxy: (x) => x.ID, - gcs: (x) => x.ID, - azureBlob: (x) => x.ID, - akeneoPim: (x) => x.ID - ); - } - } - - public string? Bucket - { - get - { - return Match( - s3: (x) => x.Bucket, - s3Compatible: (x) => x.Bucket, - cloudinaryBackup: (x) => x.Bucket, - webFolder: (_) => null, - webProxy: (_) => null, - gcs: (x) => x.Bucket, - azureBlob: (_) => null, - akeneoPim: (_) => null - ); - } - } - - public bool IncludeCanonicalHeader - { - get - { - return Match( - s3: (x) => x.IncludeCanonicalHeader, - s3Compatible: (x) => x.IncludeCanonicalHeader, - cloudinaryBackup: (x) => x.IncludeCanonicalHeader, - webFolder: (x) => x.IncludeCanonicalHeader, - webProxy: (x) => x.IncludeCanonicalHeader, - gcs: (x) => x.IncludeCanonicalHeader, - azureBlob: (x) => x.IncludeCanonicalHeader, - akeneoPim: (x) => x.IncludeCanonicalHeader - ); - } - } - - public string Name - { - get - { - return Match( - s3: (x) => x.Name, - s3Compatible: (x) => x.Name, - cloudinaryBackup: (x) => x.Name, - webFolder: (x) => x.Name, - webProxy: (x) => x.Name, - gcs: (x) => x.Name, - azureBlob: (x) => x.Name, - akeneoPim: (x) => x.Name - ); - } - } - - public string? Prefix - { - get - { - return Match( - s3: (x) => x.Prefix, - s3Compatible: (x) => x.Prefix, - cloudinaryBackup: (x) => x.Prefix, - webFolder: (_) => null, - webProxy: (_) => null, - gcs: (x) => x.Prefix, - azureBlob: (x) => x.Prefix, - akeneoPim: (_) => null - ); - } - } - - public string? BaseURLForCanonicalHeader - { - get - { - return Match( - s3: (x) => x.BaseURLForCanonicalHeader, - s3Compatible: (x) => x.BaseURLForCanonicalHeader, - cloudinaryBackup: (x) => x.BaseURLForCanonicalHeader, - webFolder: (x) => x.BaseURLForCanonicalHeader, - webProxy: (x) => x.BaseURLForCanonicalHeader, - gcs: (x) => x.BaseURLForCanonicalHeader, - azureBlob: (x) => x.BaseURLForCanonicalHeader, - akeneoPim: (x) => x.BaseURLForCanonicalHeader - ); - } - } - - public string? BaseURL - { - get - { - return Match( - s3: (_) => null, - s3Compatible: (_) => null, - cloudinaryBackup: (_) => null, - webFolder: (x) => x.BaseURL, - webProxy: (_) => null, - gcs: (_) => null, - azureBlob: (_) => null, - akeneoPim: (x) => x.BaseURL - ); - } - } - - public OriginResponse(S3 value) - { - Value = value; - } - - public OriginResponse(S3Compatible value) - { - Value = value; - } - - public OriginResponse(CloudinaryBackup value) - { - Value = value; - } - - public OriginResponse(WebFolder value) - { - Value = value; - } - - public OriginResponse(WebProxy value) - { - Value = value; - } - - public OriginResponse(Gcs value) - { - Value = value; - } - - public OriginResponse(AzureBlob value) - { - Value = value; - } - - public OriginResponse(AkeneoPim value) - { - Value = value; - } - - OriginResponse(UnknownVariant value) - { - Value = value; - } - - public static OriginResponse CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickS3([NotNullWhen(true)] out S3? value) - { - value = this.Value as S3; - return value != null; - } - - public bool TryPickS3Compatible([NotNullWhen(true)] out S3Compatible? value) - { - value = this.Value as S3Compatible; - return value != null; - } - - public bool TryPickCloudinaryBackup([NotNullWhen(true)] out CloudinaryBackup? value) - { - value = this.Value as CloudinaryBackup; - return value != null; - } - - public bool TryPickWebFolder([NotNullWhen(true)] out WebFolder? value) - { - value = this.Value as WebFolder; - return value != null; - } - - public bool TryPickWebProxy([NotNullWhen(true)] out WebProxy? value) - { - value = this.Value as WebProxy; - return value != null; - } - - public bool TryPickGcs([NotNullWhen(true)] out Gcs? value) - { - value = this.Value as Gcs; - return value != null; - } - - public bool TryPickAzureBlob([NotNullWhen(true)] out AzureBlob? value) - { - value = this.Value as AzureBlob; - return value != null; - } - - public bool TryPickAkeneoPim([NotNullWhen(true)] out AkeneoPim? value) - { - value = this.Value as AkeneoPim; - return value != null; - } - - public void Switch( - Action s3, - Action s3Compatible, - Action cloudinaryBackup, - Action webFolder, - Action webProxy, - Action gcs, - Action azureBlob, - Action akeneoPim - ) - { - switch (this.Value) - { - case S3 value: - s3(value); - break; - case S3Compatible value: - s3Compatible(value); - break; - case CloudinaryBackup value: - cloudinaryBackup(value); - break; - case WebFolder value: - webFolder(value); - break; - case WebProxy value: - webProxy(value); - break; - case Gcs value: - gcs(value); - break; - case AzureBlob value: - azureBlob(value); - break; - case AkeneoPim value: - akeneoPim(value); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match( - Func s3, - Func s3Compatible, - Func cloudinaryBackup, - Func webFolder, - Func webProxy, - Func gcs, - Func azureBlob, - Func akeneoPim - ) - { - return this.Value switch - { - OriginResponseVariants::S3 inner => s3(inner), - OriginResponseVariants::S3Compatible inner => s3Compatible(inner), - OriginResponseVariants::CloudinaryBackup inner => cloudinaryBackup(inner), - OriginResponseVariants::WebFolder inner => webFolder(inner), - OriginResponseVariants::WebProxy inner => webProxy(inner), - OriginResponseVariants::Gcs inner => gcs(inner), - OriginResponseVariants::AzureBlob inner => azureBlob(inner), - OriginResponseVariants::AkeneoPim inner => akeneoPim(inner), - _ => throw new InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException( - "Data did not match any variant of OriginResponse" - ); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class OriginResponseConverter : JsonConverter -{ - public override OriginResponse? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - var json = JsonSerializer.Deserialize(ref reader, options); - string? type; - try - { - type = json.GetProperty("type").GetString(); - } - catch - { - type = null; - } - - switch (type) - { - case "S3": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - deserialized.Validate(); - return new OriginResponse(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "S3_COMPATIBLE": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - deserialized.Validate(); - return new OriginResponse(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "CLOUDINARY_BACKUP": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - deserialized.Validate(); - return new OriginResponse(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "WEB_FOLDER": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - deserialized.Validate(); - return new OriginResponse(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "WEB_PROXY": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - deserialized.Validate(); - return new OriginResponse(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "GCS": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - deserialized.Validate(); - return new OriginResponse(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "AZURE_BLOB": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - deserialized.Validate(); - return new OriginResponse(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "AKENEO_PIM": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - deserialized.Validate(); - return new OriginResponse(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - default: - { - throw new Exception(); - } - } - } - - public override void Write( - Utf8JsonWriter writer, - OriginResponse value, - JsonSerializerOptions options - ) - { - object variant = value switch - { - OriginResponseVariants::S3(var s3) => s3, - OriginResponseVariants::S3Compatible(var s3Compatible) => s3Compatible, - OriginResponseVariants::CloudinaryBackup(var cloudinaryBackup) => cloudinaryBackup, - OriginResponseVariants::WebFolder(var webFolder) => webFolder, - OriginResponseVariants::WebProxy(var webProxy) => webProxy, - OriginResponseVariants::Gcs(var gcs) => gcs, - OriginResponseVariants::AzureBlob(var azureBlob) => azureBlob, - OriginResponseVariants::AkeneoPim(var akeneoPim) => akeneoPim, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AkeneoPim.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AkeneoPim.cs deleted file mode 100644 index 0e91e534..00000000 --- a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AkeneoPim.cs +++ /dev/null @@ -1,176 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Accounts.Origins.OriginResponseProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class AkeneoPim : ModelBase, IFromRaw -{ - /// - /// Unique identifier for the origin. This is generated by ImageKit when you create - /// a new origin. - /// - public required string ID - { - get - { - if (!this.Properties.TryGetValue("id", out JsonElement element)) - throw new ArgumentOutOfRangeException("id", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("id"); - } - set - { - this.Properties["id"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Akeneo instance base URL. - /// - public required string BaseURL - { - get - { - if (!this.Properties.TryGetValue("baseUrl", out JsonElement element)) - throw new ArgumentOutOfRangeException("baseUrl", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("baseUrl"); - } - set - { - this.Properties["baseUrl"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to send a Canonical header. - /// - public required bool IncludeCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) - throw new ArgumentOutOfRangeException( - "includeCanonicalHeader", - "Missing required argument" - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Display name of the origin. - /// - public required string Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - throw new ArgumentOutOfRangeException("name", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("name"); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public AkeneoPimProperties::Type Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ) - ?? throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentNullException("type") - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// URL used in the Canonical header (if enabled). - /// - public string? BaseURLForCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.ID; - _ = this.BaseURL; - _ = this.IncludeCanonicalHeader; - _ = this.Name; - this.Type.Validate(); - _ = this.BaseURLForCanonicalHeader; - } - - public AkeneoPim() - { - this.Type = new(); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - AkeneoPim(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static AkeneoPim FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AkeneoPimProperties/Type.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AkeneoPimProperties/Type.cs deleted file mode 100644 index 68757b6e..00000000 --- a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AkeneoPimProperties/Type.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Accounts.Origins.OriginResponseProperties.AkeneoPimProperties; - -[JsonConverter(typeof(Converter))] -public class Type -{ - public JsonElement Json { get; private init; } - - public Type() - { - Json = JsonSerializer.Deserialize("\"AKENEO_PIM\""); - } - - Type(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new Type().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); - } - } - - class Converter : JsonConverter - { - public override Type? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AzureBlob.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AzureBlob.cs deleted file mode 100644 index adf4dbdd..00000000 --- a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AzureBlob.cs +++ /dev/null @@ -1,213 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Accounts.Origins.OriginResponseProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class AzureBlob : ModelBase, IFromRaw -{ - /// - /// Unique identifier for the origin. This is generated by ImageKit when you create - /// a new origin. - /// - public required string ID - { - get - { - if (!this.Properties.TryGetValue("id", out JsonElement element)) - throw new ArgumentOutOfRangeException("id", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("id"); - } - set - { - this.Properties["id"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required string AccountName - { - get - { - if (!this.Properties.TryGetValue("accountName", out JsonElement element)) - throw new ArgumentOutOfRangeException("accountName", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("accountName"); - } - set - { - this.Properties["accountName"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required string Container - { - get - { - if (!this.Properties.TryGetValue("container", out JsonElement element)) - throw new ArgumentOutOfRangeException("container", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("container"); - } - set - { - this.Properties["container"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to send a Canonical header. - /// - public required bool IncludeCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) - throw new ArgumentOutOfRangeException( - "includeCanonicalHeader", - "Missing required argument" - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Display name of the origin. - /// - public required string Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - throw new ArgumentOutOfRangeException("name", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("name"); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required string Prefix - { - get - { - if (!this.Properties.TryGetValue("prefix", out JsonElement element)) - throw new ArgumentOutOfRangeException("prefix", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("prefix"); - } - set - { - this.Properties["prefix"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public AzureBlobProperties::Type Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ) - ?? throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentNullException("type") - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// URL used in the Canonical header (if enabled). - /// - public string? BaseURLForCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.ID; - _ = this.AccountName; - _ = this.Container; - _ = this.IncludeCanonicalHeader; - _ = this.Name; - _ = this.Prefix; - this.Type.Validate(); - _ = this.BaseURLForCanonicalHeader; - } - - public AzureBlob() - { - this.Type = new(); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - AzureBlob(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static AzureBlob FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AzureBlobProperties/Type.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AzureBlobProperties/Type.cs deleted file mode 100644 index eb2d28b8..00000000 --- a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/AzureBlobProperties/Type.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Accounts.Origins.OriginResponseProperties.AzureBlobProperties; - -[JsonConverter(typeof(Converter))] -public class Type -{ - public JsonElement Json { get; private init; } - - public Type() - { - Json = JsonSerializer.Deserialize("\"AZURE_BLOB\""); - } - - Type(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new Type().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); - } - } - - class Converter : JsonConverter - { - public override Type? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/CloudinaryBackup.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/CloudinaryBackup.cs deleted file mode 100644 index 608e2365..00000000 --- a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/CloudinaryBackup.cs +++ /dev/null @@ -1,199 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Accounts.Origins.OriginResponseProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class CloudinaryBackup : ModelBase, IFromRaw -{ - /// - /// Unique identifier for the origin. This is generated by ImageKit when you create - /// a new origin. - /// - public required string ID - { - get - { - if (!this.Properties.TryGetValue("id", out JsonElement element)) - throw new ArgumentOutOfRangeException("id", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("id"); - } - set - { - this.Properties["id"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// S3 bucket name. - /// - public required string Bucket - { - get - { - if (!this.Properties.TryGetValue("bucket", out JsonElement element)) - throw new ArgumentOutOfRangeException("bucket", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("bucket"); - } - set - { - this.Properties["bucket"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to send a Canonical header. - /// - public required bool IncludeCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) - throw new ArgumentOutOfRangeException( - "includeCanonicalHeader", - "Missing required argument" - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Display name of the origin. - /// - public required string Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - throw new ArgumentOutOfRangeException("name", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("name"); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Path prefix inside the bucket. - /// - public required string Prefix - { - get - { - if (!this.Properties.TryGetValue("prefix", out JsonElement element)) - throw new ArgumentOutOfRangeException("prefix", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("prefix"); - } - set - { - this.Properties["prefix"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public CloudinaryBackupProperties::Type Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ) - ?? throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentNullException("type") - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// URL used in the Canonical header (if enabled). - /// - public string? BaseURLForCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.ID; - _ = this.Bucket; - _ = this.IncludeCanonicalHeader; - _ = this.Name; - _ = this.Prefix; - this.Type.Validate(); - _ = this.BaseURLForCanonicalHeader; - } - - public CloudinaryBackup() - { - this.Type = new(); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - CloudinaryBackup(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static CloudinaryBackup FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/CloudinaryBackupProperties/Type.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/CloudinaryBackupProperties/Type.cs deleted file mode 100644 index 71521017..00000000 --- a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/CloudinaryBackupProperties/Type.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Accounts.Origins.OriginResponseProperties.CloudinaryBackupProperties; - -[JsonConverter(typeof(Converter))] -public class Type -{ - public JsonElement Json { get; private init; } - - public Type() - { - Json = JsonSerializer.Deserialize("\"CLOUDINARY_BACKUP\""); - } - - Type(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new Type().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); - } - } - - class Converter : JsonConverter - { - public override Type? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/Gcs.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/Gcs.cs deleted file mode 100644 index 25a84665..00000000 --- a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/Gcs.cs +++ /dev/null @@ -1,213 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Accounts.Origins.OriginResponseProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Gcs : ModelBase, IFromRaw -{ - /// - /// Unique identifier for the origin. This is generated by ImageKit when you create - /// a new origin. - /// - public required string ID - { - get - { - if (!this.Properties.TryGetValue("id", out JsonElement element)) - throw new ArgumentOutOfRangeException("id", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("id"); - } - set - { - this.Properties["id"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required string Bucket - { - get - { - if (!this.Properties.TryGetValue("bucket", out JsonElement element)) - throw new ArgumentOutOfRangeException("bucket", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("bucket"); - } - set - { - this.Properties["bucket"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required string ClientEmail - { - get - { - if (!this.Properties.TryGetValue("clientEmail", out JsonElement element)) - throw new ArgumentOutOfRangeException("clientEmail", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("clientEmail"); - } - set - { - this.Properties["clientEmail"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to send a Canonical header. - /// - public required bool IncludeCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) - throw new ArgumentOutOfRangeException( - "includeCanonicalHeader", - "Missing required argument" - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Display name of the origin. - /// - public required string Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - throw new ArgumentOutOfRangeException("name", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("name"); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required string Prefix - { - get - { - if (!this.Properties.TryGetValue("prefix", out JsonElement element)) - throw new ArgumentOutOfRangeException("prefix", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("prefix"); - } - set - { - this.Properties["prefix"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public GcsProperties::Type Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ) - ?? throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentNullException("type") - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// URL used in the Canonical header (if enabled). - /// - public string? BaseURLForCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.ID; - _ = this.Bucket; - _ = this.ClientEmail; - _ = this.IncludeCanonicalHeader; - _ = this.Name; - _ = this.Prefix; - this.Type.Validate(); - _ = this.BaseURLForCanonicalHeader; - } - - public Gcs() - { - this.Type = new(); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Gcs(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Gcs FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/GcsProperties/Type.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/GcsProperties/Type.cs deleted file mode 100644 index e366c330..00000000 --- a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/GcsProperties/Type.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Accounts.Origins.OriginResponseProperties.GcsProperties; - -[JsonConverter(typeof(Converter))] -public class Type -{ - public JsonElement Json { get; private init; } - - public Type() - { - Json = JsonSerializer.Deserialize("\"GCS\""); - } - - Type(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new Type().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); - } - } - - class Converter : JsonConverter - { - public override Type? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3.cs deleted file mode 100644 index c9d37af2..00000000 --- a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3.cs +++ /dev/null @@ -1,199 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Accounts.Origins.OriginResponseProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class S3 : ModelBase, IFromRaw -{ - /// - /// Unique identifier for the origin. This is generated by ImageKit when you create - /// a new origin. - /// - public required string ID - { - get - { - if (!this.Properties.TryGetValue("id", out JsonElement element)) - throw new ArgumentOutOfRangeException("id", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("id"); - } - set - { - this.Properties["id"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// S3 bucket name. - /// - public required string Bucket - { - get - { - if (!this.Properties.TryGetValue("bucket", out JsonElement element)) - throw new ArgumentOutOfRangeException("bucket", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("bucket"); - } - set - { - this.Properties["bucket"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to send a Canonical header. - /// - public required bool IncludeCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) - throw new ArgumentOutOfRangeException( - "includeCanonicalHeader", - "Missing required argument" - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Display name of the origin. - /// - public required string Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - throw new ArgumentOutOfRangeException("name", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("name"); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Path prefix inside the bucket. - /// - public required string Prefix - { - get - { - if (!this.Properties.TryGetValue("prefix", out JsonElement element)) - throw new ArgumentOutOfRangeException("prefix", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("prefix"); - } - set - { - this.Properties["prefix"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public S3Properties::Type Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ) - ?? throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentNullException("type") - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// URL used in the Canonical header (if enabled). - /// - public string? BaseURLForCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.ID; - _ = this.Bucket; - _ = this.IncludeCanonicalHeader; - _ = this.Name; - _ = this.Prefix; - this.Type.Validate(); - _ = this.BaseURLForCanonicalHeader; - } - - public S3() - { - this.Type = new(); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - S3(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static S3 FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3Compatible.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3Compatible.cs deleted file mode 100644 index 8cdb00df..00000000 --- a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3Compatible.cs +++ /dev/null @@ -1,247 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Accounts.Origins.OriginResponseProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class S3Compatible : ModelBase, IFromRaw -{ - /// - /// Unique identifier for the origin. This is generated by ImageKit when you create - /// a new origin. - /// - public required string ID - { - get - { - if (!this.Properties.TryGetValue("id", out JsonElement element)) - throw new ArgumentOutOfRangeException("id", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("id"); - } - set - { - this.Properties["id"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// S3 bucket name. - /// - public required string Bucket - { - get - { - if (!this.Properties.TryGetValue("bucket", out JsonElement element)) - throw new ArgumentOutOfRangeException("bucket", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("bucket"); - } - set - { - this.Properties["bucket"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Custom S3-compatible endpoint. - /// - public required string Endpoint - { - get - { - if (!this.Properties.TryGetValue("endpoint", out JsonElement element)) - throw new ArgumentOutOfRangeException("endpoint", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("endpoint"); - } - set - { - this.Properties["endpoint"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to send a Canonical header. - /// - public required bool IncludeCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) - throw new ArgumentOutOfRangeException( - "includeCanonicalHeader", - "Missing required argument" - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Display name of the origin. - /// - public required string Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - throw new ArgumentOutOfRangeException("name", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("name"); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Path prefix inside the bucket. - /// - public required string Prefix - { - get - { - if (!this.Properties.TryGetValue("prefix", out JsonElement element)) - throw new ArgumentOutOfRangeException("prefix", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("prefix"); - } - set - { - this.Properties["prefix"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Use path-style S3 URLs? - /// - public required bool S3ForcePathStyle - { - get - { - if (!this.Properties.TryGetValue("s3ForcePathStyle", out JsonElement element)) - throw new ArgumentOutOfRangeException( - "s3ForcePathStyle", - "Missing required argument" - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["s3ForcePathStyle"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public S3CompatibleProperties::Type Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ) - ?? throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentNullException("type") - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// URL used in the Canonical header (if enabled). - /// - public string? BaseURLForCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.ID; - _ = this.Bucket; - _ = this.Endpoint; - _ = this.IncludeCanonicalHeader; - _ = this.Name; - _ = this.Prefix; - _ = this.S3ForcePathStyle; - this.Type.Validate(); - _ = this.BaseURLForCanonicalHeader; - } - - public S3Compatible() - { - this.Type = new(); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - S3Compatible(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static S3Compatible FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3CompatibleProperties/Type.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3CompatibleProperties/Type.cs deleted file mode 100644 index 533601bf..00000000 --- a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3CompatibleProperties/Type.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Accounts.Origins.OriginResponseProperties.S3CompatibleProperties; - -[JsonConverter(typeof(Converter))] -public class Type -{ - public JsonElement Json { get; private init; } - - public Type() - { - Json = JsonSerializer.Deserialize("\"S3_COMPATIBLE\""); - } - - Type(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new Type().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); - } - } - - class Converter : JsonConverter - { - public override Type? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3Properties/Type.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3Properties/Type.cs deleted file mode 100644 index 30dc6717..00000000 --- a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/S3Properties/Type.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Accounts.Origins.OriginResponseProperties.S3Properties; - -[JsonConverter(typeof(Converter))] -public class Type -{ - public JsonElement Json { get; private init; } - - public Type() - { - Json = JsonSerializer.Deserialize("\"S3\""); - } - - Type(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new Type().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); - } - } - - class Converter : JsonConverter - { - public override Type? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebFolder.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebFolder.cs deleted file mode 100644 index 1164787d..00000000 --- a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebFolder.cs +++ /dev/null @@ -1,201 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Accounts.Origins.OriginResponseProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class WebFolder : ModelBase, IFromRaw -{ - /// - /// Unique identifier for the origin. This is generated by ImageKit when you create - /// a new origin. - /// - public required string ID - { - get - { - if (!this.Properties.TryGetValue("id", out JsonElement element)) - throw new ArgumentOutOfRangeException("id", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("id"); - } - set - { - this.Properties["id"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Root URL for the web folder origin. - /// - public required string BaseURL - { - get - { - if (!this.Properties.TryGetValue("baseUrl", out JsonElement element)) - throw new ArgumentOutOfRangeException("baseUrl", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("baseUrl"); - } - set - { - this.Properties["baseUrl"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Forward the Host header to origin? - /// - public required bool ForwardHostHeaderToOrigin - { - get - { - if (!this.Properties.TryGetValue("forwardHostHeaderToOrigin", out JsonElement element)) - throw new ArgumentOutOfRangeException( - "forwardHostHeaderToOrigin", - "Missing required argument" - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["forwardHostHeaderToOrigin"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to send a Canonical header. - /// - public required bool IncludeCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) - throw new ArgumentOutOfRangeException( - "includeCanonicalHeader", - "Missing required argument" - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Display name of the origin. - /// - public required string Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - throw new ArgumentOutOfRangeException("name", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("name"); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public WebFolderProperties::Type Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ) - ?? throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentNullException("type") - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// URL used in the Canonical header (if enabled). - /// - public string? BaseURLForCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.ID; - _ = this.BaseURL; - _ = this.ForwardHostHeaderToOrigin; - _ = this.IncludeCanonicalHeader; - _ = this.Name; - this.Type.Validate(); - _ = this.BaseURLForCanonicalHeader; - } - - public WebFolder() - { - this.Type = new(); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - WebFolder(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static WebFolder FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebFolderProperties/Type.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebFolderProperties/Type.cs deleted file mode 100644 index 9ac24d56..00000000 --- a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebFolderProperties/Type.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Accounts.Origins.OriginResponseProperties.WebFolderProperties; - -[JsonConverter(typeof(Converter))] -public class Type -{ - public JsonElement Json { get; private init; } - - public Type() - { - Json = JsonSerializer.Deserialize("\"WEB_FOLDER\""); - } - - Type(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new Type().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); - } - } - - class Converter : JsonConverter - { - public override Type? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebProxy.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebProxy.cs deleted file mode 100644 index abe746c9..00000000 --- a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebProxy.cs +++ /dev/null @@ -1,153 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Accounts.Origins.OriginResponseProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class WebProxy : ModelBase, IFromRaw -{ - /// - /// Unique identifier for the origin. This is generated by ImageKit when you create - /// a new origin. - /// - public required string ID - { - get - { - if (!this.Properties.TryGetValue("id", out JsonElement element)) - throw new ArgumentOutOfRangeException("id", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("id"); - } - set - { - this.Properties["id"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to send a Canonical header. - /// - public required bool IncludeCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("includeCanonicalHeader", out JsonElement element)) - throw new ArgumentOutOfRangeException( - "includeCanonicalHeader", - "Missing required argument" - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["includeCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Display name of the origin. - /// - public required string Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - throw new ArgumentOutOfRangeException("name", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("name"); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public WebProxyProperties::Type Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ) - ?? throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentNullException("type") - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// URL used in the Canonical header (if enabled). - /// - public string? BaseURLForCanonicalHeader - { - get - { - if (!this.Properties.TryGetValue("baseUrlForCanonicalHeader", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["baseUrlForCanonicalHeader"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.ID; - _ = this.IncludeCanonicalHeader; - _ = this.Name; - this.Type.Validate(); - _ = this.BaseURLForCanonicalHeader; - } - - public WebProxy() - { - this.Type = new(); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - WebProxy(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static WebProxy FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebProxyProperties/Type.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebProxyProperties/Type.cs deleted file mode 100644 index d46da7b5..00000000 --- a/src/Imagekit/Models/Accounts/Origins/OriginResponseProperties/WebProxyProperties/Type.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Accounts.Origins.OriginResponseProperties.WebProxyProperties; - -[JsonConverter(typeof(Converter))] -public class Type -{ - public JsonElement Json { get; private init; } - - public Type() - { - Json = JsonSerializer.Deserialize("\"WEB_PROXY\""); - } - - Type(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new Type().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); - } - } - - class Converter : JsonConverter - { - public override Type? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginResponseVariants/All.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponseVariants/All.cs deleted file mode 100644 index cb69f75d..00000000 --- a/src/Imagekit/Models/Accounts/Origins/OriginResponseVariants/All.cs +++ /dev/null @@ -1,123 +0,0 @@ -using OriginResponseProperties = Imagekit.Models.Accounts.Origins.OriginResponseProperties; - -namespace Imagekit.Models.Accounts.Origins.OriginResponseVariants; - -public sealed record class S3(OriginResponseProperties::S3 Value) - : OriginResponse, - IVariant -{ - public static S3 From(OriginResponseProperties::S3 value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class S3Compatible(OriginResponseProperties::S3Compatible Value) - : OriginResponse, - IVariant -{ - public static S3Compatible From(OriginResponseProperties::S3Compatible value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class CloudinaryBackup(OriginResponseProperties::CloudinaryBackup Value) - : OriginResponse, - IVariant -{ - public static CloudinaryBackup From(OriginResponseProperties::CloudinaryBackup value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class WebFolder(OriginResponseProperties::WebFolder Value) - : OriginResponse, - IVariant -{ - public static WebFolder From(OriginResponseProperties::WebFolder value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class WebProxy(OriginResponseProperties::WebProxy Value) - : OriginResponse, - IVariant -{ - public static WebProxy From(OriginResponseProperties::WebProxy value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class Gcs(OriginResponseProperties::Gcs Value) - : OriginResponse, - IVariant -{ - public static Gcs From(OriginResponseProperties::Gcs value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class AzureBlob(OriginResponseProperties::AzureBlob Value) - : OriginResponse, - IVariant -{ - public static AzureBlob From(OriginResponseProperties::AzureBlob value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class AkeneoPim(OriginResponseProperties::AkeneoPim Value) - : OriginResponse, - IVariant -{ - public static AkeneoPim From(OriginResponseProperties::AkeneoPim value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} diff --git a/src/Imagekit/Models/Accounts/Origins/OriginUpdateParams.cs b/src/Imagekit/Models/Accounts/Origins/OriginUpdateParams.cs deleted file mode 100644 index b7307994..00000000 --- a/src/Imagekit/Models/Accounts/Origins/OriginUpdateParams.cs +++ /dev/null @@ -1,69 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Net.Http; -using System.Text; -using System.Text.Json; - -namespace Imagekit.Models.Accounts.Origins; - -/// -/// **Note:** This API is currently in beta. Updates the origin identified by `id` -/// and returns the updated origin object. -/// -public sealed record class OriginUpdateParams : ParamsBase -{ - public Dictionary BodyProperties { get; set; } = []; - - public required string ID; - - /// - /// Schema for origin request resources. - /// - public required OriginRequest Origin - { - get - { - if (!this.BodyProperties.TryGetValue("origin", out JsonElement element)) - throw new ArgumentOutOfRangeException("origin", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("origin"); - } - set - { - this.BodyProperties["origin"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override Uri Url(IImageKitClient client) - { - return new UriBuilder( - client.BaseUrl.ToString().TrimEnd('/') - + string.Format("/v1/accounts/origins/{0}", this.ID) - ) - { - Query = this.QueryString(client), - }.Uri; - } - - public StringContent BodyContent() - { - return new( - JsonSerializer.Serialize(this.BodyProperties), - Encoding.UTF8, - "application/json" - ); - } - - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParams.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParams.cs deleted file mode 100644 index 6d3c58b5..00000000 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParams.cs +++ /dev/null @@ -1,131 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Net.Http; -using System.Text; -using System.Text.Json; -using Imagekit.Models.Accounts.URLEndpoints.URLEndpointCreateParamsProperties; - -namespace Imagekit.Models.Accounts.URLEndpoints; - -/// -/// **Note:** This API is currently in beta. Creates a new URL‑endpoint and returns -/// the resulting object. -/// -public sealed record class URLEndpointCreateParams : ParamsBase -{ - public Dictionary BodyProperties { get; set; } = []; - - /// - /// Description of the URL endpoint. - /// - public required string Description - { - get - { - if (!this.BodyProperties.TryGetValue("description", out JsonElement element)) - throw new ArgumentOutOfRangeException("description", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("description"); - } - set - { - this.BodyProperties["description"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Ordered list of origin IDs to try when the file isn’t in the Media Library; - /// ImageKit checks them in the sequence provided. Origin must be created before - /// it can be used in a URL endpoint. - /// - public List? Origins - { - get - { - if (!this.BodyProperties.TryGetValue("origins", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["origins"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Path segment appended to your base URL to form the endpoint (letters, digits, - /// and hyphens only — or empty for the default endpoint). - /// - public string? URLPrefix - { - get - { - if (!this.BodyProperties.TryGetValue("urlPrefix", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["urlPrefix"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Configuration for third-party URL rewriting. - /// - public URLRewriter? URLRewriter - { - get - { - if (!this.BodyProperties.TryGetValue("urlRewriter", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["urlRewriter"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override Uri Url(IImageKitClient client) - { - return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/accounts/url-endpoints") - { - Query = this.QueryString(client), - }.Uri; - } - - public StringContent BodyContent() - { - return new( - JsonSerializer.Serialize(this.BodyProperties), - Encoding.UTF8, - "application/json" - ); - } - - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriter.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriter.cs deleted file mode 100644 index 2b1b5a54..00000000 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriter.cs +++ /dev/null @@ -1,204 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Accounts.URLEndpoints.URLEndpointCreateParamsProperties.URLRewriterProperties; - -namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointCreateParamsProperties; - -/// -/// Configuration for third-party URL rewriting. -/// -[JsonConverter(typeof(URLRewriterConverter))] -public record class URLRewriter -{ - public object Value { get; private init; } - - public URLRewriter(Cloudinary value) - { - Value = value; - } - - public URLRewriter(Imgix value) - { - Value = value; - } - - public URLRewriter(Akamai value) - { - Value = value; - } - - URLRewriter(UnknownVariant value) - { - Value = value; - } - - public static URLRewriter CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickCloudinary([NotNullWhen(true)] out Cloudinary? value) - { - value = this.Value as Cloudinary; - return value != null; - } - - public bool TryPickImgix([NotNullWhen(true)] out Imgix? value) - { - value = this.Value as Imgix; - return value != null; - } - - public bool TryPickAkamai([NotNullWhen(true)] out Akamai? value) - { - value = this.Value as Akamai; - return value != null; - } - - public void Switch(Action cloudinary, Action imgix, Action akamai) - { - switch (this.Value) - { - case Cloudinary value: - cloudinary(value); - break; - case Imgix value: - imgix(value); - break; - case Akamai value: - akamai(value); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match(Func cloudinary, Func imgix, Func akamai) - { - return this.Value switch - { - URLRewriterVariants::Cloudinary inner => cloudinary(inner), - URLRewriterVariants::Imgix inner => imgix(inner), - URLRewriterVariants::Akamai inner => akamai(inner), - _ => throw new InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of URLRewriter"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class URLRewriterConverter : JsonConverter -{ - public override URLRewriter? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - var json = JsonSerializer.Deserialize(ref reader, options); - string? type; - try - { - type = json.GetProperty("type").GetString(); - } - catch - { - type = null; - } - - switch (type) - { - case "CLOUDINARY": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - deserialized.Validate(); - return new URLRewriter(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "IMGIX": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - deserialized.Validate(); - return new URLRewriter(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "AKAMAI": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - deserialized.Validate(); - return new URLRewriter(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - default: - { - throw new Exception(); - } - } - } - - public override void Write( - Utf8JsonWriter writer, - URLRewriter value, - JsonSerializerOptions options - ) - { - object variant = value switch - { - URLRewriterVariants::Cloudinary(var cloudinary) => cloudinary, - URLRewriterVariants::Imgix(var imgix) => imgix, - URLRewriterVariants::Akamai(var akamai) => akamai, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/Akamai.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/Akamai.cs deleted file mode 100644 index 47ecfa36..00000000 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/Akamai.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; - -namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointCreateParamsProperties.URLRewriterProperties; - -[JsonConverter(typeof(Converter))] -public class Akamai -{ - public JsonElement Json { get; private init; } - - public Akamai() - { - Json = JsonSerializer.Deserialize("{\"type\":\"AKAMAI\"}"); - } - - Akamai(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new Akamai().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'Akamai'"); - } - } - - class Converter : JsonConverter - { - public override Akamai? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write( - Utf8JsonWriter writer, - Akamai value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/AkamaiProperties/Type.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/AkamaiProperties/Type.cs deleted file mode 100644 index 52753b37..00000000 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/AkamaiProperties/Type.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointCreateParamsProperties.URLRewriterProperties.AkamaiProperties; - -[JsonConverter(typeof(Converter))] -public class Type -{ - public JsonElement Json { get; private init; } - - public Type() - { - Json = JsonSerializer.Deserialize("\"AKAMAI\""); - } - - Type(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new Type().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); - } - } - - class Converter : JsonConverter - { - public override Type? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/Cloudinary.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/Cloudinary.cs deleted file mode 100644 index 10cd32d5..00000000 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/Cloudinary.cs +++ /dev/null @@ -1,81 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointCreateParamsProperties.URLRewriterProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Cloudinary : ModelBase, IFromRaw -{ - public CloudinaryProperties::Type Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ) - ?? throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentNullException("type") - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to preserve `/` in the rewritten URL. - /// - public bool? PreserveAssetDeliveryTypes - { - get - { - if (!this.Properties.TryGetValue("preserveAssetDeliveryTypes", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["preserveAssetDeliveryTypes"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Type.Validate(); - _ = this.PreserveAssetDeliveryTypes; - } - - public Cloudinary() - { - this.Type = new(); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Cloudinary(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Cloudinary FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/CloudinaryProperties/Type.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/CloudinaryProperties/Type.cs deleted file mode 100644 index 88babc5e..00000000 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/CloudinaryProperties/Type.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointCreateParamsProperties.URLRewriterProperties.CloudinaryProperties; - -[JsonConverter(typeof(Converter))] -public class Type -{ - public JsonElement Json { get; private init; } - - public Type() - { - Json = JsonSerializer.Deserialize("\"CLOUDINARY\""); - } - - Type(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new Type().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); - } - } - - class Converter : JsonConverter - { - public override Type? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/Imgix.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/Imgix.cs deleted file mode 100644 index 972b4807..00000000 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/Imgix.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; - -namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointCreateParamsProperties.URLRewriterProperties; - -[JsonConverter(typeof(Converter))] -public class Imgix -{ - public JsonElement Json { get; private init; } - - public Imgix() - { - Json = JsonSerializer.Deserialize("{\"type\":\"IMGIX\"}"); - } - - Imgix(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new Imgix().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'Imgix'"); - } - } - - class Converter : JsonConverter - { - public override Imgix? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write( - Utf8JsonWriter writer, - Imgix value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/ImgixProperties/Type.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/ImgixProperties/Type.cs deleted file mode 100644 index e8f354ff..00000000 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterProperties/ImgixProperties/Type.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointCreateParamsProperties.URLRewriterProperties.ImgixProperties; - -[JsonConverter(typeof(Converter))] -public class Type -{ - public JsonElement Json { get; private init; } - - public Type() - { - Json = JsonSerializer.Deserialize("\"IMGIX\""); - } - - Type(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new Type().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); - } - } - - class Converter : JsonConverter - { - public override Type? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterVariants/All.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterVariants/All.cs deleted file mode 100644 index bbef6b5d..00000000 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointCreateParamsProperties/URLRewriterVariants/All.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System.Text.Json; -using URLRewriterProperties = Imagekit.Models.Accounts.URLEndpoints.URLEndpointCreateParamsProperties.URLRewriterProperties; - -namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointCreateParamsProperties.URLRewriterVariants; - -public sealed record class Cloudinary(URLRewriterProperties::Cloudinary Value) - : URLRewriter, - IVariant -{ - public static Cloudinary From(URLRewriterProperties::Cloudinary value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class Imgix(JsonElement Value) : URLRewriter, IVariant -{ - public static Imgix From(JsonElement value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Akamai(JsonElement Value) : URLRewriter, IVariant -{ - public static Akamai From(JsonElement value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointDeleteParams.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointDeleteParams.cs deleted file mode 100644 index 7c5510bf..00000000 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointDeleteParams.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using System.Net.Http; - -namespace Imagekit.Models.Accounts.URLEndpoints; - -/// -/// **Note:** This API is currently in beta. Deletes the URL‑endpoint identified -/// by `id`. You cannot delete the default URL‑endpoint created by ImageKit during -/// account creation. -/// -public sealed record class URLEndpointDeleteParams : ParamsBase -{ - public required string ID; - - public override Uri Url(IImageKitClient client) - { - return new UriBuilder( - client.BaseUrl.ToString().TrimEnd('/') - + string.Format("/v1/accounts/url-endpoints/{0}", this.ID) - ) - { - Query = this.QueryString(client), - }.Uri; - } - - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointGetParams.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointGetParams.cs deleted file mode 100644 index 785de18a..00000000 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointGetParams.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using System.Net.Http; - -namespace Imagekit.Models.Accounts.URLEndpoints; - -/// -/// **Note:** This API is currently in beta. Retrieves the URL‑endpoint identified -/// by `id`. -/// -public sealed record class URLEndpointGetParams : ParamsBase -{ - public required string ID; - - public override Uri Url(IImageKitClient client) - { - return new UriBuilder( - client.BaseUrl.ToString().TrimEnd('/') - + string.Format("/v1/accounts/url-endpoints/{0}", this.ID) - ) - { - Query = this.QueryString(client), - }.Uri; - } - - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointListParams.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointListParams.cs deleted file mode 100644 index 86dcc613..00000000 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointListParams.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Net.Http; - -namespace Imagekit.Models.Accounts.URLEndpoints; - -/// -/// **Note:** This API is currently in beta. Returns an array of all URL‑endpoints -/// configured including the default URL-endpoint generated by ImageKit during account -/// creation. -/// -public sealed record class URLEndpointListParams : ParamsBase -{ - public override Uri Url(IImageKitClient client) - { - return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/accounts/url-endpoints") - { - Query = this.QueryString(client), - }.Uri; - } - - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequest.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequest.cs deleted file mode 100644 index f5a1569c..00000000 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequest.cs +++ /dev/null @@ -1,133 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Accounts.URLEndpoints.URLEndpointRequestProperties; - -namespace Imagekit.Models.Accounts.URLEndpoints; - -/// -/// Schema for URL endpoint resource. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class URLEndpointRequest : ModelBase, IFromRaw -{ - /// - /// Description of the URL endpoint. - /// - public required string Description - { - get - { - if (!this.Properties.TryGetValue("description", out JsonElement element)) - throw new ArgumentOutOfRangeException("description", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("description"); - } - set - { - this.Properties["description"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Ordered list of origin IDs to try when the file isn’t in the Media Library; - /// ImageKit checks them in the sequence provided. Origin must be created before - /// it can be used in a URL endpoint. - /// - public List? Origins - { - get - { - if (!this.Properties.TryGetValue("origins", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["origins"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Path segment appended to your base URL to form the endpoint (letters, digits, - /// and hyphens only — or empty for the default endpoint). - /// - public string? URLPrefix - { - get - { - if (!this.Properties.TryGetValue("urlPrefix", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["urlPrefix"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Configuration for third-party URL rewriting. - /// - public URLRewriter? URLRewriter - { - get - { - if (!this.Properties.TryGetValue("urlRewriter", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["urlRewriter"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.Description; - _ = this.Origins; - _ = this.URLPrefix; - this.URLRewriter?.Validate(); - } - - public URLEndpointRequest() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - URLEndpointRequest(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static URLEndpointRequest FromRawUnchecked(Dictionary properties) - { - return new(properties); - } - - [SetsRequiredMembers] - public URLEndpointRequest(string description) - : this() - { - this.Description = description; - } -} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriter.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriter.cs deleted file mode 100644 index 5412a719..00000000 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriter.cs +++ /dev/null @@ -1,204 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Accounts.URLEndpoints.URLEndpointRequestProperties.URLRewriterProperties; - -namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointRequestProperties; - -/// -/// Configuration for third-party URL rewriting. -/// -[JsonConverter(typeof(URLRewriterConverter))] -public record class URLRewriter -{ - public object Value { get; private init; } - - public URLRewriter(Cloudinary value) - { - Value = value; - } - - public URLRewriter(Imgix value) - { - Value = value; - } - - public URLRewriter(Akamai value) - { - Value = value; - } - - URLRewriter(UnknownVariant value) - { - Value = value; - } - - public static URLRewriter CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickCloudinary([NotNullWhen(true)] out Cloudinary? value) - { - value = this.Value as Cloudinary; - return value != null; - } - - public bool TryPickImgix([NotNullWhen(true)] out Imgix? value) - { - value = this.Value as Imgix; - return value != null; - } - - public bool TryPickAkamai([NotNullWhen(true)] out Akamai? value) - { - value = this.Value as Akamai; - return value != null; - } - - public void Switch(Action cloudinary, Action imgix, Action akamai) - { - switch (this.Value) - { - case Cloudinary value: - cloudinary(value); - break; - case Imgix value: - imgix(value); - break; - case Akamai value: - akamai(value); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match(Func cloudinary, Func imgix, Func akamai) - { - return this.Value switch - { - URLRewriterVariants::Cloudinary inner => cloudinary(inner), - URLRewriterVariants::Imgix inner => imgix(inner), - URLRewriterVariants::Akamai inner => akamai(inner), - _ => throw new InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of URLRewriter"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class URLRewriterConverter : JsonConverter -{ - public override URLRewriter? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - var json = JsonSerializer.Deserialize(ref reader, options); - string? type; - try - { - type = json.GetProperty("type").GetString(); - } - catch - { - type = null; - } - - switch (type) - { - case "CLOUDINARY": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - deserialized.Validate(); - return new URLRewriter(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "IMGIX": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - deserialized.Validate(); - return new URLRewriter(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "AKAMAI": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - deserialized.Validate(); - return new URLRewriter(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - default: - { - throw new Exception(); - } - } - } - - public override void Write( - Utf8JsonWriter writer, - URLRewriter value, - JsonSerializerOptions options - ) - { - object variant = value switch - { - URLRewriterVariants::Cloudinary(var cloudinary) => cloudinary, - URLRewriterVariants::Imgix(var imgix) => imgix, - URLRewriterVariants::Akamai(var akamai) => akamai, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/Akamai.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/Akamai.cs deleted file mode 100644 index 6db02d06..00000000 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/Akamai.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; - -namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointRequestProperties.URLRewriterProperties; - -[JsonConverter(typeof(Converter))] -public class Akamai -{ - public JsonElement Json { get; private init; } - - public Akamai() - { - Json = JsonSerializer.Deserialize("{\"type\":\"AKAMAI\"}"); - } - - Akamai(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new Akamai().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'Akamai'"); - } - } - - class Converter : JsonConverter - { - public override Akamai? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write( - Utf8JsonWriter writer, - Akamai value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/AkamaiProperties/Type.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/AkamaiProperties/Type.cs deleted file mode 100644 index 30fcf7be..00000000 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/AkamaiProperties/Type.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointRequestProperties.URLRewriterProperties.AkamaiProperties; - -[JsonConverter(typeof(Converter))] -public class Type -{ - public JsonElement Json { get; private init; } - - public Type() - { - Json = JsonSerializer.Deserialize("\"AKAMAI\""); - } - - Type(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new Type().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); - } - } - - class Converter : JsonConverter - { - public override Type? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/Cloudinary.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/Cloudinary.cs deleted file mode 100644 index ebb8f940..00000000 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/Cloudinary.cs +++ /dev/null @@ -1,81 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointRequestProperties.URLRewriterProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Cloudinary : ModelBase, IFromRaw -{ - public CloudinaryProperties::Type Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ) - ?? throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentNullException("type") - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to preserve `/` in the rewritten URL. - /// - public bool? PreserveAssetDeliveryTypes - { - get - { - if (!this.Properties.TryGetValue("preserveAssetDeliveryTypes", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["preserveAssetDeliveryTypes"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Type.Validate(); - _ = this.PreserveAssetDeliveryTypes; - } - - public Cloudinary() - { - this.Type = new(); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Cloudinary(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Cloudinary FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/CloudinaryProperties/Type.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/CloudinaryProperties/Type.cs deleted file mode 100644 index f8492246..00000000 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/CloudinaryProperties/Type.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointRequestProperties.URLRewriterProperties.CloudinaryProperties; - -[JsonConverter(typeof(Converter))] -public class Type -{ - public JsonElement Json { get; private init; } - - public Type() - { - Json = JsonSerializer.Deserialize("\"CLOUDINARY\""); - } - - Type(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new Type().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); - } - } - - class Converter : JsonConverter - { - public override Type? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/Imgix.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/Imgix.cs deleted file mode 100644 index 6b122f45..00000000 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/Imgix.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; - -namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointRequestProperties.URLRewriterProperties; - -[JsonConverter(typeof(Converter))] -public class Imgix -{ - public JsonElement Json { get; private init; } - - public Imgix() - { - Json = JsonSerializer.Deserialize("{\"type\":\"IMGIX\"}"); - } - - Imgix(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new Imgix().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'Imgix'"); - } - } - - class Converter : JsonConverter - { - public override Imgix? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write( - Utf8JsonWriter writer, - Imgix value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/ImgixProperties/Type.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/ImgixProperties/Type.cs deleted file mode 100644 index b64c63cc..00000000 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterProperties/ImgixProperties/Type.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointRequestProperties.URLRewriterProperties.ImgixProperties; - -[JsonConverter(typeof(Converter))] -public class Type -{ - public JsonElement Json { get; private init; } - - public Type() - { - Json = JsonSerializer.Deserialize("\"IMGIX\""); - } - - Type(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new Type().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); - } - } - - class Converter : JsonConverter - { - public override Type? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterVariants/All.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterVariants/All.cs deleted file mode 100644 index fcad34a1..00000000 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointRequestProperties/URLRewriterVariants/All.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System.Text.Json; -using URLRewriterProperties = Imagekit.Models.Accounts.URLEndpoints.URLEndpointRequestProperties.URLRewriterProperties; - -namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointRequestProperties.URLRewriterVariants; - -public sealed record class Cloudinary(URLRewriterProperties::Cloudinary Value) - : URLRewriter, - IVariant -{ - public static Cloudinary From(URLRewriterProperties::Cloudinary value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class Imgix(JsonElement Value) : URLRewriter, IVariant -{ - public static Imgix From(JsonElement value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Akamai(JsonElement Value) : URLRewriter, IVariant -{ - public static Akamai From(JsonElement value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponse.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponse.cs deleted file mode 100644 index 0416b53f..00000000 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponse.cs +++ /dev/null @@ -1,152 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Accounts.URLEndpoints.URLEndpointResponseProperties; - -namespace Imagekit.Models.Accounts.URLEndpoints; - -/// -/// URL‑endpoint object as returned by the API. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class URLEndpointResponse : ModelBase, IFromRaw -{ - /// - /// Unique identifier for the URL-endpoint. This is generated by ImageKit when - /// you create a new URL-endpoint. For the default URL-endpoint, this is always `default`. - /// - public required string ID - { - get - { - if (!this.Properties.TryGetValue("id", out JsonElement element)) - throw new ArgumentOutOfRangeException("id", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("id"); - } - set - { - this.Properties["id"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Description of the URL endpoint. - /// - public required string Description - { - get - { - if (!this.Properties.TryGetValue("description", out JsonElement element)) - throw new ArgumentOutOfRangeException("description", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("description"); - } - set - { - this.Properties["description"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Ordered list of origin IDs to try when the file isn’t in the Media Library; - /// ImageKit checks them in the sequence provided. Origin must be created before - /// it can be used in a URL endpoint. - /// - public required List Origins - { - get - { - if (!this.Properties.TryGetValue("origins", out JsonElement element)) - throw new ArgumentOutOfRangeException("origins", "Missing required argument"); - - return JsonSerializer.Deserialize>(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("origins"); - } - set - { - this.Properties["origins"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Path segment appended to your base URL to form the endpoint (letters, digits, - /// and hyphens only — or empty for the default endpoint). - /// - public required string URLPrefix - { - get - { - if (!this.Properties.TryGetValue("urlPrefix", out JsonElement element)) - throw new ArgumentOutOfRangeException("urlPrefix", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("urlPrefix"); - } - set - { - this.Properties["urlPrefix"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Configuration for third-party URL rewriting. - /// - public URLRewriter? URLRewriter - { - get - { - if (!this.Properties.TryGetValue("urlRewriter", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["urlRewriter"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.ID; - _ = this.Description; - _ = this.Origins; - _ = this.URLPrefix; - this.URLRewriter?.Validate(); - } - - public URLEndpointResponse() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - URLEndpointResponse(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static URLEndpointResponse FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriter.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriter.cs deleted file mode 100644 index 6cc2ce73..00000000 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriter.cs +++ /dev/null @@ -1,204 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Accounts.URLEndpoints.URLEndpointResponseProperties.URLRewriterProperties; - -namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointResponseProperties; - -/// -/// Configuration for third-party URL rewriting. -/// -[JsonConverter(typeof(URLRewriterConverter))] -public record class URLRewriter -{ - public object Value { get; private init; } - - public URLRewriter(Cloudinary value) - { - Value = value; - } - - public URLRewriter(Imgix value) - { - Value = value; - } - - public URLRewriter(Akamai value) - { - Value = value; - } - - URLRewriter(UnknownVariant value) - { - Value = value; - } - - public static URLRewriter CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickCloudinary([NotNullWhen(true)] out Cloudinary? value) - { - value = this.Value as Cloudinary; - return value != null; - } - - public bool TryPickImgix([NotNullWhen(true)] out Imgix? value) - { - value = this.Value as Imgix; - return value != null; - } - - public bool TryPickAkamai([NotNullWhen(true)] out Akamai? value) - { - value = this.Value as Akamai; - return value != null; - } - - public void Switch(Action cloudinary, Action imgix, Action akamai) - { - switch (this.Value) - { - case Cloudinary value: - cloudinary(value); - break; - case Imgix value: - imgix(value); - break; - case Akamai value: - akamai(value); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match(Func cloudinary, Func imgix, Func akamai) - { - return this.Value switch - { - URLRewriterVariants::Cloudinary inner => cloudinary(inner), - URLRewriterVariants::Imgix inner => imgix(inner), - URLRewriterVariants::Akamai inner => akamai(inner), - _ => throw new InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of URLRewriter"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class URLRewriterConverter : JsonConverter -{ - public override URLRewriter? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - var json = JsonSerializer.Deserialize(ref reader, options); - string? type; - try - { - type = json.GetProperty("type").GetString(); - } - catch - { - type = null; - } - - switch (type) - { - case "CLOUDINARY": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - deserialized.Validate(); - return new URLRewriter(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "IMGIX": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - deserialized.Validate(); - return new URLRewriter(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "AKAMAI": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - deserialized.Validate(); - return new URLRewriter(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - default: - { - throw new Exception(); - } - } - } - - public override void Write( - Utf8JsonWriter writer, - URLRewriter value, - JsonSerializerOptions options - ) - { - object variant = value switch - { - URLRewriterVariants::Cloudinary(var cloudinary) => cloudinary, - URLRewriterVariants::Imgix(var imgix) => imgix, - URLRewriterVariants::Akamai(var akamai) => akamai, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/Akamai.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/Akamai.cs deleted file mode 100644 index 90264d6e..00000000 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/Akamai.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; - -namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointResponseProperties.URLRewriterProperties; - -[JsonConverter(typeof(Converter))] -public class Akamai -{ - public JsonElement Json { get; private init; } - - public Akamai() - { - Json = JsonSerializer.Deserialize("{\"type\":\"AKAMAI\"}"); - } - - Akamai(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new Akamai().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'Akamai'"); - } - } - - class Converter : JsonConverter - { - public override Akamai? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write( - Utf8JsonWriter writer, - Akamai value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/AkamaiProperties/Type.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/AkamaiProperties/Type.cs deleted file mode 100644 index 69dc236e..00000000 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/AkamaiProperties/Type.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointResponseProperties.URLRewriterProperties.AkamaiProperties; - -[JsonConverter(typeof(Converter))] -public class Type -{ - public JsonElement Json { get; private init; } - - public Type() - { - Json = JsonSerializer.Deserialize("\"AKAMAI\""); - } - - Type(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new Type().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); - } - } - - class Converter : JsonConverter - { - public override Type? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/Cloudinary.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/Cloudinary.cs deleted file mode 100644 index 86d99730..00000000 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/Cloudinary.cs +++ /dev/null @@ -1,91 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointResponseProperties.URLRewriterProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Cloudinary : ModelBase, IFromRaw -{ - /// - /// Whether to preserve `/` in the rewritten URL. - /// - public required bool PreserveAssetDeliveryTypes - { - get - { - if (!this.Properties.TryGetValue("preserveAssetDeliveryTypes", out JsonElement element)) - throw new ArgumentOutOfRangeException( - "preserveAssetDeliveryTypes", - "Missing required argument" - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["preserveAssetDeliveryTypes"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public CloudinaryProperties::Type Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ) - ?? throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentNullException("type") - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.PreserveAssetDeliveryTypes; - this.Type.Validate(); - } - - public Cloudinary() - { - this.Type = new(); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Cloudinary(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Cloudinary FromRawUnchecked(Dictionary properties) - { - return new(properties); - } - - [SetsRequiredMembers] - public Cloudinary(bool preserveAssetDeliveryTypes) - : this() - { - this.PreserveAssetDeliveryTypes = preserveAssetDeliveryTypes; - } -} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/CloudinaryProperties/Type.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/CloudinaryProperties/Type.cs deleted file mode 100644 index 1a557c4a..00000000 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/CloudinaryProperties/Type.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointResponseProperties.URLRewriterProperties.CloudinaryProperties; - -[JsonConverter(typeof(Converter))] -public class Type -{ - public JsonElement Json { get; private init; } - - public Type() - { - Json = JsonSerializer.Deserialize("\"CLOUDINARY\""); - } - - Type(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new Type().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); - } - } - - class Converter : JsonConverter - { - public override Type? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/Imgix.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/Imgix.cs deleted file mode 100644 index b8d1ad34..00000000 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/Imgix.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; - -namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointResponseProperties.URLRewriterProperties; - -[JsonConverter(typeof(Converter))] -public class Imgix -{ - public JsonElement Json { get; private init; } - - public Imgix() - { - Json = JsonSerializer.Deserialize("{\"type\":\"IMGIX\"}"); - } - - Imgix(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new Imgix().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'Imgix'"); - } - } - - class Converter : JsonConverter - { - public override Imgix? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write( - Utf8JsonWriter writer, - Imgix value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/ImgixProperties/Type.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/ImgixProperties/Type.cs deleted file mode 100644 index a12bdc8a..00000000 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterProperties/ImgixProperties/Type.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointResponseProperties.URLRewriterProperties.ImgixProperties; - -[JsonConverter(typeof(Converter))] -public class Type -{ - public JsonElement Json { get; private init; } - - public Type() - { - Json = JsonSerializer.Deserialize("\"IMGIX\""); - } - - Type(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new Type().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); - } - } - - class Converter : JsonConverter - { - public override Type? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterVariants/All.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterVariants/All.cs deleted file mode 100644 index 7e77ed0a..00000000 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointResponseProperties/URLRewriterVariants/All.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System.Text.Json; -using URLRewriterProperties = Imagekit.Models.Accounts.URLEndpoints.URLEndpointResponseProperties.URLRewriterProperties; - -namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointResponseProperties.URLRewriterVariants; - -public sealed record class Cloudinary(URLRewriterProperties::Cloudinary Value) - : URLRewriter, - IVariant -{ - public static Cloudinary From(URLRewriterProperties::Cloudinary value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class Imgix(JsonElement Value) : URLRewriter, IVariant -{ - public static Imgix From(JsonElement value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Akamai(JsonElement Value) : URLRewriter, IVariant -{ - public static Akamai From(JsonElement value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParams.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParams.cs deleted file mode 100644 index d19bc332..00000000 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParams.cs +++ /dev/null @@ -1,136 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Net.Http; -using System.Text; -using System.Text.Json; -using Imagekit.Models.Accounts.URLEndpoints.URLEndpointUpdateParamsProperties; - -namespace Imagekit.Models.Accounts.URLEndpoints; - -/// -/// **Note:** This API is currently in beta. Updates the URL‑endpoint identified -/// by `id` and returns the updated object. -/// -public sealed record class URLEndpointUpdateParams : ParamsBase -{ - public Dictionary BodyProperties { get; set; } = []; - - public required string ID; - - /// - /// Description of the URL endpoint. - /// - public required string Description - { - get - { - if (!this.BodyProperties.TryGetValue("description", out JsonElement element)) - throw new ArgumentOutOfRangeException("description", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("description"); - } - set - { - this.BodyProperties["description"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Ordered list of origin IDs to try when the file isn’t in the Media Library; - /// ImageKit checks them in the sequence provided. Origin must be created before - /// it can be used in a URL endpoint. - /// - public List? Origins - { - get - { - if (!this.BodyProperties.TryGetValue("origins", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["origins"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Path segment appended to your base URL to form the endpoint (letters, digits, - /// and hyphens only — or empty for the default endpoint). - /// - public string? URLPrefix - { - get - { - if (!this.BodyProperties.TryGetValue("urlPrefix", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["urlPrefix"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Configuration for third-party URL rewriting. - /// - public URLRewriter? URLRewriter - { - get - { - if (!this.BodyProperties.TryGetValue("urlRewriter", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["urlRewriter"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override Uri Url(IImageKitClient client) - { - return new UriBuilder( - client.BaseUrl.ToString().TrimEnd('/') - + string.Format("/v1/accounts/url-endpoints/{0}", this.ID) - ) - { - Query = this.QueryString(client), - }.Uri; - } - - public StringContent BodyContent() - { - return new( - JsonSerializer.Serialize(this.BodyProperties), - Encoding.UTF8, - "application/json" - ); - } - - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriter.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriter.cs deleted file mode 100644 index e30018df..00000000 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriter.cs +++ /dev/null @@ -1,204 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Accounts.URLEndpoints.URLEndpointUpdateParamsProperties.URLRewriterProperties; - -namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointUpdateParamsProperties; - -/// -/// Configuration for third-party URL rewriting. -/// -[JsonConverter(typeof(URLRewriterConverter))] -public record class URLRewriter -{ - public object Value { get; private init; } - - public URLRewriter(Cloudinary value) - { - Value = value; - } - - public URLRewriter(Imgix value) - { - Value = value; - } - - public URLRewriter(Akamai value) - { - Value = value; - } - - URLRewriter(UnknownVariant value) - { - Value = value; - } - - public static URLRewriter CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickCloudinary([NotNullWhen(true)] out Cloudinary? value) - { - value = this.Value as Cloudinary; - return value != null; - } - - public bool TryPickImgix([NotNullWhen(true)] out Imgix? value) - { - value = this.Value as Imgix; - return value != null; - } - - public bool TryPickAkamai([NotNullWhen(true)] out Akamai? value) - { - value = this.Value as Akamai; - return value != null; - } - - public void Switch(Action cloudinary, Action imgix, Action akamai) - { - switch (this.Value) - { - case Cloudinary value: - cloudinary(value); - break; - case Imgix value: - imgix(value); - break; - case Akamai value: - akamai(value); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match(Func cloudinary, Func imgix, Func akamai) - { - return this.Value switch - { - URLRewriterVariants::Cloudinary inner => cloudinary(inner), - URLRewriterVariants::Imgix inner => imgix(inner), - URLRewriterVariants::Akamai inner => akamai(inner), - _ => throw new InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of URLRewriter"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class URLRewriterConverter : JsonConverter -{ - public override URLRewriter? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - var json = JsonSerializer.Deserialize(ref reader, options); - string? type; - try - { - type = json.GetProperty("type").GetString(); - } - catch - { - type = null; - } - - switch (type) - { - case "CLOUDINARY": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - deserialized.Validate(); - return new URLRewriter(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "IMGIX": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - deserialized.Validate(); - return new URLRewriter(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "AKAMAI": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - deserialized.Validate(); - return new URLRewriter(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - default: - { - throw new Exception(); - } - } - } - - public override void Write( - Utf8JsonWriter writer, - URLRewriter value, - JsonSerializerOptions options - ) - { - object variant = value switch - { - URLRewriterVariants::Cloudinary(var cloudinary) => cloudinary, - URLRewriterVariants::Imgix(var imgix) => imgix, - URLRewriterVariants::Akamai(var akamai) => akamai, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/Akamai.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/Akamai.cs deleted file mode 100644 index dda4685e..00000000 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/Akamai.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; - -namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointUpdateParamsProperties.URLRewriterProperties; - -[JsonConverter(typeof(Converter))] -public class Akamai -{ - public JsonElement Json { get; private init; } - - public Akamai() - { - Json = JsonSerializer.Deserialize("{\"type\":\"AKAMAI\"}"); - } - - Akamai(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new Akamai().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'Akamai'"); - } - } - - class Converter : JsonConverter - { - public override Akamai? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write( - Utf8JsonWriter writer, - Akamai value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/AkamaiProperties/Type.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/AkamaiProperties/Type.cs deleted file mode 100644 index 3261f052..00000000 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/AkamaiProperties/Type.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointUpdateParamsProperties.URLRewriterProperties.AkamaiProperties; - -[JsonConverter(typeof(Converter))] -public class Type -{ - public JsonElement Json { get; private init; } - - public Type() - { - Json = JsonSerializer.Deserialize("\"AKAMAI\""); - } - - Type(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new Type().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); - } - } - - class Converter : JsonConverter - { - public override Type? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/Cloudinary.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/Cloudinary.cs deleted file mode 100644 index aba050c2..00000000 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/Cloudinary.cs +++ /dev/null @@ -1,81 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointUpdateParamsProperties.URLRewriterProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Cloudinary : ModelBase, IFromRaw -{ - public CloudinaryProperties::Type Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ) - ?? throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentNullException("type") - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to preserve `/` in the rewritten URL. - /// - public bool? PreserveAssetDeliveryTypes - { - get - { - if (!this.Properties.TryGetValue("preserveAssetDeliveryTypes", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["preserveAssetDeliveryTypes"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Type.Validate(); - _ = this.PreserveAssetDeliveryTypes; - } - - public Cloudinary() - { - this.Type = new(); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Cloudinary(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Cloudinary FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/CloudinaryProperties/Type.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/CloudinaryProperties/Type.cs deleted file mode 100644 index 367e88df..00000000 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/CloudinaryProperties/Type.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointUpdateParamsProperties.URLRewriterProperties.CloudinaryProperties; - -[JsonConverter(typeof(Converter))] -public class Type -{ - public JsonElement Json { get; private init; } - - public Type() - { - Json = JsonSerializer.Deserialize("\"CLOUDINARY\""); - } - - Type(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new Type().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); - } - } - - class Converter : JsonConverter - { - public override Type? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/Imgix.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/Imgix.cs deleted file mode 100644 index 517efa64..00000000 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/Imgix.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; - -namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointUpdateParamsProperties.URLRewriterProperties; - -[JsonConverter(typeof(Converter))] -public class Imgix -{ - public JsonElement Json { get; private init; } - - public Imgix() - { - Json = JsonSerializer.Deserialize("{\"type\":\"IMGIX\"}"); - } - - Imgix(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new Imgix().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'Imgix'"); - } - } - - class Converter : JsonConverter - { - public override Imgix? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write( - Utf8JsonWriter writer, - Imgix value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/ImgixProperties/Type.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/ImgixProperties/Type.cs deleted file mode 100644 index 8e3a4b7f..00000000 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterProperties/ImgixProperties/Type.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointUpdateParamsProperties.URLRewriterProperties.ImgixProperties; - -[JsonConverter(typeof(Converter))] -public class Type -{ - public JsonElement Json { get; private init; } - - public Type() - { - Json = JsonSerializer.Deserialize("\"IMGIX\""); - } - - Type(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new Type().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); - } - } - - class Converter : JsonConverter - { - public override Type? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterVariants/All.cs b/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterVariants/All.cs deleted file mode 100644 index bab987b0..00000000 --- a/src/Imagekit/Models/Accounts/URLEndpoints/URLEndpointUpdateParamsProperties/URLRewriterVariants/All.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System.Text.Json; -using URLRewriterProperties = Imagekit.Models.Accounts.URLEndpoints.URLEndpointUpdateParamsProperties.URLRewriterProperties; - -namespace Imagekit.Models.Accounts.URLEndpoints.URLEndpointUpdateParamsProperties.URLRewriterVariants; - -public sealed record class Cloudinary(URLRewriterProperties::Cloudinary Value) - : URLRewriter, - IVariant -{ - public static Cloudinary From(URLRewriterProperties::Cloudinary value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class Imgix(JsonElement Value) : URLRewriter, IVariant -{ - public static Imgix From(JsonElement value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Akamai(JsonElement Value) : URLRewriter, IVariant -{ - public static Akamai From(JsonElement value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/Accounts/Usage/UsageGetParams.cs b/src/Imagekit/Models/Accounts/Usage/UsageGetParams.cs deleted file mode 100644 index 6920035b..00000000 --- a/src/Imagekit/Models/Accounts/Usage/UsageGetParams.cs +++ /dev/null @@ -1,75 +0,0 @@ -using System; -using System.Net.Http; -using System.Text.Json; - -namespace Imagekit.Models.Accounts.Usage; - -/// -/// Get the account usage information between two dates. Note that the API response -/// includes data from the start date while excluding data from the end date. In -/// other words, the data covers the period starting from the specified start date -/// up to, but not including, the end date. -/// -public sealed record class UsageGetParams : ParamsBase -{ - /// - /// Specify a `endDate` in `YYYY-MM-DD` format. It should be after the `startDate`. - /// The difference between `startDate` and `endDate` should be less than 90 days. - /// - public required DateOnly EndDate - { - get - { - if (!this.QueryProperties.TryGetValue("endDate", out JsonElement element)) - throw new ArgumentOutOfRangeException("endDate", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.QueryProperties["endDate"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specify a `startDate` in `YYYY-MM-DD` format. It should be before the `endDate`. - /// The difference between `startDate` and `endDate` should be less than 90 days. - /// - public required DateOnly StartDate - { - get - { - if (!this.QueryProperties.TryGetValue("startDate", out JsonElement element)) - throw new ArgumentOutOfRangeException("startDate", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.QueryProperties["startDate"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override Uri Url(IImageKitClient client) - { - return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/accounts/usage") - { - Query = this.QueryString(client), - }.Uri; - } - - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} diff --git a/src/Imagekit/Models/Accounts/Usage/UsageGetResponse.cs b/src/Imagekit/Models/Accounts/Usage/UsageGetResponse.cs deleted file mode 100644 index d540bab5..00000000 --- a/src/Imagekit/Models/Accounts/Usage/UsageGetResponse.cs +++ /dev/null @@ -1,139 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Accounts.Usage; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class UsageGetResponse : ModelBase, IFromRaw -{ - /// - /// Amount of bandwidth used in bytes. - /// - public long? BandwidthBytes - { - get - { - if (!this.Properties.TryGetValue("bandwidthBytes", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["bandwidthBytes"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Number of extension units used. - /// - public long? ExtensionUnitsCount - { - get - { - if (!this.Properties.TryGetValue("extensionUnitsCount", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["extensionUnitsCount"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Storage used by media library in bytes. - /// - public long? MediaLibraryStorageBytes - { - get - { - if (!this.Properties.TryGetValue("mediaLibraryStorageBytes", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["mediaLibraryStorageBytes"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Storage used by the original cache in bytes. - /// - public long? OriginalCacheStorageBytes - { - get - { - if (!this.Properties.TryGetValue("originalCacheStorageBytes", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["originalCacheStorageBytes"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Number of video processing units used. - /// - public long? VideoProcessingUnitsCount - { - get - { - if (!this.Properties.TryGetValue("videoProcessingUnitsCount", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["videoProcessingUnitsCount"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.BandwidthBytes; - _ = this.ExtensionUnitsCount; - _ = this.MediaLibraryStorageBytes; - _ = this.OriginalCacheStorageBytes; - _ = this.VideoProcessingUnitsCount; - } - - public UsageGetResponse() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - UsageGetResponse(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static UsageGetResponse FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Assets/AssetListParams.cs b/src/Imagekit/Models/Assets/AssetListParams.cs deleted file mode 100644 index 0e5fb2b3..00000000 --- a/src/Imagekit/Models/Assets/AssetListParams.cs +++ /dev/null @@ -1,210 +0,0 @@ -using System; -using System.Net.Http; -using System.Text.Json; -using AssetListParamsProperties = Imagekit.Models.Assets.AssetListParamsProperties; - -namespace Imagekit.Models.Assets; - -/// -/// This API can list all the uploaded files and folders in your ImageKit.io media -/// library. In addition, you can fine-tune your query by specifying various filters -/// by generating a query string in a Lucene-like syntax and provide this generated -/// string as the value of the `searchQuery`. -/// -public sealed record class AssetListParams : ParamsBase -{ - /// - /// Filter results by file type. - /// - /// - `all` — include all file types - `image` — include only image files - /// - `non-image` — include only non-image files (e.g., JS, CSS, video) - /// - public ApiEnum? FileType - { - get - { - if (!this.QueryProperties.TryGetValue("fileType", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.QueryProperties["fileType"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The maximum number of results to return in response. - /// - public long? Limit - { - get - { - if (!this.QueryProperties.TryGetValue("limit", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.QueryProperties["limit"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Folder path if you want to limit the search within a specific folder. For - /// example, `/sales-banner/` will only search in folder sales-banner. - /// - /// Note : If your use case involves searching within a folder as well as its - /// subfolders, you can use `path` parameter in `searchQuery` with appropriate - /// operator. Checkout [Supported parameters](/docs/api-reference/digital-asset-management-dam/list-and-search-assets#supported-parameters) - /// for more information. - /// - public string? Path - { - get - { - if (!this.QueryProperties.TryGetValue("path", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.QueryProperties["path"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Query string in a Lucene-like query language e.g. `createdAt > "7d"`. - /// - /// Note : When the searchQuery parameter is present, the following query parameters - /// will have no effect on the result: - /// - /// 1. `tags` 2. `type` 3. `name` - /// - /// [Learn more](/docs/api-reference/digital-asset-management-dam/list-and-search-assets#advanced-search-queries) - /// from examples. - /// - public string? SearchQuery - { - get - { - if (!this.QueryProperties.TryGetValue("searchQuery", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.QueryProperties["searchQuery"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The number of results to skip before returning results. - /// - public long? Skip - { - get - { - if (!this.QueryProperties.TryGetValue("skip", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.QueryProperties["skip"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Sort the results by one of the supported fields in ascending or descending - /// order. - /// - public ApiEnum? Sort - { - get - { - if (!this.QueryProperties.TryGetValue("sort", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.QueryProperties["sort"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Filter results by asset type. - /// - /// - `file` — returns only files - `file-version` — returns specific file versions - /// - `folder` — returns only folders - `all` — returns both files and folders - /// (excludes `file-version`) - /// - public ApiEnum? Type - { - get - { - if (!this.QueryProperties.TryGetValue("type", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.QueryProperties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override Uri Url(IImageKitClient client) - { - return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/files") - { - Query = this.QueryString(client), - }.Uri; - } - - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} diff --git a/src/Imagekit/Models/Assets/AssetListParamsProperties/FileType.cs b/src/Imagekit/Models/Assets/AssetListParamsProperties/FileType.cs deleted file mode 100644 index 620809fb..00000000 --- a/src/Imagekit/Models/Assets/AssetListParamsProperties/FileType.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using System = System; - -namespace Imagekit.Models.Assets.AssetListParamsProperties; - -/// -/// Filter results by file type. -/// -/// - `all` — include all file types - `image` — include only image files - `non-image` -/// — include only non-image files (e.g., JS, CSS, video) -/// -[JsonConverter(typeof(FileTypeConverter))] -public enum FileType -{ - All, - Image, - NonImage, -} - -sealed class FileTypeConverter : JsonConverter -{ - public override FileType Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "all" => FileType.All, - "image" => FileType.Image, - "non-image" => FileType.NonImage, - _ => (FileType)(-1), - }; - } - - public override void Write(Utf8JsonWriter writer, FileType value, JsonSerializerOptions options) - { - JsonSerializer.Serialize( - writer, - value switch - { - FileType.All => "all", - FileType.Image => "image", - FileType.NonImage => "non-image", - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Assets/AssetListParamsProperties/Sort.cs b/src/Imagekit/Models/Assets/AssetListParamsProperties/Sort.cs deleted file mode 100644 index a932d642..00000000 --- a/src/Imagekit/Models/Assets/AssetListParamsProperties/Sort.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using System = System; - -namespace Imagekit.Models.Assets.AssetListParamsProperties; - -/// -/// Sort the results by one of the supported fields in ascending or descending order. -/// -[JsonConverter(typeof(SortConverter))] -public enum Sort -{ - AscName, - DescName, - AscCreated, - DescCreated, - AscUpdated, - DescUpdated, - AscHeight, - DescHeight, - AscWidth, - DescWidth, - AscSize, - DescSize, - AscRelevance, - DescRelevance, -} - -sealed class SortConverter : JsonConverter -{ - public override Sort Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "ASC_NAME" => Sort.AscName, - "DESC_NAME" => Sort.DescName, - "ASC_CREATED" => Sort.AscCreated, - "DESC_CREATED" => Sort.DescCreated, - "ASC_UPDATED" => Sort.AscUpdated, - "DESC_UPDATED" => Sort.DescUpdated, - "ASC_HEIGHT" => Sort.AscHeight, - "DESC_HEIGHT" => Sort.DescHeight, - "ASC_WIDTH" => Sort.AscWidth, - "DESC_WIDTH" => Sort.DescWidth, - "ASC_SIZE" => Sort.AscSize, - "DESC_SIZE" => Sort.DescSize, - "ASC_RELEVANCE" => Sort.AscRelevance, - "DESC_RELEVANCE" => Sort.DescRelevance, - _ => (Sort)(-1), - }; - } - - public override void Write(Utf8JsonWriter writer, Sort value, JsonSerializerOptions options) - { - JsonSerializer.Serialize( - writer, - value switch - { - Sort.AscName => "ASC_NAME", - Sort.DescName => "DESC_NAME", - Sort.AscCreated => "ASC_CREATED", - Sort.DescCreated => "DESC_CREATED", - Sort.AscUpdated => "ASC_UPDATED", - Sort.DescUpdated => "DESC_UPDATED", - Sort.AscHeight => "ASC_HEIGHT", - Sort.DescHeight => "DESC_HEIGHT", - Sort.AscWidth => "ASC_WIDTH", - Sort.DescWidth => "DESC_WIDTH", - Sort.AscSize => "ASC_SIZE", - Sort.DescSize => "DESC_SIZE", - Sort.AscRelevance => "ASC_RELEVANCE", - Sort.DescRelevance => "DESC_RELEVANCE", - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Assets/AssetListParamsProperties/Type.cs b/src/Imagekit/Models/Assets/AssetListParamsProperties/Type.cs deleted file mode 100644 index e3141966..00000000 --- a/src/Imagekit/Models/Assets/AssetListParamsProperties/Type.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using System = System; - -namespace Imagekit.Models.Assets.AssetListParamsProperties; - -/// -/// Filter results by asset type. -/// -/// - `file` — returns only files - `file-version` — returns specific file versions -/// - `folder` — returns only folders - `all` — returns both files and folders -/// (excludes `file-version`) -/// -[JsonConverter(typeof(TypeConverter))] -public enum Type -{ - File, - FileVersion, - Folder, - All, -} - -sealed class TypeConverter : JsonConverter -{ - public override Type Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "file" => AssetListParamsProperties.Type.File, - "file-version" => AssetListParamsProperties.Type.FileVersion, - "folder" => AssetListParamsProperties.Type.Folder, - "all" => AssetListParamsProperties.Type.All, - _ => (Type)(-1), - }; - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonSerializer.Serialize( - writer, - value switch - { - AssetListParamsProperties.Type.File => "file", - AssetListParamsProperties.Type.FileVersion => "file-version", - AssetListParamsProperties.Type.Folder => "folder", - AssetListParamsProperties.Type.All => "all", - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Assets/AssetListResponse.cs b/src/Imagekit/Models/Assets/AssetListResponse.cs deleted file mode 100644 index 4076253d..00000000 --- a/src/Imagekit/Models/Assets/AssetListResponse.cs +++ /dev/null @@ -1,181 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Files; - -namespace Imagekit.Models.Assets; - -/// -/// Object containing details of a file or file version. -/// -[JsonConverter(typeof(AssetListResponseConverter))] -public record class AssetListResponse -{ - public object Value { get; private init; } - - public DateTime? CreatedAt - { - get { return Match(file: (x) => x.CreatedAt, folder: (x) => x.CreatedAt); } - } - - public string? Name - { - get { return Match(file: (x) => x.Name, folder: (x) => x.Name); } - } - - public DateTime? UpdatedAt - { - get { return Match(file: (x) => x.UpdatedAt, folder: (x) => x.UpdatedAt); } - } - - public AssetListResponse(File value) - { - Value = value; - } - - public AssetListResponse(Folder value) - { - Value = value; - } - - AssetListResponse(UnknownVariant value) - { - Value = value; - } - - public static AssetListResponse CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickFile([NotNullWhen(true)] out File? value) - { - value = this.Value as File; - return value != null; - } - - public bool TryPickFolder([NotNullWhen(true)] out Folder? value) - { - value = this.Value as Folder; - return value != null; - } - - public void Switch(Action file, Action folder) - { - switch (this.Value) - { - case File value: - file(value); - break; - case Folder value: - folder(value); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match(Func file, Func folder) - { - return this.Value switch - { - AssetListResponseVariants::File inner => file(inner), - AssetListResponseVariants::Folder inner => folder(inner), - _ => throw new InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException( - "Data did not match any variant of AssetListResponse" - ); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class AssetListResponseConverter : JsonConverter -{ - public override AssetListResponse? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - var json = JsonSerializer.Deserialize(ref reader, options); - string? type; - try - { - type = json.GetProperty("type").GetString(); - } - catch - { - type = null; - } - - switch (type) - { - case "folder": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - deserialized.Validate(); - return new AssetListResponse(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - default: - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - deserialized.Validate(); - return new AssetListResponse(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - } - } - - public override void Write( - Utf8JsonWriter writer, - AssetListResponse value, - JsonSerializerOptions options - ) - { - object variant = value switch - { - AssetListResponseVariants::File(var file) => file, - AssetListResponseVariants::Folder(var folder) => folder, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/Assets/AssetListResponseVariants/All.cs b/src/Imagekit/Models/Assets/AssetListResponseVariants/All.cs deleted file mode 100644 index 5bd62993..00000000 --- a/src/Imagekit/Models/Assets/AssetListResponseVariants/All.cs +++ /dev/null @@ -1,34 +0,0 @@ -using Files = Imagekit.Models.Files; - -namespace Imagekit.Models.Assets.AssetListResponseVariants; - -/// -/// Object containing details of a file or file version. -/// -public sealed record class File(Files::File Value) : AssetListResponse, IVariant -{ - public static File From(Files::File value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class Folder(Files::Folder Value) - : AssetListResponse, - IVariant -{ - public static Folder From(Files::Folder value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} diff --git a/src/Imagekit/Models/BaseOverlay.cs b/src/Imagekit/Models/BaseOverlay.cs deleted file mode 100644 index b1a9d463..00000000 --- a/src/Imagekit/Models/BaseOverlay.cs +++ /dev/null @@ -1,70 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class BaseOverlay : ModelBase, IFromRaw -{ - public OverlayPosition? Position - { - get - { - if (!this.Properties.TryGetValue("position", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["position"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public OverlayTiming? Timing - { - get - { - if (!this.Properties.TryGetValue("timing", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["timing"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Position?.Validate(); - this.Timing?.Validate(); - } - - public BaseOverlay() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - BaseOverlay(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static BaseOverlay FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParams.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParams.cs deleted file mode 100644 index 4385ef03..00000000 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParams.cs +++ /dev/null @@ -1,575 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Net.Http; -using System.Text; -using System.Text.Json; -using Imagekit.Core; -using Imagekit.Exceptions; -using FileUploadParamsProperties = Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties; - -namespace Imagekit.Models.Beta.V2.Files; - -/// -/// The V2 API enhances security by verifying the entire payload using JWT. This -/// API is in beta. -/// -/// ImageKit.io allows you to upload files directly from both the server and client -/// sides. For server-side uploads, private API key authentication is used. For client-side -/// uploads, generate a one-time `token` from your secure backend using private API. -/// [Learn more](/docs/api-reference/upload-file/upload-file-v2#how-to-implement-secure-client-side-file-upload) -/// about how to implement secure client-side file upload. -/// -/// **File size limit** \ On the free plan, the maximum upload file sizes are 20MB -/// for images, audio, and raw files, and 100MB for videos. On the paid plan, these -/// limits increase to 40MB for images, audio, and raw files, and 2GB for videos. -/// These limits can be further increased with higher-tier plans. -/// -/// **Version limit** \ A file can have a maximum of 100 versions. -/// -/// **Demo applications** -/// -/// - A full-fledged [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), -/// supporting file selections from local storage, URL, Dropbox, Google Drive, Instagram, -/// and more. - [Quick start guides](/docs/quick-start-guides) for various frameworks -/// and technologies. -/// -public sealed record class FileUploadParams : ParamsBase -{ - public Dictionary BodyProperties { get; set; } = []; - - /// - /// The API accepts any of the following: - /// - /// - **Binary data** – send the raw bytes as `multipart/form-data`. - **HTTP - /// / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. - /// - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. - /// - /// When supplying a URL, the server must receive the response headers within - /// 8 seconds; otherwise the request fails with 400 Bad Request. - /// - public required string File - { - get - { - if (!this.BodyProperties.TryGetValue("file", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'file' cannot be null", - new ArgumentOutOfRangeException("file", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'file' cannot be null", - new ArgumentNullException("file") - ); - } - set - { - this.BodyProperties["file"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The name with which the file has to be uploaded. - /// - public required string FileName - { - get - { - if (!this.BodyProperties.TryGetValue("fileName", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'fileName' cannot be null", - new ArgumentOutOfRangeException("fileName", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'fileName' cannot be null", - new ArgumentNullException("fileName") - ); - } - set - { - this.BodyProperties["fileName"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// This is the client-generated JSON Web Token (JWT). The ImageKit.io server - /// uses it to authenticate and check that the upload request parameters have - /// not been tampered with after the token has been generated. Learn how to create - /// the token on the page below. This field is only required for authentication - /// when uploading a file from the client side. - /// - /// **Note**: Sending a JWT that has been used in the past will result in a validation - /// error. Even if your previous request resulted in an error, you should always - /// send a new token. - /// - /// **⚠️Warning**: JWT must be generated on the server-side because it is generated - /// using your account's private API key. This field is required for authentication - /// when uploading a file from the client-side. - /// - public string? Token - { - get - { - if (!this.BodyProperties.TryGetValue("token", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["token"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Server-side checks to run on the asset. Read more about [Upload API checks](/docs/api-reference/upload-file/upload-file-v2#upload-api-checks). - /// - public string? Checks - { - get - { - if (!this.BodyProperties.TryGetValue("checks", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["checks"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Define an important area in the image. This is only relevant for image type files. - /// - /// - To be passed as a string with the x and y coordinates of the top-left - /// corner, and width and height of the area of interest in the format `x,y,width,height`. - /// For example - `10,10,100,100` - Can be used with fo-customtransformation. - /// - If this field is not specified and the file is overwritten, then customCoordinates - /// will be removed. - /// - public string? CustomCoordinates - { - get - { - if (!this.BodyProperties.TryGetValue("customCoordinates", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["customCoordinates"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// JSON key-value pairs to associate with the asset. Create the custom metadata - /// fields before setting these values. - /// - public Dictionary? CustomMetadata - { - get - { - if (!this.BodyProperties.TryGetValue("customMetadata", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.BodyProperties["customMetadata"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Optional text to describe the contents of the file. - /// - public string? Description - { - get - { - if (!this.BodyProperties.TryGetValue("description", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["description"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Array of extensions to be applied to the asset. Each extension can be configured - /// with specific parameters based on the extension type. - /// - public List? Extensions - { - get - { - if (!this.BodyProperties.TryGetValue("extensions", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.BodyProperties["extensions"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The folder path in which the image has to be uploaded. If the folder(s) didn't - /// exist before, a new folder(s) is created. Using multiple `/` creates a nested - /// folder. - /// - public string? Folder - { - get - { - if (!this.BodyProperties.TryGetValue("folder", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["folder"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to mark the file as private or not. - /// - /// If `true`, the file is marked as private and is accessible only using named - /// transformation or signed URL. - /// - public bool? IsPrivateFile - { - get - { - if (!this.BodyProperties.TryGetValue("isPrivateFile", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["isPrivateFile"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to upload file as published or not. - /// - /// If `false`, the file is marked as unpublished, which restricts access to the - /// file only via the media library. Files in draft or unpublished state can only - /// be publicly accessed after being published. - /// - /// The option to upload in draft state is only available in custom enterprise - /// pricing plans. - /// - public bool? IsPublished - { - get - { - if (!this.BodyProperties.TryGetValue("isPublished", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["isPublished"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// If set to `true` and a file already exists at the exact location, its AITags - /// will be removed. Set `overwriteAITags` to `false` to preserve AITags. - /// - public bool? OverwriteAITags - { - get - { - if (!this.BodyProperties.TryGetValue("overwriteAITags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["overwriteAITags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// If the request does not have `customMetadata`, and a file already exists at - /// the exact location, existing customMetadata will be removed. - /// - public bool? OverwriteCustomMetadata - { - get - { - if ( - !this.BodyProperties.TryGetValue("overwriteCustomMetadata", out JsonElement element) - ) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["overwriteCustomMetadata"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// If `false` and `useUniqueFileName` is also `false`, and a file already exists - /// at the exact location, upload API will return an error immediately. - /// - public bool? OverwriteFile - { - get - { - if (!this.BodyProperties.TryGetValue("overwriteFile", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["overwriteFile"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// If the request does not have `tags`, and a file already exists at the exact - /// location, existing tags will be removed. - /// - public bool? OverwriteTags - { - get - { - if (!this.BodyProperties.TryGetValue("overwriteTags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["overwriteTags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Array of response field keys to include in the API response body. - /// - public List>? ResponseFields - { - get - { - if (!this.BodyProperties.TryGetValue("responseFields", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize - >?>(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["responseFields"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Set the tags while uploading the file. Provide an array of tag strings (e.g. - /// `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must - /// not exceed 500, and the `%` character is not allowed. If this field is not - /// specified and the file is overwritten, the existing tags will be removed. - /// - public List? Tags - { - get - { - if (!this.BodyProperties.TryGetValue("tags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["tags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Configure pre-processing (`pre`) and post-processing (`post`) transformations. - /// - /// - `pre` — applied before the file is uploaded to the Media Library. Useful - /// for reducing file size or applying basic optimizations upfront (e.g., resize, compress). - /// - /// - `post` — applied immediately after upload. Ideal for generating transformed - /// versions (like video encodes or thumbnails) in advance, so they're ready for - /// delivery without delay. - /// - /// You can mix and match any combination of post-processing types. - /// - public FileUploadParamsProperties::Transformation? Transformation - { - get - { - if (!this.BodyProperties.TryGetValue("transformation", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.BodyProperties["transformation"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to use a unique filename for this file or not. - /// - /// If `true`, ImageKit.io will add a unique suffix to the filename parameter - /// to get a unique filename. - /// - /// If `false`, then the image is uploaded with the provided filename parameter, - /// and any existing file with the same name is replaced. - /// - public bool? UseUniqueFileName - { - get - { - if (!this.BodyProperties.TryGetValue("useUniqueFileName", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["useUniqueFileName"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The final status of extensions after they have completed execution will be - /// delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) - /// about the webhook payload structure. - /// - public string? WebhookURL - { - get - { - if (!this.BodyProperties.TryGetValue("webhookUrl", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["webhookUrl"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override Uri Url(IImageKitClient client) - { - return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/api/v2/files/upload") - { - Query = this.QueryString(client), - }.Uri; - } - - internal override StringContent? BodyContent() - { - return new( - JsonSerializer.Serialize(this.BodyProperties), - Encoding.UTF8, - "application/json" - ); - } - - internal override void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/Extension.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/Extension.cs deleted file mode 100644 index 643fb77a..00000000 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/Extension.cs +++ /dev/null @@ -1,177 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.ExtensionProperties; -using ExtensionVariants = Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.ExtensionVariants; - -namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties; - -[JsonConverter(typeof(ExtensionConverter))] -public abstract record class Extension -{ - internal Extension() { } - - public static implicit operator Extension(RemoveBg value) => - new ExtensionVariants::RemoveBg(value); - - public static implicit operator Extension(AutoTaggingExtension value) => - new ExtensionVariants::AutoTaggingExtension(value); - - public bool TryPickRemoveBg([NotNullWhen(true)] out RemoveBg? value) - { - value = (this as ExtensionVariants::RemoveBg)?.Value; - return value != null; - } - - public bool TryPickAutoTagging([NotNullWhen(true)] out AutoTaggingExtension? value) - { - value = (this as ExtensionVariants::AutoTaggingExtension)?.Value; - return value != null; - } - - public bool TryPickAIAutoDescription([NotNullWhen(true)] out JsonElement? value) - { - value = (this as ExtensionVariants::AIAutoDescription)?.Value; - return value != null; - } - - public void Switch( - Action removeBg, - Action autoTagging, - Action aiAutoDescription - ) - { - switch (this) - { - case ExtensionVariants::RemoveBg inner: - removeBg(inner); - break; - case ExtensionVariants::AutoTaggingExtension inner: - autoTagging(inner); - break; - case ExtensionVariants::AIAutoDescription inner: - aiAutoDescription(inner); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match( - Func removeBg, - Func autoTagging, - Func aiAutoDescription - ) - { - return this switch - { - ExtensionVariants::RemoveBg inner => removeBg(inner), - ExtensionVariants::AutoTaggingExtension inner => autoTagging(inner), - ExtensionVariants::AIAutoDescription inner => aiAutoDescription(inner), - _ => throw new InvalidOperationException(), - }; - } - - public abstract void Validate(); -} - -sealed class ExtensionConverter : JsonConverter -{ - public override Extension? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - var json = JsonSerializer.Deserialize(ref reader, options); - string? name; - try - { - name = json.GetProperty("name").GetString(); - } - catch - { - name = null; - } - - switch (name) - { - case "remove-bg": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - return new ExtensionVariants::RemoveBg(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "ai-auto-description": - { - List exceptions = []; - - try - { - return new ExtensionVariants::AIAutoDescription( - JsonSerializer.Deserialize(json, options) - ); - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - default: - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize( - json, - options - ); - if (deserialized != null) - { - return new ExtensionVariants::AutoTaggingExtension(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - } - } - - public override void Write( - Utf8JsonWriter writer, - Extension value, - JsonSerializerOptions options - ) - { - object variant = value switch - { - ExtensionVariants::RemoveBg(var removeBg) => removeBg, - ExtensionVariants::AutoTaggingExtension(var autoTagging) => autoTagging, - ExtensionVariants::AIAutoDescription(var aiAutoDescription) => aiAutoDescription, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ExtensionProperties/AutoTaggingExtension.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ExtensionProperties/AutoTaggingExtension.cs deleted file mode 100644 index 0d372e84..00000000 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ExtensionProperties/AutoTaggingExtension.cs +++ /dev/null @@ -1,100 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.ExtensionProperties.AutoTaggingExtensionProperties; - -namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.ExtensionProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class AutoTaggingExtension : ModelBase, IFromRaw -{ - /// - /// Maximum number of tags to attach to the asset. - /// - public required long MaxTags - { - get - { - if (!this.Properties.TryGetValue("maxTags", out JsonElement element)) - throw new ArgumentOutOfRangeException("maxTags", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["maxTags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Minimum confidence level for tags to be considered valid. - /// - public required long MinConfidence - { - get - { - if (!this.Properties.TryGetValue("minConfidence", out JsonElement element)) - throw new ArgumentOutOfRangeException("minConfidence", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["minConfidence"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies the auto-tagging extension used. - /// - public required ApiEnum Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - throw new ArgumentOutOfRangeException("name", "Missing required argument"); - - return JsonSerializer.Deserialize>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.MaxTags; - _ = this.MinConfidence; - this.Name.Validate(); - } - - public AutoTaggingExtension() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - AutoTaggingExtension(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static AutoTaggingExtension FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs deleted file mode 100644 index d6d37376..00000000 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.ExtensionProperties.AutoTaggingExtensionProperties; - -/// -/// Specifies the auto-tagging extension used. -/// -[JsonConverter(typeof(NameConverter))] -public enum Name -{ - GoogleAutoTagging, - AwsAutoTagging, -} - -sealed class NameConverter : JsonConverter -{ - public override Name Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "google-auto-tagging" => Name.GoogleAutoTagging, - "aws-auto-tagging" => Name.AwsAutoTagging, - _ => (Name)(-1), - }; - } - - public override void Write(Utf8JsonWriter writer, Name value, JsonSerializerOptions options) - { - JsonSerializer.Serialize( - writer, - value switch - { - Name.GoogleAutoTagging => "google-auto-tagging", - Name.AwsAutoTagging => "aws-auto-tagging", - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ExtensionProperties/RemoveBg.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ExtensionProperties/RemoveBg.cs deleted file mode 100644 index fde15cdf..00000000 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ExtensionProperties/RemoveBg.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.ExtensionProperties.RemoveBgProperties; - -namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.ExtensionProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class RemoveBg : ModelBase, IFromRaw -{ - /// - /// Specifies the background removal extension. - /// - public JsonElement Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - throw new ArgumentOutOfRangeException("name", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public Options? Options - { - get - { - if (!this.Properties.TryGetValue("options", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["options"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Options?.Validate(); - } - - public RemoveBg() - { - this.Name = JsonSerializer.Deserialize("\"remove-bg\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - RemoveBg(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static RemoveBg FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ExtensionProperties/RemoveBgProperties/Options.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ExtensionProperties/RemoveBgProperties/Options.cs deleted file mode 100644 index 5b7de9ca..00000000 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ExtensionProperties/RemoveBgProperties/Options.cs +++ /dev/null @@ -1,122 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.ExtensionProperties.RemoveBgProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Options : ModelBase, IFromRaw -{ - /// - /// Whether to add an artificial shadow to the result. Default is false. Note: - /// Adding shadows is currently only supported for car photos. - /// - public bool? AddShadow - { - get - { - if (!this.Properties.TryGetValue("add_shadow", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["add_shadow"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies a solid color background using hex code (e.g., "81d4fa", "fff") - /// or color name (e.g., "green"). If this parameter is set, `bg_image_url` must - /// be empty. - /// - public string? BgColor - { - get - { - if (!this.Properties.TryGetValue("bg_color", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["bg_color"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Sets a background image from a URL. If this parameter is set, `bg_color` - /// must be empty. - /// - public string? BgImageURL - { - get - { - if (!this.Properties.TryGetValue("bg_image_url", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["bg_image_url"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Allows semi-transparent regions in the result. Default is true. Note: Semitransparency - /// is currently only supported for car windows. - /// - public bool? Semitransparency - { - get - { - if (!this.Properties.TryGetValue("semitransparency", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["semitransparency"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.AddShadow; - _ = this.BgColor; - _ = this.BgImageURL; - _ = this.Semitransparency; - } - - public Options() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Options(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Options FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ExtensionVariants/All.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ExtensionVariants/All.cs deleted file mode 100644 index 8806e3a7..00000000 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ExtensionVariants/All.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System.Text.Json; -using ExtensionProperties = Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.ExtensionProperties; - -namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.ExtensionVariants; - -public sealed record class RemoveBg(ExtensionProperties::RemoveBg Value) - : Extension, - IVariant -{ - public static RemoveBg From(ExtensionProperties::RemoveBg value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class AutoTaggingExtension(ExtensionProperties::AutoTaggingExtension Value) - : Extension, - IVariant -{ - public static AutoTaggingExtension From(ExtensionProperties::AutoTaggingExtension value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class AIAutoDescription(JsonElement Value) - : Extension, - IVariant -{ - public static AIAutoDescription From(JsonElement value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ResponseField.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ResponseField.cs deleted file mode 100644 index 648ab787..00000000 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/ResponseField.cs +++ /dev/null @@ -1,68 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; - -namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties; - -[JsonConverter(typeof(ResponseFieldConverter))] -public enum ResponseField -{ - Tags, - CustomCoordinates, - IsPrivateFile, - EmbeddedMetadata, - IsPublished, - CustomMetadata, - Metadata, - SelectedFieldsSchema, -} - -sealed class ResponseFieldConverter : JsonConverter -{ - public override ResponseField Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "tags" => ResponseField.Tags, - "customCoordinates" => ResponseField.CustomCoordinates, - "isPrivateFile" => ResponseField.IsPrivateFile, - "embeddedMetadata" => ResponseField.EmbeddedMetadata, - "isPublished" => ResponseField.IsPublished, - "customMetadata" => ResponseField.CustomMetadata, - "metadata" => ResponseField.Metadata, - "selectedFieldsSchema" => ResponseField.SelectedFieldsSchema, - _ => (ResponseField)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - ResponseField value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - ResponseField.Tags => "tags", - ResponseField.CustomCoordinates => "customCoordinates", - ResponseField.IsPrivateFile => "isPrivateFile", - ResponseField.EmbeddedMetadata => "embeddedMetadata", - ResponseField.IsPublished => "isPublished", - ResponseField.CustomMetadata => "customMetadata", - ResponseField.Metadata => "metadata", - ResponseField.SelectedFieldsSchema => "selectedFieldsSchema", - _ => throw new ImageKitInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/Transformation.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/Transformation.cs deleted file mode 100644 index 49762273..00000000 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/Transformation.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Core; -using Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties; - -namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties; - -/// -/// Configure pre-processing (`pre`) and post-processing (`post`) transformations. -/// -/// - `pre` — applied before the file is uploaded to the Media Library. Useful -/// for reducing file size or applying basic optimizations upfront (e.g., resize, compress). -/// -/// - `post` — applied immediately after upload. Ideal for generating transformed -/// versions (like video encodes or thumbnails) in advance, so they're ready for -/// delivery without delay. -/// -/// You can mix and match any combination of post-processing types. -/// -[JsonConverter( - typeof(ModelConverter) -)] -public sealed record class Transformation - : ModelBase, - IFromRaw -{ - /// - /// List of transformations to apply *after* the file is uploaded. Each item - /// must match one of the following types: `transformation`, `gif-to-video`, - /// `thumbnail`, `abs`. - /// - public List? Post - { - get - { - if (!this.Properties.TryGetValue("post", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["post"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Transformation string to apply before uploading the file to the Media Library. - /// Useful for optimizing files at ingestion. - /// - public string? Pre - { - get - { - if (!this.Properties.TryGetValue("pre", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["pre"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - foreach (var item in this.Post ?? []) - { - item.Validate(); - } - _ = this.Pre; - } - - public Transformation() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Transformation(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static global::Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.Transformation FromRawUnchecked( - Dictionary properties - ) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/Post.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/Post.cs deleted file mode 100644 index 29622f91..00000000 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/Post.cs +++ /dev/null @@ -1,268 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using PostProperties = Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; - -namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties; - -[JsonConverter(typeof(PostConverter))] -public record class Post -{ - public object Value { get; private init; } - - public string? Value1 - { - get - { - return Match( - transformation: (x) => x.Value, - gifToVideo: (x) => x.Value, - thumbnail: (x) => x.Value, - abs: (x) => x.Value - ); - } - } - - public Post(PostProperties::Transformation value) - { - Value = value; - } - - public Post(PostProperties::GifToVideo value) - { - Value = value; - } - - public Post(PostProperties::Thumbnail value) - { - Value = value; - } - - public Post(PostProperties::Abs value) - { - Value = value; - } - - Post(UnknownVariant value) - { - Value = value; - } - - public static Post CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickTransformation([NotNullWhen(true)] out PostProperties::Transformation? value) - { - value = this.Value as PostProperties::Transformation; - return value != null; - } - - public bool TryPickGifToVideo([NotNullWhen(true)] out PostProperties::GifToVideo? value) - { - value = this.Value as PostProperties::GifToVideo; - return value != null; - } - - public bool TryPickThumbnail([NotNullWhen(true)] out PostProperties::Thumbnail? value) - { - value = this.Value as PostProperties::Thumbnail; - return value != null; - } - - public bool TryPickAbs([NotNullWhen(true)] out PostProperties::Abs? value) - { - value = this.Value as PostProperties::Abs; - return value != null; - } - - public void Switch( - Action transformation, - Action gifToVideo, - Action thumbnail, - Action abs - ) - { - switch (this.Value) - { - case PostProperties::Transformation value: - transformation(value); - break; - case PostProperties::GifToVideo value: - gifToVideo(value); - break; - case PostProperties::Thumbnail value: - thumbnail(value); - break; - case PostProperties::Abs value: - abs(value); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match( - Func transformation, - Func gifToVideo, - Func thumbnail, - Func abs - ) - { - return this.Value switch - { - PostVariants::Transformation inner => transformation(inner), - PostVariants::GifToVideo inner => gifToVideo(inner), - PostVariants::Thumbnail inner => thumbnail(inner), - PostVariants::Abs inner => abs(inner), - _ => throw new InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of Post"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class PostConverter : JsonConverter -{ - public override Post? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - var json = JsonSerializer.Deserialize(ref reader, options); - string? type; - try - { - type = json.GetProperty("type").GetString(); - } - catch - { - type = null; - } - - switch (type) - { - case "transformation": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize( - json, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new Post(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "gif-to-video": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize( - json, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new Post(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "thumbnail": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize( - json, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new Post(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "abs": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize( - json, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new Post(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - default: - { - throw new Exception(); - } - } - } - - public override void Write(Utf8JsonWriter writer, Post value, JsonSerializerOptions options) - { - object variant = value switch - { - PostVariants::Transformation(var transformation) => transformation, - PostVariants::GifToVideo(var gifToVideo) => gifToVideo, - PostVariants::Thumbnail(var thumbnail) => thumbnail, - PostVariants::Abs(var abs) => abs, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Abs.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Abs.cs deleted file mode 100644 index 56cb3f6e..00000000 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Abs.cs +++ /dev/null @@ -1,111 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.AbsProperties; - -namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Abs : ModelBase, IFromRaw -{ - /// - /// Streaming protocol to use (`hls` or `dash`). - /// - public required ApiEnum Protocol - { - get - { - if (!this.Properties.TryGetValue("protocol", out JsonElement element)) - throw new ArgumentOutOfRangeException("protocol", "Missing required argument"); - - return JsonSerializer.Deserialize>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["protocol"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Adaptive Bitrate Streaming (ABS) setup. - /// - public AbsProperties::Type Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ) - ?? throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentNullException("type") - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// List of different representations you want to create separated by an underscore. - /// - public required string Value - { - get - { - if (!this.Properties.TryGetValue("value", out JsonElement element)) - throw new ArgumentOutOfRangeException("value", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("value"); - } - set - { - this.Properties["value"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Protocol.Validate(); - this.Type.Validate(); - _ = this.Value; - } - - public Abs() - { - this.Type = new(); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Abs(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Abs FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs deleted file mode 100644 index fb83079d..00000000 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.AbsProperties; - -/// -/// Streaming protocol to use (`hls` or `dash`). -/// -[JsonConverter(typeof(ProtocolConverter))] -public enum Protocol -{ - Hls, - Dash, -} - -sealed class ProtocolConverter : JsonConverter -{ - public override Protocol Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "hls" => Protocol.Hls, - "dash" => Protocol.Dash, - _ => (Protocol)(-1), - }; - } - - public override void Write(Utf8JsonWriter writer, Protocol value, JsonSerializerOptions options) - { - JsonSerializer.Serialize( - writer, - value switch - { - Protocol.Hls => "hls", - Protocol.Dash => "dash", - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/AbsProperties/Type.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/AbsProperties/Type.cs deleted file mode 100644 index 60311c27..00000000 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/AbsProperties/Type.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.AbsProperties; - -/// -/// Adaptive Bitrate Streaming (ABS) setup. -/// -[JsonConverter(typeof(Converter))] -public class Type -{ - public JsonElement Json { get; private init; } - - public Type() - { - Json = JsonSerializer.Deserialize("\"abs\""); - } - - Type(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new Type().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); - } - } - - class Converter : JsonConverter - { - public override Type? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideo.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideo.cs deleted file mode 100644 index 565aed5d..00000000 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideo.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class GifToVideo : ModelBase, IFromRaw -{ - /// - /// Converts an animated GIF into an MP4. - /// - public GifToVideoProperties::Type Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ) - ?? throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentNullException("type") - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Optional transformation string to apply to the output video. **Example**: - /// `q-80` - /// - public string? Value - { - get - { - if (!this.Properties.TryGetValue("value", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["value"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Type.Validate(); - _ = this.Value; - } - - public GifToVideo() - { - this.Type = new(); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - GifToVideo(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static GifToVideo FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideoProperties/Type.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideoProperties/Type.cs deleted file mode 100644 index 53920414..00000000 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideoProperties/Type.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.GifToVideoProperties; - -/// -/// Converts an animated GIF into an MP4. -/// -[JsonConverter(typeof(Converter))] -public class Type -{ - public JsonElement Json { get; private init; } - - public Type() - { - Json = JsonSerializer.Deserialize("\"gif-to-video\""); - } - - Type(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new Type().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); - } - } - - class Converter : JsonConverter - { - public override Type? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Thumbnail.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Thumbnail.cs deleted file mode 100644 index 23ab2438..00000000 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Thumbnail.cs +++ /dev/null @@ -1,84 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Thumbnail : ModelBase, IFromRaw -{ - /// - /// Generates a thumbnail image. - /// - public ThumbnailProperties::Type Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ) - ?? throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentNullException("type") - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Optional transformation string. **Example**: `w-150,h-150` - /// - public string? Value - { - get - { - if (!this.Properties.TryGetValue("value", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["value"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Type.Validate(); - _ = this.Value; - } - - public Thumbnail() - { - this.Type = new(); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Thumbnail(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Thumbnail FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/ThumbnailProperties/Type.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/ThumbnailProperties/Type.cs deleted file mode 100644 index 5dc6954e..00000000 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/ThumbnailProperties/Type.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.ThumbnailProperties; - -/// -/// Generates a thumbnail image. -/// -[JsonConverter(typeof(Converter))] -public class Type -{ - public JsonElement Json { get; private init; } - - public Type() - { - Json = JsonSerializer.Deserialize("\"thumbnail\""); - } - - Type(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new Type().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); - } - } - - class Converter : JsonConverter - { - public override Type? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Transformation.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Transformation.cs deleted file mode 100644 index c21379bb..00000000 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Transformation.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; - -[JsonConverter( - typeof(ModelConverter) -)] -public sealed record class Transformation - : ModelBase, - IFromRaw -{ - /// - /// Transformation type. - /// - public TransformationProperties::Type Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ) - ?? throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentNullException("type") - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Transformation string (e.g. `w-200,h-200`). Same syntax as ImageKit URL-based - /// transformations. - /// - public required string Value - { - get - { - if (!this.Properties.TryGetValue("value", out JsonElement element)) - throw new ArgumentOutOfRangeException("value", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("value"); - } - set - { - this.Properties["value"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Type.Validate(); - _ = this.Value; - } - - public Transformation() - { - this.Type = new(); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Transformation(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static global::Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.Transformation FromRawUnchecked( - Dictionary properties - ) - { - return new(properties); - } - - [SetsRequiredMembers] - public Transformation(string value) - : this() - { - this.Value = value; - } -} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/TransformationProperties/Type.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/TransformationProperties/Type.cs deleted file mode 100644 index 5e56206b..00000000 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/TransformationProperties/Type.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.TransformationProperties; - -/// -/// Transformation type. -/// -[JsonConverter(typeof(Converter))] -public class Type -{ - public JsonElement Json { get; private init; } - - public Type() - { - Json = JsonSerializer.Deserialize("\"transformation\""); - } - - Type(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new Type().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); - } - } - - class Converter : JsonConverter - { - public override Type? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostVariants/All.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostVariants/All.cs deleted file mode 100644 index 4530dadc..00000000 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParamsProperties/TransformationProperties/PostVariants/All.cs +++ /dev/null @@ -1,61 +0,0 @@ -using PostProperties = Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; - -namespace Imagekit.Models.Beta.V2.Files.FileUploadParamsProperties.TransformationProperties.PostVariants; - -public sealed record class Transformation(PostProperties::Transformation Value) - : Post, - IVariant -{ - public static Transformation From(PostProperties::Transformation value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class GifToVideo(PostProperties::GifToVideo Value) - : Post, - IVariant -{ - public static GifToVideo From(PostProperties::GifToVideo value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class Thumbnail(PostProperties::Thumbnail Value) - : Post, - IVariant -{ - public static Thumbnail From(PostProperties::Thumbnail value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class Abs(PostProperties::Abs Value) : Post, IVariant -{ - public static Abs From(PostProperties::Abs value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponse.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponse.cs deleted file mode 100644 index a1df6d25..00000000 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponse.cs +++ /dev/null @@ -1,640 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Core; -using Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties; -using Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties; -using Files = Imagekit.Models.Files; - -namespace Imagekit.Models.Beta.V2.Files; - -/// -/// Object containing details of a successful upload. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class FileUploadResponse : ModelBase, IFromRaw -{ - /// - /// An array of tags assigned to the uploaded file by auto tagging. - /// - public List? AITags - { - get - { - if (!this.Properties.TryGetValue("AITags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["AITags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The audio codec used in the video (only for video). - /// - public string? AudioCodec - { - get - { - if (!this.Properties.TryGetValue("audioCodec", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["audioCodec"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The bit rate of the video in kbps (only for video). - /// - public long? BitRate - { - get - { - if (!this.Properties.TryGetValue("bitRate", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["bitRate"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Value of custom coordinates associated with the image in the format `x,y,width,height`. - /// If `customCoordinates` are not defined, then it is `null`. Send `customCoordinates` - /// in `responseFields` in API request to get the value of this field. - /// - public string? CustomCoordinates - { - get - { - if (!this.Properties.TryGetValue("customCoordinates", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["customCoordinates"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// A key-value data associated with the asset. Use `responseField` in API request - /// to get `customMetadata` in the upload API response. Before setting any custom - /// metadata on an asset, you have to create the field using custom metadata - /// fields API. Send `customMetadata` in `responseFields` in API request to get - /// the value of this field. - /// - public Dictionary? CustomMetadata - { - get - { - if (!this.Properties.TryGetValue("customMetadata", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["customMetadata"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Optional text to describe the contents of the file. Can be set by the user - /// or the ai-auto-description extension. - /// - public string? Description - { - get - { - if (!this.Properties.TryGetValue("description", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["description"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The duration of the video in seconds (only for video). - /// - public long? Duration - { - get - { - if (!this.Properties.TryGetValue("duration", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["duration"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Consolidated embedded metadata associated with the file. It includes exif, - /// iptc, and xmp data. Send `embeddedMetadata` in `responseFields` in API request - /// to get embeddedMetadata in the upload API response. - /// - public Dictionary? EmbeddedMetadata - { - get - { - if (!this.Properties.TryGetValue("embeddedMetadata", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["embeddedMetadata"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Extension names with their processing status at the time of completion of - /// the request. It could have one of the following status values: - /// - /// `success`: The extension has been successfully applied. `failed`: The extension - /// has failed and will not be retried. `pending`: The extension will finish processing - /// in some time. On completion, the final status (success / failed) will be sent - /// to the `webhookUrl` provided. - /// - /// If no extension was requested, then this parameter is not returned. - /// - public ExtensionStatus? ExtensionStatus - { - get - { - if (!this.Properties.TryGetValue("extensionStatus", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["extensionStatus"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Unique fileId. Store this fileld in your database, as this will be used to - /// perform update action on this file. - /// - public string? FileID - { - get - { - if (!this.Properties.TryGetValue("fileId", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["fileId"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The relative path of the file in the media library e.g. `/marketing-assets/new-banner.jpg`. - /// - public string? FilePath - { - get - { - if (!this.Properties.TryGetValue("filePath", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["filePath"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Type of the uploaded file. Possible values are `image`, `non-image`. - /// - public string? FileType - { - get - { - if (!this.Properties.TryGetValue("fileType", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["fileType"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Height of the image in pixels (Only for images) - /// - public double? Height - { - get - { - if (!this.Properties.TryGetValue("height", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["height"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Is the file marked as private. It can be either `true` or `false`. Send `isPrivateFile` - /// in `responseFields` in API request to get the value of this field. - /// - public bool? IsPrivateFile - { - get - { - if (!this.Properties.TryGetValue("isPrivateFile", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["isPrivateFile"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Is the file published or in draft state. It can be either `true` or `false`. - /// Send `isPublished` in `responseFields` in API request to get the value of - /// this field. - /// - public bool? IsPublished - { - get - { - if (!this.Properties.TryGetValue("isPublished", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["isPublished"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Legacy metadata. Send `metadata` in `responseFields` in API request to get - /// metadata in the upload API response. - /// - public Files::Metadata? Metadata - { - get - { - if (!this.Properties.TryGetValue("metadata", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["metadata"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Name of the asset. - /// - public string? Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// This field is included in the response only if the Path policy feature is - /// available in the plan. It contains schema definitions for the custom metadata - /// fields selected for the specified file path. Field selection can only be done - /// when the Path policy feature is enabled. - /// - /// Keys are the names of the custom metadata fields; the value object has details - /// about the custom metadata schema. - /// - public Dictionary? SelectedFieldsSchema - { - get - { - if (!this.Properties.TryGetValue("selectedFieldsSchema", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["selectedFieldsSchema"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Size of the image file in Bytes. - /// - public double? Size - { - get - { - if (!this.Properties.TryGetValue("size", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["size"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The array of tags associated with the asset. If no tags are set, it will - /// be `null`. Send `tags` in `responseFields` in API request to get the value - /// of this field. - /// - public List? Tags - { - get - { - if (!this.Properties.TryGetValue("tags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["tags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// In the case of an image, a small thumbnail URL. - /// - public string? ThumbnailURL - { - get - { - if (!this.Properties.TryGetValue("thumbnailUrl", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["thumbnailUrl"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// A publicly accessible URL of the file. - /// - public string? URL - { - get - { - if (!this.Properties.TryGetValue("url", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["url"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// An object containing the file or file version's `id` (versionId) and `name`. - /// - public VersionInfo? VersionInfo - { - get - { - if (!this.Properties.TryGetValue("versionInfo", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["versionInfo"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The video codec used in the video (only for video). - /// - public string? VideoCodec - { - get - { - if (!this.Properties.TryGetValue("videoCodec", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["videoCodec"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Width of the image in pixels (Only for Images) - /// - public double? Width - { - get - { - if (!this.Properties.TryGetValue("width", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["width"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - foreach (var item in this.AITags ?? []) - { - item.Validate(); - } - _ = this.AudioCodec; - _ = this.BitRate; - _ = this.CustomCoordinates; - _ = this.CustomMetadata; - _ = this.Description; - _ = this.Duration; - _ = this.EmbeddedMetadata; - this.ExtensionStatus?.Validate(); - _ = this.FileID; - _ = this.FilePath; - _ = this.FileType; - _ = this.Height; - _ = this.IsPrivateFile; - _ = this.IsPublished; - this.Metadata?.Validate(); - _ = this.Name; - if (this.SelectedFieldsSchema != null) - { - foreach (var item in this.SelectedFieldsSchema.Values) - { - item.Validate(); - } - } - _ = this.Size; - _ = this.Tags; - _ = this.ThumbnailURL; - _ = this.URL; - this.VersionInfo?.Validate(); - _ = this.VideoCodec; - _ = this.Width; - } - - public FileUploadResponse() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - FileUploadResponse(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static FileUploadResponse FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/AITag.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/AITag.cs deleted file mode 100644 index a6c52d08..00000000 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/AITag.cs +++ /dev/null @@ -1,96 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class AITag : ModelBase, IFromRaw -{ - /// - /// Confidence score of the tag. - /// - public double? Confidence - { - get - { - if (!this.Properties.TryGetValue("confidence", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["confidence"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Name of the tag. - /// - public string? Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Array of `AITags` associated with the image. If no `AITags` are set, it will - /// be null. These tags can be added using the `google-auto-tagging` or `aws-auto-tagging` extensions. - /// - public string? Source - { - get - { - if (!this.Properties.TryGetValue("source", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["source"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.Confidence; - _ = this.Name; - _ = this.Source; - } - - public AITag() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - AITag(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static AITag FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/ExtensionStatus.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/ExtensionStatus.cs deleted file mode 100644 index aeff7b7b..00000000 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/ExtensionStatus.cs +++ /dev/null @@ -1,129 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.ExtensionStatusProperties; - -namespace Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties; - -/// -/// Extension names with their processing status at the time of completion of the -/// request. It could have one of the following status values: -/// -/// `success`: The extension has been successfully applied. `failed`: The extension -/// has failed and will not be retried. `pending`: The extension will finish processing -/// in some time. On completion, the final status (success / failed) will be sent -/// to the `webhookUrl` provided. -/// -/// If no extension was requested, then this parameter is not returned. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class ExtensionStatus : ModelBase, IFromRaw -{ - public ApiEnum? AIAutoDescription - { - get - { - if (!this.Properties.TryGetValue("ai-auto-description", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["ai-auto-description"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public ApiEnum? AwsAutoTagging - { - get - { - if (!this.Properties.TryGetValue("aws-auto-tagging", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["aws-auto-tagging"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public ApiEnum? GoogleAutoTagging - { - get - { - if (!this.Properties.TryGetValue("google-auto-tagging", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["google-auto-tagging"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public ApiEnum? RemoveBg - { - get - { - if (!this.Properties.TryGetValue("remove-bg", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["remove-bg"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.AIAutoDescription?.Validate(); - this.AwsAutoTagging?.Validate(); - this.GoogleAutoTagging?.Validate(); - this.RemoveBg?.Validate(); - } - - public ExtensionStatus() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - ExtensionStatus(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static ExtensionStatus FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/ExtensionStatusProperties/AIAutoDescription.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/ExtensionStatusProperties/AIAutoDescription.cs deleted file mode 100644 index e9577c37..00000000 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/ExtensionStatusProperties/AIAutoDescription.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.ExtensionStatusProperties; - -[JsonConverter(typeof(AIAutoDescriptionConverter))] -public enum AIAutoDescription -{ - Success, - Pending, - Failed, -} - -sealed class AIAutoDescriptionConverter : JsonConverter -{ - public override AIAutoDescription Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "success" => AIAutoDescription.Success, - "pending" => AIAutoDescription.Pending, - "failed" => AIAutoDescription.Failed, - _ => (AIAutoDescription)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - AIAutoDescription value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - AIAutoDescription.Success => "success", - AIAutoDescription.Pending => "pending", - AIAutoDescription.Failed => "failed", - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/ExtensionStatusProperties/AwsAutoTagging.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/ExtensionStatusProperties/AwsAutoTagging.cs deleted file mode 100644 index 43ece216..00000000 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/ExtensionStatusProperties/AwsAutoTagging.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.ExtensionStatusProperties; - -[JsonConverter(typeof(AwsAutoTaggingConverter))] -public enum AwsAutoTagging -{ - Success, - Pending, - Failed, -} - -sealed class AwsAutoTaggingConverter : JsonConverter -{ - public override AwsAutoTagging Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "success" => AwsAutoTagging.Success, - "pending" => AwsAutoTagging.Pending, - "failed" => AwsAutoTagging.Failed, - _ => (AwsAutoTagging)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - AwsAutoTagging value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - AwsAutoTagging.Success => "success", - AwsAutoTagging.Pending => "pending", - AwsAutoTagging.Failed => "failed", - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/ExtensionStatusProperties/GoogleAutoTagging.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/ExtensionStatusProperties/GoogleAutoTagging.cs deleted file mode 100644 index 15da92d3..00000000 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/ExtensionStatusProperties/GoogleAutoTagging.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.ExtensionStatusProperties; - -[JsonConverter(typeof(GoogleAutoTaggingConverter))] -public enum GoogleAutoTagging -{ - Success, - Pending, - Failed, -} - -sealed class GoogleAutoTaggingConverter : JsonConverter -{ - public override GoogleAutoTagging Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "success" => GoogleAutoTagging.Success, - "pending" => GoogleAutoTagging.Pending, - "failed" => GoogleAutoTagging.Failed, - _ => (GoogleAutoTagging)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - GoogleAutoTagging value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - GoogleAutoTagging.Success => "success", - GoogleAutoTagging.Pending => "pending", - GoogleAutoTagging.Failed => "failed", - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/ExtensionStatusProperties/RemoveBg.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/ExtensionStatusProperties/RemoveBg.cs deleted file mode 100644 index 9094a0e5..00000000 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/ExtensionStatusProperties/RemoveBg.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.ExtensionStatusProperties; - -[JsonConverter(typeof(RemoveBgConverter))] -public enum RemoveBg -{ - Success, - Pending, - Failed, -} - -sealed class RemoveBgConverter : JsonConverter -{ - public override RemoveBg Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "success" => RemoveBg.Success, - "pending" => RemoveBg.Pending, - "failed" => RemoveBg.Failed, - _ => (RemoveBg)(-1), - }; - } - - public override void Write(Utf8JsonWriter writer, RemoveBg value, JsonSerializerOptions options) - { - JsonSerializer.Serialize( - writer, - value switch - { - RemoveBg.Success => "success", - RemoveBg.Pending => "pending", - RemoveBg.Failed => "failed", - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs deleted file mode 100644 index ac1dd069..00000000 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs +++ /dev/null @@ -1,290 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Core; -using Imagekit.Exceptions; -using SelectedFieldsSchemaItemProperties = Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; - -namespace Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class SelectedFieldsSchemaItem : ModelBase, IFromRaw -{ - /// - /// Type of the custom metadata field. - /// - public required ApiEnum Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentOutOfRangeException("type", "Missing required argument") - ); - - return JsonSerializer.Deserialize< - ApiEnum - >(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The default value for this custom metadata field. The value should match the - /// `type` of custom metadata field. - /// - public SelectedFieldsSchemaItemProperties::DefaultValue? DefaultValue - { - get - { - if (!this.Properties.TryGetValue("defaultValue", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["defaultValue"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies if the custom metadata field is required or not. - /// - public bool? IsValueRequired - { - get - { - if (!this.Properties.TryGetValue("isValueRequired", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["isValueRequired"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. - /// - public double? MaxLength - { - get - { - if (!this.Properties.TryGetValue("maxLength", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["maxLength"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Maximum value of the field. Only set if field type is `Date` or `Number`. - /// For `Date` type field, the value will be in ISO8601 string format. For `Number` - /// type field, it will be a numeric value. - /// - public SelectedFieldsSchemaItemProperties::MaxValue? MaxValue - { - get - { - if (!this.Properties.TryGetValue("maxValue", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["maxValue"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. - /// - public double? MinLength - { - get - { - if (!this.Properties.TryGetValue("minLength", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["minLength"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Minimum value of the field. Only set if field type is `Date` or `Number`. - /// For `Date` type field, the value will be in ISO8601 string format. For `Number` - /// type field, it will be a numeric value. - /// - public SelectedFieldsSchemaItemProperties::MinValue? MinValue - { - get - { - if (!this.Properties.TryGetValue("minValue", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["minValue"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Indicates whether the custom metadata field is read only. A read only field - /// cannot be modified after being set. This field is configurable only via the - /// **Path policy** feature. - /// - public bool? ReadOnly - { - get - { - if (!this.Properties.TryGetValue("readOnly", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["readOnly"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// An array of allowed values when field type is `SingleSelect` or `MultiSelect`. - /// - public List? SelectOptions - { - get - { - if (!this.Properties.TryGetValue("selectOptions", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["selectOptions"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies if the selectOptions array is truncated. It is truncated when number - /// of options are > 100. - /// - public bool? SelectOptionsTruncated - { - get - { - if (!this.Properties.TryGetValue("selectOptionsTruncated", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["selectOptionsTruncated"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Type.Validate(); - this.DefaultValue?.Validate(); - _ = this.IsValueRequired; - _ = this.MaxLength; - this.MaxValue?.Validate(); - _ = this.MinLength; - this.MinValue?.Validate(); - _ = this.ReadOnly; - foreach (var item in this.SelectOptions ?? []) - { - item.Validate(); - } - _ = this.SelectOptionsTruncated; - } - - public SelectedFieldsSchemaItem() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - SelectedFieldsSchemaItem(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static SelectedFieldsSchemaItem FromRawUnchecked( - Dictionary properties - ) - { - return new(properties); - } - - [SetsRequiredMembers] - public SelectedFieldsSchemaItem(ApiEnum type) - : this() - { - this.Type = type; - } -} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs deleted file mode 100644 index 34d82394..00000000 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs +++ /dev/null @@ -1,214 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties; -using System = System; - -namespace Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; - -/// -/// The default value for this custom metadata field. The value should match the -/// `type` of custom metadata field. -/// -[JsonConverter(typeof(DefaultValueConverter))] -public record class DefaultValue -{ - public object Value { get; private init; } - - public DefaultValue(string value) - { - Value = value; - } - - public DefaultValue(double value) - { - Value = value; - } - - public DefaultValue(bool value) - { - Value = value; - } - - public DefaultValue(List value) - { - Value = value; - } - - DefaultValue(UnknownVariant value) - { - Value = value; - } - - public static DefaultValue CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public bool TryPickBool([NotNullWhen(true)] out bool? value) - { - value = this.Value as bool?; - return value != null; - } - - public bool TryPickMixed([NotNullWhen(true)] out List? value) - { - value = this.Value as List; - return value != null; - } - - public void Switch( - System::Action @string, - System::Action @double, - System::Action @bool, - System::Action> mixed - ) - { - switch (this.Value) - { - case string value: - @string(value); - break; - case double value: - @double(value); - break; - case bool value: - @bool(value); - break; - case List value: - mixed(value); - break; - default: - throw new ImageKitInvalidDataException( - "Data did not match any variant of DefaultValue" - ); - } - } - - public T Match( - System::Func @string, - System::Func @double, - System::Func @bool, - System::Func, T> mixed - ) - { - return this.Value switch - { - string value => @string(value), - double value => @double(value), - bool value => @bool(value), - List value => mixed(value), - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of DefaultValue" - ), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException( - "Data did not match any variant of DefaultValue" - ); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class DefaultValueConverter : JsonConverter -{ - public override DefaultValue? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new DefaultValue(deserialized); - } - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'string'", e) - ); - } - - try - { - return new DefaultValue(JsonSerializer.Deserialize(ref reader, options)); - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'double'", e) - ); - } - - try - { - return new DefaultValue(JsonSerializer.Deserialize(ref reader, options)); - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'bool'", e) - ); - } - - try - { - var deserialized = JsonSerializer.Deserialize>( - ref reader, - options - ); - if (deserialized != null) - { - return new DefaultValue(deserialized); - } - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException( - "Data does not match union variant 'List'", - e - ) - ); - } - - throw new System::AggregateException(exceptions); - } - - public override void Write( - Utf8JsonWriter writer, - DefaultValue value, - JsonSerializerOptions options - ) - { - object variant = value.Value; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent6.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent6.cs deleted file mode 100644 index fc9e6c7c..00000000 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent6.cs +++ /dev/null @@ -1,175 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties; - -[JsonConverter(typeof(UnnamedSchemaWithArrayParent6Converter))] -public record class UnnamedSchemaWithArrayParent6 -{ - public object Value { get; private init; } - - public UnnamedSchemaWithArrayParent6(string value) - { - Value = value; - } - - public UnnamedSchemaWithArrayParent6(double value) - { - Value = value; - } - - public UnnamedSchemaWithArrayParent6(bool value) - { - Value = value; - } - - UnnamedSchemaWithArrayParent6(UnknownVariant value) - { - Value = value; - } - - public static UnnamedSchemaWithArrayParent6 CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public bool TryPickBool([NotNullWhen(true)] out bool? value) - { - value = this.Value as bool?; - return value != null; - } - - public void Switch( - System::Action @string, - System::Action @double, - System::Action @bool - ) - { - switch (this.Value) - { - case string value: - @string(value); - break; - case double value: - @double(value); - break; - case bool value: - @bool(value); - break; - default: - throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent6" - ); - } - } - - public T Match( - System::Func @string, - System::Func @double, - System::Func @bool - ) - { - return this.Value switch - { - string value => @string(value), - double value => @double(value), - bool value => @bool(value), - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent6" - ), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent6" - ); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class UnnamedSchemaWithArrayParent6Converter : JsonConverter -{ - public override UnnamedSchemaWithArrayParent6? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new UnnamedSchemaWithArrayParent6(deserialized); - } - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'string'", e) - ); - } - - try - { - return new UnnamedSchemaWithArrayParent6( - JsonSerializer.Deserialize(ref reader, options) - ); - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'double'", e) - ); - } - - try - { - return new UnnamedSchemaWithArrayParent6( - JsonSerializer.Deserialize(ref reader, options) - ); - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'bool'", e) - ); - } - - throw new System::AggregateException(exceptions); - } - - public override void Write( - Utf8JsonWriter writer, - UnnamedSchemaWithArrayParent6 value, - JsonSerializerOptions options - ) - { - object variant = value.Value; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs deleted file mode 100644 index 98d54c61..00000000 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs +++ /dev/null @@ -1,136 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; - -/// -/// Maximum value of the field. Only set if field type is `Date` or `Number`. For -/// `Date` type field, the value will be in ISO8601 string format. For `Number` type -/// field, it will be a numeric value. -/// -[JsonConverter(typeof(MaxValueConverter))] -public record class MaxValue -{ - public object Value { get; private init; } - - public MaxValue(string value) - { - Value = value; - } - - public MaxValue(double value) - { - Value = value; - } - - MaxValue(UnknownVariant value) - { - Value = value; - } - - public static MaxValue CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public void Switch(System::Action @string, System::Action @double) - { - switch (this.Value) - { - case string value: - @string(value); - break; - case double value: - @double(value); - break; - default: - throw new ImageKitInvalidDataException( - "Data did not match any variant of MaxValue" - ); - } - } - - public T Match(System::Func @string, System::Func @double) - { - return this.Value switch - { - string value => @string(value), - double value => @double(value), - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of MaxValue" - ), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of MaxValue"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class MaxValueConverter : JsonConverter -{ - public override MaxValue? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new MaxValue(deserialized); - } - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'string'", e) - ); - } - - try - { - return new MaxValue(JsonSerializer.Deserialize(ref reader, options)); - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'double'", e) - ); - } - - throw new System::AggregateException(exceptions); - } - - public override void Write(Utf8JsonWriter writer, MaxValue value, JsonSerializerOptions options) - { - object variant = value.Value; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs deleted file mode 100644 index 708de7c7..00000000 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs +++ /dev/null @@ -1,136 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; - -/// -/// Minimum value of the field. Only set if field type is `Date` or `Number`. For -/// `Date` type field, the value will be in ISO8601 string format. For `Number` type -/// field, it will be a numeric value. -/// -[JsonConverter(typeof(MinValueConverter))] -public record class MinValue -{ - public object Value { get; private init; } - - public MinValue(string value) - { - Value = value; - } - - public MinValue(double value) - { - Value = value; - } - - MinValue(UnknownVariant value) - { - Value = value; - } - - public static MinValue CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public void Switch(System::Action @string, System::Action @double) - { - switch (this.Value) - { - case string value: - @string(value); - break; - case double value: - @double(value); - break; - default: - throw new ImageKitInvalidDataException( - "Data did not match any variant of MinValue" - ); - } - } - - public T Match(System::Func @string, System::Func @double) - { - return this.Value switch - { - string value => @string(value), - double value => @double(value), - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of MinValue" - ), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of MinValue"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class MinValueConverter : JsonConverter -{ - public override MinValue? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new MinValue(deserialized); - } - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'string'", e) - ); - } - - try - { - return new MinValue(JsonSerializer.Deserialize(ref reader, options)); - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'double'", e) - ); - } - - throw new System::AggregateException(exceptions); - } - - public override void Write(Utf8JsonWriter writer, MinValue value, JsonSerializerOptions options) - { - object variant = value.Value; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs deleted file mode 100644 index ec3daccd..00000000 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs +++ /dev/null @@ -1,171 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; - -[JsonConverter(typeof(SelectOptionConverter))] -public record class SelectOption -{ - public object Value { get; private init; } - - public SelectOption(string value) - { - Value = value; - } - - public SelectOption(double value) - { - Value = value; - } - - public SelectOption(bool value) - { - Value = value; - } - - SelectOption(UnknownVariant value) - { - Value = value; - } - - public static SelectOption CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public bool TryPickBool([NotNullWhen(true)] out bool? value) - { - value = this.Value as bool?; - return value != null; - } - - public void Switch( - System::Action @string, - System::Action @double, - System::Action @bool - ) - { - switch (this.Value) - { - case string value: - @string(value); - break; - case double value: - @double(value); - break; - case bool value: - @bool(value); - break; - default: - throw new ImageKitInvalidDataException( - "Data did not match any variant of SelectOption" - ); - } - } - - public T Match( - System::Func @string, - System::Func @double, - System::Func @bool - ) - { - return this.Value switch - { - string value => @string(value), - double value => @double(value), - bool value => @bool(value), - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of SelectOption" - ), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException( - "Data did not match any variant of SelectOption" - ); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class SelectOptionConverter : JsonConverter -{ - public override SelectOption? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new SelectOption(deserialized); - } - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'string'", e) - ); - } - - try - { - return new SelectOption(JsonSerializer.Deserialize(ref reader, options)); - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'double'", e) - ); - } - - try - { - return new SelectOption(JsonSerializer.Deserialize(ref reader, options)); - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'bool'", e) - ); - } - - throw new System::AggregateException(exceptions); - } - - public override void Write( - Utf8JsonWriter writer, - SelectOption value, - JsonSerializerOptions options - ) - { - object variant = value.Value; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs deleted file mode 100644 index c9c3fc27..00000000 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; - -/// -/// Type of the custom metadata field. -/// -[JsonConverter(typeof(TypeConverter))] -public enum Type -{ - Text, - Textarea, - Number, - Date, - Boolean, - SingleSelect, - MultiSelect, -} - -sealed class TypeConverter : JsonConverter -{ - public override Type Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "Text" => SelectedFieldsSchemaItemProperties.Type.Text, - "Textarea" => SelectedFieldsSchemaItemProperties.Type.Textarea, - "Number" => SelectedFieldsSchemaItemProperties.Type.Number, - "Date" => SelectedFieldsSchemaItemProperties.Type.Date, - "Boolean" => SelectedFieldsSchemaItemProperties.Type.Boolean, - "SingleSelect" => SelectedFieldsSchemaItemProperties.Type.SingleSelect, - "MultiSelect" => SelectedFieldsSchemaItemProperties.Type.MultiSelect, - _ => (Type)(-1), - }; - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonSerializer.Serialize( - writer, - value switch - { - SelectedFieldsSchemaItemProperties.Type.Text => "Text", - SelectedFieldsSchemaItemProperties.Type.Textarea => "Textarea", - SelectedFieldsSchemaItemProperties.Type.Number => "Number", - SelectedFieldsSchemaItemProperties.Type.Date => "Date", - SelectedFieldsSchemaItemProperties.Type.Boolean => "Boolean", - SelectedFieldsSchemaItemProperties.Type.SingleSelect => "SingleSelect", - SelectedFieldsSchemaItemProperties.Type.MultiSelect => "MultiSelect", - _ => throw new ImageKitInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/VersionInfo.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/VersionInfo.cs deleted file mode 100644 index ee7f3784..00000000 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponseProperties/VersionInfo.cs +++ /dev/null @@ -1,76 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Beta.V2.Files.FileUploadResponseProperties; - -/// -/// An object containing the file or file version's `id` (versionId) and `name`. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class VersionInfo : ModelBase, IFromRaw -{ - /// - /// Unique identifier of the file version. - /// - public string? ID - { - get - { - if (!this.Properties.TryGetValue("id", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["id"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Name of the file version. - /// - public string? Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.ID; - _ = this.Name; - } - - public VersionInfo() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - VersionInfo(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static VersionInfo FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Cache/Invalidation/InvalidationCreateParams.cs b/src/Imagekit/Models/Cache/Invalidation/InvalidationCreateParams.cs deleted file mode 100644 index ba9b0195..00000000 --- a/src/Imagekit/Models/Cache/Invalidation/InvalidationCreateParams.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Net.Http; -using System.Text; -using System.Text.Json; - -namespace Imagekit.Models.Cache.Invalidation; - -/// -/// This API will purge CDN cache and ImageKit.io's internal cache for a file. Note: -/// Purge cache is an asynchronous process and it may take some time to reflect the -/// changes. -/// -public sealed record class InvalidationCreateParams : ParamsBase -{ - public Dictionary BodyProperties { get; set; } = []; - - /// - /// The full URL of the file to be purged. - /// - public required string URL - { - get - { - if (!this.BodyProperties.TryGetValue("url", out JsonElement element)) - throw new ArgumentOutOfRangeException("url", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("url"); - } - set - { - this.BodyProperties["url"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override Uri Url(IImageKitClient client) - { - return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/files/purge") - { - Query = this.QueryString(client), - }.Uri; - } - - public StringContent BodyContent() - { - return new( - JsonSerializer.Serialize(this.BodyProperties), - Encoding.UTF8, - "application/json" - ); - } - - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} diff --git a/src/Imagekit/Models/Cache/Invalidation/InvalidationCreateResponse.cs b/src/Imagekit/Models/Cache/Invalidation/InvalidationCreateResponse.cs deleted file mode 100644 index 3fa13c55..00000000 --- a/src/Imagekit/Models/Cache/Invalidation/InvalidationCreateResponse.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Cache.Invalidation; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class InvalidationCreateResponse - : ModelBase, - IFromRaw -{ - /// - /// Unique identifier of the purge request. This can be used to check the status - /// of the purge request. - /// - public string? RequestID - { - get - { - if (!this.Properties.TryGetValue("requestId", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["requestId"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.RequestID; - } - - public InvalidationCreateResponse() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - InvalidationCreateResponse(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static InvalidationCreateResponse FromRawUnchecked( - Dictionary properties - ) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Cache/Invalidation/InvalidationGetParams.cs b/src/Imagekit/Models/Cache/Invalidation/InvalidationGetParams.cs deleted file mode 100644 index b856615c..00000000 --- a/src/Imagekit/Models/Cache/Invalidation/InvalidationGetParams.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using System.Net.Http; - -namespace Imagekit.Models.Cache.Invalidation; - -/// -/// This API returns the status of a purge cache request. -/// -public sealed record class InvalidationGetParams : ParamsBase -{ - public required string RequestID; - - public override Uri Url(IImageKitClient client) - { - return new UriBuilder( - client.BaseUrl.ToString().TrimEnd('/') - + string.Format("/v1/files/purge/{0}", this.RequestID) - ) - { - Query = this.QueryString(client), - }.Uri; - } - - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} diff --git a/src/Imagekit/Models/Cache/Invalidation/InvalidationGetResponse.cs b/src/Imagekit/Models/Cache/Invalidation/InvalidationGetResponse.cs deleted file mode 100644 index a61b3779..00000000 --- a/src/Imagekit/Models/Cache/Invalidation/InvalidationGetResponse.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Cache.Invalidation.InvalidationGetResponseProperties; - -namespace Imagekit.Models.Cache.Invalidation; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class InvalidationGetResponse : ModelBase, IFromRaw -{ - /// - /// Status of the purge request. - /// - public ApiEnum? Status - { - get - { - if (!this.Properties.TryGetValue("status", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["status"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Status?.Validate(); - } - - public InvalidationGetResponse() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - InvalidationGetResponse(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static InvalidationGetResponse FromRawUnchecked( - Dictionary properties - ) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Cache/Invalidation/InvalidationGetResponseProperties/Status.cs b/src/Imagekit/Models/Cache/Invalidation/InvalidationGetResponseProperties/Status.cs deleted file mode 100644 index 1760eb98..00000000 --- a/src/Imagekit/Models/Cache/Invalidation/InvalidationGetResponseProperties/Status.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Cache.Invalidation.InvalidationGetResponseProperties; - -/// -/// Status of the purge request. -/// -[JsonConverter(typeof(StatusConverter))] -public enum Status -{ - Pending, - Completed, -} - -sealed class StatusConverter : JsonConverter -{ - public override Status Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "Pending" => Status.Pending, - "Completed" => Status.Completed, - _ => (Status)(-1), - }; - } - - public override void Write(Utf8JsonWriter writer, Status value, JsonSerializerOptions options) - { - JsonSerializer.Serialize( - writer, - value switch - { - Status.Pending => "Pending", - Status.Completed => "Completed", - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataField.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataField.cs deleted file mode 100644 index 4103fe94..00000000 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataField.cs +++ /dev/null @@ -1,129 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties; - -namespace Imagekit.Models.CustomMetadataFields; - -/// -/// Object containing details of a custom metadata field. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class CustomMetadataField : ModelBase, IFromRaw -{ - /// - /// Unique identifier for the custom metadata field. Use this to update the field. - /// - public required string ID - { - get - { - if (!this.Properties.TryGetValue("id", out JsonElement element)) - throw new ArgumentOutOfRangeException("id", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("id"); - } - set - { - this.Properties["id"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Human readable name of the custom metadata field. This name is displayed as - /// form field label to the users while setting field value on the asset in the - /// media library UI. - /// - public required string Label - { - get - { - if (!this.Properties.TryGetValue("label", out JsonElement element)) - throw new ArgumentOutOfRangeException("label", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("label"); - } - set - { - this.Properties["label"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// API name of the custom metadata field. This becomes the key while setting - /// `customMetadata` (key-value object) for an asset using upload or update API. - /// - public required string Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - throw new ArgumentOutOfRangeException("name", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("name"); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// An object that describes the rules for the custom metadata field value. - /// - public required Schema Schema - { - get - { - if (!this.Properties.TryGetValue("schema", out JsonElement element)) - throw new ArgumentOutOfRangeException("schema", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("schema"); - } - set - { - this.Properties["schema"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.ID; - _ = this.Label; - _ = this.Name; - this.Schema.Validate(); - } - - public CustomMetadataField() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - CustomMetadataField(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static CustomMetadataField FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParams.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParams.cs deleted file mode 100644 index f4961b6c..00000000 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParams.cs +++ /dev/null @@ -1,111 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Net.Http; -using System.Text; -using System.Text.Json; -using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties; - -namespace Imagekit.Models.CustomMetadataFields; - -/// -/// This API creates a new custom metadata field. Once a custom metadata field is -/// created either through this API or using the dashboard UI, its value can be set -/// on the assets. The value of a field for an asset can be set using the media library -/// UI or programmatically through upload or update assets API. -/// -public sealed record class CustomMetadataFieldCreateParams : ParamsBase -{ - public Dictionary BodyProperties { get; set; } = []; - - /// - /// Human readable name of the custom metadata field. This should be unique across - /// all non deleted custom metadata fields. This name is displayed as form field - /// label to the users while setting field value on an asset in the media library UI. - /// - public required string Label - { - get - { - if (!this.BodyProperties.TryGetValue("label", out JsonElement element)) - throw new ArgumentOutOfRangeException("label", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("label"); - } - set - { - this.BodyProperties["label"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// API name of the custom metadata field. This should be unique across all (including - /// deleted) custom metadata fields. - /// - public required string Name - { - get - { - if (!this.BodyProperties.TryGetValue("name", out JsonElement element)) - throw new ArgumentOutOfRangeException("name", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("name"); - } - set - { - this.BodyProperties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required Schema Schema - { - get - { - if (!this.BodyProperties.TryGetValue("schema", out JsonElement element)) - throw new ArgumentOutOfRangeException("schema", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("schema"); - } - set - { - this.BodyProperties["schema"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override Uri Url(IImageKitClient client) - { - return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/customMetadataFields") - { - Query = this.QueryString(client), - }.Uri; - } - - public StringContent BodyContent() - { - return new( - JsonSerializer.Serialize(this.BodyProperties), - Encoding.UTF8, - "application/json" - ); - } - - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/Schema.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/Schema.cs deleted file mode 100644 index 4cd680c3..00000000 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/Schema.cs +++ /dev/null @@ -1,243 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using SchemaProperties = Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties; - -namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Schema : ModelBase, IFromRaw -{ - /// - /// Type of the custom metadata field. - /// - public required ApiEnum Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The default value for this custom metadata field. This property is only required - /// if `isValueRequired` property is set to `true`. The value should match the - /// `type` of custom metadata field. - /// - public SchemaProperties::DefaultValue? DefaultValue - { - get - { - if (!this.Properties.TryGetValue("defaultValue", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["defaultValue"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Sets this custom metadata field as required. Setting custom metadata fields - /// on an asset will throw error if the value for all required fields are not - /// present in upload or update asset API request body. - /// - public bool? IsValueRequired - { - get - { - if (!this.Properties.TryGetValue("isValueRequired", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["isValueRequired"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Maximum length of string. Only set this property if `type` is set to `Text` - /// or `Textarea`. - /// - public double? MaxLength - { - get - { - if (!this.Properties.TryGetValue("maxLength", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["maxLength"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Maximum value of the field. Only set this property if field type is `Date` - /// or `Number`. For `Date` type field, set the minimum date in ISO8601 string - /// format. For `Number` type field, set the minimum numeric value. - /// - public SchemaProperties::MaxValue? MaxValue - { - get - { - if (!this.Properties.TryGetValue("maxValue", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["maxValue"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Minimum length of string. Only set this property if `type` is set to `Text` - /// or `Textarea`. - /// - public double? MinLength - { - get - { - if (!this.Properties.TryGetValue("minLength", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["minLength"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Minimum value of the field. Only set this property if field type is `Date` - /// or `Number`. For `Date` type field, set the minimum date in ISO8601 string - /// format. For `Number` type field, set the minimum numeric value. - /// - public SchemaProperties::MinValue? MinValue - { - get - { - if (!this.Properties.TryGetValue("minValue", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["minValue"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// An array of allowed values. This property is only required if `type` property - /// is set to `SingleSelect` or `MultiSelect`. - /// - public List? SelectOptions - { - get - { - if (!this.Properties.TryGetValue("selectOptions", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["selectOptions"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Type.Validate(); - this.DefaultValue?.Validate(); - _ = this.IsValueRequired; - _ = this.MaxLength; - this.MaxValue?.Validate(); - _ = this.MinLength; - this.MinValue?.Validate(); - foreach (var item in this.SelectOptions ?? []) - { - item.Validate(); - } - } - - public Schema() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Schema(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Schema FromRawUnchecked(Dictionary properties) - { - return new(properties); - } - - [SetsRequiredMembers] - public Schema(ApiEnum type) - : this() - { - this.Type = type; - } -} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValue.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValue.cs deleted file mode 100644 index 596568f6..00000000 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValue.cs +++ /dev/null @@ -1,194 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties.DefaultValueProperties; -using System = System; - -namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties; - -/// -/// The default value for this custom metadata field. This property is only required -/// if `isValueRequired` property is set to `true`. The value should match the `type` -/// of custom metadata field. -/// -[JsonConverter(typeof(DefaultValueConverter))] -public record class DefaultValue -{ - public object Value { get; private init; } - - public DefaultValue(string value) - { - Value = value; - } - - public DefaultValue(double value) - { - Value = value; - } - - public DefaultValue(bool value) - { - Value = value; - } - - public static implicit operator DefaultValue(List value) => - new Mixed(value); - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public bool TryPickBool([NotNullWhen(true)] out bool? value) - { - value = this.Value as bool?; - return value != null; - } - - public bool TryPickMixed([NotNullWhen(true)] out List? value) - { - value = this.Value as List; - return value != null; - } - - public void Switch( - System::Action @string, - System::Action @double, - System::Action @bool, - System::Action> mixed - ) - { - switch (this.Value) - { - case string value: - @string(value); - break; - case double value: - @double(value); - break; - case bool value: - @bool(value); - break; - case List value: - mixed(value); - break; - default: - throw new System::InvalidOperationException(); - } - } - - public T Match( - System::Func @string, - System::Func @double, - System::Func @bool, - System::Func, T> mixed - ) - { - return this.Value switch - { - String inner => @string(inner), - Double inner => @double(inner), - Bool inner => @bool(inner), - Mixed inner => mixed(inner), - _ => throw new System::InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException( - "Data did not match any variant of DefaultValue" - ); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class DefaultValueConverter : JsonConverter -{ - public override DefaultValue? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new DefaultValue(deserialized); - } - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - return new DefaultValue(JsonSerializer.Deserialize(ref reader, options)); - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - return new DefaultValue(JsonSerializer.Deserialize(ref reader, options)); - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - var deserialized = JsonSerializer.Deserialize>( - ref reader, - options - ); - if (deserialized != null) - { - return new DefaultValue(deserialized); - } - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new System::AggregateException(exceptions); - } - - public override void Write( - Utf8JsonWriter writer, - DefaultValue value, - JsonSerializerOptions options - ) - { - object variant = value switch - { - String(var @string) => @string, - Double(var @double) => @double, - Bool(var @bool) => @bool, - Mixed(var mixed) => mixed, - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent2.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent2.cs deleted file mode 100644 index 4e45aa28..00000000 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent2.cs +++ /dev/null @@ -1,154 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties.DefaultValueProperties.UnnamedSchemaWithArrayParent0Variants; -using System = System; - -namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties.DefaultValueProperties; - -[JsonConverter(typeof(UnnamedSchemaWithArrayParent0Converter))] -public abstract record class UnnamedSchemaWithArrayParent0 -{ - internal UnnamedSchemaWithArrayParent0() { } - - public static implicit operator UnnamedSchemaWithArrayParent0(string value) => - new String(value); - - public static implicit operator UnnamedSchemaWithArrayParent0(double value) => - new Double(value); - - public static implicit operator UnnamedSchemaWithArrayParent0(bool value) => new Bool(value); - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public bool TryPickBool([NotNullWhen(true)] out bool? value) - { - value = this.Value as bool?; - return value != null; - } - - public void Switch( - System::Action @string, - System::Action @double, - System::Action @bool - ) - { - switch (this.Value) - { - case string value: - @string(value); - break; - case double value: - @double(value); - break; - case bool value: - @bool(value); - break; - default: - throw new System::InvalidOperationException(); - } - } - - public T Match( - System::Func @string, - System::Func @double, - System::Func @bool - ) - { - return this.Value switch - { - String inner => @string(inner), - Double inner => @double(inner), - Bool inner => @bool(inner), - _ => throw new System::InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent2" - ); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class UnnamedSchemaWithArrayParent0Converter : JsonConverter -{ - public override UnnamedSchemaWithArrayParent0? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new UnnamedSchemaWithArrayParent2(deserialized); - } - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - return new UnnamedSchemaWithArrayParent2( - JsonSerializer.Deserialize(ref reader, options) - ); - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - return new UnnamedSchemaWithArrayParent2( - JsonSerializer.Deserialize(ref reader, options) - ); - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new System::AggregateException(exceptions); - } - - public override void Write( - Utf8JsonWriter writer, - UnnamedSchemaWithArrayParent0 value, - JsonSerializerOptions options - ) - { - object variant = value switch - { - String(var @string) => @string, - Double(var @double) => @double, - Bool(var @bool) => @bool, - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent2Variants/All.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent2Variants/All.cs deleted file mode 100644 index 9907932a..00000000 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent2Variants/All.cs +++ /dev/null @@ -1,35 +0,0 @@ -namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldUpdateParamsProperties.SchemaProperties.DefaultValueProperties.UnnamedSchemaWithArrayParent2Variants; - -public sealed record class String(string Value) - : UnnamedSchemaWithArrayParent2, - IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Double(double Value) - : UnnamedSchemaWithArrayParent2, - IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Bool(bool Value) : UnnamedSchemaWithArrayParent2, IVariant -{ - public static Bool From(bool value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValueVariants/All.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValueVariants/All.cs deleted file mode 100644 index 43c33479..00000000 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/DefaultValueVariants/All.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Collections.Generic; -using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties.DefaultValueProperties; - -namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties.DefaultValueVariants; - -public sealed record class String(string Value) : DefaultValue, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Double(double Value) : DefaultValue, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Bool(bool Value) : DefaultValue, IVariant -{ - public static Bool From(bool value) - { - return new(value); - } - - public override void Validate() { } -} - -/// -/// Default value should be of type array when custom metadata field type is set to -/// `MultiSelect`. -/// -public sealed record class Mixed(List Value) - : DefaultValue, - IVariant> -{ - public static Mixed From(List value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MaxValue.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MaxValue.cs deleted file mode 100644 index d6efa5b8..00000000 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MaxValue.cs +++ /dev/null @@ -1,133 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties.MaxValueVariants; -using System = System; - -namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties; - -/// -/// Maximum value of the field. Only set this property if field type is `Date` or -/// `Number`. For `Date` type field, set the minimum date in ISO8601 string format. -/// For `Number` type field, set the minimum numeric value. -/// -[JsonConverter(typeof(MaxValueConverter))] -public record class MaxValue -{ - public object Value { get; private init; } - - public MaxValue(string value) - { - Value = value; - } - - public MaxValue(double value) - { - Value = value; - } - - MaxValue(UnknownVariant value) - { - Value = value; - } - - public static MaxValue CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public void Switch(System::Action @string, System::Action @double) - { - switch (this.Value) - { - case string value: - @string(value); - break; - case double value: - @double(value); - break; - default: - throw new System::InvalidOperationException(); - } - } - - public T Match(System::Func @string, System::Func @double) - { - return this.Value switch - { - String inner => @string(inner), - Double inner => @double(inner), - _ => throw new System::InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of MaxValue"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class MaxValueConverter : JsonConverter -{ - public override MaxValue? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new MaxValue(deserialized); - } - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - return new MaxValue(JsonSerializer.Deserialize(ref reader, options)); - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new System::AggregateException(exceptions); - } - - public override void Write(Utf8JsonWriter writer, MaxValue value, JsonSerializerOptions options) - { - object variant = value switch - { - String(var @string) => @string, - Double(var @double) => @double, - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MaxValueVariants/All.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MaxValueVariants/All.cs deleted file mode 100644 index 0702732b..00000000 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MaxValueVariants/All.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties.MaxValueVariants; - -public sealed record class String(string Value) : MaxValue, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Double(double Value) : MaxValue, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MinValue.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MinValue.cs deleted file mode 100644 index 82fa645b..00000000 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MinValue.cs +++ /dev/null @@ -1,133 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties.MinValueVariants; -using System = System; - -namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties; - -/// -/// Minimum value of the field. Only set this property if field type is `Date` or -/// `Number`. For `Date` type field, set the minimum date in ISO8601 string format. -/// For `Number` type field, set the minimum numeric value. -/// -[JsonConverter(typeof(MinValueConverter))] -public record class MinValue -{ - public object Value { get; private init; } - - public MinValue(string value) - { - Value = value; - } - - public MinValue(double value) - { - Value = value; - } - - MinValue(UnknownVariant value) - { - Value = value; - } - - public static MinValue CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public void Switch(System::Action @string, System::Action @double) - { - switch (this.Value) - { - case string value: - @string(value); - break; - case double value: - @double(value); - break; - default: - throw new System::InvalidOperationException(); - } - } - - public T Match(System::Func @string, System::Func @double) - { - return this.Value switch - { - String inner => @string(inner), - Double inner => @double(inner), - _ => throw new System::InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of MinValue"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class MinValueConverter : JsonConverter -{ - public override MinValue? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new MinValue(deserialized); - } - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - return new MinValue(JsonSerializer.Deserialize(ref reader, options)); - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new System::AggregateException(exceptions); - } - - public override void Write(Utf8JsonWriter writer, MinValue value, JsonSerializerOptions options) - { - object variant = value switch - { - String(var @string) => @string, - Double(var @double) => @double, - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MinValueVariants/All.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MinValueVariants/All.cs deleted file mode 100644 index 94c0c48b..00000000 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/MinValueVariants/All.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties.MinValueVariants; - -public sealed record class String(string Value) : MinValue, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Double(double Value) : MinValue, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/SelectOption.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/SelectOption.cs deleted file mode 100644 index 265d9883..00000000 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/SelectOption.cs +++ /dev/null @@ -1,167 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties.SelectOptionVariants; -using System = System; - -namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties; - -[JsonConverter(typeof(SelectOptionConverter))] -public record class SelectOption -{ - public object Value { get; private init; } - - public SelectOption(string value) - { - Value = value; - } - - public SelectOption(double value) - { - Value = value; - } - - public SelectOption(bool value) - { - Value = value; - } - - SelectOption(UnknownVariant value) - { - Value = value; - } - - public static SelectOption CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public bool TryPickBool([NotNullWhen(true)] out bool? value) - { - value = this.Value as bool?; - return value != null; - } - - public void Switch( - System::Action @string, - System::Action @double, - System::Action @bool - ) - { - switch (this.Value) - { - case string value: - @string(value); - break; - case double value: - @double(value); - break; - case bool value: - @bool(value); - break; - default: - throw new System::InvalidOperationException(); - } - } - - public T Match( - System::Func @string, - System::Func @double, - System::Func @bool - ) - { - return this.Value switch - { - String inner => @string(inner), - Double inner => @double(inner), - Bool inner => @bool(inner), - _ => throw new System::InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException( - "Data did not match any variant of SelectOption" - ); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class SelectOptionConverter : JsonConverter -{ - public override SelectOption? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new SelectOption(deserialized); - } - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - return new SelectOption(JsonSerializer.Deserialize(ref reader, options)); - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - return new SelectOption(JsonSerializer.Deserialize(ref reader, options)); - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new System::AggregateException(exceptions); - } - - public override void Write( - Utf8JsonWriter writer, - SelectOption value, - JsonSerializerOptions options - ) - { - object variant = value switch - { - String(var @string) => @string, - Double(var @double) => @double, - Bool(var @bool) => @bool, - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/SelectOptionVariants/All.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/SelectOptionVariants/All.cs deleted file mode 100644 index 2e894cad..00000000 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/SelectOptionVariants/All.cs +++ /dev/null @@ -1,31 +0,0 @@ -namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties.SelectOptionVariants; - -public sealed record class String(string Value) : SelectOption, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Double(double Value) : SelectOption, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Bool(bool Value) : SelectOption, IVariant -{ - public static Bool From(bool value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/Type.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/Type.cs deleted file mode 100644 index d1008752..00000000 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsProperties/SchemaProperties/Type.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using System = System; - -namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties; - -/// -/// Type of the custom metadata field. -/// -[JsonConverter(typeof(TypeConverter))] -public enum Type -{ - Text, - Textarea, - Number, - Date, - Boolean, - SingleSelect, - MultiSelect, -} - -sealed class TypeConverter : JsonConverter -{ - public override Type Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "Text" => SchemaProperties.Type.Text, - "Textarea" => SchemaProperties.Type.Textarea, - "Number" => SchemaProperties.Type.Number, - "Date" => SchemaProperties.Type.Date, - "Boolean" => SchemaProperties.Type.Boolean, - "SingleSelect" => SchemaProperties.Type.SingleSelect, - "MultiSelect" => SchemaProperties.Type.MultiSelect, - _ => (Type)(-1), - }; - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonSerializer.Serialize( - writer, - value switch - { - SchemaProperties.Type.Text => "Text", - SchemaProperties.Type.Textarea => "Textarea", - SchemaProperties.Type.Number => "Number", - SchemaProperties.Type.Date => "Date", - SchemaProperties.Type.Boolean => "Boolean", - SchemaProperties.Type.SingleSelect => "SingleSelect", - SchemaProperties.Type.MultiSelect => "MultiSelect", - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldDeleteParams.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldDeleteParams.cs deleted file mode 100644 index ccf4ec98..00000000 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldDeleteParams.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using System.Net.Http; - -namespace Imagekit.Models.CustomMetadataFields; - -/// -/// This API deletes a custom metadata field. Even after deleting a custom metadata -/// field, you cannot create any new custom metadata field with the same name. -/// -public sealed record class CustomMetadataFieldDeleteParams : ParamsBase -{ - public required string ID; - - public override Uri Url(IImageKitClient client) - { - return new UriBuilder( - client.BaseUrl.ToString().TrimEnd('/') - + string.Format("/v1/customMetadataFields/{0}", this.ID) - ) - { - Query = this.QueryString(client), - }.Uri; - } - - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldDeleteResponse.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldDeleteResponse.cs deleted file mode 100644 index 47473126..00000000 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldDeleteResponse.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.CustomMetadataFields; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class CustomMetadataFieldDeleteResponse - : ModelBase, - IFromRaw -{ - public override void Validate() { } - - public CustomMetadataFieldDeleteResponse() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - CustomMetadataFieldDeleteResponse(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static CustomMetadataFieldDeleteResponse FromRawUnchecked( - Dictionary properties - ) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldListParams.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldListParams.cs deleted file mode 100644 index e9a246c5..00000000 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldListParams.cs +++ /dev/null @@ -1,81 +0,0 @@ -using System; -using System.Net.Http; -using System.Text.Json; -using Imagekit.Core; - -namespace Imagekit.Models.CustomMetadataFields; - -/// -/// This API returns the array of created custom metadata field objects. By default -/// the API returns only non deleted field objects, but you can include deleted fields -/// in the API response. -/// -/// You can also filter results by a specific folder path to retrieve custom metadata -/// fields applicable at that location. This path-specific filtering is useful when -/// using the **Path policy** feature to determine which custom metadata fields are -/// selected for a given path. -/// -public sealed record class CustomMetadataFieldListParams : ParamsBase -{ - /// - /// The folder path (e.g., `/path/to/folder`) for which to retrieve applicable - /// custom metadata fields. Useful for determining path-specific field selections - /// when the [Path policy](https://imagekit.io/docs/dam/path-policy) feature is - /// in use. - /// - public string? FolderPath - { - get - { - if (!this.QueryProperties.TryGetValue("folderPath", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.QueryProperties["folderPath"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Set it to `true` to include deleted field objects in the API response. - /// - public bool? IncludeDeleted - { - get - { - if (!this.QueryProperties.TryGetValue("includeDeleted", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.QueryProperties["includeDeleted"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override Uri Url(IImageKitClient client) - { - return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/customMetadataFields") - { - Query = this.QueryString(client), - }.Uri; - } - - internal override void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/Schema.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/Schema.cs deleted file mode 100644 index 3ab4cebf..00000000 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/Schema.cs +++ /dev/null @@ -1,245 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Core; -using Imagekit.Exceptions; -using SchemaProperties = Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties; - -namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties; - -/// -/// An object that describes the rules for the custom metadata field value. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class Schema : ModelBase, IFromRaw -{ - /// - /// Type of the custom metadata field. - /// - public required ApiEnum Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentOutOfRangeException("type", "Missing required argument") - ); - - return JsonSerializer.Deserialize>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The default value for this custom metadata field. Data type of default value - /// depends on the field type. - /// - public SchemaProperties::DefaultValue? DefaultValue - { - get - { - if (!this.Properties.TryGetValue("defaultValue", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["defaultValue"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies if the this custom metadata field is required or not. - /// - public bool? IsValueRequired - { - get - { - if (!this.Properties.TryGetValue("isValueRequired", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["isValueRequired"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. - /// - public double? MaxLength - { - get - { - if (!this.Properties.TryGetValue("maxLength", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["maxLength"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Maximum value of the field. Only set if field type is `Date` or `Number`. - /// For `Date` type field, the value will be in ISO8601 string format. For `Number` - /// type field, it will be a numeric value. - /// - public SchemaProperties::MaxValue? MaxValue - { - get - { - if (!this.Properties.TryGetValue("maxValue", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["maxValue"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. - /// - public double? MinLength - { - get - { - if (!this.Properties.TryGetValue("minLength", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["minLength"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Minimum value of the field. Only set if field type is `Date` or `Number`. - /// For `Date` type field, the value will be in ISO8601 string format. For `Number` - /// type field, it will be a numeric value. - /// - public SchemaProperties::MinValue? MinValue - { - get - { - if (!this.Properties.TryGetValue("minValue", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["minValue"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// An array of allowed values when field type is `SingleSelect` or `MultiSelect`. - /// - public List? SelectOptions - { - get - { - if (!this.Properties.TryGetValue("selectOptions", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["selectOptions"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Type.Validate(); - this.DefaultValue?.Validate(); - _ = this.IsValueRequired; - _ = this.MaxLength; - this.MaxValue?.Validate(); - _ = this.MinLength; - this.MinValue?.Validate(); - foreach (var item in this.SelectOptions ?? []) - { - item.Validate(); - } - } - - public Schema() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Schema(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Schema FromRawUnchecked(Dictionary properties) - { - return new(properties); - } - - [SetsRequiredMembers] - public Schema(ApiEnum type) - : this() - { - this.Type = type; - } -} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValue.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValue.cs deleted file mode 100644 index 2bddef38..00000000 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValue.cs +++ /dev/null @@ -1,214 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties.DefaultValueProperties; -using System = System; - -namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties; - -/// -/// The default value for this custom metadata field. Data type of default value -/// depends on the field type. -/// -[JsonConverter(typeof(DefaultValueConverter))] -public record class DefaultValue -{ - public object Value { get; private init; } - - public DefaultValue(string value) - { - Value = value; - } - - public DefaultValue(double value) - { - Value = value; - } - - public DefaultValue(bool value) - { - Value = value; - } - - public DefaultValue(List value) - { - Value = value; - } - - DefaultValue(UnknownVariant value) - { - Value = value; - } - - public static DefaultValue CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public bool TryPickBool([NotNullWhen(true)] out bool? value) - { - value = this.Value as bool?; - return value != null; - } - - public bool TryPickMixed([NotNullWhen(true)] out List? value) - { - value = this.Value as List; - return value != null; - } - - public void Switch( - System::Action @string, - System::Action @double, - System::Action @bool, - System::Action> mixed - ) - { - switch (this.Value) - { - case string value: - @string(value); - break; - case double value: - @double(value); - break; - case bool value: - @bool(value); - break; - case List value: - mixed(value); - break; - default: - throw new ImageKitInvalidDataException( - "Data did not match any variant of DefaultValue" - ); - } - } - - public T Match( - System::Func @string, - System::Func @double, - System::Func @bool, - System::Func, T> mixed - ) - { - return this.Value switch - { - string value => @string(value), - double value => @double(value), - bool value => @bool(value), - List value => mixed(value), - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of DefaultValue" - ), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException( - "Data did not match any variant of DefaultValue" - ); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class DefaultValueConverter : JsonConverter -{ - public override DefaultValue? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new DefaultValue(deserialized); - } - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'string'", e) - ); - } - - try - { - return new DefaultValue(JsonSerializer.Deserialize(ref reader, options)); - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'double'", e) - ); - } - - try - { - return new DefaultValue(JsonSerializer.Deserialize(ref reader, options)); - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'bool'", e) - ); - } - - try - { - var deserialized = JsonSerializer.Deserialize>( - ref reader, - options - ); - if (deserialized != null) - { - return new DefaultValue(deserialized); - } - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException( - "Data does not match union variant 'List'", - e - ) - ); - } - - throw new System::AggregateException(exceptions); - } - - public override void Write( - Utf8JsonWriter writer, - DefaultValue value, - JsonSerializerOptions options - ) - { - object variant = value.Value; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent1.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent1.cs deleted file mode 100644 index a104ee4e..00000000 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent1.cs +++ /dev/null @@ -1,171 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties.DefaultValueProperties.UnnamedSchemaWithArrayParent1Variants; -using System = System; - -namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties.DefaultValueProperties; - -[JsonConverter(typeof(UnnamedSchemaWithArrayParent1Converter))] -public record class UnnamedSchemaWithArrayParent1 -{ - public object Value { get; private init; } - - public UnnamedSchemaWithArrayParent1(string value) - { - Value = value; - } - - public UnnamedSchemaWithArrayParent1(double value) - { - Value = value; - } - - public UnnamedSchemaWithArrayParent1(bool value) - { - Value = value; - } - - UnnamedSchemaWithArrayParent1(UnknownVariant value) - { - Value = value; - } - - public static UnnamedSchemaWithArrayParent1 CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public bool TryPickBool([NotNullWhen(true)] out bool? value) - { - value = this.Value as bool?; - return value != null; - } - - public void Switch( - System::Action @string, - System::Action @double, - System::Action @bool - ) - { - switch (this.Value) - { - case string value: - @string(value); - break; - case double value: - @double(value); - break; - case bool value: - @bool(value); - break; - default: - throw new System::InvalidOperationException(); - } - } - - public T Match( - System::Func @string, - System::Func @double, - System::Func @bool - ) - { - return this.Value switch - { - String inner => @string(inner), - Double inner => @double(inner), - Bool inner => @bool(inner), - _ => throw new System::InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent1" - ); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class UnnamedSchemaWithArrayParent1Converter : JsonConverter -{ - public override UnnamedSchemaWithArrayParent1? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new UnnamedSchemaWithArrayParent1(deserialized); - } - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - return new UnnamedSchemaWithArrayParent1( - JsonSerializer.Deserialize(ref reader, options) - ); - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - return new UnnamedSchemaWithArrayParent1( - JsonSerializer.Deserialize(ref reader, options) - ); - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new System::AggregateException(exceptions); - } - - public override void Write( - Utf8JsonWriter writer, - UnnamedSchemaWithArrayParent1 value, - JsonSerializerOptions options - ) - { - object variant = value switch - { - String(var @string) => @string, - Double(var @double) => @double, - Bool(var @bool) => @bool, - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent1Variants/All.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent1Variants/All.cs deleted file mode 100644 index 9bde8ea7..00000000 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent1Variants/All.cs +++ /dev/null @@ -1,35 +0,0 @@ -namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldCreateParamsProperties.SchemaProperties.DefaultValueProperties.UnnamedSchemaWithArrayParent1Variants; - -public sealed record class String(string Value) - : UnnamedSchemaWithArrayParent1, - IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Double(double Value) - : UnnamedSchemaWithArrayParent1, - IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Bool(bool Value) : UnnamedSchemaWithArrayParent1, IVariant -{ - public static Bool From(bool value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValueVariants/All.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValueVariants/All.cs deleted file mode 100644 index 2d59b456..00000000 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/DefaultValueVariants/All.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Collections.Generic; -using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties.DefaultValueProperties; - -namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties.DefaultValueVariants; - -public sealed record class String(string Value) : DefaultValue, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Double(double Value) : DefaultValue, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Bool(bool Value) : DefaultValue, IVariant -{ - public static Bool From(bool value) - { - return new(value); - } - - public override void Validate() { } -} - -/// -/// Default value should be of type array when custom metadata field type is set to -/// `MultiSelect`. -/// -public sealed record class Mixed(List Value) - : DefaultValue, - IVariant> -{ - public static Mixed From(List value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MaxValue.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MaxValue.cs deleted file mode 100644 index 9b396ae9..00000000 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MaxValue.cs +++ /dev/null @@ -1,133 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties.MaxValueVariants; -using System = System; - -namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties; - -/// -/// Maximum value of the field. Only set if field type is `Date` or `Number`. For -/// `Date` type field, the value will be in ISO8601 string format. For `Number` type -/// field, it will be a numeric value. -/// -[JsonConverter(typeof(MaxValueConverter))] -public record class MaxValue -{ - public object Value { get; private init; } - - public MaxValue(string value) - { - Value = value; - } - - public MaxValue(double value) - { - Value = value; - } - - MaxValue(UnknownVariant value) - { - Value = value; - } - - public static MaxValue CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public void Switch(System::Action @string, System::Action @double) - { - switch (this.Value) - { - case string value: - @string(value); - break; - case double value: - @double(value); - break; - default: - throw new System::InvalidOperationException(); - } - } - - public T Match(System::Func @string, System::Func @double) - { - return this.Value switch - { - String inner => @string(inner), - Double inner => @double(inner), - _ => throw new System::InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of MaxValue"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class MaxValueConverter : JsonConverter -{ - public override MaxValue? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new MaxValue(deserialized); - } - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - return new MaxValue(JsonSerializer.Deserialize(ref reader, options)); - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new System::AggregateException(exceptions); - } - - public override void Write(Utf8JsonWriter writer, MaxValue value, JsonSerializerOptions options) - { - object variant = value switch - { - String(var @string) => @string, - Double(var @double) => @double, - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MaxValueVariants/All.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MaxValueVariants/All.cs deleted file mode 100644 index 40dbd110..00000000 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MaxValueVariants/All.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties.MaxValueVariants; - -public sealed record class String(string Value) : MaxValue, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Double(double Value) : MaxValue, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MinValue.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MinValue.cs deleted file mode 100644 index f123f61e..00000000 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MinValue.cs +++ /dev/null @@ -1,133 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties.MinValueVariants; -using System = System; - -namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties; - -/// -/// Minimum value of the field. Only set if field type is `Date` or `Number`. For -/// `Date` type field, the value will be in ISO8601 string format. For `Number` type -/// field, it will be a numeric value. -/// -[JsonConverter(typeof(MinValueConverter))] -public record class MinValue -{ - public object Value { get; private init; } - - public MinValue(string value) - { - Value = value; - } - - public MinValue(double value) - { - Value = value; - } - - MinValue(UnknownVariant value) - { - Value = value; - } - - public static MinValue CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public void Switch(System::Action @string, System::Action @double) - { - switch (this.Value) - { - case string value: - @string(value); - break; - case double value: - @double(value); - break; - default: - throw new System::InvalidOperationException(); - } - } - - public T Match(System::Func @string, System::Func @double) - { - return this.Value switch - { - String inner => @string(inner), - Double inner => @double(inner), - _ => throw new System::InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of MinValue"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class MinValueConverter : JsonConverter -{ - public override MinValue? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new MinValue(deserialized); - } - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - return new MinValue(JsonSerializer.Deserialize(ref reader, options)); - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new System::AggregateException(exceptions); - } - - public override void Write(Utf8JsonWriter writer, MinValue value, JsonSerializerOptions options) - { - object variant = value switch - { - String(var @string) => @string, - Double(var @double) => @double, - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MinValueVariants/All.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MinValueVariants/All.cs deleted file mode 100644 index 6ed3faa4..00000000 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/MinValueVariants/All.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties.MinValueVariants; - -public sealed record class String(string Value) : MinValue, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Double(double Value) : MinValue, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/SelectOption.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/SelectOption.cs deleted file mode 100644 index e0f7bea7..00000000 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/SelectOption.cs +++ /dev/null @@ -1,167 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties.SelectOptionVariants; -using System = System; - -namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties; - -[JsonConverter(typeof(SelectOptionConverter))] -public record class SelectOption -{ - public object Value { get; private init; } - - public SelectOption(string value) - { - Value = value; - } - - public SelectOption(double value) - { - Value = value; - } - - public SelectOption(bool value) - { - Value = value; - } - - SelectOption(UnknownVariant value) - { - Value = value; - } - - public static SelectOption CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public bool TryPickBool([NotNullWhen(true)] out bool? value) - { - value = this.Value as bool?; - return value != null; - } - - public void Switch( - System::Action @string, - System::Action @double, - System::Action @bool - ) - { - switch (this.Value) - { - case string value: - @string(value); - break; - case double value: - @double(value); - break; - case bool value: - @bool(value); - break; - default: - throw new System::InvalidOperationException(); - } - } - - public T Match( - System::Func @string, - System::Func @double, - System::Func @bool - ) - { - return this.Value switch - { - String inner => @string(inner), - Double inner => @double(inner), - Bool inner => @bool(inner), - _ => throw new System::InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException( - "Data did not match any variant of SelectOption" - ); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class SelectOptionConverter : JsonConverter -{ - public override SelectOption? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new SelectOption(deserialized); - } - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - return new SelectOption(JsonSerializer.Deserialize(ref reader, options)); - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - return new SelectOption(JsonSerializer.Deserialize(ref reader, options)); - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new System::AggregateException(exceptions); - } - - public override void Write( - Utf8JsonWriter writer, - SelectOption value, - JsonSerializerOptions options - ) - { - object variant = value switch - { - String(var @string) => @string, - Double(var @double) => @double, - Bool(var @bool) => @bool, - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/SelectOptionVariants/All.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/SelectOptionVariants/All.cs deleted file mode 100644 index 7127cf34..00000000 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/SelectOptionVariants/All.cs +++ /dev/null @@ -1,31 +0,0 @@ -namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties.SelectOptionVariants; - -public sealed record class String(string Value) : SelectOption, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Double(double Value) : SelectOption, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Bool(bool Value) : SelectOption, IVariant -{ - public static Bool From(bool value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/Type.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/Type.cs deleted file mode 100644 index de0b7408..00000000 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldProperties/SchemaProperties/Type.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using System = System; - -namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties; - -/// -/// Type of the custom metadata field. -/// -[JsonConverter(typeof(TypeConverter))] -public enum Type -{ - Text, - Textarea, - Number, - Date, - Boolean, - SingleSelect, - MultiSelect, -} - -sealed class TypeConverter : JsonConverter -{ - public override Type Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "Text" => SchemaProperties.Type.Text, - "Textarea" => SchemaProperties.Type.Textarea, - "Number" => SchemaProperties.Type.Number, - "Date" => SchemaProperties.Type.Date, - "Boolean" => SchemaProperties.Type.Boolean, - "SingleSelect" => SchemaProperties.Type.SingleSelect, - "MultiSelect" => SchemaProperties.Type.MultiSelect, - _ => (Type)(-1), - }; - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonSerializer.Serialize( - writer, - value switch - { - SchemaProperties.Type.Text => "Text", - SchemaProperties.Type.Textarea => "Textarea", - SchemaProperties.Type.Number => "Number", - SchemaProperties.Type.Date => "Date", - SchemaProperties.Type.Boolean => "Boolean", - SchemaProperties.Type.SingleSelect => "SingleSelect", - SchemaProperties.Type.MultiSelect => "MultiSelect", - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParams.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParams.cs deleted file mode 100644 index 3bfb3f73..00000000 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParams.cs +++ /dev/null @@ -1,95 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Net.Http; -using System.Text; -using System.Text.Json; -using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldUpdateParamsProperties; - -namespace Imagekit.Models.CustomMetadataFields; - -/// -/// This API updates the label or schema of an existing custom metadata field. -/// -public sealed record class CustomMetadataFieldUpdateParams : ParamsBase -{ - public Dictionary BodyProperties { get; set; } = []; - - public required string ID; - - /// - /// Human readable name of the custom metadata field. This should be unique across - /// all non deleted custom metadata fields. This name is displayed as form field - /// label to the users while setting field value on an asset in the media library - /// UI. This parameter is required if `schema` is not provided. - /// - public string? Label - { - get - { - if (!this.BodyProperties.TryGetValue("label", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["label"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// An object that describes the rules for the custom metadata key. This parameter - /// is required if `label` is not provided. Note: `type` cannot be updated and - /// will be ignored if sent with the `schema`. The schema will be validated as - /// per the existing `type`. - /// - public Schema? Schema - { - get - { - if (!this.BodyProperties.TryGetValue("schema", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["schema"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override Uri Url(IImageKitClient client) - { - return new UriBuilder( - client.BaseUrl.ToString().TrimEnd('/') - + string.Format("/v1/customMetadataFields/{0}", this.ID) - ) - { - Query = this.QueryString(client), - }.Uri; - } - - public StringContent BodyContent() - { - return new( - JsonSerializer.Serialize(this.BodyProperties), - Encoding.UTF8, - "application/json" - ); - } - - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/Schema.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/Schema.cs deleted file mode 100644 index 634ff465..00000000 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/Schema.cs +++ /dev/null @@ -1,207 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldUpdateParamsProperties.SchemaProperties; - -namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldUpdateParamsProperties; - -/// -/// An object that describes the rules for the custom metadata key. This parameter -/// is required if `label` is not provided. Note: `type` cannot be updated and will -/// be ignored if sent with the `schema`. The schema will be validated as per the -/// existing `type`. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class Schema : ModelBase, IFromRaw -{ - /// - /// The default value for this custom metadata field. This property is only required - /// if `isValueRequired` property is set to `true`. The value should match the - /// `type` of custom metadata field. - /// - public DefaultValue? DefaultValue - { - get - { - if (!this.Properties.TryGetValue("defaultValue", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["defaultValue"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Sets this custom metadata field as required. Setting custom metadata fields - /// on an asset will throw error if the value for all required fields are not - /// present in upload or update asset API request body. - /// - public bool? IsValueRequired - { - get - { - if (!this.Properties.TryGetValue("isValueRequired", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["isValueRequired"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Maximum length of string. Only set this property if `type` is set to `Text` - /// or `Textarea`. - /// - public double? MaxLength - { - get - { - if (!this.Properties.TryGetValue("maxLength", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["maxLength"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Maximum value of the field. Only set this property if field type is `Date` - /// or `Number`. For `Date` type field, set the minimum date in ISO8601 string - /// format. For `Number` type field, set the minimum numeric value. - /// - public MaxValue? MaxValue - { - get - { - if (!this.Properties.TryGetValue("maxValue", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["maxValue"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Minimum length of string. Only set this property if `type` is set to `Text` - /// or `Textarea`. - /// - public double? MinLength - { - get - { - if (!this.Properties.TryGetValue("minLength", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["minLength"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Minimum value of the field. Only set this property if field type is `Date` - /// or `Number`. For `Date` type field, set the minimum date in ISO8601 string - /// format. For `Number` type field, set the minimum numeric value. - /// - public MinValue? MinValue - { - get - { - if (!this.Properties.TryGetValue("minValue", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["minValue"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// An array of allowed values. This property is only required if `type` property - /// is set to `SingleSelect` or `MultiSelect`. - /// - public List? SelectOptions - { - get - { - if (!this.Properties.TryGetValue("selectOptions", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["selectOptions"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.DefaultValue?.Validate(); - _ = this.IsValueRequired; - _ = this.MaxLength; - this.MaxValue?.Validate(); - _ = this.MinLength; - this.MinValue?.Validate(); - foreach (var item in this.SelectOptions ?? []) - { - item.Validate(); - } - } - - public Schema() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Schema(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Schema FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValue.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValue.cs deleted file mode 100644 index a5a70940..00000000 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValue.cs +++ /dev/null @@ -1,194 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldUpdateParamsProperties.SchemaProperties.DefaultValueProperties; - -namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldUpdateParamsProperties.SchemaProperties; - -/// -/// The default value for this custom metadata field. This property is only required -/// if `isValueRequired` property is set to `true`. The value should match the `type` -/// of custom metadata field. -/// -[JsonConverter(typeof(DefaultValueConverter))] -public record class DefaultValue -{ - public object Value { get; private init; } - - public DefaultValue(string value) - { - Value = value; - } - - public DefaultValue(double value) - { - Value = value; - } - - public DefaultValue(bool value) - { - Value = value; - } - - public static implicit operator DefaultValue(List value) => - new DefaultValueVariants::Mixed(value); - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public bool TryPickBool([NotNullWhen(true)] out bool? value) - { - value = this.Value as bool?; - return value != null; - } - - public bool TryPickMixed([NotNullWhen(true)] out List? value) - { - value = this.Value as List; - return value != null; - } - - public void Switch( - Action @string, - Action @double, - Action @bool, - Action> mixed - ) - { - switch (this.Value) - { - case string value: - @string(value); - break; - case double value: - @double(value); - break; - case bool value: - @bool(value); - break; - case List value: - mixed(value); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match( - Func @string, - Func @double, - Func @bool, - Func, T> mixed - ) - { - return this.Value switch - { - DefaultValueVariants::String inner => @string(inner), - DefaultValueVariants::Double inner => @double(inner), - DefaultValueVariants::Bool inner => @bool(inner), - DefaultValueVariants::Mixed inner => mixed(inner), - _ => throw new InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException( - "Data did not match any variant of DefaultValue" - ); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class DefaultValueConverter : JsonConverter -{ - public override DefaultValue? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new DefaultValue(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - return new DefaultValue(JsonSerializer.Deserialize(ref reader, options)); - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - return new DefaultValue(JsonSerializer.Deserialize(ref reader, options)); - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - var deserialized = JsonSerializer.Deserialize>( - ref reader, - options - ); - if (deserialized != null) - { - return new DefaultValue(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - - public override void Write( - Utf8JsonWriter writer, - DefaultValue value, - JsonSerializerOptions options - ) - { - object variant = value switch - { - DefaultValueVariants::String(var @string) => @string, - DefaultValueVariants::Double(var @double) => @double, - DefaultValueVariants::Bool(var @bool) => @bool, - DefaultValueVariants::Mixed(var mixed) => mixed, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent3.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent3.cs deleted file mode 100644 index 53690e36..00000000 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent3.cs +++ /dev/null @@ -1,155 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using UnnamedSchemaWithArrayParent2Variants = Imagekit.Models.CustomMetadataFields.CustomMetadataFieldUpdateParamsProperties.SchemaProperties.DefaultValueProperties.UnnamedSchemaWithArrayParent2Variants; - -namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldUpdateParamsProperties.SchemaProperties.DefaultValueProperties; - -[JsonConverter(typeof(UnnamedSchemaWithArrayParent2Converter))] -public abstract record class UnnamedSchemaWithArrayParent2 -{ - internal UnnamedSchemaWithArrayParent2() { } - - public static implicit operator UnnamedSchemaWithArrayParent2(string value) => - new UnnamedSchemaWithArrayParent2Variants::String(value); - - public static implicit operator UnnamedSchemaWithArrayParent2(double value) => - new UnnamedSchemaWithArrayParent2Variants::Double(value); - - public static implicit operator UnnamedSchemaWithArrayParent2(bool value) => - new UnnamedSchemaWithArrayParent2Variants::Bool(value); - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = (this as UnnamedSchemaWithArrayParent2Variants::String)?.Value; - return value != null; - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = (this as UnnamedSchemaWithArrayParent2Variants::Double)?.Value; - return value != null; - } - - public bool TryPickBool([NotNullWhen(true)] out bool? value) - { - value = (this as UnnamedSchemaWithArrayParent2Variants::Bool)?.Value; - return value != null; - } - - public void Switch( - Action @string, - Action @double, - Action @bool - ) - { - switch (this.Value) - { - case UnnamedSchemaWithArrayParent2Variants::String inner: - @string(inner); - break; - case UnnamedSchemaWithArrayParent2Variants::Double inner: - @double(inner); - break; - case UnnamedSchemaWithArrayParent2Variants::Bool inner: - @bool(inner); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match( - Func @string, - Func @double, - Func @bool - ) - { - return this.Value switch - { - UnnamedSchemaWithArrayParent2Variants::String inner => @string(inner), - UnnamedSchemaWithArrayParent2Variants::Double inner => @double(inner), - UnnamedSchemaWithArrayParent2Variants::Bool inner => @bool(inner), - _ => throw new InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent3" - ); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class UnnamedSchemaWithArrayParent2Converter : JsonConverter -{ - public override UnnamedSchemaWithArrayParent2? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new UnnamedSchemaWithArrayParent2Variants::String(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - return new UnnamedSchemaWithArrayParent2Variants::Double( - JsonSerializer.Deserialize(ref reader, options) - ); - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - return new UnnamedSchemaWithArrayParent2Variants::Bool( - JsonSerializer.Deserialize(ref reader, options) - ); - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - - public override void Write( - Utf8JsonWriter writer, - UnnamedSchemaWithArrayParent2 value, - JsonSerializerOptions options - ) - { - object variant = value switch - { - UnnamedSchemaWithArrayParent2Variants::String(var @string) => @string, - UnnamedSchemaWithArrayParent2Variants::Double(var @double) => @double, - UnnamedSchemaWithArrayParent2Variants::Bool(var @bool) => @bool, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent3Variants/All.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent3Variants/All.cs deleted file mode 100644 index 30c9b6cb..00000000 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent3Variants/All.cs +++ /dev/null @@ -1,35 +0,0 @@ -namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldProperties.SchemaProperties.DefaultValueProperties.UnnamedSchemaWithArrayParent0Variants; - -public sealed record class String(string Value) - : UnnamedSchemaWithArrayParent0, - IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Double(double Value) - : UnnamedSchemaWithArrayParent0, - IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Bool(bool Value) : UnnamedSchemaWithArrayParent0, IVariant -{ - public static Bool From(bool value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValueVariants/All.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValueVariants/All.cs deleted file mode 100644 index 0dec8fad..00000000 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/DefaultValueVariants/All.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Collections.Generic; -using Imagekit.Models.CustomMetadataFields.CustomMetadataFieldUpdateParamsProperties.SchemaProperties.DefaultValueProperties; - -namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldUpdateParamsProperties.SchemaProperties.DefaultValueVariants; - -public sealed record class String(string Value) : DefaultValue, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Double(double Value) : DefaultValue, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Bool(bool Value) : DefaultValue, IVariant -{ - public static Bool From(bool value) - { - return new(value); - } - - public override void Validate() { } -} - -/// -/// Default value should be of type array when custom metadata field type is set to -/// `MultiSelect`. -/// -public sealed record class Mixed(List Value) - : DefaultValue, - IVariant> -{ - public static Mixed From(List value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MaxValue.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MaxValue.cs deleted file mode 100644 index 799667d7..00000000 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MaxValue.cs +++ /dev/null @@ -1,133 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using MaxValueVariants = Imagekit.Models.CustomMetadataFields.CustomMetadataFieldUpdateParamsProperties.SchemaProperties.MaxValueVariants; - -namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldUpdateParamsProperties.SchemaProperties; - -/// -/// Maximum value of the field. Only set this property if field type is `Date` or -/// `Number`. For `Date` type field, set the minimum date in ISO8601 string format. -/// For `Number` type field, set the minimum numeric value. -/// -[JsonConverter(typeof(MaxValueConverter))] -public record class MaxValue -{ - public object Value { get; private init; } - - public MaxValue(string value) - { - Value = value; - } - - public MaxValue(double value) - { - Value = value; - } - - MaxValue(UnknownVariant value) - { - Value = value; - } - - public static MaxValue CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public void Switch(Action @string, Action @double) - { - switch (this.Value) - { - case string value: - @string(value); - break; - case double value: - @double(value); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match(Func @string, Func @double) - { - return this.Value switch - { - MaxValueVariants::String inner => @string(inner), - MaxValueVariants::Double inner => @double(inner), - _ => throw new InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of MaxValue"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class MaxValueConverter : JsonConverter -{ - public override MaxValue? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new MaxValue(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - return new MaxValue(JsonSerializer.Deserialize(ref reader, options)); - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - - public override void Write(Utf8JsonWriter writer, MaxValue value, JsonSerializerOptions options) - { - object variant = value switch - { - MaxValueVariants::String(var @string) => @string, - MaxValueVariants::Double(var @double) => @double, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MaxValueVariants/All.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MaxValueVariants/All.cs deleted file mode 100644 index 77dc33f7..00000000 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MaxValueVariants/All.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldUpdateParamsProperties.SchemaProperties.MaxValueVariants; - -public sealed record class String(string Value) : MaxValue, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Double(double Value) : MaxValue, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MinValue.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MinValue.cs deleted file mode 100644 index 114f65b7..00000000 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MinValue.cs +++ /dev/null @@ -1,133 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using MinValueVariants = Imagekit.Models.CustomMetadataFields.CustomMetadataFieldUpdateParamsProperties.SchemaProperties.MinValueVariants; - -namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldUpdateParamsProperties.SchemaProperties; - -/// -/// Minimum value of the field. Only set this property if field type is `Date` or -/// `Number`. For `Date` type field, set the minimum date in ISO8601 string format. -/// For `Number` type field, set the minimum numeric value. -/// -[JsonConverter(typeof(MinValueConverter))] -public record class MinValue -{ - public object Value { get; private init; } - - public MinValue(string value) - { - Value = value; - } - - public MinValue(double value) - { - Value = value; - } - - MinValue(UnknownVariant value) - { - Value = value; - } - - public static MinValue CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public void Switch(Action @string, Action @double) - { - switch (this.Value) - { - case string value: - @string(value); - break; - case double value: - @double(value); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match(Func @string, Func @double) - { - return this.Value switch - { - MinValueVariants::String inner => @string(inner), - MinValueVariants::Double inner => @double(inner), - _ => throw new InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of MinValue"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class MinValueConverter : JsonConverter -{ - public override MinValue? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new MinValue(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - return new MinValue(JsonSerializer.Deserialize(ref reader, options)); - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - - public override void Write(Utf8JsonWriter writer, MinValue value, JsonSerializerOptions options) - { - object variant = value switch - { - MinValueVariants::String(var @string) => @string, - MinValueVariants::Double(var @double) => @double, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MinValueVariants/All.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MinValueVariants/All.cs deleted file mode 100644 index c0acd9c9..00000000 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/MinValueVariants/All.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldUpdateParamsProperties.SchemaProperties.MinValueVariants; - -public sealed record class String(string Value) : MinValue, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Double(double Value) : MinValue, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/SelectOption.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/SelectOption.cs deleted file mode 100644 index 117d2a37..00000000 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/SelectOption.cs +++ /dev/null @@ -1,159 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using SelectOptionVariants = Imagekit.Models.CustomMetadataFields.CustomMetadataFieldUpdateParamsProperties.SchemaProperties.SelectOptionVariants; - -namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldUpdateParamsProperties.SchemaProperties; - -[JsonConverter(typeof(SelectOptionConverter))] -public record class SelectOption -{ - public object Value { get; private init; } - - public SelectOption(string value) - { - Value = value; - } - - public SelectOption(double value) - { - Value = value; - } - - public SelectOption(bool value) - { - Value = value; - } - - SelectOption(UnknownVariant value) - { - Value = value; - } - - public static SelectOption CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public bool TryPickBool([NotNullWhen(true)] out bool? value) - { - value = this.Value as bool?; - return value != null; - } - - public void Switch(Action @string, Action @double, Action @bool) - { - switch (this.Value) - { - case string value: - @string(value); - break; - case double value: - @double(value); - break; - case bool value: - @bool(value); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match(Func @string, Func @double, Func @bool) - { - return this.Value switch - { - SelectOptionVariants::String inner => @string(inner), - SelectOptionVariants::Double inner => @double(inner), - SelectOptionVariants::Bool inner => @bool(inner), - _ => throw new InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException( - "Data did not match any variant of SelectOption" - ); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class SelectOptionConverter : JsonConverter -{ - public override SelectOption? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new SelectOption(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - return new SelectOption(JsonSerializer.Deserialize(ref reader, options)); - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - return new SelectOption(JsonSerializer.Deserialize(ref reader, options)); - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - - public override void Write( - Utf8JsonWriter writer, - SelectOption value, - JsonSerializerOptions options - ) - { - object variant = value switch - { - SelectOptionVariants::String(var @string) => @string, - SelectOptionVariants::Double(var @double) => @double, - SelectOptionVariants::Bool(var @bool) => @bool, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/SelectOptionVariants/All.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/SelectOptionVariants/All.cs deleted file mode 100644 index 419bfb5c..00000000 --- a/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsProperties/SchemaProperties/SelectOptionVariants/All.cs +++ /dev/null @@ -1,31 +0,0 @@ -namespace Imagekit.Models.CustomMetadataFields.CustomMetadataFieldUpdateParamsProperties.SchemaProperties.SelectOptionVariants; - -public sealed record class String(string Value) : SelectOption, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Double(double Value) : SelectOption, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Bool(bool Value) : SelectOption, IVariant -{ - public static Bool From(bool value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/Files/Bulk/BulkAddTagsParams.cs b/src/Imagekit/Models/Files/Bulk/BulkAddTagsParams.cs deleted file mode 100644 index 4d075f5e..00000000 --- a/src/Imagekit/Models/Files/Bulk/BulkAddTagsParams.cs +++ /dev/null @@ -1,86 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Net.Http; -using System.Text; -using System.Text.Json; - -namespace Imagekit.Models.Files.Bulk; - -/// -/// This API adds tags to multiple files in bulk. A maximum of 50 files can be specified -/// at a time. -/// -public sealed record class BulkAddTagsParams : ParamsBase -{ - public Dictionary BodyProperties { get; set; } = []; - - /// - /// An array of fileIds to which you want to add tags. - /// - public required List FileIDs - { - get - { - if (!this.BodyProperties.TryGetValue("fileIds", out JsonElement element)) - throw new ArgumentOutOfRangeException("fileIds", "Missing required argument"); - - return JsonSerializer.Deserialize>(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("fileIds"); - } - set - { - this.BodyProperties["fileIds"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// An array of tags that you want to add to the files. - /// - public required List Tags - { - get - { - if (!this.BodyProperties.TryGetValue("tags", out JsonElement element)) - throw new ArgumentOutOfRangeException("tags", "Missing required argument"); - - return JsonSerializer.Deserialize>(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("tags"); - } - set - { - this.BodyProperties["tags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override Uri Url(IImageKitClient client) - { - return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/files/addTags") - { - Query = this.QueryString(client), - }.Uri; - } - - public StringContent BodyContent() - { - return new( - JsonSerializer.Serialize(this.BodyProperties), - Encoding.UTF8, - "application/json" - ); - } - - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} diff --git a/src/Imagekit/Models/Files/Bulk/BulkAddTagsResponse.cs b/src/Imagekit/Models/Files/Bulk/BulkAddTagsResponse.cs deleted file mode 100644 index 90e7f3ca..00000000 --- a/src/Imagekit/Models/Files/Bulk/BulkAddTagsResponse.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Core; - -namespace Imagekit.Models.Files.Bulk; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class BulkAddTagsResponse : ModelBase, IFromRaw -{ - /// - /// An array of fileIds that in which tags were successfully added. - /// - public List? SuccessfullyUpdatedFileIDs - { - get - { - if (!this.Properties.TryGetValue("successfullyUpdatedFileIds", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["successfullyUpdatedFileIds"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.SuccessfullyUpdatedFileIDs; - } - - public BulkAddTagsResponse() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - BulkAddTagsResponse(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static BulkAddTagsResponse FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/Bulk/BulkDeleteParams.cs b/src/Imagekit/Models/Files/Bulk/BulkDeleteParams.cs deleted file mode 100644 index 1a28cd44..00000000 --- a/src/Imagekit/Models/Files/Bulk/BulkDeleteParams.cs +++ /dev/null @@ -1,71 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Net.Http; -using System.Text; -using System.Text.Json; - -namespace Imagekit.Models.Files.Bulk; - -/// -/// This API deletes multiple files and all their file versions permanently. -/// -/// Note: If a file or specific transformation has been requested in the past, then -/// the response is cached. Deleting a file does not purge the cache. You can purge -/// the cache using purge cache API. -/// -/// A maximum of 100 files can be deleted at a time. -/// -public sealed record class BulkDeleteParams : ParamsBase -{ - public Dictionary BodyProperties { get; set; } = []; - - /// - /// An array of fileIds which you want to delete. - /// - public required List FileIDs - { - get - { - if (!this.BodyProperties.TryGetValue("fileIds", out JsonElement element)) - throw new ArgumentOutOfRangeException("fileIds", "Missing required argument"); - - return JsonSerializer.Deserialize>(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("fileIds"); - } - set - { - this.BodyProperties["fileIds"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override Uri Url(IImageKitClient client) - { - return new UriBuilder( - client.BaseUrl.ToString().TrimEnd('/') + "/v1/files/batch/deleteByFileIds" - ) - { - Query = this.QueryString(client), - }.Uri; - } - - public StringContent BodyContent() - { - return new( - JsonSerializer.Serialize(this.BodyProperties), - Encoding.UTF8, - "application/json" - ); - } - - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} diff --git a/src/Imagekit/Models/Files/Bulk/BulkDeleteResponse.cs b/src/Imagekit/Models/Files/Bulk/BulkDeleteResponse.cs deleted file mode 100644 index 618d4df5..00000000 --- a/src/Imagekit/Models/Files/Bulk/BulkDeleteResponse.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Core; - -namespace Imagekit.Models.Files.Bulk; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class BulkDeleteResponse : ModelBase, IFromRaw -{ - /// - /// An array of fileIds that were successfully deleted. - /// - public List? SuccessfullyDeletedFileIDs - { - get - { - if (!this.Properties.TryGetValue("successfullyDeletedFileIds", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["successfullyDeletedFileIds"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.SuccessfullyDeletedFileIDs; - } - - public BulkDeleteResponse() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - BulkDeleteResponse(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static BulkDeleteResponse FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/Bulk/BulkRemoveAITagsParams.cs b/src/Imagekit/Models/Files/Bulk/BulkRemoveAITagsParams.cs deleted file mode 100644 index ad1e2adb..00000000 --- a/src/Imagekit/Models/Files/Bulk/BulkRemoveAITagsParams.cs +++ /dev/null @@ -1,86 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Net.Http; -using System.Text; -using System.Text.Json; - -namespace Imagekit.Models.Files.Bulk; - -/// -/// This API removes AITags from multiple files in bulk. A maximum of 50 files can -/// be specified at a time. -/// -public sealed record class BulkRemoveAITagsParams : ParamsBase -{ - public Dictionary BodyProperties { get; set; } = []; - - /// - /// An array of AITags that you want to remove from the files. - /// - public required List AITags - { - get - { - if (!this.BodyProperties.TryGetValue("AITags", out JsonElement element)) - throw new ArgumentOutOfRangeException("AITags", "Missing required argument"); - - return JsonSerializer.Deserialize>(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("AITags"); - } - set - { - this.BodyProperties["AITags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// An array of fileIds from which you want to remove AITags. - /// - public required List FileIDs - { - get - { - if (!this.BodyProperties.TryGetValue("fileIds", out JsonElement element)) - throw new ArgumentOutOfRangeException("fileIds", "Missing required argument"); - - return JsonSerializer.Deserialize>(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("fileIds"); - } - set - { - this.BodyProperties["fileIds"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override Uri Url(IImageKitClient client) - { - return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/files/removeAITags") - { - Query = this.QueryString(client), - }.Uri; - } - - public StringContent BodyContent() - { - return new( - JsonSerializer.Serialize(this.BodyProperties), - Encoding.UTF8, - "application/json" - ); - } - - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} diff --git a/src/Imagekit/Models/Files/Bulk/BulkRemoveAITagsResponse.cs b/src/Imagekit/Models/Files/Bulk/BulkRemoveAITagsResponse.cs deleted file mode 100644 index 2675d95b..00000000 --- a/src/Imagekit/Models/Files/Bulk/BulkRemoveAITagsResponse.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Core; - -namespace Imagekit.Models.Files.Bulk; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class BulkRemoveAITagsResponse : ModelBase, IFromRaw -{ - /// - /// An array of fileIds that in which AITags were successfully removed. - /// - public List? SuccessfullyUpdatedFileIDs - { - get - { - if (!this.Properties.TryGetValue("successfullyUpdatedFileIds", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["successfullyUpdatedFileIds"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.SuccessfullyUpdatedFileIDs; - } - - public BulkRemoveAITagsResponse() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - BulkRemoveAITagsResponse(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static BulkRemoveAITagsResponse FromRawUnchecked( - Dictionary properties - ) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/Bulk/BulkRemoveTagsParams.cs b/src/Imagekit/Models/Files/Bulk/BulkRemoveTagsParams.cs deleted file mode 100644 index eab66eb4..00000000 --- a/src/Imagekit/Models/Files/Bulk/BulkRemoveTagsParams.cs +++ /dev/null @@ -1,86 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Net.Http; -using System.Text; -using System.Text.Json; - -namespace Imagekit.Models.Files.Bulk; - -/// -/// This API removes tags from multiple files in bulk. A maximum of 50 files can -/// be specified at a time. -/// -public sealed record class BulkRemoveTagsParams : ParamsBase -{ - public Dictionary BodyProperties { get; set; } = []; - - /// - /// An array of fileIds from which you want to remove tags. - /// - public required List FileIDs - { - get - { - if (!this.BodyProperties.TryGetValue("fileIds", out JsonElement element)) - throw new ArgumentOutOfRangeException("fileIds", "Missing required argument"); - - return JsonSerializer.Deserialize>(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("fileIds"); - } - set - { - this.BodyProperties["fileIds"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// An array of tags that you want to remove from the files. - /// - public required List Tags - { - get - { - if (!this.BodyProperties.TryGetValue("tags", out JsonElement element)) - throw new ArgumentOutOfRangeException("tags", "Missing required argument"); - - return JsonSerializer.Deserialize>(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("tags"); - } - set - { - this.BodyProperties["tags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override Uri Url(IImageKitClient client) - { - return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/files/removeTags") - { - Query = this.QueryString(client), - }.Uri; - } - - public StringContent BodyContent() - { - return new( - JsonSerializer.Serialize(this.BodyProperties), - Encoding.UTF8, - "application/json" - ); - } - - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} diff --git a/src/Imagekit/Models/Files/Bulk/BulkRemoveTagsResponse.cs b/src/Imagekit/Models/Files/Bulk/BulkRemoveTagsResponse.cs deleted file mode 100644 index 2d9835eb..00000000 --- a/src/Imagekit/Models/Files/Bulk/BulkRemoveTagsResponse.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Core; - -namespace Imagekit.Models.Files.Bulk; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class BulkRemoveTagsResponse : ModelBase, IFromRaw -{ - /// - /// An array of fileIds that in which tags were successfully removed. - /// - public List? SuccessfullyUpdatedFileIDs - { - get - { - if (!this.Properties.TryGetValue("successfullyUpdatedFileIds", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["successfullyUpdatedFileIds"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.SuccessfullyUpdatedFileIDs; - } - - public BulkRemoveTagsResponse() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - BulkRemoveTagsResponse(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static BulkRemoveTagsResponse FromRawUnchecked( - Dictionary properties - ) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/File.cs b/src/Imagekit/Models/Files/File.cs deleted file mode 100644 index 9b805262..00000000 --- a/src/Imagekit/Models/Files/File.cs +++ /dev/null @@ -1,580 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Core; -using Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties; -using FileProperties = Imagekit.Models.Files.FileProperties; - -namespace Imagekit.Models.Files; - -/// -/// Object containing details of a file or file version. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class File : ModelBase, IFromRaw -{ - /// - /// An array of tags assigned to the file by auto tagging. - /// - public List? AITags - { - get - { - if (!this.Properties.TryGetValue("AITags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["AITags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Date and time when the file was uploaded. The date and time is in ISO8601 - /// format. - /// - public DateTime? CreatedAt - { - get - { - if (!this.Properties.TryGetValue("createdAt", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["createdAt"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// An string with custom coordinates of the file. - /// - public string? CustomCoordinates - { - get - { - if (!this.Properties.TryGetValue("customCoordinates", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["customCoordinates"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// An object with custom metadata for the file. - /// - public Dictionary? CustomMetadata - { - get - { - if (!this.Properties.TryGetValue("customMetadata", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["customMetadata"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Optional text to describe the contents of the file. Can be set by the user - /// or the ai-auto-description extension. - /// - public string? Description - { - get - { - if (!this.Properties.TryGetValue("description", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["description"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Unique identifier of the asset. - /// - public string? FileID - { - get - { - if (!this.Properties.TryGetValue("fileId", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["fileId"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Path of the file. This is the path you would use in the URL to access the - /// file. For example, if the file is at the root of the media library, the path - /// will be `/file.jpg`. If the file is inside a folder named `images`, the path - /// will be `/images/file.jpg`. - /// - public string? FilePath - { - get - { - if (!this.Properties.TryGetValue("filePath", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["filePath"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Type of the file. Possible values are `image`, `non-image`. - /// - public string? FileType - { - get - { - if (!this.Properties.TryGetValue("fileType", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["fileType"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies if the image has an alpha channel. - /// - public bool? HasAlpha - { - get - { - if (!this.Properties.TryGetValue("hasAlpha", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["hasAlpha"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Height of the file. - /// - public double? Height - { - get - { - if (!this.Properties.TryGetValue("height", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["height"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies if the file is private or not. - /// - public bool? IsPrivateFile - { - get - { - if (!this.Properties.TryGetValue("isPrivateFile", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["isPrivateFile"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies if the file is published or not. - /// - public bool? IsPublished - { - get - { - if (!this.Properties.TryGetValue("isPublished", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["isPublished"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// MIME type of the file. - /// - public string? Mime - { - get - { - if (!this.Properties.TryGetValue("mime", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["mime"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Name of the asset. - /// - public string? Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// This field is included in the response only if the Path policy feature is - /// available in the plan. It contains schema definitions for the custom metadata - /// fields selected for the specified file path. Field selection can only be done - /// when the Path policy feature is enabled. - /// - /// Keys are the names of the custom metadata fields; the value object has details - /// about the custom metadata schema. - /// - public Dictionary? SelectedFieldsSchema - { - get - { - if (!this.Properties.TryGetValue("selectedFieldsSchema", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["selectedFieldsSchema"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Size of the file in bytes. - /// - public double? Size - { - get - { - if (!this.Properties.TryGetValue("size", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["size"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// An array of tags assigned to the file. Tags are used to search files in the - /// media library. - /// - public List? Tags - { - get - { - if (!this.Properties.TryGetValue("tags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["tags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// URL of the thumbnail image. This URL is used to access the thumbnail image - /// of the file in the media library. - /// - public string? Thumbnail - { - get - { - if (!this.Properties.TryGetValue("thumbnail", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["thumbnail"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Type of the asset. - /// - public ApiEnum? Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Date and time when the file was last updated. The date and time is in ISO8601 - /// format. - /// - public DateTime? UpdatedAt - { - get - { - if (!this.Properties.TryGetValue("updatedAt", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["updatedAt"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// URL of the file. - /// - public string? URL - { - get - { - if (!this.Properties.TryGetValue("url", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["url"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// An object with details of the file version. - /// - public FileProperties::VersionInfo? VersionInfo - { - get - { - if (!this.Properties.TryGetValue("versionInfo", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["versionInfo"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Width of the file. - /// - public double? Width - { - get - { - if (!this.Properties.TryGetValue("width", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["width"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - foreach (var item in this.AITags ?? []) - { - item.Validate(); - } - _ = this.CreatedAt; - _ = this.CustomCoordinates; - _ = this.CustomMetadata; - _ = this.Description; - _ = this.FileID; - _ = this.FilePath; - _ = this.FileType; - _ = this.HasAlpha; - _ = this.Height; - _ = this.IsPrivateFile; - _ = this.IsPublished; - _ = this.Mime; - _ = this.Name; - if (this.SelectedFieldsSchema != null) - { - foreach (var item in this.SelectedFieldsSchema.Values) - { - item.Validate(); - } - } - _ = this.Size; - _ = this.Tags; - _ = this.Thumbnail; - this.Type?.Validate(); - _ = this.UpdatedAt; - _ = this.URL; - this.VersionInfo?.Validate(); - _ = this.Width; - } - - public File() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - File(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static File FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/FileCopyParams.cs b/src/Imagekit/Models/Files/FileCopyParams.cs deleted file mode 100644 index ca6de278..00000000 --- a/src/Imagekit/Models/Files/FileCopyParams.cs +++ /dev/null @@ -1,118 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Net.Http; -using System.Text; -using System.Text.Json; - -namespace Imagekit.Models.Files; - -/// -/// This will copy a file from one folder to another. -/// -/// Note: If any file at the destination has the same name as the source file, then -/// the source file and its versions (if `includeFileVersions` is set to true) will -/// be appended to the destination file version history. -/// -public sealed record class FileCopyParams : ParamsBase -{ - public Dictionary BodyProperties { get; set; } = []; - - /// - /// Full path to the folder you want to copy the above file into. - /// - public required string DestinationPath - { - get - { - if (!this.BodyProperties.TryGetValue("destinationPath", out JsonElement element)) - throw new ArgumentOutOfRangeException( - "destinationPath", - "Missing required argument" - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("destinationPath"); - } - set - { - this.BodyProperties["destinationPath"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The full path of the file you want to copy. - /// - public required string SourceFilePath - { - get - { - if (!this.BodyProperties.TryGetValue("sourceFilePath", out JsonElement element)) - throw new ArgumentOutOfRangeException( - "sourceFilePath", - "Missing required argument" - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("sourceFilePath"); - } - set - { - this.BodyProperties["sourceFilePath"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Option to copy all versions of a file. By default, only the current version - /// of the file is copied. When set to true, all versions of the file will be - /// copied. Default value - `false`. - /// - public bool? IncludeFileVersions - { - get - { - if (!this.BodyProperties.TryGetValue("includeFileVersions", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["includeFileVersions"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override Uri Url(IImageKitClient client) - { - return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/files/copy") - { - Query = this.QueryString(client), - }.Uri; - } - - public StringContent BodyContent() - { - return new( - JsonSerializer.Serialize(this.BodyProperties), - Encoding.UTF8, - "application/json" - ); - } - - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} diff --git a/src/Imagekit/Models/Files/FileCopyResponse.cs b/src/Imagekit/Models/Files/FileCopyResponse.cs deleted file mode 100644 index bac4ecbb..00000000 --- a/src/Imagekit/Models/Files/FileCopyResponse.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class FileCopyResponse : ModelBase, IFromRaw -{ - public override void Validate() { } - - public FileCopyResponse() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - FileCopyResponse(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static FileCopyResponse FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/FileDeleteParams.cs b/src/Imagekit/Models/Files/FileDeleteParams.cs deleted file mode 100644 index aac0dab1..00000000 --- a/src/Imagekit/Models/Files/FileDeleteParams.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Net.Http; - -namespace Imagekit.Models.Files; - -/// -/// This API deletes the file and all its file versions permanently. -/// -/// Note: If a file or specific transformation has been requested in the past, then -/// the response is cached. Deleting a file does not purge the cache. You can purge -/// the cache using purge cache API. -/// -public sealed record class FileDeleteParams : ParamsBase -{ - public required string FileID; - - public override Uri Url(IImageKitClient client) - { - return new UriBuilder( - client.BaseUrl.ToString().TrimEnd('/') + string.Format("/v1/files/{0}", this.FileID) - ) - { - Query = this.QueryString(client), - }.Uri; - } - - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} diff --git a/src/Imagekit/Models/Files/FileGetParams.cs b/src/Imagekit/Models/Files/FileGetParams.cs deleted file mode 100644 index 5f8dbc1a..00000000 --- a/src/Imagekit/Models/Files/FileGetParams.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using System.Net.Http; - -namespace Imagekit.Models.Files; - -/// -/// This API returns an object with details or attributes about the current version -/// of the file. -/// -public sealed record class FileGetParams : ParamsBase -{ - public required string FileID; - - public override Uri Url(IImageKitClient client) - { - return new UriBuilder( - client.BaseUrl.ToString().TrimEnd('/') - + string.Format("/v1/files/{0}/details", this.FileID) - ) - { - Query = this.QueryString(client), - }.Uri; - } - - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} diff --git a/src/Imagekit/Models/Files/FileMoveParams.cs b/src/Imagekit/Models/Files/FileMoveParams.cs deleted file mode 100644 index 0bcf2dba..00000000 --- a/src/Imagekit/Models/Files/FileMoveParams.cs +++ /dev/null @@ -1,94 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Net.Http; -using System.Text; -using System.Text.Json; - -namespace Imagekit.Models.Files; - -/// -/// This will move a file and all its versions from one folder to another. -/// -/// Note: If any file at the destination has the same name as the source file, then -/// the source file and its versions will be appended to the destination file. -/// -public sealed record class FileMoveParams : ParamsBase -{ - public Dictionary BodyProperties { get; set; } = []; - - /// - /// Full path to the folder you want to move the above file into. - /// - public required string DestinationPath - { - get - { - if (!this.BodyProperties.TryGetValue("destinationPath", out JsonElement element)) - throw new ArgumentOutOfRangeException( - "destinationPath", - "Missing required argument" - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("destinationPath"); - } - set - { - this.BodyProperties["destinationPath"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The full path of the file you want to move. - /// - public required string SourceFilePath - { - get - { - if (!this.BodyProperties.TryGetValue("sourceFilePath", out JsonElement element)) - throw new ArgumentOutOfRangeException( - "sourceFilePath", - "Missing required argument" - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("sourceFilePath"); - } - set - { - this.BodyProperties["sourceFilePath"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override Uri Url(IImageKitClient client) - { - return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/files/move") - { - Query = this.QueryString(client), - }.Uri; - } - - public StringContent BodyContent() - { - return new( - JsonSerializer.Serialize(this.BodyProperties), - Encoding.UTF8, - "application/json" - ); - } - - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} diff --git a/src/Imagekit/Models/Files/FileMoveResponse.cs b/src/Imagekit/Models/Files/FileMoveResponse.cs deleted file mode 100644 index ebcffab9..00000000 --- a/src/Imagekit/Models/Files/FileMoveResponse.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class FileMoveResponse : ModelBase, IFromRaw -{ - public override void Validate() { } - - public FileMoveResponse() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - FileMoveResponse(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static FileMoveResponse FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/FileProperties/AITag.cs b/src/Imagekit/Models/Files/FileProperties/AITag.cs deleted file mode 100644 index f5bacb0e..00000000 --- a/src/Imagekit/Models/Files/FileProperties/AITag.cs +++ /dev/null @@ -1,95 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files.FileProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class AITag : ModelBase, IFromRaw -{ - /// - /// Confidence score of the tag. - /// - public double? Confidence - { - get - { - if (!this.Properties.TryGetValue("confidence", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["confidence"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Name of the tag. - /// - public string? Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Source of the tag. Possible values are `google-auto-tagging` and `aws-auto-tagging`. - /// - public string? Source - { - get - { - if (!this.Properties.TryGetValue("source", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["source"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.Confidence; - _ = this.Name; - _ = this.Source; - } - - public AITag() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - AITag(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static AITag FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs deleted file mode 100644 index 96e3b889..00000000 --- a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs +++ /dev/null @@ -1,290 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Core; -using Imagekit.Exceptions; -using SelectedFieldsSchemaItemProperties = Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; - -namespace Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class SelectedFieldsSchemaItem : ModelBase, IFromRaw -{ - /// - /// Type of the custom metadata field. - /// - public required ApiEnum Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentOutOfRangeException("type", "Missing required argument") - ); - - return JsonSerializer.Deserialize< - ApiEnum - >(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The default value for this custom metadata field. The value should match the - /// `type` of custom metadata field. - /// - public SelectedFieldsSchemaItemProperties::DefaultValue? DefaultValue - { - get - { - if (!this.Properties.TryGetValue("defaultValue", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["defaultValue"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies if the custom metadata field is required or not. - /// - public bool? IsValueRequired - { - get - { - if (!this.Properties.TryGetValue("isValueRequired", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["isValueRequired"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. - /// - public double? MaxLength - { - get - { - if (!this.Properties.TryGetValue("maxLength", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["maxLength"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Maximum value of the field. Only set if field type is `Date` or `Number`. - /// For `Date` type field, the value will be in ISO8601 string format. For `Number` - /// type field, it will be a numeric value. - /// - public SelectedFieldsSchemaItemProperties::MaxValue? MaxValue - { - get - { - if (!this.Properties.TryGetValue("maxValue", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["maxValue"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. - /// - public double? MinLength - { - get - { - if (!this.Properties.TryGetValue("minLength", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["minLength"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Minimum value of the field. Only set if field type is `Date` or `Number`. - /// For `Date` type field, the value will be in ISO8601 string format. For `Number` - /// type field, it will be a numeric value. - /// - public SelectedFieldsSchemaItemProperties::MinValue? MinValue - { - get - { - if (!this.Properties.TryGetValue("minValue", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["minValue"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Indicates whether the custom metadata field is read only. A read only field - /// cannot be modified after being set. This field is configurable only via the - /// **Path policy** feature. - /// - public bool? ReadOnly - { - get - { - if (!this.Properties.TryGetValue("readOnly", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["readOnly"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// An array of allowed values when field type is `SingleSelect` or `MultiSelect`. - /// - public List? SelectOptions - { - get - { - if (!this.Properties.TryGetValue("selectOptions", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["selectOptions"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies if the selectOptions array is truncated. It is truncated when number - /// of options are > 100. - /// - public bool? SelectOptionsTruncated - { - get - { - if (!this.Properties.TryGetValue("selectOptionsTruncated", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["selectOptionsTruncated"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Type.Validate(); - this.DefaultValue?.Validate(); - _ = this.IsValueRequired; - _ = this.MaxLength; - this.MaxValue?.Validate(); - _ = this.MinLength; - this.MinValue?.Validate(); - _ = this.ReadOnly; - foreach (var item in this.SelectOptions ?? []) - { - item.Validate(); - } - _ = this.SelectOptionsTruncated; - } - - public SelectedFieldsSchemaItem() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - SelectedFieldsSchemaItem(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static SelectedFieldsSchemaItem FromRawUnchecked( - Dictionary properties - ) - { - return new(properties); - } - - [SetsRequiredMembers] - public SelectedFieldsSchemaItem(ApiEnum type) - : this() - { - this.Type = type; - } -} diff --git a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs deleted file mode 100644 index 0bb654a5..00000000 --- a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs +++ /dev/null @@ -1,214 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties; -using System = System; - -namespace Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; - -/// -/// The default value for this custom metadata field. The value should match the -/// `type` of custom metadata field. -/// -[JsonConverter(typeof(DefaultValueConverter))] -public record class DefaultValue -{ - public object Value { get; private init; } - - public DefaultValue(string value) - { - Value = value; - } - - public DefaultValue(double value) - { - Value = value; - } - - public DefaultValue(bool value) - { - Value = value; - } - - public DefaultValue(List value) - { - Value = value; - } - - DefaultValue(UnknownVariant value) - { - Value = value; - } - - public static DefaultValue CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public bool TryPickBool([NotNullWhen(true)] out bool? value) - { - value = this.Value as bool?; - return value != null; - } - - public bool TryPickMixed([NotNullWhen(true)] out List? value) - { - value = this.Value as List; - return value != null; - } - - public void Switch( - System::Action @string, - System::Action @double, - System::Action @bool, - System::Action> mixed - ) - { - switch (this.Value) - { - case string value: - @string(value); - break; - case double value: - @double(value); - break; - case bool value: - @bool(value); - break; - case List value: - mixed(value); - break; - default: - throw new ImageKitInvalidDataException( - "Data did not match any variant of DefaultValue" - ); - } - } - - public T Match( - System::Func @string, - System::Func @double, - System::Func @bool, - System::Func, T> mixed - ) - { - return this.Value switch - { - string value => @string(value), - double value => @double(value), - bool value => @bool(value), - List value => mixed(value), - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of DefaultValue" - ), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException( - "Data did not match any variant of DefaultValue" - ); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class DefaultValueConverter : JsonConverter -{ - public override DefaultValue? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new DefaultValue(deserialized); - } - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'string'", e) - ); - } - - try - { - return new DefaultValue(JsonSerializer.Deserialize(ref reader, options)); - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'double'", e) - ); - } - - try - { - return new DefaultValue(JsonSerializer.Deserialize(ref reader, options)); - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'bool'", e) - ); - } - - try - { - var deserialized = JsonSerializer.Deserialize>( - ref reader, - options - ); - if (deserialized != null) - { - return new DefaultValue(deserialized); - } - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException( - "Data does not match union variant 'List'", - e - ) - ); - } - - throw new System::AggregateException(exceptions); - } - - public override void Write( - Utf8JsonWriter writer, - DefaultValue value, - JsonSerializerOptions options - ) - { - object variant = value.Value; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent4.cs b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent4.cs deleted file mode 100644 index 4a46c3da..00000000 --- a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent4.cs +++ /dev/null @@ -1,175 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties; - -[JsonConverter(typeof(UnnamedSchemaWithArrayParent4Converter))] -public record class UnnamedSchemaWithArrayParent4 -{ - public object Value { get; private init; } - - public UnnamedSchemaWithArrayParent4(string value) - { - Value = value; - } - - public UnnamedSchemaWithArrayParent4(double value) - { - Value = value; - } - - public UnnamedSchemaWithArrayParent4(bool value) - { - Value = value; - } - - UnnamedSchemaWithArrayParent4(UnknownVariant value) - { - Value = value; - } - - public static UnnamedSchemaWithArrayParent4 CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public bool TryPickBool([NotNullWhen(true)] out bool? value) - { - value = this.Value as bool?; - return value != null; - } - - public void Switch( - System::Action @string, - System::Action @double, - System::Action @bool - ) - { - switch (this.Value) - { - case string value: - @string(value); - break; - case double value: - @double(value); - break; - case bool value: - @bool(value); - break; - default: - throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent4" - ); - } - } - - public T Match( - System::Func @string, - System::Func @double, - System::Func @bool - ) - { - return this.Value switch - { - string value => @string(value), - double value => @double(value), - bool value => @bool(value), - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent4" - ), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent4" - ); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class UnnamedSchemaWithArrayParent4Converter : JsonConverter -{ - public override UnnamedSchemaWithArrayParent4? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new UnnamedSchemaWithArrayParent4(deserialized); - } - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'string'", e) - ); - } - - try - { - return new UnnamedSchemaWithArrayParent4( - JsonSerializer.Deserialize(ref reader, options) - ); - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'double'", e) - ); - } - - try - { - return new UnnamedSchemaWithArrayParent4( - JsonSerializer.Deserialize(ref reader, options) - ); - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'bool'", e) - ); - } - - throw new System::AggregateException(exceptions); - } - - public override void Write( - Utf8JsonWriter writer, - UnnamedSchemaWithArrayParent4 value, - JsonSerializerOptions options - ) - { - object variant = value.Value; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs deleted file mode 100644 index 8be662f7..00000000 --- a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs +++ /dev/null @@ -1,136 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; - -/// -/// Maximum value of the field. Only set if field type is `Date` or `Number`. For -/// `Date` type field, the value will be in ISO8601 string format. For `Number` type -/// field, it will be a numeric value. -/// -[JsonConverter(typeof(MaxValueConverter))] -public record class MaxValue -{ - public object Value { get; private init; } - - public MaxValue(string value) - { - Value = value; - } - - public MaxValue(double value) - { - Value = value; - } - - MaxValue(UnknownVariant value) - { - Value = value; - } - - public static MaxValue CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public void Switch(System::Action @string, System::Action @double) - { - switch (this.Value) - { - case string value: - @string(value); - break; - case double value: - @double(value); - break; - default: - throw new ImageKitInvalidDataException( - "Data did not match any variant of MaxValue" - ); - } - } - - public T Match(System::Func @string, System::Func @double) - { - return this.Value switch - { - string value => @string(value), - double value => @double(value), - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of MaxValue" - ), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of MaxValue"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class MaxValueConverter : JsonConverter -{ - public override MaxValue? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new MaxValue(deserialized); - } - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'string'", e) - ); - } - - try - { - return new MaxValue(JsonSerializer.Deserialize(ref reader, options)); - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'double'", e) - ); - } - - throw new System::AggregateException(exceptions); - } - - public override void Write(Utf8JsonWriter writer, MaxValue value, JsonSerializerOptions options) - { - object variant = value.Value; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs deleted file mode 100644 index 667e024f..00000000 --- a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs +++ /dev/null @@ -1,136 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; - -/// -/// Minimum value of the field. Only set if field type is `Date` or `Number`. For -/// `Date` type field, the value will be in ISO8601 string format. For `Number` type -/// field, it will be a numeric value. -/// -[JsonConverter(typeof(MinValueConverter))] -public record class MinValue -{ - public object Value { get; private init; } - - public MinValue(string value) - { - Value = value; - } - - public MinValue(double value) - { - Value = value; - } - - MinValue(UnknownVariant value) - { - Value = value; - } - - public static MinValue CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public void Switch(System::Action @string, System::Action @double) - { - switch (this.Value) - { - case string value: - @string(value); - break; - case double value: - @double(value); - break; - default: - throw new ImageKitInvalidDataException( - "Data did not match any variant of MinValue" - ); - } - } - - public T Match(System::Func @string, System::Func @double) - { - return this.Value switch - { - string value => @string(value), - double value => @double(value), - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of MinValue" - ), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of MinValue"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class MinValueConverter : JsonConverter -{ - public override MinValue? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new MinValue(deserialized); - } - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'string'", e) - ); - } - - try - { - return new MinValue(JsonSerializer.Deserialize(ref reader, options)); - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'double'", e) - ); - } - - throw new System::AggregateException(exceptions); - } - - public override void Write(Utf8JsonWriter writer, MinValue value, JsonSerializerOptions options) - { - object variant = value.Value; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs deleted file mode 100644 index 6c7e8220..00000000 --- a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs +++ /dev/null @@ -1,171 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; - -[JsonConverter(typeof(SelectOptionConverter))] -public record class SelectOption -{ - public object Value { get; private init; } - - public SelectOption(string value) - { - Value = value; - } - - public SelectOption(double value) - { - Value = value; - } - - public SelectOption(bool value) - { - Value = value; - } - - SelectOption(UnknownVariant value) - { - Value = value; - } - - public static SelectOption CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public bool TryPickBool([NotNullWhen(true)] out bool? value) - { - value = this.Value as bool?; - return value != null; - } - - public void Switch( - System::Action @string, - System::Action @double, - System::Action @bool - ) - { - switch (this.Value) - { - case string value: - @string(value); - break; - case double value: - @double(value); - break; - case bool value: - @bool(value); - break; - default: - throw new ImageKitInvalidDataException( - "Data did not match any variant of SelectOption" - ); - } - } - - public T Match( - System::Func @string, - System::Func @double, - System::Func @bool - ) - { - return this.Value switch - { - string value => @string(value), - double value => @double(value), - bool value => @bool(value), - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of SelectOption" - ), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException( - "Data did not match any variant of SelectOption" - ); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class SelectOptionConverter : JsonConverter -{ - public override SelectOption? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new SelectOption(deserialized); - } - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'string'", e) - ); - } - - try - { - return new SelectOption(JsonSerializer.Deserialize(ref reader, options)); - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'double'", e) - ); - } - - try - { - return new SelectOption(JsonSerializer.Deserialize(ref reader, options)); - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'bool'", e) - ); - } - - throw new System::AggregateException(exceptions); - } - - public override void Write( - Utf8JsonWriter writer, - SelectOption value, - JsonSerializerOptions options - ) - { - object variant = value.Value; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs b/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs deleted file mode 100644 index 6c435de6..00000000 --- a/src/Imagekit/Models/Files/FileProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; - -/// -/// Type of the custom metadata field. -/// -[JsonConverter( - typeof(global::Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.TypeConverter) -)] -public enum Type -{ - Text, - Textarea, - Number, - Date, - Boolean, - SingleSelect, - MultiSelect, -} - -sealed class TypeConverter - : JsonConverter -{ - public override global::Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.Type Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "Text" => SelectedFieldsSchemaItemProperties.Type.Text, - "Textarea" => SelectedFieldsSchemaItemProperties.Type.Textarea, - "Number" => SelectedFieldsSchemaItemProperties.Type.Number, - "Date" => SelectedFieldsSchemaItemProperties.Type.Date, - "Boolean" => SelectedFieldsSchemaItemProperties.Type.Boolean, - "SingleSelect" => SelectedFieldsSchemaItemProperties.Type.SingleSelect, - "MultiSelect" => SelectedFieldsSchemaItemProperties.Type.MultiSelect, - _ => - (global::Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.Type)( - -1 - ), - }; - } - - public override void Write( - Utf8JsonWriter writer, - global::Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.Type value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - SelectedFieldsSchemaItemProperties.Type.Text => "Text", - SelectedFieldsSchemaItemProperties.Type.Textarea => "Textarea", - SelectedFieldsSchemaItemProperties.Type.Number => "Number", - SelectedFieldsSchemaItemProperties.Type.Date => "Date", - SelectedFieldsSchemaItemProperties.Type.Boolean => "Boolean", - SelectedFieldsSchemaItemProperties.Type.SingleSelect => "SingleSelect", - SelectedFieldsSchemaItemProperties.Type.MultiSelect => "MultiSelect", - _ => throw new ImageKitInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Files/FileProperties/Type.cs b/src/Imagekit/Models/Files/FileProperties/Type.cs deleted file mode 100644 index 6062c976..00000000 --- a/src/Imagekit/Models/Files/FileProperties/Type.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using System = System; - -namespace Imagekit.Models.Files.FileProperties; - -/// -/// Type of the asset. -/// -[JsonConverter(typeof(TypeConverter))] -public enum Type -{ - File, - FileVersion, -} - -sealed class TypeConverter : JsonConverter -{ - public override Type Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "file" => FileProperties.Type.File, - "file-version" => FileProperties.Type.FileVersion, - _ => (Type)(-1), - }; - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonSerializer.Serialize( - writer, - value switch - { - FileProperties.Type.File => "file", - FileProperties.Type.FileVersion => "file-version", - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Files/FileProperties/VersionInfo.cs b/src/Imagekit/Models/Files/FileProperties/VersionInfo.cs deleted file mode 100644 index 48e2faf5..00000000 --- a/src/Imagekit/Models/Files/FileProperties/VersionInfo.cs +++ /dev/null @@ -1,76 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files.FileProperties; - -/// -/// An object with details of the file version. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class VersionInfo : ModelBase, IFromRaw -{ - /// - /// Unique identifier of the file version. - /// - public string? ID - { - get - { - if (!this.Properties.TryGetValue("id", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["id"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Name of the file version. - /// - public string? Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.ID; - _ = this.Name; - } - - public VersionInfo() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - VersionInfo(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static VersionInfo FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/FileRenameParams.cs b/src/Imagekit/Models/Files/FileRenameParams.cs deleted file mode 100644 index a0b6121b..00000000 --- a/src/Imagekit/Models/Files/FileRenameParams.cs +++ /dev/null @@ -1,129 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Net.Http; -using System.Text; -using System.Text.Json; - -namespace Imagekit.Models.Files; - -/// -/// You can rename an already existing file in the media library using rename file -/// API. This operation would rename all file versions of the file. -/// -/// Note: The old URLs will stop working. The file/file version URLs cached on CDN -/// will continue to work unless a purge is requested. -/// -public sealed record class FileRenameParams : ParamsBase -{ - public Dictionary BodyProperties { get; set; } = []; - - /// - /// The full path of the file you want to rename. - /// - public required string FilePath - { - get - { - if (!this.BodyProperties.TryGetValue("filePath", out JsonElement element)) - throw new ArgumentOutOfRangeException("filePath", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("filePath"); - } - set - { - this.BodyProperties["filePath"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The new name of the file. A filename can contain: - /// - /// Alphanumeric Characters: `a-z`, `A-Z`, `0-9` (including Unicode letters, marks, - /// and numerals in other languages). Special Characters: `.`, `_`, and `-`. - /// - /// Any other character, including space, will be replaced by `_`. - /// - public required string NewFileName - { - get - { - if (!this.BodyProperties.TryGetValue("newFileName", out JsonElement element)) - throw new ArgumentOutOfRangeException("newFileName", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("newFileName"); - } - set - { - this.BodyProperties["newFileName"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Option to purge cache for the old file and its versions' URLs. - /// - /// When set to true, it will internally issue a purge cache request on CDN to - /// remove cached content of old file and its versions. This purge request is - /// counted against your monthly purge quota. - /// - /// Note: If the old file were accessible at `https://ik.imagekit.io/demo/old-filename.jpg`, - /// a purge cache request would be issued against `https://ik.imagekit.io/demo/old-filename.jpg*` - /// (with a wildcard at the end). It will remove the file and its versions' URLs - /// and any transformations made using query parameters on this file or its versions. - /// However, the cache for file transformations made using path parameters will - /// persist. You can purge them using the purge API. For more details, refer to - /// the purge API documentation. - /// - /// Default value - `false` - /// - public bool? PurgeCache - { - get - { - if (!this.BodyProperties.TryGetValue("purgeCache", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["purgeCache"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override Uri Url(IImageKitClient client) - { - return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/files/rename") - { - Query = this.QueryString(client), - }.Uri; - } - - public StringContent BodyContent() - { - return new( - JsonSerializer.Serialize(this.BodyProperties), - Encoding.UTF8, - "application/json" - ); - } - - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} diff --git a/src/Imagekit/Models/Files/FileRenameResponse.cs b/src/Imagekit/Models/Files/FileRenameResponse.cs deleted file mode 100644 index 29001165..00000000 --- a/src/Imagekit/Models/Files/FileRenameResponse.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class FileRenameResponse : ModelBase, IFromRaw -{ - /// - /// Unique identifier of the purge request. This can be used to check the status - /// of the purge request. - /// - public string? PurgeRequestID - { - get - { - if (!this.Properties.TryGetValue("purgeRequestId", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["purgeRequestId"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.PurgeRequestID; - } - - public FileRenameResponse() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - FileRenameResponse(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static FileRenameResponse FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/FileUpdateParams.cs b/src/Imagekit/Models/Files/FileUpdateParams.cs deleted file mode 100644 index eb48f23f..00000000 --- a/src/Imagekit/Models/Files/FileUpdateParams.cs +++ /dev/null @@ -1,67 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Net.Http; -using System.Text; -using System.Text.Json; -using Imagekit.Models.Files.FileUpdateParamsProperties; - -namespace Imagekit.Models.Files; - -/// -/// This API updates the details or attributes of the current version of the file. -/// You can update `tags`, `customCoordinates`, `customMetadata`, publication status, -/// remove existing `AITags` and apply extensions using this API. -/// -public sealed record class FileUpdateParams : ParamsBase -{ - public Dictionary BodyProperties { get; set; } = []; - - public required string FileID; - - public Update? Update - { - get - { - if (!this.BodyProperties.TryGetValue("update", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["update"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override Uri Url(IImageKitClient client) - { - return new UriBuilder( - client.BaseUrl.ToString().TrimEnd('/') - + string.Format("/v1/files/{0}/details", this.FileID) - ) - { - Query = this.QueryString(client), - }.Uri; - } - - internal override StringContent? BodyContent() - { - return new( - JsonSerializer.Serialize(this.BodyProperties), - Encoding.UTF8, - "application/json" - ); - } - - internal override void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} diff --git a/src/Imagekit/Models/Files/FileUpdateParamsProperties/Update.cs b/src/Imagekit/Models/Files/FileUpdateParamsProperties/Update.cs deleted file mode 100644 index 2e507646..00000000 --- a/src/Imagekit/Models/Files/FileUpdateParamsProperties/Update.cs +++ /dev/null @@ -1,123 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Files.FileUpdateParamsProperties.UpdateProperties; -using UpdateVariants = Imagekit.Models.Files.FileUpdateParamsProperties.UpdateVariants; - -namespace Imagekit.Models.Files.FileUpdateParamsProperties; - -[JsonConverter(typeof(UpdateConverter))] -public abstract record class Update -{ - internal Update() { } - - public static implicit operator Update(UpdateFileDetails value) => - new UpdateVariants::UpdateFileDetails(value); - - public static implicit operator Update(ChangePublicationStatus value) => - new UpdateVariants::ChangePublicationStatus(value); - - public bool TryPickFileDetails([NotNullWhen(true)] out UpdateFileDetails? value) - { - value = (this as UpdateVariants::UpdateFileDetails)?.Value; - return value != null; - } - - public bool TryPickChangePublicationStatus( - [NotNullWhen(true)] out ChangePublicationStatus? value - ) - { - value = (this as UpdateVariants::ChangePublicationStatus)?.Value; - return value != null; - } - - public void Switch( - Action fileDetails, - Action changePublicationStatus - ) - { - switch (this) - { - case UpdateVariants::UpdateFileDetails inner: - fileDetails(inner); - break; - case UpdateVariants::ChangePublicationStatus inner: - changePublicationStatus(inner); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match( - Func fileDetails, - Func changePublicationStatus - ) - { - return this switch - { - UpdateVariants::UpdateFileDetails inner => fileDetails(inner), - UpdateVariants::ChangePublicationStatus inner => changePublicationStatus(inner), - _ => throw new InvalidOperationException(), - }; - } - - public abstract void Validate(); -} - -sealed class UpdateConverter : JsonConverter -{ - public override Update? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new UpdateVariants::UpdateFileDetails(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - try - { - var deserialized = JsonSerializer.Deserialize( - ref reader, - options - ); - if (deserialized != null) - { - return new UpdateVariants::ChangePublicationStatus(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - - public override void Write(Utf8JsonWriter writer, Update value, JsonSerializerOptions options) - { - object variant = value switch - { - UpdateVariants::UpdateFileDetails(var fileDetails) => fileDetails, - UpdateVariants::ChangePublicationStatus(var changePublicationStatus) => - changePublicationStatus, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateVariants/All.cs b/src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateVariants/All.cs deleted file mode 100644 index aea0129a..00000000 --- a/src/Imagekit/Models/Files/FileUpdateParamsProperties/UpdateVariants/All.cs +++ /dev/null @@ -1,33 +0,0 @@ -using UpdateProperties = Imagekit.Models.Files.FileUpdateParamsProperties.UpdateProperties; - -namespace Imagekit.Models.Files.FileUpdateParamsProperties.UpdateVariants; - -public sealed record class UpdateFileDetails(UpdateProperties::UpdateFileDetails Value) - : Update, - IVariant -{ - public static UpdateFileDetails From(UpdateProperties::UpdateFileDetails value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class ChangePublicationStatus(UpdateProperties::ChangePublicationStatus Value) - : Update, - IVariant -{ - public static ChangePublicationStatus From(UpdateProperties::ChangePublicationStatus value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} diff --git a/src/Imagekit/Models/Files/FileUpdateResponse.cs b/src/Imagekit/Models/Files/FileUpdateResponse.cs deleted file mode 100644 index ba6c7ca7..00000000 --- a/src/Imagekit/Models/Files/FileUpdateResponse.cs +++ /dev/null @@ -1,631 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Core; -using Imagekit.Models.Files.FileProperties.SelectedFieldsSchemaProperties; -using Imagekit.Models.Files.FileUpdateResponseProperties.IntersectionMember1Properties; -using FileProperties = Imagekit.Models.Files.FileProperties; - -namespace Imagekit.Models.Files; - -/// -/// Object containing details of a file or file version. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class FileUpdateResponse : ModelBase, IFromRaw -{ - /// - /// An array of tags assigned to the file by auto tagging. - /// - public List? AITags - { - get - { - if (!this.Properties.TryGetValue("AITags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["AITags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Date and time when the file was uploaded. The date and time is in ISO8601 - /// format. - /// - public DateTime? CreatedAt - { - get - { - if (!this.Properties.TryGetValue("createdAt", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["createdAt"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// An string with custom coordinates of the file. - /// - public string? CustomCoordinates - { - get - { - if (!this.Properties.TryGetValue("customCoordinates", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["customCoordinates"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// An object with custom metadata for the file. - /// - public Dictionary? CustomMetadata - { - get - { - if (!this.Properties.TryGetValue("customMetadata", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["customMetadata"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Optional text to describe the contents of the file. Can be set by the user - /// or the ai-auto-description extension. - /// - public string? Description - { - get - { - if (!this.Properties.TryGetValue("description", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["description"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Unique identifier of the asset. - /// - public string? FileID - { - get - { - if (!this.Properties.TryGetValue("fileId", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["fileId"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Path of the file. This is the path you would use in the URL to access the - /// file. For example, if the file is at the root of the media library, the path - /// will be `/file.jpg`. If the file is inside a folder named `images`, the path - /// will be `/images/file.jpg`. - /// - public string? FilePath - { - get - { - if (!this.Properties.TryGetValue("filePath", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["filePath"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Type of the file. Possible values are `image`, `non-image`. - /// - public string? FileType - { - get - { - if (!this.Properties.TryGetValue("fileType", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["fileType"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies if the image has an alpha channel. - /// - public bool? HasAlpha - { - get - { - if (!this.Properties.TryGetValue("hasAlpha", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["hasAlpha"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Height of the file. - /// - public double? Height - { - get - { - if (!this.Properties.TryGetValue("height", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["height"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies if the file is private or not. - /// - public bool? IsPrivateFile - { - get - { - if (!this.Properties.TryGetValue("isPrivateFile", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["isPrivateFile"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies if the file is published or not. - /// - public bool? IsPublished - { - get - { - if (!this.Properties.TryGetValue("isPublished", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["isPublished"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// MIME type of the file. - /// - public string? Mime - { - get - { - if (!this.Properties.TryGetValue("mime", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["mime"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Name of the asset. - /// - public string? Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// This field is included in the response only if the Path policy feature is - /// available in the plan. It contains schema definitions for the custom metadata - /// fields selected for the specified file path. Field selection can only be done - /// when the Path policy feature is enabled. - /// - /// Keys are the names of the custom metadata fields; the value object has details - /// about the custom metadata schema. - /// - public Dictionary? SelectedFieldsSchema - { - get - { - if (!this.Properties.TryGetValue("selectedFieldsSchema", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["selectedFieldsSchema"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Size of the file in bytes. - /// - public double? Size - { - get - { - if (!this.Properties.TryGetValue("size", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["size"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// An array of tags assigned to the file. Tags are used to search files in the - /// media library. - /// - public List? Tags - { - get - { - if (!this.Properties.TryGetValue("tags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["tags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// URL of the thumbnail image. This URL is used to access the thumbnail image - /// of the file in the media library. - /// - public string? Thumbnail - { - get - { - if (!this.Properties.TryGetValue("thumbnail", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["thumbnail"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Type of the asset. - /// - public ApiEnum? Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Date and time when the file was last updated. The date and time is in ISO8601 - /// format. - /// - public DateTime? UpdatedAt - { - get - { - if (!this.Properties.TryGetValue("updatedAt", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["updatedAt"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// URL of the file. - /// - public string? URL - { - get - { - if (!this.Properties.TryGetValue("url", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["url"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// An object with details of the file version. - /// - public FileProperties::VersionInfo? VersionInfo - { - get - { - if (!this.Properties.TryGetValue("versionInfo", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["versionInfo"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Width of the file. - /// - public double? Width - { - get - { - if (!this.Properties.TryGetValue("width", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["width"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public ExtensionStatus? ExtensionStatus - { - get - { - if (!this.Properties.TryGetValue("extensionStatus", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["extensionStatus"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public static implicit operator File(FileUpdateResponse fileUpdateResponse) => - new() - { - AITags = fileUpdateResponse.AITags, - CreatedAt = fileUpdateResponse.CreatedAt, - CustomCoordinates = fileUpdateResponse.CustomCoordinates, - CustomMetadata = fileUpdateResponse.CustomMetadata, - Description = fileUpdateResponse.Description, - FileID = fileUpdateResponse.FileID, - FilePath = fileUpdateResponse.FilePath, - FileType = fileUpdateResponse.FileType, - HasAlpha = fileUpdateResponse.HasAlpha, - Height = fileUpdateResponse.Height, - IsPrivateFile = fileUpdateResponse.IsPrivateFile, - IsPublished = fileUpdateResponse.IsPublished, - Mime = fileUpdateResponse.Mime, - Name = fileUpdateResponse.Name, - SelectedFieldsSchema = fileUpdateResponse.SelectedFieldsSchema, - Size = fileUpdateResponse.Size, - Tags = fileUpdateResponse.Tags, - Thumbnail = fileUpdateResponse.Thumbnail, - Type = fileUpdateResponse.Type, - UpdatedAt = fileUpdateResponse.UpdatedAt, - URL = fileUpdateResponse.URL, - VersionInfo = fileUpdateResponse.VersionInfo, - Width = fileUpdateResponse.Width, - }; - - public override void Validate() - { - foreach (var item in this.AITags ?? []) - { - item.Validate(); - } - _ = this.CreatedAt; - _ = this.CustomCoordinates; - _ = this.CustomMetadata; - _ = this.Description; - _ = this.FileID; - _ = this.FilePath; - _ = this.FileType; - _ = this.HasAlpha; - _ = this.Height; - _ = this.IsPrivateFile; - _ = this.IsPublished; - _ = this.Mime; - _ = this.Name; - if (this.SelectedFieldsSchema != null) - { - foreach (var item in this.SelectedFieldsSchema.Values) - { - item.Validate(); - } - } - _ = this.Size; - _ = this.Tags; - _ = this.Thumbnail; - this.Type?.Validate(); - _ = this.UpdatedAt; - _ = this.URL; - this.VersionInfo?.Validate(); - _ = this.Width; - this.ExtensionStatus?.Validate(); - } - - public FileUpdateResponse() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - FileUpdateResponse(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static FileUpdateResponse FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/FileUpdateResponseProperties/IntersectionMember1.cs b/src/Imagekit/Models/Files/FileUpdateResponseProperties/IntersectionMember1.cs deleted file mode 100644 index 18f1f617..00000000 --- a/src/Imagekit/Models/Files/FileUpdateResponseProperties/IntersectionMember1.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Files.FileUpdateResponseProperties.IntersectionMember1Properties; - -namespace Imagekit.Models.Files.FileUpdateResponseProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class IntersectionMember1 : ModelBase, IFromRaw -{ - public ExtensionStatus? ExtensionStatus - { - get - { - if (!this.Properties.TryGetValue("extensionStatus", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["extensionStatus"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.ExtensionStatus?.Validate(); - } - - public IntersectionMember1() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - IntersectionMember1(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static IntersectionMember1 FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/FileUpdateResponseProperties/IntersectionMember1Properties/ExtensionStatus.cs b/src/Imagekit/Models/Files/FileUpdateResponseProperties/IntersectionMember1Properties/ExtensionStatus.cs deleted file mode 100644 index c540e9b8..00000000 --- a/src/Imagekit/Models/Files/FileUpdateResponseProperties/IntersectionMember1Properties/ExtensionStatus.cs +++ /dev/null @@ -1,118 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Files.FileUpdateResponseProperties.IntersectionMember1Properties.ExtensionStatusProperties; - -namespace Imagekit.Models.Files.FileUpdateResponseProperties.IntersectionMember1Properties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class ExtensionStatus : ModelBase, IFromRaw -{ - public ApiEnum? AIAutoDescription - { - get - { - if (!this.Properties.TryGetValue("ai-auto-description", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["ai-auto-description"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public ApiEnum? AwsAutoTagging - { - get - { - if (!this.Properties.TryGetValue("aws-auto-tagging", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["aws-auto-tagging"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public ApiEnum? GoogleAutoTagging - { - get - { - if (!this.Properties.TryGetValue("google-auto-tagging", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["google-auto-tagging"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public ApiEnum? RemoveBg - { - get - { - if (!this.Properties.TryGetValue("remove-bg", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["remove-bg"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.AIAutoDescription?.Validate(); - this.AwsAutoTagging?.Validate(); - this.GoogleAutoTagging?.Validate(); - this.RemoveBg?.Validate(); - } - - public ExtensionStatus() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - ExtensionStatus(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static ExtensionStatus FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/FileUpdateResponseProperties/IntersectionMember1Properties/ExtensionStatusProperties/AIAutoDescription.cs b/src/Imagekit/Models/Files/FileUpdateResponseProperties/IntersectionMember1Properties/ExtensionStatusProperties/AIAutoDescription.cs deleted file mode 100644 index 5411f57f..00000000 --- a/src/Imagekit/Models/Files/FileUpdateResponseProperties/IntersectionMember1Properties/ExtensionStatusProperties/AIAutoDescription.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files.FileUpdateResponseProperties.IntersectionMember1Properties.ExtensionStatusProperties; - -[JsonConverter(typeof(AIAutoDescriptionConverter))] -public enum AIAutoDescription -{ - Success, - Pending, - Failed, -} - -sealed class AIAutoDescriptionConverter : JsonConverter -{ - public override AIAutoDescription Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "success" => AIAutoDescription.Success, - "pending" => AIAutoDescription.Pending, - "failed" => AIAutoDescription.Failed, - _ => (AIAutoDescription)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - AIAutoDescription value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - AIAutoDescription.Success => "success", - AIAutoDescription.Pending => "pending", - AIAutoDescription.Failed => "failed", - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Files/FileUpdateResponseProperties/IntersectionMember1Properties/ExtensionStatusProperties/AwsAutoTagging.cs b/src/Imagekit/Models/Files/FileUpdateResponseProperties/IntersectionMember1Properties/ExtensionStatusProperties/AwsAutoTagging.cs deleted file mode 100644 index 4e795b7b..00000000 --- a/src/Imagekit/Models/Files/FileUpdateResponseProperties/IntersectionMember1Properties/ExtensionStatusProperties/AwsAutoTagging.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files.FileUpdateResponseProperties.IntersectionMember1Properties.ExtensionStatusProperties; - -[JsonConverter(typeof(AwsAutoTaggingConverter))] -public enum AwsAutoTagging -{ - Success, - Pending, - Failed, -} - -sealed class AwsAutoTaggingConverter : JsonConverter -{ - public override AwsAutoTagging Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "success" => AwsAutoTagging.Success, - "pending" => AwsAutoTagging.Pending, - "failed" => AwsAutoTagging.Failed, - _ => (AwsAutoTagging)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - AwsAutoTagging value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - AwsAutoTagging.Success => "success", - AwsAutoTagging.Pending => "pending", - AwsAutoTagging.Failed => "failed", - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Files/FileUpdateResponseProperties/IntersectionMember1Properties/ExtensionStatusProperties/GoogleAutoTagging.cs b/src/Imagekit/Models/Files/FileUpdateResponseProperties/IntersectionMember1Properties/ExtensionStatusProperties/GoogleAutoTagging.cs deleted file mode 100644 index 98e402cc..00000000 --- a/src/Imagekit/Models/Files/FileUpdateResponseProperties/IntersectionMember1Properties/ExtensionStatusProperties/GoogleAutoTagging.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files.FileUpdateResponseProperties.IntersectionMember1Properties.ExtensionStatusProperties; - -[JsonConverter(typeof(GoogleAutoTaggingConverter))] -public enum GoogleAutoTagging -{ - Success, - Pending, - Failed, -} - -sealed class GoogleAutoTaggingConverter : JsonConverter -{ - public override GoogleAutoTagging Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "success" => GoogleAutoTagging.Success, - "pending" => GoogleAutoTagging.Pending, - "failed" => GoogleAutoTagging.Failed, - _ => (GoogleAutoTagging)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - GoogleAutoTagging value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - GoogleAutoTagging.Success => "success", - GoogleAutoTagging.Pending => "pending", - GoogleAutoTagging.Failed => "failed", - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Files/FileUpdateResponseProperties/IntersectionMember1Properties/ExtensionStatusProperties/RemoveBg.cs b/src/Imagekit/Models/Files/FileUpdateResponseProperties/IntersectionMember1Properties/ExtensionStatusProperties/RemoveBg.cs deleted file mode 100644 index 6f293e15..00000000 --- a/src/Imagekit/Models/Files/FileUpdateResponseProperties/IntersectionMember1Properties/ExtensionStatusProperties/RemoveBg.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files.FileUpdateResponseProperties.IntersectionMember1Properties.ExtensionStatusProperties; - -[JsonConverter(typeof(RemoveBgConverter))] -public enum RemoveBg -{ - Success, - Pending, - Failed, -} - -sealed class RemoveBgConverter : JsonConverter -{ - public override RemoveBg Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "success" => RemoveBg.Success, - "pending" => RemoveBg.Pending, - "failed" => RemoveBg.Failed, - _ => (RemoveBg)(-1), - }; - } - - public override void Write(Utf8JsonWriter writer, RemoveBg value, JsonSerializerOptions options) - { - JsonSerializer.Serialize( - writer, - value switch - { - RemoveBg.Success => "success", - RemoveBg.Pending => "pending", - RemoveBg.Failed => "failed", - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParams.cs b/src/Imagekit/Models/Files/FileUploadParams.cs deleted file mode 100644 index 3be2d945..00000000 --- a/src/Imagekit/Models/Files/FileUploadParams.cs +++ /dev/null @@ -1,652 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Net.Http; -using System.Text; -using System.Text.Json; -using Imagekit.Core; -using Imagekit.Exceptions; -using FileUploadParamsProperties = Imagekit.Models.Files.FileUploadParamsProperties; - -namespace Imagekit.Models.Files; - -/// -/// ImageKit.io allows you to upload files directly from both the server and client -/// sides. For server-side uploads, private API key authentication is used. For client-side -/// uploads, generate a one-time `token`, `signature`, and `expire` from your secure -/// backend using private API. [Learn more](/docs/api-reference/upload-file/upload-file#how-to-implement-client-side-file-upload) -/// about how to implement client-side file upload. -/// -/// The [V2 API](/docs/api-reference/upload-file/upload-file-v2) enhances security -/// by verifying the entire payload using JWT. -/// -/// **File size limit** \ On the free plan, the maximum upload file sizes are 20MB -/// for images, audio, and raw files and 100MB for videos. On the paid plan, these -/// limits increase to 40MB for images, audio, and raw files and 2GB for videos. These -/// limits can be further increased with higher-tier plans. -/// -/// **Version limit** \ A file can have a maximum of 100 versions. -/// -/// **Demo applications** -/// -/// - A full-fledged [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), -/// supporting file selections from local storage, URL, Dropbox, Google Drive, Instagram, -/// and more. - [Quick start guides](/docs/quick-start-guides) for various frameworks -/// and technologies. -/// -public sealed record class FileUploadParams : ParamsBase -{ - public Dictionary BodyProperties { get; set; } = []; - - /// - /// The API accepts any of the following: - /// - /// - **Binary data** – send the raw bytes as `multipart/form-data`. - **HTTP - /// / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. - /// - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. - /// - /// When supplying a URL, the server must receive the response headers within - /// 8 seconds; otherwise the request fails with 400 Bad Request. - /// - public required string File - { - get - { - if (!this.BodyProperties.TryGetValue("file", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'file' cannot be null", - new ArgumentOutOfRangeException("file", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'file' cannot be null", - new ArgumentNullException("file") - ); - } - set - { - this.BodyProperties["file"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The name with which the file has to be uploaded. The file name can contain: - /// - /// - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. - Special Characters: - /// `.`, `-` - /// - /// Any other character including space will be replaced by `_` - /// - public required string FileName - { - get - { - if (!this.BodyProperties.TryGetValue("fileName", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'fileName' cannot be null", - new ArgumentOutOfRangeException("fileName", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'fileName' cannot be null", - new ArgumentNullException("fileName") - ); - } - set - { - this.BodyProperties["fileName"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// A unique value that the ImageKit.io server will use to recognize and prevent - /// subsequent retries for the same request. We suggest using V4 UUIDs, or another - /// random string with enough entropy to avoid collisions. This field is only - /// required for authentication when uploading a file from the client side. - /// - /// **Note**: Sending a value that has been used in the past will result in a - /// validation error. Even if your previous request resulted in an error, you - /// should always send a new value for this field. - /// - public string? Token - { - get - { - if (!this.BodyProperties.TryGetValue("token", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["token"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Server-side checks to run on the asset. Read more about [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). - /// - public string? Checks - { - get - { - if (!this.BodyProperties.TryGetValue("checks", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["checks"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Define an important area in the image. This is only relevant for image type files. - /// - /// - To be passed as a string with the x and y coordinates of the top-left - /// corner, and width and height of the area of interest in the format `x,y,width,height`. - /// For example - `10,10,100,100` - Can be used with fo-customtransformation. - /// - If this field is not specified and the file is overwritten, then customCoordinates - /// will be removed. - /// - public string? CustomCoordinates - { - get - { - if (!this.BodyProperties.TryGetValue("customCoordinates", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["customCoordinates"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// JSON key-value pairs to associate with the asset. Create the custom metadata - /// fields before setting these values. - /// - public Dictionary? CustomMetadata - { - get - { - if (!this.BodyProperties.TryGetValue("customMetadata", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.BodyProperties["customMetadata"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Optional text to describe the contents of the file. - /// - public string? Description - { - get - { - if (!this.BodyProperties.TryGetValue("description", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["description"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The time until your signature is valid. It must be a [Unix time](https://en.wikipedia.org/wiki/Unix_time) - /// in less than 1 hour into the future. It should be in seconds. This field is - /// only required for authentication when uploading a file from the client side. - /// - public long? Expire - { - get - { - if (!this.BodyProperties.TryGetValue("expire", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["expire"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Array of extensions to be applied to the asset. Each extension can be configured - /// with specific parameters based on the extension type. - /// - public List? Extensions - { - get - { - if (!this.BodyProperties.TryGetValue("extensions", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.BodyProperties["extensions"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The folder path in which the image has to be uploaded. If the folder(s) didn't - /// exist before, a new folder(s) is created. - /// - /// The folder name can contain: - /// - /// - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` - Special Characters: - /// `/` , `_` , `-` - /// - /// Using multiple `/` creates a nested folder. - /// - public string? Folder - { - get - { - if (!this.BodyProperties.TryGetValue("folder", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["folder"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to mark the file as private or not. - /// - /// If `true`, the file is marked as private and is accessible only using named - /// transformation or signed URL. - /// - public bool? IsPrivateFile - { - get - { - if (!this.BodyProperties.TryGetValue("isPrivateFile", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["isPrivateFile"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to upload file as published or not. - /// - /// If `false`, the file is marked as unpublished, which restricts access to the - /// file only via the media library. Files in draft or unpublished state can only - /// be publicly accessed after being published. - /// - /// The option to upload in draft state is only available in custom enterprise - /// pricing plans. - /// - public bool? IsPublished - { - get - { - if (!this.BodyProperties.TryGetValue("isPublished", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["isPublished"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// If set to `true` and a file already exists at the exact location, its AITags - /// will be removed. Set `overwriteAITags` to `false` to preserve AITags. - /// - public bool? OverwriteAITags - { - get - { - if (!this.BodyProperties.TryGetValue("overwriteAITags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["overwriteAITags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// If the request does not have `customMetadata`, and a file already exists at - /// the exact location, existing customMetadata will be removed. - /// - public bool? OverwriteCustomMetadata - { - get - { - if ( - !this.BodyProperties.TryGetValue("overwriteCustomMetadata", out JsonElement element) - ) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["overwriteCustomMetadata"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// If `false` and `useUniqueFileName` is also `false`, and a file already exists - /// at the exact location, upload API will return an error immediately. - /// - public bool? OverwriteFile - { - get - { - if (!this.BodyProperties.TryGetValue("overwriteFile", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["overwriteFile"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// If the request does not have `tags`, and a file already exists at the exact - /// location, existing tags will be removed. - /// - public bool? OverwriteTags - { - get - { - if (!this.BodyProperties.TryGetValue("overwriteTags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["overwriteTags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Your ImageKit.io public key. This field is only required for authentication - /// when uploading a file from the client side. - /// - public string? PublicKey - { - get - { - if (!this.BodyProperties.TryGetValue("publicKey", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["publicKey"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Array of response field keys to include in the API response body. - /// - public List>? ResponseFields - { - get - { - if (!this.BodyProperties.TryGetValue("responseFields", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize - >?>(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["responseFields"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key - /// as a key. Learn how to create a signature on the page below. This should be - /// in lowercase. - /// - /// Signature must be calculated on the server-side. This field is only required - /// for authentication when uploading a file from the client side. - /// - public string? Signature - { - get - { - if (!this.BodyProperties.TryGetValue("signature", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["signature"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Set the tags while uploading the file. Provide an array of tag strings (e.g. - /// `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must - /// not exceed 500, and the `%` character is not allowed. If this field is not - /// specified and the file is overwritten, the existing tags will be removed. - /// - public List? Tags - { - get - { - if (!this.BodyProperties.TryGetValue("tags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["tags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Configure pre-processing (`pre`) and post-processing (`post`) transformations. - /// - /// - `pre` — applied before the file is uploaded to the Media Library. Useful - /// for reducing file size or applying basic optimizations upfront (e.g., resize, compress). - /// - /// - `post` — applied immediately after upload. Ideal for generating transformed - /// versions (like video encodes or thumbnails) in advance, so they're ready for - /// delivery without delay. - /// - /// You can mix and match any combination of post-processing types. - /// - public FileUploadParamsProperties::Transformation? Transformation - { - get - { - if (!this.BodyProperties.TryGetValue("transformation", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.BodyProperties["transformation"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to use a unique filename for this file or not. - /// - /// If `true`, ImageKit.io will add a unique suffix to the filename parameter - /// to get a unique filename. - /// - /// If `false`, then the image is uploaded with the provided filename parameter, - /// and any existing file with the same name is replaced. - /// - public bool? UseUniqueFileName - { - get - { - if (!this.BodyProperties.TryGetValue("useUniqueFileName", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["useUniqueFileName"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The final status of extensions after they have completed execution will be - /// delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) - /// about the webhook payload structure. - /// - public string? WebhookURL - { - get - { - if (!this.BodyProperties.TryGetValue("webhookUrl", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["webhookUrl"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override Uri Url(IImageKitClient client) - { - return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/api/v1/files/upload") - { - Query = this.QueryString(client), - }.Uri; - } - - internal override StringContent? BodyContent() - { - return new( - JsonSerializer.Serialize(this.BodyProperties), - Encoding.UTF8, - "application/json" - ); - } - - internal override void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/Extension.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/Extension.cs deleted file mode 100644 index aca5f9b4..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/Extension.cs +++ /dev/null @@ -1,177 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Files.FileUploadParamsProperties.ExtensionProperties; -using ExtensionVariants = Imagekit.Models.Files.FileUploadParamsProperties.ExtensionVariants; - -namespace Imagekit.Models.Files.FileUploadParamsProperties; - -[JsonConverter(typeof(ExtensionConverter))] -public abstract record class Extension -{ - internal Extension() { } - - public static implicit operator Extension(RemoveBg value) => - new ExtensionVariants::RemoveBg(value); - - public static implicit operator Extension(AutoTaggingExtension value) => - new ExtensionVariants::AutoTaggingExtension(value); - - public bool TryPickRemoveBg([NotNullWhen(true)] out RemoveBg? value) - { - value = (this as ExtensionVariants::RemoveBg)?.Value; - return value != null; - } - - public bool TryPickAutoTagging([NotNullWhen(true)] out AutoTaggingExtension? value) - { - value = (this as ExtensionVariants::AutoTaggingExtension)?.Value; - return value != null; - } - - public bool TryPickAIAutoDescription([NotNullWhen(true)] out JsonElement? value) - { - value = (this as ExtensionVariants::AIAutoDescription)?.Value; - return value != null; - } - - public void Switch( - Action removeBg, - Action autoTagging, - Action aiAutoDescription - ) - { - switch (this) - { - case ExtensionVariants::RemoveBg inner: - removeBg(inner); - break; - case ExtensionVariants::AutoTaggingExtension inner: - autoTagging(inner); - break; - case ExtensionVariants::AIAutoDescription inner: - aiAutoDescription(inner); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match( - Func removeBg, - Func autoTagging, - Func aiAutoDescription - ) - { - return this switch - { - ExtensionVariants::RemoveBg inner => removeBg(inner), - ExtensionVariants::AutoTaggingExtension inner => autoTagging(inner), - ExtensionVariants::AIAutoDescription inner => aiAutoDescription(inner), - _ => throw new InvalidOperationException(), - }; - } - - public abstract void Validate(); -} - -sealed class ExtensionConverter : JsonConverter -{ - public override Extension? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - var json = JsonSerializer.Deserialize(ref reader, options); - string? name; - try - { - name = json.GetProperty("name").GetString(); - } - catch - { - name = null; - } - - switch (name) - { - case "remove-bg": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - return new ExtensionVariants::RemoveBg(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "ai-auto-description": - { - List exceptions = []; - - try - { - return new ExtensionVariants::AIAutoDescription( - JsonSerializer.Deserialize(json, options) - ); - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - default: - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize( - json, - options - ); - if (deserialized != null) - { - return new ExtensionVariants::AutoTaggingExtension(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - } - } - - public override void Write( - Utf8JsonWriter writer, - Extension value, - JsonSerializerOptions options - ) - { - object variant = value switch - { - ExtensionVariants::RemoveBg(var removeBg) => removeBg, - ExtensionVariants::AutoTaggingExtension(var autoTagging) => autoTagging, - ExtensionVariants::AIAutoDescription(var aiAutoDescription) => aiAutoDescription, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionVariants/All.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionVariants/All.cs deleted file mode 100644 index b312f63e..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/ExtensionVariants/All.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System.Text.Json; -using ExtensionProperties = Imagekit.Models.Files.FileUploadParamsProperties.ExtensionProperties; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.ExtensionVariants; - -public sealed record class RemoveBg(ExtensionProperties::RemoveBg Value) - : Extension, - IVariant -{ - public static RemoveBg From(ExtensionProperties::RemoveBg value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class AutoTaggingExtension(ExtensionProperties::AutoTaggingExtension Value) - : Extension, - IVariant -{ - public static AutoTaggingExtension From(ExtensionProperties::AutoTaggingExtension value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class AIAutoDescription(JsonElement Value) - : Extension, - IVariant -{ - public static AIAutoDescription From(JsonElement value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/ResponseField.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/ResponseField.cs deleted file mode 100644 index ce14903f..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/ResponseField.cs +++ /dev/null @@ -1,68 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; - -namespace Imagekit.Models.Files.FileUploadParamsProperties; - -[JsonConverter(typeof(ResponseFieldConverter))] -public enum ResponseField -{ - Tags, - CustomCoordinates, - IsPrivateFile, - EmbeddedMetadata, - IsPublished, - CustomMetadata, - Metadata, - SelectedFieldsSchema, -} - -sealed class ResponseFieldConverter : JsonConverter -{ - public override ResponseField Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "tags" => ResponseField.Tags, - "customCoordinates" => ResponseField.CustomCoordinates, - "isPrivateFile" => ResponseField.IsPrivateFile, - "embeddedMetadata" => ResponseField.EmbeddedMetadata, - "isPublished" => ResponseField.IsPublished, - "customMetadata" => ResponseField.CustomMetadata, - "metadata" => ResponseField.Metadata, - "selectedFieldsSchema" => ResponseField.SelectedFieldsSchema, - _ => (ResponseField)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - ResponseField value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - ResponseField.Tags => "tags", - ResponseField.CustomCoordinates => "customCoordinates", - ResponseField.IsPrivateFile => "isPrivateFile", - ResponseField.EmbeddedMetadata => "embeddedMetadata", - ResponseField.IsPublished => "isPublished", - ResponseField.CustomMetadata => "customMetadata", - ResponseField.Metadata => "metadata", - ResponseField.SelectedFieldsSchema => "selectedFieldsSchema", - _ => throw new ImageKitInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/Transformation.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/Transformation.cs deleted file mode 100644 index afcbbd0d..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/Transformation.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Core; -using Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties; - -namespace Imagekit.Models.Files.FileUploadParamsProperties; - -/// -/// Configure pre-processing (`pre`) and post-processing (`post`) transformations. -/// -/// - `pre` — applied before the file is uploaded to the Media Library. Useful -/// for reducing file size or applying basic optimizations upfront (e.g., resize, compress). -/// -/// - `post` — applied immediately after upload. Ideal for generating transformed -/// versions (like video encodes or thumbnails) in advance, so they're ready for -/// delivery without delay. -/// -/// You can mix and match any combination of post-processing types. -/// -[JsonConverter( - typeof(ModelConverter) -)] -public sealed record class Transformation - : ModelBase, - IFromRaw -{ - /// - /// List of transformations to apply *after* the file is uploaded. Each item - /// must match one of the following types: `transformation`, `gif-to-video`, - /// `thumbnail`, `abs`. - /// - public List? Post - { - get - { - if (!this.Properties.TryGetValue("post", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["post"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Transformation string to apply before uploading the file to the Media Library. - /// Useful for optimizing files at ingestion. - /// - public string? Pre - { - get - { - if (!this.Properties.TryGetValue("pre", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["pre"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - foreach (var item in this.Post ?? []) - { - item.Validate(); - } - _ = this.Pre; - } - - public Transformation() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Transformation(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static global::Imagekit.Models.Files.FileUploadParamsProperties.Transformation FromRawUnchecked( - Dictionary properties - ) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/Post.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/Post.cs deleted file mode 100644 index 8202b339..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/Post.cs +++ /dev/null @@ -1,268 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using PostProperties = Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties; - -[JsonConverter(typeof(PostConverter))] -public record class Post -{ - public object Value { get; private init; } - - public string? Value1 - { - get - { - return Match( - transformation: (x) => x.Value, - gifToVideo: (x) => x.Value, - thumbnail: (x) => x.Value, - abs: (x) => x.Value - ); - } - } - - public Post(PostProperties::Transformation value) - { - Value = value; - } - - public Post(PostProperties::GifToVideo value) - { - Value = value; - } - - public Post(PostProperties::Thumbnail value) - { - Value = value; - } - - public Post(PostProperties::Abs value) - { - Value = value; - } - - Post(UnknownVariant value) - { - Value = value; - } - - public static Post CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickTransformation([NotNullWhen(true)] out PostProperties::Transformation? value) - { - value = this.Value as PostProperties::Transformation; - return value != null; - } - - public bool TryPickGifToVideo([NotNullWhen(true)] out PostProperties::GifToVideo? value) - { - value = this.Value as PostProperties::GifToVideo; - return value != null; - } - - public bool TryPickThumbnail([NotNullWhen(true)] out PostProperties::Thumbnail? value) - { - value = this.Value as PostProperties::Thumbnail; - return value != null; - } - - public bool TryPickAbs([NotNullWhen(true)] out PostProperties::Abs? value) - { - value = this.Value as PostProperties::Abs; - return value != null; - } - - public void Switch( - Action transformation, - Action gifToVideo, - Action thumbnail, - Action abs - ) - { - switch (this.Value) - { - case PostProperties::Transformation value: - transformation(value); - break; - case PostProperties::GifToVideo value: - gifToVideo(value); - break; - case PostProperties::Thumbnail value: - thumbnail(value); - break; - case PostProperties::Abs value: - abs(value); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match( - Func transformation, - Func gifToVideo, - Func thumbnail, - Func abs - ) - { - return this.Value switch - { - PostVariants::Transformation inner => transformation(inner), - PostVariants::GifToVideo inner => gifToVideo(inner), - PostVariants::Thumbnail inner => thumbnail(inner), - PostVariants::Abs inner => abs(inner), - _ => throw new InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of Post"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class PostConverter : JsonConverter -{ - public override Post? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - var json = JsonSerializer.Deserialize(ref reader, options); - string? type; - try - { - type = json.GetProperty("type").GetString(); - } - catch - { - type = null; - } - - switch (type) - { - case "transformation": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize( - json, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new Post(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "gif-to-video": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize( - json, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new Post(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "thumbnail": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize( - json, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new Post(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "abs": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize( - json, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new Post(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - default: - { - throw new Exception(); - } - } - } - - public override void Write(Utf8JsonWriter writer, Post value, JsonSerializerOptions options) - { - object variant = value switch - { - PostVariants::Transformation(var transformation) => transformation, - PostVariants::GifToVideo(var gifToVideo) => gifToVideo, - PostVariants::Thumbnail(var thumbnail) => thumbnail, - PostVariants::Abs(var abs) => abs, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Abs.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Abs.cs deleted file mode 100644 index d0126436..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Abs.cs +++ /dev/null @@ -1,111 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.AbsProperties; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Abs : ModelBase, IFromRaw -{ - /// - /// Streaming protocol to use (`hls` or `dash`). - /// - public required ApiEnum Protocol - { - get - { - if (!this.Properties.TryGetValue("protocol", out JsonElement element)) - throw new ArgumentOutOfRangeException("protocol", "Missing required argument"); - - return JsonSerializer.Deserialize>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["protocol"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Adaptive Bitrate Streaming (ABS) setup. - /// - public AbsProperties::Type Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ) - ?? throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentNullException("type") - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// List of different representations you want to create separated by an underscore. - /// - public required string Value - { - get - { - if (!this.Properties.TryGetValue("value", out JsonElement element)) - throw new ArgumentOutOfRangeException("value", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("value"); - } - set - { - this.Properties["value"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Protocol.Validate(); - this.Type.Validate(); - _ = this.Value; - } - - public Abs() - { - this.Type = new(); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Abs(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Abs FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs deleted file mode 100644 index 56d80f9f..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/AbsProperties/Protocol.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.AbsProperties; - -/// -/// Streaming protocol to use (`hls` or `dash`). -/// -[JsonConverter(typeof(ProtocolConverter))] -public enum Protocol -{ - Hls, - Dash, -} - -sealed class ProtocolConverter : JsonConverter -{ - public override Protocol Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "hls" => Protocol.Hls, - "dash" => Protocol.Dash, - _ => (Protocol)(-1), - }; - } - - public override void Write(Utf8JsonWriter writer, Protocol value, JsonSerializerOptions options) - { - JsonSerializer.Serialize( - writer, - value switch - { - Protocol.Hls => "hls", - Protocol.Dash => "dash", - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/AbsProperties/Type.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/AbsProperties/Type.cs deleted file mode 100644 index 536187f1..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/AbsProperties/Type.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.AbsProperties; - -/// -/// Adaptive Bitrate Streaming (ABS) setup. -/// -[JsonConverter(typeof(Converter))] -public class Type -{ - public JsonElement Json { get; private init; } - - public Type() - { - Json = JsonSerializer.Deserialize("\"abs\""); - } - - Type(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new Type().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); - } - } - - class Converter : JsonConverter - { - public override Type? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideo.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideo.cs deleted file mode 100644 index 1a2366ec..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideo.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class GifToVideo : ModelBase, IFromRaw -{ - /// - /// Converts an animated GIF into an MP4. - /// - public GifToVideoProperties::Type Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ) - ?? throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentNullException("type") - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Optional transformation string to apply to the output video. **Example**: - /// `q-80` - /// - public string? Value - { - get - { - if (!this.Properties.TryGetValue("value", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["value"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Type.Validate(); - _ = this.Value; - } - - public GifToVideo() - { - this.Type = new(); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - GifToVideo(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static GifToVideo FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideoProperties/Type.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideoProperties/Type.cs deleted file mode 100644 index 84e534fa..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/GifToVideoProperties/Type.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.GifToVideoProperties; - -/// -/// Converts an animated GIF into an MP4. -/// -[JsonConverter(typeof(Converter))] -public class Type -{ - public JsonElement Json { get; private init; } - - public Type() - { - Json = JsonSerializer.Deserialize("\"gif-to-video\""); - } - - Type(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new Type().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); - } - } - - class Converter : JsonConverter - { - public override Type? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Thumbnail.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Thumbnail.cs deleted file mode 100644 index 8f177cb5..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Thumbnail.cs +++ /dev/null @@ -1,84 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Thumbnail : ModelBase, IFromRaw -{ - /// - /// Generates a thumbnail image. - /// - public ThumbnailProperties::Type Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ) - ?? throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentNullException("type") - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Optional transformation string. **Example**: `w-150,h-150` - /// - public string? Value - { - get - { - if (!this.Properties.TryGetValue("value", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["value"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Type.Validate(); - _ = this.Value; - } - - public Thumbnail() - { - this.Type = new(); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Thumbnail(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Thumbnail FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/ThumbnailProperties/Type.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/ThumbnailProperties/Type.cs deleted file mode 100644 index 01486bd3..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/ThumbnailProperties/Type.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.ThumbnailProperties; - -/// -/// Generates a thumbnail image. -/// -[JsonConverter(typeof(Converter))] -public class Type -{ - public JsonElement Json { get; private init; } - - public Type() - { - Json = JsonSerializer.Deserialize("\"thumbnail\""); - } - - Type(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new Type().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); - } - } - - class Converter : JsonConverter - { - public override Type? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Transformation.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Transformation.cs deleted file mode 100644 index 8087d762..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/Transformation.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; - -[JsonConverter( - typeof(ModelConverter) -)] -public sealed record class Transformation - : ModelBase, - IFromRaw -{ - /// - /// Transformation type. - /// - public TransformationProperties::Type Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ) - ?? throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentNullException("type") - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Transformation string (e.g. `w-200,h-200`). Same syntax as ImageKit URL-based - /// transformations. - /// - public required string Value - { - get - { - if (!this.Properties.TryGetValue("value", out JsonElement element)) - throw new ArgumentOutOfRangeException("value", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("value"); - } - set - { - this.Properties["value"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Type.Validate(); - _ = this.Value; - } - - public Transformation() - { - this.Type = new(); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Transformation(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static global::Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.Transformation FromRawUnchecked( - Dictionary properties - ) - { - return new(properties); - } - - [SetsRequiredMembers] - public Transformation(string value) - : this() - { - this.Value = value; - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/TransformationProperties/Type.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/TransformationProperties/Type.cs deleted file mode 100644 index 0ed32429..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostProperties/TransformationProperties/Type.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties.TransformationProperties; - -/// -/// Transformation type. -/// -[JsonConverter(typeof(Converter))] -public class Type -{ - public JsonElement Json { get; private init; } - - public Type() - { - Json = JsonSerializer.Deserialize("\"transformation\""); - } - - Type(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new Type().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'Type'"); - } - } - - class Converter : JsonConverter - { - public override Type? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostVariants/All.cs b/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostVariants/All.cs deleted file mode 100644 index ae864596..00000000 --- a/src/Imagekit/Models/Files/FileUploadParamsProperties/TransformationProperties/PostVariants/All.cs +++ /dev/null @@ -1,61 +0,0 @@ -using PostProperties = Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostProperties; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.TransformationProperties.PostVariants; - -public sealed record class Transformation(PostProperties::Transformation Value) - : Post, - IVariant -{ - public static Transformation From(PostProperties::Transformation value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class GifToVideo(PostProperties::GifToVideo Value) - : Post, - IVariant -{ - public static GifToVideo From(PostProperties::GifToVideo value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class Thumbnail(PostProperties::Thumbnail Value) - : Post, - IVariant -{ - public static Thumbnail From(PostProperties::Thumbnail value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class Abs(PostProperties::Abs Value) : Post, IVariant -{ - public static Abs From(PostProperties::Abs value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadResponse.cs b/src/Imagekit/Models/Files/FileUploadResponse.cs deleted file mode 100644 index 9439aecd..00000000 --- a/src/Imagekit/Models/Files/FileUploadResponse.cs +++ /dev/null @@ -1,636 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Core; -using Imagekit.Models.Files.FileUploadResponseProperties; -using Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties; - -namespace Imagekit.Models.Files; - -/// -/// Object containing details of a successful upload. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class FileUploadResponse : ModelBase, IFromRaw -{ - /// - /// An array of tags assigned to the uploaded file by auto tagging. - /// - public List? AITags - { - get - { - if (!this.Properties.TryGetValue("AITags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["AITags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The audio codec used in the video (only for video). - /// - public string? AudioCodec - { - get - { - if (!this.Properties.TryGetValue("audioCodec", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["audioCodec"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The bit rate of the video in kbps (only for video). - /// - public long? BitRate - { - get - { - if (!this.Properties.TryGetValue("bitRate", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["bitRate"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Value of custom coordinates associated with the image in the format `x,y,width,height`. - /// If `customCoordinates` are not defined, then it is `null`. Send `customCoordinates` - /// in `responseFields` in API request to get the value of this field. - /// - public string? CustomCoordinates - { - get - { - if (!this.Properties.TryGetValue("customCoordinates", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["customCoordinates"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// A key-value data associated with the asset. Use `responseField` in API request - /// to get `customMetadata` in the upload API response. Before setting any custom - /// metadata on an asset, you have to create the field using custom metadata - /// fields API. Send `customMetadata` in `responseFields` in API request to get - /// the value of this field. - /// - public Dictionary? CustomMetadata - { - get - { - if (!this.Properties.TryGetValue("customMetadata", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["customMetadata"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Optional text to describe the contents of the file. Can be set by the user - /// or the ai-auto-description extension. - /// - public string? Description - { - get - { - if (!this.Properties.TryGetValue("description", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["description"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The duration of the video in seconds (only for video). - /// - public long? Duration - { - get - { - if (!this.Properties.TryGetValue("duration", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["duration"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Consolidated embedded metadata associated with the file. It includes exif, - /// iptc, and xmp data. Send `embeddedMetadata` in `responseFields` in API request - /// to get embeddedMetadata in the upload API response. - /// - public Dictionary? EmbeddedMetadata - { - get - { - if (!this.Properties.TryGetValue("embeddedMetadata", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["embeddedMetadata"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Extension names with their processing status at the time of completion of - /// the request. It could have one of the following status values: - /// - /// `success`: The extension has been successfully applied. `failed`: The extension - /// has failed and will not be retried. `pending`: The extension will finish processing - /// in some time. On completion, the final status (success / failed) will be sent - /// to the `webhookUrl` provided. - /// - /// If no extension was requested, then this parameter is not returned. - /// - public ExtensionStatus? ExtensionStatus - { - get - { - if (!this.Properties.TryGetValue("extensionStatus", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["extensionStatus"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Unique fileId. Store this fileld in your database, as this will be used to - /// perform update action on this file. - /// - public string? FileID - { - get - { - if (!this.Properties.TryGetValue("fileId", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["fileId"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The relative path of the file in the media library e.g. `/marketing-assets/new-banner.jpg`. - /// - public string? FilePath - { - get - { - if (!this.Properties.TryGetValue("filePath", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["filePath"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Type of the uploaded file. Possible values are `image`, `non-image`. - /// - public string? FileType - { - get - { - if (!this.Properties.TryGetValue("fileType", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["fileType"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Height of the image in pixels (Only for images) - /// - public double? Height - { - get - { - if (!this.Properties.TryGetValue("height", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["height"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Is the file marked as private. It can be either `true` or `false`. Send `isPrivateFile` - /// in `responseFields` in API request to get the value of this field. - /// - public bool? IsPrivateFile - { - get - { - if (!this.Properties.TryGetValue("isPrivateFile", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["isPrivateFile"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Is the file published or in draft state. It can be either `true` or `false`. - /// Send `isPublished` in `responseFields` in API request to get the value of - /// this field. - /// - public bool? IsPublished - { - get - { - if (!this.Properties.TryGetValue("isPublished", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["isPublished"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Legacy metadata. Send `metadata` in `responseFields` in API request to get - /// metadata in the upload API response. - /// - public Metadata? Metadata - { - get - { - if (!this.Properties.TryGetValue("metadata", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["metadata"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Name of the asset. - /// - public string? Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// This field is included in the response only if the Path policy feature is - /// available in the plan. It contains schema definitions for the custom metadata - /// fields selected for the specified file path. Field selection can only be done - /// when the Path policy feature is enabled. - /// - /// Keys are the names of the custom metadata fields; the value object has details - /// about the custom metadata schema. - /// - public Dictionary? SelectedFieldsSchema - { - get - { - if (!this.Properties.TryGetValue("selectedFieldsSchema", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["selectedFieldsSchema"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Size of the image file in Bytes. - /// - public double? Size - { - get - { - if (!this.Properties.TryGetValue("size", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["size"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The array of tags associated with the asset. If no tags are set, it will - /// be `null`. Send `tags` in `responseFields` in API request to get the value - /// of this field. - /// - public List? Tags - { - get - { - if (!this.Properties.TryGetValue("tags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["tags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// In the case of an image, a small thumbnail URL. - /// - public string? ThumbnailURL - { - get - { - if (!this.Properties.TryGetValue("thumbnailUrl", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["thumbnailUrl"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// A publicly accessible URL of the file. - /// - public string? URL - { - get - { - if (!this.Properties.TryGetValue("url", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["url"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// An object containing the file or file version's `id` (versionId) and `name`. - /// - public VersionInfo? VersionInfo - { - get - { - if (!this.Properties.TryGetValue("versionInfo", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["versionInfo"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The video codec used in the video (only for video). - /// - public string? VideoCodec - { - get - { - if (!this.Properties.TryGetValue("videoCodec", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["videoCodec"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Width of the image in pixels (Only for Images) - /// - public double? Width - { - get - { - if (!this.Properties.TryGetValue("width", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["width"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - foreach (var item in this.AITags ?? []) - { - item.Validate(); - } - _ = this.AudioCodec; - _ = this.BitRate; - _ = this.CustomCoordinates; - _ = this.CustomMetadata; - _ = this.Description; - _ = this.Duration; - _ = this.EmbeddedMetadata; - this.ExtensionStatus?.Validate(); - _ = this.FileID; - _ = this.FilePath; - _ = this.FileType; - _ = this.Height; - _ = this.IsPrivateFile; - _ = this.IsPublished; - this.Metadata?.Validate(); - _ = this.Name; - if (this.SelectedFieldsSchema != null) - { - foreach (var item in this.SelectedFieldsSchema.Values) - { - item.Validate(); - } - } - _ = this.Size; - _ = this.Tags; - _ = this.ThumbnailURL; - _ = this.URL; - this.VersionInfo?.Validate(); - _ = this.VideoCodec; - _ = this.Width; - } - - public FileUploadResponse() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - FileUploadResponse(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static FileUploadResponse FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadResponseProperties/AITag.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/AITag.cs deleted file mode 100644 index bbe9e966..00000000 --- a/src/Imagekit/Models/Files/FileUploadResponseProperties/AITag.cs +++ /dev/null @@ -1,96 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files.FileUploadResponseProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class AITag : ModelBase, IFromRaw -{ - /// - /// Confidence score of the tag. - /// - public double? Confidence - { - get - { - if (!this.Properties.TryGetValue("confidence", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["confidence"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Name of the tag. - /// - public string? Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Array of `AITags` associated with the image. If no `AITags` are set, it will - /// be null. These tags can be added using the `google-auto-tagging` or `aws-auto-tagging` extensions. - /// - public string? Source - { - get - { - if (!this.Properties.TryGetValue("source", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["source"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.Confidence; - _ = this.Name; - _ = this.Source; - } - - public AITag() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - AITag(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static AITag FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadResponseProperties/ExtensionStatus.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/ExtensionStatus.cs deleted file mode 100644 index a742a8b7..00000000 --- a/src/Imagekit/Models/Files/FileUploadResponseProperties/ExtensionStatus.cs +++ /dev/null @@ -1,129 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Files.FileUploadResponseProperties.ExtensionStatusProperties; - -namespace Imagekit.Models.Files.FileUploadResponseProperties; - -/// -/// Extension names with their processing status at the time of completion of the -/// request. It could have one of the following status values: -/// -/// `success`: The extension has been successfully applied. `failed`: The extension -/// has failed and will not be retried. `pending`: The extension will finish processing -/// in some time. On completion, the final status (success / failed) will be sent -/// to the `webhookUrl` provided. -/// -/// If no extension was requested, then this parameter is not returned. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class ExtensionStatus : ModelBase, IFromRaw -{ - public ApiEnum? AIAutoDescription - { - get - { - if (!this.Properties.TryGetValue("ai-auto-description", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["ai-auto-description"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public ApiEnum? AwsAutoTagging - { - get - { - if (!this.Properties.TryGetValue("aws-auto-tagging", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["aws-auto-tagging"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public ApiEnum? GoogleAutoTagging - { - get - { - if (!this.Properties.TryGetValue("google-auto-tagging", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["google-auto-tagging"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public ApiEnum? RemoveBg - { - get - { - if (!this.Properties.TryGetValue("remove-bg", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["remove-bg"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.AIAutoDescription?.Validate(); - this.AwsAutoTagging?.Validate(); - this.GoogleAutoTagging?.Validate(); - this.RemoveBg?.Validate(); - } - - public ExtensionStatus() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - ExtensionStatus(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static ExtensionStatus FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadResponseProperties/ExtensionStatusProperties/AIAutoDescription.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/ExtensionStatusProperties/AIAutoDescription.cs deleted file mode 100644 index 6a9e6728..00000000 --- a/src/Imagekit/Models/Files/FileUploadResponseProperties/ExtensionStatusProperties/AIAutoDescription.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files.FileUploadResponseProperties.ExtensionStatusProperties; - -[JsonConverter(typeof(AIAutoDescriptionConverter))] -public enum AIAutoDescription -{ - Success, - Pending, - Failed, -} - -sealed class AIAutoDescriptionConverter : JsonConverter -{ - public override AIAutoDescription Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "success" => AIAutoDescription.Success, - "pending" => AIAutoDescription.Pending, - "failed" => AIAutoDescription.Failed, - _ => (AIAutoDescription)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - AIAutoDescription value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - AIAutoDescription.Success => "success", - AIAutoDescription.Pending => "pending", - AIAutoDescription.Failed => "failed", - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadResponseProperties/ExtensionStatusProperties/AwsAutoTagging.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/ExtensionStatusProperties/AwsAutoTagging.cs deleted file mode 100644 index b1faf17d..00000000 --- a/src/Imagekit/Models/Files/FileUploadResponseProperties/ExtensionStatusProperties/AwsAutoTagging.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files.FileUploadResponseProperties.ExtensionStatusProperties; - -[JsonConverter(typeof(AwsAutoTaggingConverter))] -public enum AwsAutoTagging -{ - Success, - Pending, - Failed, -} - -sealed class AwsAutoTaggingConverter : JsonConverter -{ - public override AwsAutoTagging Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "success" => AwsAutoTagging.Success, - "pending" => AwsAutoTagging.Pending, - "failed" => AwsAutoTagging.Failed, - _ => (AwsAutoTagging)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - AwsAutoTagging value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - AwsAutoTagging.Success => "success", - AwsAutoTagging.Pending => "pending", - AwsAutoTagging.Failed => "failed", - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadResponseProperties/ExtensionStatusProperties/GoogleAutoTagging.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/ExtensionStatusProperties/GoogleAutoTagging.cs deleted file mode 100644 index 3de49b9f..00000000 --- a/src/Imagekit/Models/Files/FileUploadResponseProperties/ExtensionStatusProperties/GoogleAutoTagging.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files.FileUploadResponseProperties.ExtensionStatusProperties; - -[JsonConverter(typeof(GoogleAutoTaggingConverter))] -public enum GoogleAutoTagging -{ - Success, - Pending, - Failed, -} - -sealed class GoogleAutoTaggingConverter : JsonConverter -{ - public override GoogleAutoTagging Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "success" => GoogleAutoTagging.Success, - "pending" => GoogleAutoTagging.Pending, - "failed" => GoogleAutoTagging.Failed, - _ => (GoogleAutoTagging)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - GoogleAutoTagging value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - GoogleAutoTagging.Success => "success", - GoogleAutoTagging.Pending => "pending", - GoogleAutoTagging.Failed => "failed", - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadResponseProperties/ExtensionStatusProperties/RemoveBg.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/ExtensionStatusProperties/RemoveBg.cs deleted file mode 100644 index 08d97e52..00000000 --- a/src/Imagekit/Models/Files/FileUploadResponseProperties/ExtensionStatusProperties/RemoveBg.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files.FileUploadResponseProperties.ExtensionStatusProperties; - -[JsonConverter(typeof(RemoveBgConverter))] -public enum RemoveBg -{ - Success, - Pending, - Failed, -} - -sealed class RemoveBgConverter : JsonConverter -{ - public override RemoveBg Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "success" => RemoveBg.Success, - "pending" => RemoveBg.Pending, - "failed" => RemoveBg.Failed, - _ => (RemoveBg)(-1), - }; - } - - public override void Write(Utf8JsonWriter writer, RemoveBg value, JsonSerializerOptions options) - { - JsonSerializer.Serialize( - writer, - value switch - { - RemoveBg.Success => "success", - RemoveBg.Pending => "pending", - RemoveBg.Failed => "failed", - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs deleted file mode 100644 index 959763f7..00000000 --- a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs +++ /dev/null @@ -1,290 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Core; -using Imagekit.Exceptions; -using SelectedFieldsSchemaItemProperties = Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; - -namespace Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class SelectedFieldsSchemaItem : ModelBase, IFromRaw -{ - /// - /// Type of the custom metadata field. - /// - public required ApiEnum Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentOutOfRangeException("type", "Missing required argument") - ); - - return JsonSerializer.Deserialize< - ApiEnum - >(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The default value for this custom metadata field. The value should match the - /// `type` of custom metadata field. - /// - public SelectedFieldsSchemaItemProperties::DefaultValue? DefaultValue - { - get - { - if (!this.Properties.TryGetValue("defaultValue", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["defaultValue"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies if the custom metadata field is required or not. - /// - public bool? IsValueRequired - { - get - { - if (!this.Properties.TryGetValue("isValueRequired", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["isValueRequired"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. - /// - public double? MaxLength - { - get - { - if (!this.Properties.TryGetValue("maxLength", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["maxLength"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Maximum value of the field. Only set if field type is `Date` or `Number`. - /// For `Date` type field, the value will be in ISO8601 string format. For `Number` - /// type field, it will be a numeric value. - /// - public SelectedFieldsSchemaItemProperties::MaxValue? MaxValue - { - get - { - if (!this.Properties.TryGetValue("maxValue", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["maxValue"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. - /// - public double? MinLength - { - get - { - if (!this.Properties.TryGetValue("minLength", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["minLength"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Minimum value of the field. Only set if field type is `Date` or `Number`. - /// For `Date` type field, the value will be in ISO8601 string format. For `Number` - /// type field, it will be a numeric value. - /// - public SelectedFieldsSchemaItemProperties::MinValue? MinValue - { - get - { - if (!this.Properties.TryGetValue("minValue", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["minValue"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Indicates whether the custom metadata field is read only. A read only field - /// cannot be modified after being set. This field is configurable only via the - /// **Path policy** feature. - /// - public bool? ReadOnly - { - get - { - if (!this.Properties.TryGetValue("readOnly", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["readOnly"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// An array of allowed values when field type is `SingleSelect` or `MultiSelect`. - /// - public List? SelectOptions - { - get - { - if (!this.Properties.TryGetValue("selectOptions", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["selectOptions"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies if the selectOptions array is truncated. It is truncated when number - /// of options are > 100. - /// - public bool? SelectOptionsTruncated - { - get - { - if (!this.Properties.TryGetValue("selectOptionsTruncated", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["selectOptionsTruncated"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Type.Validate(); - this.DefaultValue?.Validate(); - _ = this.IsValueRequired; - _ = this.MaxLength; - this.MaxValue?.Validate(); - _ = this.MinLength; - this.MinValue?.Validate(); - _ = this.ReadOnly; - foreach (var item in this.SelectOptions ?? []) - { - item.Validate(); - } - _ = this.SelectOptionsTruncated; - } - - public SelectedFieldsSchemaItem() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - SelectedFieldsSchemaItem(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static SelectedFieldsSchemaItem FromRawUnchecked( - Dictionary properties - ) - { - return new(properties); - } - - [SetsRequiredMembers] - public SelectedFieldsSchemaItem(ApiEnum type) - : this() - { - this.Type = type; - } -} diff --git a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs deleted file mode 100644 index eb7295d8..00000000 --- a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs +++ /dev/null @@ -1,214 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties; -using System = System; - -namespace Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; - -/// -/// The default value for this custom metadata field. The value should match the -/// `type` of custom metadata field. -/// -[JsonConverter(typeof(DefaultValueConverter))] -public record class DefaultValue -{ - public object Value { get; private init; } - - public DefaultValue(string value) - { - Value = value; - } - - public DefaultValue(double value) - { - Value = value; - } - - public DefaultValue(bool value) - { - Value = value; - } - - public DefaultValue(List value) - { - Value = value; - } - - DefaultValue(UnknownVariant value) - { - Value = value; - } - - public static DefaultValue CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public bool TryPickBool([NotNullWhen(true)] out bool? value) - { - value = this.Value as bool?; - return value != null; - } - - public bool TryPickMixed([NotNullWhen(true)] out List? value) - { - value = this.Value as List; - return value != null; - } - - public void Switch( - System::Action @string, - System::Action @double, - System::Action @bool, - System::Action> mixed - ) - { - switch (this.Value) - { - case string value: - @string(value); - break; - case double value: - @double(value); - break; - case bool value: - @bool(value); - break; - case List value: - mixed(value); - break; - default: - throw new ImageKitInvalidDataException( - "Data did not match any variant of DefaultValue" - ); - } - } - - public T Match( - System::Func @string, - System::Func @double, - System::Func @bool, - System::Func, T> mixed - ) - { - return this.Value switch - { - string value => @string(value), - double value => @double(value), - bool value => @bool(value), - List value => mixed(value), - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of DefaultValue" - ), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException( - "Data did not match any variant of DefaultValue" - ); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class DefaultValueConverter : JsonConverter -{ - public override DefaultValue? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new DefaultValue(deserialized); - } - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'string'", e) - ); - } - - try - { - return new DefaultValue(JsonSerializer.Deserialize(ref reader, options)); - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'double'", e) - ); - } - - try - { - return new DefaultValue(JsonSerializer.Deserialize(ref reader, options)); - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'bool'", e) - ); - } - - try - { - var deserialized = JsonSerializer.Deserialize>( - ref reader, - options - ); - if (deserialized != null) - { - return new DefaultValue(deserialized); - } - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException( - "Data does not match union variant 'List'", - e - ) - ); - } - - throw new System::AggregateException(exceptions); - } - - public override void Write( - Utf8JsonWriter writer, - DefaultValue value, - JsonSerializerOptions options - ) - { - object variant = value.Value; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent5.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent5.cs deleted file mode 100644 index 0ae661e2..00000000 --- a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent5.cs +++ /dev/null @@ -1,175 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties; - -[JsonConverter(typeof(UnnamedSchemaWithArrayParent5Converter))] -public record class UnnamedSchemaWithArrayParent5 -{ - public object Value { get; private init; } - - public UnnamedSchemaWithArrayParent5(string value) - { - Value = value; - } - - public UnnamedSchemaWithArrayParent5(double value) - { - Value = value; - } - - public UnnamedSchemaWithArrayParent5(bool value) - { - Value = value; - } - - UnnamedSchemaWithArrayParent5(UnknownVariant value) - { - Value = value; - } - - public static UnnamedSchemaWithArrayParent5 CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public bool TryPickBool([NotNullWhen(true)] out bool? value) - { - value = this.Value as bool?; - return value != null; - } - - public void Switch( - System::Action @string, - System::Action @double, - System::Action @bool - ) - { - switch (this.Value) - { - case string value: - @string(value); - break; - case double value: - @double(value); - break; - case bool value: - @bool(value); - break; - default: - throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent5" - ); - } - } - - public T Match( - System::Func @string, - System::Func @double, - System::Func @bool - ) - { - return this.Value switch - { - string value => @string(value), - double value => @double(value), - bool value => @bool(value), - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent5" - ), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent5" - ); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class UnnamedSchemaWithArrayParent5Converter : JsonConverter -{ - public override UnnamedSchemaWithArrayParent5? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new UnnamedSchemaWithArrayParent5(deserialized); - } - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'string'", e) - ); - } - - try - { - return new UnnamedSchemaWithArrayParent5( - JsonSerializer.Deserialize(ref reader, options) - ); - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'double'", e) - ); - } - - try - { - return new UnnamedSchemaWithArrayParent5( - JsonSerializer.Deserialize(ref reader, options) - ); - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'bool'", e) - ); - } - - throw new System::AggregateException(exceptions); - } - - public override void Write( - Utf8JsonWriter writer, - UnnamedSchemaWithArrayParent5 value, - JsonSerializerOptions options - ) - { - object variant = value.Value; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs deleted file mode 100644 index 3dd7f56c..00000000 --- a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs +++ /dev/null @@ -1,136 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; - -/// -/// Maximum value of the field. Only set if field type is `Date` or `Number`. For -/// `Date` type field, the value will be in ISO8601 string format. For `Number` type -/// field, it will be a numeric value. -/// -[JsonConverter(typeof(MaxValueConverter))] -public record class MaxValue -{ - public object Value { get; private init; } - - public MaxValue(string value) - { - Value = value; - } - - public MaxValue(double value) - { - Value = value; - } - - MaxValue(UnknownVariant value) - { - Value = value; - } - - public static MaxValue CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public void Switch(System::Action @string, System::Action @double) - { - switch (this.Value) - { - case string value: - @string(value); - break; - case double value: - @double(value); - break; - default: - throw new ImageKitInvalidDataException( - "Data did not match any variant of MaxValue" - ); - } - } - - public T Match(System::Func @string, System::Func @double) - { - return this.Value switch - { - string value => @string(value), - double value => @double(value), - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of MaxValue" - ), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of MaxValue"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class MaxValueConverter : JsonConverter -{ - public override MaxValue? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new MaxValue(deserialized); - } - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'string'", e) - ); - } - - try - { - return new MaxValue(JsonSerializer.Deserialize(ref reader, options)); - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'double'", e) - ); - } - - throw new System::AggregateException(exceptions); - } - - public override void Write(Utf8JsonWriter writer, MaxValue value, JsonSerializerOptions options) - { - object variant = value.Value; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs deleted file mode 100644 index 3b0c2a22..00000000 --- a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs +++ /dev/null @@ -1,136 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; - -/// -/// Minimum value of the field. Only set if field type is `Date` or `Number`. For -/// `Date` type field, the value will be in ISO8601 string format. For `Number` type -/// field, it will be a numeric value. -/// -[JsonConverter(typeof(MinValueConverter))] -public record class MinValue -{ - public object Value { get; private init; } - - public MinValue(string value) - { - Value = value; - } - - public MinValue(double value) - { - Value = value; - } - - MinValue(UnknownVariant value) - { - Value = value; - } - - public static MinValue CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public void Switch(System::Action @string, System::Action @double) - { - switch (this.Value) - { - case string value: - @string(value); - break; - case double value: - @double(value); - break; - default: - throw new ImageKitInvalidDataException( - "Data did not match any variant of MinValue" - ); - } - } - - public T Match(System::Func @string, System::Func @double) - { - return this.Value switch - { - string value => @string(value), - double value => @double(value), - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of MinValue" - ), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of MinValue"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class MinValueConverter : JsonConverter -{ - public override MinValue? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new MinValue(deserialized); - } - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'string'", e) - ); - } - - try - { - return new MinValue(JsonSerializer.Deserialize(ref reader, options)); - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'double'", e) - ); - } - - throw new System::AggregateException(exceptions); - } - - public override void Write(Utf8JsonWriter writer, MinValue value, JsonSerializerOptions options) - { - object variant = value.Value; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs deleted file mode 100644 index 8af33b5b..00000000 --- a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs +++ /dev/null @@ -1,171 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; - -[JsonConverter(typeof(SelectOptionConverter))] -public record class SelectOption -{ - public object Value { get; private init; } - - public SelectOption(string value) - { - Value = value; - } - - public SelectOption(double value) - { - Value = value; - } - - public SelectOption(bool value) - { - Value = value; - } - - SelectOption(UnknownVariant value) - { - Value = value; - } - - public static SelectOption CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public bool TryPickBool([NotNullWhen(true)] out bool? value) - { - value = this.Value as bool?; - return value != null; - } - - public void Switch( - System::Action @string, - System::Action @double, - System::Action @bool - ) - { - switch (this.Value) - { - case string value: - @string(value); - break; - case double value: - @double(value); - break; - case bool value: - @bool(value); - break; - default: - throw new ImageKitInvalidDataException( - "Data did not match any variant of SelectOption" - ); - } - } - - public T Match( - System::Func @string, - System::Func @double, - System::Func @bool - ) - { - return this.Value switch - { - string value => @string(value), - double value => @double(value), - bool value => @bool(value), - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of SelectOption" - ), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException( - "Data did not match any variant of SelectOption" - ); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class SelectOptionConverter : JsonConverter -{ - public override SelectOption? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new SelectOption(deserialized); - } - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'string'", e) - ); - } - - try - { - return new SelectOption(JsonSerializer.Deserialize(ref reader, options)); - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'double'", e) - ); - } - - try - { - return new SelectOption(JsonSerializer.Deserialize(ref reader, options)); - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'bool'", e) - ); - } - - throw new System::AggregateException(exceptions); - } - - public override void Write( - Utf8JsonWriter writer, - SelectOption value, - JsonSerializerOptions options - ) - { - object variant = value.Value; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs deleted file mode 100644 index 7845b207..00000000 --- a/src/Imagekit/Models/Files/FileUploadResponseProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Files.FileUploadResponseProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; - -/// -/// Type of the custom metadata field. -/// -[JsonConverter(typeof(TypeConverter))] -public enum Type -{ - Text, - Textarea, - Number, - Date, - Boolean, - SingleSelect, - MultiSelect, -} - -sealed class TypeConverter : JsonConverter -{ - public override Type Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "Text" => SelectedFieldsSchemaItemProperties.Type.Text, - "Textarea" => SelectedFieldsSchemaItemProperties.Type.Textarea, - "Number" => SelectedFieldsSchemaItemProperties.Type.Number, - "Date" => SelectedFieldsSchemaItemProperties.Type.Date, - "Boolean" => SelectedFieldsSchemaItemProperties.Type.Boolean, - "SingleSelect" => SelectedFieldsSchemaItemProperties.Type.SingleSelect, - "MultiSelect" => SelectedFieldsSchemaItemProperties.Type.MultiSelect, - _ => (Type)(-1), - }; - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonSerializer.Serialize( - writer, - value switch - { - SelectedFieldsSchemaItemProperties.Type.Text => "Text", - SelectedFieldsSchemaItemProperties.Type.Textarea => "Textarea", - SelectedFieldsSchemaItemProperties.Type.Number => "Number", - SelectedFieldsSchemaItemProperties.Type.Date => "Date", - SelectedFieldsSchemaItemProperties.Type.Boolean => "Boolean", - SelectedFieldsSchemaItemProperties.Type.SingleSelect => "SingleSelect", - SelectedFieldsSchemaItemProperties.Type.MultiSelect => "MultiSelect", - _ => throw new ImageKitInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Files/FileUploadResponseProperties/VersionInfo.cs b/src/Imagekit/Models/Files/FileUploadResponseProperties/VersionInfo.cs deleted file mode 100644 index a54f4050..00000000 --- a/src/Imagekit/Models/Files/FileUploadResponseProperties/VersionInfo.cs +++ /dev/null @@ -1,76 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files.FileUploadResponseProperties; - -/// -/// An object containing the file or file version's `id` (versionId) and `name`. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class VersionInfo : ModelBase, IFromRaw -{ - /// - /// Unique identifier of the file version. - /// - public string? ID - { - get - { - if (!this.Properties.TryGetValue("id", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["id"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Name of the file version. - /// - public string? Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.ID; - _ = this.Name; - } - - public VersionInfo() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - VersionInfo(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static VersionInfo FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/Folder.cs b/src/Imagekit/Models/Files/Folder.cs deleted file mode 100644 index 5a3d957c..00000000 --- a/src/Imagekit/Models/Files/Folder.cs +++ /dev/null @@ -1,171 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using FolderProperties = Imagekit.Models.Files.FolderProperties; - -namespace Imagekit.Models.Files; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Folder : ModelBase, IFromRaw -{ - /// - /// Date and time when the folder was created. The date and time is in ISO8601 - /// format. - /// - public DateTime? CreatedAt - { - get - { - if (!this.Properties.TryGetValue("createdAt", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["createdAt"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Unique identifier of the asset. - /// - public string? FolderID - { - get - { - if (!this.Properties.TryGetValue("folderId", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["folderId"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Path of the folder. This is the path you would use in the URL to access the - /// folder. For example, if the folder is at the root of the media library, the - /// path will be /folder. If the folder is inside another folder named images, - /// the path will be /images/folder. - /// - public string? FolderPath - { - get - { - if (!this.Properties.TryGetValue("folderPath", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["folderPath"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Name of the asset. - /// - public string? Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Type of the asset. - /// - public ApiEnum? Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Date and time when the folder was last updated. The date and time is in ISO8601 - /// format. - /// - public DateTime? UpdatedAt - { - get - { - if (!this.Properties.TryGetValue("updatedAt", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["updatedAt"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.CreatedAt; - _ = this.FolderID; - _ = this.FolderPath; - _ = this.Name; - this.Type?.Validate(); - _ = this.UpdatedAt; - } - - public Folder() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Folder(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Folder FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/FolderProperties/Type.cs b/src/Imagekit/Models/Files/FolderProperties/Type.cs deleted file mode 100644 index 0d97363d..00000000 --- a/src/Imagekit/Models/Files/FolderProperties/Type.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using System = System; - -namespace Imagekit.Models.Files.FolderProperties; - -/// -/// Type of the asset. -/// -[JsonConverter(typeof(TypeConverter))] -public enum Type -{ - Folder, -} - -sealed class TypeConverter : JsonConverter -{ - public override Type Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "folder" => FolderProperties.Type.Folder, - _ => (Type)(-1), - }; - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonSerializer.Serialize( - writer, - value switch - { - FolderProperties.Type.Folder => "folder", - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Files/Metadata.cs b/src/Imagekit/Models/Files/Metadata.cs deleted file mode 100644 index 8c59db4f..00000000 --- a/src/Imagekit/Models/Files/Metadata.cs +++ /dev/null @@ -1,338 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Files.MetadataProperties; - -namespace Imagekit.Models.Files; - -/// -/// JSON object containing metadata. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class Metadata : ModelBase, IFromRaw -{ - /// - /// The audio codec used in the video (only for video). - /// - public string? AudioCodec - { - get - { - if (!this.Properties.TryGetValue("audioCodec", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["audioCodec"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The bit rate of the video in kbps (only for video). - /// - public long? BitRate - { - get - { - if (!this.Properties.TryGetValue("bitRate", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["bitRate"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The density of the image in DPI. - /// - public long? Density - { - get - { - if (!this.Properties.TryGetValue("density", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["density"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The duration of the video in seconds (only for video). - /// - public long? Duration - { - get - { - if (!this.Properties.TryGetValue("duration", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["duration"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public Exif? Exif - { - get - { - if (!this.Properties.TryGetValue("exif", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["exif"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The format of the file (e.g., 'jpg', 'mp4'). - /// - public string? Format - { - get - { - if (!this.Properties.TryGetValue("format", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["format"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Indicates if the image has a color profile. - /// - public bool? HasColorProfile - { - get - { - if (!this.Properties.TryGetValue("hasColorProfile", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["hasColorProfile"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Indicates if the image contains transparent areas. - /// - public bool? HasTransparency - { - get - { - if (!this.Properties.TryGetValue("hasTransparency", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["hasTransparency"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The height of the image or video in pixels. - /// - public long? Height - { - get - { - if (!this.Properties.TryGetValue("height", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["height"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Perceptual hash of the image. - /// - public string? PHash - { - get - { - if (!this.Properties.TryGetValue("pHash", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["pHash"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The quality indicator of the image. - /// - public long? Quality - { - get - { - if (!this.Properties.TryGetValue("quality", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["quality"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The file size in bytes. - /// - public long? Size - { - get - { - if (!this.Properties.TryGetValue("size", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["size"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The video codec used in the video (only for video). - /// - public string? VideoCodec - { - get - { - if (!this.Properties.TryGetValue("videoCodec", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["videoCodec"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The width of the image or video in pixels. - /// - public long? Width - { - get - { - if (!this.Properties.TryGetValue("width", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["width"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.AudioCodec; - _ = this.BitRate; - _ = this.Density; - _ = this.Duration; - this.Exif?.Validate(); - _ = this.Format; - _ = this.HasColorProfile; - _ = this.HasTransparency; - _ = this.Height; - _ = this.PHash; - _ = this.Quality; - _ = this.Size; - _ = this.VideoCodec; - _ = this.Width; - } - - public Metadata() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Metadata(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Metadata FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/Metadata/MetadataGetFromURLParams.cs b/src/Imagekit/Models/Files/Metadata/MetadataGetFromURLParams.cs deleted file mode 100644 index 8bc70260..00000000 --- a/src/Imagekit/Models/Files/Metadata/MetadataGetFromURLParams.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; -using System.Net.Http; -using System.Text.Json; - -namespace Imagekit.Models.Files.Metadata; - -/// -/// Get image EXIF, pHash, and other metadata from ImageKit.io powered remote URL -/// using this API. -/// -public sealed record class MetadataGetFromURLParams : ParamsBase -{ - /// - /// Should be a valid file URL. It should be accessible using your ImageKit.io - /// account. - /// - public required string URL - { - get - { - if (!this.QueryProperties.TryGetValue("url", out JsonElement element)) - throw new ArgumentOutOfRangeException("url", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("url"); - } - set - { - this.QueryProperties["url"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override Uri Url(IImageKitClient client) - { - return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/files/metadata") - { - Query = this.QueryString(client), - }.Uri; - } - - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} diff --git a/src/Imagekit/Models/Files/Metadata/MetadataGetParams.cs b/src/Imagekit/Models/Files/Metadata/MetadataGetParams.cs deleted file mode 100644 index acd20a10..00000000 --- a/src/Imagekit/Models/Files/Metadata/MetadataGetParams.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using System.Net.Http; - -namespace Imagekit.Models.Files.Metadata; - -/// -/// You can programmatically get image EXIF, pHash, and other metadata for uploaded -/// files in the ImageKit.io media library using this API. -/// -/// You can also get the metadata in upload API response by passing `metadata` in -/// `responseFields` parameter. -/// -public sealed record class MetadataGetParams : ParamsBase -{ - public required string FileID; - - public override Uri Url(IImageKitClient client) - { - return new UriBuilder( - client.BaseUrl.ToString().TrimEnd('/') - + string.Format("/v1/files/{0}/metadata", this.FileID) - ) - { - Query = this.QueryString(client), - }.Uri; - } - - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} diff --git a/src/Imagekit/Models/Files/MetadataProperties/Exif.cs b/src/Imagekit/Models/Files/MetadataProperties/Exif.cs deleted file mode 100644 index 4ff86411..00000000 --- a/src/Imagekit/Models/Files/MetadataProperties/Exif.cs +++ /dev/null @@ -1,178 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Core; -using ExifProperties = Imagekit.Models.Files.MetadataProperties.ExifProperties; - -namespace Imagekit.Models.Files.MetadataProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Exif : ModelBase, IFromRaw -{ - /// - /// Object containing Exif details. - /// - public ExifProperties::Exif? Exif1 - { - get - { - if (!this.Properties.TryGetValue("exif", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["exif"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Object containing GPS information. - /// - public ExifProperties::Gps? Gps - { - get - { - if (!this.Properties.TryGetValue("gps", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["gps"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Object containing EXIF image information. - /// - public ExifProperties::Image? Image - { - get - { - if (!this.Properties.TryGetValue("image", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["image"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// JSON object. - /// - public ExifProperties::Interoperability? Interoperability - { - get - { - if (!this.Properties.TryGetValue("interoperability", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["interoperability"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public Dictionary? Makernote - { - get - { - if (!this.Properties.TryGetValue("makernote", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["makernote"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Object containing Thumbnail information. - /// - public ExifProperties::Thumbnail? Thumbnail - { - get - { - if (!this.Properties.TryGetValue("thumbnail", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["thumbnail"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Exif1?.Validate(); - this.Gps?.Validate(); - this.Image?.Validate(); - this.Interoperability?.Validate(); - _ = this.Makernote; - this.Thumbnail?.Validate(); - } - - public Exif() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Exif(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Exif FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/MetadataProperties/ExifProperties/Exif.cs b/src/Imagekit/Models/Files/MetadataProperties/ExifProperties/Exif.cs deleted file mode 100644 index 03fec205..00000000 --- a/src/Imagekit/Models/Files/MetadataProperties/ExifProperties/Exif.cs +++ /dev/null @@ -1,533 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Core; - -namespace Imagekit.Models.Files.MetadataProperties.ExifProperties; - -/// -/// Object containing Exif details. -/// -[JsonConverter( - typeof(ModelConverter) -)] -public sealed record class Exif - : ModelBase, - IFromRaw -{ - public double? ApertureValue - { - get - { - if (!this.Properties.TryGetValue("ApertureValue", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["ApertureValue"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public long? ColorSpace - { - get - { - if (!this.Properties.TryGetValue("ColorSpace", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["ColorSpace"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public string? CreateDate - { - get - { - if (!this.Properties.TryGetValue("CreateDate", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["CreateDate"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public long? CustomRendered - { - get - { - if (!this.Properties.TryGetValue("CustomRendered", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["CustomRendered"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public string? DateTimeOriginal - { - get - { - if (!this.Properties.TryGetValue("DateTimeOriginal", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["DateTimeOriginal"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public long? ExifImageHeight - { - get - { - if (!this.Properties.TryGetValue("ExifImageHeight", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["ExifImageHeight"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public long? ExifImageWidth - { - get - { - if (!this.Properties.TryGetValue("ExifImageWidth", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["ExifImageWidth"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public string? ExifVersion - { - get - { - if (!this.Properties.TryGetValue("ExifVersion", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["ExifVersion"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public double? ExposureCompensation - { - get - { - if (!this.Properties.TryGetValue("ExposureCompensation", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["ExposureCompensation"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public long? ExposureMode - { - get - { - if (!this.Properties.TryGetValue("ExposureMode", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["ExposureMode"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public long? ExposureProgram - { - get - { - if (!this.Properties.TryGetValue("ExposureProgram", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["ExposureProgram"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public double? ExposureTime - { - get - { - if (!this.Properties.TryGetValue("ExposureTime", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["ExposureTime"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public long? Flash - { - get - { - if (!this.Properties.TryGetValue("Flash", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["Flash"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public string? FlashpixVersion - { - get - { - if (!this.Properties.TryGetValue("FlashpixVersion", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["FlashpixVersion"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public double? FNumber - { - get - { - if (!this.Properties.TryGetValue("FNumber", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["FNumber"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public long? FocalLength - { - get - { - if (!this.Properties.TryGetValue("FocalLength", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["FocalLength"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public long? FocalPlaneResolutionUnit - { - get - { - if (!this.Properties.TryGetValue("FocalPlaneResolutionUnit", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["FocalPlaneResolutionUnit"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public double? FocalPlaneXResolution - { - get - { - if (!this.Properties.TryGetValue("FocalPlaneXResolution", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["FocalPlaneXResolution"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public double? FocalPlaneYResolution - { - get - { - if (!this.Properties.TryGetValue("FocalPlaneYResolution", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["FocalPlaneYResolution"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public long? InteropOffset - { - get - { - if (!this.Properties.TryGetValue("InteropOffset", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["InteropOffset"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public long? ISO - { - get - { - if (!this.Properties.TryGetValue("ISO", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["ISO"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public long? MeteringMode - { - get - { - if (!this.Properties.TryGetValue("MeteringMode", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["MeteringMode"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public long? SceneCaptureType - { - get - { - if (!this.Properties.TryGetValue("SceneCaptureType", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["SceneCaptureType"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public double? ShutterSpeedValue - { - get - { - if (!this.Properties.TryGetValue("ShutterSpeedValue", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["ShutterSpeedValue"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public string? SubSecTime - { - get - { - if (!this.Properties.TryGetValue("SubSecTime", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["SubSecTime"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public long? WhiteBalance - { - get - { - if (!this.Properties.TryGetValue("WhiteBalance", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["WhiteBalance"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.ApertureValue; - _ = this.ColorSpace; - _ = this.CreateDate; - _ = this.CustomRendered; - _ = this.DateTimeOriginal; - _ = this.ExifImageHeight; - _ = this.ExifImageWidth; - _ = this.ExifVersion; - _ = this.ExposureCompensation; - _ = this.ExposureMode; - _ = this.ExposureProgram; - _ = this.ExposureTime; - _ = this.Flash; - _ = this.FlashpixVersion; - _ = this.FNumber; - _ = this.FocalLength; - _ = this.FocalPlaneResolutionUnit; - _ = this.FocalPlaneXResolution; - _ = this.FocalPlaneYResolution; - _ = this.InteropOffset; - _ = this.ISO; - _ = this.MeteringMode; - _ = this.SceneCaptureType; - _ = this.ShutterSpeedValue; - _ = this.SubSecTime; - _ = this.WhiteBalance; - } - - public Exif() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Exif(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static global::Imagekit.Models.Files.MetadataProperties.ExifProperties.Exif FromRawUnchecked( - Dictionary properties - ) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/MetadataProperties/ExifProperties/Gps.cs b/src/Imagekit/Models/Files/MetadataProperties/ExifProperties/Gps.cs deleted file mode 100644 index 94a2e672..00000000 --- a/src/Imagekit/Models/Files/MetadataProperties/ExifProperties/Gps.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Core; - -namespace Imagekit.Models.Files.MetadataProperties.ExifProperties; - -/// -/// Object containing GPS information. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class Gps : ModelBase, IFromRaw -{ - public List? GpsVersionID - { - get - { - if (!this.Properties.TryGetValue("GPSVersionID", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["GPSVersionID"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.GpsVersionID; - } - - public Gps() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Gps(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Gps FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/MetadataProperties/ExifProperties/Image.cs b/src/Imagekit/Models/Files/MetadataProperties/ExifProperties/Image.cs deleted file mode 100644 index 5c25d6a2..00000000 --- a/src/Imagekit/Models/Files/MetadataProperties/ExifProperties/Image.cs +++ /dev/null @@ -1,241 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files.MetadataProperties.ExifProperties; - -/// -/// Object containing EXIF image information. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class Image : ModelBase, IFromRaw -{ - public long? ExifOffset - { - get - { - if (!this.Properties.TryGetValue("ExifOffset", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["ExifOffset"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public long? GpsInfo - { - get - { - if (!this.Properties.TryGetValue("GPSInfo", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["GPSInfo"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public string? Make - { - get - { - if (!this.Properties.TryGetValue("Make", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["Make"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public string? Model - { - get - { - if (!this.Properties.TryGetValue("Model", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["Model"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public string? ModifyDate - { - get - { - if (!this.Properties.TryGetValue("ModifyDate", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["ModifyDate"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public long? Orientation - { - get - { - if (!this.Properties.TryGetValue("Orientation", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["Orientation"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public long? ResolutionUnit - { - get - { - if (!this.Properties.TryGetValue("ResolutionUnit", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["ResolutionUnit"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public string? Software - { - get - { - if (!this.Properties.TryGetValue("Software", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["Software"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public long? XResolution - { - get - { - if (!this.Properties.TryGetValue("XResolution", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["XResolution"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public long? YCbCrPositioning - { - get - { - if (!this.Properties.TryGetValue("YCbCrPositioning", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["YCbCrPositioning"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public long? YResolution - { - get - { - if (!this.Properties.TryGetValue("YResolution", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["YResolution"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.ExifOffset; - _ = this.GpsInfo; - _ = this.Make; - _ = this.Model; - _ = this.ModifyDate; - _ = this.Orientation; - _ = this.ResolutionUnit; - _ = this.Software; - _ = this.XResolution; - _ = this.YCbCrPositioning; - _ = this.YResolution; - } - - public Image() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Image(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Image FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/MetadataProperties/ExifProperties/Interoperability.cs b/src/Imagekit/Models/Files/MetadataProperties/ExifProperties/Interoperability.cs deleted file mode 100644 index 36225916..00000000 --- a/src/Imagekit/Models/Files/MetadataProperties/ExifProperties/Interoperability.cs +++ /dev/null @@ -1,70 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files.MetadataProperties.ExifProperties; - -/// -/// JSON object. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class Interoperability : ModelBase, IFromRaw -{ - public string? InteropIndex - { - get - { - if (!this.Properties.TryGetValue("InteropIndex", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["InteropIndex"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public string? InteropVersion - { - get - { - if (!this.Properties.TryGetValue("InteropVersion", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["InteropVersion"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.InteropIndex; - _ = this.InteropVersion; - } - - public Interoperability() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Interoperability(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Interoperability FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/MetadataProperties/ExifProperties/Thumbnail.cs b/src/Imagekit/Models/Files/MetadataProperties/ExifProperties/Thumbnail.cs deleted file mode 100644 index 9e01cf4c..00000000 --- a/src/Imagekit/Models/Files/MetadataProperties/ExifProperties/Thumbnail.cs +++ /dev/null @@ -1,146 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files.MetadataProperties.ExifProperties; - -/// -/// Object containing Thumbnail information. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class Thumbnail : ModelBase, IFromRaw -{ - public long? Compression - { - get - { - if (!this.Properties.TryGetValue("Compression", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["Compression"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public long? ResolutionUnit - { - get - { - if (!this.Properties.TryGetValue("ResolutionUnit", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["ResolutionUnit"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public long? ThumbnailLength - { - get - { - if (!this.Properties.TryGetValue("ThumbnailLength", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["ThumbnailLength"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public long? ThumbnailOffset - { - get - { - if (!this.Properties.TryGetValue("ThumbnailOffset", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["ThumbnailOffset"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public long? XResolution - { - get - { - if (!this.Properties.TryGetValue("XResolution", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["XResolution"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public long? YResolution - { - get - { - if (!this.Properties.TryGetValue("YResolution", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["YResolution"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.Compression; - _ = this.ResolutionUnit; - _ = this.ThumbnailLength; - _ = this.ThumbnailOffset; - _ = this.XResolution; - _ = this.YResolution; - } - - public Thumbnail() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Thumbnail(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Thumbnail FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/UpdateFileDetailsRequestProperties/ChangePublicationStatus.cs b/src/Imagekit/Models/Files/UpdateFileDetailsRequestProperties/ChangePublicationStatus.cs deleted file mode 100644 index 7de8ec8b..00000000 --- a/src/Imagekit/Models/Files/UpdateFileDetailsRequestProperties/ChangePublicationStatus.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Files.FileUpdateParamsProperties.UpdateProperties.ChangePublicationStatusProperties; - -namespace Imagekit.Models.Files.FileUpdateParamsProperties.UpdateProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class ChangePublicationStatus : ModelBase, IFromRaw -{ - /// - /// Configure the publication status of a file and its versions. - /// - public Publish? Publish - { - get - { - if (!this.Properties.TryGetValue("publish", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["publish"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Publish?.Validate(); - } - - public ChangePublicationStatus() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - ChangePublicationStatus(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static ChangePublicationStatus FromRawUnchecked( - Dictionary properties - ) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/UpdateFileDetailsRequestProperties/ChangePublicationStatusProperties/Publish.cs b/src/Imagekit/Models/Files/UpdateFileDetailsRequestProperties/ChangePublicationStatusProperties/Publish.cs deleted file mode 100644 index acd8feb0..00000000 --- a/src/Imagekit/Models/Files/UpdateFileDetailsRequestProperties/ChangePublicationStatusProperties/Publish.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files.FileUpdateParamsProperties.UpdateProperties.ChangePublicationStatusProperties; - -/// -/// Configure the publication status of a file and its versions. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class Publish : ModelBase, IFromRaw -{ - /// - /// Set to `true` to publish the file. Set to `false` to unpublish the file. - /// - public required bool IsPublished - { - get - { - if (!this.Properties.TryGetValue("isPublished", out JsonElement element)) - throw new ArgumentOutOfRangeException("isPublished", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["isPublished"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Set to `true` to publish/unpublish all versions of the file. Set to `false` - /// to publish/unpublish only the current version of the file. - /// - public bool? IncludeFileVersions - { - get - { - if (!this.Properties.TryGetValue("includeFileVersions", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["includeFileVersions"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.IsPublished; - _ = this.IncludeFileVersions; - } - - public Publish() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Publish(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Publish FromRawUnchecked(Dictionary properties) - { - return new(properties); - } - - [SetsRequiredMembers] - public Publish(bool isPublished) - : this() - { - this.IsPublished = isPublished; - } -} diff --git a/src/Imagekit/Models/Files/UpdateFileRequest.cs b/src/Imagekit/Models/Files/UpdateFileRequest.cs deleted file mode 100644 index 9da396a0..00000000 --- a/src/Imagekit/Models/Files/UpdateFileRequest.cs +++ /dev/null @@ -1,164 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using Imagekit.Models.Files.UpdateFileRequestProperties; - -namespace Imagekit.Models.Files; - -/// -/// Schema for update file update request. -/// -[JsonConverter(typeof(UpdateFileRequestConverter))] -public record class UpdateFileRequest -{ - public object Value { get; private init; } - - public UpdateFileRequest(UpdateFileDetails value) - { - Value = value; - } - - public UpdateFileRequest(ChangePublicationStatus value) - { - Value = value; - } - - UpdateFileRequest(UnknownVariant value) - { - Value = value; - } - - public static UpdateFileRequest CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickDetails([NotNullWhen(true)] out UpdateFileDetails? value) - { - value = this.Value as UpdateFileDetails; - return value != null; - } - - public bool TryPickChangePublicationStatus( - [NotNullWhen(true)] out ChangePublicationStatus? value - ) - { - value = this.Value as ChangePublicationStatus; - return value != null; - } - - public void Switch( - Action details, - Action changePublicationStatus - ) - { - switch (this.Value) - { - case UpdateFileDetails value: - details(value); - break; - case ChangePublicationStatus value: - changePublicationStatus(value); - break; - default: - throw new ImageKitInvalidDataException( - "Data did not match any variant of UpdateFileRequest" - ); - } - } - - public T Match( - Func details, - Func changePublicationStatus - ) - { - return this.Value switch - { - UpdateFileDetails value => details(value), - ChangePublicationStatus value => changePublicationStatus(value), - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of UpdateFileRequest" - ), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException( - "Data did not match any variant of UpdateFileRequest" - ); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class UpdateFileRequestConverter : JsonConverter -{ - public override UpdateFileRequest? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - deserialized.Validate(); - return new UpdateFileRequest(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException( - "Data does not match union variant 'UpdateFileDetails'", - e - ) - ); - } - - try - { - var deserialized = JsonSerializer.Deserialize( - ref reader, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new UpdateFileRequest(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException( - "Data does not match union variant 'ChangePublicationStatus'", - e - ) - ); - } - - throw new AggregateException(exceptions); - } - - public override void Write( - Utf8JsonWriter writer, - UpdateFileRequest value, - JsonSerializerOptions options - ) - { - object variant = value.Value; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/Files/UpdateFileRequestProperties/ChangePublicationStatus.cs b/src/Imagekit/Models/Files/UpdateFileRequestProperties/ChangePublicationStatus.cs deleted file mode 100644 index 810ae7ea..00000000 --- a/src/Imagekit/Models/Files/UpdateFileRequestProperties/ChangePublicationStatus.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Core; -using Imagekit.Models.Files.UpdateFileRequestProperties.ChangePublicationStatusProperties; - -namespace Imagekit.Models.Files.UpdateFileRequestProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class ChangePublicationStatus : ModelBase, IFromRaw -{ - /// - /// Configure the publication status of a file and its versions. - /// - public Publish? Publish - { - get - { - if (!this.Properties.TryGetValue("publish", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["publish"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Publish?.Validate(); - } - - public ChangePublicationStatus() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - ChangePublicationStatus(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static ChangePublicationStatus FromRawUnchecked( - Dictionary properties - ) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/UpdateFileRequestProperties/ChangePublicationStatusProperties/Publish.cs b/src/Imagekit/Models/Files/UpdateFileRequestProperties/ChangePublicationStatusProperties/Publish.cs deleted file mode 100644 index 41bb4a5b..00000000 --- a/src/Imagekit/Models/Files/UpdateFileRequestProperties/ChangePublicationStatusProperties/Publish.cs +++ /dev/null @@ -1,90 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Core; -using Imagekit.Exceptions; - -namespace Imagekit.Models.Files.UpdateFileRequestProperties.ChangePublicationStatusProperties; - -/// -/// Configure the publication status of a file and its versions. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class Publish : ModelBase, IFromRaw -{ - /// - /// Set to `true` to publish the file. Set to `false` to unpublish the file. - /// - public required bool IsPublished - { - get - { - if (!this.Properties.TryGetValue("isPublished", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'isPublished' cannot be null", - new ArgumentOutOfRangeException("isPublished", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["isPublished"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Set to `true` to publish/unpublish all versions of the file. Set to `false` - /// to publish/unpublish only the current version of the file. - /// - public bool? IncludeFileVersions - { - get - { - if (!this.Properties.TryGetValue("includeFileVersions", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["includeFileVersions"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.IsPublished; - _ = this.IncludeFileVersions; - } - - public Publish() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Publish(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Publish FromRawUnchecked(Dictionary properties) - { - return new(properties); - } - - [SetsRequiredMembers] - public Publish(bool isPublished) - : this() - { - this.IsPublished = isPublished; - } -} diff --git a/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetails.cs b/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetails.cs deleted file mode 100644 index 772e7d73..00000000 --- a/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetails.cs +++ /dev/null @@ -1,207 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Core; -using Imagekit.Models.Files.UpdateFileRequestProperties.UpdateFileDetailsProperties; - -namespace Imagekit.Models.Files.UpdateFileRequestProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class UpdateFileDetails : ModelBase, IFromRaw -{ - /// - /// Define an important area in the image in the format `x,y,width,height` e.g. - /// `10,10,100,100`. Send `null` to unset this value. - /// - public string? CustomCoordinates - { - get - { - if (!this.Properties.TryGetValue("customCoordinates", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["customCoordinates"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// A key-value data to be associated with the asset. To unset a key, send `null` - /// value for that key. Before setting any custom metadata on an asset you have - /// to create the field using custom metadata fields API. - /// - public Dictionary? CustomMetadata - { - get - { - if (!this.Properties.TryGetValue("customMetadata", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["customMetadata"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Optional text to describe the contents of the file. - /// - public string? Description - { - get - { - if (!this.Properties.TryGetValue("description", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["description"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Array of extensions to be applied to the asset. Each extension can be configured - /// with specific parameters based on the extension type. - /// - public List? Extensions - { - get - { - if (!this.Properties.TryGetValue("extensions", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["extensions"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// An array of AITags associated with the file that you want to remove, e.g. - /// `["car", "vehicle", "motorsports"]`. - /// - /// If you want to remove all AITags associated with the file, send a string - "all". - /// - /// Note: The remove operation for `AITags` executes before any of the `extensions` - /// are processed. - /// - public RemoveAITags? RemoveAITags - { - get - { - if (!this.Properties.TryGetValue("removeAITags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["removeAITags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// An array of tags associated with the file, such as `["tag1", "tag2"]`. Send - /// `null` to unset all tags associated with the file. - /// - public List? Tags - { - get - { - if (!this.Properties.TryGetValue("tags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["tags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The final status of extensions after they have completed execution will be - /// delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) - /// about the webhook payload structure. - /// - public string? WebhookURL - { - get - { - if (!this.Properties.TryGetValue("webhookUrl", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["webhookUrl"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.CustomCoordinates; - _ = this.CustomMetadata; - _ = this.Description; - foreach (var item in this.Extensions ?? []) - { - item.Validate(); - } - this.RemoveAITags?.Validate(); - _ = this.Tags; - _ = this.WebhookURL; - } - - public UpdateFileDetails() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - UpdateFileDetails(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static UpdateFileDetails FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/Extension.cs b/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/Extension.cs deleted file mode 100644 index 4eaae50d..00000000 --- a/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/Extension.cs +++ /dev/null @@ -1,177 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Files.FileUpdateParamsProperties.UpdateProperties.UpdateFileDetailsProperties.ExtensionProperties; -using ExtensionVariants = Imagekit.Models.Files.FileUpdateParamsProperties.UpdateProperties.UpdateFileDetailsProperties.ExtensionVariants; - -namespace Imagekit.Models.Files.FileUpdateParamsProperties.UpdateProperties.UpdateFileDetailsProperties; - -[JsonConverter(typeof(ExtensionConverter))] -public abstract record class Extension -{ - internal Extension() { } - - public static implicit operator Extension(RemoveBg value) => - new ExtensionVariants::RemoveBg(value); - - public static implicit operator Extension(AutoTaggingExtension value) => - new ExtensionVariants::AutoTaggingExtension(value); - - public bool TryPickRemoveBg([NotNullWhen(true)] out RemoveBg? value) - { - value = (this as ExtensionVariants::RemoveBg)?.Value; - return value != null; - } - - public bool TryPickAutoTagging([NotNullWhen(true)] out AutoTaggingExtension? value) - { - value = (this as ExtensionVariants::AutoTaggingExtension)?.Value; - return value != null; - } - - public bool TryPickAIAutoDescription([NotNullWhen(true)] out JsonElement? value) - { - value = (this as ExtensionVariants::AIAutoDescription)?.Value; - return value != null; - } - - public void Switch( - Action removeBg, - Action autoTagging, - Action aiAutoDescription - ) - { - switch (this) - { - case ExtensionVariants::RemoveBg inner: - removeBg(inner); - break; - case ExtensionVariants::AutoTaggingExtension inner: - autoTagging(inner); - break; - case ExtensionVariants::AIAutoDescription inner: - aiAutoDescription(inner); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match( - Func removeBg, - Func autoTagging, - Func aiAutoDescription - ) - { - return this switch - { - ExtensionVariants::RemoveBg inner => removeBg(inner), - ExtensionVariants::AutoTaggingExtension inner => autoTagging(inner), - ExtensionVariants::AIAutoDescription inner => aiAutoDescription(inner), - _ => throw new InvalidOperationException(), - }; - } - - public abstract void Validate(); -} - -sealed class ExtensionConverter : JsonConverter -{ - public override Extension? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - var json = JsonSerializer.Deserialize(ref reader, options); - string? name; - try - { - name = json.GetProperty("name").GetString(); - } - catch - { - name = null; - } - - switch (name) - { - case "remove-bg": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - return new ExtensionVariants::RemoveBg(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "ai-auto-description": - { - List exceptions = []; - - try - { - return new ExtensionVariants::AIAutoDescription( - JsonSerializer.Deserialize(json, options) - ); - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - default: - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize( - json, - options - ); - if (deserialized != null) - { - return new ExtensionVariants::AutoTaggingExtension(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - } - } - - public override void Write( - Utf8JsonWriter writer, - Extension value, - JsonSerializerOptions options - ) - { - object variant = value switch - { - ExtensionVariants::RemoveBg(var removeBg) => removeBg, - ExtensionVariants::AutoTaggingExtension(var autoTagging) => autoTagging, - ExtensionVariants::AIAutoDescription(var aiAutoDescription) => aiAutoDescription, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/ExtensionProperties/AutoTaggingExtension.cs b/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/ExtensionProperties/AutoTaggingExtension.cs deleted file mode 100644 index 61e0caf0..00000000 --- a/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/ExtensionProperties/AutoTaggingExtension.cs +++ /dev/null @@ -1,100 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Files.FileUpdateParamsProperties.UpdateProperties.UpdateFileDetailsProperties.ExtensionProperties.AutoTaggingExtensionProperties; - -namespace Imagekit.Models.Files.FileUpdateParamsProperties.UpdateProperties.UpdateFileDetailsProperties.ExtensionProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class AutoTaggingExtension : ModelBase, IFromRaw -{ - /// - /// Maximum number of tags to attach to the asset. - /// - public required long MaxTags - { - get - { - if (!this.Properties.TryGetValue("maxTags", out JsonElement element)) - throw new ArgumentOutOfRangeException("maxTags", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["maxTags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Minimum confidence level for tags to be considered valid. - /// - public required long MinConfidence - { - get - { - if (!this.Properties.TryGetValue("minConfidence", out JsonElement element)) - throw new ArgumentOutOfRangeException("minConfidence", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["minConfidence"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies the auto-tagging extension used. - /// - public required ApiEnum Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - throw new ArgumentOutOfRangeException("name", "Missing required argument"); - - return JsonSerializer.Deserialize>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.MaxTags; - _ = this.MinConfidence; - this.Name.Validate(); - } - - public AutoTaggingExtension() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - AutoTaggingExtension(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static AutoTaggingExtension FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs b/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs deleted file mode 100644 index 2f988a2d..00000000 --- a/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/ExtensionProperties/AutoTaggingExtensionProperties/Name.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files.FileUpdateParamsProperties.UpdateProperties.UpdateFileDetailsProperties.ExtensionProperties.AutoTaggingExtensionProperties; - -/// -/// Specifies the auto-tagging extension used. -/// -[JsonConverter(typeof(NameConverter))] -public enum Name -{ - GoogleAutoTagging, - AwsAutoTagging, -} - -sealed class NameConverter : JsonConverter -{ - public override Name Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "google-auto-tagging" => Name.GoogleAutoTagging, - "aws-auto-tagging" => Name.AwsAutoTagging, - _ => (Name)(-1), - }; - } - - public override void Write(Utf8JsonWriter writer, Name value, JsonSerializerOptions options) - { - JsonSerializer.Serialize( - writer, - value switch - { - Name.GoogleAutoTagging => "google-auto-tagging", - Name.AwsAutoTagging => "aws-auto-tagging", - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/ExtensionProperties/RemoveBg.cs b/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/ExtensionProperties/RemoveBg.cs deleted file mode 100644 index 195549a9..00000000 --- a/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/ExtensionProperties/RemoveBg.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Files.FileUpdateParamsProperties.UpdateProperties.UpdateFileDetailsProperties.ExtensionProperties.RemoveBgProperties; - -namespace Imagekit.Models.Files.FileUpdateParamsProperties.UpdateProperties.UpdateFileDetailsProperties.ExtensionProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class RemoveBg : ModelBase, IFromRaw -{ - /// - /// Specifies the background removal extension. - /// - public JsonElement Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - throw new ArgumentOutOfRangeException("name", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public Options? Options - { - get - { - if (!this.Properties.TryGetValue("options", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["options"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Options?.Validate(); - } - - public RemoveBg() - { - this.Name = JsonSerializer.Deserialize("\"remove-bg\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - RemoveBg(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static RemoveBg FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/ExtensionProperties/RemoveBgProperties/Options.cs b/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/ExtensionProperties/RemoveBgProperties/Options.cs deleted file mode 100644 index b2051fb0..00000000 --- a/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/ExtensionProperties/RemoveBgProperties/Options.cs +++ /dev/null @@ -1,122 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files.FileUpdateParamsProperties.UpdateProperties.UpdateFileDetailsProperties.ExtensionProperties.RemoveBgProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Options : ModelBase, IFromRaw -{ - /// - /// Whether to add an artificial shadow to the result. Default is false. Note: - /// Adding shadows is currently only supported for car photos. - /// - public bool? AddShadow - { - get - { - if (!this.Properties.TryGetValue("add_shadow", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["add_shadow"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies a solid color background using hex code (e.g., "81d4fa", "fff") - /// or color name (e.g., "green"). If this parameter is set, `bg_image_url` must - /// be empty. - /// - public string? BgColor - { - get - { - if (!this.Properties.TryGetValue("bg_color", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["bg_color"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Sets a background image from a URL. If this parameter is set, `bg_color` - /// must be empty. - /// - public string? BgImageURL - { - get - { - if (!this.Properties.TryGetValue("bg_image_url", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["bg_image_url"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Allows semi-transparent regions in the result. Default is true. Note: Semitransparency - /// is currently only supported for car windows. - /// - public bool? Semitransparency - { - get - { - if (!this.Properties.TryGetValue("semitransparency", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["semitransparency"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.AddShadow; - _ = this.BgColor; - _ = this.BgImageURL; - _ = this.Semitransparency; - } - - public Options() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Options(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Options FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/ExtensionVariants/All.cs b/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/ExtensionVariants/All.cs deleted file mode 100644 index b1d2c160..00000000 --- a/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/ExtensionVariants/All.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System.Text.Json; -using ExtensionProperties = Imagekit.Models.Files.FileUpdateParamsProperties.UpdateProperties.UpdateFileDetailsProperties.ExtensionProperties; - -namespace Imagekit.Models.Files.FileUpdateParamsProperties.UpdateProperties.UpdateFileDetailsProperties.ExtensionVariants; - -public sealed record class RemoveBg(ExtensionProperties::RemoveBg Value) - : Extension, - IVariant -{ - public static RemoveBg From(ExtensionProperties::RemoveBg value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class AutoTaggingExtension(ExtensionProperties::AutoTaggingExtension Value) - : Extension, - IVariant -{ - public static AutoTaggingExtension From(ExtensionProperties::AutoTaggingExtension value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class AIAutoDescription(JsonElement Value) - : Extension, - IVariant -{ - public static AIAutoDescription From(JsonElement value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/RemoveAITags.cs b/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/RemoveAITags.cs deleted file mode 100644 index a5ab01a0..00000000 --- a/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/RemoveAITags.cs +++ /dev/null @@ -1,148 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Files.FileUpdateParamsProperties.UpdateProperties.UpdateFileDetailsProperties.RemoveAITagsVariants; - -namespace Imagekit.Models.Files.FileUpdateParamsProperties.UpdateProperties.UpdateFileDetailsProperties; - -/// -/// An array of AITags associated with the file that you want to remove, e.g. `["car", -/// "vehicle", "motorsports"]`. -/// -/// If you want to remove all AITags associated with the file, send a string - "all". -/// -/// Note: The remove operation for `AITags` executes before any of the `extensions` -/// are processed. -/// -[JsonConverter(typeof(RemoveAITagsConverter))] -public record class RemoveAITags -{ - public object Value { get; private init; } - - public RemoveAITags(List value) - { - Value = value; - } - - public RemoveAITags(UnionMember1 value) - { - Value = value; - } - - RemoveAITags(UnknownVariant value) - { - Value = value; - } - - public static RemoveAITags CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickStrings([NotNullWhen(true)] out List? value) - { - value = this.Value as List; - return value != null; - } - - public bool TryPickAll([NotNullWhen(true)] out UnionMember1? value) - { - value = this.Value as UnionMember1; - return value != null; - } - - public void Switch(Action> strings, Action all) - { - switch (this.Value) - { - case List value: - strings(value); - break; - case UnionMember1 value: - all(value); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match(Func, T> strings, Func all) - { - return this.Value switch - { - Strings inner => strings(inner), - All inner => all(inner), - _ => throw new InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException( - "Data did not match any variant of RemoveAITags" - ); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class RemoveAITagsConverter : JsonConverter -{ - public override RemoveAITags? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - deserialized.Validate(); - return new RemoveAITags(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - var deserialized = JsonSerializer.Deserialize>(ref reader, options); - if (deserialized != null) - { - return new RemoveAITags(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - - public override void Write( - Utf8JsonWriter writer, - RemoveAITags value, - JsonSerializerOptions options - ) - { - object variant = value switch - { - Strings(var strings) => strings, - All(var all) => all, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/RemoveAITagsProperties/UnionMember1.cs b/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/RemoveAITagsProperties/UnionMember1.cs deleted file mode 100644 index 162cc220..00000000 --- a/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/RemoveAITagsProperties/UnionMember1.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; - -namespace Imagekit.Models.Files.UpdateFileRequestProperties.UpdateFileDetailsProperties.RemoveAITagsProperties; - -[JsonConverter(typeof(Converter))] -public class UnionMember1 -{ - public JsonElement Json { get; private init; } - - public UnionMember1() - { - Json = JsonSerializer.Deserialize("\"all\""); - } - - UnionMember1(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new UnionMember1().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'UnionMember1'"); - } - } - - class Converter : JsonConverter - { - public override UnionMember1? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write( - Utf8JsonWriter writer, - UnionMember1 value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/RemoveAITagsVariants/All.cs b/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/RemoveAITagsVariants/All.cs deleted file mode 100644 index 4fd3a772..00000000 --- a/src/Imagekit/Models/Files/UpdateFileRequestProperties/UpdateFileDetailsProperties/RemoveAITagsVariants/All.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System.Collections.Generic; -using System.Text.Json; - -namespace Imagekit.Models.Files.FileUpdateParamsProperties.UpdateProperties.UpdateFileDetailsProperties.RemoveAITagsVariants; - -public sealed record class Strings(List Value) - : RemoveAITags, - IVariant> -{ - public static Strings From(List value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class All(JsonElement Value) : RemoveAITags, IVariant -{ - public static All From(JsonElement value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/Files/Versions/VersionDeleteParams.cs b/src/Imagekit/Models/Files/Versions/VersionDeleteParams.cs deleted file mode 100644 index 7b43acb3..00000000 --- a/src/Imagekit/Models/Files/Versions/VersionDeleteParams.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using System.Net.Http; - -namespace Imagekit.Models.Files.Versions; - -/// -/// This API deletes a non-current file version permanently. The API returns an empty response. -/// -/// Note: If you want to delete all versions of a file, use the delete file API. -/// -public sealed record class VersionDeleteParams : ParamsBase -{ - public required string FileID; - - public required string VersionID; - - public override Uri Url(IImageKitClient client) - { - return new UriBuilder( - client.BaseUrl.ToString().TrimEnd('/') - + string.Format("/v1/files/{0}/versions/{1}", this.FileID, this.VersionID) - ) - { - Query = this.QueryString(client), - }.Uri; - } - - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} diff --git a/src/Imagekit/Models/Files/Versions/VersionDeleteResponse.cs b/src/Imagekit/Models/Files/Versions/VersionDeleteResponse.cs deleted file mode 100644 index b5ca5287..00000000 --- a/src/Imagekit/Models/Files/Versions/VersionDeleteResponse.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files.Versions; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class VersionDeleteResponse : ModelBase, IFromRaw -{ - public override void Validate() { } - - public VersionDeleteResponse() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - VersionDeleteResponse(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static VersionDeleteResponse FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Files/Versions/VersionGetParams.cs b/src/Imagekit/Models/Files/Versions/VersionGetParams.cs deleted file mode 100644 index f1850a9a..00000000 --- a/src/Imagekit/Models/Files/Versions/VersionGetParams.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using System.Net.Http; - -namespace Imagekit.Models.Files.Versions; - -/// -/// This API returns an object with details or attributes of a file version. -/// -public sealed record class VersionGetParams : ParamsBase -{ - public required string FileID; - - public required string VersionID; - - public override Uri Url(IImageKitClient client) - { - return new UriBuilder( - client.BaseUrl.ToString().TrimEnd('/') - + string.Format("/v1/files/{0}/versions/{1}", this.FileID, this.VersionID) - ) - { - Query = this.QueryString(client), - }.Uri; - } - - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} diff --git a/src/Imagekit/Models/Files/Versions/VersionListParams.cs b/src/Imagekit/Models/Files/Versions/VersionListParams.cs deleted file mode 100644 index 359cb066..00000000 --- a/src/Imagekit/Models/Files/Versions/VersionListParams.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using System.Net.Http; - -namespace Imagekit.Models.Files.Versions; - -/// -/// This API returns details of all versions of a file. -/// -public sealed record class VersionListParams : ParamsBase -{ - public required string FileID; - - public override Uri Url(IImageKitClient client) - { - return new UriBuilder( - client.BaseUrl.ToString().TrimEnd('/') - + string.Format("/v1/files/{0}/versions", this.FileID) - ) - { - Query = this.QueryString(client), - }.Uri; - } - - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} diff --git a/src/Imagekit/Models/Files/Versions/VersionRestoreParams.cs b/src/Imagekit/Models/Files/Versions/VersionRestoreParams.cs deleted file mode 100644 index 71a8ca90..00000000 --- a/src/Imagekit/Models/Files/Versions/VersionRestoreParams.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using System.Net.Http; - -namespace Imagekit.Models.Files.Versions; - -/// -/// This API restores a file version as the current file version. -/// -public sealed record class VersionRestoreParams : ParamsBase -{ - public required string FileID; - - public required string VersionID; - - public override Uri Url(IImageKitClient client) - { - return new UriBuilder( - client.BaseUrl.ToString().TrimEnd('/') - + string.Format("/v1/files/{0}/versions/{1}/restore", this.FileID, this.VersionID) - ) - { - Query = this.QueryString(client), - }.Uri; - } - - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} diff --git a/src/Imagekit/Models/Folders/FolderCopyParams.cs b/src/Imagekit/Models/Folders/FolderCopyParams.cs deleted file mode 100644 index 6c02053b..00000000 --- a/src/Imagekit/Models/Folders/FolderCopyParams.cs +++ /dev/null @@ -1,120 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Net.Http; -using System.Text; -using System.Text.Json; - -namespace Imagekit.Models.Folders; - -/// -/// This will copy one folder into another. The selected folder, its nested folders, -/// files, and their versions (in `includeVersions` is set to true) are copied in -/// this operation. Note: If any file at the destination has the same name as the -/// source file, then the source file and its versions will be appended to the destination -/// file version history. -/// -public sealed record class FolderCopyParams : ParamsBase -{ - public Dictionary BodyProperties { get; set; } = []; - - /// - /// Full path to the destination folder where you want to copy the source folder - /// into. - /// - public required string DestinationPath - { - get - { - if (!this.BodyProperties.TryGetValue("destinationPath", out JsonElement element)) - throw new ArgumentOutOfRangeException( - "destinationPath", - "Missing required argument" - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("destinationPath"); - } - set - { - this.BodyProperties["destinationPath"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The full path to the source folder you want to copy. - /// - public required string SourceFolderPath - { - get - { - if (!this.BodyProperties.TryGetValue("sourceFolderPath", out JsonElement element)) - throw new ArgumentOutOfRangeException( - "sourceFolderPath", - "Missing required argument" - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("sourceFolderPath"); - } - set - { - this.BodyProperties["sourceFolderPath"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Option to copy all versions of files that are nested inside the selected - /// folder. By default, only the current version of each file will be copied. - /// When set to true, all versions of each file will be copied. Default value - /// - `false`. - /// - public bool? IncludeVersions - { - get - { - if (!this.BodyProperties.TryGetValue("includeVersions", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["includeVersions"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override Uri Url(IImageKitClient client) - { - return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/bulkJobs/copyFolder") - { - Query = this.QueryString(client), - }.Uri; - } - - public StringContent BodyContent() - { - return new( - JsonSerializer.Serialize(this.BodyProperties), - Encoding.UTF8, - "application/json" - ); - } - - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} diff --git a/src/Imagekit/Models/Folders/FolderCopyResponse.cs b/src/Imagekit/Models/Folders/FolderCopyResponse.cs deleted file mode 100644 index 442959aa..00000000 --- a/src/Imagekit/Models/Folders/FolderCopyResponse.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Folders; - -/// -/// Job submitted successfully. A `jobId` will be returned. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class FolderCopyResponse : ModelBase, IFromRaw -{ - /// - /// Unique identifier of the bulk job. This can be used to check the status of - /// the bulk job. - /// - public required string JobID - { - get - { - if (!this.Properties.TryGetValue("jobId", out JsonElement element)) - throw new ArgumentOutOfRangeException("jobId", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("jobId"); - } - set - { - this.Properties["jobId"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.JobID; - } - - public FolderCopyResponse() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - FolderCopyResponse(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static FolderCopyResponse FromRawUnchecked(Dictionary properties) - { - return new(properties); - } - - [SetsRequiredMembers] - public FolderCopyResponse(string jobID) - : this() - { - this.JobID = jobID; - } -} diff --git a/src/Imagekit/Models/Folders/FolderCreateParams.cs b/src/Imagekit/Models/Folders/FolderCreateParams.cs deleted file mode 100644 index 5116fc00..00000000 --- a/src/Imagekit/Models/Folders/FolderCreateParams.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Net.Http; -using System.Text; -using System.Text.Json; - -namespace Imagekit.Models.Folders; - -/// -/// This will create a new folder. You can specify the folder name and location of -/// the parent folder where this new folder should be created. -/// -public sealed record class FolderCreateParams : ParamsBase -{ - public Dictionary BodyProperties { get; set; } = []; - - /// - /// The folder will be created with this name. - /// - /// All characters except alphabets and numbers (inclusive of unicode letters, - /// marks, and numerals in other languages) will be replaced by an underscore - /// i.e. `_`. - /// - public required string FolderName - { - get - { - if (!this.BodyProperties.TryGetValue("folderName", out JsonElement element)) - throw new ArgumentOutOfRangeException("folderName", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("folderName"); - } - set - { - this.BodyProperties["folderName"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The folder where the new folder should be created, for root use `/` else the - /// path e.g. `containing/folder/`. - /// - /// Note: If any folder(s) is not present in the parentFolderPath parameter, - /// it will be automatically created. For example, if you pass `/product/images/summer`, - /// then `product`, `images`, and `summer` folders will be created if they don't - /// already exist. - /// - public required string ParentFolderPath - { - get - { - if (!this.BodyProperties.TryGetValue("parentFolderPath", out JsonElement element)) - throw new ArgumentOutOfRangeException( - "parentFolderPath", - "Missing required argument" - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("parentFolderPath"); - } - set - { - this.BodyProperties["parentFolderPath"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override Uri Url(IImageKitClient client) - { - return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/folder") - { - Query = this.QueryString(client), - }.Uri; - } - - public StringContent BodyContent() - { - return new( - JsonSerializer.Serialize(this.BodyProperties), - Encoding.UTF8, - "application/json" - ); - } - - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} diff --git a/src/Imagekit/Models/Folders/FolderCreateResponse.cs b/src/Imagekit/Models/Folders/FolderCreateResponse.cs deleted file mode 100644 index c470a9e0..00000000 --- a/src/Imagekit/Models/Folders/FolderCreateResponse.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Folders; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class FolderCreateResponse : ModelBase, IFromRaw -{ - public override void Validate() { } - - public FolderCreateResponse() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - FolderCreateResponse(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static FolderCreateResponse FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Folders/FolderDeleteParams.cs b/src/Imagekit/Models/Folders/FolderDeleteParams.cs deleted file mode 100644 index b0fb2116..00000000 --- a/src/Imagekit/Models/Folders/FolderDeleteParams.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Net.Http; -using System.Text; -using System.Text.Json; - -namespace Imagekit.Models.Folders; - -/// -/// This will delete a folder and all its contents permanently. The API returns an -/// empty response. -/// -public sealed record class FolderDeleteParams : ParamsBase -{ - public Dictionary BodyProperties { get; set; } = []; - - /// - /// Full path to the folder you want to delete. For example `/folder/to/delete/`. - /// - public required string FolderPath - { - get - { - if (!this.BodyProperties.TryGetValue("folderPath", out JsonElement element)) - throw new ArgumentOutOfRangeException("folderPath", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("folderPath"); - } - set - { - this.BodyProperties["folderPath"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override Uri Url(IImageKitClient client) - { - return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/folder") - { - Query = this.QueryString(client), - }.Uri; - } - - public StringContent BodyContent() - { - return new( - JsonSerializer.Serialize(this.BodyProperties), - Encoding.UTF8, - "application/json" - ); - } - - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} diff --git a/src/Imagekit/Models/Folders/FolderDeleteResponse.cs b/src/Imagekit/Models/Folders/FolderDeleteResponse.cs deleted file mode 100644 index 3ed1bc21..00000000 --- a/src/Imagekit/Models/Folders/FolderDeleteResponse.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Folders; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class FolderDeleteResponse : ModelBase, IFromRaw -{ - public override void Validate() { } - - public FolderDeleteResponse() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - FolderDeleteResponse(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static FolderDeleteResponse FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Folders/FolderMoveParams.cs b/src/Imagekit/Models/Folders/FolderMoveParams.cs deleted file mode 100644 index f3a44f8d..00000000 --- a/src/Imagekit/Models/Folders/FolderMoveParams.cs +++ /dev/null @@ -1,95 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Net.Http; -using System.Text; -using System.Text.Json; - -namespace Imagekit.Models.Folders; - -/// -/// This will move one folder into another. The selected folder, its nested folders, -/// files, and their versions are moved in this operation. Note: If any file at the -/// destination has the same name as the source file, then the source file and its -/// versions will be appended to the destination file version history. -/// -public sealed record class FolderMoveParams : ParamsBase -{ - public Dictionary BodyProperties { get; set; } = []; - - /// - /// Full path to the destination folder where you want to move the source folder - /// into. - /// - public required string DestinationPath - { - get - { - if (!this.BodyProperties.TryGetValue("destinationPath", out JsonElement element)) - throw new ArgumentOutOfRangeException( - "destinationPath", - "Missing required argument" - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("destinationPath"); - } - set - { - this.BodyProperties["destinationPath"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The full path to the source folder you want to move. - /// - public required string SourceFolderPath - { - get - { - if (!this.BodyProperties.TryGetValue("sourceFolderPath", out JsonElement element)) - throw new ArgumentOutOfRangeException( - "sourceFolderPath", - "Missing required argument" - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("sourceFolderPath"); - } - set - { - this.BodyProperties["sourceFolderPath"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override Uri Url(IImageKitClient client) - { - return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/bulkJobs/moveFolder") - { - Query = this.QueryString(client), - }.Uri; - } - - public StringContent BodyContent() - { - return new( - JsonSerializer.Serialize(this.BodyProperties), - Encoding.UTF8, - "application/json" - ); - } - - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} diff --git a/src/Imagekit/Models/Folders/FolderMoveResponse.cs b/src/Imagekit/Models/Folders/FolderMoveResponse.cs deleted file mode 100644 index 7360799e..00000000 --- a/src/Imagekit/Models/Folders/FolderMoveResponse.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Folders; - -/// -/// Job submitted successfully. A `jobId` will be returned. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class FolderMoveResponse : ModelBase, IFromRaw -{ - /// - /// Unique identifier of the bulk job. This can be used to check the status of - /// the bulk job. - /// - public required string JobID - { - get - { - if (!this.Properties.TryGetValue("jobId", out JsonElement element)) - throw new ArgumentOutOfRangeException("jobId", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("jobId"); - } - set - { - this.Properties["jobId"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.JobID; - } - - public FolderMoveResponse() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - FolderMoveResponse(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static FolderMoveResponse FromRawUnchecked(Dictionary properties) - { - return new(properties); - } - - [SetsRequiredMembers] - public FolderMoveResponse(string jobID) - : this() - { - this.JobID = jobID; - } -} diff --git a/src/Imagekit/Models/Folders/FolderRenameParams.cs b/src/Imagekit/Models/Folders/FolderRenameParams.cs deleted file mode 100644 index 0c529a6c..00000000 --- a/src/Imagekit/Models/Folders/FolderRenameParams.cs +++ /dev/null @@ -1,126 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Net.Http; -using System.Text; -using System.Text.Json; - -namespace Imagekit.Models.Folders; - -/// -/// This API allows you to rename an existing folder. The folder and all its nested -/// assets and sub-folders will remain unchanged, but their paths will be updated -/// to reflect the new folder name. -/// -public sealed record class FolderRenameParams : ParamsBase -{ - public Dictionary BodyProperties { get; set; } = []; - - /// - /// The full path to the folder you want to rename. - /// - public required string FolderPath - { - get - { - if (!this.BodyProperties.TryGetValue("folderPath", out JsonElement element)) - throw new ArgumentOutOfRangeException("folderPath", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("folderPath"); - } - set - { - this.BodyProperties["folderPath"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The new name for the folder. - /// - /// All characters except alphabets and numbers (inclusive of unicode letters, - /// marks, and numerals in other languages) and `-` will be replaced by an underscore - /// i.e. `_`. - /// - public required string NewFolderName - { - get - { - if (!this.BodyProperties.TryGetValue("newFolderName", out JsonElement element)) - throw new ArgumentOutOfRangeException("newFolderName", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("newFolderName"); - } - set - { - this.BodyProperties["newFolderName"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Option to purge cache for the old nested files and their versions' URLs. - /// - /// When set to true, it will internally issue a purge cache request on CDN to - /// remove the cached content of the old nested files and their versions. There - /// will only be one purge request for all the nested files, which will be counted - /// against your monthly purge quota. - /// - /// Note: A purge cache request will be issued against `https://ik.imagekit.io/old/folder/path*` - /// (with a wildcard at the end). This will remove all nested files, their versions' - /// URLs, and any transformations made using query parameters on these files - /// or their versions. However, the cache for file transformations made using - /// path parameters will persist. You can purge them using the purge API. For - /// more details, refer to the purge API documentation. - /// - /// Default value - `false` - /// - public bool? PurgeCache - { - get - { - if (!this.BodyProperties.TryGetValue("purgeCache", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.BodyProperties["purgeCache"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override Uri Url(IImageKitClient client) - { - return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/bulkJobs/renameFolder") - { - Query = this.QueryString(client), - }.Uri; - } - - public StringContent BodyContent() - { - return new( - JsonSerializer.Serialize(this.BodyProperties), - Encoding.UTF8, - "application/json" - ); - } - - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} diff --git a/src/Imagekit/Models/Folders/FolderRenameResponse.cs b/src/Imagekit/Models/Folders/FolderRenameResponse.cs deleted file mode 100644 index 9a18c431..00000000 --- a/src/Imagekit/Models/Folders/FolderRenameResponse.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Folders; - -/// -/// Job submitted successfully. A `jobId` will be returned. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class FolderRenameResponse : ModelBase, IFromRaw -{ - /// - /// Unique identifier of the bulk job. This can be used to check the status of - /// the bulk job. - /// - public required string JobID - { - get - { - if (!this.Properties.TryGetValue("jobId", out JsonElement element)) - throw new ArgumentOutOfRangeException("jobId", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("jobId"); - } - set - { - this.Properties["jobId"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.JobID; - } - - public FolderRenameResponse() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - FolderRenameResponse(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static FolderRenameResponse FromRawUnchecked(Dictionary properties) - { - return new(properties); - } - - [SetsRequiredMembers] - public FolderRenameResponse(string jobID) - : this() - { - this.JobID = jobID; - } -} diff --git a/src/Imagekit/Models/Folders/Job/JobGetParams.cs b/src/Imagekit/Models/Folders/Job/JobGetParams.cs deleted file mode 100644 index cacc3f64..00000000 --- a/src/Imagekit/Models/Folders/Job/JobGetParams.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Net.Http; - -namespace Imagekit.Models.Folders.Job; - -/// -/// This API returns the status of a bulk job like copy and move folder operations. -/// -public sealed record class JobGetParams : ParamsBase -{ - public required string JobID; - - public override Uri Url(IImageKitClient client) - { - return new UriBuilder( - client.BaseUrl.ToString().TrimEnd('/') + string.Format("/v1/bulkJobs/{0}", this.JobID) - ) - { - Query = this.QueryString(client), - }.Uri; - } - - public void AddHeadersToRequest(HttpRequestMessage request, IImageKitClient client) - { - ParamsBase.AddDefaultHeaders(request, client); - foreach (var item in this.HeaderProperties) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } -} diff --git a/src/Imagekit/Models/Folders/Job/JobGetResponse.cs b/src/Imagekit/Models/Folders/Job/JobGetResponse.cs deleted file mode 100644 index 5e20478b..00000000 --- a/src/Imagekit/Models/Folders/Job/JobGetResponse.cs +++ /dev/null @@ -1,125 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Folders.Job.JobGetResponseProperties; - -namespace Imagekit.Models.Folders.Job; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class JobGetResponse : ModelBase, IFromRaw -{ - /// - /// Unique identifier of the bulk job. - /// - public string? JobID - { - get - { - if (!this.Properties.TryGetValue("jobId", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["jobId"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Unique identifier of the purge request. This will be present only if `purgeCache` - /// is set to `true` in the rename folder API request. - /// - public string? PurgeRequestID - { - get - { - if (!this.Properties.TryGetValue("purgeRequestId", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["purgeRequestId"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Status of the bulk job. - /// - public ApiEnum? Status - { - get - { - if (!this.Properties.TryGetValue("status", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["status"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Type of the bulk job. - /// - public ApiEnum? Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.JobID; - _ = this.PurgeRequestID; - this.Status?.Validate(); - this.Type?.Validate(); - } - - public JobGetResponse() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - JobGetResponse(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static JobGetResponse FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Folders/Job/JobGetResponseProperties/Status.cs b/src/Imagekit/Models/Folders/Job/JobGetResponseProperties/Status.cs deleted file mode 100644 index 21ceca11..00000000 --- a/src/Imagekit/Models/Folders/Job/JobGetResponseProperties/Status.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using System = System; - -namespace Imagekit.Models.Folders.Job.JobGetResponseProperties; - -/// -/// Status of the bulk job. -/// -[JsonConverter(typeof(StatusConverter))] -public enum Status -{ - Pending, - Completed, -} - -sealed class StatusConverter : JsonConverter -{ - public override Status Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "Pending" => Status.Pending, - "Completed" => Status.Completed, - _ => (Status)(-1), - }; - } - - public override void Write(Utf8JsonWriter writer, Status value, JsonSerializerOptions options) - { - JsonSerializer.Serialize( - writer, - value switch - { - Status.Pending => "Pending", - Status.Completed => "Completed", - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Folders/Job/JobGetResponseProperties/Type.cs b/src/Imagekit/Models/Folders/Job/JobGetResponseProperties/Type.cs deleted file mode 100644 index d9f357b4..00000000 --- a/src/Imagekit/Models/Folders/Job/JobGetResponseProperties/Type.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using System = System; - -namespace Imagekit.Models.Folders.Job.JobGetResponseProperties; - -/// -/// Type of the bulk job. -/// -[JsonConverter(typeof(TypeConverter))] -public enum Type -{ - CopyFolder, - MoveFolder, - RenameFolder, -} - -sealed class TypeConverter : JsonConverter -{ - public override Type Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "COPY_FOLDER" => JobGetResponseProperties.Type.CopyFolder, - "MOVE_FOLDER" => JobGetResponseProperties.Type.MoveFolder, - "RENAME_FOLDER" => JobGetResponseProperties.Type.RenameFolder, - _ => (Type)(-1), - }; - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonSerializer.Serialize( - writer, - value switch - { - JobGetResponseProperties.Type.CopyFolder => "COPY_FOLDER", - JobGetResponseProperties.Type.MoveFolder => "MOVE_FOLDER", - JobGetResponseProperties.Type.RenameFolder => "RENAME_FOLDER", - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/GetImageAttributesOptions.cs b/src/Imagekit/Models/GetImageAttributesOptions.cs deleted file mode 100644 index 61119bc9..00000000 --- a/src/Imagekit/Models/GetImageAttributesOptions.cs +++ /dev/null @@ -1,366 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Core; -using Imagekit.Exceptions; - -namespace Imagekit.Models; - -/// -/// Options for generating responsive image attributes including `src`, `srcSet`, -/// and `sizes` for HTML `` elements. This schema extends `SrcOptions` to add -/// support for responsive image generation with breakpoints. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class GetImageAttributesOptions - : ModelBase, - IFromRaw -{ - /// - /// Accepts a relative or absolute path of the resource. If a relative path is - /// provided, it is appended to the `urlEndpoint`. If an absolute path is provided, - /// `urlEndpoint` is ignored. - /// - public required string Src - { - get - { - if (!this.Properties.TryGetValue("src", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'src' cannot be null", - new ArgumentOutOfRangeException("src", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'src' cannot be null", - new ArgumentNullException("src") - ); - } - set - { - this.Properties["src"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Get your urlEndpoint from the [ImageKit dashboard](https://imagekit.io/dashboard/url-endpoints). - /// - public required string URLEndpoint - { - get - { - if (!this.Properties.TryGetValue("urlEndpoint", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'urlEndpoint' cannot be null", - new ArgumentOutOfRangeException("urlEndpoint", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'urlEndpoint' cannot be null", - new ArgumentNullException("urlEndpoint") - ); - } - set - { - this.Properties["urlEndpoint"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// When you want the signed URL to expire, specified in seconds. If `expiresIn` - /// is anything above 0, the URL will always be signed even if `signed` is set - /// to false. If not specified and `signed` is `true`, the signed URL will not - /// expire (valid indefinitely). - /// - /// Example: Setting `expiresIn: 3600` will make the URL expire 1 hour from generation - /// time. After the expiry time, the signed URL will no longer be valid and ImageKit - /// will return a 401 Unauthorized status code. - /// - /// [Learn more](https://imagekit.io/docs/media-delivery-basic-security#how-to-generate-signed-urls). - /// - public double? ExpiresIn - { - get - { - if (!this.Properties.TryGetValue("expiresIn", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["expiresIn"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// These are additional query parameters that you want to add to the final URL. - /// They can be any query parameters and not necessarily related to ImageKit. - /// This is especially useful if you want to add a versioning parameter to your - /// URLs. - /// - public Dictionary? QueryParameters - { - get - { - if (!this.Properties.TryGetValue("queryParameters", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["queryParameters"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to sign the URL or not. Set this to `true` if you want to generate - /// a signed URL. If `signed` is `true` and `expiresIn` is not specified, the - /// signed URL will not expire (valid indefinitely). Note: If `expiresIn` is set - /// to any value above 0, the URL will always be signed regardless of this setting. - /// [Learn more](https://imagekit.io/docs/media-delivery-basic-security#how-to-generate-signed-urls). - /// - public bool? Signed - { - get - { - if (!this.Properties.TryGetValue("signed", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["signed"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// An array of objects specifying the transformations to be applied in the URL. - /// If more than one transformation is specified, they are applied in the order - /// they are specified as chained transformations. See [Chained transformations](https://imagekit.io/docs/transformations#chained-transformations). - /// - public List? Transformation - { - get - { - if (!this.Properties.TryGetValue("transformation", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["transformation"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// By default, the transformation string is added as a query parameter in the - /// URL, e.g., `?tr=w-100,h-100`. If you want to add the transformation string - /// in the path of the URL, set this to `path`. Learn more in the [Transformations - /// guide](https://imagekit.io/docs/transformations). - /// - public ApiEnum? TransformationPosition - { - get - { - if (!this.Properties.TryGetValue("transformationPosition", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["transformationPosition"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Custom list of **device-width breakpoints** in pixels. These define common - /// screen widths for responsive image generation. - /// - /// Defaults to `[640, 750, 828, 1080, 1200, 1920, 2048, 3840]`. Sorted automatically. - /// - public List? DeviceBreakpoints - { - get - { - if (!this.Properties.TryGetValue("deviceBreakpoints", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["deviceBreakpoints"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Custom list of **image-specific breakpoints** in pixels. Useful for generating - /// small variants (e.g., placeholders or thumbnails). - /// - /// Merged with `deviceBreakpoints` before calculating `srcSet`. Defaults to `[16, - /// 32, 48, 64, 96, 128, 256, 384]`. Sorted automatically. - /// - public List? ImageBreakpoints - { - get - { - if (!this.Properties.TryGetValue("imageBreakpoints", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["imageBreakpoints"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The value for the HTML `sizes` attribute (e.g., `"100vw"` or `"(min-width:768px) - /// 50vw, 100vw"`). - /// - /// - If it includes one or more `vw` units, breakpoints smaller than the corresponding - /// percentage of the smallest device width are excluded. - If it contains no - /// `vw` units, the full breakpoint list is used. - /// - /// Enables a width-based strategy and generates `w` descriptors in `srcSet`. - /// - public string? Sizes - { - get - { - if (!this.Properties.TryGetValue("sizes", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["sizes"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The intended display width of the image in pixels, used **only when the - /// `sizes` attribute is not provided**. - /// - /// Triggers a DPR-based strategy (1x and 2x variants) and generates `x` descriptors - /// in `srcSet`. - /// - /// Ignored if `sizes` is present. - /// - public double? Width - { - get - { - if (!this.Properties.TryGetValue("width", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["width"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public static implicit operator SrcOptions( - GetImageAttributesOptions getImageAttributesOptions - ) => - new() - { - Src = getImageAttributesOptions.Src, - URLEndpoint = getImageAttributesOptions.URLEndpoint, - ExpiresIn = getImageAttributesOptions.ExpiresIn, - QueryParameters = getImageAttributesOptions.QueryParameters, - Signed = getImageAttributesOptions.Signed, - Transformation = getImageAttributesOptions.Transformation, - TransformationPosition = getImageAttributesOptions.TransformationPosition, - }; - - public override void Validate() - { - _ = this.Src; - _ = this.URLEndpoint; - _ = this.ExpiresIn; - _ = this.QueryParameters; - _ = this.Signed; - foreach (var item in this.Transformation ?? []) - { - item.Validate(); - } - this.TransformationPosition?.Validate(); - _ = this.DeviceBreakpoints; - _ = this.ImageBreakpoints; - _ = this.Sizes; - _ = this.Width; - } - - public GetImageAttributesOptions() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - GetImageAttributesOptions(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static GetImageAttributesOptions FromRawUnchecked( - Dictionary properties - ) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/GetImageAttributesOptionsProperties/IntersectionMember1.cs b/src/Imagekit/Models/GetImageAttributesOptionsProperties/IntersectionMember1.cs deleted file mode 100644 index 87e64549..00000000 --- a/src/Imagekit/Models/GetImageAttributesOptionsProperties/IntersectionMember1.cs +++ /dev/null @@ -1,138 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Core; - -namespace Imagekit.Models.GetImageAttributesOptionsProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class IntersectionMember1 : ModelBase, IFromRaw -{ - /// - /// Custom list of **device-width breakpoints** in pixels. These define common - /// screen widths for responsive image generation. - /// - /// Defaults to `[640, 750, 828, 1080, 1200, 1920, 2048, 3840]`. Sorted automatically. - /// - public List? DeviceBreakpoints - { - get - { - if (!this.Properties.TryGetValue("deviceBreakpoints", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["deviceBreakpoints"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Custom list of **image-specific breakpoints** in pixels. Useful for generating - /// small variants (e.g., placeholders or thumbnails). - /// - /// Merged with `deviceBreakpoints` before calculating `srcSet`. Defaults to `[16, - /// 32, 48, 64, 96, 128, 256, 384]`. Sorted automatically. - /// - public List? ImageBreakpoints - { - get - { - if (!this.Properties.TryGetValue("imageBreakpoints", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["imageBreakpoints"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The value for the HTML `sizes` attribute (e.g., `"100vw"` or `"(min-width:768px) - /// 50vw, 100vw"`). - /// - /// - If it includes one or more `vw` units, breakpoints smaller than the corresponding - /// percentage of the smallest device width are excluded. - If it contains no - /// `vw` units, the full breakpoint list is used. - /// - /// Enables a width-based strategy and generates `w` descriptors in `srcSet`. - /// - public string? Sizes - { - get - { - if (!this.Properties.TryGetValue("sizes", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["sizes"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The intended display width of the image in pixels, used **only when the - /// `sizes` attribute is not provided**. - /// - /// Triggers a DPR-based strategy (1x and 2x variants) and generates `x` descriptors - /// in `srcSet`. - /// - /// Ignored if `sizes` is present. - /// - public double? Width - { - get - { - if (!this.Properties.TryGetValue("width", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["width"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.DeviceBreakpoints; - _ = this.ImageBreakpoints; - _ = this.Sizes; - _ = this.Width; - } - - public IntersectionMember1() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - IntersectionMember1(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static IntersectionMember1 FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/ImageOverlay.cs b/src/Imagekit/Models/ImageOverlay.cs deleted file mode 100644 index 67998652..00000000 --- a/src/Imagekit/Models/ImageOverlay.cs +++ /dev/null @@ -1,185 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.ImageOverlayProperties.IntersectionMember1Properties; - -namespace Imagekit.Models; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class ImageOverlay : ModelBase, IFromRaw -{ - public OverlayPosition? Position - { - get - { - if (!this.Properties.TryGetValue("position", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["position"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public OverlayTiming? Timing - { - get - { - if (!this.Properties.TryGetValue("timing", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["timing"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies the relative path to the image used as an overlay. - /// - public required string Input - { - get - { - if (!this.Properties.TryGetValue("input", out JsonElement element)) - throw new ArgumentOutOfRangeException("input", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("input"); - } - set - { - this.Properties["input"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The input path can be included in the layer as either `i-{input}` or `ie-{base64_encoded_input}`. - /// By default, the SDK determines the appropriate format automatically. To - /// always use base64 encoding (`ie-{base64}`), set this parameter to `base64`. - /// To always use plain text (`i-{input}`), set it to `plain`. - /// - public ApiEnum? Encoding - { - get - { - if (!this.Properties.TryGetValue("encoding", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["encoding"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Array of transformations to be applied to the overlay image. Supported transformations - /// depends on the base/parent asset. See overlays on [Images](https://imagekit.io/docs/add-overlays-on-images#list-of-supported-image-transformations-in-image-layers) - /// and [Videos](https://imagekit.io/docs/add-overlays-on-videos#list-of-transformations-supported-on-image-overlay). - /// - public List? Transformation - { - get - { - if (!this.Properties.TryGetValue("transformation", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["transformation"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public static implicit operator BaseOverlay(ImageOverlay imageOverlay) => - new() { Position = imageOverlay.Position, Timing = imageOverlay.Timing }; - - public override void Validate() - { - this.Position?.Validate(); - this.Timing?.Validate(); - _ = this.Input; - _ = this.Type; - this.Encoding?.Validate(); - foreach (var item in this.Transformation ?? []) - { - item.Validate(); - } - } - - public ImageOverlay() - { - this.Type = JsonSerializer.Deserialize("\"image\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - ImageOverlay(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static ImageOverlay FromRawUnchecked(Dictionary properties) - { - return new(properties); - } - - [SetsRequiredMembers] - public ImageOverlay(string input) - : this() - { - this.Input = input; - } -} diff --git a/src/Imagekit/Models/ImageOverlayProperties/IntersectionMember1.cs b/src/Imagekit/Models/ImageOverlayProperties/IntersectionMember1.cs deleted file mode 100644 index 39ffe018..00000000 --- a/src/Imagekit/Models/ImageOverlayProperties/IntersectionMember1.cs +++ /dev/null @@ -1,141 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.ImageOverlayProperties.IntersectionMember1Properties; - -namespace Imagekit.Models.ImageOverlayProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class IntersectionMember1 : ModelBase, IFromRaw -{ - /// - /// Specifies the relative path to the image used as an overlay. - /// - public required string Input - { - get - { - if (!this.Properties.TryGetValue("input", out JsonElement element)) - throw new ArgumentOutOfRangeException("input", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("input"); - } - set - { - this.Properties["input"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The input path can be included in the layer as either `i-{input}` or `ie-{base64_encoded_input}`. - /// By default, the SDK determines the appropriate format automatically. To - /// always use base64 encoding (`ie-{base64}`), set this parameter to `base64`. - /// To always use plain text (`i-{input}`), set it to `plain`. - /// - public ApiEnum? Encoding - { - get - { - if (!this.Properties.TryGetValue("encoding", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["encoding"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Array of transformations to be applied to the overlay image. Supported transformations - /// depends on the base/parent asset. See overlays on [Images](https://imagekit.io/docs/add-overlays-on-images#list-of-supported-image-transformations-in-image-layers) - /// and [Videos](https://imagekit.io/docs/add-overlays-on-videos#list-of-transformations-supported-on-image-overlay). - /// - public List? Transformation - { - get - { - if (!this.Properties.TryGetValue("transformation", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["transformation"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.Input; - _ = this.Type; - this.Encoding?.Validate(); - foreach (var item in this.Transformation ?? []) - { - item.Validate(); - } - } - - public IntersectionMember1() - { - this.Type = JsonSerializer.Deserialize("\"image\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - IntersectionMember1(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static IntersectionMember1 FromRawUnchecked(Dictionary properties) - { - return new(properties); - } - - [SetsRequiredMembers] - public IntersectionMember1(string input) - : this() - { - this.Input = input; - } -} diff --git a/src/Imagekit/Models/ImageOverlayProperties/IntersectionMember1Properties/Encoding.cs b/src/Imagekit/Models/ImageOverlayProperties/IntersectionMember1Properties/Encoding.cs deleted file mode 100644 index c7efb752..00000000 --- a/src/Imagekit/Models/ImageOverlayProperties/IntersectionMember1Properties/Encoding.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.ImageOverlayProperties.IntersectionMember1Properties; - -/// -/// The input path can be included in the layer as either `i-{input}` or `ie-{base64_encoded_input}`. -/// By default, the SDK determines the appropriate format automatically. To always -/// use base64 encoding (`ie-{base64}`), set this parameter to `base64`. To always -/// use plain text (`i-{input}`), set it to `plain`. -/// -[JsonConverter(typeof(EncodingConverter))] -public enum Encoding -{ - Auto, - Plain, - Base64, -} - -sealed class EncodingConverter : JsonConverter -{ - public override Encoding Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "auto" => Encoding.Auto, - "plain" => Encoding.Plain, - "base64" => Encoding.Base64, - _ => (Encoding)(-1), - }; - } - - public override void Write(Utf8JsonWriter writer, Encoding value, JsonSerializerOptions options) - { - JsonSerializer.Serialize( - writer, - value switch - { - Encoding.Auto => "auto", - Encoding.Plain => "plain", - Encoding.Base64 => "base64", - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Overlay.cs b/src/Imagekit/Models/Overlay.cs deleted file mode 100644 index 8c17b85e..00000000 --- a/src/Imagekit/Models/Overlay.cs +++ /dev/null @@ -1,342 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using OverlayVariants = Imagekit.Models.OverlayVariants; - -namespace Imagekit.Models; - -/// -/// Specifies an overlay to be applied on the parent image or video. ImageKit supports -/// overlays including images, text, videos, subtitles, and solid colors. See [Overlay -/// using layers](https://imagekit.io/docs/transformations#overlay-using-layers). -/// -[JsonConverter(typeof(OverlayConverter))] -public record class Overlay -{ - public object Value { get; private init; } - - public OverlayPosition? Position - { - get - { - return Match( - text: (x) => x.Position, - image: (x) => x.Position, - video: (x) => x.Position, - subtitle: (x) => x.Position, - solidColor: (x) => x.Position - ); - } - } - - public OverlayTiming? Timing - { - get - { - return Match( - text: (x) => x.Timing, - image: (x) => x.Timing, - video: (x) => x.Timing, - subtitle: (x) => x.Timing, - solidColor: (x) => x.Timing - ); - } - } - - public JsonElement Type - { - get - { - return Match( - text: (x) => x.Type, - image: (x) => x.Type, - video: (x) => x.Type, - subtitle: (x) => x.Type, - solidColor: (x) => x.Type - ); - } - } - - public string? Input - { - get - { - return Match( - text: (_) => null, - image: (x) => x.Input, - video: (x) => x.Input, - subtitle: (x) => x.Input, - solidColor: (_) => null - ); - } - } - - public Overlay(TextOverlay value) - { - Value = value; - } - - public Overlay(ImageOverlay value) - { - Value = value; - } - - public Overlay(VideoOverlay value) - { - Value = value; - } - - public Overlay(SubtitleOverlay value) - { - Value = value; - } - - public Overlay(SolidColorOverlay value) - { - Value = value; - } - - Overlay(UnknownVariant value) - { - Value = value; - } - - public static Overlay CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickText([NotNullWhen(true)] out TextOverlay? value) - { - value = this.Value as TextOverlay; - return value != null; - } - - public bool TryPickImage([NotNullWhen(true)] out ImageOverlay? value) - { - value = this.Value as ImageOverlay; - return value != null; - } - - public bool TryPickVideo([NotNullWhen(true)] out VideoOverlay? value) - { - value = this.Value as VideoOverlay; - return value != null; - } - - public bool TryPickSubtitle([NotNullWhen(true)] out SubtitleOverlay? value) - { - value = this.Value as SubtitleOverlay; - return value != null; - } - - public bool TryPickSolidColor([NotNullWhen(true)] out SolidColorOverlay? value) - { - value = this.Value as SolidColorOverlay; - return value != null; - } - - public void Switch( - Action text, - Action image, - Action video, - Action subtitle, - Action solidColor - ) - { - switch (this.Value) - { - case TextOverlay value: - text(value); - break; - case ImageOverlay value: - image(value); - break; - case VideoOverlay value: - video(value); - break; - case SubtitleOverlay value: - subtitle(value); - break; - case SolidColorOverlay value: - solidColor(value); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match( - Func text, - Func image, - Func video, - Func subtitle, - Func solidColor - ) - { - return this.Value switch - { - OverlayVariants::TextOverlay inner => text(inner), - OverlayVariants::ImageOverlay inner => image(inner), - OverlayVariants::VideoOverlay inner => video(inner), - OverlayVariants::SubtitleOverlay inner => subtitle(inner), - OverlayVariants::SolidColorOverlay inner => solidColor(inner), - _ => throw new InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of Overlay"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class OverlayConverter : JsonConverter -{ - public override Overlay? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - var json = JsonSerializer.Deserialize(ref reader, options); - string? type; - try - { - type = json.GetProperty("type").GetString(); - } - catch - { - type = null; - } - - switch (type) - { - case "text": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - deserialized.Validate(); - return new Overlay(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "image": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - deserialized.Validate(); - return new Overlay(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "video": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - deserialized.Validate(); - return new Overlay(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "subtitle": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - deserialized.Validate(); - return new Overlay(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - case "solidColor": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - deserialized.Validate(); - return new Overlay(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - default: - { - throw new Exception(); - } - } - } - - public override void Write(Utf8JsonWriter writer, Overlay value, JsonSerializerOptions options) - { - object variant = value switch - { - OverlayVariants::TextOverlay(var text) => text, - OverlayVariants::ImageOverlay(var image) => image, - OverlayVariants::VideoOverlay(var video) => video, - OverlayVariants::SubtitleOverlay(var subtitle) => subtitle, - OverlayVariants::SolidColorOverlay(var solidColor) => solidColor, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/OverlayPosition.cs b/src/Imagekit/Models/OverlayPosition.cs deleted file mode 100644 index 84ba3398..00000000 --- a/src/Imagekit/Models/OverlayPosition.cs +++ /dev/null @@ -1,106 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.OverlayPositionProperties; - -namespace Imagekit.Models; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class OverlayPosition : ModelBase, IFromRaw -{ - /// - /// Specifies the position of the overlay relative to the parent image or video. - /// Maps to `lfo` in the URL. - /// - public ApiEnum? Focus - { - get - { - if (!this.Properties.TryGetValue("focus", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["focus"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies the x-coordinate of the top-left corner of the base asset where - /// the overlay's top-left corner will be positioned. It also accepts arithmetic - /// expressions such as `bw_mul_0.4` or `bw_sub_cw`. Maps to `lx` in the URL. - /// Learn about [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). - /// - public X? X - { - get - { - if (!this.Properties.TryGetValue("x", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["x"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies the y-coordinate of the top-left corner of the base asset where - /// the overlay's top-left corner will be positioned. It also accepts arithmetic - /// expressions such as `bh_mul_0.4` or `bh_sub_ch`. Maps to `ly` in the URL. - /// Learn about [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). - /// - public Y? Y - { - get - { - if (!this.Properties.TryGetValue("y", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["y"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Focus?.Validate(); - this.X?.Validate(); - this.Y?.Validate(); - } - - public OverlayPosition() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - OverlayPosition(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static OverlayPosition FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/OverlayPositionProperties/Focus.cs b/src/Imagekit/Models/OverlayPositionProperties/Focus.cs deleted file mode 100644 index 9c9b013e..00000000 --- a/src/Imagekit/Models/OverlayPositionProperties/Focus.cs +++ /dev/null @@ -1,68 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.OverlayPositionProperties; - -/// -/// Specifies the position of the overlay relative to the parent image or video. -/// Maps to `lfo` in the URL. -/// -[JsonConverter(typeof(FocusConverter))] -public enum Focus -{ - Center, - Top, - Left, - Bottom, - Right, - TopLeft, - TopRight, - BottomLeft, - BottomRight, -} - -sealed class FocusConverter : JsonConverter -{ - public override Focus Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "center" => Focus.Center, - "top" => Focus.Top, - "left" => Focus.Left, - "bottom" => Focus.Bottom, - "right" => Focus.Right, - "top_left" => Focus.TopLeft, - "top_right" => Focus.TopRight, - "bottom_left" => Focus.BottomLeft, - "bottom_right" => Focus.BottomRight, - _ => (Focus)(-1), - }; - } - - public override void Write(Utf8JsonWriter writer, Focus value, JsonSerializerOptions options) - { - JsonSerializer.Serialize( - writer, - value switch - { - Focus.Center => "center", - Focus.Top => "top", - Focus.Left => "left", - Focus.Bottom => "bottom", - Focus.Right => "right", - Focus.TopLeft => "top_left", - Focus.TopRight => "top_right", - Focus.BottomLeft => "bottom_left", - Focus.BottomRight => "bottom_right", - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/OverlayPositionProperties/X.cs b/src/Imagekit/Models/OverlayPositionProperties/X.cs deleted file mode 100644 index eb97367e..00000000 --- a/src/Imagekit/Models/OverlayPositionProperties/X.cs +++ /dev/null @@ -1,134 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using XVariants = Imagekit.Models.OverlayPositionProperties.XVariants; - -namespace Imagekit.Models.OverlayPositionProperties; - -/// -/// Specifies the x-coordinate of the top-left corner of the base asset where the -/// overlay's top-left corner will be positioned. It also accepts arithmetic expressions -/// such as `bw_mul_0.4` or `bw_sub_cw`. Maps to `lx` in the URL. Learn about [Arithmetic -/// expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). -/// -[JsonConverter(typeof(XConverter))] -public record class X -{ - public object Value { get; private init; } - - public X(double value) - { - Value = value; - } - - public X(string value) - { - Value = value; - } - - X(UnknownVariant value) - { - Value = value; - } - - public static X CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public void Switch(Action @double, Action @string) - { - switch (this.Value) - { - case double value: - @double(value); - break; - case string value: - @string(value); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match(Func @double, Func @string) - { - return this.Value switch - { - XVariants::Double inner => @double(inner), - XVariants::String inner => @string(inner), - _ => throw new InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of X"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class XConverter : JsonConverter -{ - public override X? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - return new X(JsonSerializer.Deserialize(ref reader, options)); - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new X(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - - public override void Write(Utf8JsonWriter writer, X value, JsonSerializerOptions options) - { - object variant = value switch - { - XVariants::Double(var @double) => @double, - XVariants::String(var @string) => @string, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/OverlayPositionProperties/XVariants/All.cs b/src/Imagekit/Models/OverlayPositionProperties/XVariants/All.cs deleted file mode 100644 index 83d285fc..00000000 --- a/src/Imagekit/Models/OverlayPositionProperties/XVariants/All.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace Imagekit.Models.OverlayPositionProperties.XVariants; - -public sealed record class Double(double Value) : X, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class String(string Value) : X, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/OverlayPositionProperties/Y.cs b/src/Imagekit/Models/OverlayPositionProperties/Y.cs deleted file mode 100644 index 251b7302..00000000 --- a/src/Imagekit/Models/OverlayPositionProperties/Y.cs +++ /dev/null @@ -1,134 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using YVariants = Imagekit.Models.OverlayPositionProperties.YVariants; - -namespace Imagekit.Models.OverlayPositionProperties; - -/// -/// Specifies the y-coordinate of the top-left corner of the base asset where the -/// overlay's top-left corner will be positioned. It also accepts arithmetic expressions -/// such as `bh_mul_0.4` or `bh_sub_ch`. Maps to `ly` in the URL. Learn about [Arithmetic -/// expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). -/// -[JsonConverter(typeof(YConverter))] -public record class Y -{ - public object Value { get; private init; } - - public Y(double value) - { - Value = value; - } - - public Y(string value) - { - Value = value; - } - - Y(UnknownVariant value) - { - Value = value; - } - - public static Y CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public void Switch(Action @double, Action @string) - { - switch (this.Value) - { - case double value: - @double(value); - break; - case string value: - @string(value); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match(Func @double, Func @string) - { - return this.Value switch - { - YVariants::Double inner => @double(inner), - YVariants::String inner => @string(inner), - _ => throw new InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of Y"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class YConverter : JsonConverter -{ - public override Y? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - return new Y(JsonSerializer.Deserialize(ref reader, options)); - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new Y(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - - public override void Write(Utf8JsonWriter writer, Y value, JsonSerializerOptions options) - { - object variant = value switch - { - YVariants::Double(var @double) => @double, - YVariants::String(var @string) => @string, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/OverlayPositionProperties/YVariants/All.cs b/src/Imagekit/Models/OverlayPositionProperties/YVariants/All.cs deleted file mode 100644 index b123e666..00000000 --- a/src/Imagekit/Models/OverlayPositionProperties/YVariants/All.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace Imagekit.Models.OverlayPositionProperties.YVariants; - -public sealed record class Double(double Value) : Y, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class String(string Value) : Y, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/OverlayTiming.cs b/src/Imagekit/Models/OverlayTiming.cs deleted file mode 100644 index c559ab9d..00000000 --- a/src/Imagekit/Models/OverlayTiming.cs +++ /dev/null @@ -1,106 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.OverlayTimingProperties; - -namespace Imagekit.Models; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class OverlayTiming : ModelBase, IFromRaw -{ - /// - /// Specifies the duration (in seconds) during which the overlay should appear - /// on the base video. Accepts a positive number up to two decimal places (e.g., - /// `20` or `20.50`) and arithmetic expressions such as `bdu_mul_0.4` or `bdu_sub_idu`. - /// Applies only if the base asset is a video. Maps to `ldu` in the URL. - /// - public Duration? Duration - { - get - { - if (!this.Properties.TryGetValue("duration", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["duration"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies the end time (in seconds) for when the overlay should disappear - /// from the base video. If both end and duration are provided, duration is ignored. - /// Accepts a positive number up to two decimal places (e.g., `20` or `20.50`) - /// and arithmetic expressions such as `bdu_mul_0.4` or `bdu_sub_idu`. Applies - /// only if the base asset is a video. Maps to `leo` in the URL. - /// - public End? End - { - get - { - if (!this.Properties.TryGetValue("end", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["end"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies the start time (in seconds) for when the overlay should appear on - /// the base video. Accepts a positive number up to two decimal places (e.g., - /// `20` or `20.50`) and arithmetic expressions such as `bdu_mul_0.4` or `bdu_sub_idu`. - /// Applies only if the base asset is a video. Maps to `lso` in the URL. - /// - public Start? Start - { - get - { - if (!this.Properties.TryGetValue("start", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["start"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Duration?.Validate(); - this.End?.Validate(); - this.Start?.Validate(); - } - - public OverlayTiming() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - OverlayTiming(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static OverlayTiming FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/OverlayTimingProperties/Duration.cs b/src/Imagekit/Models/OverlayTimingProperties/Duration.cs deleted file mode 100644 index 037f53ac..00000000 --- a/src/Imagekit/Models/OverlayTimingProperties/Duration.cs +++ /dev/null @@ -1,134 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using DurationVariants = Imagekit.Models.OverlayTimingProperties.DurationVariants; - -namespace Imagekit.Models.OverlayTimingProperties; - -/// -/// Specifies the duration (in seconds) during which the overlay should appear on -/// the base video. Accepts a positive number up to two decimal places (e.g., `20` -/// or `20.50`) and arithmetic expressions such as `bdu_mul_0.4` or `bdu_sub_idu`. -/// Applies only if the base asset is a video. Maps to `ldu` in the URL. -/// -[JsonConverter(typeof(DurationConverter))] -public record class Duration -{ - public object Value { get; private init; } - - public Duration(double value) - { - Value = value; - } - - public Duration(string value) - { - Value = value; - } - - Duration(UnknownVariant value) - { - Value = value; - } - - public static Duration CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public void Switch(Action @double, Action @string) - { - switch (this.Value) - { - case double value: - @double(value); - break; - case string value: - @string(value); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match(Func @double, Func @string) - { - return this.Value switch - { - DurationVariants::Double inner => @double(inner), - DurationVariants::String inner => @string(inner), - _ => throw new InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of Duration"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class DurationConverter : JsonConverter -{ - public override Duration? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - return new Duration(JsonSerializer.Deserialize(ref reader, options)); - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new Duration(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - - public override void Write(Utf8JsonWriter writer, Duration value, JsonSerializerOptions options) - { - object variant = value switch - { - DurationVariants::Double(var @double) => @double, - DurationVariants::String(var @string) => @string, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/OverlayTimingProperties/DurationVariants/All.cs b/src/Imagekit/Models/OverlayTimingProperties/DurationVariants/All.cs deleted file mode 100644 index c4645813..00000000 --- a/src/Imagekit/Models/OverlayTimingProperties/DurationVariants/All.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace Imagekit.Models.OverlayTimingProperties.DurationVariants; - -public sealed record class Double(double Value) : Duration, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class String(string Value) : Duration, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/OverlayTimingProperties/End.cs b/src/Imagekit/Models/OverlayTimingProperties/End.cs deleted file mode 100644 index 67c1946f..00000000 --- a/src/Imagekit/Models/OverlayTimingProperties/End.cs +++ /dev/null @@ -1,135 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using EndVariants = Imagekit.Models.OverlayTimingProperties.EndVariants; - -namespace Imagekit.Models.OverlayTimingProperties; - -/// -/// Specifies the end time (in seconds) for when the overlay should disappear from -/// the base video. If both end and duration are provided, duration is ignored. Accepts -/// a positive number up to two decimal places (e.g., `20` or `20.50`) and arithmetic -/// expressions such as `bdu_mul_0.4` or `bdu_sub_idu`. Applies only if the base asset -/// is a video. Maps to `leo` in the URL. -/// -[JsonConverter(typeof(EndConverter))] -public record class End -{ - public object Value { get; private init; } - - public End(double value) - { - Value = value; - } - - public End(string value) - { - Value = value; - } - - End(UnknownVariant value) - { - Value = value; - } - - public static End CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public void Switch(Action @double, Action @string) - { - switch (this.Value) - { - case double value: - @double(value); - break; - case string value: - @string(value); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match(Func @double, Func @string) - { - return this.Value switch - { - EndVariants::Double inner => @double(inner), - EndVariants::String inner => @string(inner), - _ => throw new InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of End"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class EndConverter : JsonConverter -{ - public override End? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - return new End(JsonSerializer.Deserialize(ref reader, options)); - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new End(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - - public override void Write(Utf8JsonWriter writer, End value, JsonSerializerOptions options) - { - object variant = value switch - { - EndVariants::Double(var @double) => @double, - EndVariants::String(var @string) => @string, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/OverlayTimingProperties/EndVariants/All.cs b/src/Imagekit/Models/OverlayTimingProperties/EndVariants/All.cs deleted file mode 100644 index 58912819..00000000 --- a/src/Imagekit/Models/OverlayTimingProperties/EndVariants/All.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace Imagekit.Models.OverlayTimingProperties.EndVariants; - -public sealed record class Double(double Value) : End, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class String(string Value) : End, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/OverlayTimingProperties/Start.cs b/src/Imagekit/Models/OverlayTimingProperties/Start.cs deleted file mode 100644 index c858773a..00000000 --- a/src/Imagekit/Models/OverlayTimingProperties/Start.cs +++ /dev/null @@ -1,134 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using StartVariants = Imagekit.Models.OverlayTimingProperties.StartVariants; - -namespace Imagekit.Models.OverlayTimingProperties; - -/// -/// Specifies the start time (in seconds) for when the overlay should appear on the -/// base video. Accepts a positive number up to two decimal places (e.g., `20` or -/// `20.50`) and arithmetic expressions such as `bdu_mul_0.4` or `bdu_sub_idu`. Applies -/// only if the base asset is a video. Maps to `lso` in the URL. -/// -[JsonConverter(typeof(StartConverter))] -public record class Start -{ - public object Value { get; private init; } - - public Start(double value) - { - Value = value; - } - - public Start(string value) - { - Value = value; - } - - Start(UnknownVariant value) - { - Value = value; - } - - public static Start CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public void Switch(Action @double, Action @string) - { - switch (this.Value) - { - case double value: - @double(value); - break; - case string value: - @string(value); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match(Func @double, Func @string) - { - return this.Value switch - { - StartVariants::Double inner => @double(inner), - StartVariants::String inner => @string(inner), - _ => throw new InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of Start"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class StartConverter : JsonConverter -{ - public override Start? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - return new Start(JsonSerializer.Deserialize(ref reader, options)); - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new Start(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - - public override void Write(Utf8JsonWriter writer, Start value, JsonSerializerOptions options) - { - object variant = value switch - { - StartVariants::Double(var @double) => @double, - StartVariants::String(var @string) => @string, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/OverlayTimingProperties/StartVariants/All.cs b/src/Imagekit/Models/OverlayTimingProperties/StartVariants/All.cs deleted file mode 100644 index 6554819a..00000000 --- a/src/Imagekit/Models/OverlayTimingProperties/StartVariants/All.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace Imagekit.Models.OverlayTimingProperties.StartVariants; - -public sealed record class Double(double Value) : Start, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class String(string Value) : Start, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/OverlayVariants/All.cs b/src/Imagekit/Models/OverlayVariants/All.cs deleted file mode 100644 index 3ff187c8..00000000 --- a/src/Imagekit/Models/OverlayVariants/All.cs +++ /dev/null @@ -1,78 +0,0 @@ -using Models = Imagekit.Models; - -namespace Imagekit.Models.OverlayVariants; - -public sealed record class TextOverlay(Models::TextOverlay Value) - : Models::Overlay, - IVariant -{ - public static TextOverlay From(Models::TextOverlay value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class ImageOverlay(Models::ImageOverlay Value) - : Models::Overlay, - IVariant -{ - public static ImageOverlay From(Models::ImageOverlay value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class VideoOverlay(Models::VideoOverlay Value) - : Models::Overlay, - IVariant -{ - public static VideoOverlay From(Models::VideoOverlay value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class SubtitleOverlay(Models::SubtitleOverlay Value) - : Models::Overlay, - IVariant -{ - public static SubtitleOverlay From(Models::SubtitleOverlay value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} - -public sealed record class SolidColorOverlay(Models::SolidColorOverlay Value) - : Models::Overlay, - IVariant -{ - public static SolidColorOverlay From(Models::SolidColorOverlay value) - { - return new(value); - } - - public override void Validate() - { - this.Value.Validate(); - } -} diff --git a/src/Imagekit/Models/ResponsiveImageAttributes.cs b/src/Imagekit/Models/ResponsiveImageAttributes.cs deleted file mode 100644 index c368c569..00000000 --- a/src/Imagekit/Models/ResponsiveImageAttributes.cs +++ /dev/null @@ -1,144 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Core; -using Imagekit.Exceptions; - -namespace Imagekit.Models; - -/// -/// Resulting set of attributes suitable for an HTML `` element. Useful for enabling -/// responsive image loading with `srcSet` and `sizes`. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class ResponsiveImageAttributes - : ModelBase, - IFromRaw -{ - /// - /// URL for the *largest* candidate (assigned to plain `src`). - /// - public required string Src - { - get - { - if (!this.Properties.TryGetValue("src", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'src' cannot be null", - new ArgumentOutOfRangeException("src", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'src' cannot be null", - new ArgumentNullException("src") - ); - } - set - { - this.Properties["src"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// `sizes` returned (or synthesised as `100vw`). The value for the HTML `sizes` - /// attribute. - /// - public string? Sizes - { - get - { - if (!this.Properties.TryGetValue("sizes", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["sizes"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Candidate set with `w` or `x` descriptors. Multiple image URLs separated - /// by commas, each with a descriptor. - /// - public string? SrcSet - { - get - { - if (!this.Properties.TryGetValue("srcSet", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["srcSet"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Width as a number (if `width` was provided in the input options). - /// - public double? Width - { - get - { - if (!this.Properties.TryGetValue("width", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["width"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.Src; - _ = this.Sizes; - _ = this.SrcSet; - _ = this.Width; - } - - public ResponsiveImageAttributes() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - ResponsiveImageAttributes(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static ResponsiveImageAttributes FromRawUnchecked( - Dictionary properties - ) - { - return new(properties); - } - - [SetsRequiredMembers] - public ResponsiveImageAttributes(string src) - : this() - { - this.Src = src; - } -} diff --git a/src/Imagekit/Models/SolidColorOverlay.cs b/src/Imagekit/Models/SolidColorOverlay.cs deleted file mode 100644 index 1c2c5d47..00000000 --- a/src/Imagekit/Models/SolidColorOverlay.cs +++ /dev/null @@ -1,159 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class SolidColorOverlay : ModelBase, IFromRaw -{ - public OverlayPosition? Position - { - get - { - if (!this.Properties.TryGetValue("position", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["position"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public OverlayTiming? Timing - { - get - { - if (!this.Properties.TryGetValue("timing", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["timing"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies the color of the block using an RGB hex code (e.g., `FF0000`), - /// an RGBA code (e.g., `FFAABB50`), or a color name (e.g., `red`). If an 8-character - /// value is provided, the last two characters represent the opacity level (from - /// `00` for 0.00 to `99` for 0.99). - /// - public required string Color - { - get - { - if (!this.Properties.TryGetValue("color", out JsonElement element)) - throw new ArgumentOutOfRangeException("color", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("color"); - } - set - { - this.Properties["color"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Control width and height of the solid color overlay. Supported transformations - /// depend on the base/parent asset. See overlays on [Images](https://imagekit.io/docs/add-overlays-on-images#apply-transformation-on-solid-color-overlay) - /// and [Videos](https://imagekit.io/docs/add-overlays-on-videos#apply-transformations-on-solid-color-block-overlay). - /// - public List? Transformation - { - get - { - if (!this.Properties.TryGetValue("transformation", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["transformation"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public static implicit operator BaseOverlay(SolidColorOverlay solidColorOverlay) => - new() { Position = solidColorOverlay.Position, Timing = solidColorOverlay.Timing }; - - public override void Validate() - { - this.Position?.Validate(); - this.Timing?.Validate(); - _ = this.Color; - _ = this.Type; - foreach (var item in this.Transformation ?? []) - { - item.Validate(); - } - } - - public SolidColorOverlay() - { - this.Type = JsonSerializer.Deserialize("\"solidColor\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - SolidColorOverlay(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static SolidColorOverlay FromRawUnchecked(Dictionary properties) - { - return new(properties); - } - - [SetsRequiredMembers] - public SolidColorOverlay(string color) - : this() - { - this.Color = color; - } -} diff --git a/src/Imagekit/Models/SolidColorOverlayProperties/IntersectionMember1.cs b/src/Imagekit/Models/SolidColorOverlayProperties/IntersectionMember1.cs deleted file mode 100644 index 8cc91aad..00000000 --- a/src/Imagekit/Models/SolidColorOverlayProperties/IntersectionMember1.cs +++ /dev/null @@ -1,115 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.SolidColorOverlayProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class IntersectionMember1 : ModelBase, IFromRaw -{ - /// - /// Specifies the color of the block using an RGB hex code (e.g., `FF0000`), - /// an RGBA code (e.g., `FFAABB50`), or a color name (e.g., `red`). If an 8-character - /// value is provided, the last two characters represent the opacity level (from - /// `00` for 0.00 to `99` for 0.99). - /// - public required string Color - { - get - { - if (!this.Properties.TryGetValue("color", out JsonElement element)) - throw new ArgumentOutOfRangeException("color", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("color"); - } - set - { - this.Properties["color"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Control width and height of the solid color overlay. Supported transformations - /// depend on the base/parent asset. See overlays on [Images](https://imagekit.io/docs/add-overlays-on-images#apply-transformation-on-solid-color-overlay) - /// and [Videos](https://imagekit.io/docs/add-overlays-on-videos#apply-transformations-on-solid-color-block-overlay). - /// - public List? Transformation - { - get - { - if (!this.Properties.TryGetValue("transformation", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["transformation"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.Color; - _ = this.Type; - foreach (var item in this.Transformation ?? []) - { - item.Validate(); - } - } - - public IntersectionMember1() - { - this.Type = JsonSerializer.Deserialize("\"solidColor\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - IntersectionMember1(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static IntersectionMember1 FromRawUnchecked(Dictionary properties) - { - return new(properties); - } - - [SetsRequiredMembers] - public IntersectionMember1(string color) - : this() - { - this.Color = color; - } -} diff --git a/src/Imagekit/Models/SolidColorOverlayTransformation.cs b/src/Imagekit/Models/SolidColorOverlayTransformation.cs deleted file mode 100644 index 68937764..00000000 --- a/src/Imagekit/Models/SolidColorOverlayTransformation.cs +++ /dev/null @@ -1,174 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.SolidColorOverlayTransformationProperties; - -namespace Imagekit.Models; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class SolidColorOverlayTransformation - : ModelBase, - IFromRaw -{ - /// - /// Specifies the transparency level of the solid color overlay. Accepts integers - /// from `1` to `9`. - /// - public double? Alpha - { - get - { - if (!this.Properties.TryGetValue("alpha", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["alpha"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies the background color of the solid color overlay. Accepts an RGB - /// hex code (e.g., `FF0000`), an RGBA code (e.g., `FFAABB50`), or a color name. - /// - public string? Background - { - get - { - if (!this.Properties.TryGetValue("background", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["background"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Creates a linear gradient with two colors. Pass `true` for a default gradient, - /// or provide a string for a custom gradient. Only works if the base asset is - /// an image. See [gradient](https://imagekit.io/docs/effects-and-enhancements#gradient---e-gradient). - /// - public Gradient? Gradient - { - get - { - if (!this.Properties.TryGetValue("gradient", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["gradient"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Controls the height of the solid color overlay. Accepts a numeric value or - /// an arithmetic expression. Learn about [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). - /// - public Height? Height - { - get - { - if (!this.Properties.TryGetValue("height", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["height"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies the corner radius of the solid color overlay. Set to `max` for - /// circular or oval shape. See [radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). - /// - public Radius? Radius - { - get - { - if (!this.Properties.TryGetValue("radius", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["radius"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Controls the width of the solid color overlay. Accepts a numeric value or - /// an arithmetic expression (e.g., `bw_mul_0.2` or `bh_div_2`). Learn about [arithmetic - /// expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). - /// - public Width? Width - { - get - { - if (!this.Properties.TryGetValue("width", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["width"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.Alpha; - _ = this.Background; - this.Gradient?.Validate(); - this.Height?.Validate(); - this.Radius?.Validate(); - this.Width?.Validate(); - } - - public SolidColorOverlayTransformation() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - SolidColorOverlayTransformation(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static SolidColorOverlayTransformation FromRawUnchecked( - Dictionary properties - ) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Gradient.cs b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Gradient.cs deleted file mode 100644 index e900be7b..00000000 --- a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Gradient.cs +++ /dev/null @@ -1,138 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using GradientVariants = Imagekit.Models.SolidColorOverlayTransformationProperties.GradientVariants; - -namespace Imagekit.Models.SolidColorOverlayTransformationProperties; - -/// -/// Creates a linear gradient with two colors. Pass `true` for a default gradient, -/// or provide a string for a custom gradient. Only works if the base asset is an -/// image. See [gradient](https://imagekit.io/docs/effects-and-enhancements#gradient---e-gradient). -/// -[JsonConverter(typeof(GradientConverter))] -public record class Gradient -{ - public object Value { get; private init; } - - public Gradient(UnionMember0 value) - { - Value = value; - } - - public Gradient(string value) - { - Value = value; - } - - Gradient(UnknownVariant value) - { - Value = value; - } - - public static Gradient CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickTrue([NotNullWhen(true)] out UnionMember0? value) - { - value = this.Value as UnionMember0; - return value != null; - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public void Switch(Action true1, Action @string) - { - switch (this.Value) - { - case UnionMember0 value: - true1(value); - break; - case string value: - @string(value); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match(Func true1, Func @string) - { - return this.Value switch - { - GradientVariants::True inner => true1(inner), - GradientVariants::String inner => @string(inner), - _ => throw new InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of Gradient"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class GradientConverter : JsonConverter -{ - public override Gradient? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - deserialized.Validate(); - return new Gradient(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new Gradient(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - - public override void Write(Utf8JsonWriter writer, Gradient value, JsonSerializerOptions options) - { - object variant = value switch - { - GradientVariants::True(var true1) => true1, - GradientVariants::String(var @string) => @string, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/GradientProperties/UnionMember0.cs b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/GradientProperties/UnionMember0.cs deleted file mode 100644 index e4f011a8..00000000 --- a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/GradientProperties/UnionMember0.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; - -namespace Imagekit.Models.SolidColorOverlayTransformationProperties.GradientProperties; - -[JsonConverter(typeof(Converter))] -public class UnionMember0 -{ - public JsonElement Json { get; private init; } - - public UnionMember0() - { - Json = JsonSerializer.Deserialize("true"); - } - - UnionMember0(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new UnionMember0().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'UnionMember0'"); - } - } - - class Converter : JsonConverter - { - public override UnionMember0? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write( - Utf8JsonWriter writer, - UnionMember0 value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/GradientVariants/All.cs b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/GradientVariants/All.cs deleted file mode 100644 index 4f3289f0..00000000 --- a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/GradientVariants/All.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Text.Json; - -namespace Imagekit.Models.SolidColorOverlayTransformationProperties.GradientVariants; - -public sealed record class True(JsonElement Value) : Gradient, IVariant -{ - public static True From(JsonElement value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class String(string Value) : Gradient, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Height.cs b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Height.cs deleted file mode 100644 index 69e31379..00000000 --- a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Height.cs +++ /dev/null @@ -1,132 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using HeightVariants = Imagekit.Models.SolidColorOverlayTransformationProperties.HeightVariants; - -namespace Imagekit.Models.SolidColorOverlayTransformationProperties; - -/// -/// Controls the height of the solid color overlay. Accepts a numeric value or an -/// arithmetic expression. Learn about [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). -/// -[JsonConverter(typeof(HeightConverter))] -public record class Height -{ - public object Value { get; private init; } - - public Height(double value) - { - Value = value; - } - - public Height(string value) - { - Value = value; - } - - Height(UnknownVariant value) - { - Value = value; - } - - public static Height CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public void Switch(Action @double, Action @string) - { - switch (this.Value) - { - case double value: - @double(value); - break; - case string value: - @string(value); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match(Func @double, Func @string) - { - return this.Value switch - { - HeightVariants::Double inner => @double(inner), - HeightVariants::String inner => @string(inner), - _ => throw new InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of Height"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class HeightConverter : JsonConverter -{ - public override Height? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - return new Height(JsonSerializer.Deserialize(ref reader, options)); - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new Height(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - - public override void Write(Utf8JsonWriter writer, Height value, JsonSerializerOptions options) - { - object variant = value switch - { - HeightVariants::Double(var @double) => @double, - HeightVariants::String(var @string) => @string, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/HeightVariants/All.cs b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/HeightVariants/All.cs deleted file mode 100644 index 7964bb15..00000000 --- a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/HeightVariants/All.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace Imagekit.Models.SolidColorOverlayTransformationProperties.HeightVariants; - -public sealed record class Double(double Value) : Height, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class String(string Value) : Height, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Radius.cs b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Radius.cs deleted file mode 100644 index 1728ccf5..00000000 --- a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Radius.cs +++ /dev/null @@ -1,133 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using RadiusVariants = Imagekit.Models.SolidColorOverlayTransformationProperties.RadiusVariants; - -namespace Imagekit.Models.SolidColorOverlayTransformationProperties; - -/// -/// Specifies the corner radius of the solid color overlay. Set to `max` for circular -/// or oval shape. See [radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). -/// -[JsonConverter(typeof(RadiusConverter))] -public record class Radius -{ - public object Value { get; private init; } - - public Radius(double value) - { - Value = value; - } - - public Radius(UnionMember1 value) - { - Value = value; - } - - Radius(UnknownVariant value) - { - Value = value; - } - - public static Radius CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public bool TryPickMax([NotNullWhen(true)] out UnionMember1? value) - { - value = this.Value as UnionMember1; - return value != null; - } - - public void Switch(Action @double, Action max) - { - switch (this.Value) - { - case double value: - @double(value); - break; - case UnionMember1 value: - max(value); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match(Func @double, Func max) - { - return this.Value switch - { - RadiusVariants::Double inner => @double(inner), - RadiusVariants::Max inner => max(inner), - _ => throw new InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of Radius"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class RadiusConverter : JsonConverter -{ - public override Radius? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - deserialized.Validate(); - return new Radius(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - return new Radius(JsonSerializer.Deserialize(ref reader, options)); - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - - public override void Write(Utf8JsonWriter writer, Radius value, JsonSerializerOptions options) - { - object variant = value switch - { - RadiusVariants::Double(var @double) => @double, - RadiusVariants::Max(var max) => max, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/RadiusProperties/UnionMember1.cs b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/RadiusProperties/UnionMember1.cs deleted file mode 100644 index 90a6315f..00000000 --- a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/RadiusProperties/UnionMember1.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; - -namespace Imagekit.Models.SolidColorOverlayTransformationProperties.RadiusProperties; - -[JsonConverter(typeof(Converter))] -public class UnionMember1 -{ - public JsonElement Json { get; private init; } - - public UnionMember1() - { - Json = JsonSerializer.Deserialize("\"max\""); - } - - UnionMember1(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new UnionMember1().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'UnionMember1'"); - } - } - - class Converter : JsonConverter - { - public override UnionMember1? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write( - Utf8JsonWriter writer, - UnionMember1 value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/RadiusVariants/All.cs b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/RadiusVariants/All.cs deleted file mode 100644 index 027d6797..00000000 --- a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/RadiusVariants/All.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Text.Json; - -namespace Imagekit.Models.SolidColorOverlayTransformationProperties.RadiusVariants; - -public sealed record class Double(double Value) : Radius, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Max(JsonElement Value) : Radius, IVariant -{ - public static Max From(JsonElement value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Width.cs b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Width.cs deleted file mode 100644 index 3b812d21..00000000 --- a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/Width.cs +++ /dev/null @@ -1,132 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using WidthVariants = Imagekit.Models.SolidColorOverlayTransformationProperties.WidthVariants; - -namespace Imagekit.Models.SolidColorOverlayTransformationProperties; - -/// -/// Controls the width of the solid color overlay. Accepts a numeric value or an arithmetic -/// expression (e.g., `bw_mul_0.2` or `bh_div_2`). Learn about [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). -/// -[JsonConverter(typeof(WidthConverter))] -public record class Width -{ - public object Value { get; private init; } - - public Width(double value) - { - Value = value; - } - - public Width(string value) - { - Value = value; - } - - Width(UnknownVariant value) - { - Value = value; - } - - public static Width CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public void Switch(Action @double, Action @string) - { - switch (this.Value) - { - case double value: - @double(value); - break; - case string value: - @string(value); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match(Func @double, Func @string) - { - return this.Value switch - { - WidthVariants::Double inner => @double(inner), - WidthVariants::String inner => @string(inner), - _ => throw new InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of Width"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class WidthConverter : JsonConverter -{ - public override Width? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - return new Width(JsonSerializer.Deserialize(ref reader, options)); - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new Width(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - - public override void Write(Utf8JsonWriter writer, Width value, JsonSerializerOptions options) - { - object variant = value switch - { - WidthVariants::Double(var @double) => @double, - WidthVariants::String(var @string) => @string, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/WidthVariants/All.cs b/src/Imagekit/Models/SolidColorOverlayTransformationProperties/WidthVariants/All.cs deleted file mode 100644 index 6c5afda6..00000000 --- a/src/Imagekit/Models/SolidColorOverlayTransformationProperties/WidthVariants/All.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace Imagekit.Models.SolidColorOverlayTransformationProperties.WidthVariants; - -public sealed record class Double(double Value) : Width, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class String(string Value) : Width, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/SrcOptions.cs b/src/Imagekit/Models/SrcOptions.cs deleted file mode 100644 index 6244b1fe..00000000 --- a/src/Imagekit/Models/SrcOptions.cs +++ /dev/null @@ -1,224 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models; - -/// -/// Options for generating ImageKit URLs with transformations. See the [Transformations guide](https://imagekit.io/docs/transformations). -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class SrcOptions : ModelBase, IFromRaw -{ - /// - /// Accepts a relative or absolute path of the resource. If a relative path is - /// provided, it is appended to the `urlEndpoint`. If an absolute path is provided, - /// `urlEndpoint` is ignored. - /// - public required string Src - { - get - { - if (!this.Properties.TryGetValue("src", out JsonElement element)) - throw new ArgumentOutOfRangeException("src", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("src"); - } - set - { - this.Properties["src"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Get your urlEndpoint from the [ImageKit dashboard](https://imagekit.io/dashboard/url-endpoints). - /// - public required string URLEndpoint - { - get - { - if (!this.Properties.TryGetValue("urlEndpoint", out JsonElement element)) - throw new ArgumentOutOfRangeException("urlEndpoint", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("urlEndpoint"); - } - set - { - this.Properties["urlEndpoint"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// When you want the signed URL to expire, specified in seconds. If `expiresIn` - /// is anything above 0, the URL will always be signed even if `signed` is set - /// to false. If not specified and `signed` is `true`, the signed URL will not - /// expire (valid indefinitely). - /// - /// Example: Setting `expiresIn: 3600` will make the URL expire 1 hour from generation - /// time. After the expiry time, the signed URL will no longer be valid and ImageKit - /// will return a 401 Unauthorized status code. - /// - /// [Learn more](https://imagekit.io/docs/media-delivery-basic-security#how-to-generate-signed-urls). - /// - public double? ExpiresIn - { - get - { - if (!this.Properties.TryGetValue("expiresIn", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["expiresIn"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// These are additional query parameters that you want to add to the final URL. - /// They can be any query parameters and not necessarily related to ImageKit. - /// This is especially useful if you want to add a versioning parameter to your - /// URLs. - /// - public Dictionary? QueryParameters - { - get - { - if (!this.Properties.TryGetValue("queryParameters", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["queryParameters"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to sign the URL or not. Set this to `true` if you want to generate - /// a signed URL. If `signed` is `true` and `expiresIn` is not specified, the - /// signed URL will not expire (valid indefinitely). Note: If `expiresIn` is set - /// to any value above 0, the URL will always be signed regardless of this setting. - /// [Learn more](https://imagekit.io/docs/media-delivery-basic-security#how-to-generate-signed-urls). - /// - public bool? Signed - { - get - { - if (!this.Properties.TryGetValue("signed", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["signed"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// An array of objects specifying the transformations to be applied in the URL. - /// If more than one transformation is specified, they are applied in the order - /// they are specified as chained transformations. See [Chained transformations](https://imagekit.io/docs/transformations#chained-transformations). - /// - public List? Transformation - { - get - { - if (!this.Properties.TryGetValue("transformation", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["transformation"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// By default, the transformation string is added as a query parameter in the - /// URL, e.g., `?tr=w-100,h-100`. If you want to add the transformation string - /// in the path of the URL, set this to `path`. Learn more in the [Transformations - /// guide](https://imagekit.io/docs/transformations). - /// - public ApiEnum? TransformationPosition - { - get - { - if (!this.Properties.TryGetValue("transformationPosition", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["transformationPosition"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.Src; - _ = this.URLEndpoint; - _ = this.ExpiresIn; - _ = this.QueryParameters; - _ = this.Signed; - foreach (var item in this.Transformation ?? []) - { - item.Validate(); - } - this.TransformationPosition?.Validate(); - } - - public SrcOptions() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - SrcOptions(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static SrcOptions FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/SubtitleOverlay.cs b/src/Imagekit/Models/SubtitleOverlay.cs deleted file mode 100644 index 78d6f51e..00000000 --- a/src/Imagekit/Models/SubtitleOverlay.cs +++ /dev/null @@ -1,183 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.SubtitleOverlayProperties.IntersectionMember1Properties; - -namespace Imagekit.Models; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class SubtitleOverlay : ModelBase, IFromRaw -{ - public OverlayPosition? Position - { - get - { - if (!this.Properties.TryGetValue("position", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["position"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public OverlayTiming? Timing - { - get - { - if (!this.Properties.TryGetValue("timing", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["timing"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies the relative path to the subtitle file used as an overlay. - /// - public required string Input - { - get - { - if (!this.Properties.TryGetValue("input", out JsonElement element)) - throw new ArgumentOutOfRangeException("input", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("input"); - } - set - { - this.Properties["input"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The input path can be included in the layer as either `i-{input}` or `ie-{base64_encoded_input}`. - /// By default, the SDK determines the appropriate format automatically. To - /// always use base64 encoding (`ie-{base64}`), set this parameter to `base64`. - /// To always use plain text (`i-{input}`), set it to `plain`. - /// - public ApiEnum? Encoding - { - get - { - if (!this.Properties.TryGetValue("encoding", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["encoding"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Control styling of the subtitle. See [Styling subtitles](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer). - /// - public List? Transformation - { - get - { - if (!this.Properties.TryGetValue("transformation", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["transformation"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public static implicit operator BaseOverlay(SubtitleOverlay subtitleOverlay) => - new() { Position = subtitleOverlay.Position, Timing = subtitleOverlay.Timing }; - - public override void Validate() - { - this.Position?.Validate(); - this.Timing?.Validate(); - _ = this.Input; - _ = this.Type; - this.Encoding?.Validate(); - foreach (var item in this.Transformation ?? []) - { - item.Validate(); - } - } - - public SubtitleOverlay() - { - this.Type = JsonSerializer.Deserialize("\"subtitle\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - SubtitleOverlay(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static SubtitleOverlay FromRawUnchecked(Dictionary properties) - { - return new(properties); - } - - [SetsRequiredMembers] - public SubtitleOverlay(string input) - : this() - { - this.Input = input; - } -} diff --git a/src/Imagekit/Models/SubtitleOverlayProperties/IntersectionMember1.cs b/src/Imagekit/Models/SubtitleOverlayProperties/IntersectionMember1.cs deleted file mode 100644 index 1b8c6a07..00000000 --- a/src/Imagekit/Models/SubtitleOverlayProperties/IntersectionMember1.cs +++ /dev/null @@ -1,139 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.SubtitleOverlayProperties.IntersectionMember1Properties; - -namespace Imagekit.Models.SubtitleOverlayProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class IntersectionMember1 : ModelBase, IFromRaw -{ - /// - /// Specifies the relative path to the subtitle file used as an overlay. - /// - public required string Input - { - get - { - if (!this.Properties.TryGetValue("input", out JsonElement element)) - throw new ArgumentOutOfRangeException("input", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("input"); - } - set - { - this.Properties["input"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The input path can be included in the layer as either `i-{input}` or `ie-{base64_encoded_input}`. - /// By default, the SDK determines the appropriate format automatically. To - /// always use base64 encoding (`ie-{base64}`), set this parameter to `base64`. - /// To always use plain text (`i-{input}`), set it to `plain`. - /// - public ApiEnum? Encoding - { - get - { - if (!this.Properties.TryGetValue("encoding", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["encoding"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Control styling of the subtitle. See [Styling subtitles](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer). - /// - public List? Transformation - { - get - { - if (!this.Properties.TryGetValue("transformation", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["transformation"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.Input; - _ = this.Type; - this.Encoding?.Validate(); - foreach (var item in this.Transformation ?? []) - { - item.Validate(); - } - } - - public IntersectionMember1() - { - this.Type = JsonSerializer.Deserialize("\"subtitle\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - IntersectionMember1(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static IntersectionMember1 FromRawUnchecked(Dictionary properties) - { - return new(properties); - } - - [SetsRequiredMembers] - public IntersectionMember1(string input) - : this() - { - this.Input = input; - } -} diff --git a/src/Imagekit/Models/SubtitleOverlayProperties/IntersectionMember1Properties/Encoding.cs b/src/Imagekit/Models/SubtitleOverlayProperties/IntersectionMember1Properties/Encoding.cs deleted file mode 100644 index e1dda803..00000000 --- a/src/Imagekit/Models/SubtitleOverlayProperties/IntersectionMember1Properties/Encoding.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.SubtitleOverlayProperties.IntersectionMember1Properties; - -/// -/// The input path can be included in the layer as either `i-{input}` or `ie-{base64_encoded_input}`. -/// By default, the SDK determines the appropriate format automatically. To always -/// use base64 encoding (`ie-{base64}`), set this parameter to `base64`. To always -/// use plain text (`i-{input}`), set it to `plain`. -/// -[JsonConverter(typeof(EncodingConverter))] -public enum Encoding -{ - Auto, - Plain, - Base64, -} - -sealed class EncodingConverter : JsonConverter -{ - public override Encoding Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "auto" => Encoding.Auto, - "plain" => Encoding.Plain, - "base64" => Encoding.Base64, - _ => (Encoding)(-1), - }; - } - - public override void Write(Utf8JsonWriter writer, Encoding value, JsonSerializerOptions options) - { - JsonSerializer.Serialize( - writer, - value switch - { - Encoding.Auto => "auto", - Encoding.Plain => "plain", - Encoding.Base64 => "base64", - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/SubtitleOverlayTransformation.cs b/src/Imagekit/Models/SubtitleOverlayTransformation.cs deleted file mode 100644 index 912ded35..00000000 --- a/src/Imagekit/Models/SubtitleOverlayTransformation.cs +++ /dev/null @@ -1,220 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.SubtitleOverlayTransformationProperties; - -namespace Imagekit.Models; - -/// -/// Subtitle styling options. [Learn more](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) -/// from the docs. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class SubtitleOverlayTransformation - : ModelBase, - IFromRaw -{ - /// - /// Specifies the subtitle background color using a standard color name, an RGB - /// color code (e.g., FF0000), or an RGBA color code (e.g., FFAABB50). - /// - /// [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) - /// - public string? Background - { - get - { - if (!this.Properties.TryGetValue("background", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["background"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Sets the font color of the subtitle text using a standard color name, an RGB - /// color code (e.g., FF0000), or an RGBA color code (e.g., FFAABB50). - /// - /// [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) - /// - public string? Color - { - get - { - if (!this.Properties.TryGetValue("color", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["color"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Font family for subtitles. Refer to the [supported fonts](https://imagekit.io/docs/add-overlays-on-images#supported-text-font-list). - /// - public string? FontFamily - { - get - { - if (!this.Properties.TryGetValue("fontFamily", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["fontFamily"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Sets the font outline of the subtitle text. Requires the outline width (an - /// integer) and the outline color (as an RGB color code, RGBA color code, or - /// standard web color name) separated by an underscore. Example: `fol-2_blue` - /// (outline width of 2px and outline color blue), `fol-2_A1CCDD` (outline width - /// of 2px and outline color `#A1CCDD`) and `fol-2_A1CCDD50` (outline width of - /// 2px and outline color `#A1CCDD` at 50% opacity). - /// - /// [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) - /// - public string? FontOutline - { - get - { - if (!this.Properties.TryGetValue("fontOutline", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["fontOutline"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Sets the font shadow for the subtitle text. Requires the shadow color (as - /// an RGB color code, RGBA color code, or standard web color name) and shadow - /// indent (an integer) separated by an underscore. Example: `fsh-blue_2` (shadow - /// color blue, indent of 2px), `fsh-A1CCDD_3` (shadow color `#A1CCDD`, indent - /// of 3px), `fsh-A1CCDD50_3` (shadow color `#A1CCDD` at 50% opacity, indent - /// of 3px). - /// - /// [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) - /// - public string? FontShadow - { - get - { - if (!this.Properties.TryGetValue("fontShadow", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["fontShadow"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Sets the font size of subtitle text. - /// - /// [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) - /// - public double? FontSize - { - get - { - if (!this.Properties.TryGetValue("fontSize", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["fontSize"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Sets the typography style of the subtitle text. Supports values are `b` for - /// bold, `i` for italics, and `b_i` for bold with italics. - /// - /// [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) - /// - public ApiEnum? Typography - { - get - { - if (!this.Properties.TryGetValue("typography", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["typography"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.Background; - _ = this.Color; - _ = this.FontFamily; - _ = this.FontOutline; - _ = this.FontShadow; - _ = this.FontSize; - this.Typography?.Validate(); - } - - public SubtitleOverlayTransformation() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - SubtitleOverlayTransformation(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static SubtitleOverlayTransformation FromRawUnchecked( - Dictionary properties - ) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/SubtitleOverlayTransformationProperties/Typography.cs b/src/Imagekit/Models/SubtitleOverlayTransformationProperties/Typography.cs deleted file mode 100644 index 4cef3c66..00000000 --- a/src/Imagekit/Models/SubtitleOverlayTransformationProperties/Typography.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.SubtitleOverlayTransformationProperties; - -/// -/// Sets the typography style of the subtitle text. Supports values are `b` for bold, -/// `i` for italics, and `b_i` for bold with italics. -/// -/// [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) -/// -[JsonConverter(typeof(TypographyConverter))] -public enum Typography -{ - B, - I, - BI, -} - -sealed class TypographyConverter : JsonConverter -{ - public override Typography Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "b" => Typography.B, - "i" => Typography.I, - "b_i" => Typography.BI, - _ => (Typography)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - Typography value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - Typography.B => "b", - Typography.I => "i", - Typography.BI => "b_i", - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/TextOverlay.cs b/src/Imagekit/Models/TextOverlay.cs deleted file mode 100644 index d8d3689d..00000000 --- a/src/Imagekit/Models/TextOverlay.cs +++ /dev/null @@ -1,184 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.TextOverlayProperties.IntersectionMember1Properties; - -namespace Imagekit.Models; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class TextOverlay : ModelBase, IFromRaw -{ - public OverlayPosition? Position - { - get - { - if (!this.Properties.TryGetValue("position", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["position"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public OverlayTiming? Timing - { - get - { - if (!this.Properties.TryGetValue("timing", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["timing"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies the text to be displayed in the overlay. The SDK automatically handles - /// special characters and encoding. - /// - public required string Text - { - get - { - if (!this.Properties.TryGetValue("text", out JsonElement element)) - throw new ArgumentOutOfRangeException("text", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("text"); - } - set - { - this.Properties["text"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Text can be included in the layer as either `i-{input}` (plain text) or `ie-{base64_encoded_input}` - /// (base64). By default, the SDK selects the appropriate format based on the - /// input text. To always use base64 (`ie-{base64}`), set this parameter to - /// `base64`. To always use plain text (`i-{input}`), set it to `plain`. - /// - public ApiEnum? Encoding - { - get - { - if (!this.Properties.TryGetValue("encoding", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["encoding"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Control styling of the text overlay. See [Text overlays](https://imagekit.io/docs/add-overlays-on-images#text-overlay). - /// - public List? Transformation - { - get - { - if (!this.Properties.TryGetValue("transformation", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["transformation"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public static implicit operator BaseOverlay(TextOverlay textOverlay) => - new() { Position = textOverlay.Position, Timing = textOverlay.Timing }; - - public override void Validate() - { - this.Position?.Validate(); - this.Timing?.Validate(); - _ = this.Text; - _ = this.Type; - this.Encoding?.Validate(); - foreach (var item in this.Transformation ?? []) - { - item.Validate(); - } - } - - public TextOverlay() - { - this.Type = JsonSerializer.Deserialize("\"text\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - TextOverlay(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static TextOverlay FromRawUnchecked(Dictionary properties) - { - return new(properties); - } - - [SetsRequiredMembers] - public TextOverlay(string text) - : this() - { - this.Text = text; - } -} diff --git a/src/Imagekit/Models/TextOverlayProperties/IntersectionMember1.cs b/src/Imagekit/Models/TextOverlayProperties/IntersectionMember1.cs deleted file mode 100644 index df5af566..00000000 --- a/src/Imagekit/Models/TextOverlayProperties/IntersectionMember1.cs +++ /dev/null @@ -1,140 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.TextOverlayProperties.IntersectionMember1Properties; - -namespace Imagekit.Models.TextOverlayProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class IntersectionMember1 : ModelBase, IFromRaw -{ - /// - /// Specifies the text to be displayed in the overlay. The SDK automatically handles - /// special characters and encoding. - /// - public required string Text - { - get - { - if (!this.Properties.TryGetValue("text", out JsonElement element)) - throw new ArgumentOutOfRangeException("text", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("text"); - } - set - { - this.Properties["text"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Text can be included in the layer as either `i-{input}` (plain text) or `ie-{base64_encoded_input}` - /// (base64). By default, the SDK selects the appropriate format based on the - /// input text. To always use base64 (`ie-{base64}`), set this parameter to - /// `base64`. To always use plain text (`i-{input}`), set it to `plain`. - /// - public ApiEnum? Encoding - { - get - { - if (!this.Properties.TryGetValue("encoding", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["encoding"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Control styling of the text overlay. See [Text overlays](https://imagekit.io/docs/add-overlays-on-images#text-overlay). - /// - public List? Transformation - { - get - { - if (!this.Properties.TryGetValue("transformation", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["transformation"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.Text; - _ = this.Type; - this.Encoding?.Validate(); - foreach (var item in this.Transformation ?? []) - { - item.Validate(); - } - } - - public IntersectionMember1() - { - this.Type = JsonSerializer.Deserialize("\"text\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - IntersectionMember1(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static IntersectionMember1 FromRawUnchecked(Dictionary properties) - { - return new(properties); - } - - [SetsRequiredMembers] - public IntersectionMember1(string text) - : this() - { - this.Text = text; - } -} diff --git a/src/Imagekit/Models/TextOverlayProperties/IntersectionMember1Properties/Encoding.cs b/src/Imagekit/Models/TextOverlayProperties/IntersectionMember1Properties/Encoding.cs deleted file mode 100644 index 74ed2a83..00000000 --- a/src/Imagekit/Models/TextOverlayProperties/IntersectionMember1Properties/Encoding.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.TextOverlayProperties.IntersectionMember1Properties; - -/// -/// Text can be included in the layer as either `i-{input}` (plain text) or `ie-{base64_encoded_input}` -/// (base64). By default, the SDK selects the appropriate format based on the input -/// text. To always use base64 (`ie-{base64}`), set this parameter to `base64`. -/// To always use plain text (`i-{input}`), set it to `plain`. -/// -[JsonConverter(typeof(EncodingConverter))] -public enum Encoding -{ - Auto, - Plain, - Base64, -} - -sealed class EncodingConverter : JsonConverter -{ - public override Encoding Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "auto" => Encoding.Auto, - "plain" => Encoding.Plain, - "base64" => Encoding.Base64, - _ => (Encoding)(-1), - }; - } - - public override void Write(Utf8JsonWriter writer, Encoding value, JsonSerializerOptions options) - { - JsonSerializer.Serialize( - writer, - value switch - { - Encoding.Auto => "auto", - Encoding.Plain => "plain", - Encoding.Base64 => "base64", - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/TextOverlayTransformation.cs b/src/Imagekit/Models/TextOverlayTransformation.cs deleted file mode 100644 index 0fd70a89..00000000 --- a/src/Imagekit/Models/TextOverlayTransformation.cs +++ /dev/null @@ -1,345 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.TextOverlayTransformationProperties; - -namespace Imagekit.Models; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class TextOverlayTransformation - : ModelBase, - IFromRaw -{ - /// - /// Specifies the transparency level of the text overlay. Accepts integers from - /// `1` to `9`. - /// - public double? Alpha - { - get - { - if (!this.Properties.TryGetValue("alpha", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["alpha"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies the background color of the text overlay. Accepts an RGB hex code, - /// an RGBA code, or a color name. - /// - public string? Background - { - get - { - if (!this.Properties.TryGetValue("background", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["background"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Flip the text overlay horizontally, vertically, or both. - /// - public ApiEnum? Flip - { - get - { - if (!this.Properties.TryGetValue("flip", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["flip"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies the font color of the overlaid text. Accepts an RGB hex code (e.g., - /// `FF0000`), an RGBA code (e.g., `FFAABB50`), or a color name. - /// - public string? FontColor - { - get - { - if (!this.Properties.TryGetValue("fontColor", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["fontColor"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies the font family of the overlaid text. Choose from the supported - /// fonts list or use a custom font. See [Supported fonts](https://imagekit.io/docs/add-overlays-on-images#supported-text-font-list) - /// and [Custom font](https://imagekit.io/docs/add-overlays-on-images#change-font-family-in-text-overlay). - /// - public string? FontFamily - { - get - { - if (!this.Properties.TryGetValue("fontFamily", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["fontFamily"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies the font size of the overlaid text. Accepts a numeric value or - /// an arithmetic expression. - /// - public FontSize? FontSize - { - get - { - if (!this.Properties.TryGetValue("fontSize", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["fontSize"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies the inner alignment of the text when width is more than the text - /// length. - /// - public ApiEnum? InnerAlignment - { - get - { - if (!this.Properties.TryGetValue("innerAlignment", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["innerAlignment"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies the line height of the text overlay. Accepts integer values representing - /// line height in points. It can also accept [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations) - /// such as `bw_mul_0.2`, or `bh_div_20`. - /// - public LineHeight? LineHeight - { - get - { - if (!this.Properties.TryGetValue("lineHeight", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["lineHeight"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies the padding around the overlaid text. Can be provided as a single - /// positive integer or multiple values separated by underscores (following CSS - /// shorthand order). Arithmetic expressions are also accepted. - /// - public Padding? Padding - { - get - { - if (!this.Properties.TryGetValue("padding", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["padding"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies the corner radius of the text overlay. Set to `max` to achieve - /// a circular or oval shape. - /// - public Radius? Radius - { - get - { - if (!this.Properties.TryGetValue("radius", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["radius"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies the rotation angle of the text overlay. Accepts a numeric value - /// for clockwise rotation or a string prefixed with "N" for counter-clockwise - /// rotation. - /// - public Rotation? Rotation - { - get - { - if (!this.Properties.TryGetValue("rotation", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["rotation"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies the typography style of the text. Supported values: - Single - /// styles: `b` (bold), `i` (italic), `strikethrough`. - Combinations: Any combination - /// separated by underscores, e.g., `b_i`, `b_i_strikethrough`. - /// - public string? Typography - { - get - { - if (!this.Properties.TryGetValue("typography", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["typography"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies the maximum width (in pixels) of the overlaid text. The text wraps - /// automatically, and arithmetic expressions (e.g., `bw_mul_0.2` or `bh_div_2`) - /// are supported. Useful when used in conjunction with the `background`. Learn - /// about [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). - /// - public Width? Width - { - get - { - if (!this.Properties.TryGetValue("width", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["width"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.Alpha; - _ = this.Background; - this.Flip?.Validate(); - _ = this.FontColor; - _ = this.FontFamily; - this.FontSize?.Validate(); - this.InnerAlignment?.Validate(); - this.LineHeight?.Validate(); - this.Padding?.Validate(); - this.Radius?.Validate(); - this.Rotation?.Validate(); - _ = this.Typography; - this.Width?.Validate(); - } - - public TextOverlayTransformation() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - TextOverlayTransformation(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static TextOverlayTransformation FromRawUnchecked( - Dictionary properties - ) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/TextOverlayTransformationProperties/Flip.cs b/src/Imagekit/Models/TextOverlayTransformationProperties/Flip.cs deleted file mode 100644 index 7eb76e22..00000000 --- a/src/Imagekit/Models/TextOverlayTransformationProperties/Flip.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.TextOverlayTransformationProperties; - -/// -/// Flip the text overlay horizontally, vertically, or both. -/// -[JsonConverter(typeof(FlipConverter))] -public enum Flip -{ - H, - V, - HV, - VH, -} - -sealed class FlipConverter : JsonConverter -{ - public override Flip Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "h" => Flip.H, - "v" => Flip.V, - "h_v" => Flip.HV, - "v_h" => Flip.VH, - _ => (Flip)(-1), - }; - } - - public override void Write(Utf8JsonWriter writer, Flip value, JsonSerializerOptions options) - { - JsonSerializer.Serialize( - writer, - value switch - { - Flip.H => "h", - Flip.V => "v", - Flip.HV => "h_v", - Flip.VH => "v_h", - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/TextOverlayTransformationProperties/FontSize.cs b/src/Imagekit/Models/TextOverlayTransformationProperties/FontSize.cs deleted file mode 100644 index 8d696caa..00000000 --- a/src/Imagekit/Models/TextOverlayTransformationProperties/FontSize.cs +++ /dev/null @@ -1,131 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using FontSizeVariants = Imagekit.Models.TextOverlayTransformationProperties.FontSizeVariants; - -namespace Imagekit.Models.TextOverlayTransformationProperties; - -/// -/// Specifies the font size of the overlaid text. Accepts a numeric value or an arithmetic expression. -/// -[JsonConverter(typeof(FontSizeConverter))] -public record class FontSize -{ - public object Value { get; private init; } - - public FontSize(double value) - { - Value = value; - } - - public FontSize(string value) - { - Value = value; - } - - FontSize(UnknownVariant value) - { - Value = value; - } - - public static FontSize CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public void Switch(Action @double, Action @string) - { - switch (this.Value) - { - case double value: - @double(value); - break; - case string value: - @string(value); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match(Func @double, Func @string) - { - return this.Value switch - { - FontSizeVariants::Double inner => @double(inner), - FontSizeVariants::String inner => @string(inner), - _ => throw new InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of FontSize"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class FontSizeConverter : JsonConverter -{ - public override FontSize? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - return new FontSize(JsonSerializer.Deserialize(ref reader, options)); - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new FontSize(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - - public override void Write(Utf8JsonWriter writer, FontSize value, JsonSerializerOptions options) - { - object variant = value switch - { - FontSizeVariants::Double(var @double) => @double, - FontSizeVariants::String(var @string) => @string, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/TextOverlayTransformationProperties/FontSizeVariants/All.cs b/src/Imagekit/Models/TextOverlayTransformationProperties/FontSizeVariants/All.cs deleted file mode 100644 index 3bf4b3ae..00000000 --- a/src/Imagekit/Models/TextOverlayTransformationProperties/FontSizeVariants/All.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace Imagekit.Models.TextOverlayTransformationProperties.FontSizeVariants; - -public sealed record class Double(double Value) : FontSize, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class String(string Value) : FontSize, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/TextOverlayTransformationProperties/InnerAlignment.cs b/src/Imagekit/Models/TextOverlayTransformationProperties/InnerAlignment.cs deleted file mode 100644 index 8dab9ed3..00000000 --- a/src/Imagekit/Models/TextOverlayTransformationProperties/InnerAlignment.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.TextOverlayTransformationProperties; - -/// -/// Specifies the inner alignment of the text when width is more than the text length. -/// -[JsonConverter(typeof(InnerAlignmentConverter))] -public enum InnerAlignment -{ - Left, - Right, - Center, -} - -sealed class InnerAlignmentConverter : JsonConverter -{ - public override InnerAlignment Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "left" => InnerAlignment.Left, - "right" => InnerAlignment.Right, - "center" => InnerAlignment.Center, - _ => (InnerAlignment)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - InnerAlignment value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - InnerAlignment.Left => "left", - InnerAlignment.Right => "right", - InnerAlignment.Center => "center", - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/TextOverlayTransformationProperties/LineHeight.cs b/src/Imagekit/Models/TextOverlayTransformationProperties/LineHeight.cs deleted file mode 100644 index 8335c67a..00000000 --- a/src/Imagekit/Models/TextOverlayTransformationProperties/LineHeight.cs +++ /dev/null @@ -1,137 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using LineHeightVariants = Imagekit.Models.TextOverlayTransformationProperties.LineHeightVariants; - -namespace Imagekit.Models.TextOverlayTransformationProperties; - -/// -/// Specifies the line height of the text overlay. Accepts integer values representing -/// line height in points. It can also accept [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations) -/// such as `bw_mul_0.2`, or `bh_div_20`. -/// -[JsonConverter(typeof(LineHeightConverter))] -public record class LineHeight -{ - public object Value { get; private init; } - - public LineHeight(double value) - { - Value = value; - } - - public LineHeight(string value) - { - Value = value; - } - - LineHeight(UnknownVariant value) - { - Value = value; - } - - public static LineHeight CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public void Switch(Action @double, Action @string) - { - switch (this.Value) - { - case double value: - @double(value); - break; - case string value: - @string(value); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match(Func @double, Func @string) - { - return this.Value switch - { - LineHeightVariants::Double inner => @double(inner), - LineHeightVariants::String inner => @string(inner), - _ => throw new InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of LineHeight"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class LineHeightConverter : JsonConverter -{ - public override LineHeight? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - return new LineHeight(JsonSerializer.Deserialize(ref reader, options)); - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new LineHeight(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - - public override void Write( - Utf8JsonWriter writer, - LineHeight value, - JsonSerializerOptions options - ) - { - object variant = value switch - { - LineHeightVariants::Double(var @double) => @double, - LineHeightVariants::String(var @string) => @string, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/TextOverlayTransformationProperties/LineHeightVariants/All.cs b/src/Imagekit/Models/TextOverlayTransformationProperties/LineHeightVariants/All.cs deleted file mode 100644 index 79caf949..00000000 --- a/src/Imagekit/Models/TextOverlayTransformationProperties/LineHeightVariants/All.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace Imagekit.Models.TextOverlayTransformationProperties.LineHeightVariants; - -public sealed record class Double(double Value) : LineHeight, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class String(string Value) : LineHeight, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/TextOverlayTransformationProperties/Padding.cs b/src/Imagekit/Models/TextOverlayTransformationProperties/Padding.cs deleted file mode 100644 index abb7a69d..00000000 --- a/src/Imagekit/Models/TextOverlayTransformationProperties/Padding.cs +++ /dev/null @@ -1,133 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using PaddingVariants = Imagekit.Models.TextOverlayTransformationProperties.PaddingVariants; - -namespace Imagekit.Models.TextOverlayTransformationProperties; - -/// -/// Specifies the padding around the overlaid text. Can be provided as a single positive -/// integer or multiple values separated by underscores (following CSS shorthand order). -/// Arithmetic expressions are also accepted. -/// -[JsonConverter(typeof(PaddingConverter))] -public record class Padding -{ - public object Value { get; private init; } - - public Padding(double value) - { - Value = value; - } - - public Padding(string value) - { - Value = value; - } - - Padding(UnknownVariant value) - { - Value = value; - } - - public static Padding CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public void Switch(Action @double, Action @string) - { - switch (this.Value) - { - case double value: - @double(value); - break; - case string value: - @string(value); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match(Func @double, Func @string) - { - return this.Value switch - { - PaddingVariants::Double inner => @double(inner), - PaddingVariants::String inner => @string(inner), - _ => throw new InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of Padding"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class PaddingConverter : JsonConverter -{ - public override Padding? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - return new Padding(JsonSerializer.Deserialize(ref reader, options)); - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new Padding(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - - public override void Write(Utf8JsonWriter writer, Padding value, JsonSerializerOptions options) - { - object variant = value switch - { - PaddingVariants::Double(var @double) => @double, - PaddingVariants::String(var @string) => @string, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/TextOverlayTransformationProperties/PaddingVariants/All.cs b/src/Imagekit/Models/TextOverlayTransformationProperties/PaddingVariants/All.cs deleted file mode 100644 index 4a679151..00000000 --- a/src/Imagekit/Models/TextOverlayTransformationProperties/PaddingVariants/All.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace Imagekit.Models.TextOverlayTransformationProperties.PaddingVariants; - -public sealed record class Double(double Value) : Padding, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class String(string Value) : Padding, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/TextOverlayTransformationProperties/Radius.cs b/src/Imagekit/Models/TextOverlayTransformationProperties/Radius.cs deleted file mode 100644 index 262f7059..00000000 --- a/src/Imagekit/Models/TextOverlayTransformationProperties/Radius.cs +++ /dev/null @@ -1,133 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using RadiusVariants = Imagekit.Models.TextOverlayTransformationProperties.RadiusVariants; - -namespace Imagekit.Models.TextOverlayTransformationProperties; - -/// -/// Specifies the corner radius of the text overlay. Set to `max` to achieve a circular -/// or oval shape. -/// -[JsonConverter(typeof(RadiusConverter))] -public record class Radius -{ - public object Value { get; private init; } - - public Radius(double value) - { - Value = value; - } - - public Radius(UnionMember1 value) - { - Value = value; - } - - Radius(UnknownVariant value) - { - Value = value; - } - - public static Radius CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public bool TryPickMax([NotNullWhen(true)] out UnionMember1? value) - { - value = this.Value as UnionMember1; - return value != null; - } - - public void Switch(Action @double, Action max) - { - switch (this.Value) - { - case double value: - @double(value); - break; - case UnionMember1 value: - max(value); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match(Func @double, Func max) - { - return this.Value switch - { - RadiusVariants::Double inner => @double(inner), - RadiusVariants::Max inner => max(inner), - _ => throw new InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of Radius"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class RadiusConverter : JsonConverter -{ - public override Radius? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - deserialized.Validate(); - return new Radius(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - return new Radius(JsonSerializer.Deserialize(ref reader, options)); - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - - public override void Write(Utf8JsonWriter writer, Radius value, JsonSerializerOptions options) - { - object variant = value switch - { - RadiusVariants::Double(var @double) => @double, - RadiusVariants::Max(var max) => max, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/TextOverlayTransformationProperties/RadiusProperties/UnionMember1.cs b/src/Imagekit/Models/TextOverlayTransformationProperties/RadiusProperties/UnionMember1.cs deleted file mode 100644 index 9f1e2c56..00000000 --- a/src/Imagekit/Models/TextOverlayTransformationProperties/RadiusProperties/UnionMember1.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; - -namespace Imagekit.Models.TextOverlayTransformationProperties.RadiusProperties; - -[JsonConverter(typeof(Converter))] -public class UnionMember1 -{ - public JsonElement Json { get; private init; } - - public UnionMember1() - { - Json = JsonSerializer.Deserialize("\"max\""); - } - - UnionMember1(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new UnionMember1().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'UnionMember1'"); - } - } - - class Converter : JsonConverter - { - public override UnionMember1? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write( - Utf8JsonWriter writer, - UnionMember1 value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/TextOverlayTransformationProperties/RadiusVariants/All.cs b/src/Imagekit/Models/TextOverlayTransformationProperties/RadiusVariants/All.cs deleted file mode 100644 index 8f858903..00000000 --- a/src/Imagekit/Models/TextOverlayTransformationProperties/RadiusVariants/All.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Text.Json; - -namespace Imagekit.Models.TextOverlayTransformationProperties.RadiusVariants; - -public sealed record class Double(double Value) : Radius, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Max(JsonElement Value) : Radius, IVariant -{ - public static Max From(JsonElement value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/TextOverlayTransformationProperties/Rotation.cs b/src/Imagekit/Models/TextOverlayTransformationProperties/Rotation.cs deleted file mode 100644 index cc5a5341..00000000 --- a/src/Imagekit/Models/TextOverlayTransformationProperties/Rotation.cs +++ /dev/null @@ -1,132 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using RotationVariants = Imagekit.Models.TextOverlayTransformationProperties.RotationVariants; - -namespace Imagekit.Models.TextOverlayTransformationProperties; - -/// -/// Specifies the rotation angle of the text overlay. Accepts a numeric value for -/// clockwise rotation or a string prefixed with "N" for counter-clockwise rotation. -/// -[JsonConverter(typeof(RotationConverter))] -public record class Rotation -{ - public object Value { get; private init; } - - public Rotation(double value) - { - Value = value; - } - - public Rotation(string value) - { - Value = value; - } - - Rotation(UnknownVariant value) - { - Value = value; - } - - public static Rotation CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public void Switch(Action @double, Action @string) - { - switch (this.Value) - { - case double value: - @double(value); - break; - case string value: - @string(value); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match(Func @double, Func @string) - { - return this.Value switch - { - RotationVariants::Double inner => @double(inner), - RotationVariants::String inner => @string(inner), - _ => throw new InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of Rotation"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class RotationConverter : JsonConverter -{ - public override Rotation? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - return new Rotation(JsonSerializer.Deserialize(ref reader, options)); - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new Rotation(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - - public override void Write(Utf8JsonWriter writer, Rotation value, JsonSerializerOptions options) - { - object variant = value switch - { - RotationVariants::Double(var @double) => @double, - RotationVariants::String(var @string) => @string, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/TextOverlayTransformationProperties/RotationVariants/All.cs b/src/Imagekit/Models/TextOverlayTransformationProperties/RotationVariants/All.cs deleted file mode 100644 index b56a030f..00000000 --- a/src/Imagekit/Models/TextOverlayTransformationProperties/RotationVariants/All.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace Imagekit.Models.TextOverlayTransformationProperties.RotationVariants; - -public sealed record class Double(double Value) : Rotation, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class String(string Value) : Rotation, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/TextOverlayTransformationProperties/Width.cs b/src/Imagekit/Models/TextOverlayTransformationProperties/Width.cs deleted file mode 100644 index 2a409897..00000000 --- a/src/Imagekit/Models/TextOverlayTransformationProperties/Width.cs +++ /dev/null @@ -1,134 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using WidthVariants = Imagekit.Models.TextOverlayTransformationProperties.WidthVariants; - -namespace Imagekit.Models.TextOverlayTransformationProperties; - -/// -/// Specifies the maximum width (in pixels) of the overlaid text. The text wraps -/// automatically, and arithmetic expressions (e.g., `bw_mul_0.2` or `bh_div_2`) -/// are supported. Useful when used in conjunction with the `background`. Learn about -/// [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). -/// -[JsonConverter(typeof(WidthConverter))] -public record class Width -{ - public object Value { get; private init; } - - public Width(double value) - { - Value = value; - } - - public Width(string value) - { - Value = value; - } - - Width(UnknownVariant value) - { - Value = value; - } - - public static Width CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public void Switch(Action @double, Action @string) - { - switch (this.Value) - { - case double value: - @double(value); - break; - case string value: - @string(value); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match(Func @double, Func @string) - { - return this.Value switch - { - WidthVariants::Double inner => @double(inner), - WidthVariants::String inner => @string(inner), - _ => throw new InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of Width"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class WidthConverter : JsonConverter -{ - public override Width? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - return new Width(JsonSerializer.Deserialize(ref reader, options)); - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new Width(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - - public override void Write(Utf8JsonWriter writer, Width value, JsonSerializerOptions options) - { - object variant = value switch - { - WidthVariants::Double(var @double) => @double, - WidthVariants::String(var @string) => @string, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/TextOverlayTransformationProperties/WidthVariants/All.cs b/src/Imagekit/Models/TextOverlayTransformationProperties/WidthVariants/All.cs deleted file mode 100644 index e08d3a5e..00000000 --- a/src/Imagekit/Models/TextOverlayTransformationProperties/WidthVariants/All.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace Imagekit.Models.TextOverlayTransformationProperties.WidthVariants; - -public sealed record class Double(double Value) : Width, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class String(string Value) : Width, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/Transformation.cs b/src/Imagekit/Models/Transformation.cs deleted file mode 100644 index e1051a84..00000000 --- a/src/Imagekit/Models/Transformation.cs +++ /dev/null @@ -1,1320 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.TransformationProperties; - -namespace Imagekit.Models; - -/// -/// The SDK provides easy-to-use names for transformations. These names are converted -/// to the corresponding transformation string before being added to the URL. SDKs -/// are updated regularly to support new transformations. If you want to use a transformation -/// that is not supported by the SDK, You can use the `raw` parameter to pass the -/// transformation string directly. See the [Transformations documentation](https://imagekit.io/docs/transformations). -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class Transformation : ModelBase, IFromRaw -{ - /// - /// Uses AI to change the background. Provide a text prompt or a base64-encoded - /// prompt, e.g., `prompt-snow road` or `prompte-[urlencoded_base64_encoded_text]`. - /// Not supported inside overlay. See [AI Change Background](https://imagekit.io/docs/ai-transformations#change-background-e-changebg). - /// - public string? AIChangeBackground - { - get - { - if (!this.Properties.TryGetValue("aiChangeBackground", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["aiChangeBackground"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Adds an AI-based drop shadow around a foreground object on a transparent or - /// removed background. Optionally, control the direction, elevation, and saturation - /// of the light source (e.g., `az-45` to change light direction). Pass `true` - /// for the default drop shadow, or provide a string for a custom drop shadow. - /// Supported inside overlay. See [AI Drop Shadow](https://imagekit.io/docs/ai-transformations#ai-drop-shadow-e-dropshadow). - /// - public AIDropShadow? AIDropShadow - { - get - { - if (!this.Properties.TryGetValue("aiDropShadow", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["aiDropShadow"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Uses AI to edit images based on a text prompt. Provide a text prompt or a - /// base64-encoded prompt, e.g., `prompt-snow road` or `prompte-[urlencoded_base64_encoded_text]`. - /// Not supported inside overlay. See [AI Edit](https://imagekit.io/docs/ai-transformations#edit-image-e-edit). - /// - public string? AIEdit - { - get - { - if (!this.Properties.TryGetValue("aiEdit", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["aiEdit"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Applies ImageKit's in-house background removal. Supported inside overlay. - /// See [AI Background Removal](https://imagekit.io/docs/ai-transformations#imagekit-background-removal-e-bgremove). - /// - public ApiEnum? AIRemoveBackground - { - get - { - if (!this.Properties.TryGetValue("aiRemoveBackground", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["aiRemoveBackground"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Uses third-party background removal. Note: It is recommended to use aiRemoveBackground, - /// ImageKit's in-house solution, which is more cost-effective. Supported inside - /// overlay. See [External Background Removal](https://imagekit.io/docs/ai-transformations#background-removal-e-removedotbg). - /// - public ApiEnum? AIRemoveBackgroundExternal - { - get - { - if (!this.Properties.TryGetValue("aiRemoveBackgroundExternal", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["aiRemoveBackgroundExternal"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Performs AI-based retouching to improve faces or product shots. Not supported - /// inside overlay. See [AI Retouch](https://imagekit.io/docs/ai-transformations#retouch-e-retouch). - /// - public ApiEnum? AIRetouch - { - get - { - if (!this.Properties.TryGetValue("aiRetouch", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["aiRetouch"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Upscales images beyond their original dimensions using AI. Not supported inside - /// overlay. See [AI Upscale](https://imagekit.io/docs/ai-transformations#upscale-e-upscale). - /// - public ApiEnum? AIUpscale - { - get - { - if (!this.Properties.TryGetValue("aiUpscale", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["aiUpscale"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Generates a variation of an image using AI. This produces a new image with - /// slight variations from the original, such as changes in color, texture, - /// and other visual elements, while preserving the structure and essence of the - /// original image. Not supported inside overlay. See [AI Generate Variations](https://imagekit.io/docs/ai-transformations#generate-variations-of-an-image-e-genvar). - /// - public ApiEnum? AIVariation - { - get - { - if (!this.Properties.TryGetValue("aiVariation", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["aiVariation"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies the aspect ratio for the output, e.g., "ar-4-3". Typically used - /// with either width or height (but not both). For example: aspectRatio = `4:3`, - /// `4_3`, or an expression like `iar_div_2`. See [Image resize and crop – Aspect - /// ratio](https://imagekit.io/docs/image-resize-and-crop#aspect-ratio---ar). - /// - public AspectRatio? AspectRatio - { - get - { - if (!this.Properties.TryGetValue("aspectRatio", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["aspectRatio"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies the audio codec, e.g., `aac`, `opus`, or `none`. See [Audio codec](https://imagekit.io/docs/video-optimization#audio-codec---ac). - /// - public ApiEnum? AudioCodec - { - get - { - if (!this.Properties.TryGetValue("audioCodec", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["audioCodec"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies the background to be used in conjunction with certain cropping - /// strategies when resizing an image. - A solid color: e.g., `red`, `F3F3F3`, - /// `AAFF0010`. See [Solid color background](https://imagekit.io/docs/effects-and-enhancements#solid-color-background). - /// - A blurred background: e.g., `blurred`, `blurred_25_N15`, etc. See [Blurred - /// background](https://imagekit.io/docs/effects-and-enhancements#blurred-background). - /// - Expand the image boundaries using generative fill: `genfill`. Not supported - /// inside overlay. Optionally, control the background scene by passing a text - /// prompt: `genfill[:-prompt-${text}]` or `genfill[:-prompte-${urlencoded_base64_encoded_text}]`. - /// See [Generative fill background](https://imagekit.io/docs/ai-transformations#generative-fill-bg-genfill). - /// - public string? Background - { - get - { - if (!this.Properties.TryGetValue("background", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["background"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies the Gaussian blur level. Accepts an integer value between 1 and - /// 100, or an expression like `bl-10`. See [Blur](https://imagekit.io/docs/effects-and-enhancements#blur---bl). - /// - public double? Blur - { - get - { - if (!this.Properties.TryGetValue("blur", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["blur"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Adds a border to the output media. Accepts a string in the format `_` - /// (e.g., `5_FFF000` for a 5px yellow border), or an expression like `ih_div_20_FF00FF`. - /// See [Border](https://imagekit.io/docs/effects-and-enhancements#border---b). - /// - public string? Border - { - get - { - if (!this.Properties.TryGetValue("border", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["border"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Indicates whether the output image should retain the original color profile. - /// See [Color profile](https://imagekit.io/docs/image-optimization#color-profile---cp). - /// - public bool? ColorProfile - { - get - { - if (!this.Properties.TryGetValue("colorProfile", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["colorProfile"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Automatically enhances the contrast of an image (contrast stretch). See [Contrast - /// Stretch](https://imagekit.io/docs/effects-and-enhancements#contrast-stretch---e-contrast). - /// - public ApiEnum? ContrastStretch - { - get - { - if (!this.Properties.TryGetValue("contrastStretch", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["contrastStretch"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Crop modes for image resizing. See [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). - /// - public ApiEnum? Crop - { - get - { - if (!this.Properties.TryGetValue("crop", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["crop"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Additional crop modes for image resizing. See [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). - /// - public ApiEnum? CropMode - { - get - { - if (!this.Properties.TryGetValue("cropMode", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["cropMode"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies a fallback image if the resource is not found, e.g., a URL or file - /// path. See [Default image](https://imagekit.io/docs/image-transformation#default-image---di). - /// - public string? DefaultImage - { - get - { - if (!this.Properties.TryGetValue("defaultImage", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["defaultImage"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Accepts values between 0.1 and 5, or `auto` for automatic device pixel ratio - /// (DPR) calculation. See [DPR](https://imagekit.io/docs/image-resize-and-crop#dpr---dpr). - /// - public double? Dpr - { - get - { - if (!this.Properties.TryGetValue("dpr", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["dpr"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies the duration (in seconds) for trimming videos, e.g., `5` or `10.5`. - /// Typically used with startOffset to indicate the length from the start offset. - /// Arithmetic expressions are supported. See [Trim videos – Duration](https://imagekit.io/docs/trim-videos#duration---du). - /// - public Duration? Duration - { - get - { - if (!this.Properties.TryGetValue("duration", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["duration"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies the end offset (in seconds) for trimming videos, e.g., `5` or `10.5`. - /// Typically used with startOffset to define a time window. Arithmetic expressions - /// are supported. See [Trim videos – End offset](https://imagekit.io/docs/trim-videos#end-offset---eo). - /// - public EndOffset? EndOffset - { - get - { - if (!this.Properties.TryGetValue("endOffset", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["endOffset"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Flips or mirrors an image either horizontally, vertically, or both. Acceptable - /// values: `h` (horizontal), `v` (vertical), `h_v` (horizontal and vertical), - /// or `v_h`. See [Flip](https://imagekit.io/docs/effects-and-enhancements#flip---fl). - /// - public ApiEnum? Flip - { - get - { - if (!this.Properties.TryGetValue("flip", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["flip"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Refines padding and cropping behavior for pad resize, maintain ratio, and - /// extract crop modes. Supports manual positions and coordinate-based focus. - /// With AI-based cropping, you can automatically keep key subjects in frame—such - /// as faces or detected objects (e.g., `fo-face`, `fo-person`, `fo-car`)— while - /// resizing. - See [Focus](https://imagekit.io/docs/image-resize-and-crop#focus---fo). - /// - [Object aware cropping](https://imagekit.io/docs/image-resize-and-crop#object-aware-cropping---fo-object-name) - /// - public string? Focus - { - get - { - if (!this.Properties.TryGetValue("focus", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["focus"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies the output format for images or videos, e.g., `jpg`, `png`, `webp`, - /// `mp4`, or `auto`. You can also pass `orig` for images to return the original - /// format. ImageKit automatically delivers images and videos in the optimal format - /// based on device support unless overridden by the dashboard settings or the - /// format parameter. See [Image format](https://imagekit.io/docs/image-optimization#format---f) - /// and [Video format](https://imagekit.io/docs/video-optimization#format---f). - /// - public ApiEnum? Format - { - get - { - if (!this.Properties.TryGetValue("format", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["format"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Creates a linear gradient with two colors. Pass `true` for a default gradient, - /// or provide a string for a custom gradient. See [Gradient](https://imagekit.io/docs/effects-and-enhancements#gradient---e-gradient). - /// - public Gradient? Gradient - { - get - { - if (!this.Properties.TryGetValue("gradient", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["gradient"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Enables a grayscale effect for images. See [Grayscale](https://imagekit.io/docs/effects-and-enhancements#grayscale---e-grayscale). - /// - public ApiEnum? Grayscale - { - get - { - if (!this.Properties.TryGetValue("grayscale", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["grayscale"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies the height of the output. If a value between 0 and 1 is provided, - /// it is treated as a percentage (e.g., `0.5` represents 50% of the original - /// height). You can also supply arithmetic expressions (e.g., `ih_mul_0.5`). - /// Height transformation – [Images](https://imagekit.io/docs/image-resize-and-crop#height---h) - /// · [Videos](https://imagekit.io/docs/video-resize-and-crop#height---h) - /// - public Height? Height - { - get - { - if (!this.Properties.TryGetValue("height", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["height"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies whether the output image (in JPEG or PNG) should be compressed losslessly. - /// See [Lossless compression](https://imagekit.io/docs/image-optimization#lossless-webp-and-png---lo). - /// - public bool? Lossless - { - get - { - if (!this.Properties.TryGetValue("lossless", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["lossless"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// By default, ImageKit removes all metadata during automatic image compression. - /// Set this to true to preserve metadata. See [Image metadata](https://imagekit.io/docs/image-optimization#image-metadata---md). - /// - public bool? Metadata - { - get - { - if (!this.Properties.TryGetValue("metadata", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["metadata"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Named transformation reference. See [Named transformations](https://imagekit.io/docs/transformations#named-transformations). - /// - public string? Named - { - get - { - if (!this.Properties.TryGetValue("named", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["named"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies the opacity level of the output image. See [Opacity](https://imagekit.io/docs/effects-and-enhancements#opacity---o). - /// - public double? Opacity - { - get - { - if (!this.Properties.TryGetValue("opacity", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["opacity"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// If set to true, serves the original file without applying any transformations. - /// See [Deliver original file as-is](https://imagekit.io/docs/core-delivery-features#deliver-original-file-as-is---orig-true). - /// - public bool? Original - { - get - { - if (!this.Properties.TryGetValue("original", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["original"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies an overlay to be applied on the parent image or video. ImageKit - /// supports overlays including images, text, videos, subtitles, and solid colors. - /// See [Overlay using layers](https://imagekit.io/docs/transformations#overlay-using-layers). - /// - public Overlay? Overlay - { - get - { - if (!this.Properties.TryGetValue("overlay", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["overlay"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Extracts a specific page or frame from multi-page or layered files (PDF, PSD, - /// AI). For example, specify by number (e.g., `2`), a range (e.g., `3-4` for - /// the 2nd and 3rd layers), or by name (e.g., `name-layer-4` for a PSD layer). - /// See [Thumbnail extraction](https://imagekit.io/docs/vector-and-animated-images#get-thumbnail-from-psd-pdf-ai-eps-and-animated-files). - /// - public Page? Page - { - get - { - if (!this.Properties.TryGetValue("page", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["page"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies whether the output JPEG image should be rendered progressively. - /// Progressive loading begins with a low-quality, pixelated version of the full - /// image, which gradually improves to provide a faster perceived load time. See - /// [Progressive images](https://imagekit.io/docs/image-optimization#progressive-image---pr). - /// - public bool? Progressive - { - get - { - if (!this.Properties.TryGetValue("progressive", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["progressive"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies the quality of the output image for lossy formats such as JPEG, - /// WebP, and AVIF. A higher quality value results in a larger file size with - /// better quality, while a lower value produces a smaller file size with reduced - /// quality. See [Quality](https://imagekit.io/docs/image-optimization#quality---q). - /// - public double? Quality - { - get - { - if (!this.Properties.TryGetValue("quality", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["quality"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies the corner radius for rounded corners (e.g., 20) or `max` for circular - /// or oval shape. See [Radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). - /// - public Radius? Radius - { - get - { - if (!this.Properties.TryGetValue("radius", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["radius"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Pass any transformation not directly supported by the SDK. This transformation - /// string is appended to the URL as provided. - /// - public string? Raw - { - get - { - if (!this.Properties.TryGetValue("raw", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["raw"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies the rotation angle in degrees. Positive values rotate the image - /// clockwise; you can also use, for example, `N40` for counterclockwise rotation - /// or `auto` to use the orientation specified in the image's EXIF data. For - /// videos, only the following values are supported: 0, 90, 180, 270, or 360. - /// See [Rotate](https://imagekit.io/docs/effects-and-enhancements#rotate---rt). - /// - public Rotation? Rotation - { - get - { - if (!this.Properties.TryGetValue("rotation", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["rotation"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Adds a shadow beneath solid objects in an image with a transparent background. - /// For AI-based drop shadows, refer to aiDropShadow. Pass `true` for a default - /// shadow, or provide a string for a custom shadow. See [Shadow](https://imagekit.io/docs/effects-and-enhancements#shadow---e-shadow). - /// - public Shadow? Shadow - { - get - { - if (!this.Properties.TryGetValue("shadow", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["shadow"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Sharpens the input image, highlighting edges and finer details. Pass `true` - /// for default sharpening, or provide a numeric value for custom sharpening. - /// See [Sharpen](https://imagekit.io/docs/effects-and-enhancements#sharpen---e-sharpen). - /// - public Sharpen? Sharpen - { - get - { - if (!this.Properties.TryGetValue("sharpen", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["sharpen"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies the start offset (in seconds) for trimming videos, e.g., `5` or - /// `10.5`. Arithmetic expressions are also supported. See [Trim videos – Start - /// offset](https://imagekit.io/docs/trim-videos#start-offset---so). - /// - public StartOffset? StartOffset - { - get - { - if (!this.Properties.TryGetValue("startOffset", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["startOffset"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// An array of resolutions for adaptive bitrate streaming, e.g., [`240`, `360`, - /// `480`, `720`, `1080`]. See [Adaptive Bitrate Streaming](https://imagekit.io/docs/adaptive-bitrate-streaming). - /// - public List>? StreamingResolutions - { - get - { - if (!this.Properties.TryGetValue("streamingResolutions", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize>?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["streamingResolutions"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Useful for images with a solid or nearly solid background and a central object. - /// This parameter trims the background, leaving only the central object in - /// the output image. See [Trim edges](https://imagekit.io/docs/effects-and-enhancements#trim-edges---t). - /// - public Trim? Trim - { - get - { - if (!this.Properties.TryGetValue("trim", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["trim"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Applies Unsharp Masking (USM), an image sharpening technique. Pass `true` - /// for a default unsharp mask, or provide a string for a custom unsharp mask. - /// See [Unsharp Mask](https://imagekit.io/docs/effects-and-enhancements#unsharp-mask---e-usm). - /// - public UnsharpMask? UnsharpMask - { - get - { - if (!this.Properties.TryGetValue("unsharpMask", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["unsharpMask"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies the video codec, e.g., `h264`, `vp9`, `av1`, or `none`. See [Video codec](https://imagekit.io/docs/video-optimization#video-codec---vc). - /// - public ApiEnum? VideoCodec - { - get - { - if (!this.Properties.TryGetValue("videoCodec", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["videoCodec"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies the width of the output. If a value between 0 and 1 is provided, - /// it is treated as a percentage (e.g., `0.4` represents 40% of the original - /// width). You can also supply arithmetic expressions (e.g., `iw_div_2`). Width - /// transformation – [Images](https://imagekit.io/docs/image-resize-and-crop#width---w) - /// · [Videos](https://imagekit.io/docs/video-resize-and-crop#width---w) - /// - public Width? Width - { - get - { - if (!this.Properties.TryGetValue("width", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["width"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Focus using cropped image coordinates - X coordinate. See [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). - /// - public X? X - { - get - { - if (!this.Properties.TryGetValue("x", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["x"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Focus using cropped image coordinates - X center coordinate. See [Focus using - /// cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). - /// - public XCenter? XCenter - { - get - { - if (!this.Properties.TryGetValue("xCenter", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["xCenter"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Focus using cropped image coordinates - Y coordinate. See [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). - /// - public Y? Y - { - get - { - if (!this.Properties.TryGetValue("y", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["y"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Focus using cropped image coordinates - Y center coordinate. See [Focus using - /// cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). - /// - public YCenter? YCenter - { - get - { - if (!this.Properties.TryGetValue("yCenter", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["yCenter"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Accepts a numeric value that determines how much to zoom in or out of the - /// cropped area. It should be used in conjunction with fo-face or fo-. - /// See [Zoom](https://imagekit.io/docs/image-resize-and-crop#zoom---z). - /// - public double? Zoom - { - get - { - if (!this.Properties.TryGetValue("zoom", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["zoom"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.AIChangeBackground; - this.AIDropShadow?.Validate(); - _ = this.AIEdit; - this.AIRemoveBackground?.Validate(); - this.AIRemoveBackgroundExternal?.Validate(); - this.AIRetouch?.Validate(); - this.AIUpscale?.Validate(); - this.AIVariation?.Validate(); - this.AspectRatio?.Validate(); - this.AudioCodec?.Validate(); - _ = this.Background; - _ = this.Blur; - _ = this.Border; - _ = this.ColorProfile; - this.ContrastStretch?.Validate(); - this.Crop?.Validate(); - this.CropMode?.Validate(); - _ = this.DefaultImage; - _ = this.Dpr; - this.Duration?.Validate(); - this.EndOffset?.Validate(); - this.Flip?.Validate(); - _ = this.Focus; - this.Format?.Validate(); - this.Gradient?.Validate(); - this.Grayscale?.Validate(); - this.Height?.Validate(); - _ = this.Lossless; - _ = this.Metadata; - _ = this.Named; - _ = this.Opacity; - _ = this.Original; - this.Overlay?.Validate(); - this.Page?.Validate(); - _ = this.Progressive; - _ = this.Quality; - this.Radius?.Validate(); - _ = this.Raw; - this.Rotation?.Validate(); - this.Shadow?.Validate(); - this.Sharpen?.Validate(); - this.StartOffset?.Validate(); - foreach (var item in this.StreamingResolutions ?? []) - { - item.Validate(); - } - this.Trim?.Validate(); - this.UnsharpMask?.Validate(); - this.VideoCodec?.Validate(); - this.Width?.Validate(); - this.X?.Validate(); - this.XCenter?.Validate(); - this.Y?.Validate(); - this.YCenter?.Validate(); - _ = this.Zoom; - } - - public Transformation() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Transformation(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Transformation FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/TransformationProperties/AIDropShadow.cs b/src/Imagekit/Models/TransformationProperties/AIDropShadow.cs deleted file mode 100644 index 3fba9eb9..00000000 --- a/src/Imagekit/Models/TransformationProperties/AIDropShadow.cs +++ /dev/null @@ -1,146 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using AIDropShadowVariants = Imagekit.Models.TransformationProperties.AIDropShadowVariants; - -namespace Imagekit.Models.TransformationProperties; - -/// -/// Adds an AI-based drop shadow around a foreground object on a transparent or removed -/// background. Optionally, control the direction, elevation, and saturation of -/// the light source (e.g., `az-45` to change light direction). Pass `true` for the -/// default drop shadow, or provide a string for a custom drop shadow. Supported -/// inside overlay. See [AI Drop Shadow](https://imagekit.io/docs/ai-transformations#ai-drop-shadow-e-dropshadow). -/// -[JsonConverter(typeof(AIDropShadowConverter))] -public record class AIDropShadow -{ - public object Value { get; private init; } - - public AIDropShadow(UnionMember0 value) - { - Value = value; - } - - public AIDropShadow(string value) - { - Value = value; - } - - AIDropShadow(UnknownVariant value) - { - Value = value; - } - - public static AIDropShadow CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickTrue([NotNullWhen(true)] out UnionMember0? value) - { - value = this.Value as UnionMember0; - return value != null; - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public void Switch(Action true1, Action @string) - { - switch (this.Value) - { - case UnionMember0 value: - true1(value); - break; - case string value: - @string(value); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match(Func true1, Func @string) - { - return this.Value switch - { - AIDropShadowVariants::True inner => true1(inner), - AIDropShadowVariants::String inner => @string(inner), - _ => throw new InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException( - "Data did not match any variant of AIDropShadow" - ); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class AIDropShadowConverter : JsonConverter -{ - public override AIDropShadow? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - deserialized.Validate(); - return new AIDropShadow(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new AIDropShadow(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - - public override void Write( - Utf8JsonWriter writer, - AIDropShadow value, - JsonSerializerOptions options - ) - { - object variant = value switch - { - AIDropShadowVariants::True(var true1) => true1, - AIDropShadowVariants::String(var @string) => @string, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/TransformationProperties/AIDropShadowProperties/UnionMember0.cs b/src/Imagekit/Models/TransformationProperties/AIDropShadowProperties/UnionMember0.cs deleted file mode 100644 index 6d8c4f35..00000000 --- a/src/Imagekit/Models/TransformationProperties/AIDropShadowProperties/UnionMember0.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; - -namespace Imagekit.Models.TransformationProperties.AIDropShadowProperties; - -[JsonConverter(typeof(Converter))] -public class UnionMember0 -{ - public JsonElement Json { get; private init; } - - public UnionMember0() - { - Json = JsonSerializer.Deserialize("true"); - } - - UnionMember0(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new UnionMember0().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'UnionMember0'"); - } - } - - class Converter : JsonConverter - { - public override UnionMember0? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write( - Utf8JsonWriter writer, - UnionMember0 value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/TransformationProperties/AIDropShadowVariants/All.cs b/src/Imagekit/Models/TransformationProperties/AIDropShadowVariants/All.cs deleted file mode 100644 index 8efb0f9e..00000000 --- a/src/Imagekit/Models/TransformationProperties/AIDropShadowVariants/All.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Text.Json; - -namespace Imagekit.Models.TransformationProperties.AIDropShadowVariants; - -public sealed record class True(JsonElement Value) : AIDropShadow, IVariant -{ - public static True From(JsonElement value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class String(string Value) : AIDropShadow, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/TransformationProperties/AIRemoveBackground.cs b/src/Imagekit/Models/TransformationProperties/AIRemoveBackground.cs deleted file mode 100644 index dae6c3e7..00000000 --- a/src/Imagekit/Models/TransformationProperties/AIRemoveBackground.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.TransformationProperties; - -/// -/// Applies ImageKit's in-house background removal. Supported inside overlay. See -/// [AI Background Removal](https://imagekit.io/docs/ai-transformations#imagekit-background-removal-e-bgremove). -/// -[JsonConverter(typeof(AIRemoveBackgroundConverter))] -public enum AIRemoveBackground -{ - True, -} - -sealed class AIRemoveBackgroundConverter : JsonConverter -{ - public override AIRemoveBackground Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - true => AIRemoveBackground.True, - _ => (AIRemoveBackground)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - AIRemoveBackground value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - AIRemoveBackground.True => true, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/TransformationProperties/AIRemoveBackgroundExternal.cs b/src/Imagekit/Models/TransformationProperties/AIRemoveBackgroundExternal.cs deleted file mode 100644 index 263eeab4..00000000 --- a/src/Imagekit/Models/TransformationProperties/AIRemoveBackgroundExternal.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.TransformationProperties; - -/// -/// Uses third-party background removal. Note: It is recommended to use aiRemoveBackground, -/// ImageKit's in-house solution, which is more cost-effective. Supported inside overlay. -/// See [External Background Removal](https://imagekit.io/docs/ai-transformations#background-removal-e-removedotbg). -/// -[JsonConverter(typeof(AIRemoveBackgroundExternalConverter))] -public enum AIRemoveBackgroundExternal -{ - True, -} - -sealed class AIRemoveBackgroundExternalConverter : JsonConverter -{ - public override AIRemoveBackgroundExternal Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - true => AIRemoveBackgroundExternal.True, - _ => (AIRemoveBackgroundExternal)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - AIRemoveBackgroundExternal value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - AIRemoveBackgroundExternal.True => true, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/TransformationProperties/AIRetouch.cs b/src/Imagekit/Models/TransformationProperties/AIRetouch.cs deleted file mode 100644 index 19472a80..00000000 --- a/src/Imagekit/Models/TransformationProperties/AIRetouch.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.TransformationProperties; - -/// -/// Performs AI-based retouching to improve faces or product shots. Not supported -/// inside overlay. See [AI Retouch](https://imagekit.io/docs/ai-transformations#retouch-e-retouch). -/// -[JsonConverter(typeof(AIRetouchConverter))] -public enum AIRetouch -{ - True, -} - -sealed class AIRetouchConverter : JsonConverter -{ - public override AIRetouch Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - true => AIRetouch.True, - _ => (AIRetouch)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - AIRetouch value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - AIRetouch.True => true, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/TransformationProperties/AIUpscale.cs b/src/Imagekit/Models/TransformationProperties/AIUpscale.cs deleted file mode 100644 index 0ff1ab45..00000000 --- a/src/Imagekit/Models/TransformationProperties/AIUpscale.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.TransformationProperties; - -/// -/// Upscales images beyond their original dimensions using AI. Not supported inside -/// overlay. See [AI Upscale](https://imagekit.io/docs/ai-transformations#upscale-e-upscale). -/// -[JsonConverter(typeof(AIUpscaleConverter))] -public enum AIUpscale -{ - True, -} - -sealed class AIUpscaleConverter : JsonConverter -{ - public override AIUpscale Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - true => AIUpscale.True, - _ => (AIUpscale)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - AIUpscale value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - AIUpscale.True => true, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/TransformationProperties/AIVariation.cs b/src/Imagekit/Models/TransformationProperties/AIVariation.cs deleted file mode 100644 index 4f6d49e0..00000000 --- a/src/Imagekit/Models/TransformationProperties/AIVariation.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.TransformationProperties; - -/// -/// Generates a variation of an image using AI. This produces a new image with slight -/// variations from the original, such as changes in color, texture, and other visual -/// elements, while preserving the structure and essence of the original image. Not -/// supported inside overlay. See [AI Generate Variations](https://imagekit.io/docs/ai-transformations#generate-variations-of-an-image-e-genvar). -/// -[JsonConverter(typeof(AIVariationConverter))] -public enum AIVariation -{ - True, -} - -sealed class AIVariationConverter : JsonConverter -{ - public override AIVariation Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - true => AIVariation.True, - _ => (AIVariation)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - AIVariation value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - AIVariation.True => true, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/TransformationProperties/AspectRatio.cs b/src/Imagekit/Models/TransformationProperties/AspectRatio.cs deleted file mode 100644 index c7d78221..00000000 --- a/src/Imagekit/Models/TransformationProperties/AspectRatio.cs +++ /dev/null @@ -1,137 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using AspectRatioVariants = Imagekit.Models.TransformationProperties.AspectRatioVariants; - -namespace Imagekit.Models.TransformationProperties; - -/// -/// Specifies the aspect ratio for the output, e.g., "ar-4-3". Typically used with -/// either width or height (but not both). For example: aspectRatio = `4:3`, `4_3`, -/// or an expression like `iar_div_2`. See [Image resize and crop – Aspect ratio](https://imagekit.io/docs/image-resize-and-crop#aspect-ratio---ar). -/// -[JsonConverter(typeof(AspectRatioConverter))] -public record class AspectRatio -{ - public object Value { get; private init; } - - public AspectRatio(double value) - { - Value = value; - } - - public AspectRatio(string value) - { - Value = value; - } - - AspectRatio(UnknownVariant value) - { - Value = value; - } - - public static AspectRatio CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public void Switch(Action @double, Action @string) - { - switch (this.Value) - { - case double value: - @double(value); - break; - case string value: - @string(value); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match(Func @double, Func @string) - { - return this.Value switch - { - AspectRatioVariants::Double inner => @double(inner), - AspectRatioVariants::String inner => @string(inner), - _ => throw new InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of AspectRatio"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class AspectRatioConverter : JsonConverter -{ - public override AspectRatio? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - return new AspectRatio(JsonSerializer.Deserialize(ref reader, options)); - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new AspectRatio(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - - public override void Write( - Utf8JsonWriter writer, - AspectRatio value, - JsonSerializerOptions options - ) - { - object variant = value switch - { - AspectRatioVariants::Double(var @double) => @double, - AspectRatioVariants::String(var @string) => @string, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/TransformationProperties/AspectRatioVariants/All.cs b/src/Imagekit/Models/TransformationProperties/AspectRatioVariants/All.cs deleted file mode 100644 index d22b4b13..00000000 --- a/src/Imagekit/Models/TransformationProperties/AspectRatioVariants/All.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace Imagekit.Models.TransformationProperties.AspectRatioVariants; - -public sealed record class Double(double Value) : AspectRatio, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class String(string Value) : AspectRatio, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/TransformationProperties/AudioCodec.cs b/src/Imagekit/Models/TransformationProperties/AudioCodec.cs deleted file mode 100644 index c5a861d3..00000000 --- a/src/Imagekit/Models/TransformationProperties/AudioCodec.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.TransformationProperties; - -/// -/// Specifies the audio codec, e.g., `aac`, `opus`, or `none`. See [Audio codec](https://imagekit.io/docs/video-optimization#audio-codec---ac). -/// -[JsonConverter(typeof(AudioCodecConverter))] -public enum AudioCodec -{ - Aac, - Opus, - None, -} - -sealed class AudioCodecConverter : JsonConverter -{ - public override AudioCodec Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "aac" => AudioCodec.Aac, - "opus" => AudioCodec.Opus, - "none" => AudioCodec.None, - _ => (AudioCodec)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - AudioCodec value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - AudioCodec.Aac => "aac", - AudioCodec.Opus => "opus", - AudioCodec.None => "none", - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/TransformationProperties/ContrastStretch.cs b/src/Imagekit/Models/TransformationProperties/ContrastStretch.cs deleted file mode 100644 index 4ee3ec61..00000000 --- a/src/Imagekit/Models/TransformationProperties/ContrastStretch.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.TransformationProperties; - -/// -/// Automatically enhances the contrast of an image (contrast stretch). See [Contrast -/// Stretch](https://imagekit.io/docs/effects-and-enhancements#contrast-stretch---e-contrast). -/// -[JsonConverter(typeof(ContrastStretchConverter))] -public enum ContrastStretch -{ - True, -} - -sealed class ContrastStretchConverter : JsonConverter -{ - public override ContrastStretch Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - true => ContrastStretch.True, - _ => (ContrastStretch)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - ContrastStretch value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - ContrastStretch.True => true, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/TransformationProperties/Crop.cs b/src/Imagekit/Models/TransformationProperties/Crop.cs deleted file mode 100644 index eb549d7a..00000000 --- a/src/Imagekit/Models/TransformationProperties/Crop.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.TransformationProperties; - -/// -/// Crop modes for image resizing. See [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). -/// -[JsonConverter(typeof(CropConverter))] -public enum Crop -{ - Force, - AtMax, - AtMaxEnlarge, - AtLeast, - MaintainRatio, -} - -sealed class CropConverter : JsonConverter -{ - public override Crop Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "force" => Crop.Force, - "at_max" => Crop.AtMax, - "at_max_enlarge" => Crop.AtMaxEnlarge, - "at_least" => Crop.AtLeast, - "maintain_ratio" => Crop.MaintainRatio, - _ => (Crop)(-1), - }; - } - - public override void Write(Utf8JsonWriter writer, Crop value, JsonSerializerOptions options) - { - JsonSerializer.Serialize( - writer, - value switch - { - Crop.Force => "force", - Crop.AtMax => "at_max", - Crop.AtMaxEnlarge => "at_max_enlarge", - Crop.AtLeast => "at_least", - Crop.MaintainRatio => "maintain_ratio", - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/TransformationProperties/CropMode.cs b/src/Imagekit/Models/TransformationProperties/CropMode.cs deleted file mode 100644 index ec058dc1..00000000 --- a/src/Imagekit/Models/TransformationProperties/CropMode.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.TransformationProperties; - -/// -/// Additional crop modes for image resizing. See [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). -/// -[JsonConverter(typeof(CropModeConverter))] -public enum CropMode -{ - PadResize, - Extract, - PadExtract, -} - -sealed class CropModeConverter : JsonConverter -{ - public override CropMode Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "pad_resize" => CropMode.PadResize, - "extract" => CropMode.Extract, - "pad_extract" => CropMode.PadExtract, - _ => (CropMode)(-1), - }; - } - - public override void Write(Utf8JsonWriter writer, CropMode value, JsonSerializerOptions options) - { - JsonSerializer.Serialize( - writer, - value switch - { - CropMode.PadResize => "pad_resize", - CropMode.Extract => "extract", - CropMode.PadExtract => "pad_extract", - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/TransformationProperties/Duration.cs b/src/Imagekit/Models/TransformationProperties/Duration.cs deleted file mode 100644 index 84271fa2..00000000 --- a/src/Imagekit/Models/TransformationProperties/Duration.cs +++ /dev/null @@ -1,133 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using DurationVariants = Imagekit.Models.TransformationProperties.DurationVariants; - -namespace Imagekit.Models.TransformationProperties; - -/// -/// Specifies the duration (in seconds) for trimming videos, e.g., `5` or `10.5`. -/// Typically used with startOffset to indicate the length from the start offset. -/// Arithmetic expressions are supported. See [Trim videos – Duration](https://imagekit.io/docs/trim-videos#duration---du). -/// -[JsonConverter(typeof(DurationConverter))] -public record class Duration -{ - public object Value { get; private init; } - - public Duration(double value) - { - Value = value; - } - - public Duration(string value) - { - Value = value; - } - - Duration(UnknownVariant value) - { - Value = value; - } - - public static Duration CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public void Switch(Action @double, Action @string) - { - switch (this.Value) - { - case double value: - @double(value); - break; - case string value: - @string(value); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match(Func @double, Func @string) - { - return this.Value switch - { - DurationVariants::Double inner => @double(inner), - DurationVariants::String inner => @string(inner), - _ => throw new InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of Duration"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class DurationConverter : JsonConverter -{ - public override Duration? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - return new Duration(JsonSerializer.Deserialize(ref reader, options)); - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new Duration(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - - public override void Write(Utf8JsonWriter writer, Duration value, JsonSerializerOptions options) - { - object variant = value switch - { - DurationVariants::Double(var @double) => @double, - DurationVariants::String(var @string) => @string, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/TransformationProperties/DurationVariants/All.cs b/src/Imagekit/Models/TransformationProperties/DurationVariants/All.cs deleted file mode 100644 index 0aafb7f0..00000000 --- a/src/Imagekit/Models/TransformationProperties/DurationVariants/All.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace Imagekit.Models.TransformationProperties.DurationVariants; - -public sealed record class Double(double Value) : Duration, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class String(string Value) : Duration, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/TransformationProperties/EndOffset.cs b/src/Imagekit/Models/TransformationProperties/EndOffset.cs deleted file mode 100644 index 48276d96..00000000 --- a/src/Imagekit/Models/TransformationProperties/EndOffset.cs +++ /dev/null @@ -1,137 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using EndOffsetVariants = Imagekit.Models.TransformationProperties.EndOffsetVariants; - -namespace Imagekit.Models.TransformationProperties; - -/// -/// Specifies the end offset (in seconds) for trimming videos, e.g., `5` or `10.5`. -/// Typically used with startOffset to define a time window. Arithmetic expressions -/// are supported. See [Trim videos – End offset](https://imagekit.io/docs/trim-videos#end-offset---eo). -/// -[JsonConverter(typeof(EndOffsetConverter))] -public record class EndOffset -{ - public object Value { get; private init; } - - public EndOffset(double value) - { - Value = value; - } - - public EndOffset(string value) - { - Value = value; - } - - EndOffset(UnknownVariant value) - { - Value = value; - } - - public static EndOffset CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public void Switch(Action @double, Action @string) - { - switch (this.Value) - { - case double value: - @double(value); - break; - case string value: - @string(value); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match(Func @double, Func @string) - { - return this.Value switch - { - EndOffsetVariants::Double inner => @double(inner), - EndOffsetVariants::String inner => @string(inner), - _ => throw new InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of EndOffset"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class EndOffsetConverter : JsonConverter -{ - public override EndOffset? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - return new EndOffset(JsonSerializer.Deserialize(ref reader, options)); - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new EndOffset(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - - public override void Write( - Utf8JsonWriter writer, - EndOffset value, - JsonSerializerOptions options - ) - { - object variant = value switch - { - EndOffsetVariants::Double(var @double) => @double, - EndOffsetVariants::String(var @string) => @string, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/TransformationProperties/EndOffsetVariants/All.cs b/src/Imagekit/Models/TransformationProperties/EndOffsetVariants/All.cs deleted file mode 100644 index 062c3931..00000000 --- a/src/Imagekit/Models/TransformationProperties/EndOffsetVariants/All.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace Imagekit.Models.TransformationProperties.EndOffsetVariants; - -public sealed record class Double(double Value) : EndOffset, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class String(string Value) : EndOffset, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/TransformationProperties/Flip.cs b/src/Imagekit/Models/TransformationProperties/Flip.cs deleted file mode 100644 index 581d36a2..00000000 --- a/src/Imagekit/Models/TransformationProperties/Flip.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.TransformationProperties; - -/// -/// Flips or mirrors an image either horizontally, vertically, or both. Acceptable -/// values: `h` (horizontal), `v` (vertical), `h_v` (horizontal and vertical), or -/// `v_h`. See [Flip](https://imagekit.io/docs/effects-and-enhancements#flip---fl). -/// -[JsonConverter(typeof(FlipConverter))] -public enum Flip -{ - H, - V, - HV, - VH, -} - -sealed class FlipConverter : JsonConverter -{ - public override Flip Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "h" => Flip.H, - "v" => Flip.V, - "h_v" => Flip.HV, - "v_h" => Flip.VH, - _ => (Flip)(-1), - }; - } - - public override void Write(Utf8JsonWriter writer, Flip value, JsonSerializerOptions options) - { - JsonSerializer.Serialize( - writer, - value switch - { - Flip.H => "h", - Flip.V => "v", - Flip.HV => "h_v", - Flip.VH => "v_h", - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/TransformationProperties/Format.cs b/src/Imagekit/Models/TransformationProperties/Format.cs deleted file mode 100644 index 261f1417..00000000 --- a/src/Imagekit/Models/TransformationProperties/Format.cs +++ /dev/null @@ -1,78 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.TransformationProperties; - -/// -/// Specifies the output format for images or videos, e.g., `jpg`, `png`, `webp`, -/// `mp4`, or `auto`. You can also pass `orig` for images to return the original -/// format. ImageKit automatically delivers images and videos in the optimal format -/// based on device support unless overridden by the dashboard settings or the format -/// parameter. See [Image format](https://imagekit.io/docs/image-optimization#format---f) -/// and [Video format](https://imagekit.io/docs/video-optimization#format---f). -/// -[JsonConverter(typeof(FormatConverter))] -public enum Format -{ - Auto, - Webp, - Jpg, - Jpeg, - Png, - Gif, - Svg, - MP4, - Webm, - Avif, - Orig, -} - -sealed class FormatConverter : JsonConverter -{ - public override Format Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "auto" => Format.Auto, - "webp" => Format.Webp, - "jpg" => Format.Jpg, - "jpeg" => Format.Jpeg, - "png" => Format.Png, - "gif" => Format.Gif, - "svg" => Format.Svg, - "mp4" => Format.MP4, - "webm" => Format.Webm, - "avif" => Format.Avif, - "orig" => Format.Orig, - _ => (Format)(-1), - }; - } - - public override void Write(Utf8JsonWriter writer, Format value, JsonSerializerOptions options) - { - JsonSerializer.Serialize( - writer, - value switch - { - Format.Auto => "auto", - Format.Webp => "webp", - Format.Jpg => "jpg", - Format.Jpeg => "jpeg", - Format.Png => "png", - Format.Gif => "gif", - Format.Svg => "svg", - Format.MP4 => "mp4", - Format.Webm => "webm", - Format.Avif => "avif", - Format.Orig => "orig", - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/TransformationProperties/Gradient.cs b/src/Imagekit/Models/TransformationProperties/Gradient.cs deleted file mode 100644 index 8868a3ae..00000000 --- a/src/Imagekit/Models/TransformationProperties/Gradient.cs +++ /dev/null @@ -1,137 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using GradientVariants = Imagekit.Models.TransformationProperties.GradientVariants; - -namespace Imagekit.Models.TransformationProperties; - -/// -/// Creates a linear gradient with two colors. Pass `true` for a default gradient, -/// or provide a string for a custom gradient. See [Gradient](https://imagekit.io/docs/effects-and-enhancements#gradient---e-gradient). -/// -[JsonConverter(typeof(GradientConverter))] -public record class Gradient -{ - public object Value { get; private init; } - - public Gradient(UnionMember0 value) - { - Value = value; - } - - public Gradient(string value) - { - Value = value; - } - - Gradient(UnknownVariant value) - { - Value = value; - } - - public static Gradient CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickTrue([NotNullWhen(true)] out UnionMember0? value) - { - value = this.Value as UnionMember0; - return value != null; - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public void Switch(Action true1, Action @string) - { - switch (this.Value) - { - case UnionMember0 value: - true1(value); - break; - case string value: - @string(value); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match(Func true1, Func @string) - { - return this.Value switch - { - GradientVariants::True inner => true1(inner), - GradientVariants::String inner => @string(inner), - _ => throw new InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of Gradient"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class GradientConverter : JsonConverter -{ - public override Gradient? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - deserialized.Validate(); - return new Gradient(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new Gradient(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - - public override void Write(Utf8JsonWriter writer, Gradient value, JsonSerializerOptions options) - { - object variant = value switch - { - GradientVariants::True(var true1) => true1, - GradientVariants::String(var @string) => @string, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/TransformationProperties/GradientProperties/UnionMember0.cs b/src/Imagekit/Models/TransformationProperties/GradientProperties/UnionMember0.cs deleted file mode 100644 index 53e72624..00000000 --- a/src/Imagekit/Models/TransformationProperties/GradientProperties/UnionMember0.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; - -namespace Imagekit.Models.TransformationProperties.GradientProperties; - -[JsonConverter(typeof(Converter))] -public class UnionMember0 -{ - public JsonElement Json { get; private init; } - - public UnionMember0() - { - Json = JsonSerializer.Deserialize("true"); - } - - UnionMember0(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new UnionMember0().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'UnionMember0'"); - } - } - - class Converter : JsonConverter - { - public override UnionMember0? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write( - Utf8JsonWriter writer, - UnionMember0 value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/TransformationProperties/GradientVariants/All.cs b/src/Imagekit/Models/TransformationProperties/GradientVariants/All.cs deleted file mode 100644 index 6fc6bc18..00000000 --- a/src/Imagekit/Models/TransformationProperties/GradientVariants/All.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Text.Json; - -namespace Imagekit.Models.TransformationProperties.GradientVariants; - -public sealed record class True(JsonElement Value) : Gradient, IVariant -{ - public static True From(JsonElement value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class String(string Value) : Gradient, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/TransformationProperties/Grayscale.cs b/src/Imagekit/Models/TransformationProperties/Grayscale.cs deleted file mode 100644 index 4dac211d..00000000 --- a/src/Imagekit/Models/TransformationProperties/Grayscale.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.TransformationProperties; - -/// -/// Enables a grayscale effect for images. See [Grayscale](https://imagekit.io/docs/effects-and-enhancements#grayscale---e-grayscale). -/// -[JsonConverter(typeof(GrayscaleConverter))] -public enum Grayscale -{ - True, -} - -sealed class GrayscaleConverter : JsonConverter -{ - public override Grayscale Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - true => Grayscale.True, - _ => (Grayscale)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - Grayscale value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - Grayscale.True => true, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/TransformationProperties/Height.cs b/src/Imagekit/Models/TransformationProperties/Height.cs deleted file mode 100644 index 0e80cc07..00000000 --- a/src/Imagekit/Models/TransformationProperties/Height.cs +++ /dev/null @@ -1,134 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using HeightVariants = Imagekit.Models.TransformationProperties.HeightVariants; - -namespace Imagekit.Models.TransformationProperties; - -/// -/// Specifies the height of the output. If a value between 0 and 1 is provided, it -/// is treated as a percentage (e.g., `0.5` represents 50% of the original height). -/// You can also supply arithmetic expressions (e.g., `ih_mul_0.5`). Height transformation -/// – [Images](https://imagekit.io/docs/image-resize-and-crop#height---h) · [Videos](https://imagekit.io/docs/video-resize-and-crop#height---h) -/// -[JsonConverter(typeof(HeightConverter))] -public record class Height -{ - public object Value { get; private init; } - - public Height(double value) - { - Value = value; - } - - public Height(string value) - { - Value = value; - } - - Height(UnknownVariant value) - { - Value = value; - } - - public static Height CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public void Switch(Action @double, Action @string) - { - switch (this.Value) - { - case double value: - @double(value); - break; - case string value: - @string(value); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match(Func @double, Func @string) - { - return this.Value switch - { - HeightVariants::Double inner => @double(inner), - HeightVariants::String inner => @string(inner), - _ => throw new InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of Height"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class HeightConverter : JsonConverter -{ - public override Height? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - return new Height(JsonSerializer.Deserialize(ref reader, options)); - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new Height(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - - public override void Write(Utf8JsonWriter writer, Height value, JsonSerializerOptions options) - { - object variant = value switch - { - HeightVariants::Double(var @double) => @double, - HeightVariants::String(var @string) => @string, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/TransformationProperties/HeightVariants/All.cs b/src/Imagekit/Models/TransformationProperties/HeightVariants/All.cs deleted file mode 100644 index 52dece91..00000000 --- a/src/Imagekit/Models/TransformationProperties/HeightVariants/All.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace Imagekit.Models.TransformationProperties.HeightVariants; - -public sealed record class Double(double Value) : Height, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class String(string Value) : Height, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/TransformationProperties/Page.cs b/src/Imagekit/Models/TransformationProperties/Page.cs deleted file mode 100644 index dacd8fb7..00000000 --- a/src/Imagekit/Models/TransformationProperties/Page.cs +++ /dev/null @@ -1,248 +0,0 @@ -<<<<<<< HEAD -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using PageVariants = Imagekit.Models.TransformationProperties.PageVariants; - -namespace Imagekit.Models.TransformationProperties; - -/// -/// Extracts a specific page or frame from multi-page or layered files (PDF, PSD, -/// AI). For example, specify by number (e.g., `2`), a range (e.g., `3-4` for the -/// 2nd and 3rd layers), or by name (e.g., `name-layer-4` for a PSD layer). See [Thumbnail -/// extraction](https://imagekit.io/docs/vector-and-animated-images#get-thumbnail-from-psd-pdf-ai-eps-and-animated-files). -/// -[JsonConverter(typeof(PageConverter))] -public abstract record class Page -{ - internal Page() { } - - public static implicit operator Page(double value) => new PageVariants::Double(value); - - public static implicit operator Page(string value) => new PageVariants::String(value); - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = (this as PageVariants::Double)?.Value; - return value != null; - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = (this as PageVariants::String)?.Value; - return value != null; - } - - public void Switch(Action @double, Action @string) - { - switch (this) - { - case PageVariants::Double inner: - @double(inner); - break; - case PageVariants::String inner: - @string(inner); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match(Func @double, Func @string) - { - return this switch - { - PageVariants::Double inner => @double(inner), - PageVariants::String inner => @string(inner), - _ => throw new InvalidOperationException(), - }; - } - - public abstract void Validate(); -} - -sealed class PageConverter : JsonConverter -{ - public override Page? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - return new PageVariants::Double( - JsonSerializer.Deserialize(ref reader, options) - ); - } - catch (JsonException e) - { - exceptions.Add(e); - } - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new PageVariants::String(deserialized); - } - } - catch (JsonException e) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - - public override void Write(Utf8JsonWriter writer, Page value, JsonSerializerOptions options) - { - object variant = value switch - { - PageVariants::Double(var @double) => @double, - PageVariants::String(var @string) => @string, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} -======= -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; - -namespace Imagekit.Models.TransformationProperties; - -/// -/// Extracts a specific page or frame from multi-page or layered files (PDF, PSD, -/// AI). For example, specify by number (e.g., `2`), a range (e.g., `3-4` for the -/// 2nd and 3rd layers), or by name (e.g., `name-layer-4` for a PSD layer). See [Thumbnail -/// extraction](https://imagekit.io/docs/vector-and-animated-images#get-thumbnail-from-psd-pdf-ai-eps-and-animated-files). -/// -[JsonConverter(typeof(PageConverter))] -public record class Page -{ - public object Value { get; private init; } - - public Page(double value) - { - Value = value; - } - - public Page(string value) - { - Value = value; - } - - Page(UnknownVariant value) - { - Value = value; - } - - public static Page CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public void Switch(Action @double, Action @string) - { - switch (this.Value) - { - case double value: - @double(value); - break; - case string value: - @string(value); - break; - default: - throw new ImageKitInvalidDataException("Data did not match any variant of Page"); - } - } - - public T Match(Func @double, Func @string) - { - return this.Value switch - { - double value => @double(value), - string value => @string(value), - _ => throw new ImageKitInvalidDataException("Data did not match any variant of Page"), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of Page"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class PageConverter : JsonConverter -{ - public override Page? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - return new Page(JsonSerializer.Deserialize(ref reader, options)); - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'double'", e) - ); - } - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new Page(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'string'", e) - ); - } - - throw new AggregateException(exceptions); - } - - public override void Write(Utf8JsonWriter writer, Page value, JsonSerializerOptions options) - { - object variant = value.Value; - JsonSerializer.Serialize(writer, variant, options); - } -} ->>>>>>> origin/generated--merge-conflict diff --git a/src/Imagekit/Models/TransformationProperties/PageVariants/All.cs b/src/Imagekit/Models/TransformationProperties/PageVariants/All.cs deleted file mode 100644 index ef065b2d..00000000 --- a/src/Imagekit/Models/TransformationProperties/PageVariants/All.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace Imagekit.Models.TransformationProperties.PageVariants; - -public sealed record class Double(double Value) : Page, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class String(string Value) : Page, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/TransformationProperties/Radius.cs b/src/Imagekit/Models/TransformationProperties/Radius.cs deleted file mode 100644 index cd247358..00000000 --- a/src/Imagekit/Models/TransformationProperties/Radius.cs +++ /dev/null @@ -1,133 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using RadiusVariants = Imagekit.Models.TransformationProperties.RadiusVariants; - -namespace Imagekit.Models.TransformationProperties; - -/// -/// Specifies the corner radius for rounded corners (e.g., 20) or `max` for circular -/// or oval shape. See [Radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). -/// -[JsonConverter(typeof(RadiusConverter))] -public record class Radius -{ - public object Value { get; private init; } - - public Radius(double value) - { - Value = value; - } - - public Radius(UnionMember1 value) - { - Value = value; - } - - Radius(UnknownVariant value) - { - Value = value; - } - - public static Radius CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public bool TryPickMax([NotNullWhen(true)] out UnionMember1? value) - { - value = this.Value as UnionMember1; - return value != null; - } - - public void Switch(Action @double, Action max) - { - switch (this.Value) - { - case double value: - @double(value); - break; - case UnionMember1 value: - max(value); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match(Func @double, Func max) - { - return this.Value switch - { - RadiusVariants::Double inner => @double(inner), - RadiusVariants::Max inner => max(inner), - _ => throw new InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of Radius"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class RadiusConverter : JsonConverter -{ - public override Radius? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - deserialized.Validate(); - return new Radius(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - return new Radius(JsonSerializer.Deserialize(ref reader, options)); - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - - public override void Write(Utf8JsonWriter writer, Radius value, JsonSerializerOptions options) - { - object variant = value switch - { - RadiusVariants::Double(var @double) => @double, - RadiusVariants::Max(var max) => max, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/TransformationProperties/RadiusProperties/UnionMember1.cs b/src/Imagekit/Models/TransformationProperties/RadiusProperties/UnionMember1.cs deleted file mode 100644 index fe7d2e42..00000000 --- a/src/Imagekit/Models/TransformationProperties/RadiusProperties/UnionMember1.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; - -namespace Imagekit.Models.TransformationProperties.RadiusProperties; - -[JsonConverter(typeof(Converter))] -public class UnionMember1 -{ - public JsonElement Json { get; private init; } - - public UnionMember1() - { - Json = JsonSerializer.Deserialize("\"max\""); - } - - UnionMember1(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new UnionMember1().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'UnionMember1'"); - } - } - - class Converter : JsonConverter - { - public override UnionMember1? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write( - Utf8JsonWriter writer, - UnionMember1 value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/TransformationProperties/RadiusVariants/All.cs b/src/Imagekit/Models/TransformationProperties/RadiusVariants/All.cs deleted file mode 100644 index 78448ae7..00000000 --- a/src/Imagekit/Models/TransformationProperties/RadiusVariants/All.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Text.Json; - -namespace Imagekit.Models.TransformationProperties.RadiusVariants; - -public sealed record class Double(double Value) : Radius, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Max(JsonElement Value) : Radius, IVariant -{ - public static Max From(JsonElement value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/TransformationProperties/Rotation.cs b/src/Imagekit/Models/TransformationProperties/Rotation.cs deleted file mode 100644 index 38f9a0ed..00000000 --- a/src/Imagekit/Models/TransformationProperties/Rotation.cs +++ /dev/null @@ -1,134 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using RotationVariants = Imagekit.Models.TransformationProperties.RotationVariants; - -namespace Imagekit.Models.TransformationProperties; - -/// -/// Specifies the rotation angle in degrees. Positive values rotate the image clockwise; -/// you can also use, for example, `N40` for counterclockwise rotation or `auto` -/// to use the orientation specified in the image's EXIF data. For videos, only the -/// following values are supported: 0, 90, 180, 270, or 360. See [Rotate](https://imagekit.io/docs/effects-and-enhancements#rotate---rt). -/// -[JsonConverter(typeof(RotationConverter))] -public record class Rotation -{ - public object Value { get; private init; } - - public Rotation(double value) - { - Value = value; - } - - public Rotation(string value) - { - Value = value; - } - - Rotation(UnknownVariant value) - { - Value = value; - } - - public static Rotation CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public void Switch(Action @double, Action @string) - { - switch (this.Value) - { - case double value: - @double(value); - break; - case string value: - @string(value); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match(Func @double, Func @string) - { - return this.Value switch - { - RotationVariants::Double inner => @double(inner), - RotationVariants::String inner => @string(inner), - _ => throw new InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of Rotation"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class RotationConverter : JsonConverter -{ - public override Rotation? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - return new Rotation(JsonSerializer.Deserialize(ref reader, options)); - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new Rotation(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - - public override void Write(Utf8JsonWriter writer, Rotation value, JsonSerializerOptions options) - { - object variant = value switch - { - RotationVariants::Double(var @double) => @double, - RotationVariants::String(var @string) => @string, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/TransformationProperties/RotationVariants/All.cs b/src/Imagekit/Models/TransformationProperties/RotationVariants/All.cs deleted file mode 100644 index 2e7fac03..00000000 --- a/src/Imagekit/Models/TransformationProperties/RotationVariants/All.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace Imagekit.Models.TransformationProperties.RotationVariants; - -public sealed record class Double(double Value) : Rotation, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class String(string Value) : Rotation, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/TransformationProperties/Shadow.cs b/src/Imagekit/Models/TransformationProperties/Shadow.cs deleted file mode 100644 index b64f6ecf..00000000 --- a/src/Imagekit/Models/TransformationProperties/Shadow.cs +++ /dev/null @@ -1,138 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using ShadowVariants = Imagekit.Models.TransformationProperties.ShadowVariants; - -namespace Imagekit.Models.TransformationProperties; - -/// -/// Adds a shadow beneath solid objects in an image with a transparent background. -/// For AI-based drop shadows, refer to aiDropShadow. Pass `true` for a default -/// shadow, or provide a string for a custom shadow. See [Shadow](https://imagekit.io/docs/effects-and-enhancements#shadow---e-shadow). -/// -[JsonConverter(typeof(ShadowConverter))] -public record class Shadow -{ - public object Value { get; private init; } - - public Shadow(UnionMember0 value) - { - Value = value; - } - - public Shadow(string value) - { - Value = value; - } - - Shadow(UnknownVariant value) - { - Value = value; - } - - public static Shadow CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickTrue([NotNullWhen(true)] out UnionMember0? value) - { - value = this.Value as UnionMember0; - return value != null; - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public void Switch(Action true1, Action @string) - { - switch (this.Value) - { - case UnionMember0 value: - true1(value); - break; - case string value: - @string(value); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match(Func true1, Func @string) - { - return this.Value switch - { - ShadowVariants::True inner => true1(inner), - ShadowVariants::String inner => @string(inner), - _ => throw new InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of Shadow"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class ShadowConverter : JsonConverter -{ - public override Shadow? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - deserialized.Validate(); - return new Shadow(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new Shadow(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - - public override void Write(Utf8JsonWriter writer, Shadow value, JsonSerializerOptions options) - { - object variant = value switch - { - ShadowVariants::True(var true1) => true1, - ShadowVariants::String(var @string) => @string, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/TransformationProperties/ShadowProperties/UnionMember0.cs b/src/Imagekit/Models/TransformationProperties/ShadowProperties/UnionMember0.cs deleted file mode 100644 index 06dbd966..00000000 --- a/src/Imagekit/Models/TransformationProperties/ShadowProperties/UnionMember0.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; - -namespace Imagekit.Models.TransformationProperties.ShadowProperties; - -[JsonConverter(typeof(Converter))] -public class UnionMember0 -{ - public JsonElement Json { get; private init; } - - public UnionMember0() - { - Json = JsonSerializer.Deserialize("true"); - } - - UnionMember0(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new UnionMember0().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'UnionMember0'"); - } - } - - class Converter : JsonConverter - { - public override UnionMember0? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write( - Utf8JsonWriter writer, - UnionMember0 value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/TransformationProperties/ShadowVariants/All.cs b/src/Imagekit/Models/TransformationProperties/ShadowVariants/All.cs deleted file mode 100644 index 94e02120..00000000 --- a/src/Imagekit/Models/TransformationProperties/ShadowVariants/All.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Text.Json; - -namespace Imagekit.Models.TransformationProperties.ShadowVariants; - -public sealed record class True(JsonElement Value) : Shadow, IVariant -{ - public static True From(JsonElement value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class String(string Value) : Shadow, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/TransformationProperties/Sharpen.cs b/src/Imagekit/Models/TransformationProperties/Sharpen.cs deleted file mode 100644 index 9ec13412..00000000 --- a/src/Imagekit/Models/TransformationProperties/Sharpen.cs +++ /dev/null @@ -1,134 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using SharpenVariants = Imagekit.Models.TransformationProperties.SharpenVariants; - -namespace Imagekit.Models.TransformationProperties; - -/// -/// Sharpens the input image, highlighting edges and finer details. Pass `true` -/// for default sharpening, or provide a numeric value for custom sharpening. See -/// [Sharpen](https://imagekit.io/docs/effects-and-enhancements#sharpen---e-sharpen). -/// -[JsonConverter(typeof(SharpenConverter))] -public record class Sharpen -{ - public object Value { get; private init; } - - public Sharpen(UnionMember0 value) - { - Value = value; - } - - public Sharpen(double value) - { - Value = value; - } - - Sharpen(UnknownVariant value) - { - Value = value; - } - - public static Sharpen CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickTrue([NotNullWhen(true)] out UnionMember0? value) - { - value = this.Value as UnionMember0; - return value != null; - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public void Switch(Action true1, Action @double) - { - switch (this.Value) - { - case UnionMember0 value: - true1(value); - break; - case double value: - @double(value); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match(Func true1, Func @double) - { - return this.Value switch - { - SharpenVariants::True inner => true1(inner), - SharpenVariants::Double inner => @double(inner), - _ => throw new InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of Sharpen"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class SharpenConverter : JsonConverter -{ - public override Sharpen? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - deserialized.Validate(); - return new Sharpen(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - return new Sharpen(JsonSerializer.Deserialize(ref reader, options)); - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - - public override void Write(Utf8JsonWriter writer, Sharpen value, JsonSerializerOptions options) - { - object variant = value switch - { - SharpenVariants::True(var true1) => true1, - SharpenVariants::Double(var @double) => @double, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/TransformationProperties/SharpenProperties/UnionMember0.cs b/src/Imagekit/Models/TransformationProperties/SharpenProperties/UnionMember0.cs deleted file mode 100644 index eb9d1273..00000000 --- a/src/Imagekit/Models/TransformationProperties/SharpenProperties/UnionMember0.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; - -namespace Imagekit.Models.TransformationProperties.SharpenProperties; - -[JsonConverter(typeof(Converter))] -public class UnionMember0 -{ - public JsonElement Json { get; private init; } - - public UnionMember0() - { - Json = JsonSerializer.Deserialize("true"); - } - - UnionMember0(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new UnionMember0().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'UnionMember0'"); - } - } - - class Converter : JsonConverter - { - public override UnionMember0? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write( - Utf8JsonWriter writer, - UnionMember0 value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/TransformationProperties/SharpenVariants/All.cs b/src/Imagekit/Models/TransformationProperties/SharpenVariants/All.cs deleted file mode 100644 index aa226c35..00000000 --- a/src/Imagekit/Models/TransformationProperties/SharpenVariants/All.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Text.Json; - -namespace Imagekit.Models.TransformationProperties.SharpenVariants; - -public sealed record class True(JsonElement Value) : Sharpen, IVariant -{ - public static True From(JsonElement value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Double(double Value) : Sharpen, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/TransformationProperties/StartOffset.cs b/src/Imagekit/Models/TransformationProperties/StartOffset.cs deleted file mode 100644 index 4eaa72f8..00000000 --- a/src/Imagekit/Models/TransformationProperties/StartOffset.cs +++ /dev/null @@ -1,136 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using StartOffsetVariants = Imagekit.Models.TransformationProperties.StartOffsetVariants; - -namespace Imagekit.Models.TransformationProperties; - -/// -/// Specifies the start offset (in seconds) for trimming videos, e.g., `5` or `10.5`. -/// Arithmetic expressions are also supported. See [Trim videos – Start offset](https://imagekit.io/docs/trim-videos#start-offset---so). -/// -[JsonConverter(typeof(StartOffsetConverter))] -public record class StartOffset -{ - public object Value { get; private init; } - - public StartOffset(double value) - { - Value = value; - } - - public StartOffset(string value) - { - Value = value; - } - - StartOffset(UnknownVariant value) - { - Value = value; - } - - public static StartOffset CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public void Switch(Action @double, Action @string) - { - switch (this.Value) - { - case double value: - @double(value); - break; - case string value: - @string(value); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match(Func @double, Func @string) - { - return this.Value switch - { - StartOffsetVariants::Double inner => @double(inner), - StartOffsetVariants::String inner => @string(inner), - _ => throw new InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of StartOffset"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class StartOffsetConverter : JsonConverter -{ - public override StartOffset? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - return new StartOffset(JsonSerializer.Deserialize(ref reader, options)); - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new StartOffset(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - - public override void Write( - Utf8JsonWriter writer, - StartOffset value, - JsonSerializerOptions options - ) - { - object variant = value switch - { - StartOffsetVariants::Double(var @double) => @double, - StartOffsetVariants::String(var @string) => @string, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/TransformationProperties/StartOffsetVariants/All.cs b/src/Imagekit/Models/TransformationProperties/StartOffsetVariants/All.cs deleted file mode 100644 index 652e3912..00000000 --- a/src/Imagekit/Models/TransformationProperties/StartOffsetVariants/All.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace Imagekit.Models.TransformationProperties.StartOffsetVariants; - -public sealed record class Double(double Value) : StartOffset, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class String(string Value) : StartOffset, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/TransformationProperties/Trim.cs b/src/Imagekit/Models/TransformationProperties/Trim.cs deleted file mode 100644 index ce1298ba..00000000 --- a/src/Imagekit/Models/TransformationProperties/Trim.cs +++ /dev/null @@ -1,134 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using TrimVariants = Imagekit.Models.TransformationProperties.TrimVariants; - -namespace Imagekit.Models.TransformationProperties; - -/// -/// Useful for images with a solid or nearly solid background and a central object. -/// This parameter trims the background, leaving only the central object in the output -/// image. See [Trim edges](https://imagekit.io/docs/effects-and-enhancements#trim-edges---t). -/// -[JsonConverter(typeof(TrimConverter))] -public record class Trim -{ - public object Value { get; private init; } - - public Trim(UnionMember0 value) - { - Value = value; - } - - public Trim(double value) - { - Value = value; - } - - Trim(UnknownVariant value) - { - Value = value; - } - - public static Trim CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickTrue([NotNullWhen(true)] out UnionMember0? value) - { - value = this.Value as UnionMember0; - return value != null; - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public void Switch(Action true1, Action @double) - { - switch (this.Value) - { - case UnionMember0 value: - true1(value); - break; - case double value: - @double(value); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match(Func true1, Func @double) - { - return this.Value switch - { - TrimVariants::True inner => true1(inner), - TrimVariants::Double inner => @double(inner), - _ => throw new InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of Trim"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class TrimConverter : JsonConverter -{ - public override Trim? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - deserialized.Validate(); - return new Trim(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - return new Trim(JsonSerializer.Deserialize(ref reader, options)); - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - - public override void Write(Utf8JsonWriter writer, Trim value, JsonSerializerOptions options) - { - object variant = value switch - { - TrimVariants::True(var true1) => true1, - TrimVariants::Double(var @double) => @double, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/TransformationProperties/TrimProperties/UnionMember0.cs b/src/Imagekit/Models/TransformationProperties/TrimProperties/UnionMember0.cs deleted file mode 100644 index 28421060..00000000 --- a/src/Imagekit/Models/TransformationProperties/TrimProperties/UnionMember0.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; - -namespace Imagekit.Models.TransformationProperties.TrimProperties; - -[JsonConverter(typeof(Converter))] -public class UnionMember0 -{ - public JsonElement Json { get; private init; } - - public UnionMember0() - { - Json = JsonSerializer.Deserialize("true"); - } - - UnionMember0(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new UnionMember0().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'UnionMember0'"); - } - } - - class Converter : JsonConverter - { - public override UnionMember0? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write( - Utf8JsonWriter writer, - UnionMember0 value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/TransformationProperties/TrimVariants/All.cs b/src/Imagekit/Models/TransformationProperties/TrimVariants/All.cs deleted file mode 100644 index e26ab0d0..00000000 --- a/src/Imagekit/Models/TransformationProperties/TrimVariants/All.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Text.Json; - -namespace Imagekit.Models.TransformationProperties.TrimVariants; - -public sealed record class True(JsonElement Value) : Trim, IVariant -{ - public static True From(JsonElement value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class Double(double Value) : Trim, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/TransformationProperties/UnsharpMask.cs b/src/Imagekit/Models/TransformationProperties/UnsharpMask.cs deleted file mode 100644 index cc5e6889..00000000 --- a/src/Imagekit/Models/TransformationProperties/UnsharpMask.cs +++ /dev/null @@ -1,142 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using UnsharpMaskVariants = Imagekit.Models.TransformationProperties.UnsharpMaskVariants; - -namespace Imagekit.Models.TransformationProperties; - -/// -/// Applies Unsharp Masking (USM), an image sharpening technique. Pass `true` for -/// a default unsharp mask, or provide a string for a custom unsharp mask. See [Unsharp -/// Mask](https://imagekit.io/docs/effects-and-enhancements#unsharp-mask---e-usm). -/// -[JsonConverter(typeof(UnsharpMaskConverter))] -public record class UnsharpMask -{ - public object Value { get; private init; } - - public UnsharpMask(UnionMember0 value) - { - Value = value; - } - - public UnsharpMask(string value) - { - Value = value; - } - - UnsharpMask(UnknownVariant value) - { - Value = value; - } - - public static UnsharpMask CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickTrue([NotNullWhen(true)] out UnionMember0? value) - { - value = this.Value as UnionMember0; - return value != null; - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public void Switch(Action true1, Action @string) - { - switch (this.Value) - { - case UnionMember0 value: - true1(value); - break; - case string value: - @string(value); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match(Func true1, Func @string) - { - return this.Value switch - { - UnsharpMaskVariants::True inner => true1(inner), - UnsharpMaskVariants::String inner => @string(inner), - _ => throw new InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of UnsharpMask"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class UnsharpMaskConverter : JsonConverter -{ - public override UnsharpMask? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - deserialized.Validate(); - return new UnsharpMask(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new UnsharpMask(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - - public override void Write( - Utf8JsonWriter writer, - UnsharpMask value, - JsonSerializerOptions options - ) - { - object variant = value switch - { - UnsharpMaskVariants::True(var true1) => true1, - UnsharpMaskVariants::String(var @string) => @string, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/TransformationProperties/UnsharpMaskProperties/UnionMember0.cs b/src/Imagekit/Models/TransformationProperties/UnsharpMaskProperties/UnionMember0.cs deleted file mode 100644 index 5e6c8be9..00000000 --- a/src/Imagekit/Models/TransformationProperties/UnsharpMaskProperties/UnionMember0.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; - -namespace Imagekit.Models.TransformationProperties.UnsharpMaskProperties; - -[JsonConverter(typeof(Converter))] -public class UnionMember0 -{ - public JsonElement Json { get; private init; } - - public UnionMember0() - { - Json = JsonSerializer.Deserialize("true"); - } - - UnionMember0(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new UnionMember0().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'UnionMember0'"); - } - } - - class Converter : JsonConverter - { - public override UnionMember0? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write( - Utf8JsonWriter writer, - UnionMember0 value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/TransformationProperties/UnsharpMaskVariants/All.cs b/src/Imagekit/Models/TransformationProperties/UnsharpMaskVariants/All.cs deleted file mode 100644 index 6662a69b..00000000 --- a/src/Imagekit/Models/TransformationProperties/UnsharpMaskVariants/All.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Text.Json; - -namespace Imagekit.Models.TransformationProperties.UnsharpMaskVariants; - -public sealed record class True(JsonElement Value) : UnsharpMask, IVariant -{ - public static True From(JsonElement value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class String(string Value) : UnsharpMask, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/TransformationProperties/VideoCodec.cs b/src/Imagekit/Models/TransformationProperties/VideoCodec.cs deleted file mode 100644 index c00b2b3b..00000000 --- a/src/Imagekit/Models/TransformationProperties/VideoCodec.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.TransformationProperties; - -/// -/// Specifies the video codec, e.g., `h264`, `vp9`, `av1`, or `none`. See [Video codec](https://imagekit.io/docs/video-optimization#video-codec---vc). -/// -[JsonConverter(typeof(VideoCodecConverter))] -public enum VideoCodec -{ - H264, - Vp9, - Av1, - None, -} - -sealed class VideoCodecConverter : JsonConverter -{ - public override VideoCodec Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "h264" => VideoCodec.H264, - "vp9" => VideoCodec.Vp9, - "av1" => VideoCodec.Av1, - "none" => VideoCodec.None, - _ => (VideoCodec)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - VideoCodec value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - VideoCodec.H264 => "h264", - VideoCodec.Vp9 => "vp9", - VideoCodec.Av1 => "av1", - VideoCodec.None => "none", - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/TransformationProperties/Width.cs b/src/Imagekit/Models/TransformationProperties/Width.cs deleted file mode 100644 index 6b79c3fe..00000000 --- a/src/Imagekit/Models/TransformationProperties/Width.cs +++ /dev/null @@ -1,134 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using WidthVariants = Imagekit.Models.TransformationProperties.WidthVariants; - -namespace Imagekit.Models.TransformationProperties; - -/// -/// Specifies the width of the output. If a value between 0 and 1 is provided, it -/// is treated as a percentage (e.g., `0.4` represents 40% of the original width). -/// You can also supply arithmetic expressions (e.g., `iw_div_2`). Width transformation -/// – [Images](https://imagekit.io/docs/image-resize-and-crop#width---w) · [Videos](https://imagekit.io/docs/video-resize-and-crop#width---w) -/// -[JsonConverter(typeof(WidthConverter))] -public record class Width -{ - public object Value { get; private init; } - - public Width(double value) - { - Value = value; - } - - public Width(string value) - { - Value = value; - } - - Width(UnknownVariant value) - { - Value = value; - } - - public static Width CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public void Switch(Action @double, Action @string) - { - switch (this.Value) - { - case double value: - @double(value); - break; - case string value: - @string(value); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match(Func @double, Func @string) - { - return this.Value switch - { - WidthVariants::Double inner => @double(inner), - WidthVariants::String inner => @string(inner), - _ => throw new InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of Width"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class WidthConverter : JsonConverter -{ - public override Width? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - return new Width(JsonSerializer.Deserialize(ref reader, options)); - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new Width(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - - public override void Write(Utf8JsonWriter writer, Width value, JsonSerializerOptions options) - { - object variant = value switch - { - WidthVariants::Double(var @double) => @double, - WidthVariants::String(var @string) => @string, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/TransformationProperties/WidthVariants/All.cs b/src/Imagekit/Models/TransformationProperties/WidthVariants/All.cs deleted file mode 100644 index 3899be2b..00000000 --- a/src/Imagekit/Models/TransformationProperties/WidthVariants/All.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace Imagekit.Models.TransformationProperties.WidthVariants; - -public sealed record class Double(double Value) : Width, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class String(string Value) : Width, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/TransformationProperties/X.cs b/src/Imagekit/Models/TransformationProperties/X.cs deleted file mode 100644 index a2fbde54..00000000 --- a/src/Imagekit/Models/TransformationProperties/X.cs +++ /dev/null @@ -1,131 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using XVariants = Imagekit.Models.TransformationProperties.XVariants; - -namespace Imagekit.Models.TransformationProperties; - -/// -/// Focus using cropped image coordinates - X coordinate. See [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). -/// -[JsonConverter(typeof(XConverter))] -public record class X -{ - public object Value { get; private init; } - - public X(double value) - { - Value = value; - } - - public X(string value) - { - Value = value; - } - - X(UnknownVariant value) - { - Value = value; - } - - public static X CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public void Switch(Action @double, Action @string) - { - switch (this.Value) - { - case double value: - @double(value); - break; - case string value: - @string(value); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match(Func @double, Func @string) - { - return this.Value switch - { - XVariants::Double inner => @double(inner), - XVariants::String inner => @string(inner), - _ => throw new InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of X"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class XConverter : JsonConverter -{ - public override X? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - return new X(JsonSerializer.Deserialize(ref reader, options)); - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new X(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - - public override void Write(Utf8JsonWriter writer, X value, JsonSerializerOptions options) - { - object variant = value switch - { - XVariants::Double(var @double) => @double, - XVariants::String(var @string) => @string, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/TransformationProperties/XCenter.cs b/src/Imagekit/Models/TransformationProperties/XCenter.cs deleted file mode 100644 index 068236c4..00000000 --- a/src/Imagekit/Models/TransformationProperties/XCenter.cs +++ /dev/null @@ -1,132 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using XCenterVariants = Imagekit.Models.TransformationProperties.XCenterVariants; - -namespace Imagekit.Models.TransformationProperties; - -/// -/// Focus using cropped image coordinates - X center coordinate. See [Focus using -/// cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). -/// -[JsonConverter(typeof(XCenterConverter))] -public record class XCenter -{ - public object Value { get; private init; } - - public XCenter(double value) - { - Value = value; - } - - public XCenter(string value) - { - Value = value; - } - - XCenter(UnknownVariant value) - { - Value = value; - } - - public static XCenter CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public void Switch(Action @double, Action @string) - { - switch (this.Value) - { - case double value: - @double(value); - break; - case string value: - @string(value); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match(Func @double, Func @string) - { - return this.Value switch - { - XCenterVariants::Double inner => @double(inner), - XCenterVariants::String inner => @string(inner), - _ => throw new InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of XCenter"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class XCenterConverter : JsonConverter -{ - public override XCenter? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - return new XCenter(JsonSerializer.Deserialize(ref reader, options)); - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new XCenter(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - - public override void Write(Utf8JsonWriter writer, XCenter value, JsonSerializerOptions options) - { - object variant = value switch - { - XCenterVariants::Double(var @double) => @double, - XCenterVariants::String(var @string) => @string, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/TransformationProperties/XCenterVariants/All.cs b/src/Imagekit/Models/TransformationProperties/XCenterVariants/All.cs deleted file mode 100644 index af356397..00000000 --- a/src/Imagekit/Models/TransformationProperties/XCenterVariants/All.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace Imagekit.Models.TransformationProperties.XCenterVariants; - -public sealed record class Double(double Value) : XCenter, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class String(string Value) : XCenter, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/TransformationProperties/XVariants/All.cs b/src/Imagekit/Models/TransformationProperties/XVariants/All.cs deleted file mode 100644 index f147a03c..00000000 --- a/src/Imagekit/Models/TransformationProperties/XVariants/All.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace Imagekit.Models.TransformationProperties.XVariants; - -public sealed record class Double(double Value) : X, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class String(string Value) : X, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/TransformationProperties/Y.cs b/src/Imagekit/Models/TransformationProperties/Y.cs deleted file mode 100644 index 4680e0ae..00000000 --- a/src/Imagekit/Models/TransformationProperties/Y.cs +++ /dev/null @@ -1,131 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using YVariants = Imagekit.Models.TransformationProperties.YVariants; - -namespace Imagekit.Models.TransformationProperties; - -/// -/// Focus using cropped image coordinates - Y coordinate. See [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). -/// -[JsonConverter(typeof(YConverter))] -public record class Y -{ - public object Value { get; private init; } - - public Y(double value) - { - Value = value; - } - - public Y(string value) - { - Value = value; - } - - Y(UnknownVariant value) - { - Value = value; - } - - public static Y CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public void Switch(Action @double, Action @string) - { - switch (this.Value) - { - case double value: - @double(value); - break; - case string value: - @string(value); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match(Func @double, Func @string) - { - return this.Value switch - { - YVariants::Double inner => @double(inner), - YVariants::String inner => @string(inner), - _ => throw new InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of Y"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class YConverter : JsonConverter -{ - public override Y? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - return new Y(JsonSerializer.Deserialize(ref reader, options)); - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new Y(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - - public override void Write(Utf8JsonWriter writer, Y value, JsonSerializerOptions options) - { - object variant = value switch - { - YVariants::Double(var @double) => @double, - YVariants::String(var @string) => @string, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/TransformationProperties/YCenter.cs b/src/Imagekit/Models/TransformationProperties/YCenter.cs deleted file mode 100644 index 93006759..00000000 --- a/src/Imagekit/Models/TransformationProperties/YCenter.cs +++ /dev/null @@ -1,132 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using YCenterVariants = Imagekit.Models.TransformationProperties.YCenterVariants; - -namespace Imagekit.Models.TransformationProperties; - -/// -/// Focus using cropped image coordinates - Y center coordinate. See [Focus using -/// cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). -/// -[JsonConverter(typeof(YCenterConverter))] -public record class YCenter -{ - public object Value { get; private init; } - - public YCenter(double value) - { - Value = value; - } - - public YCenter(string value) - { - Value = value; - } - - YCenter(UnknownVariant value) - { - Value = value; - } - - public static YCenter CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public void Switch(Action @double, Action @string) - { - switch (this.Value) - { - case double value: - @double(value); - break; - case string value: - @string(value); - break; - default: - throw new InvalidOperationException(); - } - } - - public T Match(Func @double, Func @string) - { - return this.Value switch - { - YCenterVariants::Double inner => @double(inner), - YCenterVariants::String inner => @string(inner), - _ => throw new InvalidOperationException(), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of YCenter"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class YCenterConverter : JsonConverter -{ - public override YCenter? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - return new YCenter(JsonSerializer.Deserialize(ref reader, options)); - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new YCenter(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add(e); - } - - throw new AggregateException(exceptions); - } - - public override void Write(Utf8JsonWriter writer, YCenter value, JsonSerializerOptions options) - { - object variant = value switch - { - YCenterVariants::Double(var @double) => @double, - YCenterVariants::String(var @string) => @string, - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/TransformationProperties/YCenterVariants/All.cs b/src/Imagekit/Models/TransformationProperties/YCenterVariants/All.cs deleted file mode 100644 index beec9696..00000000 --- a/src/Imagekit/Models/TransformationProperties/YCenterVariants/All.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace Imagekit.Models.TransformationProperties.YCenterVariants; - -public sealed record class Double(double Value) : YCenter, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class String(string Value) : YCenter, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/TransformationProperties/YVariants/All.cs b/src/Imagekit/Models/TransformationProperties/YVariants/All.cs deleted file mode 100644 index eff97584..00000000 --- a/src/Imagekit/Models/TransformationProperties/YVariants/All.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace Imagekit.Models.TransformationProperties.YVariants; - -public sealed record class Double(double Value) : Y, IVariant -{ - public static Double From(double value) - { - return new(value); - } - - public override void Validate() { } -} - -public sealed record class String(string Value) : Y, IVariant -{ - public static String From(string value) - { - return new(value); - } - - public override void Validate() { } -} diff --git a/src/Imagekit/Models/UnnamedSchemaWithArrayParent0.cs b/src/Imagekit/Models/UnnamedSchemaWithArrayParent0.cs deleted file mode 100644 index 103e2a75..00000000 --- a/src/Imagekit/Models/UnnamedSchemaWithArrayParent0.cs +++ /dev/null @@ -1,224 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using Imagekit.Models.UnnamedSchemaWithArrayParent0Properties; - -namespace Imagekit.Models; - -[JsonConverter(typeof(UnnamedSchemaWithArrayParent0Converter))] -public record class UnnamedSchemaWithArrayParent0 -{ - public object Value { get; private init; } - - public UnnamedSchemaWithArrayParent0(RemoveBg value) - { - Value = value; - } - - public UnnamedSchemaWithArrayParent0(AutoTaggingExtension value) - { - Value = value; - } - - public UnnamedSchemaWithArrayParent0(AIAutoDescription value) - { - Value = value; - } - - UnnamedSchemaWithArrayParent0(UnknownVariant value) - { - Value = value; - } - - public static UnnamedSchemaWithArrayParent0 CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickRemoveBg([NotNullWhen(true)] out RemoveBg? value) - { - value = this.Value as RemoveBg; - return value != null; - } - - public bool TryPickAutoTaggingExtension([NotNullWhen(true)] out AutoTaggingExtension? value) - { - value = this.Value as AutoTaggingExtension; - return value != null; - } - - public bool TryPickAIAutoDescription([NotNullWhen(true)] out AIAutoDescription? value) - { - value = this.Value as AIAutoDescription; - return value != null; - } - - public void Switch( - Action removeBg, - Action autoTaggingExtension, - Action aiAutoDescription - ) - { - switch (this.Value) - { - case RemoveBg value: - removeBg(value); - break; - case AutoTaggingExtension value: - autoTaggingExtension(value); - break; - case AIAutoDescription value: - aiAutoDescription(value); - break; - default: - throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent0" - ); - } - } - - public T Match( - Func removeBg, - Func autoTaggingExtension, - Func aiAutoDescription - ) - { - return this.Value switch - { - RemoveBg value => removeBg(value), - AutoTaggingExtension value => autoTaggingExtension(value), - AIAutoDescription value => aiAutoDescription(value), - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent0" - ), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent0" - ); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class UnnamedSchemaWithArrayParent0Converter : JsonConverter -{ - public override UnnamedSchemaWithArrayParent0? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - var json = JsonSerializer.Deserialize(ref reader, options); - string? name; - try - { - name = json.GetProperty("name").GetString(); - } - catch - { - name = null; - } - - switch (name) - { - case "remove-bg": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - deserialized.Validate(); - return new UnnamedSchemaWithArrayParent0(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException( - "Data does not match union variant 'RemoveBg'", - e - ) - ); - } - - throw new AggregateException(exceptions); - } - case "ai-auto-description": - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(json, options); - if (deserialized != null) - { - deserialized.Validate(); - return new UnnamedSchemaWithArrayParent0(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException( - "Data does not match union variant 'AIAutoDescription'", - e - ) - ); - } - - throw new AggregateException(exceptions); - } - default: - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize( - json, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new UnnamedSchemaWithArrayParent0(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException( - "Data does not match union variant 'AutoTaggingExtension'", - e - ) - ); - } - - throw new AggregateException(exceptions); - } - } - } - - public override void Write( - Utf8JsonWriter writer, - UnnamedSchemaWithArrayParent0 value, - JsonSerializerOptions options - ) - { - object variant = value.Value; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/AIAutoDescription.cs b/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/AIAutoDescription.cs deleted file mode 100644 index e0c2f618..00000000 --- a/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/AIAutoDescription.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; - -namespace Imagekit.Models.UnnamedSchemaWithArrayParent0Properties; - -[JsonConverter(typeof(Converter))] -public class AIAutoDescription -{ - public JsonElement Json { get; private init; } - - public AIAutoDescription() - { - Json = JsonSerializer.Deserialize("{\"name\":\"ai-auto-description\"}"); - } - - AIAutoDescription(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new AIAutoDescription().Json)) - { - throw new ImageKitInvalidDataException( - "Invalid constant given for 'AIAutoDescription'" - ); - } - } - - class Converter : JsonConverter - { - public override AIAutoDescription? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write( - Utf8JsonWriter writer, - AIAutoDescription value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/AIAutoDescriptionProperties/Name.cs b/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/AIAutoDescriptionProperties/Name.cs deleted file mode 100644 index 69b32c50..00000000 --- a/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/AIAutoDescriptionProperties/Name.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; - -namespace Imagekit.Models.UnnamedSchemaWithArrayParent0Properties.AIAutoDescriptionProperties; - -/// -/// Specifies the auto description extension. -/// -[JsonConverter(typeof(Converter))] -public class Name -{ - public JsonElement Json { get; private init; } - - public Name() - { - Json = JsonSerializer.Deserialize("\"ai-auto-description\""); - } - - Name(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new Name().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'Name'"); - } - } - - class Converter : JsonConverter - { - public override Name? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write(Utf8JsonWriter writer, Name value, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/AutoTaggingExtension.cs b/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/AutoTaggingExtension.cs deleted file mode 100644 index 2ae3a728..00000000 --- a/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/AutoTaggingExtension.cs +++ /dev/null @@ -1,100 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Files.FileUploadParamsProperties.ExtensionProperties.AutoTaggingExtensionProperties; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.ExtensionProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class AutoTaggingExtension : ModelBase, IFromRaw -{ - /// - /// Maximum number of tags to attach to the asset. - /// - public required long MaxTags - { - get - { - if (!this.Properties.TryGetValue("maxTags", out JsonElement element)) - throw new ArgumentOutOfRangeException("maxTags", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["maxTags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Minimum confidence level for tags to be considered valid. - /// - public required long MinConfidence - { - get - { - if (!this.Properties.TryGetValue("minConfidence", out JsonElement element)) - throw new ArgumentOutOfRangeException("minConfidence", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["minConfidence"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies the auto-tagging extension used. - /// - public required ApiEnum Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - throw new ArgumentOutOfRangeException("name", "Missing required argument"); - - return JsonSerializer.Deserialize>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.MaxTags; - _ = this.MinConfidence; - this.Name.Validate(); - } - - public AutoTaggingExtension() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - AutoTaggingExtension(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static AutoTaggingExtension FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/AutoTaggingExtensionProperties/Name.cs b/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/AutoTaggingExtensionProperties/Name.cs deleted file mode 100644 index 55796f3b..00000000 --- a/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/AutoTaggingExtensionProperties/Name.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.ExtensionProperties.AutoTaggingExtensionProperties; - -/// -/// Specifies the auto-tagging extension used. -/// -[JsonConverter(typeof(NameConverter))] -public enum Name -{ - GoogleAutoTagging, - AwsAutoTagging, -} - -sealed class NameConverter : JsonConverter -{ - public override Name Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "google-auto-tagging" => Name.GoogleAutoTagging, - "aws-auto-tagging" => Name.AwsAutoTagging, - _ => (Name)(-1), - }; - } - - public override void Write(Utf8JsonWriter writer, Name value, JsonSerializerOptions options) - { - JsonSerializer.Serialize( - writer, - value switch - { - Name.GoogleAutoTagging => "google-auto-tagging", - Name.AwsAutoTagging => "aws-auto-tagging", - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/RemoveBg.cs b/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/RemoveBg.cs deleted file mode 100644 index 4adf376d..00000000 --- a/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/RemoveBg.cs +++ /dev/null @@ -1,79 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Files.FileUploadParamsProperties.ExtensionProperties.RemoveBgProperties; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.ExtensionProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class RemoveBg : ModelBase, IFromRaw -{ - /// - /// Specifies the background removal extension. - /// - public Name Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - throw new ArgumentOutOfRangeException("name", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'name' cannot be null", - new ArgumentNullException("name") - ); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public Options? Options - { - get - { - if (!this.Properties.TryGetValue("options", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["options"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Name.Validate(); - this.Options?.Validate(); - } - - public RemoveBg() - { - this.Name = new(); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - RemoveBg(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static RemoveBg FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/RemoveBgProperties/Name.cs b/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/RemoveBgProperties/Name.cs deleted file mode 100644 index 01447405..00000000 --- a/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/RemoveBgProperties/Name.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; - -namespace Imagekit.Models.UnnamedSchemaWithArrayParent0Properties.RemoveBgProperties; - -/// -/// Specifies the background removal extension. -/// -[JsonConverter(typeof(Converter))] -public class Name -{ - public JsonElement Json { get; private init; } - - public Name() - { - Json = JsonSerializer.Deserialize("\"remove-bg\""); - } - - Name(JsonElement json) - { - Json = json; - } - - public void Validate() - { - if (JsonElement.DeepEquals(this.Json, new Name().Json)) - { - throw new ImageKitInvalidDataException("Invalid constant given for 'Name'"); - } - } - - class Converter : JsonConverter - { - public override Name? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return new(JsonSerializer.Deserialize(ref reader, options)); - } - - public override void Write(Utf8JsonWriter writer, Name value, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, value.Json, options); - } - } -} diff --git a/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/RemoveBgProperties/Options.cs b/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/RemoveBgProperties/Options.cs deleted file mode 100644 index 7f5799e6..00000000 --- a/src/Imagekit/Models/UnnamedSchemaWithArrayParent0Properties/RemoveBgProperties/Options.cs +++ /dev/null @@ -1,122 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Files.FileUploadParamsProperties.ExtensionProperties.RemoveBgProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Options : ModelBase, IFromRaw -{ - /// - /// Whether to add an artificial shadow to the result. Default is false. Note: - /// Adding shadows is currently only supported for car photos. - /// - public bool? AddShadow - { - get - { - if (!this.Properties.TryGetValue("add_shadow", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["add_shadow"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies a solid color background using hex code (e.g., "81d4fa", "fff") - /// or color name (e.g., "green"). If this parameter is set, `bg_image_url` must - /// be empty. - /// - public string? BgColor - { - get - { - if (!this.Properties.TryGetValue("bg_color", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["bg_color"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Sets a background image from a URL. If this parameter is set, `bg_color` - /// must be empty. - /// - public string? BgImageURL - { - get - { - if (!this.Properties.TryGetValue("bg_image_url", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["bg_image_url"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Allows semi-transparent regions in the result. Default is true. Note: Semitransparency - /// is currently only supported for car windows. - /// - public bool? Semitransparency - { - get - { - if (!this.Properties.TryGetValue("semitransparency", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["semitransparency"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.AddShadow; - _ = this.BgColor; - _ = this.BgImageURL; - _ = this.Semitransparency; - } - - public Options() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Options(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Options FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/VideoOverlay.cs b/src/Imagekit/Models/VideoOverlay.cs deleted file mode 100644 index ce00be2c..00000000 --- a/src/Imagekit/Models/VideoOverlay.cs +++ /dev/null @@ -1,184 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.VideoOverlayProperties.IntersectionMember1Properties; - -namespace Imagekit.Models; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class VideoOverlay : ModelBase, IFromRaw -{ - public OverlayPosition? Position - { - get - { - if (!this.Properties.TryGetValue("position", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["position"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public OverlayTiming? Timing - { - get - { - if (!this.Properties.TryGetValue("timing", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["timing"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies the relative path to the video used as an overlay. - /// - public required string Input - { - get - { - if (!this.Properties.TryGetValue("input", out JsonElement element)) - throw new ArgumentOutOfRangeException("input", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("input"); - } - set - { - this.Properties["input"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The input path can be included in the layer as either `i-{input}` or `ie-{base64_encoded_input}`. - /// By default, the SDK determines the appropriate format automatically. To - /// always use base64 encoding (`ie-{base64}`), set this parameter to `base64`. - /// To always use plain text (`i-{input}`), set it to `plain`. - /// - public ApiEnum? Encoding - { - get - { - if (!this.Properties.TryGetValue("encoding", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["encoding"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Array of transformation to be applied to the overlay video. Except `streamingResolutions`, - /// all other video transformations are supported. See [Video transformations](https://imagekit.io/docs/video-transformation). - /// - public List? Transformation - { - get - { - if (!this.Properties.TryGetValue("transformation", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["transformation"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public static implicit operator BaseOverlay(VideoOverlay videoOverlay) => - new() { Position = videoOverlay.Position, Timing = videoOverlay.Timing }; - - public override void Validate() - { - this.Position?.Validate(); - this.Timing?.Validate(); - _ = this.Input; - _ = this.Type; - this.Encoding?.Validate(); - foreach (var item in this.Transformation ?? []) - { - item.Validate(); - } - } - - public VideoOverlay() - { - this.Type = JsonSerializer.Deserialize("\"video\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - VideoOverlay(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static VideoOverlay FromRawUnchecked(Dictionary properties) - { - return new(properties); - } - - [SetsRequiredMembers] - public VideoOverlay(string input) - : this() - { - this.Input = input; - } -} diff --git a/src/Imagekit/Models/VideoOverlayProperties/IntersectionMember1.cs b/src/Imagekit/Models/VideoOverlayProperties/IntersectionMember1.cs deleted file mode 100644 index 65e26bf9..00000000 --- a/src/Imagekit/Models/VideoOverlayProperties/IntersectionMember1.cs +++ /dev/null @@ -1,140 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.VideoOverlayProperties.IntersectionMember1Properties; - -namespace Imagekit.Models.VideoOverlayProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class IntersectionMember1 : ModelBase, IFromRaw -{ - /// - /// Specifies the relative path to the video used as an overlay. - /// - public required string Input - { - get - { - if (!this.Properties.TryGetValue("input", out JsonElement element)) - throw new ArgumentOutOfRangeException("input", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("input"); - } - set - { - this.Properties["input"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The input path can be included in the layer as either `i-{input}` or `ie-{base64_encoded_input}`. - /// By default, the SDK determines the appropriate format automatically. To - /// always use base64 encoding (`ie-{base64}`), set this parameter to `base64`. - /// To always use plain text (`i-{input}`), set it to `plain`. - /// - public ApiEnum? Encoding - { - get - { - if (!this.Properties.TryGetValue("encoding", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["encoding"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Array of transformation to be applied to the overlay video. Except `streamingResolutions`, - /// all other video transformations are supported. See [Video transformations](https://imagekit.io/docs/video-transformation). - /// - public List? Transformation - { - get - { - if (!this.Properties.TryGetValue("transformation", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["transformation"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.Input; - _ = this.Type; - this.Encoding?.Validate(); - foreach (var item in this.Transformation ?? []) - { - item.Validate(); - } - } - - public IntersectionMember1() - { - this.Type = JsonSerializer.Deserialize("\"video\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - IntersectionMember1(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static IntersectionMember1 FromRawUnchecked(Dictionary properties) - { - return new(properties); - } - - [SetsRequiredMembers] - public IntersectionMember1(string input) - : this() - { - this.Input = input; - } -} diff --git a/src/Imagekit/Models/VideoOverlayProperties/IntersectionMember1Properties/Encoding.cs b/src/Imagekit/Models/VideoOverlayProperties/IntersectionMember1Properties/Encoding.cs deleted file mode 100644 index 8252c649..00000000 --- a/src/Imagekit/Models/VideoOverlayProperties/IntersectionMember1Properties/Encoding.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.VideoOverlayProperties.IntersectionMember1Properties; - -/// -/// The input path can be included in the layer as either `i-{input}` or `ie-{base64_encoded_input}`. -/// By default, the SDK determines the appropriate format automatically. To always -/// use base64 encoding (`ie-{base64}`), set this parameter to `base64`. To always -/// use plain text (`i-{input}`), set it to `plain`. -/// -[JsonConverter(typeof(EncodingConverter))] -public enum Encoding -{ - Auto, - Plain, - Base64, -} - -sealed class EncodingConverter : JsonConverter -{ - public override Encoding Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "auto" => Encoding.Auto, - "plain" => Encoding.Plain, - "base64" => Encoding.Base64, - _ => (Encoding)(-1), - }; - } - - public override void Write(Utf8JsonWriter writer, Encoding value, JsonSerializerOptions options) - { - JsonSerializer.Serialize( - writer, - value switch - { - Encoding.Auto => "auto", - Encoding.Plain => "plain", - Encoding.Base64 => "base64", - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Webhooks/BaseWebhookEvent.cs b/src/Imagekit/Models/Webhooks/BaseWebhookEvent.cs deleted file mode 100644 index f7d1f37d..00000000 --- a/src/Imagekit/Models/Webhooks/BaseWebhookEvent.cs +++ /dev/null @@ -1,90 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Core; -using Imagekit.Exceptions; - -namespace Imagekit.Models.Webhooks; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class BaseWebhookEvent : ModelBase, IFromRaw -{ - /// - /// Unique identifier for the event. - /// - public required string ID - { - get - { - if (!this.Properties.TryGetValue("id", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'id' cannot be null", - new ArgumentOutOfRangeException("id", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'id' cannot be null", - new ArgumentNullException("id") - ); - } - set - { - this.Properties["id"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The type of webhook event. - /// - public required string Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentOutOfRangeException("type", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentNullException("type") - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.ID; - _ = this.Type; - } - - public BaseWebhookEvent() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - BaseWebhookEvent(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static BaseWebhookEvent FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs b/src/Imagekit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs deleted file mode 100644 index 6482ffd2..00000000 --- a/src/Imagekit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs +++ /dev/null @@ -1,423 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; - -namespace Imagekit.Models.Webhooks; - -/// -/// Triggered when a new video transformation request is accepted for processing. -/// This event confirms that ImageKit has received and queued your transformation -/// request. Use this for debugging and tracking transformation lifecycle. -/// -[JsonConverter(typeof(UnsafeUnwrapWebhookEventConverter))] -public record class UnsafeUnwrapWebhookEvent -{ - public object Value { get; private init; } - - public string ID - { - get - { - return Match( - videoTransformationAccepted: (x) => x.ID, - videoTransformationReady: (x) => x.ID, - videoTransformationError: (x) => x.ID, - uploadPreTransformSuccess: (x) => x.ID, - uploadPreTransformError: (x) => x.ID, - uploadPostTransformSuccess: (x) => x.ID, - uploadPostTransformError: (x) => x.ID - ); - } - } - - public string Type - { - get - { - return Match( - videoTransformationAccepted: (x) => x.Type, - videoTransformationReady: (x) => x.Type, - videoTransformationError: (x) => x.Type, - uploadPreTransformSuccess: (x) => x.Type, - uploadPreTransformError: (x) => x.Type, - uploadPostTransformSuccess: (x) => x.Type, - uploadPostTransformError: (x) => x.Type - ); - } - } - - public DateTime CreatedAt - { - get - { - return Match( - videoTransformationAccepted: (x) => x.CreatedAt, - videoTransformationReady: (x) => x.CreatedAt, - videoTransformationError: (x) => x.CreatedAt, - uploadPreTransformSuccess: (x) => x.CreatedAt, - uploadPreTransformError: (x) => x.CreatedAt, - uploadPostTransformSuccess: (x) => x.CreatedAt, - uploadPostTransformError: (x) => x.CreatedAt - ); - } - } - - public UnsafeUnwrapWebhookEvent(VideoTransformationAcceptedEvent value) - { - Value = value; - } - - public UnsafeUnwrapWebhookEvent(VideoTransformationReadyEvent value) - { - Value = value; - } - - public UnsafeUnwrapWebhookEvent(VideoTransformationErrorEvent value) - { - Value = value; - } - - public UnsafeUnwrapWebhookEvent(UploadPreTransformSuccessEvent value) - { - Value = value; - } - - public UnsafeUnwrapWebhookEvent(UploadPreTransformErrorEvent value) - { - Value = value; - } - - public UnsafeUnwrapWebhookEvent(UploadPostTransformSuccessEvent value) - { - Value = value; - } - - public UnsafeUnwrapWebhookEvent(UploadPostTransformErrorEvent value) - { - Value = value; - } - - UnsafeUnwrapWebhookEvent(UnknownVariant value) - { - Value = value; - } - - public static UnsafeUnwrapWebhookEvent CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickVideoTransformationAccepted( - [NotNullWhen(true)] out VideoTransformationAcceptedEvent? value - ) - { - value = this.Value as VideoTransformationAcceptedEvent; - return value != null; - } - - public bool TryPickVideoTransformationReady( - [NotNullWhen(true)] out VideoTransformationReadyEvent? value - ) - { - value = this.Value as VideoTransformationReadyEvent; - return value != null; - } - - public bool TryPickVideoTransformationError( - [NotNullWhen(true)] out VideoTransformationErrorEvent? value - ) - { - value = this.Value as VideoTransformationErrorEvent; - return value != null; - } - - public bool TryPickUploadPreTransformSuccess( - [NotNullWhen(true)] out UploadPreTransformSuccessEvent? value - ) - { - value = this.Value as UploadPreTransformSuccessEvent; - return value != null; - } - - public bool TryPickUploadPreTransformError( - [NotNullWhen(true)] out UploadPreTransformErrorEvent? value - ) - { - value = this.Value as UploadPreTransformErrorEvent; - return value != null; - } - - public bool TryPickUploadPostTransformSuccess( - [NotNullWhen(true)] out UploadPostTransformSuccessEvent? value - ) - { - value = this.Value as UploadPostTransformSuccessEvent; - return value != null; - } - - public bool TryPickUploadPostTransformError( - [NotNullWhen(true)] out UploadPostTransformErrorEvent? value - ) - { - value = this.Value as UploadPostTransformErrorEvent; - return value != null; - } - - public void Switch( - Action videoTransformationAccepted, - Action videoTransformationReady, - Action videoTransformationError, - Action uploadPreTransformSuccess, - Action uploadPreTransformError, - Action uploadPostTransformSuccess, - Action uploadPostTransformError - ) - { - switch (this.Value) - { - case VideoTransformationAcceptedEvent value: - videoTransformationAccepted(value); - break; - case VideoTransformationReadyEvent value: - videoTransformationReady(value); - break; - case VideoTransformationErrorEvent value: - videoTransformationError(value); - break; - case UploadPreTransformSuccessEvent value: - uploadPreTransformSuccess(value); - break; - case UploadPreTransformErrorEvent value: - uploadPreTransformError(value); - break; - case UploadPostTransformSuccessEvent value: - uploadPostTransformSuccess(value); - break; - case UploadPostTransformErrorEvent value: - uploadPostTransformError(value); - break; - default: - throw new ImageKitInvalidDataException( - "Data did not match any variant of UnsafeUnwrapWebhookEvent" - ); - } - } - - public T Match( - Func videoTransformationAccepted, - Func videoTransformationReady, - Func videoTransformationError, - Func uploadPreTransformSuccess, - Func uploadPreTransformError, - Func uploadPostTransformSuccess, - Func uploadPostTransformError - ) - { - return this.Value switch - { - VideoTransformationAcceptedEvent value => videoTransformationAccepted(value), - VideoTransformationReadyEvent value => videoTransformationReady(value), - VideoTransformationErrorEvent value => videoTransformationError(value), - UploadPreTransformSuccessEvent value => uploadPreTransformSuccess(value), - UploadPreTransformErrorEvent value => uploadPreTransformError(value), - UploadPostTransformSuccessEvent value => uploadPostTransformSuccess(value), - UploadPostTransformErrorEvent value => uploadPostTransformError(value), - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of UnsafeUnwrapWebhookEvent" - ), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException( - "Data did not match any variant of UnsafeUnwrapWebhookEvent" - ); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class UnsafeUnwrapWebhookEventConverter : JsonConverter -{ - public override UnsafeUnwrapWebhookEvent? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize( - ref reader, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new UnsafeUnwrapWebhookEvent(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException( - "Data does not match union variant 'VideoTransformationAcceptedEvent'", - e - ) - ); - } - - try - { - var deserialized = JsonSerializer.Deserialize( - ref reader, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new UnsafeUnwrapWebhookEvent(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException( - "Data does not match union variant 'VideoTransformationReadyEvent'", - e - ) - ); - } - - try - { - var deserialized = JsonSerializer.Deserialize( - ref reader, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new UnsafeUnwrapWebhookEvent(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException( - "Data does not match union variant 'VideoTransformationErrorEvent'", - e - ) - ); - } - - try - { - var deserialized = JsonSerializer.Deserialize( - ref reader, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new UnsafeUnwrapWebhookEvent(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException( - "Data does not match union variant 'UploadPreTransformSuccessEvent'", - e - ) - ); - } - - try - { - var deserialized = JsonSerializer.Deserialize( - ref reader, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new UnsafeUnwrapWebhookEvent(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException( - "Data does not match union variant 'UploadPreTransformErrorEvent'", - e - ) - ); - } - - try - { - var deserialized = JsonSerializer.Deserialize( - ref reader, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new UnsafeUnwrapWebhookEvent(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException( - "Data does not match union variant 'UploadPostTransformSuccessEvent'", - e - ) - ); - } - - try - { - var deserialized = JsonSerializer.Deserialize( - ref reader, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new UnsafeUnwrapWebhookEvent(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException( - "Data does not match union variant 'UploadPostTransformErrorEvent'", - e - ) - ); - } - - throw new AggregateException(exceptions); - } - - public override void Write( - Utf8JsonWriter writer, - UnsafeUnwrapWebhookEvent value, - JsonSerializerOptions options - ) - { - object variant = value.Value; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/Webhooks/UnwrapWebhookEvent.cs b/src/Imagekit/Models/Webhooks/UnwrapWebhookEvent.cs deleted file mode 100644 index 1614a815..00000000 --- a/src/Imagekit/Models/Webhooks/UnwrapWebhookEvent.cs +++ /dev/null @@ -1,423 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; - -namespace Imagekit.Models.Webhooks; - -/// -/// Triggered when a new video transformation request is accepted for processing. -/// This event confirms that ImageKit has received and queued your transformation -/// request. Use this for debugging and tracking transformation lifecycle. -/// -[JsonConverter(typeof(UnwrapWebhookEventConverter))] -public record class UnwrapWebhookEvent -{ - public object Value { get; private init; } - - public string ID - { - get - { - return Match( - videoTransformationAccepted: (x) => x.ID, - videoTransformationReady: (x) => x.ID, - videoTransformationError: (x) => x.ID, - uploadPreTransformSuccess: (x) => x.ID, - uploadPreTransformError: (x) => x.ID, - uploadPostTransformSuccess: (x) => x.ID, - uploadPostTransformError: (x) => x.ID - ); - } - } - - public string Type - { - get - { - return Match( - videoTransformationAccepted: (x) => x.Type, - videoTransformationReady: (x) => x.Type, - videoTransformationError: (x) => x.Type, - uploadPreTransformSuccess: (x) => x.Type, - uploadPreTransformError: (x) => x.Type, - uploadPostTransformSuccess: (x) => x.Type, - uploadPostTransformError: (x) => x.Type - ); - } - } - - public DateTime CreatedAt - { - get - { - return Match( - videoTransformationAccepted: (x) => x.CreatedAt, - videoTransformationReady: (x) => x.CreatedAt, - videoTransformationError: (x) => x.CreatedAt, - uploadPreTransformSuccess: (x) => x.CreatedAt, - uploadPreTransformError: (x) => x.CreatedAt, - uploadPostTransformSuccess: (x) => x.CreatedAt, - uploadPostTransformError: (x) => x.CreatedAt - ); - } - } - - public UnwrapWebhookEvent(VideoTransformationAcceptedEvent value) - { - Value = value; - } - - public UnwrapWebhookEvent(VideoTransformationReadyEvent value) - { - Value = value; - } - - public UnwrapWebhookEvent(VideoTransformationErrorEvent value) - { - Value = value; - } - - public UnwrapWebhookEvent(UploadPreTransformSuccessEvent value) - { - Value = value; - } - - public UnwrapWebhookEvent(UploadPreTransformErrorEvent value) - { - Value = value; - } - - public UnwrapWebhookEvent(UploadPostTransformSuccessEvent value) - { - Value = value; - } - - public UnwrapWebhookEvent(UploadPostTransformErrorEvent value) - { - Value = value; - } - - UnwrapWebhookEvent(UnknownVariant value) - { - Value = value; - } - - public static UnwrapWebhookEvent CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickVideoTransformationAccepted( - [NotNullWhen(true)] out VideoTransformationAcceptedEvent? value - ) - { - value = this.Value as VideoTransformationAcceptedEvent; - return value != null; - } - - public bool TryPickVideoTransformationReady( - [NotNullWhen(true)] out VideoTransformationReadyEvent? value - ) - { - value = this.Value as VideoTransformationReadyEvent; - return value != null; - } - - public bool TryPickVideoTransformationError( - [NotNullWhen(true)] out VideoTransformationErrorEvent? value - ) - { - value = this.Value as VideoTransformationErrorEvent; - return value != null; - } - - public bool TryPickUploadPreTransformSuccess( - [NotNullWhen(true)] out UploadPreTransformSuccessEvent? value - ) - { - value = this.Value as UploadPreTransformSuccessEvent; - return value != null; - } - - public bool TryPickUploadPreTransformError( - [NotNullWhen(true)] out UploadPreTransformErrorEvent? value - ) - { - value = this.Value as UploadPreTransformErrorEvent; - return value != null; - } - - public bool TryPickUploadPostTransformSuccess( - [NotNullWhen(true)] out UploadPostTransformSuccessEvent? value - ) - { - value = this.Value as UploadPostTransformSuccessEvent; - return value != null; - } - - public bool TryPickUploadPostTransformError( - [NotNullWhen(true)] out UploadPostTransformErrorEvent? value - ) - { - value = this.Value as UploadPostTransformErrorEvent; - return value != null; - } - - public void Switch( - Action videoTransformationAccepted, - Action videoTransformationReady, - Action videoTransformationError, - Action uploadPreTransformSuccess, - Action uploadPreTransformError, - Action uploadPostTransformSuccess, - Action uploadPostTransformError - ) - { - switch (this.Value) - { - case VideoTransformationAcceptedEvent value: - videoTransformationAccepted(value); - break; - case VideoTransformationReadyEvent value: - videoTransformationReady(value); - break; - case VideoTransformationErrorEvent value: - videoTransformationError(value); - break; - case UploadPreTransformSuccessEvent value: - uploadPreTransformSuccess(value); - break; - case UploadPreTransformErrorEvent value: - uploadPreTransformError(value); - break; - case UploadPostTransformSuccessEvent value: - uploadPostTransformSuccess(value); - break; - case UploadPostTransformErrorEvent value: - uploadPostTransformError(value); - break; - default: - throw new ImageKitInvalidDataException( - "Data did not match any variant of UnwrapWebhookEvent" - ); - } - } - - public T Match( - Func videoTransformationAccepted, - Func videoTransformationReady, - Func videoTransformationError, - Func uploadPreTransformSuccess, - Func uploadPreTransformError, - Func uploadPostTransformSuccess, - Func uploadPostTransformError - ) - { - return this.Value switch - { - VideoTransformationAcceptedEvent value => videoTransformationAccepted(value), - VideoTransformationReadyEvent value => videoTransformationReady(value), - VideoTransformationErrorEvent value => videoTransformationError(value), - UploadPreTransformSuccessEvent value => uploadPreTransformSuccess(value), - UploadPreTransformErrorEvent value => uploadPreTransformError(value), - UploadPostTransformSuccessEvent value => uploadPostTransformSuccess(value), - UploadPostTransformErrorEvent value => uploadPostTransformError(value), - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of UnwrapWebhookEvent" - ), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException( - "Data did not match any variant of UnwrapWebhookEvent" - ); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class UnwrapWebhookEventConverter : JsonConverter -{ - public override UnwrapWebhookEvent? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize( - ref reader, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new UnwrapWebhookEvent(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException( - "Data does not match union variant 'VideoTransformationAcceptedEvent'", - e - ) - ); - } - - try - { - var deserialized = JsonSerializer.Deserialize( - ref reader, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new UnwrapWebhookEvent(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException( - "Data does not match union variant 'VideoTransformationReadyEvent'", - e - ) - ); - } - - try - { - var deserialized = JsonSerializer.Deserialize( - ref reader, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new UnwrapWebhookEvent(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException( - "Data does not match union variant 'VideoTransformationErrorEvent'", - e - ) - ); - } - - try - { - var deserialized = JsonSerializer.Deserialize( - ref reader, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new UnwrapWebhookEvent(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException( - "Data does not match union variant 'UploadPreTransformSuccessEvent'", - e - ) - ); - } - - try - { - var deserialized = JsonSerializer.Deserialize( - ref reader, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new UnwrapWebhookEvent(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException( - "Data does not match union variant 'UploadPreTransformErrorEvent'", - e - ) - ); - } - - try - { - var deserialized = JsonSerializer.Deserialize( - ref reader, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new UnwrapWebhookEvent(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException( - "Data does not match union variant 'UploadPostTransformSuccessEvent'", - e - ) - ); - } - - try - { - var deserialized = JsonSerializer.Deserialize( - ref reader, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new UnwrapWebhookEvent(deserialized); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException( - "Data does not match union variant 'UploadPostTransformErrorEvent'", - e - ) - ); - } - - throw new AggregateException(exceptions); - } - - public override void Write( - Utf8JsonWriter writer, - UnwrapWebhookEvent value, - JsonSerializerOptions options - ) - { - object variant = value.Value; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEvent.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEvent.cs deleted file mode 100644 index 8c1906d2..00000000 --- a/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEvent.cs +++ /dev/null @@ -1,180 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Core; -using Imagekit.Exceptions; -using Imagekit.Models.Webhooks.UploadPostTransformErrorEventProperties.IntersectionMember1Properties; - -namespace Imagekit.Models.Webhooks; - -/// -/// Triggered when a post-transformation fails. The original file remains available, -/// but the requested transformation could not be generated. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class UploadPostTransformErrorEvent - : ModelBase, - IFromRaw -{ - /// - /// Unique identifier for the event. - /// - public required string ID - { - get - { - if (!this.Properties.TryGetValue("id", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'id' cannot be null", - new ArgumentOutOfRangeException("id", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'id' cannot be null", - new ArgumentNullException("id") - ); - } - set - { - this.Properties["id"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The type of webhook event. - /// - public required string Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentOutOfRangeException("type", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentNullException("type") - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Timestamp of when the event occurred in ISO8601 format. - /// - public required DateTime CreatedAt - { - get - { - if (!this.Properties.TryGetValue("created_at", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'created_at' cannot be null", - new ArgumentOutOfRangeException("created_at", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["created_at"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required Data Data - { - get - { - if (!this.Properties.TryGetValue("data", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'data' cannot be null", - new ArgumentOutOfRangeException("data", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'data' cannot be null", - new ArgumentNullException("data") - ); - } - set - { - this.Properties["data"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required Request Request - { - get - { - if (!this.Properties.TryGetValue("request", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'request' cannot be null", - new ArgumentOutOfRangeException("request", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'request' cannot be null", - new ArgumentNullException("request") - ); - } - set - { - this.Properties["request"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public static implicit operator BaseWebhookEvent( - UploadPostTransformErrorEvent uploadPostTransformErrorEvent - ) => new() { ID = uploadPostTransformErrorEvent.ID, Type = uploadPostTransformErrorEvent.Type }; - - public override void Validate() - { - _ = this.ID; - _ = this.Type; - _ = this.CreatedAt; - this.Data.Validate(); - this.Request.Validate(); - } - - public UploadPostTransformErrorEvent() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - UploadPostTransformErrorEvent(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static UploadPostTransformErrorEvent FromRawUnchecked( - Dictionary properties - ) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1.cs deleted file mode 100644 index 6670a2a3..00000000 --- a/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1.cs +++ /dev/null @@ -1,139 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Core; -using Imagekit.Exceptions; -using Imagekit.Models.Webhooks.UploadPostTransformErrorEventProperties.IntersectionMember1Properties; - -namespace Imagekit.Models.Webhooks.UploadPostTransformErrorEventProperties; - -/// -/// Triggered when a post-transformation fails. The original file remains available, -/// but the requested transformation could not be generated. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class IntersectionMember1 : ModelBase, IFromRaw -{ - /// - /// Timestamp of when the event occurred in ISO8601 format. - /// - public required DateTime CreatedAt - { - get - { - if (!this.Properties.TryGetValue("created_at", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'created_at' cannot be null", - new ArgumentOutOfRangeException("created_at", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["created_at"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required Data Data - { - get - { - if (!this.Properties.TryGetValue("data", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'data' cannot be null", - new ArgumentOutOfRangeException("data", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'data' cannot be null", - new ArgumentNullException("data") - ); - } - set - { - this.Properties["data"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required Request Request - { - get - { - if (!this.Properties.TryGetValue("request", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'request' cannot be null", - new ArgumentOutOfRangeException("request", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'request' cannot be null", - new ArgumentNullException("request") - ); - } - set - { - this.Properties["request"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentOutOfRangeException("type", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.CreatedAt; - this.Data.Validate(); - this.Request.Validate(); - _ = this.Type; - } - - public IntersectionMember1() - { - this.Type = JsonSerializer.Deserialize("\"upload.post-transform.error\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - IntersectionMember1(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static IntersectionMember1 FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1Properties/Data.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1Properties/Data.cs deleted file mode 100644 index ca0598e6..00000000 --- a/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1Properties/Data.cs +++ /dev/null @@ -1,148 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using DataProperties = Imagekit.Models.Webhooks.UploadPostTransformErrorEventProperties.DataProperties; - -namespace Imagekit.Models.Webhooks.UploadPostTransformErrorEventProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Data : ModelBase, IFromRaw -{ - /// - /// Unique identifier of the originally uploaded file. - /// - public required string FileID - { - get - { - if (!this.Properties.TryGetValue("fileId", out JsonElement element)) - throw new ArgumentOutOfRangeException("fileId", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("fileId"); - } - set - { - this.Properties["fileId"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Name of the file. - /// - public required string Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - throw new ArgumentOutOfRangeException("name", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("name"); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Path of the file. - /// - public required string Path - { - get - { - if (!this.Properties.TryGetValue("path", out JsonElement element)) - throw new ArgumentOutOfRangeException("path", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("path"); - } - set - { - this.Properties["path"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required DataProperties::Transformation Transformation - { - get - { - if (!this.Properties.TryGetValue("transformation", out JsonElement element)) - throw new ArgumentOutOfRangeException( - "transformation", - "Missing required argument" - ); - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ) ?? throw new ArgumentNullException("transformation"); - } - set - { - this.Properties["transformation"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// URL of the attempted post-transformation. - /// - public required string URL - { - get - { - if (!this.Properties.TryGetValue("url", out JsonElement element)) - throw new ArgumentOutOfRangeException("url", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("url"); - } - set - { - this.Properties["url"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.FileID; - _ = this.Name; - _ = this.Path; - this.Transformation.Validate(); - _ = this.URL; - } - - public Data() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Data(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Data FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs deleted file mode 100644 index 448d585d..00000000 --- a/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Webhooks.UploadPostTransformErrorEventProperties.DataProperties.TransformationProperties; - -namespace Imagekit.Models.Webhooks.UploadPostTransformErrorEventProperties.DataProperties; - -[JsonConverter( - typeof(ModelConverter) -)] -public sealed record class Transformation - : ModelBase, - IFromRaw -{ - public required Error Error - { - get - { - if (!this.Properties.TryGetValue("error", out JsonElement element)) - throw new ArgumentOutOfRangeException("error", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("error"); - } - set - { - this.Properties["error"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Error.Validate(); - } - - public Transformation() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Transformation(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static global::Imagekit.Models.Webhooks.UploadPostTransformErrorEventProperties.IntersectionMember1Properties.DataProperties.Transformation FromRawUnchecked( - Dictionary properties - ) - { - return new(properties); - } - - [SetsRequiredMembers] - public Transformation(Error error) - : this() - { - this.Error = error; - } -} diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Error.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Error.cs deleted file mode 100644 index b9a25305..00000000 --- a/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Error.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Webhooks.UploadPostTransformErrorEventProperties.DataProperties.TransformationProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Error : ModelBase, IFromRaw -{ - /// - /// Reason for the post-transformation failure. - /// - public required string Reason - { - get - { - if (!this.Properties.TryGetValue("reason", out JsonElement element)) - throw new ArgumentOutOfRangeException("reason", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("reason"); - } - set - { - this.Properties["reason"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.Reason; - } - - public Error() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Error(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Error FromRawUnchecked(Dictionary properties) - { - return new(properties); - } - - [SetsRequiredMembers] - public Error(string reason) - : this() - { - this.Reason = reason; - } -} diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1Properties/Request.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1Properties/Request.cs deleted file mode 100644 index 5f287132..00000000 --- a/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1Properties/Request.cs +++ /dev/null @@ -1,79 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using RequestProperties = Imagekit.Models.Webhooks.UploadPostTransformErrorEventProperties.RequestProperties; - -namespace Imagekit.Models.Webhooks.UploadPostTransformErrorEventProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Request : ModelBase, IFromRaw -{ - public required RequestProperties::Transformation Transformation - { - get - { - if (!this.Properties.TryGetValue("transformation", out JsonElement element)) - throw new ArgumentOutOfRangeException( - "transformation", - "Missing required argument" - ); - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ) ?? throw new ArgumentNullException("transformation"); - } - set - { - this.Properties["transformation"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Unique identifier for the originating request. - /// - public required string XRequestID - { - get - { - if (!this.Properties.TryGetValue("x_request_id", out JsonElement element)) - throw new ArgumentOutOfRangeException("x_request_id", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("x_request_id"); - } - set - { - this.Properties["x_request_id"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Transformation.Validate(); - _ = this.XRequestID; - } - - public Request() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Request(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Request FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1Properties/RequestProperties/Transformation.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1Properties/RequestProperties/Transformation.cs deleted file mode 100644 index 4ebc989b..00000000 --- a/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1Properties/RequestProperties/Transformation.cs +++ /dev/null @@ -1,116 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using TransformationProperties = Imagekit.Models.Webhooks.UploadPostTransformErrorEventProperties.RequestProperties.TransformationProperties; - -namespace Imagekit.Models.Webhooks.UploadPostTransformErrorEventProperties.RequestProperties; - -[JsonConverter( - typeof(ModelConverter) -)] -public sealed record class Transformation - : ModelBase, - IFromRaw -{ - /// - /// Type of the requested post-transformation. - /// - public required ApiEnum Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Only applicable if transformation type is 'abs'. Streaming protocol used. - /// - public ApiEnum? Protocol - { - get - { - if (!this.Properties.TryGetValue("protocol", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["protocol"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Value for the requested transformation type. - /// - public string? Value - { - get - { - if (!this.Properties.TryGetValue("value", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["value"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Type.Validate(); - this.Protocol?.Validate(); - _ = this.Value; - } - - public Transformation() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Transformation(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static global::Imagekit.Models.Webhooks.UploadPostTransformErrorEventProperties.IntersectionMember1Properties.RequestProperties.Transformation FromRawUnchecked( - Dictionary properties - ) - { - return new(properties); - } - - [SetsRequiredMembers] - public Transformation(ApiEnum type) - : this() - { - this.Type = type; - } -} diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1Properties/RequestProperties/TransformationProperties/Protocol.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1Properties/RequestProperties/TransformationProperties/Protocol.cs deleted file mode 100644 index 734a713f..00000000 --- a/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1Properties/RequestProperties/TransformationProperties/Protocol.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using System = System; - -namespace Imagekit.Models.Webhooks.UploadPostTransformErrorEventProperties.RequestProperties.TransformationProperties; - -/// -/// Only applicable if transformation type is 'abs'. Streaming protocol used. -/// -[JsonConverter(typeof(ProtocolConverter))] -public enum Protocol -{ - Hls, - Dash, -} - -sealed class ProtocolConverter : JsonConverter -{ - public override Protocol Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "hls" => Protocol.Hls, - "dash" => Protocol.Dash, - _ => (Protocol)(-1), - }; - } - - public override void Write(Utf8JsonWriter writer, Protocol value, JsonSerializerOptions options) - { - JsonSerializer.Serialize( - writer, - value switch - { - Protocol.Hls => "hls", - Protocol.Dash => "dash", - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1Properties/RequestProperties/TransformationProperties/Type.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1Properties/RequestProperties/TransformationProperties/Type.cs deleted file mode 100644 index aa052bf9..00000000 --- a/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEventProperties/IntersectionMember1Properties/RequestProperties/TransformationProperties/Type.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using System = System; - -namespace Imagekit.Models.Webhooks.UploadPostTransformErrorEventProperties.RequestProperties.TransformationProperties; - -/// -/// Type of the requested post-transformation. -/// -[JsonConverter(typeof(TypeConverter))] -public enum Type -{ - Transformation, - Abs, - GifToVideo, - Thumbnail, -} - -sealed class TypeConverter : JsonConverter -{ - public override Type Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "transformation" => TransformationProperties.Type.Transformation, - "abs" => TransformationProperties.Type.Abs, - "gif-to-video" => TransformationProperties.Type.GifToVideo, - "thumbnail" => TransformationProperties.Type.Thumbnail, - _ => (Type)(-1), - }; - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonSerializer.Serialize( - writer, - value switch - { - TransformationProperties.Type.Transformation => "transformation", - TransformationProperties.Type.Abs => "abs", - TransformationProperties.Type.GifToVideo => "gif-to-video", - TransformationProperties.Type.Thumbnail => "thumbnail", - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEvent.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEvent.cs deleted file mode 100644 index 31ccd28c..00000000 --- a/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEvent.cs +++ /dev/null @@ -1,186 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Core; -using Imagekit.Exceptions; -using Imagekit.Models.Webhooks.UploadPostTransformSuccessEventProperties.IntersectionMember1Properties; - -namespace Imagekit.Models.Webhooks; - -/// -/// Triggered when a post-transformation completes successfully. The transformed version -/// of the file is now ready and can be accessed via the provided URL. Note that -/// each post-transformation generates a separate webhook event. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class UploadPostTransformSuccessEvent - : ModelBase, - IFromRaw -{ - /// - /// Unique identifier for the event. - /// - public required string ID - { - get - { - if (!this.Properties.TryGetValue("id", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'id' cannot be null", - new ArgumentOutOfRangeException("id", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'id' cannot be null", - new ArgumentNullException("id") - ); - } - set - { - this.Properties["id"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The type of webhook event. - /// - public required string Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentOutOfRangeException("type", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentNullException("type") - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Timestamp of when the event occurred in ISO8601 format. - /// - public required DateTime CreatedAt - { - get - { - if (!this.Properties.TryGetValue("created_at", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'created_at' cannot be null", - new ArgumentOutOfRangeException("created_at", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["created_at"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required Data Data - { - get - { - if (!this.Properties.TryGetValue("data", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'data' cannot be null", - new ArgumentOutOfRangeException("data", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'data' cannot be null", - new ArgumentNullException("data") - ); - } - set - { - this.Properties["data"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required Request Request - { - get - { - if (!this.Properties.TryGetValue("request", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'request' cannot be null", - new ArgumentOutOfRangeException("request", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'request' cannot be null", - new ArgumentNullException("request") - ); - } - set - { - this.Properties["request"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public static implicit operator BaseWebhookEvent( - UploadPostTransformSuccessEvent uploadPostTransformSuccessEvent - ) => - new() - { - ID = uploadPostTransformSuccessEvent.ID, - Type = uploadPostTransformSuccessEvent.Type, - }; - - public override void Validate() - { - _ = this.ID; - _ = this.Type; - _ = this.CreatedAt; - this.Data.Validate(); - this.Request.Validate(); - } - - public UploadPostTransformSuccessEvent() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - UploadPostTransformSuccessEvent(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static UploadPostTransformSuccessEvent FromRawUnchecked( - Dictionary properties - ) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1.cs deleted file mode 100644 index f517484c..00000000 --- a/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1.cs +++ /dev/null @@ -1,140 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Core; -using Imagekit.Exceptions; -using Imagekit.Models.Webhooks.UploadPostTransformSuccessEventProperties.IntersectionMember1Properties; - -namespace Imagekit.Models.Webhooks.UploadPostTransformSuccessEventProperties; - -/// -/// Triggered when a post-transformation completes successfully. The transformed version -/// of the file is now ready and can be accessed via the provided URL. Note that -/// each post-transformation generates a separate webhook event. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class IntersectionMember1 : ModelBase, IFromRaw -{ - /// - /// Timestamp of when the event occurred in ISO8601 format. - /// - public required DateTime CreatedAt - { - get - { - if (!this.Properties.TryGetValue("created_at", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'created_at' cannot be null", - new ArgumentOutOfRangeException("created_at", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["created_at"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required Data Data - { - get - { - if (!this.Properties.TryGetValue("data", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'data' cannot be null", - new ArgumentOutOfRangeException("data", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'data' cannot be null", - new ArgumentNullException("data") - ); - } - set - { - this.Properties["data"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required Request Request - { - get - { - if (!this.Properties.TryGetValue("request", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'request' cannot be null", - new ArgumentOutOfRangeException("request", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'request' cannot be null", - new ArgumentNullException("request") - ); - } - set - { - this.Properties["request"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentOutOfRangeException("type", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.CreatedAt; - this.Data.Validate(); - this.Request.Validate(); - _ = this.Type; - } - - public IntersectionMember1() - { - this.Type = JsonSerializer.Deserialize("\"upload.post-transform.success\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - IntersectionMember1(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static IntersectionMember1 FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1Properties/Data.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1Properties/Data.cs deleted file mode 100644 index 3f6b5807..00000000 --- a/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1Properties/Data.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Webhooks.UploadPostTransformSuccessEventProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Data : ModelBase, IFromRaw -{ - /// - /// Unique identifier of the originally uploaded file. - /// - public required string FileID - { - get - { - if (!this.Properties.TryGetValue("fileId", out JsonElement element)) - throw new ArgumentOutOfRangeException("fileId", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("fileId"); - } - set - { - this.Properties["fileId"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Name of the file. - /// - public required string Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - throw new ArgumentOutOfRangeException("name", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("name"); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// URL of the generated post-transformation. - /// - public required string URL - { - get - { - if (!this.Properties.TryGetValue("url", out JsonElement element)) - throw new ArgumentOutOfRangeException("url", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("url"); - } - set - { - this.Properties["url"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.FileID; - _ = this.Name; - _ = this.URL; - } - - public Data() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Data(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Data FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1Properties/Request.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1Properties/Request.cs deleted file mode 100644 index 4d5f81fe..00000000 --- a/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1Properties/Request.cs +++ /dev/null @@ -1,79 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using RequestProperties = Imagekit.Models.Webhooks.UploadPostTransformSuccessEventProperties.RequestProperties; - -namespace Imagekit.Models.Webhooks.UploadPostTransformSuccessEventProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Request : ModelBase, IFromRaw -{ - public required RequestProperties::Transformation Transformation - { - get - { - if (!this.Properties.TryGetValue("transformation", out JsonElement element)) - throw new ArgumentOutOfRangeException( - "transformation", - "Missing required argument" - ); - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ) ?? throw new ArgumentNullException("transformation"); - } - set - { - this.Properties["transformation"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Unique identifier for the originating request. - /// - public required string XRequestID - { - get - { - if (!this.Properties.TryGetValue("x_request_id", out JsonElement element)) - throw new ArgumentOutOfRangeException("x_request_id", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("x_request_id"); - } - set - { - this.Properties["x_request_id"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Transformation.Validate(); - _ = this.XRequestID; - } - - public Request() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Request(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Request FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1Properties/RequestProperties/Transformation.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1Properties/RequestProperties/Transformation.cs deleted file mode 100644 index 00a49edf..00000000 --- a/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1Properties/RequestProperties/Transformation.cs +++ /dev/null @@ -1,116 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using TransformationProperties = Imagekit.Models.Webhooks.UploadPostTransformSuccessEventProperties.RequestProperties.TransformationProperties; - -namespace Imagekit.Models.Webhooks.UploadPostTransformSuccessEventProperties.RequestProperties; - -[JsonConverter( - typeof(ModelConverter) -)] -public sealed record class Transformation - : ModelBase, - IFromRaw -{ - /// - /// Type of the requested post-transformation. - /// - public required ApiEnum Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Only applicable if transformation type is 'abs'. Streaming protocol used. - /// - public ApiEnum? Protocol - { - get - { - if (!this.Properties.TryGetValue("protocol", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["protocol"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Value for the requested transformation type. - /// - public string? Value - { - get - { - if (!this.Properties.TryGetValue("value", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["value"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Type.Validate(); - this.Protocol?.Validate(); - _ = this.Value; - } - - public Transformation() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Transformation(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static global::Imagekit.Models.Webhooks.UploadPostTransformSuccessEventProperties.IntersectionMember1Properties.RequestProperties.Transformation FromRawUnchecked( - Dictionary properties - ) - { - return new(properties); - } - - [SetsRequiredMembers] - public Transformation(ApiEnum type) - : this() - { - this.Type = type; - } -} diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1Properties/RequestProperties/TransformationProperties/Protocol.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1Properties/RequestProperties/TransformationProperties/Protocol.cs deleted file mode 100644 index 745547da..00000000 --- a/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1Properties/RequestProperties/TransformationProperties/Protocol.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using System = System; - -namespace Imagekit.Models.Webhooks.UploadPostTransformSuccessEventProperties.RequestProperties.TransformationProperties; - -/// -/// Only applicable if transformation type is 'abs'. Streaming protocol used. -/// -[JsonConverter(typeof(ProtocolConverter))] -public enum Protocol -{ - Hls, - Dash, -} - -sealed class ProtocolConverter : JsonConverter -{ - public override Protocol Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "hls" => Protocol.Hls, - "dash" => Protocol.Dash, - _ => (Protocol)(-1), - }; - } - - public override void Write(Utf8JsonWriter writer, Protocol value, JsonSerializerOptions options) - { - JsonSerializer.Serialize( - writer, - value switch - { - Protocol.Hls => "hls", - Protocol.Dash => "dash", - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1Properties/RequestProperties/TransformationProperties/Type.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1Properties/RequestProperties/TransformationProperties/Type.cs deleted file mode 100644 index 5ef8fe08..00000000 --- a/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEventProperties/IntersectionMember1Properties/RequestProperties/TransformationProperties/Type.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using System = System; - -namespace Imagekit.Models.Webhooks.UploadPostTransformSuccessEventProperties.RequestProperties.TransformationProperties; - -/// -/// Type of the requested post-transformation. -/// -[JsonConverter(typeof(TypeConverter))] -public enum Type -{ - Transformation, - Abs, - GifToVideo, - Thumbnail, -} - -sealed class TypeConverter : JsonConverter -{ - public override Type Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "transformation" => TransformationProperties.Type.Transformation, - "abs" => TransformationProperties.Type.Abs, - "gif-to-video" => TransformationProperties.Type.GifToVideo, - "thumbnail" => TransformationProperties.Type.Thumbnail, - _ => (Type)(-1), - }; - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonSerializer.Serialize( - writer, - value switch - { - TransformationProperties.Type.Transformation => "transformation", - TransformationProperties.Type.Abs => "abs", - TransformationProperties.Type.GifToVideo => "gif-to-video", - TransformationProperties.Type.Thumbnail => "thumbnail", - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEvent.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEvent.cs deleted file mode 100644 index 0b0730c8..00000000 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEvent.cs +++ /dev/null @@ -1,180 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Core; -using Imagekit.Exceptions; -using Imagekit.Models.Webhooks.UploadPreTransformErrorEventProperties.IntersectionMember1Properties; - -namespace Imagekit.Models.Webhooks; - -/// -/// Triggered when a pre-transformation fails. The file upload may have been accepted, -/// but the requested transformation could not be applied. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class UploadPreTransformErrorEvent - : ModelBase, - IFromRaw -{ - /// - /// Unique identifier for the event. - /// - public required string ID - { - get - { - if (!this.Properties.TryGetValue("id", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'id' cannot be null", - new ArgumentOutOfRangeException("id", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'id' cannot be null", - new ArgumentNullException("id") - ); - } - set - { - this.Properties["id"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The type of webhook event. - /// - public required string Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentOutOfRangeException("type", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentNullException("type") - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Timestamp of when the event occurred in ISO8601 format. - /// - public required DateTime CreatedAt - { - get - { - if (!this.Properties.TryGetValue("created_at", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'created_at' cannot be null", - new ArgumentOutOfRangeException("created_at", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["created_at"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required Data Data - { - get - { - if (!this.Properties.TryGetValue("data", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'data' cannot be null", - new ArgumentOutOfRangeException("data", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'data' cannot be null", - new ArgumentNullException("data") - ); - } - set - { - this.Properties["data"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required Request Request - { - get - { - if (!this.Properties.TryGetValue("request", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'request' cannot be null", - new ArgumentOutOfRangeException("request", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'request' cannot be null", - new ArgumentNullException("request") - ); - } - set - { - this.Properties["request"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public static implicit operator BaseWebhookEvent( - UploadPreTransformErrorEvent uploadPreTransformErrorEvent - ) => new() { ID = uploadPreTransformErrorEvent.ID, Type = uploadPreTransformErrorEvent.Type }; - - public override void Validate() - { - _ = this.ID; - _ = this.Type; - _ = this.CreatedAt; - this.Data.Validate(); - this.Request.Validate(); - } - - public UploadPreTransformErrorEvent() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - UploadPreTransformErrorEvent(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static UploadPreTransformErrorEvent FromRawUnchecked( - Dictionary properties - ) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/IntersectionMember1.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/IntersectionMember1.cs deleted file mode 100644 index 44b9ee28..00000000 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/IntersectionMember1.cs +++ /dev/null @@ -1,139 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Core; -using Imagekit.Exceptions; -using Imagekit.Models.Webhooks.UploadPreTransformErrorEventProperties.IntersectionMember1Properties; - -namespace Imagekit.Models.Webhooks.UploadPreTransformErrorEventProperties; - -/// -/// Triggered when a pre-transformation fails. The file upload may have been accepted, -/// but the requested transformation could not be applied. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class IntersectionMember1 : ModelBase, IFromRaw -{ - /// - /// Timestamp of when the event occurred in ISO8601 format. - /// - public required DateTime CreatedAt - { - get - { - if (!this.Properties.TryGetValue("created_at", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'created_at' cannot be null", - new ArgumentOutOfRangeException("created_at", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["created_at"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required Data Data - { - get - { - if (!this.Properties.TryGetValue("data", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'data' cannot be null", - new ArgumentOutOfRangeException("data", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'data' cannot be null", - new ArgumentNullException("data") - ); - } - set - { - this.Properties["data"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required Request Request - { - get - { - if (!this.Properties.TryGetValue("request", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'request' cannot be null", - new ArgumentOutOfRangeException("request", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'request' cannot be null", - new ArgumentNullException("request") - ); - } - set - { - this.Properties["request"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentOutOfRangeException("type", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.CreatedAt; - this.Data.Validate(); - this.Request.Validate(); - _ = this.Type; - } - - public IntersectionMember1() - { - this.Type = JsonSerializer.Deserialize("\"upload.pre-transform.error\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - IntersectionMember1(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static IntersectionMember1 FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/IntersectionMember1Properties/Data.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/IntersectionMember1Properties/Data.cs deleted file mode 100644 index 0baeff6a..00000000 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/IntersectionMember1Properties/Data.cs +++ /dev/null @@ -1,102 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using DataProperties = Imagekit.Models.Webhooks.UploadPreTransformErrorEventProperties.DataProperties; - -namespace Imagekit.Models.Webhooks.UploadPreTransformErrorEventProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Data : ModelBase, IFromRaw -{ - /// - /// Name of the file. - /// - public required string Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - throw new ArgumentOutOfRangeException("name", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("name"); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Path of the file. - /// - public required string Path - { - get - { - if (!this.Properties.TryGetValue("path", out JsonElement element)) - throw new ArgumentOutOfRangeException("path", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("path"); - } - set - { - this.Properties["path"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required DataProperties::Transformation Transformation - { - get - { - if (!this.Properties.TryGetValue("transformation", out JsonElement element)) - throw new ArgumentOutOfRangeException( - "transformation", - "Missing required argument" - ); - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ) ?? throw new ArgumentNullException("transformation"); - } - set - { - this.Properties["transformation"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.Name; - _ = this.Path; - this.Transformation.Validate(); - } - - public Data() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Data(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Data FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs deleted file mode 100644 index c8a814c2..00000000 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Webhooks.UploadPreTransformErrorEventProperties.DataProperties.TransformationProperties; - -namespace Imagekit.Models.Webhooks.UploadPreTransformErrorEventProperties.DataProperties; - -[JsonConverter( - typeof(ModelConverter) -)] -public sealed record class Transformation - : ModelBase, - IFromRaw -{ - public required Error Error - { - get - { - if (!this.Properties.TryGetValue("error", out JsonElement element)) - throw new ArgumentOutOfRangeException("error", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("error"); - } - set - { - this.Properties["error"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Error.Validate(); - } - - public Transformation() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Transformation(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static global::Imagekit.Models.Webhooks.UploadPreTransformErrorEventProperties.IntersectionMember1Properties.DataProperties.Transformation FromRawUnchecked( - Dictionary properties - ) - { - return new(properties); - } - - [SetsRequiredMembers] - public Transformation(Error error) - : this() - { - this.Error = error; - } -} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Error.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Error.cs deleted file mode 100644 index 7f7aedc1..00000000 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Error.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Webhooks.UploadPreTransformErrorEventProperties.DataProperties.TransformationProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Error : ModelBase, IFromRaw -{ - /// - /// Reason for the pre-transformation failure. - /// - public required string Reason - { - get - { - if (!this.Properties.TryGetValue("reason", out JsonElement element)) - throw new ArgumentOutOfRangeException("reason", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("reason"); - } - set - { - this.Properties["reason"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.Reason; - } - - public Error() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Error(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Error FromRawUnchecked(Dictionary properties) - { - return new(properties); - } - - [SetsRequiredMembers] - public Error(string reason) - : this() - { - this.Reason = reason; - } -} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/IntersectionMember1Properties/Request.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/IntersectionMember1Properties/Request.cs deleted file mode 100644 index bb8f1777..00000000 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEventProperties/IntersectionMember1Properties/Request.cs +++ /dev/null @@ -1,79 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Webhooks.UploadPreTransformErrorEventProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Request : ModelBase, IFromRaw -{ - /// - /// The requested pre-transformation string. - /// - public required string Transformation - { - get - { - if (!this.Properties.TryGetValue("transformation", out JsonElement element)) - throw new ArgumentOutOfRangeException( - "transformation", - "Missing required argument" - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("transformation"); - } - set - { - this.Properties["transformation"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Unique identifier for the originating request. - /// - public required string XRequestID - { - get - { - if (!this.Properties.TryGetValue("x_request_id", out JsonElement element)) - throw new ArgumentOutOfRangeException("x_request_id", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("x_request_id"); - } - set - { - this.Properties["x_request_id"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.Transformation; - _ = this.XRequestID; - } - - public Request() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Request(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Request FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEvent.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEvent.cs deleted file mode 100644 index f1840f84..00000000 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEvent.cs +++ /dev/null @@ -1,189 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Core; -using Imagekit.Exceptions; -using Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties; - -namespace Imagekit.Models.Webhooks; - -/// -/// Triggered when a pre-transformation completes successfully. The file has been -/// processed with the requested transformation and is now available in the Media -/// Library. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class UploadPreTransformSuccessEvent - : ModelBase, - IFromRaw -{ - /// - /// Unique identifier for the event. - /// - public required string ID - { - get - { - if (!this.Properties.TryGetValue("id", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'id' cannot be null", - new ArgumentOutOfRangeException("id", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'id' cannot be null", - new ArgumentNullException("id") - ); - } - set - { - this.Properties["id"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The type of webhook event. - /// - public required string Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentOutOfRangeException("type", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentNullException("type") - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Timestamp of when the event occurred in ISO8601 format. - /// - public required DateTime CreatedAt - { - get - { - if (!this.Properties.TryGetValue("created_at", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'created_at' cannot be null", - new ArgumentOutOfRangeException("created_at", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["created_at"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Object containing details of a successful upload. - /// - public required Data Data - { - get - { - if (!this.Properties.TryGetValue("data", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'data' cannot be null", - new ArgumentOutOfRangeException("data", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'data' cannot be null", - new ArgumentNullException("data") - ); - } - set - { - this.Properties["data"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required Request Request - { - get - { - if (!this.Properties.TryGetValue("request", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'request' cannot be null", - new ArgumentOutOfRangeException("request", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'request' cannot be null", - new ArgumentNullException("request") - ); - } - set - { - this.Properties["request"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public static implicit operator BaseWebhookEvent( - UploadPreTransformSuccessEvent uploadPreTransformSuccessEvent - ) => - new() - { - ID = uploadPreTransformSuccessEvent.ID, - Type = uploadPreTransformSuccessEvent.Type, - }; - - public override void Validate() - { - _ = this.ID; - _ = this.Type; - _ = this.CreatedAt; - this.Data.Validate(); - this.Request.Validate(); - } - - public UploadPreTransformSuccessEvent() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - UploadPreTransformSuccessEvent(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static UploadPreTransformSuccessEvent FromRawUnchecked( - Dictionary properties - ) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1.cs deleted file mode 100644 index 6cd7c856..00000000 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1.cs +++ /dev/null @@ -1,143 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Core; -using Imagekit.Exceptions; -using Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties; - -namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties; - -/// -/// Triggered when a pre-transformation completes successfully. The file has been -/// processed with the requested transformation and is now available in the Media -/// Library. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class IntersectionMember1 : ModelBase, IFromRaw -{ - /// - /// Timestamp of when the event occurred in ISO8601 format. - /// - public required DateTime CreatedAt - { - get - { - if (!this.Properties.TryGetValue("created_at", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'created_at' cannot be null", - new ArgumentOutOfRangeException("created_at", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["created_at"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Object containing details of a successful upload. - /// - public required Data Data - { - get - { - if (!this.Properties.TryGetValue("data", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'data' cannot be null", - new ArgumentOutOfRangeException("data", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'data' cannot be null", - new ArgumentNullException("data") - ); - } - set - { - this.Properties["data"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required Request Request - { - get - { - if (!this.Properties.TryGetValue("request", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'request' cannot be null", - new ArgumentOutOfRangeException("request", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'request' cannot be null", - new ArgumentNullException("request") - ); - } - set - { - this.Properties["request"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentOutOfRangeException("type", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.CreatedAt; - this.Data.Validate(); - this.Request.Validate(); - _ = this.Type; - } - - public IntersectionMember1() - { - this.Type = JsonSerializer.Deserialize("\"upload.pre-transform.success\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - IntersectionMember1(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static IntersectionMember1 FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/Data.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/Data.cs deleted file mode 100644 index f9fb5e64..00000000 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/Data.cs +++ /dev/null @@ -1,637 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Core; -using Imagekit.Models.Files; -using Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties; -using Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties; - -namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties; - -/// -/// Object containing details of a successful upload. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class Data : ModelBase, IFromRaw -{ - /// - /// An array of tags assigned to the uploaded file by auto tagging. - /// - public List? AITags - { - get - { - if (!this.Properties.TryGetValue("AITags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["AITags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The audio codec used in the video (only for video). - /// - public string? AudioCodec - { - get - { - if (!this.Properties.TryGetValue("audioCodec", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["audioCodec"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The bit rate of the video in kbps (only for video). - /// - public long? BitRate - { - get - { - if (!this.Properties.TryGetValue("bitRate", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["bitRate"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Value of custom coordinates associated with the image in the format `x,y,width,height`. - /// If `customCoordinates` are not defined, then it is `null`. Send `customCoordinates` - /// in `responseFields` in API request to get the value of this field. - /// - public string? CustomCoordinates - { - get - { - if (!this.Properties.TryGetValue("customCoordinates", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["customCoordinates"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// A key-value data associated with the asset. Use `responseField` in API request - /// to get `customMetadata` in the upload API response. Before setting any custom - /// metadata on an asset, you have to create the field using custom metadata - /// fields API. Send `customMetadata` in `responseFields` in API request to get - /// the value of this field. - /// - public Dictionary? CustomMetadata - { - get - { - if (!this.Properties.TryGetValue("customMetadata", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["customMetadata"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Optional text to describe the contents of the file. Can be set by the user - /// or the ai-auto-description extension. - /// - public string? Description - { - get - { - if (!this.Properties.TryGetValue("description", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["description"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The duration of the video in seconds (only for video). - /// - public long? Duration - { - get - { - if (!this.Properties.TryGetValue("duration", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["duration"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Consolidated embedded metadata associated with the file. It includes exif, - /// iptc, and xmp data. Send `embeddedMetadata` in `responseFields` in API request - /// to get embeddedMetadata in the upload API response. - /// - public Dictionary? EmbeddedMetadata - { - get - { - if (!this.Properties.TryGetValue("embeddedMetadata", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["embeddedMetadata"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Extension names with their processing status at the time of completion of - /// the request. It could have one of the following status values: - /// - /// `success`: The extension has been successfully applied. `failed`: The extension - /// has failed and will not be retried. `pending`: The extension will finish processing - /// in some time. On completion, the final status (success / failed) will be sent - /// to the `webhookUrl` provided. - /// - /// If no extension was requested, then this parameter is not returned. - /// - public ExtensionStatus? ExtensionStatus - { - get - { - if (!this.Properties.TryGetValue("extensionStatus", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["extensionStatus"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Unique fileId. Store this fileld in your database, as this will be used to - /// perform update action on this file. - /// - public string? FileID - { - get - { - if (!this.Properties.TryGetValue("fileId", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["fileId"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The relative path of the file in the media library e.g. `/marketing-assets/new-banner.jpg`. - /// - public string? FilePath - { - get - { - if (!this.Properties.TryGetValue("filePath", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["filePath"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Type of the uploaded file. Possible values are `image`, `non-image`. - /// - public string? FileType - { - get - { - if (!this.Properties.TryGetValue("fileType", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["fileType"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Height of the image in pixels (Only for images) - /// - public double? Height - { - get - { - if (!this.Properties.TryGetValue("height", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["height"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Is the file marked as private. It can be either `true` or `false`. Send `isPrivateFile` - /// in `responseFields` in API request to get the value of this field. - /// - public bool? IsPrivateFile - { - get - { - if (!this.Properties.TryGetValue("isPrivateFile", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["isPrivateFile"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Is the file published or in draft state. It can be either `true` or `false`. - /// Send `isPublished` in `responseFields` in API request to get the value of - /// this field. - /// - public bool? IsPublished - { - get - { - if (!this.Properties.TryGetValue("isPublished", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["isPublished"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Legacy metadata. Send `metadata` in `responseFields` in API request to get - /// metadata in the upload API response. - /// - public Metadata? Metadata - { - get - { - if (!this.Properties.TryGetValue("metadata", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["metadata"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Name of the asset. - /// - public string? Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// This field is included in the response only if the Path policy feature is - /// available in the plan. It contains schema definitions for the custom metadata - /// fields selected for the specified file path. Field selection can only be done - /// when the Path policy feature is enabled. - /// - /// Keys are the names of the custom metadata fields; the value object has details - /// about the custom metadata schema. - /// - public Dictionary? SelectedFieldsSchema - { - get - { - if (!this.Properties.TryGetValue("selectedFieldsSchema", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["selectedFieldsSchema"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Size of the image file in Bytes. - /// - public double? Size - { - get - { - if (!this.Properties.TryGetValue("size", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["size"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The array of tags associated with the asset. If no tags are set, it will - /// be `null`. Send `tags` in `responseFields` in API request to get the value - /// of this field. - /// - public List? Tags - { - get - { - if (!this.Properties.TryGetValue("tags", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["tags"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// In the case of an image, a small thumbnail URL. - /// - public string? ThumbnailURL - { - get - { - if (!this.Properties.TryGetValue("thumbnailUrl", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["thumbnailUrl"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// A publicly accessible URL of the file. - /// - public string? URL - { - get - { - if (!this.Properties.TryGetValue("url", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["url"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// An object containing the file or file version's `id` (versionId) and `name`. - /// - public VersionInfo? VersionInfo - { - get - { - if (!this.Properties.TryGetValue("versionInfo", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["versionInfo"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The video codec used in the video (only for video). - /// - public string? VideoCodec - { - get - { - if (!this.Properties.TryGetValue("videoCodec", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["videoCodec"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Width of the image in pixels (Only for Images) - /// - public double? Width - { - get - { - if (!this.Properties.TryGetValue("width", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["width"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - foreach (var item in this.AITags ?? []) - { - item.Validate(); - } - _ = this.AudioCodec; - _ = this.BitRate; - _ = this.CustomCoordinates; - _ = this.CustomMetadata; - _ = this.Description; - _ = this.Duration; - _ = this.EmbeddedMetadata; - this.ExtensionStatus?.Validate(); - _ = this.FileID; - _ = this.FilePath; - _ = this.FileType; - _ = this.Height; - _ = this.IsPrivateFile; - _ = this.IsPublished; - this.Metadata?.Validate(); - _ = this.Name; - if (this.SelectedFieldsSchema != null) - { - foreach (var item in this.SelectedFieldsSchema.Values) - { - item.Validate(); - } - } - _ = this.Size; - _ = this.Tags; - _ = this.ThumbnailURL; - _ = this.URL; - this.VersionInfo?.Validate(); - _ = this.VideoCodec; - _ = this.Width; - } - - public Data() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Data(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Data FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/AITag.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/AITag.cs deleted file mode 100644 index 3c5ac201..00000000 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/AITag.cs +++ /dev/null @@ -1,96 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.DataProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class AITag : ModelBase, IFromRaw -{ - /// - /// Confidence score of the tag. - /// - public double? Confidence - { - get - { - if (!this.Properties.TryGetValue("confidence", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["confidence"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Name of the tag. - /// - public string? Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Array of `AITags` associated with the image. If no `AITags` are set, it will - /// be null. These tags can be added using the `google-auto-tagging` or `aws-auto-tagging` extensions. - /// - public string? Source - { - get - { - if (!this.Properties.TryGetValue("source", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["source"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.Confidence; - _ = this.Name; - _ = this.Source; - } - - public AITag() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - AITag(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static AITag FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/ExtensionStatus.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/ExtensionStatus.cs deleted file mode 100644 index f144ed8f..00000000 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/ExtensionStatus.cs +++ /dev/null @@ -1,129 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.DataProperties.ExtensionStatusProperties; - -namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.DataProperties; - -/// -/// Extension names with their processing status at the time of completion of the -/// request. It could have one of the following status values: -/// -/// `success`: The extension has been successfully applied. `failed`: The extension -/// has failed and will not be retried. `pending`: The extension will finish processing -/// in some time. On completion, the final status (success / failed) will be sent -/// to the `webhookUrl` provided. -/// -/// If no extension was requested, then this parameter is not returned. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class ExtensionStatus : ModelBase, IFromRaw -{ - public ApiEnum? AIAutoDescription - { - get - { - if (!this.Properties.TryGetValue("ai-auto-description", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["ai-auto-description"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public ApiEnum? AwsAutoTagging - { - get - { - if (!this.Properties.TryGetValue("aws-auto-tagging", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["aws-auto-tagging"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public ApiEnum? GoogleAutoTagging - { - get - { - if (!this.Properties.TryGetValue("google-auto-tagging", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["google-auto-tagging"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public ApiEnum? RemoveBg - { - get - { - if (!this.Properties.TryGetValue("remove-bg", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["remove-bg"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.AIAutoDescription?.Validate(); - this.AwsAutoTagging?.Validate(); - this.GoogleAutoTagging?.Validate(); - this.RemoveBg?.Validate(); - } - - public ExtensionStatus() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - ExtensionStatus(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static ExtensionStatus FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/ExtensionStatusProperties/AIAutoDescription.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/ExtensionStatusProperties/AIAutoDescription.cs deleted file mode 100644 index 9ea84518..00000000 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/ExtensionStatusProperties/AIAutoDescription.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.DataProperties.ExtensionStatusProperties; - -[JsonConverter(typeof(AIAutoDescriptionConverter))] -public enum AIAutoDescription -{ - Success, - Pending, - Failed, -} - -sealed class AIAutoDescriptionConverter : JsonConverter -{ - public override AIAutoDescription Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "success" => AIAutoDescription.Success, - "pending" => AIAutoDescription.Pending, - "failed" => AIAutoDescription.Failed, - _ => (AIAutoDescription)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - AIAutoDescription value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - AIAutoDescription.Success => "success", - AIAutoDescription.Pending => "pending", - AIAutoDescription.Failed => "failed", - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/ExtensionStatusProperties/AwsAutoTagging.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/ExtensionStatusProperties/AwsAutoTagging.cs deleted file mode 100644 index 829c2741..00000000 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/ExtensionStatusProperties/AwsAutoTagging.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.DataProperties.ExtensionStatusProperties; - -[JsonConverter(typeof(AwsAutoTaggingConverter))] -public enum AwsAutoTagging -{ - Success, - Pending, - Failed, -} - -sealed class AwsAutoTaggingConverter : JsonConverter -{ - public override AwsAutoTagging Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "success" => AwsAutoTagging.Success, - "pending" => AwsAutoTagging.Pending, - "failed" => AwsAutoTagging.Failed, - _ => (AwsAutoTagging)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - AwsAutoTagging value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - AwsAutoTagging.Success => "success", - AwsAutoTagging.Pending => "pending", - AwsAutoTagging.Failed => "failed", - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/ExtensionStatusProperties/GoogleAutoTagging.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/ExtensionStatusProperties/GoogleAutoTagging.cs deleted file mode 100644 index ef9ecd16..00000000 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/ExtensionStatusProperties/GoogleAutoTagging.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.DataProperties.ExtensionStatusProperties; - -[JsonConverter(typeof(GoogleAutoTaggingConverter))] -public enum GoogleAutoTagging -{ - Success, - Pending, - Failed, -} - -sealed class GoogleAutoTaggingConverter : JsonConverter -{ - public override GoogleAutoTagging Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "success" => GoogleAutoTagging.Success, - "pending" => GoogleAutoTagging.Pending, - "failed" => GoogleAutoTagging.Failed, - _ => (GoogleAutoTagging)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - GoogleAutoTagging value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - GoogleAutoTagging.Success => "success", - GoogleAutoTagging.Pending => "pending", - GoogleAutoTagging.Failed => "failed", - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/ExtensionStatusProperties/RemoveBg.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/ExtensionStatusProperties/RemoveBg.cs deleted file mode 100644 index 98156421..00000000 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/ExtensionStatusProperties/RemoveBg.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.DataProperties.ExtensionStatusProperties; - -[JsonConverter(typeof(RemoveBgConverter))] -public enum RemoveBg -{ - Success, - Pending, - Failed, -} - -sealed class RemoveBgConverter : JsonConverter -{ - public override RemoveBg Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "success" => RemoveBg.Success, - "pending" => RemoveBg.Pending, - "failed" => RemoveBg.Failed, - _ => (RemoveBg)(-1), - }; - } - - public override void Write(Utf8JsonWriter writer, RemoveBg value, JsonSerializerOptions options) - { - JsonSerializer.Serialize( - writer, - value switch - { - RemoveBg.Success => "success", - RemoveBg.Pending => "pending", - RemoveBg.Failed => "failed", - _ => throw new ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs deleted file mode 100644 index a34f0eed..00000000 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItem.cs +++ /dev/null @@ -1,290 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Core; -using Imagekit.Exceptions; -using SelectedFieldsSchemaItemProperties = Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; - -namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class SelectedFieldsSchemaItem : ModelBase, IFromRaw -{ - /// - /// Type of the custom metadata field. - /// - public required ApiEnum Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentOutOfRangeException("type", "Missing required argument") - ); - - return JsonSerializer.Deserialize< - ApiEnum - >(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The default value for this custom metadata field. The value should match the - /// `type` of custom metadata field. - /// - public SelectedFieldsSchemaItemProperties::DefaultValue? DefaultValue - { - get - { - if (!this.Properties.TryGetValue("defaultValue", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["defaultValue"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies if the custom metadata field is required or not. - /// - public bool? IsValueRequired - { - get - { - if (!this.Properties.TryGetValue("isValueRequired", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["isValueRequired"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. - /// - public double? MaxLength - { - get - { - if (!this.Properties.TryGetValue("maxLength", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["maxLength"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Maximum value of the field. Only set if field type is `Date` or `Number`. - /// For `Date` type field, the value will be in ISO8601 string format. For `Number` - /// type field, it will be a numeric value. - /// - public SelectedFieldsSchemaItemProperties::MaxValue? MaxValue - { - get - { - if (!this.Properties.TryGetValue("maxValue", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["maxValue"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. - /// - public double? MinLength - { - get - { - if (!this.Properties.TryGetValue("minLength", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["minLength"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Minimum value of the field. Only set if field type is `Date` or `Number`. - /// For `Date` type field, the value will be in ISO8601 string format. For `Number` - /// type field, it will be a numeric value. - /// - public SelectedFieldsSchemaItemProperties::MinValue? MinValue - { - get - { - if (!this.Properties.TryGetValue("minValue", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["minValue"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Indicates whether the custom metadata field is read only. A read only field - /// cannot be modified after being set. This field is configurable only via the - /// **Path policy** feature. - /// - public bool? ReadOnly - { - get - { - if (!this.Properties.TryGetValue("readOnly", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["readOnly"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// An array of allowed values when field type is `SingleSelect` or `MultiSelect`. - /// - public List? SelectOptions - { - get - { - if (!this.Properties.TryGetValue("selectOptions", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["selectOptions"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Specifies if the selectOptions array is truncated. It is truncated when number - /// of options are > 100. - /// - public bool? SelectOptionsTruncated - { - get - { - if (!this.Properties.TryGetValue("selectOptionsTruncated", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["selectOptionsTruncated"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Type.Validate(); - this.DefaultValue?.Validate(); - _ = this.IsValueRequired; - _ = this.MaxLength; - this.MaxValue?.Validate(); - _ = this.MinLength; - this.MinValue?.Validate(); - _ = this.ReadOnly; - foreach (var item in this.SelectOptions ?? []) - { - item.Validate(); - } - _ = this.SelectOptionsTruncated; - } - - public SelectedFieldsSchemaItem() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - SelectedFieldsSchemaItem(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static SelectedFieldsSchemaItem FromRawUnchecked( - Dictionary properties - ) - { - return new(properties); - } - - [SetsRequiredMembers] - public SelectedFieldsSchemaItem(ApiEnum type) - : this() - { - this.Type = type; - } -} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs deleted file mode 100644 index cd6d134b..00000000 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValue.cs +++ /dev/null @@ -1,214 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties; -using System = System; - -namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; - -/// -/// The default value for this custom metadata field. The value should match the -/// `type` of custom metadata field. -/// -[JsonConverter(typeof(DefaultValueConverter))] -public record class DefaultValue -{ - public object Value { get; private init; } - - public DefaultValue(string value) - { - Value = value; - } - - public DefaultValue(double value) - { - Value = value; - } - - public DefaultValue(bool value) - { - Value = value; - } - - public DefaultValue(List value) - { - Value = value; - } - - DefaultValue(UnknownVariant value) - { - Value = value; - } - - public static DefaultValue CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public bool TryPickBool([NotNullWhen(true)] out bool? value) - { - value = this.Value as bool?; - return value != null; - } - - public bool TryPickMixed([NotNullWhen(true)] out List? value) - { - value = this.Value as List; - return value != null; - } - - public void Switch( - System::Action @string, - System::Action @double, - System::Action @bool, - System::Action> mixed - ) - { - switch (this.Value) - { - case string value: - @string(value); - break; - case double value: - @double(value); - break; - case bool value: - @bool(value); - break; - case List value: - mixed(value); - break; - default: - throw new ImageKitInvalidDataException( - "Data did not match any variant of DefaultValue" - ); - } - } - - public T Match( - System::Func @string, - System::Func @double, - System::Func @bool, - System::Func, T> mixed - ) - { - return this.Value switch - { - string value => @string(value), - double value => @double(value), - bool value => @bool(value), - List value => mixed(value), - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of DefaultValue" - ), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException( - "Data did not match any variant of DefaultValue" - ); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class DefaultValueConverter : JsonConverter -{ - public override DefaultValue? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new DefaultValue(deserialized); - } - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'string'", e) - ); - } - - try - { - return new DefaultValue(JsonSerializer.Deserialize(ref reader, options)); - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'double'", e) - ); - } - - try - { - return new DefaultValue(JsonSerializer.Deserialize(ref reader, options)); - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'bool'", e) - ); - } - - try - { - var deserialized = JsonSerializer.Deserialize>( - ref reader, - options - ); - if (deserialized != null) - { - return new DefaultValue(deserialized); - } - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException( - "Data does not match union variant 'List'", - e - ) - ); - } - - throw new System::AggregateException(exceptions); - } - - public override void Write( - Utf8JsonWriter writer, - DefaultValue value, - JsonSerializerOptions options - ) - { - object variant = value.Value; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent7.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent7.cs deleted file mode 100644 index 64c5b30c..00000000 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/DefaultValueProperties/UnnamedSchemaWithArrayParent7.cs +++ /dev/null @@ -1,175 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties.DefaultValueProperties; - -[JsonConverter(typeof(UnnamedSchemaWithArrayParent7Converter))] -public record class UnnamedSchemaWithArrayParent7 -{ - public object Value { get; private init; } - - public UnnamedSchemaWithArrayParent7(string value) - { - Value = value; - } - - public UnnamedSchemaWithArrayParent7(double value) - { - Value = value; - } - - public UnnamedSchemaWithArrayParent7(bool value) - { - Value = value; - } - - UnnamedSchemaWithArrayParent7(UnknownVariant value) - { - Value = value; - } - - public static UnnamedSchemaWithArrayParent7 CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public bool TryPickBool([NotNullWhen(true)] out bool? value) - { - value = this.Value as bool?; - return value != null; - } - - public void Switch( - System::Action @string, - System::Action @double, - System::Action @bool - ) - { - switch (this.Value) - { - case string value: - @string(value); - break; - case double value: - @double(value); - break; - case bool value: - @bool(value); - break; - default: - throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent7" - ); - } - } - - public T Match( - System::Func @string, - System::Func @double, - System::Func @bool - ) - { - return this.Value switch - { - string value => @string(value), - double value => @double(value), - bool value => @bool(value), - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent7" - ), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent7" - ); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class UnnamedSchemaWithArrayParent7Converter : JsonConverter -{ - public override UnnamedSchemaWithArrayParent7? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new UnnamedSchemaWithArrayParent7(deserialized); - } - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'string'", e) - ); - } - - try - { - return new UnnamedSchemaWithArrayParent7( - JsonSerializer.Deserialize(ref reader, options) - ); - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'double'", e) - ); - } - - try - { - return new UnnamedSchemaWithArrayParent7( - JsonSerializer.Deserialize(ref reader, options) - ); - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'bool'", e) - ); - } - - throw new System::AggregateException(exceptions); - } - - public override void Write( - Utf8JsonWriter writer, - UnnamedSchemaWithArrayParent7 value, - JsonSerializerOptions options - ) - { - object variant = value.Value; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs deleted file mode 100644 index 58d0c73e..00000000 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MaxValue.cs +++ /dev/null @@ -1,136 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; - -/// -/// Maximum value of the field. Only set if field type is `Date` or `Number`. For -/// `Date` type field, the value will be in ISO8601 string format. For `Number` type -/// field, it will be a numeric value. -/// -[JsonConverter(typeof(MaxValueConverter))] -public record class MaxValue -{ - public object Value { get; private init; } - - public MaxValue(string value) - { - Value = value; - } - - public MaxValue(double value) - { - Value = value; - } - - MaxValue(UnknownVariant value) - { - Value = value; - } - - public static MaxValue CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public void Switch(System::Action @string, System::Action @double) - { - switch (this.Value) - { - case string value: - @string(value); - break; - case double value: - @double(value); - break; - default: - throw new ImageKitInvalidDataException( - "Data did not match any variant of MaxValue" - ); - } - } - - public T Match(System::Func @string, System::Func @double) - { - return this.Value switch - { - string value => @string(value), - double value => @double(value), - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of MaxValue" - ), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of MaxValue"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class MaxValueConverter : JsonConverter -{ - public override MaxValue? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new MaxValue(deserialized); - } - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'string'", e) - ); - } - - try - { - return new MaxValue(JsonSerializer.Deserialize(ref reader, options)); - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'double'", e) - ); - } - - throw new System::AggregateException(exceptions); - } - - public override void Write(Utf8JsonWriter writer, MaxValue value, JsonSerializerOptions options) - { - object variant = value.Value; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs deleted file mode 100644 index 509f7528..00000000 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/MinValue.cs +++ /dev/null @@ -1,136 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; - -/// -/// Minimum value of the field. Only set if field type is `Date` or `Number`. For -/// `Date` type field, the value will be in ISO8601 string format. For `Number` type -/// field, it will be a numeric value. -/// -[JsonConverter(typeof(MinValueConverter))] -public record class MinValue -{ - public object Value { get; private init; } - - public MinValue(string value) - { - Value = value; - } - - public MinValue(double value) - { - Value = value; - } - - MinValue(UnknownVariant value) - { - Value = value; - } - - public static MinValue CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public void Switch(System::Action @string, System::Action @double) - { - switch (this.Value) - { - case string value: - @string(value); - break; - case double value: - @double(value); - break; - default: - throw new ImageKitInvalidDataException( - "Data did not match any variant of MinValue" - ); - } - } - - public T Match(System::Func @string, System::Func @double) - { - return this.Value switch - { - string value => @string(value), - double value => @double(value), - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of MinValue" - ), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException("Data did not match any variant of MinValue"); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class MinValueConverter : JsonConverter -{ - public override MinValue? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new MinValue(deserialized); - } - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'string'", e) - ); - } - - try - { - return new MinValue(JsonSerializer.Deserialize(ref reader, options)); - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'double'", e) - ); - } - - throw new System::AggregateException(exceptions); - } - - public override void Write(Utf8JsonWriter writer, MinValue value, JsonSerializerOptions options) - { - object variant = value.Value; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs deleted file mode 100644 index 8090e8ef..00000000 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/SelectOption.cs +++ /dev/null @@ -1,171 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; - -[JsonConverter(typeof(SelectOptionConverter))] -public record class SelectOption -{ - public object Value { get; private init; } - - public SelectOption(string value) - { - Value = value; - } - - public SelectOption(double value) - { - Value = value; - } - - public SelectOption(bool value) - { - Value = value; - } - - SelectOption(UnknownVariant value) - { - Value = value; - } - - public static SelectOption CreateUnknownVariant(JsonElement value) - { - return new(new UnknownVariant(value)); - } - - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - public bool TryPickBool([NotNullWhen(true)] out bool? value) - { - value = this.Value as bool?; - return value != null; - } - - public void Switch( - System::Action @string, - System::Action @double, - System::Action @bool - ) - { - switch (this.Value) - { - case string value: - @string(value); - break; - case double value: - @double(value); - break; - case bool value: - @bool(value); - break; - default: - throw new ImageKitInvalidDataException( - "Data did not match any variant of SelectOption" - ); - } - } - - public T Match( - System::Func @string, - System::Func @double, - System::Func @bool - ) - { - return this.Value switch - { - string value => @string(value), - double value => @double(value), - bool value => @bool(value), - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of SelectOption" - ), - }; - } - - public void Validate() - { - if (this.Value is UnknownVariant) - { - throw new ImageKitInvalidDataException( - "Data did not match any variant of SelectOption" - ); - } - } - - record struct UnknownVariant(JsonElement value); -} - -sealed class SelectOptionConverter : JsonConverter -{ - public override SelectOption? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - List exceptions = []; - - try - { - var deserialized = JsonSerializer.Deserialize(ref reader, options); - if (deserialized != null) - { - return new SelectOption(deserialized); - } - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'string'", e) - ); - } - - try - { - return new SelectOption(JsonSerializer.Deserialize(ref reader, options)); - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'double'", e) - ); - } - - try - { - return new SelectOption(JsonSerializer.Deserialize(ref reader, options)); - } - catch (System::Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - exceptions.Add( - new ImageKitInvalidDataException("Data does not match union variant 'bool'", e) - ); - } - - throw new System::AggregateException(exceptions); - } - - public override void Write( - Utf8JsonWriter writer, - SelectOption value, - JsonSerializerOptions options - ) - { - object variant = value.Value; - JsonSerializer.Serialize(writer, variant, options); - } -} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs deleted file mode 100644 index d6ce2ec5..00000000 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/SelectedFieldsSchemaProperties/SelectedFieldsSchemaItemProperties/Type.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Exceptions; -using System = System; - -namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.IntersectionMember1Properties.DataProperties.SelectedFieldsSchemaProperties.SelectedFieldsSchemaItemProperties; - -/// -/// Type of the custom metadata field. -/// -[JsonConverter(typeof(TypeConverter))] -public enum Type -{ - Text, - Textarea, - Number, - Date, - Boolean, - SingleSelect, - MultiSelect, -} - -sealed class TypeConverter : JsonConverter -{ - public override Type Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "Text" => SelectedFieldsSchemaItemProperties.Type.Text, - "Textarea" => SelectedFieldsSchemaItemProperties.Type.Textarea, - "Number" => SelectedFieldsSchemaItemProperties.Type.Number, - "Date" => SelectedFieldsSchemaItemProperties.Type.Date, - "Boolean" => SelectedFieldsSchemaItemProperties.Type.Boolean, - "SingleSelect" => SelectedFieldsSchemaItemProperties.Type.SingleSelect, - "MultiSelect" => SelectedFieldsSchemaItemProperties.Type.MultiSelect, - _ => (Type)(-1), - }; - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonSerializer.Serialize( - writer, - value switch - { - SelectedFieldsSchemaItemProperties.Type.Text => "Text", - SelectedFieldsSchemaItemProperties.Type.Textarea => "Textarea", - SelectedFieldsSchemaItemProperties.Type.Number => "Number", - SelectedFieldsSchemaItemProperties.Type.Date => "Date", - SelectedFieldsSchemaItemProperties.Type.Boolean => "Boolean", - SelectedFieldsSchemaItemProperties.Type.SingleSelect => "SingleSelect", - SelectedFieldsSchemaItemProperties.Type.MultiSelect => "MultiSelect", - _ => throw new ImageKitInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/VersionInfo.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/VersionInfo.cs deleted file mode 100644 index ebc97415..00000000 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/DataProperties/VersionInfo.cs +++ /dev/null @@ -1,76 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties.DataProperties; - -/// -/// An object containing the file or file version's `id` (versionId) and `name`. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class VersionInfo : ModelBase, IFromRaw -{ - /// - /// Unique identifier of the file version. - /// - public string? ID - { - get - { - if (!this.Properties.TryGetValue("id", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["id"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Name of the file version. - /// - public string? Name - { - get - { - if (!this.Properties.TryGetValue("name", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["name"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.ID; - _ = this.Name; - } - - public VersionInfo() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - VersionInfo(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static VersionInfo FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/Request.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/Request.cs deleted file mode 100644 index c51ab264..00000000 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEventProperties/IntersectionMember1Properties/Request.cs +++ /dev/null @@ -1,79 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Webhooks.UploadPreTransformSuccessEventProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Request : ModelBase, IFromRaw -{ - /// - /// The requested pre-transformation string. - /// - public required string Transformation - { - get - { - if (!this.Properties.TryGetValue("transformation", out JsonElement element)) - throw new ArgumentOutOfRangeException( - "transformation", - "Missing required argument" - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("transformation"); - } - set - { - this.Properties["transformation"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Unique identifier for the originating request. - /// - public required string XRequestID - { - get - { - if (!this.Properties.TryGetValue("x_request_id", out JsonElement element)) - throw new ArgumentOutOfRangeException("x_request_id", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("x_request_id"); - } - set - { - this.Properties["x_request_id"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.Transformation; - _ = this.XRequestID; - } - - public Request() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Request(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Request FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEvent.cs b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEvent.cs deleted file mode 100644 index 2aa0d50e..00000000 --- a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEvent.cs +++ /dev/null @@ -1,189 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Core; -using Imagekit.Exceptions; -using Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.IntersectionMember1Properties; - -namespace Imagekit.Models.Webhooks; - -/// -/// Triggered when a new video transformation request is accepted for processing. -/// This event confirms that ImageKit has received and queued your transformation -/// request. Use this for debugging and tracking transformation lifecycle. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class VideoTransformationAcceptedEvent - : ModelBase, - IFromRaw -{ - /// - /// Unique identifier for the event. - /// - public required string ID - { - get - { - if (!this.Properties.TryGetValue("id", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'id' cannot be null", - new ArgumentOutOfRangeException("id", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'id' cannot be null", - new ArgumentNullException("id") - ); - } - set - { - this.Properties["id"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The type of webhook event. - /// - public required string Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentOutOfRangeException("type", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentNullException("type") - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Timestamp when the event was created in ISO8601 format. - /// - public required DateTime CreatedAt - { - get - { - if (!this.Properties.TryGetValue("created_at", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'created_at' cannot be null", - new ArgumentOutOfRangeException("created_at", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["created_at"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required Data Data - { - get - { - if (!this.Properties.TryGetValue("data", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'data' cannot be null", - new ArgumentOutOfRangeException("data", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'data' cannot be null", - new ArgumentNullException("data") - ); - } - set - { - this.Properties["data"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Information about the original request that triggered the video transformation. - /// - public required Request Request - { - get - { - if (!this.Properties.TryGetValue("request", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'request' cannot be null", - new ArgumentOutOfRangeException("request", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'request' cannot be null", - new ArgumentNullException("request") - ); - } - set - { - this.Properties["request"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public static implicit operator BaseWebhookEvent( - VideoTransformationAcceptedEvent videoTransformationAcceptedEvent - ) => - new() - { - ID = videoTransformationAcceptedEvent.ID, - Type = videoTransformationAcceptedEvent.Type, - }; - - public override void Validate() - { - _ = this.ID; - _ = this.Type; - _ = this.CreatedAt; - this.Data.Validate(); - this.Request.Validate(); - } - - public VideoTransformationAcceptedEvent() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - VideoTransformationAcceptedEvent(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static VideoTransformationAcceptedEvent FromRawUnchecked( - Dictionary properties - ) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1.cs b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1.cs deleted file mode 100644 index 7d8051ed..00000000 --- a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1.cs +++ /dev/null @@ -1,143 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Core; -using Imagekit.Exceptions; -using Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.IntersectionMember1Properties; - -namespace Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties; - -/// -/// Triggered when a new video transformation request is accepted for processing. -/// This event confirms that ImageKit has received and queued your transformation -/// request. Use this for debugging and tracking transformation lifecycle. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class IntersectionMember1 : ModelBase, IFromRaw -{ - /// - /// Timestamp when the event was created in ISO8601 format. - /// - public required DateTime CreatedAt - { - get - { - if (!this.Properties.TryGetValue("created_at", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'created_at' cannot be null", - new ArgumentOutOfRangeException("created_at", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["created_at"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required Data Data - { - get - { - if (!this.Properties.TryGetValue("data", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'data' cannot be null", - new ArgumentOutOfRangeException("data", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'data' cannot be null", - new ArgumentNullException("data") - ); - } - set - { - this.Properties["data"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Information about the original request that triggered the video transformation. - /// - public required Request Request - { - get - { - if (!this.Properties.TryGetValue("request", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'request' cannot be null", - new ArgumentOutOfRangeException("request", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'request' cannot be null", - new ArgumentNullException("request") - ); - } - set - { - this.Properties["request"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentOutOfRangeException("type", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.CreatedAt; - this.Data.Validate(); - this.Request.Validate(); - _ = this.Type; - } - - public IntersectionMember1() - { - this.Type = JsonSerializer.Deserialize("\"video.transformation.accepted\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - IntersectionMember1(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static IntersectionMember1 FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/Data.cs b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/Data.cs deleted file mode 100644 index cfb5ce1a..00000000 --- a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/Data.cs +++ /dev/null @@ -1,84 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using DataProperties = Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.DataProperties; - -namespace Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Data : ModelBase, IFromRaw -{ - /// - /// Information about the source video asset being transformed. - /// - public required DataProperties::Asset Asset - { - get - { - if (!this.Properties.TryGetValue("asset", out JsonElement element)) - throw new ArgumentOutOfRangeException("asset", "Missing required argument"); - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ) ?? throw new ArgumentNullException("asset"); - } - set - { - this.Properties["asset"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Base information about a video transformation request. - /// - public required DataProperties::Transformation Transformation - { - get - { - if (!this.Properties.TryGetValue("transformation", out JsonElement element)) - throw new ArgumentOutOfRangeException( - "transformation", - "Missing required argument" - ); - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ) ?? throw new ArgumentNullException("transformation"); - } - set - { - this.Properties["transformation"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Asset.Validate(); - this.Transformation.Validate(); - } - - public Data() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Data(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Data FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/Asset.cs b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/Asset.cs deleted file mode 100644 index fd5e4052..00000000 --- a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/Asset.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.DataProperties; - -/// -/// Information about the source video asset being transformed. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class Asset : ModelBase, IFromRaw -{ - /// - /// URL to download or access the source video file. - /// - public required string URL - { - get - { - if (!this.Properties.TryGetValue("url", out JsonElement element)) - throw new ArgumentOutOfRangeException("url", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("url"); - } - set - { - this.Properties["url"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.URL; - } - - public Asset() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Asset(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Asset FromRawUnchecked(Dictionary properties) - { - return new(properties); - } - - [SetsRequiredMembers] - public Asset(string url) - : this() - { - this.URL = url; - } -} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs deleted file mode 100644 index 47e78e69..00000000 --- a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using TransformationProperties = Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.DataProperties.TransformationProperties; - -namespace Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.DataProperties; - -/// -/// Base information about a video transformation request. -/// -[JsonConverter( - typeof(ModelConverter) -)] -public sealed record class Transformation - : ModelBase, - IFromRaw -{ - /// - /// Type of video transformation: - `video-transformation`: Standard video processing - /// (resize, format conversion, etc.) - `gif-to-video`: Convert animated GIF to - /// video format - `video-thumbnail`: Generate thumbnail image from video - /// - public required ApiEnum Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Configuration options for video transformations. - /// - public TransformationProperties::Options? Options - { - get - { - if (!this.Properties.TryGetValue("options", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["options"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Type.Validate(); - this.Options?.Validate(); - } - - public Transformation() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Transformation(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static global::Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.IntersectionMember1Properties.DataProperties.Transformation FromRawUnchecked( - Dictionary properties - ) - { - return new(properties); - } - - [SetsRequiredMembers] - public Transformation(ApiEnum type) - : this() - { - this.Type = type; - } -} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Options.cs b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Options.cs deleted file mode 100644 index 5e8335ee..00000000 --- a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Options.cs +++ /dev/null @@ -1,200 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Core; -using Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.IntersectionMember1Properties.DataProperties.TransformationProperties.OptionsProperties; - -namespace Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.IntersectionMember1Properties.DataProperties.TransformationProperties; - -/// -/// Configuration options for video transformations. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class Options : ModelBase, IFromRaw -{ - /// - /// Audio codec used for encoding (aac or opus). - /// - public ApiEnum? AudioCodec - { - get - { - if (!this.Properties.TryGetValue("audio_codec", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["audio_codec"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to automatically rotate the video based on metadata. - /// - public bool? AutoRotate - { - get - { - if (!this.Properties.TryGetValue("auto_rotate", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["auto_rotate"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Output format for the transformed video or thumbnail. - /// - public ApiEnum? Format - { - get - { - if (!this.Properties.TryGetValue("format", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["format"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Quality setting for the output video. - /// - public long? Quality - { - get - { - if (!this.Properties.TryGetValue("quality", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["quality"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Streaming protocol for adaptive bitrate streaming. - /// - public ApiEnum? StreamProtocol - { - get - { - if (!this.Properties.TryGetValue("stream_protocol", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["stream_protocol"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Array of quality representations for adaptive bitrate streaming. - /// - public List? Variants - { - get - { - if (!this.Properties.TryGetValue("variants", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["variants"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Video codec used for encoding (h264, vp9, or av1). - /// - public ApiEnum? VideoCodec - { - get - { - if (!this.Properties.TryGetValue("video_codec", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["video_codec"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.AudioCodec?.Validate(); - _ = this.AutoRotate; - this.Format?.Validate(); - _ = this.Quality; - this.StreamProtocol?.Validate(); - _ = this.Variants; - this.VideoCodec?.Validate(); - } - - public Options() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Options(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Options FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/AudioCodec.cs b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/AudioCodec.cs deleted file mode 100644 index c448b18b..00000000 --- a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/AudioCodec.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using System = System; - -namespace Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.DataProperties.TransformationProperties.OptionsProperties; - -/// -/// Audio codec used for encoding (aac or opus). -/// -[JsonConverter(typeof(AudioCodecConverter))] -public enum AudioCodec -{ - Aac, - Opus, -} - -sealed class AudioCodecConverter : JsonConverter -{ - public override AudioCodec Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "aac" => AudioCodec.Aac, - "opus" => AudioCodec.Opus, - _ => (AudioCodec)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - AudioCodec value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - AudioCodec.Aac => "aac", - AudioCodec.Opus => "opus", - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/Format.cs b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/Format.cs deleted file mode 100644 index 48a62714..00000000 --- a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/Format.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using System = System; - -namespace Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.DataProperties.TransformationProperties.OptionsProperties; - -/// -/// Output format for the transformed video or thumbnail. -/// -[JsonConverter(typeof(FormatConverter))] -public enum Format -{ - MP4, - Webm, - Jpg, - Png, - Webp, -} - -sealed class FormatConverter : JsonConverter -{ - public override Format Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "mp4" => Format.MP4, - "webm" => Format.Webm, - "jpg" => Format.Jpg, - "png" => Format.Png, - "webp" => Format.Webp, - _ => (Format)(-1), - }; - } - - public override void Write(Utf8JsonWriter writer, Format value, JsonSerializerOptions options) - { - JsonSerializer.Serialize( - writer, - value switch - { - Format.MP4 => "mp4", - Format.Webm => "webm", - Format.Jpg => "jpg", - Format.Png => "png", - Format.Webp => "webp", - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/StreamProtocol.cs b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/StreamProtocol.cs deleted file mode 100644 index cee1bc53..00000000 --- a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/StreamProtocol.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using System = System; - -namespace Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.DataProperties.TransformationProperties.OptionsProperties; - -/// -/// Streaming protocol for adaptive bitrate streaming. -/// -[JsonConverter(typeof(StreamProtocolConverter))] -public enum StreamProtocol -{ - Hls, - Dash, -} - -sealed class StreamProtocolConverter : JsonConverter -{ - public override StreamProtocol Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "HLS" => StreamProtocol.Hls, - "DASH" => StreamProtocol.Dash, - _ => (StreamProtocol)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - StreamProtocol value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - StreamProtocol.Hls => "HLS", - StreamProtocol.Dash => "DASH", - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/VideoCodec.cs b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/VideoCodec.cs deleted file mode 100644 index 1016e491..00000000 --- a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/VideoCodec.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using System = System; - -namespace Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.DataProperties.TransformationProperties.OptionsProperties; - -/// -/// Video codec used for encoding (h264, vp9, or av1). -/// -[JsonConverter(typeof(VideoCodecConverter))] -public enum VideoCodec -{ - H264, - Vp9, - Av1, -} - -sealed class VideoCodecConverter : JsonConverter -{ - public override VideoCodec Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "h264" => VideoCodec.H264, - "vp9" => VideoCodec.Vp9, - "av1" => VideoCodec.Av1, - _ => (VideoCodec)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - VideoCodec value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - VideoCodec.H264 => "h264", - VideoCodec.Vp9 => "vp9", - VideoCodec.Av1 => "av1", - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Type.cs b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Type.cs deleted file mode 100644 index 90f9cee2..00000000 --- a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Type.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using System = System; - -namespace Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties.DataProperties.TransformationProperties; - -/// -/// Type of video transformation: - `video-transformation`: Standard video processing -/// (resize, format conversion, etc.) - `gif-to-video`: Convert animated GIF to video -/// format - `video-thumbnail`: Generate thumbnail image from video -/// -[JsonConverter(typeof(TypeConverter))] -public enum Type -{ - VideoTransformation, - GifToVideo, - VideoThumbnail, -} - -sealed class TypeConverter : JsonConverter -{ - public override Type Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "video-transformation" => TransformationProperties.Type.VideoTransformation, - "gif-to-video" => TransformationProperties.Type.GifToVideo, - "video-thumbnail" => TransformationProperties.Type.VideoThumbnail, - _ => (Type)(-1), - }; - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonSerializer.Serialize( - writer, - value switch - { - TransformationProperties.Type.VideoTransformation => "video-transformation", - TransformationProperties.Type.GifToVideo => "gif-to-video", - TransformationProperties.Type.VideoThumbnail => "video-thumbnail", - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/Request.cs b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/Request.cs deleted file mode 100644 index 6ed7b7c9..00000000 --- a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEventProperties/IntersectionMember1Properties/Request.cs +++ /dev/null @@ -1,101 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Webhooks.VideoTransformationAcceptedEventProperties; - -/// -/// Information about the original request that triggered the video transformation. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class Request : ModelBase, IFromRaw -{ - /// - /// Full URL of the transformation request that was submitted. - /// - public required string URL - { - get - { - if (!this.Properties.TryGetValue("url", out JsonElement element)) - throw new ArgumentOutOfRangeException("url", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("url"); - } - set - { - this.Properties["url"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Unique identifier for the originating transformation request. - /// - public required string XRequestID - { - get - { - if (!this.Properties.TryGetValue("x_request_id", out JsonElement element)) - throw new ArgumentOutOfRangeException("x_request_id", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("x_request_id"); - } - set - { - this.Properties["x_request_id"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// User-Agent header from the original request that triggered the transformation. - /// - public string? UserAgent - { - get - { - if (!this.Properties.TryGetValue("user_agent", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["user_agent"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.URL; - _ = this.XRequestID; - _ = this.UserAgent; - } - - public Request() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Request(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Request FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEvent.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEvent.cs deleted file mode 100644 index 65008586..00000000 --- a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEvent.cs +++ /dev/null @@ -1,185 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Core; -using Imagekit.Exceptions; -using Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.IntersectionMember1Properties; - -namespace Imagekit.Models.Webhooks; - -/// -/// Triggered when an error occurs during video encoding. Listen to this webhook to -/// log error reasons and debug issues. Check your origin and URL endpoint settings -/// if the reason is related to download failure. For other errors, contact ImageKit -/// support. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class VideoTransformationErrorEvent - : ModelBase, - IFromRaw -{ - /// - /// Unique identifier for the event. - /// - public required string ID - { - get - { - if (!this.Properties.TryGetValue("id", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'id' cannot be null", - new ArgumentOutOfRangeException("id", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'id' cannot be null", - new ArgumentNullException("id") - ); - } - set - { - this.Properties["id"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The type of webhook event. - /// - public required string Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentOutOfRangeException("type", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentNullException("type") - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Timestamp when the event was created in ISO8601 format. - /// - public required DateTime CreatedAt - { - get - { - if (!this.Properties.TryGetValue("created_at", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'created_at' cannot be null", - new ArgumentOutOfRangeException("created_at", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["created_at"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required Data Data - { - get - { - if (!this.Properties.TryGetValue("data", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'data' cannot be null", - new ArgumentOutOfRangeException("data", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'data' cannot be null", - new ArgumentNullException("data") - ); - } - set - { - this.Properties["data"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Information about the original request that triggered the video transformation. - /// - public required Request Request - { - get - { - if (!this.Properties.TryGetValue("request", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'request' cannot be null", - new ArgumentOutOfRangeException("request", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'request' cannot be null", - new ArgumentNullException("request") - ); - } - set - { - this.Properties["request"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public static implicit operator BaseWebhookEvent( - VideoTransformationErrorEvent videoTransformationErrorEvent - ) => new() { ID = videoTransformationErrorEvent.ID, Type = videoTransformationErrorEvent.Type }; - - public override void Validate() - { - _ = this.ID; - _ = this.Type; - _ = this.CreatedAt; - this.Data.Validate(); - this.Request.Validate(); - } - - public VideoTransformationErrorEvent() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - VideoTransformationErrorEvent(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static VideoTransformationErrorEvent FromRawUnchecked( - Dictionary properties - ) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1.cs deleted file mode 100644 index bfa30916..00000000 --- a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1.cs +++ /dev/null @@ -1,144 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Core; -using Imagekit.Exceptions; -using Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.IntersectionMember1Properties; - -namespace Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties; - -/// -/// Triggered when an error occurs during video encoding. Listen to this webhook to -/// log error reasons and debug issues. Check your origin and URL endpoint settings -/// if the reason is related to download failure. For other errors, contact ImageKit -/// support. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class IntersectionMember1 : ModelBase, IFromRaw -{ - /// - /// Timestamp when the event was created in ISO8601 format. - /// - public required DateTime CreatedAt - { - get - { - if (!this.Properties.TryGetValue("created_at", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'created_at' cannot be null", - new ArgumentOutOfRangeException("created_at", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["created_at"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required Data Data - { - get - { - if (!this.Properties.TryGetValue("data", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'data' cannot be null", - new ArgumentOutOfRangeException("data", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'data' cannot be null", - new ArgumentNullException("data") - ); - } - set - { - this.Properties["data"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Information about the original request that triggered the video transformation. - /// - public required Request Request - { - get - { - if (!this.Properties.TryGetValue("request", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'request' cannot be null", - new ArgumentOutOfRangeException("request", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'request' cannot be null", - new ArgumentNullException("request") - ); - } - set - { - this.Properties["request"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentOutOfRangeException("type", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.CreatedAt; - this.Data.Validate(); - this.Request.Validate(); - _ = this.Type; - } - - public IntersectionMember1() - { - this.Type = JsonSerializer.Deserialize("\"video.transformation.error\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - IntersectionMember1(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static IntersectionMember1 FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/Data.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/Data.cs deleted file mode 100644 index f43d5aa1..00000000 --- a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/Data.cs +++ /dev/null @@ -1,81 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using DataProperties = Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.DataProperties; - -namespace Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Data : ModelBase, IFromRaw -{ - /// - /// Information about the source video asset being transformed. - /// - public required DataProperties::Asset Asset - { - get - { - if (!this.Properties.TryGetValue("asset", out JsonElement element)) - throw new ArgumentOutOfRangeException("asset", "Missing required argument"); - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ) ?? throw new ArgumentNullException("asset"); - } - set - { - this.Properties["asset"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required DataProperties::Transformation Transformation - { - get - { - if (!this.Properties.TryGetValue("transformation", out JsonElement element)) - throw new ArgumentOutOfRangeException( - "transformation", - "Missing required argument" - ); - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ) ?? throw new ArgumentNullException("transformation"); - } - set - { - this.Properties["transformation"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Asset.Validate(); - this.Transformation.Validate(); - } - - public Data() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Data(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Data FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/Asset.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/Asset.cs deleted file mode 100644 index 442afbf4..00000000 --- a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/Asset.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.DataProperties; - -/// -/// Information about the source video asset being transformed. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class Asset : ModelBase, IFromRaw -{ - /// - /// URL to download or access the source video file. - /// - public required string URL - { - get - { - if (!this.Properties.TryGetValue("url", out JsonElement element)) - throw new ArgumentOutOfRangeException("url", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("url"); - } - set - { - this.Properties["url"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.URL; - } - - public Asset() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Asset(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Asset FromRawUnchecked(Dictionary properties) - { - return new(properties); - } - - [SetsRequiredMembers] - public Asset(string url) - : this() - { - this.URL = url; - } -} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs deleted file mode 100644 index 101549eb..00000000 --- a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs +++ /dev/null @@ -1,121 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using TransformationProperties = Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.DataProperties.TransformationProperties; - -namespace Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.DataProperties; - -[JsonConverter( - typeof(ModelConverter) -)] -public sealed record class Transformation - : ModelBase, - IFromRaw -{ - /// - /// Type of video transformation: - `video-transformation`: Standard video processing - /// (resize, format conversion, etc.) - `gif-to-video`: Convert animated GIF to - /// video format - `video-thumbnail`: Generate thumbnail image from video - /// - public required ApiEnum Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Details about the transformation error. - /// - public TransformationProperties::Error? Error - { - get - { - if (!this.Properties.TryGetValue("error", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["error"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Configuration options for video transformations. - /// - public TransformationProperties::Options? Options - { - get - { - if (!this.Properties.TryGetValue("options", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["options"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Type.Validate(); - this.Error?.Validate(); - this.Options?.Validate(); - } - - public Transformation() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Transformation(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static global::Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.IntersectionMember1Properties.DataProperties.Transformation FromRawUnchecked( - Dictionary properties - ) - { - return new(properties); - } - - [SetsRequiredMembers] - public Transformation(ApiEnum type) - : this() - { - this.Type = type; - } -} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Error.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Error.cs deleted file mode 100644 index 9b2dbb8d..00000000 --- a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Error.cs +++ /dev/null @@ -1,71 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.DataProperties.TransformationProperties.ErrorProperties; -using System = System; - -namespace Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.DataProperties.TransformationProperties; - -/// -/// Details about the transformation error. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class Error : ModelBase, IFromRaw -{ - /// - /// Specific reason for the transformation failure: - `encoding_failed`: Error - /// during video encoding process - `download_failed`: Could not download source - /// video - `internal_server_error`: Unexpected server error - /// - public required ApiEnum Reason - { - get - { - if (!this.Properties.TryGetValue("reason", out JsonElement element)) - throw new System::ArgumentOutOfRangeException( - "reason", - "Missing required argument" - ); - - return JsonSerializer.Deserialize>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["reason"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Reason.Validate(); - } - - public Error() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Error(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Error FromRawUnchecked(Dictionary properties) - { - return new(properties); - } - - [SetsRequiredMembers] - public Error(ApiEnum reason) - : this() - { - this.Reason = reason; - } -} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/ErrorProperties/Reason.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/ErrorProperties/Reason.cs deleted file mode 100644 index f0995426..00000000 --- a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/ErrorProperties/Reason.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using System = System; - -namespace Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.DataProperties.TransformationProperties.ErrorProperties; - -/// -/// Specific reason for the transformation failure: - `encoding_failed`: Error during -/// video encoding process - `download_failed`: Could not download source video - -/// `internal_server_error`: Unexpected server error -/// -[JsonConverter(typeof(ReasonConverter))] -public enum Reason -{ - EncodingFailed, - DownloadFailed, - InternalServerError, -} - -sealed class ReasonConverter : JsonConverter -{ - public override Reason Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "encoding_failed" => Reason.EncodingFailed, - "download_failed" => Reason.DownloadFailed, - "internal_server_error" => Reason.InternalServerError, - _ => (Reason)(-1), - }; - } - - public override void Write(Utf8JsonWriter writer, Reason value, JsonSerializerOptions options) - { - JsonSerializer.Serialize( - writer, - value switch - { - Reason.EncodingFailed => "encoding_failed", - Reason.DownloadFailed => "download_failed", - Reason.InternalServerError => "internal_server_error", - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Options.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Options.cs deleted file mode 100644 index d6b460e0..00000000 --- a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Options.cs +++ /dev/null @@ -1,200 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Core; -using Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.IntersectionMember1Properties.DataProperties.TransformationProperties.OptionsProperties; - -namespace Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.IntersectionMember1Properties.DataProperties.TransformationProperties; - -/// -/// Configuration options for video transformations. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class Options : ModelBase, IFromRaw -{ - /// - /// Audio codec used for encoding (aac or opus). - /// - public ApiEnum? AudioCodec - { - get - { - if (!this.Properties.TryGetValue("audio_codec", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["audio_codec"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to automatically rotate the video based on metadata. - /// - public bool? AutoRotate - { - get - { - if (!this.Properties.TryGetValue("auto_rotate", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["auto_rotate"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Output format for the transformed video or thumbnail. - /// - public ApiEnum? Format - { - get - { - if (!this.Properties.TryGetValue("format", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["format"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Quality setting for the output video. - /// - public long? Quality - { - get - { - if (!this.Properties.TryGetValue("quality", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["quality"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Streaming protocol for adaptive bitrate streaming. - /// - public ApiEnum? StreamProtocol - { - get - { - if (!this.Properties.TryGetValue("stream_protocol", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["stream_protocol"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Array of quality representations for adaptive bitrate streaming. - /// - public List? Variants - { - get - { - if (!this.Properties.TryGetValue("variants", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["variants"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Video codec used for encoding (h264, vp9, or av1). - /// - public ApiEnum? VideoCodec - { - get - { - if (!this.Properties.TryGetValue("video_codec", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["video_codec"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.AudioCodec?.Validate(); - _ = this.AutoRotate; - this.Format?.Validate(); - _ = this.Quality; - this.StreamProtocol?.Validate(); - _ = this.Variants; - this.VideoCodec?.Validate(); - } - - public Options() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Options(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Options FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/AudioCodec.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/AudioCodec.cs deleted file mode 100644 index 03cfe515..00000000 --- a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/AudioCodec.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using System = System; - -namespace Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.DataProperties.TransformationProperties.OptionsProperties; - -/// -/// Audio codec used for encoding (aac or opus). -/// -[JsonConverter(typeof(AudioCodecConverter))] -public enum AudioCodec -{ - Aac, - Opus, -} - -sealed class AudioCodecConverter : JsonConverter -{ - public override AudioCodec Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "aac" => AudioCodec.Aac, - "opus" => AudioCodec.Opus, - _ => (AudioCodec)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - AudioCodec value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - AudioCodec.Aac => "aac", - AudioCodec.Opus => "opus", - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/Format.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/Format.cs deleted file mode 100644 index 0955e08d..00000000 --- a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/Format.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using System = System; - -namespace Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.DataProperties.TransformationProperties.OptionsProperties; - -/// -/// Output format for the transformed video or thumbnail. -/// -[JsonConverter(typeof(FormatConverter))] -public enum Format -{ - MP4, - Webm, - Jpg, - Png, - Webp, -} - -sealed class FormatConverter : JsonConverter -{ - public override Format Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "mp4" => Format.MP4, - "webm" => Format.Webm, - "jpg" => Format.Jpg, - "png" => Format.Png, - "webp" => Format.Webp, - _ => (Format)(-1), - }; - } - - public override void Write(Utf8JsonWriter writer, Format value, JsonSerializerOptions options) - { - JsonSerializer.Serialize( - writer, - value switch - { - Format.MP4 => "mp4", - Format.Webm => "webm", - Format.Jpg => "jpg", - Format.Png => "png", - Format.Webp => "webp", - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/StreamProtocol.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/StreamProtocol.cs deleted file mode 100644 index 53822ce7..00000000 --- a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/StreamProtocol.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using System = System; - -namespace Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.DataProperties.TransformationProperties.OptionsProperties; - -/// -/// Streaming protocol for adaptive bitrate streaming. -/// -[JsonConverter(typeof(StreamProtocolConverter))] -public enum StreamProtocol -{ - Hls, - Dash, -} - -sealed class StreamProtocolConverter : JsonConverter -{ - public override StreamProtocol Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "HLS" => StreamProtocol.Hls, - "DASH" => StreamProtocol.Dash, - _ => (StreamProtocol)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - StreamProtocol value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - StreamProtocol.Hls => "HLS", - StreamProtocol.Dash => "DASH", - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/VideoCodec.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/VideoCodec.cs deleted file mode 100644 index f6d33a3e..00000000 --- a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/VideoCodec.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using System = System; - -namespace Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.DataProperties.TransformationProperties.OptionsProperties; - -/// -/// Video codec used for encoding (h264, vp9, or av1). -/// -[JsonConverter(typeof(VideoCodecConverter))] -public enum VideoCodec -{ - H264, - Vp9, - Av1, -} - -sealed class VideoCodecConverter : JsonConverter -{ - public override VideoCodec Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "h264" => VideoCodec.H264, - "vp9" => VideoCodec.Vp9, - "av1" => VideoCodec.Av1, - _ => (VideoCodec)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - VideoCodec value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - VideoCodec.H264 => "h264", - VideoCodec.Vp9 => "vp9", - VideoCodec.Av1 => "av1", - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Type.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Type.cs deleted file mode 100644 index 8823f849..00000000 --- a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Type.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using System = System; - -namespace Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties.DataProperties.TransformationProperties; - -/// -/// Type of video transformation: - `video-transformation`: Standard video processing -/// (resize, format conversion, etc.) - `gif-to-video`: Convert animated GIF to video -/// format - `video-thumbnail`: Generate thumbnail image from video -/// -[JsonConverter(typeof(TypeConverter))] -public enum Type -{ - VideoTransformation, - GifToVideo, - VideoThumbnail, -} - -sealed class TypeConverter : JsonConverter -{ - public override Type Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "video-transformation" => TransformationProperties.Type.VideoTransformation, - "gif-to-video" => TransformationProperties.Type.GifToVideo, - "video-thumbnail" => TransformationProperties.Type.VideoThumbnail, - _ => (Type)(-1), - }; - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonSerializer.Serialize( - writer, - value switch - { - TransformationProperties.Type.VideoTransformation => "video-transformation", - TransformationProperties.Type.GifToVideo => "gif-to-video", - TransformationProperties.Type.VideoThumbnail => "video-thumbnail", - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/Request.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/Request.cs deleted file mode 100644 index f18d4bde..00000000 --- a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEventProperties/IntersectionMember1Properties/Request.cs +++ /dev/null @@ -1,101 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Webhooks.VideoTransformationErrorEventProperties; - -/// -/// Information about the original request that triggered the video transformation. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class Request : ModelBase, IFromRaw -{ - /// - /// Full URL of the transformation request that was submitted. - /// - public required string URL - { - get - { - if (!this.Properties.TryGetValue("url", out JsonElement element)) - throw new ArgumentOutOfRangeException("url", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("url"); - } - set - { - this.Properties["url"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Unique identifier for the originating transformation request. - /// - public required string XRequestID - { - get - { - if (!this.Properties.TryGetValue("x_request_id", out JsonElement element)) - throw new ArgumentOutOfRangeException("x_request_id", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("x_request_id"); - } - set - { - this.Properties["x_request_id"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// User-Agent header from the original request that triggered the transformation. - /// - public string? UserAgent - { - get - { - if (!this.Properties.TryGetValue("user_agent", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["user_agent"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.URL; - _ = this.XRequestID; - _ = this.UserAgent; - } - - public Request() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Request(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Request FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEvent.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEvent.cs deleted file mode 100644 index 25bba269..00000000 --- a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEvent.cs +++ /dev/null @@ -1,207 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Core; -using Imagekit.Exceptions; -using Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.IntersectionMember1Properties; - -namespace Imagekit.Models.Webhooks; - -/// -/// Triggered when video encoding is finished and the transformed resource is ready -/// to be served. This is the key event to listen for - update your database or CMS -/// flags when you receive this so your application can start showing the transformed -/// video to users. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class VideoTransformationReadyEvent - : ModelBase, - IFromRaw -{ - /// - /// Unique identifier for the event. - /// - public required string ID - { - get - { - if (!this.Properties.TryGetValue("id", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'id' cannot be null", - new ArgumentOutOfRangeException("id", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'id' cannot be null", - new ArgumentNullException("id") - ); - } - set - { - this.Properties["id"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// The type of webhook event. - /// - public required string Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentOutOfRangeException("type", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentNullException("type") - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Timestamp when the event was created in ISO8601 format. - /// - public required DateTime CreatedAt - { - get - { - if (!this.Properties.TryGetValue("created_at", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'created_at' cannot be null", - new ArgumentOutOfRangeException("created_at", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["created_at"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required Data Data - { - get - { - if (!this.Properties.TryGetValue("data", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'data' cannot be null", - new ArgumentOutOfRangeException("data", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'data' cannot be null", - new ArgumentNullException("data") - ); - } - set - { - this.Properties["data"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Information about the original request that triggered the video transformation. - /// - public required Request Request - { - get - { - if (!this.Properties.TryGetValue("request", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'request' cannot be null", - new ArgumentOutOfRangeException("request", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'request' cannot be null", - new ArgumentNullException("request") - ); - } - set - { - this.Properties["request"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Performance metrics for the transformation process. - /// - public Timings? Timings - { - get - { - if (!this.Properties.TryGetValue("timings", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["timings"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public static implicit operator BaseWebhookEvent( - VideoTransformationReadyEvent videoTransformationReadyEvent - ) => new() { ID = videoTransformationReadyEvent.ID, Type = videoTransformationReadyEvent.Type }; - - public override void Validate() - { - _ = this.ID; - _ = this.Type; - _ = this.CreatedAt; - this.Data.Validate(); - this.Request.Validate(); - this.Timings?.Validate(); - } - - public VideoTransformationReadyEvent() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - VideoTransformationReadyEvent(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static VideoTransformationReadyEvent FromRawUnchecked( - Dictionary properties - ) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1.cs deleted file mode 100644 index 3cbd4061..00000000 --- a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1.cs +++ /dev/null @@ -1,166 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Core; -using Imagekit.Exceptions; -using Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.IntersectionMember1Properties; - -namespace Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties; - -/// -/// Triggered when video encoding is finished and the transformed resource is ready -/// to be served. This is the key event to listen for - update your database or CMS -/// flags when you receive this so your application can start showing the transformed -/// video to users. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class IntersectionMember1 : ModelBase, IFromRaw -{ - /// - /// Timestamp when the event was created in ISO8601 format. - /// - public required DateTime CreatedAt - { - get - { - if (!this.Properties.TryGetValue("created_at", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'created_at' cannot be null", - new ArgumentOutOfRangeException("created_at", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["created_at"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required Data Data - { - get - { - if (!this.Properties.TryGetValue("data", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'data' cannot be null", - new ArgumentOutOfRangeException("data", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'data' cannot be null", - new ArgumentNullException("data") - ); - } - set - { - this.Properties["data"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Information about the original request that triggered the video transformation. - /// - public required Request Request - { - get - { - if (!this.Properties.TryGetValue("request", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'request' cannot be null", - new ArgumentOutOfRangeException("request", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException( - "'request' cannot be null", - new ArgumentNullException("request") - ); - } - set - { - this.Properties["request"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public JsonElement Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ImageKitInvalidDataException( - "'type' cannot be null", - new ArgumentOutOfRangeException("type", "Missing required argument") - ); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Performance metrics for the transformation process. - /// - public Timings? Timings - { - get - { - if (!this.Properties.TryGetValue("timings", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["timings"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.CreatedAt; - this.Data.Validate(); - this.Request.Validate(); - _ = this.Type; - this.Timings?.Validate(); - } - - public IntersectionMember1() - { - this.Type = JsonSerializer.Deserialize("\"video.transformation.ready\""); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - IntersectionMember1(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static IntersectionMember1 FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/Data.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/Data.cs deleted file mode 100644 index af2b0005..00000000 --- a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/Data.cs +++ /dev/null @@ -1,81 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using DataProperties = Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.IntersectionMember1Properties.DataProperties; - -namespace Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.IntersectionMember1Properties; - -[JsonConverter(typeof(ModelConverter))] -public sealed record class Data : ModelBase, IFromRaw -{ - /// - /// Information about the source video asset being transformed. - /// - public required DataProperties::Asset Asset - { - get - { - if (!this.Properties.TryGetValue("asset", out JsonElement element)) - throw new ArgumentOutOfRangeException("asset", "Missing required argument"); - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ) ?? throw new ArgumentNullException("asset"); - } - set - { - this.Properties["asset"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public required DataProperties::Transformation Transformation - { - get - { - if (!this.Properties.TryGetValue("transformation", out JsonElement element)) - throw new ArgumentOutOfRangeException( - "transformation", - "Missing required argument" - ); - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ) ?? throw new ArgumentNullException("transformation"); - } - set - { - this.Properties["transformation"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Asset.Validate(); - this.Transformation.Validate(); - } - - public Data() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Data(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Data FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/Asset.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/Asset.cs deleted file mode 100644 index 3644c1f7..00000000 --- a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/Asset.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties; - -/// -/// Information about the source video asset being transformed. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class Asset : ModelBase, IFromRaw -{ - /// - /// URL to download or access the source video file. - /// - public required string URL - { - get - { - if (!this.Properties.TryGetValue("url", out JsonElement element)) - throw new ArgumentOutOfRangeException("url", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("url"); - } - set - { - this.Properties["url"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.URL; - } - - public Asset() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Asset(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Asset FromRawUnchecked(Dictionary properties) - { - return new(properties); - } - - [SetsRequiredMembers] - public Asset(string url) - : this() - { - this.URL = url; - } -} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs deleted file mode 100644 index fd7b253d..00000000 --- a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/Transformation.cs +++ /dev/null @@ -1,121 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using TransformationProperties = Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties.TransformationProperties; - -namespace Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties; - -[JsonConverter( - typeof(ModelConverter) -)] -public sealed record class Transformation - : ModelBase, - IFromRaw -{ - /// - /// Type of video transformation: - `video-transformation`: Standard video processing - /// (resize, format conversion, etc.) - `gif-to-video`: Convert animated GIF to - /// video format - `video-thumbnail`: Generate thumbnail image from video - /// - public required ApiEnum Type - { - get - { - if (!this.Properties.TryGetValue("type", out JsonElement element)) - throw new ArgumentOutOfRangeException("type", "Missing required argument"); - - return JsonSerializer.Deserialize>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["type"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Configuration options for video transformations. - /// - public TransformationProperties::Options? Options - { - get - { - if (!this.Properties.TryGetValue("options", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["options"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Information about the transformed output video. - /// - public TransformationProperties::Output? Output - { - get - { - if (!this.Properties.TryGetValue("output", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["output"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.Type.Validate(); - this.Options?.Validate(); - this.Output?.Validate(); - } - - public Transformation() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Transformation(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static global::Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.IntersectionMember1Properties.DataProperties.Transformation FromRawUnchecked( - Dictionary properties - ) - { - return new(properties); - } - - [SetsRequiredMembers] - public Transformation(ApiEnum type) - : this() - { - this.Type = type; - } -} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Options.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Options.cs deleted file mode 100644 index 934fd73e..00000000 --- a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Options.cs +++ /dev/null @@ -1,200 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Core; -using Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.IntersectionMember1Properties.DataProperties.TransformationProperties.OptionsProperties; - -namespace Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.IntersectionMember1Properties.DataProperties.TransformationProperties; - -/// -/// Configuration options for video transformations. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class Options : ModelBase, IFromRaw -{ - /// - /// Audio codec used for encoding (aac or opus). - /// - public ApiEnum? AudioCodec - { - get - { - if (!this.Properties.TryGetValue("audio_codec", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["audio_codec"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Whether to automatically rotate the video based on metadata. - /// - public bool? AutoRotate - { - get - { - if (!this.Properties.TryGetValue("auto_rotate", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["auto_rotate"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Output format for the transformed video or thumbnail. - /// - public ApiEnum? Format - { - get - { - if (!this.Properties.TryGetValue("format", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["format"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Quality setting for the output video. - /// - public long? Quality - { - get - { - if (!this.Properties.TryGetValue("quality", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["quality"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Streaming protocol for adaptive bitrate streaming. - /// - public ApiEnum? StreamProtocol - { - get - { - if (!this.Properties.TryGetValue("stream_protocol", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["stream_protocol"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Array of quality representations for adaptive bitrate streaming. - /// - public List? Variants - { - get - { - if (!this.Properties.TryGetValue("variants", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["variants"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Video codec used for encoding (h264, vp9, or av1). - /// - public ApiEnum? VideoCodec - { - get - { - if (!this.Properties.TryGetValue("video_codec", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize?>( - element, - ModelBase.SerializerOptions - ); - } - set - { - this.Properties["video_codec"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - this.AudioCodec?.Validate(); - _ = this.AutoRotate; - this.Format?.Validate(); - _ = this.Quality; - this.StreamProtocol?.Validate(); - _ = this.Variants; - this.VideoCodec?.Validate(); - } - - public Options() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Options(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Options FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/AudioCodec.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/AudioCodec.cs deleted file mode 100644 index b81c797b..00000000 --- a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/AudioCodec.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using System = System; - -namespace Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties.TransformationProperties.OptionsProperties; - -/// -/// Audio codec used for encoding (aac or opus). -/// -[JsonConverter(typeof(AudioCodecConverter))] -public enum AudioCodec -{ - Aac, - Opus, -} - -sealed class AudioCodecConverter : JsonConverter -{ - public override AudioCodec Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "aac" => AudioCodec.Aac, - "opus" => AudioCodec.Opus, - _ => (AudioCodec)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - AudioCodec value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - AudioCodec.Aac => "aac", - AudioCodec.Opus => "opus", - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/Format.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/Format.cs deleted file mode 100644 index 3bb8aace..00000000 --- a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/Format.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using System = System; - -namespace Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties.TransformationProperties.OptionsProperties; - -/// -/// Output format for the transformed video or thumbnail. -/// -[JsonConverter(typeof(FormatConverter))] -public enum Format -{ - MP4, - Webm, - Jpg, - Png, - Webp, -} - -sealed class FormatConverter : JsonConverter -{ - public override Format Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "mp4" => Format.MP4, - "webm" => Format.Webm, - "jpg" => Format.Jpg, - "png" => Format.Png, - "webp" => Format.Webp, - _ => (Format)(-1), - }; - } - - public override void Write(Utf8JsonWriter writer, Format value, JsonSerializerOptions options) - { - JsonSerializer.Serialize( - writer, - value switch - { - Format.MP4 => "mp4", - Format.Webm => "webm", - Format.Jpg => "jpg", - Format.Png => "png", - Format.Webp => "webp", - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/StreamProtocol.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/StreamProtocol.cs deleted file mode 100644 index e2492fe8..00000000 --- a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/StreamProtocol.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using System = System; - -namespace Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties.TransformationProperties.OptionsProperties; - -/// -/// Streaming protocol for adaptive bitrate streaming. -/// -[JsonConverter(typeof(StreamProtocolConverter))] -public enum StreamProtocol -{ - Hls, - Dash, -} - -sealed class StreamProtocolConverter : JsonConverter -{ - public override StreamProtocol Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "HLS" => StreamProtocol.Hls, - "DASH" => StreamProtocol.Dash, - _ => (StreamProtocol)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - StreamProtocol value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - StreamProtocol.Hls => "HLS", - StreamProtocol.Dash => "DASH", - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/VideoCodec.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/VideoCodec.cs deleted file mode 100644 index 0baacb16..00000000 --- a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OptionsProperties/VideoCodec.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using System = System; - -namespace Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties.TransformationProperties.OptionsProperties; - -/// -/// Video codec used for encoding (h264, vp9, or av1). -/// -[JsonConverter(typeof(VideoCodecConverter))] -public enum VideoCodec -{ - H264, - Vp9, - Av1, -} - -sealed class VideoCodecConverter : JsonConverter -{ - public override VideoCodec Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "h264" => VideoCodec.H264, - "vp9" => VideoCodec.Vp9, - "av1" => VideoCodec.Av1, - _ => (VideoCodec)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - VideoCodec value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - VideoCodec.H264 => "h264", - VideoCodec.Vp9 => "vp9", - VideoCodec.Av1 => "av1", - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Output.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Output.cs deleted file mode 100644 index 9b2d5adf..00000000 --- a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Output.cs +++ /dev/null @@ -1,86 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; -using Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties.TransformationProperties.OutputProperties; -using System = System; - -namespace Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties.TransformationProperties; - -/// -/// Information about the transformed output video. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class Output : ModelBase, IFromRaw -{ - /// - /// URL to access the transformed video. - /// - public required string URL - { - get - { - if (!this.Properties.TryGetValue("url", out JsonElement element)) - throw new System::ArgumentOutOfRangeException("url", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new System::ArgumentNullException("url"); - } - set - { - this.Properties["url"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Metadata of the output video file. - /// - public VideoMetadata? VideoMetadata - { - get - { - if (!this.Properties.TryGetValue("video_metadata", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["video_metadata"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.URL; - this.VideoMetadata?.Validate(); - } - - public Output() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Output(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Output FromRawUnchecked(Dictionary properties) - { - return new(properties); - } - - [SetsRequiredMembers] - public Output(string url) - : this() - { - this.URL = url; - } -} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OutputProperties/VideoMetadata.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OutputProperties/VideoMetadata.cs deleted file mode 100644 index 32d2e85e..00000000 --- a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/OutputProperties/VideoMetadata.cs +++ /dev/null @@ -1,121 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties.TransformationProperties.OutputProperties; - -/// -/// Metadata of the output video file. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class VideoMetadata : ModelBase, IFromRaw -{ - /// - /// Bitrate of the output video in bits per second. - /// - public required long Bitrate - { - get - { - if (!this.Properties.TryGetValue("bitrate", out JsonElement element)) - throw new ArgumentOutOfRangeException("bitrate", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["bitrate"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Duration of the output video in seconds. - /// - public required double Duration - { - get - { - if (!this.Properties.TryGetValue("duration", out JsonElement element)) - throw new ArgumentOutOfRangeException("duration", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["duration"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Height of the output video in pixels. - /// - public required long Height - { - get - { - if (!this.Properties.TryGetValue("height", out JsonElement element)) - throw new ArgumentOutOfRangeException("height", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["height"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Width of the output video in pixels. - /// - public required long Width - { - get - { - if (!this.Properties.TryGetValue("width", out JsonElement element)) - throw new ArgumentOutOfRangeException("width", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["width"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.Bitrate; - _ = this.Duration; - _ = this.Height; - _ = this.Width; - } - - public VideoMetadata() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - VideoMetadata(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static VideoMetadata FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Type.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Type.cs deleted file mode 100644 index dc9c5729..00000000 --- a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/DataProperties/TransformationProperties/Type.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using System = System; - -namespace Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties.DataProperties.TransformationProperties; - -/// -/// Type of video transformation: - `video-transformation`: Standard video processing -/// (resize, format conversion, etc.) - `gif-to-video`: Convert animated GIF to video -/// format - `video-thumbnail`: Generate thumbnail image from video -/// -[JsonConverter(typeof(TypeConverter))] -public enum Type -{ - VideoTransformation, - GifToVideo, - VideoThumbnail, -} - -sealed class TypeConverter : JsonConverter -{ - public override Type Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "video-transformation" => TransformationProperties.Type.VideoTransformation, - "gif-to-video" => TransformationProperties.Type.GifToVideo, - "video-thumbnail" => TransformationProperties.Type.VideoThumbnail, - _ => (Type)(-1), - }; - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonSerializer.Serialize( - writer, - value switch - { - TransformationProperties.Type.VideoTransformation => "video-transformation", - TransformationProperties.Type.GifToVideo => "gif-to-video", - TransformationProperties.Type.VideoThumbnail => "video-thumbnail", - _ => throw new System::ArgumentOutOfRangeException(nameof(value)), - }, - options - ); - } -} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/Request.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/Request.cs deleted file mode 100644 index b22d60ea..00000000 --- a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/Request.cs +++ /dev/null @@ -1,101 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties; - -/// -/// Information about the original request that triggered the video transformation. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class Request : ModelBase, IFromRaw -{ - /// - /// Full URL of the transformation request that was submitted. - /// - public required string URL - { - get - { - if (!this.Properties.TryGetValue("url", out JsonElement element)) - throw new ArgumentOutOfRangeException("url", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("url"); - } - set - { - this.Properties["url"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Unique identifier for the originating transformation request. - /// - public required string XRequestID - { - get - { - if (!this.Properties.TryGetValue("x_request_id", out JsonElement element)) - throw new ArgumentOutOfRangeException("x_request_id", "Missing required argument"); - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ArgumentNullException("x_request_id"); - } - set - { - this.Properties["x_request_id"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// User-Agent header from the original request that triggered the transformation. - /// - public string? UserAgent - { - get - { - if (!this.Properties.TryGetValue("user_agent", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["user_agent"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.URL; - _ = this.XRequestID; - _ = this.UserAgent; - } - - public Request() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Request(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Request FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/Timings.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/Timings.cs deleted file mode 100644 index 3f5cedd3..00000000 --- a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEventProperties/IntersectionMember1Properties/Timings.cs +++ /dev/null @@ -1,77 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Imagekit.Models.Webhooks.VideoTransformationReadyEventProperties; - -/// -/// Performance metrics for the transformation process. -/// -[JsonConverter(typeof(ModelConverter))] -public sealed record class Timings : ModelBase, IFromRaw -{ - /// - /// Time spent downloading the source video from your origin or media library, - /// in milliseconds. - /// - public long? DownloadDuration - { - get - { - if (!this.Properties.TryGetValue("download_duration", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["download_duration"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - /// - /// Time spent encoding the video, in milliseconds. - /// - public long? EncodingDuration - { - get - { - if (!this.Properties.TryGetValue("encoding_duration", out JsonElement element)) - return null; - - return JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - set - { - this.Properties["encoding_duration"] = JsonSerializer.SerializeToElement( - value, - ModelBase.SerializerOptions - ); - } - } - - public override void Validate() - { - _ = this.DownloadDuration; - _ = this.EncodingDuration; - } - - public Timings() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Timings(Dictionary properties) - { - Properties = properties; - } -#pragma warning restore CS8618 - - public static Timings FromRawUnchecked(Dictionary properties) - { - return new(properties); - } -} diff --git a/src/Imagekit/Services/Accounts/AccountService.cs b/src/Imagekit/Services/Accounts/AccountService.cs deleted file mode 100644 index b50326fe..00000000 --- a/src/Imagekit/Services/Accounts/AccountService.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using Imagekit.Services.Accounts.Origins; -using Imagekit.Services.Accounts.URLEndpoints; -using Imagekit.Services.Accounts.Usage; - -namespace Imagekit.Services.Accounts; - -public sealed class AccountService : IAccountService -{ - public AccountService(IImageKitClient client) - { - _usage = new(() => new UsageService(client)); - _origins = new(() => new OriginService(client)); - _urlEndpoints = new(() => new URLEndpointService(client)); - } - - readonly Lazy _usage; - public IUsageService Usage - { - get { return _usage.Value; } - } - - readonly Lazy _origins; - public IOriginService Origins - { - get { return _origins.Value; } - } - - readonly Lazy _urlEndpoints; - public IURLEndpointService URLEndpoints - { - get { return _urlEndpoints.Value; } - } -} diff --git a/src/Imagekit/Services/Accounts/IAccountService.cs b/src/Imagekit/Services/Accounts/IAccountService.cs deleted file mode 100644 index 918c2e42..00000000 --- a/src/Imagekit/Services/Accounts/IAccountService.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Imagekit.Services.Accounts.Origins; -using Imagekit.Services.Accounts.URLEndpoints; -using Imagekit.Services.Accounts.Usage; - -namespace Imagekit.Services.Accounts; - -public interface IAccountService -{ - IUsageService Usage { get; } - - IOriginService Origins { get; } - - IURLEndpointService URLEndpoints { get; } -} diff --git a/src/Imagekit/Services/Accounts/Origins/IOriginService.cs b/src/Imagekit/Services/Accounts/Origins/IOriginService.cs deleted file mode 100644 index 4882a4b8..00000000 --- a/src/Imagekit/Services/Accounts/Origins/IOriginService.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System.Collections.Generic; -using System.Threading.Tasks; -using Imagekit.Models.Accounts.Origins; - -namespace Imagekit.Services.Accounts.Origins; - -public interface IOriginService -{ - /// - /// **Note:** This API is currently in beta. Creates a new origin and returns - /// the origin object. - /// - Task Create(OriginCreateParams parameters); - - /// - /// **Note:** This API is currently in beta. Updates the origin identified - /// by `id` and returns the updated origin object. - /// - Task Update(OriginUpdateParams parameters); - - /// - /// **Note:** This API is currently in beta. Returns an array of all configured - /// origins for the current account. - /// - Task> List(OriginListParams? parameters = null); - - /// - /// **Note:** This API is currently in beta. Permanently removes the origin - /// identified by `id`. If the origin is in use by any URL‑endpoints, the API - /// will return an error. - /// - Task Delete(OriginDeleteParams parameters); - - /// - /// **Note:** This API is currently in beta. Retrieves the origin identified - /// by `id`. - /// - Task Get(OriginGetParams parameters); -} diff --git a/src/Imagekit/Services/Accounts/Origins/OriginService.cs b/src/Imagekit/Services/Accounts/Origins/OriginService.cs deleted file mode 100644 index f19b6a2a..00000000 --- a/src/Imagekit/Services/Accounts/Origins/OriginService.cs +++ /dev/null @@ -1,98 +0,0 @@ -using System.Collections.Generic; -using System.Net.Http; -using System.Threading.Tasks; -using Imagekit.Core; -using Imagekit.Models.Accounts.Origins; - -namespace Imagekit.Services.Accounts.Origins; - -public sealed class OriginService : IOriginService -{ - readonly IImageKitClient _client; - - public OriginService(IImageKitClient client) - { - _client = client; - } - - public async Task Create(OriginCreateParams parameters) - { - HttpRequest request = new() - { - Method = HttpMethod.Post, - Params = parameters, - }; - using var response = await this._client.Execute(request).ConfigureAwait(false); - var originResponse = await response.Deserialize().ConfigureAwait(false); - if (this._client.ResponseValidation) - { - originResponse.Validate(); - } - return originResponse; - } - - public async Task Update(OriginUpdateParams parameters) - { - HttpRequest request = new() - { - Method = HttpMethod.Put, - Params = parameters, - }; - using var response = await this._client.Execute(request).ConfigureAwait(false); - var originResponse = await response.Deserialize().ConfigureAwait(false); - if (this._client.ResponseValidation) - { - originResponse.Validate(); - } - return originResponse; - } - - public async Task> List(OriginListParams? parameters = null) - { - parameters ??= new(); - - HttpRequest request = new() - { - Method = HttpMethod.Get, - Params = parameters, - }; - using var response = await this._client.Execute(request).ConfigureAwait(false); - var originResponses = await response - .Deserialize>() - .ConfigureAwait(false); - if (this._client.ResponseValidation) - { - foreach (var item in originResponses) - { - item.Validate(); - } - } - return originResponses; - } - - public async Task Delete(OriginDeleteParams parameters) - { - HttpRequest request = new() - { - Method = HttpMethod.Delete, - Params = parameters, - }; - using var response = await this._client.Execute(request).ConfigureAwait(false); - } - - public async Task Get(OriginGetParams parameters) - { - HttpRequest request = new() - { - Method = HttpMethod.Get, - Params = parameters, - }; - using var response = await this._client.Execute(request).ConfigureAwait(false); - var originResponse = await response.Deserialize().ConfigureAwait(false); - if (this._client.ResponseValidation) - { - originResponse.Validate(); - } - return originResponse; - } -} diff --git a/src/Imagekit/Services/Accounts/URLEndpoints/IURLEndpointService.cs b/src/Imagekit/Services/Accounts/URLEndpoints/IURLEndpointService.cs deleted file mode 100644 index dbf0dd4c..00000000 --- a/src/Imagekit/Services/Accounts/URLEndpoints/IURLEndpointService.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System.Collections.Generic; -using System.Threading.Tasks; -using Imagekit.Models.Accounts.URLEndpoints; - -namespace Imagekit.Services.Accounts.URLEndpoints; - -public interface IURLEndpointService -{ - /// - /// **Note:** This API is currently in beta. Creates a new URL‑endpoint and - /// returns the resulting object. - /// - Task Create(URLEndpointCreateParams parameters); - - /// - /// **Note:** This API is currently in beta. Updates the URL‑endpoint identified - /// by `id` and returns the updated object. - /// - Task Update(URLEndpointUpdateParams parameters); - - /// - /// **Note:** This API is currently in beta. Returns an array of all URL‑endpoints - /// configured including the default URL-endpoint generated by ImageKit during - /// account creation. - /// - Task> List(URLEndpointListParams? parameters = null); - - /// - /// **Note:** This API is currently in beta. Deletes the URL‑endpoint identified - /// by `id`. You cannot delete the default URL‑endpoint created by ImageKit during - /// account creation. - /// - Task Delete(URLEndpointDeleteParams parameters); - - /// - /// **Note:** This API is currently in beta. Retrieves the URL‑endpoint identified - /// by `id`. - /// - Task Get(URLEndpointGetParams parameters); -} diff --git a/src/Imagekit/Services/Accounts/URLEndpoints/URLEndpointService.cs b/src/Imagekit/Services/Accounts/URLEndpoints/URLEndpointService.cs deleted file mode 100644 index d74a8040..00000000 --- a/src/Imagekit/Services/Accounts/URLEndpoints/URLEndpointService.cs +++ /dev/null @@ -1,104 +0,0 @@ -using System.Collections.Generic; -using System.Net.Http; -using System.Threading.Tasks; -using Imagekit.Core; -using Imagekit.Models.Accounts.URLEndpoints; - -namespace Imagekit.Services.Accounts.URLEndpoints; - -public sealed class URLEndpointService : IURLEndpointService -{ - readonly IImageKitClient _client; - - public URLEndpointService(IImageKitClient client) - { - _client = client; - } - - public async Task Create(URLEndpointCreateParams parameters) - { - HttpRequest request = new() - { - Method = HttpMethod.Post, - Params = parameters, - }; - using var response = await this._client.Execute(request).ConfigureAwait(false); - var urlEndpointResponse = await response - .Deserialize() - .ConfigureAwait(false); - if (this._client.ResponseValidation) - { - urlEndpointResponse.Validate(); - } - return urlEndpointResponse; - } - - public async Task Update(URLEndpointUpdateParams parameters) - { - HttpRequest request = new() - { - Method = HttpMethod.Put, - Params = parameters, - }; - using var response = await this._client.Execute(request).ConfigureAwait(false); - var urlEndpointResponse = await response - .Deserialize() - .ConfigureAwait(false); - if (this._client.ResponseValidation) - { - urlEndpointResponse.Validate(); - } - return urlEndpointResponse; - } - - public async Task> List(URLEndpointListParams? parameters = null) - { - parameters ??= new(); - - HttpRequest request = new() - { - Method = HttpMethod.Get, - Params = parameters, - }; - using var response = await this._client.Execute(request).ConfigureAwait(false); - var urlEndpointResponses = await response - .Deserialize>() - .ConfigureAwait(false); - if (this._client.ResponseValidation) - { - foreach (var item in urlEndpointResponses) - { - item.Validate(); - } - } - return urlEndpointResponses; - } - - public async Task Delete(URLEndpointDeleteParams parameters) - { - HttpRequest request = new() - { - Method = HttpMethod.Delete, - Params = parameters, - }; - using var response = await this._client.Execute(request).ConfigureAwait(false); - } - - public async Task Get(URLEndpointGetParams parameters) - { - HttpRequest request = new() - { - Method = HttpMethod.Get, - Params = parameters, - }; - using var response = await this._client.Execute(request).ConfigureAwait(false); - var urlEndpointResponse = await response - .Deserialize() - .ConfigureAwait(false); - if (this._client.ResponseValidation) - { - urlEndpointResponse.Validate(); - } - return urlEndpointResponse; - } -} diff --git a/src/Imagekit/Services/Accounts/Usage/IUsageService.cs b/src/Imagekit/Services/Accounts/Usage/IUsageService.cs deleted file mode 100644 index ce3d7bec..00000000 --- a/src/Imagekit/Services/Accounts/Usage/IUsageService.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Threading.Tasks; -using Imagekit.Models.Accounts.Usage; - -namespace Imagekit.Services.Accounts.Usage; - -public interface IUsageService -{ - /// - /// Get the account usage information between two dates. Note that the API response - /// includes data from the start date while excluding data from the end date. - /// In other words, the data covers the period starting from the specified start - /// date up to, but not including, the end date. - /// - Task Get(UsageGetParams parameters); -} diff --git a/src/Imagekit/Services/Accounts/Usage/UsageService.cs b/src/Imagekit/Services/Accounts/Usage/UsageService.cs deleted file mode 100644 index 040f859d..00000000 --- a/src/Imagekit/Services/Accounts/Usage/UsageService.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Net.Http; -using System.Threading.Tasks; -using Imagekit.Core; -using Imagekit.Models.Accounts.Usage; - -namespace Imagekit.Services.Accounts.Usage; - -public sealed class UsageService : IUsageService -{ - readonly IImageKitClient _client; - - public UsageService(IImageKitClient client) - { - _client = client; - } - - public async Task Get(UsageGetParams parameters) - { - HttpRequest request = new() - { - Method = HttpMethod.Get, - Params = parameters, - }; - using var response = await this._client.Execute(request).ConfigureAwait(false); - var usage = await response.Deserialize().ConfigureAwait(false); - if (this._client.ResponseValidation) - { - usage.Validate(); - } - return usage; - } -} diff --git a/src/Imagekit/Services/Assets/AssetService.cs b/src/Imagekit/Services/Assets/AssetService.cs deleted file mode 100644 index 885d6eea..00000000 --- a/src/Imagekit/Services/Assets/AssetService.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System.Collections.Generic; -using System.Net.Http; -using System.Threading.Tasks; -using Imagekit.Core; -using Imagekit.Models.Assets; - -namespace Imagekit.Services.Assets; - -public sealed class AssetService : IAssetService -{ - readonly IImageKitClient _client; - - public AssetService(IImageKitClient client) - { - _client = client; - } - - public async Task> List(AssetListParams? parameters = null) - { - parameters ??= new(); - - HttpRequest request = new() - { - Method = HttpMethod.Get, - Params = parameters, - }; - using var response = await this._client.Execute(request).ConfigureAwait(false); - var assets = await response.Deserialize>().ConfigureAwait(false); - if (this._client.ResponseValidation) - { - foreach (var item in assets) - { - item.Validate(); - } - } - return assets; - } -} diff --git a/src/Imagekit/Services/Assets/IAssetService.cs b/src/Imagekit/Services/Assets/IAssetService.cs deleted file mode 100644 index 0ee9f37c..00000000 --- a/src/Imagekit/Services/Assets/IAssetService.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.Collections.Generic; -using System.Threading.Tasks; -using Imagekit.Models.Assets; - -namespace Imagekit.Services.Assets; - -public interface IAssetService -{ - /// - /// This API can list all the uploaded files and folders in your ImageKit.io - /// media library. In addition, you can fine-tune your query by specifying various - /// filters by generating a query string in a Lucene-like syntax and provide - /// this generated string as the value of the `searchQuery`. - /// - Task> List(AssetListParams? parameters = null); -} diff --git a/src/Imagekit/Services/Beta/BetaService.cs b/src/Imagekit/Services/Beta/BetaService.cs deleted file mode 100644 index b6c9e2a1..00000000 --- a/src/Imagekit/Services/Beta/BetaService.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using Imagekit.Services.Beta.V2; - -namespace Imagekit.Services.Beta; - -public sealed class BetaService : IBetaService -{ - public BetaService(IImageKitClient client) - { - _v2 = new(() => new V2Service(client)); - } - - readonly Lazy _v2; - public IV2Service V2 - { - get { return _v2.Value; } - } -} diff --git a/src/Imagekit/Services/Beta/IBetaService.cs b/src/Imagekit/Services/Beta/IBetaService.cs deleted file mode 100644 index 65bd9f62..00000000 --- a/src/Imagekit/Services/Beta/IBetaService.cs +++ /dev/null @@ -1,8 +0,0 @@ -using Imagekit.Services.Beta.V2; - -namespace Imagekit.Services.Beta; - -public interface IBetaService -{ - IV2Service V2 { get; } -} diff --git a/src/Imagekit/Services/Beta/V2/Files/FileService.cs b/src/Imagekit/Services/Beta/V2/Files/FileService.cs deleted file mode 100644 index 7e02e1c9..00000000 --- a/src/Imagekit/Services/Beta/V2/Files/FileService.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Net.Http; -using System.Threading.Tasks; -using Imagekit.Core; -using Imagekit.Models.Beta.V2.Files; - -namespace Imagekit.Services.Beta.V2.Files; - -public sealed class FileService : IFileService -{ - readonly IImageKitClient _client; - - public FileService(IImageKitClient client) - { - _client = client; - } - - public async Task Upload(FileUploadParams parameters) - { - HttpRequest request = new() - { - Method = HttpMethod.Post, - Params = parameters, - }; - using var response = await this._client.Execute(request).ConfigureAwait(false); - var deserializedResponse = await response - .Deserialize() - .ConfigureAwait(false); - if (this._client.ResponseValidation) - { - deserializedResponse.Validate(); - } - return deserializedResponse; - } -} diff --git a/src/Imagekit/Services/Beta/V2/Files/IFileService.cs b/src/Imagekit/Services/Beta/V2/Files/IFileService.cs deleted file mode 100644 index 7e4a65f2..00000000 --- a/src/Imagekit/Services/Beta/V2/Files/IFileService.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System.Threading.Tasks; -using Imagekit.Models.Beta.V2.Files; - -namespace Imagekit.Services.Beta.V2.Files; - -public interface IFileService -{ - /// - /// The V2 API enhances security by verifying the entire payload using JWT. This - /// API is in beta. - /// - /// ImageKit.io allows you to upload files directly from both the server and client - /// sides. For server-side uploads, private API key authentication is used. For - /// client-side uploads, generate a one-time `token` from your secure backend - /// using private API. [Learn more](/docs/api-reference/upload-file/upload-file-v2#how-to-implement-secure-client-side-file-upload) - /// about how to implement secure client-side file upload. - /// - /// **File size limit** \ On the free plan, the maximum upload file sizes are - /// 20MB for images, audio, and raw files, and 100MB for videos. On the paid plan, - /// these limits increase to 40MB for images, audio, and raw files, and 2GB for - /// videos. These limits can be further increased with higher-tier plans. - /// - /// **Version limit** \ A file can have a maximum of 100 versions. - /// - /// **Demo applications** - /// - /// - A full-fledged [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), - /// supporting file selections from local storage, URL, Dropbox, Google Drive, - /// Instagram, and more. - [Quick start guides](/docs/quick-start-guides) for - /// various frameworks and technologies. - /// - Task Upload(FileUploadParams parameters); -} diff --git a/src/Imagekit/Services/Beta/V2/IV2Service.cs b/src/Imagekit/Services/Beta/V2/IV2Service.cs deleted file mode 100644 index 13609839..00000000 --- a/src/Imagekit/Services/Beta/V2/IV2Service.cs +++ /dev/null @@ -1,8 +0,0 @@ -using Imagekit.Services.Beta.V2.Files; - -namespace Imagekit.Services.Beta.V2; - -public interface IV2Service -{ - IFileService Files { get; } -} diff --git a/src/Imagekit/Services/Beta/V2/V2Service.cs b/src/Imagekit/Services/Beta/V2/V2Service.cs deleted file mode 100644 index e966651e..00000000 --- a/src/Imagekit/Services/Beta/V2/V2Service.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using Imagekit.Services.Beta.V2.Files; - -namespace Imagekit.Services.Beta.V2; - -public sealed class V2Service : IV2Service -{ - public V2Service(IImageKitClient client) - { - _files = new(() => new FileService(client)); - } - - readonly Lazy _files; - public IFileService Files - { - get { return _files.Value; } - } -} diff --git a/src/Imagekit/Services/Cache/CacheService.cs b/src/Imagekit/Services/Cache/CacheService.cs deleted file mode 100644 index 35ad5f64..00000000 --- a/src/Imagekit/Services/Cache/CacheService.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using Imagekit.Services.Cache.Invalidation; - -namespace Imagekit.Services.Cache; - -public sealed class CacheService : ICacheService -{ - public CacheService(IImageKitClient client) - { - _invalidation = new(() => new InvalidationService(client)); - } - - readonly Lazy _invalidation; - public IInvalidationService Invalidation - { - get { return _invalidation.Value; } - } -} diff --git a/src/Imagekit/Services/Cache/ICacheService.cs b/src/Imagekit/Services/Cache/ICacheService.cs deleted file mode 100644 index 91882a67..00000000 --- a/src/Imagekit/Services/Cache/ICacheService.cs +++ /dev/null @@ -1,8 +0,0 @@ -using Imagekit.Services.Cache.Invalidation; - -namespace Imagekit.Services.Cache; - -public interface ICacheService -{ - IInvalidationService Invalidation { get; } -} diff --git a/src/Imagekit/Services/Cache/Invalidation/IInvalidationService.cs b/src/Imagekit/Services/Cache/Invalidation/IInvalidationService.cs deleted file mode 100644 index 1c2a20a6..00000000 --- a/src/Imagekit/Services/Cache/Invalidation/IInvalidationService.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Threading.Tasks; -using Imagekit.Models.Cache.Invalidation; - -namespace Imagekit.Services.Cache.Invalidation; - -public interface IInvalidationService -{ - /// - /// This API will purge CDN cache and ImageKit.io's internal cache for a file. - /// Note: Purge cache is an asynchronous process and it may take some time to - /// reflect the changes. - /// - Task Create(InvalidationCreateParams parameters); - - /// - /// This API returns the status of a purge cache request. - /// - Task Get(InvalidationGetParams parameters); -} diff --git a/src/Imagekit/Services/Cache/Invalidation/InvalidationService.cs b/src/Imagekit/Services/Cache/Invalidation/InvalidationService.cs deleted file mode 100644 index c6285146..00000000 --- a/src/Imagekit/Services/Cache/Invalidation/InvalidationService.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System.Net.Http; -using System.Threading.Tasks; -using Imagekit.Core; -using Imagekit.Models.Cache.Invalidation; - -namespace Imagekit.Services.Cache.Invalidation; - -public sealed class InvalidationService : IInvalidationService -{ - readonly IImageKitClient _client; - - public InvalidationService(IImageKitClient client) - { - _client = client; - } - - public async Task Create(InvalidationCreateParams parameters) - { - HttpRequest request = new() - { - Method = HttpMethod.Post, - Params = parameters, - }; - using var response = await this._client.Execute(request).ConfigureAwait(false); - var invalidation = await response - .Deserialize() - .ConfigureAwait(false); - if (this._client.ResponseValidation) - { - invalidation.Validate(); - } - return invalidation; - } - - public async Task Get(InvalidationGetParams parameters) - { - HttpRequest request = new() - { - Method = HttpMethod.Get, - Params = parameters, - }; - using var response = await this._client.Execute(request).ConfigureAwait(false); - var invalidation = await response - .Deserialize() - .ConfigureAwait(false); - if (this._client.ResponseValidation) - { - invalidation.Validate(); - } - return invalidation; - } -} diff --git a/src/Imagekit/Services/CustomMetadataFields/CustomMetadataFieldService.cs b/src/Imagekit/Services/CustomMetadataFields/CustomMetadataFieldService.cs deleted file mode 100644 index 54aa6816..00000000 --- a/src/Imagekit/Services/CustomMetadataFields/CustomMetadataFieldService.cs +++ /dev/null @@ -1,98 +0,0 @@ -using System.Collections.Generic; -using System.Net.Http; -using System.Threading.Tasks; -using Imagekit.Core; -using Imagekit.Models.CustomMetadataFields; - -namespace Imagekit.Services.CustomMetadataFields; - -public sealed class CustomMetadataFieldService : ICustomMetadataFieldService -{ - readonly IImageKitClient _client; - - public CustomMetadataFieldService(IImageKitClient client) - { - _client = client; - } - - public async Task Create(CustomMetadataFieldCreateParams parameters) - { - HttpRequest request = new() - { - Method = HttpMethod.Post, - Params = parameters, - }; - using var response = await this._client.Execute(request).ConfigureAwait(false); - var customMetadataField = await response - .Deserialize() - .ConfigureAwait(false); - if (this._client.ResponseValidation) - { - customMetadataField.Validate(); - } - return customMetadataField; - } - - public async Task Update(CustomMetadataFieldUpdateParams parameters) - { - HttpRequest request = new() - { - Method = HttpMethod.Patch, - Params = parameters, - }; - using var response = await this._client.Execute(request).ConfigureAwait(false); - var customMetadataField = await response - .Deserialize() - .ConfigureAwait(false); - if (this._client.ResponseValidation) - { - customMetadataField.Validate(); - } - return customMetadataField; - } - - public async Task> List( - CustomMetadataFieldListParams? parameters = null - ) - { - parameters ??= new(); - - HttpRequest request = new() - { - Method = HttpMethod.Get, - Params = parameters, - }; - using var response = await this._client.Execute(request).ConfigureAwait(false); - var customMetadataFields = await response - .Deserialize>() - .ConfigureAwait(false); - if (this._client.ResponseValidation) - { - foreach (var item in customMetadataFields) - { - item.Validate(); - } - } - return customMetadataFields; - } - - public async Task Delete( - CustomMetadataFieldDeleteParams parameters - ) - { - HttpRequest request = new() - { - Method = HttpMethod.Delete, - Params = parameters, - }; - using var response = await this._client.Execute(request).ConfigureAwait(false); - var customMetadataField = await response - .Deserialize() - .ConfigureAwait(false); - if (this._client.ResponseValidation) - { - customMetadataField.Validate(); - } - return customMetadataField; - } -} diff --git a/src/Imagekit/Services/CustomMetadataFields/ICustomMetadataFieldService.cs b/src/Imagekit/Services/CustomMetadataFields/ICustomMetadataFieldService.cs deleted file mode 100644 index 0333af7b..00000000 --- a/src/Imagekit/Services/CustomMetadataFields/ICustomMetadataFieldService.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System.Collections.Generic; -using System.Threading.Tasks; -using Imagekit.Models.CustomMetadataFields; - -namespace Imagekit.Services.CustomMetadataFields; - -public interface ICustomMetadataFieldService -{ - /// - /// This API creates a new custom metadata field. Once a custom metadata field - /// is created either through this API or using the dashboard UI, its value can - /// be set on the assets. The value of a field for an asset can be set using the - /// media library UI or programmatically through upload or update assets API. - /// - Task Create(CustomMetadataFieldCreateParams parameters); - - /// - /// This API updates the label or schema of an existing custom metadata field. - /// - Task Update(CustomMetadataFieldUpdateParams parameters); - - /// - /// This API returns the array of created custom metadata field objects. By default - /// the API returns only non deleted field objects, but you can include deleted - /// fields in the API response. - /// - /// You can also filter results by a specific folder path to retrieve custom - /// metadata fields applicable at that location. This path-specific filtering - /// is useful when using the **Path policy** feature to determine which custom - /// metadata fields are selected for a given path. - /// - Task> List(CustomMetadataFieldListParams? parameters = null); - - /// - /// This API deletes a custom metadata field. Even after deleting a custom metadata - /// field, you cannot create any new custom metadata field with the same name. - /// - Task Delete(CustomMetadataFieldDeleteParams parameters); -} diff --git a/src/Imagekit/Services/Files/Bulk/BulkService.cs b/src/Imagekit/Services/Files/Bulk/BulkService.cs deleted file mode 100644 index 72d82c5f..00000000 --- a/src/Imagekit/Services/Files/Bulk/BulkService.cs +++ /dev/null @@ -1,86 +0,0 @@ -using System.Net.Http; -using System.Threading.Tasks; -using Imagekit.Core; -using Imagekit.Models.Files.Bulk; - -namespace Imagekit.Services.Files.Bulk; - -public sealed class BulkService : IBulkService -{ - readonly IImageKitClient _client; - - public BulkService(IImageKitClient client) - { - _client = client; - } - - public async Task Delete(BulkDeleteParams parameters) - { - HttpRequest request = new() - { - Method = HttpMethod.Post, - Params = parameters, - }; - using var response = await this._client.Execute(request).ConfigureAwait(false); - var bulk = await response.Deserialize().ConfigureAwait(false); - if (this._client.ResponseValidation) - { - bulk.Validate(); - } - return bulk; - } - - public async Task AddTags(BulkAddTagsParams parameters) - { - HttpRequest request = new() - { - Method = HttpMethod.Post, - Params = parameters, - }; - using var response = await this._client.Execute(request).ConfigureAwait(false); - var deserializedResponse = await response - .Deserialize() - .ConfigureAwait(false); - if (this._client.ResponseValidation) - { - deserializedResponse.Validate(); - } - return deserializedResponse; - } - - public async Task RemoveAITags(BulkRemoveAITagsParams parameters) - { - HttpRequest request = new() - { - Method = HttpMethod.Post, - Params = parameters, - }; - using var response = await this._client.Execute(request).ConfigureAwait(false); - var deserializedResponse = await response - .Deserialize() - .ConfigureAwait(false); - if (this._client.ResponseValidation) - { - deserializedResponse.Validate(); - } - return deserializedResponse; - } - - public async Task RemoveTags(BulkRemoveTagsParams parameters) - { - HttpRequest request = new() - { - Method = HttpMethod.Post, - Params = parameters, - }; - using var response = await this._client.Execute(request).ConfigureAwait(false); - var deserializedResponse = await response - .Deserialize() - .ConfigureAwait(false); - if (this._client.ResponseValidation) - { - deserializedResponse.Validate(); - } - return deserializedResponse; - } -} diff --git a/src/Imagekit/Services/Files/Bulk/IBulkService.cs b/src/Imagekit/Services/Files/Bulk/IBulkService.cs deleted file mode 100644 index da6626c9..00000000 --- a/src/Imagekit/Services/Files/Bulk/IBulkService.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Threading.Tasks; -using Imagekit.Models.Files.Bulk; - -namespace Imagekit.Services.Files.Bulk; - -public interface IBulkService -{ - /// - /// This API deletes multiple files and all their file versions permanently. - /// - /// Note: If a file or specific transformation has been requested in the past, - /// then the response is cached. Deleting a file does not purge the cache. You - /// can purge the cache using purge cache API. - /// - /// A maximum of 100 files can be deleted at a time. - /// - Task Delete(BulkDeleteParams parameters); - - /// - /// This API adds tags to multiple files in bulk. A maximum of 50 files can be - /// specified at a time. - /// - Task AddTags(BulkAddTagsParams parameters); - - /// - /// This API removes AITags from multiple files in bulk. A maximum of 50 files - /// can be specified at a time. - /// - Task RemoveAITags(BulkRemoveAITagsParams parameters); - - /// - /// This API removes tags from multiple files in bulk. A maximum of 50 files can - /// be specified at a time. - /// - Task RemoveTags(BulkRemoveTagsParams parameters); -} diff --git a/src/Imagekit/Services/Files/FileService.cs b/src/Imagekit/Services/Files/FileService.cs deleted file mode 100644 index adbbcd48..00000000 --- a/src/Imagekit/Services/Files/FileService.cs +++ /dev/null @@ -1,151 +0,0 @@ -using System; -using System.Net.Http; -using System.Threading.Tasks; -using Imagekit.Core; -using Imagekit.Models.Files; -using Imagekit.Services.Files.Bulk; -using Imagekit.Services.Files.Metadata; -using Imagekit.Services.Files.Versions; - -namespace Imagekit.Services.Files; - -public sealed class FileService : IFileService -{ - readonly IImageKitClient _client; - - public FileService(IImageKitClient client) - { - _client = client; - _bulk = new(() => new BulkService(client)); - _versions = new(() => new VersionService(client)); - _metadata = new(() => new MetadataService(client)); - } - - readonly Lazy _bulk; - public IBulkService Bulk - { - get { return _bulk.Value; } - } - - readonly Lazy _versions; - public IVersionService Versions - { - get { return _versions.Value; } - } - - readonly Lazy _metadata; - public IMetadataService Metadata - { - get { return _metadata.Value; } - } - - public async Task Update(FileUpdateParams parameters) - { - HttpRequest request = new() - { - Method = HttpMethod.Patch, - Params = parameters, - }; - using var response = await this._client.Execute(request).ConfigureAwait(false); - var file = await response.Deserialize().ConfigureAwait(false); - if (this._client.ResponseValidation) - { - file.Validate(); - } - return file; - } - - public async Task Delete(FileDeleteParams parameters) - { - HttpRequest request = new() - { - Method = HttpMethod.Delete, - Params = parameters, - }; - using var response = await this._client.Execute(request).ConfigureAwait(false); - } - - public async Task Copy(FileCopyParams parameters) - { - HttpRequest request = new() - { - Method = HttpMethod.Post, - Params = parameters, - }; - using var response = await this._client.Execute(request).ConfigureAwait(false); - var deserializedResponse = await response - .Deserialize() - .ConfigureAwait(false); - if (this._client.ResponseValidation) - { - deserializedResponse.Validate(); - } - return deserializedResponse; - } - - public async Task Get(FileGetParams parameters) - { - HttpRequest request = new() { Method = HttpMethod.Get, Params = parameters }; - using var response = await this._client.Execute(request).ConfigureAwait(false); - var file = await response.Deserialize().ConfigureAwait(false); - if (this._client.ResponseValidation) - { - file.Validate(); - } - return file; - } - - public async Task Move(FileMoveParams parameters) - { - HttpRequest request = new() - { - Method = HttpMethod.Post, - Params = parameters, - }; - using var response = await this._client.Execute(request).ConfigureAwait(false); - var deserializedResponse = await response - .Deserialize() - .ConfigureAwait(false); - if (this._client.ResponseValidation) - { - deserializedResponse.Validate(); - } - return deserializedResponse; - } - - public async Task Rename(FileRenameParams parameters) - { - HttpRequest request = new() - { - Method = HttpMethod.Put, - Params = parameters, - }; - using var response = await this._client.Execute(request).ConfigureAwait(false); - var deserializedResponse = await response - .Deserialize() - .ConfigureAwait(false); - if (this._client.ResponseValidation) - { - deserializedResponse.Validate(); - } - return deserializedResponse; - } - - public async Task Upload(FileUploadParams parameters) - { - HttpRequest request = new() - { - Method = HttpMethod.Post, - Params = parameters, - }; - using var response = await this._client.Execute(request).ConfigureAwait(false); - var deserializedResponse = await response - .Deserialize() - .ConfigureAwait(false); - if (this._client.ResponseValidation) - { - deserializedResponse.Validate(); - } - return deserializedResponse; - } -} diff --git a/src/Imagekit/Services/Files/IFileService.cs b/src/Imagekit/Services/Files/IFileService.cs deleted file mode 100644 index 183d998d..00000000 --- a/src/Imagekit/Services/Files/IFileService.cs +++ /dev/null @@ -1,91 +0,0 @@ -using System.Threading.Tasks; -using Imagekit.Models.Files; -using Imagekit.Services.Files.Bulk; -using Imagekit.Services.Files.Metadata; -using Imagekit.Services.Files.Versions; - -namespace Imagekit.Services.Files; - -public interface IFileService -{ - IBulkService Bulk { get; } - - IVersionService Versions { get; } - - IMetadataService Metadata { get; } - - /// - /// This API updates the details or attributes of the current version of the - /// file. You can update `tags`, `customCoordinates`, `customMetadata`, publication - /// status, remove existing `AITags` and apply extensions using this API. - /// - Task Update(FileUpdateParams parameters); - - /// - /// This API deletes the file and all its file versions permanently. - /// - /// Note: If a file or specific transformation has been requested in the past, - /// then the response is cached. Deleting a file does not purge the cache. You - /// can purge the cache using purge cache API. - /// - Task Delete(FileDeleteParams parameters); - - /// - /// This will copy a file from one folder to another. - /// - /// Note: If any file at the destination has the same name as the source file, - /// then the source file and its versions (if `includeFileVersions` is set to - /// true) will be appended to the destination file version history. - /// - Task Copy(FileCopyParams parameters); - - /// - /// This API returns an object with details or attributes about the current version - /// of the file. - /// - Task Get(FileGetParams parameters); - - /// - /// This will move a file and all its versions from one folder to another. - /// - /// Note: If any file at the destination has the same name as the source file, - /// then the source file and its versions will be appended to the destination - /// file. - /// - Task Move(FileMoveParams parameters); - - /// - /// You can rename an already existing file in the media library using rename - /// file API. This operation would rename all file versions of the file. - /// - /// Note: The old URLs will stop working. The file/file version URLs cached on - /// CDN will continue to work unless a purge is requested. - /// - Task Rename(FileRenameParams parameters); - - /// - /// ImageKit.io allows you to upload files directly from both the server and client - /// sides. For server-side uploads, private API key authentication is used. For - /// client-side uploads, generate a one-time `token`, `signature`, and `expire` - /// from your secure backend using private API. [Learn more](/docs/api-reference/upload-file/upload-file#how-to-implement-client-side-file-upload) - /// about how to implement client-side file upload. - /// - /// The [V2 API](/docs/api-reference/upload-file/upload-file-v2) enhances security - /// by verifying the entire payload using JWT. - /// - /// **File size limit** \ On the free plan, the maximum upload file sizes are - /// 20MB for images, audio, and raw files and 100MB for videos. On the paid plan, - /// these limits increase to 40MB for images, audio, and raw files and 2GB for - /// videos. These limits can be further increased with higher-tier plans. - /// - /// **Version limit** \ A file can have a maximum of 100 versions. - /// - /// **Demo applications** - /// - /// - A full-fledged [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), - /// supporting file selections from local storage, URL, Dropbox, Google Drive, - /// Instagram, and more. - [Quick start guides](/docs/quick-start-guides) for - /// various frameworks and technologies. - /// - Task Upload(FileUploadParams parameters); -} diff --git a/src/Imagekit/Services/Files/Metadata/IMetadataService.cs b/src/Imagekit/Services/Files/Metadata/IMetadataService.cs deleted file mode 100644 index 2135c619..00000000 --- a/src/Imagekit/Services/Files/Metadata/IMetadataService.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Threading.Tasks; -using Imagekit.Models.Files.Metadata; -using Files = Imagekit.Models.Files; - -namespace Imagekit.Services.Files.Metadata; - -public interface IMetadataService -{ - /// - /// You can programmatically get image EXIF, pHash, and other metadata for uploaded - /// files in the ImageKit.io media library using this API. - /// - /// You can also get the metadata in upload API response by passing `metadata` - /// in `responseFields` parameter. - /// - Task Get(MetadataGetParams parameters); - - /// - /// Get image EXIF, pHash, and other metadata from ImageKit.io powered remote - /// URL using this API. - /// - Task GetFromURL(MetadataGetFromURLParams parameters); -} diff --git a/src/Imagekit/Services/Files/Metadata/MetadataService.cs b/src/Imagekit/Services/Files/Metadata/MetadataService.cs deleted file mode 100644 index e0c1d703..00000000 --- a/src/Imagekit/Services/Files/Metadata/MetadataService.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System.Net.Http; -using System.Threading.Tasks; -using Imagekit.Core; -using Imagekit.Models.Files.Metadata; -using Files = Imagekit.Models.Files; - -namespace Imagekit.Services.Files.Metadata; - -public sealed class MetadataService : IMetadataService -{ - readonly IImageKitClient _client; - - public MetadataService(IImageKitClient client) - { - _client = client; - } - - public async Task Get(MetadataGetParams parameters) - { - HttpRequest request = new() - { - Method = HttpMethod.Get, - Params = parameters, - }; - using var response = await this._client.Execute(request).ConfigureAwait(false); - var metadata = await response.Deserialize().ConfigureAwait(false); - if (this._client.ResponseValidation) - { - metadata.Validate(); - } - return metadata; - } - - public async Task GetFromURL(MetadataGetFromURLParams parameters) - { - HttpRequest request = new() - { - Method = HttpMethod.Get, - Params = parameters, - }; - using var response = await this._client.Execute(request).ConfigureAwait(false); - var metadata = await response.Deserialize().ConfigureAwait(false); - if (this._client.ResponseValidation) - { - metadata.Validate(); - } - return metadata; - } -} diff --git a/src/Imagekit/Services/Files/Versions/IVersionService.cs b/src/Imagekit/Services/Files/Versions/IVersionService.cs deleted file mode 100644 index 8efbc71d..00000000 --- a/src/Imagekit/Services/Files/Versions/IVersionService.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections.Generic; -using System.Threading.Tasks; -using Imagekit.Models.Files; -using Imagekit.Models.Files.Versions; - -namespace Imagekit.Services.Files.Versions; - -public interface IVersionService -{ - /// - /// This API returns details of all versions of a file. - /// - Task> List(VersionListParams parameters); - - /// - /// This API deletes a non-current file version permanently. The API returns - /// an empty response. - /// - /// Note: If you want to delete all versions of a file, use the delete file API. - /// - Task Delete(VersionDeleteParams parameters); - - /// - /// This API returns an object with details or attributes of a file version. - /// - Task Get(VersionGetParams parameters); - - /// - /// This API restores a file version as the current file version. - /// - Task Restore(VersionRestoreParams parameters); -} diff --git a/src/Imagekit/Services/Files/Versions/VersionService.cs b/src/Imagekit/Services/Files/Versions/VersionService.cs deleted file mode 100644 index 83231194..00000000 --- a/src/Imagekit/Services/Files/Versions/VersionService.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System.Collections.Generic; -using System.Net.Http; -using System.Threading.Tasks; -using Imagekit.Core; -using Imagekit.Models.Files; -using Imagekit.Models.Files.Versions; - -namespace Imagekit.Services.Files.Versions; - -public sealed class VersionService : IVersionService -{ - readonly IImageKitClient _client; - - public VersionService(IImageKitClient client) - { - _client = client; - } - - public async Task> List(VersionListParams parameters) - { - HttpRequest request = new() - { - Method = HttpMethod.Get, - Params = parameters, - }; - using var response = await this._client.Execute(request).ConfigureAwait(false); - var files = await response.Deserialize>().ConfigureAwait(false); - if (this._client.ResponseValidation) - { - foreach (var item in files) - { - item.Validate(); - } - } - return files; - } - - public async Task Delete(VersionDeleteParams parameters) - { - HttpRequest request = new() - { - Method = HttpMethod.Delete, - Params = parameters, - }; - using var response = await this._client.Execute(request).ConfigureAwait(false); - var version = await response.Deserialize().ConfigureAwait(false); - if (this._client.ResponseValidation) - { - version.Validate(); - } - return version; - } - - public async Task Get(VersionGetParams parameters) - { - HttpRequest request = new() - { - Method = HttpMethod.Get, - Params = parameters, - }; - using var response = await this._client.Execute(request).ConfigureAwait(false); - var file = await response.Deserialize().ConfigureAwait(false); - if (this._client.ResponseValidation) - { - file.Validate(); - } - return file; - } - - public async Task Restore(VersionRestoreParams parameters) - { - HttpRequest request = new() - { - Method = HttpMethod.Put, - Params = parameters, - }; - using var response = await this._client.Execute(request).ConfigureAwait(false); - var file = await response.Deserialize().ConfigureAwait(false); - if (this._client.ResponseValidation) - { - file.Validate(); - } - return file; - } -} diff --git a/src/Imagekit/Services/Folders/FolderService.cs b/src/Imagekit/Services/Folders/FolderService.cs deleted file mode 100644 index fb946edc..00000000 --- a/src/Imagekit/Services/Folders/FolderService.cs +++ /dev/null @@ -1,111 +0,0 @@ -using System; -using System.Net.Http; -using System.Threading.Tasks; -using Imagekit.Core; -using Imagekit.Models.Folders; -using Imagekit.Services.Folders.Job; - -namespace Imagekit.Services.Folders; - -public sealed class FolderService : IFolderService -{ - readonly IImageKitClient _client; - - public FolderService(IImageKitClient client) - { - _client = client; - _job = new(() => new JobService(client)); - } - - readonly Lazy _job; - public IJobService Job - { - get { return _job.Value; } - } - - public async Task Create(FolderCreateParams parameters) - { - HttpRequest request = new() - { - Method = HttpMethod.Post, - Params = parameters, - }; - using var response = await this._client.Execute(request).ConfigureAwait(false); - var folder = await response.Deserialize().ConfigureAwait(false); - if (this._client.ResponseValidation) - { - folder.Validate(); - } - return folder; - } - - public async Task Delete(FolderDeleteParams parameters) - { - HttpRequest request = new() - { - Method = HttpMethod.Delete, - Params = parameters, - }; - using var response = await this._client.Execute(request).ConfigureAwait(false); - var folder = await response.Deserialize().ConfigureAwait(false); - if (this._client.ResponseValidation) - { - folder.Validate(); - } - return folder; - } - - public async Task Copy(FolderCopyParams parameters) - { - HttpRequest request = new() - { - Method = HttpMethod.Post, - Params = parameters, - }; - using var response = await this._client.Execute(request).ConfigureAwait(false); - var deserializedResponse = await response - .Deserialize() - .ConfigureAwait(false); - if (this._client.ResponseValidation) - { - deserializedResponse.Validate(); - } - return deserializedResponse; - } - - public async Task Move(FolderMoveParams parameters) - { - HttpRequest request = new() - { - Method = HttpMethod.Post, - Params = parameters, - }; - using var response = await this._client.Execute(request).ConfigureAwait(false); - var deserializedResponse = await response - .Deserialize() - .ConfigureAwait(false); - if (this._client.ResponseValidation) - { - deserializedResponse.Validate(); - } - return deserializedResponse; - } - - public async Task Rename(FolderRenameParams parameters) - { - HttpRequest request = new() - { - Method = HttpMethod.Post, - Params = parameters, - }; - using var response = await this._client.Execute(request).ConfigureAwait(false); - var deserializedResponse = await response - .Deserialize() - .ConfigureAwait(false); - if (this._client.ResponseValidation) - { - deserializedResponse.Validate(); - } - return deserializedResponse; - } -} diff --git a/src/Imagekit/Services/Folders/IFolderService.cs b/src/Imagekit/Services/Folders/IFolderService.cs deleted file mode 100644 index da6b7be6..00000000 --- a/src/Imagekit/Services/Folders/IFolderService.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System.Threading.Tasks; -using Imagekit.Models.Folders; -using Imagekit.Services.Folders.Job; - -namespace Imagekit.Services.Folders; - -public interface IFolderService -{ - IJobService Job { get; } - - /// - /// This will create a new folder. You can specify the folder name and location - /// of the parent folder where this new folder should be created. - /// - Task Create(FolderCreateParams parameters); - - /// - /// This will delete a folder and all its contents permanently. The API returns - /// an empty response. - /// - Task Delete(FolderDeleteParams parameters); - - /// - /// This will copy one folder into another. The selected folder, its nested folders, - /// files, and their versions (in `includeVersions` is set to true) are copied - /// in this operation. Note: If any file at the destination has the same name - /// as the source file, then the source file and its versions will be appended - /// to the destination file version history. - /// - Task Copy(FolderCopyParams parameters); - - /// - /// This will move one folder into another. The selected folder, its nested folders, - /// files, and their versions are moved in this operation. Note: If any file at - /// the destination has the same name as the source file, then the source file - /// and its versions will be appended to the destination file version history. - /// - Task Move(FolderMoveParams parameters); - - /// - /// This API allows you to rename an existing folder. The folder and all its nested - /// assets and sub-folders will remain unchanged, but their paths will be updated - /// to reflect the new folder name. - /// - Task Rename(FolderRenameParams parameters); -} diff --git a/src/Imagekit/Services/Folders/Job/IJobService.cs b/src/Imagekit/Services/Folders/Job/IJobService.cs deleted file mode 100644 index eb919607..00000000 --- a/src/Imagekit/Services/Folders/Job/IJobService.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System.Threading.Tasks; -using Imagekit.Models.Folders.Job; - -namespace Imagekit.Services.Folders.Job; - -public interface IJobService -{ - /// - /// This API returns the status of a bulk job like copy and move folder operations. - /// - Task Get(JobGetParams parameters); -} diff --git a/src/Imagekit/Services/Folders/Job/JobService.cs b/src/Imagekit/Services/Folders/Job/JobService.cs deleted file mode 100644 index 1df036fe..00000000 --- a/src/Imagekit/Services/Folders/Job/JobService.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System.Net.Http; -using System.Threading.Tasks; -using Imagekit.Core; -using Imagekit.Models.Folders.Job; - -namespace Imagekit.Services.Folders.Job; - -public sealed class JobService : IJobService -{ - readonly IImageKitClient _client; - - public JobService(IImageKitClient client) - { - _client = client; - } - - public async Task Get(JobGetParams parameters) - { - HttpRequest request = new() { Method = HttpMethod.Get, Params = parameters }; - using var response = await this._client.Execute(request).ConfigureAwait(false); - var job = await response.Deserialize().ConfigureAwait(false); - if (this._client.ResponseValidation) - { - job.Validate(); - } - return job; - } -} diff --git a/src/Imagekit/Services/Webhooks/IWebhookService.cs b/src/Imagekit/Services/Webhooks/IWebhookService.cs deleted file mode 100644 index 7529d7b5..00000000 --- a/src/Imagekit/Services/Webhooks/IWebhookService.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace Imagekit.Services.Webhooks; - -public interface IWebhookService { } diff --git a/src/Imagekit/Services/Webhooks/WebhookService.cs b/src/Imagekit/Services/Webhooks/WebhookService.cs deleted file mode 100644 index 79912020..00000000 --- a/src/Imagekit/Services/Webhooks/WebhookService.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Imagekit.Services.Webhooks; - -public sealed class WebhookService : IWebhookService -{ - public WebhookService(IImageKitClient client) { } -} From 3c4946a3d9fe40fa8c4fec7ce8a86032a89d8da4 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 29 Jan 2026 19:21:26 +0000 Subject: [PATCH 062/129] chore(internal): ignore stainless-internal artifacts --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 08a6d808..cb0f7844 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,6 @@ bin/ obj/ .vs/ .idea/ + +# do not edit! excludes generated files used internally +.artifacts/ From e78fc4603cbacc6282ca00e2fcb55eef3190955e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 30 Jan 2026 22:00:45 +0000 Subject: [PATCH 063/129] fix(client): improve union equality method --- .../Models/Accounts/Origins/OriginRequest.cs | 24 +- .../Models/Accounts/Origins/OriginResponse.cs | 24 +- .../UrlEndpoints/UrlEndpointCreateParams.cs | 19 +- .../UrlEndpoints/UrlEndpointRequest.cs | 19 +- .../UrlEndpoints/UrlEndpointResponse.cs | 19 +- .../UrlEndpoints/UrlEndpointUpdateParams.cs | 19 +- .../Models/Assets/AssetListResponse.cs | 18 +- .../Models/Beta/V2/Files/FileUploadParams.cs | 20 +- .../Beta/V2/Files/FileUploadResponse.cs | 94 ++++- .../CustomMetadataField.cs | 94 ++++- .../CustomMetadataFieldCreateParams.cs | 94 ++++- .../CustomMetadataFieldUpdateParams.cs | 94 ++++- src/ImageKit/Models/ExtensionConfig.cs | 175 +++++++-- src/ImageKit/Models/Files/File.cs | 94 ++++- src/ImageKit/Models/Files/FileUploadParams.cs | 20 +- .../Models/Files/FileUploadResponse.cs | 94 ++++- .../Models/Files/UpdateFileRequest.cs | 36 +- src/ImageKit/Models/Overlay.cs | 21 +- src/ImageKit/Models/OverlayPosition.cs | 36 +- src/ImageKit/Models/OverlayTiming.cs | 54 ++- .../Models/SolidColorOverlayTransformation.cs | 73 +++- .../Models/TextOverlayTransformation.cs | 109 ++++-- src/ImageKit/Models/Transformation.cs | 343 ++++++++++++++---- .../Models/UnnamedSchemaWithArrayParent0.cs | 176 +++++++-- .../Webhooks/UnsafeUnwrapWebhookEvent.cs | 23 +- .../Models/Webhooks/UnwrapWebhookEvent.cs | 23 +- .../UploadPreTransformSuccessEvent.cs | 94 ++++- 27 files changed, 1505 insertions(+), 404 deletions(-) diff --git a/src/ImageKit/Models/Accounts/Origins/OriginRequest.cs b/src/ImageKit/Models/Accounts/Origins/OriginRequest.cs index 46e36d31..daa6c565 100644 --- a/src/ImageKit/Models/Accounts/Origins/OriginRequest.cs +++ b/src/ImageKit/Models/Accounts/Origins/OriginRequest.cs @@ -574,10 +574,10 @@ public override void Validate() ); } - public virtual bool Equals(OriginRequest? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(OriginRequest? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -586,6 +586,22 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + S3 _ => 0, + S3Compatible _ => 1, + CloudinaryBackup _ => 2, + WebFolder _ => 3, + WebProxy _ => 4, + Gcs _ => 5, + AzureBlob _ => 6, + AkeneoPim _ => 7, + _ => -1, + }; + } } sealed class OriginRequestConverter : JsonConverter diff --git a/src/ImageKit/Models/Accounts/Origins/OriginResponse.cs b/src/ImageKit/Models/Accounts/Origins/OriginResponse.cs index 7e25f7e3..dcc43728 100644 --- a/src/ImageKit/Models/Accounts/Origins/OriginResponse.cs +++ b/src/ImageKit/Models/Accounts/Origins/OriginResponse.cs @@ -560,10 +560,10 @@ public override void Validate() ); } - public virtual bool Equals(OriginResponse? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(OriginResponse? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -572,6 +572,22 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + OriginResponseS3 _ => 0, + OriginResponseS3Compatible _ => 1, + OriginResponseCloudinaryBackup _ => 2, + OriginResponseWebFolder _ => 3, + OriginResponseWebProxy _ => 4, + OriginResponseGcs _ => 5, + OriginResponseAzureBlob _ => 6, + OriginResponseAkeneoPim _ => 7, + _ => -1, + }; + } } sealed class OriginResponseConverter : JsonConverter diff --git a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointCreateParams.cs b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointCreateParams.cs index bda360c8..64aed354 100644 --- a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointCreateParams.cs +++ b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointCreateParams.cs @@ -428,10 +428,10 @@ public override void Validate() ); } - public virtual bool Equals(UrlRewriter? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(UrlRewriter? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -440,6 +440,17 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + Cloudinary _ => 0, + Imgix _ => 1, + Akamai _ => 2, + _ => -1, + }; + } } sealed class UrlRewriterConverter : JsonConverter diff --git a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointRequest.cs b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointRequest.cs index 45522fe3..bf9a031d 100644 --- a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointRequest.cs +++ b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointRequest.cs @@ -390,10 +390,10 @@ public override void Validate() ); } - public virtual bool Equals(UrlEndpointRequestUrlRewriter? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(UrlEndpointRequestUrlRewriter? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -402,6 +402,17 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + UrlEndpointRequestUrlRewriterCloudinary _ => 0, + UrlEndpointRequestUrlRewriterImgix _ => 1, + UrlEndpointRequestUrlRewriterAkamai _ => 2, + _ => -1, + }; + } } sealed class UrlEndpointRequestUrlRewriterConverter : JsonConverter diff --git a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointResponse.cs b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointResponse.cs index 07d928a0..771e1a81 100644 --- a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointResponse.cs +++ b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointResponse.cs @@ -385,10 +385,10 @@ public override void Validate() ); } - public virtual bool Equals(UrlEndpointResponseUrlRewriter? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(UrlEndpointResponseUrlRewriter? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -397,6 +397,17 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + UrlEndpointResponseUrlRewriterCloudinary _ => 0, + UrlEndpointResponseUrlRewriterImgix _ => 1, + UrlEndpointResponseUrlRewriterAkamai _ => 2, + _ => -1, + }; + } } sealed class UrlEndpointResponseUrlRewriterConverter : JsonConverter diff --git a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParams.cs b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParams.cs index e550eaaf..7000cbca 100644 --- a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParams.cs +++ b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParams.cs @@ -466,10 +466,10 @@ public override void Validate() ); } - public virtual bool Equals(UrlEndpointUpdateParamsUrlRewriter? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(UrlEndpointUpdateParamsUrlRewriter? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -478,6 +478,17 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + UrlEndpointUpdateParamsUrlRewriterCloudinary _ => 0, + UrlEndpointUpdateParamsUrlRewriterImgix _ => 1, + UrlEndpointUpdateParamsUrlRewriterAkamai _ => 2, + _ => -1, + }; + } } sealed class UrlEndpointUpdateParamsUrlRewriterConverter diff --git a/src/ImageKit/Models/Assets/AssetListResponse.cs b/src/ImageKit/Models/Assets/AssetListResponse.cs index 5d0a812a..9864b5ee 100644 --- a/src/ImageKit/Models/Assets/AssetListResponse.cs +++ b/src/ImageKit/Models/Assets/AssetListResponse.cs @@ -210,10 +210,10 @@ public override void Validate() this.Switch((file) => file.Validate(), (folder) => folder.Validate()); } - public virtual bool Equals(AssetListResponse? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(AssetListResponse? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -222,6 +222,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + File _ => 0, + Folder _ => 1, + _ => -1, + }; + } } sealed class AssetListResponseConverter : JsonConverter diff --git a/src/ImageKit/Models/Beta/V2/Files/FileUploadParams.cs b/src/ImageKit/Models/Beta/V2/Files/FileUploadParams.cs index 6c7faead..1aebbd06 100644 --- a/src/ImageKit/Models/Beta/V2/Files/FileUploadParams.cs +++ b/src/ImageKit/Models/Beta/V2/Files/FileUploadParams.cs @@ -1061,10 +1061,10 @@ public override void Validate() ); } - public virtual bool Equals(Post? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(Post? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1073,6 +1073,18 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + PostTransformation _ => 0, + GifToVideo _ => 1, + Thumbnail _ => 2, + Abs _ => 3, + _ => -1, + }; + } } sealed class PostConverter : JsonConverter diff --git a/src/ImageKit/Models/Beta/V2/Files/FileUploadResponse.cs b/src/ImageKit/Models/Beta/V2/Files/FileUploadResponse.cs index ce4ed046..f9a6480b 100644 --- a/src/ImageKit/Models/Beta/V2/Files/FileUploadResponse.cs +++ b/src/ImageKit/Models/Beta/V2/Files/FileUploadResponse.cs @@ -1751,10 +1751,10 @@ public override void Validate() } } - public virtual bool Equals(DefaultValue? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(DefaultValue? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1763,6 +1763,18 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + bool _ => 2, + IReadOnlyList _ => 3, + _ => -1, + }; + } } sealed class DefaultValueConverter : JsonConverter @@ -2048,10 +2060,10 @@ public override void Validate() } } - public virtual bool Equals(UnnamedSchemaWithArrayParent12? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(UnnamedSchemaWithArrayParent12? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -2060,6 +2072,17 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + bool _ => 2, + _ => -1, + }; + } } sealed class UnnamedSchemaWithArrayParent12Converter : JsonConverter @@ -2289,10 +2312,10 @@ public override void Validate() } } - public virtual bool Equals(MaxValue? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(MaxValue? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -2301,6 +2324,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + _ => -1, + }; + } } sealed class MaxValueConverter : JsonConverter @@ -2517,10 +2550,10 @@ public override void Validate() } } - public virtual bool Equals(MinValue? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(MinValue? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -2529,6 +2562,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + _ => -1, + }; + } } sealed class MinValueConverter : JsonConverter @@ -2785,10 +2828,10 @@ public override void Validate() } } - public virtual bool Equals(SelectOption? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(SelectOption? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -2797,6 +2840,17 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + bool _ => 2, + _ => -1, + }; + } } sealed class SelectOptionConverter : JsonConverter diff --git a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataField.cs b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataField.cs index c97842b7..cbf5b422 100644 --- a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataField.cs +++ b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataField.cs @@ -686,10 +686,10 @@ public override void Validate() } } - public virtual bool Equals(CustomMetadataFieldSchemaDefaultValue? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(CustomMetadataFieldSchemaDefaultValue? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -698,6 +698,18 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + bool _ => 2, + IReadOnlyList _ => 3, + _ => -1, + }; + } } sealed class CustomMetadataFieldSchemaDefaultValueConverter @@ -984,10 +996,10 @@ public override void Validate() } } - public virtual bool Equals(UnnamedSchemaWithArrayParent9? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(UnnamedSchemaWithArrayParent9? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -996,6 +1008,17 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + bool _ => 2, + _ => -1, + }; + } } sealed class UnnamedSchemaWithArrayParent9Converter : JsonConverter @@ -1227,10 +1250,10 @@ public override void Validate() } } - public virtual bool Equals(CustomMetadataFieldSchemaMaxValue? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(CustomMetadataFieldSchemaMaxValue? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1239,6 +1262,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + _ => -1, + }; + } } sealed class CustomMetadataFieldSchemaMaxValueConverter @@ -1462,10 +1495,10 @@ public override void Validate() } } - public virtual bool Equals(CustomMetadataFieldSchemaMinValue? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(CustomMetadataFieldSchemaMinValue? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1474,6 +1507,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + _ => -1, + }; + } } sealed class CustomMetadataFieldSchemaMinValueConverter @@ -1737,10 +1780,10 @@ public override void Validate() } } - public virtual bool Equals(CustomMetadataFieldSchemaSelectOption? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(CustomMetadataFieldSchemaSelectOption? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1749,6 +1792,17 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + bool _ => 2, + _ => -1, + }; + } } sealed class CustomMetadataFieldSchemaSelectOptionConverter diff --git a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldCreateParams.cs b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldCreateParams.cs index 4e1c6662..6636b72e 100644 --- a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldCreateParams.cs +++ b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldCreateParams.cs @@ -738,10 +738,10 @@ public override void Validate() } } - public virtual bool Equals(DefaultValue? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(DefaultValue? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -750,6 +750,18 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + bool _ => 2, + IReadOnlyList _ => 3, + _ => -1, + }; + } } sealed class DefaultValueConverter : JsonConverter @@ -1035,10 +1047,10 @@ public override void Validate() } } - public virtual bool Equals(UnnamedSchemaWithArrayParent1? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(UnnamedSchemaWithArrayParent1? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1047,6 +1059,17 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + bool _ => 2, + _ => -1, + }; + } } sealed class UnnamedSchemaWithArrayParent1Converter : JsonConverter @@ -1276,10 +1299,10 @@ public override void Validate() } } - public virtual bool Equals(MaxValue? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(MaxValue? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1288,6 +1311,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + _ => -1, + }; + } } sealed class MaxValueConverter : JsonConverter @@ -1504,10 +1537,10 @@ public override void Validate() } } - public virtual bool Equals(MinValue? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(MinValue? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1516,6 +1549,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + _ => -1, + }; + } } sealed class MinValueConverter : JsonConverter @@ -1772,10 +1815,10 @@ public override void Validate() } } - public virtual bool Equals(SelectOption? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(SelectOption? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1784,6 +1827,17 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + bool _ => 2, + _ => -1, + }; + } } sealed class SelectOptionConverter : JsonConverter diff --git a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParams.cs b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParams.cs index a19875b3..08b7a80a 100644 --- a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParams.cs +++ b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParams.cs @@ -708,10 +708,10 @@ public override void Validate() } } - public virtual bool Equals(CustomMetadataFieldUpdateParamsSchemaDefaultValue? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(CustomMetadataFieldUpdateParamsSchemaDefaultValue? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -720,6 +720,18 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + bool _ => 2, + IReadOnlyList _ => 3, + _ => -1, + }; + } } sealed class CustomMetadataFieldUpdateParamsSchemaDefaultValueConverter @@ -1006,10 +1018,10 @@ public override void Validate() } } - public virtual bool Equals(UnnamedSchemaWithArrayParent2? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(UnnamedSchemaWithArrayParent2? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1018,6 +1030,17 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + bool _ => 2, + _ => -1, + }; + } } sealed class UnnamedSchemaWithArrayParent2Converter : JsonConverter @@ -1251,10 +1274,10 @@ public override void Validate() } } - public virtual bool Equals(CustomMetadataFieldUpdateParamsSchemaMaxValue? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(CustomMetadataFieldUpdateParamsSchemaMaxValue? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1263,6 +1286,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + _ => -1, + }; + } } sealed class CustomMetadataFieldUpdateParamsSchemaMaxValueConverter @@ -1488,10 +1521,10 @@ public override void Validate() } } - public virtual bool Equals(CustomMetadataFieldUpdateParamsSchemaMinValue? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(CustomMetadataFieldUpdateParamsSchemaMinValue? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1500,6 +1533,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + _ => -1, + }; + } } sealed class CustomMetadataFieldUpdateParamsSchemaMinValueConverter @@ -1775,10 +1818,10 @@ public override void Validate() } } - public virtual bool Equals(CustomMetadataFieldUpdateParamsSchemaSelectOption? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(CustomMetadataFieldUpdateParamsSchemaSelectOption? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1787,6 +1830,17 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + bool _ => 2, + _ => -1, + }; + } } sealed class CustomMetadataFieldUpdateParamsSchemaSelectOptionConverter diff --git a/src/ImageKit/Models/ExtensionConfig.cs b/src/ImageKit/Models/ExtensionConfig.cs index c4a32235..84fe7b9f 100644 --- a/src/ImageKit/Models/ExtensionConfig.cs +++ b/src/ImageKit/Models/ExtensionConfig.cs @@ -270,10 +270,10 @@ public override void Validate() ); } - public virtual bool Equals(ExtensionConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(ExtensionConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -282,6 +282,18 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + RemoveBg _ => 0, + AutoTaggingExtension _ => 1, + AIAutoDescription _ => 2, + AITasks _ => 3, + _ => -1, + }; + } } sealed class ExtensionConfigConverter : JsonConverter @@ -1178,10 +1190,10 @@ public override void Validate() ); } - public virtual bool Equals(Task? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(Task? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1190,6 +1202,17 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SelectTags _ => 0, + SelectMetadata _ => 1, + YesNo _ => 2, + _ => -1, + }; + } } sealed class TaskConverter : JsonConverter @@ -1808,10 +1831,10 @@ public override void Validate() } } - public virtual bool Equals(Vocabulary? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(Vocabulary? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1820,6 +1843,17 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + bool _ => 2, + _ => -1, + }; + } } sealed class VocabularyConverter : JsonConverter @@ -2512,10 +2546,10 @@ public override void Validate() } } - public virtual bool Equals(SetMetadataValue? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(SetMetadataValue? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -2524,6 +2558,18 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + bool _ => 2, + IReadOnlyList _ => 3, + _ => -1, + }; + } } sealed class SetMetadataValueConverter : JsonConverter @@ -2801,10 +2847,10 @@ public override void Validate() } } - public virtual bool Equals(UnnamedSchemaWithArrayParent3? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(UnnamedSchemaWithArrayParent3? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -2813,6 +2859,17 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + bool _ => 2, + _ => -1, + }; + } } sealed class UnnamedSchemaWithArrayParent3Converter : JsonConverter @@ -3425,10 +3482,10 @@ public override void Validate() } } - public virtual bool Equals(OnUnknownSetMetadataValue? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(OnUnknownSetMetadataValue? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -3437,6 +3494,18 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + bool _ => 2, + IReadOnlyList _ => 3, + _ => -1, + }; + } } sealed class OnUnknownSetMetadataValueConverter : JsonConverter @@ -3714,10 +3783,10 @@ public override void Validate() } } - public virtual bool Equals(UnnamedSchemaWithArrayParent4? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(UnnamedSchemaWithArrayParent4? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -3726,6 +3795,17 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + bool _ => 2, + _ => -1, + }; + } } sealed class UnnamedSchemaWithArrayParent4Converter : JsonConverter @@ -4340,10 +4420,10 @@ public override void Validate() } } - public virtual bool Equals(OnYesSetMetadataValue? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(OnYesSetMetadataValue? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -4352,6 +4432,18 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + bool _ => 2, + IReadOnlyList _ => 3, + _ => -1, + }; + } } sealed class OnYesSetMetadataValueConverter : JsonConverter @@ -4629,10 +4721,10 @@ public override void Validate() } } - public virtual bool Equals(UnnamedSchemaWithArrayParent5? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(UnnamedSchemaWithArrayParent5? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -4641,6 +4733,17 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + bool _ => 2, + _ => -1, + }; + } } sealed class UnnamedSchemaWithArrayParent5Converter : JsonConverter diff --git a/src/ImageKit/Models/Files/File.cs b/src/ImageKit/Models/Files/File.cs index 54788711..ab6a0b50 100644 --- a/src/ImageKit/Models/Files/File.cs +++ b/src/ImageKit/Models/Files/File.cs @@ -1298,10 +1298,10 @@ public override void Validate() } } - public virtual bool Equals(DefaultValue? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(DefaultValue? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1310,6 +1310,18 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + bool _ => 2, + IReadOnlyList _ => 3, + _ => -1, + }; + } } sealed class DefaultValueConverter : JsonConverter @@ -1595,10 +1607,10 @@ public override void Validate() } } - public virtual bool Equals(UnnamedSchemaWithArrayParent10? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(UnnamedSchemaWithArrayParent10? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1607,6 +1619,17 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + bool _ => 2, + _ => -1, + }; + } } sealed class UnnamedSchemaWithArrayParent10Converter : JsonConverter @@ -1836,10 +1859,10 @@ public override void Validate() } } - public virtual bool Equals(MaxValue? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(MaxValue? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1848,6 +1871,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + _ => -1, + }; + } } sealed class MaxValueConverter : JsonConverter @@ -2064,10 +2097,10 @@ public override void Validate() } } - public virtual bool Equals(MinValue? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(MinValue? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -2076,6 +2109,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + _ => -1, + }; + } } sealed class MinValueConverter : JsonConverter @@ -2332,10 +2375,10 @@ public override void Validate() } } - public virtual bool Equals(SelectOption? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(SelectOption? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -2344,6 +2387,17 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + bool _ => 2, + _ => -1, + }; + } } sealed class SelectOptionConverter : JsonConverter diff --git a/src/ImageKit/Models/Files/FileUploadParams.cs b/src/ImageKit/Models/Files/FileUploadParams.cs index 844ad915..758121be 100644 --- a/src/ImageKit/Models/Files/FileUploadParams.cs +++ b/src/ImageKit/Models/Files/FileUploadParams.cs @@ -1139,10 +1139,10 @@ public override void Validate() ); } - public virtual bool Equals(Post? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(Post? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1151,6 +1151,18 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + PostTransformation _ => 0, + GifToVideo _ => 1, + Thumbnail _ => 2, + Abs _ => 3, + _ => -1, + }; + } } sealed class PostConverter : JsonConverter diff --git a/src/ImageKit/Models/Files/FileUploadResponse.cs b/src/ImageKit/Models/Files/FileUploadResponse.cs index 811012cc..bbe82990 100644 --- a/src/ImageKit/Models/Files/FileUploadResponse.cs +++ b/src/ImageKit/Models/Files/FileUploadResponse.cs @@ -1823,10 +1823,10 @@ public override void Validate() } } - public virtual bool Equals(FileUploadResponseSelectedFieldsSchemaItemDefaultValue? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(FileUploadResponseSelectedFieldsSchemaItemDefaultValue? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1835,6 +1835,18 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + bool _ => 2, + IReadOnlyList _ => 3, + _ => -1, + }; + } } sealed class FileUploadResponseSelectedFieldsSchemaItemDefaultValueConverter @@ -2121,10 +2133,10 @@ public override void Validate() } } - public virtual bool Equals(UnnamedSchemaWithArrayParent11? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(UnnamedSchemaWithArrayParent11? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -2133,6 +2145,17 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + bool _ => 2, + _ => -1, + }; + } } sealed class UnnamedSchemaWithArrayParent11Converter : JsonConverter @@ -2374,10 +2397,10 @@ public override void Validate() } } - public virtual bool Equals(FileUploadResponseSelectedFieldsSchemaItemMaxValue? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(FileUploadResponseSelectedFieldsSchemaItemMaxValue? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -2386,6 +2409,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + _ => -1, + }; + } } sealed class FileUploadResponseSelectedFieldsSchemaItemMaxValueConverter @@ -2619,10 +2652,10 @@ public override void Validate() } } - public virtual bool Equals(FileUploadResponseSelectedFieldsSchemaItemMinValue? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(FileUploadResponseSelectedFieldsSchemaItemMinValue? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -2631,6 +2664,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + _ => -1, + }; + } } sealed class FileUploadResponseSelectedFieldsSchemaItemMinValueConverter @@ -2907,10 +2950,10 @@ public override void Validate() } } - public virtual bool Equals(FileUploadResponseSelectedFieldsSchemaItemSelectOption? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(FileUploadResponseSelectedFieldsSchemaItemSelectOption? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -2919,6 +2962,17 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + bool _ => 2, + _ => -1, + }; + } } sealed class FileUploadResponseSelectedFieldsSchemaItemSelectOptionConverter diff --git a/src/ImageKit/Models/Files/UpdateFileRequest.cs b/src/ImageKit/Models/Files/UpdateFileRequest.cs index 7ff9612f..936de263 100644 --- a/src/ImageKit/Models/Files/UpdateFileRequest.cs +++ b/src/ImageKit/Models/Files/UpdateFileRequest.cs @@ -196,10 +196,10 @@ public override void Validate() ); } - public virtual bool Equals(UpdateFileRequest? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(UpdateFileRequest? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -208,6 +208,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + UpdateFileDetails _ => 0, + ChangePublicationStatus _ => 1, + _ => -1, + }; + } } sealed class UpdateFileRequestConverter : JsonConverter @@ -668,10 +678,10 @@ public override void Validate() this.Switch((_) => { }, (all) => all.Validate()); } - public virtual bool Equals(RemoveAITags? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(RemoveAITags? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -680,6 +690,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + IReadOnlyList _ => 0, + UnionMember1 _ => 1, + _ => -1, + }; + } } sealed class RemoveAITagsConverter : JsonConverter diff --git a/src/ImageKit/Models/Overlay.cs b/src/ImageKit/Models/Overlay.cs index 101c34b7..3b26f8a0 100644 --- a/src/ImageKit/Models/Overlay.cs +++ b/src/ImageKit/Models/Overlay.cs @@ -373,10 +373,10 @@ public override void Validate() ); } - public virtual bool Equals(Overlay? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(Overlay? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -385,6 +385,19 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + TextOverlay _ => 0, + ImageOverlay _ => 1, + VideoOverlay _ => 2, + SubtitleOverlay _ => 3, + SolidColorOverlay _ => 4, + _ => -1, + }; + } } sealed class OverlayConverter : JsonConverter diff --git a/src/ImageKit/Models/OverlayPosition.cs b/src/ImageKit/Models/OverlayPosition.cs index 7274304e..3d2eebd2 100644 --- a/src/ImageKit/Models/OverlayPosition.cs +++ b/src/ImageKit/Models/OverlayPosition.cs @@ -361,10 +361,10 @@ public override void Validate() } } - public virtual bool Equals(X? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(X? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -373,6 +373,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + double _ => 0, + string _ => 1, + _ => -1, + }; + } } sealed class XConverter : JsonConverter @@ -586,10 +596,10 @@ public override void Validate() } } - public virtual bool Equals(Y? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(Y? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -598,6 +608,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + double _ => 0, + string _ => 1, + _ => -1, + }; + } } sealed class YConverter : JsonConverter diff --git a/src/ImageKit/Models/OverlayTiming.cs b/src/ImageKit/Models/OverlayTiming.cs index 3cbfbaed..b6151de9 100644 --- a/src/ImageKit/Models/OverlayTiming.cs +++ b/src/ImageKit/Models/OverlayTiming.cs @@ -303,10 +303,10 @@ public override void Validate() } } - public virtual bool Equals(Duration? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(Duration? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -315,6 +315,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + double _ => 0, + string _ => 1, + _ => -1, + }; + } } sealed class DurationConverter : JsonConverter @@ -529,10 +539,10 @@ public override void Validate() } } - public virtual bool Equals(End? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(End? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -541,6 +551,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + double _ => 0, + string _ => 1, + _ => -1, + }; + } } sealed class EndConverter : JsonConverter @@ -754,10 +774,10 @@ public override void Validate() } } - public virtual bool Equals(Start? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(Start? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -766,6 +786,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + double _ => 0, + string _ => 1, + _ => -1, + }; + } } sealed class StartConverter : JsonConverter diff --git a/src/ImageKit/Models/SolidColorOverlayTransformation.cs b/src/ImageKit/Models/SolidColorOverlayTransformation.cs index 19736040..c19f6c2c 100644 --- a/src/ImageKit/Models/SolidColorOverlayTransformation.cs +++ b/src/ImageKit/Models/SolidColorOverlayTransformation.cs @@ -380,10 +380,10 @@ public override void Validate() this.Switch((true_) => true_.Validate(), (_) => { }); } - public virtual bool Equals(Gradient? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(Gradient? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -392,6 +392,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + UnionMember0 _ => 0, + string _ => 1, + _ => -1, + }; + } } sealed class GradientConverter : JsonConverter @@ -677,10 +687,10 @@ public override void Validate() } } - public virtual bool Equals(Height? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(Height? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -689,6 +699,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + double _ => 0, + string _ => 1, + _ => -1, + }; + } } sealed class HeightConverter : JsonConverter @@ -939,10 +959,10 @@ public override void Validate() this.Switch((_) => { }, (max) => max.Validate(), (_) => { }); } - public virtual bool Equals(Radius? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(Radius? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -951,6 +971,17 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + double _ => 0, + UnionMember1 _ => 1, + string _ => 2, + _ => -1, + }; + } } sealed class RadiusConverter : JsonConverter @@ -1246,10 +1277,10 @@ public override void Validate() } } - public virtual bool Equals(Width? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(Width? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1258,6 +1289,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + double _ => 0, + string _ => 1, + _ => -1, + }; + } } sealed class WidthConverter : JsonConverter diff --git a/src/ImageKit/Models/TextOverlayTransformation.cs b/src/ImageKit/Models/TextOverlayTransformation.cs index 5009a5e3..b1e4600f 100644 --- a/src/ImageKit/Models/TextOverlayTransformation.cs +++ b/src/ImageKit/Models/TextOverlayTransformation.cs @@ -592,10 +592,10 @@ public override void Validate() } } - public virtual bool Equals(FontSize? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(FontSize? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -604,6 +604,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + double _ => 0, + string _ => 1, + _ => -1, + }; + } } sealed class FontSizeConverter : JsonConverter @@ -870,10 +880,10 @@ public override void Validate() } } - public virtual bool Equals(LineHeight? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(LineHeight? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -882,6 +892,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + double _ => 0, + string _ => 1, + _ => -1, + }; + } } sealed class LineHeightConverter : JsonConverter @@ -1100,10 +1120,10 @@ public override void Validate() } } - public virtual bool Equals(Padding? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(Padding? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1112,6 +1132,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + double _ => 0, + string _ => 1, + _ => -1, + }; + } } sealed class PaddingConverter : JsonConverter @@ -1383,10 +1413,10 @@ public override void Validate() this.Switch((_) => { }, (max) => max.Validate(), (_) => { }); } - public virtual bool Equals(TextOverlayTransformationRadius? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(TextOverlayTransformationRadius? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1395,6 +1425,17 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + double _ => 0, + TextOverlayTransformationRadiusUnionMember1 _ => 1, + string _ => 2, + _ => -1, + }; + } } sealed class TextOverlayTransformationRadiusConverter @@ -1705,10 +1746,10 @@ public override void Validate() } } - public virtual bool Equals(Rotation? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(Rotation? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1717,6 +1758,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + double _ => 0, + string _ => 1, + _ => -1, + }; + } } sealed class RotationConverter : JsonConverter @@ -1935,10 +1986,10 @@ public override void Validate() } } - public virtual bool Equals(TextOverlayTransformationWidth? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(TextOverlayTransformationWidth? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1947,6 +1998,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + double _ => 0, + string _ => 1, + _ => -1, + }; + } } sealed class TextOverlayTransformationWidthConverter : JsonConverter diff --git a/src/ImageKit/Models/Transformation.cs b/src/ImageKit/Models/Transformation.cs index 504f3bcd..f8aa76e2 100644 --- a/src/ImageKit/Models/Transformation.cs +++ b/src/ImageKit/Models/Transformation.cs @@ -1553,10 +1553,10 @@ public override void Validate() this.Switch((true_) => true_.Validate(), (_) => { }); } - public virtual bool Equals(AIDropShadow? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(AIDropShadow? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1565,6 +1565,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + AIDropShadowUnionMember0 _ => 0, + string _ => 1, + _ => -1, + }; + } } sealed class AIDropShadowConverter : JsonConverter @@ -2092,10 +2102,10 @@ public override void Validate() } } - public virtual bool Equals(AspectRatio? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(AspectRatio? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -2104,6 +2114,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + double _ => 0, + string _ => 1, + _ => -1, + }; + } } sealed class AspectRatioConverter : JsonConverter @@ -2519,10 +2539,10 @@ public override void Validate() } } - public virtual bool Equals(TransformationDuration? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(TransformationDuration? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -2531,6 +2551,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + double _ => 0, + string _ => 1, + _ => -1, + }; + } } sealed class TransformationDurationConverter : JsonConverter @@ -2751,10 +2781,10 @@ public override void Validate() } } - public virtual bool Equals(EndOffset? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(EndOffset? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -2763,6 +2793,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + double _ => 0, + string _ => 1, + _ => -1, + }; + } } sealed class EndOffsetConverter : JsonConverter @@ -3120,10 +3160,10 @@ public override void Validate() this.Switch((true_) => true_.Validate(), (_) => { }); } - public virtual bool Equals(TransformationGradient? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(TransformationGradient? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -3132,6 +3172,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + TransformationGradientUnionMember0 _ => 0, + string _ => 1, + _ => -1, + }; + } } sealed class TransformationGradientConverter : JsonConverter @@ -3479,10 +3529,10 @@ public override void Validate() } } - public virtual bool Equals(TransformationHeight? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(TransformationHeight? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -3491,6 +3541,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + double _ => 0, + string _ => 1, + _ => -1, + }; + } } sealed class TransformationHeightConverter : JsonConverter @@ -3708,10 +3768,10 @@ public override void Validate() } } - public virtual bool Equals(Page? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(Page? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -3720,6 +3780,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + double _ => 0, + string _ => 1, + _ => -1, + }; + } } sealed class PageConverter : JsonConverter @@ -3985,10 +4055,10 @@ public override void Validate() this.Switch((_) => { }, (max) => max.Validate(), (_) => { }); } - public virtual bool Equals(TransformationRadius? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(TransformationRadius? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -3997,6 +4067,17 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + double _ => 0, + TransformationRadiusUnionMember1 _ => 1, + string _ => 2, + _ => -1, + }; + } } sealed class TransformationRadiusConverter : JsonConverter @@ -4308,10 +4389,10 @@ public override void Validate() } } - public virtual bool Equals(TransformationRotation? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(TransformationRotation? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -4320,6 +4401,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + double _ => 0, + string _ => 1, + _ => -1, + }; + } } sealed class TransformationRotationConverter : JsonConverter @@ -4537,10 +4628,10 @@ public override void Validate() this.Switch((true_) => true_.Validate(), (_) => { }); } - public virtual bool Equals(Shadow? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(Shadow? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -4549,6 +4640,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + ShadowUnionMember0 _ => 0, + string _ => 1, + _ => -1, + }; + } } sealed class ShadowConverter : JsonConverter @@ -4837,10 +4938,10 @@ public override void Validate() this.Switch((true_) => true_.Validate(), (_) => { }); } - public virtual bool Equals(Sharpen? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(Sharpen? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -4849,6 +4950,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharpenUnionMember0 _ => 0, + double _ => 1, + _ => -1, + }; + } } sealed class SharpenConverter : JsonConverter @@ -5134,10 +5245,10 @@ public override void Validate() } } - public virtual bool Equals(StartOffset? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(StartOffset? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -5146,6 +5257,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + double _ => 0, + string _ => 1, + _ => -1, + }; + } } sealed class StartOffsetConverter : JsonConverter @@ -5363,10 +5484,10 @@ public override void Validate() this.Switch((true_) => true_.Validate(), (_) => { }); } - public virtual bool Equals(Trim? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(Trim? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -5375,6 +5496,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + TrimUnionMember0 _ => 0, + double _ => 1, + _ => -1, + }; + } } sealed class TrimConverter : JsonConverter @@ -5662,10 +5793,10 @@ public override void Validate() this.Switch((true_) => true_.Validate(), (_) => { }); } - public virtual bool Equals(UnsharpMask? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(UnsharpMask? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -5674,6 +5805,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + UnsharpMaskUnionMember0 _ => 0, + string _ => 1, + _ => -1, + }; + } } sealed class UnsharpMaskConverter : JsonConverter @@ -6029,10 +6170,10 @@ public override void Validate() } } - public virtual bool Equals(TransformationWidth? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(TransformationWidth? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -6041,6 +6182,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + double _ => 0, + string _ => 1, + _ => -1, + }; + } } sealed class TransformationWidthConverter : JsonConverter @@ -6261,10 +6412,10 @@ public override void Validate() } } - public virtual bool Equals(TransformationX? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(TransformationX? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -6273,6 +6424,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + double _ => 0, + string _ => 1, + _ => -1, + }; + } } sealed class TransformationXConverter : JsonConverter @@ -6490,10 +6651,10 @@ public override void Validate() } } - public virtual bool Equals(XCenter? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(XCenter? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -6502,6 +6663,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + double _ => 0, + string _ => 1, + _ => -1, + }; + } } sealed class XCenterConverter : JsonConverter @@ -6718,10 +6889,10 @@ public override void Validate() } } - public virtual bool Equals(TransformationY? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(TransformationY? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -6730,6 +6901,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + double _ => 0, + string _ => 1, + _ => -1, + }; + } } sealed class TransformationYConverter : JsonConverter @@ -6947,10 +7128,10 @@ public override void Validate() } } - public virtual bool Equals(YCenter? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(YCenter? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -6959,6 +7140,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + double _ => 0, + string _ => 1, + _ => -1, + }; + } } sealed class YCenterConverter : JsonConverter diff --git a/src/ImageKit/Models/UnnamedSchemaWithArrayParent0.cs b/src/ImageKit/Models/UnnamedSchemaWithArrayParent0.cs index 488238d6..fa6a5be6 100644 --- a/src/ImageKit/Models/UnnamedSchemaWithArrayParent0.cs +++ b/src/ImageKit/Models/UnnamedSchemaWithArrayParent0.cs @@ -332,10 +332,10 @@ public override void Validate() ); } - public virtual bool Equals(UnnamedSchemaWithArrayParent0? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(UnnamedSchemaWithArrayParent0? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -344,6 +344,19 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + UnnamedSchemaWithArrayParent0RemoveBg _ => 0, + UnnamedSchemaWithArrayParent0AutoTaggingExtension _ => 1, + UnnamedSchemaWithArrayParent0AIAutoDescription _ => 2, + UnnamedSchemaWithArrayParent0AITasks _ => 3, + SavedExtension _ => 4, + _ => -1, + }; + } } sealed class UnnamedSchemaWithArrayParent0Converter : JsonConverter @@ -1360,10 +1373,10 @@ public override void Validate() ); } - public virtual bool Equals(UnnamedSchemaWithArrayParent0AITasksTask? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(UnnamedSchemaWithArrayParent0AITasksTask? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1372,6 +1385,17 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + UnnamedSchemaWithArrayParent0AITasksTaskSelectTags _ => 0, + UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata _ => 1, + UnnamedSchemaWithArrayParent0AITasksTaskYesNo _ => 2, + _ => -1, + }; + } } sealed class UnnamedSchemaWithArrayParent0AITasksTaskConverter @@ -2058,10 +2082,10 @@ public override void Validate() public virtual bool Equals( UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabulary? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -2070,6 +2094,17 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + bool _ => 2, + _ => -1, + }; + } } sealed class UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabularyConverter @@ -2834,10 +2869,10 @@ public override void Validate() public virtual bool Equals( UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -2846,6 +2881,18 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + bool _ => 2, + IReadOnlyList _ => 3, + _ => -1, + }; + } } sealed class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueConverter @@ -3124,10 +3171,10 @@ public override void Validate() } } - public virtual bool Equals(UnnamedSchemaWithArrayParent6? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(UnnamedSchemaWithArrayParent6? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -3136,6 +3183,17 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + bool _ => 2, + _ => -1, + }; + } } sealed class UnnamedSchemaWithArrayParent6Converter : JsonConverter @@ -3817,10 +3875,10 @@ public override void Validate() public virtual bool Equals( UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -3829,6 +3887,18 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + bool _ => 2, + IReadOnlyList _ => 3, + _ => -1, + }; + } } sealed class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueConverter @@ -4107,10 +4177,10 @@ public override void Validate() } } - public virtual bool Equals(UnnamedSchemaWithArrayParent7? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(UnnamedSchemaWithArrayParent7? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -4119,6 +4189,17 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + bool _ => 2, + _ => -1, + }; + } } sealed class UnnamedSchemaWithArrayParent7Converter : JsonConverter @@ -4796,10 +4877,10 @@ public override void Validate() public virtual bool Equals( UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -4808,6 +4889,18 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + bool _ => 2, + IReadOnlyList _ => 3, + _ => -1, + }; + } } sealed class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueConverter @@ -5086,10 +5179,10 @@ public override void Validate() } } - public virtual bool Equals(UnnamedSchemaWithArrayParent8? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(UnnamedSchemaWithArrayParent8? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -5098,6 +5191,17 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + bool _ => 2, + _ => -1, + }; + } } sealed class UnnamedSchemaWithArrayParent8Converter : JsonConverter diff --git a/src/ImageKit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs b/src/ImageKit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs index 824708a5..71bdcb58 100644 --- a/src/ImageKit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs +++ b/src/ImageKit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs @@ -473,10 +473,10 @@ public override void Validate() ); } - public virtual bool Equals(UnsafeUnwrapWebhookEvent? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(UnsafeUnwrapWebhookEvent? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -485,6 +485,21 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + VideoTransformationAcceptedEvent _ => 0, + VideoTransformationReadyEvent _ => 1, + VideoTransformationErrorEvent _ => 2, + UploadPreTransformSuccessEvent _ => 3, + UploadPreTransformErrorEvent _ => 4, + UploadPostTransformSuccessEvent _ => 5, + UploadPostTransformErrorEvent _ => 6, + _ => -1, + }; + } } sealed class UnsafeUnwrapWebhookEventConverter : JsonConverter diff --git a/src/ImageKit/Models/Webhooks/UnwrapWebhookEvent.cs b/src/ImageKit/Models/Webhooks/UnwrapWebhookEvent.cs index 8c29eace..67fa2876 100644 --- a/src/ImageKit/Models/Webhooks/UnwrapWebhookEvent.cs +++ b/src/ImageKit/Models/Webhooks/UnwrapWebhookEvent.cs @@ -452,10 +452,10 @@ public override void Validate() ); } - public virtual bool Equals(UnwrapWebhookEvent? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(UnwrapWebhookEvent? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -464,6 +464,21 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + VideoTransformationAcceptedEvent _ => 0, + VideoTransformationReadyEvent _ => 1, + VideoTransformationErrorEvent _ => 2, + UploadPreTransformSuccessEvent _ => 3, + UploadPreTransformErrorEvent _ => 4, + UploadPostTransformSuccessEvent _ => 5, + UploadPostTransformErrorEvent _ => 6, + _ => -1, + }; + } } sealed class UnwrapWebhookEventConverter : JsonConverter diff --git a/src/ImageKit/Models/Webhooks/UploadPreTransformSuccessEvent.cs b/src/ImageKit/Models/Webhooks/UploadPreTransformSuccessEvent.cs index ef37cb20..63283c90 100644 --- a/src/ImageKit/Models/Webhooks/UploadPreTransformSuccessEvent.cs +++ b/src/ImageKit/Models/Webhooks/UploadPreTransformSuccessEvent.cs @@ -2028,10 +2028,10 @@ public override void Validate() } } - public virtual bool Equals(DefaultValue? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(DefaultValue? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -2040,6 +2040,18 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + bool _ => 2, + IReadOnlyList _ => 3, + _ => -1, + }; + } } sealed class DefaultValueConverter : JsonConverter @@ -2325,10 +2337,10 @@ public override void Validate() } } - public virtual bool Equals(UnnamedSchemaWithArrayParent13? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(UnnamedSchemaWithArrayParent13? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -2337,6 +2349,17 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + bool _ => 2, + _ => -1, + }; + } } sealed class UnnamedSchemaWithArrayParent13Converter : JsonConverter @@ -2566,10 +2589,10 @@ public override void Validate() } } - public virtual bool Equals(MaxValue? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(MaxValue? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -2578,6 +2601,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + _ => -1, + }; + } } sealed class MaxValueConverter : JsonConverter @@ -2794,10 +2827,10 @@ public override void Validate() } } - public virtual bool Equals(MinValue? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(MinValue? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -2806,6 +2839,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + _ => -1, + }; + } } sealed class MinValueConverter : JsonConverter @@ -3062,10 +3105,10 @@ public override void Validate() } } - public virtual bool Equals(SelectOption? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(SelectOption? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -3074,6 +3117,17 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + bool _ => 2, + _ => -1, + }; + } } sealed class SelectOptionConverter : JsonConverter From c11c19adf164e16d9444fb4cff29d1ad7e5aa20a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 2 Feb 2026 03:51:25 +0000 Subject: [PATCH 064/129] fix(api): add missing embeddedMetadata and video properties to FileDetails --- .stats.yml | 4 +- .../Models/Assets/AssetListResponseTest.cs | 16 ++ src/ImageKit.Tests/Models/Files/FileTest.cs | 142 ++++++++++++++++++ .../Models/Files/FileUpdateResponseTest.cs | 142 ++++++++++++++++++ src/ImageKit/Models/Files/File.cs | 116 ++++++++++++++ .../Models/Files/FileUpdateResponse.cs | 121 +++++++++++++++ 6 files changed, 539 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 011cf609..db4fc3c8 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-84f0d75048a9268981a84800b4190e3691997ce57dcfc0876f38a5b3fce6bacd.yml -openapi_spec_hash: 35607d4e850c8a60524223ff632c83bb +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-f2eb530f43b355f7ddab66187e45e4ca6da195825b66ea193bbf38acd3deb055.yml +openapi_spec_hash: 2137c56fcf6ae4c09fcac2891b35f789 config_hash: 47cb702ee2cb52c58d803ae39ade9b44 diff --git a/src/ImageKit.Tests/Models/Assets/AssetListResponseTest.cs b/src/ImageKit.Tests/Models/Assets/AssetListResponseTest.cs index 54a0f19a..142db99a 100644 --- a/src/ImageKit.Tests/Models/Assets/AssetListResponseTest.cs +++ b/src/ImageKit.Tests/Models/Assets/AssetListResponseTest.cs @@ -23,6 +23,8 @@ public void FileValidationWorks() Source = "source", }, ], + AudioCodec = "audioCodec", + BitRate = 0, CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), CustomCoordinates = "customCoordinates", CustomMetadata = new Dictionary() @@ -30,6 +32,11 @@ public void FileValidationWorks() { "foo", JsonSerializer.SerializeToElement("bar") }, }, Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, FileID = "fileId", FilePath = "filePath", FileType = "fileType", @@ -65,6 +72,7 @@ public void FileValidationWorks() UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Url = "https://example.com", VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", Width = 0, }; value.Validate(); @@ -99,6 +107,8 @@ public void FileSerializationRoundtripWorks() Source = "source", }, ], + AudioCodec = "audioCodec", + BitRate = 0, CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), CustomCoordinates = "customCoordinates", CustomMetadata = new Dictionary() @@ -106,6 +116,11 @@ public void FileSerializationRoundtripWorks() { "foo", JsonSerializer.SerializeToElement("bar") }, }, Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, FileID = "fileId", FilePath = "filePath", FileType = "fileType", @@ -141,6 +156,7 @@ public void FileSerializationRoundtripWorks() UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Url = "https://example.com", VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", Width = 0, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); diff --git a/src/ImageKit.Tests/Models/Files/FileTest.cs b/src/ImageKit.Tests/Models/Files/FileTest.cs index 1ef33ac1..bdd84b26 100644 --- a/src/ImageKit.Tests/Models/Files/FileTest.cs +++ b/src/ImageKit.Tests/Models/Files/FileTest.cs @@ -23,6 +23,8 @@ public void FieldRoundtrip_Works() Source = "source", }, ], + AudioCodec = "audioCodec", + BitRate = 0, CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), CustomCoordinates = "customCoordinates", CustomMetadata = new Dictionary() @@ -30,6 +32,11 @@ public void FieldRoundtrip_Works() { "foo", JsonSerializer.SerializeToElement("bar") }, }, Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, FileID = "fileId", FilePath = "filePath", FileType = "fileType", @@ -65,6 +72,7 @@ public void FieldRoundtrip_Works() UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Url = "https://example.com", VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", Width = 0, }; @@ -77,6 +85,8 @@ public void FieldRoundtrip_Works() Source = "source", }, ]; + string expectedAudioCodec = "audioCodec"; + long expectedBitRate = 0; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); string expectedCustomCoordinates = "customCoordinates"; Dictionary expectedCustomMetadata = new() @@ -84,6 +94,11 @@ public void FieldRoundtrip_Works() { "foo", JsonSerializer.SerializeToElement("bar") }, }; string expectedDescription = "description"; + long expectedDuration = 0; + Dictionary expectedEmbeddedMetadata = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; string expectedFileID = "fileId"; string expectedFilePath = "filePath"; string expectedFileType = "fileType"; @@ -119,6 +134,7 @@ public void FieldRoundtrip_Works() DateTimeOffset expectedUpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); string expectedUrl = "https://example.com"; Files::VersionInfo expectedVersionInfo = new() { ID = "id", Name = "name" }; + string expectedVideoCodec = "videoCodec"; double expectedWidth = 0; Assert.NotNull(model.AITags); @@ -127,6 +143,8 @@ public void FieldRoundtrip_Works() { Assert.Equal(expectedAITags[i], model.AITags[i]); } + Assert.Equal(expectedAudioCodec, model.AudioCodec); + Assert.Equal(expectedBitRate, model.BitRate); Assert.Equal(expectedCreatedAt, model.CreatedAt); Assert.Equal(expectedCustomCoordinates, model.CustomCoordinates); Assert.NotNull(model.CustomMetadata); @@ -138,6 +156,15 @@ public void FieldRoundtrip_Works() Assert.True(JsonElement.DeepEquals(value, model.CustomMetadata[item.Key])); } Assert.Equal(expectedDescription, model.Description); + Assert.Equal(expectedDuration, model.Duration); + Assert.NotNull(model.EmbeddedMetadata); + Assert.Equal(expectedEmbeddedMetadata.Count, model.EmbeddedMetadata.Count); + foreach (var item in expectedEmbeddedMetadata) + { + Assert.True(model.EmbeddedMetadata.TryGetValue(item.Key, out var value)); + + Assert.True(JsonElement.DeepEquals(value, model.EmbeddedMetadata[item.Key])); + } Assert.Equal(expectedFileID, model.FileID); Assert.Equal(expectedFilePath, model.FilePath); Assert.Equal(expectedFileType, model.FileType); @@ -167,6 +194,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedUpdatedAt, model.UpdatedAt); Assert.Equal(expectedUrl, model.Url); Assert.Equal(expectedVersionInfo, model.VersionInfo); + Assert.Equal(expectedVideoCodec, model.VideoCodec); Assert.Equal(expectedWidth, model.Width); } @@ -184,6 +212,8 @@ public void SerializationRoundtrip_Works() Source = "source", }, ], + AudioCodec = "audioCodec", + BitRate = 0, CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), CustomCoordinates = "customCoordinates", CustomMetadata = new Dictionary() @@ -191,6 +221,11 @@ public void SerializationRoundtrip_Works() { "foo", JsonSerializer.SerializeToElement("bar") }, }, Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, FileID = "fileId", FilePath = "filePath", FileType = "fileType", @@ -226,6 +261,7 @@ public void SerializationRoundtrip_Works() UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Url = "https://example.com", VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", Width = 0, }; @@ -252,6 +288,8 @@ public void FieldRoundtripThroughSerialization_Works() Source = "source", }, ], + AudioCodec = "audioCodec", + BitRate = 0, CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), CustomCoordinates = "customCoordinates", CustomMetadata = new Dictionary() @@ -259,6 +297,11 @@ public void FieldRoundtripThroughSerialization_Works() { "foo", JsonSerializer.SerializeToElement("bar") }, }, Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, FileID = "fileId", FilePath = "filePath", FileType = "fileType", @@ -294,6 +337,7 @@ public void FieldRoundtripThroughSerialization_Works() UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Url = "https://example.com", VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", Width = 0, }; @@ -313,6 +357,8 @@ public void FieldRoundtripThroughSerialization_Works() Source = "source", }, ]; + string expectedAudioCodec = "audioCodec"; + long expectedBitRate = 0; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); string expectedCustomCoordinates = "customCoordinates"; Dictionary expectedCustomMetadata = new() @@ -320,6 +366,11 @@ public void FieldRoundtripThroughSerialization_Works() { "foo", JsonSerializer.SerializeToElement("bar") }, }; string expectedDescription = "description"; + long expectedDuration = 0; + Dictionary expectedEmbeddedMetadata = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; string expectedFileID = "fileId"; string expectedFilePath = "filePath"; string expectedFileType = "fileType"; @@ -355,6 +406,7 @@ public void FieldRoundtripThroughSerialization_Works() DateTimeOffset expectedUpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); string expectedUrl = "https://example.com"; Files::VersionInfo expectedVersionInfo = new() { ID = "id", Name = "name" }; + string expectedVideoCodec = "videoCodec"; double expectedWidth = 0; Assert.NotNull(deserialized.AITags); @@ -363,6 +415,8 @@ public void FieldRoundtripThroughSerialization_Works() { Assert.Equal(expectedAITags[i], deserialized.AITags[i]); } + Assert.Equal(expectedAudioCodec, deserialized.AudioCodec); + Assert.Equal(expectedBitRate, deserialized.BitRate); Assert.Equal(expectedCreatedAt, deserialized.CreatedAt); Assert.Equal(expectedCustomCoordinates, deserialized.CustomCoordinates); Assert.NotNull(deserialized.CustomMetadata); @@ -374,6 +428,15 @@ public void FieldRoundtripThroughSerialization_Works() Assert.True(JsonElement.DeepEquals(value, deserialized.CustomMetadata[item.Key])); } Assert.Equal(expectedDescription, deserialized.Description); + Assert.Equal(expectedDuration, deserialized.Duration); + Assert.NotNull(deserialized.EmbeddedMetadata); + Assert.Equal(expectedEmbeddedMetadata.Count, deserialized.EmbeddedMetadata.Count); + foreach (var item in expectedEmbeddedMetadata) + { + Assert.True(deserialized.EmbeddedMetadata.TryGetValue(item.Key, out var value)); + + Assert.True(JsonElement.DeepEquals(value, deserialized.EmbeddedMetadata[item.Key])); + } Assert.Equal(expectedFileID, deserialized.FileID); Assert.Equal(expectedFilePath, deserialized.FilePath); Assert.Equal(expectedFileType, deserialized.FileType); @@ -403,6 +466,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedUpdatedAt, deserialized.UpdatedAt); Assert.Equal(expectedUrl, deserialized.Url); Assert.Equal(expectedVersionInfo, deserialized.VersionInfo); + Assert.Equal(expectedVideoCodec, deserialized.VideoCodec); Assert.Equal(expectedWidth, deserialized.Width); } @@ -420,6 +484,8 @@ public void Validation_Works() Source = "source", }, ], + AudioCodec = "audioCodec", + BitRate = 0, CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), CustomCoordinates = "customCoordinates", CustomMetadata = new Dictionary() @@ -427,6 +493,11 @@ public void Validation_Works() { "foo", JsonSerializer.SerializeToElement("bar") }, }, Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, FileID = "fileId", FilePath = "filePath", FileType = "fileType", @@ -462,6 +533,7 @@ public void Validation_Works() UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Url = "https://example.com", VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", Width = 0, }; @@ -486,12 +558,20 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() Tags = ["string"], }; + Assert.Null(model.AudioCodec); + Assert.False(model.RawData.ContainsKey("audioCodec")); + Assert.Null(model.BitRate); + Assert.False(model.RawData.ContainsKey("bitRate")); Assert.Null(model.CreatedAt); Assert.False(model.RawData.ContainsKey("createdAt")); Assert.Null(model.CustomMetadata); Assert.False(model.RawData.ContainsKey("customMetadata")); Assert.Null(model.Description); Assert.False(model.RawData.ContainsKey("description")); + Assert.Null(model.Duration); + Assert.False(model.RawData.ContainsKey("duration")); + Assert.Null(model.EmbeddedMetadata); + Assert.False(model.RawData.ContainsKey("embeddedMetadata")); Assert.Null(model.FileID); Assert.False(model.RawData.ContainsKey("fileId")); Assert.Null(model.FilePath); @@ -524,6 +604,8 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("url")); Assert.Null(model.VersionInfo); Assert.False(model.RawData.ContainsKey("versionInfo")); + Assert.Null(model.VideoCodec); + Assert.False(model.RawData.ContainsKey("videoCodec")); Assert.Null(model.Width); Assert.False(model.RawData.ContainsKey("width")); } @@ -567,9 +649,13 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() Tags = ["string"], // Null should be interpreted as omitted for these properties + AudioCodec = null, + BitRate = null, CreatedAt = null, CustomMetadata = null, Description = null, + Duration = null, + EmbeddedMetadata = null, FileID = null, FilePath = null, FileType = null, @@ -586,15 +672,24 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() UpdatedAt = null, Url = null, VersionInfo = null, + VideoCodec = null, Width = null, }; + Assert.Null(model.AudioCodec); + Assert.False(model.RawData.ContainsKey("audioCodec")); + Assert.Null(model.BitRate); + Assert.False(model.RawData.ContainsKey("bitRate")); Assert.Null(model.CreatedAt); Assert.False(model.RawData.ContainsKey("createdAt")); Assert.Null(model.CustomMetadata); Assert.False(model.RawData.ContainsKey("customMetadata")); Assert.Null(model.Description); Assert.False(model.RawData.ContainsKey("description")); + Assert.Null(model.Duration); + Assert.False(model.RawData.ContainsKey("duration")); + Assert.Null(model.EmbeddedMetadata); + Assert.False(model.RawData.ContainsKey("embeddedMetadata")); Assert.Null(model.FileID); Assert.False(model.RawData.ContainsKey("fileId")); Assert.Null(model.FilePath); @@ -627,6 +722,8 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() Assert.False(model.RawData.ContainsKey("url")); Assert.Null(model.VersionInfo); Assert.False(model.RawData.ContainsKey("versionInfo")); + Assert.Null(model.VideoCodec); + Assert.False(model.RawData.ContainsKey("videoCodec")); Assert.Null(model.Width); Assert.False(model.RawData.ContainsKey("width")); } @@ -649,9 +746,13 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() Tags = ["string"], // Null should be interpreted as omitted for these properties + AudioCodec = null, + BitRate = null, CreatedAt = null, CustomMetadata = null, Description = null, + Duration = null, + EmbeddedMetadata = null, FileID = null, FilePath = null, FileType = null, @@ -668,6 +769,7 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() UpdatedAt = null, Url = null, VersionInfo = null, + VideoCodec = null, Width = null, }; @@ -679,12 +781,19 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() { var model = new Files::File { + AudioCodec = "audioCodec", + BitRate = 0, CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), CustomMetadata = new Dictionary() { { "foo", JsonSerializer.SerializeToElement("bar") }, }, Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, FileID = "fileId", FilePath = "filePath", FileType = "fileType", @@ -719,6 +828,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Url = "https://example.com", VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", Width = 0, }; @@ -735,12 +845,19 @@ public void OptionalNullablePropertiesUnsetValidation_Works() { var model = new Files::File { + AudioCodec = "audioCodec", + BitRate = 0, CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), CustomMetadata = new Dictionary() { { "foo", JsonSerializer.SerializeToElement("bar") }, }, Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, FileID = "fileId", FilePath = "filePath", FileType = "fileType", @@ -775,6 +892,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Url = "https://example.com", VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", Width = 0, }; @@ -786,12 +904,19 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { var model = new Files::File { + AudioCodec = "audioCodec", + BitRate = 0, CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), CustomMetadata = new Dictionary() { { "foo", JsonSerializer.SerializeToElement("bar") }, }, Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, FileID = "fileId", FilePath = "filePath", FileType = "fileType", @@ -826,6 +951,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Url = "https://example.com", VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", Width = 0, AITags = null, @@ -846,12 +972,19 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() { var model = new Files::File { + AudioCodec = "audioCodec", + BitRate = 0, CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), CustomMetadata = new Dictionary() { { "foo", JsonSerializer.SerializeToElement("bar") }, }, Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, FileID = "fileId", FilePath = "filePath", FileType = "fileType", @@ -886,6 +1019,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Url = "https://example.com", VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", Width = 0, AITags = null, @@ -910,6 +1044,8 @@ public void CopyConstructor_Works() Source = "source", }, ], + AudioCodec = "audioCodec", + BitRate = 0, CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), CustomCoordinates = "customCoordinates", CustomMetadata = new Dictionary() @@ -917,6 +1053,11 @@ public void CopyConstructor_Works() { "foo", JsonSerializer.SerializeToElement("bar") }, }, Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, FileID = "fileId", FilePath = "filePath", FileType = "fileType", @@ -952,6 +1093,7 @@ public void CopyConstructor_Works() UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Url = "https://example.com", VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", Width = 0, }; diff --git a/src/ImageKit.Tests/Models/Files/FileUpdateResponseTest.cs b/src/ImageKit.Tests/Models/Files/FileUpdateResponseTest.cs index 54743c5a..20f316ca 100644 --- a/src/ImageKit.Tests/Models/Files/FileUpdateResponseTest.cs +++ b/src/ImageKit.Tests/Models/Files/FileUpdateResponseTest.cs @@ -23,6 +23,8 @@ public void FieldRoundtrip_Works() Source = "source", }, ], + AudioCodec = "audioCodec", + BitRate = 0, CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), CustomCoordinates = "customCoordinates", CustomMetadata = new Dictionary() @@ -30,6 +32,11 @@ public void FieldRoundtrip_Works() { "foo", JsonSerializer.SerializeToElement("bar") }, }, Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, FileID = "fileId", FilePath = "filePath", FileType = "fileType", @@ -65,6 +72,7 @@ public void FieldRoundtrip_Works() UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Url = "https://example.com", VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", Width = 0, ExtensionStatus = new() { @@ -85,6 +93,8 @@ public void FieldRoundtrip_Works() Source = "source", }, ]; + string expectedAudioCodec = "audioCodec"; + long expectedBitRate = 0; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); string expectedCustomCoordinates = "customCoordinates"; Dictionary expectedCustomMetadata = new() @@ -92,6 +102,11 @@ public void FieldRoundtrip_Works() { "foo", JsonSerializer.SerializeToElement("bar") }, }; string expectedDescription = "description"; + long expectedDuration = 0; + Dictionary expectedEmbeddedMetadata = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; string expectedFileID = "fileId"; string expectedFilePath = "filePath"; string expectedFileType = "fileType"; @@ -127,6 +142,7 @@ public void FieldRoundtrip_Works() DateTimeOffset expectedUpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); string expectedUrl = "https://example.com"; Files::VersionInfo expectedVersionInfo = new() { ID = "id", Name = "name" }; + string expectedVideoCodec = "videoCodec"; double expectedWidth = 0; Files::ExtensionStatus expectedExtensionStatus = new() { @@ -143,6 +159,8 @@ public void FieldRoundtrip_Works() { Assert.Equal(expectedAITags[i], model.AITags[i]); } + Assert.Equal(expectedAudioCodec, model.AudioCodec); + Assert.Equal(expectedBitRate, model.BitRate); Assert.Equal(expectedCreatedAt, model.CreatedAt); Assert.Equal(expectedCustomCoordinates, model.CustomCoordinates); Assert.NotNull(model.CustomMetadata); @@ -154,6 +172,15 @@ public void FieldRoundtrip_Works() Assert.True(JsonElement.DeepEquals(value, model.CustomMetadata[item.Key])); } Assert.Equal(expectedDescription, model.Description); + Assert.Equal(expectedDuration, model.Duration); + Assert.NotNull(model.EmbeddedMetadata); + Assert.Equal(expectedEmbeddedMetadata.Count, model.EmbeddedMetadata.Count); + foreach (var item in expectedEmbeddedMetadata) + { + Assert.True(model.EmbeddedMetadata.TryGetValue(item.Key, out var value)); + + Assert.True(JsonElement.DeepEquals(value, model.EmbeddedMetadata[item.Key])); + } Assert.Equal(expectedFileID, model.FileID); Assert.Equal(expectedFilePath, model.FilePath); Assert.Equal(expectedFileType, model.FileType); @@ -183,6 +210,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedUpdatedAt, model.UpdatedAt); Assert.Equal(expectedUrl, model.Url); Assert.Equal(expectedVersionInfo, model.VersionInfo); + Assert.Equal(expectedVideoCodec, model.VideoCodec); Assert.Equal(expectedWidth, model.Width); Assert.Equal(expectedExtensionStatus, model.ExtensionStatus); } @@ -201,6 +229,8 @@ public void SerializationRoundtrip_Works() Source = "source", }, ], + AudioCodec = "audioCodec", + BitRate = 0, CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), CustomCoordinates = "customCoordinates", CustomMetadata = new Dictionary() @@ -208,6 +238,11 @@ public void SerializationRoundtrip_Works() { "foo", JsonSerializer.SerializeToElement("bar") }, }, Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, FileID = "fileId", FilePath = "filePath", FileType = "fileType", @@ -243,6 +278,7 @@ public void SerializationRoundtrip_Works() UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Url = "https://example.com", VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", Width = 0, ExtensionStatus = new() { @@ -277,6 +313,8 @@ public void FieldRoundtripThroughSerialization_Works() Source = "source", }, ], + AudioCodec = "audioCodec", + BitRate = 0, CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), CustomCoordinates = "customCoordinates", CustomMetadata = new Dictionary() @@ -284,6 +322,11 @@ public void FieldRoundtripThroughSerialization_Works() { "foo", JsonSerializer.SerializeToElement("bar") }, }, Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, FileID = "fileId", FilePath = "filePath", FileType = "fileType", @@ -319,6 +362,7 @@ public void FieldRoundtripThroughSerialization_Works() UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Url = "https://example.com", VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", Width = 0, ExtensionStatus = new() { @@ -346,6 +390,8 @@ public void FieldRoundtripThroughSerialization_Works() Source = "source", }, ]; + string expectedAudioCodec = "audioCodec"; + long expectedBitRate = 0; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); string expectedCustomCoordinates = "customCoordinates"; Dictionary expectedCustomMetadata = new() @@ -353,6 +399,11 @@ public void FieldRoundtripThroughSerialization_Works() { "foo", JsonSerializer.SerializeToElement("bar") }, }; string expectedDescription = "description"; + long expectedDuration = 0; + Dictionary expectedEmbeddedMetadata = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; string expectedFileID = "fileId"; string expectedFilePath = "filePath"; string expectedFileType = "fileType"; @@ -388,6 +439,7 @@ public void FieldRoundtripThroughSerialization_Works() DateTimeOffset expectedUpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); string expectedUrl = "https://example.com"; Files::VersionInfo expectedVersionInfo = new() { ID = "id", Name = "name" }; + string expectedVideoCodec = "videoCodec"; double expectedWidth = 0; Files::ExtensionStatus expectedExtensionStatus = new() { @@ -404,6 +456,8 @@ public void FieldRoundtripThroughSerialization_Works() { Assert.Equal(expectedAITags[i], deserialized.AITags[i]); } + Assert.Equal(expectedAudioCodec, deserialized.AudioCodec); + Assert.Equal(expectedBitRate, deserialized.BitRate); Assert.Equal(expectedCreatedAt, deserialized.CreatedAt); Assert.Equal(expectedCustomCoordinates, deserialized.CustomCoordinates); Assert.NotNull(deserialized.CustomMetadata); @@ -415,6 +469,15 @@ public void FieldRoundtripThroughSerialization_Works() Assert.True(JsonElement.DeepEquals(value, deserialized.CustomMetadata[item.Key])); } Assert.Equal(expectedDescription, deserialized.Description); + Assert.Equal(expectedDuration, deserialized.Duration); + Assert.NotNull(deserialized.EmbeddedMetadata); + Assert.Equal(expectedEmbeddedMetadata.Count, deserialized.EmbeddedMetadata.Count); + foreach (var item in expectedEmbeddedMetadata) + { + Assert.True(deserialized.EmbeddedMetadata.TryGetValue(item.Key, out var value)); + + Assert.True(JsonElement.DeepEquals(value, deserialized.EmbeddedMetadata[item.Key])); + } Assert.Equal(expectedFileID, deserialized.FileID); Assert.Equal(expectedFilePath, deserialized.FilePath); Assert.Equal(expectedFileType, deserialized.FileType); @@ -444,6 +507,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedUpdatedAt, deserialized.UpdatedAt); Assert.Equal(expectedUrl, deserialized.Url); Assert.Equal(expectedVersionInfo, deserialized.VersionInfo); + Assert.Equal(expectedVideoCodec, deserialized.VideoCodec); Assert.Equal(expectedWidth, deserialized.Width); Assert.Equal(expectedExtensionStatus, deserialized.ExtensionStatus); } @@ -462,6 +526,8 @@ public void Validation_Works() Source = "source", }, ], + AudioCodec = "audioCodec", + BitRate = 0, CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), CustomCoordinates = "customCoordinates", CustomMetadata = new Dictionary() @@ -469,6 +535,11 @@ public void Validation_Works() { "foo", JsonSerializer.SerializeToElement("bar") }, }, Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, FileID = "fileId", FilePath = "filePath", FileType = "fileType", @@ -504,6 +575,7 @@ public void Validation_Works() UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Url = "https://example.com", VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", Width = 0, ExtensionStatus = new() { @@ -536,12 +608,20 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() Tags = ["string"], }; + Assert.Null(model.AudioCodec); + Assert.False(model.RawData.ContainsKey("audioCodec")); + Assert.Null(model.BitRate); + Assert.False(model.RawData.ContainsKey("bitRate")); Assert.Null(model.CreatedAt); Assert.False(model.RawData.ContainsKey("createdAt")); Assert.Null(model.CustomMetadata); Assert.False(model.RawData.ContainsKey("customMetadata")); Assert.Null(model.Description); Assert.False(model.RawData.ContainsKey("description")); + Assert.Null(model.Duration); + Assert.False(model.RawData.ContainsKey("duration")); + Assert.Null(model.EmbeddedMetadata); + Assert.False(model.RawData.ContainsKey("embeddedMetadata")); Assert.Null(model.FileID); Assert.False(model.RawData.ContainsKey("fileId")); Assert.Null(model.FilePath); @@ -574,6 +654,8 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("url")); Assert.Null(model.VersionInfo); Assert.False(model.RawData.ContainsKey("versionInfo")); + Assert.Null(model.VideoCodec); + Assert.False(model.RawData.ContainsKey("videoCodec")); Assert.Null(model.Width); Assert.False(model.RawData.ContainsKey("width")); Assert.Null(model.ExtensionStatus); @@ -619,9 +701,13 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() Tags = ["string"], // Null should be interpreted as omitted for these properties + AudioCodec = null, + BitRate = null, CreatedAt = null, CustomMetadata = null, Description = null, + Duration = null, + EmbeddedMetadata = null, FileID = null, FilePath = null, FileType = null, @@ -638,16 +724,25 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() UpdatedAt = null, Url = null, VersionInfo = null, + VideoCodec = null, Width = null, ExtensionStatus = null, }; + Assert.Null(model.AudioCodec); + Assert.False(model.RawData.ContainsKey("audioCodec")); + Assert.Null(model.BitRate); + Assert.False(model.RawData.ContainsKey("bitRate")); Assert.Null(model.CreatedAt); Assert.False(model.RawData.ContainsKey("createdAt")); Assert.Null(model.CustomMetadata); Assert.False(model.RawData.ContainsKey("customMetadata")); Assert.Null(model.Description); Assert.False(model.RawData.ContainsKey("description")); + Assert.Null(model.Duration); + Assert.False(model.RawData.ContainsKey("duration")); + Assert.Null(model.EmbeddedMetadata); + Assert.False(model.RawData.ContainsKey("embeddedMetadata")); Assert.Null(model.FileID); Assert.False(model.RawData.ContainsKey("fileId")); Assert.Null(model.FilePath); @@ -680,6 +775,8 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() Assert.False(model.RawData.ContainsKey("url")); Assert.Null(model.VersionInfo); Assert.False(model.RawData.ContainsKey("versionInfo")); + Assert.Null(model.VideoCodec); + Assert.False(model.RawData.ContainsKey("videoCodec")); Assert.Null(model.Width); Assert.False(model.RawData.ContainsKey("width")); Assert.Null(model.ExtensionStatus); @@ -704,9 +801,13 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() Tags = ["string"], // Null should be interpreted as omitted for these properties + AudioCodec = null, + BitRate = null, CreatedAt = null, CustomMetadata = null, Description = null, + Duration = null, + EmbeddedMetadata = null, FileID = null, FilePath = null, FileType = null, @@ -723,6 +824,7 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() UpdatedAt = null, Url = null, VersionInfo = null, + VideoCodec = null, Width = null, ExtensionStatus = null, }; @@ -735,12 +837,19 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() { var model = new Files::FileUpdateResponse { + AudioCodec = "audioCodec", + BitRate = 0, CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), CustomMetadata = new Dictionary() { { "foo", JsonSerializer.SerializeToElement("bar") }, }, Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, FileID = "fileId", FilePath = "filePath", FileType = "fileType", @@ -775,6 +884,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Url = "https://example.com", VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", Width = 0, ExtensionStatus = new() { @@ -799,12 +909,19 @@ public void OptionalNullablePropertiesUnsetValidation_Works() { var model = new Files::FileUpdateResponse { + AudioCodec = "audioCodec", + BitRate = 0, CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), CustomMetadata = new Dictionary() { { "foo", JsonSerializer.SerializeToElement("bar") }, }, Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, FileID = "fileId", FilePath = "filePath", FileType = "fileType", @@ -839,6 +956,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Url = "https://example.com", VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", Width = 0, ExtensionStatus = new() { @@ -858,12 +976,19 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { var model = new Files::FileUpdateResponse { + AudioCodec = "audioCodec", + BitRate = 0, CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), CustomMetadata = new Dictionary() { { "foo", JsonSerializer.SerializeToElement("bar") }, }, Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, FileID = "fileId", FilePath = "filePath", FileType = "fileType", @@ -898,6 +1023,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Url = "https://example.com", VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", Width = 0, ExtensionStatus = new() { @@ -926,12 +1052,19 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() { var model = new Files::FileUpdateResponse { + AudioCodec = "audioCodec", + BitRate = 0, CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), CustomMetadata = new Dictionary() { { "foo", JsonSerializer.SerializeToElement("bar") }, }, Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, FileID = "fileId", FilePath = "filePath", FileType = "fileType", @@ -966,6 +1099,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Url = "https://example.com", VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", Width = 0, ExtensionStatus = new() { @@ -998,6 +1132,8 @@ public void CopyConstructor_Works() Source = "source", }, ], + AudioCodec = "audioCodec", + BitRate = 0, CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), CustomCoordinates = "customCoordinates", CustomMetadata = new Dictionary() @@ -1005,6 +1141,11 @@ public void CopyConstructor_Works() { "foo", JsonSerializer.SerializeToElement("bar") }, }, Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, FileID = "fileId", FilePath = "filePath", FileType = "fileType", @@ -1040,6 +1181,7 @@ public void CopyConstructor_Works() UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Url = "https://example.com", VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", Width = 0, ExtensionStatus = new() { diff --git a/src/ImageKit/Models/Files/File.cs b/src/ImageKit/Models/Files/File.cs index ab6a0b50..b2e4fe1f 100644 --- a/src/ImageKit/Models/Files/File.cs +++ b/src/ImageKit/Models/Files/File.cs @@ -35,6 +35,48 @@ public IReadOnlyList? AITags } } + /// + /// The audio codec used in the video (only for video/audio). + /// + public string? AudioCodec + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("audioCodec"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("audioCodec", value); + } + } + + /// + /// The bit rate of the video in kbps (only for video). + /// + public long? BitRate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("bitRate"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("bitRate", value); + } + } + /// /// Date and time when the file was uploaded. The date and time is in ISO8601 /// format. @@ -118,6 +160,54 @@ public string? Description } } + /// + /// The duration of the video in seconds (only for video). + /// + public long? Duration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("duration"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("duration", value); + } + } + + /// + /// Consolidated embedded metadata associated with the file. It includes exif, + /// iptc, and xmp data. + /// + public IReadOnlyDictionary? EmbeddedMetadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>( + "embeddedMetadata" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "embeddedMetadata", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + /// /// Unique identifier of the asset. /// @@ -490,6 +580,27 @@ public VersionInfo? VersionInfo } } + /// + /// The video codec used in the video (only for video). + /// + public string? VideoCodec + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("videoCodec"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("videoCodec", value); + } + } + /// /// Width of the file. /// @@ -518,10 +629,14 @@ public override void Validate() { item.Validate(); } + _ = this.AudioCodec; + _ = this.BitRate; _ = this.CreatedAt; _ = this.CustomCoordinates; _ = this.CustomMetadata; _ = this.Description; + _ = this.Duration; + _ = this.EmbeddedMetadata; _ = this.FileID; _ = this.FilePath; _ = this.FileType; @@ -545,6 +660,7 @@ public override void Validate() _ = this.UpdatedAt; _ = this.Url; this.VersionInfo?.Validate(); + _ = this.VideoCodec; _ = this.Width; } diff --git a/src/ImageKit/Models/Files/FileUpdateResponse.cs b/src/ImageKit/Models/Files/FileUpdateResponse.cs index de7b30ad..ed38ad4d 100644 --- a/src/ImageKit/Models/Files/FileUpdateResponse.cs +++ b/src/ImageKit/Models/Files/FileUpdateResponse.cs @@ -35,6 +35,48 @@ public IReadOnlyList? AITags } } + /// + /// The audio codec used in the video (only for video/audio). + /// + public string? AudioCodec + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("audioCodec"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("audioCodec", value); + } + } + + /// + /// The bit rate of the video in kbps (only for video). + /// + public long? BitRate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("bitRate"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("bitRate", value); + } + } + /// /// Date and time when the file was uploaded. The date and time is in ISO8601 /// format. @@ -118,6 +160,54 @@ public string? Description } } + /// + /// The duration of the video in seconds (only for video). + /// + public long? Duration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("duration"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("duration", value); + } + } + + /// + /// Consolidated embedded metadata associated with the file. It includes exif, + /// iptc, and xmp data. + /// + public IReadOnlyDictionary? EmbeddedMetadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>( + "embeddedMetadata" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "embeddedMetadata", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + /// /// Unique identifier of the asset. /// @@ -490,6 +580,27 @@ public VersionInfo? VersionInfo } } + /// + /// The video codec used in the video (only for video). + /// + public string? VideoCodec + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("videoCodec"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("videoCodec", value); + } + } + /// /// Width of the file. /// @@ -533,10 +644,14 @@ public static implicit operator File(FileUpdateResponse fileUpdateResponse) => new() { AITags = fileUpdateResponse.AITags, + AudioCodec = fileUpdateResponse.AudioCodec, + BitRate = fileUpdateResponse.BitRate, CreatedAt = fileUpdateResponse.CreatedAt, CustomCoordinates = fileUpdateResponse.CustomCoordinates, CustomMetadata = fileUpdateResponse.CustomMetadata, Description = fileUpdateResponse.Description, + Duration = fileUpdateResponse.Duration, + EmbeddedMetadata = fileUpdateResponse.EmbeddedMetadata, FileID = fileUpdateResponse.FileID, FilePath = fileUpdateResponse.FilePath, FileType = fileUpdateResponse.FileType, @@ -554,6 +669,7 @@ public static implicit operator File(FileUpdateResponse fileUpdateResponse) => UpdatedAt = fileUpdateResponse.UpdatedAt, Url = fileUpdateResponse.Url, VersionInfo = fileUpdateResponse.VersionInfo, + VideoCodec = fileUpdateResponse.VideoCodec, Width = fileUpdateResponse.Width, }; @@ -564,10 +680,14 @@ public override void Validate() { item.Validate(); } + _ = this.AudioCodec; + _ = this.BitRate; _ = this.CreatedAt; _ = this.CustomCoordinates; _ = this.CustomMetadata; _ = this.Description; + _ = this.Duration; + _ = this.EmbeddedMetadata; _ = this.FileID; _ = this.FilePath; _ = this.FileType; @@ -591,6 +711,7 @@ public override void Validate() _ = this.UpdatedAt; _ = this.Url; this.VersionInfo?.Validate(); + _ = this.VideoCodec; _ = this.Width; this.ExtensionStatus?.Validate(); } From 3b87d89bcd3d121b3d2168a4c8673c14da628662 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 2 Feb 2026 04:47:37 +0000 Subject: [PATCH 065/129] feat(api): add customMetadata property to folder schema --- .stats.yml | 4 +- .../Models/Assets/AssetListResponseTest.cs | 8 +++ src/ImageKit.Tests/Models/Files/FolderTest.cs | 51 +++++++++++++++++++ src/ImageKit/Models/Files/Folder.cs | 28 ++++++++++ 4 files changed, 89 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index db4fc3c8..dbc39e12 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-f2eb530f43b355f7ddab66187e45e4ca6da195825b66ea193bbf38acd3deb055.yml -openapi_spec_hash: 2137c56fcf6ae4c09fcac2891b35f789 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-13fc3d7cafdea492f62eef7c1d63424d6d9d8adbff74b9f6ca6fd3fc12a36840.yml +openapi_spec_hash: a1fe6fa48207791657a1ea2d60a6dfcc config_hash: 47cb702ee2cb52c58d803ae39ade9b44 diff --git a/src/ImageKit.Tests/Models/Assets/AssetListResponseTest.cs b/src/ImageKit.Tests/Models/Assets/AssetListResponseTest.cs index 142db99a..175d7d0f 100644 --- a/src/ImageKit.Tests/Models/Assets/AssetListResponseTest.cs +++ b/src/ImageKit.Tests/Models/Assets/AssetListResponseTest.cs @@ -84,6 +84,10 @@ public void FolderValidationWorks() AssetListResponse value = new Files::Folder() { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, FolderID = "folderId", FolderPath = "folderPath", Name = "name", @@ -174,6 +178,10 @@ public void FolderSerializationRoundtripWorks() AssetListResponse value = new Files::Folder() { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, FolderID = "folderId", FolderPath = "folderPath", Name = "name", diff --git a/src/ImageKit.Tests/Models/Files/FolderTest.cs b/src/ImageKit.Tests/Models/Files/FolderTest.cs index d8d2018d..132317df 100644 --- a/src/ImageKit.Tests/Models/Files/FolderTest.cs +++ b/src/ImageKit.Tests/Models/Files/FolderTest.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Text.Json; using ImageKit.Core; using ImageKit.Exceptions; @@ -14,6 +15,10 @@ public void FieldRoundtrip_Works() var model = new Folder { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, FolderID = "folderId", FolderPath = "folderPath", Name = "name", @@ -22,6 +27,10 @@ public void FieldRoundtrip_Works() }; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + Dictionary expectedCustomMetadata = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; string expectedFolderID = "folderId"; string expectedFolderPath = "folderPath"; string expectedName = "name"; @@ -29,6 +38,14 @@ public void FieldRoundtrip_Works() DateTimeOffset expectedUpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); Assert.Equal(expectedCreatedAt, model.CreatedAt); + Assert.NotNull(model.CustomMetadata); + Assert.Equal(expectedCustomMetadata.Count, model.CustomMetadata.Count); + foreach (var item in expectedCustomMetadata) + { + Assert.True(model.CustomMetadata.TryGetValue(item.Key, out var value)); + + Assert.True(JsonElement.DeepEquals(value, model.CustomMetadata[item.Key])); + } Assert.Equal(expectedFolderID, model.FolderID); Assert.Equal(expectedFolderPath, model.FolderPath); Assert.Equal(expectedName, model.Name); @@ -42,6 +59,10 @@ public void SerializationRoundtrip_Works() var model = new Folder { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, FolderID = "folderId", FolderPath = "folderPath", Name = "name", @@ -61,6 +82,10 @@ public void FieldRoundtripThroughSerialization_Works() var model = new Folder { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, FolderID = "folderId", FolderPath = "folderPath", Name = "name", @@ -73,6 +98,10 @@ public void FieldRoundtripThroughSerialization_Works() Assert.NotNull(deserialized); DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + Dictionary expectedCustomMetadata = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; string expectedFolderID = "folderId"; string expectedFolderPath = "folderPath"; string expectedName = "name"; @@ -80,6 +109,14 @@ public void FieldRoundtripThroughSerialization_Works() DateTimeOffset expectedUpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); Assert.Equal(expectedCreatedAt, deserialized.CreatedAt); + Assert.NotNull(deserialized.CustomMetadata); + Assert.Equal(expectedCustomMetadata.Count, deserialized.CustomMetadata.Count); + foreach (var item in expectedCustomMetadata) + { + Assert.True(deserialized.CustomMetadata.TryGetValue(item.Key, out var value)); + + Assert.True(JsonElement.DeepEquals(value, deserialized.CustomMetadata[item.Key])); + } Assert.Equal(expectedFolderID, deserialized.FolderID); Assert.Equal(expectedFolderPath, deserialized.FolderPath); Assert.Equal(expectedName, deserialized.Name); @@ -93,6 +130,10 @@ public void Validation_Works() var model = new Folder { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, FolderID = "folderId", FolderPath = "folderPath", Name = "name", @@ -110,6 +151,8 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() Assert.Null(model.CreatedAt); Assert.False(model.RawData.ContainsKey("createdAt")); + Assert.Null(model.CustomMetadata); + Assert.False(model.RawData.ContainsKey("customMetadata")); Assert.Null(model.FolderID); Assert.False(model.RawData.ContainsKey("folderId")); Assert.Null(model.FolderPath); @@ -137,6 +180,7 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { // Null should be interpreted as omitted for these properties CreatedAt = null, + CustomMetadata = null, FolderID = null, FolderPath = null, Name = null, @@ -146,6 +190,8 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() Assert.Null(model.CreatedAt); Assert.False(model.RawData.ContainsKey("createdAt")); + Assert.Null(model.CustomMetadata); + Assert.False(model.RawData.ContainsKey("customMetadata")); Assert.Null(model.FolderID); Assert.False(model.RawData.ContainsKey("folderId")); Assert.Null(model.FolderPath); @@ -165,6 +211,7 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() { // Null should be interpreted as omitted for these properties CreatedAt = null, + CustomMetadata = null, FolderID = null, FolderPath = null, Name = null, @@ -181,6 +228,10 @@ public void CopyConstructor_Works() var model = new Folder { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, FolderID = "folderId", FolderPath = "folderPath", Name = "name", diff --git a/src/ImageKit/Models/Files/Folder.cs b/src/ImageKit/Models/Files/Folder.cs index c8592d26..9b309071 100644 --- a/src/ImageKit/Models/Files/Folder.cs +++ b/src/ImageKit/Models/Files/Folder.cs @@ -34,6 +34,33 @@ public sealed record class Folder : JsonModel } } + /// + /// An object with custom metadata for the folder. Returns empty object if no + /// custom metadata is set. + /// + public IReadOnlyDictionary? CustomMetadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>( + "customMetadata" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "customMetadata", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + /// /// Unique identifier of the asset. /// @@ -147,6 +174,7 @@ public ApiEnum? Type public override void Validate() { _ = this.CreatedAt; + _ = this.CustomMetadata; _ = this.FolderID; _ = this.FolderPath; _ = this.Name; From e833bbe77e182f8fd59eaf888bbb4b3240bf1389 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 6 Feb 2026 22:05:52 +0000 Subject: [PATCH 066/129] fix(client): handle edge case with renamed variable --- .../Beta/V2/Files/FileUploadParamsTest.cs | 18 +++++++++--------- .../Models/Files/FileUploadParamsTest.cs | 18 +++++++++--------- .../Models/Beta/V2/Files/FileUploadParams.cs | 12 ++++++------ src/ImageKit/Models/Files/FileUploadParams.cs | 12 ++++++------ 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/ImageKit.Tests/Models/Beta/V2/Files/FileUploadParamsTest.cs b/src/ImageKit.Tests/Models/Beta/V2/Files/FileUploadParamsTest.cs index b9288e4f..2fce9163 100644 --- a/src/ImageKit.Tests/Models/Beta/V2/Files/FileUploadParamsTest.cs +++ b/src/ImageKit.Tests/Models/Beta/V2/Files/FileUploadParamsTest.cs @@ -457,19 +457,19 @@ public class PostTransformationTest : TestBase [Fact] public void FieldRoundtrip_Works() { - var model = new PostTransformation { Value = "w-400,h-400,q-70" }; + var model = new PostTransformation { ValueValue = "w-400,h-400,q-70" }; JsonElement expectedType = JsonSerializer.SerializeToElement("transformation"); - string expectedValue = "w-400,h-400,q-70"; + string expectedValueValue = "w-400,h-400,q-70"; Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); - Assert.Equal(expectedValue, model.Value); + Assert.Equal(expectedValueValue, model.ValueValue); } [Fact] public void SerializationRoundtrip_Works() { - var model = new PostTransformation { Value = "w-400,h-400,q-70" }; + var model = new PostTransformation { ValueValue = "w-400,h-400,q-70" }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize( @@ -483,7 +483,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new PostTransformation { Value = "w-400,h-400,q-70" }; + var model = new PostTransformation { ValueValue = "w-400,h-400,q-70" }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize( @@ -493,16 +493,16 @@ public void FieldRoundtripThroughSerialization_Works() Assert.NotNull(deserialized); JsonElement expectedType = JsonSerializer.SerializeToElement("transformation"); - string expectedValue = "w-400,h-400,q-70"; + string expectedValueValue = "w-400,h-400,q-70"; Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); - Assert.Equal(expectedValue, deserialized.Value); + Assert.Equal(expectedValueValue, deserialized.ValueValue); } [Fact] public void Validation_Works() { - var model = new PostTransformation { Value = "w-400,h-400,q-70" }; + var model = new PostTransformation { ValueValue = "w-400,h-400,q-70" }; model.Validate(); } @@ -510,7 +510,7 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new PostTransformation { Value = "w-400,h-400,q-70" }; + var model = new PostTransformation { ValueValue = "w-400,h-400,q-70" }; PostTransformation copied = new(model); diff --git a/src/ImageKit.Tests/Models/Files/FileUploadParamsTest.cs b/src/ImageKit.Tests/Models/Files/FileUploadParamsTest.cs index cecbe038..65b454d6 100644 --- a/src/ImageKit.Tests/Models/Files/FileUploadParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/FileUploadParamsTest.cs @@ -472,19 +472,19 @@ public class PostTransformationTest : TestBase [Fact] public void FieldRoundtrip_Works() { - var model = new PostTransformation { Value = "w-400,h-400,q-70" }; + var model = new PostTransformation { ValueValue = "w-400,h-400,q-70" }; JsonElement expectedType = JsonSerializer.SerializeToElement("transformation"); - string expectedValue = "w-400,h-400,q-70"; + string expectedValueValue = "w-400,h-400,q-70"; Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); - Assert.Equal(expectedValue, model.Value); + Assert.Equal(expectedValueValue, model.ValueValue); } [Fact] public void SerializationRoundtrip_Works() { - var model = new PostTransformation { Value = "w-400,h-400,q-70" }; + var model = new PostTransformation { ValueValue = "w-400,h-400,q-70" }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize( @@ -498,7 +498,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new PostTransformation { Value = "w-400,h-400,q-70" }; + var model = new PostTransformation { ValueValue = "w-400,h-400,q-70" }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize( @@ -508,16 +508,16 @@ public void FieldRoundtripThroughSerialization_Works() Assert.NotNull(deserialized); JsonElement expectedType = JsonSerializer.SerializeToElement("transformation"); - string expectedValue = "w-400,h-400,q-70"; + string expectedValueValue = "w-400,h-400,q-70"; Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); - Assert.Equal(expectedValue, deserialized.Value); + Assert.Equal(expectedValueValue, deserialized.ValueValue); } [Fact] public void Validation_Works() { - var model = new PostTransformation { Value = "w-400,h-400,q-70" }; + var model = new PostTransformation { ValueValue = "w-400,h-400,q-70" }; model.Validate(); } @@ -525,7 +525,7 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new PostTransformation { Value = "w-400,h-400,q-70" }; + var model = new PostTransformation { ValueValue = "w-400,h-400,q-70" }; PostTransformation copied = new(model); diff --git a/src/ImageKit/Models/Beta/V2/Files/FileUploadParams.cs b/src/ImageKit/Models/Beta/V2/Files/FileUploadParams.cs index 1aebbd06..591f7da1 100644 --- a/src/ImageKit/Models/Beta/V2/Files/FileUploadParams.cs +++ b/src/ImageKit/Models/Beta/V2/Files/FileUploadParams.cs @@ -815,12 +815,12 @@ public JsonElement Type } } - public string? Value1 + public string? ValueValue { get { return Match( - transformation: (x) => x.Value, + transformation: (x) => x.ValueValue, gifToVideo: (x) => x.Value, thumbnail: (x) => x.Value, abs: (x) => x.Value @@ -1220,7 +1220,7 @@ public JsonElement Type /// Transformation string (e.g. `w-200,h-200`). Same syntax as ImageKit URL-based /// transformations. /// - public required string Value + public required string ValueValue { get { @@ -1237,7 +1237,7 @@ public override void Validate() { throw new ImageKitInvalidDataException("Invalid value given for constant"); } - _ = this.Value; + _ = this.ValueValue; } public PostTransformation() @@ -1275,10 +1275,10 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public PostTransformation(string value) + public PostTransformation(string valueValue) : this() { - this.Value = value; + this.ValueValue = valueValue; } } diff --git a/src/ImageKit/Models/Files/FileUploadParams.cs b/src/ImageKit/Models/Files/FileUploadParams.cs index 758121be..72c34932 100644 --- a/src/ImageKit/Models/Files/FileUploadParams.cs +++ b/src/ImageKit/Models/Files/FileUploadParams.cs @@ -893,12 +893,12 @@ public JsonElement Type } } - public string? Value1 + public string? ValueValue { get { return Match( - transformation: (x) => x.Value, + transformation: (x) => x.ValueValue, gifToVideo: (x) => x.Value, thumbnail: (x) => x.Value, abs: (x) => x.Value @@ -1298,7 +1298,7 @@ public JsonElement Type /// Transformation string (e.g. `w-200,h-200`). Same syntax as ImageKit URL-based /// transformations. /// - public required string Value + public required string ValueValue { get { @@ -1315,7 +1315,7 @@ public override void Validate() { throw new ImageKitInvalidDataException("Invalid value given for constant"); } - _ = this.Value; + _ = this.ValueValue; } public PostTransformation() @@ -1353,10 +1353,10 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public PostTransformation(string value) + public PostTransformation(string valueValue) : this() { - this.Value = value; + this.ValueValue = valueValue; } } From 5b492eced226446eabf45eabcf86eb5c3077e61c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 10 Feb 2026 19:15:25 +0000 Subject: [PATCH 067/129] fix(client): improve behaviour for comma-delimited binary content in multipart requests --- src/ImageKit/Core/MultipartJsonElement.cs | 106 +++++++++++++++------- 1 file changed, 72 insertions(+), 34 deletions(-) diff --git a/src/ImageKit/Core/MultipartJsonElement.cs b/src/ImageKit/Core/MultipartJsonElement.cs index 3884a1a9..d706283f 100644 --- a/src/ImageKit/Core/MultipartJsonElement.cs +++ b/src/ImageKit/Core/MultipartJsonElement.cs @@ -140,7 +140,7 @@ public static MultipartFormDataContent Serialize( var multipartElement = MultipartJsonSerializer.SerializeToElement(value, options); void SerializeParts(string name, JsonElement element) { - HttpContent content; + HttpContent? content; string? fileName = null; switch (element.ValueKind) { @@ -181,46 +181,84 @@ void SerializeParts(string name, JsonElement element) } return; case JsonValueKind.Array: - content = new StringContent( - string.Join( - ",", - Enumerable.Select( - element.EnumerateArray(), - item => - item.ValueKind switch + var items = new List(); + foreach (var arrayItem in element.EnumerateArray()) + { + switch (arrayItem.ValueKind) + { + case JsonValueKind.Undefined: + case JsonValueKind.Null: + items.Add(""); + break; + case JsonValueKind.True: + items.Add("true"); + break; + case JsonValueKind.False: + items.Add("false"); + break; + case JsonValueKind.String: + if ( + arrayItem.TryGetGuid(out var itemGuid) + && multipartElement.BinaryContents.TryGetValue( + itemGuid, + out var itemBinaryContent + ) + ) + { + var itemContent = new StreamContent(itemBinaryContent.Stream); + itemContent.Headers.ContentType = itemBinaryContent.ContentType; + var itemFileName = itemBinaryContent.FileName; + if (name == "") + { + formDataContent.Add(itemContent); + } + else if (itemFileName == null) + { + formDataContent.Add(itemContent, $"{name}[]"); + } + else { - JsonValueKind.Undefined or JsonValueKind.Null => "", - JsonValueKind.Number => item.GetString(), - JsonValueKind.True => "true", - JsonValueKind.False => "false", - JsonValueKind.String => item.TryGetGuid(out var guid1) - && multipartElement.BinaryContents.TryGetValue(guid1, out _) - ? throw new InvalidDataException( - "Unexpected binary content in array" - ) - : item.GetString(), - _ => throw new InvalidDataException( - "Unexpected element type in array" - ), + formDataContent.Add(itemContent, $"{name}[]", itemFileName); } - ) - ) - ); + } + else + { + items.Add(arrayItem.ToString()); + } + break; + default: + throw new InvalidDataException("Unexpected element type in array"); + } + } + + if (items.Count > 0) + { + content = new StringContent(string.Join(",", items)); + } + else + { + content = null; + } + break; default: throw new ArgumentOutOfRangeException(nameof(element)); } - if (name == "") - { - formDataContent.Add(content); - } - else if (fileName == null) - { - formDataContent.Add(content, name); - } - else + + if (content != null) { - formDataContent.Add(content, name, fileName); + if (name == "") + { + formDataContent.Add(content); + } + else if (fileName == null) + { + formDataContent.Add(content, name); + } + else + { + formDataContent.Add(content, name, fileName); + } } } SerializeParts("", multipartElement.Json); From cc0e490a123ae36a56b95fb607daeba1d0b2ed51 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 13 Feb 2026 16:47:55 +0000 Subject: [PATCH 068/129] feat(client): add equality and tostring for multipart data --- .../Core/MultipartJsonElementTest.cs | 210 ++++++++++ .../Beta/V2/Files/FileUploadParamsTest.cs | 355 ++++++++++++++++- .../Models/Files/FileUploadParamsTest.cs | 367 +++++++++++++++++- src/ImageKit/Core/ApiEnum.cs | 5 +- src/ImageKit/Core/FriendlyJsonPrinter.cs | 78 ++++ src/ImageKit/Core/JsonDictionary.cs | 7 +- src/ImageKit/Core/MultipartJsonDictionary.cs | 36 +- src/ImageKit/Core/MultipartJsonElement.cs | 114 ++++++ .../Accounts/Origins/OriginCreateParams.cs | 18 +- .../Accounts/Origins/OriginDeleteParams.cs | 18 +- .../Accounts/Origins/OriginGetParams.cs | 18 +- .../Accounts/Origins/OriginListParams.cs | 16 +- .../Models/Accounts/Origins/OriginRequest.cs | 5 +- .../Models/Accounts/Origins/OriginResponse.cs | 5 +- .../Accounts/Origins/OriginUpdateParams.cs | 20 +- .../UrlEndpoints/UrlEndpointCreateParams.cs | 23 +- .../UrlEndpoints/UrlEndpointDeleteParams.cs | 18 +- .../UrlEndpoints/UrlEndpointGetParams.cs | 18 +- .../UrlEndpoints/UrlEndpointListParams.cs | 16 +- .../UrlEndpoints/UrlEndpointRequest.cs | 5 +- .../UrlEndpoints/UrlEndpointResponse.cs | 5 +- .../UrlEndpoints/UrlEndpointUpdateParams.cs | 25 +- .../Models/Accounts/Usage/UsageGetParams.cs | 16 +- src/ImageKit/Models/Assets/AssetListParams.cs | 16 +- .../Models/Assets/AssetListResponse.cs | 5 +- .../Models/Beta/V2/Files/FileUploadParams.cs | 33 +- .../Beta/V2/Files/FileUploadResponse.cs | 25 +- .../Invalidation/InvalidationCreateParams.cs | 18 +- .../Invalidation/InvalidationGetParams.cs | 18 +- .../CustomMetadataField.cs | 25 +- .../CustomMetadataFieldCreateParams.cs | 43 +- .../CustomMetadataFieldDeleteParams.cs | 18 +- .../CustomMetadataFieldListParams.cs | 16 +- .../CustomMetadataFieldUpdateParams.cs | 45 ++- src/ImageKit/Models/ExtensionConfig.cs | 45 ++- .../Models/Files/Bulk/BulkAddTagsParams.cs | 18 +- .../Models/Files/Bulk/BulkDeleteParams.cs | 18 +- .../Files/Bulk/BulkRemoveAITagsParams.cs | 18 +- .../Models/Files/Bulk/BulkRemoveTagsParams.cs | 18 +- src/ImageKit/Models/Files/File.cs | 25 +- src/ImageKit/Models/Files/FileCopyParams.cs | 18 +- src/ImageKit/Models/Files/FileDeleteParams.cs | 18 +- src/ImageKit/Models/Files/FileGetParams.cs | 18 +- src/ImageKit/Models/Files/FileMoveParams.cs | 18 +- src/ImageKit/Models/Files/FileRenameParams.cs | 18 +- src/ImageKit/Models/Files/FileUpdateParams.cs | 20 +- src/ImageKit/Models/Files/FileUploadParams.cs | 33 +- .../Models/Files/FileUploadResponse.cs | 25 +- .../Metadata/MetadataGetFromUrlParams.cs | 16 +- .../Files/Metadata/MetadataGetParams.cs | 18 +- .../Models/Files/UpdateFileRequest.cs | 10 +- .../Files/Versions/VersionDeleteParams.cs | 20 +- .../Models/Files/Versions/VersionGetParams.cs | 20 +- .../Files/Versions/VersionListParams.cs | 18 +- .../Files/Versions/VersionRestoreParams.cs | 20 +- .../Models/Folders/FolderCopyParams.cs | 18 +- .../Models/Folders/FolderCreateParams.cs | 18 +- .../Models/Folders/FolderDeleteParams.cs | 18 +- .../Models/Folders/FolderMoveParams.cs | 18 +- .../Models/Folders/FolderRenameParams.cs | 18 +- .../Models/Folders/Job/JobGetParams.cs | 18 +- src/ImageKit/Models/Overlay.cs | 5 +- src/ImageKit/Models/OverlayPosition.cs | 10 +- src/ImageKit/Models/OverlayTiming.cs | 15 +- .../SavedExtensionCreateParams.cs | 18 +- .../SavedExtensionDeleteParams.cs | 18 +- .../SavedExtensionGetParams.cs | 18 +- .../SavedExtensionListParams.cs | 16 +- .../SavedExtensionUpdateParams.cs | 20 +- .../Models/SolidColorOverlayTransformation.cs | 20 +- .../Models/TextOverlayTransformation.cs | 30 +- src/ImageKit/Models/Transformation.cs | 95 ++++- .../Models/UnnamedSchemaWithArrayParent0.cs | 45 ++- .../Webhooks/UnsafeUnwrapWebhookEvent.cs | 5 +- .../Models/Webhooks/UnwrapWebhookEvent.cs | 5 +- .../UploadPreTransformSuccessEvent.cs | 25 +- 76 files changed, 2163 insertions(+), 382 deletions(-) create mode 100644 src/ImageKit.Tests/Core/MultipartJsonElementTest.cs create mode 100644 src/ImageKit/Core/FriendlyJsonPrinter.cs diff --git a/src/ImageKit.Tests/Core/MultipartJsonElementTest.cs b/src/ImageKit.Tests/Core/MultipartJsonElementTest.cs new file mode 100644 index 00000000..9b09cd84 --- /dev/null +++ b/src/ImageKit.Tests/Core/MultipartJsonElementTest.cs @@ -0,0 +1,210 @@ +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using ImageKit.Core; + +namespace ImageKit.Tests.Core; + +public class MultipartJsonElementTest +{ + [Fact] + public void NumberAndNumberEqual_Works() + { + MultipartJsonElement a = JsonSerializer.SerializeToElement(3); + MultipartJsonElement b = JsonSerializer.SerializeToElement(3); + Assert.True(MultipartJsonElement.DeepEquals(a, b)); + } + + [Fact] + public void NumberAndNumberNotEqual_Works() + { + MultipartJsonElement a = JsonSerializer.SerializeToElement(3); + MultipartJsonElement b = JsonSerializer.SerializeToElement(4); + Assert.False(MultipartJsonElement.DeepEquals(a, b)); + } + + [Fact] + public void StringAndStringEqual_Works() + { + MultipartJsonElement a = JsonSerializer.SerializeToElement("text"); + MultipartJsonElement b = JsonSerializer.SerializeToElement("text"); + Assert.True(MultipartJsonElement.DeepEquals(a, b)); + } + + [Fact] + public void StringAndStringNotEqual_Works() + { + MultipartJsonElement a = JsonSerializer.SerializeToElement("text"); + MultipartJsonElement b = JsonSerializer.SerializeToElement("test"); + Assert.False(MultipartJsonElement.DeepEquals(a, b)); + } + + [Fact] + public void StringAndNumberNotEqual1_Works() + { + MultipartJsonElement a = JsonSerializer.SerializeToElement("text"); + MultipartJsonElement b = JsonSerializer.SerializeToElement(3); + Assert.False(MultipartJsonElement.DeepEquals(a, b)); + } + + [Fact] + public void StringAndNumberNotEqual1_Works1() + { + MultipartJsonElement a = JsonSerializer.SerializeToElement("text"); + MultipartJsonElement b = JsonSerializer.SerializeToElement(3); + Assert.False(MultipartJsonElement.DeepEquals(a, b)); + } + + [Fact] + public void StringAndNumberNotEqual2_Works() + { + MultipartJsonElement a = JsonSerializer.SerializeToElement("3"); + MultipartJsonElement b = JsonSerializer.SerializeToElement(3); + Assert.False(MultipartJsonElement.DeepEquals(a, b)); + } + + [Fact] + public void BinaryContentEqual_Works() + { + BinaryContent content = Encoding.UTF8.GetBytes("text"); + + MultipartJsonElement a = MultipartJsonSerializer.SerializeToElement(content); + MultipartJsonElement b = MultipartJsonSerializer.SerializeToElement(content); + + Assert.True(MultipartJsonElement.DeepEquals(a, b)); + } + + [Fact] + public void BinaryContentDifferentReferencesNotEqual_Works() + { + BinaryContent contentA = Encoding.UTF8.GetBytes("text"); + BinaryContent contentB = Encoding.UTF8.GetBytes("text"); + + MultipartJsonElement a = MultipartJsonSerializer.SerializeToElement(contentA); + MultipartJsonElement b = MultipartJsonSerializer.SerializeToElement(contentB); + + Assert.False(MultipartJsonElement.DeepEquals(a, b)); + } + + [Fact] + public void ArraysEqual_Works() + { + BinaryContent content1 = Encoding.UTF8.GetBytes("text"); + BinaryContent content2 = Encoding.UTF8.GetBytes("text"); + BinaryContent content3 = Encoding.UTF8.GetBytes("text"); + + MultipartJsonElement a = MultipartJsonSerializer.SerializeToElement( + new List { content1, content2, content3 } + ); + MultipartJsonElement b = MultipartJsonSerializer.SerializeToElement( + new List { content1, content2, content3 } + ); + + Assert.True(MultipartJsonElement.DeepEquals(a, b)); + } + + [Fact] + public void ArrayMissingElementNotEqual_Works() + { + BinaryContent content1 = Encoding.UTF8.GetBytes("text"); + BinaryContent content2 = Encoding.UTF8.GetBytes("text"); + BinaryContent content3 = Encoding.UTF8.GetBytes("text"); + + MultipartJsonElement a = MultipartJsonSerializer.SerializeToElement( + new List { content1, content2, content3 } + ); + MultipartJsonElement b = MultipartJsonSerializer.SerializeToElement( + new List { content1, content2 } + ); + + Assert.False(MultipartJsonElement.DeepEquals(a, b)); + } + + [Fact] + public void ArrayOutOfOrderNotEqual_Works() + { + BinaryContent content1 = Encoding.UTF8.GetBytes("text"); + BinaryContent content2 = Encoding.UTF8.GetBytes("text"); + BinaryContent content3 = Encoding.UTF8.GetBytes("text"); + + MultipartJsonElement a = MultipartJsonSerializer.SerializeToElement( + new List { content1, content2, content3 } + ); + MultipartJsonElement b = MultipartJsonSerializer.SerializeToElement( + new List { content1, content3, content2 } + ); + + Assert.False(MultipartJsonElement.DeepEquals(a, b)); + } + + [Fact] + public void ObjectsEqual_Works() + { + BinaryContent content = Encoding.UTF8.GetBytes("text"); + + MultipartJsonElement a = MultipartJsonSerializer.SerializeToElement( + new Dictionary + { + { "string", "text" }, + { "number", -5 }, + { "binary", content }, + } + ); + MultipartJsonElement b = MultipartJsonSerializer.SerializeToElement( + new Dictionary + { + { "string", "text" }, + { "number", -5 }, + { "binary", content }, + } + ); + + Assert.True(MultipartJsonElement.DeepEquals(a, b)); + } + + [Fact] + public void ObjectExtraKeyNotEqual_Works() + { + BinaryContent content = Encoding.UTF8.GetBytes("text"); + + MultipartJsonElement a = MultipartJsonSerializer.SerializeToElement( + new Dictionary + { + { "string", "text" }, + { "number", -5 }, + { "binary", content }, + } + ); + MultipartJsonElement b = MultipartJsonSerializer.SerializeToElement( + new Dictionary + { + { "string", "text" }, + { "number", -5 }, + { "binary", content }, + { "extra", "test" }, + } + ); + + Assert.False(MultipartJsonElement.DeepEquals(a, b)); + } + + [Fact] + public void ObjectExtraKeyNotEqual_Works1() + { + BinaryContent content = Encoding.UTF8.GetBytes("text"); + + MultipartJsonElement a = MultipartJsonSerializer.SerializeToElement( + new Dictionary + { + { "string", "text" }, + { "number", -5 }, + { "binary", content }, + } + ); + MultipartJsonElement b = MultipartJsonSerializer.SerializeToElement( + new Dictionary { { "string", "text" }, { "binary", content } } + ); + + Assert.False(MultipartJsonElement.DeepEquals(a, b)); + } +} diff --git a/src/ImageKit.Tests/Models/Beta/V2/Files/FileUploadParamsTest.cs b/src/ImageKit.Tests/Models/Beta/V2/Files/FileUploadParamsTest.cs index 2fce9163..2714604f 100644 --- a/src/ImageKit.Tests/Models/Beta/V2/Files/FileUploadParamsTest.cs +++ b/src/ImageKit.Tests/Models/Beta/V2/Files/FileUploadParamsTest.cs @@ -5,19 +5,260 @@ using ImageKit.Core; using ImageKit.Exceptions; using ImageKit.Models.Beta.V2.Files; +using Models = ImageKit.Models; namespace ImageKit.Tests.Models.Beta.V2.Files; public class FileUploadParamsTest : TestBase { [Fact] - public void OptionalNonNullableParamsUnsetAreNotSet_Works() + public void FieldRoundtrip_Works() { + BinaryContent file = Encoding.UTF8.GetBytes("text"); + var parameters = new FileUploadParams { - File = Encoding.UTF8.GetBytes("text"), + File = file, FileName = "fileName", + Token = "token", + Checks = "\"request.folder\" : \"marketing/\"\n", + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "brand", JsonSerializer.SerializeToElement("bar") }, + { "color", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "Running shoes", + Extensions = + [ + new Models::UnnamedSchemaWithArrayParent0RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }, + new Models::UnnamedSchemaWithArrayParent0AutoTaggingExtension() + { + MaxTags = 5, + MinConfidence = 95, + Name = + Models::UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + }, + new Models::UnnamedSchemaWithArrayParent0AIAutoDescription(), + new Models::UnnamedSchemaWithArrayParent0AITasks( + [ + new Models::UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }, + new Models::UnnamedSchemaWithArrayParent0AITasksTaskYesNo() + { + Instruction = "Is this a luxury or high-end fashion item?", + OnNo = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnUnknown = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnYes = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + }, + ] + ), + new Models::SavedExtension("ext_abc123"), + ], + Folder = "folder", + IsPrivateFile = true, + IsPublished = true, + OverwriteAITags = true, + OverwriteCustomMetadata = true, + OverwriteFile = true, + OverwriteTags = true, + ResponseFields = + [ + ResponseField.Tags, + ResponseField.CustomCoordinates, + ResponseField.IsPrivateFile, + ], + Tags = ["t-shirt", "round-neck", "men"], + Transformation = new() + { + Post = + [ + new Thumbnail() { Value = "w-150,h-150" }, + new Abs() { Protocol = Protocol.Dash, Value = "sr-240_360_480_720_1080" }, + ], + Pre = "w-300,h-300,q-80", + }, + UseUniqueFileName = true, + WebhookUrl = "https://example.com", + }; + + BinaryContent expectedFile = file; + string expectedFileName = "fileName"; + string expectedToken = "token"; + string expectedChecks = "\"request.folder\" : \"marketing/\"\n"; + string expectedCustomCoordinates = "customCoordinates"; + Dictionary expectedCustomMetadata = new() + { + { "brand", JsonSerializer.SerializeToElement("bar") }, + { "color", JsonSerializer.SerializeToElement("bar") }, + }; + string expectedDescription = "Running shoes"; + List expectedExtensions = + [ + new Models::UnnamedSchemaWithArrayParent0RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }, + new Models::UnnamedSchemaWithArrayParent0AutoTaggingExtension() + { + MaxTags = 5, + MinConfidence = 95, + Name = + Models::UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + }, + new Models::UnnamedSchemaWithArrayParent0AIAutoDescription(), + new Models::UnnamedSchemaWithArrayParent0AITasks( + [ + new Models::UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }, + new Models::UnnamedSchemaWithArrayParent0AITasksTaskYesNo() + { + Instruction = "Is this a luxury or high-end fashion item?", + OnNo = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnUnknown = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnYes = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + }, + ] + ), + new Models::SavedExtension("ext_abc123"), + ]; + string expectedFolder = "folder"; + bool expectedIsPrivateFile = true; + bool expectedIsPublished = true; + bool expectedOverwriteAITags = true; + bool expectedOverwriteCustomMetadata = true; + bool expectedOverwriteFile = true; + bool expectedOverwriteTags = true; + List> expectedResponseFields = + [ + ResponseField.Tags, + ResponseField.CustomCoordinates, + ResponseField.IsPrivateFile, + ]; + List expectedTags = ["t-shirt", "round-neck", "men"]; + Transformation expectedTransformation = new() + { + Post = + [ + new Thumbnail() { Value = "w-150,h-150" }, + new Abs() { Protocol = Protocol.Dash, Value = "sr-240_360_480_720_1080" }, + ], + Pre = "w-300,h-300,q-80", }; + bool expectedUseUniqueFileName = true; + string expectedWebhookUrl = "https://example.com"; + + Assert.Equal(expectedFile, parameters.File); + Assert.Equal(expectedFileName, parameters.FileName); + Assert.Equal(expectedToken, parameters.Token); + Assert.Equal(expectedChecks, parameters.Checks); + Assert.Equal(expectedCustomCoordinates, parameters.CustomCoordinates); + Assert.NotNull(parameters.CustomMetadata); + Assert.Equal(expectedCustomMetadata.Count, parameters.CustomMetadata.Count); + foreach (var item in expectedCustomMetadata) + { + Assert.True(parameters.CustomMetadata.TryGetValue(item.Key, out var value)); + + Assert.True(JsonElement.DeepEquals(value, parameters.CustomMetadata[item.Key])); + } + Assert.Equal(expectedDescription, parameters.Description); + Assert.NotNull(parameters.Extensions); + Assert.Equal(expectedExtensions.Count, parameters.Extensions.Count); + for (int i = 0; i < expectedExtensions.Count; i++) + { + Assert.Equal(expectedExtensions[i], parameters.Extensions[i]); + } + Assert.Equal(expectedFolder, parameters.Folder); + Assert.Equal(expectedIsPrivateFile, parameters.IsPrivateFile); + Assert.Equal(expectedIsPublished, parameters.IsPublished); + Assert.Equal(expectedOverwriteAITags, parameters.OverwriteAITags); + Assert.Equal(expectedOverwriteCustomMetadata, parameters.OverwriteCustomMetadata); + Assert.Equal(expectedOverwriteFile, parameters.OverwriteFile); + Assert.Equal(expectedOverwriteTags, parameters.OverwriteTags); + Assert.NotNull(parameters.ResponseFields); + Assert.Equal(expectedResponseFields.Count, parameters.ResponseFields.Count); + for (int i = 0; i < expectedResponseFields.Count; i++) + { + Assert.Equal(expectedResponseFields[i], parameters.ResponseFields[i]); + } + Assert.NotNull(parameters.Tags); + Assert.Equal(expectedTags.Count, parameters.Tags.Count); + for (int i = 0; i < expectedTags.Count; i++) + { + Assert.Equal(expectedTags[i], parameters.Tags[i]); + } + Assert.Equal(expectedTransformation, parameters.Transformation); + Assert.Equal(expectedUseUniqueFileName, parameters.UseUniqueFileName); + Assert.Equal(expectedWebhookUrl, parameters.WebhookUrl); + } + + [Fact] + public void OptionalNonNullableParamsUnsetAreNotSet_Works() + { + BinaryContent file = Encoding.UTF8.GetBytes("text"); + + var parameters = new FileUploadParams { File = file, FileName = "fileName" }; Assert.Null(parameters.Token); Assert.False(parameters.RawBodyData.ContainsKey("token")); @@ -60,9 +301,11 @@ public void OptionalNonNullableParamsUnsetAreNotSet_Works() [Fact] public void OptionalNonNullableParamsSetToNullAreNotSet_Works() { + BinaryContent file = Encoding.UTF8.GetBytes("text"); + var parameters = new FileUploadParams { - File = Encoding.UTF8.GetBytes("text"), + File = file, FileName = "fileName", // Null should be interpreted as omitted for these properties @@ -137,6 +380,112 @@ public void Url_Works() Assert.Equal(new Uri("https://api.imagekit.io/api/v2/files/upload"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new FileUploadParams + { + File = Encoding.UTF8.GetBytes("text"), + FileName = "fileName", + Token = "token", + Checks = "\"request.folder\" : \"marketing/\"\n", + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "brand", JsonSerializer.SerializeToElement("bar") }, + { "color", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "Running shoes", + Extensions = + [ + new Models::UnnamedSchemaWithArrayParent0RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }, + new Models::UnnamedSchemaWithArrayParent0AutoTaggingExtension() + { + MaxTags = 5, + MinConfidence = 95, + Name = + Models::UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + }, + new Models::UnnamedSchemaWithArrayParent0AIAutoDescription(), + new Models::UnnamedSchemaWithArrayParent0AITasks( + [ + new Models::UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }, + new Models::UnnamedSchemaWithArrayParent0AITasksTaskYesNo() + { + Instruction = "Is this a luxury or high-end fashion item?", + OnNo = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnUnknown = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnYes = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + }, + ] + ), + new Models::SavedExtension("ext_abc123"), + ], + Folder = "folder", + IsPrivateFile = true, + IsPublished = true, + OverwriteAITags = true, + OverwriteCustomMetadata = true, + OverwriteFile = true, + OverwriteTags = true, + ResponseFields = + [ + ResponseField.Tags, + ResponseField.CustomCoordinates, + ResponseField.IsPrivateFile, + ], + Tags = ["t-shirt", "round-neck", "men"], + Transformation = new() + { + Post = + [ + new Thumbnail() { Value = "w-150,h-150" }, + new Abs() { Protocol = Protocol.Dash, Value = "sr-240_360_480_720_1080" }, + ], + Pre = "w-300,h-300,q-80", + }, + UseUniqueFileName = true, + WebhookUrl = "https://example.com", + }; + + FileUploadParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class ResponseFieldTest : TestBase diff --git a/src/ImageKit.Tests/Models/Files/FileUploadParamsTest.cs b/src/ImageKit.Tests/Models/Files/FileUploadParamsTest.cs index 65b454d6..f18570b3 100644 --- a/src/ImageKit.Tests/Models/Files/FileUploadParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/FileUploadParamsTest.cs @@ -5,19 +5,269 @@ using ImageKit.Core; using ImageKit.Exceptions; using ImageKit.Models.Files; +using Models = ImageKit.Models; namespace ImageKit.Tests.Models.Files; public class FileUploadParamsTest : TestBase { [Fact] - public void OptionalNonNullableParamsUnsetAreNotSet_Works() + public void FieldRoundtrip_Works() { + BinaryContent file = Encoding.UTF8.GetBytes("text"); + var parameters = new FileUploadParams { - File = Encoding.UTF8.GetBytes("text"), + File = file, FileName = "fileName", + Token = "token", + Checks = "\"request.folder\" : \"marketing/\"\n", + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "brand", JsonSerializer.SerializeToElement("bar") }, + { "color", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "Running shoes", + Expire = 0, + Extensions = + [ + new Models::UnnamedSchemaWithArrayParent0RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }, + new Models::UnnamedSchemaWithArrayParent0AutoTaggingExtension() + { + MaxTags = 5, + MinConfidence = 95, + Name = + Models::UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + }, + new Models::UnnamedSchemaWithArrayParent0AIAutoDescription(), + new Models::UnnamedSchemaWithArrayParent0AITasks( + [ + new Models::UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }, + new Models::UnnamedSchemaWithArrayParent0AITasksTaskYesNo() + { + Instruction = "Is this a luxury or high-end fashion item?", + OnNo = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnUnknown = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnYes = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + }, + ] + ), + new Models::SavedExtension("ext_abc123"), + ], + Folder = "folder", + IsPrivateFile = true, + IsPublished = true, + OverwriteAITags = true, + OverwriteCustomMetadata = true, + OverwriteFile = true, + OverwriteTags = true, + PublicKey = "publicKey", + ResponseFields = + [ + ResponseField.Tags, + ResponseField.CustomCoordinates, + ResponseField.IsPrivateFile, + ], + Signature = "signature", + Tags = ["t-shirt", "round-neck", "men"], + Transformation = new() + { + Post = + [ + new Thumbnail() { Value = "w-150,h-150" }, + new Abs() { Protocol = Protocol.Dash, Value = "sr-240_360_480_720_1080" }, + ], + Pre = "w-300,h-300,q-80", + }, + UseUniqueFileName = true, + WebhookUrl = "https://example.com", + }; + + BinaryContent expectedFile = file; + string expectedFileName = "fileName"; + string expectedToken = "token"; + string expectedChecks = "\"request.folder\" : \"marketing/\"\n"; + string expectedCustomCoordinates = "customCoordinates"; + Dictionary expectedCustomMetadata = new() + { + { "brand", JsonSerializer.SerializeToElement("bar") }, + { "color", JsonSerializer.SerializeToElement("bar") }, + }; + string expectedDescription = "Running shoes"; + long expectedExpire = 0; + List expectedExtensions = + [ + new Models::UnnamedSchemaWithArrayParent0RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }, + new Models::UnnamedSchemaWithArrayParent0AutoTaggingExtension() + { + MaxTags = 5, + MinConfidence = 95, + Name = + Models::UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + }, + new Models::UnnamedSchemaWithArrayParent0AIAutoDescription(), + new Models::UnnamedSchemaWithArrayParent0AITasks( + [ + new Models::UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }, + new Models::UnnamedSchemaWithArrayParent0AITasksTaskYesNo() + { + Instruction = "Is this a luxury or high-end fashion item?", + OnNo = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnUnknown = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnYes = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + }, + ] + ), + new Models::SavedExtension("ext_abc123"), + ]; + string expectedFolder = "folder"; + bool expectedIsPrivateFile = true; + bool expectedIsPublished = true; + bool expectedOverwriteAITags = true; + bool expectedOverwriteCustomMetadata = true; + bool expectedOverwriteFile = true; + bool expectedOverwriteTags = true; + string expectedPublicKey = "publicKey"; + List> expectedResponseFields = + [ + ResponseField.Tags, + ResponseField.CustomCoordinates, + ResponseField.IsPrivateFile, + ]; + string expectedSignature = "signature"; + List expectedTags = ["t-shirt", "round-neck", "men"]; + Transformation expectedTransformation = new() + { + Post = + [ + new Thumbnail() { Value = "w-150,h-150" }, + new Abs() { Protocol = Protocol.Dash, Value = "sr-240_360_480_720_1080" }, + ], + Pre = "w-300,h-300,q-80", }; + bool expectedUseUniqueFileName = true; + string expectedWebhookUrl = "https://example.com"; + + Assert.Equal(expectedFile, parameters.File); + Assert.Equal(expectedFileName, parameters.FileName); + Assert.Equal(expectedToken, parameters.Token); + Assert.Equal(expectedChecks, parameters.Checks); + Assert.Equal(expectedCustomCoordinates, parameters.CustomCoordinates); + Assert.NotNull(parameters.CustomMetadata); + Assert.Equal(expectedCustomMetadata.Count, parameters.CustomMetadata.Count); + foreach (var item in expectedCustomMetadata) + { + Assert.True(parameters.CustomMetadata.TryGetValue(item.Key, out var value)); + + Assert.True(JsonElement.DeepEquals(value, parameters.CustomMetadata[item.Key])); + } + Assert.Equal(expectedDescription, parameters.Description); + Assert.Equal(expectedExpire, parameters.Expire); + Assert.NotNull(parameters.Extensions); + Assert.Equal(expectedExtensions.Count, parameters.Extensions.Count); + for (int i = 0; i < expectedExtensions.Count; i++) + { + Assert.Equal(expectedExtensions[i], parameters.Extensions[i]); + } + Assert.Equal(expectedFolder, parameters.Folder); + Assert.Equal(expectedIsPrivateFile, parameters.IsPrivateFile); + Assert.Equal(expectedIsPublished, parameters.IsPublished); + Assert.Equal(expectedOverwriteAITags, parameters.OverwriteAITags); + Assert.Equal(expectedOverwriteCustomMetadata, parameters.OverwriteCustomMetadata); + Assert.Equal(expectedOverwriteFile, parameters.OverwriteFile); + Assert.Equal(expectedOverwriteTags, parameters.OverwriteTags); + Assert.Equal(expectedPublicKey, parameters.PublicKey); + Assert.NotNull(parameters.ResponseFields); + Assert.Equal(expectedResponseFields.Count, parameters.ResponseFields.Count); + for (int i = 0; i < expectedResponseFields.Count; i++) + { + Assert.Equal(expectedResponseFields[i], parameters.ResponseFields[i]); + } + Assert.Equal(expectedSignature, parameters.Signature); + Assert.NotNull(parameters.Tags); + Assert.Equal(expectedTags.Count, parameters.Tags.Count); + for (int i = 0; i < expectedTags.Count; i++) + { + Assert.Equal(expectedTags[i], parameters.Tags[i]); + } + Assert.Equal(expectedTransformation, parameters.Transformation); + Assert.Equal(expectedUseUniqueFileName, parameters.UseUniqueFileName); + Assert.Equal(expectedWebhookUrl, parameters.WebhookUrl); + } + + [Fact] + public void OptionalNonNullableParamsUnsetAreNotSet_Works() + { + BinaryContent file = Encoding.UTF8.GetBytes("text"); + + var parameters = new FileUploadParams { File = file, FileName = "fileName" }; Assert.Null(parameters.Token); Assert.False(parameters.RawBodyData.ContainsKey("token")); @@ -66,9 +316,11 @@ public void OptionalNonNullableParamsUnsetAreNotSet_Works() [Fact] public void OptionalNonNullableParamsSetToNullAreNotSet_Works() { + BinaryContent file = Encoding.UTF8.GetBytes("text"); + var parameters = new FileUploadParams { - File = Encoding.UTF8.GetBytes("text"), + File = file, FileName = "fileName", // Null should be interpreted as omitted for these properties @@ -152,6 +404,115 @@ public void Url_Works() Assert.Equal(new Uri("https://api.imagekit.io/api/v1/files/upload"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new FileUploadParams + { + File = Encoding.UTF8.GetBytes("text"), + FileName = "fileName", + Token = "token", + Checks = "\"request.folder\" : \"marketing/\"\n", + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "brand", JsonSerializer.SerializeToElement("bar") }, + { "color", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "Running shoes", + Expire = 0, + Extensions = + [ + new Models::UnnamedSchemaWithArrayParent0RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }, + new Models::UnnamedSchemaWithArrayParent0AutoTaggingExtension() + { + MaxTags = 5, + MinConfidence = 95, + Name = + Models::UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + }, + new Models::UnnamedSchemaWithArrayParent0AIAutoDescription(), + new Models::UnnamedSchemaWithArrayParent0AITasks( + [ + new Models::UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }, + new Models::UnnamedSchemaWithArrayParent0AITasksTaskYesNo() + { + Instruction = "Is this a luxury or high-end fashion item?", + OnNo = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnUnknown = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnYes = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + }, + ] + ), + new Models::SavedExtension("ext_abc123"), + ], + Folder = "folder", + IsPrivateFile = true, + IsPublished = true, + OverwriteAITags = true, + OverwriteCustomMetadata = true, + OverwriteFile = true, + OverwriteTags = true, + PublicKey = "publicKey", + ResponseFields = + [ + ResponseField.Tags, + ResponseField.CustomCoordinates, + ResponseField.IsPrivateFile, + ], + Signature = "signature", + Tags = ["t-shirt", "round-neck", "men"], + Transformation = new() + { + Post = + [ + new Thumbnail() { Value = "w-150,h-150" }, + new Abs() { Protocol = Protocol.Dash, Value = "sr-240_360_480_720_1080" }, + ], + Pre = "w-300,h-300,q-80", + }, + UseUniqueFileName = true, + WebhookUrl = "https://example.com", + }; + + FileUploadParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class ResponseFieldTest : TestBase diff --git a/src/ImageKit/Core/ApiEnum.cs b/src/ImageKit/Core/ApiEnum.cs index d92c6ca3..c625f3b8 100644 --- a/src/ImageKit/Core/ApiEnum.cs +++ b/src/ImageKit/Core/ApiEnum.cs @@ -95,7 +95,10 @@ public virtual bool Equals(ApiEnum? other) } public override string ToString() => - JsonSerializer.Serialize(this.Json, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); public override int GetHashCode() { diff --git a/src/ImageKit/Core/FriendlyJsonPrinter.cs b/src/ImageKit/Core/FriendlyJsonPrinter.cs new file mode 100644 index 00000000..7ee1bfa7 --- /dev/null +++ b/src/ImageKit/Core/FriendlyJsonPrinter.cs @@ -0,0 +1,78 @@ +using System; +using System.Collections.Generic; +using System.Text.Json; + +namespace ImageKit.Core; + +static class FriendlyJsonPrinter +{ + public static JsonElement PrintValue(JsonElement value) => value; + + public static JsonElement PrintValue(IReadOnlyDictionary value) => + JsonSerializer.SerializeToElement(value); + + public static JsonElement PrintValue(IReadOnlyList value) => + JsonSerializer.SerializeToElement(value); + + public static JsonElement PrintValue(IReadOnlyDictionary value) + { + int binaryContentCount = 0; + var ret = new Dictionary(); + foreach (var item in value) + { + ret[item.Key] = PrintValue( + item.Value.Json, + item.Value.BinaryContents, + ref binaryContentCount + ); + } + return PrintValue(ret); + } + + public static JsonElement PrintValue(MultipartJsonElement value) + { + int binaryContentCount = 0; + return PrintValue(value.Json, value.BinaryContents, ref binaryContentCount); + } + + static JsonElement PrintValue( + JsonElement json, + IReadOnlyDictionary binaryContent, + ref int binaryContentCount + ) + { + switch (json.ValueKind) + { + case JsonValueKind.Undefined: + case JsonValueKind.Null: + case JsonValueKind.Number: + case JsonValueKind.True: + case JsonValueKind.False: + return json; + case JsonValueKind.String: + return json.TryGetGuid(out var guid) && binaryContent.ContainsKey(guid) + ? JsonSerializer.SerializeToElement($"[Binary Content {binaryContentCount++}]") + : json; + case JsonValueKind.Object: + { + var ret = new Dictionary(); + foreach (var item in json.EnumerateObject()) + { + ret[item.Name] = PrintValue(item.Value, binaryContent, ref binaryContentCount); + } + return PrintValue(ret); + } + case JsonValueKind.Array: + { + var ret = new List(); + foreach (var item in json.EnumerateArray()) + { + ret.Add(PrintValue(item, binaryContent, ref binaryContentCount)); + } + return PrintValue(ret); + } + default: + throw new InvalidOperationException("Unreachable"); + } + } +} diff --git a/src/ImageKit/Core/JsonDictionary.cs b/src/ImageKit/Core/JsonDictionary.cs index b6b16140..e0d51b2e 100644 --- a/src/ImageKit/Core/JsonDictionary.cs +++ b/src/ImageKit/Core/JsonDictionary.cs @@ -19,7 +19,7 @@ namespace ImageKit.Core; ///
sealed class JsonDictionary { - IDictionary _rawData; + IReadOnlyDictionary _rawData; readonly ConcurrentDictionary _deserializedData; @@ -198,7 +198,10 @@ public T GetNotNullStruct(string key) } public override string ToString() => - JsonSerializer.Serialize(this._rawData, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this._rawData), + ModelBase.ToStringSerializerOptions + ); public override bool Equals(object? obj) { diff --git a/src/ImageKit/Core/MultipartJsonDictionary.cs b/src/ImageKit/Core/MultipartJsonDictionary.cs index 7d75c5a7..2afe9f3a 100644 --- a/src/ImageKit/Core/MultipartJsonDictionary.cs +++ b/src/ImageKit/Core/MultipartJsonDictionary.cs @@ -19,7 +19,7 @@ namespace ImageKit.Core; ///
sealed class MultipartJsonDictionary { - IDictionary _rawData; + IReadOnlyDictionary _rawData; readonly ConcurrentDictionary _deserializedData; @@ -205,4 +205,38 @@ public T GetNotNullStruct(string key) _deserializedData[key] = deserialized; return deserialized; } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this._rawData), + ModelBase.ToStringSerializerOptions + ); + + public override bool Equals(object? obj) + { + if (obj is not MultipartJsonDictionary other || _rawData.Count != other._rawData.Count) + { + return false; + } + + foreach (var item in _rawData) + { + if (!other._rawData.TryGetValue(item.Key, out var otherValue)) + { + return false; + } + + if (!MultipartJsonElement.DeepEquals(item.Value, otherValue)) + { + return false; + } + } + + return true; + } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/ImageKit/Core/MultipartJsonElement.cs b/src/ImageKit/Core/MultipartJsonElement.cs index d706283f..7affb5f2 100644 --- a/src/ImageKit/Core/MultipartJsonElement.cs +++ b/src/ImageKit/Core/MultipartJsonElement.cs @@ -31,6 +31,120 @@ public readonly struct MultipartJsonElement() FrozenDictionary.ToFrozenDictionary(new Dictionary()); public static implicit operator MultipartJsonElement(JsonElement json) => new() { Json = json }; + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this), + ModelBase.ToStringSerializerOptions + ); + + public static bool DeepEquals(MultipartJsonElement a, MultipartJsonElement b) => + MultipartJsonElement.DeepEqualsInner(a.Json, a.BinaryContents, b.Json, b.BinaryContents); + + static bool DeepEqualsInner( + JsonElement jsonA, + IReadOnlyDictionary binaryA, + JsonElement jsonB, + IReadOnlyDictionary binaryB + ) + { + if (jsonA.ValueKind != jsonB.ValueKind) + { + return false; + } + + switch (jsonA.ValueKind) + { + case JsonValueKind.Undefined: + case JsonValueKind.Null: + case JsonValueKind.True: + case JsonValueKind.False: + return true; + case JsonValueKind.Number: + return JsonElement.DeepEquals(jsonA, jsonB); + case JsonValueKind.String: + BinaryContent? aContent = null; + + BinaryContent? bContent = null; + + if (jsonA.TryGetGuid(out var guidA) && binaryA.TryGetValue(guidA, out var a)) + { + aContent = a; + } + + if (jsonB.TryGetGuid(out var guidB) && binaryB.TryGetValue(guidB, out var b)) + { + bContent = b; + } + + if (aContent != null && bContent != null) + { + return aContent == bContent; + } + else if (aContent == null && bContent == null) + { + return jsonA.GetString() == jsonB.GetString(); + } + else + { + return false; + } + case JsonValueKind.Object: + Dictionary propertiesA = new(); + + foreach (var item1 in jsonA.EnumerateObject()) + { + propertiesA[item1.Name] = item1.Value; + } + + Dictionary propertiesB = new(); + + foreach (var item1 in jsonB.EnumerateObject()) + { + propertiesB[item1.Name] = item1.Value; + } + + if (propertiesA.Count != propertiesB.Count) + { + return false; + } + + foreach (var property in propertiesA) + { + if (!propertiesB.TryGetValue(property.Key, out var b1)) + { + return false; + } + + if (!MultipartJsonElement.DeepEqualsInner(property.Value, binaryA, b1, binaryB)) + { + return false; + } + } + + return true; + case JsonValueKind.Array: + if (jsonA.GetArrayLength() != jsonB.GetArrayLength()) + { + return false; + } + + var i = 0; + foreach (var item in jsonA.EnumerateArray()) + { + if (!MultipartJsonElement.DeepEqualsInner(item, binaryA, jsonB[i], binaryB)) + { + return false; + } + + i++; + } + + return true; + default: + throw new InvalidOperationException("Unreachable"); + } + } } /// diff --git a/src/ImageKit/Models/Accounts/Origins/OriginCreateParams.cs b/src/ImageKit/Models/Accounts/Origins/OriginCreateParams.cs index c0989dfd..84c40270 100644 --- a/src/ImageKit/Models/Accounts/Origins/OriginCreateParams.cs +++ b/src/ImageKit/Models/Accounts/Origins/OriginCreateParams.cs @@ -90,12 +90,18 @@ IReadOnlyDictionary rawBodyData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - ["BodyData"] = this._rawBodyData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/ImageKit/Models/Accounts/Origins/OriginDeleteParams.cs b/src/ImageKit/Models/Accounts/Origins/OriginDeleteParams.cs index fde2e66e..63da26fe 100644 --- a/src/ImageKit/Models/Accounts/Origins/OriginDeleteParams.cs +++ b/src/ImageKit/Models/Accounts/Origins/OriginDeleteParams.cs @@ -66,12 +66,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["ID"] = this.ID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ID"] = JsonSerializer.SerializeToElement(this.ID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/ImageKit/Models/Accounts/Origins/OriginGetParams.cs b/src/ImageKit/Models/Accounts/Origins/OriginGetParams.cs index c555f537..c8d1b8f8 100644 --- a/src/ImageKit/Models/Accounts/Origins/OriginGetParams.cs +++ b/src/ImageKit/Models/Accounts/Origins/OriginGetParams.cs @@ -65,12 +65,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["ID"] = this.ID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ID"] = JsonSerializer.SerializeToElement(this.ID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/ImageKit/Models/Accounts/Origins/OriginListParams.cs b/src/ImageKit/Models/Accounts/Origins/OriginListParams.cs index 4655f09e..05a29757 100644 --- a/src/ImageKit/Models/Accounts/Origins/OriginListParams.cs +++ b/src/ImageKit/Models/Accounts/Origins/OriginListParams.cs @@ -61,11 +61,17 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/ImageKit/Models/Accounts/Origins/OriginRequest.cs b/src/ImageKit/Models/Accounts/Origins/OriginRequest.cs index daa6c565..a1e5e786 100644 --- a/src/ImageKit/Models/Accounts/Origins/OriginRequest.cs +++ b/src/ImageKit/Models/Accounts/Origins/OriginRequest.cs @@ -585,7 +585,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/ImageKit/Models/Accounts/Origins/OriginResponse.cs b/src/ImageKit/Models/Accounts/Origins/OriginResponse.cs index dcc43728..4859a56f 100644 --- a/src/ImageKit/Models/Accounts/Origins/OriginResponse.cs +++ b/src/ImageKit/Models/Accounts/Origins/OriginResponse.cs @@ -571,7 +571,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/ImageKit/Models/Accounts/Origins/OriginUpdateParams.cs b/src/ImageKit/Models/Accounts/Origins/OriginUpdateParams.cs index b06f6f79..b8662882 100644 --- a/src/ImageKit/Models/Accounts/Origins/OriginUpdateParams.cs +++ b/src/ImageKit/Models/Accounts/Origins/OriginUpdateParams.cs @@ -94,13 +94,19 @@ IReadOnlyDictionary rawBodyData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["ID"] = this.ID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - ["BodyData"] = this._rawBodyData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ID"] = JsonSerializer.SerializeToElement(this.ID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointCreateParams.cs b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointCreateParams.cs index 64aed354..550905c9 100644 --- a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointCreateParams.cs +++ b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointCreateParams.cs @@ -162,12 +162,18 @@ IReadOnlyDictionary rawBodyData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - ["BodyData"] = this._rawBodyData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); @@ -439,7 +445,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointDeleteParams.cs b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointDeleteParams.cs index a73ce4af..40b14582 100644 --- a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointDeleteParams.cs +++ b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointDeleteParams.cs @@ -67,12 +67,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["ID"] = this.ID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ID"] = JsonSerializer.SerializeToElement(this.ID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointGetParams.cs b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointGetParams.cs index 4c0aa186..c16951e8 100644 --- a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointGetParams.cs +++ b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointGetParams.cs @@ -66,12 +66,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["ID"] = this.ID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ID"] = JsonSerializer.SerializeToElement(this.ID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointListParams.cs b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointListParams.cs index 3b9db351..d9c525d2 100644 --- a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointListParams.cs +++ b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointListParams.cs @@ -61,11 +61,17 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointRequest.cs b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointRequest.cs index bf9a031d..c8a5a703 100644 --- a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointRequest.cs +++ b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointRequest.cs @@ -401,7 +401,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointResponse.cs b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointResponse.cs index 771e1a81..e1f0504d 100644 --- a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointResponse.cs +++ b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointResponse.cs @@ -396,7 +396,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParams.cs b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParams.cs index 7000cbca..40e53fb7 100644 --- a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParams.cs +++ b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParams.cs @@ -168,13 +168,19 @@ IReadOnlyDictionary rawBodyData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["ID"] = this.ID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - ["BodyData"] = this._rawBodyData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ID"] = JsonSerializer.SerializeToElement(this.ID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); @@ -477,7 +483,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/ImageKit/Models/Accounts/Usage/UsageGetParams.cs b/src/ImageKit/Models/Accounts/Usage/UsageGetParams.cs index 42f9e9da..82f23050 100644 --- a/src/ImageKit/Models/Accounts/Usage/UsageGetParams.cs +++ b/src/ImageKit/Models/Accounts/Usage/UsageGetParams.cs @@ -91,11 +91,17 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/ImageKit/Models/Assets/AssetListParams.cs b/src/ImageKit/Models/Assets/AssetListParams.cs index d095f4e3..fb310b80 100644 --- a/src/ImageKit/Models/Assets/AssetListParams.cs +++ b/src/ImageKit/Models/Assets/AssetListParams.cs @@ -236,11 +236,17 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/ImageKit/Models/Assets/AssetListResponse.cs b/src/ImageKit/Models/Assets/AssetListResponse.cs index 9864b5ee..f8fdeef9 100644 --- a/src/ImageKit/Models/Assets/AssetListResponse.cs +++ b/src/ImageKit/Models/Assets/AssetListResponse.cs @@ -221,7 +221,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/ImageKit/Models/Beta/V2/Files/FileUploadParams.cs b/src/ImageKit/Models/Beta/V2/Files/FileUploadParams.cs index 591f7da1..2ff6ae76 100644 --- a/src/ImageKit/Models/Beta/V2/Files/FileUploadParams.cs +++ b/src/ImageKit/Models/Beta/V2/Files/FileUploadParams.cs @@ -583,6 +583,34 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(FileUploadParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder( @@ -1072,7 +1100,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/ImageKit/Models/Beta/V2/Files/FileUploadResponse.cs b/src/ImageKit/Models/Beta/V2/Files/FileUploadResponse.cs index f9a6480b..f9795085 100644 --- a/src/ImageKit/Models/Beta/V2/Files/FileUploadResponse.cs +++ b/src/ImageKit/Models/Beta/V2/Files/FileUploadResponse.cs @@ -1762,7 +1762,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -2071,7 +2074,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -2323,7 +2329,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -2561,7 +2570,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -2839,7 +2851,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/ImageKit/Models/Cache/Invalidation/InvalidationCreateParams.cs b/src/ImageKit/Models/Cache/Invalidation/InvalidationCreateParams.cs index dbb942e2..701cfe80 100644 --- a/src/ImageKit/Models/Cache/Invalidation/InvalidationCreateParams.cs +++ b/src/ImageKit/Models/Cache/Invalidation/InvalidationCreateParams.cs @@ -90,12 +90,18 @@ IReadOnlyDictionary rawBodyData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - ["BodyData"] = this._rawBodyData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/ImageKit/Models/Cache/Invalidation/InvalidationGetParams.cs b/src/ImageKit/Models/Cache/Invalidation/InvalidationGetParams.cs index fe7a92f5..97879c00 100644 --- a/src/ImageKit/Models/Cache/Invalidation/InvalidationGetParams.cs +++ b/src/ImageKit/Models/Cache/Invalidation/InvalidationGetParams.cs @@ -65,12 +65,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["RequestID"] = this.RequestID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["RequestID"] = JsonSerializer.SerializeToElement(this.RequestID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataField.cs b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataField.cs index cbf5b422..fe3ee6e2 100644 --- a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataField.cs +++ b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataField.cs @@ -697,7 +697,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -1007,7 +1010,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -1261,7 +1267,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -1506,7 +1515,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -1791,7 +1803,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldCreateParams.cs b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldCreateParams.cs index 6636b72e..ec4e15eb 100644 --- a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldCreateParams.cs +++ b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldCreateParams.cs @@ -123,12 +123,18 @@ IReadOnlyDictionary rawBodyData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - ["BodyData"] = this._rawBodyData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); @@ -749,7 +755,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -1058,7 +1067,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -1310,7 +1322,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -1548,7 +1563,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -1826,7 +1844,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldDeleteParams.cs b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldDeleteParams.cs index 73631a62..bb80ffa0 100644 --- a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldDeleteParams.cs +++ b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldDeleteParams.cs @@ -68,12 +68,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["ID"] = this.ID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ID"] = JsonSerializer.SerializeToElement(this.ID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldListParams.cs b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldListParams.cs index 2252a1e2..a7e74c56 100644 --- a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldListParams.cs +++ b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldListParams.cs @@ -114,11 +114,17 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParams.cs b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParams.cs index 08b7a80a..1f93a409 100644 --- a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParams.cs +++ b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParams.cs @@ -135,13 +135,19 @@ IReadOnlyDictionary rawBodyData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["ID"] = this.ID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - ["BodyData"] = this._rawBodyData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ID"] = JsonSerializer.SerializeToElement(this.ID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); @@ -719,7 +725,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -1029,7 +1038,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -1285,7 +1297,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -1532,7 +1547,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -1829,7 +1847,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/ImageKit/Models/ExtensionConfig.cs b/src/ImageKit/Models/ExtensionConfig.cs index 84fe7b9f..272a0615 100644 --- a/src/ImageKit/Models/ExtensionConfig.cs +++ b/src/ImageKit/Models/ExtensionConfig.cs @@ -281,7 +281,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -1201,7 +1204,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -1842,7 +1848,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -2557,7 +2566,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -2858,7 +2870,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -3493,7 +3508,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -3794,7 +3812,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -4431,7 +4452,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -4732,7 +4756,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/ImageKit/Models/Files/Bulk/BulkAddTagsParams.cs b/src/ImageKit/Models/Files/Bulk/BulkAddTagsParams.cs index df283149..433fb382 100644 --- a/src/ImageKit/Models/Files/Bulk/BulkAddTagsParams.cs +++ b/src/ImageKit/Models/Files/Bulk/BulkAddTagsParams.cs @@ -116,12 +116,18 @@ IReadOnlyDictionary rawBodyData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - ["BodyData"] = this._rawBodyData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/ImageKit/Models/Files/Bulk/BulkDeleteParams.cs b/src/ImageKit/Models/Files/Bulk/BulkDeleteParams.cs index 9b82c5e6..edb69a31 100644 --- a/src/ImageKit/Models/Files/Bulk/BulkDeleteParams.cs +++ b/src/ImageKit/Models/Files/Bulk/BulkDeleteParams.cs @@ -102,12 +102,18 @@ IReadOnlyDictionary rawBodyData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - ["BodyData"] = this._rawBodyData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/ImageKit/Models/Files/Bulk/BulkRemoveAITagsParams.cs b/src/ImageKit/Models/Files/Bulk/BulkRemoveAITagsParams.cs index 479864bb..86a1aaf7 100644 --- a/src/ImageKit/Models/Files/Bulk/BulkRemoveAITagsParams.cs +++ b/src/ImageKit/Models/Files/Bulk/BulkRemoveAITagsParams.cs @@ -116,12 +116,18 @@ IReadOnlyDictionary rawBodyData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - ["BodyData"] = this._rawBodyData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/ImageKit/Models/Files/Bulk/BulkRemoveTagsParams.cs b/src/ImageKit/Models/Files/Bulk/BulkRemoveTagsParams.cs index e01166d5..19469d14 100644 --- a/src/ImageKit/Models/Files/Bulk/BulkRemoveTagsParams.cs +++ b/src/ImageKit/Models/Files/Bulk/BulkRemoveTagsParams.cs @@ -116,12 +116,18 @@ IReadOnlyDictionary rawBodyData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - ["BodyData"] = this._rawBodyData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/ImageKit/Models/Files/File.cs b/src/ImageKit/Models/Files/File.cs index b2e4fe1f..873e38da 100644 --- a/src/ImageKit/Models/Files/File.cs +++ b/src/ImageKit/Models/Files/File.cs @@ -1425,7 +1425,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -1734,7 +1737,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -1986,7 +1992,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -2224,7 +2233,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -2502,7 +2514,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/ImageKit/Models/Files/FileCopyParams.cs b/src/ImageKit/Models/Files/FileCopyParams.cs index 1bfc5af9..f753d543 100644 --- a/src/ImageKit/Models/Files/FileCopyParams.cs +++ b/src/ImageKit/Models/Files/FileCopyParams.cs @@ -129,12 +129,18 @@ IReadOnlyDictionary rawBodyData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - ["BodyData"] = this._rawBodyData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/ImageKit/Models/Files/FileDeleteParams.cs b/src/ImageKit/Models/Files/FileDeleteParams.cs index e404bcdb..b5ebe506 100644 --- a/src/ImageKit/Models/Files/FileDeleteParams.cs +++ b/src/ImageKit/Models/Files/FileDeleteParams.cs @@ -69,12 +69,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["FileID"] = this.FileID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["FileID"] = JsonSerializer.SerializeToElement(this.FileID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/ImageKit/Models/Files/FileGetParams.cs b/src/ImageKit/Models/Files/FileGetParams.cs index 0b454cee..9e9c3f26 100644 --- a/src/ImageKit/Models/Files/FileGetParams.cs +++ b/src/ImageKit/Models/Files/FileGetParams.cs @@ -66,12 +66,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["FileID"] = this.FileID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["FileID"] = JsonSerializer.SerializeToElement(this.FileID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/ImageKit/Models/Files/FileMoveParams.cs b/src/ImageKit/Models/Files/FileMoveParams.cs index 3a44a747..1468d03e 100644 --- a/src/ImageKit/Models/Files/FileMoveParams.cs +++ b/src/ImageKit/Models/Files/FileMoveParams.cs @@ -105,12 +105,18 @@ IReadOnlyDictionary rawBodyData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - ["BodyData"] = this._rawBodyData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/ImageKit/Models/Files/FileRenameParams.cs b/src/ImageKit/Models/Files/FileRenameParams.cs index ed99e9a6..d21b273c 100644 --- a/src/ImageKit/Models/Files/FileRenameParams.cs +++ b/src/ImageKit/Models/Files/FileRenameParams.cs @@ -146,12 +146,18 @@ IReadOnlyDictionary rawBodyData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - ["BodyData"] = this._rawBodyData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/ImageKit/Models/Files/FileUpdateParams.cs b/src/ImageKit/Models/Files/FileUpdateParams.cs index 88720d36..a7097a49 100644 --- a/src/ImageKit/Models/Files/FileUpdateParams.cs +++ b/src/ImageKit/Models/Files/FileUpdateParams.cs @@ -95,13 +95,19 @@ IReadOnlyDictionary rawBodyData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["FileID"] = this.FileID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - ["BodyData"] = this._rawBodyData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["FileID"] = JsonSerializer.SerializeToElement(this.FileID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/ImageKit/Models/Files/FileUploadParams.cs b/src/ImageKit/Models/Files/FileUploadParams.cs index 72c34932..9671d243 100644 --- a/src/ImageKit/Models/Files/FileUploadParams.cs +++ b/src/ImageKit/Models/Files/FileUploadParams.cs @@ -661,6 +661,34 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(FileUploadParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder( @@ -1150,7 +1178,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/ImageKit/Models/Files/FileUploadResponse.cs b/src/ImageKit/Models/Files/FileUploadResponse.cs index bbe82990..427d75f7 100644 --- a/src/ImageKit/Models/Files/FileUploadResponse.cs +++ b/src/ImageKit/Models/Files/FileUploadResponse.cs @@ -1834,7 +1834,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -2144,7 +2147,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -2408,7 +2414,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -2663,7 +2672,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -2961,7 +2973,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/ImageKit/Models/Files/Metadata/MetadataGetFromUrlParams.cs b/src/ImageKit/Models/Files/Metadata/MetadataGetFromUrlParams.cs index 9b008d54..6b89b976 100644 --- a/src/ImageKit/Models/Files/Metadata/MetadataGetFromUrlParams.cs +++ b/src/ImageKit/Models/Files/Metadata/MetadataGetFromUrlParams.cs @@ -75,11 +75,17 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/ImageKit/Models/Files/Metadata/MetadataGetParams.cs b/src/ImageKit/Models/Files/Metadata/MetadataGetParams.cs index e02fd2f2..c1e118fb 100644 --- a/src/ImageKit/Models/Files/Metadata/MetadataGetParams.cs +++ b/src/ImageKit/Models/Files/Metadata/MetadataGetParams.cs @@ -69,12 +69,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["FileID"] = this.FileID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["FileID"] = JsonSerializer.SerializeToElement(this.FileID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/ImageKit/Models/Files/UpdateFileRequest.cs b/src/ImageKit/Models/Files/UpdateFileRequest.cs index 936de263..5a90a49c 100644 --- a/src/ImageKit/Models/Files/UpdateFileRequest.cs +++ b/src/ImageKit/Models/Files/UpdateFileRequest.cs @@ -207,7 +207,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -689,7 +692,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/ImageKit/Models/Files/Versions/VersionDeleteParams.cs b/src/ImageKit/Models/Files/Versions/VersionDeleteParams.cs index 89f04cdb..44386248 100644 --- a/src/ImageKit/Models/Files/Versions/VersionDeleteParams.cs +++ b/src/ImageKit/Models/Files/Versions/VersionDeleteParams.cs @@ -70,13 +70,19 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["FileID"] = this.FileID, - ["VersionID"] = this.VersionID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["FileID"] = JsonSerializer.SerializeToElement(this.FileID), + ["VersionID"] = JsonSerializer.SerializeToElement(this.VersionID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/ImageKit/Models/Files/Versions/VersionGetParams.cs b/src/ImageKit/Models/Files/Versions/VersionGetParams.cs index 5af86762..e3d98310 100644 --- a/src/ImageKit/Models/Files/Versions/VersionGetParams.cs +++ b/src/ImageKit/Models/Files/Versions/VersionGetParams.cs @@ -68,13 +68,19 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["FileID"] = this.FileID, - ["VersionID"] = this.VersionID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["FileID"] = JsonSerializer.SerializeToElement(this.FileID), + ["VersionID"] = JsonSerializer.SerializeToElement(this.VersionID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/ImageKit/Models/Files/Versions/VersionListParams.cs b/src/ImageKit/Models/Files/Versions/VersionListParams.cs index 632da287..fc659e77 100644 --- a/src/ImageKit/Models/Files/Versions/VersionListParams.cs +++ b/src/ImageKit/Models/Files/Versions/VersionListParams.cs @@ -65,12 +65,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["FileID"] = this.FileID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["FileID"] = JsonSerializer.SerializeToElement(this.FileID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/ImageKit/Models/Files/Versions/VersionRestoreParams.cs b/src/ImageKit/Models/Files/Versions/VersionRestoreParams.cs index cabd0070..f92b4ba4 100644 --- a/src/ImageKit/Models/Files/Versions/VersionRestoreParams.cs +++ b/src/ImageKit/Models/Files/Versions/VersionRestoreParams.cs @@ -68,13 +68,19 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["FileID"] = this.FileID, - ["VersionID"] = this.VersionID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["FileID"] = JsonSerializer.SerializeToElement(this.FileID), + ["VersionID"] = JsonSerializer.SerializeToElement(this.VersionID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/ImageKit/Models/Folders/FolderCopyParams.cs b/src/ImageKit/Models/Folders/FolderCopyParams.cs index f2c61c8b..df64d046 100644 --- a/src/ImageKit/Models/Folders/FolderCopyParams.cs +++ b/src/ImageKit/Models/Folders/FolderCopyParams.cs @@ -130,12 +130,18 @@ IReadOnlyDictionary rawBodyData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - ["BodyData"] = this._rawBodyData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/ImageKit/Models/Folders/FolderCreateParams.cs b/src/ImageKit/Models/Folders/FolderCreateParams.cs index 7e5fd4e0..324d2ec9 100644 --- a/src/ImageKit/Models/Folders/FolderCreateParams.cs +++ b/src/ImageKit/Models/Folders/FolderCreateParams.cs @@ -113,12 +113,18 @@ IReadOnlyDictionary rawBodyData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - ["BodyData"] = this._rawBodyData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/ImageKit/Models/Folders/FolderDeleteParams.cs b/src/ImageKit/Models/Folders/FolderDeleteParams.cs index e4767eb2..3a7ef551 100644 --- a/src/ImageKit/Models/Folders/FolderDeleteParams.cs +++ b/src/ImageKit/Models/Folders/FolderDeleteParams.cs @@ -90,12 +90,18 @@ IReadOnlyDictionary rawBodyData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - ["BodyData"] = this._rawBodyData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/ImageKit/Models/Folders/FolderMoveParams.cs b/src/ImageKit/Models/Folders/FolderMoveParams.cs index c4f5833d..fc7f0536 100644 --- a/src/ImageKit/Models/Folders/FolderMoveParams.cs +++ b/src/ImageKit/Models/Folders/FolderMoveParams.cs @@ -106,12 +106,18 @@ IReadOnlyDictionary rawBodyData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - ["BodyData"] = this._rawBodyData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/ImageKit/Models/Folders/FolderRenameParams.cs b/src/ImageKit/Models/Folders/FolderRenameParams.cs index 3dcd63e1..af437fdd 100644 --- a/src/ImageKit/Models/Folders/FolderRenameParams.cs +++ b/src/ImageKit/Models/Folders/FolderRenameParams.cs @@ -143,12 +143,18 @@ IReadOnlyDictionary rawBodyData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - ["BodyData"] = this._rawBodyData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/ImageKit/Models/Folders/Job/JobGetParams.cs b/src/ImageKit/Models/Folders/Job/JobGetParams.cs index 41e49a54..daf8d7d3 100644 --- a/src/ImageKit/Models/Folders/Job/JobGetParams.cs +++ b/src/ImageKit/Models/Folders/Job/JobGetParams.cs @@ -65,12 +65,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["JobID"] = this.JobID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["JobID"] = JsonSerializer.SerializeToElement(this.JobID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/ImageKit/Models/Overlay.cs b/src/ImageKit/Models/Overlay.cs index 3b26f8a0..6e3db454 100644 --- a/src/ImageKit/Models/Overlay.cs +++ b/src/ImageKit/Models/Overlay.cs @@ -384,7 +384,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/ImageKit/Models/OverlayPosition.cs b/src/ImageKit/Models/OverlayPosition.cs index 3d2eebd2..c01067c5 100644 --- a/src/ImageKit/Models/OverlayPosition.cs +++ b/src/ImageKit/Models/OverlayPosition.cs @@ -372,7 +372,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -607,7 +610,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/ImageKit/Models/OverlayTiming.cs b/src/ImageKit/Models/OverlayTiming.cs index b6151de9..86cdb1e8 100644 --- a/src/ImageKit/Models/OverlayTiming.cs +++ b/src/ImageKit/Models/OverlayTiming.cs @@ -314,7 +314,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -550,7 +553,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -785,7 +791,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/ImageKit/Models/SavedExtensions/SavedExtensionCreateParams.cs b/src/ImageKit/Models/SavedExtensions/SavedExtensionCreateParams.cs index e26bcf0b..24b770da 100644 --- a/src/ImageKit/Models/SavedExtensions/SavedExtensionCreateParams.cs +++ b/src/ImageKit/Models/SavedExtensions/SavedExtensionCreateParams.cs @@ -120,12 +120,18 @@ IReadOnlyDictionary rawBodyData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - ["BodyData"] = this._rawBodyData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/ImageKit/Models/SavedExtensions/SavedExtensionDeleteParams.cs b/src/ImageKit/Models/SavedExtensions/SavedExtensionDeleteParams.cs index 38beadc8..8c3b4139 100644 --- a/src/ImageKit/Models/SavedExtensions/SavedExtensionDeleteParams.cs +++ b/src/ImageKit/Models/SavedExtensions/SavedExtensionDeleteParams.cs @@ -65,12 +65,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["ID"] = this.ID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ID"] = JsonSerializer.SerializeToElement(this.ID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/ImageKit/Models/SavedExtensions/SavedExtensionGetParams.cs b/src/ImageKit/Models/SavedExtensions/SavedExtensionGetParams.cs index 5bdf33e2..938c565e 100644 --- a/src/ImageKit/Models/SavedExtensions/SavedExtensionGetParams.cs +++ b/src/ImageKit/Models/SavedExtensions/SavedExtensionGetParams.cs @@ -65,12 +65,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["ID"] = this.ID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ID"] = JsonSerializer.SerializeToElement(this.ID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/ImageKit/Models/SavedExtensions/SavedExtensionListParams.cs b/src/ImageKit/Models/SavedExtensions/SavedExtensionListParams.cs index 795a8f36..c80b7447 100644 --- a/src/ImageKit/Models/SavedExtensions/SavedExtensionListParams.cs +++ b/src/ImageKit/Models/SavedExtensions/SavedExtensionListParams.cs @@ -62,11 +62,17 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/ImageKit/Models/SavedExtensions/SavedExtensionUpdateParams.cs b/src/ImageKit/Models/SavedExtensions/SavedExtensionUpdateParams.cs index a5efcaa1..d7c05310 100644 --- a/src/ImageKit/Models/SavedExtensions/SavedExtensionUpdateParams.cs +++ b/src/ImageKit/Models/SavedExtensions/SavedExtensionUpdateParams.cs @@ -144,13 +144,19 @@ IReadOnlyDictionary rawBodyData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["ID"] = this.ID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - ["BodyData"] = this._rawBodyData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ID"] = JsonSerializer.SerializeToElement(this.ID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/ImageKit/Models/SolidColorOverlayTransformation.cs b/src/ImageKit/Models/SolidColorOverlayTransformation.cs index c19f6c2c..0ba07584 100644 --- a/src/ImageKit/Models/SolidColorOverlayTransformation.cs +++ b/src/ImageKit/Models/SolidColorOverlayTransformation.cs @@ -391,7 +391,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -698,7 +701,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -970,7 +976,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -1288,7 +1297,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/ImageKit/Models/TextOverlayTransformation.cs b/src/ImageKit/Models/TextOverlayTransformation.cs index b1e4600f..431aeb8a 100644 --- a/src/ImageKit/Models/TextOverlayTransformation.cs +++ b/src/ImageKit/Models/TextOverlayTransformation.cs @@ -603,7 +603,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -891,7 +894,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -1131,7 +1137,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -1424,7 +1433,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -1757,7 +1769,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -1997,7 +2012,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/ImageKit/Models/Transformation.cs b/src/ImageKit/Models/Transformation.cs index f8aa76e2..6ec3bf5e 100644 --- a/src/ImageKit/Models/Transformation.cs +++ b/src/ImageKit/Models/Transformation.cs @@ -1564,7 +1564,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -2113,7 +2116,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -2550,7 +2556,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -2792,7 +2801,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -3171,7 +3183,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -3540,7 +3555,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -3779,7 +3797,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -4066,7 +4087,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -4400,7 +4424,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -4639,7 +4666,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -4949,7 +4979,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -5256,7 +5289,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -5495,7 +5531,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -5804,7 +5843,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -6181,7 +6223,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -6423,7 +6468,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -6662,7 +6710,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -6900,7 +6951,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -7139,7 +7193,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/ImageKit/Models/UnnamedSchemaWithArrayParent0.cs b/src/ImageKit/Models/UnnamedSchemaWithArrayParent0.cs index fa6a5be6..6a0933ae 100644 --- a/src/ImageKit/Models/UnnamedSchemaWithArrayParent0.cs +++ b/src/ImageKit/Models/UnnamedSchemaWithArrayParent0.cs @@ -343,7 +343,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -1384,7 +1387,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -2093,7 +2099,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -2880,7 +2889,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -3182,7 +3194,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -3886,7 +3901,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -4188,7 +4206,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -4888,7 +4909,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -5190,7 +5214,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/ImageKit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs b/src/ImageKit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs index 71bdcb58..81e68557 100644 --- a/src/ImageKit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs +++ b/src/ImageKit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs @@ -484,7 +484,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/ImageKit/Models/Webhooks/UnwrapWebhookEvent.cs b/src/ImageKit/Models/Webhooks/UnwrapWebhookEvent.cs index 67fa2876..b25779dd 100644 --- a/src/ImageKit/Models/Webhooks/UnwrapWebhookEvent.cs +++ b/src/ImageKit/Models/Webhooks/UnwrapWebhookEvent.cs @@ -463,7 +463,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/ImageKit/Models/Webhooks/UploadPreTransformSuccessEvent.cs b/src/ImageKit/Models/Webhooks/UploadPreTransformSuccessEvent.cs index 63283c90..d9103896 100644 --- a/src/ImageKit/Models/Webhooks/UploadPreTransformSuccessEvent.cs +++ b/src/ImageKit/Models/Webhooks/UploadPreTransformSuccessEvent.cs @@ -2039,7 +2039,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -2348,7 +2351,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -2600,7 +2606,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -2838,7 +2847,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -3116,7 +3128,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { From f051a136ea8e267c7de0e39721312f9b6bcc1001 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 17 Feb 2026 18:24:28 +0000 Subject: [PATCH 069/129] fix(client): validate unions properly --- .../Beta/V2/Files/FileUploadResponse.cs | 16 +++++++ .../CustomMetadataField.cs | 16 +++++++ .../CustomMetadataFieldCreateParams.cs | 16 +++++++ .../CustomMetadataFieldUpdateParams.cs | 16 +++++++ src/ImageKit/Models/ExtensionConfig.cs | 48 +++++++++++++++++++ src/ImageKit/Models/Files/File.cs | 16 +++++++ .../Models/Files/FileUploadResponse.cs | 16 +++++++ .../Models/UnnamedSchemaWithArrayParent0.cs | 48 +++++++++++++++++++ .../UploadPreTransformSuccessEvent.cs | 16 +++++++ 9 files changed, 208 insertions(+) diff --git a/src/ImageKit/Models/Beta/V2/Files/FileUploadResponse.cs b/src/ImageKit/Models/Beta/V2/Files/FileUploadResponse.cs index f9795085..48b20fbc 100644 --- a/src/ImageKit/Models/Beta/V2/Files/FileUploadResponse.cs +++ b/src/ImageKit/Models/Beta/V2/Files/FileUploadResponse.cs @@ -1749,6 +1749,18 @@ public override void Validate() "Data did not match any variant of DefaultValue" ); } + this.Switch( + (_) => { }, + (_) => { }, + (_) => { }, + (mixed) => + { + foreach (var item in mixed) + { + item.Validate(); + } + } + ); } public virtual bool Equals(DefaultValue? other) => @@ -1828,6 +1840,10 @@ JsonSerializerOptions options ); if (deserialized != null) { + foreach (var item in deserialized) + { + item.Validate(); + } return new(deserialized, element); } } diff --git a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataField.cs b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataField.cs index fe3ee6e2..96be0ceb 100644 --- a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataField.cs +++ b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataField.cs @@ -684,6 +684,18 @@ public override void Validate() "Data did not match any variant of CustomMetadataFieldSchemaDefaultValue" ); } + this.Switch( + (_) => { }, + (_) => { }, + (_) => { }, + (mixed) => + { + foreach (var item in mixed) + { + item.Validate(); + } + } + ); } public virtual bool Equals(CustomMetadataFieldSchemaDefaultValue? other) => @@ -764,6 +776,10 @@ JsonSerializerOptions options ); if (deserialized != null) { + foreach (var item in deserialized) + { + item.Validate(); + } return new(deserialized, element); } } diff --git a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldCreateParams.cs b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldCreateParams.cs index ec4e15eb..b635989e 100644 --- a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldCreateParams.cs +++ b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldCreateParams.cs @@ -742,6 +742,18 @@ public override void Validate() "Data did not match any variant of DefaultValue" ); } + this.Switch( + (_) => { }, + (_) => { }, + (_) => { }, + (mixed) => + { + foreach (var item in mixed) + { + item.Validate(); + } + } + ); } public virtual bool Equals(DefaultValue? other) => @@ -821,6 +833,10 @@ JsonSerializerOptions options ); if (deserialized != null) { + foreach (var item in deserialized) + { + item.Validate(); + } return new(deserialized, element); } } diff --git a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParams.cs b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParams.cs index 1f93a409..740d05fc 100644 --- a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParams.cs +++ b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParams.cs @@ -712,6 +712,18 @@ public override void Validate() "Data did not match any variant of CustomMetadataFieldUpdateParamsSchemaDefaultValue" ); } + this.Switch( + (_) => { }, + (_) => { }, + (_) => { }, + (mixed) => + { + foreach (var item in mixed) + { + item.Validate(); + } + } + ); } public virtual bool Equals(CustomMetadataFieldUpdateParamsSchemaDefaultValue? other) => @@ -792,6 +804,10 @@ JsonSerializerOptions options ); if (deserialized != null) { + foreach (var item in deserialized) + { + item.Validate(); + } return new(deserialized, element); } } diff --git a/src/ImageKit/Models/ExtensionConfig.cs b/src/ImageKit/Models/ExtensionConfig.cs index 272a0615..018cbe87 100644 --- a/src/ImageKit/Models/ExtensionConfig.cs +++ b/src/ImageKit/Models/ExtensionConfig.cs @@ -2553,6 +2553,18 @@ public override void Validate() "Data did not match any variant of SetMetadataValue" ); } + this.Switch( + (_) => { }, + (_) => { }, + (_) => { }, + (mixed) => + { + foreach (var item in mixed) + { + item.Validate(); + } + } + ); } public virtual bool Equals(SetMetadataValue? other) => @@ -2632,6 +2644,10 @@ JsonSerializerOptions options ); if (deserialized != null) { + foreach (var item in deserialized) + { + item.Validate(); + } return new(deserialized, element); } } @@ -3495,6 +3511,18 @@ public override void Validate() "Data did not match any variant of OnUnknownSetMetadataValue" ); } + this.Switch( + (_) => { }, + (_) => { }, + (_) => { }, + (mixed) => + { + foreach (var item in mixed) + { + item.Validate(); + } + } + ); } public virtual bool Equals(OnUnknownSetMetadataValue? other) => @@ -3574,6 +3602,10 @@ JsonSerializerOptions options ); if (deserialized != null) { + foreach (var item in deserialized) + { + item.Validate(); + } return new(deserialized, element); } } @@ -4439,6 +4471,18 @@ public override void Validate() "Data did not match any variant of OnYesSetMetadataValue" ); } + this.Switch( + (_) => { }, + (_) => { }, + (_) => { }, + (mixed) => + { + foreach (var item in mixed) + { + item.Validate(); + } + } + ); } public virtual bool Equals(OnYesSetMetadataValue? other) => @@ -4518,6 +4562,10 @@ JsonSerializerOptions options ); if (deserialized != null) { + foreach (var item in deserialized) + { + item.Validate(); + } return new(deserialized, element); } } diff --git a/src/ImageKit/Models/Files/File.cs b/src/ImageKit/Models/Files/File.cs index 873e38da..29379a78 100644 --- a/src/ImageKit/Models/Files/File.cs +++ b/src/ImageKit/Models/Files/File.cs @@ -1412,6 +1412,18 @@ public override void Validate() "Data did not match any variant of DefaultValue" ); } + this.Switch( + (_) => { }, + (_) => { }, + (_) => { }, + (mixed) => + { + foreach (var item in mixed) + { + item.Validate(); + } + } + ); } public virtual bool Equals(DefaultValue? other) => @@ -1491,6 +1503,10 @@ JsonSerializerOptions options ); if (deserialized != null) { + foreach (var item in deserialized) + { + item.Validate(); + } return new(deserialized, element); } } diff --git a/src/ImageKit/Models/Files/FileUploadResponse.cs b/src/ImageKit/Models/Files/FileUploadResponse.cs index 427d75f7..d5c35efc 100644 --- a/src/ImageKit/Models/Files/FileUploadResponse.cs +++ b/src/ImageKit/Models/Files/FileUploadResponse.cs @@ -1821,6 +1821,18 @@ public override void Validate() "Data did not match any variant of FileUploadResponseSelectedFieldsSchemaItemDefaultValue" ); } + this.Switch( + (_) => { }, + (_) => { }, + (_) => { }, + (mixed) => + { + foreach (var item in mixed) + { + item.Validate(); + } + } + ); } public virtual bool Equals(FileUploadResponseSelectedFieldsSchemaItemDefaultValue? other) => @@ -1901,6 +1913,10 @@ JsonSerializerOptions options ); if (deserialized != null) { + foreach (var item in deserialized) + { + item.Validate(); + } return new(deserialized, element); } } diff --git a/src/ImageKit/Models/UnnamedSchemaWithArrayParent0.cs b/src/ImageKit/Models/UnnamedSchemaWithArrayParent0.cs index 6a0933ae..24296fa1 100644 --- a/src/ImageKit/Models/UnnamedSchemaWithArrayParent0.cs +++ b/src/ImageKit/Models/UnnamedSchemaWithArrayParent0.cs @@ -2874,6 +2874,18 @@ public override void Validate() "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue" ); } + this.Switch( + (_) => { }, + (_) => { }, + (_) => { }, + (mixed) => + { + foreach (var item in mixed) + { + item.Validate(); + } + } + ); } public virtual bool Equals( @@ -2956,6 +2968,10 @@ JsonSerializerOptions options ); if (deserialized != null) { + foreach (var item in deserialized) + { + item.Validate(); + } return new(deserialized, element); } } @@ -3886,6 +3902,18 @@ public override void Validate() "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue" ); } + this.Switch( + (_) => { }, + (_) => { }, + (_) => { }, + (mixed) => + { + foreach (var item in mixed) + { + item.Validate(); + } + } + ); } public virtual bool Equals( @@ -3968,6 +3996,10 @@ JsonSerializerOptions options ); if (deserialized != null) { + foreach (var item in deserialized) + { + item.Validate(); + } return new(deserialized, element); } } @@ -4894,6 +4926,18 @@ public override void Validate() "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue" ); } + this.Switch( + (_) => { }, + (_) => { }, + (_) => { }, + (mixed) => + { + foreach (var item in mixed) + { + item.Validate(); + } + } + ); } public virtual bool Equals( @@ -4976,6 +5020,10 @@ JsonSerializerOptions options ); if (deserialized != null) { + foreach (var item in deserialized) + { + item.Validate(); + } return new(deserialized, element); } } diff --git a/src/ImageKit/Models/Webhooks/UploadPreTransformSuccessEvent.cs b/src/ImageKit/Models/Webhooks/UploadPreTransformSuccessEvent.cs index d9103896..1d1f2026 100644 --- a/src/ImageKit/Models/Webhooks/UploadPreTransformSuccessEvent.cs +++ b/src/ImageKit/Models/Webhooks/UploadPreTransformSuccessEvent.cs @@ -2026,6 +2026,18 @@ public override void Validate() "Data did not match any variant of DefaultValue" ); } + this.Switch( + (_) => { }, + (_) => { }, + (_) => { }, + (mixed) => + { + foreach (var item in mixed) + { + item.Validate(); + } + } + ); } public virtual bool Equals(DefaultValue? other) => @@ -2105,6 +2117,10 @@ JsonSerializerOptions options ); if (deserialized != null) { + foreach (var item in deserialized) + { + item.Validate(); + } return new(deserialized, element); } } From 0db5603b89957482070fd32814f0982ace6dfc49 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 19 Feb 2026 16:03:26 +0000 Subject: [PATCH 070/129] chore(internal): remove mock server code --- scripts/mock | 41 ----------------------------------------- scripts/test | 50 -------------------------------------------------- 2 files changed, 91 deletions(-) delete mode 100755 scripts/mock diff --git a/scripts/mock b/scripts/mock deleted file mode 100755 index 0b28f6ea..00000000 --- a/scripts/mock +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env bash - -set -e - -cd "$(dirname "$0")/.." - -if [[ -n "$1" && "$1" != '--'* ]]; then - URL="$1" - shift -else - URL="$(grep 'openapi_spec_url' .stats.yml | cut -d' ' -f2)" -fi - -# Check if the URL is empty -if [ -z "$URL" ]; then - echo "Error: No OpenAPI spec path/url provided or found in .stats.yml" - exit 1 -fi - -echo "==> Starting mock server with URL ${URL}" - -# Run prism mock on the given spec -if [ "$1" == "--daemon" ]; then - npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" &> .prism.log & - - # Wait for server to come online - echo -n "Waiting for server" - while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do - echo -n "." - sleep 0.1 - done - - if grep -q "✖ fatal" ".prism.log"; then - cat .prism.log - exit 1 - fi - - echo -else - npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" -fi diff --git a/scripts/test b/scripts/test index f47e4b7f..bd71d26e 100755 --- a/scripts/test +++ b/scripts/test @@ -4,57 +4,7 @@ set -e cd -- "$(dirname -- "$0")/.." -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[0;33m' -NC='\033[0m' # No Color -function prism_is_running() { - curl --silent "http://localhost:4010" >/dev/null 2>&1 -} - -kill_server_on_port() { - if [ ! "$(which lsof)" ]; then - echo "Warning: lsof not found. Prism will not be killed." - return 0 - fi - pids=$(lsof -t -i tcp:"$1" || echo "") - if [ "$pids" != "" ]; then - kill "$pids" - echo "Stopped $pids." - fi -} - -function is_overriding_api_base_url() { - [ -n "$TEST_API_BASE_URL" ] -} - -if ! is_overriding_api_base_url && ! prism_is_running ; then - # When we exit this script, make sure to kill the background mock server process - trap 'kill_server_on_port 4010' EXIT - - # Start the dev server - ./scripts/mock --daemon -fi - -if is_overriding_api_base_url ; then - echo -e "${GREEN}✔ Running tests against ${TEST_API_BASE_URL}${NC}" - echo -elif ! prism_is_running ; then - echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Prism server" - echo -e "running against your OpenAPI spec." - echo - echo -e "To run the server, pass in the path or url of your OpenAPI" - echo -e "spec to the prism command:" - echo - echo -e " \$ ${YELLOW}npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock path/to/your.openapi.yml${NC}" - echo - - exit 1 -else - echo -e "${GREEN}✔ Mock prism server is running with your OpenAPI spec${NC}" - echo -fi echo "==> Running tests" dotnet test From eda74887bad3b66bdc9bbda95f31873a5f6f43d8 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 19 Feb 2026 16:33:44 +0000 Subject: [PATCH 071/129] chore: update mock server docs --- .devcontainer/devcontainer.json | 2 +- .../Services/Accounts/OriginServiceTest.cs | 10 +++++----- .../Services/Accounts/UrlEndpointServiceTest.cs | 10 +++++----- .../Services/Accounts/UsageServiceTest.cs | 2 +- src/ImageKit.Tests/Services/AssetServiceTest.cs | 2 +- .../Services/Beta/V2/FileServiceTest.cs | 2 +- .../Services/Cache/InvalidationServiceTest.cs | 4 ++-- .../Services/CustomMetadataFieldServiceTest.cs | 8 ++++---- src/ImageKit.Tests/Services/FileServiceTest.cs | 14 +++++++------- .../Services/Files/BulkServiceTest.cs | 8 ++++---- .../Services/Files/MetadataServiceTest.cs | 4 ++-- .../Services/Files/VersionServiceTest.cs | 8 ++++---- src/ImageKit.Tests/Services/FolderServiceTest.cs | 10 +++++----- .../Services/Folders/JobServiceTest.cs | 2 +- .../Services/SavedExtensionServiceTest.cs | 10 +++++----- 15 files changed, 48 insertions(+), 48 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 00e36898..9f50ad39 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -6,7 +6,7 @@ "postAttachCommand": "cat .vscode/extensions.json | jq -r .recommendations[] | xargs -n 1 code --install-extension", "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", "features": { - // For the Prism mock server. + // For the mock server. "ghcr.io/devcontainers/features/node:1": {} } } diff --git a/src/ImageKit.Tests/Services/Accounts/OriginServiceTest.cs b/src/ImageKit.Tests/Services/Accounts/OriginServiceTest.cs index 0aee0d61..2bab595d 100644 --- a/src/ImageKit.Tests/Services/Accounts/OriginServiceTest.cs +++ b/src/ImageKit.Tests/Services/Accounts/OriginServiceTest.cs @@ -5,7 +5,7 @@ namespace ImageKit.Tests.Services.Accounts; public class OriginServiceTest : TestBase { - [Fact(Skip = "Prism tests are disabled")] + [Fact(Skip = "Mock server tests are disabled")] public async Task Create_Works() { var originResponse = await this.client.Accounts.Origins.Create( @@ -27,7 +27,7 @@ public async Task Create_Works() originResponse.Validate(); } - [Fact(Skip = "Prism tests are disabled")] + [Fact(Skip = "Mock server tests are disabled")] public async Task Update_Works() { var originResponse = await this.client.Accounts.Origins.Update( @@ -50,7 +50,7 @@ public async Task Update_Works() originResponse.Validate(); } - [Fact(Skip = "Prism tests are disabled")] + [Fact(Skip = "Mock server tests are disabled")] public async Task List_Works() { var originResponses = await this.client.Accounts.Origins.List( @@ -63,7 +63,7 @@ public async Task List_Works() } } - [Fact(Skip = "Prism tests are disabled")] + [Fact(Skip = "Mock server tests are disabled")] public async Task Delete_Works() { await this.client.Accounts.Origins.Delete( @@ -73,7 +73,7 @@ await this.client.Accounts.Origins.Delete( ); } - [Fact(Skip = "Prism tests are disabled")] + [Fact(Skip = "Mock server tests are disabled")] public async Task Get_Works() { var originResponse = await this.client.Accounts.Origins.Get( diff --git a/src/ImageKit.Tests/Services/Accounts/UrlEndpointServiceTest.cs b/src/ImageKit.Tests/Services/Accounts/UrlEndpointServiceTest.cs index 2ab59468..77e8adfc 100644 --- a/src/ImageKit.Tests/Services/Accounts/UrlEndpointServiceTest.cs +++ b/src/ImageKit.Tests/Services/Accounts/UrlEndpointServiceTest.cs @@ -4,7 +4,7 @@ namespace ImageKit.Tests.Services.Accounts; public class UrlEndpointServiceTest : TestBase { - [Fact(Skip = "Prism tests are disabled")] + [Fact(Skip = "Mock server tests are disabled")] public async Task Create_Works() { var urlEndpointResponse = await this.client.Accounts.UrlEndpoints.Create( @@ -14,7 +14,7 @@ public async Task Create_Works() urlEndpointResponse.Validate(); } - [Fact(Skip = "Prism tests are disabled")] + [Fact(Skip = "Mock server tests are disabled")] public async Task Update_Works() { var urlEndpointResponse = await this.client.Accounts.UrlEndpoints.Update( @@ -25,7 +25,7 @@ public async Task Update_Works() urlEndpointResponse.Validate(); } - [Fact(Skip = "Prism tests are disabled")] + [Fact(Skip = "Mock server tests are disabled")] public async Task List_Works() { var urlEndpointResponses = await this.client.Accounts.UrlEndpoints.List( @@ -38,7 +38,7 @@ public async Task List_Works() } } - [Fact(Skip = "Prism tests are disabled")] + [Fact(Skip = "Mock server tests are disabled")] public async Task Delete_Works() { await this.client.Accounts.UrlEndpoints.Delete( @@ -48,7 +48,7 @@ await this.client.Accounts.UrlEndpoints.Delete( ); } - [Fact(Skip = "Prism tests are disabled")] + [Fact(Skip = "Mock server tests are disabled")] public async Task Get_Works() { var urlEndpointResponse = await this.client.Accounts.UrlEndpoints.Get( diff --git a/src/ImageKit.Tests/Services/Accounts/UsageServiceTest.cs b/src/ImageKit.Tests/Services/Accounts/UsageServiceTest.cs index 90f107d8..8637eded 100644 --- a/src/ImageKit.Tests/Services/Accounts/UsageServiceTest.cs +++ b/src/ImageKit.Tests/Services/Accounts/UsageServiceTest.cs @@ -4,7 +4,7 @@ namespace ImageKit.Tests.Services.Accounts; public class UsageServiceTest : TestBase { - [Fact(Skip = "Prism tests are disabled")] + [Fact(Skip = "Mock server tests are disabled")] public async Task Get_Works() { var usage = await this.client.Accounts.Usage.Get( diff --git a/src/ImageKit.Tests/Services/AssetServiceTest.cs b/src/ImageKit.Tests/Services/AssetServiceTest.cs index 2ada0a28..74c9f150 100644 --- a/src/ImageKit.Tests/Services/AssetServiceTest.cs +++ b/src/ImageKit.Tests/Services/AssetServiceTest.cs @@ -4,7 +4,7 @@ namespace ImageKit.Tests.Services; public class AssetServiceTest : TestBase { - [Fact(Skip = "Prism tests are disabled")] + [Fact(Skip = "Mock server tests are disabled")] public async Task List_Works() { var assets = await this.client.Assets.List(new(), TestContext.Current.CancellationToken); diff --git a/src/ImageKit.Tests/Services/Beta/V2/FileServiceTest.cs b/src/ImageKit.Tests/Services/Beta/V2/FileServiceTest.cs index 5f9e9c64..886ad97d 100644 --- a/src/ImageKit.Tests/Services/Beta/V2/FileServiceTest.cs +++ b/src/ImageKit.Tests/Services/Beta/V2/FileServiceTest.cs @@ -5,7 +5,7 @@ namespace ImageKit.Tests.Services.Beta.V2; public class FileServiceTest : TestBase { - [Fact(Skip = "Prism tests are disabled")] + [Fact(Skip = "Mock server tests are disabled")] public async Task Upload_Works() { var response = await this.client.Beta.V2.Files.Upload( diff --git a/src/ImageKit.Tests/Services/Cache/InvalidationServiceTest.cs b/src/ImageKit.Tests/Services/Cache/InvalidationServiceTest.cs index de3319ba..42c4e0a6 100644 --- a/src/ImageKit.Tests/Services/Cache/InvalidationServiceTest.cs +++ b/src/ImageKit.Tests/Services/Cache/InvalidationServiceTest.cs @@ -4,7 +4,7 @@ namespace ImageKit.Tests.Services.Cache; public class InvalidationServiceTest : TestBase { - [Fact(Skip = "Prism tests are disabled")] + [Fact(Skip = "Mock server tests are disabled")] public async Task Create_Works() { var invalidation = await this.client.Cache.Invalidation.Create( @@ -14,7 +14,7 @@ public async Task Create_Works() invalidation.Validate(); } - [Fact(Skip = "Prism tests are disabled")] + [Fact(Skip = "Mock server tests are disabled")] public async Task Get_Works() { var invalidation = await this.client.Cache.Invalidation.Get( diff --git a/src/ImageKit.Tests/Services/CustomMetadataFieldServiceTest.cs b/src/ImageKit.Tests/Services/CustomMetadataFieldServiceTest.cs index fea3debc..fa2490a2 100644 --- a/src/ImageKit.Tests/Services/CustomMetadataFieldServiceTest.cs +++ b/src/ImageKit.Tests/Services/CustomMetadataFieldServiceTest.cs @@ -5,7 +5,7 @@ namespace ImageKit.Tests.Services; public class CustomMetadataFieldServiceTest : TestBase { - [Fact(Skip = "Prism tests are disabled")] + [Fact(Skip = "Mock server tests are disabled")] public async Task Create_Works() { var customMetadataField = await this.client.CustomMetadataFields.Create( @@ -30,7 +30,7 @@ public async Task Create_Works() customMetadataField.Validate(); } - [Fact(Skip = "Prism tests are disabled")] + [Fact(Skip = "Mock server tests are disabled")] public async Task Update_Works() { var customMetadataField = await this.client.CustomMetadataFields.Update( @@ -41,7 +41,7 @@ public async Task Update_Works() customMetadataField.Validate(); } - [Fact(Skip = "Prism tests are disabled")] + [Fact(Skip = "Mock server tests are disabled")] public async Task List_Works() { var customMetadataFields = await this.client.CustomMetadataFields.List( @@ -54,7 +54,7 @@ public async Task List_Works() } } - [Fact(Skip = "Prism tests are disabled")] + [Fact(Skip = "Mock server tests are disabled")] public async Task Delete_Works() { var customMetadataField = await this.client.CustomMetadataFields.Delete( diff --git a/src/ImageKit.Tests/Services/FileServiceTest.cs b/src/ImageKit.Tests/Services/FileServiceTest.cs index dcf98c76..189c56a4 100644 --- a/src/ImageKit.Tests/Services/FileServiceTest.cs +++ b/src/ImageKit.Tests/Services/FileServiceTest.cs @@ -9,7 +9,7 @@ namespace ImageKit.Tests.Services; public class FileServiceTest : TestBase { - [Fact(Skip = "Prism tests are disabled")] + [Fact(Skip = "Mock server tests are disabled")] public async Task Update_Works() { var file = await this.client.Files.Update( @@ -75,13 +75,13 @@ public async Task Update_Works() file.Validate(); } - [Fact(Skip = "Prism tests are disabled")] + [Fact(Skip = "Mock server tests are disabled")] public async Task Delete_Works() { await this.client.Files.Delete("fileId", new(), TestContext.Current.CancellationToken); } - [Fact(Skip = "Prism tests are disabled")] + [Fact(Skip = "Mock server tests are disabled")] public async Task Copy_Works() { var response = await this.client.Files.Copy( @@ -95,7 +95,7 @@ public async Task Copy_Works() response.Validate(); } - [Fact(Skip = "Prism tests are disabled")] + [Fact(Skip = "Mock server tests are disabled")] public async Task Get_Works() { var file = await this.client.Files.Get( @@ -106,7 +106,7 @@ public async Task Get_Works() file.Validate(); } - [Fact(Skip = "Prism tests are disabled")] + [Fact(Skip = "Mock server tests are disabled")] public async Task Move_Works() { var response = await this.client.Files.Move( @@ -120,7 +120,7 @@ public async Task Move_Works() response.Validate(); } - [Fact(Skip = "Prism tests are disabled")] + [Fact(Skip = "Mock server tests are disabled")] public async Task Rename_Works() { var response = await this.client.Files.Rename( @@ -130,7 +130,7 @@ public async Task Rename_Works() response.Validate(); } - [Fact(Skip = "Prism tests are disabled")] + [Fact(Skip = "Mock server tests are disabled")] public async Task Upload_Works() { var response = await this.client.Files.Upload( diff --git a/src/ImageKit.Tests/Services/Files/BulkServiceTest.cs b/src/ImageKit.Tests/Services/Files/BulkServiceTest.cs index f8d7c213..b5d3f578 100644 --- a/src/ImageKit.Tests/Services/Files/BulkServiceTest.cs +++ b/src/ImageKit.Tests/Services/Files/BulkServiceTest.cs @@ -4,7 +4,7 @@ namespace ImageKit.Tests.Services.Files; public class BulkServiceTest : TestBase { - [Fact(Skip = "Prism tests are disabled")] + [Fact(Skip = "Mock server tests are disabled")] public async Task Delete_Works() { var bulk = await this.client.Files.Bulk.Delete( @@ -14,7 +14,7 @@ public async Task Delete_Works() bulk.Validate(); } - [Fact(Skip = "Prism tests are disabled")] + [Fact(Skip = "Mock server tests are disabled")] public async Task AddTags_Works() { var response = await this.client.Files.Bulk.AddTags( @@ -28,7 +28,7 @@ public async Task AddTags_Works() response.Validate(); } - [Fact(Skip = "Prism tests are disabled")] + [Fact(Skip = "Mock server tests are disabled")] public async Task RemoveAITags_Works() { var response = await this.client.Files.Bulk.RemoveAITags( @@ -42,7 +42,7 @@ public async Task RemoveAITags_Works() response.Validate(); } - [Fact(Skip = "Prism tests are disabled")] + [Fact(Skip = "Mock server tests are disabled")] public async Task RemoveTags_Works() { var response = await this.client.Files.Bulk.RemoveTags( diff --git a/src/ImageKit.Tests/Services/Files/MetadataServiceTest.cs b/src/ImageKit.Tests/Services/Files/MetadataServiceTest.cs index 834dfce5..f47cb544 100644 --- a/src/ImageKit.Tests/Services/Files/MetadataServiceTest.cs +++ b/src/ImageKit.Tests/Services/Files/MetadataServiceTest.cs @@ -4,7 +4,7 @@ namespace ImageKit.Tests.Services.Files; public class MetadataServiceTest : TestBase { - [Fact(Skip = "Prism tests are disabled")] + [Fact(Skip = "Mock server tests are disabled")] public async Task Get_Works() { var metadata = await this.client.Files.Metadata.Get( @@ -15,7 +15,7 @@ public async Task Get_Works() metadata.Validate(); } - [Fact(Skip = "Prism tests are disabled")] + [Fact(Skip = "Mock server tests are disabled")] public async Task GetFromUrl_Works() { var metadata = await this.client.Files.Metadata.GetFromUrl( diff --git a/src/ImageKit.Tests/Services/Files/VersionServiceTest.cs b/src/ImageKit.Tests/Services/Files/VersionServiceTest.cs index f25b2233..2318c8e8 100644 --- a/src/ImageKit.Tests/Services/Files/VersionServiceTest.cs +++ b/src/ImageKit.Tests/Services/Files/VersionServiceTest.cs @@ -4,7 +4,7 @@ namespace ImageKit.Tests.Services.Files; public class VersionServiceTest : TestBase { - [Fact(Skip = "Prism tests are disabled")] + [Fact(Skip = "Mock server tests are disabled")] public async Task List_Works() { var files = await this.client.Files.Versions.List( @@ -18,7 +18,7 @@ public async Task List_Works() } } - [Fact(Skip = "Prism tests are disabled")] + [Fact(Skip = "Mock server tests are disabled")] public async Task Delete_Works() { var version = await this.client.Files.Versions.Delete( @@ -29,7 +29,7 @@ public async Task Delete_Works() version.Validate(); } - [Fact(Skip = "Prism tests are disabled")] + [Fact(Skip = "Mock server tests are disabled")] public async Task Get_Works() { var file = await this.client.Files.Versions.Get( @@ -40,7 +40,7 @@ public async Task Get_Works() file.Validate(); } - [Fact(Skip = "Prism tests are disabled")] + [Fact(Skip = "Mock server tests are disabled")] public async Task Restore_Works() { var file = await this.client.Files.Versions.Restore( diff --git a/src/ImageKit.Tests/Services/FolderServiceTest.cs b/src/ImageKit.Tests/Services/FolderServiceTest.cs index 028bf06c..3db9f864 100644 --- a/src/ImageKit.Tests/Services/FolderServiceTest.cs +++ b/src/ImageKit.Tests/Services/FolderServiceTest.cs @@ -4,7 +4,7 @@ namespace ImageKit.Tests.Services; public class FolderServiceTest : TestBase { - [Fact(Skip = "Prism tests are disabled")] + [Fact(Skip = "Mock server tests are disabled")] public async Task Create_Works() { var folder = await this.client.Folders.Create( @@ -14,7 +14,7 @@ public async Task Create_Works() folder.Validate(); } - [Fact(Skip = "Prism tests are disabled")] + [Fact(Skip = "Mock server tests are disabled")] public async Task Delete_Works() { var folder = await this.client.Folders.Delete( @@ -24,7 +24,7 @@ public async Task Delete_Works() folder.Validate(); } - [Fact(Skip = "Prism tests are disabled")] + [Fact(Skip = "Mock server tests are disabled")] public async Task Copy_Works() { var response = await this.client.Folders.Copy( @@ -38,7 +38,7 @@ public async Task Copy_Works() response.Validate(); } - [Fact(Skip = "Prism tests are disabled")] + [Fact(Skip = "Mock server tests are disabled")] public async Task Move_Works() { var response = await this.client.Folders.Move( @@ -52,7 +52,7 @@ public async Task Move_Works() response.Validate(); } - [Fact(Skip = "Prism tests are disabled")] + [Fact(Skip = "Mock server tests are disabled")] public async Task Rename_Works() { var response = await this.client.Folders.Rename( diff --git a/src/ImageKit.Tests/Services/Folders/JobServiceTest.cs b/src/ImageKit.Tests/Services/Folders/JobServiceTest.cs index 4e324499..b3d76b7b 100644 --- a/src/ImageKit.Tests/Services/Folders/JobServiceTest.cs +++ b/src/ImageKit.Tests/Services/Folders/JobServiceTest.cs @@ -4,7 +4,7 @@ namespace ImageKit.Tests.Services.Folders; public class JobServiceTest : TestBase { - [Fact(Skip = "Prism tests are disabled")] + [Fact(Skip = "Mock server tests are disabled")] public async Task Get_Works() { var job = await this.client.Folders.Job.Get( diff --git a/src/ImageKit.Tests/Services/SavedExtensionServiceTest.cs b/src/ImageKit.Tests/Services/SavedExtensionServiceTest.cs index cd76b445..b0c5adfc 100644 --- a/src/ImageKit.Tests/Services/SavedExtensionServiceTest.cs +++ b/src/ImageKit.Tests/Services/SavedExtensionServiceTest.cs @@ -5,7 +5,7 @@ namespace ImageKit.Tests.Services; public class SavedExtensionServiceTest : TestBase { - [Fact(Skip = "Prism tests are disabled")] + [Fact(Skip = "Mock server tests are disabled")] public async Task Create_Works() { var savedExtension = await this.client.SavedExtensions.Create( @@ -29,7 +29,7 @@ public async Task Create_Works() savedExtension.Validate(); } - [Fact(Skip = "Prism tests are disabled")] + [Fact(Skip = "Mock server tests are disabled")] public async Task Update_Works() { var savedExtension = await this.client.SavedExtensions.Update( @@ -40,7 +40,7 @@ public async Task Update_Works() savedExtension.Validate(); } - [Fact(Skip = "Prism tests are disabled")] + [Fact(Skip = "Mock server tests are disabled")] public async Task List_Works() { var savedExtensions = await this.client.SavedExtensions.List( @@ -53,7 +53,7 @@ public async Task List_Works() } } - [Fact(Skip = "Prism tests are disabled")] + [Fact(Skip = "Mock server tests are disabled")] public async Task Delete_Works() { await this.client.SavedExtensions.Delete( @@ -63,7 +63,7 @@ await this.client.SavedExtensions.Delete( ); } - [Fact(Skip = "Prism tests are disabled")] + [Fact(Skip = "Mock server tests are disabled")] public async Task Get_Works() { var savedExtension = await this.client.SavedExtensions.Get( From 5864f17fd98fb3d6b8cacfd2e8d69bd8c311f0ff Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 20 Feb 2026 22:38:30 +0000 Subject: [PATCH 072/129] refactor(internal): default headers --- src/ImageKit/Core/ParamsBase.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/ImageKit/Core/ParamsBase.cs b/src/ImageKit/Core/ParamsBase.cs index 9173f70b..3fc38e12 100644 --- a/src/ImageKit/Core/ParamsBase.cs +++ b/src/ImageKit/Core/ParamsBase.cs @@ -220,6 +220,13 @@ internal static void AddDefaultHeaders(HttpRequestMessage request, ClientOptions static string GetUserAgent() => $"{typeof(ImageKitClient).Name}/C# {GetPackageVersion()}"; + static string GetPackageVersion() => + Assembly + .GetExecutingAssembly() + .GetCustomAttribute() + ?.InformationalVersion + ?? "unknown"; + static string GetOSArch() => RuntimeInformation.OSArchitecture switch { @@ -254,13 +261,6 @@ static string GetOS() return $"Other:{RuntimeInformation.OSDescription}"; } - static string GetPackageVersion() => - Assembly - .GetExecutingAssembly() - .GetCustomAttribute() - ?.InformationalVersion - ?? "unknown"; - static Runtime GetRuntime() { var runtimeDescription = RuntimeInformation.FrameworkDescription; From c6c1b1e5676edb381459d6a28fd0d395515b17d8 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 23 Feb 2026 15:25:26 +0000 Subject: [PATCH 073/129] chore(docs): add proxy documentation to readme --- README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/README.md b/README.md index b0446cda..cc783e7c 100644 --- a/README.md +++ b/README.md @@ -219,6 +219,26 @@ var response = await client Console.WriteLine(response); ``` +### Proxies + +To route requests through a proxy, configure your client with a custom [`HttpClient`](https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpclient?view=net-10.0): + +```csharp +using System.Net; +using System.Net.Http; +using ImageKit; + +var httpClient = new HttpClient +( + new HttpClientHandler + { + Proxy = new WebProxy("https://example.com:8080") + } +); + +ImageKitClient client = new() { HttpClient = httpClient }; +``` + ## Undocumented API functionality The SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API. From 808b9c7ce1f6c50a2f221bbe645900a1d422540b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 24 Feb 2026 17:58:00 +0000 Subject: [PATCH 074/129] chore(docs): add undocumented parameters to readme --- README.md | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) diff --git a/README.md b/README.md index cc783e7c..7ac17ff6 100644 --- a/README.md +++ b/README.md @@ -243,6 +243,120 @@ ImageKitClient client = new() { HttpClient = httpClient }; The SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API. +### Parameters + +To set undocumented parameters, a constructor exists that accepts dictionaries for additional header, query, and body values. If the method type doesn't support request bodies (e.g. `GET` requests), the constructor will only accept a header and query dictionary. + +```csharp +using System.Collections.Generic; +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Models.Files; + +FileUploadParams parameters = new +( + rawHeaderData: new Dictionary() + { + { "Custom-Header", JsonSerializer.SerializeToElement(42) } + }, + + rawQueryData: new Dictionary() + { + { "custom_query_param", JsonSerializer.SerializeToElement(42) } + }, + + rawBodyData: new Dictionary() + { + { "custom_body_param", JsonSerializer.SerializeToElement(42) } + } +) +{ + // Documented properties can still be added here. + // In case of conflict, these parameters take precedence over the custom parameters. + Expire = 0 +}; +``` + +The raw parameters can also be accessed through the `RawHeaderData`, `RawQueryData`, and `RawBodyData` (if available) properties. + +This can also be used to set a documented parameter to an undocumented or not yet supported _value_, as long as the parameter is optional. If the parameter is required, omitting its `init` property will result in a compile-time error. To work around this, the `FromRawUnchecked` method can be used: + +```csharp +using System.Collections.Generic; +using System.Text.Json; +using ImageKit.Models.Files; + +var parameters = FileUploadParams.FromRawUnchecked +( + + rawHeaderData: new Dictionary(), + rawQueryData: new Dictionary(), + rawBodyData: new Dictionary + { + { + "file", + JsonSerializer.SerializeToElement("custom value") + } + } +); +``` + +### Nested Parameters + +Undocumented properties, or undocumented values of documented properties, on nested parameters can be set similarly, using a dictionary in the constructor of the nested parameter. + +```csharp +using System.Collections.Generic; +using System.Text.Json; +using ImageKit.Models.Files; + +FileUploadParams parameters = new() +{ + Transformation = new + ( + new Dictionary + { + { "custom_nested_param", JsonSerializer.SerializeToElement(42) } + } + ) +}; +``` + +Required properties on the nested parameter can also be changed or omitted using the `FromRawUnchecked` method: + +```csharp +using System.Collections.Generic; +using System.Text.Json; +using ImageKit.Models.Files; + +FileUploadParams parameters = new() +{ + Transformation = Transformation.FromRawUnchecked + ( + new Dictionary + { + { "required_property", JsonSerializer.SerializeToElement("custom value") } + } + ) +}; +``` + +### Response properties + +To access undocumented response properties, the `RawData` property can be used: + +```csharp +using System.Text.Json; + +var response = client.Files.Upload(parameters) +if (response.RawData.TryGetValue("my_custom_key", out JsonElement value)) +{ + // Do something with `value` +} +``` + +`RawData` is a `IReadonlyDictionary`. It holds the full data received from the API server. + ### Response validation In rare cases, the API may return a response that doesn't match the expected type. For example, the SDK may expect a property to contain a `string`, but the API could return something else. From 9dee001f1baf7776413872bb2c118adcb7027cea Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 26 Feb 2026 11:23:58 +0000 Subject: [PATCH 075/129] feat(api): dpr type update --- .stats.yml | 4 +- .../Models/TransformationTest.cs | 41 ++- .../Models/Beta/V2/Files/FileUploadParams.cs | 8 +- src/ImageKit/Models/Files/FileUploadParams.cs | 8 +- src/ImageKit/Models/Transformation.cs | 243 +++++++++++++++++- src/ImageKit/Services/Beta/V2/IFileService.cs | 8 +- src/ImageKit/Services/IFileService.cs | 8 +- 7 files changed, 301 insertions(+), 19 deletions(-) diff --git a/.stats.yml b/.stats.yml index dbc39e12..7401c19f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-13fc3d7cafdea492f62eef7c1d63424d6d9d8adbff74b9f6ca6fd3fc12a36840.yml -openapi_spec_hash: a1fe6fa48207791657a1ea2d60a6dfcc +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-e5b5a158784fff63311ceef956e8d5ce9e87c6b557d23ab737270040eb39adcd.yml +openapi_spec_hash: b0293985a8806f367319af573d1b418c config_hash: 47cb702ee2cb52c58d803ae39ade9b44 diff --git a/src/ImageKit.Tests/Models/TransformationTest.cs b/src/ImageKit.Tests/Models/TransformationTest.cs index cd08f493..2abdac6c 100644 --- a/src/ImageKit.Tests/Models/TransformationTest.cs +++ b/src/ImageKit.Tests/Models/TransformationTest.cs @@ -126,7 +126,7 @@ public void FieldRoundtrip_Works() ApiEnum expectedCropMode = CropMode.PadResize; string expectedDefaultImage = "defaultImage"; string expectedDistort = "distort"; - double expectedDpr = 2; + Dpr expectedDpr = 2; TransformationDuration expectedDuration = 0; EndOffset expectedEndOffset = 0; ApiEnum expectedFlip = TransformationFlip.H; @@ -492,7 +492,7 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum expectedCropMode = CropMode.PadResize; string expectedDefaultImage = "defaultImage"; string expectedDistort = "distort"; - double expectedDpr = 2; + Dpr expectedDpr = 2; TransformationDuration expectedDuration = 0; EndOffset expectedEndOffset = 0; ApiEnum expectedFlip = TransformationFlip.H; @@ -1875,6 +1875,43 @@ public void InvalidEnumSerializationRoundtrip_Works() } } +public class DprTest : TestBase +{ + [Fact] + public void DoubleValidationWorks() + { + Dpr value = 0; + value.Validate(); + } + + [Fact] + public void StringValidationWorks() + { + Dpr value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + Dpr value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + Dpr value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + public class TransformationDurationTest : TestBase { [Fact] diff --git a/src/ImageKit/Models/Beta/V2/Files/FileUploadParams.cs b/src/ImageKit/Models/Beta/V2/Files/FileUploadParams.cs index 2ff6ae76..4f172112 100644 --- a/src/ImageKit/Models/Beta/V2/Files/FileUploadParams.cs +++ b/src/ImageKit/Models/Beta/V2/Files/FileUploadParams.cs @@ -22,9 +22,11 @@ namespace ImageKit.Models.Beta.V2.Files; /// about how to implement secure client-side file upload. /// /// **File size limit** \ On the free plan, the maximum upload file sizes are -/// 20MB for images, audio, and raw files, and 100MB for videos. On the paid plan, -/// these limits increase to 40MB for images, audio, and raw files, and 2GB for videos. -/// These limits can be further increased with higher-tier plans. +/// 25MB for images, audio, and raw files, and 100MB for videos. On the Lite paid +/// plan, these limits increase to 40MB for images, audio, and raw files and 300MB +/// for videos, whereas on the Pro paid plan, these limits increase to 50MB for images, +/// audio, and raw files and 2GB for videos. These limits can be further increased +/// with enterprise plans. /// /// **Version limit** \ A file can have a maximum of 100 versions. /// diff --git a/src/ImageKit/Models/Files/FileUploadParams.cs b/src/ImageKit/Models/Files/FileUploadParams.cs index 9671d243..1ef2972a 100644 --- a/src/ImageKit/Models/Files/FileUploadParams.cs +++ b/src/ImageKit/Models/Files/FileUploadParams.cs @@ -22,9 +22,11 @@ namespace ImageKit.Models.Files; /// by verifying the entire payload using JWT. /// /// **File size limit** \ On the free plan, the maximum upload file sizes are -/// 20MB for images, audio, and raw files and 100MB for videos. On the paid plan, -/// these limits increase to 40MB for images, audio, and raw files and 2GB for videos. -/// These limits can be further increased with higher-tier plans. +/// 25MB for images, audio, and raw files and 100MB for videos. On the Lite paid plan, +/// these limits increase to 40MB for images, audio, and raw files and 300MB for +/// videos, whereas on the Pro paid plan, these limits increase to 50MB for images, +/// audio, and raw files and 2GB for videos. These limits can be further increased +/// with enterprise plans. /// /// **Version limit** \ A file can have a maximum of 100 versions. /// diff --git a/src/ImageKit/Models/Transformation.cs b/src/ImageKit/Models/Transformation.cs index 6ec3bf5e..1565b2a4 100644 --- a/src/ImageKit/Models/Transformation.cs +++ b/src/ImageKit/Models/Transformation.cs @@ -498,12 +498,12 @@ public string? Distort /// expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). /// - See [DPR](https://imagekit.io/docs/image-resize-and-crop#dpr---dpr). /// - public double? Dpr + public Dpr? Dpr { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("dpr"); + return this._rawData.GetNullableClass("dpr"); } init { @@ -1300,7 +1300,7 @@ public override void Validate() this.CropMode?.Validate(); _ = this.DefaultImage; _ = this.Distort; - _ = this.Dpr; + this.Dpr?.Validate(); this.Duration?.Validate(); this.EndOffset?.Validate(); this.Flip?.Validate(); @@ -2369,6 +2369,243 @@ public override void Write(Utf8JsonWriter writer, CropMode value, JsonSerializer } } +/// +/// Accepts values between 0.1 and 5, or `auto` for automatic device pixel ratio (DPR) +/// calculation. Also accepts arithmetic expressions. - Learn about [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). +/// - See [DPR](https://imagekit.io/docs/image-resize-and-crop#dpr---dpr). +/// +[JsonConverter(typeof(DprConverter))] +public record class Dpr : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public Dpr(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Dpr(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Dpr(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public void Switch(Action @double, Action @string) + { + switch (this.Value) + { + case double value: + @double(value); + break; + case string value: + @string(value); + break; + default: + throw new ImageKitInvalidDataException("Data did not match any variant of Dpr"); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public T Match(Func @double, Func @string) + { + return this.Value switch + { + double value => @double(value), + string value => @string(value), + _ => throw new ImageKitInvalidDataException("Data did not match any variant of Dpr"), + }; + } + + public static implicit operator Dpr(double value) => new(value); + + public static implicit operator Dpr(string value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException("Data did not match any variant of Dpr"); + } + } + + public virtual bool Equals(Dpr? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + double _ => 0, + string _ => 1, + _ => -1, + }; + } +} + +sealed class DprConverter : JsonConverter +{ + public override Dpr? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write(Utf8JsonWriter writer, Dpr value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + /// /// Specifies the duration (in seconds) for trimming videos, e.g., `5` or `10.5`. /// Typically used with startOffset to indicate the length from the start offset. diff --git a/src/ImageKit/Services/Beta/V2/IFileService.cs b/src/ImageKit/Services/Beta/V2/IFileService.cs index 91af38d4..91c9834e 100644 --- a/src/ImageKit/Services/Beta/V2/IFileService.cs +++ b/src/ImageKit/Services/Beta/V2/IFileService.cs @@ -37,9 +37,11 @@ public interface IFileService /// about how to implement secure client-side file upload. /// /// **File size limit** \ On the free plan, the maximum upload file sizes - /// are 20MB for images, audio, and raw files, and 100MB for videos. On the paid - /// plan, these limits increase to 40MB for images, audio, and raw files, and - /// 2GB for videos. These limits can be further increased with higher-tier plans. + /// are 25MB for images, audio, and raw files, and 100MB for videos. On the Lite + /// paid plan, these limits increase to 40MB for images, audio, and raw files + /// and 300MB for videos, whereas on the Pro paid plan, these limits increase + /// to 50MB for images, audio, and raw files and 2GB for videos. These limits + /// can be further increased with enterprise plans. /// /// **Version limit** \ A file can have a maximum of 100 versions. /// diff --git a/src/ImageKit/Services/IFileService.cs b/src/ImageKit/Services/IFileService.cs index e347c72b..8f83b0e3 100644 --- a/src/ImageKit/Services/IFileService.cs +++ b/src/ImageKit/Services/IFileService.cs @@ -125,9 +125,11 @@ Task Rename( /// security by verifying the entire payload using JWT. /// /// **File size limit** \ On the free plan, the maximum upload file sizes - /// are 20MB for images, audio, and raw files and 100MB for videos. On the paid - /// plan, these limits increase to 40MB for images, audio, and raw files and 2GB - /// for videos. These limits can be further increased with higher-tier plans. + /// are 25MB for images, audio, and raw files and 100MB for videos. On the Lite + /// paid plan, these limits increase to 40MB for images, audio, and raw files + /// and 300MB for videos, whereas on the Pro paid plan, these limits increase + /// to 50MB for images, audio, and raw files and 2GB for videos. These limits + /// can be further increased with enterprise plans. /// /// **Version limit** \ A file can have a maximum of 100 versions. /// From 5b1b23ef47d15ad1d73633a1feb8b532b5befd5a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 2 Mar 2026 06:41:19 +0000 Subject: [PATCH 076/129] chore(tests): add tests for retry logic --- src/ImageKit.Tests/ImageKit.Tests.csproj | 1 + src/ImageKit.Tests/RetriesTest.cs | 359 +++++++++++++++++++++++ src/ImageKit/ImageKitClient.cs | 6 +- 3 files changed, 365 insertions(+), 1 deletion(-) create mode 100644 src/ImageKit.Tests/RetriesTest.cs diff --git a/src/ImageKit.Tests/ImageKit.Tests.csproj b/src/ImageKit.Tests/ImageKit.Tests.csproj index f631a267..57d54f6e 100644 --- a/src/ImageKit.Tests/ImageKit.Tests.csproj +++ b/src/ImageKit.Tests/ImageKit.Tests.csproj @@ -14,6 +14,7 @@ + diff --git a/src/ImageKit.Tests/RetriesTest.cs b/src/ImageKit.Tests/RetriesTest.cs new file mode 100644 index 00000000..f273257e --- /dev/null +++ b/src/ImageKit.Tests/RetriesTest.cs @@ -0,0 +1,359 @@ +using System; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; +using ImageKit; +using ImageKit.Core; +using Moq; +using Moq.Protected; + +namespace ImageKit.Tests; + +public class RetriesTest : TestBase +{ + record class BlankParams : ParamsBase + { + internal override void AddHeadersToRequest( + HttpRequestMessage _request, + ClientOptions _options + ) + { + // do nothing + } + + public override Uri Url(ClientOptions _options) + { + return new Uri("http://localhost/something"); + } + } + + record class ParamsWithOverwrittenRetryHeader : ParamsBase + { + internal override void AddHeadersToRequest( + HttpRequestMessage request, + ClientOptions _options + ) + { + request.Headers.TryAddWithoutValidation("x-stainless-retry-count", "42"); + } + + public override Uri Url(ClientOptions _options) + { + return new Uri("http://localhost/something"); + } + } + + [Fact] + public async Task ImmediateSuccess_Works() + { + var handlerMock = new Mock(); + handlerMock + .Protected() + .Setup>( + "SendAsync", + ItExpr.IsAny(), + ItExpr.IsAny() + ) + .ReturnsAsync( + new HttpResponseMessage() + { + StatusCode = HttpStatusCode.OK, + Content = new StringContent("foo"), + } + ); + + var httpClient = new HttpClient(handlerMock.Object); + + ImageKitClient client = new() { HttpClient = httpClient, MaxRetries = 2 }; + + var resp = await client.WithRawResponse.Execute( + new HttpRequest { Method = HttpMethod.Get, Params = new() }, + TestContext.Current.CancellationToken + ); + + Assert.Equal(HttpStatusCode.OK, resp.StatusCode); + + handlerMock + .Protected() + .Verify( + "SendAsync", + Times.Exactly(1), + ItExpr.Is( + (req) => + req.Method == HttpMethod.Get + && req.RequestUri == new Uri("http://localhost/something") + ), + ItExpr.IsAny() + ); + } + + [Fact] + public async Task RetryAfterHeader_Works() + { + var ResponseWithRetryDate = new HttpResponseMessage() + { + StatusCode = HttpStatusCode.ServiceUnavailable, + Content = new StringContent("foo"), + }; + ResponseWithRetryDate.Headers.Add("Retry-After", "Wed, 21 Oct 2015 07:28:00 GMT"); + + var ResponseWithRetryDelay = new HttpResponseMessage() + { + StatusCode = HttpStatusCode.ServiceUnavailable, + Content = new StringContent("foo"), + }; + // decimals are technically out of spec, but we want to ensure we can parse them regardless + ResponseWithRetryDelay.Headers.TryAddWithoutValidation("Retry-After", "1.234"); + + var handlerMock = new Mock(); + handlerMock + .Protected() + .SetupSequence>( + "SendAsync", + ItExpr.IsAny(), + ItExpr.IsAny() + ) + .ReturnsAsync(ResponseWithRetryDate) + .ReturnsAsync(ResponseWithRetryDelay) + .ReturnsAsync( + new HttpResponseMessage() + { + StatusCode = HttpStatusCode.OK, + Content = new StringContent("foo"), + } + ); + + var httpClient = new HttpClient(handlerMock.Object); + + ImageKitClient client = new() { HttpClient = httpClient, MaxRetries = 2 }; + + var resp = await client.WithRawResponse.Execute( + new HttpRequest { Method = HttpMethod.Get, Params = new() }, + TestContext.Current.CancellationToken + ); + + Assert.Equal(HttpStatusCode.OK, resp.StatusCode); + handlerMock + .Protected() + .Verify( + "SendAsync", + Times.Exactly(1), + ItExpr.Is( + (req) => + req.Method == HttpMethod.Get + && req.RequestUri == new Uri("http://localhost/something") + && Enumerable.Single(req.Headers.GetValues("x-stainless-retry-count")) + == "0" + ), + ItExpr.IsAny() + ); + handlerMock + .Protected() + .Verify( + "SendAsync", + Times.Exactly(1), + ItExpr.Is( + (req) => + req.Method == HttpMethod.Get + && req.RequestUri == new Uri("http://localhost/something") + && Enumerable.Single(req.Headers.GetValues("x-stainless-retry-count")) + == "1" + ), + ItExpr.IsAny() + ); + handlerMock + .Protected() + .Verify( + "SendAsync", + Times.Exactly(1), + ItExpr.Is( + (req) => + req.Method == HttpMethod.Get + && req.RequestUri == new Uri("http://localhost/something") + && Enumerable.Single(req.Headers.GetValues("x-stainless-retry-count")) + == "2" + ), + ItExpr.IsAny() + ); + } + + [Fact] + public async Task OverwrittenRetryCountHeader_Works() + { + var handlerMock = new Mock(); + handlerMock + .Protected() + .SetupSequence>( + "SendAsync", + ItExpr.IsAny(), + ItExpr.IsAny() + ) + .ReturnsAsync( + new HttpResponseMessage() + { + StatusCode = HttpStatusCode.ServiceUnavailable, + Content = new StringContent("foo"), + } + ) + .ReturnsAsync( + new HttpResponseMessage() + { + StatusCode = HttpStatusCode.OK, + Content = new StringContent("foo"), + } + ); + + var httpClient = new HttpClient(handlerMock.Object); + + ImageKitClient client = new() { HttpClient = httpClient, MaxRetries = 2 }; + + var resp = await client.WithRawResponse.Execute( + new HttpRequest + { + Method = HttpMethod.Get, + Params = new(), + }, + TestContext.Current.CancellationToken + ); + + Assert.Equal(HttpStatusCode.OK, resp.StatusCode); + + handlerMock + .Protected() + .Verify( + "SendAsync", + Times.Exactly(2), + ItExpr.Is( + (req) => + req.Method == HttpMethod.Get + && req.RequestUri == new Uri("http://localhost/something") + && Enumerable.Single(req.Headers.GetValues("x-stainless-retry-count")) + == "42" + ), + ItExpr.IsAny() + ); + } + + [Fact] + public async Task RetryAfterMsHeader_Works() + { + var failResponse = new HttpResponseMessage() + { + StatusCode = HttpStatusCode.ServiceUnavailable, + Content = new StringContent("foo"), + }; + failResponse.Headers.TryAddWithoutValidation("Retry-After-Ms", "10"); + + var handlerMock = new Mock(); + handlerMock + .Protected() + .SetupSequence>( + "SendAsync", + ItExpr.IsAny(), + ItExpr.IsAny() + ) + .ReturnsAsync(failResponse) + .ReturnsAsync( + new HttpResponseMessage() + { + StatusCode = HttpStatusCode.OK, + Content = new StringContent("foo"), + } + ); + + var httpClient = new HttpClient(handlerMock.Object); + + ImageKitClient client = new() { HttpClient = httpClient, MaxRetries = 1 }; + + var resp = await client.WithRawResponse.Execute( + new HttpRequest { Method = HttpMethod.Get, Params = new() }, + TestContext.Current.CancellationToken + ); + + Assert.Equal(HttpStatusCode.OK, resp.StatusCode); + handlerMock + .Protected() + .Verify( + "SendAsync", + Times.Exactly(2), + ItExpr.Is( + (req) => + req.Method == HttpMethod.Get + && req.RequestUri == new Uri("http://localhost/something") + ), + ItExpr.IsAny() + ); + } + + [Fact] + public async Task RetryableException_Works() + { + var callCount = 0; + + var handlerMock = new Mock(); + handlerMock + .Protected() + .Setup>( + "SendAsync", + ItExpr.IsAny(), + ItExpr.IsAny() + ) + .Returns( + (_, ct) => + { + callCount++; + if (callCount == 1) + throw new HttpRequestException("Simulated retryable failure"); + + return Task.FromResult( + new HttpResponseMessage() + { + StatusCode = HttpStatusCode.OK, + Content = new StringContent("foo"), + } + ); + } + ); + + var httpClient = new HttpClient(handlerMock.Object); + + ImageKitClient client = new() { HttpClient = httpClient, MaxRetries = 2 }; + + var resp = await client.WithRawResponse.Execute( + new HttpRequest { Method = HttpMethod.Get, Params = new() }, + TestContext.Current.CancellationToken + ); + + Assert.Equal(HttpStatusCode.OK, resp.StatusCode); + handlerMock + .Protected() + .Verify( + "SendAsync", + Times.Exactly(1), + ItExpr.Is( + (req) => + req.Method == HttpMethod.Get + && req.RequestUri == new Uri("http://localhost/something") + && Enumerable.Single(req.Headers.GetValues("x-stainless-retry-count")) + == "0" + ), + ItExpr.IsAny() + ); + handlerMock + .Protected() + .Verify( + "SendAsync", + Times.Exactly(1), + ItExpr.Is( + (req) => + req.Method == HttpMethod.Get + && req.RequestUri == new Uri("http://localhost/something") + && Enumerable.Single(req.Headers.GetValues("x-stainless-retry-count")) + == "1" + ), + ItExpr.IsAny() + ); + } +} diff --git a/src/ImageKit/ImageKitClient.cs b/src/ImageKit/ImageKitClient.cs index 58b2634c..8a997026 100644 --- a/src/ImageKit/ImageKitClient.cs +++ b/src/ImageKit/ImageKitClient.cs @@ -401,7 +401,11 @@ async Task ExecuteOnce( static TimeSpan ComputeRetryBackoff(int retries, HttpResponse? response) { TimeSpan? apiBackoff = ParseRetryAfterMsHeader(response) ?? ParseRetryAfterHeader(response); - if (apiBackoff != null && apiBackoff < TimeSpan.FromMinutes(1)) + if ( + apiBackoff != null + && apiBackoff > TimeSpan.Zero + && apiBackoff < TimeSpan.FromMinutes(1) + ) { // If the API asks us to wait a certain amount of time (and it's a reasonable amount), then just // do what it says. From 53a5f5102ba217fb7fea972832d2554054d8281a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 3 Mar 2026 02:39:25 +0000 Subject: [PATCH 077/129] docs: remove typo in README.md --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 7ac17ff6..124d940d 100644 --- a/README.md +++ b/README.md @@ -146,8 +146,6 @@ The SDK throws custom unchecked exception types: Additionally, all 4xx errors inherit from `ImageKit4xxException`. -false - - `ImageKitIOException`: I/O networking errors. - `ImageKitInvalidDataException`: Failure to interpret successfully parsed data. For example, when accessing a property that's supposed to be required, but the API unexpectedly omitted it from the response. From be0481db26eba8a068d312791d11f4a2cb10d15e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 5 Mar 2026 03:17:50 +0000 Subject: [PATCH 078/129] feat(api): revert dpr breaking change --- .stats.yml | 4 +- .../Models/TransformationTest.cs | 41 +-- src/ImageKit/Models/Transformation.cs | 243 +----------------- 3 files changed, 7 insertions(+), 281 deletions(-) diff --git a/.stats.yml b/.stats.yml index 7401c19f..749d6988 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-e5b5a158784fff63311ceef956e8d5ce9e87c6b557d23ab737270040eb39adcd.yml -openapi_spec_hash: b0293985a8806f367319af573d1b418c +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-83a7f3659a437113f2a79e1e72794be19eff00ec232fd0206198c80364ccfebf.yml +openapi_spec_hash: b327552548ab641eb4ea3b45e643dfce config_hash: 47cb702ee2cb52c58d803ae39ade9b44 diff --git a/src/ImageKit.Tests/Models/TransformationTest.cs b/src/ImageKit.Tests/Models/TransformationTest.cs index 2abdac6c..cd08f493 100644 --- a/src/ImageKit.Tests/Models/TransformationTest.cs +++ b/src/ImageKit.Tests/Models/TransformationTest.cs @@ -126,7 +126,7 @@ public void FieldRoundtrip_Works() ApiEnum expectedCropMode = CropMode.PadResize; string expectedDefaultImage = "defaultImage"; string expectedDistort = "distort"; - Dpr expectedDpr = 2; + double expectedDpr = 2; TransformationDuration expectedDuration = 0; EndOffset expectedEndOffset = 0; ApiEnum expectedFlip = TransformationFlip.H; @@ -492,7 +492,7 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum expectedCropMode = CropMode.PadResize; string expectedDefaultImage = "defaultImage"; string expectedDistort = "distort"; - Dpr expectedDpr = 2; + double expectedDpr = 2; TransformationDuration expectedDuration = 0; EndOffset expectedEndOffset = 0; ApiEnum expectedFlip = TransformationFlip.H; @@ -1875,43 +1875,6 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class DprTest : TestBase -{ - [Fact] - public void DoubleValidationWorks() - { - Dpr value = 0; - value.Validate(); - } - - [Fact] - public void StringValidationWorks() - { - Dpr value = "string"; - value.Validate(); - } - - [Fact] - public void DoubleSerializationRoundtripWorks() - { - Dpr value = 0; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void StringSerializationRoundtripWorks() - { - Dpr value = "string"; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } -} - public class TransformationDurationTest : TestBase { [Fact] diff --git a/src/ImageKit/Models/Transformation.cs b/src/ImageKit/Models/Transformation.cs index 1565b2a4..6ec3bf5e 100644 --- a/src/ImageKit/Models/Transformation.cs +++ b/src/ImageKit/Models/Transformation.cs @@ -498,12 +498,12 @@ public string? Distort /// expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). /// - See [DPR](https://imagekit.io/docs/image-resize-and-crop#dpr---dpr). /// - public Dpr? Dpr + public double? Dpr { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("dpr"); + return this._rawData.GetNullableStruct("dpr"); } init { @@ -1300,7 +1300,7 @@ public override void Validate() this.CropMode?.Validate(); _ = this.DefaultImage; _ = this.Distort; - this.Dpr?.Validate(); + _ = this.Dpr; this.Duration?.Validate(); this.EndOffset?.Validate(); this.Flip?.Validate(); @@ -2369,243 +2369,6 @@ public override void Write(Utf8JsonWriter writer, CropMode value, JsonSerializer } } -/// -/// Accepts values between 0.1 and 5, or `auto` for automatic device pixel ratio (DPR) -/// calculation. Also accepts arithmetic expressions. - Learn about [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). -/// - See [DPR](https://imagekit.io/docs/image-resize-and-crop#dpr---dpr). -/// -[JsonConverter(typeof(DprConverter))] -public record class Dpr : ModelBase -{ - public object? Value { get; } = null; - - JsonElement? _element = null; - - public JsonElement Json - { - get - { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions - ); - } - } - - public Dpr(double value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public Dpr(string value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public Dpr(JsonElement element) - { - this._element = element; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickDouble(out var value)) { - /// // `value` is of type `double` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickString(out var value)) { - /// // `value` is of type `string` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you need your function parameters to return something. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// instance.Switch( - /// (double value) => {...}, - /// (string value) => {...} - /// ); - /// - /// - /// - public void Switch(Action @double, Action @string) - { - switch (this.Value) - { - case double value: - @double(value); - break; - case string value: - @string(value); - break; - default: - throw new ImageKitInvalidDataException("Data did not match any variant of Dpr"); - } - } - - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with and - /// returns its result. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you don't need your function parameters to return a value. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// var result = instance.Match( - /// (double value) => {...}, - /// (string value) => {...} - /// ); - /// - /// - /// - public T Match(Func @double, Func @string) - { - return this.Value switch - { - double value => @double(value), - string value => @string(value), - _ => throw new ImageKitInvalidDataException("Data did not match any variant of Dpr"), - }; - } - - public static implicit operator Dpr(double value) => new(value); - - public static implicit operator Dpr(string value) => new(value); - - /// - /// Validates that the instance was constructed with a known variant and that this variant is valid - /// (based on its own Validate method). - /// - /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). - /// - /// - /// Thrown when the instance does not pass validation. - /// - /// - public override void Validate() - { - if (this.Value == null) - { - throw new ImageKitInvalidDataException("Data did not match any variant of Dpr"); - } - } - - public virtual bool Equals(Dpr? other) => - other != null - && this.VariantIndex() == other.VariantIndex() - && JsonElement.DeepEquals(this.Json, other.Json); - - public override int GetHashCode() - { - return 0; - } - - public override string ToString() => - JsonSerializer.Serialize( - FriendlyJsonPrinter.PrintValue(this.Json), - ModelBase.ToStringSerializerOptions - ); - - int VariantIndex() - { - return this.Value switch - { - double _ => 0, - string _ => 1, - _ => -1, - }; - } -} - -sealed class DprConverter : JsonConverter -{ - public override Dpr? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - var element = JsonSerializer.Deserialize(ref reader, options); - try - { - return new(JsonSerializer.Deserialize(element, options), element); - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - // ignore - } - - try - { - var deserialized = JsonSerializer.Deserialize(element, options); - if (deserialized != null) - { - return new(deserialized, element); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - // ignore - } - - return new(element); - } - - public override void Write(Utf8JsonWriter writer, Dpr value, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, value.Json, options); - } -} - /// /// Specifies the duration (in seconds) for trimming videos, e.g., `5` or `10.5`. /// Typically used with startOffset to indicate the length from the start offset. From 9151f2f26e15ca5309bb49c85b030119f3043df9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 7 Mar 2026 13:18:03 +0000 Subject: [PATCH 079/129] chore: update placeholder string --- .../Models/Beta/V2/Files/FileUploadParamsTest.cs | 10 +++++----- .../Models/Files/FileUploadParamsTest.cs | 10 +++++----- src/ImageKit.Tests/Services/Beta/V2/FileServiceTest.cs | 2 +- src/ImageKit.Tests/Services/FileServiceTest.cs | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/ImageKit.Tests/Models/Beta/V2/Files/FileUploadParamsTest.cs b/src/ImageKit.Tests/Models/Beta/V2/Files/FileUploadParamsTest.cs index 2714604f..df9cfb30 100644 --- a/src/ImageKit.Tests/Models/Beta/V2/Files/FileUploadParamsTest.cs +++ b/src/ImageKit.Tests/Models/Beta/V2/Files/FileUploadParamsTest.cs @@ -14,7 +14,7 @@ public class FileUploadParamsTest : TestBase [Fact] public void FieldRoundtrip_Works() { - BinaryContent file = Encoding.UTF8.GetBytes("text"); + BinaryContent file = Encoding.UTF8.GetBytes("Example data"); var parameters = new FileUploadParams { @@ -256,7 +256,7 @@ public void FieldRoundtrip_Works() [Fact] public void OptionalNonNullableParamsUnsetAreNotSet_Works() { - BinaryContent file = Encoding.UTF8.GetBytes("text"); + BinaryContent file = Encoding.UTF8.GetBytes("Example data"); var parameters = new FileUploadParams { File = file, FileName = "fileName" }; @@ -301,7 +301,7 @@ public void OptionalNonNullableParamsUnsetAreNotSet_Works() [Fact] public void OptionalNonNullableParamsSetToNullAreNotSet_Works() { - BinaryContent file = Encoding.UTF8.GetBytes("text"); + BinaryContent file = Encoding.UTF8.GetBytes("Example data"); var parameters = new FileUploadParams { @@ -372,7 +372,7 @@ public void Url_Works() { FileUploadParams parameters = new() { - File = Encoding.UTF8.GetBytes("text"), + File = Encoding.UTF8.GetBytes("Example data"), FileName = "fileName", }; @@ -386,7 +386,7 @@ public void CopyConstructor_Works() { var parameters = new FileUploadParams { - File = Encoding.UTF8.GetBytes("text"), + File = Encoding.UTF8.GetBytes("Example data"), FileName = "fileName", Token = "token", Checks = "\"request.folder\" : \"marketing/\"\n", diff --git a/src/ImageKit.Tests/Models/Files/FileUploadParamsTest.cs b/src/ImageKit.Tests/Models/Files/FileUploadParamsTest.cs index f18570b3..d0f77eb2 100644 --- a/src/ImageKit.Tests/Models/Files/FileUploadParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/FileUploadParamsTest.cs @@ -14,7 +14,7 @@ public class FileUploadParamsTest : TestBase [Fact] public void FieldRoundtrip_Works() { - BinaryContent file = Encoding.UTF8.GetBytes("text"); + BinaryContent file = Encoding.UTF8.GetBytes("Example data"); var parameters = new FileUploadParams { @@ -265,7 +265,7 @@ public void FieldRoundtrip_Works() [Fact] public void OptionalNonNullableParamsUnsetAreNotSet_Works() { - BinaryContent file = Encoding.UTF8.GetBytes("text"); + BinaryContent file = Encoding.UTF8.GetBytes("Example data"); var parameters = new FileUploadParams { File = file, FileName = "fileName" }; @@ -316,7 +316,7 @@ public void OptionalNonNullableParamsUnsetAreNotSet_Works() [Fact] public void OptionalNonNullableParamsSetToNullAreNotSet_Works() { - BinaryContent file = Encoding.UTF8.GetBytes("text"); + BinaryContent file = Encoding.UTF8.GetBytes("Example data"); var parameters = new FileUploadParams { @@ -396,7 +396,7 @@ public void Url_Works() { FileUploadParams parameters = new() { - File = Encoding.UTF8.GetBytes("text"), + File = Encoding.UTF8.GetBytes("Example data"), FileName = "fileName", }; @@ -410,7 +410,7 @@ public void CopyConstructor_Works() { var parameters = new FileUploadParams { - File = Encoding.UTF8.GetBytes("text"), + File = Encoding.UTF8.GetBytes("Example data"), FileName = "fileName", Token = "token", Checks = "\"request.folder\" : \"marketing/\"\n", diff --git a/src/ImageKit.Tests/Services/Beta/V2/FileServiceTest.cs b/src/ImageKit.Tests/Services/Beta/V2/FileServiceTest.cs index 886ad97d..df377064 100644 --- a/src/ImageKit.Tests/Services/Beta/V2/FileServiceTest.cs +++ b/src/ImageKit.Tests/Services/Beta/V2/FileServiceTest.cs @@ -9,7 +9,7 @@ public class FileServiceTest : TestBase public async Task Upload_Works() { var response = await this.client.Beta.V2.Files.Upload( - new() { File = Encoding.UTF8.GetBytes("text"), FileName = "fileName" }, + new() { File = Encoding.UTF8.GetBytes("Example data"), FileName = "fileName" }, TestContext.Current.CancellationToken ); response.Validate(); diff --git a/src/ImageKit.Tests/Services/FileServiceTest.cs b/src/ImageKit.Tests/Services/FileServiceTest.cs index 189c56a4..278afa14 100644 --- a/src/ImageKit.Tests/Services/FileServiceTest.cs +++ b/src/ImageKit.Tests/Services/FileServiceTest.cs @@ -134,7 +134,7 @@ public async Task Rename_Works() public async Task Upload_Works() { var response = await this.client.Files.Upload( - new() { File = Encoding.UTF8.GetBytes("text"), FileName = "fileName" }, + new() { File = Encoding.UTF8.GetBytes("Example data"), FileName = "fileName" }, TestContext.Current.CancellationToken ); response.Validate(); From 9b3352912b92f706d5a99f6abbe579f22a43ab77 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 11 Mar 2026 14:25:36 +0000 Subject: [PATCH 080/129] chore(client): update formatting --- src/ImageKit/Core/ApiEnum.cs | 27 ++++++++++++-------- src/ImageKit/Core/ClientOptions.cs | 4 +-- src/ImageKit/Core/JsonDictionary.cs | 6 ++--- src/ImageKit/Core/MultipartJsonDictionary.cs | 6 ++--- src/ImageKit/Core/MultipartJsonElement.cs | 12 +++++---- src/ImageKit/Core/ParamsBase.cs | 9 +++++-- src/ImageKit/Shims.cs | 21 ++++++++++----- 7 files changed, 54 insertions(+), 31 deletions(-) diff --git a/src/ImageKit/Core/ApiEnum.cs b/src/ImageKit/Core/ApiEnum.cs index c625f3b8..3c82b6fb 100644 --- a/src/ImageKit/Core/ApiEnum.cs +++ b/src/ImageKit/Core/ApiEnum.cs @@ -11,19 +11,26 @@ namespace ImageKit.Core; /// /// In most cases you don't have to worry about this type and can rely on its implicit operators to /// wrap and unwrap enum values. -/// -/// -/// Returns this instance's raw value. -/// -/// This is usually only useful if this instance was deserialized from data that doesn't match the -/// expected type (), and you want to know that value. For example, if the -/// SDK is on an older version than the API, then the API may respond with new data types that the SDK is -/// unaware of. -/// /// -public record class ApiEnum(JsonElement Json) +public record class ApiEnum where TEnum : struct, Enum { + /// + /// Returns this instance's raw value. + /// + /// This is usually only useful if this instance was deserialized from data that doesn't match the + /// expected type (), and you want to know that value. For example, if the + /// SDK is on an older version than the API, then the API may respond with new data types that the SDK is + /// unaware of. + /// + /// + public JsonElement Json; + + public ApiEnum(JsonElement json) + { + Json = json; + } + /// /// Returns this instance's raw value. /// diff --git a/src/ImageKit/Core/ClientOptions.cs b/src/ImageKit/Core/ClientOptions.cs index af27e857..2a9c6d7f 100644 --- a/src/ImageKit/Core/ClientOptions.cs +++ b/src/ImageKit/Core/ClientOptions.cs @@ -71,7 +71,7 @@ public string BaseUrl /// Defaults to 2 when null. Set to 0 to /// disable retries, which also ignores API instructions to retry. /// - public int? MaxRetries { get; set; } + public int? MaxRetries { get; set; } = null; /// /// Sets the maximum time allowed for a complete HTTP call, not including retries. @@ -81,7 +81,7 @@ public string BaseUrl /// /// Defaults to TimeSpan.FromMinutes(1) when null. /// - public TimeSpan? Timeout { get; set; } + public TimeSpan? Timeout { get; set; } = null; /// /// Your ImageKit private API key (starts with `private_`). You can find this diff --git a/src/ImageKit/Core/JsonDictionary.cs b/src/ImageKit/Core/JsonDictionary.cs index e0d51b2e..e45bd1bb 100644 --- a/src/ImageKit/Core/JsonDictionary.cs +++ b/src/ImageKit/Core/JsonDictionary.cs @@ -38,19 +38,19 @@ Dictionary MutableRawData public JsonDictionary() { _rawData = new Dictionary(); - _deserializedData = []; + _deserializedData = new(); } public JsonDictionary(IReadOnlyDictionary dictionary) { _rawData = Enumerable.ToDictionary(dictionary, (e) => e.Key, (e) => e.Value); - _deserializedData = []; + _deserializedData = new(); } public JsonDictionary(FrozenDictionary dictionary) { _rawData = dictionary; - _deserializedData = []; + _deserializedData = new(); } public JsonDictionary(JsonDictionary dictionary) diff --git a/src/ImageKit/Core/MultipartJsonDictionary.cs b/src/ImageKit/Core/MultipartJsonDictionary.cs index 2afe9f3a..39a838c3 100644 --- a/src/ImageKit/Core/MultipartJsonDictionary.cs +++ b/src/ImageKit/Core/MultipartJsonDictionary.cs @@ -38,19 +38,19 @@ Dictionary MutableRawData public MultipartJsonDictionary() { _rawData = new Dictionary(); - _deserializedData = []; + _deserializedData = new(); } public MultipartJsonDictionary(IReadOnlyDictionary dictionary) { _rawData = Enumerable.ToDictionary(dictionary, (e) => e.Key, (e) => e.Value); - _deserializedData = []; + _deserializedData = new(); } public MultipartJsonDictionary(FrozenDictionary dictionary) { _rawData = dictionary; - _deserializedData = []; + _deserializedData = new(); } public MultipartJsonDictionary(MultipartJsonDictionary dictionary) diff --git a/src/ImageKit/Core/MultipartJsonElement.cs b/src/ImageKit/Core/MultipartJsonElement.cs index 7affb5f2..ebacb7f7 100644 --- a/src/ImageKit/Core/MultipartJsonElement.cs +++ b/src/ImageKit/Core/MultipartJsonElement.cs @@ -15,13 +15,13 @@ namespace ImageKit.Core; /// /// Use to construct or read instances of this class. /// -public readonly struct MultipartJsonElement() +public readonly struct MultipartJsonElement { /// /// A with placeholders /// for . /// - internal JsonElement Json { get; init; } + internal JsonElement Json { get; init; } = default; /// /// A dictionary from placeholder string in the JSON to @@ -32,6 +32,8 @@ public readonly struct MultipartJsonElement() public static implicit operator MultipartJsonElement(JsonElement json) => new() { Json = json }; + public MultipartJsonElement() { } + public override string ToString() => JsonSerializer.Serialize( FriendlyJsonPrinter.PrintValue(this), @@ -176,7 +178,7 @@ internal static Dictionary BinaryContents static readonly ThreadLocal< Dictionary - > MultipartSerializerOptionsCache = new(() => []); + > MultipartSerializerOptionsCache = new(() => new()); static readonly JsonSerializerOptions DefaultMultipartSerializerOptions = MultipartSerializerOptions(new()); @@ -207,7 +209,7 @@ public static MultipartJsonElement SerializeToElement( var previousBinaryContents = CurrentBinaryContents.Value; try { - CurrentBinaryContents.Value = []; + CurrentBinaryContents.Value = new(); var element = JsonSerializer.SerializeToElement( value, MultipartSerializerOptions(options) @@ -250,7 +252,7 @@ public static MultipartFormDataContent Serialize( JsonSerializerOptions? options = null ) { - MultipartFormDataContent formDataContent = []; + MultipartFormDataContent formDataContent = new(); var multipartElement = MultipartJsonSerializer.SerializeToElement(value, options); void SerializeParts(string name, JsonElement element) { diff --git a/src/ImageKit/Core/ParamsBase.cs b/src/ImageKit/Core/ParamsBase.cs index 3fc38e12..b3da410d 100644 --- a/src/ImageKit/Core/ParamsBase.cs +++ b/src/ImageKit/Core/ParamsBase.cs @@ -158,7 +158,7 @@ JsonElement element internal string QueryString(ClientOptions options) { - NameValueCollection collection = []; + NameValueCollection collection = new(); foreach (var item in this.RawQueryData) { ParamsBase.AddQueryElementToCollection(collection, item.Key, item.Value); @@ -279,5 +279,10 @@ static Runtime GetRuntime() }; } - readonly record struct Runtime(string Name, string Version); + readonly record struct Runtime + { + public string Name { get; init; } + + public string Version { get; init; } + } } diff --git a/src/ImageKit/Shims.cs b/src/ImageKit/Shims.cs index afd5582f..c93321fb 100644 --- a/src/ImageKit/Shims.cs +++ b/src/ImageKit/Shims.cs @@ -15,27 +15,36 @@ namespace System.Runtime.CompilerServices AllowMultiple = false, Inherited = false )] - internal sealed class RequiredMemberAttribute : Attribute; + internal sealed class RequiredMemberAttribute : Attribute { } [AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = false)] - internal sealed class CompilerFeatureRequiredAttribute(string feature) : Attribute; + internal sealed class CompilerFeatureRequiredAttribute : Attribute + { + public CompilerFeatureRequiredAttribute(string feature) { } + } // Allow `init` to compile when targeting .NET Standard 2.0. - internal static class IsExternalInit; + internal static class IsExternalInit { } } namespace System.Diagnostics.CodeAnalysis { // Allow `[SetsRequiredMembers]` to compile when targeting .NET Standard 2.0. [AttributeUsage(AttributeTargets.Constructor, AllowMultiple = false, Inherited = false)] - internal sealed class SetsRequiredMembersAttribute : Attribute; + internal sealed class SetsRequiredMembersAttribute : Attribute { } // Allow `[MaybeNullWhen(...)]` to compile when targeting .NET Standard 2.0. [AttributeUsage(AttributeTargets.Parameter, Inherited = false)] - internal sealed class MaybeNullWhenAttribute(bool returnValue) : Attribute; + internal sealed class MaybeNullWhenAttribute : Attribute + { + public MaybeNullWhenAttribute(bool returnValue) { } + } // Allow `[NotNullWhen(...)]` to compile when targeting .NET Standard 2.0. [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)] - internal sealed class NotNullWhenAttribute(bool returnValue) : Attribute; + internal sealed class NotNullWhenAttribute : Attribute + { + public NotNullWhenAttribute(bool returnValue) { } + } } #endif From 8db05ede91cd8e2742b365f13cc432e4856f5b09 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 16 Mar 2026 14:33:02 +0000 Subject: [PATCH 081/129] fix(docs): make xml syntactically correct --- src/Directory.Build.props | 2 +- src/ImageKit/Core/JsonDictionary.cs | 6 +- src/ImageKit/Core/MultipartJsonDictionary.cs | 6 +- .../Accounts/Origins/OriginCreateParams.cs | 2 +- .../Accounts/Origins/OriginDeleteParams.cs | 2 +- .../Accounts/Origins/OriginGetParams.cs | 2 +- .../Accounts/Origins/OriginListParams.cs | 2 +- .../Models/Accounts/Origins/OriginRequest.cs | 52 +-- .../Models/Accounts/Origins/OriginResponse.cs | 52 +-- .../Accounts/Origins/OriginUpdateParams.cs | 2 +- .../UrlEndpoints/UrlEndpointCreateParams.cs | 26 +- .../UrlEndpoints/UrlEndpointDeleteParams.cs | 2 +- .../UrlEndpoints/UrlEndpointGetParams.cs | 2 +- .../UrlEndpoints/UrlEndpointListParams.cs | 2 +- .../UrlEndpoints/UrlEndpointRequest.cs | 24 +- .../UrlEndpoints/UrlEndpointResponse.cs | 24 +- .../UrlEndpoints/UrlEndpointUpdateParams.cs | 26 +- .../Models/Accounts/Usage/UsageGetParams.cs | 2 +- src/ImageKit/Models/Assets/AssetListParams.cs | 4 +- .../Models/Assets/AssetListResponse.cs | 16 +- .../Models/Beta/V2/Files/FileUploadParams.cs | 30 +- .../Beta/V2/Files/FileUploadResponse.cs | 110 +++--- .../Invalidation/InvalidationCreateParams.cs | 2 +- .../Invalidation/InvalidationGetParams.cs | 2 +- .../CustomMetadataField.cs | 108 +++--- .../CustomMetadataFieldCreateParams.cs | 110 +++--- .../CustomMetadataFieldDeleteParams.cs | 2 +- .../CustomMetadataFieldListParams.cs | 2 +- .../CustomMetadataFieldUpdateParams.cs | 110 +++--- src/ImageKit/Models/ExtensionConfig.cs | 234 ++++++------- .../Models/Files/Bulk/BulkAddTagsParams.cs | 2 +- .../Models/Files/Bulk/BulkDeleteParams.cs | 2 +- .../Files/Bulk/BulkRemoveAITagsParams.cs | 2 +- .../Models/Files/Bulk/BulkRemoveTagsParams.cs | 2 +- src/ImageKit/Models/Files/File.cs | 110 +++--- src/ImageKit/Models/Files/FileCopyParams.cs | 2 +- src/ImageKit/Models/Files/FileDeleteParams.cs | 2 +- src/ImageKit/Models/Files/FileGetParams.cs | 2 +- src/ImageKit/Models/Files/FileMoveParams.cs | 2 +- src/ImageKit/Models/Files/FileRenameParams.cs | 2 +- src/ImageKit/Models/Files/FileUpdateParams.cs | 2 +- src/ImageKit/Models/Files/FileUploadParams.cs | 30 +- .../Models/Files/FileUploadResponse.cs | 110 +++--- .../Metadata/MetadataGetFromUrlParams.cs | 2 +- .../Files/Metadata/MetadataGetParams.cs | 2 +- .../Models/Files/UpdateFileRequest.cs | 36 +- .../Files/Versions/VersionDeleteParams.cs | 2 +- .../Models/Files/Versions/VersionGetParams.cs | 2 +- .../Files/Versions/VersionListParams.cs | 2 +- .../Files/Versions/VersionRestoreParams.cs | 2 +- .../Models/Folders/FolderCopyParams.cs | 2 +- .../Models/Folders/FolderCreateParams.cs | 2 +- .../Models/Folders/FolderDeleteParams.cs | 2 +- .../Models/Folders/FolderMoveParams.cs | 2 +- .../Models/Folders/FolderRenameParams.cs | 2 +- .../Models/Folders/Job/JobGetParams.cs | 2 +- .../Models/GetImageAttributesOptions.cs | 4 +- src/ImageKit/Models/Overlay.cs | 34 +- src/ImageKit/Models/OverlayPosition.cs | 32 +- src/ImageKit/Models/OverlayTiming.cs | 48 +-- .../Models/ResponsiveImageAttributes.cs | 4 +- .../SavedExtensionCreateParams.cs | 2 +- .../SavedExtensionDeleteParams.cs | 2 +- .../SavedExtensionGetParams.cs | 2 +- .../SavedExtensionListParams.cs | 2 +- .../SavedExtensionUpdateParams.cs | 2 +- .../Models/SolidColorOverlayTransformation.cs | 70 ++-- .../Models/TextOverlayTransformation.cs | 102 +++--- src/ImageKit/Models/Transformation.cs | 322 +++++++++--------- .../Models/UnnamedSchemaWithArrayParent0.cs | 240 ++++++------- .../Webhooks/UnsafeUnwrapWebhookEvent.cs | 46 +-- .../Models/Webhooks/UnwrapWebhookEvent.cs | 46 +-- .../UploadPreTransformSuccessEvent.cs | 110 +++--- .../Services/Accounts/IOriginService.cs | 26 +- .../Services/Accounts/IUrlEndpointService.cs | 10 +- .../Services/Accounts/IUsageService.cs | 8 +- src/ImageKit/Services/Beta/V2/IFileService.cs | 36 +- .../Services/Cache/IInvalidationService.cs | 10 +- src/ImageKit/Services/Files/IBulkService.cs | 24 +- .../Services/Files/IMetadataService.cs | 10 +- .../Services/Files/IVersionService.cs | 12 +- src/ImageKit/Services/Folders/IJobService.cs | 2 +- src/ImageKit/Services/IAssetService.cs | 2 +- .../Services/ICustomMetadataFieldService.cs | 22 +- src/ImageKit/Services/IFileService.cs | 68 ++-- src/ImageKit/Services/IFolderService.cs | 38 +-- .../Services/ISavedExtensionService.cs | 22 +- 87 files changed, 1329 insertions(+), 1325 deletions(-) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 0a76a1bb..e5417938 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -12,7 +12,7 @@ true - $(NoWarn),1570,1573,1574,1591 + $(NoWarn),1573,1591 true diff --git a/src/ImageKit/Core/JsonDictionary.cs b/src/ImageKit/Core/JsonDictionary.cs index e45bd1bb..07b60600 100644 --- a/src/ImageKit/Core/JsonDictionary.cs +++ b/src/ImageKit/Core/JsonDictionary.cs @@ -11,9 +11,9 @@ namespace ImageKit.Core; /// /// A dictionary that holds JSON data. /// -/// It can be mutated and then frozen once no more mutations are expected. This -/// is useful for allowing the dictionary to be modified by a class's init -/// properties, but then preventing it from being modified afterwards. +/// It can be mutated and then frozen once no more mutations are expected. +/// This is useful for allowing the dictionary to be modified by a class's +/// init properties, but then preventing it from being modified afterwards. /// /// It also caches data deserialization for performance. /// diff --git a/src/ImageKit/Core/MultipartJsonDictionary.cs b/src/ImageKit/Core/MultipartJsonDictionary.cs index 39a838c3..909c4693 100644 --- a/src/ImageKit/Core/MultipartJsonDictionary.cs +++ b/src/ImageKit/Core/MultipartJsonDictionary.cs @@ -11,9 +11,9 @@ namespace ImageKit.Core; /// /// A dictionary that holds mixed JSON and binary content. /// -/// It can be mutated and then frozen once no more mutations are expected. This -/// is useful for allowing the dictionary to be modified by a class's init -/// properties, but then preventing it from being modified afterwards. +/// It can be mutated and then frozen once no more mutations are expected. +/// This is useful for allowing the dictionary to be modified by a class's +/// init properties, but then preventing it from being modified afterwards. /// /// It also caches data deserialization for performance. /// diff --git a/src/ImageKit/Models/Accounts/Origins/OriginCreateParams.cs b/src/ImageKit/Models/Accounts/Origins/OriginCreateParams.cs index 84c40270..d9efb146 100644 --- a/src/ImageKit/Models/Accounts/Origins/OriginCreateParams.cs +++ b/src/ImageKit/Models/Accounts/Origins/OriginCreateParams.cs @@ -74,7 +74,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static OriginCreateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, diff --git a/src/ImageKit/Models/Accounts/Origins/OriginDeleteParams.cs b/src/ImageKit/Models/Accounts/Origins/OriginDeleteParams.cs index 63da26fe..6743ad71 100644 --- a/src/ImageKit/Models/Accounts/Origins/OriginDeleteParams.cs +++ b/src/ImageKit/Models/Accounts/Origins/OriginDeleteParams.cs @@ -52,7 +52,7 @@ FrozenDictionary rawQueryData } #pragma warning restore CS8618 - /// + /// public static OriginDeleteParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData diff --git a/src/ImageKit/Models/Accounts/Origins/OriginGetParams.cs b/src/ImageKit/Models/Accounts/Origins/OriginGetParams.cs index c8d1b8f8..a46353e8 100644 --- a/src/ImageKit/Models/Accounts/Origins/OriginGetParams.cs +++ b/src/ImageKit/Models/Accounts/Origins/OriginGetParams.cs @@ -51,7 +51,7 @@ FrozenDictionary rawQueryData } #pragma warning restore CS8618 - /// + /// public static OriginGetParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData diff --git a/src/ImageKit/Models/Accounts/Origins/OriginListParams.cs b/src/ImageKit/Models/Accounts/Origins/OriginListParams.cs index 05a29757..86e74fd5 100644 --- a/src/ImageKit/Models/Accounts/Origins/OriginListParams.cs +++ b/src/ImageKit/Models/Accounts/Origins/OriginListParams.cs @@ -47,7 +47,7 @@ FrozenDictionary rawQueryData } #pragma warning restore CS8618 - /// + /// public static OriginListParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData diff --git a/src/ImageKit/Models/Accounts/Origins/OriginRequest.cs b/src/ImageKit/Models/Accounts/Origins/OriginRequest.cs index a1e5e786..6ddc8849 100644 --- a/src/ImageKit/Models/Accounts/Origins/OriginRequest.cs +++ b/src/ImageKit/Models/Accounts/Origins/OriginRequest.cs @@ -240,7 +240,7 @@ public OriginRequest(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -261,7 +261,7 @@ public bool TryPickS3([NotNullWhen(true)] out S3? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -282,7 +282,7 @@ public bool TryPickS3Compatible([NotNullWhen(true)] out S3Compatible? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -303,7 +303,7 @@ public bool TryPickCloudinaryBackup([NotNullWhen(true)] out CloudinaryBackup? va /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -324,7 +324,7 @@ public bool TryPickWebFolder([NotNullWhen(true)] out WebFolder? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -345,7 +345,7 @@ public bool TryPickWebProxy([NotNullWhen(true)] out WebProxy? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -366,7 +366,7 @@ public bool TryPickGcs([NotNullWhen(true)] out Gcs? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -387,7 +387,7 @@ public bool TryPickAzureBlob([NotNullWhen(true)] out AzureBlob? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -407,7 +407,7 @@ public bool TryPickAkeneoPim([NotNullWhen(true)] out AkeneoPim? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -418,14 +418,14 @@ public bool TryPickAkeneoPim([NotNullWhen(true)] out AkeneoPim? value) /// /// /// instance.Switch( - /// (S3 value) => {...}, - /// (S3Compatible value) => {...}, - /// (CloudinaryBackup value) => {...}, - /// (WebFolder value) => {...}, - /// (WebProxy value) => {...}, - /// (Gcs value) => {...}, - /// (AzureBlob value) => {...}, - /// (AkeneoPim value) => {...} + /// (S3 value) => {...}, + /// (S3Compatible value) => {...}, + /// (CloudinaryBackup value) => {...}, + /// (WebFolder value) => {...}, + /// (WebProxy value) => {...}, + /// (Gcs value) => {...}, + /// (AzureBlob value) => {...}, + /// (AkeneoPim value) => {...} /// ); /// /// @@ -478,7 +478,7 @@ Action akeneoPim /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -489,14 +489,14 @@ Action akeneoPim /// /// /// var result = instance.Match( - /// (S3 value) => {...}, - /// (S3Compatible value) => {...}, - /// (CloudinaryBackup value) => {...}, - /// (WebFolder value) => {...}, - /// (WebProxy value) => {...}, - /// (Gcs value) => {...}, - /// (AzureBlob value) => {...}, - /// (AkeneoPim value) => {...} + /// (S3 value) => {...}, + /// (S3Compatible value) => {...}, + /// (CloudinaryBackup value) => {...}, + /// (WebFolder value) => {...}, + /// (WebProxy value) => {...}, + /// (Gcs value) => {...}, + /// (AzureBlob value) => {...}, + /// (AkeneoPim value) => {...} /// ); /// /// diff --git a/src/ImageKit/Models/Accounts/Origins/OriginResponse.cs b/src/ImageKit/Models/Accounts/Origins/OriginResponse.cs index 4859a56f..56c46f8d 100644 --- a/src/ImageKit/Models/Accounts/Origins/OriginResponse.cs +++ b/src/ImageKit/Models/Accounts/Origins/OriginResponse.cs @@ -223,7 +223,7 @@ public OriginResponse(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -244,7 +244,7 @@ public bool TryPickS3([NotNullWhen(true)] out OriginResponseS3? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -265,7 +265,7 @@ public bool TryPickS3Compatible([NotNullWhen(true)] out OriginResponseS3Compatib /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -288,7 +288,7 @@ public bool TryPickCloudinaryBackup( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -309,7 +309,7 @@ public bool TryPickWebFolder([NotNullWhen(true)] out OriginResponseWebFolder? va /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -330,7 +330,7 @@ public bool TryPickWebProxy([NotNullWhen(true)] out OriginResponseWebProxy? valu /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -351,7 +351,7 @@ public bool TryPickGcs([NotNullWhen(true)] out OriginResponseGcs? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -372,7 +372,7 @@ public bool TryPickAzureBlob([NotNullWhen(true)] out OriginResponseAzureBlob? va /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -392,7 +392,7 @@ public bool TryPickAkeneoPim([NotNullWhen(true)] out OriginResponseAkeneoPim? va /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -403,14 +403,14 @@ public bool TryPickAkeneoPim([NotNullWhen(true)] out OriginResponseAkeneoPim? va /// /// /// instance.Switch( - /// (OriginResponseS3 value) => {...}, - /// (OriginResponseS3Compatible value) => {...}, - /// (OriginResponseCloudinaryBackup value) => {...}, - /// (OriginResponseWebFolder value) => {...}, - /// (OriginResponseWebProxy value) => {...}, - /// (OriginResponseGcs value) => {...}, - /// (OriginResponseAzureBlob value) => {...}, - /// (OriginResponseAkeneoPim value) => {...} + /// (OriginResponseS3 value) => {...}, + /// (OriginResponseS3Compatible value) => {...}, + /// (OriginResponseCloudinaryBackup value) => {...}, + /// (OriginResponseWebFolder value) => {...}, + /// (OriginResponseWebProxy value) => {...}, + /// (OriginResponseGcs value) => {...}, + /// (OriginResponseAzureBlob value) => {...}, + /// (OriginResponseAkeneoPim value) => {...} /// ); /// /// @@ -463,7 +463,7 @@ Action akeneoPim /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -474,14 +474,14 @@ Action akeneoPim /// /// /// var result = instance.Match( - /// (OriginResponseS3 value) => {...}, - /// (OriginResponseS3Compatible value) => {...}, - /// (OriginResponseCloudinaryBackup value) => {...}, - /// (OriginResponseWebFolder value) => {...}, - /// (OriginResponseWebProxy value) => {...}, - /// (OriginResponseGcs value) => {...}, - /// (OriginResponseAzureBlob value) => {...}, - /// (OriginResponseAkeneoPim value) => {...} + /// (OriginResponseS3 value) => {...}, + /// (OriginResponseS3Compatible value) => {...}, + /// (OriginResponseCloudinaryBackup value) => {...}, + /// (OriginResponseWebFolder value) => {...}, + /// (OriginResponseWebProxy value) => {...}, + /// (OriginResponseGcs value) => {...}, + /// (OriginResponseAzureBlob value) => {...}, + /// (OriginResponseAkeneoPim value) => {...} /// ); /// /// diff --git a/src/ImageKit/Models/Accounts/Origins/OriginUpdateParams.cs b/src/ImageKit/Models/Accounts/Origins/OriginUpdateParams.cs index b8662882..b06d700a 100644 --- a/src/ImageKit/Models/Accounts/Origins/OriginUpdateParams.cs +++ b/src/ImageKit/Models/Accounts/Origins/OriginUpdateParams.cs @@ -78,7 +78,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static OriginUpdateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, diff --git a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointCreateParams.cs b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointCreateParams.cs index 550905c9..0d12b923 100644 --- a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointCreateParams.cs +++ b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointCreateParams.cs @@ -146,7 +146,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static UrlEndpointCreateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, @@ -270,7 +270,7 @@ public UrlRewriter(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -291,7 +291,7 @@ public bool TryPickCloudinary([NotNullWhen(true)] out Cloudinary? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -312,7 +312,7 @@ public bool TryPickImgix([NotNullWhen(true)] out Imgix? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -332,7 +332,7 @@ public bool TryPickAkamai([NotNullWhen(true)] out Akamai? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -343,9 +343,9 @@ public bool TryPickAkamai([NotNullWhen(true)] out Akamai? value) /// /// /// instance.Switch( - /// (Cloudinary value) => {...}, - /// (Imgix value) => {...}, - /// (Akamai value) => {...} + /// (Cloudinary value) => {...}, + /// (Imgix value) => {...}, + /// (Akamai value) => {...} /// ); /// /// @@ -374,7 +374,7 @@ public void Switch(Action cloudinary, Action imgix, ActionUse the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -385,9 +385,9 @@ public void Switch(Action cloudinary, Action imgix, Action /// /// var result = instance.Match( - /// (Cloudinary value) => {...}, - /// (Imgix value) => {...}, - /// (Akamai value) => {...} + /// (Cloudinary value) => {...}, + /// (Imgix value) => {...}, + /// (Akamai value) => {...} /// ); /// /// @@ -568,7 +568,7 @@ public JsonElement Type } /// - /// Whether to preserve `/` in the rewritten URL. + /// Whether to preserve `<asset_type>/<delivery_type>` in the rewritten URL. /// public bool? PreserveAssetDeliveryTypes { diff --git a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointDeleteParams.cs b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointDeleteParams.cs index 40b14582..ad120ae9 100644 --- a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointDeleteParams.cs +++ b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointDeleteParams.cs @@ -53,7 +53,7 @@ FrozenDictionary rawQueryData } #pragma warning restore CS8618 - /// + /// public static UrlEndpointDeleteParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData diff --git a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointGetParams.cs b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointGetParams.cs index c16951e8..88f84d63 100644 --- a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointGetParams.cs +++ b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointGetParams.cs @@ -52,7 +52,7 @@ FrozenDictionary rawQueryData } #pragma warning restore CS8618 - /// + /// public static UrlEndpointGetParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData diff --git a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointListParams.cs b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointListParams.cs index d9c525d2..41ea3fc4 100644 --- a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointListParams.cs +++ b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointListParams.cs @@ -47,7 +47,7 @@ FrozenDictionary rawQueryData } #pragma warning restore CS8618 - /// + /// public static UrlEndpointListParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData diff --git a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointRequest.cs b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointRequest.cs index c8a5a703..dbcdaf45 100644 --- a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointRequest.cs +++ b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointRequest.cs @@ -208,7 +208,7 @@ public UrlEndpointRequestUrlRewriter(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -231,7 +231,7 @@ public bool TryPickCloudinary( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -252,7 +252,7 @@ public bool TryPickImgix([NotNullWhen(true)] out UrlEndpointRequestUrlRewriterIm /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -272,7 +272,7 @@ public bool TryPickAkamai([NotNullWhen(true)] out UrlEndpointRequestUrlRewriterA /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -283,9 +283,9 @@ public bool TryPickAkamai([NotNullWhen(true)] out UrlEndpointRequestUrlRewriterA /// /// /// instance.Switch( - /// (UrlEndpointRequestUrlRewriterCloudinary value) => {...}, - /// (UrlEndpointRequestUrlRewriterImgix value) => {...}, - /// (UrlEndpointRequestUrlRewriterAkamai value) => {...} + /// (UrlEndpointRequestUrlRewriterCloudinary value) => {...}, + /// (UrlEndpointRequestUrlRewriterImgix value) => {...}, + /// (UrlEndpointRequestUrlRewriterAkamai value) => {...} /// ); /// /// @@ -318,7 +318,7 @@ Action akamai /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -329,9 +329,9 @@ Action akamai /// /// /// var result = instance.Match( - /// (UrlEndpointRequestUrlRewriterCloudinary value) => {...}, - /// (UrlEndpointRequestUrlRewriterImgix value) => {...}, - /// (UrlEndpointRequestUrlRewriterAkamai value) => {...} + /// (UrlEndpointRequestUrlRewriterCloudinary value) => {...}, + /// (UrlEndpointRequestUrlRewriterImgix value) => {...}, + /// (UrlEndpointRequestUrlRewriterAkamai value) => {...} /// ); /// /// @@ -541,7 +541,7 @@ public JsonElement Type } /// - /// Whether to preserve `/` in the rewritten URL. + /// Whether to preserve `<asset_type>/<delivery_type>` in the rewritten URL. /// public bool? PreserveAssetDeliveryTypes { diff --git a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointResponse.cs b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointResponse.cs index e1f0504d..e4071337 100644 --- a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointResponse.cs +++ b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointResponse.cs @@ -203,7 +203,7 @@ public UrlEndpointResponseUrlRewriter(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -226,7 +226,7 @@ public bool TryPickCloudinary( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -247,7 +247,7 @@ public bool TryPickImgix([NotNullWhen(true)] out UrlEndpointResponseUrlRewriterI /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -267,7 +267,7 @@ public bool TryPickAkamai([NotNullWhen(true)] out UrlEndpointResponseUrlRewriter /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -278,9 +278,9 @@ public bool TryPickAkamai([NotNullWhen(true)] out UrlEndpointResponseUrlRewriter /// /// /// instance.Switch( - /// (UrlEndpointResponseUrlRewriterCloudinary value) => {...}, - /// (UrlEndpointResponseUrlRewriterImgix value) => {...}, - /// (UrlEndpointResponseUrlRewriterAkamai value) => {...} + /// (UrlEndpointResponseUrlRewriterCloudinary value) => {...}, + /// (UrlEndpointResponseUrlRewriterImgix value) => {...}, + /// (UrlEndpointResponseUrlRewriterAkamai value) => {...} /// ); /// /// @@ -313,7 +313,7 @@ Action akamai /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -324,9 +324,9 @@ Action akamai /// /// /// var result = instance.Match( - /// (UrlEndpointResponseUrlRewriterCloudinary value) => {...}, - /// (UrlEndpointResponseUrlRewriterImgix value) => {...}, - /// (UrlEndpointResponseUrlRewriterAkamai value) => {...} + /// (UrlEndpointResponseUrlRewriterCloudinary value) => {...}, + /// (UrlEndpointResponseUrlRewriterImgix value) => {...}, + /// (UrlEndpointResponseUrlRewriterAkamai value) => {...} /// ); /// /// @@ -526,7 +526,7 @@ JsonSerializerOptions options public sealed record class UrlEndpointResponseUrlRewriterCloudinary : JsonModel { /// - /// Whether to preserve `/` in the rewritten URL. + /// Whether to preserve `<asset_type>/<delivery_type>` in the rewritten URL. /// public required bool PreserveAssetDeliveryTypes { diff --git a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParams.cs b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParams.cs index 40e53fb7..8a3142a4 100644 --- a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParams.cs +++ b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParams.cs @@ -152,7 +152,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static UrlEndpointUpdateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, @@ -288,7 +288,7 @@ public UrlEndpointUpdateParamsUrlRewriter(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -311,7 +311,7 @@ public bool TryPickCloudinary( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -332,7 +332,7 @@ public bool TryPickImgix([NotNullWhen(true)] out UrlEndpointUpdateParamsUrlRewri /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -354,7 +354,7 @@ public bool TryPickAkamai( /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -365,9 +365,9 @@ public bool TryPickAkamai( /// /// /// instance.Switch( - /// (UrlEndpointUpdateParamsUrlRewriterCloudinary value) => {...}, - /// (UrlEndpointUpdateParamsUrlRewriterImgix value) => {...}, - /// (UrlEndpointUpdateParamsUrlRewriterAkamai value) => {...} + /// (UrlEndpointUpdateParamsUrlRewriterCloudinary value) => {...}, + /// (UrlEndpointUpdateParamsUrlRewriterImgix value) => {...}, + /// (UrlEndpointUpdateParamsUrlRewriterAkamai value) => {...} /// ); /// /// @@ -400,7 +400,7 @@ Action akamai /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -411,9 +411,9 @@ Action akamai /// /// /// var result = instance.Match( - /// (UrlEndpointUpdateParamsUrlRewriterCloudinary value) => {...}, - /// (UrlEndpointUpdateParamsUrlRewriterImgix value) => {...}, - /// (UrlEndpointUpdateParamsUrlRewriterAkamai value) => {...} + /// (UrlEndpointUpdateParamsUrlRewriterCloudinary value) => {...}, + /// (UrlEndpointUpdateParamsUrlRewriterImgix value) => {...}, + /// (UrlEndpointUpdateParamsUrlRewriterAkamai value) => {...} /// ); /// /// @@ -624,7 +624,7 @@ public JsonElement Type } /// - /// Whether to preserve `/` in the rewritten URL. + /// Whether to preserve `<asset_type>/<delivery_type>` in the rewritten URL. /// public bool? PreserveAssetDeliveryTypes { diff --git a/src/ImageKit/Models/Accounts/Usage/UsageGetParams.cs b/src/ImageKit/Models/Accounts/Usage/UsageGetParams.cs index 82f23050..c48c1042 100644 --- a/src/ImageKit/Models/Accounts/Usage/UsageGetParams.cs +++ b/src/ImageKit/Models/Accounts/Usage/UsageGetParams.cs @@ -77,7 +77,7 @@ FrozenDictionary rawQueryData } #pragma warning restore CS8618 - /// + /// public static UsageGetParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData diff --git a/src/ImageKit/Models/Assets/AssetListParams.cs b/src/ImageKit/Models/Assets/AssetListParams.cs index fb310b80..6828602b 100644 --- a/src/ImageKit/Models/Assets/AssetListParams.cs +++ b/src/ImageKit/Models/Assets/AssetListParams.cs @@ -95,7 +95,7 @@ public string? Path } /// - /// Query string in a Lucene-like query language e.g. `createdAt > "7d"`. + /// Query string in a Lucene-like query language e.g. `createdAt > "7d"`. /// /// Note : When the searchQuery parameter is present, the following query /// parameters will have no effect on the result: @@ -222,7 +222,7 @@ FrozenDictionary rawQueryData } #pragma warning restore CS8618 - /// + /// public static AssetListParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData diff --git a/src/ImageKit/Models/Assets/AssetListResponse.cs b/src/ImageKit/Models/Assets/AssetListResponse.cs index f8fdeef9..f63a4281 100644 --- a/src/ImageKit/Models/Assets/AssetListResponse.cs +++ b/src/ImageKit/Models/Assets/AssetListResponse.cs @@ -77,7 +77,7 @@ public AssetListResponse(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -98,7 +98,7 @@ public bool TryPickFile([NotNullWhen(true)] out File? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -118,7 +118,7 @@ public bool TryPickFolder([NotNullWhen(true)] out Folder? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -129,8 +129,8 @@ public bool TryPickFolder([NotNullWhen(true)] out Folder? value) /// /// /// instance.Switch( - /// (File value) => {...}, - /// (Folder value) => {...} + /// (File value) => {...}, + /// (Folder value) => {...} /// ); /// /// @@ -156,7 +156,7 @@ public void Switch(System::Action file, System::Action folder) /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -167,8 +167,8 @@ public void Switch(System::Action file, System::Action folder) /// /// /// var result = instance.Match( - /// (File value) => {...}, - /// (Folder value) => {...} + /// (File value) => {...}, + /// (Folder value) => {...} /// ); /// /// diff --git a/src/ImageKit/Models/Beta/V2/Files/FileUploadParams.cs b/src/ImageKit/Models/Beta/V2/Files/FileUploadParams.cs index 4f172112..ae95bda9 100644 --- a/src/ImageKit/Models/Beta/V2/Files/FileUploadParams.cs +++ b/src/ImageKit/Models/Beta/V2/Files/FileUploadParams.cs @@ -571,7 +571,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static FileUploadParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, @@ -891,7 +891,7 @@ public Post(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -912,7 +912,7 @@ public bool TryPickTransformation([NotNullWhen(true)] out PostTransformation? va /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -933,7 +933,7 @@ public bool TryPickGifToVideo([NotNullWhen(true)] out GifToVideo? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -954,7 +954,7 @@ public bool TryPickThumbnail([NotNullWhen(true)] out Thumbnail? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -974,7 +974,7 @@ public bool TryPickAbs([NotNullWhen(true)] out Abs? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -985,10 +985,10 @@ public bool TryPickAbs([NotNullWhen(true)] out Abs? value) /// /// /// instance.Switch( - /// (PostTransformation value) => {...}, - /// (GifToVideo value) => {...}, - /// (Thumbnail value) => {...}, - /// (Abs value) => {...} + /// (PostTransformation value) => {...}, + /// (GifToVideo value) => {...}, + /// (Thumbnail value) => {...}, + /// (Abs value) => {...} /// ); /// /// @@ -1023,7 +1023,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1034,10 +1034,10 @@ public void Switch( /// /// /// var result = instance.Match( - /// (PostTransformation value) => {...}, - /// (GifToVideo value) => {...}, - /// (Thumbnail value) => {...}, - /// (Abs value) => {...} + /// (PostTransformation value) => {...}, + /// (GifToVideo value) => {...}, + /// (Thumbnail value) => {...}, + /// (Abs value) => {...} /// ); /// /// diff --git a/src/ImageKit/Models/Beta/V2/Files/FileUploadResponse.cs b/src/ImageKit/Models/Beta/V2/Files/FileUploadResponse.cs index 48b20fbc..d6f311e8 100644 --- a/src/ImageKit/Models/Beta/V2/Files/FileUploadResponse.cs +++ b/src/ImageKit/Models/Beta/V2/Files/FileUploadResponse.cs @@ -1343,7 +1343,7 @@ public IReadOnlyList? SelectOptions /// /// Specifies if the selectOptions array is truncated. It is truncated when number - /// of options are > 100. + /// of options are > 100. /// public bool? SelectOptionsTruncated { @@ -1548,7 +1548,7 @@ public DefaultValue(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1569,7 +1569,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1590,7 +1590,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1609,14 +1609,14 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type where T is a UnnamedSchemaWithArrayParent12. /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickMixed(out var value)) { - /// // `value` is of type `IReadOnlyList` + /// // `value` is of type `IReadOnlyList<UnnamedSchemaWithArrayParent12>` /// Console.WriteLine(value); /// } /// @@ -1633,7 +1633,7 @@ public bool TryPickMixed( /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1644,10 +1644,10 @@ public bool TryPickMixed( /// /// /// instance.Switch( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...}, - /// (IReadOnlyList value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList<UnnamedSchemaWithArrayParent12> value) => {...} /// ); /// /// @@ -1684,7 +1684,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1695,10 +1695,10 @@ public void Switch( /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...}, - /// (IReadOnlyList value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList<UnnamedSchemaWithArrayParent12> value) => {...} /// ); /// /// @@ -1910,7 +1910,7 @@ public UnnamedSchemaWithArrayParent12(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1931,7 +1931,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1952,7 +1952,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1972,7 +1972,7 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1983,9 +1983,9 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// /// instance.Switch( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} /// ); /// /// @@ -2018,7 +2018,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -2029,9 +2029,9 @@ public void Switch( /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} /// ); /// /// @@ -2204,7 +2204,7 @@ public MaxValue(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2225,7 +2225,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2245,7 +2245,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -2256,8 +2256,8 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// /// /// instance.Switch( - /// (string value) => {...}, - /// (double value) => {...} + /// (string value) => {...}, + /// (double value) => {...} /// ); /// /// @@ -2283,7 +2283,7 @@ public void Switch(System::Action @string, System::Action @doubl /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -2294,8 +2294,8 @@ public void Switch(System::Action @string, System::Action @doubl /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (double value) => {...} + /// (string value) => {...}, + /// (double value) => {...} /// ); /// /// @@ -2445,7 +2445,7 @@ public MinValue(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2466,7 +2466,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2486,7 +2486,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -2497,8 +2497,8 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// /// /// instance.Switch( - /// (string value) => {...}, - /// (double value) => {...} + /// (string value) => {...}, + /// (double value) => {...} /// ); /// /// @@ -2524,7 +2524,7 @@ public void Switch(System::Action @string, System::Action @doubl /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -2535,8 +2535,8 @@ public void Switch(System::Action @string, System::Action @doubl /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (double value) => {...} + /// (string value) => {...}, + /// (double value) => {...} /// ); /// /// @@ -2687,7 +2687,7 @@ public SelectOption(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2708,7 +2708,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2729,7 +2729,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2749,7 +2749,7 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -2760,9 +2760,9 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// /// instance.Switch( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} /// ); /// /// @@ -2795,7 +2795,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -2806,9 +2806,9 @@ public void Switch( /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} /// ); /// /// diff --git a/src/ImageKit/Models/Cache/Invalidation/InvalidationCreateParams.cs b/src/ImageKit/Models/Cache/Invalidation/InvalidationCreateParams.cs index 701cfe80..5df6d94b 100644 --- a/src/ImageKit/Models/Cache/Invalidation/InvalidationCreateParams.cs +++ b/src/ImageKit/Models/Cache/Invalidation/InvalidationCreateParams.cs @@ -74,7 +74,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static InvalidationCreateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, diff --git a/src/ImageKit/Models/Cache/Invalidation/InvalidationGetParams.cs b/src/ImageKit/Models/Cache/Invalidation/InvalidationGetParams.cs index 97879c00..d5eff502 100644 --- a/src/ImageKit/Models/Cache/Invalidation/InvalidationGetParams.cs +++ b/src/ImageKit/Models/Cache/Invalidation/InvalidationGetParams.cs @@ -51,7 +51,7 @@ FrozenDictionary rawQueryData } #pragma warning restore CS8618 - /// + /// public static InvalidationGetParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData diff --git a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataField.cs b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataField.cs index 96be0ceb..a7f83517 100644 --- a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataField.cs +++ b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataField.cs @@ -480,7 +480,7 @@ public CustomMetadataFieldSchemaDefaultValue(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -501,7 +501,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -522,7 +522,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -541,14 +541,14 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type where T is a UnnamedSchemaWithArrayParent9. /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickMixed(out var value)) { - /// // `value` is of type `IReadOnlyList` + /// // `value` is of type `IReadOnlyList<UnnamedSchemaWithArrayParent9>` /// Console.WriteLine(value); /// } /// @@ -565,7 +565,7 @@ public bool TryPickMixed( /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -576,10 +576,10 @@ public bool TryPickMixed( /// /// /// instance.Switch( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...}, - /// (IReadOnlyList value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList<UnnamedSchemaWithArrayParent9> value) => {...} /// ); /// /// @@ -616,7 +616,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -627,10 +627,10 @@ public void Switch( /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...}, - /// (IReadOnlyList value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList<UnnamedSchemaWithArrayParent9> value) => {...} /// ); /// /// @@ -846,7 +846,7 @@ public UnnamedSchemaWithArrayParent9(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -867,7 +867,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -888,7 +888,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -908,7 +908,7 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -919,9 +919,9 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// /// instance.Switch( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} /// ); /// /// @@ -954,7 +954,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -965,9 +965,9 @@ public void Switch( /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} /// ); /// /// @@ -1140,7 +1140,7 @@ public CustomMetadataFieldSchemaMaxValue(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1161,7 +1161,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1181,7 +1181,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1192,8 +1192,8 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// /// /// instance.Switch( - /// (string value) => {...}, - /// (double value) => {...} + /// (string value) => {...}, + /// (double value) => {...} /// ); /// /// @@ -1219,7 +1219,7 @@ public void Switch(System::Action @string, System::Action @doubl /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1230,8 +1230,8 @@ public void Switch(System::Action @string, System::Action @doubl /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (double value) => {...} + /// (string value) => {...}, + /// (double value) => {...} /// ); /// /// @@ -1388,7 +1388,7 @@ public CustomMetadataFieldSchemaMinValue(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1409,7 +1409,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1429,7 +1429,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1440,8 +1440,8 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// /// /// instance.Switch( - /// (string value) => {...}, - /// (double value) => {...} + /// (string value) => {...}, + /// (double value) => {...} /// ); /// /// @@ -1467,7 +1467,7 @@ public void Switch(System::Action @string, System::Action @doubl /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1478,8 +1478,8 @@ public void Switch(System::Action @string, System::Action @doubl /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (double value) => {...} + /// (string value) => {...}, + /// (double value) => {...} /// ); /// /// @@ -1637,7 +1637,7 @@ public CustomMetadataFieldSchemaSelectOption(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1658,7 +1658,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1679,7 +1679,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1699,7 +1699,7 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1710,9 +1710,9 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// /// instance.Switch( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} /// ); /// /// @@ -1745,7 +1745,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1756,9 +1756,9 @@ public void Switch( /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} /// ); /// /// diff --git a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldCreateParams.cs b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldCreateParams.cs index b635989e..0be80059 100644 --- a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldCreateParams.cs +++ b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldCreateParams.cs @@ -107,7 +107,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static CustomMetadataFieldCreateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, @@ -541,7 +541,7 @@ public DefaultValue(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -562,7 +562,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -583,7 +583,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -602,14 +602,14 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type where T is a UnnamedSchemaWithArrayParent1. /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickMixed(out var value)) { - /// // `value` is of type `IReadOnlyList` + /// // `value` is of type `IReadOnlyList<UnnamedSchemaWithArrayParent1>` /// Console.WriteLine(value); /// } /// @@ -626,7 +626,7 @@ public bool TryPickMixed( /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -637,10 +637,10 @@ public bool TryPickMixed( /// /// /// instance.Switch( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...}, - /// (IReadOnlyList value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList<UnnamedSchemaWithArrayParent1> value) => {...} /// ); /// /// @@ -677,7 +677,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -688,10 +688,10 @@ public void Switch( /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...}, - /// (IReadOnlyList value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList<UnnamedSchemaWithArrayParent1> value) => {...} /// ); /// /// @@ -903,7 +903,7 @@ public UnnamedSchemaWithArrayParent1(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -924,7 +924,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -945,7 +945,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -965,7 +965,7 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -976,9 +976,9 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// /// instance.Switch( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} /// ); /// /// @@ -1011,7 +1011,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1022,9 +1022,9 @@ public void Switch( /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} /// ); /// /// @@ -1197,7 +1197,7 @@ public MaxValue(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1218,7 +1218,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1238,7 +1238,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1249,8 +1249,8 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// /// /// instance.Switch( - /// (string value) => {...}, - /// (double value) => {...} + /// (string value) => {...}, + /// (double value) => {...} /// ); /// /// @@ -1276,7 +1276,7 @@ public void Switch(System::Action @string, System::Action @doubl /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1287,8 +1287,8 @@ public void Switch(System::Action @string, System::Action @doubl /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (double value) => {...} + /// (string value) => {...}, + /// (double value) => {...} /// ); /// /// @@ -1438,7 +1438,7 @@ public MinValue(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1459,7 +1459,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1479,7 +1479,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1490,8 +1490,8 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// /// /// instance.Switch( - /// (string value) => {...}, - /// (double value) => {...} + /// (string value) => {...}, + /// (double value) => {...} /// ); /// /// @@ -1517,7 +1517,7 @@ public void Switch(System::Action @string, System::Action @doubl /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1528,8 +1528,8 @@ public void Switch(System::Action @string, System::Action @doubl /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (double value) => {...} + /// (string value) => {...}, + /// (double value) => {...} /// ); /// /// @@ -1680,7 +1680,7 @@ public SelectOption(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1701,7 +1701,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1722,7 +1722,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1742,7 +1742,7 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1753,9 +1753,9 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// /// instance.Switch( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} /// ); /// /// @@ -1788,7 +1788,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1799,9 +1799,9 @@ public void Switch( /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} /// ); /// /// diff --git a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldDeleteParams.cs b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldDeleteParams.cs index bb80ffa0..f637b221 100644 --- a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldDeleteParams.cs +++ b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldDeleteParams.cs @@ -54,7 +54,7 @@ FrozenDictionary rawQueryData } #pragma warning restore CS8618 - /// + /// public static CustomMetadataFieldDeleteParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData diff --git a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldListParams.cs b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldListParams.cs index a7e74c56..70831d7d 100644 --- a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldListParams.cs +++ b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldListParams.cs @@ -100,7 +100,7 @@ FrozenDictionary rawQueryData } #pragma warning restore CS8618 - /// + /// public static CustomMetadataFieldListParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData diff --git a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParams.cs b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParams.cs index 740d05fc..09cbb349 100644 --- a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParams.cs +++ b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParams.cs @@ -119,7 +119,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static CustomMetadataFieldUpdateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, @@ -505,7 +505,7 @@ public CustomMetadataFieldUpdateParamsSchemaDefaultValue(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -526,7 +526,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -547,7 +547,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -566,14 +566,14 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type where T is a UnnamedSchemaWithArrayParent2. /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickMixed(out var value)) { - /// // `value` is of type `IReadOnlyList` + /// // `value` is of type `IReadOnlyList<UnnamedSchemaWithArrayParent2>` /// Console.WriteLine(value); /// } /// @@ -590,7 +590,7 @@ public bool TryPickMixed( /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -601,10 +601,10 @@ public bool TryPickMixed( /// /// /// instance.Switch( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...}, - /// (IReadOnlyList value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList<UnnamedSchemaWithArrayParent2> value) => {...} /// ); /// /// @@ -641,7 +641,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -652,10 +652,10 @@ public void Switch( /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...}, - /// (IReadOnlyList value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList<UnnamedSchemaWithArrayParent2> value) => {...} /// ); /// /// @@ -874,7 +874,7 @@ public UnnamedSchemaWithArrayParent2(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -895,7 +895,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -916,7 +916,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -936,7 +936,7 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -947,9 +947,9 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// /// instance.Switch( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} /// ); /// /// @@ -982,7 +982,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -993,9 +993,9 @@ public void Switch( /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} /// ); /// /// @@ -1168,7 +1168,7 @@ public CustomMetadataFieldUpdateParamsSchemaMaxValue(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1189,7 +1189,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1209,7 +1209,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1220,8 +1220,8 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// /// /// instance.Switch( - /// (string value) => {...}, - /// (double value) => {...} + /// (string value) => {...}, + /// (double value) => {...} /// ); /// /// @@ -1247,7 +1247,7 @@ public void Switch(System::Action @string, System::Action @doubl /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1258,8 +1258,8 @@ public void Switch(System::Action @string, System::Action @doubl /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (double value) => {...} + /// (string value) => {...}, + /// (double value) => {...} /// ); /// /// @@ -1418,7 +1418,7 @@ public CustomMetadataFieldUpdateParamsSchemaMinValue(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1439,7 +1439,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1459,7 +1459,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1470,8 +1470,8 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// /// /// instance.Switch( - /// (string value) => {...}, - /// (double value) => {...} + /// (string value) => {...}, + /// (double value) => {...} /// ); /// /// @@ -1497,7 +1497,7 @@ public void Switch(System::Action @string, System::Action @doubl /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1508,8 +1508,8 @@ public void Switch(System::Action @string, System::Action @doubl /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (double value) => {...} + /// (string value) => {...}, + /// (double value) => {...} /// ); /// /// @@ -1678,7 +1678,7 @@ public CustomMetadataFieldUpdateParamsSchemaSelectOption(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1699,7 +1699,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1720,7 +1720,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1740,7 +1740,7 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1751,9 +1751,9 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// /// instance.Switch( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} /// ); /// /// @@ -1786,7 +1786,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1797,9 +1797,9 @@ public void Switch( /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} /// ); /// /// diff --git a/src/ImageKit/Models/ExtensionConfig.cs b/src/ImageKit/Models/ExtensionConfig.cs index 018cbe87..bf6c8794 100644 --- a/src/ImageKit/Models/ExtensionConfig.cs +++ b/src/ImageKit/Models/ExtensionConfig.cs @@ -64,7 +64,7 @@ public ExtensionConfig(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -85,7 +85,7 @@ public bool TryPickRemoveBg([NotNullWhen(true)] out RemoveBg? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -106,7 +106,7 @@ public bool TryPickAutoTaggingExtension([NotNullWhen(true)] out AutoTaggingExten /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -127,7 +127,7 @@ public bool TryPickAIAutoDescription([NotNullWhen(true)] out AIAutoDescription? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -147,7 +147,7 @@ public bool TryPickAITasks([NotNullWhen(true)] out AITasks? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -158,10 +158,10 @@ public bool TryPickAITasks([NotNullWhen(true)] out AITasks? value) /// /// /// instance.Switch( - /// (RemoveBg value) => {...}, - /// (AutoTaggingExtension value) => {...}, - /// (AIAutoDescription value) => {...}, - /// (AITasks value) => {...} + /// (RemoveBg value) => {...}, + /// (AutoTaggingExtension value) => {...}, + /// (AIAutoDescription value) => {...}, + /// (AITasks value) => {...} /// ); /// /// @@ -198,7 +198,7 @@ Action aiTasks /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -209,10 +209,10 @@ Action aiTasks /// /// /// var result = instance.Match( - /// (RemoveBg value) => {...}, - /// (AutoTaggingExtension value) => {...}, - /// (AIAutoDescription value) => {...}, - /// (AITasks value) => {...} + /// (RemoveBg value) => {...}, + /// (AutoTaggingExtension value) => {...}, + /// (AIAutoDescription value) => {...}, + /// (AITasks value) => {...} /// ); /// /// @@ -1025,7 +1025,7 @@ public Task(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1046,7 +1046,7 @@ public bool TryPickSelectTags([NotNullWhen(true)] out SelectTags? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1067,7 +1067,7 @@ public bool TryPickSelectMetadata([NotNullWhen(true)] out SelectMetadata? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1087,7 +1087,7 @@ public bool TryPickYesNo([NotNullWhen(true)] out YesNo? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1098,9 +1098,9 @@ public bool TryPickYesNo([NotNullWhen(true)] out YesNo? value) /// /// /// instance.Switch( - /// (SelectTags value) => {...}, - /// (SelectMetadata value) => {...}, - /// (YesNo value) => {...} + /// (SelectTags value) => {...}, + /// (SelectMetadata value) => {...}, + /// (YesNo value) => {...} /// ); /// /// @@ -1131,7 +1131,7 @@ Action yesNo /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1142,9 +1142,9 @@ Action yesNo /// /// /// var result = instance.Match( - /// (SelectTags value) => {...}, - /// (SelectMetadata value) => {...}, - /// (YesNo value) => {...} + /// (SelectTags value) => {...}, + /// (SelectMetadata value) => {...}, + /// (YesNo value) => {...} /// ); /// /// @@ -1678,7 +1678,7 @@ public Vocabulary(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1699,7 +1699,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1720,7 +1720,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1740,7 +1740,7 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1751,9 +1751,9 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// /// instance.Switch( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} /// ); /// /// @@ -1782,7 +1782,7 @@ public void Switch(Action @string, Action @double, Action /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1793,9 +1793,9 @@ public void Switch(Action @string, Action @double, Action /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} /// ); /// /// @@ -2352,7 +2352,7 @@ public SetMetadataValue(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2373,7 +2373,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2394,7 +2394,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2413,14 +2413,14 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type where T is a UnnamedSchemaWithArrayParent3. /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickMixed(out var value)) { - /// // `value` is of type `IReadOnlyList` + /// // `value` is of type `IReadOnlyList<UnnamedSchemaWithArrayParent3>` /// Console.WriteLine(value); /// } /// @@ -2437,7 +2437,7 @@ public bool TryPickMixed( /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -2448,10 +2448,10 @@ public bool TryPickMixed( /// /// /// instance.Switch( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...}, - /// (IReadOnlyList value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList<UnnamedSchemaWithArrayParent3> value) => {...} /// ); /// /// @@ -2488,7 +2488,7 @@ Action> mixed /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -2499,10 +2499,10 @@ Action> mixed /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...}, - /// (IReadOnlyList value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList<UnnamedSchemaWithArrayParent3> value) => {...} /// ); /// /// @@ -2714,7 +2714,7 @@ public UnnamedSchemaWithArrayParent3(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2735,7 +2735,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2756,7 +2756,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2776,7 +2776,7 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -2787,9 +2787,9 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// /// instance.Switch( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} /// ); /// /// @@ -2818,7 +2818,7 @@ public void Switch(Action @string, Action @double, Action /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -2829,9 +2829,9 @@ public void Switch(Action @string, Action @double, Action /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} /// ); /// /// @@ -3309,7 +3309,7 @@ public OnUnknownSetMetadataValue(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -3330,7 +3330,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -3351,7 +3351,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -3370,14 +3370,14 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type where T is a UnnamedSchemaWithArrayParent4. /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickMixed(out var value)) { - /// // `value` is of type `IReadOnlyList` + /// // `value` is of type `IReadOnlyList<UnnamedSchemaWithArrayParent4>` /// Console.WriteLine(value); /// } /// @@ -3394,7 +3394,7 @@ public bool TryPickMixed( /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -3405,10 +3405,10 @@ public bool TryPickMixed( /// /// /// instance.Switch( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...}, - /// (IReadOnlyList value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList<UnnamedSchemaWithArrayParent4> value) => {...} /// ); /// /// @@ -3445,7 +3445,7 @@ Action> mixed /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -3456,10 +3456,10 @@ Action> mixed /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...}, - /// (IReadOnlyList value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList<UnnamedSchemaWithArrayParent4> value) => {...} /// ); /// /// @@ -3672,7 +3672,7 @@ public UnnamedSchemaWithArrayParent4(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -3693,7 +3693,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -3714,7 +3714,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -3734,7 +3734,7 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -3745,9 +3745,9 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// /// instance.Switch( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} /// ); /// /// @@ -3776,7 +3776,7 @@ public void Switch(Action @string, Action @double, Action /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -3787,9 +3787,9 @@ public void Switch(Action @string, Action @double, Action /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} /// ); /// /// @@ -4269,7 +4269,7 @@ public OnYesSetMetadataValue(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -4290,7 +4290,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -4311,7 +4311,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -4330,14 +4330,14 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type where T is a UnnamedSchemaWithArrayParent5. /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickMixed(out var value)) { - /// // `value` is of type `IReadOnlyList` + /// // `value` is of type `IReadOnlyList<UnnamedSchemaWithArrayParent5>` /// Console.WriteLine(value); /// } /// @@ -4354,7 +4354,7 @@ public bool TryPickMixed( /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -4365,10 +4365,10 @@ public bool TryPickMixed( /// /// /// instance.Switch( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...}, - /// (IReadOnlyList value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList<UnnamedSchemaWithArrayParent5> value) => {...} /// ); /// /// @@ -4405,7 +4405,7 @@ Action> mixed /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -4416,10 +4416,10 @@ Action> mixed /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...}, - /// (IReadOnlyList value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList<UnnamedSchemaWithArrayParent5> value) => {...} /// ); /// /// @@ -4632,7 +4632,7 @@ public UnnamedSchemaWithArrayParent5(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -4653,7 +4653,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -4674,7 +4674,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -4694,7 +4694,7 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -4705,9 +4705,9 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// /// instance.Switch( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} /// ); /// /// @@ -4736,7 +4736,7 @@ public void Switch(Action @string, Action @double, Action /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -4747,9 +4747,9 @@ public void Switch(Action @string, Action @double, Action /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} /// ); /// /// diff --git a/src/ImageKit/Models/Files/Bulk/BulkAddTagsParams.cs b/src/ImageKit/Models/Files/Bulk/BulkAddTagsParams.cs index 433fb382..c7636f99 100644 --- a/src/ImageKit/Models/Files/Bulk/BulkAddTagsParams.cs +++ b/src/ImageKit/Models/Files/Bulk/BulkAddTagsParams.cs @@ -100,7 +100,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static BulkAddTagsParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, diff --git a/src/ImageKit/Models/Files/Bulk/BulkDeleteParams.cs b/src/ImageKit/Models/Files/Bulk/BulkDeleteParams.cs index edb69a31..b5bbb209 100644 --- a/src/ImageKit/Models/Files/Bulk/BulkDeleteParams.cs +++ b/src/ImageKit/Models/Files/Bulk/BulkDeleteParams.cs @@ -86,7 +86,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static BulkDeleteParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, diff --git a/src/ImageKit/Models/Files/Bulk/BulkRemoveAITagsParams.cs b/src/ImageKit/Models/Files/Bulk/BulkRemoveAITagsParams.cs index 86a1aaf7..817f5323 100644 --- a/src/ImageKit/Models/Files/Bulk/BulkRemoveAITagsParams.cs +++ b/src/ImageKit/Models/Files/Bulk/BulkRemoveAITagsParams.cs @@ -100,7 +100,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static BulkRemoveAITagsParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, diff --git a/src/ImageKit/Models/Files/Bulk/BulkRemoveTagsParams.cs b/src/ImageKit/Models/Files/Bulk/BulkRemoveTagsParams.cs index 19469d14..8a804308 100644 --- a/src/ImageKit/Models/Files/Bulk/BulkRemoveTagsParams.cs +++ b/src/ImageKit/Models/Files/Bulk/BulkRemoveTagsParams.cs @@ -100,7 +100,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static BulkRemoveTagsParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, diff --git a/src/ImageKit/Models/Files/File.cs b/src/ImageKit/Models/Files/File.cs index 29379a78..7a56692c 100644 --- a/src/ImageKit/Models/Files/File.cs +++ b/src/ImageKit/Models/Files/File.cs @@ -1008,7 +1008,7 @@ public IReadOnlyList? SelectOptions /// /// Specifies if the selectOptions array is truncated. It is truncated when number - /// of options are > 100. + /// of options are > 100. /// public bool? SelectOptionsTruncated { @@ -1211,7 +1211,7 @@ public DefaultValue(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1232,7 +1232,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1253,7 +1253,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1272,14 +1272,14 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type where T is a UnnamedSchemaWithArrayParent10. /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickMixed(out var value)) { - /// // `value` is of type `IReadOnlyList` + /// // `value` is of type `IReadOnlyList<UnnamedSchemaWithArrayParent10>` /// Console.WriteLine(value); /// } /// @@ -1296,7 +1296,7 @@ public bool TryPickMixed( /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1307,10 +1307,10 @@ public bool TryPickMixed( /// /// /// instance.Switch( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...}, - /// (IReadOnlyList value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList<UnnamedSchemaWithArrayParent10> value) => {...} /// ); /// /// @@ -1347,7 +1347,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1358,10 +1358,10 @@ public void Switch( /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...}, - /// (IReadOnlyList value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList<UnnamedSchemaWithArrayParent10> value) => {...} /// ); /// /// @@ -1573,7 +1573,7 @@ public UnnamedSchemaWithArrayParent10(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1594,7 +1594,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1615,7 +1615,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1635,7 +1635,7 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1646,9 +1646,9 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// /// instance.Switch( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} /// ); /// /// @@ -1681,7 +1681,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1692,9 +1692,9 @@ public void Switch( /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} /// ); /// /// @@ -1867,7 +1867,7 @@ public MaxValue(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1888,7 +1888,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1908,7 +1908,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1919,8 +1919,8 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// /// /// instance.Switch( - /// (string value) => {...}, - /// (double value) => {...} + /// (string value) => {...}, + /// (double value) => {...} /// ); /// /// @@ -1946,7 +1946,7 @@ public void Switch(System::Action @string, System::Action @doubl /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1957,8 +1957,8 @@ public void Switch(System::Action @string, System::Action @doubl /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (double value) => {...} + /// (string value) => {...}, + /// (double value) => {...} /// ); /// /// @@ -2108,7 +2108,7 @@ public MinValue(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2129,7 +2129,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2149,7 +2149,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -2160,8 +2160,8 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// /// /// instance.Switch( - /// (string value) => {...}, - /// (double value) => {...} + /// (string value) => {...}, + /// (double value) => {...} /// ); /// /// @@ -2187,7 +2187,7 @@ public void Switch(System::Action @string, System::Action @doubl /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -2198,8 +2198,8 @@ public void Switch(System::Action @string, System::Action @doubl /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (double value) => {...} + /// (string value) => {...}, + /// (double value) => {...} /// ); /// /// @@ -2350,7 +2350,7 @@ public SelectOption(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2371,7 +2371,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2392,7 +2392,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2412,7 +2412,7 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -2423,9 +2423,9 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// /// instance.Switch( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} /// ); /// /// @@ -2458,7 +2458,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -2469,9 +2469,9 @@ public void Switch( /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} /// ); /// /// diff --git a/src/ImageKit/Models/Files/FileCopyParams.cs b/src/ImageKit/Models/Files/FileCopyParams.cs index f753d543..b04dcf3f 100644 --- a/src/ImageKit/Models/Files/FileCopyParams.cs +++ b/src/ImageKit/Models/Files/FileCopyParams.cs @@ -113,7 +113,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static FileCopyParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, diff --git a/src/ImageKit/Models/Files/FileDeleteParams.cs b/src/ImageKit/Models/Files/FileDeleteParams.cs index b5ebe506..ffd598e5 100644 --- a/src/ImageKit/Models/Files/FileDeleteParams.cs +++ b/src/ImageKit/Models/Files/FileDeleteParams.cs @@ -55,7 +55,7 @@ FrozenDictionary rawQueryData } #pragma warning restore CS8618 - /// + /// public static FileDeleteParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData diff --git a/src/ImageKit/Models/Files/FileGetParams.cs b/src/ImageKit/Models/Files/FileGetParams.cs index 9e9c3f26..c14bd131 100644 --- a/src/ImageKit/Models/Files/FileGetParams.cs +++ b/src/ImageKit/Models/Files/FileGetParams.cs @@ -52,7 +52,7 @@ FrozenDictionary rawQueryData } #pragma warning restore CS8618 - /// + /// public static FileGetParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData diff --git a/src/ImageKit/Models/Files/FileMoveParams.cs b/src/ImageKit/Models/Files/FileMoveParams.cs index 1468d03e..01b7b2b8 100644 --- a/src/ImageKit/Models/Files/FileMoveParams.cs +++ b/src/ImageKit/Models/Files/FileMoveParams.cs @@ -89,7 +89,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static FileMoveParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, diff --git a/src/ImageKit/Models/Files/FileRenameParams.cs b/src/ImageKit/Models/Files/FileRenameParams.cs index d21b273c..87fd5d31 100644 --- a/src/ImageKit/Models/Files/FileRenameParams.cs +++ b/src/ImageKit/Models/Files/FileRenameParams.cs @@ -130,7 +130,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static FileRenameParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, diff --git a/src/ImageKit/Models/Files/FileUpdateParams.cs b/src/ImageKit/Models/Files/FileUpdateParams.cs index a7097a49..da3303af 100644 --- a/src/ImageKit/Models/Files/FileUpdateParams.cs +++ b/src/ImageKit/Models/Files/FileUpdateParams.cs @@ -79,7 +79,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static FileUpdateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, diff --git a/src/ImageKit/Models/Files/FileUploadParams.cs b/src/ImageKit/Models/Files/FileUploadParams.cs index 1ef2972a..2eeaf662 100644 --- a/src/ImageKit/Models/Files/FileUploadParams.cs +++ b/src/ImageKit/Models/Files/FileUploadParams.cs @@ -649,7 +649,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static FileUploadParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, @@ -969,7 +969,7 @@ public Post(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -990,7 +990,7 @@ public bool TryPickTransformation([NotNullWhen(true)] out PostTransformation? va /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1011,7 +1011,7 @@ public bool TryPickGifToVideo([NotNullWhen(true)] out GifToVideo? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1032,7 +1032,7 @@ public bool TryPickThumbnail([NotNullWhen(true)] out Thumbnail? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1052,7 +1052,7 @@ public bool TryPickAbs([NotNullWhen(true)] out Abs? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1063,10 +1063,10 @@ public bool TryPickAbs([NotNullWhen(true)] out Abs? value) /// /// /// instance.Switch( - /// (PostTransformation value) => {...}, - /// (GifToVideo value) => {...}, - /// (Thumbnail value) => {...}, - /// (Abs value) => {...} + /// (PostTransformation value) => {...}, + /// (GifToVideo value) => {...}, + /// (Thumbnail value) => {...}, + /// (Abs value) => {...} /// ); /// /// @@ -1101,7 +1101,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1112,10 +1112,10 @@ public void Switch( /// /// /// var result = instance.Match( - /// (PostTransformation value) => {...}, - /// (GifToVideo value) => {...}, - /// (Thumbnail value) => {...}, - /// (Abs value) => {...} + /// (PostTransformation value) => {...}, + /// (GifToVideo value) => {...}, + /// (Thumbnail value) => {...}, + /// (Abs value) => {...} /// ); /// /// diff --git a/src/ImageKit/Models/Files/FileUploadResponse.cs b/src/ImageKit/Models/Files/FileUploadResponse.cs index d5c35efc..dda141d3 100644 --- a/src/ImageKit/Models/Files/FileUploadResponse.cs +++ b/src/ImageKit/Models/Files/FileUploadResponse.cs @@ -1393,7 +1393,7 @@ public IReadOnlyList? Se /// /// Specifies if the selectOptions array is truncated. It is truncated when number - /// of options are > 100. + /// of options are > 100. /// public bool? SelectOptionsTruncated { @@ -1613,7 +1613,7 @@ public FileUploadResponseSelectedFieldsSchemaItemDefaultValue(JsonElement elemen /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1634,7 +1634,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1655,7 +1655,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1674,14 +1674,14 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type where T is a UnnamedSchemaWithArrayParent11. /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickMixed(out var value)) { - /// // `value` is of type `IReadOnlyList` + /// // `value` is of type `IReadOnlyList<UnnamedSchemaWithArrayParent11>` /// Console.WriteLine(value); /// } /// @@ -1698,7 +1698,7 @@ public bool TryPickMixed( /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1709,10 +1709,10 @@ public bool TryPickMixed( /// /// /// instance.Switch( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...}, - /// (IReadOnlyList value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList<UnnamedSchemaWithArrayParent11> value) => {...} /// ); /// /// @@ -1749,7 +1749,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1760,10 +1760,10 @@ public void Switch( /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...}, - /// (IReadOnlyList value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList<UnnamedSchemaWithArrayParent11> value) => {...} /// ); /// /// @@ -1983,7 +1983,7 @@ public UnnamedSchemaWithArrayParent11(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2004,7 +2004,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2025,7 +2025,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2045,7 +2045,7 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -2056,9 +2056,9 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// /// instance.Switch( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} /// ); /// /// @@ -2091,7 +2091,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -2102,9 +2102,9 @@ public void Switch( /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} /// ); /// /// @@ -2283,7 +2283,7 @@ public FileUploadResponseSelectedFieldsSchemaItemMaxValue(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2304,7 +2304,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2324,7 +2324,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -2335,8 +2335,8 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// /// /// instance.Switch( - /// (string value) => {...}, - /// (double value) => {...} + /// (string value) => {...}, + /// (double value) => {...} /// ); /// /// @@ -2362,7 +2362,7 @@ public void Switch(System::Action @string, System::Action @doubl /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -2373,8 +2373,8 @@ public void Switch(System::Action @string, System::Action @doubl /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (double value) => {...} + /// (string value) => {...}, + /// (double value) => {...} /// ); /// /// @@ -2541,7 +2541,7 @@ public FileUploadResponseSelectedFieldsSchemaItemMinValue(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2562,7 +2562,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2582,7 +2582,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -2593,8 +2593,8 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// /// /// instance.Switch( - /// (string value) => {...}, - /// (double value) => {...} + /// (string value) => {...}, + /// (double value) => {...} /// ); /// /// @@ -2620,7 +2620,7 @@ public void Switch(System::Action @string, System::Action @doubl /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -2631,8 +2631,8 @@ public void Switch(System::Action @string, System::Action @doubl /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (double value) => {...} + /// (string value) => {...}, + /// (double value) => {...} /// ); /// /// @@ -2803,7 +2803,7 @@ public FileUploadResponseSelectedFieldsSchemaItemSelectOption(JsonElement elemen /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2824,7 +2824,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2845,7 +2845,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2865,7 +2865,7 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -2876,9 +2876,9 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// /// instance.Switch( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} /// ); /// /// @@ -2911,7 +2911,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -2922,9 +2922,9 @@ public void Switch( /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} /// ); /// /// diff --git a/src/ImageKit/Models/Files/Metadata/MetadataGetFromUrlParams.cs b/src/ImageKit/Models/Files/Metadata/MetadataGetFromUrlParams.cs index 6b89b976..6260be3b 100644 --- a/src/ImageKit/Models/Files/Metadata/MetadataGetFromUrlParams.cs +++ b/src/ImageKit/Models/Files/Metadata/MetadataGetFromUrlParams.cs @@ -61,7 +61,7 @@ FrozenDictionary rawQueryData } #pragma warning restore CS8618 - /// + /// public static MetadataGetFromUrlParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData diff --git a/src/ImageKit/Models/Files/Metadata/MetadataGetParams.cs b/src/ImageKit/Models/Files/Metadata/MetadataGetParams.cs index c1e118fb..d9ff63f1 100644 --- a/src/ImageKit/Models/Files/Metadata/MetadataGetParams.cs +++ b/src/ImageKit/Models/Files/Metadata/MetadataGetParams.cs @@ -55,7 +55,7 @@ FrozenDictionary rawQueryData } #pragma warning restore CS8618 - /// + /// public static MetadataGetParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData diff --git a/src/ImageKit/Models/Files/UpdateFileRequest.cs b/src/ImageKit/Models/Files/UpdateFileRequest.cs index 5a90a49c..c99ace8c 100644 --- a/src/ImageKit/Models/Files/UpdateFileRequest.cs +++ b/src/ImageKit/Models/Files/UpdateFileRequest.cs @@ -52,7 +52,7 @@ public UpdateFileRequest(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -73,7 +73,7 @@ public bool TryPickDetails([NotNullWhen(true)] out UpdateFileDetails? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -95,7 +95,7 @@ public bool TryPickChangePublicationStatus( /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -106,8 +106,8 @@ public bool TryPickChangePublicationStatus( /// /// /// instance.Switch( - /// (UpdateFileDetails value) => {...}, - /// (ChangePublicationStatus value) => {...} + /// (UpdateFileDetails value) => {...}, + /// (ChangePublicationStatus value) => {...} /// ); /// /// @@ -136,7 +136,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -147,8 +147,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (UpdateFileDetails value) => {...}, - /// (ChangePublicationStatus value) => {...} + /// (UpdateFileDetails value) => {...}, + /// (ChangePublicationStatus value) => {...} /// ); /// /// @@ -539,14 +539,14 @@ public RemoveAITags(JsonElement element) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type where T is a string. /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickStrings(out var value)) { - /// // `value` is of type `IReadOnlyList` + /// // `value` is of type `IReadOnlyList<string>` /// Console.WriteLine(value); /// } /// @@ -562,7 +562,7 @@ public bool TryPickStrings([NotNullWhen(true)] out IReadOnlyList? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -582,7 +582,7 @@ public bool TryPickAll([NotNullWhen(true)] out UnionMember1? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -593,8 +593,8 @@ public bool TryPickAll([NotNullWhen(true)] out UnionMember1? value) /// /// /// instance.Switch( - /// (IReadOnlyList value) => {...}, - /// (UnionMember1 value) => {...} + /// (IReadOnlyList<string> value) => {...}, + /// (UnionMember1 value) => {...} /// ); /// /// @@ -623,7 +623,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -634,8 +634,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (IReadOnlyList value) => {...}, - /// (UnionMember1 value) => {...} + /// (IReadOnlyList<string> value) => {...}, + /// (UnionMember1 value) => {...} /// ); /// /// diff --git a/src/ImageKit/Models/Files/Versions/VersionDeleteParams.cs b/src/ImageKit/Models/Files/Versions/VersionDeleteParams.cs index 44386248..0a1fe22d 100644 --- a/src/ImageKit/Models/Files/Versions/VersionDeleteParams.cs +++ b/src/ImageKit/Models/Files/Versions/VersionDeleteParams.cs @@ -56,7 +56,7 @@ FrozenDictionary rawQueryData } #pragma warning restore CS8618 - /// + /// public static VersionDeleteParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData diff --git a/src/ImageKit/Models/Files/Versions/VersionGetParams.cs b/src/ImageKit/Models/Files/Versions/VersionGetParams.cs index e3d98310..aaf61c78 100644 --- a/src/ImageKit/Models/Files/Versions/VersionGetParams.cs +++ b/src/ImageKit/Models/Files/Versions/VersionGetParams.cs @@ -54,7 +54,7 @@ FrozenDictionary rawQueryData } #pragma warning restore CS8618 - /// + /// public static VersionGetParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData diff --git a/src/ImageKit/Models/Files/Versions/VersionListParams.cs b/src/ImageKit/Models/Files/Versions/VersionListParams.cs index fc659e77..e4214e02 100644 --- a/src/ImageKit/Models/Files/Versions/VersionListParams.cs +++ b/src/ImageKit/Models/Files/Versions/VersionListParams.cs @@ -51,7 +51,7 @@ FrozenDictionary rawQueryData } #pragma warning restore CS8618 - /// + /// public static VersionListParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData diff --git a/src/ImageKit/Models/Files/Versions/VersionRestoreParams.cs b/src/ImageKit/Models/Files/Versions/VersionRestoreParams.cs index f92b4ba4..d572b182 100644 --- a/src/ImageKit/Models/Files/Versions/VersionRestoreParams.cs +++ b/src/ImageKit/Models/Files/Versions/VersionRestoreParams.cs @@ -54,7 +54,7 @@ FrozenDictionary rawQueryData } #pragma warning restore CS8618 - /// + /// public static VersionRestoreParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData diff --git a/src/ImageKit/Models/Folders/FolderCopyParams.cs b/src/ImageKit/Models/Folders/FolderCopyParams.cs index df64d046..4a6961ad 100644 --- a/src/ImageKit/Models/Folders/FolderCopyParams.cs +++ b/src/ImageKit/Models/Folders/FolderCopyParams.cs @@ -114,7 +114,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static FolderCopyParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, diff --git a/src/ImageKit/Models/Folders/FolderCreateParams.cs b/src/ImageKit/Models/Folders/FolderCreateParams.cs index 324d2ec9..d693105b 100644 --- a/src/ImageKit/Models/Folders/FolderCreateParams.cs +++ b/src/ImageKit/Models/Folders/FolderCreateParams.cs @@ -97,7 +97,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static FolderCreateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, diff --git a/src/ImageKit/Models/Folders/FolderDeleteParams.cs b/src/ImageKit/Models/Folders/FolderDeleteParams.cs index 3a7ef551..488a012b 100644 --- a/src/ImageKit/Models/Folders/FolderDeleteParams.cs +++ b/src/ImageKit/Models/Folders/FolderDeleteParams.cs @@ -74,7 +74,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static FolderDeleteParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, diff --git a/src/ImageKit/Models/Folders/FolderMoveParams.cs b/src/ImageKit/Models/Folders/FolderMoveParams.cs index fc7f0536..bc0d0fe1 100644 --- a/src/ImageKit/Models/Folders/FolderMoveParams.cs +++ b/src/ImageKit/Models/Folders/FolderMoveParams.cs @@ -90,7 +90,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static FolderMoveParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, diff --git a/src/ImageKit/Models/Folders/FolderRenameParams.cs b/src/ImageKit/Models/Folders/FolderRenameParams.cs index af437fdd..6e37368c 100644 --- a/src/ImageKit/Models/Folders/FolderRenameParams.cs +++ b/src/ImageKit/Models/Folders/FolderRenameParams.cs @@ -127,7 +127,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static FolderRenameParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, diff --git a/src/ImageKit/Models/Folders/Job/JobGetParams.cs b/src/ImageKit/Models/Folders/Job/JobGetParams.cs index daf8d7d3..d4f17c7e 100644 --- a/src/ImageKit/Models/Folders/Job/JobGetParams.cs +++ b/src/ImageKit/Models/Folders/Job/JobGetParams.cs @@ -51,7 +51,7 @@ FrozenDictionary rawQueryData } #pragma warning restore CS8618 - /// + /// public static JobGetParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData diff --git a/src/ImageKit/Models/GetImageAttributesOptions.cs b/src/ImageKit/Models/GetImageAttributesOptions.cs index 72a8fbed..a4e2ef4e 100644 --- a/src/ImageKit/Models/GetImageAttributesOptions.cs +++ b/src/ImageKit/Models/GetImageAttributesOptions.cs @@ -10,8 +10,8 @@ namespace ImageKit.Models; /// /// Options for generating responsive image attributes including `src`, `srcSet`, -/// and `sizes` for HTML `` elements. This schema extends `SrcOptions` to add -/// support for responsive image generation with breakpoints. +/// and `sizes` for HTML `<img>` elements. This schema extends `SrcOptions` +/// to add support for responsive image generation with breakpoints. /// [JsonConverter( typeof(JsonModelConverter) diff --git a/src/ImageKit/Models/Overlay.cs b/src/ImageKit/Models/Overlay.cs index 6e3db454..144c6514 100644 --- a/src/ImageKit/Models/Overlay.cs +++ b/src/ImageKit/Models/Overlay.cs @@ -139,7 +139,7 @@ public Overlay(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -160,7 +160,7 @@ public bool TryPickText([NotNullWhen(true)] out TextOverlay? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -181,7 +181,7 @@ public bool TryPickImage([NotNullWhen(true)] out ImageOverlay? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -202,7 +202,7 @@ public bool TryPickVideo([NotNullWhen(true)] out VideoOverlay? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -223,7 +223,7 @@ public bool TryPickSubtitle([NotNullWhen(true)] out SubtitleOverlay? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -243,7 +243,7 @@ public bool TryPickSolidColor([NotNullWhen(true)] out SolidColorOverlay? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -254,11 +254,11 @@ public bool TryPickSolidColor([NotNullWhen(true)] out SolidColorOverlay? value) /// /// /// instance.Switch( - /// (TextOverlay value) => {...}, - /// (ImageOverlay value) => {...}, - /// (VideoOverlay value) => {...}, - /// (SubtitleOverlay value) => {...}, - /// (SolidColorOverlay value) => {...} + /// (TextOverlay value) => {...}, + /// (ImageOverlay value) => {...}, + /// (VideoOverlay value) => {...}, + /// (SubtitleOverlay value) => {...}, + /// (SolidColorOverlay value) => {...} /// ); /// /// @@ -297,7 +297,7 @@ Action solidColor /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -308,11 +308,11 @@ Action solidColor /// /// /// var result = instance.Match( - /// (TextOverlay value) => {...}, - /// (ImageOverlay value) => {...}, - /// (VideoOverlay value) => {...}, - /// (SubtitleOverlay value) => {...}, - /// (SolidColorOverlay value) => {...} + /// (TextOverlay value) => {...}, + /// (ImageOverlay value) => {...}, + /// (VideoOverlay value) => {...}, + /// (SubtitleOverlay value) => {...}, + /// (SolidColorOverlay value) => {...} /// ); /// /// diff --git a/src/ImageKit/Models/OverlayPosition.cs b/src/ImageKit/Models/OverlayPosition.cs index c01067c5..e4d94de8 100644 --- a/src/ImageKit/Models/OverlayPosition.cs +++ b/src/ImageKit/Models/OverlayPosition.cs @@ -235,7 +235,7 @@ public X(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -256,7 +256,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -276,7 +276,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -287,8 +287,8 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// /// instance.Switch( - /// (double value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -312,7 +312,7 @@ public void Switch(Action @double, Action @string) /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -323,8 +323,8 @@ public void Switch(Action @double, Action @string) /// /// /// var result = instance.Match( - /// (double value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -473,7 +473,7 @@ public Y(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -494,7 +494,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -514,7 +514,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -525,8 +525,8 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// /// instance.Switch( - /// (double value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -550,7 +550,7 @@ public void Switch(Action @double, Action @string) /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -561,8 +561,8 @@ public void Switch(Action @double, Action @string) /// /// /// var result = instance.Match( - /// (double value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (string value) => {...} /// ); /// /// diff --git a/src/ImageKit/Models/OverlayTiming.cs b/src/ImageKit/Models/OverlayTiming.cs index 86cdb1e8..7804df98 100644 --- a/src/ImageKit/Models/OverlayTiming.cs +++ b/src/ImageKit/Models/OverlayTiming.cs @@ -173,7 +173,7 @@ public Duration(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -194,7 +194,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -214,7 +214,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -225,8 +225,8 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// /// instance.Switch( - /// (double value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -252,7 +252,7 @@ public void Switch(Action @double, Action @string) /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -263,8 +263,8 @@ public void Switch(Action @double, Action @string) /// /// /// var result = instance.Match( - /// (double value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -416,7 +416,7 @@ public End(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -437,7 +437,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -457,7 +457,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -468,8 +468,8 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// /// instance.Switch( - /// (double value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -493,7 +493,7 @@ public void Switch(Action @double, Action @string) /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -504,8 +504,8 @@ public void Switch(Action @double, Action @string) /// /// /// var result = instance.Match( - /// (double value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -654,7 +654,7 @@ public Start(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -675,7 +675,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -695,7 +695,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -706,8 +706,8 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// /// instance.Switch( - /// (double value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -731,7 +731,7 @@ public void Switch(Action @double, Action @string) /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -742,8 +742,8 @@ public void Switch(Action @double, Action @string) /// /// /// var result = instance.Match( - /// (double value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (string value) => {...} /// ); /// /// diff --git a/src/ImageKit/Models/ResponsiveImageAttributes.cs b/src/ImageKit/Models/ResponsiveImageAttributes.cs index 33504439..840f18f4 100644 --- a/src/ImageKit/Models/ResponsiveImageAttributes.cs +++ b/src/ImageKit/Models/ResponsiveImageAttributes.cs @@ -8,8 +8,8 @@ namespace ImageKit.Models; /// -/// Resulting set of attributes suitable for an HTML `` element. Useful for -/// enabling responsive image loading with `srcSet` and `sizes`. +/// Resulting set of attributes suitable for an HTML `<img>` element. Useful +/// for enabling responsive image loading with `srcSet` and `sizes`. /// [JsonConverter( typeof(JsonModelConverter) diff --git a/src/ImageKit/Models/SavedExtensions/SavedExtensionCreateParams.cs b/src/ImageKit/Models/SavedExtensions/SavedExtensionCreateParams.cs index 24b770da..f525e2a4 100644 --- a/src/ImageKit/Models/SavedExtensions/SavedExtensionCreateParams.cs +++ b/src/ImageKit/Models/SavedExtensions/SavedExtensionCreateParams.cs @@ -104,7 +104,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static SavedExtensionCreateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, diff --git a/src/ImageKit/Models/SavedExtensions/SavedExtensionDeleteParams.cs b/src/ImageKit/Models/SavedExtensions/SavedExtensionDeleteParams.cs index 8c3b4139..3607d1e3 100644 --- a/src/ImageKit/Models/SavedExtensions/SavedExtensionDeleteParams.cs +++ b/src/ImageKit/Models/SavedExtensions/SavedExtensionDeleteParams.cs @@ -51,7 +51,7 @@ FrozenDictionary rawQueryData } #pragma warning restore CS8618 - /// + /// public static SavedExtensionDeleteParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData diff --git a/src/ImageKit/Models/SavedExtensions/SavedExtensionGetParams.cs b/src/ImageKit/Models/SavedExtensions/SavedExtensionGetParams.cs index 938c565e..6fdd4e0a 100644 --- a/src/ImageKit/Models/SavedExtensions/SavedExtensionGetParams.cs +++ b/src/ImageKit/Models/SavedExtensions/SavedExtensionGetParams.cs @@ -51,7 +51,7 @@ FrozenDictionary rawQueryData } #pragma warning restore CS8618 - /// + /// public static SavedExtensionGetParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData diff --git a/src/ImageKit/Models/SavedExtensions/SavedExtensionListParams.cs b/src/ImageKit/Models/SavedExtensions/SavedExtensionListParams.cs index c80b7447..917c1108 100644 --- a/src/ImageKit/Models/SavedExtensions/SavedExtensionListParams.cs +++ b/src/ImageKit/Models/SavedExtensions/SavedExtensionListParams.cs @@ -48,7 +48,7 @@ FrozenDictionary rawQueryData } #pragma warning restore CS8618 - /// + /// public static SavedExtensionListParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData diff --git a/src/ImageKit/Models/SavedExtensions/SavedExtensionUpdateParams.cs b/src/ImageKit/Models/SavedExtensions/SavedExtensionUpdateParams.cs index d7c05310..3920c278 100644 --- a/src/ImageKit/Models/SavedExtensions/SavedExtensionUpdateParams.cs +++ b/src/ImageKit/Models/SavedExtensions/SavedExtensionUpdateParams.cs @@ -128,7 +128,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static SavedExtensionUpdateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, diff --git a/src/ImageKit/Models/SolidColorOverlayTransformation.cs b/src/ImageKit/Models/SolidColorOverlayTransformation.cs index 0ba07584..c8e1e310 100644 --- a/src/ImageKit/Models/SolidColorOverlayTransformation.cs +++ b/src/ImageKit/Models/SolidColorOverlayTransformation.cs @@ -249,7 +249,7 @@ public Gradient(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -270,7 +270,7 @@ public bool TryPickTrue([NotNullWhen(true)] out UnionMember0? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -290,7 +290,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -301,8 +301,8 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// /// instance.Switch( - /// (UnionMember0 value) => {...}, - /// (string value) => {...} + /// (UnionMember0 value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -328,7 +328,7 @@ public void Switch(Action true_, Action @string) /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -339,8 +339,8 @@ public void Switch(Action true_, Action @string) /// /// /// var result = instance.Match( - /// (UnionMember0 value) => {...}, - /// (string value) => {...} + /// (UnionMember0 value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -564,7 +564,7 @@ public Height(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -585,7 +585,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -605,7 +605,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -616,8 +616,8 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// /// instance.Switch( - /// (double value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -641,7 +641,7 @@ public void Switch(Action @double, Action @string) /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -652,8 +652,8 @@ public void Switch(Action @double, Action @string) /// /// /// var result = instance.Match( - /// (double value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -809,7 +809,7 @@ public Radius(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -830,7 +830,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -851,7 +851,7 @@ public bool TryPickMax([NotNullWhen(true)] out UnionMember1? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -871,7 +871,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -882,9 +882,9 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// /// instance.Switch( - /// (double value) => {...}, - /// (UnionMember1 value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (UnionMember1 value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -911,7 +911,7 @@ public void Switch(Action @double, Action max, ActionUse the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -922,9 +922,9 @@ public void Switch(Action @double, Action max, Action /// /// var result = instance.Match( - /// (double value) => {...}, - /// (UnionMember1 value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (UnionMember1 value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -1160,7 +1160,7 @@ public Width(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1181,7 +1181,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1201,7 +1201,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1212,8 +1212,8 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// /// instance.Switch( - /// (double value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -1237,7 +1237,7 @@ public void Switch(Action @double, Action @string) /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1248,8 +1248,8 @@ public void Switch(Action @double, Action @string) /// /// /// var result = instance.Match( - /// (double value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (string value) => {...} /// ); /// /// diff --git a/src/ImageKit/Models/TextOverlayTransformation.cs b/src/ImageKit/Models/TextOverlayTransformation.cs index 431aeb8a..7af21dad 100644 --- a/src/ImageKit/Models/TextOverlayTransformation.cs +++ b/src/ImageKit/Models/TextOverlayTransformation.cs @@ -462,7 +462,7 @@ public FontSize(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -483,7 +483,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -503,7 +503,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -514,8 +514,8 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// /// instance.Switch( - /// (double value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -541,7 +541,7 @@ public void Switch(Action @double, Action @string) /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -552,8 +552,8 @@ public void Switch(Action @double, Action @string) /// /// /// var result = instance.Match( - /// (double value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -753,7 +753,7 @@ public LineHeight(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -774,7 +774,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -794,7 +794,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -805,8 +805,8 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// /// instance.Switch( - /// (double value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -832,7 +832,7 @@ public void Switch(Action @double, Action @string) /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -843,8 +843,8 @@ public void Switch(Action @double, Action @string) /// /// /// var result = instance.Match( - /// (double value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -998,7 +998,7 @@ public Padding(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1019,7 +1019,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1039,7 +1039,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1050,8 +1050,8 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// /// instance.Switch( - /// (double value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -1075,7 +1075,7 @@ public void Switch(Action @double, Action @string) /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1086,8 +1086,8 @@ public void Switch(Action @double, Action @string) /// /// /// var result = instance.Match( - /// (double value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -1248,7 +1248,7 @@ public TextOverlayTransformationRadius(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1269,7 +1269,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1292,7 +1292,7 @@ public bool TryPickMax( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1312,7 +1312,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1323,9 +1323,9 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// /// instance.Switch( - /// (double value) => {...}, - /// (TextOverlayTransformationRadiusUnionMember1 value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (TextOverlayTransformationRadiusUnionMember1 value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -1358,7 +1358,7 @@ Action @string /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1369,9 +1369,9 @@ Action @string /// /// /// var result = instance.Match( - /// (double value) => {...}, - /// (TextOverlayTransformationRadiusUnionMember1 value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (TextOverlayTransformationRadiusUnionMember1 value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -1628,7 +1628,7 @@ public Rotation(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1649,7 +1649,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1669,7 +1669,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1680,8 +1680,8 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// /// instance.Switch( - /// (double value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -1707,7 +1707,7 @@ public void Switch(Action @double, Action @string) /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1718,8 +1718,8 @@ public void Switch(Action @double, Action @string) /// /// /// var result = instance.Match( - /// (double value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -1869,7 +1869,7 @@ public TextOverlayTransformationWidth(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1890,7 +1890,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1910,7 +1910,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1921,8 +1921,8 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// /// instance.Switch( - /// (double value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -1948,7 +1948,7 @@ public void Switch(Action @double, Action @string) /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1959,8 +1959,8 @@ public void Switch(Action @double, Action @string) /// /// /// var result = instance.Match( - /// (double value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (string value) => {...} /// ); /// /// diff --git a/src/ImageKit/Models/Transformation.cs b/src/ImageKit/Models/Transformation.cs index 6ec3bf5e..092f9d26 100644 --- a/src/ImageKit/Models/Transformation.cs +++ b/src/ImageKit/Models/Transformation.cs @@ -310,7 +310,7 @@ public double? Blur } /// - /// Adds a border to the output media. Accepts a string in the format `_` + /// Adds a border to the output media. Accepts a string in the format `<border-width>_<hex-code>` /// (e.g., `5_FFF000` for a 5px yellow border), or an expression like `ih_div_20_FF00FF`. /// See [Border](https://imagekit.io/docs/effects-and-enhancements#border---b). /// @@ -405,7 +405,7 @@ public ApiEnum? ContrastStretch } /// - /// Crop modes for image resizing. See [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). + /// Crop modes for image resizing. See [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). /// public ApiEnum? Crop { @@ -426,7 +426,7 @@ public ApiEnum? Crop } /// - /// Additional crop modes for image resizing. See [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). + /// Additional crop modes for image resizing. See [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). /// public ApiEnum? CropMode { @@ -1256,7 +1256,7 @@ public YCenter? YCenter /// /// Accepts a numeric value that determines how much to zoom in or out of the - /// cropped area. It should be used in conjunction with fo-face or fo-. + /// cropped area. It should be used in conjunction with fo-face or fo-<object_name>. /// See [Zoom](https://imagekit.io/docs/image-resize-and-crop#zoom---z). /// public double? Zoom @@ -1420,7 +1420,7 @@ public AIDropShadow(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1441,7 +1441,7 @@ public bool TryPickTrue([NotNullWhen(true)] out AIDropShadowUnionMember0? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1461,7 +1461,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1472,8 +1472,8 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// /// instance.Switch( - /// (AIDropShadowUnionMember0 value) => {...}, - /// (string value) => {...} + /// (AIDropShadowUnionMember0 value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -1499,7 +1499,7 @@ public void Switch(Action true_, Action @strin /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1510,8 +1510,8 @@ public void Switch(Action true_, Action @strin /// /// /// var result = instance.Match( - /// (AIDropShadowUnionMember0 value) => {...}, - /// (string value) => {...} + /// (AIDropShadowUnionMember0 value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -1975,7 +1975,7 @@ public AspectRatio(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1996,7 +1996,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2016,7 +2016,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -2027,8 +2027,8 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// /// instance.Switch( - /// (double value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -2054,7 +2054,7 @@ public void Switch(Action @double, Action @string) /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -2065,8 +2065,8 @@ public void Switch(Action @double, Action @string) /// /// /// var result = instance.Match( - /// (double value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -2272,7 +2272,7 @@ JsonSerializerOptions options } /// -/// Crop modes for image resizing. See [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). +/// Crop modes for image resizing. See [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). /// [JsonConverter(typeof(CropConverter))] public enum Crop @@ -2324,7 +2324,7 @@ public override void Write(Utf8JsonWriter writer, Crop value, JsonSerializerOpti } /// -/// Additional crop modes for image resizing. See [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). +/// Additional crop modes for image resizing. See [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). /// [JsonConverter(typeof(CropModeConverter))] public enum CropMode @@ -2413,7 +2413,7 @@ public TransformationDuration(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2434,7 +2434,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2454,7 +2454,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -2465,8 +2465,8 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// /// instance.Switch( - /// (double value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -2492,7 +2492,7 @@ public void Switch(Action @double, Action @string) /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -2503,8 +2503,8 @@ public void Switch(Action @double, Action @string) /// /// /// var result = instance.Match( - /// (double value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -2660,7 +2660,7 @@ public EndOffset(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2681,7 +2681,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2701,7 +2701,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -2712,8 +2712,8 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// /// instance.Switch( - /// (double value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -2739,7 +2739,7 @@ public void Switch(Action @double, Action @string) /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -2750,8 +2750,8 @@ public void Switch(Action @double, Action @string) /// /// /// var result = instance.Match( - /// (double value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -3037,7 +3037,7 @@ public TransformationGradient(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -3058,7 +3058,7 @@ public bool TryPickTrue([NotNullWhen(true)] out TransformationGradientUnionMembe /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -3078,7 +3078,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -3089,8 +3089,8 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// /// instance.Switch( - /// (TransformationGradientUnionMember0 value) => {...}, - /// (string value) => {...} + /// (TransformationGradientUnionMember0 value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -3116,7 +3116,7 @@ public void Switch(Action true_, ActionUse the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -3127,8 +3127,8 @@ public void Switch(Action true_, Action /// /// var result = instance.Match( - /// (TransformationGradientUnionMember0 value) => {...}, - /// (string value) => {...} + /// (TransformationGradientUnionMember0 value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -3412,7 +3412,7 @@ public TransformationHeight(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -3433,7 +3433,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -3453,7 +3453,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -3464,8 +3464,8 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// /// instance.Switch( - /// (double value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -3491,7 +3491,7 @@ public void Switch(Action @double, Action @string) /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -3502,8 +3502,8 @@ public void Switch(Action @double, Action @string) /// /// /// var result = instance.Match( - /// (double value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -3660,7 +3660,7 @@ public Page(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -3681,7 +3681,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -3701,7 +3701,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -3712,8 +3712,8 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// /// instance.Switch( - /// (double value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -3737,7 +3737,7 @@ public void Switch(Action @double, Action @string) /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -3748,8 +3748,8 @@ public void Switch(Action @double, Action @string) /// /// /// var result = instance.Match( - /// (double value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -3905,7 +3905,7 @@ public TransformationRadius(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -3926,7 +3926,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -3947,7 +3947,7 @@ public bool TryPickMax([NotNullWhen(true)] out TransformationRadiusUnionMember1? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -3967,7 +3967,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -3978,9 +3978,9 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// /// instance.Switch( - /// (double value) => {...}, - /// (TransformationRadiusUnionMember1 value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (TransformationRadiusUnionMember1 value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -4013,7 +4013,7 @@ Action @string /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -4024,9 +4024,9 @@ Action @string /// /// /// var result = instance.Match( - /// (double value) => {...}, - /// (TransformationRadiusUnionMember1 value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (TransformationRadiusUnionMember1 value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -4281,7 +4281,7 @@ public TransformationRotation(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -4302,7 +4302,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -4322,7 +4322,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -4333,8 +4333,8 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// /// instance.Switch( - /// (double value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -4360,7 +4360,7 @@ public void Switch(Action @double, Action @string) /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -4371,8 +4371,8 @@ public void Switch(Action @double, Action @string) /// /// /// var result = instance.Match( - /// (double value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -4528,7 +4528,7 @@ public Shadow(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -4549,7 +4549,7 @@ public bool TryPickTrue([NotNullWhen(true)] out ShadowUnionMember0? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -4569,7 +4569,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -4580,8 +4580,8 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// /// instance.Switch( - /// (ShadowUnionMember0 value) => {...}, - /// (string value) => {...} + /// (ShadowUnionMember0 value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -4605,7 +4605,7 @@ public void Switch(Action true_, Action @string) /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -4616,8 +4616,8 @@ public void Switch(Action true_, Action @string) /// /// /// var result = instance.Match( - /// (ShadowUnionMember0 value) => {...}, - /// (string value) => {...} + /// (ShadowUnionMember0 value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -4839,7 +4839,7 @@ public Sharpen(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -4860,7 +4860,7 @@ public bool TryPickTrue([NotNullWhen(true)] out SharpenUnionMember0? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -4880,7 +4880,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -4891,8 +4891,8 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// /// /// instance.Switch( - /// (SharpenUnionMember0 value) => {...}, - /// (double value) => {...} + /// (SharpenUnionMember0 value) => {...}, + /// (double value) => {...} /// ); /// /// @@ -4916,7 +4916,7 @@ public void Switch(Action true_, Action @double) /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -4927,8 +4927,8 @@ public void Switch(Action true_, Action @double) /// /// /// var result = instance.Match( - /// (SharpenUnionMember0 value) => {...}, - /// (double value) => {...} + /// (SharpenUnionMember0 value) => {...}, + /// (double value) => {...} /// ); /// /// @@ -5148,7 +5148,7 @@ public StartOffset(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -5169,7 +5169,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -5189,7 +5189,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -5200,8 +5200,8 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// /// instance.Switch( - /// (double value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -5227,7 +5227,7 @@ public void Switch(Action @double, Action @string) /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -5238,8 +5238,8 @@ public void Switch(Action @double, Action @string) /// /// /// var result = instance.Match( - /// (double value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -5393,7 +5393,7 @@ public Trim(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -5414,7 +5414,7 @@ public bool TryPickTrue([NotNullWhen(true)] out TrimUnionMember0? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -5434,7 +5434,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -5445,8 +5445,8 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// /// /// instance.Switch( - /// (TrimUnionMember0 value) => {...}, - /// (double value) => {...} + /// (TrimUnionMember0 value) => {...}, + /// (double value) => {...} /// ); /// /// @@ -5470,7 +5470,7 @@ public void Switch(Action true_, Action @double) /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -5481,8 +5481,8 @@ public void Switch(Action true_, Action @double) /// /// /// var result = instance.Match( - /// (TrimUnionMember0 value) => {...}, - /// (double value) => {...} + /// (TrimUnionMember0 value) => {...}, + /// (double value) => {...} /// ); /// /// @@ -5701,7 +5701,7 @@ public UnsharpMask(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -5722,7 +5722,7 @@ public bool TryPickTrue([NotNullWhen(true)] out UnsharpMaskUnionMember0? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -5742,7 +5742,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -5753,8 +5753,8 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// /// instance.Switch( - /// (UnsharpMaskUnionMember0 value) => {...}, - /// (string value) => {...} + /// (UnsharpMaskUnionMember0 value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -5780,7 +5780,7 @@ public void Switch(Action true_, Action @string /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -5791,8 +5791,8 @@ public void Switch(Action true_, Action @string /// /// /// var result = instance.Match( - /// (UnsharpMaskUnionMember0 value) => {...}, - /// (string value) => {...} + /// (UnsharpMaskUnionMember0 value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -6080,7 +6080,7 @@ public TransformationWidth(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -6101,7 +6101,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -6121,7 +6121,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -6132,8 +6132,8 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// /// instance.Switch( - /// (double value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -6159,7 +6159,7 @@ public void Switch(Action @double, Action @string) /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -6170,8 +6170,8 @@ public void Switch(Action @double, Action @string) /// /// /// var result = instance.Match( - /// (double value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -6325,7 +6325,7 @@ public TransformationX(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -6346,7 +6346,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -6366,7 +6366,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -6377,8 +6377,8 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// /// instance.Switch( - /// (double value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -6404,7 +6404,7 @@ public void Switch(Action @double, Action @string) /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -6415,8 +6415,8 @@ public void Switch(Action @double, Action @string) /// /// /// var result = instance.Match( - /// (double value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -6571,7 +6571,7 @@ public XCenter(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -6592,7 +6592,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -6612,7 +6612,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -6623,8 +6623,8 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// /// instance.Switch( - /// (double value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -6648,7 +6648,7 @@ public void Switch(Action @double, Action @string) /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -6659,8 +6659,8 @@ public void Switch(Action @double, Action @string) /// /// /// var result = instance.Match( - /// (double value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -6808,7 +6808,7 @@ public TransformationY(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -6829,7 +6829,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -6849,7 +6849,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -6860,8 +6860,8 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// /// instance.Switch( - /// (double value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -6887,7 +6887,7 @@ public void Switch(Action @double, Action @string) /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -6898,8 +6898,8 @@ public void Switch(Action @double, Action @string) /// /// /// var result = instance.Match( - /// (double value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -7054,7 +7054,7 @@ public YCenter(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -7075,7 +7075,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -7095,7 +7095,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -7106,8 +7106,8 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// /// instance.Switch( - /// (double value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (string value) => {...} /// ); /// /// @@ -7131,7 +7131,7 @@ public void Switch(Action @double, Action @string) /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -7142,8 +7142,8 @@ public void Switch(Action @double, Action @string) /// /// /// var result = instance.Match( - /// (double value) => {...}, - /// (string value) => {...} + /// (double value) => {...}, + /// (string value) => {...} /// ); /// /// diff --git a/src/ImageKit/Models/UnnamedSchemaWithArrayParent0.cs b/src/ImageKit/Models/UnnamedSchemaWithArrayParent0.cs index 24296fa1..6a9eb639 100644 --- a/src/ImageKit/Models/UnnamedSchemaWithArrayParent0.cs +++ b/src/ImageKit/Models/UnnamedSchemaWithArrayParent0.cs @@ -79,7 +79,7 @@ public UnnamedSchemaWithArrayParent0(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -102,7 +102,7 @@ public bool TryPickRemoveBg( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -125,7 +125,7 @@ public bool TryPickAutoTaggingExtension( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -148,7 +148,7 @@ public bool TryPickAIAutoDescription( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -169,7 +169,7 @@ public bool TryPickAITasks([NotNullWhen(true)] out UnnamedSchemaWithArrayParent0 /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -189,7 +189,7 @@ public bool TryPickSavedExtension([NotNullWhen(true)] out SavedExtension? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -200,11 +200,11 @@ public bool TryPickSavedExtension([NotNullWhen(true)] out SavedExtension? value) /// /// /// instance.Switch( - /// (UnnamedSchemaWithArrayParent0RemoveBg value) => {...}, - /// (UnnamedSchemaWithArrayParent0AutoTaggingExtension value) => {...}, - /// (UnnamedSchemaWithArrayParent0AIAutoDescription value) => {...}, - /// (UnnamedSchemaWithArrayParent0AITasks value) => {...}, - /// (SavedExtension value) => {...} + /// (UnnamedSchemaWithArrayParent0RemoveBg value) => {...}, + /// (UnnamedSchemaWithArrayParent0AutoTaggingExtension value) => {...}, + /// (UnnamedSchemaWithArrayParent0AIAutoDescription value) => {...}, + /// (UnnamedSchemaWithArrayParent0AITasks value) => {...}, + /// (SavedExtension value) => {...} /// ); /// /// @@ -245,7 +245,7 @@ Action savedExtension /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -256,11 +256,11 @@ Action savedExtension /// /// /// var result = instance.Match( - /// (UnnamedSchemaWithArrayParent0RemoveBg value) => {...}, - /// (UnnamedSchemaWithArrayParent0AutoTaggingExtension value) => {...}, - /// (UnnamedSchemaWithArrayParent0AIAutoDescription value) => {...}, - /// (UnnamedSchemaWithArrayParent0AITasks value) => {...}, - /// (SavedExtension value) => {...} + /// (UnnamedSchemaWithArrayParent0RemoveBg value) => {...}, + /// (UnnamedSchemaWithArrayParent0AutoTaggingExtension value) => {...}, + /// (UnnamedSchemaWithArrayParent0AIAutoDescription value) => {...}, + /// (UnnamedSchemaWithArrayParent0AITasks value) => {...}, + /// (SavedExtension value) => {...} /// ); /// /// @@ -1190,7 +1190,7 @@ public UnnamedSchemaWithArrayParent0AITasksTask(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1213,7 +1213,7 @@ public bool TryPickSelectTags( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1236,7 +1236,7 @@ public bool TryPickSelectMetadata( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1258,7 +1258,7 @@ public bool TryPickYesNo( /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1269,9 +1269,9 @@ public bool TryPickYesNo( /// /// /// instance.Switch( - /// (UnnamedSchemaWithArrayParent0AITasksTaskSelectTags value) => {...}, - /// (UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata value) => {...}, - /// (UnnamedSchemaWithArrayParent0AITasksTaskYesNo value) => {...} + /// (UnnamedSchemaWithArrayParent0AITasksTaskSelectTags value) => {...}, + /// (UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata value) => {...}, + /// (UnnamedSchemaWithArrayParent0AITasksTaskYesNo value) => {...} /// ); /// /// @@ -1304,7 +1304,7 @@ Action yesNo /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1315,9 +1315,9 @@ Action yesNo /// /// /// var result = instance.Match( - /// (UnnamedSchemaWithArrayParent0AITasksTaskSelectTags value) => {...}, - /// (UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata value) => {...}, - /// (UnnamedSchemaWithArrayParent0AITasksTaskYesNo value) => {...} + /// (UnnamedSchemaWithArrayParent0AITasksTaskSelectTags value) => {...}, + /// (UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata value) => {...}, + /// (UnnamedSchemaWithArrayParent0AITasksTaskYesNo value) => {...} /// ); /// /// @@ -1919,7 +1919,7 @@ public UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabulary(JsonElem /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1940,7 +1940,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1961,7 +1961,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1981,7 +1981,7 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1992,9 +1992,9 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// /// instance.Switch( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} /// ); /// /// @@ -2023,7 +2023,7 @@ public void Switch(Action @string, Action @double, Action /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -2034,9 +2034,9 @@ public void Switch(Action @string, Action @double, Action /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} /// ); /// /// @@ -2666,7 +2666,7 @@ public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue(JsonEle /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2687,7 +2687,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2708,7 +2708,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2727,14 +2727,14 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type where T is a UnnamedSchemaWithArrayParent6. /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickMixed(out var value)) { - /// // `value` is of type `IReadOnlyList` + /// // `value` is of type `IReadOnlyList<UnnamedSchemaWithArrayParent6>` /// Console.WriteLine(value); /// } /// @@ -2751,7 +2751,7 @@ public bool TryPickMixed( /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -2762,10 +2762,10 @@ public bool TryPickMixed( /// /// /// instance.Switch( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...}, - /// (IReadOnlyList value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList<UnnamedSchemaWithArrayParent6> value) => {...} /// ); /// /// @@ -2802,7 +2802,7 @@ Action> mixed /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -2813,10 +2813,10 @@ Action> mixed /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...}, - /// (IReadOnlyList value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList<UnnamedSchemaWithArrayParent6> value) => {...} /// ); /// /// @@ -3038,7 +3038,7 @@ public UnnamedSchemaWithArrayParent6(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -3059,7 +3059,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -3080,7 +3080,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -3100,7 +3100,7 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -3111,9 +3111,9 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// /// instance.Switch( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} /// ); /// /// @@ -3142,7 +3142,7 @@ public void Switch(Action @string, Action @double, Action /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -3153,9 +3153,9 @@ public void Switch(Action @string, Action @double, Action /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} /// ); /// /// @@ -3694,7 +3694,7 @@ JsonElement element /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -3715,7 +3715,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -3736,7 +3736,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -3755,14 +3755,14 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type where T is a UnnamedSchemaWithArrayParent7. /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickMixed(out var value)) { - /// // `value` is of type `IReadOnlyList` + /// // `value` is of type `IReadOnlyList<UnnamedSchemaWithArrayParent7>` /// Console.WriteLine(value); /// } /// @@ -3779,7 +3779,7 @@ public bool TryPickMixed( /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -3790,10 +3790,10 @@ public bool TryPickMixed( /// /// /// instance.Switch( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...}, - /// (IReadOnlyList value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList<UnnamedSchemaWithArrayParent7> value) => {...} /// ); /// /// @@ -3830,7 +3830,7 @@ Action> mixed /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -3841,10 +3841,10 @@ Action> mixed /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...}, - /// (IReadOnlyList value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList<UnnamedSchemaWithArrayParent7> value) => {...} /// ); /// /// @@ -4066,7 +4066,7 @@ public UnnamedSchemaWithArrayParent7(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -4087,7 +4087,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -4108,7 +4108,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -4128,7 +4128,7 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -4139,9 +4139,9 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// /// instance.Switch( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} /// ); /// /// @@ -4170,7 +4170,7 @@ public void Switch(Action @string, Action @double, Action /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -4181,9 +4181,9 @@ public void Switch(Action @string, Action @double, Action /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} /// ); /// /// @@ -4718,7 +4718,7 @@ public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue(JsonEl /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -4739,7 +4739,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -4760,7 +4760,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -4779,14 +4779,14 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type where T is a UnnamedSchemaWithArrayParent8. /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickMixed(out var value)) { - /// // `value` is of type `IReadOnlyList` + /// // `value` is of type `IReadOnlyList<UnnamedSchemaWithArrayParent8>` /// Console.WriteLine(value); /// } /// @@ -4803,7 +4803,7 @@ public bool TryPickMixed( /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -4814,10 +4814,10 @@ public bool TryPickMixed( /// /// /// instance.Switch( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...}, - /// (IReadOnlyList value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList<UnnamedSchemaWithArrayParent8> value) => {...} /// ); /// /// @@ -4854,7 +4854,7 @@ Action> mixed /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -4865,10 +4865,10 @@ Action> mixed /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...}, - /// (IReadOnlyList value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList<UnnamedSchemaWithArrayParent8> value) => {...} /// ); /// /// @@ -5090,7 +5090,7 @@ public UnnamedSchemaWithArrayParent8(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -5111,7 +5111,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -5132,7 +5132,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -5152,7 +5152,7 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -5163,9 +5163,9 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// /// instance.Switch( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} /// ); /// /// @@ -5194,7 +5194,7 @@ public void Switch(Action @string, Action @double, Action /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -5205,9 +5205,9 @@ public void Switch(Action @string, Action @double, Action /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} /// ); /// /// diff --git a/src/ImageKit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs b/src/ImageKit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs index 81e68557..662da824 100644 --- a/src/ImageKit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs +++ b/src/ImageKit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs @@ -147,7 +147,7 @@ public UnsafeUnwrapWebhookEvent(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -170,7 +170,7 @@ public bool TryPickVideoTransformationAccepted( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -193,7 +193,7 @@ public bool TryPickVideoTransformationReady( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -216,7 +216,7 @@ public bool TryPickVideoTransformationError( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -239,7 +239,7 @@ public bool TryPickUploadPreTransformSuccess( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -262,7 +262,7 @@ public bool TryPickUploadPreTransformError( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -285,7 +285,7 @@ public bool TryPickUploadPostTransformSuccess( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -307,7 +307,7 @@ public bool TryPickUploadPostTransformError( /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -318,13 +318,13 @@ public bool TryPickUploadPostTransformError( /// /// /// instance.Switch( - /// (VideoTransformationAcceptedEvent value) => {...}, - /// (VideoTransformationReadyEvent value) => {...}, - /// (VideoTransformationErrorEvent value) => {...}, - /// (UploadPreTransformSuccessEvent value) => {...}, - /// (UploadPreTransformErrorEvent value) => {...}, - /// (UploadPostTransformSuccessEvent value) => {...}, - /// (UploadPostTransformErrorEvent value) => {...} + /// (VideoTransformationAcceptedEvent value) => {...}, + /// (VideoTransformationReadyEvent value) => {...}, + /// (VideoTransformationErrorEvent value) => {...}, + /// (UploadPreTransformSuccessEvent value) => {...}, + /// (UploadPreTransformErrorEvent value) => {...}, + /// (UploadPostTransformSuccessEvent value) => {...}, + /// (UploadPostTransformErrorEvent value) => {...} /// ); /// /// @@ -373,7 +373,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -384,13 +384,13 @@ public void Switch( /// /// /// var result = instance.Match( - /// (VideoTransformationAcceptedEvent value) => {...}, - /// (VideoTransformationReadyEvent value) => {...}, - /// (VideoTransformationErrorEvent value) => {...}, - /// (UploadPreTransformSuccessEvent value) => {...}, - /// (UploadPreTransformErrorEvent value) => {...}, - /// (UploadPostTransformSuccessEvent value) => {...}, - /// (UploadPostTransformErrorEvent value) => {...} + /// (VideoTransformationAcceptedEvent value) => {...}, + /// (VideoTransformationReadyEvent value) => {...}, + /// (VideoTransformationErrorEvent value) => {...}, + /// (UploadPreTransformSuccessEvent value) => {...}, + /// (UploadPreTransformErrorEvent value) => {...}, + /// (UploadPostTransformSuccessEvent value) => {...}, + /// (UploadPostTransformErrorEvent value) => {...} /// ); /// /// diff --git a/src/ImageKit/Models/Webhooks/UnwrapWebhookEvent.cs b/src/ImageKit/Models/Webhooks/UnwrapWebhookEvent.cs index b25779dd..7a87a34c 100644 --- a/src/ImageKit/Models/Webhooks/UnwrapWebhookEvent.cs +++ b/src/ImageKit/Models/Webhooks/UnwrapWebhookEvent.cs @@ -129,7 +129,7 @@ public UnwrapWebhookEvent(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -152,7 +152,7 @@ public bool TryPickVideoTransformationAccepted( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -175,7 +175,7 @@ public bool TryPickVideoTransformationReady( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -198,7 +198,7 @@ public bool TryPickVideoTransformationError( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -221,7 +221,7 @@ public bool TryPickUploadPreTransformSuccess( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -244,7 +244,7 @@ public bool TryPickUploadPreTransformError( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -267,7 +267,7 @@ public bool TryPickUploadPostTransformSuccess( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -289,7 +289,7 @@ public bool TryPickUploadPostTransformError( /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -300,13 +300,13 @@ public bool TryPickUploadPostTransformError( /// /// /// instance.Switch( - /// (VideoTransformationAcceptedEvent value) => {...}, - /// (VideoTransformationReadyEvent value) => {...}, - /// (VideoTransformationErrorEvent value) => {...}, - /// (UploadPreTransformSuccessEvent value) => {...}, - /// (UploadPreTransformErrorEvent value) => {...}, - /// (UploadPostTransformSuccessEvent value) => {...}, - /// (UploadPostTransformErrorEvent value) => {...} + /// (VideoTransformationAcceptedEvent value) => {...}, + /// (VideoTransformationReadyEvent value) => {...}, + /// (VideoTransformationErrorEvent value) => {...}, + /// (UploadPreTransformSuccessEvent value) => {...}, + /// (UploadPreTransformErrorEvent value) => {...}, + /// (UploadPostTransformSuccessEvent value) => {...}, + /// (UploadPostTransformErrorEvent value) => {...} /// ); /// /// @@ -355,7 +355,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -366,13 +366,13 @@ public void Switch( /// /// /// var result = instance.Match( - /// (VideoTransformationAcceptedEvent value) => {...}, - /// (VideoTransformationReadyEvent value) => {...}, - /// (VideoTransformationErrorEvent value) => {...}, - /// (UploadPreTransformSuccessEvent value) => {...}, - /// (UploadPreTransformErrorEvent value) => {...}, - /// (UploadPostTransformSuccessEvent value) => {...}, - /// (UploadPostTransformErrorEvent value) => {...} + /// (VideoTransformationAcceptedEvent value) => {...}, + /// (VideoTransformationReadyEvent value) => {...}, + /// (VideoTransformationErrorEvent value) => {...}, + /// (UploadPreTransformSuccessEvent value) => {...}, + /// (UploadPreTransformErrorEvent value) => {...}, + /// (UploadPostTransformSuccessEvent value) => {...}, + /// (UploadPostTransformErrorEvent value) => {...} /// ); /// /// diff --git a/src/ImageKit/Models/Webhooks/UploadPreTransformSuccessEvent.cs b/src/ImageKit/Models/Webhooks/UploadPreTransformSuccessEvent.cs index 1d1f2026..941492c9 100644 --- a/src/ImageKit/Models/Webhooks/UploadPreTransformSuccessEvent.cs +++ b/src/ImageKit/Models/Webhooks/UploadPreTransformSuccessEvent.cs @@ -1622,7 +1622,7 @@ public IReadOnlyList? SelectOptions /// /// Specifies if the selectOptions array is truncated. It is truncated when number - /// of options are > 100. + /// of options are > 100. /// public bool? SelectOptionsTruncated { @@ -1825,7 +1825,7 @@ public DefaultValue(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1846,7 +1846,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1867,7 +1867,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1886,14 +1886,14 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type where T is a UnnamedSchemaWithArrayParent13. /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickMixed(out var value)) { - /// // `value` is of type `IReadOnlyList` + /// // `value` is of type `IReadOnlyList<UnnamedSchemaWithArrayParent13>` /// Console.WriteLine(value); /// } /// @@ -1910,7 +1910,7 @@ public bool TryPickMixed( /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1921,10 +1921,10 @@ public bool TryPickMixed( /// /// /// instance.Switch( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...}, - /// (IReadOnlyList value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList<UnnamedSchemaWithArrayParent13> value) => {...} /// ); /// /// @@ -1961,7 +1961,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1972,10 +1972,10 @@ public void Switch( /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...}, - /// (IReadOnlyList value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...}, + /// (IReadOnlyList<UnnamedSchemaWithArrayParent13> value) => {...} /// ); /// /// @@ -2187,7 +2187,7 @@ public UnnamedSchemaWithArrayParent13(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2208,7 +2208,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2229,7 +2229,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2249,7 +2249,7 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -2260,9 +2260,9 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// /// instance.Switch( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} /// ); /// /// @@ -2295,7 +2295,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -2306,9 +2306,9 @@ public void Switch( /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} /// ); /// /// @@ -2481,7 +2481,7 @@ public MaxValue(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2502,7 +2502,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2522,7 +2522,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -2533,8 +2533,8 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// /// /// instance.Switch( - /// (string value) => {...}, - /// (double value) => {...} + /// (string value) => {...}, + /// (double value) => {...} /// ); /// /// @@ -2560,7 +2560,7 @@ public void Switch(System::Action @string, System::Action @doubl /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -2571,8 +2571,8 @@ public void Switch(System::Action @string, System::Action @doubl /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (double value) => {...} + /// (string value) => {...}, + /// (double value) => {...} /// ); /// /// @@ -2722,7 +2722,7 @@ public MinValue(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2743,7 +2743,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2763,7 +2763,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -2774,8 +2774,8 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// /// /// instance.Switch( - /// (string value) => {...}, - /// (double value) => {...} + /// (string value) => {...}, + /// (double value) => {...} /// ); /// /// @@ -2801,7 +2801,7 @@ public void Switch(System::Action @string, System::Action @doubl /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -2812,8 +2812,8 @@ public void Switch(System::Action @string, System::Action @doubl /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (double value) => {...} + /// (string value) => {...}, + /// (double value) => {...} /// ); /// /// @@ -2964,7 +2964,7 @@ public SelectOption(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2985,7 +2985,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -3006,7 +3006,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -3026,7 +3026,7 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -3037,9 +3037,9 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// /// instance.Switch( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} /// ); /// /// @@ -3072,7 +3072,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -3083,9 +3083,9 @@ public void Switch( /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} /// ); /// /// diff --git a/src/ImageKit/Services/Accounts/IOriginService.cs b/src/ImageKit/Services/Accounts/IOriginService.cs index d7bea064..50e50fd8 100644 --- a/src/ImageKit/Services/Accounts/IOriginService.cs +++ b/src/ImageKit/Services/Accounts/IOriginService.cs @@ -28,8 +28,8 @@ public interface IOriginService IOriginService WithOptions(Func modifier); /// - /// **Note:** This API is currently in beta. Creates a new origin and returns - /// the origin object. + /// **Note:** This API is currently in beta. Creates a new origin and returns the + /// origin object. /// Task Create( OriginCreateParams parameters, @@ -37,8 +37,8 @@ Task Create( ); /// - /// **Note:** This API is currently in beta. Updates the origin identified by - /// `id` and returns the updated origin object. + /// **Note:** This API is currently in beta. Updates the origin identified by `id` + /// and returns the updated origin object. /// Task Update( OriginUpdateParams parameters, @@ -63,8 +63,8 @@ Task> List( /// /// **Note:** This API is currently in beta. Permanently removes the origin - /// identified by `id`. If the origin is in use by any URL‑endpoints, the API - /// will return an error. + /// identified by `id`. If the origin is in use by any URL‑endpoints, the API will + /// return an error. /// Task Delete(OriginDeleteParams parameters, CancellationToken cancellationToken = default); @@ -76,8 +76,8 @@ Task Delete( ); /// - /// **Note:** This API is currently in beta. Retrieves the origin identified - /// by `id`. + /// **Note:** This API is currently in beta. Retrieves the origin identified by + /// `id`. /// Task Get( OriginGetParams parameters, @@ -106,7 +106,7 @@ public interface IOriginServiceWithRawResponse IOriginServiceWithRawResponse WithOptions(Func modifier); /// - /// Returns a raw HTTP response for `post /v1/accounts/origins`, but is otherwise the + /// Returns a raw HTTP response for post /v1/accounts/origins, but is otherwise the /// same as . /// Task> Create( @@ -115,7 +115,7 @@ Task> Create( ); /// - /// Returns a raw HTTP response for `put /v1/accounts/origins/{id}`, but is otherwise the + /// Returns a raw HTTP response for put /v1/accounts/origins/{id}, but is otherwise the /// same as . /// Task> Update( @@ -131,7 +131,7 @@ Task> Update( ); /// - /// Returns a raw HTTP response for `get /v1/accounts/origins`, but is otherwise the + /// Returns a raw HTTP response for get /v1/accounts/origins, but is otherwise the /// same as . /// Task>> List( @@ -140,7 +140,7 @@ Task>> List( ); /// - /// Returns a raw HTTP response for `delete /v1/accounts/origins/{id}`, but is otherwise the + /// Returns a raw HTTP response for delete /v1/accounts/origins/{id}, but is otherwise the /// same as . /// Task Delete( @@ -156,7 +156,7 @@ Task Delete( ); /// - /// Returns a raw HTTP response for `get /v1/accounts/origins/{id}`, but is otherwise the + /// Returns a raw HTTP response for get /v1/accounts/origins/{id}, but is otherwise the /// same as . /// Task> Get( diff --git a/src/ImageKit/Services/Accounts/IUrlEndpointService.cs b/src/ImageKit/Services/Accounts/IUrlEndpointService.cs index 3bce6320..4036ed48 100644 --- a/src/ImageKit/Services/Accounts/IUrlEndpointService.cs +++ b/src/ImageKit/Services/Accounts/IUrlEndpointService.cs @@ -107,7 +107,7 @@ public interface IUrlEndpointServiceWithRawResponse IUrlEndpointServiceWithRawResponse WithOptions(Func modifier); /// - /// Returns a raw HTTP response for `post /v1/accounts/url-endpoints`, but is otherwise the + /// Returns a raw HTTP response for post /v1/accounts/url-endpoints, but is otherwise the /// same as . /// Task> Create( @@ -116,7 +116,7 @@ Task> Create( ); /// - /// Returns a raw HTTP response for `put /v1/accounts/url-endpoints/{id}`, but is otherwise the + /// Returns a raw HTTP response for put /v1/accounts/url-endpoints/{id}, but is otherwise the /// same as . /// Task> Update( @@ -132,7 +132,7 @@ Task> Update( ); /// - /// Returns a raw HTTP response for `get /v1/accounts/url-endpoints`, but is otherwise the + /// Returns a raw HTTP response for get /v1/accounts/url-endpoints, but is otherwise the /// same as . /// Task>> List( @@ -141,7 +141,7 @@ Task>> List( ); /// - /// Returns a raw HTTP response for `delete /v1/accounts/url-endpoints/{id}`, but is otherwise the + /// Returns a raw HTTP response for delete /v1/accounts/url-endpoints/{id}, but is otherwise the /// same as . /// Task Delete( @@ -157,7 +157,7 @@ Task Delete( ); /// - /// Returns a raw HTTP response for `get /v1/accounts/url-endpoints/{id}`, but is otherwise the + /// Returns a raw HTTP response for get /v1/accounts/url-endpoints/{id}, but is otherwise the /// same as . /// Task> Get( diff --git a/src/ImageKit/Services/Accounts/IUsageService.cs b/src/ImageKit/Services/Accounts/IUsageService.cs index dafe9f6b..4b330f69 100644 --- a/src/ImageKit/Services/Accounts/IUsageService.cs +++ b/src/ImageKit/Services/Accounts/IUsageService.cs @@ -28,9 +28,9 @@ public interface IUsageService /// /// Get the account usage information between two dates. Note that the API response - /// includes data from the start date while excluding data from the end date. - /// In other words, the data covers the period starting from the specified start - /// date up to, but not including, the end date. + /// includes data from the start date while excluding data from the end date. In + /// other words, the data covers the period starting from the specified start date + /// up to, but not including, the end date. /// Task Get( UsageGetParams parameters, @@ -52,7 +52,7 @@ public interface IUsageServiceWithRawResponse IUsageServiceWithRawResponse WithOptions(Func modifier); /// - /// Returns a raw HTTP response for `get /v1/accounts/usage`, but is otherwise the + /// Returns a raw HTTP response for get /v1/accounts/usage, but is otherwise the /// same as . /// Task> Get( diff --git a/src/ImageKit/Services/Beta/V2/IFileService.cs b/src/ImageKit/Services/Beta/V2/IFileService.cs index 91c9834e..c87e0ddb 100644 --- a/src/ImageKit/Services/Beta/V2/IFileService.cs +++ b/src/ImageKit/Services/Beta/V2/IFileService.cs @@ -27,30 +27,32 @@ public interface IFileService IFileService WithOptions(Func modifier); /// - /// The V2 API enhances security by verifying the entire payload using JWT. This - /// API is in beta. + /// The V2 API enhances security by verifying the entire payload using JWT. This API + /// is in beta. /// - /// ImageKit.io allows you to upload files directly from both the server - /// and client sides. For server-side uploads, private API key authentication - /// is used. For client-side uploads, generate a one-time `token` from your secure - /// backend using private API. [Learn more](/docs/api-reference/upload-file/upload-file-v2#how-to-implement-secure-client-side-file-upload) + /// ImageKit.io allows you to upload files directly from both the server and + /// client sides. For server-side uploads, private API key authentication is used. + /// For client-side uploads, generate a one-time `token` from your secure backend + /// using private API. [Learn + /// more](/docs/api-reference/upload-file/upload-file-v2#how-to-implement-secure-client-side-file-upload) /// about how to implement secure client-side file upload. /// - /// **File size limit** \ On the free plan, the maximum upload file sizes - /// are 25MB for images, audio, and raw files, and 100MB for videos. On the Lite - /// paid plan, these limits increase to 40MB for images, audio, and raw files - /// and 300MB for videos, whereas on the Pro paid plan, these limits increase - /// to 50MB for images, audio, and raw files and 2GB for videos. These limits - /// can be further increased with enterprise plans. + /// **File size limit** \ On the free plan, the maximum upload file sizes are + /// 25MB for images, audio, and raw files, and 100MB for videos. On the Lite paid + /// plan, these limits increase to 40MB for images, audio, and raw files and 300MB + /// for videos, whereas on the Pro paid plan, these limits increase to 50MB for + /// images, audio, and raw files and 2GB for videos. These limits can be further + /// increased with enterprise plans. /// /// **Version limit** \ A file can have a maximum of 100 versions. /// /// **Demo applications** /// - /// - A full-fledged [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), - /// supporting file selections from local storage, URL, Dropbox, Google Drive, - /// Instagram, and more. - [Quick start guides](/docs/quick-start-guides) for - /// various frameworks and technologies. + /// - A full-fledged [upload widget using + /// Uppy](https://github.com/imagekit-samples/uppy-uploader), supporting file + /// selections from local storage, URL, Dropbox, Google Drive, Instagram, and more. + /// - [Quick start guides](/docs/quick-start-guides) for various frameworks and + /// technologies. /// Task Upload( FileUploadParams parameters, @@ -72,7 +74,7 @@ public interface IFileServiceWithRawResponse IFileServiceWithRawResponse WithOptions(Func modifier); /// - /// Returns a raw HTTP response for `post /api/v2/files/upload`, but is otherwise the + /// Returns a raw HTTP response for post /api/v2/files/upload, but is otherwise the /// same as . /// Task> Upload( diff --git a/src/ImageKit/Services/Cache/IInvalidationService.cs b/src/ImageKit/Services/Cache/IInvalidationService.cs index 24c88e22..edff0d9b 100644 --- a/src/ImageKit/Services/Cache/IInvalidationService.cs +++ b/src/ImageKit/Services/Cache/IInvalidationService.cs @@ -27,9 +27,9 @@ public interface IInvalidationService IInvalidationService WithOptions(Func modifier); /// - /// This API will purge CDN cache and ImageKit.io's internal cache for a file. - /// Note: Purge cache is an asynchronous process and it may take some time to - /// reflect the changes. + /// This API will purge CDN cache and ImageKit.io's internal cache for a file. Note: + /// Purge cache is an asynchronous process and it may take some time to reflect the changes. + /// /// Task Create( InvalidationCreateParams parameters, @@ -66,7 +66,7 @@ public interface IInvalidationServiceWithRawResponse IInvalidationServiceWithRawResponse WithOptions(Func modifier); /// - /// Returns a raw HTTP response for `post /v1/files/purge`, but is otherwise the + /// Returns a raw HTTP response for post /v1/files/purge, but is otherwise the /// same as . /// Task> Create( @@ -75,7 +75,7 @@ Task> Create( ); /// - /// Returns a raw HTTP response for `get /v1/files/purge/{requestId}`, but is otherwise the + /// Returns a raw HTTP response for get /v1/files/purge/{requestId}, but is otherwise the /// same as . /// Task> Get( diff --git a/src/ImageKit/Services/Files/IBulkService.cs b/src/ImageKit/Services/Files/IBulkService.cs index 0a410525..eeb5cc83 100644 --- a/src/ImageKit/Services/Files/IBulkService.cs +++ b/src/ImageKit/Services/Files/IBulkService.cs @@ -29,11 +29,11 @@ public interface IBulkService /// /// This API deletes multiple files and all their file versions permanently. /// - /// Note: If a file or specific transformation has been requested in the - /// past, then the response is cached. Deleting a file does not purge the cache. - /// You can purge the cache using purge cache API. + /// Note: If a file or specific transformation has been requested in the past, + /// then the response is cached. Deleting a file does not purge the cache. You can + /// purge the cache using purge cache API. /// - /// A maximum of 100 files can be deleted at a time. + /// A maximum of 100 files can be deleted at a time. /// Task Delete( BulkDeleteParams parameters, @@ -50,8 +50,8 @@ Task AddTags( ); /// - /// This API removes AITags from multiple files in bulk. A maximum of 50 files - /// can be specified at a time. + /// This API removes AITags from multiple files in bulk. A maximum of 50 files can + /// be specified at a time. /// Task RemoveAITags( BulkRemoveAITagsParams parameters, @@ -59,8 +59,8 @@ Task RemoveAITags( ); /// - /// This API removes tags from multiple files in bulk. A maximum of 50 files - /// can be specified at a time. + /// This API removes tags from multiple files in bulk. A maximum of 50 files can be + /// specified at a time. /// Task RemoveTags( BulkRemoveTagsParams parameters, @@ -82,7 +82,7 @@ public interface IBulkServiceWithRawResponse IBulkServiceWithRawResponse WithOptions(Func modifier); /// - /// Returns a raw HTTP response for `post /v1/files/batch/deleteByFileIds`, but is otherwise the + /// Returns a raw HTTP response for post /v1/files/batch/deleteByFileIds, but is otherwise the /// same as . /// Task> Delete( @@ -91,7 +91,7 @@ Task> Delete( ); /// - /// Returns a raw HTTP response for `post /v1/files/addTags`, but is otherwise the + /// Returns a raw HTTP response for post /v1/files/addTags, but is otherwise the /// same as . /// Task> AddTags( @@ -100,7 +100,7 @@ Task> AddTags( ); /// - /// Returns a raw HTTP response for `post /v1/files/removeAITags`, but is otherwise the + /// Returns a raw HTTP response for post /v1/files/removeAITags, but is otherwise the /// same as . /// Task> RemoveAITags( @@ -109,7 +109,7 @@ Task> RemoveAITags( ); /// - /// Returns a raw HTTP response for `post /v1/files/removeTags`, but is otherwise the + /// Returns a raw HTTP response for post /v1/files/removeTags, but is otherwise the /// same as . /// Task> RemoveTags( diff --git a/src/ImageKit/Services/Files/IMetadataService.cs b/src/ImageKit/Services/Files/IMetadataService.cs index 31b7c3da..9c88707c 100644 --- a/src/ImageKit/Services/Files/IMetadataService.cs +++ b/src/ImageKit/Services/Files/IMetadataService.cs @@ -32,7 +32,7 @@ public interface IMetadataService /// files in the ImageKit.io media library using this API. /// /// You can also get the metadata in upload API response by passing `metadata` - /// in `responseFields` parameter. + /// in `responseFields` parameter. /// Task Get( MetadataGetParams parameters, @@ -47,8 +47,8 @@ Task Get( ); /// - /// Get image EXIF, pHash, and other metadata from ImageKit.io powered remote - /// URL using this API. + /// Get image EXIF, pHash, and other metadata from ImageKit.io powered remote URL + /// using this API. /// Task GetFromUrl( MetadataGetFromUrlParams parameters, @@ -70,7 +70,7 @@ public interface IMetadataServiceWithRawResponse IMetadataServiceWithRawResponse WithOptions(Func modifier); /// - /// Returns a raw HTTP response for `get /v1/files/{fileId}/metadata`, but is otherwise the + /// Returns a raw HTTP response for get /v1/files/{fileId}/metadata, but is otherwise the /// same as . /// Task> Get( @@ -86,7 +86,7 @@ Task> Get( ); /// - /// Returns a raw HTTP response for `get /v1/metadata`, but is otherwise the + /// Returns a raw HTTP response for get /v1/metadata, but is otherwise the /// same as . /// Task> GetFromUrl( diff --git a/src/ImageKit/Services/Files/IVersionService.cs b/src/ImageKit/Services/Files/IVersionService.cs index 0f567cc9..e8879cc6 100644 --- a/src/ImageKit/Services/Files/IVersionService.cs +++ b/src/ImageKit/Services/Files/IVersionService.cs @@ -47,8 +47,8 @@ Task> List( /// This API deletes a non-current file version permanently. The API returns an /// empty response. /// - /// Note: If you want to delete all versions of a file, use the delete - /// file API. + /// Note: If you want to delete all versions of a file, use the delete file + /// API. /// Task Delete( VersionDeleteParams parameters, @@ -104,7 +104,7 @@ public interface IVersionServiceWithRawResponse IVersionServiceWithRawResponse WithOptions(Func modifier); /// - /// Returns a raw HTTP response for `get /v1/files/{fileId}/versions`, but is otherwise the + /// Returns a raw HTTP response for get /v1/files/{fileId}/versions, but is otherwise the /// same as . /// Task>> List( @@ -120,7 +120,7 @@ Task>> List( ); /// - /// Returns a raw HTTP response for `delete /v1/files/{fileId}/versions/{versionId}`, but is otherwise the + /// Returns a raw HTTP response for delete /v1/files/{fileId}/versions/{versionId}, but is otherwise the /// same as . /// Task> Delete( @@ -136,7 +136,7 @@ Task> Delete( ); /// - /// Returns a raw HTTP response for `get /v1/files/{fileId}/versions/{versionId}`, but is otherwise the + /// Returns a raw HTTP response for get /v1/files/{fileId}/versions/{versionId}, but is otherwise the /// same as . /// Task> Get( @@ -152,7 +152,7 @@ Task> Get( ); /// - /// Returns a raw HTTP response for `put /v1/files/{fileId}/versions/{versionId}/restore`, but is otherwise the + /// Returns a raw HTTP response for put /v1/files/{fileId}/versions/{versionId}/restore, but is otherwise the /// same as . /// Task> Restore( diff --git a/src/ImageKit/Services/Folders/IJobService.cs b/src/ImageKit/Services/Folders/IJobService.cs index ca1a58cd..767564e3 100644 --- a/src/ImageKit/Services/Folders/IJobService.cs +++ b/src/ImageKit/Services/Folders/IJobService.cs @@ -56,7 +56,7 @@ public interface IJobServiceWithRawResponse IJobServiceWithRawResponse WithOptions(Func modifier); /// - /// Returns a raw HTTP response for `get /v1/bulkJobs/{jobId}`, but is otherwise the + /// Returns a raw HTTP response for get /v1/bulkJobs/{jobId}, but is otherwise the /// same as . /// Task> Get( diff --git a/src/ImageKit/Services/IAssetService.cs b/src/ImageKit/Services/IAssetService.cs index 32f55c02..930997b8 100644 --- a/src/ImageKit/Services/IAssetService.cs +++ b/src/ImageKit/Services/IAssetService.cs @@ -53,7 +53,7 @@ public interface IAssetServiceWithRawResponse IAssetServiceWithRawResponse WithOptions(Func modifier); /// - /// Returns a raw HTTP response for `get /v1/files`, but is otherwise the + /// Returns a raw HTTP response for get /v1/files, but is otherwise the /// same as . /// Task>> List( diff --git a/src/ImageKit/Services/ICustomMetadataFieldService.cs b/src/ImageKit/Services/ICustomMetadataFieldService.cs index 4c776b7b..8e23395a 100644 --- a/src/ImageKit/Services/ICustomMetadataFieldService.cs +++ b/src/ImageKit/Services/ICustomMetadataFieldService.cs @@ -28,10 +28,10 @@ public interface ICustomMetadataFieldService ICustomMetadataFieldService WithOptions(Func modifier); /// - /// This API creates a new custom metadata field. Once a custom metadata field - /// is created either through this API or using the dashboard UI, its value can - /// be set on the assets. The value of a field for an asset can be set using - /// the media library UI or programmatically through upload or update assets API. + /// This API creates a new custom metadata field. Once a custom metadata field is + /// created either through this API or using the dashboard UI, its value can be set + /// on the assets. The value of a field for an asset can be set using the media + /// library UI or programmatically through upload or update assets API. /// Task Create( CustomMetadataFieldCreateParams parameters, @@ -59,9 +59,9 @@ Task Update( /// fields in the API response. /// /// You can also filter results by a specific folder path to retrieve custom - /// metadata fields applicable at that location. This path-specific filtering - /// is useful when using the **Path policy** feature to determine which custom - /// metadata fields are selected for a given path. + /// metadata fields applicable at that location. This path-specific filtering is + /// useful when using the **Path policy** feature to determine which custom metadata + /// fields are selected for a given path. /// Task> List( CustomMetadataFieldListParams? parameters = null, @@ -101,7 +101,7 @@ Func modifier ); /// - /// Returns a raw HTTP response for `post /v1/customMetadataFields`, but is otherwise the + /// Returns a raw HTTP response for post /v1/customMetadataFields, but is otherwise the /// same as . /// Task> Create( @@ -110,7 +110,7 @@ Task> Create( ); /// - /// Returns a raw HTTP response for `patch /v1/customMetadataFields/{id}`, but is otherwise the + /// Returns a raw HTTP response for patch /v1/customMetadataFields/{id}, but is otherwise the /// same as . /// Task> Update( @@ -126,7 +126,7 @@ Task> Update( ); /// - /// Returns a raw HTTP response for `get /v1/customMetadataFields`, but is otherwise the + /// Returns a raw HTTP response for get /v1/customMetadataFields, but is otherwise the /// same as . /// Task>> List( @@ -135,7 +135,7 @@ Task>> List( ); /// - /// Returns a raw HTTP response for `delete /v1/customMetadataFields/{id}`, but is otherwise the + /// Returns a raw HTTP response for delete /v1/customMetadataFields/{id}, but is otherwise the /// same as . /// Task> Delete( diff --git a/src/ImageKit/Services/IFileService.cs b/src/ImageKit/Services/IFileService.cs index 8f83b0e3..50ced006 100644 --- a/src/ImageKit/Services/IFileService.cs +++ b/src/ImageKit/Services/IFileService.cs @@ -53,9 +53,9 @@ Task Update( /// /// This API deletes the file and all its file versions permanently. /// - /// Note: If a file or specific transformation has been requested in the - /// past, then the response is cached. Deleting a file does not purge the cache. - /// You can purge the cache using purge cache API. + /// Note: If a file or specific transformation has been requested in the past, + /// then the response is cached. Deleting a file does not purge the cache. You can + /// purge the cache using purge cache API. /// Task Delete(FileDeleteParams parameters, CancellationToken cancellationToken = default); @@ -69,9 +69,9 @@ Task Delete( /// /// This will copy a file from one folder to another. /// - /// Note: If any file at the destination has the same name as the source - /// file, then the source file and its versions (if `includeFileVersions` is set - /// to true) will be appended to the destination file version history. + /// Note: If any file at the destination has the same name as the source file, + /// then the source file and its versions (if `includeFileVersions` is set to true) + /// will be appended to the destination file version history. /// Task Copy( FileCopyParams parameters, @@ -94,8 +94,8 @@ Task Get( /// /// This will move a file and all its versions from one folder to another. /// - /// Note: If any file at the destination has the same name as the source - /// file, then the source file and its versions will be appended to the destination file. + /// Note: If any file at the destination has the same name as the source file, + /// then the source file and its versions will be appended to the destination file. /// Task Move( FileMoveParams parameters, @@ -103,11 +103,11 @@ Task Move( ); /// - /// You can rename an already existing file in the media library using rename - /// file API. This operation would rename all file versions of the file. + /// You can rename an already existing file in the media library using rename file + /// API. This operation would rename all file versions of the file. /// - /// Note: The old URLs will stop working. The file/file version URLs cached - /// on CDN will continue to work unless a purge is requested. + /// Note: The old URLs will stop working. The file/file version URLs cached on + /// CDN will continue to work unless a purge is requested. /// Task Rename( FileRenameParams parameters, @@ -115,30 +115,32 @@ Task Rename( ); /// - /// ImageKit.io allows you to upload files directly from both the server and - /// client sides. For server-side uploads, private API key authentication is - /// used. For client-side uploads, generate a one-time `token`, `signature`, and - /// `expire` from your secure backend using private API. [Learn more](/docs/api-reference/upload-file/upload-file#how-to-implement-client-side-file-upload) + /// ImageKit.io allows you to upload files directly from both the server and client + /// sides. For server-side uploads, private API key authentication is used. For + /// client-side uploads, generate a one-time `token`, `signature`, and `expire` from + /// your secure backend using private API. [Learn + /// more](/docs/api-reference/upload-file/upload-file#how-to-implement-client-side-file-upload) /// about how to implement client-side file upload. /// /// The [V2 API](/docs/api-reference/upload-file/upload-file-v2) enhances /// security by verifying the entire payload using JWT. /// - /// **File size limit** \ On the free plan, the maximum upload file sizes - /// are 25MB for images, audio, and raw files and 100MB for videos. On the Lite - /// paid plan, these limits increase to 40MB for images, audio, and raw files - /// and 300MB for videos, whereas on the Pro paid plan, these limits increase - /// to 50MB for images, audio, and raw files and 2GB for videos. These limits - /// can be further increased with enterprise plans. + /// **File size limit** \ On the free plan, the maximum upload file sizes are + /// 25MB for images, audio, and raw files and 100MB for videos. On the Lite paid + /// plan, these limits increase to 40MB for images, audio, and raw files and 300MB + /// for videos, whereas on the Pro paid plan, these limits increase to 50MB for + /// images, audio, and raw files and 2GB for videos. These limits can be further + /// increased with enterprise plans. /// /// **Version limit** \ A file can have a maximum of 100 versions. /// /// **Demo applications** /// - /// - A full-fledged [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), - /// supporting file selections from local storage, URL, Dropbox, Google Drive, - /// Instagram, and more. - [Quick start guides](/docs/quick-start-guides) for - /// various frameworks and technologies. + /// - A full-fledged [upload widget using + /// Uppy](https://github.com/imagekit-samples/uppy-uploader), supporting file + /// selections from local storage, URL, Dropbox, Google Drive, Instagram, and more. + /// - [Quick start guides](/docs/quick-start-guides) for various frameworks and + /// technologies. /// Task Upload( FileUploadParams parameters, @@ -166,7 +168,7 @@ public interface IFileServiceWithRawResponse IMetadataServiceWithRawResponse Metadata { get; } /// - /// Returns a raw HTTP response for `patch /v1/files/{fileId}/details`, but is otherwise the + /// Returns a raw HTTP response for patch /v1/files/{fileId}/details, but is otherwise the /// same as . /// Task> Update( @@ -182,7 +184,7 @@ Task> Update( ); /// - /// Returns a raw HTTP response for `delete /v1/files/{fileId}`, but is otherwise the + /// Returns a raw HTTP response for delete /v1/files/{fileId}, but is otherwise the /// same as . /// Task Delete( @@ -198,7 +200,7 @@ Task Delete( ); /// - /// Returns a raw HTTP response for `post /v1/files/copy`, but is otherwise the + /// Returns a raw HTTP response for post /v1/files/copy, but is otherwise the /// same as . /// Task> Copy( @@ -207,7 +209,7 @@ Task> Copy( ); /// - /// Returns a raw HTTP response for `get /v1/files/{fileId}/details`, but is otherwise the + /// Returns a raw HTTP response for get /v1/files/{fileId}/details, but is otherwise the /// same as . /// Task> Get( @@ -223,7 +225,7 @@ Task> Get( ); /// - /// Returns a raw HTTP response for `post /v1/files/move`, but is otherwise the + /// Returns a raw HTTP response for post /v1/files/move, but is otherwise the /// same as . /// Task> Move( @@ -232,7 +234,7 @@ Task> Move( ); /// - /// Returns a raw HTTP response for `put /v1/files/rename`, but is otherwise the + /// Returns a raw HTTP response for put /v1/files/rename, but is otherwise the /// same as . /// Task> Rename( @@ -241,7 +243,7 @@ Task> Rename( ); /// - /// Returns a raw HTTP response for `post /api/v1/files/upload`, but is otherwise the + /// Returns a raw HTTP response for post /api/v1/files/upload, but is otherwise the /// same as . /// Task> Upload( diff --git a/src/ImageKit/Services/IFolderService.cs b/src/ImageKit/Services/IFolderService.cs index d63c2d7c..947be4e2 100644 --- a/src/ImageKit/Services/IFolderService.cs +++ b/src/ImageKit/Services/IFolderService.cs @@ -30,8 +30,8 @@ public interface IFolderService IJobService Job { get; } /// - /// This will create a new folder. You can specify the folder name and location - /// of the parent folder where this new folder should be created. + /// This will create a new folder. You can specify the folder name and location of + /// the parent folder where this new folder should be created. /// Task Create( FolderCreateParams parameters, @@ -39,8 +39,8 @@ Task Create( ); /// - /// This will delete a folder and all its contents permanently. The API returns - /// an empty response. + /// This will delete a folder and all its contents permanently. The API returns an + /// empty response. /// Task Delete( FolderDeleteParams parameters, @@ -49,10 +49,10 @@ Task Delete( /// /// This will copy one folder into another. The selected folder, its nested folders, - /// files, and their versions (in `includeVersions` is set to true) are copied - /// in this operation. Note: If any file at the destination has the same name - /// as the source file, then the source file and its versions will be appended - /// to the destination file version history. + /// files, and their versions (in `includeVersions` is set to true) are copied in + /// this operation. Note: If any file at the destination has the same name as the + /// source file, then the source file and its versions will be appended to the + /// destination file version history. /// Task Copy( FolderCopyParams parameters, @@ -61,9 +61,9 @@ Task Copy( /// /// This will move one folder into another. The selected folder, its nested folders, - /// files, and their versions are moved in this operation. Note: If any file - /// at the destination has the same name as the source file, then the source - /// file and its versions will be appended to the destination file version history. + /// files, and their versions are moved in this operation. Note: If any file at the + /// destination has the same name as the source file, then the source file and its + /// versions will be appended to the destination file version history. /// Task Move( FolderMoveParams parameters, @@ -71,9 +71,9 @@ Task Move( ); /// - /// This API allows you to rename an existing folder. The folder and all its - /// nested assets and sub-folders will remain unchanged, but their paths will - /// be updated to reflect the new folder name. + /// This API allows you to rename an existing folder. The folder and all its nested + /// assets and sub-folders will remain unchanged, but their paths will be updated to + /// reflect the new folder name. /// Task Rename( FolderRenameParams parameters, @@ -97,7 +97,7 @@ public interface IFolderServiceWithRawResponse IJobServiceWithRawResponse Job { get; } /// - /// Returns a raw HTTP response for `post /v1/folder`, but is otherwise the + /// Returns a raw HTTP response for post /v1/folder, but is otherwise the /// same as . /// Task> Create( @@ -106,7 +106,7 @@ Task> Create( ); /// - /// Returns a raw HTTP response for `delete /v1/folder`, but is otherwise the + /// Returns a raw HTTP response for delete /v1/folder, but is otherwise the /// same as . /// Task> Delete( @@ -115,7 +115,7 @@ Task> Delete( ); /// - /// Returns a raw HTTP response for `post /v1/bulkJobs/copyFolder`, but is otherwise the + /// Returns a raw HTTP response for post /v1/bulkJobs/copyFolder, but is otherwise the /// same as . /// Task> Copy( @@ -124,7 +124,7 @@ Task> Copy( ); /// - /// Returns a raw HTTP response for `post /v1/bulkJobs/moveFolder`, but is otherwise the + /// Returns a raw HTTP response for post /v1/bulkJobs/moveFolder, but is otherwise the /// same as . /// Task> Move( @@ -133,7 +133,7 @@ Task> Move( ); /// - /// Returns a raw HTTP response for `post /v1/bulkJobs/renameFolder`, but is otherwise the + /// Returns a raw HTTP response for post /v1/bulkJobs/renameFolder, but is otherwise the /// same as . /// Task> Rename( diff --git a/src/ImageKit/Services/ISavedExtensionService.cs b/src/ImageKit/Services/ISavedExtensionService.cs index b2c783b9..d8770f25 100644 --- a/src/ImageKit/Services/ISavedExtensionService.cs +++ b/src/ImageKit/Services/ISavedExtensionService.cs @@ -33,8 +33,8 @@ public interface ISavedExtensionService /// complex extension configurations (like AI tasks) and reuse them by referencing /// the ID in upload or update file APIs. /// - /// **Saved extension limit** \ You can create a maximum of 100 saved extensions - /// per account. + /// **Saved extension limit** \ You can create a maximum of 100 saved + /// extensions per account. /// Task Create( SavedExtensionCreateParams parameters, @@ -42,8 +42,8 @@ public interface ISavedExtensionService ); /// - /// This API updates an existing saved extension. You can update the name, description, - /// or config. + /// This API updates an existing saved extension. You can update the name, + /// description, or config. /// Task Update( SavedExtensionUpdateParams parameters, @@ -59,8 +59,8 @@ public interface ISavedExtensionService /// /// This API returns an array of all saved extensions for your account. Saved - /// extensions allow you to save complex extension configurations and reuse them - /// by referencing them by ID in upload or update file APIs. + /// extensions allow you to save complex extension configurations and reuse them by + /// referencing them by ID in upload or update file APIs. /// Task> List( SavedExtensionListParams? parameters = null, @@ -112,7 +112,7 @@ public interface ISavedExtensionServiceWithRawResponse ISavedExtensionServiceWithRawResponse WithOptions(Func modifier); /// - /// Returns a raw HTTP response for `post /v1/saved-extensions`, but is otherwise the + /// Returns a raw HTTP response for post /v1/saved-extensions, but is otherwise the /// same as . /// Task> Create( @@ -121,7 +121,7 @@ public interface ISavedExtensionServiceWithRawResponse ); /// - /// Returns a raw HTTP response for `patch /v1/saved-extensions/{id}`, but is otherwise the + /// Returns a raw HTTP response for patch /v1/saved-extensions/{id}, but is otherwise the /// same as . /// Task> Update( @@ -137,7 +137,7 @@ public interface ISavedExtensionServiceWithRawResponse ); /// - /// Returns a raw HTTP response for `get /v1/saved-extensions`, but is otherwise the + /// Returns a raw HTTP response for get /v1/saved-extensions, but is otherwise the /// same as . /// Task>> List( @@ -146,7 +146,7 @@ public interface ISavedExtensionServiceWithRawResponse ); /// - /// Returns a raw HTTP response for `delete /v1/saved-extensions/{id}`, but is otherwise the + /// Returns a raw HTTP response for delete /v1/saved-extensions/{id}, but is otherwise the /// same as . /// Task Delete( @@ -162,7 +162,7 @@ Task Delete( ); /// - /// Returns a raw HTTP response for `get /v1/saved-extensions/{id}`, but is otherwise the + /// Returns a raw HTTP response for get /v1/saved-extensions/{id}, but is otherwise the /// same as . /// Task> Get( From 7378ffadddfa96764d27d774e4ba8cf3c920d67a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 16 Mar 2026 20:46:46 +0000 Subject: [PATCH 082/129] chore(internal): tweak CI branches --- .github/workflows/ci.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4157d2b7..a23d2a74 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,12 +1,14 @@ name: CI on: push: - branches-ignore: - - 'generated' - - 'codegen/**' - - 'integrated/**' - - 'stl-preview-head/**' - - 'stl-preview-base/**' + branches: + - '**' + - '!integrated/**' + - '!stl-preview-head/**' + - '!stl-preview-base/**' + - '!generated' + - '!codegen/**' + - 'codegen/stl/**' pull_request: branches-ignore: - 'stl-preview-head/**' From 87f94216c76365266eaee43c4e47833506a7841b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 18 Mar 2026 17:40:45 +0000 Subject: [PATCH 083/129] fix(client): handle path params correctly in `FromRawUnchecked` --- .../Models/Accounts/Origins/OriginDeleteParams.cs | 10 +++++++--- .../Models/Accounts/Origins/OriginGetParams.cs | 10 +++++++--- .../Models/Accounts/Origins/OriginUpdateParams.cs | 10 +++++++--- .../UrlEndpoints/UrlEndpointDeleteParams.cs | 10 +++++++--- .../Accounts/UrlEndpoints/UrlEndpointGetParams.cs | 10 +++++++--- .../UrlEndpoints/UrlEndpointUpdateParams.cs | 10 +++++++--- .../Cache/Invalidation/InvalidationGetParams.cs | 10 +++++++--- .../CustomMetadataFieldDeleteParams.cs | 10 +++++++--- .../CustomMetadataFieldUpdateParams.cs | 10 +++++++--- src/ImageKit/Models/Files/FileDeleteParams.cs | 10 +++++++--- src/ImageKit/Models/Files/FileGetParams.cs | 10 +++++++--- src/ImageKit/Models/Files/FileUpdateParams.cs | 10 +++++++--- .../Models/Files/Metadata/MetadataGetParams.cs | 10 +++++++--- .../Models/Files/Versions/VersionDeleteParams.cs | 14 +++++++++++--- .../Models/Files/Versions/VersionGetParams.cs | 14 +++++++++++--- .../Models/Files/Versions/VersionListParams.cs | 10 +++++++--- .../Models/Files/Versions/VersionRestoreParams.cs | 14 +++++++++++--- src/ImageKit/Models/Folders/Job/JobGetParams.cs | 10 +++++++--- .../SavedExtensions/SavedExtensionDeleteParams.cs | 10 +++++++--- .../SavedExtensions/SavedExtensionGetParams.cs | 10 +++++++--- .../SavedExtensions/SavedExtensionUpdateParams.cs | 10 +++++++--- 21 files changed, 159 insertions(+), 63 deletions(-) diff --git a/src/ImageKit/Models/Accounts/Origins/OriginDeleteParams.cs b/src/ImageKit/Models/Accounts/Origins/OriginDeleteParams.cs index 6743ad71..28bd610b 100644 --- a/src/ImageKit/Models/Accounts/Origins/OriginDeleteParams.cs +++ b/src/ImageKit/Models/Accounts/Origins/OriginDeleteParams.cs @@ -44,23 +44,27 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] OriginDeleteParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string id ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.ID = id; } #pragma warning restore CS8618 /// public static OriginDeleteParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string id ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + id ); } diff --git a/src/ImageKit/Models/Accounts/Origins/OriginGetParams.cs b/src/ImageKit/Models/Accounts/Origins/OriginGetParams.cs index a46353e8..da52e29c 100644 --- a/src/ImageKit/Models/Accounts/Origins/OriginGetParams.cs +++ b/src/ImageKit/Models/Accounts/Origins/OriginGetParams.cs @@ -43,23 +43,27 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] OriginGetParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string id ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.ID = id; } #pragma warning restore CS8618 /// public static OriginGetParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string id ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + id ); } diff --git a/src/ImageKit/Models/Accounts/Origins/OriginUpdateParams.cs b/src/ImageKit/Models/Accounts/Origins/OriginUpdateParams.cs index b06d700a..0d58c456 100644 --- a/src/ImageKit/Models/Accounts/Origins/OriginUpdateParams.cs +++ b/src/ImageKit/Models/Accounts/Origins/OriginUpdateParams.cs @@ -69,12 +69,14 @@ IReadOnlyDictionary rawBodyData OriginUpdateParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string id ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.ID = id; } #pragma warning restore CS8618 @@ -82,13 +84,15 @@ FrozenDictionary rawBodyData public static OriginUpdateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string id ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + id ); } diff --git a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointDeleteParams.cs b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointDeleteParams.cs index ad120ae9..5efe9c26 100644 --- a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointDeleteParams.cs +++ b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointDeleteParams.cs @@ -45,23 +45,27 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] UrlEndpointDeleteParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string id ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.ID = id; } #pragma warning restore CS8618 /// public static UrlEndpointDeleteParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string id ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + id ); } diff --git a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointGetParams.cs b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointGetParams.cs index 88f84d63..b53bc26a 100644 --- a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointGetParams.cs +++ b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointGetParams.cs @@ -44,23 +44,27 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] UrlEndpointGetParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string id ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.ID = id; } #pragma warning restore CS8618 /// public static UrlEndpointGetParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string id ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + id ); } diff --git a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParams.cs b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParams.cs index 8a3142a4..b8ed99d1 100644 --- a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParams.cs +++ b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParams.cs @@ -143,12 +143,14 @@ IReadOnlyDictionary rawBodyData UrlEndpointUpdateParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string id ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.ID = id; } #pragma warning restore CS8618 @@ -156,13 +158,15 @@ FrozenDictionary rawBodyData public static UrlEndpointUpdateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string id ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + id ); } diff --git a/src/ImageKit/Models/Cache/Invalidation/InvalidationGetParams.cs b/src/ImageKit/Models/Cache/Invalidation/InvalidationGetParams.cs index d5eff502..26ed9c65 100644 --- a/src/ImageKit/Models/Cache/Invalidation/InvalidationGetParams.cs +++ b/src/ImageKit/Models/Cache/Invalidation/InvalidationGetParams.cs @@ -43,23 +43,27 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] InvalidationGetParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string requestID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.RequestID = requestID; } #pragma warning restore CS8618 /// public static InvalidationGetParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string requestID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + requestID ); } diff --git a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldDeleteParams.cs b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldDeleteParams.cs index f637b221..4d005432 100644 --- a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldDeleteParams.cs +++ b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldDeleteParams.cs @@ -46,23 +46,27 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] CustomMetadataFieldDeleteParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string id ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.ID = id; } #pragma warning restore CS8618 /// public static CustomMetadataFieldDeleteParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string id ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + id ); } diff --git a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParams.cs b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParams.cs index 09cbb349..a1def4cf 100644 --- a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParams.cs +++ b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParams.cs @@ -110,12 +110,14 @@ IReadOnlyDictionary rawBodyData CustomMetadataFieldUpdateParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string id ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.ID = id; } #pragma warning restore CS8618 @@ -123,13 +125,15 @@ FrozenDictionary rawBodyData public static CustomMetadataFieldUpdateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string id ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + id ); } diff --git a/src/ImageKit/Models/Files/FileDeleteParams.cs b/src/ImageKit/Models/Files/FileDeleteParams.cs index ffd598e5..8ed7ed1f 100644 --- a/src/ImageKit/Models/Files/FileDeleteParams.cs +++ b/src/ImageKit/Models/Files/FileDeleteParams.cs @@ -47,23 +47,27 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] FileDeleteParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string fileID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.FileID = fileID; } #pragma warning restore CS8618 /// public static FileDeleteParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string fileID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + fileID ); } diff --git a/src/ImageKit/Models/Files/FileGetParams.cs b/src/ImageKit/Models/Files/FileGetParams.cs index c14bd131..78e1fb0e 100644 --- a/src/ImageKit/Models/Files/FileGetParams.cs +++ b/src/ImageKit/Models/Files/FileGetParams.cs @@ -44,23 +44,27 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] FileGetParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string fileID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.FileID = fileID; } #pragma warning restore CS8618 /// public static FileGetParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string fileID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + fileID ); } diff --git a/src/ImageKit/Models/Files/FileUpdateParams.cs b/src/ImageKit/Models/Files/FileUpdateParams.cs index da3303af..f78f73fa 100644 --- a/src/ImageKit/Models/Files/FileUpdateParams.cs +++ b/src/ImageKit/Models/Files/FileUpdateParams.cs @@ -70,12 +70,14 @@ IReadOnlyDictionary rawBodyData FileUpdateParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string fileID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.FileID = fileID; } #pragma warning restore CS8618 @@ -83,13 +85,15 @@ FrozenDictionary rawBodyData public static FileUpdateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string fileID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + fileID ); } diff --git a/src/ImageKit/Models/Files/Metadata/MetadataGetParams.cs b/src/ImageKit/Models/Files/Metadata/MetadataGetParams.cs index d9ff63f1..7352b408 100644 --- a/src/ImageKit/Models/Files/Metadata/MetadataGetParams.cs +++ b/src/ImageKit/Models/Files/Metadata/MetadataGetParams.cs @@ -47,23 +47,27 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] MetadataGetParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string fileID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.FileID = fileID; } #pragma warning restore CS8618 /// public static MetadataGetParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string fileID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + fileID ); } diff --git a/src/ImageKit/Models/Files/Versions/VersionDeleteParams.cs b/src/ImageKit/Models/Files/Versions/VersionDeleteParams.cs index 0a1fe22d..a2bf8f31 100644 --- a/src/ImageKit/Models/Files/Versions/VersionDeleteParams.cs +++ b/src/ImageKit/Models/Files/Versions/VersionDeleteParams.cs @@ -48,23 +48,31 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] VersionDeleteParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string fileID, + string versionID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.FileID = fileID; + this.VersionID = versionID; } #pragma warning restore CS8618 /// public static VersionDeleteParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string fileID, + string versionID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + fileID, + versionID ); } diff --git a/src/ImageKit/Models/Files/Versions/VersionGetParams.cs b/src/ImageKit/Models/Files/Versions/VersionGetParams.cs index aaf61c78..44fe8852 100644 --- a/src/ImageKit/Models/Files/Versions/VersionGetParams.cs +++ b/src/ImageKit/Models/Files/Versions/VersionGetParams.cs @@ -46,23 +46,31 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] VersionGetParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string fileID, + string versionID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.FileID = fileID; + this.VersionID = versionID; } #pragma warning restore CS8618 /// public static VersionGetParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string fileID, + string versionID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + fileID, + versionID ); } diff --git a/src/ImageKit/Models/Files/Versions/VersionListParams.cs b/src/ImageKit/Models/Files/Versions/VersionListParams.cs index e4214e02..6a9dea2e 100644 --- a/src/ImageKit/Models/Files/Versions/VersionListParams.cs +++ b/src/ImageKit/Models/Files/Versions/VersionListParams.cs @@ -43,23 +43,27 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] VersionListParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string fileID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.FileID = fileID; } #pragma warning restore CS8618 /// public static VersionListParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string fileID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + fileID ); } diff --git a/src/ImageKit/Models/Files/Versions/VersionRestoreParams.cs b/src/ImageKit/Models/Files/Versions/VersionRestoreParams.cs index d572b182..ca4a4fd5 100644 --- a/src/ImageKit/Models/Files/Versions/VersionRestoreParams.cs +++ b/src/ImageKit/Models/Files/Versions/VersionRestoreParams.cs @@ -46,23 +46,31 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] VersionRestoreParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string fileID, + string versionID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.FileID = fileID; + this.VersionID = versionID; } #pragma warning restore CS8618 /// public static VersionRestoreParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string fileID, + string versionID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + fileID, + versionID ); } diff --git a/src/ImageKit/Models/Folders/Job/JobGetParams.cs b/src/ImageKit/Models/Folders/Job/JobGetParams.cs index d4f17c7e..cf03c15b 100644 --- a/src/ImageKit/Models/Folders/Job/JobGetParams.cs +++ b/src/ImageKit/Models/Folders/Job/JobGetParams.cs @@ -43,23 +43,27 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] JobGetParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string jobID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.JobID = jobID; } #pragma warning restore CS8618 /// public static JobGetParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string jobID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + jobID ); } diff --git a/src/ImageKit/Models/SavedExtensions/SavedExtensionDeleteParams.cs b/src/ImageKit/Models/SavedExtensions/SavedExtensionDeleteParams.cs index 3607d1e3..6d9d0d97 100644 --- a/src/ImageKit/Models/SavedExtensions/SavedExtensionDeleteParams.cs +++ b/src/ImageKit/Models/SavedExtensions/SavedExtensionDeleteParams.cs @@ -43,23 +43,27 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] SavedExtensionDeleteParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string id ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.ID = id; } #pragma warning restore CS8618 /// public static SavedExtensionDeleteParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string id ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + id ); } diff --git a/src/ImageKit/Models/SavedExtensions/SavedExtensionGetParams.cs b/src/ImageKit/Models/SavedExtensions/SavedExtensionGetParams.cs index 6fdd4e0a..264db6bd 100644 --- a/src/ImageKit/Models/SavedExtensions/SavedExtensionGetParams.cs +++ b/src/ImageKit/Models/SavedExtensions/SavedExtensionGetParams.cs @@ -43,23 +43,27 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] SavedExtensionGetParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string id ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.ID = id; } #pragma warning restore CS8618 /// public static SavedExtensionGetParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string id ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + id ); } diff --git a/src/ImageKit/Models/SavedExtensions/SavedExtensionUpdateParams.cs b/src/ImageKit/Models/SavedExtensions/SavedExtensionUpdateParams.cs index 3920c278..081cc4b7 100644 --- a/src/ImageKit/Models/SavedExtensions/SavedExtensionUpdateParams.cs +++ b/src/ImageKit/Models/SavedExtensions/SavedExtensionUpdateParams.cs @@ -119,12 +119,14 @@ IReadOnlyDictionary rawBodyData SavedExtensionUpdateParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string id ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.ID = id; } #pragma warning restore CS8618 @@ -132,13 +134,15 @@ FrozenDictionary rawBodyData public static SavedExtensionUpdateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string id ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + id ); } From dab469ddca42227808aa6dbef3cbe75b0d3b6f69 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 20 Mar 2026 21:32:31 +0000 Subject: [PATCH 084/129] fix(client): handle root bodies in requests properly --- src/ImageKit/Core/JsonDictionary.cs | 56 +---------- src/ImageKit/Core/MultipartJsonDictionary.cs | 62 +------------ src/ImageKit/Core/WrappedJsonSerializer.cs | 87 +++++++++++++++++ .../Core/WrappedMultipartJsonSerializer.cs | 93 +++++++++++++++++++ .../Accounts/Origins/OriginCreateParams.cs | 32 +++---- .../Accounts/Origins/OriginUpdateParams.cs | 32 +++---- src/ImageKit/Models/Files/FileUpdateParams.cs | 32 +++---- 7 files changed, 233 insertions(+), 161 deletions(-) create mode 100644 src/ImageKit/Core/WrappedJsonSerializer.cs create mode 100644 src/ImageKit/Core/WrappedMultipartJsonSerializer.cs diff --git a/src/ImageKit/Core/JsonDictionary.cs b/src/ImageKit/Core/JsonDictionary.cs index 07b60600..b8fdaa69 100644 --- a/src/ImageKit/Core/JsonDictionary.cs +++ b/src/ImageKit/Core/JsonDictionary.cs @@ -94,20 +94,7 @@ public T GetNotNullClass(string key) { throw new ImageKitInvalidDataException($"'{key}' cannot be absent"); } - T deserialized; - try - { - deserialized = - JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException($"'{key}' cannot be null"); - } - catch (JsonException e) - { - throw new ImageKitInvalidDataException( - $"'{key}' must be of type {typeof(T).FullName}", - e - ); - } + T deserialized = WrappedJsonSerializer.GetNotNullClass(element, key); _deserializedData[key] = deserialized; return deserialized; } @@ -123,20 +110,7 @@ public T GetNotNullStruct(string key) { throw new ImageKitInvalidDataException($"'{key}' cannot be absent"); } - T deserialized; - try - { - deserialized = - JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException($"'{key}' cannot be null"); - } - catch (JsonException e) - { - throw new ImageKitInvalidDataException( - $"'{key}' must be of type {typeof(T).FullName}", - e - ); - } + T deserialized = WrappedJsonSerializer.GetNotNullStruct(element, key); _deserializedData[key] = deserialized; return deserialized; } @@ -153,18 +127,7 @@ public T GetNotNullStruct(string key) _deserializedData[key] = null; return null; } - T? deserialized; - try - { - deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - catch (JsonException e) - { - throw new ImageKitInvalidDataException( - $"'{key}' must be of type {typeof(T).FullName}", - e - ); - } + T? deserialized = WrappedJsonSerializer.GetNullableClass(element, key); _deserializedData[key] = deserialized; return deserialized; } @@ -181,18 +144,7 @@ public T GetNotNullStruct(string key) _deserializedData[key] = null; return null; } - T? deserialized; - try - { - deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - catch (JsonException e) - { - throw new ImageKitInvalidDataException( - $"'{key}' must be of type {typeof(T).FullName}", - e - ); - } + T? deserialized = WrappedJsonSerializer.GetNullableStruct(element, key); _deserializedData[key] = deserialized; return deserialized; } diff --git a/src/ImageKit/Core/MultipartJsonDictionary.cs b/src/ImageKit/Core/MultipartJsonDictionary.cs index 909c4693..fcde5210 100644 --- a/src/ImageKit/Core/MultipartJsonDictionary.cs +++ b/src/ImageKit/Core/MultipartJsonDictionary.cs @@ -97,20 +97,7 @@ public T GetNotNullClass(string key) { throw new ImageKitInvalidDataException($"'{key}' cannot be absent"); } - T deserialized; - try - { - deserialized = - MultipartJsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException($"'{key}' cannot be null"); - } - catch (JsonException e) - { - throw new ImageKitInvalidDataException( - $"'{key}' must be of type {typeof(T).FullName}", - e - ); - } + T? deserialized = WrappedMultipartJsonSerializer.GetNotNullClass(element, key); _deserializedData[key] = deserialized; return deserialized; } @@ -126,20 +113,7 @@ public T GetNotNullStruct(string key) { throw new ImageKitInvalidDataException($"'{key}' cannot be absent"); } - T deserialized; - try - { - deserialized = - MultipartJsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new ImageKitInvalidDataException($"'{key}' cannot be null"); - } - catch (JsonException e) - { - throw new ImageKitInvalidDataException( - $"'{key}' must be of type {typeof(T).FullName}", - e - ); - } + T deserialized = WrappedMultipartJsonSerializer.GetNotNullStruct(element, key); _deserializedData[key] = deserialized; return deserialized; } @@ -156,21 +130,7 @@ public T GetNotNullStruct(string key) _deserializedData[key] = null; return null; } - T? deserialized; - try - { - deserialized = MultipartJsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - catch (JsonException e) - { - throw new ImageKitInvalidDataException( - $"'{key}' must be of type {typeof(T).FullName}", - e - ); - } + T? deserialized = WrappedMultipartJsonSerializer.GetNullableClass(element, key); _deserializedData[key] = deserialized; return deserialized; } @@ -187,21 +147,7 @@ public T GetNotNullStruct(string key) _deserializedData[key] = null; return null; } - T? deserialized; - try - { - deserialized = MultipartJsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - catch (JsonException e) - { - throw new ImageKitInvalidDataException( - $"'{key}' must be of type {typeof(T).FullName}", - e - ); - } + T? deserialized = WrappedMultipartJsonSerializer.GetNullableStruct(element, key); _deserializedData[key] = deserialized; return deserialized; } diff --git a/src/ImageKit/Core/WrappedJsonSerializer.cs b/src/ImageKit/Core/WrappedJsonSerializer.cs new file mode 100644 index 00000000..07c93be8 --- /dev/null +++ b/src/ImageKit/Core/WrappedJsonSerializer.cs @@ -0,0 +1,87 @@ +using System.Text.Json; +using ImageKit.Exceptions; + +namespace ImageKit.Core; + +/// +/// Helper class for deserializing <c>JsonElement</c> objects. This handles +/// edge-cases around nullability and reference/value types. +/// +sealed class WrappedJsonSerializer +{ + public static T GetNotNullClass(JsonElement element, string name) + where T : class + { + T deserialized; + try + { + deserialized = + JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ImageKitInvalidDataException($"'{name}' cannot be null"); + } + catch (JsonException e) + { + throw new ImageKitInvalidDataException( + $"'{name}' must be of type {typeof(T).FullName}", + e + ); + } + return deserialized; + } + + public static T GetNotNullStruct(JsonElement element, string name) + where T : struct + { + T deserialized; + try + { + deserialized = + JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ImageKitInvalidDataException($"'{name}' cannot be null"); + } + catch (JsonException e) + { + throw new ImageKitInvalidDataException( + $"'{name}' must be of type {typeof(T).FullName}", + e + ); + } + return deserialized; + } + + public static T? GetNullableClass(JsonElement element, string name) + where T : class + { + T? deserialized; + try + { + deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + catch (JsonException e) + { + throw new ImageKitInvalidDataException( + $"'{name}' must be of type {typeof(T).FullName}", + e + ); + } + return deserialized; + } + + public static T? GetNullableStruct(JsonElement element, string name) + where T : struct + { + T? deserialized; + try + { + deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + catch (JsonException e) + { + throw new ImageKitInvalidDataException( + $"'{name}' must be of type {typeof(T).FullName}", + e + ); + } + return deserialized; + } +} diff --git a/src/ImageKit/Core/WrappedMultipartJsonSerializer.cs b/src/ImageKit/Core/WrappedMultipartJsonSerializer.cs new file mode 100644 index 00000000..d9cb47df --- /dev/null +++ b/src/ImageKit/Core/WrappedMultipartJsonSerializer.cs @@ -0,0 +1,93 @@ +using System.Text.Json; +using ImageKit.Exceptions; + +namespace ImageKit.Core; + +/// +/// Helper class for deserializing <c>MultipartJsonElement</c> objects. +/// This handles edge-cases around nullability and reference/value types. +/// +sealed class WrappedMultipartJsonSerializer +{ + public static T GetNotNullClass(MultipartJsonElement element, string name) + where T : class + { + T deserialized; + try + { + deserialized = + MultipartJsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ImageKitInvalidDataException($"'{name}' cannot be null"); + } + catch (JsonException e) + { + throw new ImageKitInvalidDataException( + $"'{name}' must be of type {typeof(T).FullName}", + e + ); + } + return deserialized; + } + + public static T GetNotNullStruct(MultipartJsonElement element, string name) + where T : struct + { + T deserialized; + try + { + deserialized = + MultipartJsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new ImageKitInvalidDataException($"'{name}' cannot be null"); + } + catch (JsonException e) + { + throw new ImageKitInvalidDataException( + $"'{name}' must be of type {typeof(T).FullName}", + e + ); + } + return deserialized; + } + + public static T? GetNullableClass(MultipartJsonElement element, string name) + where T : class + { + T? deserialized; + try + { + deserialized = MultipartJsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + catch (JsonException e) + { + throw new ImageKitInvalidDataException( + $"'{name}' must be of type {typeof(T).FullName}", + e + ); + } + return deserialized; + } + + public static T? GetNullableStruct(MultipartJsonElement element, string name) + where T : struct + { + T? deserialized; + try + { + deserialized = MultipartJsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + catch (JsonException e) + { + throw new ImageKitInvalidDataException( + $"'{name}' must be of type {typeof(T).FullName}", + e + ); + } + return deserialized; + } +} diff --git a/src/ImageKit/Models/Accounts/Origins/OriginCreateParams.cs b/src/ImageKit/Models/Accounts/Origins/OriginCreateParams.cs index d9efb146..19b8b6b5 100644 --- a/src/ImageKit/Models/Accounts/Origins/OriginCreateParams.cs +++ b/src/ImageKit/Models/Accounts/Origins/OriginCreateParams.cs @@ -19,11 +19,7 @@ namespace ImageKit.Models.Accounts.Origins; /// public record class OriginCreateParams : ParamsBase { - readonly JsonDictionary _rawBodyData = new(); - public IReadOnlyDictionary RawBodyData - { - get { return this._rawBodyData.Freeze(); } - } + public JsonElement RawBodyData { get; private init; } /// /// Schema for origin request resources. @@ -32,10 +28,12 @@ public required OriginRequest OriginRequest { get { - this._rawBodyData.Freeze(); - return this._rawBodyData.GetNotNullClass("OriginRequest"); + return WrappedJsonSerializer.GetNotNullClass( + this.RawBodyData, + "RawBodyData" + ); } - init { this._rawBodyData.Set("OriginRequest", value); } + init { this.RawBodyData = JsonSerializer.SerializeToElement(value); } } public OriginCreateParams() { } @@ -45,19 +43,19 @@ public OriginCreateParams() { } public OriginCreateParams(OriginCreateParams originCreateParams) : base(originCreateParams) { - this._rawBodyData = new(originCreateParams._rawBodyData); + this.RawBodyData = originCreateParams.RawBodyData; } #pragma warning restore CS8618 public OriginCreateParams( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + JsonElement rawBodyData ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); - this._rawBodyData = new(rawBodyData); + this.RawBodyData = rawBodyData; } #pragma warning disable CS8618 @@ -65,12 +63,12 @@ IReadOnlyDictionary rawBodyData OriginCreateParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + JsonElement rawBodyData ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); - this._rawBodyData = new(rawBodyData); + this.RawBodyData = rawBodyData; } #pragma warning restore CS8618 @@ -78,13 +76,13 @@ FrozenDictionary rawBodyData public static OriginCreateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + JsonElement rawBodyData ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + rawBodyData ); } @@ -99,7 +97,7 @@ public override string ToString() => ["QueryData"] = FriendlyJsonPrinter.PrintValue( JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) ), - ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this.RawBodyData), } ), ModelBase.ToStringSerializerOptions @@ -113,7 +111,7 @@ public virtual bool Equals(OriginCreateParams? other) } return this._rawHeaderData.Equals(other._rawHeaderData) && this._rawQueryData.Equals(other._rawQueryData) - && this._rawBodyData.Equals(other._rawBodyData); + && this.RawBodyData.Equals(other.RawBodyData); } public override Uri Url(ClientOptions options) diff --git a/src/ImageKit/Models/Accounts/Origins/OriginUpdateParams.cs b/src/ImageKit/Models/Accounts/Origins/OriginUpdateParams.cs index 0d58c456..c9ccac5e 100644 --- a/src/ImageKit/Models/Accounts/Origins/OriginUpdateParams.cs +++ b/src/ImageKit/Models/Accounts/Origins/OriginUpdateParams.cs @@ -19,11 +19,7 @@ namespace ImageKit.Models.Accounts.Origins; /// public record class OriginUpdateParams : ParamsBase { - readonly JsonDictionary _rawBodyData = new(); - public IReadOnlyDictionary RawBodyData - { - get { return this._rawBodyData.Freeze(); } - } + public JsonElement RawBodyData { get; private init; } public string? ID { get; init; } @@ -34,10 +30,12 @@ public required OriginRequest OriginRequest { get { - this._rawBodyData.Freeze(); - return this._rawBodyData.GetNotNullClass("OriginRequest"); + return WrappedJsonSerializer.GetNotNullClass( + this.RawBodyData, + "RawBodyData" + ); } - init { this._rawBodyData.Set("OriginRequest", value); } + init { this.RawBodyData = JsonSerializer.SerializeToElement(value); } } public OriginUpdateParams() { } @@ -49,19 +47,19 @@ public OriginUpdateParams(OriginUpdateParams originUpdateParams) { this.ID = originUpdateParams.ID; - this._rawBodyData = new(originUpdateParams._rawBodyData); + this.RawBodyData = originUpdateParams.RawBodyData; } #pragma warning restore CS8618 public OriginUpdateParams( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + JsonElement rawBodyData ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); - this._rawBodyData = new(rawBodyData); + this.RawBodyData = rawBodyData; } #pragma warning disable CS8618 @@ -69,13 +67,13 @@ IReadOnlyDictionary rawBodyData OriginUpdateParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData, + JsonElement rawBodyData, string id ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); - this._rawBodyData = new(rawBodyData); + this.RawBodyData = rawBodyData; this.ID = id; } #pragma warning restore CS8618 @@ -84,14 +82,14 @@ string id public static OriginUpdateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData, + JsonElement rawBodyData, string id ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData), + rawBodyData, id ); } @@ -108,7 +106,7 @@ public override string ToString() => ["QueryData"] = FriendlyJsonPrinter.PrintValue( JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) ), - ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this.RawBodyData), } ), ModelBase.ToStringSerializerOptions @@ -123,7 +121,7 @@ public virtual bool Equals(OriginUpdateParams? other) return (this.ID?.Equals(other.ID) ?? other.ID == null) && this._rawHeaderData.Equals(other._rawHeaderData) && this._rawQueryData.Equals(other._rawQueryData) - && this._rawBodyData.Equals(other._rawBodyData); + && this.RawBodyData.Equals(other.RawBodyData); } public override Uri Url(ClientOptions options) diff --git a/src/ImageKit/Models/Files/FileUpdateParams.cs b/src/ImageKit/Models/Files/FileUpdateParams.cs index f78f73fa..3d0deac5 100644 --- a/src/ImageKit/Models/Files/FileUpdateParams.cs +++ b/src/ImageKit/Models/Files/FileUpdateParams.cs @@ -20,11 +20,7 @@ namespace ImageKit.Models.Files; /// public record class FileUpdateParams : ParamsBase { - readonly JsonDictionary _rawBodyData = new(); - public IReadOnlyDictionary RawBodyData - { - get { return this._rawBodyData.Freeze(); } - } + public JsonElement RawBodyData { get; private init; } public string? FileID { get; init; } @@ -35,10 +31,12 @@ public required UpdateFileRequest UpdateFileRequest { get { - this._rawBodyData.Freeze(); - return this._rawBodyData.GetNotNullClass("UpdateFileRequest"); + return WrappedJsonSerializer.GetNotNullClass( + this.RawBodyData, + "RawBodyData" + ); } - init { this._rawBodyData.Set("UpdateFileRequest", value); } + init { this.RawBodyData = JsonSerializer.SerializeToElement(value); } } public FileUpdateParams() { } @@ -50,19 +48,19 @@ public FileUpdateParams(FileUpdateParams fileUpdateParams) { this.FileID = fileUpdateParams.FileID; - this._rawBodyData = new(fileUpdateParams._rawBodyData); + this.RawBodyData = fileUpdateParams.RawBodyData; } #pragma warning restore CS8618 public FileUpdateParams( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + JsonElement rawBodyData ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); - this._rawBodyData = new(rawBodyData); + this.RawBodyData = rawBodyData; } #pragma warning disable CS8618 @@ -70,13 +68,13 @@ IReadOnlyDictionary rawBodyData FileUpdateParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData, + JsonElement rawBodyData, string fileID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); - this._rawBodyData = new(rawBodyData); + this.RawBodyData = rawBodyData; this.FileID = fileID; } #pragma warning restore CS8618 @@ -85,14 +83,14 @@ string fileID public static FileUpdateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData, + JsonElement rawBodyData, string fileID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData), + rawBodyData, fileID ); } @@ -109,7 +107,7 @@ public override string ToString() => ["QueryData"] = FriendlyJsonPrinter.PrintValue( JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) ), - ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this.RawBodyData), } ), ModelBase.ToStringSerializerOptions @@ -124,7 +122,7 @@ public virtual bool Equals(FileUpdateParams? other) return (this.FileID?.Equals(other.FileID) ?? other.FileID == null) && this._rawHeaderData.Equals(other._rawHeaderData) && this._rawQueryData.Equals(other._rawQueryData) - && this._rawBodyData.Equals(other._rawBodyData); + && this.RawBodyData.Equals(other.RawBodyData); } public override Uri Url(ClientOptions options) From 34b3e4442c80d16f6028a6424d305f448f22e6e1 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 23 Mar 2026 12:39:14 +0000 Subject: [PATCH 085/129] chore(internal): update gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index cb0f7844..1ce7f848 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .prism.log +.stdy.log bin/ obj/ .vs/ From 9b8f4768182dfde1955cde7e65afd6457c0b31ee Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 24 Mar 2026 15:17:25 +0000 Subject: [PATCH 086/129] chore(ci): skip lint on metadata-only changes Note that we still want to run tests, as these depend on the metadata. --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a23d2a74..81d69f2b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ jobs: timeout-minutes: 10 name: lint runs-on: ${{ github.repository == 'stainless-sdks/imagekit-csharp' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} - if: github.event_name == 'push' || github.event.pull_request.head.repo.fork + if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata') steps: - uses: actions/checkout@v6 @@ -38,7 +38,7 @@ jobs: timeout-minutes: 10 name: build runs-on: ${{ github.repository == 'stainless-sdks/imagekit-csharp' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} - if: github.event_name == 'push' || github.event.pull_request.head.repo.fork + if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata') steps: - uses: actions/checkout@v6 From fce341d12058b8fdaa4673cf94b8f63972baa769 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 31 Mar 2026 15:15:23 +0000 Subject: [PATCH 087/129] fix(client): allow cancelling when enumerating over an http response --- src/ImageKit/Core/HttpResponse.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/ImageKit/Core/HttpResponse.cs b/src/ImageKit/Core/HttpResponse.cs index f64d9c0f..478cbc91 100644 --- a/src/ImageKit/Core/HttpResponse.cs +++ b/src/ImageKit/Core/HttpResponse.cs @@ -4,6 +4,7 @@ using System.IO; using System.Net; using System.Net.Http; +using System.Runtime.CompilerServices; using System.Text.Json; using System.Threading.Tasks; using ImageKit.Exceptions; @@ -161,12 +162,17 @@ internal StreamingHttpResponse( this.CancellationToken = response.CancellationToken; } - public IAsyncEnumerable Enumerate(Threading::CancellationToken cancellationToken = default) + public async IAsyncEnumerable Enumerate( + [EnumeratorCancellationAttribute] Threading::CancellationToken cancellationToken = default + ) { using var cts = Threading::CancellationTokenSource.CreateLinkedTokenSource( this.CancellationToken, cancellationToken ); - return this._enumerate(cts.Token); + await foreach (var item in this._enumerate(cts.Token)) + { + yield return item; + } } } From d240560a6ea9a06d2dc454a8c4c04ad34ef2bd41 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 31 Mar 2026 18:02:56 +0000 Subject: [PATCH 088/129] fix(client): don't overzealously validate union variants when deserializing --- .../Models/Accounts/Origins/OriginRequest.cs | 24 +++++++------------ .../Models/Accounts/Origins/OriginResponse.cs | 24 +++++++------------ .../UrlEndpoints/UrlEndpointCreateParams.cs | 9 +++---- .../UrlEndpoints/UrlEndpointRequest.cs | 9 +++---- .../UrlEndpoints/UrlEndpointResponse.cs | 9 +++---- .../UrlEndpoints/UrlEndpointUpdateParams.cs | 9 +++---- .../Models/Assets/AssetListResponse.cs | 8 ++----- .../Models/Beta/V2/Files/FileUploadParams.cs | 16 ++++--------- src/ImageKit/Models/ExtensionConfig.cs | 21 ++++++---------- src/ImageKit/Models/Files/FileUploadParams.cs | 16 ++++--------- src/ImageKit/Models/Overlay.cs | 15 ++++-------- .../Models/UnnamedSchemaWithArrayParent0.cs | 24 +++++++------------ 12 files changed, 58 insertions(+), 126 deletions(-) diff --git a/src/ImageKit/Models/Accounts/Origins/OriginRequest.cs b/src/ImageKit/Models/Accounts/Origins/OriginRequest.cs index 6ddc8849..ddf96a3a 100644 --- a/src/ImageKit/Models/Accounts/Origins/OriginRequest.cs +++ b/src/ImageKit/Models/Accounts/Origins/OriginRequest.cs @@ -635,11 +635,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } @@ -653,11 +652,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } @@ -674,11 +672,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } @@ -692,11 +689,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } @@ -710,11 +706,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } @@ -728,11 +723,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } @@ -746,11 +740,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } @@ -764,11 +757,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/ImageKit/Models/Accounts/Origins/OriginResponse.cs b/src/ImageKit/Models/Accounts/Origins/OriginResponse.cs index 56c46f8d..c0cf4111 100644 --- a/src/ImageKit/Models/Accounts/Origins/OriginResponse.cs +++ b/src/ImageKit/Models/Accounts/Origins/OriginResponse.cs @@ -624,11 +624,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } @@ -645,11 +644,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } @@ -666,11 +664,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } @@ -687,11 +684,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } @@ -708,11 +704,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } @@ -729,11 +724,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } @@ -750,11 +744,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } @@ -771,11 +764,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointCreateParams.cs b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointCreateParams.cs index 0d12b923..321a6bad 100644 --- a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointCreateParams.cs +++ b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointCreateParams.cs @@ -490,11 +490,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } @@ -508,11 +507,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } @@ -526,11 +524,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointRequest.cs b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointRequest.cs index dbcdaf45..6f485a42 100644 --- a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointRequest.cs +++ b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointRequest.cs @@ -450,11 +450,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } @@ -472,11 +471,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } @@ -494,11 +492,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointResponse.cs b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointResponse.cs index e4071337..bd7f8eda 100644 --- a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointResponse.cs +++ b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointResponse.cs @@ -445,11 +445,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } @@ -467,11 +466,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } @@ -489,11 +487,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParams.cs b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParams.cs index b8ed99d1..8103f8b2 100644 --- a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParams.cs +++ b/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParams.cs @@ -537,11 +537,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } @@ -559,11 +558,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } @@ -581,11 +579,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/ImageKit/Models/Assets/AssetListResponse.cs b/src/ImageKit/Models/Assets/AssetListResponse.cs index f63a4281..f8601ce4 100644 --- a/src/ImageKit/Models/Assets/AssetListResponse.cs +++ b/src/ImageKit/Models/Assets/AssetListResponse.cs @@ -265,12 +265,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } @@ -284,12 +282,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/ImageKit/Models/Beta/V2/Files/FileUploadParams.cs b/src/ImageKit/Models/Beta/V2/Files/FileUploadParams.cs index ae95bda9..e956d593 100644 --- a/src/ImageKit/Models/Beta/V2/Files/FileUploadParams.cs +++ b/src/ImageKit/Models/Beta/V2/Files/FileUploadParams.cs @@ -1151,12 +1151,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } @@ -1170,12 +1168,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } @@ -1189,12 +1185,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } @@ -1208,12 +1202,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/ImageKit/Models/ExtensionConfig.cs b/src/ImageKit/Models/ExtensionConfig.cs index bf6c8794..c21e3bc3 100644 --- a/src/ImageKit/Models/ExtensionConfig.cs +++ b/src/ImageKit/Models/ExtensionConfig.cs @@ -327,11 +327,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } @@ -348,11 +347,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } @@ -366,11 +364,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } @@ -387,11 +384,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } @@ -1249,11 +1245,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } @@ -1267,11 +1262,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } @@ -1285,11 +1279,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/ImageKit/Models/Files/FileUploadParams.cs b/src/ImageKit/Models/Files/FileUploadParams.cs index 2eeaf662..7f079878 100644 --- a/src/ImageKit/Models/Files/FileUploadParams.cs +++ b/src/ImageKit/Models/Files/FileUploadParams.cs @@ -1229,12 +1229,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } @@ -1248,12 +1246,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } @@ -1267,12 +1263,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } @@ -1286,12 +1280,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/ImageKit/Models/Overlay.cs b/src/ImageKit/Models/Overlay.cs index 144c6514..b24822b8 100644 --- a/src/ImageKit/Models/Overlay.cs +++ b/src/ImageKit/Models/Overlay.cs @@ -431,11 +431,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } @@ -449,11 +448,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } @@ -467,11 +465,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } @@ -488,11 +485,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } @@ -509,11 +505,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/ImageKit/Models/UnnamedSchemaWithArrayParent0.cs b/src/ImageKit/Models/UnnamedSchemaWithArrayParent0.cs index 6a9eb639..8e0f321e 100644 --- a/src/ImageKit/Models/UnnamedSchemaWithArrayParent0.cs +++ b/src/ImageKit/Models/UnnamedSchemaWithArrayParent0.cs @@ -394,11 +394,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } @@ -416,11 +415,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } @@ -438,11 +436,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } @@ -456,11 +453,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } @@ -478,11 +474,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } @@ -1437,11 +1432,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } @@ -1459,11 +1453,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } @@ -1481,11 +1474,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + catch (JsonException) { // ignore } From 581632583d310ac6a67be73a6b019fef3637ebc1 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 31 Mar 2026 19:16:31 +0000 Subject: [PATCH 089/129] feat(client): enable gzip decompression --- src/ImageKit/Core/ClientOptions.cs | 3 +- src/ImageKit/Core/DecompressionMethods.cs | 49 +++++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 src/ImageKit/Core/DecompressionMethods.cs diff --git a/src/ImageKit/Core/ClientOptions.cs b/src/ImageKit/Core/ClientOptions.cs index 2a9c6d7f..c5bcc0f7 100644 --- a/src/ImageKit/Core/ClientOptions.cs +++ b/src/ImageKit/Core/ClientOptions.cs @@ -22,7 +22,8 @@ public record struct ClientOptions() /// /// The HTTP client to use for making requests in the SDK. /// - public HttpClient HttpClient { get; set; } = new(); + public HttpClient HttpClient { get; set; } = + new(new HttpClientHandler() { AutomaticDecompression = DecompressionMethods.Available }); Lazy _baseUrl = new(() => Environment.GetEnvironmentVariable("IMAGE_KIT_BASE_URL") ?? EnvironmentUrl.Production diff --git a/src/ImageKit/Core/DecompressionMethods.cs b/src/ImageKit/Core/DecompressionMethods.cs new file mode 100644 index 00000000..187fe0ca --- /dev/null +++ b/src/ImageKit/Core/DecompressionMethods.cs @@ -0,0 +1,49 @@ +using System.IO; +using System.IO.Compression; +using Net = System.Net; + +namespace ImageKit.Core; + +static class DecompressionMethods +{ + internal static readonly Net::DecompressionMethods Available; + + static DecompressionMethods() + { + try + { + // Minimal valid GZip payload (empty body). + var gzipPayload = new byte[] + { + 0x1f, + 0x8b, + 0x08, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x03, + 0x03, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + }; + using var memoryStream = new MemoryStream(gzipPayload); + using var gzipStream = new GZipStream(memoryStream, CompressionMode.Decompress); + gzipStream.CopyTo(Stream.Null); + Available = Net::DecompressionMethods.GZip; + } + catch + { + Available = Net::DecompressionMethods.None; + } + } +} From c78c8706445418d3ff8888c9665d3d62eb7d8dd8 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 6 Apr 2026 06:34:54 +0000 Subject: [PATCH 090/129] feat(api): Introduce lxc, lyc, lap parameters in overlays. --- .stats.yml | 4 +- src/ImageKit.Tests/Models/BaseOverlayTest.cs | 21 + .../Models/GetImageAttributesOptionsTest.cs | 21 + src/ImageKit.Tests/Models/ImageOverlayTest.cs | 63 ++ .../Models/OverlayPositionTest.cs | 203 ++++++ src/ImageKit.Tests/Models/OverlayTest.cs | 42 ++ .../Models/SolidColorOverlayTest.cs | 21 + src/ImageKit.Tests/Models/SrcOptionsTest.cs | 21 + .../Models/SubtitleOverlayTest.cs | 21 + src/ImageKit.Tests/Models/TextOverlayTest.cs | 21 + .../Models/TransformationTest.cs | 57 +- src/ImageKit.Tests/Models/VideoOverlayTest.cs | 63 ++ src/ImageKit/Core/ModelBase.cs | 1 + src/ImageKit/Models/ExtensionConfig.cs | 11 +- src/ImageKit/Models/OverlayPosition.cs | 668 +++++++++++++++++- src/ImageKit/Models/Transformation.cs | 80 ++- .../Models/UnnamedSchemaWithArrayParent0.cs | 11 +- 17 files changed, 1250 insertions(+), 79 deletions(-) diff --git a/.stats.yml b/.stats.yml index 749d6988..df5aafb6 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-83a7f3659a437113f2a79e1e72794be19eff00ec232fd0206198c80364ccfebf.yml -openapi_spec_hash: b327552548ab641eb4ea3b45e643dfce +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-63aff1629530786015da3c86131afa8a9b60545d488884b77641f1d4b89c6e9d.yml +openapi_spec_hash: 586d357bd7e5217d240a99e0d83c6d1f config_hash: 47cb702ee2cb52c58d803ae39ade9b44 diff --git a/src/ImageKit.Tests/Models/BaseOverlayTest.cs b/src/ImageKit.Tests/Models/BaseOverlayTest.cs index 66b3f066..03fa60af 100644 --- a/src/ImageKit.Tests/Models/BaseOverlayTest.cs +++ b/src/ImageKit.Tests/Models/BaseOverlayTest.cs @@ -15,9 +15,12 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -30,9 +33,12 @@ public void FieldRoundtrip_Works() ApiEnum expectedLayerMode = LayerMode.Multiply; OverlayPosition expectedPosition = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }; OverlayTiming expectedTiming = new() { @@ -54,9 +60,12 @@ public void SerializationRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -83,9 +92,12 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -105,9 +117,12 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum expectedLayerMode = LayerMode.Multiply; OverlayPosition expectedPosition = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }; OverlayTiming expectedTiming = new() { @@ -129,9 +144,12 @@ public void Validation_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -206,9 +224,12 @@ public void CopyConstructor_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { diff --git a/src/ImageKit.Tests/Models/GetImageAttributesOptionsTest.cs b/src/ImageKit.Tests/Models/GetImageAttributesOptionsTest.cs index f38eddfe..be0824d6 100644 --- a/src/ImageKit.Tests/Models/GetImageAttributesOptionsTest.cs +++ b/src/ImageKit.Tests/Models/GetImageAttributesOptionsTest.cs @@ -60,9 +60,12 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -168,9 +171,12 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -316,9 +322,12 @@ public void SerializationRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -438,9 +447,12 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -553,9 +565,12 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -701,9 +716,12 @@ public void Validation_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -921,9 +939,12 @@ public void CopyConstructor_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { diff --git a/src/ImageKit.Tests/Models/ImageOverlayTest.cs b/src/ImageKit.Tests/Models/ImageOverlayTest.cs index 06c31fcf..05d97bf4 100644 --- a/src/ImageKit.Tests/Models/ImageOverlayTest.cs +++ b/src/ImageKit.Tests/Models/ImageOverlayTest.cs @@ -16,9 +16,12 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -71,9 +74,12 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -129,9 +135,12 @@ public void FieldRoundtrip_Works() ApiEnum expectedLayerMode = LayerMode.Multiply; OverlayPosition expectedPosition = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }; OverlayTiming expectedTiming = new() { @@ -185,9 +194,12 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -261,9 +273,12 @@ public void SerializationRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -316,9 +331,12 @@ public void SerializationRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -388,9 +406,12 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -443,9 +464,12 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -508,9 +532,12 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum expectedLayerMode = LayerMode.Multiply; OverlayPosition expectedPosition = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }; OverlayTiming expectedTiming = new() { @@ -564,9 +591,12 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -640,9 +670,12 @@ public void Validation_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -695,9 +728,12 @@ public void Validation_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -831,9 +867,12 @@ public void CopyConstructor_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -886,9 +925,12 @@ public void CopyConstructor_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -999,9 +1041,12 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -1100,9 +1145,12 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -1215,9 +1263,12 @@ public void SerializationRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -1329,9 +1380,12 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -1437,9 +1491,12 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -1552,9 +1609,12 @@ public void Validation_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -1712,9 +1772,12 @@ public void CopyConstructor_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { diff --git a/src/ImageKit.Tests/Models/OverlayPositionTest.cs b/src/ImageKit.Tests/Models/OverlayPositionTest.cs index f38eb42b..69ec6237 100644 --- a/src/ImageKit.Tests/Models/OverlayPositionTest.cs +++ b/src/ImageKit.Tests/Models/OverlayPositionTest.cs @@ -12,18 +12,27 @@ public void FieldRoundtrip_Works() { var model = new OverlayPosition { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }; + ApiEnum expectedAnchorPoint = AnchorPoint.Top; ApiEnum expectedFocus = Focus.Center; X expectedX = 0; + XCenter expectedXCenter = 0; Y expectedY = 0; + YCenter expectedYCenter = 0; + Assert.Equal(expectedAnchorPoint, model.AnchorPoint); Assert.Equal(expectedFocus, model.Focus); Assert.Equal(expectedX, model.X); + Assert.Equal(expectedXCenter, model.XCenter); Assert.Equal(expectedY, model.Y); + Assert.Equal(expectedYCenter, model.YCenter); } [Fact] @@ -31,9 +40,12 @@ public void SerializationRoundtrip_Works() { var model = new OverlayPosition { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -50,9 +62,12 @@ public void FieldRoundtripThroughSerialization_Works() { var model = new OverlayPosition { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -62,13 +77,19 @@ public void FieldRoundtripThroughSerialization_Works() ); Assert.NotNull(deserialized); + ApiEnum expectedAnchorPoint = AnchorPoint.Top; ApiEnum expectedFocus = Focus.Center; X expectedX = 0; + XCenter expectedXCenter = 0; Y expectedY = 0; + YCenter expectedYCenter = 0; + Assert.Equal(expectedAnchorPoint, deserialized.AnchorPoint); Assert.Equal(expectedFocus, deserialized.Focus); Assert.Equal(expectedX, deserialized.X); + Assert.Equal(expectedXCenter, deserialized.XCenter); Assert.Equal(expectedY, deserialized.Y); + Assert.Equal(expectedYCenter, deserialized.YCenter); } [Fact] @@ -76,9 +97,12 @@ public void Validation_Works() { var model = new OverlayPosition { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }; model.Validate(); @@ -89,12 +113,18 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { var model = new OverlayPosition { }; + Assert.Null(model.AnchorPoint); + Assert.False(model.RawData.ContainsKey("anchorPoint")); Assert.Null(model.Focus); Assert.False(model.RawData.ContainsKey("focus")); Assert.Null(model.X); Assert.False(model.RawData.ContainsKey("x")); + Assert.Null(model.XCenter); + Assert.False(model.RawData.ContainsKey("xCenter")); Assert.Null(model.Y); Assert.False(model.RawData.ContainsKey("y")); + Assert.Null(model.YCenter); + Assert.False(model.RawData.ContainsKey("yCenter")); } [Fact] @@ -111,17 +141,26 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() var model = new OverlayPosition { // Null should be interpreted as omitted for these properties + AnchorPoint = null, Focus = null, X = null, + XCenter = null, Y = null, + YCenter = null, }; + Assert.Null(model.AnchorPoint); + Assert.False(model.RawData.ContainsKey("anchorPoint")); Assert.Null(model.Focus); Assert.False(model.RawData.ContainsKey("focus")); Assert.Null(model.X); Assert.False(model.RawData.ContainsKey("x")); + Assert.Null(model.XCenter); + Assert.False(model.RawData.ContainsKey("xCenter")); Assert.Null(model.Y); Assert.False(model.RawData.ContainsKey("y")); + Assert.Null(model.YCenter); + Assert.False(model.RawData.ContainsKey("yCenter")); } [Fact] @@ -130,9 +169,12 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() var model = new OverlayPosition { // Null should be interpreted as omitted for these properties + AnchorPoint = null, Focus = null, X = null, + XCenter = null, Y = null, + YCenter = null, }; model.Validate(); @@ -143,9 +185,12 @@ public void CopyConstructor_Works() { var model = new OverlayPosition { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }; OverlayPosition copied = new(model); @@ -154,6 +199,78 @@ public void CopyConstructor_Works() } } +public class AnchorPointTest : TestBase +{ + [Theory] + [InlineData(AnchorPoint.Top)] + [InlineData(AnchorPoint.Left)] + [InlineData(AnchorPoint.Right)] + [InlineData(AnchorPoint.Bottom)] + [InlineData(AnchorPoint.TopLeft)] + [InlineData(AnchorPoint.TopRight)] + [InlineData(AnchorPoint.BottomLeft)] + [InlineData(AnchorPoint.BottomRight)] + [InlineData(AnchorPoint.Center)] + public void Validation_Works(AnchorPoint rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(AnchorPoint.Top)] + [InlineData(AnchorPoint.Left)] + [InlineData(AnchorPoint.Right)] + [InlineData(AnchorPoint.Bottom)] + [InlineData(AnchorPoint.TopLeft)] + [InlineData(AnchorPoint.TopRight)] + [InlineData(AnchorPoint.BottomLeft)] + [InlineData(AnchorPoint.BottomRight)] + [InlineData(AnchorPoint.Center)] + public void SerializationRoundtrip_Works(AnchorPoint rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + public class FocusTest : TestBase { [Theory] @@ -263,6 +380,49 @@ public void StringSerializationRoundtripWorks() } } +public class XCenterTest : TestBase +{ + [Fact] + public void DoubleValidationWorks() + { + XCenter value = 0; + value.Validate(); + } + + [Fact] + public void StringValidationWorks() + { + XCenter value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + XCenter value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + XCenter value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + public class YTest : TestBase { [Fact] @@ -299,3 +459,46 @@ public void StringSerializationRoundtripWorks() Assert.Equal(value, deserialized); } } + +public class YCenterTest : TestBase +{ + [Fact] + public void DoubleValidationWorks() + { + YCenter value = 0; + value.Validate(); + } + + [Fact] + public void StringValidationWorks() + { + YCenter value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + YCenter value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + YCenter value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} diff --git a/src/ImageKit.Tests/Models/OverlayTest.cs b/src/ImageKit.Tests/Models/OverlayTest.cs index 76d92332..ae78c797 100644 --- a/src/ImageKit.Tests/Models/OverlayTest.cs +++ b/src/ImageKit.Tests/Models/OverlayTest.cs @@ -14,9 +14,12 @@ public void TextValidationWorks() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -57,9 +60,12 @@ public void ImageValidationWorks() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -112,9 +118,12 @@ public void ImageValidationWorks() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -177,9 +186,12 @@ public void VideoValidationWorks() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -232,9 +244,12 @@ public void VideoValidationWorks() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -297,9 +312,12 @@ public void SubtitleValidationWorks() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -334,9 +352,12 @@ public void SolidColorValidationWorks() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -369,9 +390,12 @@ public void TextSerializationRoundtripWorks() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -418,9 +442,12 @@ public void ImageSerializationRoundtripWorks() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -473,9 +500,12 @@ public void ImageSerializationRoundtripWorks() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -544,9 +574,12 @@ public void VideoSerializationRoundtripWorks() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -599,9 +632,12 @@ public void VideoSerializationRoundtripWorks() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -670,9 +706,12 @@ public void SubtitleSerializationRoundtripWorks() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -713,9 +752,12 @@ public void SolidColorSerializationRoundtripWorks() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { diff --git a/src/ImageKit.Tests/Models/SolidColorOverlayTest.cs b/src/ImageKit.Tests/Models/SolidColorOverlayTest.cs index 7b9aa0bf..6ae4efdc 100644 --- a/src/ImageKit.Tests/Models/SolidColorOverlayTest.cs +++ b/src/ImageKit.Tests/Models/SolidColorOverlayTest.cs @@ -15,9 +15,12 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -43,9 +46,12 @@ public void FieldRoundtrip_Works() ApiEnum expectedLayerMode = LayerMode.Multiply; OverlayPosition expectedPosition = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }; OverlayTiming expectedTiming = new() { @@ -89,9 +95,12 @@ public void SerializationRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -131,9 +140,12 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -166,9 +178,12 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum expectedLayerMode = LayerMode.Multiply; OverlayPosition expectedPosition = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }; OverlayTiming expectedTiming = new() { @@ -212,9 +227,12 @@ public void Validation_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -312,9 +330,12 @@ public void CopyConstructor_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { diff --git a/src/ImageKit.Tests/Models/SrcOptionsTest.cs b/src/ImageKit.Tests/Models/SrcOptionsTest.cs index 33cb777e..d8677cfe 100644 --- a/src/ImageKit.Tests/Models/SrcOptionsTest.cs +++ b/src/ImageKit.Tests/Models/SrcOptionsTest.cs @@ -60,9 +60,12 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -164,9 +167,12 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -294,9 +300,12 @@ public void SerializationRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -412,9 +421,12 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -523,9 +535,12 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -653,9 +668,12 @@ public void Validation_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -845,9 +863,12 @@ public void CopyConstructor_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { diff --git a/src/ImageKit.Tests/Models/SubtitleOverlayTest.cs b/src/ImageKit.Tests/Models/SubtitleOverlayTest.cs index 882bbbc2..6aa3c431 100644 --- a/src/ImageKit.Tests/Models/SubtitleOverlayTest.cs +++ b/src/ImageKit.Tests/Models/SubtitleOverlayTest.cs @@ -16,9 +16,12 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -46,9 +49,12 @@ public void FieldRoundtrip_Works() ApiEnum expectedLayerMode = LayerMode.Multiply; OverlayPosition expectedPosition = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }; OverlayTiming expectedTiming = new() { @@ -96,9 +102,12 @@ public void SerializationRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -140,9 +149,12 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -177,9 +189,12 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum expectedLayerMode = LayerMode.Multiply; OverlayPosition expectedPosition = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }; OverlayTiming expectedTiming = new() { @@ -227,9 +242,12 @@ public void Validation_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -335,9 +353,12 @@ public void CopyConstructor_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { diff --git a/src/ImageKit.Tests/Models/TextOverlayTest.cs b/src/ImageKit.Tests/Models/TextOverlayTest.cs index b047d512..2e222480 100644 --- a/src/ImageKit.Tests/Models/TextOverlayTest.cs +++ b/src/ImageKit.Tests/Models/TextOverlayTest.cs @@ -16,9 +16,12 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -52,9 +55,12 @@ public void FieldRoundtrip_Works() ApiEnum expectedLayerMode = LayerMode.Multiply; OverlayPosition expectedPosition = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }; OverlayTiming expectedTiming = new() { @@ -108,9 +114,12 @@ public void SerializationRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -158,9 +167,12 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -201,9 +213,12 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum expectedLayerMode = LayerMode.Multiply; OverlayPosition expectedPosition = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }; OverlayTiming expectedTiming = new() { @@ -257,9 +272,12 @@ public void Validation_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -371,9 +389,12 @@ public void CopyConstructor_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { diff --git a/src/ImageKit.Tests/Models/TransformationTest.cs b/src/ImageKit.Tests/Models/TransformationTest.cs index cd08f493..7db3251e 100644 --- a/src/ImageKit.Tests/Models/TransformationTest.cs +++ b/src/ImageKit.Tests/Models/TransformationTest.cs @@ -52,9 +52,12 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -145,9 +148,12 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -195,9 +201,9 @@ public void FieldRoundtrip_Works() ApiEnum expectedVideoCodec = VideoCodec.H264; TransformationWidth expectedWidth = 300; TransformationX expectedX = 0; - XCenter expectedXCenter = 0; + TransformationXCenter expectedXCenter = 0; TransformationY expectedY = 0; - YCenter expectedYCenter = 0; + TransformationYCenter expectedYCenter = 0; double expectedZoom = 0; Assert.Equal(expectedAIChangeBackground, model.AIChangeBackground); @@ -305,9 +311,12 @@ public void SerializationRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -411,9 +420,12 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -511,9 +523,12 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -561,9 +576,9 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum expectedVideoCodec = VideoCodec.H264; TransformationWidth expectedWidth = 300; TransformationX expectedX = 0; - XCenter expectedXCenter = 0; + TransformationXCenter expectedXCenter = 0; TransformationY expectedY = 0; - YCenter expectedYCenter = 0; + TransformationYCenter expectedYCenter = 0; double expectedZoom = 0; Assert.Equal(expectedAIChangeBackground, deserialized.AIChangeBackground); @@ -671,9 +686,12 @@ public void Validation_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -1131,9 +1149,12 @@ public void CopyConstructor_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -3209,28 +3230,28 @@ public void StringSerializationRoundtripWorks() } } -public class XCenterTest : TestBase +public class TransformationXCenterTest : TestBase { [Fact] public void DoubleValidationWorks() { - XCenter value = 0; + TransformationXCenter value = 0; value.Validate(); } [Fact] public void StringValidationWorks() { - XCenter value = "string"; + TransformationXCenter value = "string"; value.Validate(); } [Fact] public void DoubleSerializationRoundtripWorks() { - XCenter value = 0; + TransformationXCenter value = 0; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -3241,9 +3262,9 @@ public void DoubleSerializationRoundtripWorks() [Fact] public void StringSerializationRoundtripWorks() { - XCenter value = "string"; + TransformationXCenter value = "string"; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -3295,28 +3316,28 @@ public void StringSerializationRoundtripWorks() } } -public class YCenterTest : TestBase +public class TransformationYCenterTest : TestBase { [Fact] public void DoubleValidationWorks() { - YCenter value = 0; + TransformationYCenter value = 0; value.Validate(); } [Fact] public void StringValidationWorks() { - YCenter value = "string"; + TransformationYCenter value = "string"; value.Validate(); } [Fact] public void DoubleSerializationRoundtripWorks() { - YCenter value = 0; + TransformationYCenter value = 0; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -3327,9 +3348,9 @@ public void DoubleSerializationRoundtripWorks() [Fact] public void StringSerializationRoundtripWorks() { - YCenter value = "string"; + TransformationYCenter value = "string"; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); diff --git a/src/ImageKit.Tests/Models/VideoOverlayTest.cs b/src/ImageKit.Tests/Models/VideoOverlayTest.cs index 60dc9c37..d1e345e4 100644 --- a/src/ImageKit.Tests/Models/VideoOverlayTest.cs +++ b/src/ImageKit.Tests/Models/VideoOverlayTest.cs @@ -16,9 +16,12 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -71,9 +74,12 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -129,9 +135,12 @@ public void FieldRoundtrip_Works() ApiEnum expectedLayerMode = LayerMode.Multiply; OverlayPosition expectedPosition = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }; OverlayTiming expectedTiming = new() { @@ -186,9 +195,12 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -262,9 +274,12 @@ public void SerializationRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -317,9 +332,12 @@ public void SerializationRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -389,9 +407,12 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -444,9 +465,12 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -509,9 +533,12 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum expectedLayerMode = LayerMode.Multiply; OverlayPosition expectedPosition = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }; OverlayTiming expectedTiming = new() { @@ -566,9 +593,12 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -642,9 +672,12 @@ public void Validation_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -697,9 +730,12 @@ public void Validation_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -833,9 +869,12 @@ public void CopyConstructor_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -888,9 +927,12 @@ public void CopyConstructor_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -1001,9 +1043,12 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -1103,9 +1148,12 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -1218,9 +1266,12 @@ public void SerializationRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -1332,9 +1383,12 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -1441,9 +1495,12 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -1556,9 +1613,12 @@ public void Validation_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -1716,9 +1776,12 @@ public void CopyConstructor_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { diff --git a/src/ImageKit/Core/ModelBase.cs b/src/ImageKit/Core/ModelBase.cs index 7cc9e272..616e6674 100644 --- a/src/ImageKit/Core/ModelBase.cs +++ b/src/ImageKit/Core/ModelBase.cs @@ -32,6 +32,7 @@ protected ModelBase(ModelBase modelBase) new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), + new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), diff --git a/src/ImageKit/Models/ExtensionConfig.cs b/src/ImageKit/Models/ExtensionConfig.cs index c21e3bc3..88cd9fe8 100644 --- a/src/ImageKit/Models/ExtensionConfig.cs +++ b/src/ImageKit/Models/ExtensionConfig.cs @@ -1374,8 +1374,10 @@ public long? MinSelections } /// - /// Array of possible tag values. Combined length of all strings must not exceed - /// 500 characters. Cannot contain the `%` character. + /// Array of possible tag values. The combined length of all strings must not + /// exceed 500 characters, and values cannot include the `%` character. When + /// providing large vocabularies (more than 30 items), the AI may not follow + /// the list strictly. /// public IReadOnlyList? Vocabulary { @@ -1544,7 +1546,10 @@ public long? MinSelections } /// - /// Array of possible values matching the custom metadata field type. + /// An array of possible values matching the custom metadata field type. If not + /// provided for SingleSelect or MultiSelect field types, all values from the + /// custom metadata field definition will be used. When providing large vocabularies + /// (above 30 items), the AI may not strictly adhere to the list. /// public IReadOnlyList? Vocabulary { diff --git a/src/ImageKit/Models/OverlayPosition.cs b/src/ImageKit/Models/OverlayPosition.cs index e4d94de8..33f724d8 100644 --- a/src/ImageKit/Models/OverlayPosition.cs +++ b/src/ImageKit/Models/OverlayPosition.cs @@ -12,9 +12,33 @@ namespace ImageKit.Models; [JsonConverter(typeof(JsonModelConverter))] public sealed record class OverlayPosition : JsonModel { + /// + /// Sets the anchor point on the base asset from which the overlay offset is + /// calculated. The default value is `top_left`. Maps to `lap` in the URL. Can + /// only be used with one or more of `x`, `y`, `xCenter`, or `yCenter`. + /// + public ApiEnum? AnchorPoint + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("anchorPoint"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("anchorPoint", value); + } + } + /// /// Specifies the position of the overlay relative to the parent image or video. - /// Maps to `lfo` in the URL. + /// If one or more of `x`, `y`, `xCenter`, or `yCenter` parameters are specified, + /// this parameter is ignored. Maps to `lfo` in the URL. /// public ApiEnum? Focus { @@ -58,6 +82,30 @@ public X? X } } + /// + /// Specifies the x-coordinate on the base asset where the overlay's center will + /// be positioned. It also accepts arithmetic expressions such as `bw_mul_0.4` + /// or `bw_sub_cw`. Maps to `lxc` in the URL. Cannot be used together with `x`, + /// but can be used with `y`. Learn about [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + /// + public XCenter? XCenter + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("xCenter"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("xCenter", value); + } + } + /// /// Specifies the y-coordinate of the top-left corner of the base asset where /// the overlay's top-left corner will be positioned. It also accepts arithmetic @@ -82,12 +130,39 @@ public Y? Y } } + /// + /// Specifies the y-coordinate on the base asset where the overlay's center will + /// be positioned. It also accepts arithmetic expressions such as `bh_mul_0.4` + /// or `bh_sub_ch`. Maps to `lyc` in the URL. Cannot be used together with `y`, + /// but can be used with `x`. Learn about [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + /// + public YCenter? YCenter + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("yCenter"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("yCenter", value); + } + } + /// public override void Validate() { + this.AnchorPoint?.Validate(); this.Focus?.Validate(); this.X?.Validate(); + this.XCenter?.Validate(); this.Y?.Validate(); + this.YCenter?.Validate(); } public OverlayPosition() { } @@ -126,8 +201,79 @@ public OverlayPosition FromRawUnchecked(IReadOnlyDictionary } /// -/// Specifies the position of the overlay relative to the parent image or video. Maps -/// to `lfo` in the URL. +/// Sets the anchor point on the base asset from which the overlay offset is calculated. +/// The default value is `top_left`. Maps to `lap` in the URL. Can only be used with +/// one or more of `x`, `y`, `xCenter`, or `yCenter`. +/// +[JsonConverter(typeof(AnchorPointConverter))] +public enum AnchorPoint +{ + Top, + Left, + Right, + Bottom, + TopLeft, + TopRight, + BottomLeft, + BottomRight, + Center, +} + +sealed class AnchorPointConverter : JsonConverter +{ + public override AnchorPoint Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "top" => AnchorPoint.Top, + "left" => AnchorPoint.Left, + "right" => AnchorPoint.Right, + "bottom" => AnchorPoint.Bottom, + "top_left" => AnchorPoint.TopLeft, + "top_right" => AnchorPoint.TopRight, + "bottom_left" => AnchorPoint.BottomLeft, + "bottom_right" => AnchorPoint.BottomRight, + "center" => AnchorPoint.Center, + _ => (AnchorPoint)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + AnchorPoint value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + AnchorPoint.Top => "top", + AnchorPoint.Left => "left", + AnchorPoint.Right => "right", + AnchorPoint.Bottom => "bottom", + AnchorPoint.TopLeft => "top_left", + AnchorPoint.TopRight => "top_right", + AnchorPoint.BottomLeft => "bottom_left", + AnchorPoint.BottomRight => "bottom_right", + AnchorPoint.Center => "center", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Specifies the position of the overlay relative to the parent image or video. If +/// one or more of `x`, `y`, `xCenter`, or `yCenter` parameters are specified, this +/// parameter is ignored. Maps to `lfo` in the URL. /// [JsonConverter(typeof(FocusConverter))] public enum Focus @@ -429,13 +575,13 @@ public override void Write(Utf8JsonWriter writer, X value, JsonSerializerOptions } /// -/// Specifies the y-coordinate of the top-left corner of the base asset where the -/// overlay's top-left corner will be positioned. It also accepts arithmetic expressions -/// such as `bh_mul_0.4` or `bh_sub_ch`. Maps to `ly` in the URL. Learn about [Arithmetic -/// expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). +/// Specifies the x-coordinate on the base asset where the overlay's center will +/// be positioned. It also accepts arithmetic expressions such as `bw_mul_0.4` or +/// `bw_sub_cw`. Maps to `lxc` in the URL. Cannot be used together with `x`, but can +/// be used with `y`. Learn about [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). /// -[JsonConverter(typeof(YConverter))] -public record class Y : ModelBase +[JsonConverter(typeof(XCenterConverter))] +public record class XCenter : ModelBase { public object? Value { get; } = null; @@ -452,19 +598,19 @@ public JsonElement Json } } - public Y(double value, JsonElement? element = null) + public XCenter(double value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Y(string value, JsonElement? element = null) + public XCenter(string value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Y(JsonElement element) + public XCenter(JsonElement element) { this._element = element; } @@ -542,7 +688,7 @@ public void Switch(Action @double, Action @string) @string(value); break; default: - throw new ImageKitInvalidDataException("Data did not match any variant of Y"); + throw new ImageKitInvalidDataException("Data did not match any variant of XCenter"); } } @@ -573,13 +719,15 @@ public T Match(Func @double, Func @string) { double value => @double(value), string value => @string(value), - _ => throw new ImageKitInvalidDataException("Data did not match any variant of Y"), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of XCenter" + ), }; } - public static implicit operator Y(double value) => new(value); + public static implicit operator XCenter(double value) => new(value); - public static implicit operator Y(string value) => new(value); + public static implicit operator XCenter(string value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -595,11 +743,11 @@ public override void Validate() { if (this.Value == null) { - throw new ImageKitInvalidDataException("Data did not match any variant of Y"); + throw new ImageKitInvalidDataException("Data did not match any variant of XCenter"); } } - public virtual bool Equals(Y? other) => + public virtual bool Equals(XCenter? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -626,9 +774,9 @@ int VariantIndex() } } -sealed class YConverter : JsonConverter +sealed class XCenterConverter : JsonConverter { - public override Y? Read( + public override XCenter? Read( ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options @@ -660,7 +808,485 @@ JsonSerializerOptions options return new(element); } - public override void Write(Utf8JsonWriter writer, Y value, JsonSerializerOptions options) + public override void Write(Utf8JsonWriter writer, XCenter value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +/// +/// Specifies the y-coordinate of the top-left corner of the base asset where the +/// overlay's top-left corner will be positioned. It also accepts arithmetic expressions +/// such as `bh_mul_0.4` or `bh_sub_ch`. Maps to `ly` in the URL. Learn about [Arithmetic +/// expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). +/// +[JsonConverter(typeof(YConverter))] +public record class Y : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public Y(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Y(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Y(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public void Switch(Action @double, Action @string) + { + switch (this.Value) + { + case double value: + @double(value); + break; + case string value: + @string(value); + break; + default: + throw new ImageKitInvalidDataException("Data did not match any variant of Y"); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public T Match(Func @double, Func @string) + { + return this.Value switch + { + double value => @double(value), + string value => @string(value), + _ => throw new ImageKitInvalidDataException("Data did not match any variant of Y"), + }; + } + + public static implicit operator Y(double value) => new(value); + + public static implicit operator Y(string value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException("Data did not match any variant of Y"); + } + } + + public virtual bool Equals(Y? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + double _ => 0, + string _ => 1, + _ => -1, + }; + } +} + +sealed class YConverter : JsonConverter +{ + public override Y? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write(Utf8JsonWriter writer, Y value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +/// +/// Specifies the y-coordinate on the base asset where the overlay's center will +/// be positioned. It also accepts arithmetic expressions such as `bh_mul_0.4` or +/// `bh_sub_ch`. Maps to `lyc` in the URL. Cannot be used together with `y`, but can +/// be used with `x`. Learn about [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). +/// +[JsonConverter(typeof(YCenterConverter))] +public record class YCenter : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public YCenter(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public YCenter(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public YCenter(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public void Switch(Action @double, Action @string) + { + switch (this.Value) + { + case double value: + @double(value); + break; + case string value: + @string(value); + break; + default: + throw new ImageKitInvalidDataException("Data did not match any variant of YCenter"); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public T Match(Func @double, Func @string) + { + return this.Value switch + { + double value => @double(value), + string value => @string(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of YCenter" + ), + }; + } + + public static implicit operator YCenter(double value) => new(value); + + public static implicit operator YCenter(string value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException("Data did not match any variant of YCenter"); + } + } + + public virtual bool Equals(YCenter? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + double _ => 0, + string _ => 1, + _ => -1, + }; + } +} + +sealed class YCenterConverter : JsonConverter +{ + public override YCenter? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write(Utf8JsonWriter writer, YCenter value, JsonSerializerOptions options) { JsonSerializer.Serialize(writer, value.Json, options); } diff --git a/src/ImageKit/Models/Transformation.cs b/src/ImageKit/Models/Transformation.cs index 092f9d26..262cc84d 100644 --- a/src/ImageKit/Models/Transformation.cs +++ b/src/ImageKit/Models/Transformation.cs @@ -1193,12 +1193,12 @@ public TransformationX? X /// Focus using cropped image coordinates - X center coordinate. See [Focus using /// cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). /// - public XCenter? XCenter + public TransformationXCenter? XCenter { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("xCenter"); + return this._rawData.GetNullableClass("xCenter"); } init { @@ -1236,12 +1236,12 @@ public TransformationY? Y /// Focus using cropped image coordinates - Y center coordinate. See [Focus using /// cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). /// - public YCenter? YCenter + public TransformationYCenter? YCenter { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("yCenter"); + return this._rawData.GetNullableClass("yCenter"); } init { @@ -6532,8 +6532,8 @@ JsonSerializerOptions options /// Focus using cropped image coordinates - X center coordinate. See [Focus using /// cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). /// -[JsonConverter(typeof(XCenterConverter))] -public record class XCenter : ModelBase +[JsonConverter(typeof(TransformationXCenterConverter))] +public record class TransformationXCenter : ModelBase { public object? Value { get; } = null; @@ -6550,19 +6550,19 @@ public JsonElement Json } } - public XCenter(double value, JsonElement? element = null) + public TransformationXCenter(double value, JsonElement? element = null) { this.Value = value; this._element = element; } - public XCenter(string value, JsonElement? element = null) + public TransformationXCenter(string value, JsonElement? element = null) { this.Value = value; this._element = element; } - public XCenter(JsonElement element) + public TransformationXCenter(JsonElement element) { this._element = element; } @@ -6640,7 +6640,9 @@ public void Switch(Action @double, Action @string) @string(value); break; default: - throw new ImageKitInvalidDataException("Data did not match any variant of XCenter"); + throw new ImageKitInvalidDataException( + "Data did not match any variant of TransformationXCenter" + ); } } @@ -6672,14 +6674,14 @@ public T Match(Func @double, Func @string) double value => @double(value), string value => @string(value), _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of XCenter" + "Data did not match any variant of TransformationXCenter" ), }; } - public static implicit operator XCenter(double value) => new(value); + public static implicit operator TransformationXCenter(double value) => new(value); - public static implicit operator XCenter(string value) => new(value); + public static implicit operator TransformationXCenter(string value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -6695,11 +6697,13 @@ public override void Validate() { if (this.Value == null) { - throw new ImageKitInvalidDataException("Data did not match any variant of XCenter"); + throw new ImageKitInvalidDataException( + "Data did not match any variant of TransformationXCenter" + ); } } - public virtual bool Equals(XCenter? other) => + public virtual bool Equals(TransformationXCenter? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -6726,9 +6730,9 @@ int VariantIndex() } } -sealed class XCenterConverter : JsonConverter +sealed class TransformationXCenterConverter : JsonConverter { - public override XCenter? Read( + public override TransformationXCenter? Read( ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options @@ -6760,7 +6764,11 @@ JsonSerializerOptions options return new(element); } - public override void Write(Utf8JsonWriter writer, XCenter value, JsonSerializerOptions options) + public override void Write( + Utf8JsonWriter writer, + TransformationXCenter value, + JsonSerializerOptions options + ) { JsonSerializer.Serialize(writer, value.Json, options); } @@ -7015,8 +7023,8 @@ JsonSerializerOptions options /// Focus using cropped image coordinates - Y center coordinate. See [Focus using /// cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). /// -[JsonConverter(typeof(YCenterConverter))] -public record class YCenter : ModelBase +[JsonConverter(typeof(TransformationYCenterConverter))] +public record class TransformationYCenter : ModelBase { public object? Value { get; } = null; @@ -7033,19 +7041,19 @@ public JsonElement Json } } - public YCenter(double value, JsonElement? element = null) + public TransformationYCenter(double value, JsonElement? element = null) { this.Value = value; this._element = element; } - public YCenter(string value, JsonElement? element = null) + public TransformationYCenter(string value, JsonElement? element = null) { this.Value = value; this._element = element; } - public YCenter(JsonElement element) + public TransformationYCenter(JsonElement element) { this._element = element; } @@ -7123,7 +7131,9 @@ public void Switch(Action @double, Action @string) @string(value); break; default: - throw new ImageKitInvalidDataException("Data did not match any variant of YCenter"); + throw new ImageKitInvalidDataException( + "Data did not match any variant of TransformationYCenter" + ); } } @@ -7155,14 +7165,14 @@ public T Match(Func @double, Func @string) double value => @double(value), string value => @string(value), _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of YCenter" + "Data did not match any variant of TransformationYCenter" ), }; } - public static implicit operator YCenter(double value) => new(value); + public static implicit operator TransformationYCenter(double value) => new(value); - public static implicit operator YCenter(string value) => new(value); + public static implicit operator TransformationYCenter(string value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -7178,11 +7188,13 @@ public override void Validate() { if (this.Value == null) { - throw new ImageKitInvalidDataException("Data did not match any variant of YCenter"); + throw new ImageKitInvalidDataException( + "Data did not match any variant of TransformationYCenter" + ); } } - public virtual bool Equals(YCenter? other) => + public virtual bool Equals(TransformationYCenter? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -7209,9 +7221,9 @@ int VariantIndex() } } -sealed class YCenterConverter : JsonConverter +sealed class TransformationYCenterConverter : JsonConverter { - public override YCenter? Read( + public override TransformationYCenter? Read( ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options @@ -7243,7 +7255,11 @@ JsonSerializerOptions options return new(element); } - public override void Write(Utf8JsonWriter writer, YCenter value, JsonSerializerOptions options) + public override void Write( + Utf8JsonWriter writer, + TransformationYCenter value, + JsonSerializerOptions options + ) { JsonSerializer.Serialize(writer, value.Json, options); } diff --git a/src/ImageKit/Models/UnnamedSchemaWithArrayParent0.cs b/src/ImageKit/Models/UnnamedSchemaWithArrayParent0.cs index 8e0f321e..f66652c4 100644 --- a/src/ImageKit/Models/UnnamedSchemaWithArrayParent0.cs +++ b/src/ImageKit/Models/UnnamedSchemaWithArrayParent0.cs @@ -1578,8 +1578,10 @@ public long? MinSelections } /// - /// Array of possible tag values. Combined length of all strings must not exceed - /// 500 characters. Cannot contain the `%` character. + /// Array of possible tag values. The combined length of all strings must not + /// exceed 500 characters, and values cannot include the `%` character. When + /// providing large vocabularies (more than 30 items), the AI may not follow + /// the list strictly. /// public IReadOnlyList? Vocabulary { @@ -1763,7 +1765,10 @@ public long? MinSelections } /// - /// Array of possible values matching the custom metadata field type. + /// An array of possible values matching the custom metadata field type. If not + /// provided for SingleSelect or MultiSelect field types, all values from the + /// custom metadata field definition will be used. When providing large vocabularies + /// (above 30 items), the AI may not strictly adhere to the list. /// public IReadOnlyList? Vocabulary { From 5c34c3e882a78631bd7d724809fa43723e5c7422 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 10 Apr 2026 06:07:54 +0000 Subject: [PATCH 091/129] feat(api): dam related webhook events --- .stats.yml | 6 +- README.md | 6 +- .../Origins/OriginCreateParamsTest.cs | 2 +- .../Origins/OriginDeleteParamsTest.cs | 2 +- .../Accounts/Origins/OriginGetParamsTest.cs | 2 +- .../Origins/OriginUpdateParamsTest.cs | 2 +- .../UrlEndpointCreateParamsTest.cs | 2 +- .../UrlEndpointDeleteParamsTest.cs | 2 +- .../UrlEndpoints/UrlEndpointGetParamsTest.cs | 2 +- .../UrlEndpointUpdateParamsTest.cs | 2 +- .../Accounts/Usage/UsageGetParamsTest.cs | 2 +- .../Models/Assets/AssetListParamsTest.cs | 2 +- src/ImageKit.Tests/Models/BaseOverlayTest.cs | 21 - .../Beta/V2/Files/FileUploadParamsTest.cs | 2 +- .../InvalidationCreateParamsTest.cs | 2 +- .../Invalidation/InvalidationGetParamsTest.cs | 2 +- .../CustomMetadataFieldCreateParamsTest.cs | 2 +- .../CustomMetadataFieldDeleteParamsTest.cs | 2 +- .../CustomMetadataFieldListParamsTest.cs | 2 +- .../CustomMetadataFieldUpdateParamsTest.cs | 2 +- .../Files/Bulk/BulkAddTagsParamsTest.cs | 2 +- .../Models/Files/Bulk/BulkDeleteParamsTest.cs | 2 +- .../Files/Bulk/BulkRemoveAITagsParamsTest.cs | 2 +- .../Files/Bulk/BulkRemoveTagsParamsTest.cs | 2 +- .../Models/Files/FileCopyParamsTest.cs | 2 +- .../Models/Files/FileDeleteParamsTest.cs | 2 +- .../Models/Files/FileGetParamsTest.cs | 2 +- .../Models/Files/FileMoveParamsTest.cs | 2 +- .../Models/Files/FileRenameParamsTest.cs | 2 +- .../Models/Files/FileUpdateParamsTest.cs | 2 +- .../Models/Files/FileUploadParamsTest.cs | 2 +- .../Metadata/MetadataGetFromUrlParamsTest.cs | 2 +- .../Files/Metadata/MetadataGetParamsTest.cs | 2 +- .../Files/Versions/VersionDeleteParamsTest.cs | 2 +- .../Files/Versions/VersionGetParamsTest.cs | 2 +- .../Files/Versions/VersionListParamsTest.cs | 2 +- .../Versions/VersionRestoreParamsTest.cs | 2 +- .../Models/Folders/FolderCopyParamsTest.cs | 2 +- .../Models/Folders/FolderCreateParamsTest.cs | 2 +- .../Models/Folders/FolderDeleteParamsTest.cs | 2 +- .../Models/Folders/FolderMoveParamsTest.cs | 2 +- .../Models/Folders/FolderRenameParamsTest.cs | 2 +- .../Models/Folders/Job/JobGetParamsTest.cs | 2 +- .../Models/GetImageAttributesOptionsTest.cs | 21 - src/ImageKit.Tests/Models/ImageOverlayTest.cs | 63 - .../Models/OverlayPositionTest.cs | 203 ---- src/ImageKit.Tests/Models/OverlayTest.cs | 42 - .../SavedExtensionCreateParamsTest.cs | 2 +- .../SavedExtensionDeleteParamsTest.cs | 2 +- .../SavedExtensionGetParamsTest.cs | 2 +- .../SavedExtensionUpdateParamsTest.cs | 2 +- .../Models/SolidColorOverlayTest.cs | 21 - src/ImageKit.Tests/Models/SrcOptionsTest.cs | 21 - .../Models/SubtitleOverlayTest.cs | 21 - src/ImageKit.Tests/Models/TextOverlayTest.cs | 21 - .../Models/TransformationTest.cs | 57 +- src/ImageKit.Tests/Models/VideoOverlayTest.cs | 63 - .../Models/Webhooks/DamFileCreateEventTest.cs | 1070 +++++++++++++++++ .../Models/Webhooks/DamFileDeleteEventTest.cs | 256 ++++ .../Models/Webhooks/DamFileUpdateEventTest.cs | 1070 +++++++++++++++++ .../Webhooks/DamFileVersionCreateEventTest.cs | 200 +++ .../Webhooks/DamFileVersionDeleteEventTest.cs | 304 +++++ .../Webhooks/UnsafeUnwrapWebhookEventTest.cs | 409 +++++++ .../Models/Webhooks/UnwrapWebhookEventTest.cs | 409 +++++++ .../UploadPostTransformErrorEventTest.cs | 72 +- src/ImageKit.Tests/TestBase.cs | 1 - src/ImageKit/Core/ModelBase.cs | 1 - src/ImageKit/Core/ParamsBase.cs | 16 - src/ImageKit/Models/ExtensionConfig.cs | 11 +- src/ImageKit/Models/OverlayPosition.cs | 666 +--------- src/ImageKit/Models/Transformation.cs | 80 +- .../Models/UnnamedSchemaWithArrayParent0.cs | 11 +- .../Models/Webhooks/DamFileCreateEvent.cs | 225 ++++ .../Models/Webhooks/DamFileDeleteEvent.cs | 282 +++++ .../Models/Webhooks/DamFileUpdateEvent.cs | 225 ++++ .../Webhooks/DamFileVersionCreateEvent.cs | 229 ++++ .../Webhooks/DamFileVersionDeleteEvent.cs | 317 +++++ .../Webhooks/UnsafeUnwrapWebhookEvent.cs | 325 ++++- .../Models/Webhooks/UnwrapWebhookEvent.cs | 322 ++++- .../Webhooks/UploadPostTransformErrorEvent.cs | 86 +- 80 files changed, 5847 insertions(+), 1394 deletions(-) create mode 100644 src/ImageKit.Tests/Models/Webhooks/DamFileCreateEventTest.cs create mode 100644 src/ImageKit.Tests/Models/Webhooks/DamFileDeleteEventTest.cs create mode 100644 src/ImageKit.Tests/Models/Webhooks/DamFileUpdateEventTest.cs create mode 100644 src/ImageKit.Tests/Models/Webhooks/DamFileVersionCreateEventTest.cs create mode 100644 src/ImageKit.Tests/Models/Webhooks/DamFileVersionDeleteEventTest.cs create mode 100644 src/ImageKit/Models/Webhooks/DamFileCreateEvent.cs create mode 100644 src/ImageKit/Models/Webhooks/DamFileDeleteEvent.cs create mode 100644 src/ImageKit/Models/Webhooks/DamFileUpdateEvent.cs create mode 100644 src/ImageKit/Models/Webhooks/DamFileVersionCreateEvent.cs create mode 100644 src/ImageKit/Models/Webhooks/DamFileVersionDeleteEvent.cs diff --git a/.stats.yml b/.stats.yml index df5aafb6..3e331fe9 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-63aff1629530786015da3c86131afa8a9b60545d488884b77641f1d4b89c6e9d.yml -openapi_spec_hash: 586d357bd7e5217d240a99e0d83c6d1f -config_hash: 47cb702ee2cb52c58d803ae39ade9b44 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-1422f7513f230162270b197061e5768c2e0c803b94b8cd03a5e72544ac75a27f.yml +openapi_spec_hash: 41175e752e6f6ce900b36aecba687fa7 +config_hash: 17e408231b0b01676298010c7405f483 diff --git a/README.md b/README.md index 124d940d..7ed6afd5 100644 --- a/README.md +++ b/README.md @@ -54,11 +54,7 @@ Or manually: ```csharp using ImageKit; -ImageKitClient client = new() -{ - PrivateKey = "My Private Key", - Password = "My Password", -}; +ImageKitClient client = new() { PrivateKey = "My Private Key" }; ``` Or using a combination of the two approaches. diff --git a/src/ImageKit.Tests/Models/Accounts/Origins/OriginCreateParamsTest.cs b/src/ImageKit.Tests/Models/Accounts/Origins/OriginCreateParamsTest.cs index cf8f0d31..5ccf9ac4 100644 --- a/src/ImageKit.Tests/Models/Accounts/Origins/OriginCreateParamsTest.cs +++ b/src/ImageKit.Tests/Models/Accounts/Origins/OriginCreateParamsTest.cs @@ -53,7 +53,7 @@ public void Url_Works() }, }; - var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/accounts/origins"), url); } diff --git a/src/ImageKit.Tests/Models/Accounts/Origins/OriginDeleteParamsTest.cs b/src/ImageKit.Tests/Models/Accounts/Origins/OriginDeleteParamsTest.cs index de154ad9..a12858d4 100644 --- a/src/ImageKit.Tests/Models/Accounts/Origins/OriginDeleteParamsTest.cs +++ b/src/ImageKit.Tests/Models/Accounts/Origins/OriginDeleteParamsTest.cs @@ -20,7 +20,7 @@ public void Url_Works() { OriginDeleteParams parameters = new() { ID = "id" }; - var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/accounts/origins/id"), url); } diff --git a/src/ImageKit.Tests/Models/Accounts/Origins/OriginGetParamsTest.cs b/src/ImageKit.Tests/Models/Accounts/Origins/OriginGetParamsTest.cs index 51509129..17b0cfac 100644 --- a/src/ImageKit.Tests/Models/Accounts/Origins/OriginGetParamsTest.cs +++ b/src/ImageKit.Tests/Models/Accounts/Origins/OriginGetParamsTest.cs @@ -20,7 +20,7 @@ public void Url_Works() { OriginGetParams parameters = new() { ID = "id" }; - var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/accounts/origins/id"), url); } diff --git a/src/ImageKit.Tests/Models/Accounts/Origins/OriginUpdateParamsTest.cs b/src/ImageKit.Tests/Models/Accounts/Origins/OriginUpdateParamsTest.cs index 6828eb88..a37e7f51 100644 --- a/src/ImageKit.Tests/Models/Accounts/Origins/OriginUpdateParamsTest.cs +++ b/src/ImageKit.Tests/Models/Accounts/Origins/OriginUpdateParamsTest.cs @@ -57,7 +57,7 @@ public void Url_Works() }, }; - var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/accounts/origins/id"), url); } diff --git a/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointCreateParamsTest.cs b/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointCreateParamsTest.cs index 971baa20..9a10c84a 100644 --- a/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointCreateParamsTest.cs +++ b/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointCreateParamsTest.cs @@ -75,7 +75,7 @@ public void Url_Works() { UrlEndpointCreateParams parameters = new() { Description = "My custom URL endpoint" }; - var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/accounts/url-endpoints"), url); } diff --git a/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointDeleteParamsTest.cs b/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointDeleteParamsTest.cs index f4dc5da0..f8f3b56d 100644 --- a/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointDeleteParamsTest.cs +++ b/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointDeleteParamsTest.cs @@ -20,7 +20,7 @@ public void Url_Works() { UrlEndpointDeleteParams parameters = new() { ID = "id" }; - var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/accounts/url-endpoints/id"), url); } diff --git a/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointGetParamsTest.cs b/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointGetParamsTest.cs index cd8562ad..2eb97ed9 100644 --- a/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointGetParamsTest.cs +++ b/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointGetParamsTest.cs @@ -20,7 +20,7 @@ public void Url_Works() { UrlEndpointGetParams parameters = new() { ID = "id" }; - var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/accounts/url-endpoints/id"), url); } diff --git a/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParamsTest.cs b/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParamsTest.cs index 552ee2f1..2cb59f16 100644 --- a/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParamsTest.cs +++ b/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParamsTest.cs @@ -94,7 +94,7 @@ public void Url_Works() Description = "My custom URL endpoint", }; - var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/accounts/url-endpoints/id"), url); } diff --git a/src/ImageKit.Tests/Models/Accounts/Usage/UsageGetParamsTest.cs b/src/ImageKit.Tests/Models/Accounts/Usage/UsageGetParamsTest.cs index d3f8003a..166d4529 100644 --- a/src/ImageKit.Tests/Models/Accounts/Usage/UsageGetParamsTest.cs +++ b/src/ImageKit.Tests/Models/Accounts/Usage/UsageGetParamsTest.cs @@ -22,7 +22,7 @@ public void Url_Works() { UsageGetParams parameters = new() { EndDate = "2019-12-27", StartDate = "2019-12-27" }; - var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key" }); Assert.Equal( new Uri( diff --git a/src/ImageKit.Tests/Models/Assets/AssetListParamsTest.cs b/src/ImageKit.Tests/Models/Assets/AssetListParamsTest.cs index 9058639f..93a60ada 100644 --- a/src/ImageKit.Tests/Models/Assets/AssetListParamsTest.cs +++ b/src/ImageKit.Tests/Models/Assets/AssetListParamsTest.cs @@ -105,7 +105,7 @@ public void Url_Works() Type = Assets::Type.File, }; - var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key" }); Assert.Equal( new Uri( diff --git a/src/ImageKit.Tests/Models/BaseOverlayTest.cs b/src/ImageKit.Tests/Models/BaseOverlayTest.cs index 03fa60af..66b3f066 100644 --- a/src/ImageKit.Tests/Models/BaseOverlayTest.cs +++ b/src/ImageKit.Tests/Models/BaseOverlayTest.cs @@ -15,12 +15,9 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -33,12 +30,9 @@ public void FieldRoundtrip_Works() ApiEnum expectedLayerMode = LayerMode.Multiply; OverlayPosition expectedPosition = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }; OverlayTiming expectedTiming = new() { @@ -60,12 +54,9 @@ public void SerializationRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -92,12 +83,9 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -117,12 +105,9 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum expectedLayerMode = LayerMode.Multiply; OverlayPosition expectedPosition = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }; OverlayTiming expectedTiming = new() { @@ -144,12 +129,9 @@ public void Validation_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -224,12 +206,9 @@ public void CopyConstructor_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { diff --git a/src/ImageKit.Tests/Models/Beta/V2/Files/FileUploadParamsTest.cs b/src/ImageKit.Tests/Models/Beta/V2/Files/FileUploadParamsTest.cs index df9cfb30..24f848ad 100644 --- a/src/ImageKit.Tests/Models/Beta/V2/Files/FileUploadParamsTest.cs +++ b/src/ImageKit.Tests/Models/Beta/V2/Files/FileUploadParamsTest.cs @@ -376,7 +376,7 @@ public void Url_Works() FileName = "fileName", }; - var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key" }); Assert.Equal(new Uri("https://api.imagekit.io/api/v2/files/upload"), url); } diff --git a/src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationCreateParamsTest.cs b/src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationCreateParamsTest.cs index a42ee393..0d5f1956 100644 --- a/src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationCreateParamsTest.cs +++ b/src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationCreateParamsTest.cs @@ -26,7 +26,7 @@ public void Url_Works() UrlValue = "https://ik.imagekit.io/your_imagekit_id/default-image.jpg", }; - var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/files/purge"), url); } diff --git a/src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationGetParamsTest.cs b/src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationGetParamsTest.cs index 60def5ee..f79b8936 100644 --- a/src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationGetParamsTest.cs +++ b/src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationGetParamsTest.cs @@ -20,7 +20,7 @@ public void Url_Works() { InvalidationGetParams parameters = new() { RequestID = "requestId" }; - var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/files/purge/requestId"), url); } diff --git a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsTest.cs b/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsTest.cs index cc1697df..b79620e2 100644 --- a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsTest.cs +++ b/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsTest.cs @@ -68,7 +68,7 @@ public void Url_Works() }, }; - var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/customMetadataFields"), url); } diff --git a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldDeleteParamsTest.cs b/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldDeleteParamsTest.cs index 14045bf0..6cce2ed4 100644 --- a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldDeleteParamsTest.cs +++ b/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldDeleteParamsTest.cs @@ -20,7 +20,7 @@ public void Url_Works() { CustomMetadataFieldDeleteParams parameters = new() { ID = "id" }; - var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/customMetadataFields/id"), url); } diff --git a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldListParamsTest.cs b/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldListParamsTest.cs index de7b0113..61a6d1fa 100644 --- a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldListParamsTest.cs +++ b/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldListParamsTest.cs @@ -57,7 +57,7 @@ public void Url_Works() IncludeDeleted = true, }; - var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key" }); Assert.Equal( new Uri( diff --git a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsTest.cs b/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsTest.cs index 7e969966..746be2b9 100644 --- a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsTest.cs +++ b/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsTest.cs @@ -79,7 +79,7 @@ public void Url_Works() { CustomMetadataFieldUpdateParams parameters = new() { ID = "id" }; - var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/customMetadataFields/id"), url); } diff --git a/src/ImageKit.Tests/Models/Files/Bulk/BulkAddTagsParamsTest.cs b/src/ImageKit.Tests/Models/Files/Bulk/BulkAddTagsParamsTest.cs index ee0c224e..6820095a 100644 --- a/src/ImageKit.Tests/Models/Files/Bulk/BulkAddTagsParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/Bulk/BulkAddTagsParamsTest.cs @@ -39,7 +39,7 @@ public void Url_Works() Tags = ["t-shirt", "round-neck", "sale2019"], }; - var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/files/addTags"), url); } diff --git a/src/ImageKit.Tests/Models/Files/Bulk/BulkDeleteParamsTest.cs b/src/ImageKit.Tests/Models/Files/Bulk/BulkDeleteParamsTest.cs index 5b8d87a7..995c11ab 100644 --- a/src/ImageKit.Tests/Models/Files/Bulk/BulkDeleteParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/Bulk/BulkDeleteParamsTest.cs @@ -31,7 +31,7 @@ public void Url_Works() FileIds = ["598821f949c0a938d57563bd", "598821f949c0a938d57563be"], }; - var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/files/batch/deleteByFileIds"), url); } diff --git a/src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveAITagsParamsTest.cs b/src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveAITagsParamsTest.cs index 391cf465..ce22f26c 100644 --- a/src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveAITagsParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveAITagsParamsTest.cs @@ -39,7 +39,7 @@ public void Url_Works() FileIds = ["598821f949c0a938d57563bd", "598821f949c0a938d57563be"], }; - var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/files/removeAITags"), url); } diff --git a/src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveTagsParamsTest.cs b/src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveTagsParamsTest.cs index 49f93c1f..238be62d 100644 --- a/src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveTagsParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveTagsParamsTest.cs @@ -39,7 +39,7 @@ public void Url_Works() Tags = ["t-shirt", "round-neck", "sale2019"], }; - var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/files/removeTags"), url); } diff --git a/src/ImageKit.Tests/Models/Files/FileCopyParamsTest.cs b/src/ImageKit.Tests/Models/Files/FileCopyParamsTest.cs index 3a52f2cb..4253ecd6 100644 --- a/src/ImageKit.Tests/Models/Files/FileCopyParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/FileCopyParamsTest.cs @@ -62,7 +62,7 @@ public void Url_Works() SourceFilePath = "/path/to/file.jpg", }; - var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/files/copy"), url); } diff --git a/src/ImageKit.Tests/Models/Files/FileDeleteParamsTest.cs b/src/ImageKit.Tests/Models/Files/FileDeleteParamsTest.cs index 65107f82..871dc21d 100644 --- a/src/ImageKit.Tests/Models/Files/FileDeleteParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/FileDeleteParamsTest.cs @@ -20,7 +20,7 @@ public void Url_Works() { FileDeleteParams parameters = new() { FileID = "fileId" }; - var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/files/fileId"), url); } diff --git a/src/ImageKit.Tests/Models/Files/FileGetParamsTest.cs b/src/ImageKit.Tests/Models/Files/FileGetParamsTest.cs index d2372359..5cecb84e 100644 --- a/src/ImageKit.Tests/Models/Files/FileGetParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/FileGetParamsTest.cs @@ -20,7 +20,7 @@ public void Url_Works() { FileGetParams parameters = new() { FileID = "fileId" }; - var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/files/fileId/details"), url); } diff --git a/src/ImageKit.Tests/Models/Files/FileMoveParamsTest.cs b/src/ImageKit.Tests/Models/Files/FileMoveParamsTest.cs index 2f134efc..de87d380 100644 --- a/src/ImageKit.Tests/Models/Files/FileMoveParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/FileMoveParamsTest.cs @@ -30,7 +30,7 @@ public void Url_Works() SourceFilePath = "/path/to/file.jpg", }; - var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/files/move"), url); } diff --git a/src/ImageKit.Tests/Models/Files/FileRenameParamsTest.cs b/src/ImageKit.Tests/Models/Files/FileRenameParamsTest.cs index e8cf12d8..b429b96d 100644 --- a/src/ImageKit.Tests/Models/Files/FileRenameParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/FileRenameParamsTest.cs @@ -62,7 +62,7 @@ public void Url_Works() NewFileName = "newFileName.jpg", }; - var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/files/rename"), url); } diff --git a/src/ImageKit.Tests/Models/Files/FileUpdateParamsTest.cs b/src/ImageKit.Tests/Models/Files/FileUpdateParamsTest.cs index 093b5533..21d4ae5a 100644 --- a/src/ImageKit.Tests/Models/Files/FileUpdateParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/FileUpdateParamsTest.cs @@ -185,7 +185,7 @@ public void Url_Works() }, }; - var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/files/fileId/details"), url); } diff --git a/src/ImageKit.Tests/Models/Files/FileUploadParamsTest.cs b/src/ImageKit.Tests/Models/Files/FileUploadParamsTest.cs index d0f77eb2..bb304a2d 100644 --- a/src/ImageKit.Tests/Models/Files/FileUploadParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/FileUploadParamsTest.cs @@ -400,7 +400,7 @@ public void Url_Works() FileName = "fileName", }; - var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key" }); Assert.Equal(new Uri("https://api.imagekit.io/api/v1/files/upload"), url); } diff --git a/src/ImageKit.Tests/Models/Files/Metadata/MetadataGetFromUrlParamsTest.cs b/src/ImageKit.Tests/Models/Files/Metadata/MetadataGetFromUrlParamsTest.cs index 41155870..10017b83 100644 --- a/src/ImageKit.Tests/Models/Files/Metadata/MetadataGetFromUrlParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/Metadata/MetadataGetFromUrlParamsTest.cs @@ -20,7 +20,7 @@ public void Url_Works() { MetadataGetFromUrlParams parameters = new() { UrlValue = "https://example.com" }; - var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key" }); Assert.Equal( new Uri("https://api.imagekit.io/v1/metadata?url=https%3a%2f%2fexample.com"), diff --git a/src/ImageKit.Tests/Models/Files/Metadata/MetadataGetParamsTest.cs b/src/ImageKit.Tests/Models/Files/Metadata/MetadataGetParamsTest.cs index d80a0a72..3f52b69e 100644 --- a/src/ImageKit.Tests/Models/Files/Metadata/MetadataGetParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/Metadata/MetadataGetParamsTest.cs @@ -20,7 +20,7 @@ public void Url_Works() { MetadataGetParams parameters = new() { FileID = "fileId" }; - var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/files/fileId/metadata"), url); } diff --git a/src/ImageKit.Tests/Models/Files/Versions/VersionDeleteParamsTest.cs b/src/ImageKit.Tests/Models/Files/Versions/VersionDeleteParamsTest.cs index 105270a8..c28f06f0 100644 --- a/src/ImageKit.Tests/Models/Files/Versions/VersionDeleteParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/Versions/VersionDeleteParamsTest.cs @@ -22,7 +22,7 @@ public void Url_Works() { VersionDeleteParams parameters = new() { FileID = "fileId", VersionID = "versionId" }; - var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/files/fileId/versions/versionId"), url); } diff --git a/src/ImageKit.Tests/Models/Files/Versions/VersionGetParamsTest.cs b/src/ImageKit.Tests/Models/Files/Versions/VersionGetParamsTest.cs index e189bc4c..24b3315f 100644 --- a/src/ImageKit.Tests/Models/Files/Versions/VersionGetParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/Versions/VersionGetParamsTest.cs @@ -22,7 +22,7 @@ public void Url_Works() { VersionGetParams parameters = new() { FileID = "fileId", VersionID = "versionId" }; - var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/files/fileId/versions/versionId"), url); } diff --git a/src/ImageKit.Tests/Models/Files/Versions/VersionListParamsTest.cs b/src/ImageKit.Tests/Models/Files/Versions/VersionListParamsTest.cs index c6826fb4..0688f8d2 100644 --- a/src/ImageKit.Tests/Models/Files/Versions/VersionListParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/Versions/VersionListParamsTest.cs @@ -20,7 +20,7 @@ public void Url_Works() { VersionListParams parameters = new() { FileID = "fileId" }; - var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/files/fileId/versions"), url); } diff --git a/src/ImageKit.Tests/Models/Files/Versions/VersionRestoreParamsTest.cs b/src/ImageKit.Tests/Models/Files/Versions/VersionRestoreParamsTest.cs index a6b785d9..e12f29cd 100644 --- a/src/ImageKit.Tests/Models/Files/Versions/VersionRestoreParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/Versions/VersionRestoreParamsTest.cs @@ -22,7 +22,7 @@ public void Url_Works() { VersionRestoreParams parameters = new() { FileID = "fileId", VersionID = "versionId" }; - var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key" }); Assert.Equal( new Uri("https://api.imagekit.io/v1/files/fileId/versions/versionId/restore"), diff --git a/src/ImageKit.Tests/Models/Folders/FolderCopyParamsTest.cs b/src/ImageKit.Tests/Models/Folders/FolderCopyParamsTest.cs index 9027c155..2d28e679 100644 --- a/src/ImageKit.Tests/Models/Folders/FolderCopyParamsTest.cs +++ b/src/ImageKit.Tests/Models/Folders/FolderCopyParamsTest.cs @@ -62,7 +62,7 @@ public void Url_Works() SourceFolderPath = "/path/of/source/folder", }; - var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/bulkJobs/copyFolder"), url); } diff --git a/src/ImageKit.Tests/Models/Folders/FolderCreateParamsTest.cs b/src/ImageKit.Tests/Models/Folders/FolderCreateParamsTest.cs index ef6278aa..3407b592 100644 --- a/src/ImageKit.Tests/Models/Folders/FolderCreateParamsTest.cs +++ b/src/ImageKit.Tests/Models/Folders/FolderCreateParamsTest.cs @@ -30,7 +30,7 @@ public void Url_Works() ParentFolderPath = "/product/images/", }; - var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/folder"), url); } diff --git a/src/ImageKit.Tests/Models/Folders/FolderDeleteParamsTest.cs b/src/ImageKit.Tests/Models/Folders/FolderDeleteParamsTest.cs index ec79dff4..7e5d1de1 100644 --- a/src/ImageKit.Tests/Models/Folders/FolderDeleteParamsTest.cs +++ b/src/ImageKit.Tests/Models/Folders/FolderDeleteParamsTest.cs @@ -20,7 +20,7 @@ public void Url_Works() { FolderDeleteParams parameters = new() { FolderPath = "/folder/to/delete/" }; - var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/folder"), url); } diff --git a/src/ImageKit.Tests/Models/Folders/FolderMoveParamsTest.cs b/src/ImageKit.Tests/Models/Folders/FolderMoveParamsTest.cs index 453c9468..ba8e01b5 100644 --- a/src/ImageKit.Tests/Models/Folders/FolderMoveParamsTest.cs +++ b/src/ImageKit.Tests/Models/Folders/FolderMoveParamsTest.cs @@ -30,7 +30,7 @@ public void Url_Works() SourceFolderPath = "/path/of/source/folder", }; - var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/bulkJobs/moveFolder"), url); } diff --git a/src/ImageKit.Tests/Models/Folders/FolderRenameParamsTest.cs b/src/ImageKit.Tests/Models/Folders/FolderRenameParamsTest.cs index f52fa209..b57e3d80 100644 --- a/src/ImageKit.Tests/Models/Folders/FolderRenameParamsTest.cs +++ b/src/ImageKit.Tests/Models/Folders/FolderRenameParamsTest.cs @@ -62,7 +62,7 @@ public void Url_Works() NewFolderName = "new-folder-name", }; - var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/bulkJobs/renameFolder"), url); } diff --git a/src/ImageKit.Tests/Models/Folders/Job/JobGetParamsTest.cs b/src/ImageKit.Tests/Models/Folders/Job/JobGetParamsTest.cs index 110cb8b1..9ebb12e3 100644 --- a/src/ImageKit.Tests/Models/Folders/Job/JobGetParamsTest.cs +++ b/src/ImageKit.Tests/Models/Folders/Job/JobGetParamsTest.cs @@ -20,7 +20,7 @@ public void Url_Works() { JobGetParams parameters = new() { JobID = "jobId" }; - var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/bulkJobs/jobId"), url); } diff --git a/src/ImageKit.Tests/Models/GetImageAttributesOptionsTest.cs b/src/ImageKit.Tests/Models/GetImageAttributesOptionsTest.cs index be0824d6..f38eddfe 100644 --- a/src/ImageKit.Tests/Models/GetImageAttributesOptionsTest.cs +++ b/src/ImageKit.Tests/Models/GetImageAttributesOptionsTest.cs @@ -60,12 +60,9 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -171,12 +168,9 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -322,12 +316,9 @@ public void SerializationRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -447,12 +438,9 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -565,12 +553,9 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -716,12 +701,9 @@ public void Validation_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -939,12 +921,9 @@ public void CopyConstructor_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { diff --git a/src/ImageKit.Tests/Models/ImageOverlayTest.cs b/src/ImageKit.Tests/Models/ImageOverlayTest.cs index 05d97bf4..06c31fcf 100644 --- a/src/ImageKit.Tests/Models/ImageOverlayTest.cs +++ b/src/ImageKit.Tests/Models/ImageOverlayTest.cs @@ -16,12 +16,9 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -74,12 +71,9 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -135,12 +129,9 @@ public void FieldRoundtrip_Works() ApiEnum expectedLayerMode = LayerMode.Multiply; OverlayPosition expectedPosition = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }; OverlayTiming expectedTiming = new() { @@ -194,12 +185,9 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -273,12 +261,9 @@ public void SerializationRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -331,12 +316,9 @@ public void SerializationRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -406,12 +388,9 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -464,12 +443,9 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -532,12 +508,9 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum expectedLayerMode = LayerMode.Multiply; OverlayPosition expectedPosition = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }; OverlayTiming expectedTiming = new() { @@ -591,12 +564,9 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -670,12 +640,9 @@ public void Validation_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -728,12 +695,9 @@ public void Validation_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -867,12 +831,9 @@ public void CopyConstructor_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -925,12 +886,9 @@ public void CopyConstructor_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -1041,12 +999,9 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -1145,12 +1100,9 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -1263,12 +1215,9 @@ public void SerializationRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -1380,12 +1329,9 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -1491,12 +1437,9 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -1609,12 +1552,9 @@ public void Validation_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -1772,12 +1712,9 @@ public void CopyConstructor_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { diff --git a/src/ImageKit.Tests/Models/OverlayPositionTest.cs b/src/ImageKit.Tests/Models/OverlayPositionTest.cs index 69ec6237..f38eb42b 100644 --- a/src/ImageKit.Tests/Models/OverlayPositionTest.cs +++ b/src/ImageKit.Tests/Models/OverlayPositionTest.cs @@ -12,27 +12,18 @@ public void FieldRoundtrip_Works() { var model = new OverlayPosition { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }; - ApiEnum expectedAnchorPoint = AnchorPoint.Top; ApiEnum expectedFocus = Focus.Center; X expectedX = 0; - XCenter expectedXCenter = 0; Y expectedY = 0; - YCenter expectedYCenter = 0; - Assert.Equal(expectedAnchorPoint, model.AnchorPoint); Assert.Equal(expectedFocus, model.Focus); Assert.Equal(expectedX, model.X); - Assert.Equal(expectedXCenter, model.XCenter); Assert.Equal(expectedY, model.Y); - Assert.Equal(expectedYCenter, model.YCenter); } [Fact] @@ -40,12 +31,9 @@ public void SerializationRoundtrip_Works() { var model = new OverlayPosition { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -62,12 +50,9 @@ public void FieldRoundtripThroughSerialization_Works() { var model = new OverlayPosition { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -77,19 +62,13 @@ public void FieldRoundtripThroughSerialization_Works() ); Assert.NotNull(deserialized); - ApiEnum expectedAnchorPoint = AnchorPoint.Top; ApiEnum expectedFocus = Focus.Center; X expectedX = 0; - XCenter expectedXCenter = 0; Y expectedY = 0; - YCenter expectedYCenter = 0; - Assert.Equal(expectedAnchorPoint, deserialized.AnchorPoint); Assert.Equal(expectedFocus, deserialized.Focus); Assert.Equal(expectedX, deserialized.X); - Assert.Equal(expectedXCenter, deserialized.XCenter); Assert.Equal(expectedY, deserialized.Y); - Assert.Equal(expectedYCenter, deserialized.YCenter); } [Fact] @@ -97,12 +76,9 @@ public void Validation_Works() { var model = new OverlayPosition { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }; model.Validate(); @@ -113,18 +89,12 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { var model = new OverlayPosition { }; - Assert.Null(model.AnchorPoint); - Assert.False(model.RawData.ContainsKey("anchorPoint")); Assert.Null(model.Focus); Assert.False(model.RawData.ContainsKey("focus")); Assert.Null(model.X); Assert.False(model.RawData.ContainsKey("x")); - Assert.Null(model.XCenter); - Assert.False(model.RawData.ContainsKey("xCenter")); Assert.Null(model.Y); Assert.False(model.RawData.ContainsKey("y")); - Assert.Null(model.YCenter); - Assert.False(model.RawData.ContainsKey("yCenter")); } [Fact] @@ -141,26 +111,17 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() var model = new OverlayPosition { // Null should be interpreted as omitted for these properties - AnchorPoint = null, Focus = null, X = null, - XCenter = null, Y = null, - YCenter = null, }; - Assert.Null(model.AnchorPoint); - Assert.False(model.RawData.ContainsKey("anchorPoint")); Assert.Null(model.Focus); Assert.False(model.RawData.ContainsKey("focus")); Assert.Null(model.X); Assert.False(model.RawData.ContainsKey("x")); - Assert.Null(model.XCenter); - Assert.False(model.RawData.ContainsKey("xCenter")); Assert.Null(model.Y); Assert.False(model.RawData.ContainsKey("y")); - Assert.Null(model.YCenter); - Assert.False(model.RawData.ContainsKey("yCenter")); } [Fact] @@ -169,12 +130,9 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() var model = new OverlayPosition { // Null should be interpreted as omitted for these properties - AnchorPoint = null, Focus = null, X = null, - XCenter = null, Y = null, - YCenter = null, }; model.Validate(); @@ -185,12 +143,9 @@ public void CopyConstructor_Works() { var model = new OverlayPosition { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }; OverlayPosition copied = new(model); @@ -199,78 +154,6 @@ public void CopyConstructor_Works() } } -public class AnchorPointTest : TestBase -{ - [Theory] - [InlineData(AnchorPoint.Top)] - [InlineData(AnchorPoint.Left)] - [InlineData(AnchorPoint.Right)] - [InlineData(AnchorPoint.Bottom)] - [InlineData(AnchorPoint.TopLeft)] - [InlineData(AnchorPoint.TopRight)] - [InlineData(AnchorPoint.BottomLeft)] - [InlineData(AnchorPoint.BottomRight)] - [InlineData(AnchorPoint.Center)] - public void Validation_Works(AnchorPoint rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - value.Validate(); - } - - [Fact] - public void InvalidEnumValidationThrows_Works() - { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); - - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); - } - - [Theory] - [InlineData(AnchorPoint.Top)] - [InlineData(AnchorPoint.Left)] - [InlineData(AnchorPoint.Right)] - [InlineData(AnchorPoint.Bottom)] - [InlineData(AnchorPoint.TopLeft)] - [InlineData(AnchorPoint.TopRight)] - [InlineData(AnchorPoint.BottomLeft)] - [InlineData(AnchorPoint.BottomRight)] - [InlineData(AnchorPoint.Center)] - public void SerializationRoundtrip_Works(AnchorPoint rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void InvalidEnumSerializationRoundtrip_Works() - { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } -} - public class FocusTest : TestBase { [Theory] @@ -380,49 +263,6 @@ public void StringSerializationRoundtripWorks() } } -public class XCenterTest : TestBase -{ - [Fact] - public void DoubleValidationWorks() - { - XCenter value = 0; - value.Validate(); - } - - [Fact] - public void StringValidationWorks() - { - XCenter value = "string"; - value.Validate(); - } - - [Fact] - public void DoubleSerializationRoundtripWorks() - { - XCenter value = 0; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void StringSerializationRoundtripWorks() - { - XCenter value = "string"; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } -} - public class YTest : TestBase { [Fact] @@ -459,46 +299,3 @@ public void StringSerializationRoundtripWorks() Assert.Equal(value, deserialized); } } - -public class YCenterTest : TestBase -{ - [Fact] - public void DoubleValidationWorks() - { - YCenter value = 0; - value.Validate(); - } - - [Fact] - public void StringValidationWorks() - { - YCenter value = "string"; - value.Validate(); - } - - [Fact] - public void DoubleSerializationRoundtripWorks() - { - YCenter value = 0; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void StringSerializationRoundtripWorks() - { - YCenter value = "string"; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } -} diff --git a/src/ImageKit.Tests/Models/OverlayTest.cs b/src/ImageKit.Tests/Models/OverlayTest.cs index ae78c797..76d92332 100644 --- a/src/ImageKit.Tests/Models/OverlayTest.cs +++ b/src/ImageKit.Tests/Models/OverlayTest.cs @@ -14,12 +14,9 @@ public void TextValidationWorks() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -60,12 +57,9 @@ public void ImageValidationWorks() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -118,12 +112,9 @@ public void ImageValidationWorks() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -186,12 +177,9 @@ public void VideoValidationWorks() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -244,12 +232,9 @@ public void VideoValidationWorks() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -312,12 +297,9 @@ public void SubtitleValidationWorks() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -352,12 +334,9 @@ public void SolidColorValidationWorks() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -390,12 +369,9 @@ public void TextSerializationRoundtripWorks() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -442,12 +418,9 @@ public void ImageSerializationRoundtripWorks() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -500,12 +473,9 @@ public void ImageSerializationRoundtripWorks() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -574,12 +544,9 @@ public void VideoSerializationRoundtripWorks() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -632,12 +599,9 @@ public void VideoSerializationRoundtripWorks() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -706,12 +670,9 @@ public void SubtitleSerializationRoundtripWorks() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -752,12 +713,9 @@ public void SolidColorSerializationRoundtripWorks() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { diff --git a/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionCreateParamsTest.cs b/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionCreateParamsTest.cs index 168e5dad..bc5d3695 100644 --- a/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionCreateParamsTest.cs +++ b/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionCreateParamsTest.cs @@ -63,7 +63,7 @@ public void Url_Works() Name = "Car Quality Analysis", }; - var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/saved-extensions"), url); } diff --git a/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionDeleteParamsTest.cs b/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionDeleteParamsTest.cs index 8c6831cd..a7db02bd 100644 --- a/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionDeleteParamsTest.cs +++ b/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionDeleteParamsTest.cs @@ -20,7 +20,7 @@ public void Url_Works() { SavedExtensionDeleteParams parameters = new() { ID = "id" }; - var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/saved-extensions/id"), url); } diff --git a/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionGetParamsTest.cs b/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionGetParamsTest.cs index 016a46cc..6e01cb32 100644 --- a/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionGetParamsTest.cs +++ b/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionGetParamsTest.cs @@ -20,7 +20,7 @@ public void Url_Works() { SavedExtensionGetParams parameters = new() { ID = "id" }; - var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/saved-extensions/id"), url); } diff --git a/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionUpdateParamsTest.cs b/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionUpdateParamsTest.cs index 1a4fb0ee..34a3000d 100644 --- a/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionUpdateParamsTest.cs +++ b/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionUpdateParamsTest.cs @@ -85,7 +85,7 @@ public void Url_Works() { SavedExtensionUpdateParams parameters = new() { ID = "id" }; - var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/saved-extensions/id"), url); } diff --git a/src/ImageKit.Tests/Models/SolidColorOverlayTest.cs b/src/ImageKit.Tests/Models/SolidColorOverlayTest.cs index 6ae4efdc..7b9aa0bf 100644 --- a/src/ImageKit.Tests/Models/SolidColorOverlayTest.cs +++ b/src/ImageKit.Tests/Models/SolidColorOverlayTest.cs @@ -15,12 +15,9 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -46,12 +43,9 @@ public void FieldRoundtrip_Works() ApiEnum expectedLayerMode = LayerMode.Multiply; OverlayPosition expectedPosition = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }; OverlayTiming expectedTiming = new() { @@ -95,12 +89,9 @@ public void SerializationRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -140,12 +131,9 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -178,12 +166,9 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum expectedLayerMode = LayerMode.Multiply; OverlayPosition expectedPosition = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }; OverlayTiming expectedTiming = new() { @@ -227,12 +212,9 @@ public void Validation_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -330,12 +312,9 @@ public void CopyConstructor_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { diff --git a/src/ImageKit.Tests/Models/SrcOptionsTest.cs b/src/ImageKit.Tests/Models/SrcOptionsTest.cs index d8677cfe..33cb777e 100644 --- a/src/ImageKit.Tests/Models/SrcOptionsTest.cs +++ b/src/ImageKit.Tests/Models/SrcOptionsTest.cs @@ -60,12 +60,9 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -167,12 +164,9 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -300,12 +294,9 @@ public void SerializationRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -421,12 +412,9 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -535,12 +523,9 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -668,12 +653,9 @@ public void Validation_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -863,12 +845,9 @@ public void CopyConstructor_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { diff --git a/src/ImageKit.Tests/Models/SubtitleOverlayTest.cs b/src/ImageKit.Tests/Models/SubtitleOverlayTest.cs index 6aa3c431..882bbbc2 100644 --- a/src/ImageKit.Tests/Models/SubtitleOverlayTest.cs +++ b/src/ImageKit.Tests/Models/SubtitleOverlayTest.cs @@ -16,12 +16,9 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -49,12 +46,9 @@ public void FieldRoundtrip_Works() ApiEnum expectedLayerMode = LayerMode.Multiply; OverlayPosition expectedPosition = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }; OverlayTiming expectedTiming = new() { @@ -102,12 +96,9 @@ public void SerializationRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -149,12 +140,9 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -189,12 +177,9 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum expectedLayerMode = LayerMode.Multiply; OverlayPosition expectedPosition = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }; OverlayTiming expectedTiming = new() { @@ -242,12 +227,9 @@ public void Validation_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -353,12 +335,9 @@ public void CopyConstructor_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { diff --git a/src/ImageKit.Tests/Models/TextOverlayTest.cs b/src/ImageKit.Tests/Models/TextOverlayTest.cs index 2e222480..b047d512 100644 --- a/src/ImageKit.Tests/Models/TextOverlayTest.cs +++ b/src/ImageKit.Tests/Models/TextOverlayTest.cs @@ -16,12 +16,9 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -55,12 +52,9 @@ public void FieldRoundtrip_Works() ApiEnum expectedLayerMode = LayerMode.Multiply; OverlayPosition expectedPosition = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }; OverlayTiming expectedTiming = new() { @@ -114,12 +108,9 @@ public void SerializationRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -167,12 +158,9 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -213,12 +201,9 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum expectedLayerMode = LayerMode.Multiply; OverlayPosition expectedPosition = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }; OverlayTiming expectedTiming = new() { @@ -272,12 +257,9 @@ public void Validation_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -389,12 +371,9 @@ public void CopyConstructor_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { diff --git a/src/ImageKit.Tests/Models/TransformationTest.cs b/src/ImageKit.Tests/Models/TransformationTest.cs index 7db3251e..cd08f493 100644 --- a/src/ImageKit.Tests/Models/TransformationTest.cs +++ b/src/ImageKit.Tests/Models/TransformationTest.cs @@ -52,12 +52,9 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -148,12 +145,9 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -201,9 +195,9 @@ public void FieldRoundtrip_Works() ApiEnum expectedVideoCodec = VideoCodec.H264; TransformationWidth expectedWidth = 300; TransformationX expectedX = 0; - TransformationXCenter expectedXCenter = 0; + XCenter expectedXCenter = 0; TransformationY expectedY = 0; - TransformationYCenter expectedYCenter = 0; + YCenter expectedYCenter = 0; double expectedZoom = 0; Assert.Equal(expectedAIChangeBackground, model.AIChangeBackground); @@ -311,12 +305,9 @@ public void SerializationRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -420,12 +411,9 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -523,12 +511,9 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -576,9 +561,9 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum expectedVideoCodec = VideoCodec.H264; TransformationWidth expectedWidth = 300; TransformationX expectedX = 0; - TransformationXCenter expectedXCenter = 0; + XCenter expectedXCenter = 0; TransformationY expectedY = 0; - TransformationYCenter expectedYCenter = 0; + YCenter expectedYCenter = 0; double expectedZoom = 0; Assert.Equal(expectedAIChangeBackground, deserialized.AIChangeBackground); @@ -686,12 +671,9 @@ public void Validation_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -1149,12 +1131,9 @@ public void CopyConstructor_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -3230,28 +3209,28 @@ public void StringSerializationRoundtripWorks() } } -public class TransformationXCenterTest : TestBase +public class XCenterTest : TestBase { [Fact] public void DoubleValidationWorks() { - TransformationXCenter value = 0; + XCenter value = 0; value.Validate(); } [Fact] public void StringValidationWorks() { - TransformationXCenter value = "string"; + XCenter value = "string"; value.Validate(); } [Fact] public void DoubleSerializationRoundtripWorks() { - TransformationXCenter value = 0; + XCenter value = 0; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -3262,9 +3241,9 @@ public void DoubleSerializationRoundtripWorks() [Fact] public void StringSerializationRoundtripWorks() { - TransformationXCenter value = "string"; + XCenter value = "string"; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -3316,28 +3295,28 @@ public void StringSerializationRoundtripWorks() } } -public class TransformationYCenterTest : TestBase +public class YCenterTest : TestBase { [Fact] public void DoubleValidationWorks() { - TransformationYCenter value = 0; + YCenter value = 0; value.Validate(); } [Fact] public void StringValidationWorks() { - TransformationYCenter value = "string"; + YCenter value = "string"; value.Validate(); } [Fact] public void DoubleSerializationRoundtripWorks() { - TransformationYCenter value = 0; + YCenter value = 0; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -3348,9 +3327,9 @@ public void DoubleSerializationRoundtripWorks() [Fact] public void StringSerializationRoundtripWorks() { - TransformationYCenter value = "string"; + YCenter value = "string"; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); diff --git a/src/ImageKit.Tests/Models/VideoOverlayTest.cs b/src/ImageKit.Tests/Models/VideoOverlayTest.cs index d1e345e4..60dc9c37 100644 --- a/src/ImageKit.Tests/Models/VideoOverlayTest.cs +++ b/src/ImageKit.Tests/Models/VideoOverlayTest.cs @@ -16,12 +16,9 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -74,12 +71,9 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -135,12 +129,9 @@ public void FieldRoundtrip_Works() ApiEnum expectedLayerMode = LayerMode.Multiply; OverlayPosition expectedPosition = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }; OverlayTiming expectedTiming = new() { @@ -195,12 +186,9 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -274,12 +262,9 @@ public void SerializationRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -332,12 +317,9 @@ public void SerializationRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -407,12 +389,9 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -465,12 +444,9 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -533,12 +509,9 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum expectedLayerMode = LayerMode.Multiply; OverlayPosition expectedPosition = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }; OverlayTiming expectedTiming = new() { @@ -593,12 +566,9 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -672,12 +642,9 @@ public void Validation_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -730,12 +697,9 @@ public void Validation_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -869,12 +833,9 @@ public void CopyConstructor_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -927,12 +888,9 @@ public void CopyConstructor_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -1043,12 +1001,9 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -1148,12 +1103,9 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -1266,12 +1218,9 @@ public void SerializationRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -1383,12 +1332,9 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -1495,12 +1441,9 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -1613,12 +1556,9 @@ public void Validation_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { @@ -1776,12 +1716,9 @@ public void CopyConstructor_Works() LayerMode = LayerMode.Multiply, Position = new() { - AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, - XCenter = 0, Y = 0, - YCenter = 0, }, Timing = new() { diff --git a/src/ImageKit.Tests/Models/Webhooks/DamFileCreateEventTest.cs b/src/ImageKit.Tests/Models/Webhooks/DamFileCreateEventTest.cs new file mode 100644 index 00000000..e5fa8a5f --- /dev/null +++ b/src/ImageKit.Tests/Models/Webhooks/DamFileCreateEventTest.cs @@ -0,0 +1,1070 @@ +using System; +using System.Collections.Generic; +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Models.Webhooks; +using Files = ImageKit.Models.Files; + +namespace ImageKit.Tests.Models.Webhooks; + +public class DamFileCreateEventTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new DamFileCreateEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, + }; + + string expectedID = "id"; + string expectedType = "type"; + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + Files::File expectedData = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedType, model.Type); + Assert.Equal(expectedCreatedAt, model.CreatedAt); + Assert.Equal(expectedData, model.Data); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new DamFileCreateEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new DamFileCreateEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedType = "type"; + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + Files::File expectedData = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedType, deserialized.Type); + Assert.Equal(expectedCreatedAt, deserialized.CreatedAt); + Assert.Equal(expectedData, deserialized.Data); + } + + [Fact] + public void Validation_Works() + { + var model = new DamFileCreateEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new DamFileCreateEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, + }; + + DamFileCreateEvent copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class IntersectionMember1Test : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new IntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, + }; + + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + Files::File expectedData = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }; + JsonElement expectedType = JsonSerializer.SerializeToElement("file.created"); + + Assert.Equal(expectedCreatedAt, model.CreatedAt); + Assert.Equal(expectedData, model.Data); + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new IntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new IntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + Files::File expectedData = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }; + JsonElement expectedType = JsonSerializer.SerializeToElement("file.created"); + + Assert.Equal(expectedCreatedAt, deserialized.CreatedAt); + Assert.Equal(expectedData, deserialized.Data); + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + } + + [Fact] + public void Validation_Works() + { + var model = new IntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new IntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, + }; + + IntersectionMember1 copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Webhooks/DamFileDeleteEventTest.cs b/src/ImageKit.Tests/Models/Webhooks/DamFileDeleteEventTest.cs new file mode 100644 index 00000000..fe454941 --- /dev/null +++ b/src/ImageKit.Tests/Models/Webhooks/DamFileDeleteEventTest.cs @@ -0,0 +1,256 @@ +using System; +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Models.Webhooks; + +namespace ImageKit.Tests.Models.Webhooks; + +public class DamFileDeleteEventTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new DamFileDeleteEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new("fileId"), + }; + + string expectedID = "id"; + string expectedType = "type"; + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + Data expectedData = new("fileId"); + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedType, model.Type); + Assert.Equal(expectedCreatedAt, model.CreatedAt); + Assert.Equal(expectedData, model.Data); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new DamFileDeleteEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new("fileId"), + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new DamFileDeleteEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new("fileId"), + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedType = "type"; + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + Data expectedData = new("fileId"); + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedType, deserialized.Type); + Assert.Equal(expectedCreatedAt, deserialized.CreatedAt); + Assert.Equal(expectedData, deserialized.Data); + } + + [Fact] + public void Validation_Works() + { + var model = new DamFileDeleteEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new("fileId"), + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new DamFileDeleteEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new("fileId"), + }; + + DamFileDeleteEvent copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class DamFileDeleteEventIntersectionMember1Test : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new DamFileDeleteEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new("fileId"), + }; + + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + Data expectedData = new("fileId"); + JsonElement expectedType = JsonSerializer.SerializeToElement("file.deleted"); + + Assert.Equal(expectedCreatedAt, model.CreatedAt); + Assert.Equal(expectedData, model.Data); + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new DamFileDeleteEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new("fileId"), + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new DamFileDeleteEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new("fileId"), + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + Data expectedData = new("fileId"); + JsonElement expectedType = JsonSerializer.SerializeToElement("file.deleted"); + + Assert.Equal(expectedCreatedAt, deserialized.CreatedAt); + Assert.Equal(expectedData, deserialized.Data); + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + } + + [Fact] + public void Validation_Works() + { + var model = new DamFileDeleteEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new("fileId"), + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new DamFileDeleteEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new("fileId"), + }; + + DamFileDeleteEventIntersectionMember1 copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class DataTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Data { FileID = "fileId" }; + + string expectedFileID = "fileId"; + + Assert.Equal(expectedFileID, model.FileID); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Data { FileID = "fileId" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Data { FileID = "fileId" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + Assert.NotNull(deserialized); + + string expectedFileID = "fileId"; + + Assert.Equal(expectedFileID, deserialized.FileID); + } + + [Fact] + public void Validation_Works() + { + var model = new Data { FileID = "fileId" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Data { FileID = "fileId" }; + + Data copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Webhooks/DamFileUpdateEventTest.cs b/src/ImageKit.Tests/Models/Webhooks/DamFileUpdateEventTest.cs new file mode 100644 index 00000000..68fae29a --- /dev/null +++ b/src/ImageKit.Tests/Models/Webhooks/DamFileUpdateEventTest.cs @@ -0,0 +1,1070 @@ +using System; +using System.Collections.Generic; +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Models.Webhooks; +using Files = ImageKit.Models.Files; + +namespace ImageKit.Tests.Models.Webhooks; + +public class DamFileUpdateEventTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new DamFileUpdateEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, + }; + + string expectedID = "id"; + string expectedType = "type"; + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + Files::File expectedData = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedType, model.Type); + Assert.Equal(expectedCreatedAt, model.CreatedAt); + Assert.Equal(expectedData, model.Data); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new DamFileUpdateEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new DamFileUpdateEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedType = "type"; + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + Files::File expectedData = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedType, deserialized.Type); + Assert.Equal(expectedCreatedAt, deserialized.CreatedAt); + Assert.Equal(expectedData, deserialized.Data); + } + + [Fact] + public void Validation_Works() + { + var model = new DamFileUpdateEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new DamFileUpdateEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, + }; + + DamFileUpdateEvent copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class DamFileUpdateEventIntersectionMember1Test : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new DamFileUpdateEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, + }; + + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + Files::File expectedData = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }; + JsonElement expectedType = JsonSerializer.SerializeToElement("file.updated"); + + Assert.Equal(expectedCreatedAt, model.CreatedAt); + Assert.Equal(expectedData, model.Data); + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new DamFileUpdateEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new DamFileUpdateEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + Files::File expectedData = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }; + JsonElement expectedType = JsonSerializer.SerializeToElement("file.updated"); + + Assert.Equal(expectedCreatedAt, deserialized.CreatedAt); + Assert.Equal(expectedData, deserialized.Data); + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + } + + [Fact] + public void Validation_Works() + { + var model = new DamFileUpdateEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new DamFileUpdateEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, + }; + + DamFileUpdateEventIntersectionMember1 copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Webhooks/DamFileVersionCreateEventTest.cs b/src/ImageKit.Tests/Models/Webhooks/DamFileVersionCreateEventTest.cs new file mode 100644 index 00000000..847beca5 --- /dev/null +++ b/src/ImageKit.Tests/Models/Webhooks/DamFileVersionCreateEventTest.cs @@ -0,0 +1,200 @@ +using System; +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Models.Webhooks; + +namespace ImageKit.Tests.Models.Webhooks; + +public class DamFileVersionCreateEventTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new DamFileVersionCreateEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = JsonSerializer.Deserialize("{}"), + }; + + string expectedID = "id"; + string expectedType = "type"; + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + JsonElement expectedData = JsonSerializer.Deserialize("{}"); + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedType, model.Type); + Assert.Equal(expectedCreatedAt, model.CreatedAt); + Assert.True(JsonElement.DeepEquals(expectedData, model.Data)); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new DamFileVersionCreateEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = JsonSerializer.Deserialize("{}"), + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new DamFileVersionCreateEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = JsonSerializer.Deserialize("{}"), + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedType = "type"; + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + JsonElement expectedData = JsonSerializer.Deserialize("{}"); + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedType, deserialized.Type); + Assert.Equal(expectedCreatedAt, deserialized.CreatedAt); + Assert.True(JsonElement.DeepEquals(expectedData, deserialized.Data)); + } + + [Fact] + public void Validation_Works() + { + var model = new DamFileVersionCreateEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = JsonSerializer.Deserialize("{}"), + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new DamFileVersionCreateEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = JsonSerializer.Deserialize("{}"), + }; + + DamFileVersionCreateEvent copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class DamFileVersionCreateEventIntersectionMember1Test : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new DamFileVersionCreateEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = JsonSerializer.Deserialize("{}"), + }; + + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + JsonElement expectedData = JsonSerializer.Deserialize("{}"); + JsonElement expectedType = JsonSerializer.SerializeToElement("file-version.created"); + + Assert.Equal(expectedCreatedAt, model.CreatedAt); + Assert.True(JsonElement.DeepEquals(expectedData, model.Data)); + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new DamFileVersionCreateEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = JsonSerializer.Deserialize("{}"), + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new DamFileVersionCreateEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = JsonSerializer.Deserialize("{}"), + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + JsonElement expectedData = JsonSerializer.Deserialize("{}"); + JsonElement expectedType = JsonSerializer.SerializeToElement("file-version.created"); + + Assert.Equal(expectedCreatedAt, deserialized.CreatedAt); + Assert.True(JsonElement.DeepEquals(expectedData, deserialized.Data)); + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + } + + [Fact] + public void Validation_Works() + { + var model = new DamFileVersionCreateEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = JsonSerializer.Deserialize("{}"), + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new DamFileVersionCreateEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = JsonSerializer.Deserialize("{}"), + }; + + DamFileVersionCreateEventIntersectionMember1 copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Webhooks/DamFileVersionDeleteEventTest.cs b/src/ImageKit.Tests/Models/Webhooks/DamFileVersionDeleteEventTest.cs new file mode 100644 index 00000000..2f9d64e6 --- /dev/null +++ b/src/ImageKit.Tests/Models/Webhooks/DamFileVersionDeleteEventTest.cs @@ -0,0 +1,304 @@ +using System; +using System.Text.Json; +using ImageKit.Core; +using ImageKit.Models.Webhooks; + +namespace ImageKit.Tests.Models.Webhooks; + +public class DamFileVersionDeleteEventTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new DamFileVersionDeleteEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() { FileID = "fileId", VersionID = "versionId" }, + }; + + string expectedID = "id"; + string expectedType = "type"; + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + DamFileVersionDeleteEventIntersectionMember1Data expectedData = new() + { + FileID = "fileId", + VersionID = "versionId", + }; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedType, model.Type); + Assert.Equal(expectedCreatedAt, model.CreatedAt); + Assert.Equal(expectedData, model.Data); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new DamFileVersionDeleteEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() { FileID = "fileId", VersionID = "versionId" }, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new DamFileVersionDeleteEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() { FileID = "fileId", VersionID = "versionId" }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedType = "type"; + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + DamFileVersionDeleteEventIntersectionMember1Data expectedData = new() + { + FileID = "fileId", + VersionID = "versionId", + }; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedType, deserialized.Type); + Assert.Equal(expectedCreatedAt, deserialized.CreatedAt); + Assert.Equal(expectedData, deserialized.Data); + } + + [Fact] + public void Validation_Works() + { + var model = new DamFileVersionDeleteEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() { FileID = "fileId", VersionID = "versionId" }, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new DamFileVersionDeleteEvent + { + ID = "id", + Type = "type", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() { FileID = "fileId", VersionID = "versionId" }, + }; + + DamFileVersionDeleteEvent copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class DamFileVersionDeleteEventIntersectionMember1Test : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new DamFileVersionDeleteEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() { FileID = "fileId", VersionID = "versionId" }, + }; + + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + DamFileVersionDeleteEventIntersectionMember1Data expectedData = new() + { + FileID = "fileId", + VersionID = "versionId", + }; + JsonElement expectedType = JsonSerializer.SerializeToElement("file-version.deleted"); + + Assert.Equal(expectedCreatedAt, model.CreatedAt); + Assert.Equal(expectedData, model.Data); + Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new DamFileVersionDeleteEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() { FileID = "fileId", VersionID = "versionId" }, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new DamFileVersionDeleteEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() { FileID = "fileId", VersionID = "versionId" }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + DamFileVersionDeleteEventIntersectionMember1Data expectedData = new() + { + FileID = "fileId", + VersionID = "versionId", + }; + JsonElement expectedType = JsonSerializer.SerializeToElement("file-version.deleted"); + + Assert.Equal(expectedCreatedAt, deserialized.CreatedAt); + Assert.Equal(expectedData, deserialized.Data); + Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); + } + + [Fact] + public void Validation_Works() + { + var model = new DamFileVersionDeleteEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() { FileID = "fileId", VersionID = "versionId" }, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new DamFileVersionDeleteEventIntersectionMember1 + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() { FileID = "fileId", VersionID = "versionId" }, + }; + + DamFileVersionDeleteEventIntersectionMember1 copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class DamFileVersionDeleteEventIntersectionMember1DataTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new DamFileVersionDeleteEventIntersectionMember1Data + { + FileID = "fileId", + VersionID = "versionId", + }; + + string expectedFileID = "fileId"; + string expectedVersionID = "versionId"; + + Assert.Equal(expectedFileID, model.FileID); + Assert.Equal(expectedVersionID, model.VersionID); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new DamFileVersionDeleteEventIntersectionMember1Data + { + FileID = "fileId", + VersionID = "versionId", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new DamFileVersionDeleteEventIntersectionMember1Data + { + FileID = "fileId", + VersionID = "versionId", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedFileID = "fileId"; + string expectedVersionID = "versionId"; + + Assert.Equal(expectedFileID, deserialized.FileID); + Assert.Equal(expectedVersionID, deserialized.VersionID); + } + + [Fact] + public void Validation_Works() + { + var model = new DamFileVersionDeleteEventIntersectionMember1Data + { + FileID = "fileId", + VersionID = "versionId", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new DamFileVersionDeleteEventIntersectionMember1Data + { + FileID = "fileId", + VersionID = "versionId", + }; + + DamFileVersionDeleteEventIntersectionMember1Data copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/ImageKit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs b/src/ImageKit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs index 92c81f97..70303719 100644 --- a/src/ImageKit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs +++ b/src/ImageKit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Text.Json; using ImageKit.Core; +using Files = ImageKit.Models.Files; using Webhooks = ImageKit.Models.Webhooks; namespace ImageKit.Tests.Models.Webhooks; @@ -383,6 +384,195 @@ public void UploadPostTransformErrorValidationWorks() value.Validate(); } + [Fact] + public void DamFileCreateValidationWorks() + { + Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::DamFileCreateEvent() + { + ID = "id", + Type = "file.created", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, + }; + value.Validate(); + } + + [Fact] + public void DamFileUpdateValidationWorks() + { + Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::DamFileUpdateEvent() + { + ID = "id", + Type = "file.updated", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, + }; + value.Validate(); + } + + [Fact] + public void DamFileDeleteValidationWorks() + { + Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::DamFileDeleteEvent() + { + ID = "id", + Type = "file.deleted", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new("fileId"), + }; + value.Validate(); + } + + [Fact] + public void DamFileVersionCreateValidationWorks() + { + Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::DamFileVersionCreateEvent() + { + ID = "id", + Type = "file-version.created", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = JsonSerializer.Deserialize("{}"), + }; + value.Validate(); + } + + [Fact] + public void DamFileVersionDeleteValidationWorks() + { + Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::DamFileVersionDeleteEvent() + { + ID = "id", + Type = "file-version.deleted", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() { FileID = "fileId", VersionID = "versionId" }, + }; + value.Validate(); + } + [Fact] public void VideoTransformationAcceptedSerializationRoundtripWorks() { @@ -799,4 +989,223 @@ public void UploadPostTransformErrorSerializationRoundtripWorks() Assert.Equal(value, deserialized); } + + [Fact] + public void DamFileCreateSerializationRoundtripWorks() + { + Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::DamFileCreateEvent() + { + ID = "id", + Type = "file.created", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DamFileUpdateSerializationRoundtripWorks() + { + Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::DamFileUpdateEvent() + { + ID = "id", + Type = "file.updated", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DamFileDeleteSerializationRoundtripWorks() + { + Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::DamFileDeleteEvent() + { + ID = "id", + Type = "file.deleted", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new("fileId"), + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DamFileVersionCreateSerializationRoundtripWorks() + { + Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::DamFileVersionCreateEvent() + { + ID = "id", + Type = "file-version.created", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = JsonSerializer.Deserialize("{}"), + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DamFileVersionDeleteSerializationRoundtripWorks() + { + Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::DamFileVersionDeleteEvent() + { + ID = "id", + Type = "file-version.deleted", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() { FileID = "fileId", VersionID = "versionId" }, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } } diff --git a/src/ImageKit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs b/src/ImageKit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs index 9ab16533..454133f7 100644 --- a/src/ImageKit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs +++ b/src/ImageKit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Text.Json; using ImageKit.Core; +using Files = ImageKit.Models.Files; using Webhooks = ImageKit.Models.Webhooks; namespace ImageKit.Tests.Models.Webhooks; @@ -383,6 +384,195 @@ public void UploadPostTransformErrorValidationWorks() value.Validate(); } + [Fact] + public void DamFileCreateValidationWorks() + { + Webhooks::UnwrapWebhookEvent value = new Webhooks::DamFileCreateEvent() + { + ID = "id", + Type = "file.created", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, + }; + value.Validate(); + } + + [Fact] + public void DamFileUpdateValidationWorks() + { + Webhooks::UnwrapWebhookEvent value = new Webhooks::DamFileUpdateEvent() + { + ID = "id", + Type = "file.updated", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, + }; + value.Validate(); + } + + [Fact] + public void DamFileDeleteValidationWorks() + { + Webhooks::UnwrapWebhookEvent value = new Webhooks::DamFileDeleteEvent() + { + ID = "id", + Type = "file.deleted", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new("fileId"), + }; + value.Validate(); + } + + [Fact] + public void DamFileVersionCreateValidationWorks() + { + Webhooks::UnwrapWebhookEvent value = new Webhooks::DamFileVersionCreateEvent() + { + ID = "id", + Type = "file-version.created", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = JsonSerializer.Deserialize("{}"), + }; + value.Validate(); + } + + [Fact] + public void DamFileVersionDeleteValidationWorks() + { + Webhooks::UnwrapWebhookEvent value = new Webhooks::DamFileVersionDeleteEvent() + { + ID = "id", + Type = "file-version.deleted", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() { FileID = "fileId", VersionID = "versionId" }, + }; + value.Validate(); + } + [Fact] public void VideoTransformationAcceptedSerializationRoundtripWorks() { @@ -799,4 +989,223 @@ public void UploadPostTransformErrorSerializationRoundtripWorks() Assert.Equal(value, deserialized); } + + [Fact] + public void DamFileCreateSerializationRoundtripWorks() + { + Webhooks::UnwrapWebhookEvent value = new Webhooks::DamFileCreateEvent() + { + ID = "id", + Type = "file.created", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DamFileUpdateSerializationRoundtripWorks() + { + Webhooks::UnwrapWebhookEvent value = new Webhooks::DamFileUpdateEvent() + { + ID = "id", + Type = "file.updated", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DamFileDeleteSerializationRoundtripWorks() + { + Webhooks::UnwrapWebhookEvent value = new Webhooks::DamFileDeleteEvent() + { + ID = "id", + Type = "file.deleted", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new("fileId"), + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DamFileVersionCreateSerializationRoundtripWorks() + { + Webhooks::UnwrapWebhookEvent value = new Webhooks::DamFileVersionCreateEvent() + { + ID = "id", + Type = "file-version.created", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = JsonSerializer.Deserialize("{}"), + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DamFileVersionDeleteSerializationRoundtripWorks() + { + Webhooks::UnwrapWebhookEvent value = new Webhooks::DamFileVersionDeleteEvent() + { + ID = "id", + Type = "file-version.deleted", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() { FileID = "fileId", VersionID = "versionId" }, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } } diff --git a/src/ImageKit.Tests/Models/Webhooks/UploadPostTransformErrorEventTest.cs b/src/ImageKit.Tests/Models/Webhooks/UploadPostTransformErrorEventTest.cs index bbdc932a..43d93c31 100644 --- a/src/ImageKit.Tests/Models/Webhooks/UploadPostTransformErrorEventTest.cs +++ b/src/ImageKit.Tests/Models/Webhooks/UploadPostTransformErrorEventTest.cs @@ -39,7 +39,7 @@ public void FieldRoundtrip_Works() string expectedID = "id"; string expectedType = "type"; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - Webhooks::Data expectedData = new() + Webhooks::UploadPostTransformErrorEventIntersectionMember1Data expectedData = new() { FileID = "fileId", Name = "name", @@ -140,7 +140,7 @@ public void FieldRoundtripThroughSerialization_Works() string expectedID = "id"; string expectedType = "type"; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - Webhooks::Data expectedData = new() + Webhooks::UploadPostTransformErrorEventIntersectionMember1Data expectedData = new() { FileID = "fileId", Name = "name", @@ -231,12 +231,12 @@ public void CopyConstructor_Works() } } -public class IntersectionMember1Test : TestBase +public class UploadPostTransformErrorEventIntersectionMember1Test : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Webhooks::IntersectionMember1 + var model = new Webhooks::UploadPostTransformErrorEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -260,7 +260,7 @@ public void FieldRoundtrip_Works() }; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - Webhooks::Data expectedData = new() + Webhooks::UploadPostTransformErrorEventIntersectionMember1Data expectedData = new() { FileID = "fileId", Name = "name", @@ -289,7 +289,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Webhooks::IntersectionMember1 + var model = new Webhooks::UploadPostTransformErrorEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -313,10 +313,11 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -324,7 +325,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Webhooks::IntersectionMember1 + var model = new Webhooks::UploadPostTransformErrorEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -348,14 +349,15 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.NotNull(deserialized); DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - Webhooks::Data expectedData = new() + Webhooks::UploadPostTransformErrorEventIntersectionMember1Data expectedData = new() { FileID = "fileId", Name = "name", @@ -384,7 +386,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Webhooks::IntersectionMember1 + var model = new Webhooks::UploadPostTransformErrorEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -413,7 +415,7 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new Webhooks::IntersectionMember1 + var model = new Webhooks::UploadPostTransformErrorEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -436,18 +438,18 @@ public void CopyConstructor_Works() }, }; - Webhooks::IntersectionMember1 copied = new(model); + Webhooks::UploadPostTransformErrorEventIntersectionMember1 copied = new(model); Assert.Equal(model, copied); } } -public class DataTest : TestBase +public class UploadPostTransformErrorEventIntersectionMember1DataTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Webhooks::Data + var model = new Webhooks::UploadPostTransformErrorEventIntersectionMember1Data { FileID = "fileId", Name = "name", @@ -474,7 +476,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Webhooks::Data + var model = new Webhooks::UploadPostTransformErrorEventIntersectionMember1Data { FileID = "fileId", Name = "name", @@ -484,10 +486,11 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -495,7 +498,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Webhooks::Data + var model = new Webhooks::UploadPostTransformErrorEventIntersectionMember1Data { FileID = "fileId", Name = "name", @@ -505,10 +508,11 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.NotNull(deserialized); string expectedFileID = "fileId"; @@ -529,7 +533,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Webhooks::Data + var model = new Webhooks::UploadPostTransformErrorEventIntersectionMember1Data { FileID = "fileId", Name = "name", @@ -544,7 +548,7 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new Webhooks::Data + var model = new Webhooks::UploadPostTransformErrorEventIntersectionMember1Data { FileID = "fileId", Name = "name", @@ -553,7 +557,7 @@ public void CopyConstructor_Works() Url = "https://example.com", }; - Webhooks::Data copied = new(model); + Webhooks::UploadPostTransformErrorEventIntersectionMember1Data copied = new(model); Assert.Equal(model, copied); } diff --git a/src/ImageKit.Tests/TestBase.cs b/src/ImageKit.Tests/TestBase.cs index 5153c17c..77e1ea15 100644 --- a/src/ImageKit.Tests/TestBase.cs +++ b/src/ImageKit.Tests/TestBase.cs @@ -14,7 +14,6 @@ public TestBase() BaseUrl = Environment.GetEnvironmentVariable("TEST_API_BASE_URL") ?? "http://localhost:4010", PrivateKey = "My Private Key", - Password = "My Password", }; } } diff --git a/src/ImageKit/Core/ModelBase.cs b/src/ImageKit/Core/ModelBase.cs index 616e6674..7cc9e272 100644 --- a/src/ImageKit/Core/ModelBase.cs +++ b/src/ImageKit/Core/ModelBase.cs @@ -32,7 +32,6 @@ protected ModelBase(ModelBase modelBase) new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), - new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), diff --git a/src/ImageKit/Core/ParamsBase.cs b/src/ImageKit/Core/ParamsBase.cs index b3da410d..403a5e00 100644 --- a/src/ImageKit/Core/ParamsBase.cs +++ b/src/ImageKit/Core/ParamsBase.cs @@ -196,22 +196,6 @@ internal static void AddDefaultHeaders(HttpRequestMessage request, ClientOptions request.Headers.Add(header.Key, header.Value); } - if (options.PrivateKey != null && options.Password != null) - { - request.Headers.Add( - "Authorization", - string.Format( - "Basic {0}", - Convert.ToBase64String( - Encoding - .GetEncoding("ISO-8859-1") - .GetBytes( - string.Format("{0}:{1}", options.PrivateKey, options.Password) - ) - ) - ) - ); - } request.Headers.Add( "X-Stainless-Timeout", (options.Timeout ?? ClientOptions.DefaultTimeout).TotalSeconds.ToString() diff --git a/src/ImageKit/Models/ExtensionConfig.cs b/src/ImageKit/Models/ExtensionConfig.cs index 88cd9fe8..c21e3bc3 100644 --- a/src/ImageKit/Models/ExtensionConfig.cs +++ b/src/ImageKit/Models/ExtensionConfig.cs @@ -1374,10 +1374,8 @@ public long? MinSelections } /// - /// Array of possible tag values. The combined length of all strings must not - /// exceed 500 characters, and values cannot include the `%` character. When - /// providing large vocabularies (more than 30 items), the AI may not follow - /// the list strictly. + /// Array of possible tag values. Combined length of all strings must not exceed + /// 500 characters. Cannot contain the `%` character. /// public IReadOnlyList? Vocabulary { @@ -1546,10 +1544,7 @@ public long? MinSelections } /// - /// An array of possible values matching the custom metadata field type. If not - /// provided for SingleSelect or MultiSelect field types, all values from the - /// custom metadata field definition will be used. When providing large vocabularies - /// (above 30 items), the AI may not strictly adhere to the list. + /// Array of possible values matching the custom metadata field type. /// public IReadOnlyList? Vocabulary { diff --git a/src/ImageKit/Models/OverlayPosition.cs b/src/ImageKit/Models/OverlayPosition.cs index 33f724d8..e4d94de8 100644 --- a/src/ImageKit/Models/OverlayPosition.cs +++ b/src/ImageKit/Models/OverlayPosition.cs @@ -12,33 +12,9 @@ namespace ImageKit.Models; [JsonConverter(typeof(JsonModelConverter))] public sealed record class OverlayPosition : JsonModel { - /// - /// Sets the anchor point on the base asset from which the overlay offset is - /// calculated. The default value is `top_left`. Maps to `lap` in the URL. Can - /// only be used with one or more of `x`, `y`, `xCenter`, or `yCenter`. - /// - public ApiEnum? AnchorPoint - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass>("anchorPoint"); - } - init - { - if (value == null) - { - return; - } - - this._rawData.Set("anchorPoint", value); - } - } - /// /// Specifies the position of the overlay relative to the parent image or video. - /// If one or more of `x`, `y`, `xCenter`, or `yCenter` parameters are specified, - /// this parameter is ignored. Maps to `lfo` in the URL. + /// Maps to `lfo` in the URL. /// public ApiEnum? Focus { @@ -82,30 +58,6 @@ public X? X } } - /// - /// Specifies the x-coordinate on the base asset where the overlay's center will - /// be positioned. It also accepts arithmetic expressions such as `bw_mul_0.4` - /// or `bw_sub_cw`. Maps to `lxc` in the URL. Cannot be used together with `x`, - /// but can be used with `y`. Learn about [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). - /// - public XCenter? XCenter - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("xCenter"); - } - init - { - if (value == null) - { - return; - } - - this._rawData.Set("xCenter", value); - } - } - /// /// Specifies the y-coordinate of the top-left corner of the base asset where /// the overlay's top-left corner will be positioned. It also accepts arithmetic @@ -130,39 +82,12 @@ public Y? Y } } - /// - /// Specifies the y-coordinate on the base asset where the overlay's center will - /// be positioned. It also accepts arithmetic expressions such as `bh_mul_0.4` - /// or `bh_sub_ch`. Maps to `lyc` in the URL. Cannot be used together with `y`, - /// but can be used with `x`. Learn about [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). - /// - public YCenter? YCenter - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("yCenter"); - } - init - { - if (value == null) - { - return; - } - - this._rawData.Set("yCenter", value); - } - } - /// public override void Validate() { - this.AnchorPoint?.Validate(); this.Focus?.Validate(); this.X?.Validate(); - this.XCenter?.Validate(); this.Y?.Validate(); - this.YCenter?.Validate(); } public OverlayPosition() { } @@ -201,79 +126,8 @@ public OverlayPosition FromRawUnchecked(IReadOnlyDictionary } /// -/// Sets the anchor point on the base asset from which the overlay offset is calculated. -/// The default value is `top_left`. Maps to `lap` in the URL. Can only be used with -/// one or more of `x`, `y`, `xCenter`, or `yCenter`. -/// -[JsonConverter(typeof(AnchorPointConverter))] -public enum AnchorPoint -{ - Top, - Left, - Right, - Bottom, - TopLeft, - TopRight, - BottomLeft, - BottomRight, - Center, -} - -sealed class AnchorPointConverter : JsonConverter -{ - public override AnchorPoint Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "top" => AnchorPoint.Top, - "left" => AnchorPoint.Left, - "right" => AnchorPoint.Right, - "bottom" => AnchorPoint.Bottom, - "top_left" => AnchorPoint.TopLeft, - "top_right" => AnchorPoint.TopRight, - "bottom_left" => AnchorPoint.BottomLeft, - "bottom_right" => AnchorPoint.BottomRight, - "center" => AnchorPoint.Center, - _ => (AnchorPoint)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - AnchorPoint value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - AnchorPoint.Top => "top", - AnchorPoint.Left => "left", - AnchorPoint.Right => "right", - AnchorPoint.Bottom => "bottom", - AnchorPoint.TopLeft => "top_left", - AnchorPoint.TopRight => "top_right", - AnchorPoint.BottomLeft => "bottom_left", - AnchorPoint.BottomRight => "bottom_right", - AnchorPoint.Center => "center", - _ => throw new ImageKitInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } -} - -/// -/// Specifies the position of the overlay relative to the parent image or video. If -/// one or more of `x`, `y`, `xCenter`, or `yCenter` parameters are specified, this -/// parameter is ignored. Maps to `lfo` in the URL. +/// Specifies the position of the overlay relative to the parent image or video. Maps +/// to `lfo` in the URL. /// [JsonConverter(typeof(FocusConverter))] public enum Focus @@ -575,13 +429,13 @@ public override void Write(Utf8JsonWriter writer, X value, JsonSerializerOptions } /// -/// Specifies the x-coordinate on the base asset where the overlay's center will -/// be positioned. It also accepts arithmetic expressions such as `bw_mul_0.4` or -/// `bw_sub_cw`. Maps to `lxc` in the URL. Cannot be used together with `x`, but can -/// be used with `y`. Learn about [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). +/// Specifies the y-coordinate of the top-left corner of the base asset where the +/// overlay's top-left corner will be positioned. It also accepts arithmetic expressions +/// such as `bh_mul_0.4` or `bh_sub_ch`. Maps to `ly` in the URL. Learn about [Arithmetic +/// expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). /// -[JsonConverter(typeof(XCenterConverter))] -public record class XCenter : ModelBase +[JsonConverter(typeof(YConverter))] +public record class Y : ModelBase { public object? Value { get; } = null; @@ -598,19 +452,19 @@ public JsonElement Json } } - public XCenter(double value, JsonElement? element = null) + public Y(double value, JsonElement? element = null) { this.Value = value; this._element = element; } - public XCenter(string value, JsonElement? element = null) + public Y(string value, JsonElement? element = null) { this.Value = value; this._element = element; } - public XCenter(JsonElement element) + public Y(JsonElement element) { this._element = element; } @@ -688,7 +542,7 @@ public void Switch(Action @double, Action @string) @string(value); break; default: - throw new ImageKitInvalidDataException("Data did not match any variant of XCenter"); + throw new ImageKitInvalidDataException("Data did not match any variant of Y"); } } @@ -719,15 +573,13 @@ public T Match(Func @double, Func @string) { double value => @double(value), string value => @string(value), - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of XCenter" - ), + _ => throw new ImageKitInvalidDataException("Data did not match any variant of Y"), }; } - public static implicit operator XCenter(double value) => new(value); + public static implicit operator Y(double value) => new(value); - public static implicit operator XCenter(string value) => new(value); + public static implicit operator Y(string value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -743,11 +595,11 @@ public override void Validate() { if (this.Value == null) { - throw new ImageKitInvalidDataException("Data did not match any variant of XCenter"); + throw new ImageKitInvalidDataException("Data did not match any variant of Y"); } } - public virtual bool Equals(XCenter? other) => + public virtual bool Equals(Y? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -774,247 +626,9 @@ int VariantIndex() } } -sealed class XCenterConverter : JsonConverter +sealed class YConverter : JsonConverter { - public override XCenter? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - var element = JsonSerializer.Deserialize(ref reader, options); - try - { - return new(JsonSerializer.Deserialize(element, options), element); - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - // ignore - } - - try - { - var deserialized = JsonSerializer.Deserialize(element, options); - if (deserialized != null) - { - return new(deserialized, element); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - // ignore - } - - return new(element); - } - - public override void Write(Utf8JsonWriter writer, XCenter value, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, value.Json, options); - } -} - -/// -/// Specifies the y-coordinate of the top-left corner of the base asset where the -/// overlay's top-left corner will be positioned. It also accepts arithmetic expressions -/// such as `bh_mul_0.4` or `bh_sub_ch`. Maps to `ly` in the URL. Learn about [Arithmetic -/// expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). -/// -[JsonConverter(typeof(YConverter))] -public record class Y : ModelBase -{ - public object? Value { get; } = null; - - JsonElement? _element = null; - - public JsonElement Json - { - get - { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions - ); - } - } - - public Y(double value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public Y(string value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public Y(JsonElement element) - { - this._element = element; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickDouble(out var value)) { - /// // `value` is of type `double` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickString(out var value)) { - /// // `value` is of type `string` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you need your function parameters to return something. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// instance.Switch( - /// (double value) => {...}, - /// (string value) => {...} - /// ); - /// - /// - /// - public void Switch(Action @double, Action @string) - { - switch (this.Value) - { - case double value: - @double(value); - break; - case string value: - @string(value); - break; - default: - throw new ImageKitInvalidDataException("Data did not match any variant of Y"); - } - } - - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with and - /// returns its result. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you don't need your function parameters to return a value. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// var result = instance.Match( - /// (double value) => {...}, - /// (string value) => {...} - /// ); - /// - /// - /// - public T Match(Func @double, Func @string) - { - return this.Value switch - { - double value => @double(value), - string value => @string(value), - _ => throw new ImageKitInvalidDataException("Data did not match any variant of Y"), - }; - } - - public static implicit operator Y(double value) => new(value); - - public static implicit operator Y(string value) => new(value); - - /// - /// Validates that the instance was constructed with a known variant and that this variant is valid - /// (based on its own Validate method). - /// - /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). - /// - /// - /// Thrown when the instance does not pass validation. - /// - /// - public override void Validate() - { - if (this.Value == null) - { - throw new ImageKitInvalidDataException("Data did not match any variant of Y"); - } - } - - public virtual bool Equals(Y? other) => - other != null - && this.VariantIndex() == other.VariantIndex() - && JsonElement.DeepEquals(this.Json, other.Json); - - public override int GetHashCode() - { - return 0; - } - - public override string ToString() => - JsonSerializer.Serialize( - FriendlyJsonPrinter.PrintValue(this.Json), - ModelBase.ToStringSerializerOptions - ); - - int VariantIndex() - { - return this.Value switch - { - double _ => 0, - string _ => 1, - _ => -1, - }; - } -} - -sealed class YConverter : JsonConverter -{ - public override Y? Read( + public override Y? Read( ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options @@ -1051,243 +665,3 @@ public override void Write(Utf8JsonWriter writer, Y value, JsonSerializerOptions JsonSerializer.Serialize(writer, value.Json, options); } } - -/// -/// Specifies the y-coordinate on the base asset where the overlay's center will -/// be positioned. It also accepts arithmetic expressions such as `bh_mul_0.4` or -/// `bh_sub_ch`. Maps to `lyc` in the URL. Cannot be used together with `y`, but can -/// be used with `x`. Learn about [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). -/// -[JsonConverter(typeof(YCenterConverter))] -public record class YCenter : ModelBase -{ - public object? Value { get; } = null; - - JsonElement? _element = null; - - public JsonElement Json - { - get - { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions - ); - } - } - - public YCenter(double value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public YCenter(string value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public YCenter(JsonElement element) - { - this._element = element; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickDouble(out var value)) { - /// // `value` is of type `double` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickDouble([NotNullWhen(true)] out double? value) - { - value = this.Value as double?; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickString(out var value)) { - /// // `value` is of type `string` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickString([NotNullWhen(true)] out string? value) - { - value = this.Value as string; - return value != null; - } - - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you need your function parameters to return something. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// instance.Switch( - /// (double value) => {...}, - /// (string value) => {...} - /// ); - /// - /// - /// - public void Switch(Action @double, Action @string) - { - switch (this.Value) - { - case double value: - @double(value); - break; - case string value: - @string(value); - break; - default: - throw new ImageKitInvalidDataException("Data did not match any variant of YCenter"); - } - } - - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with and - /// returns its result. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you don't need your function parameters to return a value. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// var result = instance.Match( - /// (double value) => {...}, - /// (string value) => {...} - /// ); - /// - /// - /// - public T Match(Func @double, Func @string) - { - return this.Value switch - { - double value => @double(value), - string value => @string(value), - _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of YCenter" - ), - }; - } - - public static implicit operator YCenter(double value) => new(value); - - public static implicit operator YCenter(string value) => new(value); - - /// - /// Validates that the instance was constructed with a known variant and that this variant is valid - /// (based on its own Validate method). - /// - /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). - /// - /// - /// Thrown when the instance does not pass validation. - /// - /// - public override void Validate() - { - if (this.Value == null) - { - throw new ImageKitInvalidDataException("Data did not match any variant of YCenter"); - } - } - - public virtual bool Equals(YCenter? other) => - other != null - && this.VariantIndex() == other.VariantIndex() - && JsonElement.DeepEquals(this.Json, other.Json); - - public override int GetHashCode() - { - return 0; - } - - public override string ToString() => - JsonSerializer.Serialize( - FriendlyJsonPrinter.PrintValue(this.Json), - ModelBase.ToStringSerializerOptions - ); - - int VariantIndex() - { - return this.Value switch - { - double _ => 0, - string _ => 1, - _ => -1, - }; - } -} - -sealed class YCenterConverter : JsonConverter -{ - public override YCenter? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - var element = JsonSerializer.Deserialize(ref reader, options); - try - { - return new(JsonSerializer.Deserialize(element, options), element); - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - // ignore - } - - try - { - var deserialized = JsonSerializer.Deserialize(element, options); - if (deserialized != null) - { - return new(deserialized, element); - } - } - catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) - { - // ignore - } - - return new(element); - } - - public override void Write(Utf8JsonWriter writer, YCenter value, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, value.Json, options); - } -} diff --git a/src/ImageKit/Models/Transformation.cs b/src/ImageKit/Models/Transformation.cs index 262cc84d..092f9d26 100644 --- a/src/ImageKit/Models/Transformation.cs +++ b/src/ImageKit/Models/Transformation.cs @@ -1193,12 +1193,12 @@ public TransformationX? X /// Focus using cropped image coordinates - X center coordinate. See [Focus using /// cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). /// - public TransformationXCenter? XCenter + public XCenter? XCenter { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("xCenter"); + return this._rawData.GetNullableClass("xCenter"); } init { @@ -1236,12 +1236,12 @@ public TransformationY? Y /// Focus using cropped image coordinates - Y center coordinate. See [Focus using /// cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). /// - public TransformationYCenter? YCenter + public YCenter? YCenter { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("yCenter"); + return this._rawData.GetNullableClass("yCenter"); } init { @@ -6532,8 +6532,8 @@ JsonSerializerOptions options /// Focus using cropped image coordinates - X center coordinate. See [Focus using /// cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). /// -[JsonConverter(typeof(TransformationXCenterConverter))] -public record class TransformationXCenter : ModelBase +[JsonConverter(typeof(XCenterConverter))] +public record class XCenter : ModelBase { public object? Value { get; } = null; @@ -6550,19 +6550,19 @@ public JsonElement Json } } - public TransformationXCenter(double value, JsonElement? element = null) + public XCenter(double value, JsonElement? element = null) { this.Value = value; this._element = element; } - public TransformationXCenter(string value, JsonElement? element = null) + public XCenter(string value, JsonElement? element = null) { this.Value = value; this._element = element; } - public TransformationXCenter(JsonElement element) + public XCenter(JsonElement element) { this._element = element; } @@ -6640,9 +6640,7 @@ public void Switch(Action @double, Action @string) @string(value); break; default: - throw new ImageKitInvalidDataException( - "Data did not match any variant of TransformationXCenter" - ); + throw new ImageKitInvalidDataException("Data did not match any variant of XCenter"); } } @@ -6674,14 +6672,14 @@ public T Match(Func @double, Func @string) double value => @double(value), string value => @string(value), _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of TransformationXCenter" + "Data did not match any variant of XCenter" ), }; } - public static implicit operator TransformationXCenter(double value) => new(value); + public static implicit operator XCenter(double value) => new(value); - public static implicit operator TransformationXCenter(string value) => new(value); + public static implicit operator XCenter(string value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -6697,13 +6695,11 @@ public override void Validate() { if (this.Value == null) { - throw new ImageKitInvalidDataException( - "Data did not match any variant of TransformationXCenter" - ); + throw new ImageKitInvalidDataException("Data did not match any variant of XCenter"); } } - public virtual bool Equals(TransformationXCenter? other) => + public virtual bool Equals(XCenter? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -6730,9 +6726,9 @@ int VariantIndex() } } -sealed class TransformationXCenterConverter : JsonConverter +sealed class XCenterConverter : JsonConverter { - public override TransformationXCenter? Read( + public override XCenter? Read( ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options @@ -6764,11 +6760,7 @@ JsonSerializerOptions options return new(element); } - public override void Write( - Utf8JsonWriter writer, - TransformationXCenter value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, XCenter value, JsonSerializerOptions options) { JsonSerializer.Serialize(writer, value.Json, options); } @@ -7023,8 +7015,8 @@ JsonSerializerOptions options /// Focus using cropped image coordinates - Y center coordinate. See [Focus using /// cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). /// -[JsonConverter(typeof(TransformationYCenterConverter))] -public record class TransformationYCenter : ModelBase +[JsonConverter(typeof(YCenterConverter))] +public record class YCenter : ModelBase { public object? Value { get; } = null; @@ -7041,19 +7033,19 @@ public JsonElement Json } } - public TransformationYCenter(double value, JsonElement? element = null) + public YCenter(double value, JsonElement? element = null) { this.Value = value; this._element = element; } - public TransformationYCenter(string value, JsonElement? element = null) + public YCenter(string value, JsonElement? element = null) { this.Value = value; this._element = element; } - public TransformationYCenter(JsonElement element) + public YCenter(JsonElement element) { this._element = element; } @@ -7131,9 +7123,7 @@ public void Switch(Action @double, Action @string) @string(value); break; default: - throw new ImageKitInvalidDataException( - "Data did not match any variant of TransformationYCenter" - ); + throw new ImageKitInvalidDataException("Data did not match any variant of YCenter"); } } @@ -7165,14 +7155,14 @@ public T Match(Func @double, Func @string) double value => @double(value), string value => @string(value), _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of TransformationYCenter" + "Data did not match any variant of YCenter" ), }; } - public static implicit operator TransformationYCenter(double value) => new(value); + public static implicit operator YCenter(double value) => new(value); - public static implicit operator TransformationYCenter(string value) => new(value); + public static implicit operator YCenter(string value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -7188,13 +7178,11 @@ public override void Validate() { if (this.Value == null) { - throw new ImageKitInvalidDataException( - "Data did not match any variant of TransformationYCenter" - ); + throw new ImageKitInvalidDataException("Data did not match any variant of YCenter"); } } - public virtual bool Equals(TransformationYCenter? other) => + public virtual bool Equals(YCenter? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -7221,9 +7209,9 @@ int VariantIndex() } } -sealed class TransformationYCenterConverter : JsonConverter +sealed class YCenterConverter : JsonConverter { - public override TransformationYCenter? Read( + public override YCenter? Read( ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options @@ -7255,11 +7243,7 @@ JsonSerializerOptions options return new(element); } - public override void Write( - Utf8JsonWriter writer, - TransformationYCenter value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, YCenter value, JsonSerializerOptions options) { JsonSerializer.Serialize(writer, value.Json, options); } diff --git a/src/ImageKit/Models/UnnamedSchemaWithArrayParent0.cs b/src/ImageKit/Models/UnnamedSchemaWithArrayParent0.cs index f66652c4..8e0f321e 100644 --- a/src/ImageKit/Models/UnnamedSchemaWithArrayParent0.cs +++ b/src/ImageKit/Models/UnnamedSchemaWithArrayParent0.cs @@ -1578,10 +1578,8 @@ public long? MinSelections } /// - /// Array of possible tag values. The combined length of all strings must not - /// exceed 500 characters, and values cannot include the `%` character. When - /// providing large vocabularies (more than 30 items), the AI may not follow - /// the list strictly. + /// Array of possible tag values. Combined length of all strings must not exceed + /// 500 characters. Cannot contain the `%` character. /// public IReadOnlyList? Vocabulary { @@ -1765,10 +1763,7 @@ public long? MinSelections } /// - /// An array of possible values matching the custom metadata field type. If not - /// provided for SingleSelect or MultiSelect field types, all values from the - /// custom metadata field definition will be used. When providing large vocabularies - /// (above 30 items), the AI may not strictly adhere to the list. + /// Array of possible values matching the custom metadata field type. /// public IReadOnlyList? Vocabulary { diff --git a/src/ImageKit/Models/Webhooks/DamFileCreateEvent.cs b/src/ImageKit/Models/Webhooks/DamFileCreateEvent.cs new file mode 100644 index 00000000..10f4ce4b --- /dev/null +++ b/src/ImageKit/Models/Webhooks/DamFileCreateEvent.cs @@ -0,0 +1,225 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; +using ImageKit.Exceptions; +using ImageKit.Models.Files; + +namespace ImageKit.Models.Webhooks; + +/// +/// Triggered when a file is created. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class DamFileCreateEvent : JsonModel +{ + /// + /// Unique identifier for the event. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The type of webhook event. + /// + public required string Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// Timestamp of when the event occurred in ISO8601 format. + /// + public required DateTimeOffset CreatedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("created_at"); + } + init { this._rawData.Set("created_at", value); } + } + + /// + /// Object containing details of a file or file version. + /// + public required File Data + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("data"); + } + init { this._rawData.Set("data", value); } + } + + public static implicit operator BaseWebhookEvent(DamFileCreateEvent damFileCreateEvent) => + new() { ID = damFileCreateEvent.ID, Type = damFileCreateEvent.Type }; + + /// + public override void Validate() + { + _ = this.ID; + _ = this.Type; + _ = this.CreatedAt; + this.Data.Validate(); + } + + public DamFileCreateEvent() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public DamFileCreateEvent(DamFileCreateEvent damFileCreateEvent) + : base(damFileCreateEvent) { } +#pragma warning restore CS8618 + + public DamFileCreateEvent(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + DamFileCreateEvent(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static DamFileCreateEvent FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class DamFileCreateEventFromRaw : IFromRawJson +{ + /// + public DamFileCreateEvent FromRawUnchecked(IReadOnlyDictionary rawData) => + DamFileCreateEvent.FromRawUnchecked(rawData); +} + +/// +/// Triggered when a file is created. +/// +[JsonConverter( + typeof(JsonModelConverter< + global::ImageKit.Models.Webhooks.IntersectionMember1, + global::ImageKit.Models.Webhooks.IntersectionMember1FromRaw + >) +)] +public sealed record class IntersectionMember1 : JsonModel +{ + /// + /// Timestamp of when the event occurred in ISO8601 format. + /// + public required DateTimeOffset CreatedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("created_at"); + } + init { this._rawData.Set("created_at", value); } + } + + /// + /// Object containing details of a file or file version. + /// + public required File Data + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("data"); + } + init { this._rawData.Set("data", value); } + } + + /// + /// Type of the webhook event. + /// + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + public override void Validate() + { + _ = this.CreatedAt; + this.Data.Validate(); + if (!JsonElement.DeepEquals(this.Type, JsonSerializer.SerializeToElement("file.created"))) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + } + + public IntersectionMember1() + { + this.Type = JsonSerializer.SerializeToElement("file.created"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public IntersectionMember1( + global::ImageKit.Models.Webhooks.IntersectionMember1 intersectionMember1 + ) + : base(intersectionMember1) { } +#pragma warning restore CS8618 + + public IntersectionMember1(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("file.created"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + IntersectionMember1(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static global::ImageKit.Models.Webhooks.IntersectionMember1 FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class IntersectionMember1FromRaw + : IFromRawJson +{ + /// + public global::ImageKit.Models.Webhooks.IntersectionMember1 FromRawUnchecked( + IReadOnlyDictionary rawData + ) => global::ImageKit.Models.Webhooks.IntersectionMember1.FromRawUnchecked(rawData); +} diff --git a/src/ImageKit/Models/Webhooks/DamFileDeleteEvent.cs b/src/ImageKit/Models/Webhooks/DamFileDeleteEvent.cs new file mode 100644 index 00000000..edda5014 --- /dev/null +++ b/src/ImageKit/Models/Webhooks/DamFileDeleteEvent.cs @@ -0,0 +1,282 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; +using ImageKit.Exceptions; + +namespace ImageKit.Models.Webhooks; + +/// +/// Triggered when a file is deleted. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class DamFileDeleteEvent : JsonModel +{ + /// + /// Unique identifier for the event. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The type of webhook event. + /// + public required string Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// Timestamp of when the event occurred in ISO8601 format. + /// + public required DateTimeOffset CreatedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("created_at"); + } + init { this._rawData.Set("created_at", value); } + } + + public required Data Data + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("data"); + } + init { this._rawData.Set("data", value); } + } + + public static implicit operator BaseWebhookEvent(DamFileDeleteEvent damFileDeleteEvent) => + new() { ID = damFileDeleteEvent.ID, Type = damFileDeleteEvent.Type }; + + /// + public override void Validate() + { + _ = this.ID; + _ = this.Type; + _ = this.CreatedAt; + this.Data.Validate(); + } + + public DamFileDeleteEvent() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public DamFileDeleteEvent(DamFileDeleteEvent damFileDeleteEvent) + : base(damFileDeleteEvent) { } +#pragma warning restore CS8618 + + public DamFileDeleteEvent(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + DamFileDeleteEvent(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static DamFileDeleteEvent FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class DamFileDeleteEventFromRaw : IFromRawJson +{ + /// + public DamFileDeleteEvent FromRawUnchecked(IReadOnlyDictionary rawData) => + DamFileDeleteEvent.FromRawUnchecked(rawData); +} + +/// +/// Triggered when a file is deleted. +/// +[JsonConverter( + typeof(JsonModelConverter< + DamFileDeleteEventIntersectionMember1, + DamFileDeleteEventIntersectionMember1FromRaw + >) +)] +public sealed record class DamFileDeleteEventIntersectionMember1 : JsonModel +{ + /// + /// Timestamp of when the event occurred in ISO8601 format. + /// + public required DateTimeOffset CreatedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("created_at"); + } + init { this._rawData.Set("created_at", value); } + } + + public required Data Data + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("data"); + } + init { this._rawData.Set("data", value); } + } + + /// + /// Type of the webhook event. + /// + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + public override void Validate() + { + _ = this.CreatedAt; + this.Data.Validate(); + if (!JsonElement.DeepEquals(this.Type, JsonSerializer.SerializeToElement("file.deleted"))) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + } + + public DamFileDeleteEventIntersectionMember1() + { + this.Type = JsonSerializer.SerializeToElement("file.deleted"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public DamFileDeleteEventIntersectionMember1( + DamFileDeleteEventIntersectionMember1 damFileDeleteEventIntersectionMember1 + ) + : base(damFileDeleteEventIntersectionMember1) { } +#pragma warning restore CS8618 + + public DamFileDeleteEventIntersectionMember1(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("file.deleted"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + DamFileDeleteEventIntersectionMember1(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static DamFileDeleteEventIntersectionMember1 FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class DamFileDeleteEventIntersectionMember1FromRaw + : IFromRawJson +{ + /// + public DamFileDeleteEventIntersectionMember1 FromRawUnchecked( + IReadOnlyDictionary rawData + ) => DamFileDeleteEventIntersectionMember1.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Data : JsonModel +{ + /// + /// The unique `fileId` of the deleted file. + /// + public required string FileID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("fileId"); + } + init { this._rawData.Set("fileId", value); } + } + + /// + public override void Validate() + { + _ = this.FileID; + } + + public Data() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Data(Data data) + : base(data) { } +#pragma warning restore CS8618 + + public Data(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Data(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static Data FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public Data(string fileID) + : this() + { + this.FileID = fileID; + } +} + +class DataFromRaw : IFromRawJson +{ + /// + public Data FromRawUnchecked(IReadOnlyDictionary rawData) => + Data.FromRawUnchecked(rawData); +} diff --git a/src/ImageKit/Models/Webhooks/DamFileUpdateEvent.cs b/src/ImageKit/Models/Webhooks/DamFileUpdateEvent.cs new file mode 100644 index 00000000..7f3cebe0 --- /dev/null +++ b/src/ImageKit/Models/Webhooks/DamFileUpdateEvent.cs @@ -0,0 +1,225 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; +using ImageKit.Exceptions; +using ImageKit.Models.Files; + +namespace ImageKit.Models.Webhooks; + +/// +/// Triggered when a file is updated. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class DamFileUpdateEvent : JsonModel +{ + /// + /// Unique identifier for the event. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The type of webhook event. + /// + public required string Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// Timestamp of when the event occurred in ISO8601 format. + /// + public required DateTimeOffset CreatedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("created_at"); + } + init { this._rawData.Set("created_at", value); } + } + + /// + /// Object containing details of a file or file version. + /// + public required File Data + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("data"); + } + init { this._rawData.Set("data", value); } + } + + public static implicit operator BaseWebhookEvent(DamFileUpdateEvent damFileUpdateEvent) => + new() { ID = damFileUpdateEvent.ID, Type = damFileUpdateEvent.Type }; + + /// + public override void Validate() + { + _ = this.ID; + _ = this.Type; + _ = this.CreatedAt; + this.Data.Validate(); + } + + public DamFileUpdateEvent() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public DamFileUpdateEvent(DamFileUpdateEvent damFileUpdateEvent) + : base(damFileUpdateEvent) { } +#pragma warning restore CS8618 + + public DamFileUpdateEvent(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + DamFileUpdateEvent(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static DamFileUpdateEvent FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class DamFileUpdateEventFromRaw : IFromRawJson +{ + /// + public DamFileUpdateEvent FromRawUnchecked(IReadOnlyDictionary rawData) => + DamFileUpdateEvent.FromRawUnchecked(rawData); +} + +/// +/// Triggered when a file is updated. +/// +[JsonConverter( + typeof(JsonModelConverter< + DamFileUpdateEventIntersectionMember1, + DamFileUpdateEventIntersectionMember1FromRaw + >) +)] +public sealed record class DamFileUpdateEventIntersectionMember1 : JsonModel +{ + /// + /// Timestamp of when the event occurred in ISO8601 format. + /// + public required DateTimeOffset CreatedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("created_at"); + } + init { this._rawData.Set("created_at", value); } + } + + /// + /// Object containing details of a file or file version. + /// + public required File Data + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("data"); + } + init { this._rawData.Set("data", value); } + } + + /// + /// Type of the webhook event. + /// + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + public override void Validate() + { + _ = this.CreatedAt; + this.Data.Validate(); + if (!JsonElement.DeepEquals(this.Type, JsonSerializer.SerializeToElement("file.updated"))) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + } + + public DamFileUpdateEventIntersectionMember1() + { + this.Type = JsonSerializer.SerializeToElement("file.updated"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public DamFileUpdateEventIntersectionMember1( + DamFileUpdateEventIntersectionMember1 damFileUpdateEventIntersectionMember1 + ) + : base(damFileUpdateEventIntersectionMember1) { } +#pragma warning restore CS8618 + + public DamFileUpdateEventIntersectionMember1(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("file.updated"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + DamFileUpdateEventIntersectionMember1(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static DamFileUpdateEventIntersectionMember1 FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class DamFileUpdateEventIntersectionMember1FromRaw + : IFromRawJson +{ + /// + public DamFileUpdateEventIntersectionMember1 FromRawUnchecked( + IReadOnlyDictionary rawData + ) => DamFileUpdateEventIntersectionMember1.FromRawUnchecked(rawData); +} diff --git a/src/ImageKit/Models/Webhooks/DamFileVersionCreateEvent.cs b/src/ImageKit/Models/Webhooks/DamFileVersionCreateEvent.cs new file mode 100644 index 00000000..4c5d34f0 --- /dev/null +++ b/src/ImageKit/Models/Webhooks/DamFileVersionCreateEvent.cs @@ -0,0 +1,229 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; +using ImageKit.Exceptions; + +namespace ImageKit.Models.Webhooks; + +/// +/// Triggered when a file version is created. +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class DamFileVersionCreateEvent : JsonModel +{ + /// + /// Unique identifier for the event. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The type of webhook event. + /// + public required string Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// Timestamp of when the event occurred in ISO8601 format. + /// + public required DateTimeOffset CreatedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("created_at"); + } + init { this._rawData.Set("created_at", value); } + } + + public required JsonElement Data + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("data"); + } + init { this._rawData.Set("data", value); } + } + + public static implicit operator BaseWebhookEvent( + DamFileVersionCreateEvent damFileVersionCreateEvent + ) => new() { ID = damFileVersionCreateEvent.ID, Type = damFileVersionCreateEvent.Type }; + + /// + public override void Validate() + { + _ = this.ID; + _ = this.Type; + _ = this.CreatedAt; + _ = this.Data; + } + + public DamFileVersionCreateEvent() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public DamFileVersionCreateEvent(DamFileVersionCreateEvent damFileVersionCreateEvent) + : base(damFileVersionCreateEvent) { } +#pragma warning restore CS8618 + + public DamFileVersionCreateEvent(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + DamFileVersionCreateEvent(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static DamFileVersionCreateEvent FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class DamFileVersionCreateEventFromRaw : IFromRawJson +{ + /// + public DamFileVersionCreateEvent FromRawUnchecked( + IReadOnlyDictionary rawData + ) => DamFileVersionCreateEvent.FromRawUnchecked(rawData); +} + +/// +/// Triggered when a file version is created. +/// +[JsonConverter( + typeof(JsonModelConverter< + DamFileVersionCreateEventIntersectionMember1, + DamFileVersionCreateEventIntersectionMember1FromRaw + >) +)] +public sealed record class DamFileVersionCreateEventIntersectionMember1 : JsonModel +{ + /// + /// Timestamp of when the event occurred in ISO8601 format. + /// + public required DateTimeOffset CreatedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("created_at"); + } + init { this._rawData.Set("created_at", value); } + } + + public required JsonElement Data + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("data"); + } + init { this._rawData.Set("data", value); } + } + + /// + /// Type of the webhook event. + /// + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + public override void Validate() + { + _ = this.CreatedAt; + _ = this.Data; + if ( + !JsonElement.DeepEquals( + this.Type, + JsonSerializer.SerializeToElement("file-version.created") + ) + ) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + } + + public DamFileVersionCreateEventIntersectionMember1() + { + this.Type = JsonSerializer.SerializeToElement("file-version.created"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public DamFileVersionCreateEventIntersectionMember1( + DamFileVersionCreateEventIntersectionMember1 damFileVersionCreateEventIntersectionMember1 + ) + : base(damFileVersionCreateEventIntersectionMember1) { } +#pragma warning restore CS8618 + + public DamFileVersionCreateEventIntersectionMember1( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("file-version.created"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + DamFileVersionCreateEventIntersectionMember1(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static DamFileVersionCreateEventIntersectionMember1 FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class DamFileVersionCreateEventIntersectionMember1FromRaw + : IFromRawJson +{ + /// + public DamFileVersionCreateEventIntersectionMember1 FromRawUnchecked( + IReadOnlyDictionary rawData + ) => DamFileVersionCreateEventIntersectionMember1.FromRawUnchecked(rawData); +} diff --git a/src/ImageKit/Models/Webhooks/DamFileVersionDeleteEvent.cs b/src/ImageKit/Models/Webhooks/DamFileVersionDeleteEvent.cs new file mode 100644 index 00000000..6959bbe7 --- /dev/null +++ b/src/ImageKit/Models/Webhooks/DamFileVersionDeleteEvent.cs @@ -0,0 +1,317 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using ImageKit.Core; +using ImageKit.Exceptions; + +namespace ImageKit.Models.Webhooks; + +/// +/// Triggered when a file version is deleted. +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class DamFileVersionDeleteEvent : JsonModel +{ + /// + /// Unique identifier for the event. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The type of webhook event. + /// + public required string Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// Timestamp of when the event occurred in ISO8601 format. + /// + public required DateTimeOffset CreatedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("created_at"); + } + init { this._rawData.Set("created_at", value); } + } + + public required DamFileVersionDeleteEventIntersectionMember1Data Data + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "data" + ); + } + init { this._rawData.Set("data", value); } + } + + public static implicit operator BaseWebhookEvent( + DamFileVersionDeleteEvent damFileVersionDeleteEvent + ) => new() { ID = damFileVersionDeleteEvent.ID, Type = damFileVersionDeleteEvent.Type }; + + /// + public override void Validate() + { + _ = this.ID; + _ = this.Type; + _ = this.CreatedAt; + this.Data.Validate(); + } + + public DamFileVersionDeleteEvent() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public DamFileVersionDeleteEvent(DamFileVersionDeleteEvent damFileVersionDeleteEvent) + : base(damFileVersionDeleteEvent) { } +#pragma warning restore CS8618 + + public DamFileVersionDeleteEvent(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + DamFileVersionDeleteEvent(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static DamFileVersionDeleteEvent FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class DamFileVersionDeleteEventFromRaw : IFromRawJson +{ + /// + public DamFileVersionDeleteEvent FromRawUnchecked( + IReadOnlyDictionary rawData + ) => DamFileVersionDeleteEvent.FromRawUnchecked(rawData); +} + +/// +/// Triggered when a file version is deleted. +/// +[JsonConverter( + typeof(JsonModelConverter< + DamFileVersionDeleteEventIntersectionMember1, + DamFileVersionDeleteEventIntersectionMember1FromRaw + >) +)] +public sealed record class DamFileVersionDeleteEventIntersectionMember1 : JsonModel +{ + /// + /// Timestamp of when the event occurred in ISO8601 format. + /// + public required DateTimeOffset CreatedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("created_at"); + } + init { this._rawData.Set("created_at", value); } + } + + public required DamFileVersionDeleteEventIntersectionMember1Data Data + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "data" + ); + } + init { this._rawData.Set("data", value); } + } + + /// + /// Type of the webhook event. + /// + public JsonElement Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + public override void Validate() + { + _ = this.CreatedAt; + this.Data.Validate(); + if ( + !JsonElement.DeepEquals( + this.Type, + JsonSerializer.SerializeToElement("file-version.deleted") + ) + ) + { + throw new ImageKitInvalidDataException("Invalid value given for constant"); + } + } + + public DamFileVersionDeleteEventIntersectionMember1() + { + this.Type = JsonSerializer.SerializeToElement("file-version.deleted"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public DamFileVersionDeleteEventIntersectionMember1( + DamFileVersionDeleteEventIntersectionMember1 damFileVersionDeleteEventIntersectionMember1 + ) + : base(damFileVersionDeleteEventIntersectionMember1) { } +#pragma warning restore CS8618 + + public DamFileVersionDeleteEventIntersectionMember1( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.Type = JsonSerializer.SerializeToElement("file-version.deleted"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + DamFileVersionDeleteEventIntersectionMember1(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static DamFileVersionDeleteEventIntersectionMember1 FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class DamFileVersionDeleteEventIntersectionMember1FromRaw + : IFromRawJson +{ + /// + public DamFileVersionDeleteEventIntersectionMember1 FromRawUnchecked( + IReadOnlyDictionary rawData + ) => DamFileVersionDeleteEventIntersectionMember1.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + DamFileVersionDeleteEventIntersectionMember1Data, + DamFileVersionDeleteEventIntersectionMember1DataFromRaw + >) +)] +public sealed record class DamFileVersionDeleteEventIntersectionMember1Data : JsonModel +{ + /// + /// The unique `fileId` of the deleted file. + /// + public required string FileID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("fileId"); + } + init { this._rawData.Set("fileId", value); } + } + + /// + /// The unique `versionId` of the deleted file version. + /// + public required string VersionID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("versionId"); + } + init { this._rawData.Set("versionId", value); } + } + + /// + public override void Validate() + { + _ = this.FileID; + _ = this.VersionID; + } + + public DamFileVersionDeleteEventIntersectionMember1Data() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public DamFileVersionDeleteEventIntersectionMember1Data( + DamFileVersionDeleteEventIntersectionMember1Data damFileVersionDeleteEventIntersectionMember1Data + ) + : base(damFileVersionDeleteEventIntersectionMember1Data) { } +#pragma warning restore CS8618 + + public DamFileVersionDeleteEventIntersectionMember1Data( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + DamFileVersionDeleteEventIntersectionMember1Data(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static DamFileVersionDeleteEventIntersectionMember1Data FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class DamFileVersionDeleteEventIntersectionMember1DataFromRaw + : IFromRawJson +{ + /// + public DamFileVersionDeleteEventIntersectionMember1Data FromRawUnchecked( + IReadOnlyDictionary rawData + ) => DamFileVersionDeleteEventIntersectionMember1Data.FromRawUnchecked(rawData); +} diff --git a/src/ImageKit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs b/src/ImageKit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs index 662da824..b555f421 100644 --- a/src/ImageKit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs +++ b/src/ImageKit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs @@ -41,7 +41,12 @@ public string ID uploadPreTransformSuccess: (x) => x.ID, uploadPreTransformError: (x) => x.ID, uploadPostTransformSuccess: (x) => x.ID, - uploadPostTransformError: (x) => x.ID + uploadPostTransformError: (x) => x.ID, + damFileCreate: (x) => x.ID, + damFileUpdate: (x) => x.ID, + damFileDelete: (x) => x.ID, + damFileVersionCreate: (x) => x.ID, + damFileVersionDelete: (x) => x.ID ); } } @@ -57,7 +62,12 @@ public string Type uploadPreTransformSuccess: (x) => x.Type, uploadPreTransformError: (x) => x.Type, uploadPostTransformSuccess: (x) => x.Type, - uploadPostTransformError: (x) => x.Type + uploadPostTransformError: (x) => x.Type, + damFileCreate: (x) => x.Type, + damFileUpdate: (x) => x.Type, + damFileDelete: (x) => x.Type, + damFileVersionCreate: (x) => x.Type, + damFileVersionDelete: (x) => x.Type ); } } @@ -73,7 +83,12 @@ public string Type uploadPreTransformSuccess: (x) => x.CreatedAt, uploadPreTransformError: (x) => x.CreatedAt, uploadPostTransformSuccess: (x) => x.CreatedAt, - uploadPostTransformError: (x) => x.CreatedAt + uploadPostTransformError: (x) => x.CreatedAt, + damFileCreate: (x) => x.CreatedAt, + damFileUpdate: (x) => x.CreatedAt, + damFileDelete: (x) => x.CreatedAt, + damFileVersionCreate: (x) => x.CreatedAt, + damFileVersionDelete: (x) => x.CreatedAt ); } } @@ -138,6 +153,36 @@ public UnsafeUnwrapWebhookEvent( this._element = element; } + public UnsafeUnwrapWebhookEvent(DamFileCreateEvent value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnsafeUnwrapWebhookEvent(DamFileUpdateEvent value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnsafeUnwrapWebhookEvent(DamFileDeleteEvent value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnsafeUnwrapWebhookEvent(DamFileVersionCreateEvent value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnsafeUnwrapWebhookEvent(DamFileVersionDeleteEvent value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + public UnsafeUnwrapWebhookEvent(JsonElement element) { this._element = element; @@ -304,6 +349,115 @@ public bool TryPickUploadPostTransformError( return value != null; } + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDamFileCreate(out var value)) { + /// // `value` is of type `DamFileCreateEvent` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDamFileCreate([NotNullWhen(true)] out DamFileCreateEvent? value) + { + value = this.Value as DamFileCreateEvent; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDamFileUpdate(out var value)) { + /// // `value` is of type `DamFileUpdateEvent` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDamFileUpdate([NotNullWhen(true)] out DamFileUpdateEvent? value) + { + value = this.Value as DamFileUpdateEvent; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDamFileDelete(out var value)) { + /// // `value` is of type `DamFileDeleteEvent` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDamFileDelete([NotNullWhen(true)] out DamFileDeleteEvent? value) + { + value = this.Value as DamFileDeleteEvent; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDamFileVersionCreate(out var value)) { + /// // `value` is of type `DamFileVersionCreateEvent` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDamFileVersionCreate( + [NotNullWhen(true)] out DamFileVersionCreateEvent? value + ) + { + value = this.Value as DamFileVersionCreateEvent; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDamFileVersionDelete(out var value)) { + /// // `value` is of type `DamFileVersionDeleteEvent` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDamFileVersionDelete( + [NotNullWhen(true)] out DamFileVersionDeleteEvent? value + ) + { + value = this.Value as DamFileVersionDeleteEvent; + return value != null; + } + /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// @@ -324,7 +478,12 @@ public bool TryPickUploadPostTransformError( /// (UploadPreTransformSuccessEvent value) => {...}, /// (UploadPreTransformErrorEvent value) => {...}, /// (UploadPostTransformSuccessEvent value) => {...}, - /// (UploadPostTransformErrorEvent value) => {...} + /// (UploadPostTransformErrorEvent value) => {...}, + /// (DamFileCreateEvent value) => {...}, + /// (DamFileUpdateEvent value) => {...}, + /// (DamFileDeleteEvent value) => {...}, + /// (DamFileVersionCreateEvent value) => {...}, + /// (DamFileVersionDeleteEvent value) => {...} /// ); /// /// @@ -336,7 +495,12 @@ public void Switch( System::Action uploadPreTransformSuccess, System::Action uploadPreTransformError, System::Action uploadPostTransformSuccess, - System::Action uploadPostTransformError + System::Action uploadPostTransformError, + System::Action damFileCreate, + System::Action damFileUpdate, + System::Action damFileDelete, + System::Action damFileVersionCreate, + System::Action damFileVersionDelete ) { switch (this.Value) @@ -362,6 +526,21 @@ public void Switch( case UploadPostTransformErrorEvent value: uploadPostTransformError(value); break; + case DamFileCreateEvent value: + damFileCreate(value); + break; + case DamFileUpdateEvent value: + damFileUpdate(value); + break; + case DamFileDeleteEvent value: + damFileDelete(value); + break; + case DamFileVersionCreateEvent value: + damFileVersionCreate(value); + break; + case DamFileVersionDeleteEvent value: + damFileVersionDelete(value); + break; default: throw new ImageKitInvalidDataException( "Data did not match any variant of UnsafeUnwrapWebhookEvent" @@ -390,7 +569,12 @@ public void Switch( /// (UploadPreTransformSuccessEvent value) => {...}, /// (UploadPreTransformErrorEvent value) => {...}, /// (UploadPostTransformSuccessEvent value) => {...}, - /// (UploadPostTransformErrorEvent value) => {...} + /// (UploadPostTransformErrorEvent value) => {...}, + /// (DamFileCreateEvent value) => {...}, + /// (DamFileUpdateEvent value) => {...}, + /// (DamFileDeleteEvent value) => {...}, + /// (DamFileVersionCreateEvent value) => {...}, + /// (DamFileVersionDeleteEvent value) => {...} /// ); /// /// @@ -402,7 +586,12 @@ public T Match( System::Func uploadPreTransformSuccess, System::Func uploadPreTransformError, System::Func uploadPostTransformSuccess, - System::Func uploadPostTransformError + System::Func uploadPostTransformError, + System::Func damFileCreate, + System::Func damFileUpdate, + System::Func damFileDelete, + System::Func damFileVersionCreate, + System::Func damFileVersionDelete ) { return this.Value switch @@ -414,6 +603,11 @@ public T Match( UploadPreTransformErrorEvent value => uploadPreTransformError(value), UploadPostTransformSuccessEvent value => uploadPostTransformSuccess(value), UploadPostTransformErrorEvent value => uploadPostTransformError(value), + DamFileCreateEvent value => damFileCreate(value), + DamFileUpdateEvent value => damFileUpdate(value), + DamFileDeleteEvent value => damFileDelete(value), + DamFileVersionCreateEvent value => damFileVersionCreate(value), + DamFileVersionDeleteEvent value => damFileVersionDelete(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of UnsafeUnwrapWebhookEvent" ), @@ -444,6 +638,21 @@ UploadPostTransformSuccessEvent value public static implicit operator UnsafeUnwrapWebhookEvent(UploadPostTransformErrorEvent value) => new(value); + public static implicit operator UnsafeUnwrapWebhookEvent(DamFileCreateEvent value) => + new(value); + + public static implicit operator UnsafeUnwrapWebhookEvent(DamFileUpdateEvent value) => + new(value); + + public static implicit operator UnsafeUnwrapWebhookEvent(DamFileDeleteEvent value) => + new(value); + + public static implicit operator UnsafeUnwrapWebhookEvent(DamFileVersionCreateEvent value) => + new(value); + + public static implicit operator UnsafeUnwrapWebhookEvent(DamFileVersionDeleteEvent value) => + new(value); + /// /// Validates that the instance was constructed with a known variant and that this variant is valid /// (based on its own Validate method). @@ -469,7 +678,12 @@ public override void Validate() (uploadPreTransformSuccess) => uploadPreTransformSuccess.Validate(), (uploadPreTransformError) => uploadPreTransformError.Validate(), (uploadPostTransformSuccess) => uploadPostTransformSuccess.Validate(), - (uploadPostTransformError) => uploadPostTransformError.Validate() + (uploadPostTransformError) => uploadPostTransformError.Validate(), + (damFileCreate) => damFileCreate.Validate(), + (damFileUpdate) => damFileUpdate.Validate(), + (damFileDelete) => damFileDelete.Validate(), + (damFileVersionCreate) => damFileVersionCreate.Validate(), + (damFileVersionDelete) => damFileVersionDelete.Validate() ); } @@ -500,6 +714,11 @@ int VariantIndex() UploadPreTransformErrorEvent _ => 4, UploadPostTransformSuccessEvent _ => 5, UploadPostTransformErrorEvent _ => 6, + DamFileCreateEvent _ => 7, + DamFileUpdateEvent _ => 8, + DamFileDeleteEvent _ => 9, + DamFileVersionCreateEvent _ => 10, + DamFileVersionDeleteEvent _ => 11, _ => -1, }; } @@ -654,6 +873,96 @@ JsonSerializerOptions options // ignore } + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + return new(element); } } diff --git a/src/ImageKit/Models/Webhooks/UnwrapWebhookEvent.cs b/src/ImageKit/Models/Webhooks/UnwrapWebhookEvent.cs index 7a87a34c..43a9e72a 100644 --- a/src/ImageKit/Models/Webhooks/UnwrapWebhookEvent.cs +++ b/src/ImageKit/Models/Webhooks/UnwrapWebhookEvent.cs @@ -41,7 +41,12 @@ public string ID uploadPreTransformSuccess: (x) => x.ID, uploadPreTransformError: (x) => x.ID, uploadPostTransformSuccess: (x) => x.ID, - uploadPostTransformError: (x) => x.ID + uploadPostTransformError: (x) => x.ID, + damFileCreate: (x) => x.ID, + damFileUpdate: (x) => x.ID, + damFileDelete: (x) => x.ID, + damFileVersionCreate: (x) => x.ID, + damFileVersionDelete: (x) => x.ID ); } } @@ -57,7 +62,12 @@ public string Type uploadPreTransformSuccess: (x) => x.Type, uploadPreTransformError: (x) => x.Type, uploadPostTransformSuccess: (x) => x.Type, - uploadPostTransformError: (x) => x.Type + uploadPostTransformError: (x) => x.Type, + damFileCreate: (x) => x.Type, + damFileUpdate: (x) => x.Type, + damFileDelete: (x) => x.Type, + damFileVersionCreate: (x) => x.Type, + damFileVersionDelete: (x) => x.Type ); } } @@ -73,7 +83,12 @@ public string Type uploadPreTransformSuccess: (x) => x.CreatedAt, uploadPreTransformError: (x) => x.CreatedAt, uploadPostTransformSuccess: (x) => x.CreatedAt, - uploadPostTransformError: (x) => x.CreatedAt + uploadPostTransformError: (x) => x.CreatedAt, + damFileCreate: (x) => x.CreatedAt, + damFileUpdate: (x) => x.CreatedAt, + damFileDelete: (x) => x.CreatedAt, + damFileVersionCreate: (x) => x.CreatedAt, + damFileVersionDelete: (x) => x.CreatedAt ); } } @@ -120,6 +135,36 @@ public UnwrapWebhookEvent(UploadPostTransformErrorEvent value, JsonElement? elem this._element = element; } + public UnwrapWebhookEvent(DamFileCreateEvent value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnwrapWebhookEvent(DamFileUpdateEvent value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnwrapWebhookEvent(DamFileDeleteEvent value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnwrapWebhookEvent(DamFileVersionCreateEvent value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public UnwrapWebhookEvent(DamFileVersionDeleteEvent value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + public UnwrapWebhookEvent(JsonElement element) { this._element = element; @@ -286,6 +331,115 @@ public bool TryPickUploadPostTransformError( return value != null; } + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDamFileCreate(out var value)) { + /// // `value` is of type `DamFileCreateEvent` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDamFileCreate([NotNullWhen(true)] out DamFileCreateEvent? value) + { + value = this.Value as DamFileCreateEvent; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDamFileUpdate(out var value)) { + /// // `value` is of type `DamFileUpdateEvent` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDamFileUpdate([NotNullWhen(true)] out DamFileUpdateEvent? value) + { + value = this.Value as DamFileUpdateEvent; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDamFileDelete(out var value)) { + /// // `value` is of type `DamFileDeleteEvent` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDamFileDelete([NotNullWhen(true)] out DamFileDeleteEvent? value) + { + value = this.Value as DamFileDeleteEvent; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDamFileVersionCreate(out var value)) { + /// // `value` is of type `DamFileVersionCreateEvent` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDamFileVersionCreate( + [NotNullWhen(true)] out DamFileVersionCreateEvent? value + ) + { + value = this.Value as DamFileVersionCreateEvent; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDamFileVersionDelete(out var value)) { + /// // `value` is of type `DamFileVersionDeleteEvent` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDamFileVersionDelete( + [NotNullWhen(true)] out DamFileVersionDeleteEvent? value + ) + { + value = this.Value as DamFileVersionDeleteEvent; + return value != null; + } + /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// @@ -306,7 +460,12 @@ public bool TryPickUploadPostTransformError( /// (UploadPreTransformSuccessEvent value) => {...}, /// (UploadPreTransformErrorEvent value) => {...}, /// (UploadPostTransformSuccessEvent value) => {...}, - /// (UploadPostTransformErrorEvent value) => {...} + /// (UploadPostTransformErrorEvent value) => {...}, + /// (DamFileCreateEvent value) => {...}, + /// (DamFileUpdateEvent value) => {...}, + /// (DamFileDeleteEvent value) => {...}, + /// (DamFileVersionCreateEvent value) => {...}, + /// (DamFileVersionDeleteEvent value) => {...} /// ); /// /// @@ -318,7 +477,12 @@ public void Switch( System::Action uploadPreTransformSuccess, System::Action uploadPreTransformError, System::Action uploadPostTransformSuccess, - System::Action uploadPostTransformError + System::Action uploadPostTransformError, + System::Action damFileCreate, + System::Action damFileUpdate, + System::Action damFileDelete, + System::Action damFileVersionCreate, + System::Action damFileVersionDelete ) { switch (this.Value) @@ -344,6 +508,21 @@ public void Switch( case UploadPostTransformErrorEvent value: uploadPostTransformError(value); break; + case DamFileCreateEvent value: + damFileCreate(value); + break; + case DamFileUpdateEvent value: + damFileUpdate(value); + break; + case DamFileDeleteEvent value: + damFileDelete(value); + break; + case DamFileVersionCreateEvent value: + damFileVersionCreate(value); + break; + case DamFileVersionDeleteEvent value: + damFileVersionDelete(value); + break; default: throw new ImageKitInvalidDataException( "Data did not match any variant of UnwrapWebhookEvent" @@ -372,7 +551,12 @@ public void Switch( /// (UploadPreTransformSuccessEvent value) => {...}, /// (UploadPreTransformErrorEvent value) => {...}, /// (UploadPostTransformSuccessEvent value) => {...}, - /// (UploadPostTransformErrorEvent value) => {...} + /// (UploadPostTransformErrorEvent value) => {...}, + /// (DamFileCreateEvent value) => {...}, + /// (DamFileUpdateEvent value) => {...}, + /// (DamFileDeleteEvent value) => {...}, + /// (DamFileVersionCreateEvent value) => {...}, + /// (DamFileVersionDeleteEvent value) => {...} /// ); /// /// @@ -384,7 +568,12 @@ public T Match( System::Func uploadPreTransformSuccess, System::Func uploadPreTransformError, System::Func uploadPostTransformSuccess, - System::Func uploadPostTransformError + System::Func uploadPostTransformError, + System::Func damFileCreate, + System::Func damFileUpdate, + System::Func damFileDelete, + System::Func damFileVersionCreate, + System::Func damFileVersionDelete ) { return this.Value switch @@ -396,6 +585,11 @@ public T Match( UploadPreTransformErrorEvent value => uploadPreTransformError(value), UploadPostTransformSuccessEvent value => uploadPostTransformSuccess(value), UploadPostTransformErrorEvent value => uploadPostTransformError(value), + DamFileCreateEvent value => damFileCreate(value), + DamFileUpdateEvent value => damFileUpdate(value), + DamFileDeleteEvent value => damFileDelete(value), + DamFileVersionCreateEvent value => damFileVersionCreate(value), + DamFileVersionDeleteEvent value => damFileVersionDelete(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of UnwrapWebhookEvent" ), @@ -423,6 +617,18 @@ public static implicit operator UnwrapWebhookEvent(UploadPostTransformSuccessEve public static implicit operator UnwrapWebhookEvent(UploadPostTransformErrorEvent value) => new(value); + public static implicit operator UnwrapWebhookEvent(DamFileCreateEvent value) => new(value); + + public static implicit operator UnwrapWebhookEvent(DamFileUpdateEvent value) => new(value); + + public static implicit operator UnwrapWebhookEvent(DamFileDeleteEvent value) => new(value); + + public static implicit operator UnwrapWebhookEvent(DamFileVersionCreateEvent value) => + new(value); + + public static implicit operator UnwrapWebhookEvent(DamFileVersionDeleteEvent value) => + new(value); + /// /// Validates that the instance was constructed with a known variant and that this variant is valid /// (based on its own Validate method). @@ -448,7 +654,12 @@ public override void Validate() (uploadPreTransformSuccess) => uploadPreTransformSuccess.Validate(), (uploadPreTransformError) => uploadPreTransformError.Validate(), (uploadPostTransformSuccess) => uploadPostTransformSuccess.Validate(), - (uploadPostTransformError) => uploadPostTransformError.Validate() + (uploadPostTransformError) => uploadPostTransformError.Validate(), + (damFileCreate) => damFileCreate.Validate(), + (damFileUpdate) => damFileUpdate.Validate(), + (damFileDelete) => damFileDelete.Validate(), + (damFileVersionCreate) => damFileVersionCreate.Validate(), + (damFileVersionDelete) => damFileVersionDelete.Validate() ); } @@ -479,6 +690,11 @@ int VariantIndex() UploadPreTransformErrorEvent _ => 4, UploadPostTransformSuccessEvent _ => 5, UploadPostTransformErrorEvent _ => 6, + DamFileCreateEvent _ => 7, + DamFileUpdateEvent _ => 8, + DamFileDeleteEvent _ => 9, + DamFileVersionCreateEvent _ => 10, + DamFileVersionDeleteEvent _ => 11, _ => -1, }; } @@ -633,6 +849,96 @@ JsonSerializerOptions options // ignore } + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + return new(element); } } diff --git a/src/ImageKit/Models/Webhooks/UploadPostTransformErrorEvent.cs b/src/ImageKit/Models/Webhooks/UploadPostTransformErrorEvent.cs index 5b5245f8..ffa377f3 100644 --- a/src/ImageKit/Models/Webhooks/UploadPostTransformErrorEvent.cs +++ b/src/ImageKit/Models/Webhooks/UploadPostTransformErrorEvent.cs @@ -57,12 +57,14 @@ public required string Type init { this._rawData.Set("created_at", value); } } - public required Data Data + public required UploadPostTransformErrorEventIntersectionMember1Data Data { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("data"); + return this._rawData.GetNotNullClass( + "data" + ); } init { this._rawData.Set("data", value); } } @@ -135,8 +137,13 @@ IReadOnlyDictionary rawData /// Triggered when a post-transformation fails. The original file remains available, /// but the requested transformation could not be generated. /// -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class IntersectionMember1 : JsonModel +[JsonConverter( + typeof(JsonModelConverter< + UploadPostTransformErrorEventIntersectionMember1, + UploadPostTransformErrorEventIntersectionMember1FromRaw + >) +)] +public sealed record class UploadPostTransformErrorEventIntersectionMember1 : JsonModel { /// /// Timestamp of when the event occurred in ISO8601 format. @@ -151,12 +158,14 @@ public sealed record class IntersectionMember1 : JsonModel init { this._rawData.Set("created_at", value); } } - public required Data Data + public required UploadPostTransformErrorEventIntersectionMember1Data Data { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("data"); + return this._rawData.GetNotNullClass( + "data" + ); } init { this._rawData.Set("data", value); } } @@ -198,18 +207,22 @@ public override void Validate() } } - public IntersectionMember1() + public UploadPostTransformErrorEventIntersectionMember1() { this.Type = JsonSerializer.SerializeToElement("upload.post-transform.error"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public IntersectionMember1(IntersectionMember1 intersectionMember1) - : base(intersectionMember1) { } + public UploadPostTransformErrorEventIntersectionMember1( + UploadPostTransformErrorEventIntersectionMember1 uploadPostTransformErrorEventIntersectionMember1 + ) + : base(uploadPostTransformErrorEventIntersectionMember1) { } #pragma warning restore CS8618 - public IntersectionMember1(IReadOnlyDictionary rawData) + public UploadPostTransformErrorEventIntersectionMember1( + IReadOnlyDictionary rawData + ) { this._rawData = new(rawData); @@ -218,14 +231,14 @@ public IntersectionMember1(IReadOnlyDictionary rawData) #pragma warning disable CS8618 [SetsRequiredMembers] - IntersectionMember1(FrozenDictionary rawData) + UploadPostTransformErrorEventIntersectionMember1(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static IntersectionMember1 FromRawUnchecked( + /// + public static UploadPostTransformErrorEventIntersectionMember1 FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -233,15 +246,22 @@ IReadOnlyDictionary rawData } } -class IntersectionMember1FromRaw : IFromRawJson +class UploadPostTransformErrorEventIntersectionMember1FromRaw + : IFromRawJson { /// - public IntersectionMember1 FromRawUnchecked(IReadOnlyDictionary rawData) => - IntersectionMember1.FromRawUnchecked(rawData); + public UploadPostTransformErrorEventIntersectionMember1 FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UploadPostTransformErrorEventIntersectionMember1.FromRawUnchecked(rawData); } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class Data : JsonModel +[JsonConverter( + typeof(JsonModelConverter< + UploadPostTransformErrorEventIntersectionMember1Data, + UploadPostTransformErrorEventIntersectionMember1DataFromRaw + >) +)] +public sealed record class UploadPostTransformErrorEventIntersectionMember1Data : JsonModel { /// /// Unique identifier of the originally uploaded file. @@ -315,39 +335,49 @@ public override void Validate() _ = this.Url; } - public Data() { } + public UploadPostTransformErrorEventIntersectionMember1Data() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public Data(Data data) - : base(data) { } + public UploadPostTransformErrorEventIntersectionMember1Data( + UploadPostTransformErrorEventIntersectionMember1Data uploadPostTransformErrorEventIntersectionMember1Data + ) + : base(uploadPostTransformErrorEventIntersectionMember1Data) { } #pragma warning restore CS8618 - public Data(IReadOnlyDictionary rawData) + public UploadPostTransformErrorEventIntersectionMember1Data( + IReadOnlyDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - Data(FrozenDictionary rawData) + UploadPostTransformErrorEventIntersectionMember1Data( + FrozenDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static Data FromRawUnchecked(IReadOnlyDictionary rawData) + /// + public static UploadPostTransformErrorEventIntersectionMember1Data FromRawUnchecked( + IReadOnlyDictionary rawData + ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class DataFromRaw : IFromRawJson +class UploadPostTransformErrorEventIntersectionMember1DataFromRaw + : IFromRawJson { /// - public Data FromRawUnchecked(IReadOnlyDictionary rawData) => - Data.FromRawUnchecked(rawData); + public UploadPostTransformErrorEventIntersectionMember1Data FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UploadPostTransformErrorEventIntersectionMember1Data.FromRawUnchecked(rawData); } [JsonConverter(typeof(JsonModelConverter))] From 8efe42de25549c94f7ad779c3f0f1438b2431ad7 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 10 Apr 2026 06:24:10 +0000 Subject: [PATCH 092/129] feat(api): fix spec indentation --- .stats.yml | 4 ++-- README.md | 6 +++++- .../Accounts/Origins/OriginCreateParamsTest.cs | 2 +- .../Accounts/Origins/OriginDeleteParamsTest.cs | 2 +- .../Accounts/Origins/OriginGetParamsTest.cs | 2 +- .../Accounts/Origins/OriginUpdateParamsTest.cs | 2 +- .../UrlEndpoints/UrlEndpointCreateParamsTest.cs | 2 +- .../UrlEndpoints/UrlEndpointDeleteParamsTest.cs | 2 +- .../UrlEndpoints/UrlEndpointGetParamsTest.cs | 2 +- .../UrlEndpoints/UrlEndpointUpdateParamsTest.cs | 2 +- .../Models/Accounts/Usage/UsageGetParamsTest.cs | 2 +- .../Models/Assets/AssetListParamsTest.cs | 2 +- .../Models/Beta/V2/Files/FileUploadParamsTest.cs | 2 +- .../Invalidation/InvalidationCreateParamsTest.cs | 2 +- .../Invalidation/InvalidationGetParamsTest.cs | 2 +- .../CustomMetadataFieldCreateParamsTest.cs | 2 +- .../CustomMetadataFieldDeleteParamsTest.cs | 2 +- .../CustomMetadataFieldListParamsTest.cs | 2 +- .../CustomMetadataFieldUpdateParamsTest.cs | 2 +- .../Models/Files/Bulk/BulkAddTagsParamsTest.cs | 2 +- .../Models/Files/Bulk/BulkDeleteParamsTest.cs | 2 +- .../Files/Bulk/BulkRemoveAITagsParamsTest.cs | 2 +- .../Files/Bulk/BulkRemoveTagsParamsTest.cs | 2 +- .../Models/Files/FileCopyParamsTest.cs | 2 +- .../Models/Files/FileDeleteParamsTest.cs | 2 +- .../Models/Files/FileGetParamsTest.cs | 2 +- .../Models/Files/FileMoveParamsTest.cs | 2 +- .../Models/Files/FileRenameParamsTest.cs | 2 +- .../Models/Files/FileUpdateParamsTest.cs | 2 +- .../Models/Files/FileUploadParamsTest.cs | 2 +- .../Metadata/MetadataGetFromUrlParamsTest.cs | 2 +- .../Files/Metadata/MetadataGetParamsTest.cs | 2 +- .../Files/Versions/VersionDeleteParamsTest.cs | 2 +- .../Files/Versions/VersionGetParamsTest.cs | 2 +- .../Files/Versions/VersionListParamsTest.cs | 2 +- .../Files/Versions/VersionRestoreParamsTest.cs | 2 +- .../Models/Folders/FolderCopyParamsTest.cs | 2 +- .../Models/Folders/FolderCreateParamsTest.cs | 2 +- .../Models/Folders/FolderDeleteParamsTest.cs | 2 +- .../Models/Folders/FolderMoveParamsTest.cs | 2 +- .../Models/Folders/FolderRenameParamsTest.cs | 2 +- .../Models/Folders/Job/JobGetParamsTest.cs | 2 +- .../SavedExtensionCreateParamsTest.cs | 2 +- .../SavedExtensionDeleteParamsTest.cs | 2 +- .../SavedExtensionGetParamsTest.cs | 2 +- .../SavedExtensionUpdateParamsTest.cs | 2 +- src/ImageKit.Tests/TestBase.cs | 1 + src/ImageKit/Core/ParamsBase.cs | 16 ++++++++++++++++ 48 files changed, 68 insertions(+), 47 deletions(-) diff --git a/.stats.yml b/.stats.yml index 3e331fe9..5beb1d71 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-1422f7513f230162270b197061e5768c2e0c803b94b8cd03a5e72544ac75a27f.yml -openapi_spec_hash: 41175e752e6f6ce900b36aecba687fa7 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-f4cd00365ba96133e0675eae3d5d3c6ac13874789e2ce69a84310ab64a4f87dd.yml +openapi_spec_hash: dce632cfbb5464a98c0f5d8eb9573d68 config_hash: 17e408231b0b01676298010c7405f483 diff --git a/README.md b/README.md index 7ed6afd5..124d940d 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,11 @@ Or manually: ```csharp using ImageKit; -ImageKitClient client = new() { PrivateKey = "My Private Key" }; +ImageKitClient client = new() +{ + PrivateKey = "My Private Key", + Password = "My Password", +}; ``` Or using a combination of the two approaches. diff --git a/src/ImageKit.Tests/Models/Accounts/Origins/OriginCreateParamsTest.cs b/src/ImageKit.Tests/Models/Accounts/Origins/OriginCreateParamsTest.cs index 5ccf9ac4..cf8f0d31 100644 --- a/src/ImageKit.Tests/Models/Accounts/Origins/OriginCreateParamsTest.cs +++ b/src/ImageKit.Tests/Models/Accounts/Origins/OriginCreateParamsTest.cs @@ -53,7 +53,7 @@ public void Url_Works() }, }; - var url = parameters.Url(new() { PrivateKey = "My Private Key" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/accounts/origins"), url); } diff --git a/src/ImageKit.Tests/Models/Accounts/Origins/OriginDeleteParamsTest.cs b/src/ImageKit.Tests/Models/Accounts/Origins/OriginDeleteParamsTest.cs index a12858d4..de154ad9 100644 --- a/src/ImageKit.Tests/Models/Accounts/Origins/OriginDeleteParamsTest.cs +++ b/src/ImageKit.Tests/Models/Accounts/Origins/OriginDeleteParamsTest.cs @@ -20,7 +20,7 @@ public void Url_Works() { OriginDeleteParams parameters = new() { ID = "id" }; - var url = parameters.Url(new() { PrivateKey = "My Private Key" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/accounts/origins/id"), url); } diff --git a/src/ImageKit.Tests/Models/Accounts/Origins/OriginGetParamsTest.cs b/src/ImageKit.Tests/Models/Accounts/Origins/OriginGetParamsTest.cs index 17b0cfac..51509129 100644 --- a/src/ImageKit.Tests/Models/Accounts/Origins/OriginGetParamsTest.cs +++ b/src/ImageKit.Tests/Models/Accounts/Origins/OriginGetParamsTest.cs @@ -20,7 +20,7 @@ public void Url_Works() { OriginGetParams parameters = new() { ID = "id" }; - var url = parameters.Url(new() { PrivateKey = "My Private Key" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/accounts/origins/id"), url); } diff --git a/src/ImageKit.Tests/Models/Accounts/Origins/OriginUpdateParamsTest.cs b/src/ImageKit.Tests/Models/Accounts/Origins/OriginUpdateParamsTest.cs index a37e7f51..6828eb88 100644 --- a/src/ImageKit.Tests/Models/Accounts/Origins/OriginUpdateParamsTest.cs +++ b/src/ImageKit.Tests/Models/Accounts/Origins/OriginUpdateParamsTest.cs @@ -57,7 +57,7 @@ public void Url_Works() }, }; - var url = parameters.Url(new() { PrivateKey = "My Private Key" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/accounts/origins/id"), url); } diff --git a/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointCreateParamsTest.cs b/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointCreateParamsTest.cs index 9a10c84a..971baa20 100644 --- a/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointCreateParamsTest.cs +++ b/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointCreateParamsTest.cs @@ -75,7 +75,7 @@ public void Url_Works() { UrlEndpointCreateParams parameters = new() { Description = "My custom URL endpoint" }; - var url = parameters.Url(new() { PrivateKey = "My Private Key" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/accounts/url-endpoints"), url); } diff --git a/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointDeleteParamsTest.cs b/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointDeleteParamsTest.cs index f8f3b56d..f4dc5da0 100644 --- a/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointDeleteParamsTest.cs +++ b/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointDeleteParamsTest.cs @@ -20,7 +20,7 @@ public void Url_Works() { UrlEndpointDeleteParams parameters = new() { ID = "id" }; - var url = parameters.Url(new() { PrivateKey = "My Private Key" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/accounts/url-endpoints/id"), url); } diff --git a/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointGetParamsTest.cs b/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointGetParamsTest.cs index 2eb97ed9..cd8562ad 100644 --- a/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointGetParamsTest.cs +++ b/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointGetParamsTest.cs @@ -20,7 +20,7 @@ public void Url_Works() { UrlEndpointGetParams parameters = new() { ID = "id" }; - var url = parameters.Url(new() { PrivateKey = "My Private Key" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/accounts/url-endpoints/id"), url); } diff --git a/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParamsTest.cs b/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParamsTest.cs index 2cb59f16..552ee2f1 100644 --- a/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParamsTest.cs +++ b/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParamsTest.cs @@ -94,7 +94,7 @@ public void Url_Works() Description = "My custom URL endpoint", }; - var url = parameters.Url(new() { PrivateKey = "My Private Key" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/accounts/url-endpoints/id"), url); } diff --git a/src/ImageKit.Tests/Models/Accounts/Usage/UsageGetParamsTest.cs b/src/ImageKit.Tests/Models/Accounts/Usage/UsageGetParamsTest.cs index 166d4529..d3f8003a 100644 --- a/src/ImageKit.Tests/Models/Accounts/Usage/UsageGetParamsTest.cs +++ b/src/ImageKit.Tests/Models/Accounts/Usage/UsageGetParamsTest.cs @@ -22,7 +22,7 @@ public void Url_Works() { UsageGetParams parameters = new() { EndDate = "2019-12-27", StartDate = "2019-12-27" }; - var url = parameters.Url(new() { PrivateKey = "My Private Key" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); Assert.Equal( new Uri( diff --git a/src/ImageKit.Tests/Models/Assets/AssetListParamsTest.cs b/src/ImageKit.Tests/Models/Assets/AssetListParamsTest.cs index 93a60ada..9058639f 100644 --- a/src/ImageKit.Tests/Models/Assets/AssetListParamsTest.cs +++ b/src/ImageKit.Tests/Models/Assets/AssetListParamsTest.cs @@ -105,7 +105,7 @@ public void Url_Works() Type = Assets::Type.File, }; - var url = parameters.Url(new() { PrivateKey = "My Private Key" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); Assert.Equal( new Uri( diff --git a/src/ImageKit.Tests/Models/Beta/V2/Files/FileUploadParamsTest.cs b/src/ImageKit.Tests/Models/Beta/V2/Files/FileUploadParamsTest.cs index 24f848ad..df9cfb30 100644 --- a/src/ImageKit.Tests/Models/Beta/V2/Files/FileUploadParamsTest.cs +++ b/src/ImageKit.Tests/Models/Beta/V2/Files/FileUploadParamsTest.cs @@ -376,7 +376,7 @@ public void Url_Works() FileName = "fileName", }; - var url = parameters.Url(new() { PrivateKey = "My Private Key" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); Assert.Equal(new Uri("https://api.imagekit.io/api/v2/files/upload"), url); } diff --git a/src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationCreateParamsTest.cs b/src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationCreateParamsTest.cs index 0d5f1956..a42ee393 100644 --- a/src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationCreateParamsTest.cs +++ b/src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationCreateParamsTest.cs @@ -26,7 +26,7 @@ public void Url_Works() UrlValue = "https://ik.imagekit.io/your_imagekit_id/default-image.jpg", }; - var url = parameters.Url(new() { PrivateKey = "My Private Key" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/files/purge"), url); } diff --git a/src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationGetParamsTest.cs b/src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationGetParamsTest.cs index f79b8936..60def5ee 100644 --- a/src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationGetParamsTest.cs +++ b/src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationGetParamsTest.cs @@ -20,7 +20,7 @@ public void Url_Works() { InvalidationGetParams parameters = new() { RequestID = "requestId" }; - var url = parameters.Url(new() { PrivateKey = "My Private Key" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/files/purge/requestId"), url); } diff --git a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsTest.cs b/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsTest.cs index b79620e2..cc1697df 100644 --- a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsTest.cs +++ b/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsTest.cs @@ -68,7 +68,7 @@ public void Url_Works() }, }; - var url = parameters.Url(new() { PrivateKey = "My Private Key" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/customMetadataFields"), url); } diff --git a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldDeleteParamsTest.cs b/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldDeleteParamsTest.cs index 6cce2ed4..14045bf0 100644 --- a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldDeleteParamsTest.cs +++ b/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldDeleteParamsTest.cs @@ -20,7 +20,7 @@ public void Url_Works() { CustomMetadataFieldDeleteParams parameters = new() { ID = "id" }; - var url = parameters.Url(new() { PrivateKey = "My Private Key" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/customMetadataFields/id"), url); } diff --git a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldListParamsTest.cs b/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldListParamsTest.cs index 61a6d1fa..de7b0113 100644 --- a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldListParamsTest.cs +++ b/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldListParamsTest.cs @@ -57,7 +57,7 @@ public void Url_Works() IncludeDeleted = true, }; - var url = parameters.Url(new() { PrivateKey = "My Private Key" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); Assert.Equal( new Uri( diff --git a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsTest.cs b/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsTest.cs index 746be2b9..7e969966 100644 --- a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsTest.cs +++ b/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsTest.cs @@ -79,7 +79,7 @@ public void Url_Works() { CustomMetadataFieldUpdateParams parameters = new() { ID = "id" }; - var url = parameters.Url(new() { PrivateKey = "My Private Key" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/customMetadataFields/id"), url); } diff --git a/src/ImageKit.Tests/Models/Files/Bulk/BulkAddTagsParamsTest.cs b/src/ImageKit.Tests/Models/Files/Bulk/BulkAddTagsParamsTest.cs index 6820095a..ee0c224e 100644 --- a/src/ImageKit.Tests/Models/Files/Bulk/BulkAddTagsParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/Bulk/BulkAddTagsParamsTest.cs @@ -39,7 +39,7 @@ public void Url_Works() Tags = ["t-shirt", "round-neck", "sale2019"], }; - var url = parameters.Url(new() { PrivateKey = "My Private Key" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/files/addTags"), url); } diff --git a/src/ImageKit.Tests/Models/Files/Bulk/BulkDeleteParamsTest.cs b/src/ImageKit.Tests/Models/Files/Bulk/BulkDeleteParamsTest.cs index 995c11ab..5b8d87a7 100644 --- a/src/ImageKit.Tests/Models/Files/Bulk/BulkDeleteParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/Bulk/BulkDeleteParamsTest.cs @@ -31,7 +31,7 @@ public void Url_Works() FileIds = ["598821f949c0a938d57563bd", "598821f949c0a938d57563be"], }; - var url = parameters.Url(new() { PrivateKey = "My Private Key" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/files/batch/deleteByFileIds"), url); } diff --git a/src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveAITagsParamsTest.cs b/src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveAITagsParamsTest.cs index ce22f26c..391cf465 100644 --- a/src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveAITagsParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveAITagsParamsTest.cs @@ -39,7 +39,7 @@ public void Url_Works() FileIds = ["598821f949c0a938d57563bd", "598821f949c0a938d57563be"], }; - var url = parameters.Url(new() { PrivateKey = "My Private Key" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/files/removeAITags"), url); } diff --git a/src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveTagsParamsTest.cs b/src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveTagsParamsTest.cs index 238be62d..49f93c1f 100644 --- a/src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveTagsParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveTagsParamsTest.cs @@ -39,7 +39,7 @@ public void Url_Works() Tags = ["t-shirt", "round-neck", "sale2019"], }; - var url = parameters.Url(new() { PrivateKey = "My Private Key" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/files/removeTags"), url); } diff --git a/src/ImageKit.Tests/Models/Files/FileCopyParamsTest.cs b/src/ImageKit.Tests/Models/Files/FileCopyParamsTest.cs index 4253ecd6..3a52f2cb 100644 --- a/src/ImageKit.Tests/Models/Files/FileCopyParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/FileCopyParamsTest.cs @@ -62,7 +62,7 @@ public void Url_Works() SourceFilePath = "/path/to/file.jpg", }; - var url = parameters.Url(new() { PrivateKey = "My Private Key" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/files/copy"), url); } diff --git a/src/ImageKit.Tests/Models/Files/FileDeleteParamsTest.cs b/src/ImageKit.Tests/Models/Files/FileDeleteParamsTest.cs index 871dc21d..65107f82 100644 --- a/src/ImageKit.Tests/Models/Files/FileDeleteParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/FileDeleteParamsTest.cs @@ -20,7 +20,7 @@ public void Url_Works() { FileDeleteParams parameters = new() { FileID = "fileId" }; - var url = parameters.Url(new() { PrivateKey = "My Private Key" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/files/fileId"), url); } diff --git a/src/ImageKit.Tests/Models/Files/FileGetParamsTest.cs b/src/ImageKit.Tests/Models/Files/FileGetParamsTest.cs index 5cecb84e..d2372359 100644 --- a/src/ImageKit.Tests/Models/Files/FileGetParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/FileGetParamsTest.cs @@ -20,7 +20,7 @@ public void Url_Works() { FileGetParams parameters = new() { FileID = "fileId" }; - var url = parameters.Url(new() { PrivateKey = "My Private Key" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/files/fileId/details"), url); } diff --git a/src/ImageKit.Tests/Models/Files/FileMoveParamsTest.cs b/src/ImageKit.Tests/Models/Files/FileMoveParamsTest.cs index de87d380..2f134efc 100644 --- a/src/ImageKit.Tests/Models/Files/FileMoveParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/FileMoveParamsTest.cs @@ -30,7 +30,7 @@ public void Url_Works() SourceFilePath = "/path/to/file.jpg", }; - var url = parameters.Url(new() { PrivateKey = "My Private Key" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/files/move"), url); } diff --git a/src/ImageKit.Tests/Models/Files/FileRenameParamsTest.cs b/src/ImageKit.Tests/Models/Files/FileRenameParamsTest.cs index b429b96d..e8cf12d8 100644 --- a/src/ImageKit.Tests/Models/Files/FileRenameParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/FileRenameParamsTest.cs @@ -62,7 +62,7 @@ public void Url_Works() NewFileName = "newFileName.jpg", }; - var url = parameters.Url(new() { PrivateKey = "My Private Key" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/files/rename"), url); } diff --git a/src/ImageKit.Tests/Models/Files/FileUpdateParamsTest.cs b/src/ImageKit.Tests/Models/Files/FileUpdateParamsTest.cs index 21d4ae5a..093b5533 100644 --- a/src/ImageKit.Tests/Models/Files/FileUpdateParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/FileUpdateParamsTest.cs @@ -185,7 +185,7 @@ public void Url_Works() }, }; - var url = parameters.Url(new() { PrivateKey = "My Private Key" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/files/fileId/details"), url); } diff --git a/src/ImageKit.Tests/Models/Files/FileUploadParamsTest.cs b/src/ImageKit.Tests/Models/Files/FileUploadParamsTest.cs index bb304a2d..d0f77eb2 100644 --- a/src/ImageKit.Tests/Models/Files/FileUploadParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/FileUploadParamsTest.cs @@ -400,7 +400,7 @@ public void Url_Works() FileName = "fileName", }; - var url = parameters.Url(new() { PrivateKey = "My Private Key" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); Assert.Equal(new Uri("https://api.imagekit.io/api/v1/files/upload"), url); } diff --git a/src/ImageKit.Tests/Models/Files/Metadata/MetadataGetFromUrlParamsTest.cs b/src/ImageKit.Tests/Models/Files/Metadata/MetadataGetFromUrlParamsTest.cs index 10017b83..41155870 100644 --- a/src/ImageKit.Tests/Models/Files/Metadata/MetadataGetFromUrlParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/Metadata/MetadataGetFromUrlParamsTest.cs @@ -20,7 +20,7 @@ public void Url_Works() { MetadataGetFromUrlParams parameters = new() { UrlValue = "https://example.com" }; - var url = parameters.Url(new() { PrivateKey = "My Private Key" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); Assert.Equal( new Uri("https://api.imagekit.io/v1/metadata?url=https%3a%2f%2fexample.com"), diff --git a/src/ImageKit.Tests/Models/Files/Metadata/MetadataGetParamsTest.cs b/src/ImageKit.Tests/Models/Files/Metadata/MetadataGetParamsTest.cs index 3f52b69e..d80a0a72 100644 --- a/src/ImageKit.Tests/Models/Files/Metadata/MetadataGetParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/Metadata/MetadataGetParamsTest.cs @@ -20,7 +20,7 @@ public void Url_Works() { MetadataGetParams parameters = new() { FileID = "fileId" }; - var url = parameters.Url(new() { PrivateKey = "My Private Key" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/files/fileId/metadata"), url); } diff --git a/src/ImageKit.Tests/Models/Files/Versions/VersionDeleteParamsTest.cs b/src/ImageKit.Tests/Models/Files/Versions/VersionDeleteParamsTest.cs index c28f06f0..105270a8 100644 --- a/src/ImageKit.Tests/Models/Files/Versions/VersionDeleteParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/Versions/VersionDeleteParamsTest.cs @@ -22,7 +22,7 @@ public void Url_Works() { VersionDeleteParams parameters = new() { FileID = "fileId", VersionID = "versionId" }; - var url = parameters.Url(new() { PrivateKey = "My Private Key" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/files/fileId/versions/versionId"), url); } diff --git a/src/ImageKit.Tests/Models/Files/Versions/VersionGetParamsTest.cs b/src/ImageKit.Tests/Models/Files/Versions/VersionGetParamsTest.cs index 24b3315f..e189bc4c 100644 --- a/src/ImageKit.Tests/Models/Files/Versions/VersionGetParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/Versions/VersionGetParamsTest.cs @@ -22,7 +22,7 @@ public void Url_Works() { VersionGetParams parameters = new() { FileID = "fileId", VersionID = "versionId" }; - var url = parameters.Url(new() { PrivateKey = "My Private Key" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/files/fileId/versions/versionId"), url); } diff --git a/src/ImageKit.Tests/Models/Files/Versions/VersionListParamsTest.cs b/src/ImageKit.Tests/Models/Files/Versions/VersionListParamsTest.cs index 0688f8d2..c6826fb4 100644 --- a/src/ImageKit.Tests/Models/Files/Versions/VersionListParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/Versions/VersionListParamsTest.cs @@ -20,7 +20,7 @@ public void Url_Works() { VersionListParams parameters = new() { FileID = "fileId" }; - var url = parameters.Url(new() { PrivateKey = "My Private Key" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/files/fileId/versions"), url); } diff --git a/src/ImageKit.Tests/Models/Files/Versions/VersionRestoreParamsTest.cs b/src/ImageKit.Tests/Models/Files/Versions/VersionRestoreParamsTest.cs index e12f29cd..a6b785d9 100644 --- a/src/ImageKit.Tests/Models/Files/Versions/VersionRestoreParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/Versions/VersionRestoreParamsTest.cs @@ -22,7 +22,7 @@ public void Url_Works() { VersionRestoreParams parameters = new() { FileID = "fileId", VersionID = "versionId" }; - var url = parameters.Url(new() { PrivateKey = "My Private Key" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); Assert.Equal( new Uri("https://api.imagekit.io/v1/files/fileId/versions/versionId/restore"), diff --git a/src/ImageKit.Tests/Models/Folders/FolderCopyParamsTest.cs b/src/ImageKit.Tests/Models/Folders/FolderCopyParamsTest.cs index 2d28e679..9027c155 100644 --- a/src/ImageKit.Tests/Models/Folders/FolderCopyParamsTest.cs +++ b/src/ImageKit.Tests/Models/Folders/FolderCopyParamsTest.cs @@ -62,7 +62,7 @@ public void Url_Works() SourceFolderPath = "/path/of/source/folder", }; - var url = parameters.Url(new() { PrivateKey = "My Private Key" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/bulkJobs/copyFolder"), url); } diff --git a/src/ImageKit.Tests/Models/Folders/FolderCreateParamsTest.cs b/src/ImageKit.Tests/Models/Folders/FolderCreateParamsTest.cs index 3407b592..ef6278aa 100644 --- a/src/ImageKit.Tests/Models/Folders/FolderCreateParamsTest.cs +++ b/src/ImageKit.Tests/Models/Folders/FolderCreateParamsTest.cs @@ -30,7 +30,7 @@ public void Url_Works() ParentFolderPath = "/product/images/", }; - var url = parameters.Url(new() { PrivateKey = "My Private Key" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/folder"), url); } diff --git a/src/ImageKit.Tests/Models/Folders/FolderDeleteParamsTest.cs b/src/ImageKit.Tests/Models/Folders/FolderDeleteParamsTest.cs index 7e5d1de1..ec79dff4 100644 --- a/src/ImageKit.Tests/Models/Folders/FolderDeleteParamsTest.cs +++ b/src/ImageKit.Tests/Models/Folders/FolderDeleteParamsTest.cs @@ -20,7 +20,7 @@ public void Url_Works() { FolderDeleteParams parameters = new() { FolderPath = "/folder/to/delete/" }; - var url = parameters.Url(new() { PrivateKey = "My Private Key" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/folder"), url); } diff --git a/src/ImageKit.Tests/Models/Folders/FolderMoveParamsTest.cs b/src/ImageKit.Tests/Models/Folders/FolderMoveParamsTest.cs index ba8e01b5..453c9468 100644 --- a/src/ImageKit.Tests/Models/Folders/FolderMoveParamsTest.cs +++ b/src/ImageKit.Tests/Models/Folders/FolderMoveParamsTest.cs @@ -30,7 +30,7 @@ public void Url_Works() SourceFolderPath = "/path/of/source/folder", }; - var url = parameters.Url(new() { PrivateKey = "My Private Key" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/bulkJobs/moveFolder"), url); } diff --git a/src/ImageKit.Tests/Models/Folders/FolderRenameParamsTest.cs b/src/ImageKit.Tests/Models/Folders/FolderRenameParamsTest.cs index b57e3d80..f52fa209 100644 --- a/src/ImageKit.Tests/Models/Folders/FolderRenameParamsTest.cs +++ b/src/ImageKit.Tests/Models/Folders/FolderRenameParamsTest.cs @@ -62,7 +62,7 @@ public void Url_Works() NewFolderName = "new-folder-name", }; - var url = parameters.Url(new() { PrivateKey = "My Private Key" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/bulkJobs/renameFolder"), url); } diff --git a/src/ImageKit.Tests/Models/Folders/Job/JobGetParamsTest.cs b/src/ImageKit.Tests/Models/Folders/Job/JobGetParamsTest.cs index 9ebb12e3..110cb8b1 100644 --- a/src/ImageKit.Tests/Models/Folders/Job/JobGetParamsTest.cs +++ b/src/ImageKit.Tests/Models/Folders/Job/JobGetParamsTest.cs @@ -20,7 +20,7 @@ public void Url_Works() { JobGetParams parameters = new() { JobID = "jobId" }; - var url = parameters.Url(new() { PrivateKey = "My Private Key" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/bulkJobs/jobId"), url); } diff --git a/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionCreateParamsTest.cs b/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionCreateParamsTest.cs index bc5d3695..168e5dad 100644 --- a/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionCreateParamsTest.cs +++ b/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionCreateParamsTest.cs @@ -63,7 +63,7 @@ public void Url_Works() Name = "Car Quality Analysis", }; - var url = parameters.Url(new() { PrivateKey = "My Private Key" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/saved-extensions"), url); } diff --git a/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionDeleteParamsTest.cs b/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionDeleteParamsTest.cs index a7db02bd..8c6831cd 100644 --- a/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionDeleteParamsTest.cs +++ b/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionDeleteParamsTest.cs @@ -20,7 +20,7 @@ public void Url_Works() { SavedExtensionDeleteParams parameters = new() { ID = "id" }; - var url = parameters.Url(new() { PrivateKey = "My Private Key" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/saved-extensions/id"), url); } diff --git a/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionGetParamsTest.cs b/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionGetParamsTest.cs index 6e01cb32..016a46cc 100644 --- a/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionGetParamsTest.cs +++ b/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionGetParamsTest.cs @@ -20,7 +20,7 @@ public void Url_Works() { SavedExtensionGetParams parameters = new() { ID = "id" }; - var url = parameters.Url(new() { PrivateKey = "My Private Key" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/saved-extensions/id"), url); } diff --git a/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionUpdateParamsTest.cs b/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionUpdateParamsTest.cs index 34a3000d..1a4fb0ee 100644 --- a/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionUpdateParamsTest.cs +++ b/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionUpdateParamsTest.cs @@ -85,7 +85,7 @@ public void Url_Works() { SavedExtensionUpdateParams parameters = new() { ID = "id" }; - var url = parameters.Url(new() { PrivateKey = "My Private Key" }); + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); Assert.Equal(new Uri("https://api.imagekit.io/v1/saved-extensions/id"), url); } diff --git a/src/ImageKit.Tests/TestBase.cs b/src/ImageKit.Tests/TestBase.cs index 77e1ea15..5153c17c 100644 --- a/src/ImageKit.Tests/TestBase.cs +++ b/src/ImageKit.Tests/TestBase.cs @@ -14,6 +14,7 @@ public TestBase() BaseUrl = Environment.GetEnvironmentVariable("TEST_API_BASE_URL") ?? "http://localhost:4010", PrivateKey = "My Private Key", + Password = "My Password", }; } } diff --git a/src/ImageKit/Core/ParamsBase.cs b/src/ImageKit/Core/ParamsBase.cs index 403a5e00..b3da410d 100644 --- a/src/ImageKit/Core/ParamsBase.cs +++ b/src/ImageKit/Core/ParamsBase.cs @@ -196,6 +196,22 @@ internal static void AddDefaultHeaders(HttpRequestMessage request, ClientOptions request.Headers.Add(header.Key, header.Value); } + if (options.PrivateKey != null && options.Password != null) + { + request.Headers.Add( + "Authorization", + string.Format( + "Basic {0}", + Convert.ToBase64String( + Encoding + .GetEncoding("ISO-8859-1") + .GetBytes( + string.Format("{0}:{1}", options.PrivateKey, options.Password) + ) + ) + ) + ); + } request.Headers.Add( "X-Stainless-Timeout", (options.Timeout ?? ClientOptions.DefaultTimeout).TotalSeconds.ToString() From c5c541a4f1badafe327688cd8a93a6d088cdc08a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 10 Apr 2026 06:30:54 +0000 Subject: [PATCH 093/129] feat(api): indentation fix --- .stats.yml | 4 +- .../Webhooks/DamFileVersionCreateEventTest.cs | 906 +++++++++++++++++- .../Webhooks/UnsafeUnwrapWebhookEventTest.cs | 128 ++- .../Models/Webhooks/UnwrapWebhookEventTest.cs | 128 ++- .../Webhooks/DamFileVersionCreateEvent.cs | 19 +- 5 files changed, 1155 insertions(+), 30 deletions(-) diff --git a/.stats.yml b/.stats.yml index 5beb1d71..3ae941b7 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-f4cd00365ba96133e0675eae3d5d3c6ac13874789e2ce69a84310ab64a4f87dd.yml -openapi_spec_hash: dce632cfbb5464a98c0f5d8eb9573d68 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-3234424a3a5871f31f5d6dcb8173593fc6c1db14802a0e71f14f3527ad16c871.yml +openapi_spec_hash: 017a8ab68d905ed9e163022f68d8be78 config_hash: 17e408231b0b01676298010c7405f483 diff --git a/src/ImageKit.Tests/Models/Webhooks/DamFileVersionCreateEventTest.cs b/src/ImageKit.Tests/Models/Webhooks/DamFileVersionCreateEventTest.cs index 847beca5..83175b89 100644 --- a/src/ImageKit.Tests/Models/Webhooks/DamFileVersionCreateEventTest.cs +++ b/src/ImageKit.Tests/Models/Webhooks/DamFileVersionCreateEventTest.cs @@ -1,7 +1,9 @@ using System; +using System.Collections.Generic; using System.Text.Json; using ImageKit.Core; using ImageKit.Models.Webhooks; +using Files = ImageKit.Models.Files; namespace ImageKit.Tests.Models.Webhooks; @@ -15,18 +17,142 @@ public void FieldRoundtrip_Works() ID = "id", Type = "type", CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - Data = JsonSerializer.Deserialize("{}"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, }; string expectedID = "id"; string expectedType = "type"; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - JsonElement expectedData = JsonSerializer.Deserialize("{}"); + Files::File expectedData = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedType, model.Type); Assert.Equal(expectedCreatedAt, model.CreatedAt); - Assert.True(JsonElement.DeepEquals(expectedData, model.Data)); + Assert.Equal(expectedData, model.Data); } [Fact] @@ -37,7 +163,69 @@ public void SerializationRoundtrip_Works() ID = "id", Type = "type", CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - Data = JsonSerializer.Deserialize("{}"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -57,7 +245,69 @@ public void FieldRoundtripThroughSerialization_Works() ID = "id", Type = "type", CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - Data = JsonSerializer.Deserialize("{}"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -70,12 +320,74 @@ public void FieldRoundtripThroughSerialization_Works() string expectedID = "id"; string expectedType = "type"; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - JsonElement expectedData = JsonSerializer.Deserialize("{}"); + Files::File expectedData = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedType, deserialized.Type); Assert.Equal(expectedCreatedAt, deserialized.CreatedAt); - Assert.True(JsonElement.DeepEquals(expectedData, deserialized.Data)); + Assert.Equal(expectedData, deserialized.Data); } [Fact] @@ -86,7 +398,69 @@ public void Validation_Works() ID = "id", Type = "type", CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - Data = JsonSerializer.Deserialize("{}"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, }; model.Validate(); @@ -100,7 +474,69 @@ public void CopyConstructor_Works() ID = "id", Type = "type", CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - Data = JsonSerializer.Deserialize("{}"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, }; DamFileVersionCreateEvent copied = new(model); @@ -117,15 +553,139 @@ public void FieldRoundtrip_Works() var model = new DamFileVersionCreateEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - Data = JsonSerializer.Deserialize("{}"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, }; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - JsonElement expectedData = JsonSerializer.Deserialize("{}"); + Files::File expectedData = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }; JsonElement expectedType = JsonSerializer.SerializeToElement("file-version.created"); Assert.Equal(expectedCreatedAt, model.CreatedAt); - Assert.True(JsonElement.DeepEquals(expectedData, model.Data)); + Assert.Equal(expectedData, model.Data); Assert.True(JsonElement.DeepEquals(expectedType, model.Type)); } @@ -135,7 +695,69 @@ public void SerializationRoundtrip_Works() var model = new DamFileVersionCreateEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - Data = JsonSerializer.Deserialize("{}"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -153,7 +775,69 @@ public void FieldRoundtripThroughSerialization_Works() var model = new DamFileVersionCreateEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - Data = JsonSerializer.Deserialize("{}"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -164,11 +848,73 @@ public void FieldRoundtripThroughSerialization_Works() Assert.NotNull(deserialized); DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - JsonElement expectedData = JsonSerializer.Deserialize("{}"); + Files::File expectedData = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }; JsonElement expectedType = JsonSerializer.SerializeToElement("file-version.created"); Assert.Equal(expectedCreatedAt, deserialized.CreatedAt); - Assert.True(JsonElement.DeepEquals(expectedData, deserialized.Data)); + Assert.Equal(expectedData, deserialized.Data); Assert.True(JsonElement.DeepEquals(expectedType, deserialized.Type)); } @@ -178,7 +924,69 @@ public void Validation_Works() var model = new DamFileVersionCreateEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - Data = JsonSerializer.Deserialize("{}"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, }; model.Validate(); @@ -190,7 +998,69 @@ public void CopyConstructor_Works() var model = new DamFileVersionCreateEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - Data = JsonSerializer.Deserialize("{}"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, }; DamFileVersionCreateEventIntersectionMember1 copied = new(model); diff --git a/src/ImageKit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs b/src/ImageKit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs index 70303719..32e48a5f 100644 --- a/src/ImageKit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs +++ b/src/ImageKit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs @@ -555,7 +555,69 @@ public void DamFileVersionCreateValidationWorks() ID = "id", Type = "file-version.created", CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - Data = JsonSerializer.Deserialize("{}"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, }; value.Validate(); } @@ -1179,7 +1241,69 @@ public void DamFileVersionCreateSerializationRoundtripWorks() ID = "id", Type = "file-version.created", CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - Data = JsonSerializer.Deserialize("{}"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize( diff --git a/src/ImageKit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs b/src/ImageKit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs index 454133f7..3faec7d0 100644 --- a/src/ImageKit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs +++ b/src/ImageKit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs @@ -555,7 +555,69 @@ public void DamFileVersionCreateValidationWorks() ID = "id", Type = "file-version.created", CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - Data = JsonSerializer.Deserialize("{}"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, }; value.Validate(); } @@ -1179,7 +1241,69 @@ public void DamFileVersionCreateSerializationRoundtripWorks() ID = "id", Type = "file-version.created", CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - Data = JsonSerializer.Deserialize("{}"), + Data = new() + { + AITags = + [ + new() + { + Confidence = 0, + Name = "name", + Source = "source", + }, + ], + AudioCodec = "audioCodec", + BitRate = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomCoordinates = "customCoordinates", + CustomMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Description = "description", + Duration = 0, + EmbeddedMetadata = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + FileID = "fileId", + FilePath = "filePath", + FileType = "fileType", + HasAlpha = true, + Height = 0, + IsPrivateFile = true, + IsPublished = true, + Mime = "mime", + Name = "name", + SelectedFieldsSchema = new Dictionary() + { + { + "foo", + new() + { + Type = Files::Type.Text, + DefaultValue = "string", + IsValueRequired = true, + MaxLength = 0, + MaxValue = "string", + MinLength = 0, + MinValue = "string", + ReadOnly = true, + SelectOptions = ["small", "medium", "large", 30, 40, true], + SelectOptionsTruncated = true, + } + }, + }, + Size = 0, + Tags = ["string"], + Thumbnail = "https://example.com", + Type = Files::FileType.File, + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Url = "https://example.com", + VersionInfo = new() { ID = "id", Name = "name" }, + VideoCodec = "videoCodec", + Width = 0, + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize( diff --git a/src/ImageKit/Models/Webhooks/DamFileVersionCreateEvent.cs b/src/ImageKit/Models/Webhooks/DamFileVersionCreateEvent.cs index 4c5d34f0..cabd6185 100644 --- a/src/ImageKit/Models/Webhooks/DamFileVersionCreateEvent.cs +++ b/src/ImageKit/Models/Webhooks/DamFileVersionCreateEvent.cs @@ -6,6 +6,7 @@ using System.Text.Json.Serialization; using ImageKit.Core; using ImageKit.Exceptions; +using ImageKit.Models.Files; namespace ImageKit.Models.Webhooks; @@ -56,12 +57,15 @@ public required DateTimeOffset CreatedAt init { this._rawData.Set("created_at", value); } } - public required JsonElement Data + /// + /// Object containing details of a file or file version. + /// + public required File Data { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("data"); + return this._rawData.GetNotNullClass("data"); } init { this._rawData.Set("data", value); } } @@ -76,7 +80,7 @@ public override void Validate() _ = this.ID; _ = this.Type; _ = this.CreatedAt; - _ = this.Data; + this.Data.Validate(); } public DamFileVersionCreateEvent() { } @@ -141,12 +145,15 @@ public required DateTimeOffset CreatedAt init { this._rawData.Set("created_at", value); } } - public required JsonElement Data + /// + /// Object containing details of a file or file version. + /// + public required File Data { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("data"); + return this._rawData.GetNotNullClass("data"); } init { this._rawData.Set("data", value); } } @@ -168,7 +175,7 @@ public JsonElement Type public override void Validate() { _ = this.CreatedAt; - _ = this.Data; + this.Data.Validate(); if ( !JsonElement.DeepEquals( this.Type, From 371c05839627af8ca90c92f206dcd6c4eab2acbc Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 10 Apr 2026 06:39:21 +0000 Subject: [PATCH 094/129] feat(api): merge with main to bring back missing parameters --- .stats.yml | 4 +- src/ImageKit.Tests/Models/BaseOverlayTest.cs | 21 + .../Models/GetImageAttributesOptionsTest.cs | 21 + src/ImageKit.Tests/Models/ImageOverlayTest.cs | 63 ++ .../Models/OverlayPositionTest.cs | 203 ++++++ src/ImageKit.Tests/Models/OverlayTest.cs | 42 ++ .../Models/SolidColorOverlayTest.cs | 21 + src/ImageKit.Tests/Models/SrcOptionsTest.cs | 21 + .../Models/SubtitleOverlayTest.cs | 21 + src/ImageKit.Tests/Models/TextOverlayTest.cs | 21 + .../Models/TransformationTest.cs | 57 +- src/ImageKit.Tests/Models/VideoOverlayTest.cs | 63 ++ src/ImageKit/Core/ModelBase.cs | 1 + src/ImageKit/Models/ExtensionConfig.cs | 11 +- src/ImageKit/Models/OverlayPosition.cs | 668 +++++++++++++++++- src/ImageKit/Models/Transformation.cs | 80 ++- .../Models/UnnamedSchemaWithArrayParent0.cs | 11 +- 17 files changed, 1250 insertions(+), 79 deletions(-) diff --git a/.stats.yml b/.stats.yml index 3ae941b7..0898c6b1 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-3234424a3a5871f31f5d6dcb8173593fc6c1db14802a0e71f14f3527ad16c871.yml -openapi_spec_hash: 017a8ab68d905ed9e163022f68d8be78 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-18b46cb8c1dd5cd0eea8559fa9671600540c5c4bee32f2d74f932416b7a1aee0.yml +openapi_spec_hash: 539770659847d04a92ef965a5313adde config_hash: 17e408231b0b01676298010c7405f483 diff --git a/src/ImageKit.Tests/Models/BaseOverlayTest.cs b/src/ImageKit.Tests/Models/BaseOverlayTest.cs index 66b3f066..03fa60af 100644 --- a/src/ImageKit.Tests/Models/BaseOverlayTest.cs +++ b/src/ImageKit.Tests/Models/BaseOverlayTest.cs @@ -15,9 +15,12 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -30,9 +33,12 @@ public void FieldRoundtrip_Works() ApiEnum expectedLayerMode = LayerMode.Multiply; OverlayPosition expectedPosition = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }; OverlayTiming expectedTiming = new() { @@ -54,9 +60,12 @@ public void SerializationRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -83,9 +92,12 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -105,9 +117,12 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum expectedLayerMode = LayerMode.Multiply; OverlayPosition expectedPosition = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }; OverlayTiming expectedTiming = new() { @@ -129,9 +144,12 @@ public void Validation_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -206,9 +224,12 @@ public void CopyConstructor_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { diff --git a/src/ImageKit.Tests/Models/GetImageAttributesOptionsTest.cs b/src/ImageKit.Tests/Models/GetImageAttributesOptionsTest.cs index f38eddfe..be0824d6 100644 --- a/src/ImageKit.Tests/Models/GetImageAttributesOptionsTest.cs +++ b/src/ImageKit.Tests/Models/GetImageAttributesOptionsTest.cs @@ -60,9 +60,12 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -168,9 +171,12 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -316,9 +322,12 @@ public void SerializationRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -438,9 +447,12 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -553,9 +565,12 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -701,9 +716,12 @@ public void Validation_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -921,9 +939,12 @@ public void CopyConstructor_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { diff --git a/src/ImageKit.Tests/Models/ImageOverlayTest.cs b/src/ImageKit.Tests/Models/ImageOverlayTest.cs index 06c31fcf..05d97bf4 100644 --- a/src/ImageKit.Tests/Models/ImageOverlayTest.cs +++ b/src/ImageKit.Tests/Models/ImageOverlayTest.cs @@ -16,9 +16,12 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -71,9 +74,12 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -129,9 +135,12 @@ public void FieldRoundtrip_Works() ApiEnum expectedLayerMode = LayerMode.Multiply; OverlayPosition expectedPosition = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }; OverlayTiming expectedTiming = new() { @@ -185,9 +194,12 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -261,9 +273,12 @@ public void SerializationRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -316,9 +331,12 @@ public void SerializationRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -388,9 +406,12 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -443,9 +464,12 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -508,9 +532,12 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum expectedLayerMode = LayerMode.Multiply; OverlayPosition expectedPosition = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }; OverlayTiming expectedTiming = new() { @@ -564,9 +591,12 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -640,9 +670,12 @@ public void Validation_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -695,9 +728,12 @@ public void Validation_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -831,9 +867,12 @@ public void CopyConstructor_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -886,9 +925,12 @@ public void CopyConstructor_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -999,9 +1041,12 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -1100,9 +1145,12 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -1215,9 +1263,12 @@ public void SerializationRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -1329,9 +1380,12 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -1437,9 +1491,12 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -1552,9 +1609,12 @@ public void Validation_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -1712,9 +1772,12 @@ public void CopyConstructor_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { diff --git a/src/ImageKit.Tests/Models/OverlayPositionTest.cs b/src/ImageKit.Tests/Models/OverlayPositionTest.cs index f38eb42b..69ec6237 100644 --- a/src/ImageKit.Tests/Models/OverlayPositionTest.cs +++ b/src/ImageKit.Tests/Models/OverlayPositionTest.cs @@ -12,18 +12,27 @@ public void FieldRoundtrip_Works() { var model = new OverlayPosition { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }; + ApiEnum expectedAnchorPoint = AnchorPoint.Top; ApiEnum expectedFocus = Focus.Center; X expectedX = 0; + XCenter expectedXCenter = 0; Y expectedY = 0; + YCenter expectedYCenter = 0; + Assert.Equal(expectedAnchorPoint, model.AnchorPoint); Assert.Equal(expectedFocus, model.Focus); Assert.Equal(expectedX, model.X); + Assert.Equal(expectedXCenter, model.XCenter); Assert.Equal(expectedY, model.Y); + Assert.Equal(expectedYCenter, model.YCenter); } [Fact] @@ -31,9 +40,12 @@ public void SerializationRoundtrip_Works() { var model = new OverlayPosition { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -50,9 +62,12 @@ public void FieldRoundtripThroughSerialization_Works() { var model = new OverlayPosition { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -62,13 +77,19 @@ public void FieldRoundtripThroughSerialization_Works() ); Assert.NotNull(deserialized); + ApiEnum expectedAnchorPoint = AnchorPoint.Top; ApiEnum expectedFocus = Focus.Center; X expectedX = 0; + XCenter expectedXCenter = 0; Y expectedY = 0; + YCenter expectedYCenter = 0; + Assert.Equal(expectedAnchorPoint, deserialized.AnchorPoint); Assert.Equal(expectedFocus, deserialized.Focus); Assert.Equal(expectedX, deserialized.X); + Assert.Equal(expectedXCenter, deserialized.XCenter); Assert.Equal(expectedY, deserialized.Y); + Assert.Equal(expectedYCenter, deserialized.YCenter); } [Fact] @@ -76,9 +97,12 @@ public void Validation_Works() { var model = new OverlayPosition { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }; model.Validate(); @@ -89,12 +113,18 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { var model = new OverlayPosition { }; + Assert.Null(model.AnchorPoint); + Assert.False(model.RawData.ContainsKey("anchorPoint")); Assert.Null(model.Focus); Assert.False(model.RawData.ContainsKey("focus")); Assert.Null(model.X); Assert.False(model.RawData.ContainsKey("x")); + Assert.Null(model.XCenter); + Assert.False(model.RawData.ContainsKey("xCenter")); Assert.Null(model.Y); Assert.False(model.RawData.ContainsKey("y")); + Assert.Null(model.YCenter); + Assert.False(model.RawData.ContainsKey("yCenter")); } [Fact] @@ -111,17 +141,26 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() var model = new OverlayPosition { // Null should be interpreted as omitted for these properties + AnchorPoint = null, Focus = null, X = null, + XCenter = null, Y = null, + YCenter = null, }; + Assert.Null(model.AnchorPoint); + Assert.False(model.RawData.ContainsKey("anchorPoint")); Assert.Null(model.Focus); Assert.False(model.RawData.ContainsKey("focus")); Assert.Null(model.X); Assert.False(model.RawData.ContainsKey("x")); + Assert.Null(model.XCenter); + Assert.False(model.RawData.ContainsKey("xCenter")); Assert.Null(model.Y); Assert.False(model.RawData.ContainsKey("y")); + Assert.Null(model.YCenter); + Assert.False(model.RawData.ContainsKey("yCenter")); } [Fact] @@ -130,9 +169,12 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() var model = new OverlayPosition { // Null should be interpreted as omitted for these properties + AnchorPoint = null, Focus = null, X = null, + XCenter = null, Y = null, + YCenter = null, }; model.Validate(); @@ -143,9 +185,12 @@ public void CopyConstructor_Works() { var model = new OverlayPosition { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }; OverlayPosition copied = new(model); @@ -154,6 +199,78 @@ public void CopyConstructor_Works() } } +public class AnchorPointTest : TestBase +{ + [Theory] + [InlineData(AnchorPoint.Top)] + [InlineData(AnchorPoint.Left)] + [InlineData(AnchorPoint.Right)] + [InlineData(AnchorPoint.Bottom)] + [InlineData(AnchorPoint.TopLeft)] + [InlineData(AnchorPoint.TopRight)] + [InlineData(AnchorPoint.BottomLeft)] + [InlineData(AnchorPoint.BottomRight)] + [InlineData(AnchorPoint.Center)] + public void Validation_Works(AnchorPoint rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(AnchorPoint.Top)] + [InlineData(AnchorPoint.Left)] + [InlineData(AnchorPoint.Right)] + [InlineData(AnchorPoint.Bottom)] + [InlineData(AnchorPoint.TopLeft)] + [InlineData(AnchorPoint.TopRight)] + [InlineData(AnchorPoint.BottomLeft)] + [InlineData(AnchorPoint.BottomRight)] + [InlineData(AnchorPoint.Center)] + public void SerializationRoundtrip_Works(AnchorPoint rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + public class FocusTest : TestBase { [Theory] @@ -263,6 +380,49 @@ public void StringSerializationRoundtripWorks() } } +public class XCenterTest : TestBase +{ + [Fact] + public void DoubleValidationWorks() + { + XCenter value = 0; + value.Validate(); + } + + [Fact] + public void StringValidationWorks() + { + XCenter value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + XCenter value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + XCenter value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + public class YTest : TestBase { [Fact] @@ -299,3 +459,46 @@ public void StringSerializationRoundtripWorks() Assert.Equal(value, deserialized); } } + +public class YCenterTest : TestBase +{ + [Fact] + public void DoubleValidationWorks() + { + YCenter value = 0; + value.Validate(); + } + + [Fact] + public void StringValidationWorks() + { + YCenter value = "string"; + value.Validate(); + } + + [Fact] + public void DoubleSerializationRoundtripWorks() + { + YCenter value = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void StringSerializationRoundtripWorks() + { + YCenter value = "string"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} diff --git a/src/ImageKit.Tests/Models/OverlayTest.cs b/src/ImageKit.Tests/Models/OverlayTest.cs index 76d92332..ae78c797 100644 --- a/src/ImageKit.Tests/Models/OverlayTest.cs +++ b/src/ImageKit.Tests/Models/OverlayTest.cs @@ -14,9 +14,12 @@ public void TextValidationWorks() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -57,9 +60,12 @@ public void ImageValidationWorks() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -112,9 +118,12 @@ public void ImageValidationWorks() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -177,9 +186,12 @@ public void VideoValidationWorks() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -232,9 +244,12 @@ public void VideoValidationWorks() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -297,9 +312,12 @@ public void SubtitleValidationWorks() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -334,9 +352,12 @@ public void SolidColorValidationWorks() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -369,9 +390,12 @@ public void TextSerializationRoundtripWorks() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -418,9 +442,12 @@ public void ImageSerializationRoundtripWorks() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -473,9 +500,12 @@ public void ImageSerializationRoundtripWorks() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -544,9 +574,12 @@ public void VideoSerializationRoundtripWorks() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -599,9 +632,12 @@ public void VideoSerializationRoundtripWorks() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -670,9 +706,12 @@ public void SubtitleSerializationRoundtripWorks() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -713,9 +752,12 @@ public void SolidColorSerializationRoundtripWorks() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { diff --git a/src/ImageKit.Tests/Models/SolidColorOverlayTest.cs b/src/ImageKit.Tests/Models/SolidColorOverlayTest.cs index 7b9aa0bf..6ae4efdc 100644 --- a/src/ImageKit.Tests/Models/SolidColorOverlayTest.cs +++ b/src/ImageKit.Tests/Models/SolidColorOverlayTest.cs @@ -15,9 +15,12 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -43,9 +46,12 @@ public void FieldRoundtrip_Works() ApiEnum expectedLayerMode = LayerMode.Multiply; OverlayPosition expectedPosition = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }; OverlayTiming expectedTiming = new() { @@ -89,9 +95,12 @@ public void SerializationRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -131,9 +140,12 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -166,9 +178,12 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum expectedLayerMode = LayerMode.Multiply; OverlayPosition expectedPosition = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }; OverlayTiming expectedTiming = new() { @@ -212,9 +227,12 @@ public void Validation_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -312,9 +330,12 @@ public void CopyConstructor_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { diff --git a/src/ImageKit.Tests/Models/SrcOptionsTest.cs b/src/ImageKit.Tests/Models/SrcOptionsTest.cs index 33cb777e..d8677cfe 100644 --- a/src/ImageKit.Tests/Models/SrcOptionsTest.cs +++ b/src/ImageKit.Tests/Models/SrcOptionsTest.cs @@ -60,9 +60,12 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -164,9 +167,12 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -294,9 +300,12 @@ public void SerializationRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -412,9 +421,12 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -523,9 +535,12 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -653,9 +668,12 @@ public void Validation_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -845,9 +863,12 @@ public void CopyConstructor_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { diff --git a/src/ImageKit.Tests/Models/SubtitleOverlayTest.cs b/src/ImageKit.Tests/Models/SubtitleOverlayTest.cs index 882bbbc2..6aa3c431 100644 --- a/src/ImageKit.Tests/Models/SubtitleOverlayTest.cs +++ b/src/ImageKit.Tests/Models/SubtitleOverlayTest.cs @@ -16,9 +16,12 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -46,9 +49,12 @@ public void FieldRoundtrip_Works() ApiEnum expectedLayerMode = LayerMode.Multiply; OverlayPosition expectedPosition = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }; OverlayTiming expectedTiming = new() { @@ -96,9 +102,12 @@ public void SerializationRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -140,9 +149,12 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -177,9 +189,12 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum expectedLayerMode = LayerMode.Multiply; OverlayPosition expectedPosition = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }; OverlayTiming expectedTiming = new() { @@ -227,9 +242,12 @@ public void Validation_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -335,9 +353,12 @@ public void CopyConstructor_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { diff --git a/src/ImageKit.Tests/Models/TextOverlayTest.cs b/src/ImageKit.Tests/Models/TextOverlayTest.cs index b047d512..2e222480 100644 --- a/src/ImageKit.Tests/Models/TextOverlayTest.cs +++ b/src/ImageKit.Tests/Models/TextOverlayTest.cs @@ -16,9 +16,12 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -52,9 +55,12 @@ public void FieldRoundtrip_Works() ApiEnum expectedLayerMode = LayerMode.Multiply; OverlayPosition expectedPosition = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }; OverlayTiming expectedTiming = new() { @@ -108,9 +114,12 @@ public void SerializationRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -158,9 +167,12 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -201,9 +213,12 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum expectedLayerMode = LayerMode.Multiply; OverlayPosition expectedPosition = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }; OverlayTiming expectedTiming = new() { @@ -257,9 +272,12 @@ public void Validation_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -371,9 +389,12 @@ public void CopyConstructor_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { diff --git a/src/ImageKit.Tests/Models/TransformationTest.cs b/src/ImageKit.Tests/Models/TransformationTest.cs index cd08f493..7db3251e 100644 --- a/src/ImageKit.Tests/Models/TransformationTest.cs +++ b/src/ImageKit.Tests/Models/TransformationTest.cs @@ -52,9 +52,12 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -145,9 +148,12 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -195,9 +201,9 @@ public void FieldRoundtrip_Works() ApiEnum expectedVideoCodec = VideoCodec.H264; TransformationWidth expectedWidth = 300; TransformationX expectedX = 0; - XCenter expectedXCenter = 0; + TransformationXCenter expectedXCenter = 0; TransformationY expectedY = 0; - YCenter expectedYCenter = 0; + TransformationYCenter expectedYCenter = 0; double expectedZoom = 0; Assert.Equal(expectedAIChangeBackground, model.AIChangeBackground); @@ -305,9 +311,12 @@ public void SerializationRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -411,9 +420,12 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -511,9 +523,12 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -561,9 +576,9 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum expectedVideoCodec = VideoCodec.H264; TransformationWidth expectedWidth = 300; TransformationX expectedX = 0; - XCenter expectedXCenter = 0; + TransformationXCenter expectedXCenter = 0; TransformationY expectedY = 0; - YCenter expectedYCenter = 0; + TransformationYCenter expectedYCenter = 0; double expectedZoom = 0; Assert.Equal(expectedAIChangeBackground, deserialized.AIChangeBackground); @@ -671,9 +686,12 @@ public void Validation_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -1131,9 +1149,12 @@ public void CopyConstructor_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -3209,28 +3230,28 @@ public void StringSerializationRoundtripWorks() } } -public class XCenterTest : TestBase +public class TransformationXCenterTest : TestBase { [Fact] public void DoubleValidationWorks() { - XCenter value = 0; + TransformationXCenter value = 0; value.Validate(); } [Fact] public void StringValidationWorks() { - XCenter value = "string"; + TransformationXCenter value = "string"; value.Validate(); } [Fact] public void DoubleSerializationRoundtripWorks() { - XCenter value = 0; + TransformationXCenter value = 0; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -3241,9 +3262,9 @@ public void DoubleSerializationRoundtripWorks() [Fact] public void StringSerializationRoundtripWorks() { - XCenter value = "string"; + TransformationXCenter value = "string"; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -3295,28 +3316,28 @@ public void StringSerializationRoundtripWorks() } } -public class YCenterTest : TestBase +public class TransformationYCenterTest : TestBase { [Fact] public void DoubleValidationWorks() { - YCenter value = 0; + TransformationYCenter value = 0; value.Validate(); } [Fact] public void StringValidationWorks() { - YCenter value = "string"; + TransformationYCenter value = "string"; value.Validate(); } [Fact] public void DoubleSerializationRoundtripWorks() { - YCenter value = 0; + TransformationYCenter value = 0; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -3327,9 +3348,9 @@ public void DoubleSerializationRoundtripWorks() [Fact] public void StringSerializationRoundtripWorks() { - YCenter value = "string"; + TransformationYCenter value = "string"; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); diff --git a/src/ImageKit.Tests/Models/VideoOverlayTest.cs b/src/ImageKit.Tests/Models/VideoOverlayTest.cs index 60dc9c37..d1e345e4 100644 --- a/src/ImageKit.Tests/Models/VideoOverlayTest.cs +++ b/src/ImageKit.Tests/Models/VideoOverlayTest.cs @@ -16,9 +16,12 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -71,9 +74,12 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -129,9 +135,12 @@ public void FieldRoundtrip_Works() ApiEnum expectedLayerMode = LayerMode.Multiply; OverlayPosition expectedPosition = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }; OverlayTiming expectedTiming = new() { @@ -186,9 +195,12 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -262,9 +274,12 @@ public void SerializationRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -317,9 +332,12 @@ public void SerializationRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -389,9 +407,12 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -444,9 +465,12 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -509,9 +533,12 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum expectedLayerMode = LayerMode.Multiply; OverlayPosition expectedPosition = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }; OverlayTiming expectedTiming = new() { @@ -566,9 +593,12 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -642,9 +672,12 @@ public void Validation_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -697,9 +730,12 @@ public void Validation_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -833,9 +869,12 @@ public void CopyConstructor_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -888,9 +927,12 @@ public void CopyConstructor_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -1001,9 +1043,12 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -1103,9 +1148,12 @@ public void FieldRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -1218,9 +1266,12 @@ public void SerializationRoundtrip_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -1332,9 +1383,12 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -1441,9 +1495,12 @@ public void FieldRoundtripThroughSerialization_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -1556,9 +1613,12 @@ public void Validation_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { @@ -1716,9 +1776,12 @@ public void CopyConstructor_Works() LayerMode = LayerMode.Multiply, Position = new() { + AnchorPoint = AnchorPoint.Top, Focus = Focus.Center, X = 0, + XCenter = 0, Y = 0, + YCenter = 0, }, Timing = new() { diff --git a/src/ImageKit/Core/ModelBase.cs b/src/ImageKit/Core/ModelBase.cs index 7cc9e272..616e6674 100644 --- a/src/ImageKit/Core/ModelBase.cs +++ b/src/ImageKit/Core/ModelBase.cs @@ -32,6 +32,7 @@ protected ModelBase(ModelBase modelBase) new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), + new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), diff --git a/src/ImageKit/Models/ExtensionConfig.cs b/src/ImageKit/Models/ExtensionConfig.cs index c21e3bc3..88cd9fe8 100644 --- a/src/ImageKit/Models/ExtensionConfig.cs +++ b/src/ImageKit/Models/ExtensionConfig.cs @@ -1374,8 +1374,10 @@ public long? MinSelections } /// - /// Array of possible tag values. Combined length of all strings must not exceed - /// 500 characters. Cannot contain the `%` character. + /// Array of possible tag values. The combined length of all strings must not + /// exceed 500 characters, and values cannot include the `%` character. When + /// providing large vocabularies (more than 30 items), the AI may not follow + /// the list strictly. /// public IReadOnlyList? Vocabulary { @@ -1544,7 +1546,10 @@ public long? MinSelections } /// - /// Array of possible values matching the custom metadata field type. + /// An array of possible values matching the custom metadata field type. If not + /// provided for SingleSelect or MultiSelect field types, all values from the + /// custom metadata field definition will be used. When providing large vocabularies + /// (above 30 items), the AI may not strictly adhere to the list. /// public IReadOnlyList? Vocabulary { diff --git a/src/ImageKit/Models/OverlayPosition.cs b/src/ImageKit/Models/OverlayPosition.cs index e4d94de8..33f724d8 100644 --- a/src/ImageKit/Models/OverlayPosition.cs +++ b/src/ImageKit/Models/OverlayPosition.cs @@ -12,9 +12,33 @@ namespace ImageKit.Models; [JsonConverter(typeof(JsonModelConverter))] public sealed record class OverlayPosition : JsonModel { + /// + /// Sets the anchor point on the base asset from which the overlay offset is + /// calculated. The default value is `top_left`. Maps to `lap` in the URL. Can + /// only be used with one or more of `x`, `y`, `xCenter`, or `yCenter`. + /// + public ApiEnum? AnchorPoint + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("anchorPoint"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("anchorPoint", value); + } + } + /// /// Specifies the position of the overlay relative to the parent image or video. - /// Maps to `lfo` in the URL. + /// If one or more of `x`, `y`, `xCenter`, or `yCenter` parameters are specified, + /// this parameter is ignored. Maps to `lfo` in the URL. /// public ApiEnum? Focus { @@ -58,6 +82,30 @@ public X? X } } + /// + /// Specifies the x-coordinate on the base asset where the overlay's center will + /// be positioned. It also accepts arithmetic expressions such as `bw_mul_0.4` + /// or `bw_sub_cw`. Maps to `lxc` in the URL. Cannot be used together with `x`, + /// but can be used with `y`. Learn about [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + /// + public XCenter? XCenter + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("xCenter"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("xCenter", value); + } + } + /// /// Specifies the y-coordinate of the top-left corner of the base asset where /// the overlay's top-left corner will be positioned. It also accepts arithmetic @@ -82,12 +130,39 @@ public Y? Y } } + /// + /// Specifies the y-coordinate on the base asset where the overlay's center will + /// be positioned. It also accepts arithmetic expressions such as `bh_mul_0.4` + /// or `bh_sub_ch`. Maps to `lyc` in the URL. Cannot be used together with `y`, + /// but can be used with `x`. Learn about [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + /// + public YCenter? YCenter + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("yCenter"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("yCenter", value); + } + } + /// public override void Validate() { + this.AnchorPoint?.Validate(); this.Focus?.Validate(); this.X?.Validate(); + this.XCenter?.Validate(); this.Y?.Validate(); + this.YCenter?.Validate(); } public OverlayPosition() { } @@ -126,8 +201,79 @@ public OverlayPosition FromRawUnchecked(IReadOnlyDictionary } /// -/// Specifies the position of the overlay relative to the parent image or video. Maps -/// to `lfo` in the URL. +/// Sets the anchor point on the base asset from which the overlay offset is calculated. +/// The default value is `top_left`. Maps to `lap` in the URL. Can only be used with +/// one or more of `x`, `y`, `xCenter`, or `yCenter`. +/// +[JsonConverter(typeof(AnchorPointConverter))] +public enum AnchorPoint +{ + Top, + Left, + Right, + Bottom, + TopLeft, + TopRight, + BottomLeft, + BottomRight, + Center, +} + +sealed class AnchorPointConverter : JsonConverter +{ + public override AnchorPoint Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "top" => AnchorPoint.Top, + "left" => AnchorPoint.Left, + "right" => AnchorPoint.Right, + "bottom" => AnchorPoint.Bottom, + "top_left" => AnchorPoint.TopLeft, + "top_right" => AnchorPoint.TopRight, + "bottom_left" => AnchorPoint.BottomLeft, + "bottom_right" => AnchorPoint.BottomRight, + "center" => AnchorPoint.Center, + _ => (AnchorPoint)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + AnchorPoint value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + AnchorPoint.Top => "top", + AnchorPoint.Left => "left", + AnchorPoint.Right => "right", + AnchorPoint.Bottom => "bottom", + AnchorPoint.TopLeft => "top_left", + AnchorPoint.TopRight => "top_right", + AnchorPoint.BottomLeft => "bottom_left", + AnchorPoint.BottomRight => "bottom_right", + AnchorPoint.Center => "center", + _ => throw new ImageKitInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Specifies the position of the overlay relative to the parent image or video. If +/// one or more of `x`, `y`, `xCenter`, or `yCenter` parameters are specified, this +/// parameter is ignored. Maps to `lfo` in the URL. /// [JsonConverter(typeof(FocusConverter))] public enum Focus @@ -429,13 +575,13 @@ public override void Write(Utf8JsonWriter writer, X value, JsonSerializerOptions } /// -/// Specifies the y-coordinate of the top-left corner of the base asset where the -/// overlay's top-left corner will be positioned. It also accepts arithmetic expressions -/// such as `bh_mul_0.4` or `bh_sub_ch`. Maps to `ly` in the URL. Learn about [Arithmetic -/// expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). +/// Specifies the x-coordinate on the base asset where the overlay's center will +/// be positioned. It also accepts arithmetic expressions such as `bw_mul_0.4` or +/// `bw_sub_cw`. Maps to `lxc` in the URL. Cannot be used together with `x`, but can +/// be used with `y`. Learn about [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). /// -[JsonConverter(typeof(YConverter))] -public record class Y : ModelBase +[JsonConverter(typeof(XCenterConverter))] +public record class XCenter : ModelBase { public object? Value { get; } = null; @@ -452,19 +598,19 @@ public JsonElement Json } } - public Y(double value, JsonElement? element = null) + public XCenter(double value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Y(string value, JsonElement? element = null) + public XCenter(string value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Y(JsonElement element) + public XCenter(JsonElement element) { this._element = element; } @@ -542,7 +688,7 @@ public void Switch(Action @double, Action @string) @string(value); break; default: - throw new ImageKitInvalidDataException("Data did not match any variant of Y"); + throw new ImageKitInvalidDataException("Data did not match any variant of XCenter"); } } @@ -573,13 +719,15 @@ public T Match(Func @double, Func @string) { double value => @double(value), string value => @string(value), - _ => throw new ImageKitInvalidDataException("Data did not match any variant of Y"), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of XCenter" + ), }; } - public static implicit operator Y(double value) => new(value); + public static implicit operator XCenter(double value) => new(value); - public static implicit operator Y(string value) => new(value); + public static implicit operator XCenter(string value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -595,11 +743,11 @@ public override void Validate() { if (this.Value == null) { - throw new ImageKitInvalidDataException("Data did not match any variant of Y"); + throw new ImageKitInvalidDataException("Data did not match any variant of XCenter"); } } - public virtual bool Equals(Y? other) => + public virtual bool Equals(XCenter? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -626,9 +774,9 @@ int VariantIndex() } } -sealed class YConverter : JsonConverter +sealed class XCenterConverter : JsonConverter { - public override Y? Read( + public override XCenter? Read( ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options @@ -660,7 +808,485 @@ JsonSerializerOptions options return new(element); } - public override void Write(Utf8JsonWriter writer, Y value, JsonSerializerOptions options) + public override void Write(Utf8JsonWriter writer, XCenter value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +/// +/// Specifies the y-coordinate of the top-left corner of the base asset where the +/// overlay's top-left corner will be positioned. It also accepts arithmetic expressions +/// such as `bh_mul_0.4` or `bh_sub_ch`. Maps to `ly` in the URL. Learn about [Arithmetic +/// expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). +/// +[JsonConverter(typeof(YConverter))] +public record class Y : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public Y(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Y(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Y(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public void Switch(Action @double, Action @string) + { + switch (this.Value) + { + case double value: + @double(value); + break; + case string value: + @string(value); + break; + default: + throw new ImageKitInvalidDataException("Data did not match any variant of Y"); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public T Match(Func @double, Func @string) + { + return this.Value switch + { + double value => @double(value), + string value => @string(value), + _ => throw new ImageKitInvalidDataException("Data did not match any variant of Y"), + }; + } + + public static implicit operator Y(double value) => new(value); + + public static implicit operator Y(string value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException("Data did not match any variant of Y"); + } + } + + public virtual bool Equals(Y? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + double _ => 0, + string _ => 1, + _ => -1, + }; + } +} + +sealed class YConverter : JsonConverter +{ + public override Y? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write(Utf8JsonWriter writer, Y value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +/// +/// Specifies the y-coordinate on the base asset where the overlay's center will +/// be positioned. It also accepts arithmetic expressions such as `bh_mul_0.4` or +/// `bh_sub_ch`. Maps to `lyc` in the URL. Cannot be used together with `y`, but can +/// be used with `x`. Learn about [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). +/// +[JsonConverter(typeof(YCenterConverter))] +public record class YCenter : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public YCenter(double value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public YCenter(string value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public YCenter(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDouble(out var value)) { + /// // `value` is of type `double` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDouble([NotNullWhen(true)] out double? value) + { + value = this.Value as double?; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickString(out var value)) { + /// // `value` is of type `string` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickString([NotNullWhen(true)] out string? value) + { + value = this.Value as string; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public void Switch(Action @double, Action @string) + { + switch (this.Value) + { + case double value: + @double(value); + break; + case string value: + @string(value); + break; + default: + throw new ImageKitInvalidDataException("Data did not match any variant of YCenter"); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (double value) => {...}, + /// (string value) => {...} + /// ); + /// + /// + /// + public T Match(Func @double, Func @string) + { + return this.Value switch + { + double value => @double(value), + string value => @string(value), + _ => throw new ImageKitInvalidDataException( + "Data did not match any variant of YCenter" + ), + }; + } + + public static implicit operator YCenter(double value) => new(value); + + public static implicit operator YCenter(string value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new ImageKitInvalidDataException("Data did not match any variant of YCenter"); + } + } + + public virtual bool Equals(YCenter? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + double _ => 0, + string _ => 1, + _ => -1, + }; + } +} + +sealed class YCenterConverter : JsonConverter +{ + public override YCenter? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + try + { + return new(JsonSerializer.Deserialize(element, options), element); + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (Exception e) when (e is JsonException || e is ImageKitInvalidDataException) + { + // ignore + } + + return new(element); + } + + public override void Write(Utf8JsonWriter writer, YCenter value, JsonSerializerOptions options) { JsonSerializer.Serialize(writer, value.Json, options); } diff --git a/src/ImageKit/Models/Transformation.cs b/src/ImageKit/Models/Transformation.cs index 092f9d26..262cc84d 100644 --- a/src/ImageKit/Models/Transformation.cs +++ b/src/ImageKit/Models/Transformation.cs @@ -1193,12 +1193,12 @@ public TransformationX? X /// Focus using cropped image coordinates - X center coordinate. See [Focus using /// cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). /// - public XCenter? XCenter + public TransformationXCenter? XCenter { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("xCenter"); + return this._rawData.GetNullableClass("xCenter"); } init { @@ -1236,12 +1236,12 @@ public TransformationY? Y /// Focus using cropped image coordinates - Y center coordinate. See [Focus using /// cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). /// - public YCenter? YCenter + public TransformationYCenter? YCenter { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("yCenter"); + return this._rawData.GetNullableClass("yCenter"); } init { @@ -6532,8 +6532,8 @@ JsonSerializerOptions options /// Focus using cropped image coordinates - X center coordinate. See [Focus using /// cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). /// -[JsonConverter(typeof(XCenterConverter))] -public record class XCenter : ModelBase +[JsonConverter(typeof(TransformationXCenterConverter))] +public record class TransformationXCenter : ModelBase { public object? Value { get; } = null; @@ -6550,19 +6550,19 @@ public JsonElement Json } } - public XCenter(double value, JsonElement? element = null) + public TransformationXCenter(double value, JsonElement? element = null) { this.Value = value; this._element = element; } - public XCenter(string value, JsonElement? element = null) + public TransformationXCenter(string value, JsonElement? element = null) { this.Value = value; this._element = element; } - public XCenter(JsonElement element) + public TransformationXCenter(JsonElement element) { this._element = element; } @@ -6640,7 +6640,9 @@ public void Switch(Action @double, Action @string) @string(value); break; default: - throw new ImageKitInvalidDataException("Data did not match any variant of XCenter"); + throw new ImageKitInvalidDataException( + "Data did not match any variant of TransformationXCenter" + ); } } @@ -6672,14 +6674,14 @@ public T Match(Func @double, Func @string) double value => @double(value), string value => @string(value), _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of XCenter" + "Data did not match any variant of TransformationXCenter" ), }; } - public static implicit operator XCenter(double value) => new(value); + public static implicit operator TransformationXCenter(double value) => new(value); - public static implicit operator XCenter(string value) => new(value); + public static implicit operator TransformationXCenter(string value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -6695,11 +6697,13 @@ public override void Validate() { if (this.Value == null) { - throw new ImageKitInvalidDataException("Data did not match any variant of XCenter"); + throw new ImageKitInvalidDataException( + "Data did not match any variant of TransformationXCenter" + ); } } - public virtual bool Equals(XCenter? other) => + public virtual bool Equals(TransformationXCenter? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -6726,9 +6730,9 @@ int VariantIndex() } } -sealed class XCenterConverter : JsonConverter +sealed class TransformationXCenterConverter : JsonConverter { - public override XCenter? Read( + public override TransformationXCenter? Read( ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options @@ -6760,7 +6764,11 @@ JsonSerializerOptions options return new(element); } - public override void Write(Utf8JsonWriter writer, XCenter value, JsonSerializerOptions options) + public override void Write( + Utf8JsonWriter writer, + TransformationXCenter value, + JsonSerializerOptions options + ) { JsonSerializer.Serialize(writer, value.Json, options); } @@ -7015,8 +7023,8 @@ JsonSerializerOptions options /// Focus using cropped image coordinates - Y center coordinate. See [Focus using /// cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). /// -[JsonConverter(typeof(YCenterConverter))] -public record class YCenter : ModelBase +[JsonConverter(typeof(TransformationYCenterConverter))] +public record class TransformationYCenter : ModelBase { public object? Value { get; } = null; @@ -7033,19 +7041,19 @@ public JsonElement Json } } - public YCenter(double value, JsonElement? element = null) + public TransformationYCenter(double value, JsonElement? element = null) { this.Value = value; this._element = element; } - public YCenter(string value, JsonElement? element = null) + public TransformationYCenter(string value, JsonElement? element = null) { this.Value = value; this._element = element; } - public YCenter(JsonElement element) + public TransformationYCenter(JsonElement element) { this._element = element; } @@ -7123,7 +7131,9 @@ public void Switch(Action @double, Action @string) @string(value); break; default: - throw new ImageKitInvalidDataException("Data did not match any variant of YCenter"); + throw new ImageKitInvalidDataException( + "Data did not match any variant of TransformationYCenter" + ); } } @@ -7155,14 +7165,14 @@ public T Match(Func @double, Func @string) double value => @double(value), string value => @string(value), _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of YCenter" + "Data did not match any variant of TransformationYCenter" ), }; } - public static implicit operator YCenter(double value) => new(value); + public static implicit operator TransformationYCenter(double value) => new(value); - public static implicit operator YCenter(string value) => new(value); + public static implicit operator TransformationYCenter(string value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -7178,11 +7188,13 @@ public override void Validate() { if (this.Value == null) { - throw new ImageKitInvalidDataException("Data did not match any variant of YCenter"); + throw new ImageKitInvalidDataException( + "Data did not match any variant of TransformationYCenter" + ); } } - public virtual bool Equals(YCenter? other) => + public virtual bool Equals(TransformationYCenter? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -7209,9 +7221,9 @@ int VariantIndex() } } -sealed class YCenterConverter : JsonConverter +sealed class TransformationYCenterConverter : JsonConverter { - public override YCenter? Read( + public override TransformationYCenter? Read( ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options @@ -7243,7 +7255,11 @@ JsonSerializerOptions options return new(element); } - public override void Write(Utf8JsonWriter writer, YCenter value, JsonSerializerOptions options) + public override void Write( + Utf8JsonWriter writer, + TransformationYCenter value, + JsonSerializerOptions options + ) { JsonSerializer.Serialize(writer, value.Json, options); } diff --git a/src/ImageKit/Models/UnnamedSchemaWithArrayParent0.cs b/src/ImageKit/Models/UnnamedSchemaWithArrayParent0.cs index 8e0f321e..f66652c4 100644 --- a/src/ImageKit/Models/UnnamedSchemaWithArrayParent0.cs +++ b/src/ImageKit/Models/UnnamedSchemaWithArrayParent0.cs @@ -1578,8 +1578,10 @@ public long? MinSelections } /// - /// Array of possible tag values. Combined length of all strings must not exceed - /// 500 characters. Cannot contain the `%` character. + /// Array of possible tag values. The combined length of all strings must not + /// exceed 500 characters, and values cannot include the `%` character. When + /// providing large vocabularies (more than 30 items), the AI may not follow + /// the list strictly. /// public IReadOnlyList? Vocabulary { @@ -1763,7 +1765,10 @@ public long? MinSelections } /// - /// Array of possible values matching the custom metadata field type. + /// An array of possible values matching the custom metadata field type. If not + /// provided for SingleSelect or MultiSelect field types, all values from the + /// custom metadata field definition will be used. When providing large vocabularies + /// (above 30 items), the AI may not strictly adhere to the list. /// public IReadOnlyList? Vocabulary { From 9b4782b93b8c25c9f4d8860d77fef233df03a556 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 10 Apr 2026 06:55:04 +0000 Subject: [PATCH 095/129] feat(api): update webhook event names and remove DAM prefix --- .stats.yml | 4 +- ...Test.cs => FileCreatedWebhookEventTest.cs} | 36 +-- ...Test.cs => FileDeletedWebhookEventTest.cs} | 70 +++--- ...Test.cs => FileUpdatedWebhookEventTest.cs} | 36 +-- ... => FileVersionCreatedWebhookEventTest.cs} | 50 ++-- ... => FileVersionDeletedWebhookEventTest.cs} | 76 +++--- .../Webhooks/UnsafeUnwrapWebhookEventTest.cs | 88 +++---- .../Models/Webhooks/UnwrapWebhookEventTest.cs | 88 +++---- .../UploadPostTransformErrorEventTest.cs | 72 +++--- ...ateEvent.cs => FileCreatedWebhookEvent.cs} | 62 ++--- ...eteEvent.cs => FileDeletedWebhookEvent.cs} | 113 +++++---- ...ateEvent.cs => FileUpdatedWebhookEvent.cs} | 62 ++--- ...t.cs => FileVersionCreatedWebhookEvent.cs} | 68 +++--- ...t.cs => FileVersionDeletedWebhookEvent.cs} | 108 +++++---- .../Webhooks/UnsafeUnwrapWebhookEvent.cs | 216 +++++++++--------- .../Models/Webhooks/UnwrapWebhookEvent.cs | 204 ++++++++--------- .../Webhooks/UploadPostTransformErrorEvent.cs | 86 +++---- 17 files changed, 746 insertions(+), 693 deletions(-) rename src/ImageKit.Tests/Models/Webhooks/{DamFileCreateEventTest.cs => FileCreatedWebhookEventTest.cs} (94%) rename src/ImageKit.Tests/Models/Webhooks/{DamFileDeleteEventTest.cs => FileDeletedWebhookEventTest.cs} (66%) rename src/ImageKit.Tests/Models/Webhooks/{DamFileUpdateEventTest.cs => FileUpdatedWebhookEventTest.cs} (94%) rename src/ImageKit.Tests/Models/Webhooks/{DamFileVersionCreateEventTest.cs => FileVersionCreatedWebhookEventTest.cs} (93%) rename src/ImageKit.Tests/Models/Webhooks/{DamFileVersionDeleteEventTest.cs => FileVersionDeletedWebhookEventTest.cs} (71%) rename src/ImageKit/Models/Webhooks/{DamFileCreateEvent.cs => FileCreatedWebhookEvent.cs} (64%) rename src/ImageKit/Models/Webhooks/{DamFileDeleteEvent.cs => FileDeletedWebhookEvent.cs} (52%) rename src/ImageKit/Models/Webhooks/{DamFileUpdateEvent.cs => FileUpdatedWebhookEvent.cs} (64%) rename src/ImageKit/Models/Webhooks/{DamFileVersionCreateEvent.cs => FileVersionCreatedWebhookEvent.cs} (64%) rename src/ImageKit/Models/Webhooks/{DamFileVersionDeleteEvent.cs => FileVersionDeletedWebhookEvent.cs} (57%) diff --git a/.stats.yml b/.stats.yml index 0898c6b1..4bc5fef0 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-18b46cb8c1dd5cd0eea8559fa9671600540c5c4bee32f2d74f932416b7a1aee0.yml -openapi_spec_hash: 539770659847d04a92ef965a5313adde +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-d73a37dc3426586109bd153f02c6a605036b6a7396bba5173d013468c5291ce6.yml +openapi_spec_hash: c193c6e557ff477481ec8d5ac8a0c96e config_hash: 17e408231b0b01676298010c7405f483 diff --git a/src/ImageKit.Tests/Models/Webhooks/DamFileCreateEventTest.cs b/src/ImageKit.Tests/Models/Webhooks/FileCreatedWebhookEventTest.cs similarity index 94% rename from src/ImageKit.Tests/Models/Webhooks/DamFileCreateEventTest.cs rename to src/ImageKit.Tests/Models/Webhooks/FileCreatedWebhookEventTest.cs index e5fa8a5f..042db2a9 100644 --- a/src/ImageKit.Tests/Models/Webhooks/DamFileCreateEventTest.cs +++ b/src/ImageKit.Tests/Models/Webhooks/FileCreatedWebhookEventTest.cs @@ -7,12 +7,12 @@ namespace ImageKit.Tests.Models.Webhooks; -public class DamFileCreateEventTest : TestBase +public class FileCreatedWebhookEventTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new DamFileCreateEvent + var model = new FileCreatedWebhookEvent { ID = "id", Type = "type", @@ -158,7 +158,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new DamFileCreateEvent + var model = new FileCreatedWebhookEvent { ID = "id", Type = "type", @@ -229,7 +229,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -240,7 +240,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new DamFileCreateEvent + var model = new FileCreatedWebhookEvent { ID = "id", Type = "type", @@ -311,7 +311,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -393,7 +393,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new DamFileCreateEvent + var model = new FileCreatedWebhookEvent { ID = "id", Type = "type", @@ -469,7 +469,7 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new DamFileCreateEvent + var model = new FileCreatedWebhookEvent { ID = "id", Type = "type", @@ -539,18 +539,18 @@ public void CopyConstructor_Works() }, }; - DamFileCreateEvent copied = new(model); + FileCreatedWebhookEvent copied = new(model); Assert.Equal(model, copied); } } -public class IntersectionMember1Test : TestBase +public class FileCreatedWebhookEventIntersectionMember1Test : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new IntersectionMember1 + var model = new FileCreatedWebhookEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -692,7 +692,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new IntersectionMember1 + var model = new FileCreatedWebhookEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -761,7 +761,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -772,7 +772,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new IntersectionMember1 + var model = new FileCreatedWebhookEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -841,7 +841,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -921,7 +921,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new IntersectionMember1 + var model = new FileCreatedWebhookEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -995,7 +995,7 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new IntersectionMember1 + var model = new FileCreatedWebhookEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -1063,7 +1063,7 @@ public void CopyConstructor_Works() }, }; - IntersectionMember1 copied = new(model); + FileCreatedWebhookEventIntersectionMember1 copied = new(model); Assert.Equal(model, copied); } diff --git a/src/ImageKit.Tests/Models/Webhooks/DamFileDeleteEventTest.cs b/src/ImageKit.Tests/Models/Webhooks/FileDeletedWebhookEventTest.cs similarity index 66% rename from src/ImageKit.Tests/Models/Webhooks/DamFileDeleteEventTest.cs rename to src/ImageKit.Tests/Models/Webhooks/FileDeletedWebhookEventTest.cs index fe454941..87deb329 100644 --- a/src/ImageKit.Tests/Models/Webhooks/DamFileDeleteEventTest.cs +++ b/src/ImageKit.Tests/Models/Webhooks/FileDeletedWebhookEventTest.cs @@ -5,12 +5,12 @@ namespace ImageKit.Tests.Models.Webhooks; -public class DamFileDeleteEventTest : TestBase +public class FileDeletedWebhookEventTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new DamFileDeleteEvent + var model = new FileDeletedWebhookEvent { ID = "id", Type = "type", @@ -21,7 +21,7 @@ public void FieldRoundtrip_Works() string expectedID = "id"; string expectedType = "type"; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - Data expectedData = new("fileId"); + FileDeletedWebhookEventIntersectionMember1Data expectedData = new("fileId"); Assert.Equal(expectedID, model.ID); Assert.Equal(expectedType, model.Type); @@ -32,7 +32,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new DamFileDeleteEvent + var model = new FileDeletedWebhookEvent { ID = "id", Type = "type", @@ -41,7 +41,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -52,7 +52,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new DamFileDeleteEvent + var model = new FileDeletedWebhookEvent { ID = "id", Type = "type", @@ -61,7 +61,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -70,7 +70,7 @@ public void FieldRoundtripThroughSerialization_Works() string expectedID = "id"; string expectedType = "type"; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - Data expectedData = new("fileId"); + FileDeletedWebhookEventIntersectionMember1Data expectedData = new("fileId"); Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedType, deserialized.Type); @@ -81,7 +81,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new DamFileDeleteEvent + var model = new FileDeletedWebhookEvent { ID = "id", Type = "type", @@ -95,7 +95,7 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new DamFileDeleteEvent + var model = new FileDeletedWebhookEvent { ID = "id", Type = "type", @@ -103,25 +103,25 @@ public void CopyConstructor_Works() Data = new("fileId"), }; - DamFileDeleteEvent copied = new(model); + FileDeletedWebhookEvent copied = new(model); Assert.Equal(model, copied); } } -public class DamFileDeleteEventIntersectionMember1Test : TestBase +public class FileDeletedWebhookEventIntersectionMember1Test : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new DamFileDeleteEventIntersectionMember1 + var model = new FileDeletedWebhookEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new("fileId"), }; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - Data expectedData = new("fileId"); + FileDeletedWebhookEventIntersectionMember1Data expectedData = new("fileId"); JsonElement expectedType = JsonSerializer.SerializeToElement("file.deleted"); Assert.Equal(expectedCreatedAt, model.CreatedAt); @@ -132,14 +132,14 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new DamFileDeleteEventIntersectionMember1 + var model = new FileDeletedWebhookEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new("fileId"), }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -150,21 +150,21 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new DamFileDeleteEventIntersectionMember1 + var model = new FileDeletedWebhookEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new("fileId"), }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - Data expectedData = new("fileId"); + FileDeletedWebhookEventIntersectionMember1Data expectedData = new("fileId"); JsonElement expectedType = JsonSerializer.SerializeToElement("file.deleted"); Assert.Equal(expectedCreatedAt, deserialized.CreatedAt); @@ -175,7 +175,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new DamFileDeleteEventIntersectionMember1 + var model = new FileDeletedWebhookEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new("fileId"), @@ -187,24 +187,24 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new DamFileDeleteEventIntersectionMember1 + var model = new FileDeletedWebhookEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new("fileId"), }; - DamFileDeleteEventIntersectionMember1 copied = new(model); + FileDeletedWebhookEventIntersectionMember1 copied = new(model); Assert.Equal(model, copied); } } -public class DataTest : TestBase +public class FileDeletedWebhookEventIntersectionMember1DataTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Data { FileID = "fileId" }; + var model = new FileDeletedWebhookEventIntersectionMember1Data { FileID = "fileId" }; string expectedFileID = "fileId"; @@ -214,10 +214,14 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Data { FileID = "fileId" }; + var model = new FileDeletedWebhookEventIntersectionMember1Data { FileID = "fileId" }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -225,10 +229,14 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Data { FileID = "fileId" }; + var model = new FileDeletedWebhookEventIntersectionMember1Data { FileID = "fileId" }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.NotNull(deserialized); string expectedFileID = "fileId"; @@ -239,7 +247,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Data { FileID = "fileId" }; + var model = new FileDeletedWebhookEventIntersectionMember1Data { FileID = "fileId" }; model.Validate(); } @@ -247,9 +255,9 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new Data { FileID = "fileId" }; + var model = new FileDeletedWebhookEventIntersectionMember1Data { FileID = "fileId" }; - Data copied = new(model); + FileDeletedWebhookEventIntersectionMember1Data copied = new(model); Assert.Equal(model, copied); } diff --git a/src/ImageKit.Tests/Models/Webhooks/DamFileUpdateEventTest.cs b/src/ImageKit.Tests/Models/Webhooks/FileUpdatedWebhookEventTest.cs similarity index 94% rename from src/ImageKit.Tests/Models/Webhooks/DamFileUpdateEventTest.cs rename to src/ImageKit.Tests/Models/Webhooks/FileUpdatedWebhookEventTest.cs index 68fae29a..51d1c3b1 100644 --- a/src/ImageKit.Tests/Models/Webhooks/DamFileUpdateEventTest.cs +++ b/src/ImageKit.Tests/Models/Webhooks/FileUpdatedWebhookEventTest.cs @@ -7,12 +7,12 @@ namespace ImageKit.Tests.Models.Webhooks; -public class DamFileUpdateEventTest : TestBase +public class FileUpdatedWebhookEventTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new DamFileUpdateEvent + var model = new FileUpdatedWebhookEvent { ID = "id", Type = "type", @@ -158,7 +158,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new DamFileUpdateEvent + var model = new FileUpdatedWebhookEvent { ID = "id", Type = "type", @@ -229,7 +229,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -240,7 +240,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new DamFileUpdateEvent + var model = new FileUpdatedWebhookEvent { ID = "id", Type = "type", @@ -311,7 +311,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -393,7 +393,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new DamFileUpdateEvent + var model = new FileUpdatedWebhookEvent { ID = "id", Type = "type", @@ -469,7 +469,7 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new DamFileUpdateEvent + var model = new FileUpdatedWebhookEvent { ID = "id", Type = "type", @@ -539,18 +539,18 @@ public void CopyConstructor_Works() }, }; - DamFileUpdateEvent copied = new(model); + FileUpdatedWebhookEvent copied = new(model); Assert.Equal(model, copied); } } -public class DamFileUpdateEventIntersectionMember1Test : TestBase +public class FileUpdatedWebhookEventIntersectionMember1Test : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new DamFileUpdateEventIntersectionMember1 + var model = new FileUpdatedWebhookEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -692,7 +692,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new DamFileUpdateEventIntersectionMember1 + var model = new FileUpdatedWebhookEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -761,7 +761,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -772,7 +772,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new DamFileUpdateEventIntersectionMember1 + var model = new FileUpdatedWebhookEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -841,7 +841,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -921,7 +921,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new DamFileUpdateEventIntersectionMember1 + var model = new FileUpdatedWebhookEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -995,7 +995,7 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new DamFileUpdateEventIntersectionMember1 + var model = new FileUpdatedWebhookEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -1063,7 +1063,7 @@ public void CopyConstructor_Works() }, }; - DamFileUpdateEventIntersectionMember1 copied = new(model); + FileUpdatedWebhookEventIntersectionMember1 copied = new(model); Assert.Equal(model, copied); } diff --git a/src/ImageKit.Tests/Models/Webhooks/DamFileVersionCreateEventTest.cs b/src/ImageKit.Tests/Models/Webhooks/FileVersionCreatedWebhookEventTest.cs similarity index 93% rename from src/ImageKit.Tests/Models/Webhooks/DamFileVersionCreateEventTest.cs rename to src/ImageKit.Tests/Models/Webhooks/FileVersionCreatedWebhookEventTest.cs index 83175b89..eb671ec0 100644 --- a/src/ImageKit.Tests/Models/Webhooks/DamFileVersionCreateEventTest.cs +++ b/src/ImageKit.Tests/Models/Webhooks/FileVersionCreatedWebhookEventTest.cs @@ -7,12 +7,12 @@ namespace ImageKit.Tests.Models.Webhooks; -public class DamFileVersionCreateEventTest : TestBase +public class FileVersionCreatedWebhookEventTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new DamFileVersionCreateEvent + var model = new FileVersionCreatedWebhookEvent { ID = "id", Type = "type", @@ -158,7 +158,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new DamFileVersionCreateEvent + var model = new FileVersionCreatedWebhookEvent { ID = "id", Type = "type", @@ -229,7 +229,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -240,7 +240,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new DamFileVersionCreateEvent + var model = new FileVersionCreatedWebhookEvent { ID = "id", Type = "type", @@ -311,7 +311,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -393,7 +393,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new DamFileVersionCreateEvent + var model = new FileVersionCreatedWebhookEvent { ID = "id", Type = "type", @@ -469,7 +469,7 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new DamFileVersionCreateEvent + var model = new FileVersionCreatedWebhookEvent { ID = "id", Type = "type", @@ -539,18 +539,18 @@ public void CopyConstructor_Works() }, }; - DamFileVersionCreateEvent copied = new(model); + FileVersionCreatedWebhookEvent copied = new(model); Assert.Equal(model, copied); } } -public class DamFileVersionCreateEventIntersectionMember1Test : TestBase +public class FileVersionCreatedWebhookEventIntersectionMember1Test : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new DamFileVersionCreateEventIntersectionMember1 + var model = new FileVersionCreatedWebhookEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -692,7 +692,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new DamFileVersionCreateEventIntersectionMember1 + var model = new FileVersionCreatedWebhookEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -761,10 +761,11 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -772,7 +773,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new DamFileVersionCreateEventIntersectionMember1 + var model = new FileVersionCreatedWebhookEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -841,10 +842,11 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.NotNull(deserialized); DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); @@ -921,7 +923,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new DamFileVersionCreateEventIntersectionMember1 + var model = new FileVersionCreatedWebhookEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -995,7 +997,7 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new DamFileVersionCreateEventIntersectionMember1 + var model = new FileVersionCreatedWebhookEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -1063,7 +1065,7 @@ public void CopyConstructor_Works() }, }; - DamFileVersionCreateEventIntersectionMember1 copied = new(model); + FileVersionCreatedWebhookEventIntersectionMember1 copied = new(model); Assert.Equal(model, copied); } diff --git a/src/ImageKit.Tests/Models/Webhooks/DamFileVersionDeleteEventTest.cs b/src/ImageKit.Tests/Models/Webhooks/FileVersionDeletedWebhookEventTest.cs similarity index 71% rename from src/ImageKit.Tests/Models/Webhooks/DamFileVersionDeleteEventTest.cs rename to src/ImageKit.Tests/Models/Webhooks/FileVersionDeletedWebhookEventTest.cs index 2f9d64e6..ca0e0cb9 100644 --- a/src/ImageKit.Tests/Models/Webhooks/DamFileVersionDeleteEventTest.cs +++ b/src/ImageKit.Tests/Models/Webhooks/FileVersionDeletedWebhookEventTest.cs @@ -5,12 +5,12 @@ namespace ImageKit.Tests.Models.Webhooks; -public class DamFileVersionDeleteEventTest : TestBase +public class FileVersionDeletedWebhookEventTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new DamFileVersionDeleteEvent + var model = new FileVersionDeletedWebhookEvent { ID = "id", Type = "type", @@ -21,7 +21,7 @@ public void FieldRoundtrip_Works() string expectedID = "id"; string expectedType = "type"; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - DamFileVersionDeleteEventIntersectionMember1Data expectedData = new() + FileVersionDeletedWebhookEventIntersectionMember1Data expectedData = new() { FileID = "fileId", VersionID = "versionId", @@ -36,7 +36,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new DamFileVersionDeleteEvent + var model = new FileVersionDeletedWebhookEvent { ID = "id", Type = "type", @@ -45,7 +45,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -56,7 +56,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new DamFileVersionDeleteEvent + var model = new FileVersionDeletedWebhookEvent { ID = "id", Type = "type", @@ -65,7 +65,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -74,7 +74,7 @@ public void FieldRoundtripThroughSerialization_Works() string expectedID = "id"; string expectedType = "type"; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - DamFileVersionDeleteEventIntersectionMember1Data expectedData = new() + FileVersionDeletedWebhookEventIntersectionMember1Data expectedData = new() { FileID = "fileId", VersionID = "versionId", @@ -89,7 +89,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new DamFileVersionDeleteEvent + var model = new FileVersionDeletedWebhookEvent { ID = "id", Type = "type", @@ -103,7 +103,7 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new DamFileVersionDeleteEvent + var model = new FileVersionDeletedWebhookEvent { ID = "id", Type = "type", @@ -111,25 +111,25 @@ public void CopyConstructor_Works() Data = new() { FileID = "fileId", VersionID = "versionId" }, }; - DamFileVersionDeleteEvent copied = new(model); + FileVersionDeletedWebhookEvent copied = new(model); Assert.Equal(model, copied); } } -public class DamFileVersionDeleteEventIntersectionMember1Test : TestBase +public class FileVersionDeletedWebhookEventIntersectionMember1Test : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new DamFileVersionDeleteEventIntersectionMember1 + var model = new FileVersionDeletedWebhookEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() { FileID = "fileId", VersionID = "versionId" }, }; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - DamFileVersionDeleteEventIntersectionMember1Data expectedData = new() + FileVersionDeletedWebhookEventIntersectionMember1Data expectedData = new() { FileID = "fileId", VersionID = "versionId", @@ -144,17 +144,18 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new DamFileVersionDeleteEventIntersectionMember1 + var model = new FileVersionDeletedWebhookEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() { FileID = "fileId", VersionID = "versionId" }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -162,21 +163,22 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new DamFileVersionDeleteEventIntersectionMember1 + var model = new FileVersionDeletedWebhookEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() { FileID = "fileId", VersionID = "versionId" }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.NotNull(deserialized); DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - DamFileVersionDeleteEventIntersectionMember1Data expectedData = new() + FileVersionDeletedWebhookEventIntersectionMember1Data expectedData = new() { FileID = "fileId", VersionID = "versionId", @@ -191,7 +193,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new DamFileVersionDeleteEventIntersectionMember1 + var model = new FileVersionDeletedWebhookEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() { FileID = "fileId", VersionID = "versionId" }, @@ -203,24 +205,24 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new DamFileVersionDeleteEventIntersectionMember1 + var model = new FileVersionDeletedWebhookEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() { FileID = "fileId", VersionID = "versionId" }, }; - DamFileVersionDeleteEventIntersectionMember1 copied = new(model); + FileVersionDeletedWebhookEventIntersectionMember1 copied = new(model); Assert.Equal(model, copied); } } -public class DamFileVersionDeleteEventIntersectionMember1DataTest : TestBase +public class FileVersionDeletedWebhookEventIntersectionMember1DataTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new DamFileVersionDeleteEventIntersectionMember1Data + var model = new FileVersionDeletedWebhookEventIntersectionMember1Data { FileID = "fileId", VersionID = "versionId", @@ -236,7 +238,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new DamFileVersionDeleteEventIntersectionMember1Data + var model = new FileVersionDeletedWebhookEventIntersectionMember1Data { FileID = "fileId", VersionID = "versionId", @@ -244,7 +246,7 @@ public void SerializationRoundtrip_Works() string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -255,7 +257,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new DamFileVersionDeleteEventIntersectionMember1Data + var model = new FileVersionDeletedWebhookEventIntersectionMember1Data { FileID = "fileId", VersionID = "versionId", @@ -263,7 +265,7 @@ public void FieldRoundtripThroughSerialization_Works() string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -279,7 +281,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new DamFileVersionDeleteEventIntersectionMember1Data + var model = new FileVersionDeletedWebhookEventIntersectionMember1Data { FileID = "fileId", VersionID = "versionId", @@ -291,13 +293,13 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new DamFileVersionDeleteEventIntersectionMember1Data + var model = new FileVersionDeletedWebhookEventIntersectionMember1Data { FileID = "fileId", VersionID = "versionId", }; - DamFileVersionDeleteEventIntersectionMember1Data copied = new(model); + FileVersionDeletedWebhookEventIntersectionMember1Data copied = new(model); Assert.Equal(model, copied); } diff --git a/src/ImageKit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs b/src/ImageKit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs index 32e48a5f..c1cd1663 100644 --- a/src/ImageKit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs +++ b/src/ImageKit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs @@ -385,14 +385,14 @@ public void UploadPostTransformErrorValidationWorks() } [Fact] - public void DamFileCreateValidationWorks() + public void FileCreatedValidationWorks() { - Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::DamFileCreateEvent() + Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::FileCreatedWebhookEvent() { ID = "id", Type = "file.created", - CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - Data = new() + STAINLESS_FIXME_CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + STAINLESS_FIXME_Data = new() { AITags = [ @@ -460,14 +460,14 @@ public void DamFileCreateValidationWorks() } [Fact] - public void DamFileUpdateValidationWorks() + public void FileUpdatedValidationWorks() { - Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::DamFileUpdateEvent() + Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::FileUpdatedWebhookEvent() { ID = "id", Type = "file.updated", - CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - Data = new() + STAINLESS_FIXME_CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + STAINLESS_FIXME_Data = new() { AITags = [ @@ -535,27 +535,27 @@ public void DamFileUpdateValidationWorks() } [Fact] - public void DamFileDeleteValidationWorks() + public void FileDeletedValidationWorks() { - Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::DamFileDeleteEvent() + Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::FileDeletedWebhookEvent() { ID = "id", Type = "file.deleted", - CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - Data = new("fileId"), + STAINLESS_FIXME_CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + STAINLESS_FIXME_Data = new("fileId"), }; value.Validate(); } [Fact] - public void DamFileVersionCreateValidationWorks() + public void FileVersionCreatedValidationWorks() { - Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::DamFileVersionCreateEvent() + Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::FileVersionCreatedWebhookEvent() { ID = "id", Type = "file-version.created", - CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - Data = new() + STAINLESS_FIXME_CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + STAINLESS_FIXME_Data = new() { AITags = [ @@ -623,14 +623,18 @@ public void DamFileVersionCreateValidationWorks() } [Fact] - public void DamFileVersionDeleteValidationWorks() + public void FileVersionDeletedValidationWorks() { - Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::DamFileVersionDeleteEvent() + Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::FileVersionDeletedWebhookEvent() { ID = "id", Type = "file-version.deleted", - CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - Data = new() { FileID = "fileId", VersionID = "versionId" }, + STAINLESS_FIXME_CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + STAINLESS_FIXME_Data = new() + { + STAINLESS_FIXME_FileID = "fileId", + STAINLESS_FIXME_VersionID = "versionId", + }, }; value.Validate(); } @@ -1053,14 +1057,14 @@ public void UploadPostTransformErrorSerializationRoundtripWorks() } [Fact] - public void DamFileCreateSerializationRoundtripWorks() + public void FileCreatedSerializationRoundtripWorks() { - Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::DamFileCreateEvent() + Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::FileCreatedWebhookEvent() { ID = "id", Type = "file.created", - CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - Data = new() + STAINLESS_FIXME_CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + STAINLESS_FIXME_Data = new() { AITags = [ @@ -1134,14 +1138,14 @@ public void DamFileCreateSerializationRoundtripWorks() } [Fact] - public void DamFileUpdateSerializationRoundtripWorks() + public void FileUpdatedSerializationRoundtripWorks() { - Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::DamFileUpdateEvent() + Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::FileUpdatedWebhookEvent() { ID = "id", Type = "file.updated", - CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - Data = new() + STAINLESS_FIXME_CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + STAINLESS_FIXME_Data = new() { AITags = [ @@ -1215,14 +1219,14 @@ public void DamFileUpdateSerializationRoundtripWorks() } [Fact] - public void DamFileDeleteSerializationRoundtripWorks() + public void FileDeletedSerializationRoundtripWorks() { - Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::DamFileDeleteEvent() + Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::FileDeletedWebhookEvent() { ID = "id", Type = "file.deleted", - CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - Data = new("fileId"), + STAINLESS_FIXME_CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + STAINLESS_FIXME_Data = new("fileId"), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize( @@ -1234,14 +1238,14 @@ public void DamFileDeleteSerializationRoundtripWorks() } [Fact] - public void DamFileVersionCreateSerializationRoundtripWorks() + public void FileVersionCreatedSerializationRoundtripWorks() { - Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::DamFileVersionCreateEvent() + Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::FileVersionCreatedWebhookEvent() { ID = "id", Type = "file-version.created", - CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - Data = new() + STAINLESS_FIXME_CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + STAINLESS_FIXME_Data = new() { AITags = [ @@ -1315,14 +1319,18 @@ public void DamFileVersionCreateSerializationRoundtripWorks() } [Fact] - public void DamFileVersionDeleteSerializationRoundtripWorks() + public void FileVersionDeletedSerializationRoundtripWorks() { - Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::DamFileVersionDeleteEvent() + Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::FileVersionDeletedWebhookEvent() { ID = "id", Type = "file-version.deleted", - CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - Data = new() { FileID = "fileId", VersionID = "versionId" }, + STAINLESS_FIXME_CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + STAINLESS_FIXME_Data = new() + { + STAINLESS_FIXME_FileID = "fileId", + STAINLESS_FIXME_VersionID = "versionId", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize( diff --git a/src/ImageKit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs b/src/ImageKit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs index 3faec7d0..4f13861b 100644 --- a/src/ImageKit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs +++ b/src/ImageKit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs @@ -385,14 +385,14 @@ public void UploadPostTransformErrorValidationWorks() } [Fact] - public void DamFileCreateValidationWorks() + public void FileCreatedValidationWorks() { - Webhooks::UnwrapWebhookEvent value = new Webhooks::DamFileCreateEvent() + Webhooks::UnwrapWebhookEvent value = new Webhooks::FileCreatedWebhookEvent() { ID = "id", Type = "file.created", - CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - Data = new() + STAINLESS_FIXME_CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + STAINLESS_FIXME_Data = new() { AITags = [ @@ -460,14 +460,14 @@ public void DamFileCreateValidationWorks() } [Fact] - public void DamFileUpdateValidationWorks() + public void FileUpdatedValidationWorks() { - Webhooks::UnwrapWebhookEvent value = new Webhooks::DamFileUpdateEvent() + Webhooks::UnwrapWebhookEvent value = new Webhooks::FileUpdatedWebhookEvent() { ID = "id", Type = "file.updated", - CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - Data = new() + STAINLESS_FIXME_CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + STAINLESS_FIXME_Data = new() { AITags = [ @@ -535,27 +535,27 @@ public void DamFileUpdateValidationWorks() } [Fact] - public void DamFileDeleteValidationWorks() + public void FileDeletedValidationWorks() { - Webhooks::UnwrapWebhookEvent value = new Webhooks::DamFileDeleteEvent() + Webhooks::UnwrapWebhookEvent value = new Webhooks::FileDeletedWebhookEvent() { ID = "id", Type = "file.deleted", - CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - Data = new("fileId"), + STAINLESS_FIXME_CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + STAINLESS_FIXME_Data = new("fileId"), }; value.Validate(); } [Fact] - public void DamFileVersionCreateValidationWorks() + public void FileVersionCreatedValidationWorks() { - Webhooks::UnwrapWebhookEvent value = new Webhooks::DamFileVersionCreateEvent() + Webhooks::UnwrapWebhookEvent value = new Webhooks::FileVersionCreatedWebhookEvent() { ID = "id", Type = "file-version.created", - CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - Data = new() + STAINLESS_FIXME_CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + STAINLESS_FIXME_Data = new() { AITags = [ @@ -623,14 +623,18 @@ public void DamFileVersionCreateValidationWorks() } [Fact] - public void DamFileVersionDeleteValidationWorks() + public void FileVersionDeletedValidationWorks() { - Webhooks::UnwrapWebhookEvent value = new Webhooks::DamFileVersionDeleteEvent() + Webhooks::UnwrapWebhookEvent value = new Webhooks::FileVersionDeletedWebhookEvent() { ID = "id", Type = "file-version.deleted", - CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - Data = new() { FileID = "fileId", VersionID = "versionId" }, + STAINLESS_FIXME_CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + STAINLESS_FIXME_Data = new() + { + STAINLESS_FIXME_FileID = "fileId", + STAINLESS_FIXME_VersionID = "versionId", + }, }; value.Validate(); } @@ -1053,14 +1057,14 @@ public void UploadPostTransformErrorSerializationRoundtripWorks() } [Fact] - public void DamFileCreateSerializationRoundtripWorks() + public void FileCreatedSerializationRoundtripWorks() { - Webhooks::UnwrapWebhookEvent value = new Webhooks::DamFileCreateEvent() + Webhooks::UnwrapWebhookEvent value = new Webhooks::FileCreatedWebhookEvent() { ID = "id", Type = "file.created", - CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - Data = new() + STAINLESS_FIXME_CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + STAINLESS_FIXME_Data = new() { AITags = [ @@ -1134,14 +1138,14 @@ public void DamFileCreateSerializationRoundtripWorks() } [Fact] - public void DamFileUpdateSerializationRoundtripWorks() + public void FileUpdatedSerializationRoundtripWorks() { - Webhooks::UnwrapWebhookEvent value = new Webhooks::DamFileUpdateEvent() + Webhooks::UnwrapWebhookEvent value = new Webhooks::FileUpdatedWebhookEvent() { ID = "id", Type = "file.updated", - CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - Data = new() + STAINLESS_FIXME_CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + STAINLESS_FIXME_Data = new() { AITags = [ @@ -1215,14 +1219,14 @@ public void DamFileUpdateSerializationRoundtripWorks() } [Fact] - public void DamFileDeleteSerializationRoundtripWorks() + public void FileDeletedSerializationRoundtripWorks() { - Webhooks::UnwrapWebhookEvent value = new Webhooks::DamFileDeleteEvent() + Webhooks::UnwrapWebhookEvent value = new Webhooks::FileDeletedWebhookEvent() { ID = "id", Type = "file.deleted", - CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - Data = new("fileId"), + STAINLESS_FIXME_CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + STAINLESS_FIXME_Data = new("fileId"), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize( @@ -1234,14 +1238,14 @@ public void DamFileDeleteSerializationRoundtripWorks() } [Fact] - public void DamFileVersionCreateSerializationRoundtripWorks() + public void FileVersionCreatedSerializationRoundtripWorks() { - Webhooks::UnwrapWebhookEvent value = new Webhooks::DamFileVersionCreateEvent() + Webhooks::UnwrapWebhookEvent value = new Webhooks::FileVersionCreatedWebhookEvent() { ID = "id", Type = "file-version.created", - CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - Data = new() + STAINLESS_FIXME_CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + STAINLESS_FIXME_Data = new() { AITags = [ @@ -1315,14 +1319,18 @@ public void DamFileVersionCreateSerializationRoundtripWorks() } [Fact] - public void DamFileVersionDeleteSerializationRoundtripWorks() + public void FileVersionDeletedSerializationRoundtripWorks() { - Webhooks::UnwrapWebhookEvent value = new Webhooks::DamFileVersionDeleteEvent() + Webhooks::UnwrapWebhookEvent value = new Webhooks::FileVersionDeletedWebhookEvent() { ID = "id", Type = "file-version.deleted", - CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - Data = new() { FileID = "fileId", VersionID = "versionId" }, + STAINLESS_FIXME_CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + STAINLESS_FIXME_Data = new() + { + STAINLESS_FIXME_FileID = "fileId", + STAINLESS_FIXME_VersionID = "versionId", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize( diff --git a/src/ImageKit.Tests/Models/Webhooks/UploadPostTransformErrorEventTest.cs b/src/ImageKit.Tests/Models/Webhooks/UploadPostTransformErrorEventTest.cs index 43d93c31..bbdc932a 100644 --- a/src/ImageKit.Tests/Models/Webhooks/UploadPostTransformErrorEventTest.cs +++ b/src/ImageKit.Tests/Models/Webhooks/UploadPostTransformErrorEventTest.cs @@ -39,7 +39,7 @@ public void FieldRoundtrip_Works() string expectedID = "id"; string expectedType = "type"; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - Webhooks::UploadPostTransformErrorEventIntersectionMember1Data expectedData = new() + Webhooks::Data expectedData = new() { FileID = "fileId", Name = "name", @@ -140,7 +140,7 @@ public void FieldRoundtripThroughSerialization_Works() string expectedID = "id"; string expectedType = "type"; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - Webhooks::UploadPostTransformErrorEventIntersectionMember1Data expectedData = new() + Webhooks::Data expectedData = new() { FileID = "fileId", Name = "name", @@ -231,12 +231,12 @@ public void CopyConstructor_Works() } } -public class UploadPostTransformErrorEventIntersectionMember1Test : TestBase +public class IntersectionMember1Test : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Webhooks::UploadPostTransformErrorEventIntersectionMember1 + var model = new Webhooks::IntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -260,7 +260,7 @@ public void FieldRoundtrip_Works() }; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - Webhooks::UploadPostTransformErrorEventIntersectionMember1Data expectedData = new() + Webhooks::Data expectedData = new() { FileID = "fileId", Name = "name", @@ -289,7 +289,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Webhooks::UploadPostTransformErrorEventIntersectionMember1 + var model = new Webhooks::IntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -313,11 +313,10 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -325,7 +324,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Webhooks::UploadPostTransformErrorEventIntersectionMember1 + var model = new Webhooks::IntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -349,15 +348,14 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.NotNull(deserialized); DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - Webhooks::UploadPostTransformErrorEventIntersectionMember1Data expectedData = new() + Webhooks::Data expectedData = new() { FileID = "fileId", Name = "name", @@ -386,7 +384,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Webhooks::UploadPostTransformErrorEventIntersectionMember1 + var model = new Webhooks::IntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -415,7 +413,7 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new Webhooks::UploadPostTransformErrorEventIntersectionMember1 + var model = new Webhooks::IntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -438,18 +436,18 @@ public void CopyConstructor_Works() }, }; - Webhooks::UploadPostTransformErrorEventIntersectionMember1 copied = new(model); + Webhooks::IntersectionMember1 copied = new(model); Assert.Equal(model, copied); } } -public class UploadPostTransformErrorEventIntersectionMember1DataTest : TestBase +public class DataTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Webhooks::UploadPostTransformErrorEventIntersectionMember1Data + var model = new Webhooks::Data { FileID = "fileId", Name = "name", @@ -476,7 +474,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Webhooks::UploadPostTransformErrorEventIntersectionMember1Data + var model = new Webhooks::Data { FileID = "fileId", Name = "name", @@ -486,11 +484,10 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -498,7 +495,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Webhooks::UploadPostTransformErrorEventIntersectionMember1Data + var model = new Webhooks::Data { FileID = "fileId", Name = "name", @@ -508,11 +505,10 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.NotNull(deserialized); string expectedFileID = "fileId"; @@ -533,7 +529,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Webhooks::UploadPostTransformErrorEventIntersectionMember1Data + var model = new Webhooks::Data { FileID = "fileId", Name = "name", @@ -548,7 +544,7 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new Webhooks::UploadPostTransformErrorEventIntersectionMember1Data + var model = new Webhooks::Data { FileID = "fileId", Name = "name", @@ -557,7 +553,7 @@ public void CopyConstructor_Works() Url = "https://example.com", }; - Webhooks::UploadPostTransformErrorEventIntersectionMember1Data copied = new(model); + Webhooks::Data copied = new(model); Assert.Equal(model, copied); } diff --git a/src/ImageKit/Models/Webhooks/DamFileCreateEvent.cs b/src/ImageKit/Models/Webhooks/FileCreatedWebhookEvent.cs similarity index 64% rename from src/ImageKit/Models/Webhooks/DamFileCreateEvent.cs rename to src/ImageKit/Models/Webhooks/FileCreatedWebhookEvent.cs index 10f4ce4b..8a658aac 100644 --- a/src/ImageKit/Models/Webhooks/DamFileCreateEvent.cs +++ b/src/ImageKit/Models/Webhooks/FileCreatedWebhookEvent.cs @@ -13,8 +13,8 @@ namespace ImageKit.Models.Webhooks; /// /// Triggered when a file is created. /// -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class DamFileCreateEvent : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class FileCreatedWebhookEvent : JsonModel { /// /// Unique identifier for the event. @@ -68,8 +68,9 @@ public required File Data init { this._rawData.Set("data", value); } } - public static implicit operator BaseWebhookEvent(DamFileCreateEvent damFileCreateEvent) => - new() { ID = damFileCreateEvent.ID, Type = damFileCreateEvent.Type }; + public static implicit operator BaseWebhookEvent( + FileCreatedWebhookEvent fileCreatedWebhookEvent + ) => new() { ID = fileCreatedWebhookEvent.ID, Type = fileCreatedWebhookEvent.Type }; /// public override void Validate() @@ -80,29 +81,29 @@ public override void Validate() this.Data.Validate(); } - public DamFileCreateEvent() { } + public FileCreatedWebhookEvent() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public DamFileCreateEvent(DamFileCreateEvent damFileCreateEvent) - : base(damFileCreateEvent) { } + public FileCreatedWebhookEvent(FileCreatedWebhookEvent fileCreatedWebhookEvent) + : base(fileCreatedWebhookEvent) { } #pragma warning restore CS8618 - public DamFileCreateEvent(IReadOnlyDictionary rawData) + public FileCreatedWebhookEvent(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - DamFileCreateEvent(FrozenDictionary rawData) + FileCreatedWebhookEvent(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static DamFileCreateEvent FromRawUnchecked( + /// + public static FileCreatedWebhookEvent FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -110,11 +111,12 @@ IReadOnlyDictionary rawData } } -class DamFileCreateEventFromRaw : IFromRawJson +class FileCreatedWebhookEventFromRaw : IFromRawJson { /// - public DamFileCreateEvent FromRawUnchecked(IReadOnlyDictionary rawData) => - DamFileCreateEvent.FromRawUnchecked(rawData); + public FileCreatedWebhookEvent FromRawUnchecked( + IReadOnlyDictionary rawData + ) => FileCreatedWebhookEvent.FromRawUnchecked(rawData); } /// @@ -122,11 +124,11 @@ public DamFileCreateEvent FromRawUnchecked(IReadOnlyDictionary [JsonConverter( typeof(JsonModelConverter< - global::ImageKit.Models.Webhooks.IntersectionMember1, - global::ImageKit.Models.Webhooks.IntersectionMember1FromRaw + FileCreatedWebhookEventIntersectionMember1, + FileCreatedWebhookEventIntersectionMember1FromRaw >) )] -public sealed record class IntersectionMember1 : JsonModel +public sealed record class FileCreatedWebhookEventIntersectionMember1 : JsonModel { /// /// Timestamp of when the event occurred in ISO8601 format. @@ -178,20 +180,22 @@ public override void Validate() } } - public IntersectionMember1() + public FileCreatedWebhookEventIntersectionMember1() { this.Type = JsonSerializer.SerializeToElement("file.created"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public IntersectionMember1( - global::ImageKit.Models.Webhooks.IntersectionMember1 intersectionMember1 + public FileCreatedWebhookEventIntersectionMember1( + FileCreatedWebhookEventIntersectionMember1 fileCreatedWebhookEventIntersectionMember1 ) - : base(intersectionMember1) { } + : base(fileCreatedWebhookEventIntersectionMember1) { } #pragma warning restore CS8618 - public IntersectionMember1(IReadOnlyDictionary rawData) + public FileCreatedWebhookEventIntersectionMember1( + IReadOnlyDictionary rawData + ) { this._rawData = new(rawData); @@ -200,14 +204,14 @@ public IntersectionMember1(IReadOnlyDictionary rawData) #pragma warning disable CS8618 [SetsRequiredMembers] - IntersectionMember1(FrozenDictionary rawData) + FileCreatedWebhookEventIntersectionMember1(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::ImageKit.Models.Webhooks.IntersectionMember1 FromRawUnchecked( + /// + public static FileCreatedWebhookEventIntersectionMember1 FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -215,11 +219,11 @@ IReadOnlyDictionary rawData } } -class IntersectionMember1FromRaw - : IFromRawJson +class FileCreatedWebhookEventIntersectionMember1FromRaw + : IFromRawJson { /// - public global::ImageKit.Models.Webhooks.IntersectionMember1 FromRawUnchecked( + public FileCreatedWebhookEventIntersectionMember1 FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::ImageKit.Models.Webhooks.IntersectionMember1.FromRawUnchecked(rawData); + ) => FileCreatedWebhookEventIntersectionMember1.FromRawUnchecked(rawData); } diff --git a/src/ImageKit/Models/Webhooks/DamFileDeleteEvent.cs b/src/ImageKit/Models/Webhooks/FileDeletedWebhookEvent.cs similarity index 52% rename from src/ImageKit/Models/Webhooks/DamFileDeleteEvent.cs rename to src/ImageKit/Models/Webhooks/FileDeletedWebhookEvent.cs index edda5014..b8d7255e 100644 --- a/src/ImageKit/Models/Webhooks/DamFileDeleteEvent.cs +++ b/src/ImageKit/Models/Webhooks/FileDeletedWebhookEvent.cs @@ -12,8 +12,8 @@ namespace ImageKit.Models.Webhooks; /// /// Triggered when a file is deleted. /// -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class DamFileDeleteEvent : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class FileDeletedWebhookEvent : JsonModel { /// /// Unique identifier for the event. @@ -54,18 +54,21 @@ public required DateTimeOffset CreatedAt init { this._rawData.Set("created_at", value); } } - public required Data Data + public required FileDeletedWebhookEventIntersectionMember1Data Data { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("data"); + return this._rawData.GetNotNullClass( + "data" + ); } init { this._rawData.Set("data", value); } } - public static implicit operator BaseWebhookEvent(DamFileDeleteEvent damFileDeleteEvent) => - new() { ID = damFileDeleteEvent.ID, Type = damFileDeleteEvent.Type }; + public static implicit operator BaseWebhookEvent( + FileDeletedWebhookEvent fileDeletedWebhookEvent + ) => new() { ID = fileDeletedWebhookEvent.ID, Type = fileDeletedWebhookEvent.Type }; /// public override void Validate() @@ -76,29 +79,29 @@ public override void Validate() this.Data.Validate(); } - public DamFileDeleteEvent() { } + public FileDeletedWebhookEvent() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public DamFileDeleteEvent(DamFileDeleteEvent damFileDeleteEvent) - : base(damFileDeleteEvent) { } + public FileDeletedWebhookEvent(FileDeletedWebhookEvent fileDeletedWebhookEvent) + : base(fileDeletedWebhookEvent) { } #pragma warning restore CS8618 - public DamFileDeleteEvent(IReadOnlyDictionary rawData) + public FileDeletedWebhookEvent(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - DamFileDeleteEvent(FrozenDictionary rawData) + FileDeletedWebhookEvent(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static DamFileDeleteEvent FromRawUnchecked( + /// + public static FileDeletedWebhookEvent FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -106,11 +109,12 @@ IReadOnlyDictionary rawData } } -class DamFileDeleteEventFromRaw : IFromRawJson +class FileDeletedWebhookEventFromRaw : IFromRawJson { /// - public DamFileDeleteEvent FromRawUnchecked(IReadOnlyDictionary rawData) => - DamFileDeleteEvent.FromRawUnchecked(rawData); + public FileDeletedWebhookEvent FromRawUnchecked( + IReadOnlyDictionary rawData + ) => FileDeletedWebhookEvent.FromRawUnchecked(rawData); } /// @@ -118,11 +122,11 @@ public DamFileDeleteEvent FromRawUnchecked(IReadOnlyDictionary [JsonConverter( typeof(JsonModelConverter< - DamFileDeleteEventIntersectionMember1, - DamFileDeleteEventIntersectionMember1FromRaw + FileDeletedWebhookEventIntersectionMember1, + FileDeletedWebhookEventIntersectionMember1FromRaw >) )] -public sealed record class DamFileDeleteEventIntersectionMember1 : JsonModel +public sealed record class FileDeletedWebhookEventIntersectionMember1 : JsonModel { /// /// Timestamp of when the event occurred in ISO8601 format. @@ -137,12 +141,14 @@ public required DateTimeOffset CreatedAt init { this._rawData.Set("created_at", value); } } - public required Data Data + public required FileDeletedWebhookEventIntersectionMember1Data Data { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("data"); + return this._rawData.GetNotNullClass( + "data" + ); } init { this._rawData.Set("data", value); } } @@ -171,20 +177,22 @@ public override void Validate() } } - public DamFileDeleteEventIntersectionMember1() + public FileDeletedWebhookEventIntersectionMember1() { this.Type = JsonSerializer.SerializeToElement("file.deleted"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public DamFileDeleteEventIntersectionMember1( - DamFileDeleteEventIntersectionMember1 damFileDeleteEventIntersectionMember1 + public FileDeletedWebhookEventIntersectionMember1( + FileDeletedWebhookEventIntersectionMember1 fileDeletedWebhookEventIntersectionMember1 ) - : base(damFileDeleteEventIntersectionMember1) { } + : base(fileDeletedWebhookEventIntersectionMember1) { } #pragma warning restore CS8618 - public DamFileDeleteEventIntersectionMember1(IReadOnlyDictionary rawData) + public FileDeletedWebhookEventIntersectionMember1( + IReadOnlyDictionary rawData + ) { this._rawData = new(rawData); @@ -193,14 +201,14 @@ public DamFileDeleteEventIntersectionMember1(IReadOnlyDictionary rawData) + FileDeletedWebhookEventIntersectionMember1(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static DamFileDeleteEventIntersectionMember1 FromRawUnchecked( + /// + public static FileDeletedWebhookEventIntersectionMember1 FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -208,17 +216,22 @@ IReadOnlyDictionary rawData } } -class DamFileDeleteEventIntersectionMember1FromRaw - : IFromRawJson +class FileDeletedWebhookEventIntersectionMember1FromRaw + : IFromRawJson { /// - public DamFileDeleteEventIntersectionMember1 FromRawUnchecked( + public FileDeletedWebhookEventIntersectionMember1 FromRawUnchecked( IReadOnlyDictionary rawData - ) => DamFileDeleteEventIntersectionMember1.FromRawUnchecked(rawData); + ) => FileDeletedWebhookEventIntersectionMember1.FromRawUnchecked(rawData); } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class Data : JsonModel +[JsonConverter( + typeof(JsonModelConverter< + FileDeletedWebhookEventIntersectionMember1Data, + FileDeletedWebhookEventIntersectionMember1DataFromRaw + >) +)] +public sealed record class FileDeletedWebhookEventIntersectionMember1Data : JsonModel { /// /// The unique `fileId` of the deleted file. @@ -239,44 +252,52 @@ public override void Validate() _ = this.FileID; } - public Data() { } + public FileDeletedWebhookEventIntersectionMember1Data() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public Data(Data data) - : base(data) { } + public FileDeletedWebhookEventIntersectionMember1Data( + FileDeletedWebhookEventIntersectionMember1Data fileDeletedWebhookEventIntersectionMember1Data + ) + : base(fileDeletedWebhookEventIntersectionMember1Data) { } #pragma warning restore CS8618 - public Data(IReadOnlyDictionary rawData) + public FileDeletedWebhookEventIntersectionMember1Data( + IReadOnlyDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - Data(FrozenDictionary rawData) + FileDeletedWebhookEventIntersectionMember1Data(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static Data FromRawUnchecked(IReadOnlyDictionary rawData) + /// + public static FileDeletedWebhookEventIntersectionMember1Data FromRawUnchecked( + IReadOnlyDictionary rawData + ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } [SetsRequiredMembers] - public Data(string fileID) + public FileDeletedWebhookEventIntersectionMember1Data(string fileID) : this() { this.FileID = fileID; } } -class DataFromRaw : IFromRawJson +class FileDeletedWebhookEventIntersectionMember1DataFromRaw + : IFromRawJson { /// - public Data FromRawUnchecked(IReadOnlyDictionary rawData) => - Data.FromRawUnchecked(rawData); + public FileDeletedWebhookEventIntersectionMember1Data FromRawUnchecked( + IReadOnlyDictionary rawData + ) => FileDeletedWebhookEventIntersectionMember1Data.FromRawUnchecked(rawData); } diff --git a/src/ImageKit/Models/Webhooks/DamFileUpdateEvent.cs b/src/ImageKit/Models/Webhooks/FileUpdatedWebhookEvent.cs similarity index 64% rename from src/ImageKit/Models/Webhooks/DamFileUpdateEvent.cs rename to src/ImageKit/Models/Webhooks/FileUpdatedWebhookEvent.cs index 7f3cebe0..5004025e 100644 --- a/src/ImageKit/Models/Webhooks/DamFileUpdateEvent.cs +++ b/src/ImageKit/Models/Webhooks/FileUpdatedWebhookEvent.cs @@ -13,8 +13,8 @@ namespace ImageKit.Models.Webhooks; /// /// Triggered when a file is updated. /// -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class DamFileUpdateEvent : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class FileUpdatedWebhookEvent : JsonModel { /// /// Unique identifier for the event. @@ -68,8 +68,9 @@ public required File Data init { this._rawData.Set("data", value); } } - public static implicit operator BaseWebhookEvent(DamFileUpdateEvent damFileUpdateEvent) => - new() { ID = damFileUpdateEvent.ID, Type = damFileUpdateEvent.Type }; + public static implicit operator BaseWebhookEvent( + FileUpdatedWebhookEvent fileUpdatedWebhookEvent + ) => new() { ID = fileUpdatedWebhookEvent.ID, Type = fileUpdatedWebhookEvent.Type }; /// public override void Validate() @@ -80,29 +81,29 @@ public override void Validate() this.Data.Validate(); } - public DamFileUpdateEvent() { } + public FileUpdatedWebhookEvent() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public DamFileUpdateEvent(DamFileUpdateEvent damFileUpdateEvent) - : base(damFileUpdateEvent) { } + public FileUpdatedWebhookEvent(FileUpdatedWebhookEvent fileUpdatedWebhookEvent) + : base(fileUpdatedWebhookEvent) { } #pragma warning restore CS8618 - public DamFileUpdateEvent(IReadOnlyDictionary rawData) + public FileUpdatedWebhookEvent(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - DamFileUpdateEvent(FrozenDictionary rawData) + FileUpdatedWebhookEvent(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static DamFileUpdateEvent FromRawUnchecked( + /// + public static FileUpdatedWebhookEvent FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -110,11 +111,12 @@ IReadOnlyDictionary rawData } } -class DamFileUpdateEventFromRaw : IFromRawJson +class FileUpdatedWebhookEventFromRaw : IFromRawJson { /// - public DamFileUpdateEvent FromRawUnchecked(IReadOnlyDictionary rawData) => - DamFileUpdateEvent.FromRawUnchecked(rawData); + public FileUpdatedWebhookEvent FromRawUnchecked( + IReadOnlyDictionary rawData + ) => FileUpdatedWebhookEvent.FromRawUnchecked(rawData); } /// @@ -122,11 +124,11 @@ public DamFileUpdateEvent FromRawUnchecked(IReadOnlyDictionary [JsonConverter( typeof(JsonModelConverter< - DamFileUpdateEventIntersectionMember1, - DamFileUpdateEventIntersectionMember1FromRaw + FileUpdatedWebhookEventIntersectionMember1, + FileUpdatedWebhookEventIntersectionMember1FromRaw >) )] -public sealed record class DamFileUpdateEventIntersectionMember1 : JsonModel +public sealed record class FileUpdatedWebhookEventIntersectionMember1 : JsonModel { /// /// Timestamp of when the event occurred in ISO8601 format. @@ -178,20 +180,22 @@ public override void Validate() } } - public DamFileUpdateEventIntersectionMember1() + public FileUpdatedWebhookEventIntersectionMember1() { this.Type = JsonSerializer.SerializeToElement("file.updated"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public DamFileUpdateEventIntersectionMember1( - DamFileUpdateEventIntersectionMember1 damFileUpdateEventIntersectionMember1 + public FileUpdatedWebhookEventIntersectionMember1( + FileUpdatedWebhookEventIntersectionMember1 fileUpdatedWebhookEventIntersectionMember1 ) - : base(damFileUpdateEventIntersectionMember1) { } + : base(fileUpdatedWebhookEventIntersectionMember1) { } #pragma warning restore CS8618 - public DamFileUpdateEventIntersectionMember1(IReadOnlyDictionary rawData) + public FileUpdatedWebhookEventIntersectionMember1( + IReadOnlyDictionary rawData + ) { this._rawData = new(rawData); @@ -200,14 +204,14 @@ public DamFileUpdateEventIntersectionMember1(IReadOnlyDictionary rawData) + FileUpdatedWebhookEventIntersectionMember1(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static DamFileUpdateEventIntersectionMember1 FromRawUnchecked( + /// + public static FileUpdatedWebhookEventIntersectionMember1 FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -215,11 +219,11 @@ IReadOnlyDictionary rawData } } -class DamFileUpdateEventIntersectionMember1FromRaw - : IFromRawJson +class FileUpdatedWebhookEventIntersectionMember1FromRaw + : IFromRawJson { /// - public DamFileUpdateEventIntersectionMember1 FromRawUnchecked( + public FileUpdatedWebhookEventIntersectionMember1 FromRawUnchecked( IReadOnlyDictionary rawData - ) => DamFileUpdateEventIntersectionMember1.FromRawUnchecked(rawData); + ) => FileUpdatedWebhookEventIntersectionMember1.FromRawUnchecked(rawData); } diff --git a/src/ImageKit/Models/Webhooks/DamFileVersionCreateEvent.cs b/src/ImageKit/Models/Webhooks/FileVersionCreatedWebhookEvent.cs similarity index 64% rename from src/ImageKit/Models/Webhooks/DamFileVersionCreateEvent.cs rename to src/ImageKit/Models/Webhooks/FileVersionCreatedWebhookEvent.cs index cabd6185..bb2f1134 100644 --- a/src/ImageKit/Models/Webhooks/DamFileVersionCreateEvent.cs +++ b/src/ImageKit/Models/Webhooks/FileVersionCreatedWebhookEvent.cs @@ -14,9 +14,12 @@ namespace ImageKit.Models.Webhooks; /// Triggered when a file version is created. /// [JsonConverter( - typeof(JsonModelConverter) + typeof(JsonModelConverter< + FileVersionCreatedWebhookEvent, + FileVersionCreatedWebhookEventFromRaw + >) )] -public sealed record class DamFileVersionCreateEvent : JsonModel +public sealed record class FileVersionCreatedWebhookEvent : JsonModel { /// /// Unique identifier for the event. @@ -71,8 +74,13 @@ public required File Data } public static implicit operator BaseWebhookEvent( - DamFileVersionCreateEvent damFileVersionCreateEvent - ) => new() { ID = damFileVersionCreateEvent.ID, Type = damFileVersionCreateEvent.Type }; + FileVersionCreatedWebhookEvent fileVersionCreatedWebhookEvent + ) => + new() + { + ID = fileVersionCreatedWebhookEvent.ID, + Type = fileVersionCreatedWebhookEvent.Type, + }; /// public override void Validate() @@ -83,29 +91,31 @@ public override void Validate() this.Data.Validate(); } - public DamFileVersionCreateEvent() { } + public FileVersionCreatedWebhookEvent() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public DamFileVersionCreateEvent(DamFileVersionCreateEvent damFileVersionCreateEvent) - : base(damFileVersionCreateEvent) { } + public FileVersionCreatedWebhookEvent( + FileVersionCreatedWebhookEvent fileVersionCreatedWebhookEvent + ) + : base(fileVersionCreatedWebhookEvent) { } #pragma warning restore CS8618 - public DamFileVersionCreateEvent(IReadOnlyDictionary rawData) + public FileVersionCreatedWebhookEvent(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - DamFileVersionCreateEvent(FrozenDictionary rawData) + FileVersionCreatedWebhookEvent(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static DamFileVersionCreateEvent FromRawUnchecked( + /// + public static FileVersionCreatedWebhookEvent FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -113,12 +123,12 @@ IReadOnlyDictionary rawData } } -class DamFileVersionCreateEventFromRaw : IFromRawJson +class FileVersionCreatedWebhookEventFromRaw : IFromRawJson { /// - public DamFileVersionCreateEvent FromRawUnchecked( + public FileVersionCreatedWebhookEvent FromRawUnchecked( IReadOnlyDictionary rawData - ) => DamFileVersionCreateEvent.FromRawUnchecked(rawData); + ) => FileVersionCreatedWebhookEvent.FromRawUnchecked(rawData); } /// @@ -126,11 +136,11 @@ IReadOnlyDictionary rawData /// [JsonConverter( typeof(JsonModelConverter< - DamFileVersionCreateEventIntersectionMember1, - DamFileVersionCreateEventIntersectionMember1FromRaw + FileVersionCreatedWebhookEventIntersectionMember1, + FileVersionCreatedWebhookEventIntersectionMember1FromRaw >) )] -public sealed record class DamFileVersionCreateEventIntersectionMember1 : JsonModel +public sealed record class FileVersionCreatedWebhookEventIntersectionMember1 : JsonModel { /// /// Timestamp of when the event occurred in ISO8601 format. @@ -187,20 +197,20 @@ public override void Validate() } } - public DamFileVersionCreateEventIntersectionMember1() + public FileVersionCreatedWebhookEventIntersectionMember1() { this.Type = JsonSerializer.SerializeToElement("file-version.created"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public DamFileVersionCreateEventIntersectionMember1( - DamFileVersionCreateEventIntersectionMember1 damFileVersionCreateEventIntersectionMember1 + public FileVersionCreatedWebhookEventIntersectionMember1( + FileVersionCreatedWebhookEventIntersectionMember1 fileVersionCreatedWebhookEventIntersectionMember1 ) - : base(damFileVersionCreateEventIntersectionMember1) { } + : base(fileVersionCreatedWebhookEventIntersectionMember1) { } #pragma warning restore CS8618 - public DamFileVersionCreateEventIntersectionMember1( + public FileVersionCreatedWebhookEventIntersectionMember1( IReadOnlyDictionary rawData ) { @@ -211,14 +221,14 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - DamFileVersionCreateEventIntersectionMember1(FrozenDictionary rawData) + FileVersionCreatedWebhookEventIntersectionMember1(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static DamFileVersionCreateEventIntersectionMember1 FromRawUnchecked( + /// + public static FileVersionCreatedWebhookEventIntersectionMember1 FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -226,11 +236,11 @@ IReadOnlyDictionary rawData } } -class DamFileVersionCreateEventIntersectionMember1FromRaw - : IFromRawJson +class FileVersionCreatedWebhookEventIntersectionMember1FromRaw + : IFromRawJson { /// - public DamFileVersionCreateEventIntersectionMember1 FromRawUnchecked( + public FileVersionCreatedWebhookEventIntersectionMember1 FromRawUnchecked( IReadOnlyDictionary rawData - ) => DamFileVersionCreateEventIntersectionMember1.FromRawUnchecked(rawData); + ) => FileVersionCreatedWebhookEventIntersectionMember1.FromRawUnchecked(rawData); } diff --git a/src/ImageKit/Models/Webhooks/DamFileVersionDeleteEvent.cs b/src/ImageKit/Models/Webhooks/FileVersionDeletedWebhookEvent.cs similarity index 57% rename from src/ImageKit/Models/Webhooks/DamFileVersionDeleteEvent.cs rename to src/ImageKit/Models/Webhooks/FileVersionDeletedWebhookEvent.cs index 6959bbe7..72d16eb3 100644 --- a/src/ImageKit/Models/Webhooks/DamFileVersionDeleteEvent.cs +++ b/src/ImageKit/Models/Webhooks/FileVersionDeletedWebhookEvent.cs @@ -13,9 +13,12 @@ namespace ImageKit.Models.Webhooks; /// Triggered when a file version is deleted. /// [JsonConverter( - typeof(JsonModelConverter) + typeof(JsonModelConverter< + FileVersionDeletedWebhookEvent, + FileVersionDeletedWebhookEventFromRaw + >) )] -public sealed record class DamFileVersionDeleteEvent : JsonModel +public sealed record class FileVersionDeletedWebhookEvent : JsonModel { /// /// Unique identifier for the event. @@ -56,12 +59,12 @@ public required DateTimeOffset CreatedAt init { this._rawData.Set("created_at", value); } } - public required DamFileVersionDeleteEventIntersectionMember1Data Data + public required FileVersionDeletedWebhookEventIntersectionMember1Data Data { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "data" ); } @@ -69,8 +72,13 @@ public required DamFileVersionDeleteEventIntersectionMember1Data Data } public static implicit operator BaseWebhookEvent( - DamFileVersionDeleteEvent damFileVersionDeleteEvent - ) => new() { ID = damFileVersionDeleteEvent.ID, Type = damFileVersionDeleteEvent.Type }; + FileVersionDeletedWebhookEvent fileVersionDeletedWebhookEvent + ) => + new() + { + ID = fileVersionDeletedWebhookEvent.ID, + Type = fileVersionDeletedWebhookEvent.Type, + }; /// public override void Validate() @@ -81,29 +89,31 @@ public override void Validate() this.Data.Validate(); } - public DamFileVersionDeleteEvent() { } + public FileVersionDeletedWebhookEvent() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public DamFileVersionDeleteEvent(DamFileVersionDeleteEvent damFileVersionDeleteEvent) - : base(damFileVersionDeleteEvent) { } + public FileVersionDeletedWebhookEvent( + FileVersionDeletedWebhookEvent fileVersionDeletedWebhookEvent + ) + : base(fileVersionDeletedWebhookEvent) { } #pragma warning restore CS8618 - public DamFileVersionDeleteEvent(IReadOnlyDictionary rawData) + public FileVersionDeletedWebhookEvent(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - DamFileVersionDeleteEvent(FrozenDictionary rawData) + FileVersionDeletedWebhookEvent(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static DamFileVersionDeleteEvent FromRawUnchecked( + /// + public static FileVersionDeletedWebhookEvent FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -111,12 +121,12 @@ IReadOnlyDictionary rawData } } -class DamFileVersionDeleteEventFromRaw : IFromRawJson +class FileVersionDeletedWebhookEventFromRaw : IFromRawJson { /// - public DamFileVersionDeleteEvent FromRawUnchecked( + public FileVersionDeletedWebhookEvent FromRawUnchecked( IReadOnlyDictionary rawData - ) => DamFileVersionDeleteEvent.FromRawUnchecked(rawData); + ) => FileVersionDeletedWebhookEvent.FromRawUnchecked(rawData); } /// @@ -124,11 +134,11 @@ IReadOnlyDictionary rawData /// [JsonConverter( typeof(JsonModelConverter< - DamFileVersionDeleteEventIntersectionMember1, - DamFileVersionDeleteEventIntersectionMember1FromRaw + FileVersionDeletedWebhookEventIntersectionMember1, + FileVersionDeletedWebhookEventIntersectionMember1FromRaw >) )] -public sealed record class DamFileVersionDeleteEventIntersectionMember1 : JsonModel +public sealed record class FileVersionDeletedWebhookEventIntersectionMember1 : JsonModel { /// /// Timestamp of when the event occurred in ISO8601 format. @@ -143,12 +153,12 @@ public required DateTimeOffset CreatedAt init { this._rawData.Set("created_at", value); } } - public required DamFileVersionDeleteEventIntersectionMember1Data Data + public required FileVersionDeletedWebhookEventIntersectionMember1Data Data { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "data" ); } @@ -184,20 +194,20 @@ public override void Validate() } } - public DamFileVersionDeleteEventIntersectionMember1() + public FileVersionDeletedWebhookEventIntersectionMember1() { this.Type = JsonSerializer.SerializeToElement("file-version.deleted"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public DamFileVersionDeleteEventIntersectionMember1( - DamFileVersionDeleteEventIntersectionMember1 damFileVersionDeleteEventIntersectionMember1 + public FileVersionDeletedWebhookEventIntersectionMember1( + FileVersionDeletedWebhookEventIntersectionMember1 fileVersionDeletedWebhookEventIntersectionMember1 ) - : base(damFileVersionDeleteEventIntersectionMember1) { } + : base(fileVersionDeletedWebhookEventIntersectionMember1) { } #pragma warning restore CS8618 - public DamFileVersionDeleteEventIntersectionMember1( + public FileVersionDeletedWebhookEventIntersectionMember1( IReadOnlyDictionary rawData ) { @@ -208,14 +218,14 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - DamFileVersionDeleteEventIntersectionMember1(FrozenDictionary rawData) + FileVersionDeletedWebhookEventIntersectionMember1(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static DamFileVersionDeleteEventIntersectionMember1 FromRawUnchecked( + /// + public static FileVersionDeletedWebhookEventIntersectionMember1 FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -223,22 +233,22 @@ IReadOnlyDictionary rawData } } -class DamFileVersionDeleteEventIntersectionMember1FromRaw - : IFromRawJson +class FileVersionDeletedWebhookEventIntersectionMember1FromRaw + : IFromRawJson { /// - public DamFileVersionDeleteEventIntersectionMember1 FromRawUnchecked( + public FileVersionDeletedWebhookEventIntersectionMember1 FromRawUnchecked( IReadOnlyDictionary rawData - ) => DamFileVersionDeleteEventIntersectionMember1.FromRawUnchecked(rawData); + ) => FileVersionDeletedWebhookEventIntersectionMember1.FromRawUnchecked(rawData); } [JsonConverter( typeof(JsonModelConverter< - DamFileVersionDeleteEventIntersectionMember1Data, - DamFileVersionDeleteEventIntersectionMember1DataFromRaw + FileVersionDeletedWebhookEventIntersectionMember1Data, + FileVersionDeletedWebhookEventIntersectionMember1DataFromRaw >) )] -public sealed record class DamFileVersionDeleteEventIntersectionMember1Data : JsonModel +public sealed record class FileVersionDeletedWebhookEventIntersectionMember1Data : JsonModel { /// /// The unique `fileId` of the deleted file. @@ -273,17 +283,17 @@ public override void Validate() _ = this.VersionID; } - public DamFileVersionDeleteEventIntersectionMember1Data() { } + public FileVersionDeletedWebhookEventIntersectionMember1Data() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public DamFileVersionDeleteEventIntersectionMember1Data( - DamFileVersionDeleteEventIntersectionMember1Data damFileVersionDeleteEventIntersectionMember1Data + public FileVersionDeletedWebhookEventIntersectionMember1Data( + FileVersionDeletedWebhookEventIntersectionMember1Data fileVersionDeletedWebhookEventIntersectionMember1Data ) - : base(damFileVersionDeleteEventIntersectionMember1Data) { } + : base(fileVersionDeletedWebhookEventIntersectionMember1Data) { } #pragma warning restore CS8618 - public DamFileVersionDeleteEventIntersectionMember1Data( + public FileVersionDeletedWebhookEventIntersectionMember1Data( IReadOnlyDictionary rawData ) { @@ -292,14 +302,16 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - DamFileVersionDeleteEventIntersectionMember1Data(FrozenDictionary rawData) + FileVersionDeletedWebhookEventIntersectionMember1Data( + FrozenDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static DamFileVersionDeleteEventIntersectionMember1Data FromRawUnchecked( + /// + public static FileVersionDeletedWebhookEventIntersectionMember1Data FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -307,11 +319,11 @@ IReadOnlyDictionary rawData } } -class DamFileVersionDeleteEventIntersectionMember1DataFromRaw - : IFromRawJson +class FileVersionDeletedWebhookEventIntersectionMember1DataFromRaw + : IFromRawJson { /// - public DamFileVersionDeleteEventIntersectionMember1Data FromRawUnchecked( + public FileVersionDeletedWebhookEventIntersectionMember1Data FromRawUnchecked( IReadOnlyDictionary rawData - ) => DamFileVersionDeleteEventIntersectionMember1Data.FromRawUnchecked(rawData); + ) => FileVersionDeletedWebhookEventIntersectionMember1Data.FromRawUnchecked(rawData); } diff --git a/src/ImageKit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs b/src/ImageKit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs index b555f421..afb9eb6f 100644 --- a/src/ImageKit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs +++ b/src/ImageKit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs @@ -42,11 +42,11 @@ public string ID uploadPreTransformError: (x) => x.ID, uploadPostTransformSuccess: (x) => x.ID, uploadPostTransformError: (x) => x.ID, - damFileCreate: (x) => x.ID, - damFileUpdate: (x) => x.ID, - damFileDelete: (x) => x.ID, - damFileVersionCreate: (x) => x.ID, - damFileVersionDelete: (x) => x.ID + fileCreated: (x) => x.STAINLESS_FIXME_ID, + fileUpdated: (x) => x.STAINLESS_FIXME_ID, + fileDeleted: (x) => x.STAINLESS_FIXME_ID, + fileVersionCreated: (x) => x.STAINLESS_FIXME_ID, + fileVersionDeleted: (x) => x.STAINLESS_FIXME_ID ); } } @@ -63,11 +63,11 @@ public string Type uploadPreTransformError: (x) => x.Type, uploadPostTransformSuccess: (x) => x.Type, uploadPostTransformError: (x) => x.Type, - damFileCreate: (x) => x.Type, - damFileUpdate: (x) => x.Type, - damFileDelete: (x) => x.Type, - damFileVersionCreate: (x) => x.Type, - damFileVersionDelete: (x) => x.Type + fileCreated: (x) => x.STAINLESS_FIXME_Type, + fileUpdated: (x) => x.STAINLESS_FIXME_Type, + fileDeleted: (x) => x.STAINLESS_FIXME_Type, + fileVersionCreated: (x) => x.STAINLESS_FIXME_Type, + fileVersionDeleted: (x) => x.STAINLESS_FIXME_Type ); } } @@ -84,11 +84,11 @@ public string Type uploadPreTransformError: (x) => x.CreatedAt, uploadPostTransformSuccess: (x) => x.CreatedAt, uploadPostTransformError: (x) => x.CreatedAt, - damFileCreate: (x) => x.CreatedAt, - damFileUpdate: (x) => x.CreatedAt, - damFileDelete: (x) => x.CreatedAt, - damFileVersionCreate: (x) => x.CreatedAt, - damFileVersionDelete: (x) => x.CreatedAt + fileCreated: (x) => x.STAINLESS_FIXME_CreatedAt, + fileUpdated: (x) => x.STAINLESS_FIXME_CreatedAt, + fileDeleted: (x) => x.STAINLESS_FIXME_CreatedAt, + fileVersionCreated: (x) => x.STAINLESS_FIXME_CreatedAt, + fileVersionDeleted: (x) => x.STAINLESS_FIXME_CreatedAt ); } } @@ -153,31 +153,37 @@ public UnsafeUnwrapWebhookEvent( this._element = element; } - public UnsafeUnwrapWebhookEvent(DamFileCreateEvent value, JsonElement? element = null) + public UnsafeUnwrapWebhookEvent(FileCreatedWebhookEvent value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnsafeUnwrapWebhookEvent(DamFileUpdateEvent value, JsonElement? element = null) + public UnsafeUnwrapWebhookEvent(FileUpdatedWebhookEvent value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnsafeUnwrapWebhookEvent(DamFileDeleteEvent value, JsonElement? element = null) + public UnsafeUnwrapWebhookEvent(FileDeletedWebhookEvent value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnsafeUnwrapWebhookEvent(DamFileVersionCreateEvent value, JsonElement? element = null) + public UnsafeUnwrapWebhookEvent( + FileVersionCreatedWebhookEvent value, + JsonElement? element = null + ) { this.Value = value; this._element = element; } - public UnsafeUnwrapWebhookEvent(DamFileVersionDeleteEvent value, JsonElement? element = null) + public UnsafeUnwrapWebhookEvent( + FileVersionDeletedWebhookEvent value, + JsonElement? element = null + ) { this.Value = value; this._element = element; @@ -351,110 +357,110 @@ public bool TryPickUploadPostTransformError( /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickDamFileCreate(out var value)) { - /// // `value` is of type `DamFileCreateEvent` + /// if (instance.TryPickFileCreated(out var value)) { + /// // `value` is of type `FileCreatedWebhookEvent` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickDamFileCreate([NotNullWhen(true)] out DamFileCreateEvent? value) + public bool TryPickFileCreated([NotNullWhen(true)] out FileCreatedWebhookEvent? value) { - value = this.Value as DamFileCreateEvent; + value = this.Value as FileCreatedWebhookEvent; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickDamFileUpdate(out var value)) { - /// // `value` is of type `DamFileUpdateEvent` + /// if (instance.TryPickFileUpdated(out var value)) { + /// // `value` is of type `FileUpdatedWebhookEvent` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickDamFileUpdate([NotNullWhen(true)] out DamFileUpdateEvent? value) + public bool TryPickFileUpdated([NotNullWhen(true)] out FileUpdatedWebhookEvent? value) { - value = this.Value as DamFileUpdateEvent; + value = this.Value as FileUpdatedWebhookEvent; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickDamFileDelete(out var value)) { - /// // `value` is of type `DamFileDeleteEvent` + /// if (instance.TryPickFileDeleted(out var value)) { + /// // `value` is of type `FileDeletedWebhookEvent` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickDamFileDelete([NotNullWhen(true)] out DamFileDeleteEvent? value) + public bool TryPickFileDeleted([NotNullWhen(true)] out FileDeletedWebhookEvent? value) { - value = this.Value as DamFileDeleteEvent; + value = this.Value as FileDeletedWebhookEvent; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickDamFileVersionCreate(out var value)) { - /// // `value` is of type `DamFileVersionCreateEvent` + /// if (instance.TryPickFileVersionCreated(out var value)) { + /// // `value` is of type `FileVersionCreatedWebhookEvent` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickDamFileVersionCreate( - [NotNullWhen(true)] out DamFileVersionCreateEvent? value + public bool TryPickFileVersionCreated( + [NotNullWhen(true)] out FileVersionCreatedWebhookEvent? value ) { - value = this.Value as DamFileVersionCreateEvent; + value = this.Value as FileVersionCreatedWebhookEvent; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickDamFileVersionDelete(out var value)) { - /// // `value` is of type `DamFileVersionDeleteEvent` + /// if (instance.TryPickFileVersionDeleted(out var value)) { + /// // `value` is of type `FileVersionDeletedWebhookEvent` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickDamFileVersionDelete( - [NotNullWhen(true)] out DamFileVersionDeleteEvent? value + public bool TryPickFileVersionDeleted( + [NotNullWhen(true)] out FileVersionDeletedWebhookEvent? value ) { - value = this.Value as DamFileVersionDeleteEvent; + value = this.Value as FileVersionDeletedWebhookEvent; return value != null; } @@ -479,11 +485,11 @@ public bool TryPickDamFileVersionDelete( /// (UploadPreTransformErrorEvent value) => {...}, /// (UploadPostTransformSuccessEvent value) => {...}, /// (UploadPostTransformErrorEvent value) => {...}, - /// (DamFileCreateEvent value) => {...}, - /// (DamFileUpdateEvent value) => {...}, - /// (DamFileDeleteEvent value) => {...}, - /// (DamFileVersionCreateEvent value) => {...}, - /// (DamFileVersionDeleteEvent value) => {...} + /// (FileCreatedWebhookEvent value) => {...}, + /// (FileUpdatedWebhookEvent value) => {...}, + /// (FileDeletedWebhookEvent value) => {...}, + /// (FileVersionCreatedWebhookEvent value) => {...}, + /// (FileVersionDeletedWebhookEvent value) => {...} /// ); /// /// @@ -496,11 +502,11 @@ public void Switch( System::Action uploadPreTransformError, System::Action uploadPostTransformSuccess, System::Action uploadPostTransformError, - System::Action damFileCreate, - System::Action damFileUpdate, - System::Action damFileDelete, - System::Action damFileVersionCreate, - System::Action damFileVersionDelete + System::Action fileCreated, + System::Action fileUpdated, + System::Action fileDeleted, + System::Action fileVersionCreated, + System::Action fileVersionDeleted ) { switch (this.Value) @@ -526,20 +532,20 @@ public void Switch( case UploadPostTransformErrorEvent value: uploadPostTransformError(value); break; - case DamFileCreateEvent value: - damFileCreate(value); + case FileCreatedWebhookEvent value: + fileCreated(value); break; - case DamFileUpdateEvent value: - damFileUpdate(value); + case FileUpdatedWebhookEvent value: + fileUpdated(value); break; - case DamFileDeleteEvent value: - damFileDelete(value); + case FileDeletedWebhookEvent value: + fileDeleted(value); break; - case DamFileVersionCreateEvent value: - damFileVersionCreate(value); + case FileVersionCreatedWebhookEvent value: + fileVersionCreated(value); break; - case DamFileVersionDeleteEvent value: - damFileVersionDelete(value); + case FileVersionDeletedWebhookEvent value: + fileVersionDeleted(value); break; default: throw new ImageKitInvalidDataException( @@ -570,11 +576,11 @@ public void Switch( /// (UploadPreTransformErrorEvent value) => {...}, /// (UploadPostTransformSuccessEvent value) => {...}, /// (UploadPostTransformErrorEvent value) => {...}, - /// (DamFileCreateEvent value) => {...}, - /// (DamFileUpdateEvent value) => {...}, - /// (DamFileDeleteEvent value) => {...}, - /// (DamFileVersionCreateEvent value) => {...}, - /// (DamFileVersionDeleteEvent value) => {...} + /// (FileCreatedWebhookEvent value) => {...}, + /// (FileUpdatedWebhookEvent value) => {...}, + /// (FileDeletedWebhookEvent value) => {...}, + /// (FileVersionCreatedWebhookEvent value) => {...}, + /// (FileVersionDeletedWebhookEvent value) => {...} /// ); /// /// @@ -587,11 +593,11 @@ public T Match( System::Func uploadPreTransformError, System::Func uploadPostTransformSuccess, System::Func uploadPostTransformError, - System::Func damFileCreate, - System::Func damFileUpdate, - System::Func damFileDelete, - System::Func damFileVersionCreate, - System::Func damFileVersionDelete + System::Func fileCreated, + System::Func fileUpdated, + System::Func fileDeleted, + System::Func fileVersionCreated, + System::Func fileVersionDeleted ) { return this.Value switch @@ -603,11 +609,11 @@ public T Match( UploadPreTransformErrorEvent value => uploadPreTransformError(value), UploadPostTransformSuccessEvent value => uploadPostTransformSuccess(value), UploadPostTransformErrorEvent value => uploadPostTransformError(value), - DamFileCreateEvent value => damFileCreate(value), - DamFileUpdateEvent value => damFileUpdate(value), - DamFileDeleteEvent value => damFileDelete(value), - DamFileVersionCreateEvent value => damFileVersionCreate(value), - DamFileVersionDeleteEvent value => damFileVersionDelete(value), + FileCreatedWebhookEvent value => fileCreated(value), + FileUpdatedWebhookEvent value => fileUpdated(value), + FileDeletedWebhookEvent value => fileDeleted(value), + FileVersionCreatedWebhookEvent value => fileVersionCreated(value), + FileVersionDeletedWebhookEvent value => fileVersionDeleted(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of UnsafeUnwrapWebhookEvent" ), @@ -638,20 +644,22 @@ UploadPostTransformSuccessEvent value public static implicit operator UnsafeUnwrapWebhookEvent(UploadPostTransformErrorEvent value) => new(value); - public static implicit operator UnsafeUnwrapWebhookEvent(DamFileCreateEvent value) => + public static implicit operator UnsafeUnwrapWebhookEvent(FileCreatedWebhookEvent value) => new(value); - public static implicit operator UnsafeUnwrapWebhookEvent(DamFileUpdateEvent value) => + public static implicit operator UnsafeUnwrapWebhookEvent(FileUpdatedWebhookEvent value) => new(value); - public static implicit operator UnsafeUnwrapWebhookEvent(DamFileDeleteEvent value) => + public static implicit operator UnsafeUnwrapWebhookEvent(FileDeletedWebhookEvent value) => new(value); - public static implicit operator UnsafeUnwrapWebhookEvent(DamFileVersionCreateEvent value) => - new(value); + public static implicit operator UnsafeUnwrapWebhookEvent( + FileVersionCreatedWebhookEvent value + ) => new(value); - public static implicit operator UnsafeUnwrapWebhookEvent(DamFileVersionDeleteEvent value) => - new(value); + public static implicit operator UnsafeUnwrapWebhookEvent( + FileVersionDeletedWebhookEvent value + ) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -679,11 +687,11 @@ public override void Validate() (uploadPreTransformError) => uploadPreTransformError.Validate(), (uploadPostTransformSuccess) => uploadPostTransformSuccess.Validate(), (uploadPostTransformError) => uploadPostTransformError.Validate(), - (damFileCreate) => damFileCreate.Validate(), - (damFileUpdate) => damFileUpdate.Validate(), - (damFileDelete) => damFileDelete.Validate(), - (damFileVersionCreate) => damFileVersionCreate.Validate(), - (damFileVersionDelete) => damFileVersionDelete.Validate() + (fileCreated) => fileCreated.Validate(), + (fileUpdated) => fileUpdated.Validate(), + (fileDeleted) => fileDeleted.Validate(), + (fileVersionCreated) => fileVersionCreated.Validate(), + (fileVersionDeleted) => fileVersionDeleted.Validate() ); } @@ -714,11 +722,11 @@ int VariantIndex() UploadPreTransformErrorEvent _ => 4, UploadPostTransformSuccessEvent _ => 5, UploadPostTransformErrorEvent _ => 6, - DamFileCreateEvent _ => 7, - DamFileUpdateEvent _ => 8, - DamFileDeleteEvent _ => 9, - DamFileVersionCreateEvent _ => 10, - DamFileVersionDeleteEvent _ => 11, + FileCreatedWebhookEvent _ => 7, + FileUpdatedWebhookEvent _ => 8, + FileDeletedWebhookEvent _ => 9, + FileVersionCreatedWebhookEvent _ => 10, + FileVersionDeletedWebhookEvent _ => 11, _ => -1, }; } @@ -875,7 +883,7 @@ JsonSerializerOptions options try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -893,7 +901,7 @@ JsonSerializerOptions options try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -911,7 +919,7 @@ JsonSerializerOptions options try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -929,7 +937,7 @@ JsonSerializerOptions options try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -947,7 +955,7 @@ JsonSerializerOptions options try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); diff --git a/src/ImageKit/Models/Webhooks/UnwrapWebhookEvent.cs b/src/ImageKit/Models/Webhooks/UnwrapWebhookEvent.cs index 43a9e72a..6d6d3206 100644 --- a/src/ImageKit/Models/Webhooks/UnwrapWebhookEvent.cs +++ b/src/ImageKit/Models/Webhooks/UnwrapWebhookEvent.cs @@ -42,11 +42,11 @@ public string ID uploadPreTransformError: (x) => x.ID, uploadPostTransformSuccess: (x) => x.ID, uploadPostTransformError: (x) => x.ID, - damFileCreate: (x) => x.ID, - damFileUpdate: (x) => x.ID, - damFileDelete: (x) => x.ID, - damFileVersionCreate: (x) => x.ID, - damFileVersionDelete: (x) => x.ID + fileCreated: (x) => x.STAINLESS_FIXME_ID, + fileUpdated: (x) => x.STAINLESS_FIXME_ID, + fileDeleted: (x) => x.STAINLESS_FIXME_ID, + fileVersionCreated: (x) => x.STAINLESS_FIXME_ID, + fileVersionDeleted: (x) => x.STAINLESS_FIXME_ID ); } } @@ -63,11 +63,11 @@ public string Type uploadPreTransformError: (x) => x.Type, uploadPostTransformSuccess: (x) => x.Type, uploadPostTransformError: (x) => x.Type, - damFileCreate: (x) => x.Type, - damFileUpdate: (x) => x.Type, - damFileDelete: (x) => x.Type, - damFileVersionCreate: (x) => x.Type, - damFileVersionDelete: (x) => x.Type + fileCreated: (x) => x.STAINLESS_FIXME_Type, + fileUpdated: (x) => x.STAINLESS_FIXME_Type, + fileDeleted: (x) => x.STAINLESS_FIXME_Type, + fileVersionCreated: (x) => x.STAINLESS_FIXME_Type, + fileVersionDeleted: (x) => x.STAINLESS_FIXME_Type ); } } @@ -84,11 +84,11 @@ public string Type uploadPreTransformError: (x) => x.CreatedAt, uploadPostTransformSuccess: (x) => x.CreatedAt, uploadPostTransformError: (x) => x.CreatedAt, - damFileCreate: (x) => x.CreatedAt, - damFileUpdate: (x) => x.CreatedAt, - damFileDelete: (x) => x.CreatedAt, - damFileVersionCreate: (x) => x.CreatedAt, - damFileVersionDelete: (x) => x.CreatedAt + fileCreated: (x) => x.STAINLESS_FIXME_CreatedAt, + fileUpdated: (x) => x.STAINLESS_FIXME_CreatedAt, + fileDeleted: (x) => x.STAINLESS_FIXME_CreatedAt, + fileVersionCreated: (x) => x.STAINLESS_FIXME_CreatedAt, + fileVersionDeleted: (x) => x.STAINLESS_FIXME_CreatedAt ); } } @@ -135,31 +135,31 @@ public UnwrapWebhookEvent(UploadPostTransformErrorEvent value, JsonElement? elem this._element = element; } - public UnwrapWebhookEvent(DamFileCreateEvent value, JsonElement? element = null) + public UnwrapWebhookEvent(FileCreatedWebhookEvent value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnwrapWebhookEvent(DamFileUpdateEvent value, JsonElement? element = null) + public UnwrapWebhookEvent(FileUpdatedWebhookEvent value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnwrapWebhookEvent(DamFileDeleteEvent value, JsonElement? element = null) + public UnwrapWebhookEvent(FileDeletedWebhookEvent value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnwrapWebhookEvent(DamFileVersionCreateEvent value, JsonElement? element = null) + public UnwrapWebhookEvent(FileVersionCreatedWebhookEvent value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnwrapWebhookEvent(DamFileVersionDeleteEvent value, JsonElement? element = null) + public UnwrapWebhookEvent(FileVersionDeletedWebhookEvent value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -333,110 +333,110 @@ public bool TryPickUploadPostTransformError( /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickDamFileCreate(out var value)) { - /// // `value` is of type `DamFileCreateEvent` + /// if (instance.TryPickFileCreated(out var value)) { + /// // `value` is of type `FileCreatedWebhookEvent` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickDamFileCreate([NotNullWhen(true)] out DamFileCreateEvent? value) + public bool TryPickFileCreated([NotNullWhen(true)] out FileCreatedWebhookEvent? value) { - value = this.Value as DamFileCreateEvent; + value = this.Value as FileCreatedWebhookEvent; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickDamFileUpdate(out var value)) { - /// // `value` is of type `DamFileUpdateEvent` + /// if (instance.TryPickFileUpdated(out var value)) { + /// // `value` is of type `FileUpdatedWebhookEvent` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickDamFileUpdate([NotNullWhen(true)] out DamFileUpdateEvent? value) + public bool TryPickFileUpdated([NotNullWhen(true)] out FileUpdatedWebhookEvent? value) { - value = this.Value as DamFileUpdateEvent; + value = this.Value as FileUpdatedWebhookEvent; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickDamFileDelete(out var value)) { - /// // `value` is of type `DamFileDeleteEvent` + /// if (instance.TryPickFileDeleted(out var value)) { + /// // `value` is of type `FileDeletedWebhookEvent` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickDamFileDelete([NotNullWhen(true)] out DamFileDeleteEvent? value) + public bool TryPickFileDeleted([NotNullWhen(true)] out FileDeletedWebhookEvent? value) { - value = this.Value as DamFileDeleteEvent; + value = this.Value as FileDeletedWebhookEvent; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickDamFileVersionCreate(out var value)) { - /// // `value` is of type `DamFileVersionCreateEvent` + /// if (instance.TryPickFileVersionCreated(out var value)) { + /// // `value` is of type `FileVersionCreatedWebhookEvent` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickDamFileVersionCreate( - [NotNullWhen(true)] out DamFileVersionCreateEvent? value + public bool TryPickFileVersionCreated( + [NotNullWhen(true)] out FileVersionCreatedWebhookEvent? value ) { - value = this.Value as DamFileVersionCreateEvent; + value = this.Value as FileVersionCreatedWebhookEvent; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickDamFileVersionDelete(out var value)) { - /// // `value` is of type `DamFileVersionDeleteEvent` + /// if (instance.TryPickFileVersionDeleted(out var value)) { + /// // `value` is of type `FileVersionDeletedWebhookEvent` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickDamFileVersionDelete( - [NotNullWhen(true)] out DamFileVersionDeleteEvent? value + public bool TryPickFileVersionDeleted( + [NotNullWhen(true)] out FileVersionDeletedWebhookEvent? value ) { - value = this.Value as DamFileVersionDeleteEvent; + value = this.Value as FileVersionDeletedWebhookEvent; return value != null; } @@ -461,11 +461,11 @@ public bool TryPickDamFileVersionDelete( /// (UploadPreTransformErrorEvent value) => {...}, /// (UploadPostTransformSuccessEvent value) => {...}, /// (UploadPostTransformErrorEvent value) => {...}, - /// (DamFileCreateEvent value) => {...}, - /// (DamFileUpdateEvent value) => {...}, - /// (DamFileDeleteEvent value) => {...}, - /// (DamFileVersionCreateEvent value) => {...}, - /// (DamFileVersionDeleteEvent value) => {...} + /// (FileCreatedWebhookEvent value) => {...}, + /// (FileUpdatedWebhookEvent value) => {...}, + /// (FileDeletedWebhookEvent value) => {...}, + /// (FileVersionCreatedWebhookEvent value) => {...}, + /// (FileVersionDeletedWebhookEvent value) => {...} /// ); /// /// @@ -478,11 +478,11 @@ public void Switch( System::Action uploadPreTransformError, System::Action uploadPostTransformSuccess, System::Action uploadPostTransformError, - System::Action damFileCreate, - System::Action damFileUpdate, - System::Action damFileDelete, - System::Action damFileVersionCreate, - System::Action damFileVersionDelete + System::Action fileCreated, + System::Action fileUpdated, + System::Action fileDeleted, + System::Action fileVersionCreated, + System::Action fileVersionDeleted ) { switch (this.Value) @@ -508,20 +508,20 @@ public void Switch( case UploadPostTransformErrorEvent value: uploadPostTransformError(value); break; - case DamFileCreateEvent value: - damFileCreate(value); + case FileCreatedWebhookEvent value: + fileCreated(value); break; - case DamFileUpdateEvent value: - damFileUpdate(value); + case FileUpdatedWebhookEvent value: + fileUpdated(value); break; - case DamFileDeleteEvent value: - damFileDelete(value); + case FileDeletedWebhookEvent value: + fileDeleted(value); break; - case DamFileVersionCreateEvent value: - damFileVersionCreate(value); + case FileVersionCreatedWebhookEvent value: + fileVersionCreated(value); break; - case DamFileVersionDeleteEvent value: - damFileVersionDelete(value); + case FileVersionDeletedWebhookEvent value: + fileVersionDeleted(value); break; default: throw new ImageKitInvalidDataException( @@ -552,11 +552,11 @@ public void Switch( /// (UploadPreTransformErrorEvent value) => {...}, /// (UploadPostTransformSuccessEvent value) => {...}, /// (UploadPostTransformErrorEvent value) => {...}, - /// (DamFileCreateEvent value) => {...}, - /// (DamFileUpdateEvent value) => {...}, - /// (DamFileDeleteEvent value) => {...}, - /// (DamFileVersionCreateEvent value) => {...}, - /// (DamFileVersionDeleteEvent value) => {...} + /// (FileCreatedWebhookEvent value) => {...}, + /// (FileUpdatedWebhookEvent value) => {...}, + /// (FileDeletedWebhookEvent value) => {...}, + /// (FileVersionCreatedWebhookEvent value) => {...}, + /// (FileVersionDeletedWebhookEvent value) => {...} /// ); /// /// @@ -569,11 +569,11 @@ public T Match( System::Func uploadPreTransformError, System::Func uploadPostTransformSuccess, System::Func uploadPostTransformError, - System::Func damFileCreate, - System::Func damFileUpdate, - System::Func damFileDelete, - System::Func damFileVersionCreate, - System::Func damFileVersionDelete + System::Func fileCreated, + System::Func fileUpdated, + System::Func fileDeleted, + System::Func fileVersionCreated, + System::Func fileVersionDeleted ) { return this.Value switch @@ -585,11 +585,11 @@ public T Match( UploadPreTransformErrorEvent value => uploadPreTransformError(value), UploadPostTransformSuccessEvent value => uploadPostTransformSuccess(value), UploadPostTransformErrorEvent value => uploadPostTransformError(value), - DamFileCreateEvent value => damFileCreate(value), - DamFileUpdateEvent value => damFileUpdate(value), - DamFileDeleteEvent value => damFileDelete(value), - DamFileVersionCreateEvent value => damFileVersionCreate(value), - DamFileVersionDeleteEvent value => damFileVersionDelete(value), + FileCreatedWebhookEvent value => fileCreated(value), + FileUpdatedWebhookEvent value => fileUpdated(value), + FileDeletedWebhookEvent value => fileDeleted(value), + FileVersionCreatedWebhookEvent value => fileVersionCreated(value), + FileVersionDeletedWebhookEvent value => fileVersionDeleted(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of UnwrapWebhookEvent" ), @@ -617,16 +617,16 @@ public static implicit operator UnwrapWebhookEvent(UploadPostTransformSuccessEve public static implicit operator UnwrapWebhookEvent(UploadPostTransformErrorEvent value) => new(value); - public static implicit operator UnwrapWebhookEvent(DamFileCreateEvent value) => new(value); + public static implicit operator UnwrapWebhookEvent(FileCreatedWebhookEvent value) => new(value); - public static implicit operator UnwrapWebhookEvent(DamFileUpdateEvent value) => new(value); + public static implicit operator UnwrapWebhookEvent(FileUpdatedWebhookEvent value) => new(value); - public static implicit operator UnwrapWebhookEvent(DamFileDeleteEvent value) => new(value); + public static implicit operator UnwrapWebhookEvent(FileDeletedWebhookEvent value) => new(value); - public static implicit operator UnwrapWebhookEvent(DamFileVersionCreateEvent value) => + public static implicit operator UnwrapWebhookEvent(FileVersionCreatedWebhookEvent value) => new(value); - public static implicit operator UnwrapWebhookEvent(DamFileVersionDeleteEvent value) => + public static implicit operator UnwrapWebhookEvent(FileVersionDeletedWebhookEvent value) => new(value); /// @@ -655,11 +655,11 @@ public override void Validate() (uploadPreTransformError) => uploadPreTransformError.Validate(), (uploadPostTransformSuccess) => uploadPostTransformSuccess.Validate(), (uploadPostTransformError) => uploadPostTransformError.Validate(), - (damFileCreate) => damFileCreate.Validate(), - (damFileUpdate) => damFileUpdate.Validate(), - (damFileDelete) => damFileDelete.Validate(), - (damFileVersionCreate) => damFileVersionCreate.Validate(), - (damFileVersionDelete) => damFileVersionDelete.Validate() + (fileCreated) => fileCreated.Validate(), + (fileUpdated) => fileUpdated.Validate(), + (fileDeleted) => fileDeleted.Validate(), + (fileVersionCreated) => fileVersionCreated.Validate(), + (fileVersionDeleted) => fileVersionDeleted.Validate() ); } @@ -690,11 +690,11 @@ int VariantIndex() UploadPreTransformErrorEvent _ => 4, UploadPostTransformSuccessEvent _ => 5, UploadPostTransformErrorEvent _ => 6, - DamFileCreateEvent _ => 7, - DamFileUpdateEvent _ => 8, - DamFileDeleteEvent _ => 9, - DamFileVersionCreateEvent _ => 10, - DamFileVersionDeleteEvent _ => 11, + FileCreatedWebhookEvent _ => 7, + FileUpdatedWebhookEvent _ => 8, + FileDeletedWebhookEvent _ => 9, + FileVersionCreatedWebhookEvent _ => 10, + FileVersionDeletedWebhookEvent _ => 11, _ => -1, }; } @@ -851,7 +851,7 @@ JsonSerializerOptions options try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -869,7 +869,7 @@ JsonSerializerOptions options try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -887,7 +887,7 @@ JsonSerializerOptions options try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -905,7 +905,7 @@ JsonSerializerOptions options try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -923,7 +923,7 @@ JsonSerializerOptions options try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); diff --git a/src/ImageKit/Models/Webhooks/UploadPostTransformErrorEvent.cs b/src/ImageKit/Models/Webhooks/UploadPostTransformErrorEvent.cs index ffa377f3..5b5245f8 100644 --- a/src/ImageKit/Models/Webhooks/UploadPostTransformErrorEvent.cs +++ b/src/ImageKit/Models/Webhooks/UploadPostTransformErrorEvent.cs @@ -57,14 +57,12 @@ public required string Type init { this._rawData.Set("created_at", value); } } - public required UploadPostTransformErrorEventIntersectionMember1Data Data + public required Data Data { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "data" - ); + return this._rawData.GetNotNullClass("data"); } init { this._rawData.Set("data", value); } } @@ -137,13 +135,8 @@ IReadOnlyDictionary rawData /// Triggered when a post-transformation fails. The original file remains available, /// but the requested transformation could not be generated. /// -[JsonConverter( - typeof(JsonModelConverter< - UploadPostTransformErrorEventIntersectionMember1, - UploadPostTransformErrorEventIntersectionMember1FromRaw - >) -)] -public sealed record class UploadPostTransformErrorEventIntersectionMember1 : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class IntersectionMember1 : JsonModel { /// /// Timestamp of when the event occurred in ISO8601 format. @@ -158,14 +151,12 @@ public sealed record class UploadPostTransformErrorEventIntersectionMember1 : Js init { this._rawData.Set("created_at", value); } } - public required UploadPostTransformErrorEventIntersectionMember1Data Data + public required Data Data { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "data" - ); + return this._rawData.GetNotNullClass("data"); } init { this._rawData.Set("data", value); } } @@ -207,22 +198,18 @@ public override void Validate() } } - public UploadPostTransformErrorEventIntersectionMember1() + public IntersectionMember1() { this.Type = JsonSerializer.SerializeToElement("upload.post-transform.error"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public UploadPostTransformErrorEventIntersectionMember1( - UploadPostTransformErrorEventIntersectionMember1 uploadPostTransformErrorEventIntersectionMember1 - ) - : base(uploadPostTransformErrorEventIntersectionMember1) { } + public IntersectionMember1(IntersectionMember1 intersectionMember1) + : base(intersectionMember1) { } #pragma warning restore CS8618 - public UploadPostTransformErrorEventIntersectionMember1( - IReadOnlyDictionary rawData - ) + public IntersectionMember1(IReadOnlyDictionary rawData) { this._rawData = new(rawData); @@ -231,14 +218,14 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - UploadPostTransformErrorEventIntersectionMember1(FrozenDictionary rawData) + IntersectionMember1(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static UploadPostTransformErrorEventIntersectionMember1 FromRawUnchecked( + /// + public static IntersectionMember1 FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -246,22 +233,15 @@ IReadOnlyDictionary rawData } } -class UploadPostTransformErrorEventIntersectionMember1FromRaw - : IFromRawJson +class IntersectionMember1FromRaw : IFromRawJson { /// - public UploadPostTransformErrorEventIntersectionMember1 FromRawUnchecked( - IReadOnlyDictionary rawData - ) => UploadPostTransformErrorEventIntersectionMember1.FromRawUnchecked(rawData); + public IntersectionMember1 FromRawUnchecked(IReadOnlyDictionary rawData) => + IntersectionMember1.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(JsonModelConverter< - UploadPostTransformErrorEventIntersectionMember1Data, - UploadPostTransformErrorEventIntersectionMember1DataFromRaw - >) -)] -public sealed record class UploadPostTransformErrorEventIntersectionMember1Data : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Data : JsonModel { /// /// Unique identifier of the originally uploaded file. @@ -335,49 +315,39 @@ public override void Validate() _ = this.Url; } - public UploadPostTransformErrorEventIntersectionMember1Data() { } + public Data() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public UploadPostTransformErrorEventIntersectionMember1Data( - UploadPostTransformErrorEventIntersectionMember1Data uploadPostTransformErrorEventIntersectionMember1Data - ) - : base(uploadPostTransformErrorEventIntersectionMember1Data) { } + public Data(Data data) + : base(data) { } #pragma warning restore CS8618 - public UploadPostTransformErrorEventIntersectionMember1Data( - IReadOnlyDictionary rawData - ) + public Data(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - UploadPostTransformErrorEventIntersectionMember1Data( - FrozenDictionary rawData - ) + Data(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static UploadPostTransformErrorEventIntersectionMember1Data FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Data FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class UploadPostTransformErrorEventIntersectionMember1DataFromRaw - : IFromRawJson +class DataFromRaw : IFromRawJson { /// - public UploadPostTransformErrorEventIntersectionMember1Data FromRawUnchecked( - IReadOnlyDictionary rawData - ) => UploadPostTransformErrorEventIntersectionMember1Data.FromRawUnchecked(rawData); + public Data FromRawUnchecked(IReadOnlyDictionary rawData) => + Data.FromRawUnchecked(rawData); } [JsonConverter(typeof(JsonModelConverter))] From 547632077b3d8b927d08be2a7de882ce7b14e29d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 10 Apr 2026 06:59:14 +0000 Subject: [PATCH 096/129] fix(api): rename DamFile events to File for consistency --- .stats.yml | 2 +- ...ookEventTest.cs => FileCreateEventTest.cs} | 36 +-- ...ookEventTest.cs => FileDeleteEventTest.cs} | 70 +++--- ...ookEventTest.cs => FileUpdateEventTest.cs} | 36 +-- ...tTest.cs => FileVersionCreateEventTest.cs} | 50 ++-- ...tTest.cs => FileVersionDeleteEventTest.cs} | 76 +++--- .../Webhooks/UnsafeUnwrapWebhookEventTest.cs | 88 ++++--- .../Models/Webhooks/UnwrapWebhookEventTest.cs | 88 ++++--- .../UploadPostTransformErrorEventTest.cs | 72 +++--- ...atedWebhookEvent.cs => FileCreateEvent.cs} | 64 +++-- ...etedWebhookEvent.cs => FileDeleteEvent.cs} | 114 ++++----- ...atedWebhookEvent.cs => FileUpdateEvent.cs} | 63 +++-- ...hookEvent.cs => FileVersionCreateEvent.cs} | 70 +++--- ...hookEvent.cs => FileVersionDeleteEvent.cs} | 110 ++++----- .../Webhooks/UnsafeUnwrapWebhookEvent.cs | 219 ++++++++---------- .../Models/Webhooks/UnwrapWebhookEvent.cs | 206 ++++++++-------- .../Webhooks/UploadPostTransformErrorEvent.cs | 86 ++++--- 17 files changed, 686 insertions(+), 764 deletions(-) rename src/ImageKit.Tests/Models/Webhooks/{FileCreatedWebhookEventTest.cs => FileCreateEventTest.cs} (94%) rename src/ImageKit.Tests/Models/Webhooks/{FileDeletedWebhookEventTest.cs => FileDeleteEventTest.cs} (69%) rename src/ImageKit.Tests/Models/Webhooks/{FileUpdatedWebhookEventTest.cs => FileUpdateEventTest.cs} (95%) rename src/ImageKit.Tests/Models/Webhooks/{FileVersionCreatedWebhookEventTest.cs => FileVersionCreateEventTest.cs} (94%) rename src/ImageKit.Tests/Models/Webhooks/{FileVersionDeletedWebhookEventTest.cs => FileVersionDeleteEventTest.cs} (72%) rename src/ImageKit/Models/Webhooks/{FileCreatedWebhookEvent.cs => FileCreateEvent.cs} (63%) rename src/ImageKit/Models/Webhooks/{FileDeletedWebhookEvent.cs => FileDeleteEvent.cs} (52%) rename src/ImageKit/Models/Webhooks/{FileUpdatedWebhookEvent.cs => FileUpdateEvent.cs} (63%) rename src/ImageKit/Models/Webhooks/{FileVersionCreatedWebhookEvent.cs => FileVersionCreateEvent.cs} (64%) rename src/ImageKit/Models/Webhooks/{FileVersionDeletedWebhookEvent.cs => FileVersionDeleteEvent.cs} (58%) diff --git a/.stats.yml b/.stats.yml index 4bc5fef0..aae6cba6 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-d73a37dc3426586109bd153f02c6a605036b6a7396bba5173d013468c5291ce6.yml openapi_spec_hash: c193c6e557ff477481ec8d5ac8a0c96e -config_hash: 17e408231b0b01676298010c7405f483 +config_hash: 32b155378f65c234d3abeb18519fb3cd diff --git a/src/ImageKit.Tests/Models/Webhooks/FileCreatedWebhookEventTest.cs b/src/ImageKit.Tests/Models/Webhooks/FileCreateEventTest.cs similarity index 94% rename from src/ImageKit.Tests/Models/Webhooks/FileCreatedWebhookEventTest.cs rename to src/ImageKit.Tests/Models/Webhooks/FileCreateEventTest.cs index 042db2a9..83f1225d 100644 --- a/src/ImageKit.Tests/Models/Webhooks/FileCreatedWebhookEventTest.cs +++ b/src/ImageKit.Tests/Models/Webhooks/FileCreateEventTest.cs @@ -7,12 +7,12 @@ namespace ImageKit.Tests.Models.Webhooks; -public class FileCreatedWebhookEventTest : TestBase +public class FileCreateEventTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new FileCreatedWebhookEvent + var model = new FileCreateEvent { ID = "id", Type = "type", @@ -158,7 +158,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new FileCreatedWebhookEvent + var model = new FileCreateEvent { ID = "id", Type = "type", @@ -229,7 +229,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -240,7 +240,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new FileCreatedWebhookEvent + var model = new FileCreateEvent { ID = "id", Type = "type", @@ -311,7 +311,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -393,7 +393,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new FileCreatedWebhookEvent + var model = new FileCreateEvent { ID = "id", Type = "type", @@ -469,7 +469,7 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new FileCreatedWebhookEvent + var model = new FileCreateEvent { ID = "id", Type = "type", @@ -539,18 +539,18 @@ public void CopyConstructor_Works() }, }; - FileCreatedWebhookEvent copied = new(model); + FileCreateEvent copied = new(model); Assert.Equal(model, copied); } } -public class FileCreatedWebhookEventIntersectionMember1Test : TestBase +public class IntersectionMember1Test : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new FileCreatedWebhookEventIntersectionMember1 + var model = new IntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -692,7 +692,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new FileCreatedWebhookEventIntersectionMember1 + var model = new IntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -761,7 +761,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -772,7 +772,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new FileCreatedWebhookEventIntersectionMember1 + var model = new IntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -841,7 +841,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -921,7 +921,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new FileCreatedWebhookEventIntersectionMember1 + var model = new IntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -995,7 +995,7 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new FileCreatedWebhookEventIntersectionMember1 + var model = new IntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -1063,7 +1063,7 @@ public void CopyConstructor_Works() }, }; - FileCreatedWebhookEventIntersectionMember1 copied = new(model); + IntersectionMember1 copied = new(model); Assert.Equal(model, copied); } diff --git a/src/ImageKit.Tests/Models/Webhooks/FileDeletedWebhookEventTest.cs b/src/ImageKit.Tests/Models/Webhooks/FileDeleteEventTest.cs similarity index 69% rename from src/ImageKit.Tests/Models/Webhooks/FileDeletedWebhookEventTest.cs rename to src/ImageKit.Tests/Models/Webhooks/FileDeleteEventTest.cs index 87deb329..46045359 100644 --- a/src/ImageKit.Tests/Models/Webhooks/FileDeletedWebhookEventTest.cs +++ b/src/ImageKit.Tests/Models/Webhooks/FileDeleteEventTest.cs @@ -5,12 +5,12 @@ namespace ImageKit.Tests.Models.Webhooks; -public class FileDeletedWebhookEventTest : TestBase +public class FileDeleteEventTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new FileDeletedWebhookEvent + var model = new FileDeleteEvent { ID = "id", Type = "type", @@ -21,7 +21,7 @@ public void FieldRoundtrip_Works() string expectedID = "id"; string expectedType = "type"; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - FileDeletedWebhookEventIntersectionMember1Data expectedData = new("fileId"); + Data expectedData = new("fileId"); Assert.Equal(expectedID, model.ID); Assert.Equal(expectedType, model.Type); @@ -32,7 +32,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new FileDeletedWebhookEvent + var model = new FileDeleteEvent { ID = "id", Type = "type", @@ -41,7 +41,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -52,7 +52,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new FileDeletedWebhookEvent + var model = new FileDeleteEvent { ID = "id", Type = "type", @@ -61,7 +61,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -70,7 +70,7 @@ public void FieldRoundtripThroughSerialization_Works() string expectedID = "id"; string expectedType = "type"; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - FileDeletedWebhookEventIntersectionMember1Data expectedData = new("fileId"); + Data expectedData = new("fileId"); Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedType, deserialized.Type); @@ -81,7 +81,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new FileDeletedWebhookEvent + var model = new FileDeleteEvent { ID = "id", Type = "type", @@ -95,7 +95,7 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new FileDeletedWebhookEvent + var model = new FileDeleteEvent { ID = "id", Type = "type", @@ -103,25 +103,25 @@ public void CopyConstructor_Works() Data = new("fileId"), }; - FileDeletedWebhookEvent copied = new(model); + FileDeleteEvent copied = new(model); Assert.Equal(model, copied); } } -public class FileDeletedWebhookEventIntersectionMember1Test : TestBase +public class FileDeleteEventIntersectionMember1Test : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new FileDeletedWebhookEventIntersectionMember1 + var model = new FileDeleteEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new("fileId"), }; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - FileDeletedWebhookEventIntersectionMember1Data expectedData = new("fileId"); + Data expectedData = new("fileId"); JsonElement expectedType = JsonSerializer.SerializeToElement("file.deleted"); Assert.Equal(expectedCreatedAt, model.CreatedAt); @@ -132,14 +132,14 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new FileDeletedWebhookEventIntersectionMember1 + var model = new FileDeleteEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new("fileId"), }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -150,21 +150,21 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new FileDeletedWebhookEventIntersectionMember1 + var model = new FileDeleteEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new("fileId"), }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - FileDeletedWebhookEventIntersectionMember1Data expectedData = new("fileId"); + Data expectedData = new("fileId"); JsonElement expectedType = JsonSerializer.SerializeToElement("file.deleted"); Assert.Equal(expectedCreatedAt, deserialized.CreatedAt); @@ -175,7 +175,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new FileDeletedWebhookEventIntersectionMember1 + var model = new FileDeleteEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new("fileId"), @@ -187,24 +187,24 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new FileDeletedWebhookEventIntersectionMember1 + var model = new FileDeleteEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new("fileId"), }; - FileDeletedWebhookEventIntersectionMember1 copied = new(model); + FileDeleteEventIntersectionMember1 copied = new(model); Assert.Equal(model, copied); } } -public class FileDeletedWebhookEventIntersectionMember1DataTest : TestBase +public class DataTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new FileDeletedWebhookEventIntersectionMember1Data { FileID = "fileId" }; + var model = new Data { FileID = "fileId" }; string expectedFileID = "fileId"; @@ -214,14 +214,10 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new FileDeletedWebhookEventIntersectionMember1Data { FileID = "fileId" }; + var model = new Data { FileID = "fileId" }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); Assert.Equal(model, deserialized); } @@ -229,14 +225,10 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new FileDeletedWebhookEventIntersectionMember1Data { FileID = "fileId" }; + var model = new Data { FileID = "fileId" }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); Assert.NotNull(deserialized); string expectedFileID = "fileId"; @@ -247,7 +239,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new FileDeletedWebhookEventIntersectionMember1Data { FileID = "fileId" }; + var model = new Data { FileID = "fileId" }; model.Validate(); } @@ -255,9 +247,9 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new FileDeletedWebhookEventIntersectionMember1Data { FileID = "fileId" }; + var model = new Data { FileID = "fileId" }; - FileDeletedWebhookEventIntersectionMember1Data copied = new(model); + Data copied = new(model); Assert.Equal(model, copied); } diff --git a/src/ImageKit.Tests/Models/Webhooks/FileUpdatedWebhookEventTest.cs b/src/ImageKit.Tests/Models/Webhooks/FileUpdateEventTest.cs similarity index 95% rename from src/ImageKit.Tests/Models/Webhooks/FileUpdatedWebhookEventTest.cs rename to src/ImageKit.Tests/Models/Webhooks/FileUpdateEventTest.cs index 51d1c3b1..a4d57dc9 100644 --- a/src/ImageKit.Tests/Models/Webhooks/FileUpdatedWebhookEventTest.cs +++ b/src/ImageKit.Tests/Models/Webhooks/FileUpdateEventTest.cs @@ -7,12 +7,12 @@ namespace ImageKit.Tests.Models.Webhooks; -public class FileUpdatedWebhookEventTest : TestBase +public class FileUpdateEventTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new FileUpdatedWebhookEvent + var model = new FileUpdateEvent { ID = "id", Type = "type", @@ -158,7 +158,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new FileUpdatedWebhookEvent + var model = new FileUpdateEvent { ID = "id", Type = "type", @@ -229,7 +229,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -240,7 +240,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new FileUpdatedWebhookEvent + var model = new FileUpdateEvent { ID = "id", Type = "type", @@ -311,7 +311,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -393,7 +393,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new FileUpdatedWebhookEvent + var model = new FileUpdateEvent { ID = "id", Type = "type", @@ -469,7 +469,7 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new FileUpdatedWebhookEvent + var model = new FileUpdateEvent { ID = "id", Type = "type", @@ -539,18 +539,18 @@ public void CopyConstructor_Works() }, }; - FileUpdatedWebhookEvent copied = new(model); + FileUpdateEvent copied = new(model); Assert.Equal(model, copied); } } -public class FileUpdatedWebhookEventIntersectionMember1Test : TestBase +public class FileUpdateEventIntersectionMember1Test : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new FileUpdatedWebhookEventIntersectionMember1 + var model = new FileUpdateEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -692,7 +692,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new FileUpdatedWebhookEventIntersectionMember1 + var model = new FileUpdateEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -761,7 +761,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -772,7 +772,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new FileUpdatedWebhookEventIntersectionMember1 + var model = new FileUpdateEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -841,7 +841,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -921,7 +921,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new FileUpdatedWebhookEventIntersectionMember1 + var model = new FileUpdateEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -995,7 +995,7 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new FileUpdatedWebhookEventIntersectionMember1 + var model = new FileUpdateEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -1063,7 +1063,7 @@ public void CopyConstructor_Works() }, }; - FileUpdatedWebhookEventIntersectionMember1 copied = new(model); + FileUpdateEventIntersectionMember1 copied = new(model); Assert.Equal(model, copied); } diff --git a/src/ImageKit.Tests/Models/Webhooks/FileVersionCreatedWebhookEventTest.cs b/src/ImageKit.Tests/Models/Webhooks/FileVersionCreateEventTest.cs similarity index 94% rename from src/ImageKit.Tests/Models/Webhooks/FileVersionCreatedWebhookEventTest.cs rename to src/ImageKit.Tests/Models/Webhooks/FileVersionCreateEventTest.cs index eb671ec0..7c386988 100644 --- a/src/ImageKit.Tests/Models/Webhooks/FileVersionCreatedWebhookEventTest.cs +++ b/src/ImageKit.Tests/Models/Webhooks/FileVersionCreateEventTest.cs @@ -7,12 +7,12 @@ namespace ImageKit.Tests.Models.Webhooks; -public class FileVersionCreatedWebhookEventTest : TestBase +public class FileVersionCreateEventTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new FileVersionCreatedWebhookEvent + var model = new FileVersionCreateEvent { ID = "id", Type = "type", @@ -158,7 +158,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new FileVersionCreatedWebhookEvent + var model = new FileVersionCreateEvent { ID = "id", Type = "type", @@ -229,7 +229,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -240,7 +240,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new FileVersionCreatedWebhookEvent + var model = new FileVersionCreateEvent { ID = "id", Type = "type", @@ -311,7 +311,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -393,7 +393,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new FileVersionCreatedWebhookEvent + var model = new FileVersionCreateEvent { ID = "id", Type = "type", @@ -469,7 +469,7 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new FileVersionCreatedWebhookEvent + var model = new FileVersionCreateEvent { ID = "id", Type = "type", @@ -539,18 +539,18 @@ public void CopyConstructor_Works() }, }; - FileVersionCreatedWebhookEvent copied = new(model); + FileVersionCreateEvent copied = new(model); Assert.Equal(model, copied); } } -public class FileVersionCreatedWebhookEventIntersectionMember1Test : TestBase +public class FileVersionCreateEventIntersectionMember1Test : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new FileVersionCreatedWebhookEventIntersectionMember1 + var model = new FileVersionCreateEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -692,7 +692,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new FileVersionCreatedWebhookEventIntersectionMember1 + var model = new FileVersionCreateEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -761,11 +761,10 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -773,7 +772,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new FileVersionCreatedWebhookEventIntersectionMember1 + var model = new FileVersionCreateEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -842,11 +841,10 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.NotNull(deserialized); DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); @@ -923,7 +921,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new FileVersionCreatedWebhookEventIntersectionMember1 + var model = new FileVersionCreateEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -997,7 +995,7 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new FileVersionCreatedWebhookEventIntersectionMember1 + var model = new FileVersionCreateEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -1065,7 +1063,7 @@ public void CopyConstructor_Works() }, }; - FileVersionCreatedWebhookEventIntersectionMember1 copied = new(model); + FileVersionCreateEventIntersectionMember1 copied = new(model); Assert.Equal(model, copied); } diff --git a/src/ImageKit.Tests/Models/Webhooks/FileVersionDeletedWebhookEventTest.cs b/src/ImageKit.Tests/Models/Webhooks/FileVersionDeleteEventTest.cs similarity index 72% rename from src/ImageKit.Tests/Models/Webhooks/FileVersionDeletedWebhookEventTest.cs rename to src/ImageKit.Tests/Models/Webhooks/FileVersionDeleteEventTest.cs index ca0e0cb9..fac2ce1b 100644 --- a/src/ImageKit.Tests/Models/Webhooks/FileVersionDeletedWebhookEventTest.cs +++ b/src/ImageKit.Tests/Models/Webhooks/FileVersionDeleteEventTest.cs @@ -5,12 +5,12 @@ namespace ImageKit.Tests.Models.Webhooks; -public class FileVersionDeletedWebhookEventTest : TestBase +public class FileVersionDeleteEventTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new FileVersionDeletedWebhookEvent + var model = new FileVersionDeleteEvent { ID = "id", Type = "type", @@ -21,7 +21,7 @@ public void FieldRoundtrip_Works() string expectedID = "id"; string expectedType = "type"; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - FileVersionDeletedWebhookEventIntersectionMember1Data expectedData = new() + FileVersionDeleteEventIntersectionMember1Data expectedData = new() { FileID = "fileId", VersionID = "versionId", @@ -36,7 +36,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new FileVersionDeletedWebhookEvent + var model = new FileVersionDeleteEvent { ID = "id", Type = "type", @@ -45,7 +45,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -56,7 +56,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new FileVersionDeletedWebhookEvent + var model = new FileVersionDeleteEvent { ID = "id", Type = "type", @@ -65,7 +65,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -74,7 +74,7 @@ public void FieldRoundtripThroughSerialization_Works() string expectedID = "id"; string expectedType = "type"; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - FileVersionDeletedWebhookEventIntersectionMember1Data expectedData = new() + FileVersionDeleteEventIntersectionMember1Data expectedData = new() { FileID = "fileId", VersionID = "versionId", @@ -89,7 +89,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new FileVersionDeletedWebhookEvent + var model = new FileVersionDeleteEvent { ID = "id", Type = "type", @@ -103,7 +103,7 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new FileVersionDeletedWebhookEvent + var model = new FileVersionDeleteEvent { ID = "id", Type = "type", @@ -111,25 +111,25 @@ public void CopyConstructor_Works() Data = new() { FileID = "fileId", VersionID = "versionId" }, }; - FileVersionDeletedWebhookEvent copied = new(model); + FileVersionDeleteEvent copied = new(model); Assert.Equal(model, copied); } } -public class FileVersionDeletedWebhookEventIntersectionMember1Test : TestBase +public class FileVersionDeleteEventIntersectionMember1Test : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new FileVersionDeletedWebhookEventIntersectionMember1 + var model = new FileVersionDeleteEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() { FileID = "fileId", VersionID = "versionId" }, }; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - FileVersionDeletedWebhookEventIntersectionMember1Data expectedData = new() + FileVersionDeleteEventIntersectionMember1Data expectedData = new() { FileID = "fileId", VersionID = "versionId", @@ -144,18 +144,17 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new FileVersionDeletedWebhookEventIntersectionMember1 + var model = new FileVersionDeleteEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() { FileID = "fileId", VersionID = "versionId" }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -163,22 +162,21 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new FileVersionDeletedWebhookEventIntersectionMember1 + var model = new FileVersionDeleteEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() { FileID = "fileId", VersionID = "versionId" }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.NotNull(deserialized); DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - FileVersionDeletedWebhookEventIntersectionMember1Data expectedData = new() + FileVersionDeleteEventIntersectionMember1Data expectedData = new() { FileID = "fileId", VersionID = "versionId", @@ -193,7 +191,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new FileVersionDeletedWebhookEventIntersectionMember1 + var model = new FileVersionDeleteEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() { FileID = "fileId", VersionID = "versionId" }, @@ -205,24 +203,24 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new FileVersionDeletedWebhookEventIntersectionMember1 + var model = new FileVersionDeleteEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() { FileID = "fileId", VersionID = "versionId" }, }; - FileVersionDeletedWebhookEventIntersectionMember1 copied = new(model); + FileVersionDeleteEventIntersectionMember1 copied = new(model); Assert.Equal(model, copied); } } -public class FileVersionDeletedWebhookEventIntersectionMember1DataTest : TestBase +public class FileVersionDeleteEventIntersectionMember1DataTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new FileVersionDeletedWebhookEventIntersectionMember1Data + var model = new FileVersionDeleteEventIntersectionMember1Data { FileID = "fileId", VersionID = "versionId", @@ -238,7 +236,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new FileVersionDeletedWebhookEventIntersectionMember1Data + var model = new FileVersionDeleteEventIntersectionMember1Data { FileID = "fileId", VersionID = "versionId", @@ -246,7 +244,7 @@ public void SerializationRoundtrip_Works() string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -257,7 +255,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new FileVersionDeletedWebhookEventIntersectionMember1Data + var model = new FileVersionDeleteEventIntersectionMember1Data { FileID = "fileId", VersionID = "versionId", @@ -265,7 +263,7 @@ public void FieldRoundtripThroughSerialization_Works() string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -281,7 +279,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new FileVersionDeletedWebhookEventIntersectionMember1Data + var model = new FileVersionDeleteEventIntersectionMember1Data { FileID = "fileId", VersionID = "versionId", @@ -293,13 +291,13 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new FileVersionDeletedWebhookEventIntersectionMember1Data + var model = new FileVersionDeleteEventIntersectionMember1Data { FileID = "fileId", VersionID = "versionId", }; - FileVersionDeletedWebhookEventIntersectionMember1Data copied = new(model); + FileVersionDeleteEventIntersectionMember1Data copied = new(model); Assert.Equal(model, copied); } diff --git a/src/ImageKit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs b/src/ImageKit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs index c1cd1663..b19ae6fa 100644 --- a/src/ImageKit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs +++ b/src/ImageKit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs @@ -385,14 +385,14 @@ public void UploadPostTransformErrorValidationWorks() } [Fact] - public void FileCreatedValidationWorks() + public void FileCreateValidationWorks() { - Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::FileCreatedWebhookEvent() + Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::FileCreateEvent() { ID = "id", Type = "file.created", - STAINLESS_FIXME_CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - STAINLESS_FIXME_Data = new() + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() { AITags = [ @@ -460,14 +460,14 @@ public void FileCreatedValidationWorks() } [Fact] - public void FileUpdatedValidationWorks() + public void FileUpdateValidationWorks() { - Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::FileUpdatedWebhookEvent() + Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::FileUpdateEvent() { ID = "id", Type = "file.updated", - STAINLESS_FIXME_CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - STAINLESS_FIXME_Data = new() + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() { AITags = [ @@ -535,27 +535,27 @@ public void FileUpdatedValidationWorks() } [Fact] - public void FileDeletedValidationWorks() + public void FileDeleteValidationWorks() { - Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::FileDeletedWebhookEvent() + Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::FileDeleteEvent() { ID = "id", Type = "file.deleted", - STAINLESS_FIXME_CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - STAINLESS_FIXME_Data = new("fileId"), + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new("fileId"), }; value.Validate(); } [Fact] - public void FileVersionCreatedValidationWorks() + public void FileVersionCreateValidationWorks() { - Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::FileVersionCreatedWebhookEvent() + Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::FileVersionCreateEvent() { ID = "id", Type = "file-version.created", - STAINLESS_FIXME_CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - STAINLESS_FIXME_Data = new() + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() { AITags = [ @@ -623,18 +623,14 @@ public void FileVersionCreatedValidationWorks() } [Fact] - public void FileVersionDeletedValidationWorks() + public void FileVersionDeleteValidationWorks() { - Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::FileVersionDeletedWebhookEvent() + Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::FileVersionDeleteEvent() { ID = "id", Type = "file-version.deleted", - STAINLESS_FIXME_CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - STAINLESS_FIXME_Data = new() - { - STAINLESS_FIXME_FileID = "fileId", - STAINLESS_FIXME_VersionID = "versionId", - }, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() { FileID = "fileId", VersionID = "versionId" }, }; value.Validate(); } @@ -1057,14 +1053,14 @@ public void UploadPostTransformErrorSerializationRoundtripWorks() } [Fact] - public void FileCreatedSerializationRoundtripWorks() + public void FileCreateSerializationRoundtripWorks() { - Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::FileCreatedWebhookEvent() + Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::FileCreateEvent() { ID = "id", Type = "file.created", - STAINLESS_FIXME_CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - STAINLESS_FIXME_Data = new() + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() { AITags = [ @@ -1138,14 +1134,14 @@ public void FileCreatedSerializationRoundtripWorks() } [Fact] - public void FileUpdatedSerializationRoundtripWorks() + public void FileUpdateSerializationRoundtripWorks() { - Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::FileUpdatedWebhookEvent() + Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::FileUpdateEvent() { ID = "id", Type = "file.updated", - STAINLESS_FIXME_CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - STAINLESS_FIXME_Data = new() + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() { AITags = [ @@ -1219,14 +1215,14 @@ public void FileUpdatedSerializationRoundtripWorks() } [Fact] - public void FileDeletedSerializationRoundtripWorks() + public void FileDeleteSerializationRoundtripWorks() { - Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::FileDeletedWebhookEvent() + Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::FileDeleteEvent() { ID = "id", Type = "file.deleted", - STAINLESS_FIXME_CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - STAINLESS_FIXME_Data = new("fileId"), + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new("fileId"), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize( @@ -1238,14 +1234,14 @@ public void FileDeletedSerializationRoundtripWorks() } [Fact] - public void FileVersionCreatedSerializationRoundtripWorks() + public void FileVersionCreateSerializationRoundtripWorks() { - Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::FileVersionCreatedWebhookEvent() + Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::FileVersionCreateEvent() { ID = "id", Type = "file-version.created", - STAINLESS_FIXME_CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - STAINLESS_FIXME_Data = new() + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() { AITags = [ @@ -1319,18 +1315,14 @@ public void FileVersionCreatedSerializationRoundtripWorks() } [Fact] - public void FileVersionDeletedSerializationRoundtripWorks() + public void FileVersionDeleteSerializationRoundtripWorks() { - Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::FileVersionDeletedWebhookEvent() + Webhooks::UnsafeUnwrapWebhookEvent value = new Webhooks::FileVersionDeleteEvent() { ID = "id", Type = "file-version.deleted", - STAINLESS_FIXME_CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - STAINLESS_FIXME_Data = new() - { - STAINLESS_FIXME_FileID = "fileId", - STAINLESS_FIXME_VersionID = "versionId", - }, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() { FileID = "fileId", VersionID = "versionId" }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize( diff --git a/src/ImageKit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs b/src/ImageKit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs index 4f13861b..9a2423c5 100644 --- a/src/ImageKit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs +++ b/src/ImageKit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs @@ -385,14 +385,14 @@ public void UploadPostTransformErrorValidationWorks() } [Fact] - public void FileCreatedValidationWorks() + public void FileCreateValidationWorks() { - Webhooks::UnwrapWebhookEvent value = new Webhooks::FileCreatedWebhookEvent() + Webhooks::UnwrapWebhookEvent value = new Webhooks::FileCreateEvent() { ID = "id", Type = "file.created", - STAINLESS_FIXME_CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - STAINLESS_FIXME_Data = new() + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() { AITags = [ @@ -460,14 +460,14 @@ public void FileCreatedValidationWorks() } [Fact] - public void FileUpdatedValidationWorks() + public void FileUpdateValidationWorks() { - Webhooks::UnwrapWebhookEvent value = new Webhooks::FileUpdatedWebhookEvent() + Webhooks::UnwrapWebhookEvent value = new Webhooks::FileUpdateEvent() { ID = "id", Type = "file.updated", - STAINLESS_FIXME_CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - STAINLESS_FIXME_Data = new() + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() { AITags = [ @@ -535,27 +535,27 @@ public void FileUpdatedValidationWorks() } [Fact] - public void FileDeletedValidationWorks() + public void FileDeleteValidationWorks() { - Webhooks::UnwrapWebhookEvent value = new Webhooks::FileDeletedWebhookEvent() + Webhooks::UnwrapWebhookEvent value = new Webhooks::FileDeleteEvent() { ID = "id", Type = "file.deleted", - STAINLESS_FIXME_CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - STAINLESS_FIXME_Data = new("fileId"), + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new("fileId"), }; value.Validate(); } [Fact] - public void FileVersionCreatedValidationWorks() + public void FileVersionCreateValidationWorks() { - Webhooks::UnwrapWebhookEvent value = new Webhooks::FileVersionCreatedWebhookEvent() + Webhooks::UnwrapWebhookEvent value = new Webhooks::FileVersionCreateEvent() { ID = "id", Type = "file-version.created", - STAINLESS_FIXME_CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - STAINLESS_FIXME_Data = new() + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() { AITags = [ @@ -623,18 +623,14 @@ public void FileVersionCreatedValidationWorks() } [Fact] - public void FileVersionDeletedValidationWorks() + public void FileVersionDeleteValidationWorks() { - Webhooks::UnwrapWebhookEvent value = new Webhooks::FileVersionDeletedWebhookEvent() + Webhooks::UnwrapWebhookEvent value = new Webhooks::FileVersionDeleteEvent() { ID = "id", Type = "file-version.deleted", - STAINLESS_FIXME_CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - STAINLESS_FIXME_Data = new() - { - STAINLESS_FIXME_FileID = "fileId", - STAINLESS_FIXME_VersionID = "versionId", - }, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() { FileID = "fileId", VersionID = "versionId" }, }; value.Validate(); } @@ -1057,14 +1053,14 @@ public void UploadPostTransformErrorSerializationRoundtripWorks() } [Fact] - public void FileCreatedSerializationRoundtripWorks() + public void FileCreateSerializationRoundtripWorks() { - Webhooks::UnwrapWebhookEvent value = new Webhooks::FileCreatedWebhookEvent() + Webhooks::UnwrapWebhookEvent value = new Webhooks::FileCreateEvent() { ID = "id", Type = "file.created", - STAINLESS_FIXME_CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - STAINLESS_FIXME_Data = new() + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() { AITags = [ @@ -1138,14 +1134,14 @@ public void FileCreatedSerializationRoundtripWorks() } [Fact] - public void FileUpdatedSerializationRoundtripWorks() + public void FileUpdateSerializationRoundtripWorks() { - Webhooks::UnwrapWebhookEvent value = new Webhooks::FileUpdatedWebhookEvent() + Webhooks::UnwrapWebhookEvent value = new Webhooks::FileUpdateEvent() { ID = "id", Type = "file.updated", - STAINLESS_FIXME_CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - STAINLESS_FIXME_Data = new() + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() { AITags = [ @@ -1219,14 +1215,14 @@ public void FileUpdatedSerializationRoundtripWorks() } [Fact] - public void FileDeletedSerializationRoundtripWorks() + public void FileDeleteSerializationRoundtripWorks() { - Webhooks::UnwrapWebhookEvent value = new Webhooks::FileDeletedWebhookEvent() + Webhooks::UnwrapWebhookEvent value = new Webhooks::FileDeleteEvent() { ID = "id", Type = "file.deleted", - STAINLESS_FIXME_CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - STAINLESS_FIXME_Data = new("fileId"), + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new("fileId"), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize( @@ -1238,14 +1234,14 @@ public void FileDeletedSerializationRoundtripWorks() } [Fact] - public void FileVersionCreatedSerializationRoundtripWorks() + public void FileVersionCreateSerializationRoundtripWorks() { - Webhooks::UnwrapWebhookEvent value = new Webhooks::FileVersionCreatedWebhookEvent() + Webhooks::UnwrapWebhookEvent value = new Webhooks::FileVersionCreateEvent() { ID = "id", Type = "file-version.created", - STAINLESS_FIXME_CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - STAINLESS_FIXME_Data = new() + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() { AITags = [ @@ -1319,18 +1315,14 @@ public void FileVersionCreatedSerializationRoundtripWorks() } [Fact] - public void FileVersionDeletedSerializationRoundtripWorks() + public void FileVersionDeleteSerializationRoundtripWorks() { - Webhooks::UnwrapWebhookEvent value = new Webhooks::FileVersionDeletedWebhookEvent() + Webhooks::UnwrapWebhookEvent value = new Webhooks::FileVersionDeleteEvent() { ID = "id", Type = "file-version.deleted", - STAINLESS_FIXME_CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - STAINLESS_FIXME_Data = new() - { - STAINLESS_FIXME_FileID = "fileId", - STAINLESS_FIXME_VersionID = "versionId", - }, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Data = new() { FileID = "fileId", VersionID = "versionId" }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize( diff --git a/src/ImageKit.Tests/Models/Webhooks/UploadPostTransformErrorEventTest.cs b/src/ImageKit.Tests/Models/Webhooks/UploadPostTransformErrorEventTest.cs index bbdc932a..43d93c31 100644 --- a/src/ImageKit.Tests/Models/Webhooks/UploadPostTransformErrorEventTest.cs +++ b/src/ImageKit.Tests/Models/Webhooks/UploadPostTransformErrorEventTest.cs @@ -39,7 +39,7 @@ public void FieldRoundtrip_Works() string expectedID = "id"; string expectedType = "type"; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - Webhooks::Data expectedData = new() + Webhooks::UploadPostTransformErrorEventIntersectionMember1Data expectedData = new() { FileID = "fileId", Name = "name", @@ -140,7 +140,7 @@ public void FieldRoundtripThroughSerialization_Works() string expectedID = "id"; string expectedType = "type"; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - Webhooks::Data expectedData = new() + Webhooks::UploadPostTransformErrorEventIntersectionMember1Data expectedData = new() { FileID = "fileId", Name = "name", @@ -231,12 +231,12 @@ public void CopyConstructor_Works() } } -public class IntersectionMember1Test : TestBase +public class UploadPostTransformErrorEventIntersectionMember1Test : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Webhooks::IntersectionMember1 + var model = new Webhooks::UploadPostTransformErrorEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -260,7 +260,7 @@ public void FieldRoundtrip_Works() }; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - Webhooks::Data expectedData = new() + Webhooks::UploadPostTransformErrorEventIntersectionMember1Data expectedData = new() { FileID = "fileId", Name = "name", @@ -289,7 +289,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Webhooks::IntersectionMember1 + var model = new Webhooks::UploadPostTransformErrorEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -313,10 +313,11 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -324,7 +325,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Webhooks::IntersectionMember1 + var model = new Webhooks::UploadPostTransformErrorEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -348,14 +349,15 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.NotNull(deserialized); DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - Webhooks::Data expectedData = new() + Webhooks::UploadPostTransformErrorEventIntersectionMember1Data expectedData = new() { FileID = "fileId", Name = "name", @@ -384,7 +386,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Webhooks::IntersectionMember1 + var model = new Webhooks::UploadPostTransformErrorEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -413,7 +415,7 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new Webhooks::IntersectionMember1 + var model = new Webhooks::UploadPostTransformErrorEventIntersectionMember1 { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -436,18 +438,18 @@ public void CopyConstructor_Works() }, }; - Webhooks::IntersectionMember1 copied = new(model); + Webhooks::UploadPostTransformErrorEventIntersectionMember1 copied = new(model); Assert.Equal(model, copied); } } -public class DataTest : TestBase +public class UploadPostTransformErrorEventIntersectionMember1DataTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Webhooks::Data + var model = new Webhooks::UploadPostTransformErrorEventIntersectionMember1Data { FileID = "fileId", Name = "name", @@ -474,7 +476,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Webhooks::Data + var model = new Webhooks::UploadPostTransformErrorEventIntersectionMember1Data { FileID = "fileId", Name = "name", @@ -484,10 +486,11 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -495,7 +498,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Webhooks::Data + var model = new Webhooks::UploadPostTransformErrorEventIntersectionMember1Data { FileID = "fileId", Name = "name", @@ -505,10 +508,11 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.NotNull(deserialized); string expectedFileID = "fileId"; @@ -529,7 +533,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Webhooks::Data + var model = new Webhooks::UploadPostTransformErrorEventIntersectionMember1Data { FileID = "fileId", Name = "name", @@ -544,7 +548,7 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new Webhooks::Data + var model = new Webhooks::UploadPostTransformErrorEventIntersectionMember1Data { FileID = "fileId", Name = "name", @@ -553,7 +557,7 @@ public void CopyConstructor_Works() Url = "https://example.com", }; - Webhooks::Data copied = new(model); + Webhooks::UploadPostTransformErrorEventIntersectionMember1Data copied = new(model); Assert.Equal(model, copied); } diff --git a/src/ImageKit/Models/Webhooks/FileCreatedWebhookEvent.cs b/src/ImageKit/Models/Webhooks/FileCreateEvent.cs similarity index 63% rename from src/ImageKit/Models/Webhooks/FileCreatedWebhookEvent.cs rename to src/ImageKit/Models/Webhooks/FileCreateEvent.cs index 8a658aac..d912bd4f 100644 --- a/src/ImageKit/Models/Webhooks/FileCreatedWebhookEvent.cs +++ b/src/ImageKit/Models/Webhooks/FileCreateEvent.cs @@ -13,8 +13,8 @@ namespace ImageKit.Models.Webhooks; /// /// Triggered when a file is created. /// -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class FileCreatedWebhookEvent : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class FileCreateEvent : JsonModel { /// /// Unique identifier for the event. @@ -68,9 +68,8 @@ public required File Data init { this._rawData.Set("data", value); } } - public static implicit operator BaseWebhookEvent( - FileCreatedWebhookEvent fileCreatedWebhookEvent - ) => new() { ID = fileCreatedWebhookEvent.ID, Type = fileCreatedWebhookEvent.Type }; + public static implicit operator BaseWebhookEvent(FileCreateEvent fileCreateEvent) => + new() { ID = fileCreateEvent.ID, Type = fileCreateEvent.Type }; /// public override void Validate() @@ -81,42 +80,39 @@ public override void Validate() this.Data.Validate(); } - public FileCreatedWebhookEvent() { } + public FileCreateEvent() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public FileCreatedWebhookEvent(FileCreatedWebhookEvent fileCreatedWebhookEvent) - : base(fileCreatedWebhookEvent) { } + public FileCreateEvent(FileCreateEvent fileCreateEvent) + : base(fileCreateEvent) { } #pragma warning restore CS8618 - public FileCreatedWebhookEvent(IReadOnlyDictionary rawData) + public FileCreateEvent(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - FileCreatedWebhookEvent(FrozenDictionary rawData) + FileCreateEvent(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static FileCreatedWebhookEvent FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static FileCreateEvent FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class FileCreatedWebhookEventFromRaw : IFromRawJson +class FileCreateEventFromRaw : IFromRawJson { /// - public FileCreatedWebhookEvent FromRawUnchecked( - IReadOnlyDictionary rawData - ) => FileCreatedWebhookEvent.FromRawUnchecked(rawData); + public FileCreateEvent FromRawUnchecked(IReadOnlyDictionary rawData) => + FileCreateEvent.FromRawUnchecked(rawData); } /// @@ -124,11 +120,11 @@ IReadOnlyDictionary rawData /// [JsonConverter( typeof(JsonModelConverter< - FileCreatedWebhookEventIntersectionMember1, - FileCreatedWebhookEventIntersectionMember1FromRaw + global::ImageKit.Models.Webhooks.IntersectionMember1, + global::ImageKit.Models.Webhooks.IntersectionMember1FromRaw >) )] -public sealed record class FileCreatedWebhookEventIntersectionMember1 : JsonModel +public sealed record class IntersectionMember1 : JsonModel { /// /// Timestamp of when the event occurred in ISO8601 format. @@ -180,22 +176,20 @@ public override void Validate() } } - public FileCreatedWebhookEventIntersectionMember1() + public IntersectionMember1() { this.Type = JsonSerializer.SerializeToElement("file.created"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public FileCreatedWebhookEventIntersectionMember1( - FileCreatedWebhookEventIntersectionMember1 fileCreatedWebhookEventIntersectionMember1 + public IntersectionMember1( + global::ImageKit.Models.Webhooks.IntersectionMember1 intersectionMember1 ) - : base(fileCreatedWebhookEventIntersectionMember1) { } + : base(intersectionMember1) { } #pragma warning restore CS8618 - public FileCreatedWebhookEventIntersectionMember1( - IReadOnlyDictionary rawData - ) + public IntersectionMember1(IReadOnlyDictionary rawData) { this._rawData = new(rawData); @@ -204,14 +198,14 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - FileCreatedWebhookEventIntersectionMember1(FrozenDictionary rawData) + IntersectionMember1(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static FileCreatedWebhookEventIntersectionMember1 FromRawUnchecked( + /// + public static global::ImageKit.Models.Webhooks.IntersectionMember1 FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -219,11 +213,11 @@ IReadOnlyDictionary rawData } } -class FileCreatedWebhookEventIntersectionMember1FromRaw - : IFromRawJson +class IntersectionMember1FromRaw + : IFromRawJson { /// - public FileCreatedWebhookEventIntersectionMember1 FromRawUnchecked( + public global::ImageKit.Models.Webhooks.IntersectionMember1 FromRawUnchecked( IReadOnlyDictionary rawData - ) => FileCreatedWebhookEventIntersectionMember1.FromRawUnchecked(rawData); + ) => global::ImageKit.Models.Webhooks.IntersectionMember1.FromRawUnchecked(rawData); } diff --git a/src/ImageKit/Models/Webhooks/FileDeletedWebhookEvent.cs b/src/ImageKit/Models/Webhooks/FileDeleteEvent.cs similarity index 52% rename from src/ImageKit/Models/Webhooks/FileDeletedWebhookEvent.cs rename to src/ImageKit/Models/Webhooks/FileDeleteEvent.cs index b8d7255e..625fbd82 100644 --- a/src/ImageKit/Models/Webhooks/FileDeletedWebhookEvent.cs +++ b/src/ImageKit/Models/Webhooks/FileDeleteEvent.cs @@ -12,8 +12,8 @@ namespace ImageKit.Models.Webhooks; /// /// Triggered when a file is deleted. /// -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class FileDeletedWebhookEvent : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class FileDeleteEvent : JsonModel { /// /// Unique identifier for the event. @@ -54,21 +54,18 @@ public required DateTimeOffset CreatedAt init { this._rawData.Set("created_at", value); } } - public required FileDeletedWebhookEventIntersectionMember1Data Data + public required Data Data { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "data" - ); + return this._rawData.GetNotNullClass("data"); } init { this._rawData.Set("data", value); } } - public static implicit operator BaseWebhookEvent( - FileDeletedWebhookEvent fileDeletedWebhookEvent - ) => new() { ID = fileDeletedWebhookEvent.ID, Type = fileDeletedWebhookEvent.Type }; + public static implicit operator BaseWebhookEvent(FileDeleteEvent fileDeleteEvent) => + new() { ID = fileDeleteEvent.ID, Type = fileDeleteEvent.Type }; /// public override void Validate() @@ -79,42 +76,39 @@ public override void Validate() this.Data.Validate(); } - public FileDeletedWebhookEvent() { } + public FileDeleteEvent() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public FileDeletedWebhookEvent(FileDeletedWebhookEvent fileDeletedWebhookEvent) - : base(fileDeletedWebhookEvent) { } + public FileDeleteEvent(FileDeleteEvent fileDeleteEvent) + : base(fileDeleteEvent) { } #pragma warning restore CS8618 - public FileDeletedWebhookEvent(IReadOnlyDictionary rawData) + public FileDeleteEvent(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - FileDeletedWebhookEvent(FrozenDictionary rawData) + FileDeleteEvent(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static FileDeletedWebhookEvent FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static FileDeleteEvent FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class FileDeletedWebhookEventFromRaw : IFromRawJson +class FileDeleteEventFromRaw : IFromRawJson { /// - public FileDeletedWebhookEvent FromRawUnchecked( - IReadOnlyDictionary rawData - ) => FileDeletedWebhookEvent.FromRawUnchecked(rawData); + public FileDeleteEvent FromRawUnchecked(IReadOnlyDictionary rawData) => + FileDeleteEvent.FromRawUnchecked(rawData); } /// @@ -122,11 +116,11 @@ IReadOnlyDictionary rawData /// [JsonConverter( typeof(JsonModelConverter< - FileDeletedWebhookEventIntersectionMember1, - FileDeletedWebhookEventIntersectionMember1FromRaw + FileDeleteEventIntersectionMember1, + FileDeleteEventIntersectionMember1FromRaw >) )] -public sealed record class FileDeletedWebhookEventIntersectionMember1 : JsonModel +public sealed record class FileDeleteEventIntersectionMember1 : JsonModel { /// /// Timestamp of when the event occurred in ISO8601 format. @@ -141,14 +135,12 @@ public required DateTimeOffset CreatedAt init { this._rawData.Set("created_at", value); } } - public required FileDeletedWebhookEventIntersectionMember1Data Data + public required Data Data { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "data" - ); + return this._rawData.GetNotNullClass("data"); } init { this._rawData.Set("data", value); } } @@ -177,22 +169,20 @@ public override void Validate() } } - public FileDeletedWebhookEventIntersectionMember1() + public FileDeleteEventIntersectionMember1() { this.Type = JsonSerializer.SerializeToElement("file.deleted"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public FileDeletedWebhookEventIntersectionMember1( - FileDeletedWebhookEventIntersectionMember1 fileDeletedWebhookEventIntersectionMember1 + public FileDeleteEventIntersectionMember1( + FileDeleteEventIntersectionMember1 fileDeleteEventIntersectionMember1 ) - : base(fileDeletedWebhookEventIntersectionMember1) { } + : base(fileDeleteEventIntersectionMember1) { } #pragma warning restore CS8618 - public FileDeletedWebhookEventIntersectionMember1( - IReadOnlyDictionary rawData - ) + public FileDeleteEventIntersectionMember1(IReadOnlyDictionary rawData) { this._rawData = new(rawData); @@ -201,14 +191,14 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - FileDeletedWebhookEventIntersectionMember1(FrozenDictionary rawData) + FileDeleteEventIntersectionMember1(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static FileDeletedWebhookEventIntersectionMember1 FromRawUnchecked( + /// + public static FileDeleteEventIntersectionMember1 FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -216,22 +206,16 @@ IReadOnlyDictionary rawData } } -class FileDeletedWebhookEventIntersectionMember1FromRaw - : IFromRawJson +class FileDeleteEventIntersectionMember1FromRaw : IFromRawJson { /// - public FileDeletedWebhookEventIntersectionMember1 FromRawUnchecked( + public FileDeleteEventIntersectionMember1 FromRawUnchecked( IReadOnlyDictionary rawData - ) => FileDeletedWebhookEventIntersectionMember1.FromRawUnchecked(rawData); + ) => FileDeleteEventIntersectionMember1.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(JsonModelConverter< - FileDeletedWebhookEventIntersectionMember1Data, - FileDeletedWebhookEventIntersectionMember1DataFromRaw - >) -)] -public sealed record class FileDeletedWebhookEventIntersectionMember1Data : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Data : JsonModel { /// /// The unique `fileId` of the deleted file. @@ -252,52 +236,44 @@ public override void Validate() _ = this.FileID; } - public FileDeletedWebhookEventIntersectionMember1Data() { } + public Data() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public FileDeletedWebhookEventIntersectionMember1Data( - FileDeletedWebhookEventIntersectionMember1Data fileDeletedWebhookEventIntersectionMember1Data - ) - : base(fileDeletedWebhookEventIntersectionMember1Data) { } + public Data(Data data) + : base(data) { } #pragma warning restore CS8618 - public FileDeletedWebhookEventIntersectionMember1Data( - IReadOnlyDictionary rawData - ) + public Data(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - FileDeletedWebhookEventIntersectionMember1Data(FrozenDictionary rawData) + Data(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static FileDeletedWebhookEventIntersectionMember1Data FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Data FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } [SetsRequiredMembers] - public FileDeletedWebhookEventIntersectionMember1Data(string fileID) + public Data(string fileID) : this() { this.FileID = fileID; } } -class FileDeletedWebhookEventIntersectionMember1DataFromRaw - : IFromRawJson +class DataFromRaw : IFromRawJson { /// - public FileDeletedWebhookEventIntersectionMember1Data FromRawUnchecked( - IReadOnlyDictionary rawData - ) => FileDeletedWebhookEventIntersectionMember1Data.FromRawUnchecked(rawData); + public Data FromRawUnchecked(IReadOnlyDictionary rawData) => + Data.FromRawUnchecked(rawData); } diff --git a/src/ImageKit/Models/Webhooks/FileUpdatedWebhookEvent.cs b/src/ImageKit/Models/Webhooks/FileUpdateEvent.cs similarity index 63% rename from src/ImageKit/Models/Webhooks/FileUpdatedWebhookEvent.cs rename to src/ImageKit/Models/Webhooks/FileUpdateEvent.cs index 5004025e..20691c46 100644 --- a/src/ImageKit/Models/Webhooks/FileUpdatedWebhookEvent.cs +++ b/src/ImageKit/Models/Webhooks/FileUpdateEvent.cs @@ -13,8 +13,8 @@ namespace ImageKit.Models.Webhooks; /// /// Triggered when a file is updated. /// -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class FileUpdatedWebhookEvent : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class FileUpdateEvent : JsonModel { /// /// Unique identifier for the event. @@ -68,9 +68,8 @@ public required File Data init { this._rawData.Set("data", value); } } - public static implicit operator BaseWebhookEvent( - FileUpdatedWebhookEvent fileUpdatedWebhookEvent - ) => new() { ID = fileUpdatedWebhookEvent.ID, Type = fileUpdatedWebhookEvent.Type }; + public static implicit operator BaseWebhookEvent(FileUpdateEvent fileUpdateEvent) => + new() { ID = fileUpdateEvent.ID, Type = fileUpdateEvent.Type }; /// public override void Validate() @@ -81,42 +80,39 @@ public override void Validate() this.Data.Validate(); } - public FileUpdatedWebhookEvent() { } + public FileUpdateEvent() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public FileUpdatedWebhookEvent(FileUpdatedWebhookEvent fileUpdatedWebhookEvent) - : base(fileUpdatedWebhookEvent) { } + public FileUpdateEvent(FileUpdateEvent fileUpdateEvent) + : base(fileUpdateEvent) { } #pragma warning restore CS8618 - public FileUpdatedWebhookEvent(IReadOnlyDictionary rawData) + public FileUpdateEvent(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - FileUpdatedWebhookEvent(FrozenDictionary rawData) + FileUpdateEvent(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static FileUpdatedWebhookEvent FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static FileUpdateEvent FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class FileUpdatedWebhookEventFromRaw : IFromRawJson +class FileUpdateEventFromRaw : IFromRawJson { /// - public FileUpdatedWebhookEvent FromRawUnchecked( - IReadOnlyDictionary rawData - ) => FileUpdatedWebhookEvent.FromRawUnchecked(rawData); + public FileUpdateEvent FromRawUnchecked(IReadOnlyDictionary rawData) => + FileUpdateEvent.FromRawUnchecked(rawData); } /// @@ -124,11 +120,11 @@ IReadOnlyDictionary rawData /// [JsonConverter( typeof(JsonModelConverter< - FileUpdatedWebhookEventIntersectionMember1, - FileUpdatedWebhookEventIntersectionMember1FromRaw + FileUpdateEventIntersectionMember1, + FileUpdateEventIntersectionMember1FromRaw >) )] -public sealed record class FileUpdatedWebhookEventIntersectionMember1 : JsonModel +public sealed record class FileUpdateEventIntersectionMember1 : JsonModel { /// /// Timestamp of when the event occurred in ISO8601 format. @@ -180,22 +176,20 @@ public override void Validate() } } - public FileUpdatedWebhookEventIntersectionMember1() + public FileUpdateEventIntersectionMember1() { this.Type = JsonSerializer.SerializeToElement("file.updated"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public FileUpdatedWebhookEventIntersectionMember1( - FileUpdatedWebhookEventIntersectionMember1 fileUpdatedWebhookEventIntersectionMember1 + public FileUpdateEventIntersectionMember1( + FileUpdateEventIntersectionMember1 fileUpdateEventIntersectionMember1 ) - : base(fileUpdatedWebhookEventIntersectionMember1) { } + : base(fileUpdateEventIntersectionMember1) { } #pragma warning restore CS8618 - public FileUpdatedWebhookEventIntersectionMember1( - IReadOnlyDictionary rawData - ) + public FileUpdateEventIntersectionMember1(IReadOnlyDictionary rawData) { this._rawData = new(rawData); @@ -204,14 +198,14 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - FileUpdatedWebhookEventIntersectionMember1(FrozenDictionary rawData) + FileUpdateEventIntersectionMember1(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static FileUpdatedWebhookEventIntersectionMember1 FromRawUnchecked( + /// + public static FileUpdateEventIntersectionMember1 FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -219,11 +213,10 @@ IReadOnlyDictionary rawData } } -class FileUpdatedWebhookEventIntersectionMember1FromRaw - : IFromRawJson +class FileUpdateEventIntersectionMember1FromRaw : IFromRawJson { /// - public FileUpdatedWebhookEventIntersectionMember1 FromRawUnchecked( + public FileUpdateEventIntersectionMember1 FromRawUnchecked( IReadOnlyDictionary rawData - ) => FileUpdatedWebhookEventIntersectionMember1.FromRawUnchecked(rawData); + ) => FileUpdateEventIntersectionMember1.FromRawUnchecked(rawData); } diff --git a/src/ImageKit/Models/Webhooks/FileVersionCreatedWebhookEvent.cs b/src/ImageKit/Models/Webhooks/FileVersionCreateEvent.cs similarity index 64% rename from src/ImageKit/Models/Webhooks/FileVersionCreatedWebhookEvent.cs rename to src/ImageKit/Models/Webhooks/FileVersionCreateEvent.cs index bb2f1134..4b935d9e 100644 --- a/src/ImageKit/Models/Webhooks/FileVersionCreatedWebhookEvent.cs +++ b/src/ImageKit/Models/Webhooks/FileVersionCreateEvent.cs @@ -13,13 +13,8 @@ namespace ImageKit.Models.Webhooks; /// /// Triggered when a file version is created. /// -[JsonConverter( - typeof(JsonModelConverter< - FileVersionCreatedWebhookEvent, - FileVersionCreatedWebhookEventFromRaw - >) -)] -public sealed record class FileVersionCreatedWebhookEvent : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class FileVersionCreateEvent : JsonModel { /// /// Unique identifier for the event. @@ -74,13 +69,8 @@ public required File Data } public static implicit operator BaseWebhookEvent( - FileVersionCreatedWebhookEvent fileVersionCreatedWebhookEvent - ) => - new() - { - ID = fileVersionCreatedWebhookEvent.ID, - Type = fileVersionCreatedWebhookEvent.Type, - }; + FileVersionCreateEvent fileVersionCreateEvent + ) => new() { ID = fileVersionCreateEvent.ID, Type = fileVersionCreateEvent.Type }; /// public override void Validate() @@ -91,31 +81,29 @@ public override void Validate() this.Data.Validate(); } - public FileVersionCreatedWebhookEvent() { } + public FileVersionCreateEvent() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public FileVersionCreatedWebhookEvent( - FileVersionCreatedWebhookEvent fileVersionCreatedWebhookEvent - ) - : base(fileVersionCreatedWebhookEvent) { } + public FileVersionCreateEvent(FileVersionCreateEvent fileVersionCreateEvent) + : base(fileVersionCreateEvent) { } #pragma warning restore CS8618 - public FileVersionCreatedWebhookEvent(IReadOnlyDictionary rawData) + public FileVersionCreateEvent(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - FileVersionCreatedWebhookEvent(FrozenDictionary rawData) + FileVersionCreateEvent(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static FileVersionCreatedWebhookEvent FromRawUnchecked( + /// + public static FileVersionCreateEvent FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -123,12 +111,12 @@ IReadOnlyDictionary rawData } } -class FileVersionCreatedWebhookEventFromRaw : IFromRawJson +class FileVersionCreateEventFromRaw : IFromRawJson { /// - public FileVersionCreatedWebhookEvent FromRawUnchecked( + public FileVersionCreateEvent FromRawUnchecked( IReadOnlyDictionary rawData - ) => FileVersionCreatedWebhookEvent.FromRawUnchecked(rawData); + ) => FileVersionCreateEvent.FromRawUnchecked(rawData); } /// @@ -136,11 +124,11 @@ IReadOnlyDictionary rawData /// [JsonConverter( typeof(JsonModelConverter< - FileVersionCreatedWebhookEventIntersectionMember1, - FileVersionCreatedWebhookEventIntersectionMember1FromRaw + FileVersionCreateEventIntersectionMember1, + FileVersionCreateEventIntersectionMember1FromRaw >) )] -public sealed record class FileVersionCreatedWebhookEventIntersectionMember1 : JsonModel +public sealed record class FileVersionCreateEventIntersectionMember1 : JsonModel { /// /// Timestamp of when the event occurred in ISO8601 format. @@ -197,20 +185,20 @@ public override void Validate() } } - public FileVersionCreatedWebhookEventIntersectionMember1() + public FileVersionCreateEventIntersectionMember1() { this.Type = JsonSerializer.SerializeToElement("file-version.created"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public FileVersionCreatedWebhookEventIntersectionMember1( - FileVersionCreatedWebhookEventIntersectionMember1 fileVersionCreatedWebhookEventIntersectionMember1 + public FileVersionCreateEventIntersectionMember1( + FileVersionCreateEventIntersectionMember1 fileVersionCreateEventIntersectionMember1 ) - : base(fileVersionCreatedWebhookEventIntersectionMember1) { } + : base(fileVersionCreateEventIntersectionMember1) { } #pragma warning restore CS8618 - public FileVersionCreatedWebhookEventIntersectionMember1( + public FileVersionCreateEventIntersectionMember1( IReadOnlyDictionary rawData ) { @@ -221,14 +209,14 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - FileVersionCreatedWebhookEventIntersectionMember1(FrozenDictionary rawData) + FileVersionCreateEventIntersectionMember1(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static FileVersionCreatedWebhookEventIntersectionMember1 FromRawUnchecked( + /// + public static FileVersionCreateEventIntersectionMember1 FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -236,11 +224,11 @@ IReadOnlyDictionary rawData } } -class FileVersionCreatedWebhookEventIntersectionMember1FromRaw - : IFromRawJson +class FileVersionCreateEventIntersectionMember1FromRaw + : IFromRawJson { /// - public FileVersionCreatedWebhookEventIntersectionMember1 FromRawUnchecked( + public FileVersionCreateEventIntersectionMember1 FromRawUnchecked( IReadOnlyDictionary rawData - ) => FileVersionCreatedWebhookEventIntersectionMember1.FromRawUnchecked(rawData); + ) => FileVersionCreateEventIntersectionMember1.FromRawUnchecked(rawData); } diff --git a/src/ImageKit/Models/Webhooks/FileVersionDeletedWebhookEvent.cs b/src/ImageKit/Models/Webhooks/FileVersionDeleteEvent.cs similarity index 58% rename from src/ImageKit/Models/Webhooks/FileVersionDeletedWebhookEvent.cs rename to src/ImageKit/Models/Webhooks/FileVersionDeleteEvent.cs index 72d16eb3..0eca65b3 100644 --- a/src/ImageKit/Models/Webhooks/FileVersionDeletedWebhookEvent.cs +++ b/src/ImageKit/Models/Webhooks/FileVersionDeleteEvent.cs @@ -12,13 +12,8 @@ namespace ImageKit.Models.Webhooks; /// /// Triggered when a file version is deleted. /// -[JsonConverter( - typeof(JsonModelConverter< - FileVersionDeletedWebhookEvent, - FileVersionDeletedWebhookEventFromRaw - >) -)] -public sealed record class FileVersionDeletedWebhookEvent : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class FileVersionDeleteEvent : JsonModel { /// /// Unique identifier for the event. @@ -59,12 +54,12 @@ public required DateTimeOffset CreatedAt init { this._rawData.Set("created_at", value); } } - public required FileVersionDeletedWebhookEventIntersectionMember1Data Data + public required FileVersionDeleteEventIntersectionMember1Data Data { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "data" ); } @@ -72,13 +67,8 @@ public required FileVersionDeletedWebhookEventIntersectionMember1Data Data } public static implicit operator BaseWebhookEvent( - FileVersionDeletedWebhookEvent fileVersionDeletedWebhookEvent - ) => - new() - { - ID = fileVersionDeletedWebhookEvent.ID, - Type = fileVersionDeletedWebhookEvent.Type, - }; + FileVersionDeleteEvent fileVersionDeleteEvent + ) => new() { ID = fileVersionDeleteEvent.ID, Type = fileVersionDeleteEvent.Type }; /// public override void Validate() @@ -89,31 +79,29 @@ public override void Validate() this.Data.Validate(); } - public FileVersionDeletedWebhookEvent() { } + public FileVersionDeleteEvent() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public FileVersionDeletedWebhookEvent( - FileVersionDeletedWebhookEvent fileVersionDeletedWebhookEvent - ) - : base(fileVersionDeletedWebhookEvent) { } + public FileVersionDeleteEvent(FileVersionDeleteEvent fileVersionDeleteEvent) + : base(fileVersionDeleteEvent) { } #pragma warning restore CS8618 - public FileVersionDeletedWebhookEvent(IReadOnlyDictionary rawData) + public FileVersionDeleteEvent(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - FileVersionDeletedWebhookEvent(FrozenDictionary rawData) + FileVersionDeleteEvent(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static FileVersionDeletedWebhookEvent FromRawUnchecked( + /// + public static FileVersionDeleteEvent FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -121,12 +109,12 @@ IReadOnlyDictionary rawData } } -class FileVersionDeletedWebhookEventFromRaw : IFromRawJson +class FileVersionDeleteEventFromRaw : IFromRawJson { /// - public FileVersionDeletedWebhookEvent FromRawUnchecked( + public FileVersionDeleteEvent FromRawUnchecked( IReadOnlyDictionary rawData - ) => FileVersionDeletedWebhookEvent.FromRawUnchecked(rawData); + ) => FileVersionDeleteEvent.FromRawUnchecked(rawData); } /// @@ -134,11 +122,11 @@ IReadOnlyDictionary rawData /// [JsonConverter( typeof(JsonModelConverter< - FileVersionDeletedWebhookEventIntersectionMember1, - FileVersionDeletedWebhookEventIntersectionMember1FromRaw + FileVersionDeleteEventIntersectionMember1, + FileVersionDeleteEventIntersectionMember1FromRaw >) )] -public sealed record class FileVersionDeletedWebhookEventIntersectionMember1 : JsonModel +public sealed record class FileVersionDeleteEventIntersectionMember1 : JsonModel { /// /// Timestamp of when the event occurred in ISO8601 format. @@ -153,12 +141,12 @@ public required DateTimeOffset CreatedAt init { this._rawData.Set("created_at", value); } } - public required FileVersionDeletedWebhookEventIntersectionMember1Data Data + public required FileVersionDeleteEventIntersectionMember1Data Data { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "data" ); } @@ -194,20 +182,20 @@ public override void Validate() } } - public FileVersionDeletedWebhookEventIntersectionMember1() + public FileVersionDeleteEventIntersectionMember1() { this.Type = JsonSerializer.SerializeToElement("file-version.deleted"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public FileVersionDeletedWebhookEventIntersectionMember1( - FileVersionDeletedWebhookEventIntersectionMember1 fileVersionDeletedWebhookEventIntersectionMember1 + public FileVersionDeleteEventIntersectionMember1( + FileVersionDeleteEventIntersectionMember1 fileVersionDeleteEventIntersectionMember1 ) - : base(fileVersionDeletedWebhookEventIntersectionMember1) { } + : base(fileVersionDeleteEventIntersectionMember1) { } #pragma warning restore CS8618 - public FileVersionDeletedWebhookEventIntersectionMember1( + public FileVersionDeleteEventIntersectionMember1( IReadOnlyDictionary rawData ) { @@ -218,14 +206,14 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - FileVersionDeletedWebhookEventIntersectionMember1(FrozenDictionary rawData) + FileVersionDeleteEventIntersectionMember1(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static FileVersionDeletedWebhookEventIntersectionMember1 FromRawUnchecked( + /// + public static FileVersionDeleteEventIntersectionMember1 FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -233,22 +221,22 @@ IReadOnlyDictionary rawData } } -class FileVersionDeletedWebhookEventIntersectionMember1FromRaw - : IFromRawJson +class FileVersionDeleteEventIntersectionMember1FromRaw + : IFromRawJson { /// - public FileVersionDeletedWebhookEventIntersectionMember1 FromRawUnchecked( + public FileVersionDeleteEventIntersectionMember1 FromRawUnchecked( IReadOnlyDictionary rawData - ) => FileVersionDeletedWebhookEventIntersectionMember1.FromRawUnchecked(rawData); + ) => FileVersionDeleteEventIntersectionMember1.FromRawUnchecked(rawData); } [JsonConverter( typeof(JsonModelConverter< - FileVersionDeletedWebhookEventIntersectionMember1Data, - FileVersionDeletedWebhookEventIntersectionMember1DataFromRaw + FileVersionDeleteEventIntersectionMember1Data, + FileVersionDeleteEventIntersectionMember1DataFromRaw >) )] -public sealed record class FileVersionDeletedWebhookEventIntersectionMember1Data : JsonModel +public sealed record class FileVersionDeleteEventIntersectionMember1Data : JsonModel { /// /// The unique `fileId` of the deleted file. @@ -283,17 +271,17 @@ public override void Validate() _ = this.VersionID; } - public FileVersionDeletedWebhookEventIntersectionMember1Data() { } + public FileVersionDeleteEventIntersectionMember1Data() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public FileVersionDeletedWebhookEventIntersectionMember1Data( - FileVersionDeletedWebhookEventIntersectionMember1Data fileVersionDeletedWebhookEventIntersectionMember1Data + public FileVersionDeleteEventIntersectionMember1Data( + FileVersionDeleteEventIntersectionMember1Data fileVersionDeleteEventIntersectionMember1Data ) - : base(fileVersionDeletedWebhookEventIntersectionMember1Data) { } + : base(fileVersionDeleteEventIntersectionMember1Data) { } #pragma warning restore CS8618 - public FileVersionDeletedWebhookEventIntersectionMember1Data( + public FileVersionDeleteEventIntersectionMember1Data( IReadOnlyDictionary rawData ) { @@ -302,16 +290,14 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - FileVersionDeletedWebhookEventIntersectionMember1Data( - FrozenDictionary rawData - ) + FileVersionDeleteEventIntersectionMember1Data(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static FileVersionDeletedWebhookEventIntersectionMember1Data FromRawUnchecked( + /// + public static FileVersionDeleteEventIntersectionMember1Data FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -319,11 +305,11 @@ IReadOnlyDictionary rawData } } -class FileVersionDeletedWebhookEventIntersectionMember1DataFromRaw - : IFromRawJson +class FileVersionDeleteEventIntersectionMember1DataFromRaw + : IFromRawJson { /// - public FileVersionDeletedWebhookEventIntersectionMember1Data FromRawUnchecked( + public FileVersionDeleteEventIntersectionMember1Data FromRawUnchecked( IReadOnlyDictionary rawData - ) => FileVersionDeletedWebhookEventIntersectionMember1Data.FromRawUnchecked(rawData); + ) => FileVersionDeleteEventIntersectionMember1Data.FromRawUnchecked(rawData); } diff --git a/src/ImageKit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs b/src/ImageKit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs index afb9eb6f..856ebd1f 100644 --- a/src/ImageKit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs +++ b/src/ImageKit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs @@ -42,11 +42,11 @@ public string ID uploadPreTransformError: (x) => x.ID, uploadPostTransformSuccess: (x) => x.ID, uploadPostTransformError: (x) => x.ID, - fileCreated: (x) => x.STAINLESS_FIXME_ID, - fileUpdated: (x) => x.STAINLESS_FIXME_ID, - fileDeleted: (x) => x.STAINLESS_FIXME_ID, - fileVersionCreated: (x) => x.STAINLESS_FIXME_ID, - fileVersionDeleted: (x) => x.STAINLESS_FIXME_ID + fileCreate: (x) => x.ID, + fileUpdate: (x) => x.ID, + fileDelete: (x) => x.ID, + fileVersionCreate: (x) => x.ID, + fileVersionDelete: (x) => x.ID ); } } @@ -63,11 +63,11 @@ public string Type uploadPreTransformError: (x) => x.Type, uploadPostTransformSuccess: (x) => x.Type, uploadPostTransformError: (x) => x.Type, - fileCreated: (x) => x.STAINLESS_FIXME_Type, - fileUpdated: (x) => x.STAINLESS_FIXME_Type, - fileDeleted: (x) => x.STAINLESS_FIXME_Type, - fileVersionCreated: (x) => x.STAINLESS_FIXME_Type, - fileVersionDeleted: (x) => x.STAINLESS_FIXME_Type + fileCreate: (x) => x.Type, + fileUpdate: (x) => x.Type, + fileDelete: (x) => x.Type, + fileVersionCreate: (x) => x.Type, + fileVersionDelete: (x) => x.Type ); } } @@ -84,11 +84,11 @@ public string Type uploadPreTransformError: (x) => x.CreatedAt, uploadPostTransformSuccess: (x) => x.CreatedAt, uploadPostTransformError: (x) => x.CreatedAt, - fileCreated: (x) => x.STAINLESS_FIXME_CreatedAt, - fileUpdated: (x) => x.STAINLESS_FIXME_CreatedAt, - fileDeleted: (x) => x.STAINLESS_FIXME_CreatedAt, - fileVersionCreated: (x) => x.STAINLESS_FIXME_CreatedAt, - fileVersionDeleted: (x) => x.STAINLESS_FIXME_CreatedAt + fileCreate: (x) => x.CreatedAt, + fileUpdate: (x) => x.CreatedAt, + fileDelete: (x) => x.CreatedAt, + fileVersionCreate: (x) => x.CreatedAt, + fileVersionDelete: (x) => x.CreatedAt ); } } @@ -153,37 +153,31 @@ public UnsafeUnwrapWebhookEvent( this._element = element; } - public UnsafeUnwrapWebhookEvent(FileCreatedWebhookEvent value, JsonElement? element = null) + public UnsafeUnwrapWebhookEvent(FileCreateEvent value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnsafeUnwrapWebhookEvent(FileUpdatedWebhookEvent value, JsonElement? element = null) + public UnsafeUnwrapWebhookEvent(FileUpdateEvent value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnsafeUnwrapWebhookEvent(FileDeletedWebhookEvent value, JsonElement? element = null) + public UnsafeUnwrapWebhookEvent(FileDeleteEvent value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnsafeUnwrapWebhookEvent( - FileVersionCreatedWebhookEvent value, - JsonElement? element = null - ) + public UnsafeUnwrapWebhookEvent(FileVersionCreateEvent value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnsafeUnwrapWebhookEvent( - FileVersionDeletedWebhookEvent value, - JsonElement? element = null - ) + public UnsafeUnwrapWebhookEvent(FileVersionDeleteEvent value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -357,110 +351,106 @@ public bool TryPickUploadPostTransformError( /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickFileCreated(out var value)) { - /// // `value` is of type `FileCreatedWebhookEvent` + /// if (instance.TryPickFileCreate(out var value)) { + /// // `value` is of type `FileCreateEvent` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickFileCreated([NotNullWhen(true)] out FileCreatedWebhookEvent? value) + public bool TryPickFileCreate([NotNullWhen(true)] out FileCreateEvent? value) { - value = this.Value as FileCreatedWebhookEvent; + value = this.Value as FileCreateEvent; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickFileUpdated(out var value)) { - /// // `value` is of type `FileUpdatedWebhookEvent` + /// if (instance.TryPickFileUpdate(out var value)) { + /// // `value` is of type `FileUpdateEvent` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickFileUpdated([NotNullWhen(true)] out FileUpdatedWebhookEvent? value) + public bool TryPickFileUpdate([NotNullWhen(true)] out FileUpdateEvent? value) { - value = this.Value as FileUpdatedWebhookEvent; + value = this.Value as FileUpdateEvent; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickFileDeleted(out var value)) { - /// // `value` is of type `FileDeletedWebhookEvent` + /// if (instance.TryPickFileDelete(out var value)) { + /// // `value` is of type `FileDeleteEvent` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickFileDeleted([NotNullWhen(true)] out FileDeletedWebhookEvent? value) + public bool TryPickFileDelete([NotNullWhen(true)] out FileDeleteEvent? value) { - value = this.Value as FileDeletedWebhookEvent; + value = this.Value as FileDeleteEvent; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickFileVersionCreated(out var value)) { - /// // `value` is of type `FileVersionCreatedWebhookEvent` + /// if (instance.TryPickFileVersionCreate(out var value)) { + /// // `value` is of type `FileVersionCreateEvent` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickFileVersionCreated( - [NotNullWhen(true)] out FileVersionCreatedWebhookEvent? value - ) + public bool TryPickFileVersionCreate([NotNullWhen(true)] out FileVersionCreateEvent? value) { - value = this.Value as FileVersionCreatedWebhookEvent; + value = this.Value as FileVersionCreateEvent; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickFileVersionDeleted(out var value)) { - /// // `value` is of type `FileVersionDeletedWebhookEvent` + /// if (instance.TryPickFileVersionDelete(out var value)) { + /// // `value` is of type `FileVersionDeleteEvent` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickFileVersionDeleted( - [NotNullWhen(true)] out FileVersionDeletedWebhookEvent? value - ) + public bool TryPickFileVersionDelete([NotNullWhen(true)] out FileVersionDeleteEvent? value) { - value = this.Value as FileVersionDeletedWebhookEvent; + value = this.Value as FileVersionDeleteEvent; return value != null; } @@ -485,11 +475,11 @@ public bool TryPickFileVersionDeleted( /// (UploadPreTransformErrorEvent value) => {...}, /// (UploadPostTransformSuccessEvent value) => {...}, /// (UploadPostTransformErrorEvent value) => {...}, - /// (FileCreatedWebhookEvent value) => {...}, - /// (FileUpdatedWebhookEvent value) => {...}, - /// (FileDeletedWebhookEvent value) => {...}, - /// (FileVersionCreatedWebhookEvent value) => {...}, - /// (FileVersionDeletedWebhookEvent value) => {...} + /// (FileCreateEvent value) => {...}, + /// (FileUpdateEvent value) => {...}, + /// (FileDeleteEvent value) => {...}, + /// (FileVersionCreateEvent value) => {...}, + /// (FileVersionDeleteEvent value) => {...} /// ); /// /// @@ -502,11 +492,11 @@ public void Switch( System::Action uploadPreTransformError, System::Action uploadPostTransformSuccess, System::Action uploadPostTransformError, - System::Action fileCreated, - System::Action fileUpdated, - System::Action fileDeleted, - System::Action fileVersionCreated, - System::Action fileVersionDeleted + System::Action fileCreate, + System::Action fileUpdate, + System::Action fileDelete, + System::Action fileVersionCreate, + System::Action fileVersionDelete ) { switch (this.Value) @@ -532,20 +522,20 @@ public void Switch( case UploadPostTransformErrorEvent value: uploadPostTransformError(value); break; - case FileCreatedWebhookEvent value: - fileCreated(value); + case FileCreateEvent value: + fileCreate(value); break; - case FileUpdatedWebhookEvent value: - fileUpdated(value); + case FileUpdateEvent value: + fileUpdate(value); break; - case FileDeletedWebhookEvent value: - fileDeleted(value); + case FileDeleteEvent value: + fileDelete(value); break; - case FileVersionCreatedWebhookEvent value: - fileVersionCreated(value); + case FileVersionCreateEvent value: + fileVersionCreate(value); break; - case FileVersionDeletedWebhookEvent value: - fileVersionDeleted(value); + case FileVersionDeleteEvent value: + fileVersionDelete(value); break; default: throw new ImageKitInvalidDataException( @@ -576,11 +566,11 @@ public void Switch( /// (UploadPreTransformErrorEvent value) => {...}, /// (UploadPostTransformSuccessEvent value) => {...}, /// (UploadPostTransformErrorEvent value) => {...}, - /// (FileCreatedWebhookEvent value) => {...}, - /// (FileUpdatedWebhookEvent value) => {...}, - /// (FileDeletedWebhookEvent value) => {...}, - /// (FileVersionCreatedWebhookEvent value) => {...}, - /// (FileVersionDeletedWebhookEvent value) => {...} + /// (FileCreateEvent value) => {...}, + /// (FileUpdateEvent value) => {...}, + /// (FileDeleteEvent value) => {...}, + /// (FileVersionCreateEvent value) => {...}, + /// (FileVersionDeleteEvent value) => {...} /// ); /// /// @@ -593,11 +583,11 @@ public T Match( System::Func uploadPreTransformError, System::Func uploadPostTransformSuccess, System::Func uploadPostTransformError, - System::Func fileCreated, - System::Func fileUpdated, - System::Func fileDeleted, - System::Func fileVersionCreated, - System::Func fileVersionDeleted + System::Func fileCreate, + System::Func fileUpdate, + System::Func fileDelete, + System::Func fileVersionCreate, + System::Func fileVersionDelete ) { return this.Value switch @@ -609,11 +599,11 @@ public T Match( UploadPreTransformErrorEvent value => uploadPreTransformError(value), UploadPostTransformSuccessEvent value => uploadPostTransformSuccess(value), UploadPostTransformErrorEvent value => uploadPostTransformError(value), - FileCreatedWebhookEvent value => fileCreated(value), - FileUpdatedWebhookEvent value => fileUpdated(value), - FileDeletedWebhookEvent value => fileDeleted(value), - FileVersionCreatedWebhookEvent value => fileVersionCreated(value), - FileVersionDeletedWebhookEvent value => fileVersionDeleted(value), + FileCreateEvent value => fileCreate(value), + FileUpdateEvent value => fileUpdate(value), + FileDeleteEvent value => fileDelete(value), + FileVersionCreateEvent value => fileVersionCreate(value), + FileVersionDeleteEvent value => fileVersionDelete(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of UnsafeUnwrapWebhookEvent" ), @@ -644,22 +634,17 @@ UploadPostTransformSuccessEvent value public static implicit operator UnsafeUnwrapWebhookEvent(UploadPostTransformErrorEvent value) => new(value); - public static implicit operator UnsafeUnwrapWebhookEvent(FileCreatedWebhookEvent value) => - new(value); + public static implicit operator UnsafeUnwrapWebhookEvent(FileCreateEvent value) => new(value); - public static implicit operator UnsafeUnwrapWebhookEvent(FileUpdatedWebhookEvent value) => - new(value); + public static implicit operator UnsafeUnwrapWebhookEvent(FileUpdateEvent value) => new(value); - public static implicit operator UnsafeUnwrapWebhookEvent(FileDeletedWebhookEvent value) => - new(value); + public static implicit operator UnsafeUnwrapWebhookEvent(FileDeleteEvent value) => new(value); - public static implicit operator UnsafeUnwrapWebhookEvent( - FileVersionCreatedWebhookEvent value - ) => new(value); + public static implicit operator UnsafeUnwrapWebhookEvent(FileVersionCreateEvent value) => + new(value); - public static implicit operator UnsafeUnwrapWebhookEvent( - FileVersionDeletedWebhookEvent value - ) => new(value); + public static implicit operator UnsafeUnwrapWebhookEvent(FileVersionDeleteEvent value) => + new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -687,11 +672,11 @@ public override void Validate() (uploadPreTransformError) => uploadPreTransformError.Validate(), (uploadPostTransformSuccess) => uploadPostTransformSuccess.Validate(), (uploadPostTransformError) => uploadPostTransformError.Validate(), - (fileCreated) => fileCreated.Validate(), - (fileUpdated) => fileUpdated.Validate(), - (fileDeleted) => fileDeleted.Validate(), - (fileVersionCreated) => fileVersionCreated.Validate(), - (fileVersionDeleted) => fileVersionDeleted.Validate() + (fileCreate) => fileCreate.Validate(), + (fileUpdate) => fileUpdate.Validate(), + (fileDelete) => fileDelete.Validate(), + (fileVersionCreate) => fileVersionCreate.Validate(), + (fileVersionDelete) => fileVersionDelete.Validate() ); } @@ -722,11 +707,11 @@ int VariantIndex() UploadPreTransformErrorEvent _ => 4, UploadPostTransformSuccessEvent _ => 5, UploadPostTransformErrorEvent _ => 6, - FileCreatedWebhookEvent _ => 7, - FileUpdatedWebhookEvent _ => 8, - FileDeletedWebhookEvent _ => 9, - FileVersionCreatedWebhookEvent _ => 10, - FileVersionDeletedWebhookEvent _ => 11, + FileCreateEvent _ => 7, + FileUpdateEvent _ => 8, + FileDeleteEvent _ => 9, + FileVersionCreateEvent _ => 10, + FileVersionDeleteEvent _ => 11, _ => -1, }; } @@ -883,7 +868,7 @@ JsonSerializerOptions options try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -901,7 +886,7 @@ JsonSerializerOptions options try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -919,7 +904,7 @@ JsonSerializerOptions options try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -937,7 +922,7 @@ JsonSerializerOptions options try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -955,7 +940,7 @@ JsonSerializerOptions options try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); diff --git a/src/ImageKit/Models/Webhooks/UnwrapWebhookEvent.cs b/src/ImageKit/Models/Webhooks/UnwrapWebhookEvent.cs index 6d6d3206..d33477ad 100644 --- a/src/ImageKit/Models/Webhooks/UnwrapWebhookEvent.cs +++ b/src/ImageKit/Models/Webhooks/UnwrapWebhookEvent.cs @@ -42,11 +42,11 @@ public string ID uploadPreTransformError: (x) => x.ID, uploadPostTransformSuccess: (x) => x.ID, uploadPostTransformError: (x) => x.ID, - fileCreated: (x) => x.STAINLESS_FIXME_ID, - fileUpdated: (x) => x.STAINLESS_FIXME_ID, - fileDeleted: (x) => x.STAINLESS_FIXME_ID, - fileVersionCreated: (x) => x.STAINLESS_FIXME_ID, - fileVersionDeleted: (x) => x.STAINLESS_FIXME_ID + fileCreate: (x) => x.ID, + fileUpdate: (x) => x.ID, + fileDelete: (x) => x.ID, + fileVersionCreate: (x) => x.ID, + fileVersionDelete: (x) => x.ID ); } } @@ -63,11 +63,11 @@ public string Type uploadPreTransformError: (x) => x.Type, uploadPostTransformSuccess: (x) => x.Type, uploadPostTransformError: (x) => x.Type, - fileCreated: (x) => x.STAINLESS_FIXME_Type, - fileUpdated: (x) => x.STAINLESS_FIXME_Type, - fileDeleted: (x) => x.STAINLESS_FIXME_Type, - fileVersionCreated: (x) => x.STAINLESS_FIXME_Type, - fileVersionDeleted: (x) => x.STAINLESS_FIXME_Type + fileCreate: (x) => x.Type, + fileUpdate: (x) => x.Type, + fileDelete: (x) => x.Type, + fileVersionCreate: (x) => x.Type, + fileVersionDelete: (x) => x.Type ); } } @@ -84,11 +84,11 @@ public string Type uploadPreTransformError: (x) => x.CreatedAt, uploadPostTransformSuccess: (x) => x.CreatedAt, uploadPostTransformError: (x) => x.CreatedAt, - fileCreated: (x) => x.STAINLESS_FIXME_CreatedAt, - fileUpdated: (x) => x.STAINLESS_FIXME_CreatedAt, - fileDeleted: (x) => x.STAINLESS_FIXME_CreatedAt, - fileVersionCreated: (x) => x.STAINLESS_FIXME_CreatedAt, - fileVersionDeleted: (x) => x.STAINLESS_FIXME_CreatedAt + fileCreate: (x) => x.CreatedAt, + fileUpdate: (x) => x.CreatedAt, + fileDelete: (x) => x.CreatedAt, + fileVersionCreate: (x) => x.CreatedAt, + fileVersionDelete: (x) => x.CreatedAt ); } } @@ -135,31 +135,31 @@ public UnwrapWebhookEvent(UploadPostTransformErrorEvent value, JsonElement? elem this._element = element; } - public UnwrapWebhookEvent(FileCreatedWebhookEvent value, JsonElement? element = null) + public UnwrapWebhookEvent(FileCreateEvent value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnwrapWebhookEvent(FileUpdatedWebhookEvent value, JsonElement? element = null) + public UnwrapWebhookEvent(FileUpdateEvent value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnwrapWebhookEvent(FileDeletedWebhookEvent value, JsonElement? element = null) + public UnwrapWebhookEvent(FileDeleteEvent value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnwrapWebhookEvent(FileVersionCreatedWebhookEvent value, JsonElement? element = null) + public UnwrapWebhookEvent(FileVersionCreateEvent value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnwrapWebhookEvent(FileVersionDeletedWebhookEvent value, JsonElement? element = null) + public UnwrapWebhookEvent(FileVersionDeleteEvent value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -333,110 +333,106 @@ public bool TryPickUploadPostTransformError( /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickFileCreated(out var value)) { - /// // `value` is of type `FileCreatedWebhookEvent` + /// if (instance.TryPickFileCreate(out var value)) { + /// // `value` is of type `FileCreateEvent` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickFileCreated([NotNullWhen(true)] out FileCreatedWebhookEvent? value) + public bool TryPickFileCreate([NotNullWhen(true)] out FileCreateEvent? value) { - value = this.Value as FileCreatedWebhookEvent; + value = this.Value as FileCreateEvent; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickFileUpdated(out var value)) { - /// // `value` is of type `FileUpdatedWebhookEvent` + /// if (instance.TryPickFileUpdate(out var value)) { + /// // `value` is of type `FileUpdateEvent` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickFileUpdated([NotNullWhen(true)] out FileUpdatedWebhookEvent? value) + public bool TryPickFileUpdate([NotNullWhen(true)] out FileUpdateEvent? value) { - value = this.Value as FileUpdatedWebhookEvent; + value = this.Value as FileUpdateEvent; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickFileDeleted(out var value)) { - /// // `value` is of type `FileDeletedWebhookEvent` + /// if (instance.TryPickFileDelete(out var value)) { + /// // `value` is of type `FileDeleteEvent` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickFileDeleted([NotNullWhen(true)] out FileDeletedWebhookEvent? value) + public bool TryPickFileDelete([NotNullWhen(true)] out FileDeleteEvent? value) { - value = this.Value as FileDeletedWebhookEvent; + value = this.Value as FileDeleteEvent; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickFileVersionCreated(out var value)) { - /// // `value` is of type `FileVersionCreatedWebhookEvent` + /// if (instance.TryPickFileVersionCreate(out var value)) { + /// // `value` is of type `FileVersionCreateEvent` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickFileVersionCreated( - [NotNullWhen(true)] out FileVersionCreatedWebhookEvent? value - ) + public bool TryPickFileVersionCreate([NotNullWhen(true)] out FileVersionCreateEvent? value) { - value = this.Value as FileVersionCreatedWebhookEvent; + value = this.Value as FileVersionCreateEvent; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickFileVersionDeleted(out var value)) { - /// // `value` is of type `FileVersionDeletedWebhookEvent` + /// if (instance.TryPickFileVersionDelete(out var value)) { + /// // `value` is of type `FileVersionDeleteEvent` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickFileVersionDeleted( - [NotNullWhen(true)] out FileVersionDeletedWebhookEvent? value - ) + public bool TryPickFileVersionDelete([NotNullWhen(true)] out FileVersionDeleteEvent? value) { - value = this.Value as FileVersionDeletedWebhookEvent; + value = this.Value as FileVersionDeleteEvent; return value != null; } @@ -461,11 +457,11 @@ public bool TryPickFileVersionDeleted( /// (UploadPreTransformErrorEvent value) => {...}, /// (UploadPostTransformSuccessEvent value) => {...}, /// (UploadPostTransformErrorEvent value) => {...}, - /// (FileCreatedWebhookEvent value) => {...}, - /// (FileUpdatedWebhookEvent value) => {...}, - /// (FileDeletedWebhookEvent value) => {...}, - /// (FileVersionCreatedWebhookEvent value) => {...}, - /// (FileVersionDeletedWebhookEvent value) => {...} + /// (FileCreateEvent value) => {...}, + /// (FileUpdateEvent value) => {...}, + /// (FileDeleteEvent value) => {...}, + /// (FileVersionCreateEvent value) => {...}, + /// (FileVersionDeleteEvent value) => {...} /// ); /// /// @@ -478,11 +474,11 @@ public void Switch( System::Action uploadPreTransformError, System::Action uploadPostTransformSuccess, System::Action uploadPostTransformError, - System::Action fileCreated, - System::Action fileUpdated, - System::Action fileDeleted, - System::Action fileVersionCreated, - System::Action fileVersionDeleted + System::Action fileCreate, + System::Action fileUpdate, + System::Action fileDelete, + System::Action fileVersionCreate, + System::Action fileVersionDelete ) { switch (this.Value) @@ -508,20 +504,20 @@ public void Switch( case UploadPostTransformErrorEvent value: uploadPostTransformError(value); break; - case FileCreatedWebhookEvent value: - fileCreated(value); + case FileCreateEvent value: + fileCreate(value); break; - case FileUpdatedWebhookEvent value: - fileUpdated(value); + case FileUpdateEvent value: + fileUpdate(value); break; - case FileDeletedWebhookEvent value: - fileDeleted(value); + case FileDeleteEvent value: + fileDelete(value); break; - case FileVersionCreatedWebhookEvent value: - fileVersionCreated(value); + case FileVersionCreateEvent value: + fileVersionCreate(value); break; - case FileVersionDeletedWebhookEvent value: - fileVersionDeleted(value); + case FileVersionDeleteEvent value: + fileVersionDelete(value); break; default: throw new ImageKitInvalidDataException( @@ -552,11 +548,11 @@ public void Switch( /// (UploadPreTransformErrorEvent value) => {...}, /// (UploadPostTransformSuccessEvent value) => {...}, /// (UploadPostTransformErrorEvent value) => {...}, - /// (FileCreatedWebhookEvent value) => {...}, - /// (FileUpdatedWebhookEvent value) => {...}, - /// (FileDeletedWebhookEvent value) => {...}, - /// (FileVersionCreatedWebhookEvent value) => {...}, - /// (FileVersionDeletedWebhookEvent value) => {...} + /// (FileCreateEvent value) => {...}, + /// (FileUpdateEvent value) => {...}, + /// (FileDeleteEvent value) => {...}, + /// (FileVersionCreateEvent value) => {...}, + /// (FileVersionDeleteEvent value) => {...} /// ); /// /// @@ -569,11 +565,11 @@ public T Match( System::Func uploadPreTransformError, System::Func uploadPostTransformSuccess, System::Func uploadPostTransformError, - System::Func fileCreated, - System::Func fileUpdated, - System::Func fileDeleted, - System::Func fileVersionCreated, - System::Func fileVersionDeleted + System::Func fileCreate, + System::Func fileUpdate, + System::Func fileDelete, + System::Func fileVersionCreate, + System::Func fileVersionDelete ) { return this.Value switch @@ -585,11 +581,11 @@ public T Match( UploadPreTransformErrorEvent value => uploadPreTransformError(value), UploadPostTransformSuccessEvent value => uploadPostTransformSuccess(value), UploadPostTransformErrorEvent value => uploadPostTransformError(value), - FileCreatedWebhookEvent value => fileCreated(value), - FileUpdatedWebhookEvent value => fileUpdated(value), - FileDeletedWebhookEvent value => fileDeleted(value), - FileVersionCreatedWebhookEvent value => fileVersionCreated(value), - FileVersionDeletedWebhookEvent value => fileVersionDeleted(value), + FileCreateEvent value => fileCreate(value), + FileUpdateEvent value => fileUpdate(value), + FileDeleteEvent value => fileDelete(value), + FileVersionCreateEvent value => fileVersionCreate(value), + FileVersionDeleteEvent value => fileVersionDelete(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of UnwrapWebhookEvent" ), @@ -617,17 +613,15 @@ public static implicit operator UnwrapWebhookEvent(UploadPostTransformSuccessEve public static implicit operator UnwrapWebhookEvent(UploadPostTransformErrorEvent value) => new(value); - public static implicit operator UnwrapWebhookEvent(FileCreatedWebhookEvent value) => new(value); + public static implicit operator UnwrapWebhookEvent(FileCreateEvent value) => new(value); - public static implicit operator UnwrapWebhookEvent(FileUpdatedWebhookEvent value) => new(value); + public static implicit operator UnwrapWebhookEvent(FileUpdateEvent value) => new(value); - public static implicit operator UnwrapWebhookEvent(FileDeletedWebhookEvent value) => new(value); + public static implicit operator UnwrapWebhookEvent(FileDeleteEvent value) => new(value); - public static implicit operator UnwrapWebhookEvent(FileVersionCreatedWebhookEvent value) => - new(value); + public static implicit operator UnwrapWebhookEvent(FileVersionCreateEvent value) => new(value); - public static implicit operator UnwrapWebhookEvent(FileVersionDeletedWebhookEvent value) => - new(value); + public static implicit operator UnwrapWebhookEvent(FileVersionDeleteEvent value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -655,11 +649,11 @@ public override void Validate() (uploadPreTransformError) => uploadPreTransformError.Validate(), (uploadPostTransformSuccess) => uploadPostTransformSuccess.Validate(), (uploadPostTransformError) => uploadPostTransformError.Validate(), - (fileCreated) => fileCreated.Validate(), - (fileUpdated) => fileUpdated.Validate(), - (fileDeleted) => fileDeleted.Validate(), - (fileVersionCreated) => fileVersionCreated.Validate(), - (fileVersionDeleted) => fileVersionDeleted.Validate() + (fileCreate) => fileCreate.Validate(), + (fileUpdate) => fileUpdate.Validate(), + (fileDelete) => fileDelete.Validate(), + (fileVersionCreate) => fileVersionCreate.Validate(), + (fileVersionDelete) => fileVersionDelete.Validate() ); } @@ -690,11 +684,11 @@ int VariantIndex() UploadPreTransformErrorEvent _ => 4, UploadPostTransformSuccessEvent _ => 5, UploadPostTransformErrorEvent _ => 6, - FileCreatedWebhookEvent _ => 7, - FileUpdatedWebhookEvent _ => 8, - FileDeletedWebhookEvent _ => 9, - FileVersionCreatedWebhookEvent _ => 10, - FileVersionDeletedWebhookEvent _ => 11, + FileCreateEvent _ => 7, + FileUpdateEvent _ => 8, + FileDeleteEvent _ => 9, + FileVersionCreateEvent _ => 10, + FileVersionDeleteEvent _ => 11, _ => -1, }; } @@ -851,7 +845,7 @@ JsonSerializerOptions options try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -869,7 +863,7 @@ JsonSerializerOptions options try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -887,7 +881,7 @@ JsonSerializerOptions options try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -905,7 +899,7 @@ JsonSerializerOptions options try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -923,7 +917,7 @@ JsonSerializerOptions options try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); diff --git a/src/ImageKit/Models/Webhooks/UploadPostTransformErrorEvent.cs b/src/ImageKit/Models/Webhooks/UploadPostTransformErrorEvent.cs index 5b5245f8..ffa377f3 100644 --- a/src/ImageKit/Models/Webhooks/UploadPostTransformErrorEvent.cs +++ b/src/ImageKit/Models/Webhooks/UploadPostTransformErrorEvent.cs @@ -57,12 +57,14 @@ public required string Type init { this._rawData.Set("created_at", value); } } - public required Data Data + public required UploadPostTransformErrorEventIntersectionMember1Data Data { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("data"); + return this._rawData.GetNotNullClass( + "data" + ); } init { this._rawData.Set("data", value); } } @@ -135,8 +137,13 @@ IReadOnlyDictionary rawData /// Triggered when a post-transformation fails. The original file remains available, /// but the requested transformation could not be generated. /// -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class IntersectionMember1 : JsonModel +[JsonConverter( + typeof(JsonModelConverter< + UploadPostTransformErrorEventIntersectionMember1, + UploadPostTransformErrorEventIntersectionMember1FromRaw + >) +)] +public sealed record class UploadPostTransformErrorEventIntersectionMember1 : JsonModel { /// /// Timestamp of when the event occurred in ISO8601 format. @@ -151,12 +158,14 @@ public sealed record class IntersectionMember1 : JsonModel init { this._rawData.Set("created_at", value); } } - public required Data Data + public required UploadPostTransformErrorEventIntersectionMember1Data Data { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("data"); + return this._rawData.GetNotNullClass( + "data" + ); } init { this._rawData.Set("data", value); } } @@ -198,18 +207,22 @@ public override void Validate() } } - public IntersectionMember1() + public UploadPostTransformErrorEventIntersectionMember1() { this.Type = JsonSerializer.SerializeToElement("upload.post-transform.error"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public IntersectionMember1(IntersectionMember1 intersectionMember1) - : base(intersectionMember1) { } + public UploadPostTransformErrorEventIntersectionMember1( + UploadPostTransformErrorEventIntersectionMember1 uploadPostTransformErrorEventIntersectionMember1 + ) + : base(uploadPostTransformErrorEventIntersectionMember1) { } #pragma warning restore CS8618 - public IntersectionMember1(IReadOnlyDictionary rawData) + public UploadPostTransformErrorEventIntersectionMember1( + IReadOnlyDictionary rawData + ) { this._rawData = new(rawData); @@ -218,14 +231,14 @@ public IntersectionMember1(IReadOnlyDictionary rawData) #pragma warning disable CS8618 [SetsRequiredMembers] - IntersectionMember1(FrozenDictionary rawData) + UploadPostTransformErrorEventIntersectionMember1(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static IntersectionMember1 FromRawUnchecked( + /// + public static UploadPostTransformErrorEventIntersectionMember1 FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -233,15 +246,22 @@ IReadOnlyDictionary rawData } } -class IntersectionMember1FromRaw : IFromRawJson +class UploadPostTransformErrorEventIntersectionMember1FromRaw + : IFromRawJson { /// - public IntersectionMember1 FromRawUnchecked(IReadOnlyDictionary rawData) => - IntersectionMember1.FromRawUnchecked(rawData); + public UploadPostTransformErrorEventIntersectionMember1 FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UploadPostTransformErrorEventIntersectionMember1.FromRawUnchecked(rawData); } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class Data : JsonModel +[JsonConverter( + typeof(JsonModelConverter< + UploadPostTransformErrorEventIntersectionMember1Data, + UploadPostTransformErrorEventIntersectionMember1DataFromRaw + >) +)] +public sealed record class UploadPostTransformErrorEventIntersectionMember1Data : JsonModel { /// /// Unique identifier of the originally uploaded file. @@ -315,39 +335,49 @@ public override void Validate() _ = this.Url; } - public Data() { } + public UploadPostTransformErrorEventIntersectionMember1Data() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public Data(Data data) - : base(data) { } + public UploadPostTransformErrorEventIntersectionMember1Data( + UploadPostTransformErrorEventIntersectionMember1Data uploadPostTransformErrorEventIntersectionMember1Data + ) + : base(uploadPostTransformErrorEventIntersectionMember1Data) { } #pragma warning restore CS8618 - public Data(IReadOnlyDictionary rawData) + public UploadPostTransformErrorEventIntersectionMember1Data( + IReadOnlyDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - Data(FrozenDictionary rawData) + UploadPostTransformErrorEventIntersectionMember1Data( + FrozenDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static Data FromRawUnchecked(IReadOnlyDictionary rawData) + /// + public static UploadPostTransformErrorEventIntersectionMember1Data FromRawUnchecked( + IReadOnlyDictionary rawData + ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class DataFromRaw : IFromRawJson +class UploadPostTransformErrorEventIntersectionMember1DataFromRaw + : IFromRawJson { /// - public Data FromRawUnchecked(IReadOnlyDictionary rawData) => - Data.FromRawUnchecked(rawData); + public UploadPostTransformErrorEventIntersectionMember1Data FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UploadPostTransformErrorEventIntersectionMember1Data.FromRawUnchecked(rawData); } [JsonConverter(typeof(JsonModelConverter))] From a7ba71eb4a00bfb04ea2c7adaa3b223e37f273d9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 10 Apr 2026 18:07:25 +0000 Subject: [PATCH 097/129] docs: improve examples --- .../Models/Assets/AssetListResponseTest.cs | 16 +- .../Beta/V2/Files/FileUploadResponseTest.cs | 144 ++++++++-- .../CustomMetadataFieldCreateParamsTest.cs | 88 +++++- .../CustomMetadataFieldTest.cs | 112 +++++++- .../CustomMetadataFieldUpdateParamsTest.cs | 80 +++++- src/ImageKit.Tests/Models/Files/FileTest.cs | 144 ++++++++-- .../Models/Files/FileUpdateResponseTest.cs | 88 +++++- .../Models/Files/FileUploadResponseTest.cs | 144 ++++++++-- .../Models/Files/UpdateFileRequestTest.cs | 26 +- .../Models/GetImageAttributesOptionsTest.cs | 14 +- src/ImageKit.Tests/Models/ImageOverlayTest.cs | 28 +- src/ImageKit.Tests/Models/OverlayTest.cs | 16 +- .../Models/SolidColorOverlayTest.cs | 28 +- .../SolidColorOverlayTransformationTest.cs | 14 +- src/ImageKit.Tests/Models/SrcOptionsTest.cs | 14 +- src/ImageKit.Tests/Models/TextOverlayTest.cs | 28 +- .../Models/TextOverlayTransformationTest.cs | 16 +- .../Models/TransformationTest.cs | 14 +- src/ImageKit.Tests/Models/VideoOverlayTest.cs | 28 +- .../Models/Webhooks/FileCreateEventTest.cs | 112 +++++++- .../Models/Webhooks/FileUpdateEventTest.cs | 112 +++++++- .../Webhooks/FileVersionCreateEventTest.cs | 112 +++++++- .../Webhooks/UnsafeUnwrapWebhookEventTest.cs | 64 ++++- .../Models/Webhooks/UnwrapWebhookEventTest.cs | 64 ++++- .../UploadPreTransformSuccessEventTest.cs | 256 +++++++++++++++--- .../CustomMetadataFieldServiceTest.cs | 8 +- 26 files changed, 1465 insertions(+), 305 deletions(-) diff --git a/src/ImageKit.Tests/Models/Assets/AssetListResponseTest.cs b/src/ImageKit.Tests/Models/Assets/AssetListResponseTest.cs index 175d7d0f..25f5762c 100644 --- a/src/ImageKit.Tests/Models/Assets/AssetListResponseTest.cs +++ b/src/ImageKit.Tests/Models/Assets/AssetListResponseTest.cs @@ -53,7 +53,13 @@ public void FileValidationWorks() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -141,7 +147,13 @@ public void FileSerializationRoundtripWorks() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", diff --git a/src/ImageKit.Tests/Models/Beta/V2/Files/FileUploadResponseTest.cs b/src/ImageKit.Tests/Models/Beta/V2/Files/FileUploadResponseTest.cs index 306aee8e..f4e6bf15 100644 --- a/src/ImageKit.Tests/Models/Beta/V2/Files/FileUploadResponseTest.cs +++ b/src/ImageKit.Tests/Models/Beta/V2/Files/FileUploadResponseTest.cs @@ -139,7 +139,13 @@ public void FieldRoundtrip_Works() new() { Type = Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent12(true), + new UnnamedSchemaWithArrayParent12(10), + new UnnamedSchemaWithArrayParent12("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -285,7 +291,13 @@ public void FieldRoundtrip_Works() new() { Type = Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent12(true), + new UnnamedSchemaWithArrayParent12(10), + new UnnamedSchemaWithArrayParent12("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -493,7 +505,13 @@ public void SerializationRoundtrip_Works() new() { Type = Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent12(true), + new UnnamedSchemaWithArrayParent12(10), + new UnnamedSchemaWithArrayParent12("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -653,7 +671,13 @@ public void FieldRoundtripThroughSerialization_Works() new() { Type = Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent12(true), + new UnnamedSchemaWithArrayParent12(10), + new UnnamedSchemaWithArrayParent12("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -806,7 +830,13 @@ public void FieldRoundtripThroughSerialization_Works() new() { Type = Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent12(true), + new UnnamedSchemaWithArrayParent12(10), + new UnnamedSchemaWithArrayParent12("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -1014,7 +1044,13 @@ public void Validation_Works() new() { Type = Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent12(true), + new UnnamedSchemaWithArrayParent12(10), + new UnnamedSchemaWithArrayParent12("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -1376,7 +1412,13 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() new() { Type = Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent12(true), + new UnnamedSchemaWithArrayParent12(10), + new UnnamedSchemaWithArrayParent12("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -1524,7 +1566,13 @@ public void OptionalNullablePropertiesUnsetValidation_Works() new() { Type = Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent12(true), + new UnnamedSchemaWithArrayParent12(10), + new UnnamedSchemaWithArrayParent12("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -1667,7 +1715,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() new() { Type = Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent12(true), + new UnnamedSchemaWithArrayParent12(10), + new UnnamedSchemaWithArrayParent12("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -1819,7 +1873,13 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() new() { Type = Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent12(true), + new UnnamedSchemaWithArrayParent12(10), + new UnnamedSchemaWithArrayParent12("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -1976,7 +2036,13 @@ public void CopyConstructor_Works() new() { Type = Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent12(true), + new UnnamedSchemaWithArrayParent12(10), + new UnnamedSchemaWithArrayParent12("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -2633,7 +2699,13 @@ public void FieldRoundtrip_Works() var model = new SelectedFieldsSchemaItem { Type = Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent12(true), + new UnnamedSchemaWithArrayParent12(10), + new UnnamedSchemaWithArrayParent12("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -2645,7 +2717,13 @@ public void FieldRoundtrip_Works() }; ApiEnum expectedType = Type.Text; - DefaultValue expectedDefaultValue = "string"; + DefaultValue expectedDefaultValue = new( + [ + new UnnamedSchemaWithArrayParent12(true), + new UnnamedSchemaWithArrayParent12(10), + new UnnamedSchemaWithArrayParent12("Hello"), + ] + ); bool expectedIsValueRequired = true; double expectedMaxLength = 0; MaxValue expectedMaxValue = "string"; @@ -2678,7 +2756,13 @@ public void SerializationRoundtrip_Works() var model = new SelectedFieldsSchemaItem { Type = Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent12(true), + new UnnamedSchemaWithArrayParent12(10), + new UnnamedSchemaWithArrayParent12("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -2704,7 +2788,13 @@ public void FieldRoundtripThroughSerialization_Works() var model = new SelectedFieldsSchemaItem { Type = Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent12(true), + new UnnamedSchemaWithArrayParent12(10), + new UnnamedSchemaWithArrayParent12("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -2723,7 +2813,13 @@ public void FieldRoundtripThroughSerialization_Works() Assert.NotNull(deserialized); ApiEnum expectedType = Type.Text; - DefaultValue expectedDefaultValue = "string"; + DefaultValue expectedDefaultValue = new( + [ + new UnnamedSchemaWithArrayParent12(true), + new UnnamedSchemaWithArrayParent12(10), + new UnnamedSchemaWithArrayParent12("Hello"), + ] + ); bool expectedIsValueRequired = true; double expectedMaxLength = 0; MaxValue expectedMaxValue = "string"; @@ -2756,7 +2852,13 @@ public void Validation_Works() var model = new SelectedFieldsSchemaItem { Type = Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent12(true), + new UnnamedSchemaWithArrayParent12(10), + new UnnamedSchemaWithArrayParent12("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -2870,7 +2972,13 @@ public void CopyConstructor_Works() var model = new SelectedFieldsSchemaItem { Type = Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent12(true), + new UnnamedSchemaWithArrayParent12(10), + new UnnamedSchemaWithArrayParent12("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", diff --git a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsTest.cs b/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsTest.cs index cc1697df..b43d419f 100644 --- a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsTest.cs +++ b/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsTest.cs @@ -19,7 +19,13 @@ public void FieldRoundtrip_Works() Schema = new() { Type = CustomMetadataFields::Type.Number, - DefaultValue = "string", + DefaultValue = new( + [ + new CustomMetadataFields::UnnamedSchemaWithArrayParent1(true), + new CustomMetadataFields::UnnamedSchemaWithArrayParent1(10), + new CustomMetadataFields::UnnamedSchemaWithArrayParent1("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = 3000, @@ -34,7 +40,13 @@ public void FieldRoundtrip_Works() CustomMetadataFields::Schema expectedSchema = new() { Type = CustomMetadataFields::Type.Number, - DefaultValue = "string", + DefaultValue = new( + [ + new CustomMetadataFields::UnnamedSchemaWithArrayParent1(true), + new CustomMetadataFields::UnnamedSchemaWithArrayParent1(10), + new CustomMetadataFields::UnnamedSchemaWithArrayParent1("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = 3000, @@ -58,7 +70,13 @@ public void Url_Works() Schema = new() { Type = CustomMetadataFields::Type.Number, - DefaultValue = "string", + DefaultValue = new( + [ + new CustomMetadataFields::UnnamedSchemaWithArrayParent1(true), + new CustomMetadataFields::UnnamedSchemaWithArrayParent1(10), + new CustomMetadataFields::UnnamedSchemaWithArrayParent1("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = 3000, @@ -83,7 +101,13 @@ public void CopyConstructor_Works() Schema = new() { Type = CustomMetadataFields::Type.Number, - DefaultValue = "string", + DefaultValue = new( + [ + new CustomMetadataFields::UnnamedSchemaWithArrayParent1(true), + new CustomMetadataFields::UnnamedSchemaWithArrayParent1(10), + new CustomMetadataFields::UnnamedSchemaWithArrayParent1("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = 3000, @@ -107,7 +131,13 @@ public void FieldRoundtrip_Works() var model = new CustomMetadataFields::Schema { Type = CustomMetadataFields::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new CustomMetadataFields::UnnamedSchemaWithArrayParent1(true), + new CustomMetadataFields::UnnamedSchemaWithArrayParent1(10), + new CustomMetadataFields::UnnamedSchemaWithArrayParent1("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -117,7 +147,13 @@ public void FieldRoundtrip_Works() }; ApiEnum expectedType = CustomMetadataFields::Type.Text; - CustomMetadataFields::DefaultValue expectedDefaultValue = "string"; + CustomMetadataFields::DefaultValue expectedDefaultValue = new( + [ + new CustomMetadataFields::UnnamedSchemaWithArrayParent1(true), + new CustomMetadataFields::UnnamedSchemaWithArrayParent1(10), + new CustomMetadataFields::UnnamedSchemaWithArrayParent1("Hello"), + ] + ); bool expectedIsValueRequired = true; double expectedMaxLength = 0; CustomMetadataFields::MaxValue expectedMaxValue = "string"; @@ -154,7 +190,13 @@ public void SerializationRoundtrip_Works() var model = new CustomMetadataFields::Schema { Type = CustomMetadataFields::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new CustomMetadataFields::UnnamedSchemaWithArrayParent1(true), + new CustomMetadataFields::UnnamedSchemaWithArrayParent1(10), + new CustomMetadataFields::UnnamedSchemaWithArrayParent1("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -178,7 +220,13 @@ public void FieldRoundtripThroughSerialization_Works() var model = new CustomMetadataFields::Schema { Type = CustomMetadataFields::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new CustomMetadataFields::UnnamedSchemaWithArrayParent1(true), + new CustomMetadataFields::UnnamedSchemaWithArrayParent1(10), + new CustomMetadataFields::UnnamedSchemaWithArrayParent1("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -195,7 +243,13 @@ public void FieldRoundtripThroughSerialization_Works() Assert.NotNull(deserialized); ApiEnum expectedType = CustomMetadataFields::Type.Text; - CustomMetadataFields::DefaultValue expectedDefaultValue = "string"; + CustomMetadataFields::DefaultValue expectedDefaultValue = new( + [ + new CustomMetadataFields::UnnamedSchemaWithArrayParent1(true), + new CustomMetadataFields::UnnamedSchemaWithArrayParent1(10), + new CustomMetadataFields::UnnamedSchemaWithArrayParent1("Hello"), + ] + ); bool expectedIsValueRequired = true; double expectedMaxLength = 0; CustomMetadataFields::MaxValue expectedMaxValue = "string"; @@ -232,7 +286,13 @@ public void Validation_Works() var model = new CustomMetadataFields::Schema { Type = CustomMetadataFields::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new CustomMetadataFields::UnnamedSchemaWithArrayParent1(true), + new CustomMetadataFields::UnnamedSchemaWithArrayParent1(10), + new CustomMetadataFields::UnnamedSchemaWithArrayParent1("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -332,7 +392,13 @@ public void CopyConstructor_Works() var model = new CustomMetadataFields::Schema { Type = CustomMetadataFields::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new CustomMetadataFields::UnnamedSchemaWithArrayParent1(true), + new CustomMetadataFields::UnnamedSchemaWithArrayParent1(10), + new CustomMetadataFields::UnnamedSchemaWithArrayParent1("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", diff --git a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldTest.cs b/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldTest.cs index 7f085638..3fefd8cb 100644 --- a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldTest.cs +++ b/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldTest.cs @@ -19,7 +19,13 @@ public void FieldRoundtrip_Works() Schema = new() { Type = CustomMetadataFieldSchemaType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent9(true), + new UnnamedSchemaWithArrayParent9(10), + new UnnamedSchemaWithArrayParent9("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -35,7 +41,13 @@ public void FieldRoundtrip_Works() CustomMetadataFieldSchema expectedSchema = new() { Type = CustomMetadataFieldSchemaType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent9(true), + new UnnamedSchemaWithArrayParent9(10), + new UnnamedSchemaWithArrayParent9("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -61,7 +73,13 @@ public void SerializationRoundtrip_Works() Schema = new() { Type = CustomMetadataFieldSchemaType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent9(true), + new UnnamedSchemaWithArrayParent9(10), + new UnnamedSchemaWithArrayParent9("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -91,7 +109,13 @@ public void FieldRoundtripThroughSerialization_Works() Schema = new() { Type = CustomMetadataFieldSchemaType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent9(true), + new UnnamedSchemaWithArrayParent9(10), + new UnnamedSchemaWithArrayParent9("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -114,7 +138,13 @@ public void FieldRoundtripThroughSerialization_Works() CustomMetadataFieldSchema expectedSchema = new() { Type = CustomMetadataFieldSchemaType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent9(true), + new UnnamedSchemaWithArrayParent9(10), + new UnnamedSchemaWithArrayParent9("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -140,7 +170,13 @@ public void Validation_Works() Schema = new() { Type = CustomMetadataFieldSchemaType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent9(true), + new UnnamedSchemaWithArrayParent9(10), + new UnnamedSchemaWithArrayParent9("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -164,7 +200,13 @@ public void CopyConstructor_Works() Schema = new() { Type = CustomMetadataFieldSchemaType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent9(true), + new UnnamedSchemaWithArrayParent9(10), + new UnnamedSchemaWithArrayParent9("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -188,7 +230,13 @@ public void FieldRoundtrip_Works() var model = new CustomMetadataFieldSchema { Type = CustomMetadataFieldSchemaType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent9(true), + new UnnamedSchemaWithArrayParent9(10), + new UnnamedSchemaWithArrayParent9("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -199,7 +247,13 @@ public void FieldRoundtrip_Works() ApiEnum expectedType = CustomMetadataFieldSchemaType.Text; - CustomMetadataFieldSchemaDefaultValue expectedDefaultValue = "string"; + CustomMetadataFieldSchemaDefaultValue expectedDefaultValue = new( + [ + new UnnamedSchemaWithArrayParent9(true), + new UnnamedSchemaWithArrayParent9(10), + new UnnamedSchemaWithArrayParent9("Hello"), + ] + ); bool expectedIsValueRequired = true; double expectedMaxLength = 0; CustomMetadataFieldSchemaMaxValue expectedMaxValue = "string"; @@ -236,7 +290,13 @@ public void SerializationRoundtrip_Works() var model = new CustomMetadataFieldSchema { Type = CustomMetadataFieldSchemaType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent9(true), + new UnnamedSchemaWithArrayParent9(10), + new UnnamedSchemaWithArrayParent9("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -260,7 +320,13 @@ public void FieldRoundtripThroughSerialization_Works() var model = new CustomMetadataFieldSchema { Type = CustomMetadataFieldSchemaType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent9(true), + new UnnamedSchemaWithArrayParent9(10), + new UnnamedSchemaWithArrayParent9("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -278,7 +344,13 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum expectedType = CustomMetadataFieldSchemaType.Text; - CustomMetadataFieldSchemaDefaultValue expectedDefaultValue = "string"; + CustomMetadataFieldSchemaDefaultValue expectedDefaultValue = new( + [ + new UnnamedSchemaWithArrayParent9(true), + new UnnamedSchemaWithArrayParent9(10), + new UnnamedSchemaWithArrayParent9("Hello"), + ] + ); bool expectedIsValueRequired = true; double expectedMaxLength = 0; CustomMetadataFieldSchemaMaxValue expectedMaxValue = "string"; @@ -315,7 +387,13 @@ public void Validation_Works() var model = new CustomMetadataFieldSchema { Type = CustomMetadataFieldSchemaType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent9(true), + new UnnamedSchemaWithArrayParent9(10), + new UnnamedSchemaWithArrayParent9("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -415,7 +493,13 @@ public void CopyConstructor_Works() var model = new CustomMetadataFieldSchema { Type = CustomMetadataFieldSchemaType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent9(true), + new UnnamedSchemaWithArrayParent9(10), + new UnnamedSchemaWithArrayParent9("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", diff --git a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsTest.cs b/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsTest.cs index 7e969966..36caefd5 100644 --- a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsTest.cs +++ b/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsTest.cs @@ -17,7 +17,13 @@ public void FieldRoundtrip_Works() Label = "price", Schema = new() { - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = 3000, @@ -31,7 +37,13 @@ public void FieldRoundtrip_Works() string expectedLabel = "price"; CustomMetadataFieldUpdateParamsSchema expectedSchema = new() { - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = 3000, @@ -93,7 +105,13 @@ public void CopyConstructor_Works() Label = "price", Schema = new() { - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = 3000, @@ -116,7 +134,13 @@ public void FieldRoundtrip_Works() { var model = new CustomMetadataFieldUpdateParamsSchema { - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -125,7 +149,13 @@ public void FieldRoundtrip_Works() SelectOptions = ["small", "medium", "large", 30, 40, true], }; - CustomMetadataFieldUpdateParamsSchemaDefaultValue expectedDefaultValue = "string"; + CustomMetadataFieldUpdateParamsSchemaDefaultValue expectedDefaultValue = new( + [ + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), + ] + ); bool expectedIsValueRequired = true; double expectedMaxLength = 0; CustomMetadataFieldUpdateParamsSchemaMaxValue expectedMaxValue = "string"; @@ -160,7 +190,13 @@ public void SerializationRoundtrip_Works() { var model = new CustomMetadataFieldUpdateParamsSchema { - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -183,7 +219,13 @@ public void FieldRoundtripThroughSerialization_Works() { var model = new CustomMetadataFieldUpdateParamsSchema { - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -199,7 +241,13 @@ public void FieldRoundtripThroughSerialization_Works() ); Assert.NotNull(deserialized); - CustomMetadataFieldUpdateParamsSchemaDefaultValue expectedDefaultValue = "string"; + CustomMetadataFieldUpdateParamsSchemaDefaultValue expectedDefaultValue = new( + [ + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), + ] + ); bool expectedIsValueRequired = true; double expectedMaxLength = 0; CustomMetadataFieldUpdateParamsSchemaMaxValue expectedMaxValue = "string"; @@ -234,7 +282,13 @@ public void Validation_Works() { var model = new CustomMetadataFieldUpdateParamsSchema { - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -329,7 +383,13 @@ public void CopyConstructor_Works() { var model = new CustomMetadataFieldUpdateParamsSchema { - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", diff --git a/src/ImageKit.Tests/Models/Files/FileTest.cs b/src/ImageKit.Tests/Models/Files/FileTest.cs index bdd84b26..8b5e6a8a 100644 --- a/src/ImageKit.Tests/Models/Files/FileTest.cs +++ b/src/ImageKit.Tests/Models/Files/FileTest.cs @@ -53,7 +53,13 @@ public void FieldRoundtrip_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -115,7 +121,13 @@ public void FieldRoundtrip_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -242,7 +254,13 @@ public void SerializationRoundtrip_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -318,7 +336,13 @@ public void FieldRoundtripThroughSerialization_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -387,7 +411,13 @@ public void FieldRoundtripThroughSerialization_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -514,7 +544,13 @@ public void Validation_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -810,7 +846,13 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -874,7 +916,13 @@ public void OptionalNullablePropertiesUnsetValidation_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -933,7 +981,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -1001,7 +1055,13 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -1074,7 +1134,13 @@ public void CopyConstructor_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -1260,7 +1326,13 @@ public void FieldRoundtrip_Works() var model = new Files::SelectedFieldsSchemaItem { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -1272,7 +1344,13 @@ public void FieldRoundtrip_Works() }; ApiEnum expectedType = Files::Type.Text; - Files::DefaultValue expectedDefaultValue = "string"; + Files::DefaultValue expectedDefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ); bool expectedIsValueRequired = true; double expectedMaxLength = 0; Files::MaxValue expectedMaxValue = "string"; @@ -1313,7 +1391,13 @@ public void SerializationRoundtrip_Works() var model = new Files::SelectedFieldsSchemaItem { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -1339,7 +1423,13 @@ public void FieldRoundtripThroughSerialization_Works() var model = new Files::SelectedFieldsSchemaItem { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -1358,7 +1448,13 @@ public void FieldRoundtripThroughSerialization_Works() Assert.NotNull(deserialized); ApiEnum expectedType = Files::Type.Text; - Files::DefaultValue expectedDefaultValue = "string"; + Files::DefaultValue expectedDefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ); bool expectedIsValueRequired = true; double expectedMaxLength = 0; Files::MaxValue expectedMaxValue = "string"; @@ -1399,7 +1495,13 @@ public void Validation_Works() var model = new Files::SelectedFieldsSchemaItem { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -1513,7 +1615,13 @@ public void CopyConstructor_Works() var model = new Files::SelectedFieldsSchemaItem { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", diff --git a/src/ImageKit.Tests/Models/Files/FileUpdateResponseTest.cs b/src/ImageKit.Tests/Models/Files/FileUpdateResponseTest.cs index 20f316ca..28653512 100644 --- a/src/ImageKit.Tests/Models/Files/FileUpdateResponseTest.cs +++ b/src/ImageKit.Tests/Models/Files/FileUpdateResponseTest.cs @@ -53,7 +53,13 @@ public void FieldRoundtrip_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -123,7 +129,13 @@ public void FieldRoundtrip_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -259,7 +271,13 @@ public void SerializationRoundtrip_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -343,7 +361,13 @@ public void FieldRoundtripThroughSerialization_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -420,7 +444,13 @@ public void FieldRoundtripThroughSerialization_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -556,7 +586,13 @@ public void Validation_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -866,7 +902,13 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -938,7 +980,13 @@ public void OptionalNullablePropertiesUnsetValidation_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -1005,7 +1053,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -1081,7 +1135,13 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -1162,7 +1222,13 @@ public void CopyConstructor_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", diff --git a/src/ImageKit.Tests/Models/Files/FileUploadResponseTest.cs b/src/ImageKit.Tests/Models/Files/FileUploadResponseTest.cs index a88a2210..f870a912 100644 --- a/src/ImageKit.Tests/Models/Files/FileUploadResponseTest.cs +++ b/src/ImageKit.Tests/Models/Files/FileUploadResponseTest.cs @@ -141,7 +141,13 @@ public void FieldRoundtrip_Works() new() { Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent11(true), + new UnnamedSchemaWithArrayParent11(10), + new UnnamedSchemaWithArrayParent11("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -290,7 +296,13 @@ public void FieldRoundtrip_Works() new() { Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent11(true), + new UnnamedSchemaWithArrayParent11(10), + new UnnamedSchemaWithArrayParent11("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -501,7 +513,13 @@ public void SerializationRoundtrip_Works() new() { Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent11(true), + new UnnamedSchemaWithArrayParent11(10), + new UnnamedSchemaWithArrayParent11("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -664,7 +682,13 @@ public void FieldRoundtripThroughSerialization_Works() new() { Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent11(true), + new UnnamedSchemaWithArrayParent11(10), + new UnnamedSchemaWithArrayParent11("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -820,7 +844,13 @@ public void FieldRoundtripThroughSerialization_Works() new() { Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent11(true), + new UnnamedSchemaWithArrayParent11(10), + new UnnamedSchemaWithArrayParent11("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -1031,7 +1061,13 @@ public void Validation_Works() new() { Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent11(true), + new UnnamedSchemaWithArrayParent11(10), + new UnnamedSchemaWithArrayParent11("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -1396,7 +1432,13 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() new() { Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent11(true), + new UnnamedSchemaWithArrayParent11(10), + new UnnamedSchemaWithArrayParent11("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -1547,7 +1589,13 @@ public void OptionalNullablePropertiesUnsetValidation_Works() new() { Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent11(true), + new UnnamedSchemaWithArrayParent11(10), + new UnnamedSchemaWithArrayParent11("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -1693,7 +1741,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() new() { Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent11(true), + new UnnamedSchemaWithArrayParent11(10), + new UnnamedSchemaWithArrayParent11("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -1848,7 +1902,13 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() new() { Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent11(true), + new UnnamedSchemaWithArrayParent11(10), + new UnnamedSchemaWithArrayParent11("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -2008,7 +2068,13 @@ public void CopyConstructor_Works() new() { Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent11(true), + new UnnamedSchemaWithArrayParent11(10), + new UnnamedSchemaWithArrayParent11("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -2675,7 +2741,13 @@ public void FieldRoundtrip_Works() var model = new FileUploadResponseSelectedFieldsSchemaItem { Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent11(true), + new UnnamedSchemaWithArrayParent11(10), + new UnnamedSchemaWithArrayParent11("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -2688,7 +2760,13 @@ public void FieldRoundtrip_Works() ApiEnum expectedType = FileUploadResponseSelectedFieldsSchemaItemType.Text; - FileUploadResponseSelectedFieldsSchemaItemDefaultValue expectedDefaultValue = "string"; + FileUploadResponseSelectedFieldsSchemaItemDefaultValue expectedDefaultValue = new( + [ + new UnnamedSchemaWithArrayParent11(true), + new UnnamedSchemaWithArrayParent11(10), + new UnnamedSchemaWithArrayParent11("Hello"), + ] + ); bool expectedIsValueRequired = true; double expectedMaxLength = 0; FileUploadResponseSelectedFieldsSchemaItemMaxValue expectedMaxValue = "string"; @@ -2729,7 +2807,13 @@ public void SerializationRoundtrip_Works() var model = new FileUploadResponseSelectedFieldsSchemaItem { Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent11(true), + new UnnamedSchemaWithArrayParent11(10), + new UnnamedSchemaWithArrayParent11("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -2755,7 +2839,13 @@ public void FieldRoundtripThroughSerialization_Works() var model = new FileUploadResponseSelectedFieldsSchemaItem { Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent11(true), + new UnnamedSchemaWithArrayParent11(10), + new UnnamedSchemaWithArrayParent11("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -2775,7 +2865,13 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum expectedType = FileUploadResponseSelectedFieldsSchemaItemType.Text; - FileUploadResponseSelectedFieldsSchemaItemDefaultValue expectedDefaultValue = "string"; + FileUploadResponseSelectedFieldsSchemaItemDefaultValue expectedDefaultValue = new( + [ + new UnnamedSchemaWithArrayParent11(true), + new UnnamedSchemaWithArrayParent11(10), + new UnnamedSchemaWithArrayParent11("Hello"), + ] + ); bool expectedIsValueRequired = true; double expectedMaxLength = 0; FileUploadResponseSelectedFieldsSchemaItemMaxValue expectedMaxValue = "string"; @@ -2816,7 +2912,13 @@ public void Validation_Works() var model = new FileUploadResponseSelectedFieldsSchemaItem { Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent11(true), + new UnnamedSchemaWithArrayParent11(10), + new UnnamedSchemaWithArrayParent11("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -2936,7 +3038,13 @@ public void CopyConstructor_Works() var model = new FileUploadResponseSelectedFieldsSchemaItem { Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent11(true), + new UnnamedSchemaWithArrayParent11(10), + new UnnamedSchemaWithArrayParent11("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", diff --git a/src/ImageKit.Tests/Models/Files/UpdateFileRequestTest.cs b/src/ImageKit.Tests/Models/Files/UpdateFileRequestTest.cs index dd12727e..c5e6bd6e 100644 --- a/src/ImageKit.Tests/Models/Files/UpdateFileRequestTest.cs +++ b/src/ImageKit.Tests/Models/Files/UpdateFileRequestTest.cs @@ -77,7 +77,7 @@ public void DetailsValidationWorks() ), new SavedExtension("ext_abc123"), ], - RemoveAITags = new(["string"]), + RemoveAITags = new Files::UnionMember1(), Tags = ["tag1", "tag2"], WebhookUrl = "https://example.com", }; @@ -162,7 +162,7 @@ public void DetailsSerializationRoundtripWorks() ), new SavedExtension("ext_abc123"), ], - RemoveAITags = new(["string"]), + RemoveAITags = new Files::UnionMember1(), Tags = ["tag1", "tag2"], WebhookUrl = "https://example.com", }; @@ -262,7 +262,7 @@ public void FieldRoundtrip_Works() ), new SavedExtension("ext_abc123"), ], - RemoveAITags = new(["string"]), + RemoveAITags = new Files::UnionMember1(), Tags = ["tag1", "tag2"], WebhookUrl = "https://example.com", }; @@ -330,7 +330,7 @@ public void FieldRoundtrip_Works() ), new SavedExtension("ext_abc123"), ]; - Files::RemoveAITags expectedRemoveAITags = new(["string"]); + Files::RemoveAITags expectedRemoveAITags = new Files::UnionMember1(); List expectedTags = ["tag1", "tag2"]; string expectedWebhookUrl = "https://example.com"; @@ -428,7 +428,7 @@ public void SerializationRoundtrip_Works() ), new SavedExtension("ext_abc123"), ], - RemoveAITags = new(["string"]), + RemoveAITags = new Files::UnionMember1(), Tags = ["tag1", "tag2"], WebhookUrl = "https://example.com", }; @@ -510,7 +510,7 @@ public void FieldRoundtripThroughSerialization_Works() ), new SavedExtension("ext_abc123"), ], - RemoveAITags = new(["string"]), + RemoveAITags = new Files::UnionMember1(), Tags = ["tag1", "tag2"], WebhookUrl = "https://example.com", }; @@ -585,7 +585,7 @@ public void FieldRoundtripThroughSerialization_Works() ), new SavedExtension("ext_abc123"), ]; - Files::RemoveAITags expectedRemoveAITags = new(["string"]); + Files::RemoveAITags expectedRemoveAITags = new Files::UnionMember1(); List expectedTags = ["tag1", "tag2"]; string expectedWebhookUrl = "https://example.com"; @@ -683,7 +683,7 @@ public void Validation_Works() ), new SavedExtension("ext_abc123"), ], - RemoveAITags = new(["string"]), + RemoveAITags = new Files::UnionMember1(), Tags = ["tag1", "tag2"], WebhookUrl = "https://example.com", }; @@ -838,7 +838,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() ), new SavedExtension("ext_abc123"), ], - RemoveAITags = new(["string"]), + RemoveAITags = new Files::UnionMember1(), WebhookUrl = "https://example.com", }; @@ -915,7 +915,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() ), new SavedExtension("ext_abc123"), ], - RemoveAITags = new(["string"]), + RemoveAITags = new Files::UnionMember1(), WebhookUrl = "https://example.com", }; @@ -989,7 +989,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() ), new SavedExtension("ext_abc123"), ], - RemoveAITags = new(["string"]), + RemoveAITags = new Files::UnionMember1(), WebhookUrl = "https://example.com", CustomCoordinates = null, @@ -1069,7 +1069,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ), new SavedExtension("ext_abc123"), ], - RemoveAITags = new(["string"]), + RemoveAITags = new Files::UnionMember1(), WebhookUrl = "https://example.com", CustomCoordinates = null, @@ -1147,7 +1147,7 @@ public void CopyConstructor_Works() ), new SavedExtension("ext_abc123"), ], - RemoveAITags = new(["string"]), + RemoveAITags = new Files::UnionMember1(), Tags = ["tag1", "tag2"], WebhookUrl = "https://example.com", }; diff --git a/src/ImageKit.Tests/Models/GetImageAttributesOptionsTest.cs b/src/ImageKit.Tests/Models/GetImageAttributesOptionsTest.cs index be0824d6..7a07560b 100644 --- a/src/ImageKit.Tests/Models/GetImageAttributesOptionsTest.cs +++ b/src/ImageKit.Tests/Models/GetImageAttributesOptionsTest.cs @@ -88,7 +88,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -199,7 +199,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -350,7 +350,7 @@ public void SerializationRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -475,7 +475,7 @@ public void FieldRoundtripThroughSerialization_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -593,7 +593,7 @@ public void FieldRoundtripThroughSerialization_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -744,7 +744,7 @@ public void Validation_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -967,7 +967,7 @@ public void CopyConstructor_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, diff --git a/src/ImageKit.Tests/Models/ImageOverlayTest.cs b/src/ImageKit.Tests/Models/ImageOverlayTest.cs index 05d97bf4..47289a76 100644 --- a/src/ImageKit.Tests/Models/ImageOverlayTest.cs +++ b/src/ImageKit.Tests/Models/ImageOverlayTest.cs @@ -102,7 +102,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -222,7 +222,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -359,7 +359,7 @@ public void SerializationRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -492,7 +492,7 @@ public void FieldRoundtripThroughSerialization_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -619,7 +619,7 @@ public void FieldRoundtripThroughSerialization_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -756,7 +756,7 @@ public void Validation_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -953,7 +953,7 @@ public void CopyConstructor_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -1069,7 +1069,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -1173,7 +1173,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -1291,7 +1291,7 @@ public void SerializationRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -1408,7 +1408,7 @@ public void FieldRoundtripThroughSerialization_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -1519,7 +1519,7 @@ public void FieldRoundtripThroughSerialization_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -1637,7 +1637,7 @@ public void Validation_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -1800,7 +1800,7 @@ public void CopyConstructor_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, diff --git a/src/ImageKit.Tests/Models/OverlayTest.cs b/src/ImageKit.Tests/Models/OverlayTest.cs index ae78c797..5a7c8d6b 100644 --- a/src/ImageKit.Tests/Models/OverlayTest.cs +++ b/src/ImageKit.Tests/Models/OverlayTest.cs @@ -42,7 +42,7 @@ public void TextValidationWorks() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -146,7 +146,7 @@ public void ImageValidationWorks() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -272,7 +272,7 @@ public void VideoValidationWorks() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -374,7 +374,7 @@ public void SolidColorValidationWorks() Background = "background", Gradient = new UnionMember0(), Height = 0, - Radius = 0, + Radius = new UnionMember1(), Width = 0, }, ], @@ -418,7 +418,7 @@ public void TextSerializationRoundtripWorks() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -528,7 +528,7 @@ public void ImageSerializationRoundtripWorks() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -660,7 +660,7 @@ public void VideoSerializationRoundtripWorks() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -774,7 +774,7 @@ public void SolidColorSerializationRoundtripWorks() Background = "background", Gradient = new UnionMember0(), Height = 0, - Radius = 0, + Radius = new UnionMember1(), Width = 0, }, ], diff --git a/src/ImageKit.Tests/Models/SolidColorOverlayTest.cs b/src/ImageKit.Tests/Models/SolidColorOverlayTest.cs index 6ae4efdc..00961ad2 100644 --- a/src/ImageKit.Tests/Models/SolidColorOverlayTest.cs +++ b/src/ImageKit.Tests/Models/SolidColorOverlayTest.cs @@ -37,7 +37,7 @@ public void FieldRoundtrip_Works() Background = "background", Gradient = new UnionMember0(), Height = 0, - Radius = 0, + Radius = new UnionMember1(), Width = 0, }, ], @@ -69,7 +69,7 @@ public void FieldRoundtrip_Works() Background = "background", Gradient = new UnionMember0(), Height = 0, - Radius = 0, + Radius = new UnionMember1(), Width = 0, }, ]; @@ -117,7 +117,7 @@ public void SerializationRoundtrip_Works() Background = "background", Gradient = new UnionMember0(), Height = 0, - Radius = 0, + Radius = new UnionMember1(), Width = 0, }, ], @@ -162,7 +162,7 @@ public void FieldRoundtripThroughSerialization_Works() Background = "background", Gradient = new UnionMember0(), Height = 0, - Radius = 0, + Radius = new UnionMember1(), Width = 0, }, ], @@ -201,7 +201,7 @@ public void FieldRoundtripThroughSerialization_Works() Background = "background", Gradient = new UnionMember0(), Height = 0, - Radius = 0, + Radius = new UnionMember1(), Width = 0, }, ]; @@ -249,7 +249,7 @@ public void Validation_Works() Background = "background", Gradient = new UnionMember0(), Height = 0, - Radius = 0, + Radius = new UnionMember1(), Width = 0, }, ], @@ -352,7 +352,7 @@ public void CopyConstructor_Works() Background = "background", Gradient = new UnionMember0(), Height = 0, - Radius = 0, + Radius = new UnionMember1(), Width = 0, }, ], @@ -380,7 +380,7 @@ public void FieldRoundtrip_Works() Background = "background", Gradient = new UnionMember0(), Height = 0, - Radius = 0, + Radius = new UnionMember1(), Width = 0, }, ], @@ -396,7 +396,7 @@ public void FieldRoundtrip_Works() Background = "background", Gradient = new UnionMember0(), Height = 0, - Radius = 0, + Radius = new UnionMember1(), Width = 0, }, ]; @@ -425,7 +425,7 @@ public void SerializationRoundtrip_Works() Background = "background", Gradient = new UnionMember0(), Height = 0, - Radius = 0, + Radius = new UnionMember1(), Width = 0, }, ], @@ -454,7 +454,7 @@ public void FieldRoundtripThroughSerialization_Works() Background = "background", Gradient = new UnionMember0(), Height = 0, - Radius = 0, + Radius = new UnionMember1(), Width = 0, }, ], @@ -477,7 +477,7 @@ public void FieldRoundtripThroughSerialization_Works() Background = "background", Gradient = new UnionMember0(), Height = 0, - Radius = 0, + Radius = new UnionMember1(), Width = 0, }, ]; @@ -506,7 +506,7 @@ public void Validation_Works() Background = "background", Gradient = new UnionMember0(), Height = 0, - Radius = 0, + Radius = new UnionMember1(), Width = 0, }, ], @@ -575,7 +575,7 @@ public void CopyConstructor_Works() Background = "background", Gradient = new UnionMember0(), Height = 0, - Radius = 0, + Radius = new UnionMember1(), Width = 0, }, ], diff --git a/src/ImageKit.Tests/Models/SolidColorOverlayTransformationTest.cs b/src/ImageKit.Tests/Models/SolidColorOverlayTransformationTest.cs index c67cfb17..d84a841b 100644 --- a/src/ImageKit.Tests/Models/SolidColorOverlayTransformationTest.cs +++ b/src/ImageKit.Tests/Models/SolidColorOverlayTransformationTest.cs @@ -16,7 +16,7 @@ public void FieldRoundtrip_Works() Background = "background", Gradient = new UnionMember0(), Height = 0, - Radius = 0, + Radius = new UnionMember1(), Width = 0, }; @@ -24,7 +24,7 @@ public void FieldRoundtrip_Works() string expectedBackground = "background"; Gradient expectedGradient = new UnionMember0(); Height expectedHeight = 0; - Radius expectedRadius = 0; + Radius expectedRadius = new UnionMember1(); Width expectedWidth = 0; Assert.Equal(expectedAlpha, model.Alpha); @@ -44,7 +44,7 @@ public void SerializationRoundtrip_Works() Background = "background", Gradient = new UnionMember0(), Height = 0, - Radius = 0, + Radius = new UnionMember1(), Width = 0, }; @@ -66,7 +66,7 @@ public void FieldRoundtripThroughSerialization_Works() Background = "background", Gradient = new UnionMember0(), Height = 0, - Radius = 0, + Radius = new UnionMember1(), Width = 0, }; @@ -81,7 +81,7 @@ public void FieldRoundtripThroughSerialization_Works() string expectedBackground = "background"; Gradient expectedGradient = new UnionMember0(); Height expectedHeight = 0; - Radius expectedRadius = 0; + Radius expectedRadius = new UnionMember1(); Width expectedWidth = 0; Assert.Equal(expectedAlpha, deserialized.Alpha); @@ -101,7 +101,7 @@ public void Validation_Works() Background = "background", Gradient = new UnionMember0(), Height = 0, - Radius = 0, + Radius = new UnionMember1(), Width = 0, }; @@ -189,7 +189,7 @@ public void CopyConstructor_Works() Background = "background", Gradient = new UnionMember0(), Height = 0, - Radius = 0, + Radius = new UnionMember1(), Width = 0, }; diff --git a/src/ImageKit.Tests/Models/SrcOptionsTest.cs b/src/ImageKit.Tests/Models/SrcOptionsTest.cs index d8677cfe..fe25fe16 100644 --- a/src/ImageKit.Tests/Models/SrcOptionsTest.cs +++ b/src/ImageKit.Tests/Models/SrcOptionsTest.cs @@ -88,7 +88,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -195,7 +195,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -328,7 +328,7 @@ public void SerializationRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -449,7 +449,7 @@ public void FieldRoundtripThroughSerialization_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -563,7 +563,7 @@ public void FieldRoundtripThroughSerialization_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -696,7 +696,7 @@ public void Validation_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -891,7 +891,7 @@ public void CopyConstructor_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, diff --git a/src/ImageKit.Tests/Models/TextOverlayTest.cs b/src/ImageKit.Tests/Models/TextOverlayTest.cs index 2e222480..0c510d69 100644 --- a/src/ImageKit.Tests/Models/TextOverlayTest.cs +++ b/src/ImageKit.Tests/Models/TextOverlayTest.cs @@ -44,7 +44,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -85,7 +85,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -142,7 +142,7 @@ public void SerializationRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -195,7 +195,7 @@ public void FieldRoundtripThroughSerialization_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -243,7 +243,7 @@ public void FieldRoundtripThroughSerialization_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -300,7 +300,7 @@ public void Validation_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -417,7 +417,7 @@ public void CopyConstructor_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -453,7 +453,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -478,7 +478,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -516,7 +516,7 @@ public void SerializationRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -553,7 +553,7 @@ public void FieldRoundtripThroughSerialization_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -585,7 +585,7 @@ public void FieldRoundtripThroughSerialization_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -623,7 +623,7 @@ public void Validation_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -706,7 +706,7 @@ public void CopyConstructor_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, diff --git a/src/ImageKit.Tests/Models/TextOverlayTransformationTest.cs b/src/ImageKit.Tests/Models/TextOverlayTransformationTest.cs index 2a69266d..1af130ca 100644 --- a/src/ImageKit.Tests/Models/TextOverlayTransformationTest.cs +++ b/src/ImageKit.Tests/Models/TextOverlayTransformationTest.cs @@ -21,7 +21,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -36,7 +36,8 @@ public void FieldRoundtrip_Works() ApiEnum expectedInnerAlignment = InnerAlignment.Left; LineHeight expectedLineHeight = 0; Padding expectedPadding = 0; - TextOverlayTransformationRadius expectedRadius = 0; + TextOverlayTransformationRadius expectedRadius = + new TextOverlayTransformationRadiusUnionMember1(); Rotation expectedRotation = 0; string expectedTypography = "typography"; TextOverlayTransformationWidth expectedWidth = 0; @@ -70,7 +71,7 @@ public void SerializationRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -99,7 +100,7 @@ public void FieldRoundtripThroughSerialization_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -121,7 +122,8 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum expectedInnerAlignment = InnerAlignment.Left; LineHeight expectedLineHeight = 0; Padding expectedPadding = 0; - TextOverlayTransformationRadius expectedRadius = 0; + TextOverlayTransformationRadius expectedRadius = + new TextOverlayTransformationRadiusUnionMember1(); Rotation expectedRotation = 0; string expectedTypography = "typography"; TextOverlayTransformationWidth expectedWidth = 0; @@ -155,7 +157,7 @@ public void Validation_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -292,7 +294,7 @@ public void CopyConstructor_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, diff --git a/src/ImageKit.Tests/Models/TransformationTest.cs b/src/ImageKit.Tests/Models/TransformationTest.cs index 7db3251e..5aed46f3 100644 --- a/src/ImageKit.Tests/Models/TransformationTest.cs +++ b/src/ImageKit.Tests/Models/TransformationTest.cs @@ -80,7 +80,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -176,7 +176,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -339,7 +339,7 @@ public void SerializationRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -448,7 +448,7 @@ public void FieldRoundtripThroughSerialization_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -551,7 +551,7 @@ public void FieldRoundtripThroughSerialization_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -714,7 +714,7 @@ public void Validation_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -1177,7 +1177,7 @@ public void CopyConstructor_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, diff --git a/src/ImageKit.Tests/Models/VideoOverlayTest.cs b/src/ImageKit.Tests/Models/VideoOverlayTest.cs index d1e345e4..6147caf3 100644 --- a/src/ImageKit.Tests/Models/VideoOverlayTest.cs +++ b/src/ImageKit.Tests/Models/VideoOverlayTest.cs @@ -102,7 +102,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -223,7 +223,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -360,7 +360,7 @@ public void SerializationRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -493,7 +493,7 @@ public void FieldRoundtripThroughSerialization_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -621,7 +621,7 @@ public void FieldRoundtripThroughSerialization_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -758,7 +758,7 @@ public void Validation_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -955,7 +955,7 @@ public void CopyConstructor_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -1071,7 +1071,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -1176,7 +1176,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -1294,7 +1294,7 @@ public void SerializationRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -1411,7 +1411,7 @@ public void FieldRoundtripThroughSerialization_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -1523,7 +1523,7 @@ public void FieldRoundtripThroughSerialization_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -1641,7 +1641,7 @@ public void Validation_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, @@ -1804,7 +1804,7 @@ public void CopyConstructor_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), Rotation = 0, Typography = "typography", Width = 0, diff --git a/src/ImageKit.Tests/Models/Webhooks/FileCreateEventTest.cs b/src/ImageKit.Tests/Models/Webhooks/FileCreateEventTest.cs index 83f1225d..95db784a 100644 --- a/src/ImageKit.Tests/Models/Webhooks/FileCreateEventTest.cs +++ b/src/ImageKit.Tests/Models/Webhooks/FileCreateEventTest.cs @@ -58,7 +58,13 @@ public void FieldRoundtrip_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -126,7 +132,13 @@ public void FieldRoundtrip_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -204,7 +216,13 @@ public void SerializationRoundtrip_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -286,7 +304,13 @@ public void FieldRoundtripThroughSerialization_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -361,7 +385,13 @@ public void FieldRoundtripThroughSerialization_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -439,7 +469,13 @@ public void Validation_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -515,7 +551,13 @@ public void CopyConstructor_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -594,7 +636,13 @@ public void FieldRoundtrip_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -660,7 +708,13 @@ public void FieldRoundtrip_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -736,7 +790,13 @@ public void SerializationRoundtrip_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -816,7 +876,13 @@ public void FieldRoundtripThroughSerialization_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -889,7 +955,13 @@ public void FieldRoundtripThroughSerialization_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -965,7 +1037,13 @@ public void Validation_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -1039,7 +1117,13 @@ public void CopyConstructor_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", diff --git a/src/ImageKit.Tests/Models/Webhooks/FileUpdateEventTest.cs b/src/ImageKit.Tests/Models/Webhooks/FileUpdateEventTest.cs index a4d57dc9..19bcf67c 100644 --- a/src/ImageKit.Tests/Models/Webhooks/FileUpdateEventTest.cs +++ b/src/ImageKit.Tests/Models/Webhooks/FileUpdateEventTest.cs @@ -58,7 +58,13 @@ public void FieldRoundtrip_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -126,7 +132,13 @@ public void FieldRoundtrip_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -204,7 +216,13 @@ public void SerializationRoundtrip_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -286,7 +304,13 @@ public void FieldRoundtripThroughSerialization_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -361,7 +385,13 @@ public void FieldRoundtripThroughSerialization_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -439,7 +469,13 @@ public void Validation_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -515,7 +551,13 @@ public void CopyConstructor_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -594,7 +636,13 @@ public void FieldRoundtrip_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -660,7 +708,13 @@ public void FieldRoundtrip_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -736,7 +790,13 @@ public void SerializationRoundtrip_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -816,7 +876,13 @@ public void FieldRoundtripThroughSerialization_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -889,7 +955,13 @@ public void FieldRoundtripThroughSerialization_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -965,7 +1037,13 @@ public void Validation_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -1039,7 +1117,13 @@ public void CopyConstructor_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", diff --git a/src/ImageKit.Tests/Models/Webhooks/FileVersionCreateEventTest.cs b/src/ImageKit.Tests/Models/Webhooks/FileVersionCreateEventTest.cs index 7c386988..dd26a01e 100644 --- a/src/ImageKit.Tests/Models/Webhooks/FileVersionCreateEventTest.cs +++ b/src/ImageKit.Tests/Models/Webhooks/FileVersionCreateEventTest.cs @@ -58,7 +58,13 @@ public void FieldRoundtrip_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -126,7 +132,13 @@ public void FieldRoundtrip_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -204,7 +216,13 @@ public void SerializationRoundtrip_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -286,7 +304,13 @@ public void FieldRoundtripThroughSerialization_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -361,7 +385,13 @@ public void FieldRoundtripThroughSerialization_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -439,7 +469,13 @@ public void Validation_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -515,7 +551,13 @@ public void CopyConstructor_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -594,7 +636,13 @@ public void FieldRoundtrip_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -660,7 +708,13 @@ public void FieldRoundtrip_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -736,7 +790,13 @@ public void SerializationRoundtrip_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -816,7 +876,13 @@ public void FieldRoundtripThroughSerialization_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -889,7 +955,13 @@ public void FieldRoundtripThroughSerialization_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -965,7 +1037,13 @@ public void Validation_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -1039,7 +1117,13 @@ public void CopyConstructor_Works() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", diff --git a/src/ImageKit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs b/src/ImageKit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs index b19ae6fa..c8be295a 100644 --- a/src/ImageKit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs +++ b/src/ImageKit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs @@ -276,7 +276,13 @@ public void UploadPreTransformSuccessValidationWorks() new() { Type = Webhooks::SelectedFieldsSchemaItemType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Webhooks::UnnamedSchemaWithArrayParent13(true), + new Webhooks::UnnamedSchemaWithArrayParent13(10), + new Webhooks::UnnamedSchemaWithArrayParent13("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -433,7 +439,13 @@ public void FileCreateValidationWorks() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -508,7 +520,13 @@ public void FileUpdateValidationWorks() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -596,7 +614,13 @@ public void FileVersionCreateValidationWorks() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -920,7 +944,13 @@ public void UploadPreTransformSuccessSerializationRoundtripWorks() new() { Type = Webhooks::SelectedFieldsSchemaItemType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Webhooks::UnnamedSchemaWithArrayParent13(true), + new Webhooks::UnnamedSchemaWithArrayParent13(10), + new Webhooks::UnnamedSchemaWithArrayParent13("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -1101,7 +1131,13 @@ public void FileCreateSerializationRoundtripWorks() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -1182,7 +1218,13 @@ public void FileUpdateSerializationRoundtripWorks() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -1282,7 +1324,13 @@ public void FileVersionCreateSerializationRoundtripWorks() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", diff --git a/src/ImageKit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs b/src/ImageKit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs index 9a2423c5..15e958f9 100644 --- a/src/ImageKit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs +++ b/src/ImageKit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs @@ -276,7 +276,13 @@ public void UploadPreTransformSuccessValidationWorks() new() { Type = Webhooks::SelectedFieldsSchemaItemType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Webhooks::UnnamedSchemaWithArrayParent13(true), + new Webhooks::UnnamedSchemaWithArrayParent13(10), + new Webhooks::UnnamedSchemaWithArrayParent13("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -433,7 +439,13 @@ public void FileCreateValidationWorks() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -508,7 +520,13 @@ public void FileUpdateValidationWorks() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -596,7 +614,13 @@ public void FileVersionCreateValidationWorks() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -920,7 +944,13 @@ public void UploadPreTransformSuccessSerializationRoundtripWorks() new() { Type = Webhooks::SelectedFieldsSchemaItemType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Webhooks::UnnamedSchemaWithArrayParent13(true), + new Webhooks::UnnamedSchemaWithArrayParent13(10), + new Webhooks::UnnamedSchemaWithArrayParent13("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -1101,7 +1131,13 @@ public void FileCreateSerializationRoundtripWorks() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -1182,7 +1218,13 @@ public void FileUpdateSerializationRoundtripWorks() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -1282,7 +1324,13 @@ public void FileVersionCreateSerializationRoundtripWorks() new() { Type = Files::Type.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new Files::UnnamedSchemaWithArrayParent10(true), + new Files::UnnamedSchemaWithArrayParent10(10), + new Files::UnnamedSchemaWithArrayParent10("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", diff --git a/src/ImageKit.Tests/Models/Webhooks/UploadPreTransformSuccessEventTest.cs b/src/ImageKit.Tests/Models/Webhooks/UploadPreTransformSuccessEventTest.cs index 3990d21f..da9ad81d 100644 --- a/src/ImageKit.Tests/Models/Webhooks/UploadPreTransformSuccessEventTest.cs +++ b/src/ImageKit.Tests/Models/Webhooks/UploadPreTransformSuccessEventTest.cs @@ -145,7 +145,13 @@ public void FieldRoundtrip_Works() new() { Type = SelectedFieldsSchemaItemType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent13(true), + new UnnamedSchemaWithArrayParent13(10), + new UnnamedSchemaWithArrayParent13("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -298,7 +304,13 @@ public void FieldRoundtrip_Works() new() { Type = SelectedFieldsSchemaItemType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent13(true), + new UnnamedSchemaWithArrayParent13(10), + new UnnamedSchemaWithArrayParent13("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -466,7 +478,13 @@ public void SerializationRoundtrip_Works() new() { Type = SelectedFieldsSchemaItemType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent13(true), + new UnnamedSchemaWithArrayParent13(10), + new UnnamedSchemaWithArrayParent13("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -633,7 +651,13 @@ public void FieldRoundtripThroughSerialization_Works() new() { Type = SelectedFieldsSchemaItemType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent13(true), + new UnnamedSchemaWithArrayParent13(10), + new UnnamedSchemaWithArrayParent13("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -793,7 +817,13 @@ public void FieldRoundtripThroughSerialization_Works() new() { Type = SelectedFieldsSchemaItemType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent13(true), + new UnnamedSchemaWithArrayParent13(10), + new UnnamedSchemaWithArrayParent13("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -961,7 +991,13 @@ public void Validation_Works() new() { Type = SelectedFieldsSchemaItemType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent13(true), + new UnnamedSchemaWithArrayParent13(10), + new UnnamedSchemaWithArrayParent13("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -1122,7 +1158,13 @@ public void CopyConstructor_Works() new() { Type = SelectedFieldsSchemaItemType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent13(true), + new UnnamedSchemaWithArrayParent13(10), + new UnnamedSchemaWithArrayParent13("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -1286,7 +1328,13 @@ public void FieldRoundtrip_Works() new() { Type = SelectedFieldsSchemaItemType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent13(true), + new UnnamedSchemaWithArrayParent13(10), + new UnnamedSchemaWithArrayParent13("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -1437,7 +1485,13 @@ public void FieldRoundtrip_Works() new() { Type = SelectedFieldsSchemaItemType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent13(true), + new UnnamedSchemaWithArrayParent13(10), + new UnnamedSchemaWithArrayParent13("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -1605,7 +1659,13 @@ public void SerializationRoundtrip_Works() new() { Type = SelectedFieldsSchemaItemType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent13(true), + new UnnamedSchemaWithArrayParent13(10), + new UnnamedSchemaWithArrayParent13("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -1771,7 +1831,13 @@ public void FieldRoundtripThroughSerialization_Works() new() { Type = SelectedFieldsSchemaItemType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent13(true), + new UnnamedSchemaWithArrayParent13(10), + new UnnamedSchemaWithArrayParent13("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -1930,7 +1996,13 @@ public void FieldRoundtripThroughSerialization_Works() new() { Type = SelectedFieldsSchemaItemType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent13(true), + new UnnamedSchemaWithArrayParent13(10), + new UnnamedSchemaWithArrayParent13("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -2098,7 +2170,13 @@ public void Validation_Works() new() { Type = SelectedFieldsSchemaItemType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent13(true), + new UnnamedSchemaWithArrayParent13(10), + new UnnamedSchemaWithArrayParent13("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -2257,7 +2335,13 @@ public void CopyConstructor_Works() new() { Type = SelectedFieldsSchemaItemType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent13(true), + new UnnamedSchemaWithArrayParent13(10), + new UnnamedSchemaWithArrayParent13("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -2418,7 +2502,13 @@ public void FieldRoundtrip_Works() new() { Type = SelectedFieldsSchemaItemType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent13(true), + new UnnamedSchemaWithArrayParent13(10), + new UnnamedSchemaWithArrayParent13("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -2564,7 +2654,13 @@ public void FieldRoundtrip_Works() new() { Type = SelectedFieldsSchemaItemType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent13(true), + new UnnamedSchemaWithArrayParent13(10), + new UnnamedSchemaWithArrayParent13("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -2772,7 +2868,13 @@ public void SerializationRoundtrip_Works() new() { Type = SelectedFieldsSchemaItemType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent13(true), + new UnnamedSchemaWithArrayParent13(10), + new UnnamedSchemaWithArrayParent13("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -2933,7 +3035,13 @@ public void FieldRoundtripThroughSerialization_Works() new() { Type = SelectedFieldsSchemaItemType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent13(true), + new UnnamedSchemaWithArrayParent13(10), + new UnnamedSchemaWithArrayParent13("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -3087,7 +3195,13 @@ public void FieldRoundtripThroughSerialization_Works() new() { Type = SelectedFieldsSchemaItemType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent13(true), + new UnnamedSchemaWithArrayParent13(10), + new UnnamedSchemaWithArrayParent13("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -3295,7 +3409,13 @@ public void Validation_Works() new() { Type = SelectedFieldsSchemaItemType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent13(true), + new UnnamedSchemaWithArrayParent13(10), + new UnnamedSchemaWithArrayParent13("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -3657,7 +3777,13 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() new() { Type = SelectedFieldsSchemaItemType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent13(true), + new UnnamedSchemaWithArrayParent13(10), + new UnnamedSchemaWithArrayParent13("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -3805,7 +3931,13 @@ public void OptionalNullablePropertiesUnsetValidation_Works() new() { Type = SelectedFieldsSchemaItemType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent13(true), + new UnnamedSchemaWithArrayParent13(10), + new UnnamedSchemaWithArrayParent13("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -3948,7 +4080,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() new() { Type = SelectedFieldsSchemaItemType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent13(true), + new UnnamedSchemaWithArrayParent13(10), + new UnnamedSchemaWithArrayParent13("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -4100,7 +4238,13 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() new() { Type = SelectedFieldsSchemaItemType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent13(true), + new UnnamedSchemaWithArrayParent13(10), + new UnnamedSchemaWithArrayParent13("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -4257,7 +4401,13 @@ public void CopyConstructor_Works() new() { Type = SelectedFieldsSchemaItemType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent13(true), + new UnnamedSchemaWithArrayParent13(10), + new UnnamedSchemaWithArrayParent13("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -4914,7 +5064,13 @@ public void FieldRoundtrip_Works() var model = new SelectedFieldsSchemaItem { Type = SelectedFieldsSchemaItemType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent13(true), + new UnnamedSchemaWithArrayParent13(10), + new UnnamedSchemaWithArrayParent13("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -4927,7 +5083,13 @@ public void FieldRoundtrip_Works() ApiEnum expectedType = SelectedFieldsSchemaItemType.Text; - DefaultValue expectedDefaultValue = "string"; + DefaultValue expectedDefaultValue = new( + [ + new UnnamedSchemaWithArrayParent13(true), + new UnnamedSchemaWithArrayParent13(10), + new UnnamedSchemaWithArrayParent13("Hello"), + ] + ); bool expectedIsValueRequired = true; double expectedMaxLength = 0; MaxValue expectedMaxValue = "string"; @@ -4960,7 +5122,13 @@ public void SerializationRoundtrip_Works() var model = new SelectedFieldsSchemaItem { Type = SelectedFieldsSchemaItemType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent13(true), + new UnnamedSchemaWithArrayParent13(10), + new UnnamedSchemaWithArrayParent13("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -4986,7 +5154,13 @@ public void FieldRoundtripThroughSerialization_Works() var model = new SelectedFieldsSchemaItem { Type = SelectedFieldsSchemaItemType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent13(true), + new UnnamedSchemaWithArrayParent13(10), + new UnnamedSchemaWithArrayParent13("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -5006,7 +5180,13 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum expectedType = SelectedFieldsSchemaItemType.Text; - DefaultValue expectedDefaultValue = "string"; + DefaultValue expectedDefaultValue = new( + [ + new UnnamedSchemaWithArrayParent13(true), + new UnnamedSchemaWithArrayParent13(10), + new UnnamedSchemaWithArrayParent13("Hello"), + ] + ); bool expectedIsValueRequired = true; double expectedMaxLength = 0; MaxValue expectedMaxValue = "string"; @@ -5039,7 +5219,13 @@ public void Validation_Works() var model = new SelectedFieldsSchemaItem { Type = SelectedFieldsSchemaItemType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent13(true), + new UnnamedSchemaWithArrayParent13(10), + new UnnamedSchemaWithArrayParent13("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", @@ -5153,7 +5339,13 @@ public void CopyConstructor_Works() var model = new SelectedFieldsSchemaItem { Type = SelectedFieldsSchemaItemType.Text, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent13(true), + new UnnamedSchemaWithArrayParent13(10), + new UnnamedSchemaWithArrayParent13("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = "string", diff --git a/src/ImageKit.Tests/Services/CustomMetadataFieldServiceTest.cs b/src/ImageKit.Tests/Services/CustomMetadataFieldServiceTest.cs index fa2490a2..0d6b464b 100644 --- a/src/ImageKit.Tests/Services/CustomMetadataFieldServiceTest.cs +++ b/src/ImageKit.Tests/Services/CustomMetadataFieldServiceTest.cs @@ -16,7 +16,13 @@ public async Task Create_Works() Schema = new() { Type = Type.Number, - DefaultValue = "string", + DefaultValue = new( + [ + new UnnamedSchemaWithArrayParent1(true), + new UnnamedSchemaWithArrayParent1(10), + new UnnamedSchemaWithArrayParent1("Hello"), + ] + ), IsValueRequired = true, MaxLength = 0, MaxValue = 3000, From edde1fb32d9c70580500de0595a2705d52381411 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 13 Apr 2026 00:58:24 +0000 Subject: [PATCH 098/129] fix(api): extract shared schemas to prevent Go webhook union breaking changes --- .stats.yml | 6 +++--- .../Models/Beta/V2/Files/FileUploadResponse.cs | 7 ++++--- src/ImageKit/Models/Files/File.cs | 17 ++++++++++++----- src/ImageKit/Models/Files/FileUpdateResponse.cs | 15 +++++++++++---- src/ImageKit/Models/Files/FileUploadResponse.cs | 7 ++++--- .../Webhooks/UploadPreTransformSuccessEvent.cs | 7 ++++--- 6 files changed, 38 insertions(+), 21 deletions(-) diff --git a/.stats.yml b/.stats.yml index aae6cba6..92aebe1f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-d73a37dc3426586109bd153f02c6a605036b6a7396bba5173d013468c5291ce6.yml -openapi_spec_hash: c193c6e557ff477481ec8d5ac8a0c96e -config_hash: 32b155378f65c234d3abeb18519fb3cd +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-7c4c23556be689ded6bcafd05e1645b82239521c9c841c0f7e76336e2eefcffa.yml +openapi_spec_hash: eca5b039a0066c6536296248c3a80854 +config_hash: e3c2679d25f6235381dfb11962fbf3d9 diff --git a/src/ImageKit/Models/Beta/V2/Files/FileUploadResponse.cs b/src/ImageKit/Models/Beta/V2/Files/FileUploadResponse.cs index d6f311e8..418a5a32 100644 --- a/src/ImageKit/Models/Beta/V2/Files/FileUploadResponse.cs +++ b/src/ImageKit/Models/Beta/V2/Files/FileUploadResponse.cs @@ -18,7 +18,9 @@ namespace ImageKit.Models.Beta.V2.Files; public sealed record class FileUploadResponse : JsonModel { /// - /// An array of tags assigned to the uploaded file by auto tagging. + /// Array of `AITags` associated with the image. If no `AITags` are set, it will + /// be null. These tags can be added using the `google-auto-tagging` or `aws-auto-tagging` + /// extensions. /// public IReadOnlyList? AITags { @@ -697,8 +699,7 @@ public string? Name } /// - /// Array of `AITags` associated with the image. If no `AITags` are set, it will - /// be null. These tags can be added using the `google-auto-tagging` or `aws-auto-tagging` extensions. + /// Source of the tag. Possible values are `google-auto-tagging` and `aws-auto-tagging`. /// public string? Source { diff --git a/src/ImageKit/Models/Files/File.cs b/src/ImageKit/Models/Files/File.cs index 7a56692c..321c96cf 100644 --- a/src/ImageKit/Models/Files/File.cs +++ b/src/ImageKit/Models/Files/File.cs @@ -17,7 +17,9 @@ namespace ImageKit.Models.Files; public sealed record class File : JsonModel { /// - /// An array of tags assigned to the file by auto tagging. + /// Array of `AITags` associated with the image. If no `AITags` are set, it will + /// be null. These tags can be added using the `google-auto-tagging` or `aws-auto-tagging` + /// extensions. /// public IReadOnlyList? AITags { @@ -113,7 +115,11 @@ public string? CustomCoordinates } /// - /// An object with custom metadata for the file. + /// A key-value data associated with the asset. Use `responseField` in API request + /// to get `customMetadata` in the upload API response. Before setting any custom + /// metadata on an asset, you have to create the field using custom metadata fields + /// API. Send `customMetadata` in `responseFields` in API request to get the value + /// of this field. /// public IReadOnlyDictionary? CustomMetadata { @@ -183,7 +189,8 @@ public long? Duration /// /// Consolidated embedded metadata associated with the file. It includes exif, - /// iptc, and xmp data. + /// iptc, and xmp data. Send `embeddedMetadata` in `responseFields` in API request + /// to get embeddedMetadata in the upload API response. /// public IReadOnlyDictionary? EmbeddedMetadata { @@ -560,7 +567,7 @@ public string? Url } /// - /// An object with details of the file version. + /// An object containing the file or file version's `id` (versionId) and `name`. /// public VersionInfo? VersionInfo { @@ -2644,7 +2651,7 @@ public override void Write(Utf8JsonWriter writer, FileType value, JsonSerializer } /// -/// An object with details of the file version. +/// An object containing the file or file version's `id` (versionId) and `name`. /// [JsonConverter(typeof(JsonModelConverter))] public sealed record class VersionInfo : JsonModel diff --git a/src/ImageKit/Models/Files/FileUpdateResponse.cs b/src/ImageKit/Models/Files/FileUpdateResponse.cs index ed38ad4d..60933e7b 100644 --- a/src/ImageKit/Models/Files/FileUpdateResponse.cs +++ b/src/ImageKit/Models/Files/FileUpdateResponse.cs @@ -17,7 +17,9 @@ namespace ImageKit.Models.Files; public sealed record class FileUpdateResponse : JsonModel { /// - /// An array of tags assigned to the file by auto tagging. + /// Array of `AITags` associated with the image. If no `AITags` are set, it will + /// be null. These tags can be added using the `google-auto-tagging` or `aws-auto-tagging` + /// extensions. /// public IReadOnlyList? AITags { @@ -113,7 +115,11 @@ public string? CustomCoordinates } /// - /// An object with custom metadata for the file. + /// A key-value data associated with the asset. Use `responseField` in API request + /// to get `customMetadata` in the upload API response. Before setting any custom + /// metadata on an asset, you have to create the field using custom metadata fields + /// API. Send `customMetadata` in `responseFields` in API request to get the value + /// of this field. /// public IReadOnlyDictionary? CustomMetadata { @@ -183,7 +189,8 @@ public long? Duration /// /// Consolidated embedded metadata associated with the file. It includes exif, - /// iptc, and xmp data. + /// iptc, and xmp data. Send `embeddedMetadata` in `responseFields` in API request + /// to get embeddedMetadata in the upload API response. /// public IReadOnlyDictionary? EmbeddedMetadata { @@ -560,7 +567,7 @@ public string? Url } /// - /// An object with details of the file version. + /// An object containing the file or file version's `id` (versionId) and `name`. /// public VersionInfo? VersionInfo { diff --git a/src/ImageKit/Models/Files/FileUploadResponse.cs b/src/ImageKit/Models/Files/FileUploadResponse.cs index dda141d3..74f270f5 100644 --- a/src/ImageKit/Models/Files/FileUploadResponse.cs +++ b/src/ImageKit/Models/Files/FileUploadResponse.cs @@ -17,7 +17,9 @@ namespace ImageKit.Models.Files; public sealed record class FileUploadResponse : JsonModel { /// - /// An array of tags assigned to the uploaded file by auto tagging. + /// Array of `AITags` associated with the image. If no `AITags` are set, it will + /// be null. These tags can be added using the `google-auto-tagging` or `aws-auto-tagging` + /// extensions. /// public IReadOnlyList? AITags { @@ -706,8 +708,7 @@ public string? Name } /// - /// Array of `AITags` associated with the image. If no `AITags` are set, it will - /// be null. These tags can be added using the `google-auto-tagging` or `aws-auto-tagging` extensions. + /// Source of the tag. Possible values are `google-auto-tagging` and `aws-auto-tagging`. /// public string? Source { diff --git a/src/ImageKit/Models/Webhooks/UploadPreTransformSuccessEvent.cs b/src/ImageKit/Models/Webhooks/UploadPreTransformSuccessEvent.cs index 941492c9..14bc0326 100644 --- a/src/ImageKit/Models/Webhooks/UploadPreTransformSuccessEvent.cs +++ b/src/ImageKit/Models/Webhooks/UploadPreTransformSuccessEvent.cs @@ -289,7 +289,9 @@ IReadOnlyDictionary rawData public sealed record class UploadPreTransformSuccessEventIntersectionMember1Data : JsonModel { /// - /// An array of tags assigned to the uploaded file by auto tagging. + /// Array of `AITags` associated with the image. If no `AITags` are set, it will + /// be null. These tags can be added using the `google-auto-tagging` or `aws-auto-tagging` + /// extensions. /// public IReadOnlyList? AITags { @@ -976,8 +978,7 @@ public string? Name } /// - /// Array of `AITags` associated with the image. If no `AITags` are set, it will - /// be null. These tags can be added using the `google-auto-tagging` or `aws-auto-tagging` extensions. + /// Source of the tag. Possible values are `google-auto-tagging` and `aws-auto-tagging`. /// public string? Source { From 96a592274f12921a2c617a440f160b0805d05c27 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 13 Apr 2026 01:00:04 +0000 Subject: [PATCH 099/129] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 92aebe1f..c4bde9f0 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-7c4c23556be689ded6bcafd05e1645b82239521c9c841c0f7e76336e2eefcffa.yml openapi_spec_hash: eca5b039a0066c6536296248c3a80854 -config_hash: e3c2679d25f6235381dfb11962fbf3d9 +config_hash: f914ebc9670f6e7c7751660caa4e5556 From f131bc5feaa7a3a8159f0a02f61a5693d70d3a41 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 13 Apr 2026 01:33:05 +0000 Subject: [PATCH 100/129] refactor: AITags to singular AITag schema with array items pattern --- .stats.yml | 6 +++--- .../Beta/V2/Files/FileUploadResponse.cs | 8 +++++--- src/ImageKit/Models/Files/File.cs | 20 +++++++++---------- .../Models/Files/FileUpdateResponse.cs | 14 ++++--------- .../Models/Files/FileUploadResponse.cs | 8 +++++--- .../UploadPreTransformSuccessEvent.cs | 8 +++++--- 6 files changed, 31 insertions(+), 33 deletions(-) diff --git a/.stats.yml b/.stats.yml index c4bde9f0..3d19128a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-7c4c23556be689ded6bcafd05e1645b82239521c9c841c0f7e76336e2eefcffa.yml -openapi_spec_hash: eca5b039a0066c6536296248c3a80854 -config_hash: f914ebc9670f6e7c7751660caa4e5556 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-70c42eda2bee929830b2537f758400a58dded1f1ef5686a286e2469c35a041a0.yml +openapi_spec_hash: cdaeed824e91657b45092765cf55eb42 +config_hash: e3c2679d25f6235381dfb11962fbf3d9 diff --git a/src/ImageKit/Models/Beta/V2/Files/FileUploadResponse.cs b/src/ImageKit/Models/Beta/V2/Files/FileUploadResponse.cs index 418a5a32..8d5da5b7 100644 --- a/src/ImageKit/Models/Beta/V2/Files/FileUploadResponse.cs +++ b/src/ImageKit/Models/Beta/V2/Files/FileUploadResponse.cs @@ -18,9 +18,7 @@ namespace ImageKit.Models.Beta.V2.Files; public sealed record class FileUploadResponse : JsonModel { /// - /// Array of `AITags` associated with the image. If no `AITags` are set, it will - /// be null. These tags can be added using the `google-auto-tagging` or `aws-auto-tagging` - /// extensions. + /// An array of tags assigned to the uploaded file by auto tagging. /// public IReadOnlyList? AITags { @@ -653,6 +651,10 @@ public FileUploadResponse FromRawUnchecked(IReadOnlyDictionary +/// AI-generated tag associated with an image. These tags can be added using the `google-auto-tagging` +/// or `aws-auto-tagging` extensions. +/// [JsonConverter(typeof(JsonModelConverter))] public sealed record class AITag : JsonModel { diff --git a/src/ImageKit/Models/Files/File.cs b/src/ImageKit/Models/Files/File.cs index 321c96cf..991280e9 100644 --- a/src/ImageKit/Models/Files/File.cs +++ b/src/ImageKit/Models/Files/File.cs @@ -17,9 +17,8 @@ namespace ImageKit.Models.Files; public sealed record class File : JsonModel { /// - /// Array of `AITags` associated with the image. If no `AITags` are set, it will - /// be null. These tags can be added using the `google-auto-tagging` or `aws-auto-tagging` - /// extensions. + /// Array of AI-generated tags associated with the image. If no AITags are set, + /// it will be null. /// public IReadOnlyList? AITags { @@ -115,11 +114,7 @@ public string? CustomCoordinates } /// - /// A key-value data associated with the asset. Use `responseField` in API request - /// to get `customMetadata` in the upload API response. Before setting any custom - /// metadata on an asset, you have to create the field using custom metadata fields - /// API. Send `customMetadata` in `responseFields` in API request to get the value - /// of this field. + /// An object with custom metadata for the file. /// public IReadOnlyDictionary? CustomMetadata { @@ -189,8 +184,7 @@ public long? Duration /// /// Consolidated embedded metadata associated with the file. It includes exif, - /// iptc, and xmp data. Send `embeddedMetadata` in `responseFields` in API request - /// to get embeddedMetadata in the upload API response. + /// iptc, and xmp data. /// public IReadOnlyDictionary? EmbeddedMetadata { @@ -567,7 +561,7 @@ public string? Url } /// - /// An object containing the file or file version's `id` (versionId) and `name`. + /// An object with details of the file version. /// public VersionInfo? VersionInfo { @@ -706,6 +700,10 @@ public File FromRawUnchecked(IReadOnlyDictionary rawData) = File.FromRawUnchecked(rawData); } +/// +/// AI-generated tag associated with an image. These tags can be added using the `google-auto-tagging` +/// or `aws-auto-tagging` extensions. +/// [JsonConverter(typeof(JsonModelConverter))] public sealed record class AITag : JsonModel { diff --git a/src/ImageKit/Models/Files/FileUpdateResponse.cs b/src/ImageKit/Models/Files/FileUpdateResponse.cs index 60933e7b..1453997f 100644 --- a/src/ImageKit/Models/Files/FileUpdateResponse.cs +++ b/src/ImageKit/Models/Files/FileUpdateResponse.cs @@ -17,9 +17,8 @@ namespace ImageKit.Models.Files; public sealed record class FileUpdateResponse : JsonModel { /// - /// Array of `AITags` associated with the image. If no `AITags` are set, it will - /// be null. These tags can be added using the `google-auto-tagging` or `aws-auto-tagging` - /// extensions. + /// Array of AI-generated tags associated with the image. If no AITags are set, + /// it will be null. /// public IReadOnlyList? AITags { @@ -115,11 +114,7 @@ public string? CustomCoordinates } /// - /// A key-value data associated with the asset. Use `responseField` in API request - /// to get `customMetadata` in the upload API response. Before setting any custom - /// metadata on an asset, you have to create the field using custom metadata fields - /// API. Send `customMetadata` in `responseFields` in API request to get the value - /// of this field. + /// A key-value data associated with the asset. /// public IReadOnlyDictionary? CustomMetadata { @@ -189,8 +184,7 @@ public long? Duration /// /// Consolidated embedded metadata associated with the file. It includes exif, - /// iptc, and xmp data. Send `embeddedMetadata` in `responseFields` in API request - /// to get embeddedMetadata in the upload API response. + /// iptc, and xmp data. /// public IReadOnlyDictionary? EmbeddedMetadata { diff --git a/src/ImageKit/Models/Files/FileUploadResponse.cs b/src/ImageKit/Models/Files/FileUploadResponse.cs index 74f270f5..000ed3fc 100644 --- a/src/ImageKit/Models/Files/FileUploadResponse.cs +++ b/src/ImageKit/Models/Files/FileUploadResponse.cs @@ -17,9 +17,7 @@ namespace ImageKit.Models.Files; public sealed record class FileUploadResponse : JsonModel { /// - /// Array of `AITags` associated with the image. If no `AITags` are set, it will - /// be null. These tags can be added using the `google-auto-tagging` or `aws-auto-tagging` - /// extensions. + /// An array of tags assigned to the uploaded file by auto tagging. /// public IReadOnlyList? AITags { @@ -662,6 +660,10 @@ public FileUploadResponse FromRawUnchecked(IReadOnlyDictionary +/// AI-generated tag associated with an image. These tags can be added using the `google-auto-tagging` +/// or `aws-auto-tagging` extensions. +/// [JsonConverter(typeof(JsonModelConverter))] public sealed record class FileUploadResponseAITag : JsonModel { diff --git a/src/ImageKit/Models/Webhooks/UploadPreTransformSuccessEvent.cs b/src/ImageKit/Models/Webhooks/UploadPreTransformSuccessEvent.cs index 14bc0326..b7ae0c48 100644 --- a/src/ImageKit/Models/Webhooks/UploadPreTransformSuccessEvent.cs +++ b/src/ImageKit/Models/Webhooks/UploadPreTransformSuccessEvent.cs @@ -289,9 +289,7 @@ IReadOnlyDictionary rawData public sealed record class UploadPreTransformSuccessEventIntersectionMember1Data : JsonModel { /// - /// Array of `AITags` associated with the image. If no `AITags` are set, it will - /// be null. These tags can be added using the `google-auto-tagging` or `aws-auto-tagging` - /// extensions. + /// An array of tags assigned to the uploaded file by auto tagging. /// public IReadOnlyList? AITags { @@ -932,6 +930,10 @@ IReadOnlyDictionary rawData ) => UploadPreTransformSuccessEventIntersectionMember1Data.FromRawUnchecked(rawData); } +/// +/// AI-generated tag associated with an image. These tags can be added using the `google-auto-tagging` +/// or `aws-auto-tagging` extensions. +/// [JsonConverter(typeof(JsonModelConverter))] public sealed record class AITag : JsonModel { From 7f4c93104c19958fe8036f659f1484416b349705 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 13 Apr 2026 02:08:48 +0000 Subject: [PATCH 101/129] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 3d19128a..1ee5069c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-70c42eda2bee929830b2537f758400a58dded1f1ef5686a286e2469c35a041a0.yml openapi_spec_hash: cdaeed824e91657b45092765cf55eb42 -config_hash: e3c2679d25f6235381dfb11962fbf3d9 +config_hash: 83967503e501e4199b4042d0d0f2b615 From b1928aa69e2bbe51e6c653dca980fd35f8378dcc Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 15 Apr 2026 13:33:22 +0000 Subject: [PATCH 102/129] fix(tests): round-trip urls correctly --- .../Origins/OriginCreateParamsTest.cs | 4 +- .../Origins/OriginDeleteParamsTest.cs | 4 +- .../Accounts/Origins/OriginGetParamsTest.cs | 4 +- .../Origins/OriginUpdateParamsTest.cs | 4 +- .../UrlEndpointCreateParamsTest.cs | 4 +- .../UrlEndpointDeleteParamsTest.cs | 4 +- .../UrlEndpoints/UrlEndpointGetParamsTest.cs | 4 +- .../UrlEndpointUpdateParamsTest.cs | 4 +- .../Accounts/Usage/UsageGetParamsTest.cs | 12 +++--- .../Models/Assets/AssetListParamsTest.cs | 12 +++--- .../Beta/V2/Files/FileUploadParamsTest.cs | 4 +- .../InvalidationCreateParamsTest.cs | 2 +- .../Invalidation/InvalidationGetParamsTest.cs | 4 +- .../CustomMetadataFieldCreateParamsTest.cs | 4 +- .../CustomMetadataFieldDeleteParamsTest.cs | 4 +- .../CustomMetadataFieldListParamsTest.cs | 12 +++--- .../CustomMetadataFieldUpdateParamsTest.cs | 4 +- .../Files/Bulk/BulkAddTagsParamsTest.cs | 2 +- .../Models/Files/Bulk/BulkDeleteParamsTest.cs | 7 +++- .../Files/Bulk/BulkRemoveAITagsParamsTest.cs | 4 +- .../Files/Bulk/BulkRemoveTagsParamsTest.cs | 4 +- .../Models/Files/FileCopyParamsTest.cs | 2 +- .../Models/Files/FileDeleteParamsTest.cs | 2 +- .../Models/Files/FileGetParamsTest.cs | 4 +- .../Models/Files/FileMoveParamsTest.cs | 2 +- .../Models/Files/FileRenameParamsTest.cs | 2 +- .../Models/Files/FileUpdateParamsTest.cs | 4 +- .../Models/Files/FileUploadParamsTest.cs | 4 +- .../Metadata/MetadataGetFromUrlParamsTest.cs | 8 ++-- .../Files/Metadata/MetadataGetParamsTest.cs | 4 +- .../Files/Versions/VersionDeleteParamsTest.cs | 7 +++- .../Files/Versions/VersionGetParamsTest.cs | 7 +++- .../Files/Versions/VersionListParamsTest.cs | 4 +- .../Versions/VersionRestoreParamsTest.cs | 8 ++-- .../Models/Folders/FolderCopyParamsTest.cs | 4 +- .../Models/Folders/FolderCreateParamsTest.cs | 2 +- .../Models/Folders/FolderDeleteParamsTest.cs | 2 +- .../Models/Folders/FolderMoveParamsTest.cs | 4 +- .../Models/Folders/FolderRenameParamsTest.cs | 4 +- .../Models/Folders/Job/JobGetParamsTest.cs | 2 +- .../SavedExtensionCreateParamsTest.cs | 4 +- .../SavedExtensionDeleteParamsTest.cs | 4 +- .../SavedExtensionGetParamsTest.cs | 4 +- .../SavedExtensionUpdateParamsTest.cs | 4 +- src/ImageKit.Tests/TestBase.cs | 40 +++++++++++++++++++ 45 files changed, 179 insertions(+), 60 deletions(-) diff --git a/src/ImageKit.Tests/Models/Accounts/Origins/OriginCreateParamsTest.cs b/src/ImageKit.Tests/Models/Accounts/Origins/OriginCreateParamsTest.cs index cf8f0d31..1f23bab3 100644 --- a/src/ImageKit.Tests/Models/Accounts/Origins/OriginCreateParamsTest.cs +++ b/src/ImageKit.Tests/Models/Accounts/Origins/OriginCreateParamsTest.cs @@ -55,7 +55,9 @@ public void Url_Works() var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); - Assert.Equal(new Uri("https://api.imagekit.io/v1/accounts/origins"), url); + Assert.True( + TestBase.UrisEqual(new Uri("https://api.imagekit.io/v1/accounts/origins"), url) + ); } [Fact] diff --git a/src/ImageKit.Tests/Models/Accounts/Origins/OriginDeleteParamsTest.cs b/src/ImageKit.Tests/Models/Accounts/Origins/OriginDeleteParamsTest.cs index de154ad9..25d61dee 100644 --- a/src/ImageKit.Tests/Models/Accounts/Origins/OriginDeleteParamsTest.cs +++ b/src/ImageKit.Tests/Models/Accounts/Origins/OriginDeleteParamsTest.cs @@ -22,7 +22,9 @@ public void Url_Works() var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); - Assert.Equal(new Uri("https://api.imagekit.io/v1/accounts/origins/id"), url); + Assert.True( + TestBase.UrisEqual(new Uri("https://api.imagekit.io/v1/accounts/origins/id"), url) + ); } [Fact] diff --git a/src/ImageKit.Tests/Models/Accounts/Origins/OriginGetParamsTest.cs b/src/ImageKit.Tests/Models/Accounts/Origins/OriginGetParamsTest.cs index 51509129..8abbdcea 100644 --- a/src/ImageKit.Tests/Models/Accounts/Origins/OriginGetParamsTest.cs +++ b/src/ImageKit.Tests/Models/Accounts/Origins/OriginGetParamsTest.cs @@ -22,7 +22,9 @@ public void Url_Works() var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); - Assert.Equal(new Uri("https://api.imagekit.io/v1/accounts/origins/id"), url); + Assert.True( + TestBase.UrisEqual(new Uri("https://api.imagekit.io/v1/accounts/origins/id"), url) + ); } [Fact] diff --git a/src/ImageKit.Tests/Models/Accounts/Origins/OriginUpdateParamsTest.cs b/src/ImageKit.Tests/Models/Accounts/Origins/OriginUpdateParamsTest.cs index 6828eb88..c0d66ad5 100644 --- a/src/ImageKit.Tests/Models/Accounts/Origins/OriginUpdateParamsTest.cs +++ b/src/ImageKit.Tests/Models/Accounts/Origins/OriginUpdateParamsTest.cs @@ -59,7 +59,9 @@ public void Url_Works() var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); - Assert.Equal(new Uri("https://api.imagekit.io/v1/accounts/origins/id"), url); + Assert.True( + TestBase.UrisEqual(new Uri("https://api.imagekit.io/v1/accounts/origins/id"), url) + ); } [Fact] diff --git a/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointCreateParamsTest.cs b/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointCreateParamsTest.cs index 971baa20..9e04fce2 100644 --- a/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointCreateParamsTest.cs +++ b/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointCreateParamsTest.cs @@ -77,7 +77,9 @@ public void Url_Works() var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); - Assert.Equal(new Uri("https://api.imagekit.io/v1/accounts/url-endpoints"), url); + Assert.True( + TestBase.UrisEqual(new Uri("https://api.imagekit.io/v1/accounts/url-endpoints"), url) + ); } [Fact] diff --git a/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointDeleteParamsTest.cs b/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointDeleteParamsTest.cs index f4dc5da0..2fd7c37c 100644 --- a/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointDeleteParamsTest.cs +++ b/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointDeleteParamsTest.cs @@ -22,7 +22,9 @@ public void Url_Works() var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); - Assert.Equal(new Uri("https://api.imagekit.io/v1/accounts/url-endpoints/id"), url); + Assert.True( + TestBase.UrisEqual(new Uri("https://api.imagekit.io/v1/accounts/url-endpoints/id"), url) + ); } [Fact] diff --git a/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointGetParamsTest.cs b/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointGetParamsTest.cs index cd8562ad..32457d84 100644 --- a/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointGetParamsTest.cs +++ b/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointGetParamsTest.cs @@ -22,7 +22,9 @@ public void Url_Works() var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); - Assert.Equal(new Uri("https://api.imagekit.io/v1/accounts/url-endpoints/id"), url); + Assert.True( + TestBase.UrisEqual(new Uri("https://api.imagekit.io/v1/accounts/url-endpoints/id"), url) + ); } [Fact] diff --git a/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParamsTest.cs b/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParamsTest.cs index 552ee2f1..63fdfdbc 100644 --- a/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParamsTest.cs +++ b/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParamsTest.cs @@ -96,7 +96,9 @@ public void Url_Works() var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); - Assert.Equal(new Uri("https://api.imagekit.io/v1/accounts/url-endpoints/id"), url); + Assert.True( + TestBase.UrisEqual(new Uri("https://api.imagekit.io/v1/accounts/url-endpoints/id"), url) + ); } [Fact] diff --git a/src/ImageKit.Tests/Models/Accounts/Usage/UsageGetParamsTest.cs b/src/ImageKit.Tests/Models/Accounts/Usage/UsageGetParamsTest.cs index d3f8003a..89c48fc7 100644 --- a/src/ImageKit.Tests/Models/Accounts/Usage/UsageGetParamsTest.cs +++ b/src/ImageKit.Tests/Models/Accounts/Usage/UsageGetParamsTest.cs @@ -24,11 +24,13 @@ public void Url_Works() var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); - Assert.Equal( - new Uri( - "https://api.imagekit.io/v1/accounts/usage?endDate=2019-12-27&startDate=2019-12-27" - ), - url + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.imagekit.io/v1/accounts/usage?endDate=2019-12-27&startDate=2019-12-27" + ), + url + ) ); } diff --git a/src/ImageKit.Tests/Models/Assets/AssetListParamsTest.cs b/src/ImageKit.Tests/Models/Assets/AssetListParamsTest.cs index 9058639f..c81eb7b3 100644 --- a/src/ImageKit.Tests/Models/Assets/AssetListParamsTest.cs +++ b/src/ImageKit.Tests/Models/Assets/AssetListParamsTest.cs @@ -107,11 +107,13 @@ public void Url_Works() var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); - Assert.Equal( - new Uri( - "https://api.imagekit.io/v1/files?fileType=all&limit=1&path=path&searchQuery=searchQuery&skip=0&sort=ASC_NAME&type=file" - ), - url + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.imagekit.io/v1/files?fileType=all&limit=1&path=path&searchQuery=searchQuery&skip=0&sort=ASC_NAME&type=file" + ), + url + ) ); } diff --git a/src/ImageKit.Tests/Models/Beta/V2/Files/FileUploadParamsTest.cs b/src/ImageKit.Tests/Models/Beta/V2/Files/FileUploadParamsTest.cs index df9cfb30..ce314fff 100644 --- a/src/ImageKit.Tests/Models/Beta/V2/Files/FileUploadParamsTest.cs +++ b/src/ImageKit.Tests/Models/Beta/V2/Files/FileUploadParamsTest.cs @@ -378,7 +378,9 @@ public void Url_Works() var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); - Assert.Equal(new Uri("https://api.imagekit.io/api/v2/files/upload"), url); + Assert.True( + TestBase.UrisEqual(new Uri("https://api.imagekit.io/api/v2/files/upload"), url) + ); } [Fact] diff --git a/src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationCreateParamsTest.cs b/src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationCreateParamsTest.cs index a42ee393..001f2d69 100644 --- a/src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationCreateParamsTest.cs +++ b/src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationCreateParamsTest.cs @@ -28,7 +28,7 @@ public void Url_Works() var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); - Assert.Equal(new Uri("https://api.imagekit.io/v1/files/purge"), url); + Assert.True(TestBase.UrisEqual(new Uri("https://api.imagekit.io/v1/files/purge"), url)); } [Fact] diff --git a/src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationGetParamsTest.cs b/src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationGetParamsTest.cs index 60def5ee..3cd3f946 100644 --- a/src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationGetParamsTest.cs +++ b/src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationGetParamsTest.cs @@ -22,7 +22,9 @@ public void Url_Works() var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); - Assert.Equal(new Uri("https://api.imagekit.io/v1/files/purge/requestId"), url); + Assert.True( + TestBase.UrisEqual(new Uri("https://api.imagekit.io/v1/files/purge/requestId"), url) + ); } [Fact] diff --git a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsTest.cs b/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsTest.cs index b43d419f..9a279e77 100644 --- a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsTest.cs +++ b/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsTest.cs @@ -88,7 +88,9 @@ public void Url_Works() var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); - Assert.Equal(new Uri("https://api.imagekit.io/v1/customMetadataFields"), url); + Assert.True( + TestBase.UrisEqual(new Uri("https://api.imagekit.io/v1/customMetadataFields"), url) + ); } [Fact] diff --git a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldDeleteParamsTest.cs b/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldDeleteParamsTest.cs index 14045bf0..03b17b5e 100644 --- a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldDeleteParamsTest.cs +++ b/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldDeleteParamsTest.cs @@ -22,7 +22,9 @@ public void Url_Works() var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); - Assert.Equal(new Uri("https://api.imagekit.io/v1/customMetadataFields/id"), url); + Assert.True( + TestBase.UrisEqual(new Uri("https://api.imagekit.io/v1/customMetadataFields/id"), url) + ); } [Fact] diff --git a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldListParamsTest.cs b/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldListParamsTest.cs index de7b0113..86cd2d8e 100644 --- a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldListParamsTest.cs +++ b/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldListParamsTest.cs @@ -59,11 +59,13 @@ public void Url_Works() var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); - Assert.Equal( - new Uri( - "https://api.imagekit.io/v1/customMetadataFields?folderPath=folderPath&includeDeleted=true" - ), - url + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.imagekit.io/v1/customMetadataFields?folderPath=folderPath&includeDeleted=true" + ), + url + ) ); } diff --git a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsTest.cs b/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsTest.cs index 36caefd5..323e2eef 100644 --- a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsTest.cs +++ b/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsTest.cs @@ -93,7 +93,9 @@ public void Url_Works() var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); - Assert.Equal(new Uri("https://api.imagekit.io/v1/customMetadataFields/id"), url); + Assert.True( + TestBase.UrisEqual(new Uri("https://api.imagekit.io/v1/customMetadataFields/id"), url) + ); } [Fact] diff --git a/src/ImageKit.Tests/Models/Files/Bulk/BulkAddTagsParamsTest.cs b/src/ImageKit.Tests/Models/Files/Bulk/BulkAddTagsParamsTest.cs index ee0c224e..ea19f998 100644 --- a/src/ImageKit.Tests/Models/Files/Bulk/BulkAddTagsParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/Bulk/BulkAddTagsParamsTest.cs @@ -41,7 +41,7 @@ public void Url_Works() var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); - Assert.Equal(new Uri("https://api.imagekit.io/v1/files/addTags"), url); + Assert.True(TestBase.UrisEqual(new Uri("https://api.imagekit.io/v1/files/addTags"), url)); } [Fact] diff --git a/src/ImageKit.Tests/Models/Files/Bulk/BulkDeleteParamsTest.cs b/src/ImageKit.Tests/Models/Files/Bulk/BulkDeleteParamsTest.cs index 5b8d87a7..837c4b9d 100644 --- a/src/ImageKit.Tests/Models/Files/Bulk/BulkDeleteParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/Bulk/BulkDeleteParamsTest.cs @@ -33,7 +33,12 @@ public void Url_Works() var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); - Assert.Equal(new Uri("https://api.imagekit.io/v1/files/batch/deleteByFileIds"), url); + Assert.True( + TestBase.UrisEqual( + new Uri("https://api.imagekit.io/v1/files/batch/deleteByFileIds"), + url + ) + ); } [Fact] diff --git a/src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveAITagsParamsTest.cs b/src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveAITagsParamsTest.cs index 391cf465..cd052204 100644 --- a/src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveAITagsParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveAITagsParamsTest.cs @@ -41,7 +41,9 @@ public void Url_Works() var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); - Assert.Equal(new Uri("https://api.imagekit.io/v1/files/removeAITags"), url); + Assert.True( + TestBase.UrisEqual(new Uri("https://api.imagekit.io/v1/files/removeAITags"), url) + ); } [Fact] diff --git a/src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveTagsParamsTest.cs b/src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveTagsParamsTest.cs index 49f93c1f..1a8a5d99 100644 --- a/src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveTagsParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveTagsParamsTest.cs @@ -41,7 +41,9 @@ public void Url_Works() var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); - Assert.Equal(new Uri("https://api.imagekit.io/v1/files/removeTags"), url); + Assert.True( + TestBase.UrisEqual(new Uri("https://api.imagekit.io/v1/files/removeTags"), url) + ); } [Fact] diff --git a/src/ImageKit.Tests/Models/Files/FileCopyParamsTest.cs b/src/ImageKit.Tests/Models/Files/FileCopyParamsTest.cs index 3a52f2cb..c55eb81d 100644 --- a/src/ImageKit.Tests/Models/Files/FileCopyParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/FileCopyParamsTest.cs @@ -64,7 +64,7 @@ public void Url_Works() var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); - Assert.Equal(new Uri("https://api.imagekit.io/v1/files/copy"), url); + Assert.True(TestBase.UrisEqual(new Uri("https://api.imagekit.io/v1/files/copy"), url)); } [Fact] diff --git a/src/ImageKit.Tests/Models/Files/FileDeleteParamsTest.cs b/src/ImageKit.Tests/Models/Files/FileDeleteParamsTest.cs index 65107f82..7d538015 100644 --- a/src/ImageKit.Tests/Models/Files/FileDeleteParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/FileDeleteParamsTest.cs @@ -22,7 +22,7 @@ public void Url_Works() var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); - Assert.Equal(new Uri("https://api.imagekit.io/v1/files/fileId"), url); + Assert.True(TestBase.UrisEqual(new Uri("https://api.imagekit.io/v1/files/fileId"), url)); } [Fact] diff --git a/src/ImageKit.Tests/Models/Files/FileGetParamsTest.cs b/src/ImageKit.Tests/Models/Files/FileGetParamsTest.cs index d2372359..184e80ce 100644 --- a/src/ImageKit.Tests/Models/Files/FileGetParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/FileGetParamsTest.cs @@ -22,7 +22,9 @@ public void Url_Works() var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); - Assert.Equal(new Uri("https://api.imagekit.io/v1/files/fileId/details"), url); + Assert.True( + TestBase.UrisEqual(new Uri("https://api.imagekit.io/v1/files/fileId/details"), url) + ); } [Fact] diff --git a/src/ImageKit.Tests/Models/Files/FileMoveParamsTest.cs b/src/ImageKit.Tests/Models/Files/FileMoveParamsTest.cs index 2f134efc..3953c9a8 100644 --- a/src/ImageKit.Tests/Models/Files/FileMoveParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/FileMoveParamsTest.cs @@ -32,7 +32,7 @@ public void Url_Works() var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); - Assert.Equal(new Uri("https://api.imagekit.io/v1/files/move"), url); + Assert.True(TestBase.UrisEqual(new Uri("https://api.imagekit.io/v1/files/move"), url)); } [Fact] diff --git a/src/ImageKit.Tests/Models/Files/FileRenameParamsTest.cs b/src/ImageKit.Tests/Models/Files/FileRenameParamsTest.cs index e8cf12d8..5f207be4 100644 --- a/src/ImageKit.Tests/Models/Files/FileRenameParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/FileRenameParamsTest.cs @@ -64,7 +64,7 @@ public void Url_Works() var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); - Assert.Equal(new Uri("https://api.imagekit.io/v1/files/rename"), url); + Assert.True(TestBase.UrisEqual(new Uri("https://api.imagekit.io/v1/files/rename"), url)); } [Fact] diff --git a/src/ImageKit.Tests/Models/Files/FileUpdateParamsTest.cs b/src/ImageKit.Tests/Models/Files/FileUpdateParamsTest.cs index 093b5533..75dda865 100644 --- a/src/ImageKit.Tests/Models/Files/FileUpdateParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/FileUpdateParamsTest.cs @@ -187,7 +187,9 @@ public void Url_Works() var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); - Assert.Equal(new Uri("https://api.imagekit.io/v1/files/fileId/details"), url); + Assert.True( + TestBase.UrisEqual(new Uri("https://api.imagekit.io/v1/files/fileId/details"), url) + ); } [Fact] diff --git a/src/ImageKit.Tests/Models/Files/FileUploadParamsTest.cs b/src/ImageKit.Tests/Models/Files/FileUploadParamsTest.cs index d0f77eb2..fabaa7ca 100644 --- a/src/ImageKit.Tests/Models/Files/FileUploadParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/FileUploadParamsTest.cs @@ -402,7 +402,9 @@ public void Url_Works() var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); - Assert.Equal(new Uri("https://api.imagekit.io/api/v1/files/upload"), url); + Assert.True( + TestBase.UrisEqual(new Uri("https://api.imagekit.io/api/v1/files/upload"), url) + ); } [Fact] diff --git a/src/ImageKit.Tests/Models/Files/Metadata/MetadataGetFromUrlParamsTest.cs b/src/ImageKit.Tests/Models/Files/Metadata/MetadataGetFromUrlParamsTest.cs index 41155870..2404e6ec 100644 --- a/src/ImageKit.Tests/Models/Files/Metadata/MetadataGetFromUrlParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/Metadata/MetadataGetFromUrlParamsTest.cs @@ -22,9 +22,11 @@ public void Url_Works() var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); - Assert.Equal( - new Uri("https://api.imagekit.io/v1/metadata?url=https%3a%2f%2fexample.com"), - url + Assert.True( + TestBase.UrisEqual( + new Uri("https://api.imagekit.io/v1/metadata?url=https%3a%2f%2fexample.com"), + url + ) ); } diff --git a/src/ImageKit.Tests/Models/Files/Metadata/MetadataGetParamsTest.cs b/src/ImageKit.Tests/Models/Files/Metadata/MetadataGetParamsTest.cs index d80a0a72..f72914d6 100644 --- a/src/ImageKit.Tests/Models/Files/Metadata/MetadataGetParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/Metadata/MetadataGetParamsTest.cs @@ -22,7 +22,9 @@ public void Url_Works() var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); - Assert.Equal(new Uri("https://api.imagekit.io/v1/files/fileId/metadata"), url); + Assert.True( + TestBase.UrisEqual(new Uri("https://api.imagekit.io/v1/files/fileId/metadata"), url) + ); } [Fact] diff --git a/src/ImageKit.Tests/Models/Files/Versions/VersionDeleteParamsTest.cs b/src/ImageKit.Tests/Models/Files/Versions/VersionDeleteParamsTest.cs index 105270a8..f1c89b50 100644 --- a/src/ImageKit.Tests/Models/Files/Versions/VersionDeleteParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/Versions/VersionDeleteParamsTest.cs @@ -24,7 +24,12 @@ public void Url_Works() var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); - Assert.Equal(new Uri("https://api.imagekit.io/v1/files/fileId/versions/versionId"), url); + Assert.True( + TestBase.UrisEqual( + new Uri("https://api.imagekit.io/v1/files/fileId/versions/versionId"), + url + ) + ); } [Fact] diff --git a/src/ImageKit.Tests/Models/Files/Versions/VersionGetParamsTest.cs b/src/ImageKit.Tests/Models/Files/Versions/VersionGetParamsTest.cs index e189bc4c..053cbc36 100644 --- a/src/ImageKit.Tests/Models/Files/Versions/VersionGetParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/Versions/VersionGetParamsTest.cs @@ -24,7 +24,12 @@ public void Url_Works() var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); - Assert.Equal(new Uri("https://api.imagekit.io/v1/files/fileId/versions/versionId"), url); + Assert.True( + TestBase.UrisEqual( + new Uri("https://api.imagekit.io/v1/files/fileId/versions/versionId"), + url + ) + ); } [Fact] diff --git a/src/ImageKit.Tests/Models/Files/Versions/VersionListParamsTest.cs b/src/ImageKit.Tests/Models/Files/Versions/VersionListParamsTest.cs index c6826fb4..30c8b63f 100644 --- a/src/ImageKit.Tests/Models/Files/Versions/VersionListParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/Versions/VersionListParamsTest.cs @@ -22,7 +22,9 @@ public void Url_Works() var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); - Assert.Equal(new Uri("https://api.imagekit.io/v1/files/fileId/versions"), url); + Assert.True( + TestBase.UrisEqual(new Uri("https://api.imagekit.io/v1/files/fileId/versions"), url) + ); } [Fact] diff --git a/src/ImageKit.Tests/Models/Files/Versions/VersionRestoreParamsTest.cs b/src/ImageKit.Tests/Models/Files/Versions/VersionRestoreParamsTest.cs index a6b785d9..bd411834 100644 --- a/src/ImageKit.Tests/Models/Files/Versions/VersionRestoreParamsTest.cs +++ b/src/ImageKit.Tests/Models/Files/Versions/VersionRestoreParamsTest.cs @@ -24,9 +24,11 @@ public void Url_Works() var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); - Assert.Equal( - new Uri("https://api.imagekit.io/v1/files/fileId/versions/versionId/restore"), - url + Assert.True( + TestBase.UrisEqual( + new Uri("https://api.imagekit.io/v1/files/fileId/versions/versionId/restore"), + url + ) ); } diff --git a/src/ImageKit.Tests/Models/Folders/FolderCopyParamsTest.cs b/src/ImageKit.Tests/Models/Folders/FolderCopyParamsTest.cs index 9027c155..2168c1a8 100644 --- a/src/ImageKit.Tests/Models/Folders/FolderCopyParamsTest.cs +++ b/src/ImageKit.Tests/Models/Folders/FolderCopyParamsTest.cs @@ -64,7 +64,9 @@ public void Url_Works() var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); - Assert.Equal(new Uri("https://api.imagekit.io/v1/bulkJobs/copyFolder"), url); + Assert.True( + TestBase.UrisEqual(new Uri("https://api.imagekit.io/v1/bulkJobs/copyFolder"), url) + ); } [Fact] diff --git a/src/ImageKit.Tests/Models/Folders/FolderCreateParamsTest.cs b/src/ImageKit.Tests/Models/Folders/FolderCreateParamsTest.cs index ef6278aa..8f6c081f 100644 --- a/src/ImageKit.Tests/Models/Folders/FolderCreateParamsTest.cs +++ b/src/ImageKit.Tests/Models/Folders/FolderCreateParamsTest.cs @@ -32,7 +32,7 @@ public void Url_Works() var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); - Assert.Equal(new Uri("https://api.imagekit.io/v1/folder"), url); + Assert.True(TestBase.UrisEqual(new Uri("https://api.imagekit.io/v1/folder"), url)); } [Fact] diff --git a/src/ImageKit.Tests/Models/Folders/FolderDeleteParamsTest.cs b/src/ImageKit.Tests/Models/Folders/FolderDeleteParamsTest.cs index ec79dff4..973d471e 100644 --- a/src/ImageKit.Tests/Models/Folders/FolderDeleteParamsTest.cs +++ b/src/ImageKit.Tests/Models/Folders/FolderDeleteParamsTest.cs @@ -22,7 +22,7 @@ public void Url_Works() var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); - Assert.Equal(new Uri("https://api.imagekit.io/v1/folder"), url); + Assert.True(TestBase.UrisEqual(new Uri("https://api.imagekit.io/v1/folder"), url)); } [Fact] diff --git a/src/ImageKit.Tests/Models/Folders/FolderMoveParamsTest.cs b/src/ImageKit.Tests/Models/Folders/FolderMoveParamsTest.cs index 453c9468..66a8fe0b 100644 --- a/src/ImageKit.Tests/Models/Folders/FolderMoveParamsTest.cs +++ b/src/ImageKit.Tests/Models/Folders/FolderMoveParamsTest.cs @@ -32,7 +32,9 @@ public void Url_Works() var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); - Assert.Equal(new Uri("https://api.imagekit.io/v1/bulkJobs/moveFolder"), url); + Assert.True( + TestBase.UrisEqual(new Uri("https://api.imagekit.io/v1/bulkJobs/moveFolder"), url) + ); } [Fact] diff --git a/src/ImageKit.Tests/Models/Folders/FolderRenameParamsTest.cs b/src/ImageKit.Tests/Models/Folders/FolderRenameParamsTest.cs index f52fa209..0d730804 100644 --- a/src/ImageKit.Tests/Models/Folders/FolderRenameParamsTest.cs +++ b/src/ImageKit.Tests/Models/Folders/FolderRenameParamsTest.cs @@ -64,7 +64,9 @@ public void Url_Works() var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); - Assert.Equal(new Uri("https://api.imagekit.io/v1/bulkJobs/renameFolder"), url); + Assert.True( + TestBase.UrisEqual(new Uri("https://api.imagekit.io/v1/bulkJobs/renameFolder"), url) + ); } [Fact] diff --git a/src/ImageKit.Tests/Models/Folders/Job/JobGetParamsTest.cs b/src/ImageKit.Tests/Models/Folders/Job/JobGetParamsTest.cs index 110cb8b1..f6a398bb 100644 --- a/src/ImageKit.Tests/Models/Folders/Job/JobGetParamsTest.cs +++ b/src/ImageKit.Tests/Models/Folders/Job/JobGetParamsTest.cs @@ -22,7 +22,7 @@ public void Url_Works() var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); - Assert.Equal(new Uri("https://api.imagekit.io/v1/bulkJobs/jobId"), url); + Assert.True(TestBase.UrisEqual(new Uri("https://api.imagekit.io/v1/bulkJobs/jobId"), url)); } [Fact] diff --git a/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionCreateParamsTest.cs b/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionCreateParamsTest.cs index 168e5dad..d55a5c5d 100644 --- a/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionCreateParamsTest.cs +++ b/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionCreateParamsTest.cs @@ -65,7 +65,9 @@ public void Url_Works() var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); - Assert.Equal(new Uri("https://api.imagekit.io/v1/saved-extensions"), url); + Assert.True( + TestBase.UrisEqual(new Uri("https://api.imagekit.io/v1/saved-extensions"), url) + ); } [Fact] diff --git a/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionDeleteParamsTest.cs b/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionDeleteParamsTest.cs index 8c6831cd..ad99ca25 100644 --- a/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionDeleteParamsTest.cs +++ b/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionDeleteParamsTest.cs @@ -22,7 +22,9 @@ public void Url_Works() var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); - Assert.Equal(new Uri("https://api.imagekit.io/v1/saved-extensions/id"), url); + Assert.True( + TestBase.UrisEqual(new Uri("https://api.imagekit.io/v1/saved-extensions/id"), url) + ); } [Fact] diff --git a/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionGetParamsTest.cs b/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionGetParamsTest.cs index 016a46cc..1a600f15 100644 --- a/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionGetParamsTest.cs +++ b/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionGetParamsTest.cs @@ -22,7 +22,9 @@ public void Url_Works() var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); - Assert.Equal(new Uri("https://api.imagekit.io/v1/saved-extensions/id"), url); + Assert.True( + TestBase.UrisEqual(new Uri("https://api.imagekit.io/v1/saved-extensions/id"), url) + ); } [Fact] diff --git a/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionUpdateParamsTest.cs b/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionUpdateParamsTest.cs index 1a4fb0ee..7fd9c38b 100644 --- a/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionUpdateParamsTest.cs +++ b/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionUpdateParamsTest.cs @@ -87,7 +87,9 @@ public void Url_Works() var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); - Assert.Equal(new Uri("https://api.imagekit.io/v1/saved-extensions/id"), url); + Assert.True( + TestBase.UrisEqual(new Uri("https://api.imagekit.io/v1/saved-extensions/id"), url) + ); } [Fact] diff --git a/src/ImageKit.Tests/TestBase.cs b/src/ImageKit.Tests/TestBase.cs index 5153c17c..e73e908c 100644 --- a/src/ImageKit.Tests/TestBase.cs +++ b/src/ImageKit.Tests/TestBase.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using System.Linq; using ImageKit; namespace ImageKit.Tests; @@ -17,4 +19,42 @@ public TestBase() Password = "My Password", }; } + + internal static bool UrisEqual(Uri uri1, Uri uri2) + { + if ( + uri1.Scheme != uri2.Scheme + || uri1.Host != uri2.Host + || uri1.Port != uri2.Port + || uri1.AbsolutePath != uri2.AbsolutePath + ) + { + return false; + } + + var query1 = ParseQueryString(uri1.Query); + var query2 = ParseQueryString(uri2.Query); + + return Enumerable.SequenceEqual(query1, query2); + } + + static SortedDictionary ParseQueryString(string query) + { + var ret = new SortedDictionary(StringComparer.Ordinal); + + if (string.IsNullOrEmpty(query)) + return ret; + + var pairs = query.TrimStart('?').Split(['&'], StringSplitOptions.RemoveEmptyEntries); + + foreach (var pair in pairs) + { + var parts = pair.Split(['&'], 2); + var key = Uri.UnescapeDataString(parts[0]); + var value = parts.Length > 1 ? Uri.UnescapeDataString(parts[1]) : string.Empty; + ret[key] = value; + } + + return ret; + } } From 1a120c68bebddbf75186230aa5c483287a17df9f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 18 Apr 2026 06:45:46 +0000 Subject: [PATCH 103/129] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 1ee5069c..3aa7595d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-70c42eda2bee929830b2537f758400a58dded1f1ef5686a286e2469c35a041a0.yml openapi_spec_hash: cdaeed824e91657b45092765cf55eb42 -config_hash: 83967503e501e4199b4042d0d0f2b615 +config_hash: 2a6f67c966b8b3db6f986be4ac23a507 From f4258cb2262cecc7299c0c66debf2e0231811108 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 20 Apr 2026 04:52:13 +0000 Subject: [PATCH 104/129] Java dev --- .stats.yml | 6 +- .../Models/Assets/AssetListResponseTest.cs | 12 +- .../Beta/V2/Files/FileUploadResponseTest.cs | 140 ++++---- .../CustomMetadataFieldCreateParamsTest.cs | 119 ++++--- .../CustomMetadataFieldTest.cs | 137 ++++---- .../CustomMetadataFieldUpdateParamsTest.cs | 117 ++++--- .../Models/ExtensionConfigTest.cs | 76 +++-- src/ImageKit.Tests/Models/Files/FileTest.cs | 140 ++++---- .../Models/Files/FileUpdateResponseTest.cs | 66 ++-- .../Models/Files/FileUploadResponseTest.cs | 140 ++++---- .../UnnamedSchemaWithArrayParent0Test.cs | 180 ++++++---- .../Models/Webhooks/FileCreateEventTest.cs | 84 ++--- .../Models/Webhooks/FileUpdateEventTest.cs | 84 ++--- .../Webhooks/FileVersionCreateEventTest.cs | 84 ++--- .../Webhooks/UnsafeUnwrapWebhookEventTest.cs | 48 +-- .../Models/Webhooks/UnwrapWebhookEventTest.cs | 48 +-- .../UploadPreTransformSuccessEventTest.cs | 224 ++++++------- .../CustomMetadataFieldServiceTest.cs | 6 +- .../Beta/V2/Files/FileUploadResponse.cs | 62 ++-- .../CustomMetadataField.cs | 86 +++-- .../CustomMetadataFieldCreateParams.cs | 70 ++-- .../CustomMetadataFieldUpdateParams.cs | 97 ++++-- src/ImageKit/Models/ExtensionConfig.cs | 209 ++++++------ src/ImageKit/Models/Files/File.cs | 62 ++-- .../Models/Files/FileUploadResponse.cs | 62 ++-- .../Models/UnnamedSchemaWithArrayParent0.cs | 312 ++++++++++++------ .../UploadPreTransformSuccessEvent.cs | 62 ++-- 27 files changed, 1473 insertions(+), 1260 deletions(-) diff --git a/.stats.yml b/.stats.yml index 3aa7595d..c9a36176 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-70c42eda2bee929830b2537f758400a58dded1f1ef5686a286e2469c35a041a0.yml -openapi_spec_hash: cdaeed824e91657b45092765cf55eb42 -config_hash: 2a6f67c966b8b3db6f986be4ac23a507 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-c7f578172392bde58bbb72be2a25b9e917529cd07550358c645ce155debf2418.yml +openapi_spec_hash: f0d797a17b1e8e81707517700cd44b13 +config_hash: cc8ab8a2b72639af4d57e4e268ed3f73 diff --git a/src/ImageKit.Tests/Models/Assets/AssetListResponseTest.cs b/src/ImageKit.Tests/Models/Assets/AssetListResponseTest.cs index 25f5762c..b517da39 100644 --- a/src/ImageKit.Tests/Models/Assets/AssetListResponseTest.cs +++ b/src/ImageKit.Tests/Models/Assets/AssetListResponseTest.cs @@ -55,9 +55,9 @@ public void FileValidationWorks() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -149,9 +149,9 @@ public void FileSerializationRoundtripWorks() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, diff --git a/src/ImageKit.Tests/Models/Beta/V2/Files/FileUploadResponseTest.cs b/src/ImageKit.Tests/Models/Beta/V2/Files/FileUploadResponseTest.cs index f4e6bf15..6588cc9f 100644 --- a/src/ImageKit.Tests/Models/Beta/V2/Files/FileUploadResponseTest.cs +++ b/src/ImageKit.Tests/Models/Beta/V2/Files/FileUploadResponseTest.cs @@ -141,9 +141,9 @@ public void FieldRoundtrip_Works() Type = Type.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent12(true), - new UnnamedSchemaWithArrayParent12(10), - new UnnamedSchemaWithArrayParent12("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ), IsValueRequired = true, @@ -293,9 +293,9 @@ public void FieldRoundtrip_Works() Type = Type.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent12(true), - new UnnamedSchemaWithArrayParent12(10), - new UnnamedSchemaWithArrayParent12("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ), IsValueRequired = true, @@ -507,9 +507,9 @@ public void SerializationRoundtrip_Works() Type = Type.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent12(true), - new UnnamedSchemaWithArrayParent12(10), - new UnnamedSchemaWithArrayParent12("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ), IsValueRequired = true, @@ -673,9 +673,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Type.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent12(true), - new UnnamedSchemaWithArrayParent12(10), - new UnnamedSchemaWithArrayParent12("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ), IsValueRequired = true, @@ -832,9 +832,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Type.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent12(true), - new UnnamedSchemaWithArrayParent12(10), - new UnnamedSchemaWithArrayParent12("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ), IsValueRequired = true, @@ -1046,9 +1046,9 @@ public void Validation_Works() Type = Type.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent12(true), - new UnnamedSchemaWithArrayParent12(10), - new UnnamedSchemaWithArrayParent12("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ), IsValueRequired = true, @@ -1414,9 +1414,9 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Type = Type.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent12(true), - new UnnamedSchemaWithArrayParent12(10), - new UnnamedSchemaWithArrayParent12("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ), IsValueRequired = true, @@ -1568,9 +1568,9 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Type = Type.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent12(true), - new UnnamedSchemaWithArrayParent12(10), - new UnnamedSchemaWithArrayParent12("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ), IsValueRequired = true, @@ -1717,9 +1717,9 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Type = Type.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent12(true), - new UnnamedSchemaWithArrayParent12(10), - new UnnamedSchemaWithArrayParent12("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ), IsValueRequired = true, @@ -1875,9 +1875,9 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Type = Type.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent12(true), - new UnnamedSchemaWithArrayParent12(10), - new UnnamedSchemaWithArrayParent12("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ), IsValueRequired = true, @@ -2038,9 +2038,9 @@ public void CopyConstructor_Works() Type = Type.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent12(true), - new UnnamedSchemaWithArrayParent12(10), - new UnnamedSchemaWithArrayParent12("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ), IsValueRequired = true, @@ -2701,9 +2701,9 @@ public void FieldRoundtrip_Works() Type = Type.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent12(true), - new UnnamedSchemaWithArrayParent12(10), - new UnnamedSchemaWithArrayParent12("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ), IsValueRequired = true, @@ -2719,9 +2719,9 @@ public void FieldRoundtrip_Works() ApiEnum expectedType = Type.Text; DefaultValue expectedDefaultValue = new( [ - new UnnamedSchemaWithArrayParent12(true), - new UnnamedSchemaWithArrayParent12(10), - new UnnamedSchemaWithArrayParent12("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ); bool expectedIsValueRequired = true; @@ -2758,9 +2758,9 @@ public void SerializationRoundtrip_Works() Type = Type.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent12(true), - new UnnamedSchemaWithArrayParent12(10), - new UnnamedSchemaWithArrayParent12("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ), IsValueRequired = true, @@ -2790,9 +2790,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Type.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent12(true), - new UnnamedSchemaWithArrayParent12(10), - new UnnamedSchemaWithArrayParent12("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ), IsValueRequired = true, @@ -2815,9 +2815,9 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum expectedType = Type.Text; DefaultValue expectedDefaultValue = new( [ - new UnnamedSchemaWithArrayParent12(true), - new UnnamedSchemaWithArrayParent12(10), - new UnnamedSchemaWithArrayParent12("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ); bool expectedIsValueRequired = true; @@ -2854,9 +2854,9 @@ public void Validation_Works() Type = Type.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent12(true), - new UnnamedSchemaWithArrayParent12(10), - new UnnamedSchemaWithArrayParent12("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ), IsValueRequired = true, @@ -2974,9 +2974,9 @@ public void CopyConstructor_Works() Type = Type.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent12(true), - new UnnamedSchemaWithArrayParent12(10), - new UnnamedSchemaWithArrayParent12("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ), IsValueRequired = true, @@ -3091,9 +3091,9 @@ public void MixedValidationWorks() { DefaultValue value = new( [ - new UnnamedSchemaWithArrayParent12(true), - new UnnamedSchemaWithArrayParent12(10), - new UnnamedSchemaWithArrayParent12("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ); value.Validate(); @@ -3143,9 +3143,9 @@ public void MixedSerializationRoundtripWorks() { DefaultValue value = new( [ - new UnnamedSchemaWithArrayParent12(true), - new UnnamedSchemaWithArrayParent12(10), - new UnnamedSchemaWithArrayParent12("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ); string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3158,35 +3158,35 @@ public void MixedSerializationRoundtripWorks() } } -public class UnnamedSchemaWithArrayParent12Test : TestBase +public class UnnamedSchemaWithArrayParent3Test : TestBase { [Fact] public void StringValidationWorks() { - UnnamedSchemaWithArrayParent12 value = "string"; + UnnamedSchemaWithArrayParent3 value = "string"; value.Validate(); } [Fact] public void DoubleValidationWorks() { - UnnamedSchemaWithArrayParent12 value = 0; + UnnamedSchemaWithArrayParent3 value = 0; value.Validate(); } [Fact] public void BoolValidationWorks() { - UnnamedSchemaWithArrayParent12 value = true; + UnnamedSchemaWithArrayParent3 value = true; value.Validate(); } [Fact] public void StringSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent12 value = "string"; + UnnamedSchemaWithArrayParent3 value = "string"; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -3197,9 +3197,9 @@ public void StringSerializationRoundtripWorks() [Fact] public void DoubleSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent12 value = 0; + UnnamedSchemaWithArrayParent3 value = 0; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -3210,9 +3210,9 @@ public void DoubleSerializationRoundtripWorks() [Fact] public void BoolSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent12 value = true; + UnnamedSchemaWithArrayParent3 value = true; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); diff --git a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsTest.cs b/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsTest.cs index 9a279e77..8ceb8b85 100644 --- a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsTest.cs +++ b/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsTest.cs @@ -21,9 +21,9 @@ public void FieldRoundtrip_Works() Type = CustomMetadataFields::Type.Number, DefaultValue = new( [ - new CustomMetadataFields::UnnamedSchemaWithArrayParent1(true), - new CustomMetadataFields::UnnamedSchemaWithArrayParent1(10), - new CustomMetadataFields::UnnamedSchemaWithArrayParent1("Hello"), + new CustomMetadataFields::DefaultValueItem(true), + new CustomMetadataFields::DefaultValueItem(10), + new CustomMetadataFields::DefaultValueItem("Hello"), ] ), IsValueRequired = true, @@ -42,9 +42,9 @@ public void FieldRoundtrip_Works() Type = CustomMetadataFields::Type.Number, DefaultValue = new( [ - new CustomMetadataFields::UnnamedSchemaWithArrayParent1(true), - new CustomMetadataFields::UnnamedSchemaWithArrayParent1(10), - new CustomMetadataFields::UnnamedSchemaWithArrayParent1("Hello"), + new CustomMetadataFields::DefaultValueItem(true), + new CustomMetadataFields::DefaultValueItem(10), + new CustomMetadataFields::DefaultValueItem("Hello"), ] ), IsValueRequired = true, @@ -72,9 +72,9 @@ public void Url_Works() Type = CustomMetadataFields::Type.Number, DefaultValue = new( [ - new CustomMetadataFields::UnnamedSchemaWithArrayParent1(true), - new CustomMetadataFields::UnnamedSchemaWithArrayParent1(10), - new CustomMetadataFields::UnnamedSchemaWithArrayParent1("Hello"), + new CustomMetadataFields::DefaultValueItem(true), + new CustomMetadataFields::DefaultValueItem(10), + new CustomMetadataFields::DefaultValueItem("Hello"), ] ), IsValueRequired = true, @@ -105,9 +105,9 @@ public void CopyConstructor_Works() Type = CustomMetadataFields::Type.Number, DefaultValue = new( [ - new CustomMetadataFields::UnnamedSchemaWithArrayParent1(true), - new CustomMetadataFields::UnnamedSchemaWithArrayParent1(10), - new CustomMetadataFields::UnnamedSchemaWithArrayParent1("Hello"), + new CustomMetadataFields::DefaultValueItem(true), + new CustomMetadataFields::DefaultValueItem(10), + new CustomMetadataFields::DefaultValueItem("Hello"), ] ), IsValueRequired = true, @@ -135,9 +135,9 @@ public void FieldRoundtrip_Works() Type = CustomMetadataFields::Type.Text, DefaultValue = new( [ - new CustomMetadataFields::UnnamedSchemaWithArrayParent1(true), - new CustomMetadataFields::UnnamedSchemaWithArrayParent1(10), - new CustomMetadataFields::UnnamedSchemaWithArrayParent1("Hello"), + new CustomMetadataFields::DefaultValueItem(true), + new CustomMetadataFields::DefaultValueItem(10), + new CustomMetadataFields::DefaultValueItem("Hello"), ] ), IsValueRequired = true, @@ -151,9 +151,9 @@ public void FieldRoundtrip_Works() ApiEnum expectedType = CustomMetadataFields::Type.Text; CustomMetadataFields::DefaultValue expectedDefaultValue = new( [ - new CustomMetadataFields::UnnamedSchemaWithArrayParent1(true), - new CustomMetadataFields::UnnamedSchemaWithArrayParent1(10), - new CustomMetadataFields::UnnamedSchemaWithArrayParent1("Hello"), + new CustomMetadataFields::DefaultValueItem(true), + new CustomMetadataFields::DefaultValueItem(10), + new CustomMetadataFields::DefaultValueItem("Hello"), ] ); bool expectedIsValueRequired = true; @@ -194,9 +194,9 @@ public void SerializationRoundtrip_Works() Type = CustomMetadataFields::Type.Text, DefaultValue = new( [ - new CustomMetadataFields::UnnamedSchemaWithArrayParent1(true), - new CustomMetadataFields::UnnamedSchemaWithArrayParent1(10), - new CustomMetadataFields::UnnamedSchemaWithArrayParent1("Hello"), + new CustomMetadataFields::DefaultValueItem(true), + new CustomMetadataFields::DefaultValueItem(10), + new CustomMetadataFields::DefaultValueItem("Hello"), ] ), IsValueRequired = true, @@ -224,9 +224,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = CustomMetadataFields::Type.Text, DefaultValue = new( [ - new CustomMetadataFields::UnnamedSchemaWithArrayParent1(true), - new CustomMetadataFields::UnnamedSchemaWithArrayParent1(10), - new CustomMetadataFields::UnnamedSchemaWithArrayParent1("Hello"), + new CustomMetadataFields::DefaultValueItem(true), + new CustomMetadataFields::DefaultValueItem(10), + new CustomMetadataFields::DefaultValueItem("Hello"), ] ), IsValueRequired = true, @@ -247,9 +247,9 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum expectedType = CustomMetadataFields::Type.Text; CustomMetadataFields::DefaultValue expectedDefaultValue = new( [ - new CustomMetadataFields::UnnamedSchemaWithArrayParent1(true), - new CustomMetadataFields::UnnamedSchemaWithArrayParent1(10), - new CustomMetadataFields::UnnamedSchemaWithArrayParent1("Hello"), + new CustomMetadataFields::DefaultValueItem(true), + new CustomMetadataFields::DefaultValueItem(10), + new CustomMetadataFields::DefaultValueItem("Hello"), ] ); bool expectedIsValueRequired = true; @@ -290,9 +290,9 @@ public void Validation_Works() Type = CustomMetadataFields::Type.Text, DefaultValue = new( [ - new CustomMetadataFields::UnnamedSchemaWithArrayParent1(true), - new CustomMetadataFields::UnnamedSchemaWithArrayParent1(10), - new CustomMetadataFields::UnnamedSchemaWithArrayParent1("Hello"), + new CustomMetadataFields::DefaultValueItem(true), + new CustomMetadataFields::DefaultValueItem(10), + new CustomMetadataFields::DefaultValueItem("Hello"), ] ), IsValueRequired = true, @@ -396,9 +396,9 @@ public void CopyConstructor_Works() Type = CustomMetadataFields::Type.Text, DefaultValue = new( [ - new CustomMetadataFields::UnnamedSchemaWithArrayParent1(true), - new CustomMetadataFields::UnnamedSchemaWithArrayParent1(10), - new CustomMetadataFields::UnnamedSchemaWithArrayParent1("Hello"), + new CustomMetadataFields::DefaultValueItem(true), + new CustomMetadataFields::DefaultValueItem(10), + new CustomMetadataFields::DefaultValueItem("Hello"), ] ), IsValueRequired = true, @@ -511,9 +511,9 @@ public void MixedValidationWorks() { CustomMetadataFields::DefaultValue value = new( [ - new CustomMetadataFields::UnnamedSchemaWithArrayParent1(true), - new CustomMetadataFields::UnnamedSchemaWithArrayParent1(10), - new CustomMetadataFields::UnnamedSchemaWithArrayParent1("Hello"), + new CustomMetadataFields::DefaultValueItem(true), + new CustomMetadataFields::DefaultValueItem(10), + new CustomMetadataFields::DefaultValueItem("Hello"), ] ); value.Validate(); @@ -563,9 +563,9 @@ public void MixedSerializationRoundtripWorks() { CustomMetadataFields::DefaultValue value = new( [ - new CustomMetadataFields::UnnamedSchemaWithArrayParent1(true), - new CustomMetadataFields::UnnamedSchemaWithArrayParent1(10), - new CustomMetadataFields::UnnamedSchemaWithArrayParent1("Hello"), + new CustomMetadataFields::DefaultValueItem(true), + new CustomMetadataFields::DefaultValueItem(10), + new CustomMetadataFields::DefaultValueItem("Hello"), ] ); string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -578,39 +578,38 @@ public void MixedSerializationRoundtripWorks() } } -public class UnnamedSchemaWithArrayParent1Test : TestBase +public class DefaultValueItemTest : TestBase { [Fact] public void StringValidationWorks() { - CustomMetadataFields::UnnamedSchemaWithArrayParent1 value = "string"; + CustomMetadataFields::DefaultValueItem value = "string"; value.Validate(); } [Fact] public void DoubleValidationWorks() { - CustomMetadataFields::UnnamedSchemaWithArrayParent1 value = 0; + CustomMetadataFields::DefaultValueItem value = 0; value.Validate(); } [Fact] public void BoolValidationWorks() { - CustomMetadataFields::UnnamedSchemaWithArrayParent1 value = true; + CustomMetadataFields::DefaultValueItem value = true; value.Validate(); } [Fact] public void StringSerializationRoundtripWorks() { - CustomMetadataFields::UnnamedSchemaWithArrayParent1 value = "string"; + CustomMetadataFields::DefaultValueItem value = "string"; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } @@ -618,13 +617,12 @@ public void StringSerializationRoundtripWorks() [Fact] public void DoubleSerializationRoundtripWorks() { - CustomMetadataFields::UnnamedSchemaWithArrayParent1 value = 0; + CustomMetadataFields::DefaultValueItem value = 0; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } @@ -632,13 +630,12 @@ public void DoubleSerializationRoundtripWorks() [Fact] public void BoolSerializationRoundtripWorks() { - CustomMetadataFields::UnnamedSchemaWithArrayParent1 value = true; + CustomMetadataFields::DefaultValueItem value = true; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } diff --git a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldTest.cs b/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldTest.cs index 3fefd8cb..51098ace 100644 --- a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldTest.cs +++ b/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldTest.cs @@ -21,9 +21,9 @@ public void FieldRoundtrip_Works() Type = CustomMetadataFieldSchemaType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent9(true), - new UnnamedSchemaWithArrayParent9(10), - new UnnamedSchemaWithArrayParent9("Hello"), + new CustomMetadataFieldSchemaDefaultValueDefaultValueItem(true), + new CustomMetadataFieldSchemaDefaultValueDefaultValueItem(10), + new CustomMetadataFieldSchemaDefaultValueDefaultValueItem("Hello"), ] ), IsValueRequired = true, @@ -43,9 +43,9 @@ public void FieldRoundtrip_Works() Type = CustomMetadataFieldSchemaType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent9(true), - new UnnamedSchemaWithArrayParent9(10), - new UnnamedSchemaWithArrayParent9("Hello"), + new CustomMetadataFieldSchemaDefaultValueDefaultValueItem(true), + new CustomMetadataFieldSchemaDefaultValueDefaultValueItem(10), + new CustomMetadataFieldSchemaDefaultValueDefaultValueItem("Hello"), ] ), IsValueRequired = true, @@ -75,9 +75,9 @@ public void SerializationRoundtrip_Works() Type = CustomMetadataFieldSchemaType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent9(true), - new UnnamedSchemaWithArrayParent9(10), - new UnnamedSchemaWithArrayParent9("Hello"), + new CustomMetadataFieldSchemaDefaultValueDefaultValueItem(true), + new CustomMetadataFieldSchemaDefaultValueDefaultValueItem(10), + new CustomMetadataFieldSchemaDefaultValueDefaultValueItem("Hello"), ] ), IsValueRequired = true, @@ -111,9 +111,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = CustomMetadataFieldSchemaType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent9(true), - new UnnamedSchemaWithArrayParent9(10), - new UnnamedSchemaWithArrayParent9("Hello"), + new CustomMetadataFieldSchemaDefaultValueDefaultValueItem(true), + new CustomMetadataFieldSchemaDefaultValueDefaultValueItem(10), + new CustomMetadataFieldSchemaDefaultValueDefaultValueItem("Hello"), ] ), IsValueRequired = true, @@ -140,9 +140,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = CustomMetadataFieldSchemaType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent9(true), - new UnnamedSchemaWithArrayParent9(10), - new UnnamedSchemaWithArrayParent9("Hello"), + new CustomMetadataFieldSchemaDefaultValueDefaultValueItem(true), + new CustomMetadataFieldSchemaDefaultValueDefaultValueItem(10), + new CustomMetadataFieldSchemaDefaultValueDefaultValueItem("Hello"), ] ), IsValueRequired = true, @@ -172,9 +172,9 @@ public void Validation_Works() Type = CustomMetadataFieldSchemaType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent9(true), - new UnnamedSchemaWithArrayParent9(10), - new UnnamedSchemaWithArrayParent9("Hello"), + new CustomMetadataFieldSchemaDefaultValueDefaultValueItem(true), + new CustomMetadataFieldSchemaDefaultValueDefaultValueItem(10), + new CustomMetadataFieldSchemaDefaultValueDefaultValueItem("Hello"), ] ), IsValueRequired = true, @@ -202,9 +202,9 @@ public void CopyConstructor_Works() Type = CustomMetadataFieldSchemaType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent9(true), - new UnnamedSchemaWithArrayParent9(10), - new UnnamedSchemaWithArrayParent9("Hello"), + new CustomMetadataFieldSchemaDefaultValueDefaultValueItem(true), + new CustomMetadataFieldSchemaDefaultValueDefaultValueItem(10), + new CustomMetadataFieldSchemaDefaultValueDefaultValueItem("Hello"), ] ), IsValueRequired = true, @@ -232,9 +232,9 @@ public void FieldRoundtrip_Works() Type = CustomMetadataFieldSchemaType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent9(true), - new UnnamedSchemaWithArrayParent9(10), - new UnnamedSchemaWithArrayParent9("Hello"), + new CustomMetadataFieldSchemaDefaultValueDefaultValueItem(true), + new CustomMetadataFieldSchemaDefaultValueDefaultValueItem(10), + new CustomMetadataFieldSchemaDefaultValueDefaultValueItem("Hello"), ] ), IsValueRequired = true, @@ -249,9 +249,9 @@ public void FieldRoundtrip_Works() CustomMetadataFieldSchemaType.Text; CustomMetadataFieldSchemaDefaultValue expectedDefaultValue = new( [ - new UnnamedSchemaWithArrayParent9(true), - new UnnamedSchemaWithArrayParent9(10), - new UnnamedSchemaWithArrayParent9("Hello"), + new CustomMetadataFieldSchemaDefaultValueDefaultValueItem(true), + new CustomMetadataFieldSchemaDefaultValueDefaultValueItem(10), + new CustomMetadataFieldSchemaDefaultValueDefaultValueItem("Hello"), ] ); bool expectedIsValueRequired = true; @@ -292,9 +292,9 @@ public void SerializationRoundtrip_Works() Type = CustomMetadataFieldSchemaType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent9(true), - new UnnamedSchemaWithArrayParent9(10), - new UnnamedSchemaWithArrayParent9("Hello"), + new CustomMetadataFieldSchemaDefaultValueDefaultValueItem(true), + new CustomMetadataFieldSchemaDefaultValueDefaultValueItem(10), + new CustomMetadataFieldSchemaDefaultValueDefaultValueItem("Hello"), ] ), IsValueRequired = true, @@ -322,9 +322,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = CustomMetadataFieldSchemaType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent9(true), - new UnnamedSchemaWithArrayParent9(10), - new UnnamedSchemaWithArrayParent9("Hello"), + new CustomMetadataFieldSchemaDefaultValueDefaultValueItem(true), + new CustomMetadataFieldSchemaDefaultValueDefaultValueItem(10), + new CustomMetadataFieldSchemaDefaultValueDefaultValueItem("Hello"), ] ), IsValueRequired = true, @@ -346,9 +346,9 @@ public void FieldRoundtripThroughSerialization_Works() CustomMetadataFieldSchemaType.Text; CustomMetadataFieldSchemaDefaultValue expectedDefaultValue = new( [ - new UnnamedSchemaWithArrayParent9(true), - new UnnamedSchemaWithArrayParent9(10), - new UnnamedSchemaWithArrayParent9("Hello"), + new CustomMetadataFieldSchemaDefaultValueDefaultValueItem(true), + new CustomMetadataFieldSchemaDefaultValueDefaultValueItem(10), + new CustomMetadataFieldSchemaDefaultValueDefaultValueItem("Hello"), ] ); bool expectedIsValueRequired = true; @@ -389,9 +389,9 @@ public void Validation_Works() Type = CustomMetadataFieldSchemaType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent9(true), - new UnnamedSchemaWithArrayParent9(10), - new UnnamedSchemaWithArrayParent9("Hello"), + new CustomMetadataFieldSchemaDefaultValueDefaultValueItem(true), + new CustomMetadataFieldSchemaDefaultValueDefaultValueItem(10), + new CustomMetadataFieldSchemaDefaultValueDefaultValueItem("Hello"), ] ), IsValueRequired = true, @@ -495,9 +495,9 @@ public void CopyConstructor_Works() Type = CustomMetadataFieldSchemaType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent9(true), - new UnnamedSchemaWithArrayParent9(10), - new UnnamedSchemaWithArrayParent9("Hello"), + new CustomMetadataFieldSchemaDefaultValueDefaultValueItem(true), + new CustomMetadataFieldSchemaDefaultValueDefaultValueItem(10), + new CustomMetadataFieldSchemaDefaultValueDefaultValueItem("Hello"), ] ), IsValueRequired = true, @@ -608,9 +608,9 @@ public void MixedValidationWorks() { CustomMetadataFieldSchemaDefaultValue value = new( [ - new UnnamedSchemaWithArrayParent9(true), - new UnnamedSchemaWithArrayParent9(10), - new UnnamedSchemaWithArrayParent9("Hello"), + new CustomMetadataFieldSchemaDefaultValueDefaultValueItem(true), + new CustomMetadataFieldSchemaDefaultValueDefaultValueItem(10), + new CustomMetadataFieldSchemaDefaultValueDefaultValueItem("Hello"), ] ); value.Validate(); @@ -660,9 +660,9 @@ public void MixedSerializationRoundtripWorks() { CustomMetadataFieldSchemaDefaultValue value = new( [ - new UnnamedSchemaWithArrayParent9(true), - new UnnamedSchemaWithArrayParent9(10), - new UnnamedSchemaWithArrayParent9("Hello"), + new CustomMetadataFieldSchemaDefaultValueDefaultValueItem(true), + new CustomMetadataFieldSchemaDefaultValueDefaultValueItem(10), + new CustomMetadataFieldSchemaDefaultValueDefaultValueItem("Hello"), ] ); string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -675,38 +675,39 @@ public void MixedSerializationRoundtripWorks() } } -public class UnnamedSchemaWithArrayParent9Test : TestBase +public class CustomMetadataFieldSchemaDefaultValueDefaultValueItemTest : TestBase { [Fact] public void StringValidationWorks() { - UnnamedSchemaWithArrayParent9 value = "string"; + CustomMetadataFieldSchemaDefaultValueDefaultValueItem value = "string"; value.Validate(); } [Fact] public void DoubleValidationWorks() { - UnnamedSchemaWithArrayParent9 value = 0; + CustomMetadataFieldSchemaDefaultValueDefaultValueItem value = 0; value.Validate(); } [Fact] public void BoolValidationWorks() { - UnnamedSchemaWithArrayParent9 value = true; + CustomMetadataFieldSchemaDefaultValueDefaultValueItem value = true; value.Validate(); } [Fact] public void StringSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent9 value = "string"; + CustomMetadataFieldSchemaDefaultValueDefaultValueItem value = "string"; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } @@ -714,12 +715,13 @@ public void StringSerializationRoundtripWorks() [Fact] public void DoubleSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent9 value = 0; + CustomMetadataFieldSchemaDefaultValueDefaultValueItem value = 0; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } @@ -727,12 +729,13 @@ public void DoubleSerializationRoundtripWorks() [Fact] public void BoolSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent9 value = true; + CustomMetadataFieldSchemaDefaultValueDefaultValueItem value = true; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } diff --git a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsTest.cs b/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsTest.cs index 323e2eef..26218957 100644 --- a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsTest.cs +++ b/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsTest.cs @@ -19,9 +19,11 @@ public void FieldRoundtrip_Works() { DefaultValue = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem(true), + new CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem(10), + new CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem( + "Hello" + ), ] ), IsValueRequired = true, @@ -39,9 +41,9 @@ public void FieldRoundtrip_Works() { DefaultValue = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem(true), + new CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem(10), + new CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem("Hello"), ] ), IsValueRequired = true, @@ -109,9 +111,11 @@ public void CopyConstructor_Works() { DefaultValue = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem(true), + new CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem(10), + new CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem( + "Hello" + ), ] ), IsValueRequired = true, @@ -138,9 +142,9 @@ public void FieldRoundtrip_Works() { DefaultValue = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem(true), + new CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem(10), + new CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem("Hello"), ] ), IsValueRequired = true, @@ -153,9 +157,9 @@ public void FieldRoundtrip_Works() CustomMetadataFieldUpdateParamsSchemaDefaultValue expectedDefaultValue = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem(true), + new CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem(10), + new CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem("Hello"), ] ); bool expectedIsValueRequired = true; @@ -194,9 +198,9 @@ public void SerializationRoundtrip_Works() { DefaultValue = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem(true), + new CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem(10), + new CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem("Hello"), ] ), IsValueRequired = true, @@ -223,9 +227,9 @@ public void FieldRoundtripThroughSerialization_Works() { DefaultValue = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem(true), + new CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem(10), + new CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem("Hello"), ] ), IsValueRequired = true, @@ -245,9 +249,9 @@ public void FieldRoundtripThroughSerialization_Works() CustomMetadataFieldUpdateParamsSchemaDefaultValue expectedDefaultValue = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem(true), + new CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem(10), + new CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem("Hello"), ] ); bool expectedIsValueRequired = true; @@ -286,9 +290,9 @@ public void Validation_Works() { DefaultValue = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem(true), + new CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem(10), + new CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem("Hello"), ] ), IsValueRequired = true, @@ -387,9 +391,9 @@ public void CopyConstructor_Works() { DefaultValue = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem(true), + new CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem(10), + new CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem("Hello"), ] ), IsValueRequired = true, @@ -434,9 +438,9 @@ public void MixedValidationWorks() { CustomMetadataFieldUpdateParamsSchemaDefaultValue value = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem(true), + new CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem(10), + new CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem("Hello"), ] ); value.Validate(); @@ -489,9 +493,9 @@ public void MixedSerializationRoundtripWorks() { CustomMetadataFieldUpdateParamsSchemaDefaultValue value = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem(true), + new CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem(10), + new CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem("Hello"), ] ); string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -505,38 +509,39 @@ public void MixedSerializationRoundtripWorks() } } -public class UnnamedSchemaWithArrayParent2Test : TestBase +public class CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItemTest : TestBase { [Fact] public void StringValidationWorks() { - UnnamedSchemaWithArrayParent2 value = "string"; + CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem value = "string"; value.Validate(); } [Fact] public void DoubleValidationWorks() { - UnnamedSchemaWithArrayParent2 value = 0; + CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem value = 0; value.Validate(); } [Fact] public void BoolValidationWorks() { - UnnamedSchemaWithArrayParent2 value = true; + CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem value = true; value.Validate(); } [Fact] public void StringSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent2 value = "string"; + CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem value = "string"; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } @@ -544,12 +549,13 @@ public void StringSerializationRoundtripWorks() [Fact] public void DoubleSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent2 value = 0; + CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem value = 0; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } @@ -557,12 +563,13 @@ public void DoubleSerializationRoundtripWorks() [Fact] public void BoolSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent2 value = true; + CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem value = true; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } diff --git a/src/ImageKit.Tests/Models/ExtensionConfigTest.cs b/src/ImageKit.Tests/Models/ExtensionConfigTest.cs index 62940855..3fbb1f11 100644 --- a/src/ImageKit.Tests/Models/ExtensionConfigTest.cs +++ b/src/ImageKit.Tests/Models/ExtensionConfigTest.cs @@ -2003,7 +2003,7 @@ public void BoolValidationWorks() [Fact] public void MixedValidationWorks() { - SetMetadataValue value = new([new UnnamedSchemaWithArrayParent3("string")]); + SetMetadataValue value = new([new MetadataValueItem("string")]); value.Validate(); } @@ -2049,7 +2049,7 @@ public void BoolSerializationRoundtripWorks() [Fact] public void MixedSerializationRoundtripWorks() { - SetMetadataValue value = new([new UnnamedSchemaWithArrayParent3("string")]); + SetMetadataValue value = new([new MetadataValueItem("string")]); string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize( element, @@ -2060,35 +2060,35 @@ public void MixedSerializationRoundtripWorks() } } -public class UnnamedSchemaWithArrayParent3Test : TestBase +public class MetadataValueItemTest : TestBase { [Fact] public void StringValidationWorks() { - UnnamedSchemaWithArrayParent3 value = "string"; + MetadataValueItem value = "string"; value.Validate(); } [Fact] public void DoubleValidationWorks() { - UnnamedSchemaWithArrayParent3 value = 0; + MetadataValueItem value = 0; value.Validate(); } [Fact] public void BoolValidationWorks() { - UnnamedSchemaWithArrayParent3 value = true; + MetadataValueItem value = true; value.Validate(); } [Fact] public void StringSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent3 value = "string"; + MetadataValueItem value = "string"; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -2099,9 +2099,9 @@ public void StringSerializationRoundtripWorks() [Fact] public void DoubleSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent3 value = 0; + MetadataValueItem value = 0; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -2112,9 +2112,9 @@ public void DoubleSerializationRoundtripWorks() [Fact] public void BoolSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent3 value = true; + MetadataValueItem value = true; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -2484,7 +2484,9 @@ public void BoolValidationWorks() [Fact] public void MixedValidationWorks() { - OnUnknownSetMetadataValue value = new([new UnnamedSchemaWithArrayParent4("string")]); + OnUnknownSetMetadataValue value = new( + [new OnUnknownSetMetadataValueMetadataValueItem("string")] + ); value.Validate(); } @@ -2530,7 +2532,9 @@ public void BoolSerializationRoundtripWorks() [Fact] public void MixedSerializationRoundtripWorks() { - OnUnknownSetMetadataValue value = new([new UnnamedSchemaWithArrayParent4("string")]); + OnUnknownSetMetadataValue value = new( + [new OnUnknownSetMetadataValueMetadataValueItem("string")] + ); string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize( element, @@ -2541,35 +2545,35 @@ public void MixedSerializationRoundtripWorks() } } -public class UnnamedSchemaWithArrayParent4Test : TestBase +public class OnUnknownSetMetadataValueMetadataValueItemTest : TestBase { [Fact] public void StringValidationWorks() { - UnnamedSchemaWithArrayParent4 value = "string"; + OnUnknownSetMetadataValueMetadataValueItem value = "string"; value.Validate(); } [Fact] public void DoubleValidationWorks() { - UnnamedSchemaWithArrayParent4 value = 0; + OnUnknownSetMetadataValueMetadataValueItem value = 0; value.Validate(); } [Fact] public void BoolValidationWorks() { - UnnamedSchemaWithArrayParent4 value = true; + OnUnknownSetMetadataValueMetadataValueItem value = true; value.Validate(); } [Fact] public void StringSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent4 value = "string"; + OnUnknownSetMetadataValueMetadataValueItem value = "string"; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -2580,9 +2584,9 @@ public void StringSerializationRoundtripWorks() [Fact] public void DoubleSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent4 value = 0; + OnUnknownSetMetadataValueMetadataValueItem value = 0; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -2593,9 +2597,9 @@ public void DoubleSerializationRoundtripWorks() [Fact] public void BoolSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent4 value = true; + OnUnknownSetMetadataValueMetadataValueItem value = true; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -2962,7 +2966,7 @@ public void BoolValidationWorks() [Fact] public void MixedValidationWorks() { - OnYesSetMetadataValue value = new([new UnnamedSchemaWithArrayParent5("string")]); + OnYesSetMetadataValue value = new([new OnYesSetMetadataValueMetadataValueItem("string")]); value.Validate(); } @@ -3008,7 +3012,7 @@ public void BoolSerializationRoundtripWorks() [Fact] public void MixedSerializationRoundtripWorks() { - OnYesSetMetadataValue value = new([new UnnamedSchemaWithArrayParent5("string")]); + OnYesSetMetadataValue value = new([new OnYesSetMetadataValueMetadataValueItem("string")]); string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize( element, @@ -3019,35 +3023,35 @@ public void MixedSerializationRoundtripWorks() } } -public class UnnamedSchemaWithArrayParent5Test : TestBase +public class OnYesSetMetadataValueMetadataValueItemTest : TestBase { [Fact] public void StringValidationWorks() { - UnnamedSchemaWithArrayParent5 value = "string"; + OnYesSetMetadataValueMetadataValueItem value = "string"; value.Validate(); } [Fact] public void DoubleValidationWorks() { - UnnamedSchemaWithArrayParent5 value = 0; + OnYesSetMetadataValueMetadataValueItem value = 0; value.Validate(); } [Fact] public void BoolValidationWorks() { - UnnamedSchemaWithArrayParent5 value = true; + OnYesSetMetadataValueMetadataValueItem value = true; value.Validate(); } [Fact] public void StringSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent5 value = "string"; + OnYesSetMetadataValueMetadataValueItem value = "string"; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -3058,9 +3062,9 @@ public void StringSerializationRoundtripWorks() [Fact] public void DoubleSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent5 value = 0; + OnYesSetMetadataValueMetadataValueItem value = 0; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -3071,9 +3075,9 @@ public void DoubleSerializationRoundtripWorks() [Fact] public void BoolSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent5 value = true; + OnYesSetMetadataValueMetadataValueItem value = true; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); diff --git a/src/ImageKit.Tests/Models/Files/FileTest.cs b/src/ImageKit.Tests/Models/Files/FileTest.cs index 8b5e6a8a..e87fa09b 100644 --- a/src/ImageKit.Tests/Models/Files/FileTest.cs +++ b/src/ImageKit.Tests/Models/Files/FileTest.cs @@ -55,9 +55,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -123,9 +123,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -256,9 +256,9 @@ public void SerializationRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -338,9 +338,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -413,9 +413,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -546,9 +546,9 @@ public void Validation_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -848,9 +848,9 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -918,9 +918,9 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -983,9 +983,9 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -1057,9 +1057,9 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -1136,9 +1136,9 @@ public void CopyConstructor_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -1328,9 +1328,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -1346,9 +1346,9 @@ public void FieldRoundtrip_Works() ApiEnum expectedType = Files::Type.Text; Files::DefaultValue expectedDefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ); bool expectedIsValueRequired = true; @@ -1393,9 +1393,9 @@ public void SerializationRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -1425,9 +1425,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -1450,9 +1450,9 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum expectedType = Files::Type.Text; Files::DefaultValue expectedDefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ); bool expectedIsValueRequired = true; @@ -1497,9 +1497,9 @@ public void Validation_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -1617,9 +1617,9 @@ public void CopyConstructor_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -1734,9 +1734,9 @@ public void MixedValidationWorks() { Files::DefaultValue value = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ); value.Validate(); @@ -1786,9 +1786,9 @@ public void MixedSerializationRoundtripWorks() { Files::DefaultValue value = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ); string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -1801,35 +1801,35 @@ public void MixedSerializationRoundtripWorks() } } -public class UnnamedSchemaWithArrayParent10Test : TestBase +public class UnnamedSchemaWithArrayParent1Test : TestBase { [Fact] public void StringValidationWorks() { - Files::UnnamedSchemaWithArrayParent10 value = "string"; + Files::UnnamedSchemaWithArrayParent1 value = "string"; value.Validate(); } [Fact] public void DoubleValidationWorks() { - Files::UnnamedSchemaWithArrayParent10 value = 0; + Files::UnnamedSchemaWithArrayParent1 value = 0; value.Validate(); } [Fact] public void BoolValidationWorks() { - Files::UnnamedSchemaWithArrayParent10 value = true; + Files::UnnamedSchemaWithArrayParent1 value = true; value.Validate(); } [Fact] public void StringSerializationRoundtripWorks() { - Files::UnnamedSchemaWithArrayParent10 value = "string"; + Files::UnnamedSchemaWithArrayParent1 value = "string"; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -1840,9 +1840,9 @@ public void StringSerializationRoundtripWorks() [Fact] public void DoubleSerializationRoundtripWorks() { - Files::UnnamedSchemaWithArrayParent10 value = 0; + Files::UnnamedSchemaWithArrayParent1 value = 0; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -1853,9 +1853,9 @@ public void DoubleSerializationRoundtripWorks() [Fact] public void BoolSerializationRoundtripWorks() { - Files::UnnamedSchemaWithArrayParent10 value = true; + Files::UnnamedSchemaWithArrayParent1 value = true; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); diff --git a/src/ImageKit.Tests/Models/Files/FileUpdateResponseTest.cs b/src/ImageKit.Tests/Models/Files/FileUpdateResponseTest.cs index 28653512..4387211a 100644 --- a/src/ImageKit.Tests/Models/Files/FileUpdateResponseTest.cs +++ b/src/ImageKit.Tests/Models/Files/FileUpdateResponseTest.cs @@ -55,9 +55,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -131,9 +131,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -273,9 +273,9 @@ public void SerializationRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -363,9 +363,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -446,9 +446,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -588,9 +588,9 @@ public void Validation_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -904,9 +904,9 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -982,9 +982,9 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -1055,9 +1055,9 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -1137,9 +1137,9 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -1224,9 +1224,9 @@ public void CopyConstructor_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, diff --git a/src/ImageKit.Tests/Models/Files/FileUploadResponseTest.cs b/src/ImageKit.Tests/Models/Files/FileUploadResponseTest.cs index f870a912..be5b9c7c 100644 --- a/src/ImageKit.Tests/Models/Files/FileUploadResponseTest.cs +++ b/src/ImageKit.Tests/Models/Files/FileUploadResponseTest.cs @@ -143,9 +143,9 @@ public void FieldRoundtrip_Works() Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent11(true), - new UnnamedSchemaWithArrayParent11(10), - new UnnamedSchemaWithArrayParent11("Hello"), + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), ] ), IsValueRequired = true, @@ -298,9 +298,9 @@ public void FieldRoundtrip_Works() Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent11(true), - new UnnamedSchemaWithArrayParent11(10), - new UnnamedSchemaWithArrayParent11("Hello"), + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), ] ), IsValueRequired = true, @@ -515,9 +515,9 @@ public void SerializationRoundtrip_Works() Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent11(true), - new UnnamedSchemaWithArrayParent11(10), - new UnnamedSchemaWithArrayParent11("Hello"), + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), ] ), IsValueRequired = true, @@ -684,9 +684,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent11(true), - new UnnamedSchemaWithArrayParent11(10), - new UnnamedSchemaWithArrayParent11("Hello"), + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), ] ), IsValueRequired = true, @@ -846,9 +846,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent11(true), - new UnnamedSchemaWithArrayParent11(10), - new UnnamedSchemaWithArrayParent11("Hello"), + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), ] ), IsValueRequired = true, @@ -1063,9 +1063,9 @@ public void Validation_Works() Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent11(true), - new UnnamedSchemaWithArrayParent11(10), - new UnnamedSchemaWithArrayParent11("Hello"), + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), ] ), IsValueRequired = true, @@ -1434,9 +1434,9 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent11(true), - new UnnamedSchemaWithArrayParent11(10), - new UnnamedSchemaWithArrayParent11("Hello"), + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), ] ), IsValueRequired = true, @@ -1591,9 +1591,9 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent11(true), - new UnnamedSchemaWithArrayParent11(10), - new UnnamedSchemaWithArrayParent11("Hello"), + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), ] ), IsValueRequired = true, @@ -1743,9 +1743,9 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent11(true), - new UnnamedSchemaWithArrayParent11(10), - new UnnamedSchemaWithArrayParent11("Hello"), + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), ] ), IsValueRequired = true, @@ -1904,9 +1904,9 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent11(true), - new UnnamedSchemaWithArrayParent11(10), - new UnnamedSchemaWithArrayParent11("Hello"), + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), ] ), IsValueRequired = true, @@ -2070,9 +2070,9 @@ public void CopyConstructor_Works() Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent11(true), - new UnnamedSchemaWithArrayParent11(10), - new UnnamedSchemaWithArrayParent11("Hello"), + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), ] ), IsValueRequired = true, @@ -2743,9 +2743,9 @@ public void FieldRoundtrip_Works() Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent11(true), - new UnnamedSchemaWithArrayParent11(10), - new UnnamedSchemaWithArrayParent11("Hello"), + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), ] ), IsValueRequired = true, @@ -2762,9 +2762,9 @@ public void FieldRoundtrip_Works() FileUploadResponseSelectedFieldsSchemaItemType.Text; FileUploadResponseSelectedFieldsSchemaItemDefaultValue expectedDefaultValue = new( [ - new UnnamedSchemaWithArrayParent11(true), - new UnnamedSchemaWithArrayParent11(10), - new UnnamedSchemaWithArrayParent11("Hello"), + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), ] ); bool expectedIsValueRequired = true; @@ -2809,9 +2809,9 @@ public void SerializationRoundtrip_Works() Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent11(true), - new UnnamedSchemaWithArrayParent11(10), - new UnnamedSchemaWithArrayParent11("Hello"), + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), ] ), IsValueRequired = true, @@ -2841,9 +2841,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent11(true), - new UnnamedSchemaWithArrayParent11(10), - new UnnamedSchemaWithArrayParent11("Hello"), + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), ] ), IsValueRequired = true, @@ -2867,9 +2867,9 @@ public void FieldRoundtripThroughSerialization_Works() FileUploadResponseSelectedFieldsSchemaItemType.Text; FileUploadResponseSelectedFieldsSchemaItemDefaultValue expectedDefaultValue = new( [ - new UnnamedSchemaWithArrayParent11(true), - new UnnamedSchemaWithArrayParent11(10), - new UnnamedSchemaWithArrayParent11("Hello"), + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), ] ); bool expectedIsValueRequired = true; @@ -2914,9 +2914,9 @@ public void Validation_Works() Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent11(true), - new UnnamedSchemaWithArrayParent11(10), - new UnnamedSchemaWithArrayParent11("Hello"), + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), ] ), IsValueRequired = true, @@ -3040,9 +3040,9 @@ public void CopyConstructor_Works() Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent11(true), - new UnnamedSchemaWithArrayParent11(10), - new UnnamedSchemaWithArrayParent11("Hello"), + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), ] ), IsValueRequired = true, @@ -3155,9 +3155,9 @@ public void MixedValidationWorks() { FileUploadResponseSelectedFieldsSchemaItemDefaultValue value = new( [ - new UnnamedSchemaWithArrayParent11(true), - new UnnamedSchemaWithArrayParent11(10), - new UnnamedSchemaWithArrayParent11("Hello"), + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), ] ); value.Validate(); @@ -3210,9 +3210,9 @@ public void MixedSerializationRoundtripWorks() { FileUploadResponseSelectedFieldsSchemaItemDefaultValue value = new( [ - new UnnamedSchemaWithArrayParent11(true), - new UnnamedSchemaWithArrayParent11(10), - new UnnamedSchemaWithArrayParent11("Hello"), + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), ] ); string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3226,35 +3226,35 @@ public void MixedSerializationRoundtripWorks() } } -public class UnnamedSchemaWithArrayParent11Test : TestBase +public class UnnamedSchemaWithArrayParent2Test : TestBase { [Fact] public void StringValidationWorks() { - UnnamedSchemaWithArrayParent11 value = "string"; + UnnamedSchemaWithArrayParent2 value = "string"; value.Validate(); } [Fact] public void DoubleValidationWorks() { - UnnamedSchemaWithArrayParent11 value = 0; + UnnamedSchemaWithArrayParent2 value = 0; value.Validate(); } [Fact] public void BoolValidationWorks() { - UnnamedSchemaWithArrayParent11 value = true; + UnnamedSchemaWithArrayParent2 value = true; value.Validate(); } [Fact] public void StringSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent11 value = "string"; + UnnamedSchemaWithArrayParent2 value = "string"; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -3265,9 +3265,9 @@ public void StringSerializationRoundtripWorks() [Fact] public void DoubleSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent11 value = 0; + UnnamedSchemaWithArrayParent2 value = 0; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -3278,9 +3278,9 @@ public void DoubleSerializationRoundtripWorks() [Fact] public void BoolSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent11 value = true; + UnnamedSchemaWithArrayParent2 value = true; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); diff --git a/src/ImageKit.Tests/Models/UnnamedSchemaWithArrayParent0Test.cs b/src/ImageKit.Tests/Models/UnnamedSchemaWithArrayParent0Test.cs index 27f3c47e..34c08047 100644 --- a/src/ImageKit.Tests/Models/UnnamedSchemaWithArrayParent0Test.cs +++ b/src/ImageKit.Tests/Models/UnnamedSchemaWithArrayParent0Test.cs @@ -2126,7 +2126,11 @@ public void BoolValidationWorks() public void MixedValidationWorks() { UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue value = new( - [new UnnamedSchemaWithArrayParent6("string")] + [ + new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem( + "string" + ), + ] ); value.Validate(); } @@ -2177,7 +2181,11 @@ public void BoolSerializationRoundtripWorks() public void MixedSerializationRoundtripWorks() { UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue value = new( - [new UnnamedSchemaWithArrayParent6("string")] + [ + new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem( + "string" + ), + ] ); string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = @@ -2190,38 +2198,44 @@ [new UnnamedSchemaWithArrayParent6("string")] } } -public class UnnamedSchemaWithArrayParent6Test : TestBase +public class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItemTest + : TestBase { [Fact] public void StringValidationWorks() { - UnnamedSchemaWithArrayParent6 value = "string"; + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem value = + "string"; value.Validate(); } [Fact] public void DoubleValidationWorks() { - UnnamedSchemaWithArrayParent6 value = 0; + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem value = + 0; value.Validate(); } [Fact] public void BoolValidationWorks() { - UnnamedSchemaWithArrayParent6 value = true; + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem value = + true; value.Validate(); } [Fact] public void StringSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent6 value = "string"; + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem value = + "string"; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } @@ -2229,12 +2243,14 @@ public void StringSerializationRoundtripWorks() [Fact] public void DoubleSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent6 value = 0; + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem value = + 0; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } @@ -2242,12 +2258,14 @@ public void DoubleSerializationRoundtripWorks() [Fact] public void BoolSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent6 value = true; + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem value = + true; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } @@ -2667,7 +2685,11 @@ public void BoolValidationWorks() public void MixedValidationWorks() { UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue value = new( - [new UnnamedSchemaWithArrayParent7("string")] + [ + new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem( + "string" + ), + ] ); value.Validate(); } @@ -2718,7 +2740,11 @@ public void BoolSerializationRoundtripWorks() public void MixedSerializationRoundtripWorks() { UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue value = new( - [new UnnamedSchemaWithArrayParent7("string")] + [ + new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem( + "string" + ), + ] ); string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = @@ -2731,38 +2757,44 @@ [new UnnamedSchemaWithArrayParent7("string")] } } -public class UnnamedSchemaWithArrayParent7Test : TestBase +public class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItemTest + : TestBase { [Fact] public void StringValidationWorks() { - UnnamedSchemaWithArrayParent7 value = "string"; + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem value = + "string"; value.Validate(); } [Fact] public void DoubleValidationWorks() { - UnnamedSchemaWithArrayParent7 value = 0; + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem value = + 0; value.Validate(); } [Fact] public void BoolValidationWorks() { - UnnamedSchemaWithArrayParent7 value = true; + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem value = + true; value.Validate(); } [Fact] public void StringSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent7 value = "string"; + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem value = + "string"; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } @@ -2770,12 +2802,14 @@ public void StringSerializationRoundtripWorks() [Fact] public void DoubleSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent7 value = 0; + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem value = + 0; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } @@ -2783,12 +2817,14 @@ public void DoubleSerializationRoundtripWorks() [Fact] public void BoolSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent7 value = true; + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem value = + true; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } @@ -3206,7 +3242,11 @@ public void BoolValidationWorks() public void MixedValidationWorks() { UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue value = new( - [new UnnamedSchemaWithArrayParent8("string")] + [ + new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem( + "string" + ), + ] ); value.Validate(); } @@ -3257,7 +3297,11 @@ public void BoolSerializationRoundtripWorks() public void MixedSerializationRoundtripWorks() { UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue value = new( - [new UnnamedSchemaWithArrayParent8("string")] + [ + new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem( + "string" + ), + ] ); string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = @@ -3270,38 +3314,44 @@ [new UnnamedSchemaWithArrayParent8("string")] } } -public class UnnamedSchemaWithArrayParent8Test : TestBase +public class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItemTest + : TestBase { [Fact] public void StringValidationWorks() { - UnnamedSchemaWithArrayParent8 value = "string"; + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem value = + "string"; value.Validate(); } [Fact] public void DoubleValidationWorks() { - UnnamedSchemaWithArrayParent8 value = 0; + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem value = + 0; value.Validate(); } [Fact] public void BoolValidationWorks() { - UnnamedSchemaWithArrayParent8 value = true; + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem value = + true; value.Validate(); } [Fact] public void StringSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent8 value = "string"; + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem value = + "string"; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } @@ -3309,12 +3359,14 @@ public void StringSerializationRoundtripWorks() [Fact] public void DoubleSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent8 value = 0; + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem value = + 0; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } @@ -3322,12 +3374,14 @@ public void DoubleSerializationRoundtripWorks() [Fact] public void BoolSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent8 value = true; + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem value = + true; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } diff --git a/src/ImageKit.Tests/Models/Webhooks/FileCreateEventTest.cs b/src/ImageKit.Tests/Models/Webhooks/FileCreateEventTest.cs index 95db784a..8ec2e0fa 100644 --- a/src/ImageKit.Tests/Models/Webhooks/FileCreateEventTest.cs +++ b/src/ImageKit.Tests/Models/Webhooks/FileCreateEventTest.cs @@ -60,9 +60,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -134,9 +134,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -218,9 +218,9 @@ public void SerializationRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -306,9 +306,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -387,9 +387,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -471,9 +471,9 @@ public void Validation_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -553,9 +553,9 @@ public void CopyConstructor_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -638,9 +638,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -710,9 +710,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -792,9 +792,9 @@ public void SerializationRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -878,9 +878,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -957,9 +957,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -1039,9 +1039,9 @@ public void Validation_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -1119,9 +1119,9 @@ public void CopyConstructor_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, diff --git a/src/ImageKit.Tests/Models/Webhooks/FileUpdateEventTest.cs b/src/ImageKit.Tests/Models/Webhooks/FileUpdateEventTest.cs index 19bcf67c..71095754 100644 --- a/src/ImageKit.Tests/Models/Webhooks/FileUpdateEventTest.cs +++ b/src/ImageKit.Tests/Models/Webhooks/FileUpdateEventTest.cs @@ -60,9 +60,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -134,9 +134,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -218,9 +218,9 @@ public void SerializationRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -306,9 +306,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -387,9 +387,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -471,9 +471,9 @@ public void Validation_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -553,9 +553,9 @@ public void CopyConstructor_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -638,9 +638,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -710,9 +710,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -792,9 +792,9 @@ public void SerializationRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -878,9 +878,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -957,9 +957,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -1039,9 +1039,9 @@ public void Validation_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -1119,9 +1119,9 @@ public void CopyConstructor_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, diff --git a/src/ImageKit.Tests/Models/Webhooks/FileVersionCreateEventTest.cs b/src/ImageKit.Tests/Models/Webhooks/FileVersionCreateEventTest.cs index dd26a01e..9cf1785e 100644 --- a/src/ImageKit.Tests/Models/Webhooks/FileVersionCreateEventTest.cs +++ b/src/ImageKit.Tests/Models/Webhooks/FileVersionCreateEventTest.cs @@ -60,9 +60,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -134,9 +134,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -218,9 +218,9 @@ public void SerializationRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -306,9 +306,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -387,9 +387,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -471,9 +471,9 @@ public void Validation_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -553,9 +553,9 @@ public void CopyConstructor_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -638,9 +638,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -710,9 +710,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -792,9 +792,9 @@ public void SerializationRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -878,9 +878,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -957,9 +957,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -1039,9 +1039,9 @@ public void Validation_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -1119,9 +1119,9 @@ public void CopyConstructor_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, diff --git a/src/ImageKit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs b/src/ImageKit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs index c8be295a..c8320a2e 100644 --- a/src/ImageKit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs +++ b/src/ImageKit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs @@ -278,9 +278,9 @@ public void UploadPreTransformSuccessValidationWorks() Type = Webhooks::SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new Webhooks::UnnamedSchemaWithArrayParent13(true), - new Webhooks::UnnamedSchemaWithArrayParent13(10), - new Webhooks::UnnamedSchemaWithArrayParent13("Hello"), + new Webhooks::UnnamedSchemaWithArrayParent4(true), + new Webhooks::UnnamedSchemaWithArrayParent4(10), + new Webhooks::UnnamedSchemaWithArrayParent4("Hello"), ] ), IsValueRequired = true, @@ -441,9 +441,9 @@ public void FileCreateValidationWorks() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -522,9 +522,9 @@ public void FileUpdateValidationWorks() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -616,9 +616,9 @@ public void FileVersionCreateValidationWorks() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -946,9 +946,9 @@ public void UploadPreTransformSuccessSerializationRoundtripWorks() Type = Webhooks::SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new Webhooks::UnnamedSchemaWithArrayParent13(true), - new Webhooks::UnnamedSchemaWithArrayParent13(10), - new Webhooks::UnnamedSchemaWithArrayParent13("Hello"), + new Webhooks::UnnamedSchemaWithArrayParent4(true), + new Webhooks::UnnamedSchemaWithArrayParent4(10), + new Webhooks::UnnamedSchemaWithArrayParent4("Hello"), ] ), IsValueRequired = true, @@ -1133,9 +1133,9 @@ public void FileCreateSerializationRoundtripWorks() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -1220,9 +1220,9 @@ public void FileUpdateSerializationRoundtripWorks() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -1326,9 +1326,9 @@ public void FileVersionCreateSerializationRoundtripWorks() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, diff --git a/src/ImageKit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs b/src/ImageKit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs index 15e958f9..d6dc519d 100644 --- a/src/ImageKit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs +++ b/src/ImageKit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs @@ -278,9 +278,9 @@ public void UploadPreTransformSuccessValidationWorks() Type = Webhooks::SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new Webhooks::UnnamedSchemaWithArrayParent13(true), - new Webhooks::UnnamedSchemaWithArrayParent13(10), - new Webhooks::UnnamedSchemaWithArrayParent13("Hello"), + new Webhooks::UnnamedSchemaWithArrayParent4(true), + new Webhooks::UnnamedSchemaWithArrayParent4(10), + new Webhooks::UnnamedSchemaWithArrayParent4("Hello"), ] ), IsValueRequired = true, @@ -441,9 +441,9 @@ public void FileCreateValidationWorks() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -522,9 +522,9 @@ public void FileUpdateValidationWorks() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -616,9 +616,9 @@ public void FileVersionCreateValidationWorks() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -946,9 +946,9 @@ public void UploadPreTransformSuccessSerializationRoundtripWorks() Type = Webhooks::SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new Webhooks::UnnamedSchemaWithArrayParent13(true), - new Webhooks::UnnamedSchemaWithArrayParent13(10), - new Webhooks::UnnamedSchemaWithArrayParent13("Hello"), + new Webhooks::UnnamedSchemaWithArrayParent4(true), + new Webhooks::UnnamedSchemaWithArrayParent4(10), + new Webhooks::UnnamedSchemaWithArrayParent4("Hello"), ] ), IsValueRequired = true, @@ -1133,9 +1133,9 @@ public void FileCreateSerializationRoundtripWorks() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -1220,9 +1220,9 @@ public void FileUpdateSerializationRoundtripWorks() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -1326,9 +1326,9 @@ public void FileVersionCreateSerializationRoundtripWorks() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent10(true), - new Files::UnnamedSchemaWithArrayParent10(10), - new Files::UnnamedSchemaWithArrayParent10("Hello"), + new Files::UnnamedSchemaWithArrayParent1(true), + new Files::UnnamedSchemaWithArrayParent1(10), + new Files::UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, diff --git a/src/ImageKit.Tests/Models/Webhooks/UploadPreTransformSuccessEventTest.cs b/src/ImageKit.Tests/Models/Webhooks/UploadPreTransformSuccessEventTest.cs index da9ad81d..b12e1285 100644 --- a/src/ImageKit.Tests/Models/Webhooks/UploadPreTransformSuccessEventTest.cs +++ b/src/ImageKit.Tests/Models/Webhooks/UploadPreTransformSuccessEventTest.cs @@ -147,9 +147,9 @@ public void FieldRoundtrip_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent13(true), - new UnnamedSchemaWithArrayParent13(10), - new UnnamedSchemaWithArrayParent13("Hello"), + new UnnamedSchemaWithArrayParent4(true), + new UnnamedSchemaWithArrayParent4(10), + new UnnamedSchemaWithArrayParent4("Hello"), ] ), IsValueRequired = true, @@ -306,9 +306,9 @@ public void FieldRoundtrip_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent13(true), - new UnnamedSchemaWithArrayParent13(10), - new UnnamedSchemaWithArrayParent13("Hello"), + new UnnamedSchemaWithArrayParent4(true), + new UnnamedSchemaWithArrayParent4(10), + new UnnamedSchemaWithArrayParent4("Hello"), ] ), IsValueRequired = true, @@ -480,9 +480,9 @@ public void SerializationRoundtrip_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent13(true), - new UnnamedSchemaWithArrayParent13(10), - new UnnamedSchemaWithArrayParent13("Hello"), + new UnnamedSchemaWithArrayParent4(true), + new UnnamedSchemaWithArrayParent4(10), + new UnnamedSchemaWithArrayParent4("Hello"), ] ), IsValueRequired = true, @@ -653,9 +653,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent13(true), - new UnnamedSchemaWithArrayParent13(10), - new UnnamedSchemaWithArrayParent13("Hello"), + new UnnamedSchemaWithArrayParent4(true), + new UnnamedSchemaWithArrayParent4(10), + new UnnamedSchemaWithArrayParent4("Hello"), ] ), IsValueRequired = true, @@ -819,9 +819,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent13(true), - new UnnamedSchemaWithArrayParent13(10), - new UnnamedSchemaWithArrayParent13("Hello"), + new UnnamedSchemaWithArrayParent4(true), + new UnnamedSchemaWithArrayParent4(10), + new UnnamedSchemaWithArrayParent4("Hello"), ] ), IsValueRequired = true, @@ -993,9 +993,9 @@ public void Validation_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent13(true), - new UnnamedSchemaWithArrayParent13(10), - new UnnamedSchemaWithArrayParent13("Hello"), + new UnnamedSchemaWithArrayParent4(true), + new UnnamedSchemaWithArrayParent4(10), + new UnnamedSchemaWithArrayParent4("Hello"), ] ), IsValueRequired = true, @@ -1160,9 +1160,9 @@ public void CopyConstructor_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent13(true), - new UnnamedSchemaWithArrayParent13(10), - new UnnamedSchemaWithArrayParent13("Hello"), + new UnnamedSchemaWithArrayParent4(true), + new UnnamedSchemaWithArrayParent4(10), + new UnnamedSchemaWithArrayParent4("Hello"), ] ), IsValueRequired = true, @@ -1330,9 +1330,9 @@ public void FieldRoundtrip_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent13(true), - new UnnamedSchemaWithArrayParent13(10), - new UnnamedSchemaWithArrayParent13("Hello"), + new UnnamedSchemaWithArrayParent4(true), + new UnnamedSchemaWithArrayParent4(10), + new UnnamedSchemaWithArrayParent4("Hello"), ] ), IsValueRequired = true, @@ -1487,9 +1487,9 @@ public void FieldRoundtrip_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent13(true), - new UnnamedSchemaWithArrayParent13(10), - new UnnamedSchemaWithArrayParent13("Hello"), + new UnnamedSchemaWithArrayParent4(true), + new UnnamedSchemaWithArrayParent4(10), + new UnnamedSchemaWithArrayParent4("Hello"), ] ), IsValueRequired = true, @@ -1661,9 +1661,9 @@ public void SerializationRoundtrip_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent13(true), - new UnnamedSchemaWithArrayParent13(10), - new UnnamedSchemaWithArrayParent13("Hello"), + new UnnamedSchemaWithArrayParent4(true), + new UnnamedSchemaWithArrayParent4(10), + new UnnamedSchemaWithArrayParent4("Hello"), ] ), IsValueRequired = true, @@ -1833,9 +1833,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent13(true), - new UnnamedSchemaWithArrayParent13(10), - new UnnamedSchemaWithArrayParent13("Hello"), + new UnnamedSchemaWithArrayParent4(true), + new UnnamedSchemaWithArrayParent4(10), + new UnnamedSchemaWithArrayParent4("Hello"), ] ), IsValueRequired = true, @@ -1998,9 +1998,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent13(true), - new UnnamedSchemaWithArrayParent13(10), - new UnnamedSchemaWithArrayParent13("Hello"), + new UnnamedSchemaWithArrayParent4(true), + new UnnamedSchemaWithArrayParent4(10), + new UnnamedSchemaWithArrayParent4("Hello"), ] ), IsValueRequired = true, @@ -2172,9 +2172,9 @@ public void Validation_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent13(true), - new UnnamedSchemaWithArrayParent13(10), - new UnnamedSchemaWithArrayParent13("Hello"), + new UnnamedSchemaWithArrayParent4(true), + new UnnamedSchemaWithArrayParent4(10), + new UnnamedSchemaWithArrayParent4("Hello"), ] ), IsValueRequired = true, @@ -2337,9 +2337,9 @@ public void CopyConstructor_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent13(true), - new UnnamedSchemaWithArrayParent13(10), - new UnnamedSchemaWithArrayParent13("Hello"), + new UnnamedSchemaWithArrayParent4(true), + new UnnamedSchemaWithArrayParent4(10), + new UnnamedSchemaWithArrayParent4("Hello"), ] ), IsValueRequired = true, @@ -2504,9 +2504,9 @@ public void FieldRoundtrip_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent13(true), - new UnnamedSchemaWithArrayParent13(10), - new UnnamedSchemaWithArrayParent13("Hello"), + new UnnamedSchemaWithArrayParent4(true), + new UnnamedSchemaWithArrayParent4(10), + new UnnamedSchemaWithArrayParent4("Hello"), ] ), IsValueRequired = true, @@ -2656,9 +2656,9 @@ public void FieldRoundtrip_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent13(true), - new UnnamedSchemaWithArrayParent13(10), - new UnnamedSchemaWithArrayParent13("Hello"), + new UnnamedSchemaWithArrayParent4(true), + new UnnamedSchemaWithArrayParent4(10), + new UnnamedSchemaWithArrayParent4("Hello"), ] ), IsValueRequired = true, @@ -2870,9 +2870,9 @@ public void SerializationRoundtrip_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent13(true), - new UnnamedSchemaWithArrayParent13(10), - new UnnamedSchemaWithArrayParent13("Hello"), + new UnnamedSchemaWithArrayParent4(true), + new UnnamedSchemaWithArrayParent4(10), + new UnnamedSchemaWithArrayParent4("Hello"), ] ), IsValueRequired = true, @@ -3037,9 +3037,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent13(true), - new UnnamedSchemaWithArrayParent13(10), - new UnnamedSchemaWithArrayParent13("Hello"), + new UnnamedSchemaWithArrayParent4(true), + new UnnamedSchemaWithArrayParent4(10), + new UnnamedSchemaWithArrayParent4("Hello"), ] ), IsValueRequired = true, @@ -3197,9 +3197,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent13(true), - new UnnamedSchemaWithArrayParent13(10), - new UnnamedSchemaWithArrayParent13("Hello"), + new UnnamedSchemaWithArrayParent4(true), + new UnnamedSchemaWithArrayParent4(10), + new UnnamedSchemaWithArrayParent4("Hello"), ] ), IsValueRequired = true, @@ -3411,9 +3411,9 @@ public void Validation_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent13(true), - new UnnamedSchemaWithArrayParent13(10), - new UnnamedSchemaWithArrayParent13("Hello"), + new UnnamedSchemaWithArrayParent4(true), + new UnnamedSchemaWithArrayParent4(10), + new UnnamedSchemaWithArrayParent4("Hello"), ] ), IsValueRequired = true, @@ -3779,9 +3779,9 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent13(true), - new UnnamedSchemaWithArrayParent13(10), - new UnnamedSchemaWithArrayParent13("Hello"), + new UnnamedSchemaWithArrayParent4(true), + new UnnamedSchemaWithArrayParent4(10), + new UnnamedSchemaWithArrayParent4("Hello"), ] ), IsValueRequired = true, @@ -3933,9 +3933,9 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent13(true), - new UnnamedSchemaWithArrayParent13(10), - new UnnamedSchemaWithArrayParent13("Hello"), + new UnnamedSchemaWithArrayParent4(true), + new UnnamedSchemaWithArrayParent4(10), + new UnnamedSchemaWithArrayParent4("Hello"), ] ), IsValueRequired = true, @@ -4082,9 +4082,9 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent13(true), - new UnnamedSchemaWithArrayParent13(10), - new UnnamedSchemaWithArrayParent13("Hello"), + new UnnamedSchemaWithArrayParent4(true), + new UnnamedSchemaWithArrayParent4(10), + new UnnamedSchemaWithArrayParent4("Hello"), ] ), IsValueRequired = true, @@ -4240,9 +4240,9 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent13(true), - new UnnamedSchemaWithArrayParent13(10), - new UnnamedSchemaWithArrayParent13("Hello"), + new UnnamedSchemaWithArrayParent4(true), + new UnnamedSchemaWithArrayParent4(10), + new UnnamedSchemaWithArrayParent4("Hello"), ] ), IsValueRequired = true, @@ -4403,9 +4403,9 @@ public void CopyConstructor_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent13(true), - new UnnamedSchemaWithArrayParent13(10), - new UnnamedSchemaWithArrayParent13("Hello"), + new UnnamedSchemaWithArrayParent4(true), + new UnnamedSchemaWithArrayParent4(10), + new UnnamedSchemaWithArrayParent4("Hello"), ] ), IsValueRequired = true, @@ -5066,9 +5066,9 @@ public void FieldRoundtrip_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent13(true), - new UnnamedSchemaWithArrayParent13(10), - new UnnamedSchemaWithArrayParent13("Hello"), + new UnnamedSchemaWithArrayParent4(true), + new UnnamedSchemaWithArrayParent4(10), + new UnnamedSchemaWithArrayParent4("Hello"), ] ), IsValueRequired = true, @@ -5085,9 +5085,9 @@ public void FieldRoundtrip_Works() SelectedFieldsSchemaItemType.Text; DefaultValue expectedDefaultValue = new( [ - new UnnamedSchemaWithArrayParent13(true), - new UnnamedSchemaWithArrayParent13(10), - new UnnamedSchemaWithArrayParent13("Hello"), + new UnnamedSchemaWithArrayParent4(true), + new UnnamedSchemaWithArrayParent4(10), + new UnnamedSchemaWithArrayParent4("Hello"), ] ); bool expectedIsValueRequired = true; @@ -5124,9 +5124,9 @@ public void SerializationRoundtrip_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent13(true), - new UnnamedSchemaWithArrayParent13(10), - new UnnamedSchemaWithArrayParent13("Hello"), + new UnnamedSchemaWithArrayParent4(true), + new UnnamedSchemaWithArrayParent4(10), + new UnnamedSchemaWithArrayParent4("Hello"), ] ), IsValueRequired = true, @@ -5156,9 +5156,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent13(true), - new UnnamedSchemaWithArrayParent13(10), - new UnnamedSchemaWithArrayParent13("Hello"), + new UnnamedSchemaWithArrayParent4(true), + new UnnamedSchemaWithArrayParent4(10), + new UnnamedSchemaWithArrayParent4("Hello"), ] ), IsValueRequired = true, @@ -5182,9 +5182,9 @@ public void FieldRoundtripThroughSerialization_Works() SelectedFieldsSchemaItemType.Text; DefaultValue expectedDefaultValue = new( [ - new UnnamedSchemaWithArrayParent13(true), - new UnnamedSchemaWithArrayParent13(10), - new UnnamedSchemaWithArrayParent13("Hello"), + new UnnamedSchemaWithArrayParent4(true), + new UnnamedSchemaWithArrayParent4(10), + new UnnamedSchemaWithArrayParent4("Hello"), ] ); bool expectedIsValueRequired = true; @@ -5221,9 +5221,9 @@ public void Validation_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent13(true), - new UnnamedSchemaWithArrayParent13(10), - new UnnamedSchemaWithArrayParent13("Hello"), + new UnnamedSchemaWithArrayParent4(true), + new UnnamedSchemaWithArrayParent4(10), + new UnnamedSchemaWithArrayParent4("Hello"), ] ), IsValueRequired = true, @@ -5341,9 +5341,9 @@ public void CopyConstructor_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent13(true), - new UnnamedSchemaWithArrayParent13(10), - new UnnamedSchemaWithArrayParent13("Hello"), + new UnnamedSchemaWithArrayParent4(true), + new UnnamedSchemaWithArrayParent4(10), + new UnnamedSchemaWithArrayParent4("Hello"), ] ), IsValueRequired = true, @@ -5456,9 +5456,9 @@ public void MixedValidationWorks() { DefaultValue value = new( [ - new UnnamedSchemaWithArrayParent13(true), - new UnnamedSchemaWithArrayParent13(10), - new UnnamedSchemaWithArrayParent13("Hello"), + new UnnamedSchemaWithArrayParent4(true), + new UnnamedSchemaWithArrayParent4(10), + new UnnamedSchemaWithArrayParent4("Hello"), ] ); value.Validate(); @@ -5508,9 +5508,9 @@ public void MixedSerializationRoundtripWorks() { DefaultValue value = new( [ - new UnnamedSchemaWithArrayParent13(true), - new UnnamedSchemaWithArrayParent13(10), - new UnnamedSchemaWithArrayParent13("Hello"), + new UnnamedSchemaWithArrayParent4(true), + new UnnamedSchemaWithArrayParent4(10), + new UnnamedSchemaWithArrayParent4("Hello"), ] ); string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -5523,35 +5523,35 @@ public void MixedSerializationRoundtripWorks() } } -public class UnnamedSchemaWithArrayParent13Test : TestBase +public class UnnamedSchemaWithArrayParent4Test : TestBase { [Fact] public void StringValidationWorks() { - UnnamedSchemaWithArrayParent13 value = "string"; + UnnamedSchemaWithArrayParent4 value = "string"; value.Validate(); } [Fact] public void DoubleValidationWorks() { - UnnamedSchemaWithArrayParent13 value = 0; + UnnamedSchemaWithArrayParent4 value = 0; value.Validate(); } [Fact] public void BoolValidationWorks() { - UnnamedSchemaWithArrayParent13 value = true; + UnnamedSchemaWithArrayParent4 value = true; value.Validate(); } [Fact] public void StringSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent13 value = "string"; + UnnamedSchemaWithArrayParent4 value = "string"; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -5562,9 +5562,9 @@ public void StringSerializationRoundtripWorks() [Fact] public void DoubleSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent13 value = 0; + UnnamedSchemaWithArrayParent4 value = 0; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -5575,9 +5575,9 @@ public void DoubleSerializationRoundtripWorks() [Fact] public void BoolSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent13 value = true; + UnnamedSchemaWithArrayParent4 value = true; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); diff --git a/src/ImageKit.Tests/Services/CustomMetadataFieldServiceTest.cs b/src/ImageKit.Tests/Services/CustomMetadataFieldServiceTest.cs index 0d6b464b..36001a81 100644 --- a/src/ImageKit.Tests/Services/CustomMetadataFieldServiceTest.cs +++ b/src/ImageKit.Tests/Services/CustomMetadataFieldServiceTest.cs @@ -18,9 +18,9 @@ public async Task Create_Works() Type = Type.Number, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent1(true), - new UnnamedSchemaWithArrayParent1(10), - new UnnamedSchemaWithArrayParent1("Hello"), + new DefaultValueItem(true), + new DefaultValueItem(10), + new DefaultValueItem("Hello"), ] ), IsValueRequired = true, diff --git a/src/ImageKit/Models/Beta/V2/Files/FileUploadResponse.cs b/src/ImageKit/Models/Beta/V2/Files/FileUploadResponse.cs index 8d5da5b7..0148fcc0 100644 --- a/src/ImageKit/Models/Beta/V2/Files/FileUploadResponse.cs +++ b/src/ImageKit/Models/Beta/V2/Files/FileUploadResponse.cs @@ -1534,7 +1534,7 @@ public DefaultValue(bool value, JsonElement? element = null) } public DefaultValue( - IReadOnlyList value, + IReadOnlyList value, JsonElement? element = null ) { @@ -1612,24 +1612,24 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type where T is a UnnamedSchemaWithArrayParent12. + /// type where T is a UnnamedSchemaWithArrayParent3. /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickMixed(out var value)) { - /// // `value` is of type `IReadOnlyList<UnnamedSchemaWithArrayParent12>` + /// // `value` is of type `IReadOnlyList<UnnamedSchemaWithArrayParent3>` /// Console.WriteLine(value); /// } /// /// /// public bool TryPickMixed( - [NotNullWhen(true)] out IReadOnlyList? value + [NotNullWhen(true)] out IReadOnlyList? value ) { - value = this.Value as IReadOnlyList; + value = this.Value as IReadOnlyList; return value != null; } @@ -1650,7 +1650,7 @@ public bool TryPickMixed( /// (string value) => {...}, /// (double value) => {...}, /// (bool value) => {...}, - /// (IReadOnlyList<UnnamedSchemaWithArrayParent12> value) => {...} + /// (IReadOnlyList<UnnamedSchemaWithArrayParent3> value) => {...} /// ); /// /// @@ -1659,7 +1659,7 @@ public void Switch( System::Action @string, System::Action @double, System::Action @bool, - System::Action> mixed + System::Action> mixed ) { switch (this.Value) @@ -1673,7 +1673,7 @@ public void Switch( case bool value: @bool(value); break; - case IReadOnlyList value: + case IReadOnlyList value: mixed(value); break; default: @@ -1701,7 +1701,7 @@ public void Switch( /// (string value) => {...}, /// (double value) => {...}, /// (bool value) => {...}, - /// (IReadOnlyList<UnnamedSchemaWithArrayParent12> value) => {...} + /// (IReadOnlyList<UnnamedSchemaWithArrayParent3> value) => {...} /// ); /// /// @@ -1710,7 +1710,7 @@ public T Match( System::Func @string, System::Func @double, System::Func @bool, - System::Func, T> mixed + System::Func, T> mixed ) { return this.Value switch @@ -1718,7 +1718,7 @@ public T Match( string value => @string(value), double value => @double(value), bool value => @bool(value), - IReadOnlyList value => mixed(value), + IReadOnlyList value => mixed(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of DefaultValue" ), @@ -1731,8 +1731,8 @@ public T Match( public static implicit operator DefaultValue(bool value) => new(value); - public static implicit operator DefaultValue(List value) => - new((IReadOnlyList)value); + public static implicit operator DefaultValue(List value) => + new((IReadOnlyList)value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -1789,7 +1789,7 @@ int VariantIndex() string _ => 0, double _ => 1, bool _ => 2, - IReadOnlyList _ => 3, + IReadOnlyList _ => 3, _ => -1, }; } @@ -1837,7 +1837,7 @@ JsonSerializerOptions options try { - var deserialized = JsonSerializer.Deserialize>( + var deserialized = JsonSerializer.Deserialize>( element, options ); @@ -1868,8 +1868,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(UnnamedSchemaWithArrayParent12Converter))] -public record class UnnamedSchemaWithArrayParent12 : ModelBase +[JsonConverter(typeof(UnnamedSchemaWithArrayParent3Converter))] +public record class UnnamedSchemaWithArrayParent3 : ModelBase { public object? Value { get; } = null; @@ -1886,25 +1886,25 @@ public JsonElement Json } } - public UnnamedSchemaWithArrayParent12(string value, JsonElement? element = null) + public UnnamedSchemaWithArrayParent3(string value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent12(double value, JsonElement? element = null) + public UnnamedSchemaWithArrayParent3(double value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent12(bool value, JsonElement? element = null) + public UnnamedSchemaWithArrayParent3(bool value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent12(JsonElement element) + public UnnamedSchemaWithArrayParent3(JsonElement element) { this._element = element; } @@ -2012,7 +2012,7 @@ public void Switch( break; default: throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent12" + "Data did not match any variant of UnnamedSchemaWithArrayParent3" ); } } @@ -2051,16 +2051,16 @@ public T Match( double value => @double(value), bool value => @bool(value), _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent12" + "Data did not match any variant of UnnamedSchemaWithArrayParent3" ), }; } - public static implicit operator UnnamedSchemaWithArrayParent12(string value) => new(value); + public static implicit operator UnnamedSchemaWithArrayParent3(string value) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent12(double value) => new(value); + public static implicit operator UnnamedSchemaWithArrayParent3(double value) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent12(bool value) => new(value); + public static implicit operator UnnamedSchemaWithArrayParent3(bool value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -2077,12 +2077,12 @@ public override void Validate() if (this.Value == null) { throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent12" + "Data did not match any variant of UnnamedSchemaWithArrayParent3" ); } } - public virtual bool Equals(UnnamedSchemaWithArrayParent12? other) => + public virtual bool Equals(UnnamedSchemaWithArrayParent3? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -2110,9 +2110,9 @@ int VariantIndex() } } -sealed class UnnamedSchemaWithArrayParent12Converter : JsonConverter +sealed class UnnamedSchemaWithArrayParent3Converter : JsonConverter { - public override UnnamedSchemaWithArrayParent12? Read( + public override UnnamedSchemaWithArrayParent3? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -2155,7 +2155,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - UnnamedSchemaWithArrayParent12 value, + UnnamedSchemaWithArrayParent3 value, JsonSerializerOptions options ) { diff --git a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataField.cs b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataField.cs index a7f83517..367d9bb3 100644 --- a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataField.cs +++ b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataField.cs @@ -463,7 +463,7 @@ public CustomMetadataFieldSchemaDefaultValue(bool value, JsonElement? element = } public CustomMetadataFieldSchemaDefaultValue( - IReadOnlyList value, + IReadOnlyList value, JsonElement? element = null ) { @@ -541,24 +541,25 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type where T is a UnnamedSchemaWithArrayParent9. + /// type where T is a CustomMetadataFieldSchemaDefaultValueDefaultValueItem. /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickMixed(out var value)) { - /// // `value` is of type `IReadOnlyList<UnnamedSchemaWithArrayParent9>` + /// // `value` is of type `IReadOnlyList<CustomMetadataFieldSchemaDefaultValueDefaultValueItem>` /// Console.WriteLine(value); /// } /// /// /// public bool TryPickMixed( - [NotNullWhen(true)] out IReadOnlyList? value + [NotNullWhen(true)] + out IReadOnlyList? value ) { - value = this.Value as IReadOnlyList; + value = this.Value as IReadOnlyList; return value != null; } @@ -579,7 +580,7 @@ public bool TryPickMixed( /// (string value) => {...}, /// (double value) => {...}, /// (bool value) => {...}, - /// (IReadOnlyList<UnnamedSchemaWithArrayParent9> value) => {...} + /// (IReadOnlyList<CustomMetadataFieldSchemaDefaultValueDefaultValueItem> value) => {...} /// ); /// /// @@ -588,7 +589,7 @@ public void Switch( System::Action @string, System::Action @double, System::Action @bool, - System::Action> mixed + System::Action> mixed ) { switch (this.Value) @@ -602,7 +603,7 @@ public void Switch( case bool value: @bool(value); break; - case IReadOnlyList value: + case IReadOnlyList value: mixed(value); break; default: @@ -630,7 +631,7 @@ public void Switch( /// (string value) => {...}, /// (double value) => {...}, /// (bool value) => {...}, - /// (IReadOnlyList<UnnamedSchemaWithArrayParent9> value) => {...} + /// (IReadOnlyList<CustomMetadataFieldSchemaDefaultValueDefaultValueItem> value) => {...} /// ); /// /// @@ -639,7 +640,7 @@ public T Match( System::Func @string, System::Func @double, System::Func @bool, - System::Func, T> mixed + System::Func, T> mixed ) { return this.Value switch @@ -647,7 +648,9 @@ public T Match( string value => @string(value), double value => @double(value), bool value => @bool(value), - IReadOnlyList value => mixed(value), + IReadOnlyList value => mixed( + value + ), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of CustomMetadataFieldSchemaDefaultValue" ), @@ -663,8 +666,8 @@ public static implicit operator CustomMetadataFieldSchemaDefaultValue(double val public static implicit operator CustomMetadataFieldSchemaDefaultValue(bool value) => new(value); public static implicit operator CustomMetadataFieldSchemaDefaultValue( - List value - ) => new((IReadOnlyList)value); + List value + ) => new((IReadOnlyList)value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -721,7 +724,7 @@ int VariantIndex() string _ => 0, double _ => 1, bool _ => 2, - IReadOnlyList _ => 3, + IReadOnlyList _ => 3, _ => -1, }; } @@ -770,10 +773,9 @@ JsonSerializerOptions options try { - var deserialized = JsonSerializer.Deserialize>( - element, - options - ); + var deserialized = JsonSerializer.Deserialize< + List + >(element, options); if (deserialized != null) { foreach (var item in deserialized) @@ -801,8 +803,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(UnnamedSchemaWithArrayParent9Converter))] -public record class UnnamedSchemaWithArrayParent9 : ModelBase +[JsonConverter(typeof(CustomMetadataFieldSchemaDefaultValueDefaultValueItemConverter))] +public record class CustomMetadataFieldSchemaDefaultValueDefaultValueItem : ModelBase { public object? Value { get; } = null; @@ -819,25 +821,34 @@ public JsonElement Json } } - public UnnamedSchemaWithArrayParent9(string value, JsonElement? element = null) + public CustomMetadataFieldSchemaDefaultValueDefaultValueItem( + string value, + JsonElement? element = null + ) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent9(double value, JsonElement? element = null) + public CustomMetadataFieldSchemaDefaultValueDefaultValueItem( + double value, + JsonElement? element = null + ) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent9(bool value, JsonElement? element = null) + public CustomMetadataFieldSchemaDefaultValueDefaultValueItem( + bool value, + JsonElement? element = null + ) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent9(JsonElement element) + public CustomMetadataFieldSchemaDefaultValueDefaultValueItem(JsonElement element) { this._element = element; } @@ -945,7 +956,7 @@ public void Switch( break; default: throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent9" + "Data did not match any variant of CustomMetadataFieldSchemaDefaultValueDefaultValueItem" ); } } @@ -984,16 +995,22 @@ public T Match( double value => @double(value), bool value => @bool(value), _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent9" + "Data did not match any variant of CustomMetadataFieldSchemaDefaultValueDefaultValueItem" ), }; } - public static implicit operator UnnamedSchemaWithArrayParent9(string value) => new(value); + public static implicit operator CustomMetadataFieldSchemaDefaultValueDefaultValueItem( + string value + ) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent9(double value) => new(value); + public static implicit operator CustomMetadataFieldSchemaDefaultValueDefaultValueItem( + double value + ) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent9(bool value) => new(value); + public static implicit operator CustomMetadataFieldSchemaDefaultValueDefaultValueItem( + bool value + ) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -1010,12 +1027,12 @@ public override void Validate() if (this.Value == null) { throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent9" + "Data did not match any variant of CustomMetadataFieldSchemaDefaultValueDefaultValueItem" ); } } - public virtual bool Equals(UnnamedSchemaWithArrayParent9? other) => + public virtual bool Equals(CustomMetadataFieldSchemaDefaultValueDefaultValueItem? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -1043,9 +1060,10 @@ int VariantIndex() } } -sealed class UnnamedSchemaWithArrayParent9Converter : JsonConverter +sealed class CustomMetadataFieldSchemaDefaultValueDefaultValueItemConverter + : JsonConverter { - public override UnnamedSchemaWithArrayParent9? Read( + public override CustomMetadataFieldSchemaDefaultValueDefaultValueItem? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -1088,7 +1106,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - UnnamedSchemaWithArrayParent9 value, + CustomMetadataFieldSchemaDefaultValueDefaultValueItem value, JsonSerializerOptions options ) { diff --git a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldCreateParams.cs b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldCreateParams.cs index 0be80059..328b55bb 100644 --- a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldCreateParams.cs +++ b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldCreateParams.cs @@ -523,10 +523,7 @@ public DefaultValue(bool value, JsonElement? element = null) this._element = element; } - public DefaultValue( - IReadOnlyList value, - JsonElement? element = null - ) + public DefaultValue(IReadOnlyList value, JsonElement? element = null) { this.Value = ImmutableArray.ToImmutableArray(value); this._element = element; @@ -602,24 +599,22 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type where T is a UnnamedSchemaWithArrayParent1. + /// type where T is a DefaultValueItem. /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickMixed(out var value)) { - /// // `value` is of type `IReadOnlyList<UnnamedSchemaWithArrayParent1>` + /// // `value` is of type `IReadOnlyList<DefaultValueItem>` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickMixed( - [NotNullWhen(true)] out IReadOnlyList? value - ) + public bool TryPickMixed([NotNullWhen(true)] out IReadOnlyList? value) { - value = this.Value as IReadOnlyList; + value = this.Value as IReadOnlyList; return value != null; } @@ -640,7 +635,7 @@ public bool TryPickMixed( /// (string value) => {...}, /// (double value) => {...}, /// (bool value) => {...}, - /// (IReadOnlyList<UnnamedSchemaWithArrayParent1> value) => {...} + /// (IReadOnlyList<DefaultValueItem> value) => {...} /// ); /// /// @@ -649,7 +644,7 @@ public void Switch( System::Action @string, System::Action @double, System::Action @bool, - System::Action> mixed + System::Action> mixed ) { switch (this.Value) @@ -663,7 +658,7 @@ public void Switch( case bool value: @bool(value); break; - case IReadOnlyList value: + case IReadOnlyList value: mixed(value); break; default: @@ -691,7 +686,7 @@ public void Switch( /// (string value) => {...}, /// (double value) => {...}, /// (bool value) => {...}, - /// (IReadOnlyList<UnnamedSchemaWithArrayParent1> value) => {...} + /// (IReadOnlyList<DefaultValueItem> value) => {...} /// ); /// /// @@ -700,7 +695,7 @@ public T Match( System::Func @string, System::Func @double, System::Func @bool, - System::Func, T> mixed + System::Func, T> mixed ) { return this.Value switch @@ -708,7 +703,7 @@ public T Match( string value => @string(value), double value => @double(value), bool value => @bool(value), - IReadOnlyList value => mixed(value), + IReadOnlyList value => mixed(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of DefaultValue" ), @@ -721,8 +716,8 @@ public T Match( public static implicit operator DefaultValue(bool value) => new(value); - public static implicit operator DefaultValue(List value) => - new((IReadOnlyList)value); + public static implicit operator DefaultValue(List value) => + new((IReadOnlyList)value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -779,7 +774,7 @@ int VariantIndex() string _ => 0, double _ => 1, bool _ => 2, - IReadOnlyList _ => 3, + IReadOnlyList _ => 3, _ => -1, }; } @@ -827,10 +822,7 @@ JsonSerializerOptions options try { - var deserialized = JsonSerializer.Deserialize>( - element, - options - ); + var deserialized = JsonSerializer.Deserialize>(element, options); if (deserialized != null) { foreach (var item in deserialized) @@ -858,8 +850,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(UnnamedSchemaWithArrayParent1Converter))] -public record class UnnamedSchemaWithArrayParent1 : ModelBase +[JsonConverter(typeof(DefaultValueItemConverter))] +public record class DefaultValueItem : ModelBase { public object? Value { get; } = null; @@ -876,25 +868,25 @@ public JsonElement Json } } - public UnnamedSchemaWithArrayParent1(string value, JsonElement? element = null) + public DefaultValueItem(string value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent1(double value, JsonElement? element = null) + public DefaultValueItem(double value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent1(bool value, JsonElement? element = null) + public DefaultValueItem(bool value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent1(JsonElement element) + public DefaultValueItem(JsonElement element) { this._element = element; } @@ -1002,7 +994,7 @@ public void Switch( break; default: throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent1" + "Data did not match any variant of DefaultValueItem" ); } } @@ -1041,16 +1033,16 @@ public T Match( double value => @double(value), bool value => @bool(value), _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent1" + "Data did not match any variant of DefaultValueItem" ), }; } - public static implicit operator UnnamedSchemaWithArrayParent1(string value) => new(value); + public static implicit operator DefaultValueItem(string value) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent1(double value) => new(value); + public static implicit operator DefaultValueItem(double value) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent1(bool value) => new(value); + public static implicit operator DefaultValueItem(bool value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -1067,12 +1059,12 @@ public override void Validate() if (this.Value == null) { throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent1" + "Data did not match any variant of DefaultValueItem" ); } } - public virtual bool Equals(UnnamedSchemaWithArrayParent1? other) => + public virtual bool Equals(DefaultValueItem? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -1100,9 +1092,9 @@ int VariantIndex() } } -sealed class UnnamedSchemaWithArrayParent1Converter : JsonConverter +sealed class DefaultValueItemConverter : JsonConverter { - public override UnnamedSchemaWithArrayParent1? Read( + public override DefaultValueItem? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -1145,7 +1137,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - UnnamedSchemaWithArrayParent1 value, + DefaultValueItem value, JsonSerializerOptions options ) { diff --git a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParams.cs b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParams.cs index a1def4cf..3dad5378 100644 --- a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParams.cs +++ b/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParams.cs @@ -492,7 +492,7 @@ public CustomMetadataFieldUpdateParamsSchemaDefaultValue( } public CustomMetadataFieldUpdateParamsSchemaDefaultValue( - IReadOnlyList value, + IReadOnlyList value, JsonElement? element = null ) { @@ -570,24 +570,27 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type where T is a UnnamedSchemaWithArrayParent2. + /// type where T is a CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem. /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickMixed(out var value)) { - /// // `value` is of type `IReadOnlyList<UnnamedSchemaWithArrayParent2>` + /// // `value` is of type `IReadOnlyList<CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem>` /// Console.WriteLine(value); /// } /// /// /// public bool TryPickMixed( - [NotNullWhen(true)] out IReadOnlyList? value + [NotNullWhen(true)] + out IReadOnlyList? value ) { - value = this.Value as IReadOnlyList; + value = + this.Value + as IReadOnlyList; return value != null; } @@ -608,7 +611,7 @@ public bool TryPickMixed( /// (string value) => {...}, /// (double value) => {...}, /// (bool value) => {...}, - /// (IReadOnlyList<UnnamedSchemaWithArrayParent2> value) => {...} + /// (IReadOnlyList<CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem> value) => {...} /// ); /// /// @@ -617,7 +620,9 @@ public void Switch( System::Action @string, System::Action @double, System::Action @bool, - System::Action> mixed + System::Action< + IReadOnlyList + > mixed ) { switch (this.Value) @@ -631,7 +636,7 @@ public void Switch( case bool value: @bool(value); break; - case IReadOnlyList value: + case IReadOnlyList value: mixed(value); break; default: @@ -659,7 +664,7 @@ public void Switch( /// (string value) => {...}, /// (double value) => {...}, /// (bool value) => {...}, - /// (IReadOnlyList<UnnamedSchemaWithArrayParent2> value) => {...} + /// (IReadOnlyList<CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem> value) => {...} /// ); /// /// @@ -668,7 +673,10 @@ public T Match( System::Func @string, System::Func @double, System::Func @bool, - System::Func, T> mixed + System::Func< + IReadOnlyList, + T + > mixed ) { return this.Value switch @@ -676,7 +684,8 @@ public T Match( string value => @string(value), double value => @double(value), bool value => @bool(value), - IReadOnlyList value => mixed(value), + IReadOnlyList value => + mixed(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of CustomMetadataFieldUpdateParamsSchemaDefaultValue" ), @@ -695,8 +704,11 @@ public static implicit operator CustomMetadataFieldUpdateParamsSchemaDefaultValu new(value); public static implicit operator CustomMetadataFieldUpdateParamsSchemaDefaultValue( - List value - ) => new((IReadOnlyList)value); + List value + ) => + new( + (IReadOnlyList)value + ); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -753,7 +765,7 @@ int VariantIndex() string _ => 0, double _ => 1, bool _ => 2, - IReadOnlyList _ => 3, + IReadOnlyList _ => 3, _ => -1, }; } @@ -802,10 +814,9 @@ JsonSerializerOptions options try { - var deserialized = JsonSerializer.Deserialize>( - element, - options - ); + var deserialized = JsonSerializer.Deserialize< + List + >(element, options); if (deserialized != null) { foreach (var item in deserialized) @@ -833,8 +844,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(UnnamedSchemaWithArrayParent2Converter))] -public record class UnnamedSchemaWithArrayParent2 : ModelBase +[JsonConverter(typeof(CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItemConverter))] +public record class CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem : ModelBase { public object? Value { get; } = null; @@ -851,25 +862,34 @@ public JsonElement Json } } - public UnnamedSchemaWithArrayParent2(string value, JsonElement? element = null) + public CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem( + string value, + JsonElement? element = null + ) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent2(double value, JsonElement? element = null) + public CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem( + double value, + JsonElement? element = null + ) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent2(bool value, JsonElement? element = null) + public CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem( + bool value, + JsonElement? element = null + ) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent2(JsonElement element) + public CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem(JsonElement element) { this._element = element; } @@ -977,7 +997,7 @@ public void Switch( break; default: throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent2" + "Data did not match any variant of CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem" ); } } @@ -1016,16 +1036,22 @@ public T Match( double value => @double(value), bool value => @bool(value), _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent2" + "Data did not match any variant of CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem" ), }; } - public static implicit operator UnnamedSchemaWithArrayParent2(string value) => new(value); + public static implicit operator CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem( + string value + ) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent2(double value) => new(value); + public static implicit operator CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem( + double value + ) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent2(bool value) => new(value); + public static implicit operator CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem( + bool value + ) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -1042,12 +1068,14 @@ public override void Validate() if (this.Value == null) { throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent2" + "Data did not match any variant of CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem" ); } } - public virtual bool Equals(UnnamedSchemaWithArrayParent2? other) => + public virtual bool Equals( + CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem? other + ) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -1075,9 +1103,10 @@ int VariantIndex() } } -sealed class UnnamedSchemaWithArrayParent2Converter : JsonConverter +sealed class CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItemConverter + : JsonConverter { - public override UnnamedSchemaWithArrayParent2? Read( + public override CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -1120,7 +1149,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - UnnamedSchemaWithArrayParent2 value, + CustomMetadataFieldUpdateParamsSchemaDefaultValueDefaultValueItem value, JsonSerializerOptions options ) { diff --git a/src/ImageKit/Models/ExtensionConfig.cs b/src/ImageKit/Models/ExtensionConfig.cs index 88cd9fe8..1200fbea 100644 --- a/src/ImageKit/Models/ExtensionConfig.cs +++ b/src/ImageKit/Models/ExtensionConfig.cs @@ -2332,10 +2332,7 @@ public SetMetadataValue(bool value, JsonElement? element = null) this._element = element; } - public SetMetadataValue( - IReadOnlyList value, - JsonElement? element = null - ) + public SetMetadataValue(IReadOnlyList value, JsonElement? element = null) { this.Value = ImmutableArray.ToImmutableArray(value); this._element = element; @@ -2411,24 +2408,22 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type where T is a UnnamedSchemaWithArrayParent3. + /// type where T is a MetadataValueItem. /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickMixed(out var value)) { - /// // `value` is of type `IReadOnlyList<UnnamedSchemaWithArrayParent3>` + /// // `value` is of type `IReadOnlyList<MetadataValueItem>` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickMixed( - [NotNullWhen(true)] out IReadOnlyList? value - ) + public bool TryPickMixed([NotNullWhen(true)] out IReadOnlyList? value) { - value = this.Value as IReadOnlyList; + value = this.Value as IReadOnlyList; return value != null; } @@ -2449,7 +2444,7 @@ public bool TryPickMixed( /// (string value) => {...}, /// (double value) => {...}, /// (bool value) => {...}, - /// (IReadOnlyList<UnnamedSchemaWithArrayParent3> value) => {...} + /// (IReadOnlyList<MetadataValueItem> value) => {...} /// ); /// /// @@ -2458,7 +2453,7 @@ public void Switch( Action @string, Action @double, Action @bool, - Action> mixed + Action> mixed ) { switch (this.Value) @@ -2472,7 +2467,7 @@ Action> mixed case bool value: @bool(value); break; - case IReadOnlyList value: + case IReadOnlyList value: mixed(value); break; default: @@ -2500,7 +2495,7 @@ Action> mixed /// (string value) => {...}, /// (double value) => {...}, /// (bool value) => {...}, - /// (IReadOnlyList<UnnamedSchemaWithArrayParent3> value) => {...} + /// (IReadOnlyList<MetadataValueItem> value) => {...} /// ); /// /// @@ -2509,7 +2504,7 @@ public T Match( Func @string, Func @double, Func @bool, - Func, T> mixed + Func, T> mixed ) { return this.Value switch @@ -2517,7 +2512,7 @@ Func, T> mixed string value => @string(value), double value => @double(value), bool value => @bool(value), - IReadOnlyList value => mixed(value), + IReadOnlyList value => mixed(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of SetMetadataValue" ), @@ -2530,8 +2525,8 @@ Func, T> mixed public static implicit operator SetMetadataValue(bool value) => new(value); - public static implicit operator SetMetadataValue(List value) => - new((IReadOnlyList)value); + public static implicit operator SetMetadataValue(List value) => + new((IReadOnlyList)value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -2588,7 +2583,7 @@ int VariantIndex() string _ => 0, double _ => 1, bool _ => 2, - IReadOnlyList _ => 3, + IReadOnlyList _ => 3, _ => -1, }; } @@ -2636,7 +2631,7 @@ JsonSerializerOptions options try { - var deserialized = JsonSerializer.Deserialize>( + var deserialized = JsonSerializer.Deserialize>( element, options ); @@ -2667,8 +2662,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(UnnamedSchemaWithArrayParent3Converter))] -public record class UnnamedSchemaWithArrayParent3 : ModelBase +[JsonConverter(typeof(MetadataValueItemConverter))] +public record class MetadataValueItem : ModelBase { public object? Value { get; } = null; @@ -2685,25 +2680,25 @@ public JsonElement Json } } - public UnnamedSchemaWithArrayParent3(string value, JsonElement? element = null) + public MetadataValueItem(string value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent3(double value, JsonElement? element = null) + public MetadataValueItem(double value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent3(bool value, JsonElement? element = null) + public MetadataValueItem(bool value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent3(JsonElement element) + public MetadataValueItem(JsonElement element) { this._element = element; } @@ -2807,7 +2802,7 @@ public void Switch(Action @string, Action @double, Action break; default: throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent3" + "Data did not match any variant of MetadataValueItem" ); } } @@ -2842,16 +2837,16 @@ public T Match(Func @string, Func @double, Func @double(value), bool value => @bool(value), _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent3" + "Data did not match any variant of MetadataValueItem" ), }; } - public static implicit operator UnnamedSchemaWithArrayParent3(string value) => new(value); + public static implicit operator MetadataValueItem(string value) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent3(double value) => new(value); + public static implicit operator MetadataValueItem(double value) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent3(bool value) => new(value); + public static implicit operator MetadataValueItem(bool value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -2868,12 +2863,12 @@ public override void Validate() if (this.Value == null) { throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent3" + "Data did not match any variant of MetadataValueItem" ); } } - public virtual bool Equals(UnnamedSchemaWithArrayParent3? other) => + public virtual bool Equals(MetadataValueItem? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -2901,9 +2896,9 @@ int VariantIndex() } } -sealed class UnnamedSchemaWithArrayParent3Converter : JsonConverter +sealed class MetadataValueItemConverter : JsonConverter { - public override UnnamedSchemaWithArrayParent3? Read( + public override MetadataValueItem? Read( ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options @@ -2946,7 +2941,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - UnnamedSchemaWithArrayParent3 value, + MetadataValueItem value, JsonSerializerOptions options ) { @@ -3290,7 +3285,7 @@ public OnUnknownSetMetadataValue(bool value, JsonElement? element = null) } public OnUnknownSetMetadataValue( - IReadOnlyList value, + IReadOnlyList value, JsonElement? element = null ) { @@ -3368,24 +3363,24 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type where T is a UnnamedSchemaWithArrayParent4. + /// type where T is a OnUnknownSetMetadataValueMetadataValueItem. /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickMixed(out var value)) { - /// // `value` is of type `IReadOnlyList<UnnamedSchemaWithArrayParent4>` + /// // `value` is of type `IReadOnlyList<OnUnknownSetMetadataValueMetadataValueItem>` /// Console.WriteLine(value); /// } /// /// /// public bool TryPickMixed( - [NotNullWhen(true)] out IReadOnlyList? value + [NotNullWhen(true)] out IReadOnlyList? value ) { - value = this.Value as IReadOnlyList; + value = this.Value as IReadOnlyList; return value != null; } @@ -3406,7 +3401,7 @@ public bool TryPickMixed( /// (string value) => {...}, /// (double value) => {...}, /// (bool value) => {...}, - /// (IReadOnlyList<UnnamedSchemaWithArrayParent4> value) => {...} + /// (IReadOnlyList<OnUnknownSetMetadataValueMetadataValueItem> value) => {...} /// ); /// /// @@ -3415,7 +3410,7 @@ public void Switch( Action @string, Action @double, Action @bool, - Action> mixed + Action> mixed ) { switch (this.Value) @@ -3429,7 +3424,7 @@ Action> mixed case bool value: @bool(value); break; - case IReadOnlyList value: + case IReadOnlyList value: mixed(value); break; default: @@ -3457,7 +3452,7 @@ Action> mixed /// (string value) => {...}, /// (double value) => {...}, /// (bool value) => {...}, - /// (IReadOnlyList<UnnamedSchemaWithArrayParent4> value) => {...} + /// (IReadOnlyList<OnUnknownSetMetadataValueMetadataValueItem> value) => {...} /// ); /// /// @@ -3466,7 +3461,7 @@ public T Match( Func @string, Func @double, Func @bool, - Func, T> mixed + Func, T> mixed ) { return this.Value switch @@ -3474,7 +3469,7 @@ Func, T> mixed string value => @string(value), double value => @double(value), bool value => @bool(value), - IReadOnlyList value => mixed(value), + IReadOnlyList value => mixed(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of OnUnknownSetMetadataValue" ), @@ -3488,8 +3483,8 @@ Func, T> mixed public static implicit operator OnUnknownSetMetadataValue(bool value) => new(value); public static implicit operator OnUnknownSetMetadataValue( - List value - ) => new((IReadOnlyList)value); + List value + ) => new((IReadOnlyList)value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -3546,7 +3541,7 @@ int VariantIndex() string _ => 0, double _ => 1, bool _ => 2, - IReadOnlyList _ => 3, + IReadOnlyList _ => 3, _ => -1, }; } @@ -3594,10 +3589,9 @@ JsonSerializerOptions options try { - var deserialized = JsonSerializer.Deserialize>( - element, - options - ); + var deserialized = JsonSerializer.Deserialize< + List + >(element, options); if (deserialized != null) { foreach (var item in deserialized) @@ -3625,8 +3619,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(UnnamedSchemaWithArrayParent4Converter))] -public record class UnnamedSchemaWithArrayParent4 : ModelBase +[JsonConverter(typeof(OnUnknownSetMetadataValueMetadataValueItemConverter))] +public record class OnUnknownSetMetadataValueMetadataValueItem : ModelBase { public object? Value { get; } = null; @@ -3643,25 +3637,25 @@ public JsonElement Json } } - public UnnamedSchemaWithArrayParent4(string value, JsonElement? element = null) + public OnUnknownSetMetadataValueMetadataValueItem(string value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent4(double value, JsonElement? element = null) + public OnUnknownSetMetadataValueMetadataValueItem(double value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent4(bool value, JsonElement? element = null) + public OnUnknownSetMetadataValueMetadataValueItem(bool value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent4(JsonElement element) + public OnUnknownSetMetadataValueMetadataValueItem(JsonElement element) { this._element = element; } @@ -3765,7 +3759,7 @@ public void Switch(Action @string, Action @double, Action break; default: throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent4" + "Data did not match any variant of OnUnknownSetMetadataValueMetadataValueItem" ); } } @@ -3800,16 +3794,19 @@ public T Match(Func @string, Func @double, Func @double(value), bool value => @bool(value), _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent4" + "Data did not match any variant of OnUnknownSetMetadataValueMetadataValueItem" ), }; } - public static implicit operator UnnamedSchemaWithArrayParent4(string value) => new(value); + public static implicit operator OnUnknownSetMetadataValueMetadataValueItem(string value) => + new(value); - public static implicit operator UnnamedSchemaWithArrayParent4(double value) => new(value); + public static implicit operator OnUnknownSetMetadataValueMetadataValueItem(double value) => + new(value); - public static implicit operator UnnamedSchemaWithArrayParent4(bool value) => new(value); + public static implicit operator OnUnknownSetMetadataValueMetadataValueItem(bool value) => + new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -3826,12 +3823,12 @@ public override void Validate() if (this.Value == null) { throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent4" + "Data did not match any variant of OnUnknownSetMetadataValueMetadataValueItem" ); } } - public virtual bool Equals(UnnamedSchemaWithArrayParent4? other) => + public virtual bool Equals(OnUnknownSetMetadataValueMetadataValueItem? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -3859,9 +3856,10 @@ int VariantIndex() } } -sealed class UnnamedSchemaWithArrayParent4Converter : JsonConverter +sealed class OnUnknownSetMetadataValueMetadataValueItemConverter + : JsonConverter { - public override UnnamedSchemaWithArrayParent4? Read( + public override OnUnknownSetMetadataValueMetadataValueItem? Read( ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options @@ -3904,7 +3902,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - UnnamedSchemaWithArrayParent4 value, + OnUnknownSetMetadataValueMetadataValueItem value, JsonSerializerOptions options ) { @@ -4250,7 +4248,7 @@ public OnYesSetMetadataValue(bool value, JsonElement? element = null) } public OnYesSetMetadataValue( - IReadOnlyList value, + IReadOnlyList value, JsonElement? element = null ) { @@ -4328,24 +4326,24 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type where T is a UnnamedSchemaWithArrayParent5. + /// type where T is a OnYesSetMetadataValueMetadataValueItem. /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickMixed(out var value)) { - /// // `value` is of type `IReadOnlyList<UnnamedSchemaWithArrayParent5>` + /// // `value` is of type `IReadOnlyList<OnYesSetMetadataValueMetadataValueItem>` /// Console.WriteLine(value); /// } /// /// /// public bool TryPickMixed( - [NotNullWhen(true)] out IReadOnlyList? value + [NotNullWhen(true)] out IReadOnlyList? value ) { - value = this.Value as IReadOnlyList; + value = this.Value as IReadOnlyList; return value != null; } @@ -4366,7 +4364,7 @@ public bool TryPickMixed( /// (string value) => {...}, /// (double value) => {...}, /// (bool value) => {...}, - /// (IReadOnlyList<UnnamedSchemaWithArrayParent5> value) => {...} + /// (IReadOnlyList<OnYesSetMetadataValueMetadataValueItem> value) => {...} /// ); /// /// @@ -4375,7 +4373,7 @@ public void Switch( Action @string, Action @double, Action @bool, - Action> mixed + Action> mixed ) { switch (this.Value) @@ -4389,7 +4387,7 @@ Action> mixed case bool value: @bool(value); break; - case IReadOnlyList value: + case IReadOnlyList value: mixed(value); break; default: @@ -4417,7 +4415,7 @@ Action> mixed /// (string value) => {...}, /// (double value) => {...}, /// (bool value) => {...}, - /// (IReadOnlyList<UnnamedSchemaWithArrayParent5> value) => {...} + /// (IReadOnlyList<OnYesSetMetadataValueMetadataValueItem> value) => {...} /// ); /// /// @@ -4426,7 +4424,7 @@ public T Match( Func @string, Func @double, Func @bool, - Func, T> mixed + Func, T> mixed ) { return this.Value switch @@ -4434,7 +4432,7 @@ Func, T> mixed string value => @string(value), double value => @double(value), bool value => @bool(value), - IReadOnlyList value => mixed(value), + IReadOnlyList value => mixed(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of OnYesSetMetadataValue" ), @@ -4448,8 +4446,8 @@ Func, T> mixed public static implicit operator OnYesSetMetadataValue(bool value) => new(value); public static implicit operator OnYesSetMetadataValue( - List value - ) => new((IReadOnlyList)value); + List value + ) => new((IReadOnlyList)value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -4506,7 +4504,7 @@ int VariantIndex() string _ => 0, double _ => 1, bool _ => 2, - IReadOnlyList _ => 3, + IReadOnlyList _ => 3, _ => -1, }; } @@ -4554,10 +4552,9 @@ JsonSerializerOptions options try { - var deserialized = JsonSerializer.Deserialize>( - element, - options - ); + var deserialized = JsonSerializer.Deserialize< + List + >(element, options); if (deserialized != null) { foreach (var item in deserialized) @@ -4585,8 +4582,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(UnnamedSchemaWithArrayParent5Converter))] -public record class UnnamedSchemaWithArrayParent5 : ModelBase +[JsonConverter(typeof(OnYesSetMetadataValueMetadataValueItemConverter))] +public record class OnYesSetMetadataValueMetadataValueItem : ModelBase { public object? Value { get; } = null; @@ -4603,25 +4600,25 @@ public JsonElement Json } } - public UnnamedSchemaWithArrayParent5(string value, JsonElement? element = null) + public OnYesSetMetadataValueMetadataValueItem(string value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent5(double value, JsonElement? element = null) + public OnYesSetMetadataValueMetadataValueItem(double value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent5(bool value, JsonElement? element = null) + public OnYesSetMetadataValueMetadataValueItem(bool value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent5(JsonElement element) + public OnYesSetMetadataValueMetadataValueItem(JsonElement element) { this._element = element; } @@ -4725,7 +4722,7 @@ public void Switch(Action @string, Action @double, Action break; default: throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent5" + "Data did not match any variant of OnYesSetMetadataValueMetadataValueItem" ); } } @@ -4760,16 +4757,19 @@ public T Match(Func @string, Func @double, Func @double(value), bool value => @bool(value), _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent5" + "Data did not match any variant of OnYesSetMetadataValueMetadataValueItem" ), }; } - public static implicit operator UnnamedSchemaWithArrayParent5(string value) => new(value); + public static implicit operator OnYesSetMetadataValueMetadataValueItem(string value) => + new(value); - public static implicit operator UnnamedSchemaWithArrayParent5(double value) => new(value); + public static implicit operator OnYesSetMetadataValueMetadataValueItem(double value) => + new(value); - public static implicit operator UnnamedSchemaWithArrayParent5(bool value) => new(value); + public static implicit operator OnYesSetMetadataValueMetadataValueItem(bool value) => + new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -4786,12 +4786,12 @@ public override void Validate() if (this.Value == null) { throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent5" + "Data did not match any variant of OnYesSetMetadataValueMetadataValueItem" ); } } - public virtual bool Equals(UnnamedSchemaWithArrayParent5? other) => + public virtual bool Equals(OnYesSetMetadataValueMetadataValueItem? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -4819,9 +4819,10 @@ int VariantIndex() } } -sealed class UnnamedSchemaWithArrayParent5Converter : JsonConverter +sealed class OnYesSetMetadataValueMetadataValueItemConverter + : JsonConverter { - public override UnnamedSchemaWithArrayParent5? Read( + public override OnYesSetMetadataValueMetadataValueItem? Read( ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options @@ -4864,7 +4865,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - UnnamedSchemaWithArrayParent5 value, + OnYesSetMetadataValueMetadataValueItem value, JsonSerializerOptions options ) { diff --git a/src/ImageKit/Models/Files/File.cs b/src/ImageKit/Models/Files/File.cs index 991280e9..a940e867 100644 --- a/src/ImageKit/Models/Files/File.cs +++ b/src/ImageKit/Models/Files/File.cs @@ -1199,7 +1199,7 @@ public DefaultValue(bool value, JsonElement? element = null) } public DefaultValue( - IReadOnlyList value, + IReadOnlyList value, JsonElement? element = null ) { @@ -1277,24 +1277,24 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type where T is a UnnamedSchemaWithArrayParent10. + /// type where T is a UnnamedSchemaWithArrayParent1. /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickMixed(out var value)) { - /// // `value` is of type `IReadOnlyList<UnnamedSchemaWithArrayParent10>` + /// // `value` is of type `IReadOnlyList<UnnamedSchemaWithArrayParent1>` /// Console.WriteLine(value); /// } /// /// /// public bool TryPickMixed( - [NotNullWhen(true)] out IReadOnlyList? value + [NotNullWhen(true)] out IReadOnlyList? value ) { - value = this.Value as IReadOnlyList; + value = this.Value as IReadOnlyList; return value != null; } @@ -1315,7 +1315,7 @@ public bool TryPickMixed( /// (string value) => {...}, /// (double value) => {...}, /// (bool value) => {...}, - /// (IReadOnlyList<UnnamedSchemaWithArrayParent10> value) => {...} + /// (IReadOnlyList<UnnamedSchemaWithArrayParent1> value) => {...} /// ); /// /// @@ -1324,7 +1324,7 @@ public void Switch( System::Action @string, System::Action @double, System::Action @bool, - System::Action> mixed + System::Action> mixed ) { switch (this.Value) @@ -1338,7 +1338,7 @@ public void Switch( case bool value: @bool(value); break; - case IReadOnlyList value: + case IReadOnlyList value: mixed(value); break; default: @@ -1366,7 +1366,7 @@ public void Switch( /// (string value) => {...}, /// (double value) => {...}, /// (bool value) => {...}, - /// (IReadOnlyList<UnnamedSchemaWithArrayParent10> value) => {...} + /// (IReadOnlyList<UnnamedSchemaWithArrayParent1> value) => {...} /// ); /// /// @@ -1375,7 +1375,7 @@ public T Match( System::Func @string, System::Func @double, System::Func @bool, - System::Func, T> mixed + System::Func, T> mixed ) { return this.Value switch @@ -1383,7 +1383,7 @@ public T Match( string value => @string(value), double value => @double(value), bool value => @bool(value), - IReadOnlyList value => mixed(value), + IReadOnlyList value => mixed(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of DefaultValue" ), @@ -1396,8 +1396,8 @@ public T Match( public static implicit operator DefaultValue(bool value) => new(value); - public static implicit operator DefaultValue(List value) => - new((IReadOnlyList)value); + public static implicit operator DefaultValue(List value) => + new((IReadOnlyList)value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -1454,7 +1454,7 @@ int VariantIndex() string _ => 0, double _ => 1, bool _ => 2, - IReadOnlyList _ => 3, + IReadOnlyList _ => 3, _ => -1, }; } @@ -1502,7 +1502,7 @@ JsonSerializerOptions options try { - var deserialized = JsonSerializer.Deserialize>( + var deserialized = JsonSerializer.Deserialize>( element, options ); @@ -1533,8 +1533,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(UnnamedSchemaWithArrayParent10Converter))] -public record class UnnamedSchemaWithArrayParent10 : ModelBase +[JsonConverter(typeof(UnnamedSchemaWithArrayParent1Converter))] +public record class UnnamedSchemaWithArrayParent1 : ModelBase { public object? Value { get; } = null; @@ -1551,25 +1551,25 @@ public JsonElement Json } } - public UnnamedSchemaWithArrayParent10(string value, JsonElement? element = null) + public UnnamedSchemaWithArrayParent1(string value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent10(double value, JsonElement? element = null) + public UnnamedSchemaWithArrayParent1(double value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent10(bool value, JsonElement? element = null) + public UnnamedSchemaWithArrayParent1(bool value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent10(JsonElement element) + public UnnamedSchemaWithArrayParent1(JsonElement element) { this._element = element; } @@ -1677,7 +1677,7 @@ public void Switch( break; default: throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent10" + "Data did not match any variant of UnnamedSchemaWithArrayParent1" ); } } @@ -1716,16 +1716,16 @@ public T Match( double value => @double(value), bool value => @bool(value), _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent10" + "Data did not match any variant of UnnamedSchemaWithArrayParent1" ), }; } - public static implicit operator UnnamedSchemaWithArrayParent10(string value) => new(value); + public static implicit operator UnnamedSchemaWithArrayParent1(string value) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent10(double value) => new(value); + public static implicit operator UnnamedSchemaWithArrayParent1(double value) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent10(bool value) => new(value); + public static implicit operator UnnamedSchemaWithArrayParent1(bool value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -1742,12 +1742,12 @@ public override void Validate() if (this.Value == null) { throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent10" + "Data did not match any variant of UnnamedSchemaWithArrayParent1" ); } } - public virtual bool Equals(UnnamedSchemaWithArrayParent10? other) => + public virtual bool Equals(UnnamedSchemaWithArrayParent1? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -1775,9 +1775,9 @@ int VariantIndex() } } -sealed class UnnamedSchemaWithArrayParent10Converter : JsonConverter +sealed class UnnamedSchemaWithArrayParent1Converter : JsonConverter { - public override UnnamedSchemaWithArrayParent10? Read( + public override UnnamedSchemaWithArrayParent1? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -1820,7 +1820,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - UnnamedSchemaWithArrayParent10 value, + UnnamedSchemaWithArrayParent1 value, JsonSerializerOptions options ) { diff --git a/src/ImageKit/Models/Files/FileUploadResponse.cs b/src/ImageKit/Models/Files/FileUploadResponse.cs index 000ed3fc..dc94cb9b 100644 --- a/src/ImageKit/Models/Files/FileUploadResponse.cs +++ b/src/ImageKit/Models/Files/FileUploadResponse.cs @@ -1599,7 +1599,7 @@ public FileUploadResponseSelectedFieldsSchemaItemDefaultValue( } public FileUploadResponseSelectedFieldsSchemaItemDefaultValue( - IReadOnlyList value, + IReadOnlyList value, JsonElement? element = null ) { @@ -1677,24 +1677,24 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type where T is a UnnamedSchemaWithArrayParent11. + /// type where T is a UnnamedSchemaWithArrayParent2. /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickMixed(out var value)) { - /// // `value` is of type `IReadOnlyList<UnnamedSchemaWithArrayParent11>` + /// // `value` is of type `IReadOnlyList<UnnamedSchemaWithArrayParent2>` /// Console.WriteLine(value); /// } /// /// /// public bool TryPickMixed( - [NotNullWhen(true)] out IReadOnlyList? value + [NotNullWhen(true)] out IReadOnlyList? value ) { - value = this.Value as IReadOnlyList; + value = this.Value as IReadOnlyList; return value != null; } @@ -1715,7 +1715,7 @@ public bool TryPickMixed( /// (string value) => {...}, /// (double value) => {...}, /// (bool value) => {...}, - /// (IReadOnlyList<UnnamedSchemaWithArrayParent11> value) => {...} + /// (IReadOnlyList<UnnamedSchemaWithArrayParent2> value) => {...} /// ); /// /// @@ -1724,7 +1724,7 @@ public void Switch( System::Action @string, System::Action @double, System::Action @bool, - System::Action> mixed + System::Action> mixed ) { switch (this.Value) @@ -1738,7 +1738,7 @@ public void Switch( case bool value: @bool(value); break; - case IReadOnlyList value: + case IReadOnlyList value: mixed(value); break; default: @@ -1766,7 +1766,7 @@ public void Switch( /// (string value) => {...}, /// (double value) => {...}, /// (bool value) => {...}, - /// (IReadOnlyList<UnnamedSchemaWithArrayParent11> value) => {...} + /// (IReadOnlyList<UnnamedSchemaWithArrayParent2> value) => {...} /// ); /// /// @@ -1775,7 +1775,7 @@ public T Match( System::Func @string, System::Func @double, System::Func @bool, - System::Func, T> mixed + System::Func, T> mixed ) { return this.Value switch @@ -1783,7 +1783,7 @@ public T Match( string value => @string(value), double value => @double(value), bool value => @bool(value), - IReadOnlyList value => mixed(value), + IReadOnlyList value => mixed(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of FileUploadResponseSelectedFieldsSchemaItemDefaultValue" ), @@ -1803,8 +1803,8 @@ bool value ) => new(value); public static implicit operator FileUploadResponseSelectedFieldsSchemaItemDefaultValue( - List value - ) => new((IReadOnlyList)value); + List value + ) => new((IReadOnlyList)value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -1861,7 +1861,7 @@ int VariantIndex() string _ => 0, double _ => 1, bool _ => 2, - IReadOnlyList _ => 3, + IReadOnlyList _ => 3, _ => -1, }; } @@ -1910,7 +1910,7 @@ JsonSerializerOptions options try { - var deserialized = JsonSerializer.Deserialize>( + var deserialized = JsonSerializer.Deserialize>( element, options ); @@ -1941,8 +1941,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(UnnamedSchemaWithArrayParent11Converter))] -public record class UnnamedSchemaWithArrayParent11 : ModelBase +[JsonConverter(typeof(UnnamedSchemaWithArrayParent2Converter))] +public record class UnnamedSchemaWithArrayParent2 : ModelBase { public object? Value { get; } = null; @@ -1959,25 +1959,25 @@ public JsonElement Json } } - public UnnamedSchemaWithArrayParent11(string value, JsonElement? element = null) + public UnnamedSchemaWithArrayParent2(string value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent11(double value, JsonElement? element = null) + public UnnamedSchemaWithArrayParent2(double value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent11(bool value, JsonElement? element = null) + public UnnamedSchemaWithArrayParent2(bool value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent11(JsonElement element) + public UnnamedSchemaWithArrayParent2(JsonElement element) { this._element = element; } @@ -2085,7 +2085,7 @@ public void Switch( break; default: throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent11" + "Data did not match any variant of UnnamedSchemaWithArrayParent2" ); } } @@ -2124,16 +2124,16 @@ public T Match( double value => @double(value), bool value => @bool(value), _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent11" + "Data did not match any variant of UnnamedSchemaWithArrayParent2" ), }; } - public static implicit operator UnnamedSchemaWithArrayParent11(string value) => new(value); + public static implicit operator UnnamedSchemaWithArrayParent2(string value) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent11(double value) => new(value); + public static implicit operator UnnamedSchemaWithArrayParent2(double value) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent11(bool value) => new(value); + public static implicit operator UnnamedSchemaWithArrayParent2(bool value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -2150,12 +2150,12 @@ public override void Validate() if (this.Value == null) { throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent11" + "Data did not match any variant of UnnamedSchemaWithArrayParent2" ); } } - public virtual bool Equals(UnnamedSchemaWithArrayParent11? other) => + public virtual bool Equals(UnnamedSchemaWithArrayParent2? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -2183,9 +2183,9 @@ int VariantIndex() } } -sealed class UnnamedSchemaWithArrayParent11Converter : JsonConverter +sealed class UnnamedSchemaWithArrayParent2Converter : JsonConverter { - public override UnnamedSchemaWithArrayParent11? Read( + public override UnnamedSchemaWithArrayParent2? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -2228,7 +2228,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - UnnamedSchemaWithArrayParent11 value, + UnnamedSchemaWithArrayParent2 value, JsonSerializerOptions options ) { diff --git a/src/ImageKit/Models/UnnamedSchemaWithArrayParent0.cs b/src/ImageKit/Models/UnnamedSchemaWithArrayParent0.cs index f66652c4..0f451e90 100644 --- a/src/ImageKit/Models/UnnamedSchemaWithArrayParent0.cs +++ b/src/ImageKit/Models/UnnamedSchemaWithArrayParent0.cs @@ -2646,7 +2646,7 @@ public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue( } public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue( - IReadOnlyList value, + IReadOnlyList value, JsonElement? element = null ) { @@ -2724,24 +2724,27 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type where T is a UnnamedSchemaWithArrayParent6. + /// type where T is a UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem. /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickMixed(out var value)) { - /// // `value` is of type `IReadOnlyList<UnnamedSchemaWithArrayParent6>` + /// // `value` is of type `IReadOnlyList<UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem>` /// Console.WriteLine(value); /// } /// /// /// public bool TryPickMixed( - [NotNullWhen(true)] out IReadOnlyList? value + [NotNullWhen(true)] + out IReadOnlyList? value ) { - value = this.Value as IReadOnlyList; + value = + this.Value + as IReadOnlyList; return value != null; } @@ -2762,7 +2765,7 @@ public bool TryPickMixed( /// (string value) => {...}, /// (double value) => {...}, /// (bool value) => {...}, - /// (IReadOnlyList<UnnamedSchemaWithArrayParent6> value) => {...} + /// (IReadOnlyList<UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem> value) => {...} /// ); /// /// @@ -2771,7 +2774,9 @@ public void Switch( Action @string, Action @double, Action @bool, - Action> mixed + Action< + IReadOnlyList + > mixed ) { switch (this.Value) @@ -2785,7 +2790,7 @@ Action> mixed case bool value: @bool(value); break; - case IReadOnlyList value: + case IReadOnlyList value: mixed(value); break; default: @@ -2813,7 +2818,7 @@ Action> mixed /// (string value) => {...}, /// (double value) => {...}, /// (bool value) => {...}, - /// (IReadOnlyList<UnnamedSchemaWithArrayParent6> value) => {...} + /// (IReadOnlyList<UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem> value) => {...} /// ); /// /// @@ -2822,7 +2827,10 @@ public T Match( Func @string, Func @double, Func @bool, - Func, T> mixed + Func< + IReadOnlyList, + T + > mixed ) { return this.Value switch @@ -2830,7 +2838,8 @@ Func, T> mixed string value => @string(value), double value => @double(value), bool value => @bool(value), - IReadOnlyList value => mixed(value), + IReadOnlyList value => + mixed(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue" ), @@ -2850,8 +2859,12 @@ bool value ) => new(value); public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue( - List value - ) => new((IReadOnlyList)value); + List value + ) => + new( + (IReadOnlyList) + value + ); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -2910,7 +2923,8 @@ int VariantIndex() string _ => 0, double _ => 1, bool _ => 2, - IReadOnlyList _ => 3, + IReadOnlyList _ => + 3, _ => -1, }; } @@ -2959,10 +2973,9 @@ JsonSerializerOptions options try { - var deserialized = JsonSerializer.Deserialize>( - element, - options - ); + var deserialized = JsonSerializer.Deserialize< + List + >(element, options); if (deserialized != null) { foreach (var item in deserialized) @@ -2990,8 +3003,11 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(UnnamedSchemaWithArrayParent6Converter))] -public record class UnnamedSchemaWithArrayParent6 : ModelBase +[JsonConverter( + typeof(UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItemConverter) +)] +public record class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem + : ModelBase { public object? Value { get; } = null; @@ -3008,25 +3024,36 @@ public JsonElement Json } } - public UnnamedSchemaWithArrayParent6(string value, JsonElement? element = null) + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem( + string value, + JsonElement? element = null + ) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent6(double value, JsonElement? element = null) + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem( + double value, + JsonElement? element = null + ) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent6(bool value, JsonElement? element = null) + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem( + bool value, + JsonElement? element = null + ) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent6(JsonElement element) + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem( + JsonElement element + ) { this._element = element; } @@ -3130,7 +3157,7 @@ public void Switch(Action @string, Action @double, Action break; default: throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent6" + "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem" ); } } @@ -3165,16 +3192,22 @@ public T Match(Func @string, Func @double, Func @double(value), bool value => @bool(value), _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent6" + "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem" ), }; } - public static implicit operator UnnamedSchemaWithArrayParent6(string value) => new(value); + public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem( + string value + ) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent6(double value) => new(value); + public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem( + double value + ) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent6(bool value) => new(value); + public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem( + bool value + ) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -3191,12 +3224,14 @@ public override void Validate() if (this.Value == null) { throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent6" + "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem" ); } } - public virtual bool Equals(UnnamedSchemaWithArrayParent6? other) => + public virtual bool Equals( + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem? other + ) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -3224,9 +3259,10 @@ int VariantIndex() } } -sealed class UnnamedSchemaWithArrayParent6Converter : JsonConverter +sealed class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItemConverter + : JsonConverter { - public override UnnamedSchemaWithArrayParent6? Read( + public override UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem? Read( ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options @@ -3269,7 +3305,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - UnnamedSchemaWithArrayParent6 value, + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem value, JsonSerializerOptions options ) { @@ -3672,7 +3708,7 @@ public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue( } public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue( - IReadOnlyList value, + IReadOnlyList value, JsonElement? element = null ) { @@ -3752,24 +3788,27 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type where T is a UnnamedSchemaWithArrayParent7. + /// type where T is a UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem. /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickMixed(out var value)) { - /// // `value` is of type `IReadOnlyList<UnnamedSchemaWithArrayParent7>` + /// // `value` is of type `IReadOnlyList<UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem>` /// Console.WriteLine(value); /// } /// /// /// public bool TryPickMixed( - [NotNullWhen(true)] out IReadOnlyList? value + [NotNullWhen(true)] + out IReadOnlyList? value ) { - value = this.Value as IReadOnlyList; + value = + this.Value + as IReadOnlyList; return value != null; } @@ -3790,7 +3829,7 @@ public bool TryPickMixed( /// (string value) => {...}, /// (double value) => {...}, /// (bool value) => {...}, - /// (IReadOnlyList<UnnamedSchemaWithArrayParent7> value) => {...} + /// (IReadOnlyList<UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem> value) => {...} /// ); /// /// @@ -3799,7 +3838,9 @@ public void Switch( Action @string, Action @double, Action @bool, - Action> mixed + Action< + IReadOnlyList + > mixed ) { switch (this.Value) @@ -3813,7 +3854,7 @@ Action> mixed case bool value: @bool(value); break; - case IReadOnlyList value: + case IReadOnlyList value: mixed(value); break; default: @@ -3841,7 +3882,7 @@ Action> mixed /// (string value) => {...}, /// (double value) => {...}, /// (bool value) => {...}, - /// (IReadOnlyList<UnnamedSchemaWithArrayParent7> value) => {...} + /// (IReadOnlyList<UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem> value) => {...} /// ); /// /// @@ -3850,7 +3891,10 @@ public T Match( Func @string, Func @double, Func @bool, - Func, T> mixed + Func< + IReadOnlyList, + T + > mixed ) { return this.Value switch @@ -3858,7 +3902,8 @@ Func, T> mixed string value => @string(value), double value => @double(value), bool value => @bool(value), - IReadOnlyList value => mixed(value), + IReadOnlyList value => + mixed(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue" ), @@ -3878,8 +3923,12 @@ bool value ) => new(value); public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue( - List value - ) => new((IReadOnlyList)value); + List value + ) => + new( + (IReadOnlyList) + value + ); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -3938,7 +3987,8 @@ int VariantIndex() string _ => 0, double _ => 1, bool _ => 2, - IReadOnlyList _ => 3, + IReadOnlyList _ => + 3, _ => -1, }; } @@ -3987,10 +4037,9 @@ JsonSerializerOptions options try { - var deserialized = JsonSerializer.Deserialize>( - element, - options - ); + var deserialized = JsonSerializer.Deserialize< + List + >(element, options); if (deserialized != null) { foreach (var item in deserialized) @@ -4018,8 +4067,11 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(UnnamedSchemaWithArrayParent7Converter))] -public record class UnnamedSchemaWithArrayParent7 : ModelBase +[JsonConverter( + typeof(UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItemConverter) +)] +public record class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem + : ModelBase { public object? Value { get; } = null; @@ -4036,25 +4088,36 @@ public JsonElement Json } } - public UnnamedSchemaWithArrayParent7(string value, JsonElement? element = null) + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem( + string value, + JsonElement? element = null + ) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent7(double value, JsonElement? element = null) + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem( + double value, + JsonElement? element = null + ) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent7(bool value, JsonElement? element = null) + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem( + bool value, + JsonElement? element = null + ) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent7(JsonElement element) + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem( + JsonElement element + ) { this._element = element; } @@ -4158,7 +4221,7 @@ public void Switch(Action @string, Action @double, Action break; default: throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent7" + "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem" ); } } @@ -4193,16 +4256,22 @@ public T Match(Func @string, Func @double, Func @double(value), bool value => @bool(value), _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent7" + "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem" ), }; } - public static implicit operator UnnamedSchemaWithArrayParent7(string value) => new(value); + public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem( + string value + ) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent7(double value) => new(value); + public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem( + double value + ) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent7(bool value) => new(value); + public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem( + bool value + ) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -4219,12 +4288,14 @@ public override void Validate() if (this.Value == null) { throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent7" + "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem" ); } } - public virtual bool Equals(UnnamedSchemaWithArrayParent7? other) => + public virtual bool Equals( + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem? other + ) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -4252,9 +4323,10 @@ int VariantIndex() } } -sealed class UnnamedSchemaWithArrayParent7Converter : JsonConverter +sealed class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItemConverter + : JsonConverter { - public override UnnamedSchemaWithArrayParent7? Read( + public override UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem? Read( ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options @@ -4297,7 +4369,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - UnnamedSchemaWithArrayParent7 value, + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem value, JsonSerializerOptions options ) { @@ -4698,7 +4770,7 @@ public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue( } public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue( - IReadOnlyList value, + IReadOnlyList value, JsonElement? element = null ) { @@ -4776,24 +4848,27 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type where T is a UnnamedSchemaWithArrayParent8. + /// type where T is a UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem. /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickMixed(out var value)) { - /// // `value` is of type `IReadOnlyList<UnnamedSchemaWithArrayParent8>` + /// // `value` is of type `IReadOnlyList<UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem>` /// Console.WriteLine(value); /// } /// /// /// public bool TryPickMixed( - [NotNullWhen(true)] out IReadOnlyList? value + [NotNullWhen(true)] + out IReadOnlyList? value ) { - value = this.Value as IReadOnlyList; + value = + this.Value + as IReadOnlyList; return value != null; } @@ -4814,7 +4889,7 @@ public bool TryPickMixed( /// (string value) => {...}, /// (double value) => {...}, /// (bool value) => {...}, - /// (IReadOnlyList<UnnamedSchemaWithArrayParent8> value) => {...} + /// (IReadOnlyList<UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem> value) => {...} /// ); /// /// @@ -4823,7 +4898,9 @@ public void Switch( Action @string, Action @double, Action @bool, - Action> mixed + Action< + IReadOnlyList + > mixed ) { switch (this.Value) @@ -4837,7 +4914,7 @@ Action> mixed case bool value: @bool(value); break; - case IReadOnlyList value: + case IReadOnlyList value: mixed(value); break; default: @@ -4865,7 +4942,7 @@ Action> mixed /// (string value) => {...}, /// (double value) => {...}, /// (bool value) => {...}, - /// (IReadOnlyList<UnnamedSchemaWithArrayParent8> value) => {...} + /// (IReadOnlyList<UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem> value) => {...} /// ); /// /// @@ -4874,7 +4951,10 @@ public T Match( Func @string, Func @double, Func @bool, - Func, T> mixed + Func< + IReadOnlyList, + T + > mixed ) { return this.Value switch @@ -4882,7 +4962,8 @@ Func, T> mixed string value => @string(value), double value => @double(value), bool value => @bool(value), - IReadOnlyList value => mixed(value), + IReadOnlyList value => + mixed(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue" ), @@ -4902,8 +4983,12 @@ bool value ) => new(value); public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue( - List value - ) => new((IReadOnlyList)value); + List value + ) => + new( + (IReadOnlyList) + value + ); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -4962,7 +5047,8 @@ int VariantIndex() string _ => 0, double _ => 1, bool _ => 2, - IReadOnlyList _ => 3, + IReadOnlyList _ => + 3, _ => -1, }; } @@ -5011,10 +5097,9 @@ JsonSerializerOptions options try { - var deserialized = JsonSerializer.Deserialize>( - element, - options - ); + var deserialized = JsonSerializer.Deserialize< + List + >(element, options); if (deserialized != null) { foreach (var item in deserialized) @@ -5042,8 +5127,11 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(UnnamedSchemaWithArrayParent8Converter))] -public record class UnnamedSchemaWithArrayParent8 : ModelBase +[JsonConverter( + typeof(UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItemConverter) +)] +public record class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem + : ModelBase { public object? Value { get; } = null; @@ -5060,25 +5148,36 @@ public JsonElement Json } } - public UnnamedSchemaWithArrayParent8(string value, JsonElement? element = null) + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem( + string value, + JsonElement? element = null + ) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent8(double value, JsonElement? element = null) + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem( + double value, + JsonElement? element = null + ) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent8(bool value, JsonElement? element = null) + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem( + bool value, + JsonElement? element = null + ) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent8(JsonElement element) + public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem( + JsonElement element + ) { this._element = element; } @@ -5182,7 +5281,7 @@ public void Switch(Action @string, Action @double, Action break; default: throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent8" + "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem" ); } } @@ -5217,16 +5316,22 @@ public T Match(Func @string, Func @double, Func @double(value), bool value => @bool(value), _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent8" + "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem" ), }; } - public static implicit operator UnnamedSchemaWithArrayParent8(string value) => new(value); + public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem( + string value + ) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent8(double value) => new(value); + public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem( + double value + ) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent8(bool value) => new(value); + public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem( + bool value + ) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -5243,12 +5348,14 @@ public override void Validate() if (this.Value == null) { throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent8" + "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem" ); } } - public virtual bool Equals(UnnamedSchemaWithArrayParent8? other) => + public virtual bool Equals( + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem? other + ) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -5276,9 +5383,10 @@ int VariantIndex() } } -sealed class UnnamedSchemaWithArrayParent8Converter : JsonConverter +sealed class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItemConverter + : JsonConverter { - public override UnnamedSchemaWithArrayParent8? Read( + public override UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem? Read( ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options @@ -5321,7 +5429,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - UnnamedSchemaWithArrayParent8 value, + UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem value, JsonSerializerOptions options ) { diff --git a/src/ImageKit/Models/Webhooks/UploadPreTransformSuccessEvent.cs b/src/ImageKit/Models/Webhooks/UploadPreTransformSuccessEvent.cs index b7ae0c48..25490531 100644 --- a/src/ImageKit/Models/Webhooks/UploadPreTransformSuccessEvent.cs +++ b/src/ImageKit/Models/Webhooks/UploadPreTransformSuccessEvent.cs @@ -1811,7 +1811,7 @@ public DefaultValue(bool value, JsonElement? element = null) } public DefaultValue( - IReadOnlyList value, + IReadOnlyList value, JsonElement? element = null ) { @@ -1889,24 +1889,24 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type where T is a UnnamedSchemaWithArrayParent13. + /// type where T is a UnnamedSchemaWithArrayParent4. /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickMixed(out var value)) { - /// // `value` is of type `IReadOnlyList<UnnamedSchemaWithArrayParent13>` + /// // `value` is of type `IReadOnlyList<UnnamedSchemaWithArrayParent4>` /// Console.WriteLine(value); /// } /// /// /// public bool TryPickMixed( - [NotNullWhen(true)] out IReadOnlyList? value + [NotNullWhen(true)] out IReadOnlyList? value ) { - value = this.Value as IReadOnlyList; + value = this.Value as IReadOnlyList; return value != null; } @@ -1927,7 +1927,7 @@ public bool TryPickMixed( /// (string value) => {...}, /// (double value) => {...}, /// (bool value) => {...}, - /// (IReadOnlyList<UnnamedSchemaWithArrayParent13> value) => {...} + /// (IReadOnlyList<UnnamedSchemaWithArrayParent4> value) => {...} /// ); /// /// @@ -1936,7 +1936,7 @@ public void Switch( System::Action @string, System::Action @double, System::Action @bool, - System::Action> mixed + System::Action> mixed ) { switch (this.Value) @@ -1950,7 +1950,7 @@ public void Switch( case bool value: @bool(value); break; - case IReadOnlyList value: + case IReadOnlyList value: mixed(value); break; default: @@ -1978,7 +1978,7 @@ public void Switch( /// (string value) => {...}, /// (double value) => {...}, /// (bool value) => {...}, - /// (IReadOnlyList<UnnamedSchemaWithArrayParent13> value) => {...} + /// (IReadOnlyList<UnnamedSchemaWithArrayParent4> value) => {...} /// ); /// /// @@ -1987,7 +1987,7 @@ public T Match( System::Func @string, System::Func @double, System::Func @bool, - System::Func, T> mixed + System::Func, T> mixed ) { return this.Value switch @@ -1995,7 +1995,7 @@ public T Match( string value => @string(value), double value => @double(value), bool value => @bool(value), - IReadOnlyList value => mixed(value), + IReadOnlyList value => mixed(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of DefaultValue" ), @@ -2008,8 +2008,8 @@ public T Match( public static implicit operator DefaultValue(bool value) => new(value); - public static implicit operator DefaultValue(List value) => - new((IReadOnlyList)value); + public static implicit operator DefaultValue(List value) => + new((IReadOnlyList)value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -2066,7 +2066,7 @@ int VariantIndex() string _ => 0, double _ => 1, bool _ => 2, - IReadOnlyList _ => 3, + IReadOnlyList _ => 3, _ => -1, }; } @@ -2114,7 +2114,7 @@ JsonSerializerOptions options try { - var deserialized = JsonSerializer.Deserialize>( + var deserialized = JsonSerializer.Deserialize>( element, options ); @@ -2145,8 +2145,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(UnnamedSchemaWithArrayParent13Converter))] -public record class UnnamedSchemaWithArrayParent13 : ModelBase +[JsonConverter(typeof(UnnamedSchemaWithArrayParent4Converter))] +public record class UnnamedSchemaWithArrayParent4 : ModelBase { public object? Value { get; } = null; @@ -2163,25 +2163,25 @@ public JsonElement Json } } - public UnnamedSchemaWithArrayParent13(string value, JsonElement? element = null) + public UnnamedSchemaWithArrayParent4(string value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent13(double value, JsonElement? element = null) + public UnnamedSchemaWithArrayParent4(double value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent13(bool value, JsonElement? element = null) + public UnnamedSchemaWithArrayParent4(bool value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent13(JsonElement element) + public UnnamedSchemaWithArrayParent4(JsonElement element) { this._element = element; } @@ -2289,7 +2289,7 @@ public void Switch( break; default: throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent13" + "Data did not match any variant of UnnamedSchemaWithArrayParent4" ); } } @@ -2328,16 +2328,16 @@ public T Match( double value => @double(value), bool value => @bool(value), _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent13" + "Data did not match any variant of UnnamedSchemaWithArrayParent4" ), }; } - public static implicit operator UnnamedSchemaWithArrayParent13(string value) => new(value); + public static implicit operator UnnamedSchemaWithArrayParent4(string value) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent13(double value) => new(value); + public static implicit operator UnnamedSchemaWithArrayParent4(double value) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent13(bool value) => new(value); + public static implicit operator UnnamedSchemaWithArrayParent4(bool value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -2354,12 +2354,12 @@ public override void Validate() if (this.Value == null) { throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent13" + "Data did not match any variant of UnnamedSchemaWithArrayParent4" ); } } - public virtual bool Equals(UnnamedSchemaWithArrayParent13? other) => + public virtual bool Equals(UnnamedSchemaWithArrayParent4? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -2387,9 +2387,9 @@ int VariantIndex() } } -sealed class UnnamedSchemaWithArrayParent13Converter : JsonConverter +sealed class UnnamedSchemaWithArrayParent4Converter : JsonConverter { - public override UnnamedSchemaWithArrayParent13? Read( + public override UnnamedSchemaWithArrayParent4? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -2432,7 +2432,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - UnnamedSchemaWithArrayParent13 value, + UnnamedSchemaWithArrayParent4 value, JsonSerializerOptions options ) { From bf8f7a0d182624be47794938b1b5b1966a1fae7b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 20 Apr 2026 05:06:34 +0000 Subject: [PATCH 105/129] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index c9a36176..669269dd 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-c7f578172392bde58bbb72be2a25b9e917529cd07550358c645ce155debf2418.yml openapi_spec_hash: f0d797a17b1e8e81707517700cd44b13 -config_hash: cc8ab8a2b72639af4d57e4e268ed3f73 +config_hash: d886c9d8ebe60aa25c77553dba16d410 From 8c36d51a7246680fbef29dc36ddb35c542e10e3d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 20 Apr 2026 05:11:19 +0000 Subject: [PATCH 106/129] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 669269dd..a37aee71 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-c7f578172392bde58bbb72be2a25b9e917529cd07550358c645ce155debf2418.yml openapi_spec_hash: f0d797a17b1e8e81707517700cd44b13 -config_hash: d886c9d8ebe60aa25c77553dba16d410 +config_hash: 4fa07762cb363071cfdeef3f7eeec56e From 8e600a87ba1353b7762a9728f69ebd4034a4d87f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 20 Apr 2026 05:51:59 +0000 Subject: [PATCH 107/129] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index a37aee71..71485510 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-c7f578172392bde58bbb72be2a25b9e917529cd07550358c645ce155debf2418.yml openapi_spec_hash: f0d797a17b1e8e81707517700cd44b13 -config_hash: 4fa07762cb363071cfdeef3f7eeec56e +config_hash: ef918f7e878d4168a07e867607eb68ea From 1ce1aabf4f5f75aad5c97ba1f200b2e7062d3e90 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 20 Apr 2026 05:53:05 +0000 Subject: [PATCH 108/129] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 71485510..7ae635fc 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-c7f578172392bde58bbb72be2a25b9e917529cd07550358c645ce155debf2418.yml openapi_spec_hash: f0d797a17b1e8e81707517700cd44b13 -config_hash: ef918f7e878d4168a07e867607eb68ea +config_hash: 85ee7f056e5c05338bd9b7a7abb33c6e From af31dd70ee2437869d6c78ba1e83cd21df47d1ff Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 20 Apr 2026 06:58:07 +0000 Subject: [PATCH 109/129] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 7ae635fc..8624958a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-c7f578172392bde58bbb72be2a25b9e917529cd07550358c645ce155debf2418.yml openapi_spec_hash: f0d797a17b1e8e81707517700cd44b13 -config_hash: 85ee7f056e5c05338bd9b7a7abb33c6e +config_hash: 4e6bdc90056ab9bddbeb207bd720cf53 From a0d99beb25d3900180c229884267c72adc607175 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 20 Apr 2026 18:43:29 +0000 Subject: [PATCH 110/129] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 8624958a..6d0a83a8 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-c7f578172392bde58bbb72be2a25b9e917529cd07550358c645ce155debf2418.yml openapi_spec_hash: f0d797a17b1e8e81707517700cd44b13 -config_hash: 4e6bdc90056ab9bddbeb207bd720cf53 +config_hash: da0c89d794fefcf600a4ddfc78553c2a From e56445cd29dafbe13ed2b9d7847babddcb12d4b3 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 24 Apr 2026 05:08:43 +0000 Subject: [PATCH 111/129] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 6d0a83a8..a1b609ac 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-c7f578172392bde58bbb72be2a25b9e917529cd07550358c645ce155debf2418.yml openapi_spec_hash: f0d797a17b1e8e81707517700cd44b13 -config_hash: da0c89d794fefcf600a4ddfc78553c2a +config_hash: 94f48fd13b7d41b8b6a203a3a8cee9ed From bba6a4ac127a0099237b6d25e1de569d3e7ac031 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 27 Apr 2026 22:28:44 +0000 Subject: [PATCH 112/129] feat: support setting headers via env --- src/ImageKit/Core/ParamsBase.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/ImageKit/Core/ParamsBase.cs b/src/ImageKit/Core/ParamsBase.cs index b3da410d..46913b04 100644 --- a/src/ImageKit/Core/ParamsBase.cs +++ b/src/ImageKit/Core/ParamsBase.cs @@ -18,7 +18,7 @@ public abstract record class ParamsBase static ParamsBase() { var runtime = GetRuntime(); - defaultHeaders = new Dictionary + var headers = new Dictionary { ["User-Agent"] = GetUserAgent(), ["X-Stainless-Arch"] = GetOSArch(), @@ -28,6 +28,21 @@ static ParamsBase() ["X-Stainless-Runtime"] = runtime.Name, ["X-Stainless-Runtime-Version"] = runtime.Version, }; + + var customHeadersEnv = Environment.GetEnvironmentVariable("IMAGE_KIT_CUSTOM_HEADERS"); + if (customHeadersEnv != null) + { + foreach (var line in customHeadersEnv.Split('\n')) + { + var colon = line.IndexOf(':'); + if (colon >= 0) + { + headers[line.Substring(0, colon).Trim()] = line.Substring(colon + 1).Trim(); + } + } + } + + defaultHeaders = headers; } private protected JsonDictionary _rawQueryData = new(); From 74cba8f7ac2250b8190e5f493f6dff6a691b358e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 29 Apr 2026 18:15:27 +0000 Subject: [PATCH 113/129] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index a1b609ac..92b16878 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-c7f578172392bde58bbb72be2a25b9e917529cd07550358c645ce155debf2418.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc/imagekit-c7f578172392bde58bbb72be2a25b9e917529cd07550358c645ce155debf2418.yml openapi_spec_hash: f0d797a17b1e8e81707517700cd44b13 config_hash: 94f48fd13b7d41b8b6a203a3a8cee9ed From 2e5e9c2c0532685d6367736d717c31ba49787eae Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 Apr 2026 16:22:33 +0000 Subject: [PATCH 114/129] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 92b16878..6b776b6f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc/imagekit-c7f578172392bde58bbb72be2a25b9e917529cd07550358c645ce155debf2418.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc/imagekit-362d0336e8f52ab1beb7d9602a3665dbb0277700e8dc01ef4f96fc7651699349.yml openapi_spec_hash: f0d797a17b1e8e81707517700cd44b13 config_hash: 94f48fd13b7d41b8b6a203a3a8cee9ed From 7a339f0e7d011a747f1417cc0c14def30064b976 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 8 May 2026 20:09:46 +0000 Subject: [PATCH 115/129] fix(internal): disable default HttpClient timeout as we have our own --- src/ImageKit/Core/ClientOptions.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ImageKit/Core/ClientOptions.cs b/src/ImageKit/Core/ClientOptions.cs index c5bcc0f7..f9f29458 100644 --- a/src/ImageKit/Core/ClientOptions.cs +++ b/src/ImageKit/Core/ClientOptions.cs @@ -21,9 +21,16 @@ public record struct ClientOptions() /// /// The HTTP client to use for making requests in the SDK. + /// + /// Note: The HttpClient has a built-in timeout, which defaults to 100 seconds. + /// When passing a custom HttpClient, this timeout may conflict with the SDK's + /// own timeout handler and cause premature cancellation. /// public HttpClient HttpClient { get; set; } = - new(new HttpClientHandler() { AutomaticDecompression = DecompressionMethods.Available }); + new(new HttpClientHandler() { AutomaticDecompression = DecompressionMethods.Available }) + { + Timeout = global::System.Threading.Timeout.InfiniteTimeSpan, + }; Lazy _baseUrl = new(() => Environment.GetEnvironmentVariable("IMAGE_KIT_BASE_URL") ?? EnvironmentUrl.Production From 1d7934808fdd3654e131cdef2d8c340803c810f0 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 12 May 2026 19:06:59 +0000 Subject: [PATCH 116/129] ci: pin GitHub Actions to commit SHAs Pin all GitHub Actions referenced in generated workflows (both first-party `actions/*` and third-party) to immutable commit SHAs. Updating pinned actions is now a deliberate codegen-side bump rather than implicit on every workflow run. --- .github/workflows/ci.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 81d69f2b..cfbd2192 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,10 +22,10 @@ jobs: if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata') steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Set up .NET - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@55ec9447dda3d1cf6bd587150f3262f30ee10815 # v3.4.2 with: dotnet-version: '8.0.x' @@ -41,10 +41,10 @@ jobs: if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata') steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Set up .NET - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@55ec9447dda3d1cf6bd587150f3262f30ee10815 # v3.4.2 with: dotnet-version: '8.0.x' @@ -57,10 +57,10 @@ jobs: runs-on: ${{ github.repository == 'stainless-sdks/imagekit-csharp' && 'depot-windows-2022' || 'windows-latest' }} if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Set up .NET - uses: actions/setup-dotnet@v5 + uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0 with: dotnet-version: '8.0.x' From 1b0cef3420a8ba0ef0e9fd70b6a2f117c51b1e76 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 13 May 2026 06:27:29 +0000 Subject: [PATCH 117/129] feat(api): add no-enlarge crop modes and colorize transformation - Add `maintain_ratio_no_enlarge` to `crop` enum - Add `pad_resize_no_enlarge` and `pad_extract_no_shrink` to `cropMode` enum - Add `colorize` transformation parameter for applying color tints --- .stats.yml | 4 +-- .../Models/GetImageAttributesOptionsTest.cs | 7 ++++ src/ImageKit.Tests/Models/ImageOverlayTest.cs | 14 ++++++++ src/ImageKit.Tests/Models/OverlayTest.cs | 4 +++ src/ImageKit.Tests/Models/SrcOptionsTest.cs | 7 ++++ .../Models/TransformationTest.cs | 21 ++++++++++++ src/ImageKit.Tests/Models/VideoOverlayTest.cs | 14 ++++++++ src/ImageKit/Models/Transformation.cs | 34 +++++++++++++++++++ 8 files changed, 103 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 6b776b6f..278a536d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc/imagekit-362d0336e8f52ab1beb7d9602a3665dbb0277700e8dc01ef4f96fc7651699349.yml -openapi_spec_hash: f0d797a17b1e8e81707517700cd44b13 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc/imagekit-ad6dd3b4acf289708568a12574b997503059a47c4a4ca5ffefe64f40f3d3dbf3.yml +openapi_spec_hash: 7c103e2dff0edcbeea82057e62f58d4d config_hash: 94f48fd13b7d41b8b6a203a3a8cee9ed diff --git a/src/ImageKit.Tests/Models/GetImageAttributesOptionsTest.cs b/src/ImageKit.Tests/Models/GetImageAttributesOptionsTest.cs index 7a07560b..55d2be97 100644 --- a/src/ImageKit.Tests/Models/GetImageAttributesOptionsTest.cs +++ b/src/ImageKit.Tests/Models/GetImageAttributesOptionsTest.cs @@ -34,6 +34,7 @@ public void FieldRoundtrip_Works() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, @@ -145,6 +146,7 @@ public void FieldRoundtrip_Works() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, @@ -296,6 +298,7 @@ public void SerializationRoundtrip_Works() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, @@ -421,6 +424,7 @@ public void FieldRoundtripThroughSerialization_Works() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, @@ -539,6 +543,7 @@ public void FieldRoundtripThroughSerialization_Works() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, @@ -690,6 +695,7 @@ public void Validation_Works() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, @@ -913,6 +919,7 @@ public void CopyConstructor_Works() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, diff --git a/src/ImageKit.Tests/Models/ImageOverlayTest.cs b/src/ImageKit.Tests/Models/ImageOverlayTest.cs index 47289a76..a1a520d8 100644 --- a/src/ImageKit.Tests/Models/ImageOverlayTest.cs +++ b/src/ImageKit.Tests/Models/ImageOverlayTest.cs @@ -48,6 +48,7 @@ public void FieldRoundtrip_Works() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, @@ -168,6 +169,7 @@ public void FieldRoundtrip_Works() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, @@ -305,6 +307,7 @@ public void SerializationRoundtrip_Works() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, @@ -438,6 +441,7 @@ public void FieldRoundtripThroughSerialization_Works() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, @@ -565,6 +569,7 @@ public void FieldRoundtripThroughSerialization_Works() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, @@ -702,6 +707,7 @@ public void Validation_Works() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, @@ -899,6 +905,7 @@ public void CopyConstructor_Works() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, @@ -1015,6 +1022,7 @@ public void FieldRoundtrip_Works() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, @@ -1119,6 +1127,7 @@ public void FieldRoundtrip_Works() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, @@ -1237,6 +1246,7 @@ public void SerializationRoundtrip_Works() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, @@ -1354,6 +1364,7 @@ public void FieldRoundtripThroughSerialization_Works() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, @@ -1465,6 +1476,7 @@ public void FieldRoundtripThroughSerialization_Works() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, @@ -1583,6 +1595,7 @@ public void Validation_Works() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, @@ -1746,6 +1759,7 @@ public void CopyConstructor_Works() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, diff --git a/src/ImageKit.Tests/Models/OverlayTest.cs b/src/ImageKit.Tests/Models/OverlayTest.cs index 5a7c8d6b..f02149fb 100644 --- a/src/ImageKit.Tests/Models/OverlayTest.cs +++ b/src/ImageKit.Tests/Models/OverlayTest.cs @@ -92,6 +92,7 @@ public void ImageValidationWorks() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, @@ -218,6 +219,7 @@ public void VideoValidationWorks() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, @@ -474,6 +476,7 @@ public void ImageSerializationRoundtripWorks() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, @@ -606,6 +609,7 @@ public void VideoSerializationRoundtripWorks() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, diff --git a/src/ImageKit.Tests/Models/SrcOptionsTest.cs b/src/ImageKit.Tests/Models/SrcOptionsTest.cs index fe25fe16..6d6fcc25 100644 --- a/src/ImageKit.Tests/Models/SrcOptionsTest.cs +++ b/src/ImageKit.Tests/Models/SrcOptionsTest.cs @@ -34,6 +34,7 @@ public void FieldRoundtrip_Works() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, @@ -141,6 +142,7 @@ public void FieldRoundtrip_Works() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, @@ -274,6 +276,7 @@ public void SerializationRoundtrip_Works() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, @@ -395,6 +398,7 @@ public void FieldRoundtripThroughSerialization_Works() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, @@ -509,6 +513,7 @@ public void FieldRoundtripThroughSerialization_Works() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, @@ -642,6 +647,7 @@ public void Validation_Works() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, @@ -837,6 +843,7 @@ public void CopyConstructor_Works() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, diff --git a/src/ImageKit.Tests/Models/TransformationTest.cs b/src/ImageKit.Tests/Models/TransformationTest.cs index 5aed46f3..c1fb139c 100644 --- a/src/ImageKit.Tests/Models/TransformationTest.cs +++ b/src/ImageKit.Tests/Models/TransformationTest.cs @@ -26,6 +26,7 @@ public void FieldRoundtrip_Works() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, @@ -122,6 +123,7 @@ public void FieldRoundtrip_Works() string expectedBackground = "red"; double expectedBlur = 10; string expectedBorder = "5_FF0000"; + string expectedColorize = "colorize"; bool expectedColorProfile = true; string expectedColorReplace = "colorReplace"; ApiEnum expectedContrastStretch = ContrastStretch.True; @@ -219,6 +221,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedBackground, model.Background); Assert.Equal(expectedBlur, model.Blur); Assert.Equal(expectedBorder, model.Border); + Assert.Equal(expectedColorize, model.Colorize); Assert.Equal(expectedColorProfile, model.ColorProfile); Assert.Equal(expectedColorReplace, model.ColorReplace); Assert.Equal(expectedContrastStretch, model.ContrastStretch); @@ -285,6 +288,7 @@ public void SerializationRoundtrip_Works() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, @@ -394,6 +398,7 @@ public void FieldRoundtripThroughSerialization_Works() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, @@ -497,6 +502,7 @@ public void FieldRoundtripThroughSerialization_Works() string expectedBackground = "red"; double expectedBlur = 10; string expectedBorder = "5_FF0000"; + string expectedColorize = "colorize"; bool expectedColorProfile = true; string expectedColorReplace = "colorReplace"; ApiEnum expectedContrastStretch = ContrastStretch.True; @@ -594,6 +600,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedBackground, deserialized.Background); Assert.Equal(expectedBlur, deserialized.Blur); Assert.Equal(expectedBorder, deserialized.Border); + Assert.Equal(expectedColorize, deserialized.Colorize); Assert.Equal(expectedColorProfile, deserialized.ColorProfile); Assert.Equal(expectedColorReplace, deserialized.ColorReplace); Assert.Equal(expectedContrastStretch, deserialized.ContrastStretch); @@ -660,6 +667,7 @@ public void Validation_Works() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, @@ -776,6 +784,8 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("blur")); Assert.Null(model.Border); Assert.False(model.RawData.ContainsKey("border")); + Assert.Null(model.Colorize); + Assert.False(model.RawData.ContainsKey("colorize")); Assert.Null(model.ColorProfile); Assert.False(model.RawData.ContainsKey("colorProfile")); Assert.Null(model.ColorReplace); @@ -887,6 +897,7 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() Background = null, Blur = null, Border = null, + Colorize = null, ColorProfile = null, ColorReplace = null, ContrastStretch = null, @@ -956,6 +967,8 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() Assert.False(model.RawData.ContainsKey("blur")); Assert.Null(model.Border); Assert.False(model.RawData.ContainsKey("border")); + Assert.Null(model.Colorize); + Assert.False(model.RawData.ContainsKey("colorize")); Assert.Null(model.ColorProfile); Assert.False(model.RawData.ContainsKey("colorProfile")); Assert.Null(model.ColorReplace); @@ -1059,6 +1072,7 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() Background = null, Blur = null, Border = null, + Colorize = null, ColorProfile = null, ColorReplace = null, ContrastStretch = null, @@ -1123,6 +1137,7 @@ public void CopyConstructor_Works() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, @@ -1780,6 +1795,7 @@ public class CropTest : TestBase [InlineData(Crop.AtMaxEnlarge)] [InlineData(Crop.AtLeast)] [InlineData(Crop.MaintainRatio)] + [InlineData(Crop.MaintainRatioNoEnlarge)] public void Validation_Works(Crop rawValue) { // force implicit conversion because Theory can't do that for us @@ -1805,6 +1821,7 @@ public void InvalidEnumValidationThrows_Works() [InlineData(Crop.AtMaxEnlarge)] [InlineData(Crop.AtLeast)] [InlineData(Crop.MaintainRatio)] + [InlineData(Crop.MaintainRatioNoEnlarge)] public void SerializationRoundtrip_Works(Crop rawValue) { // force implicit conversion because Theory can't do that for us @@ -1842,6 +1859,8 @@ public class CropModeTest : TestBase [InlineData(CropMode.PadResize)] [InlineData(CropMode.Extract)] [InlineData(CropMode.PadExtract)] + [InlineData(CropMode.PadResizeNoEnlarge)] + [InlineData(CropMode.PadExtractNoShrink)] public void Validation_Works(CropMode rawValue) { // force implicit conversion because Theory can't do that for us @@ -1865,6 +1884,8 @@ public void InvalidEnumValidationThrows_Works() [InlineData(CropMode.PadResize)] [InlineData(CropMode.Extract)] [InlineData(CropMode.PadExtract)] + [InlineData(CropMode.PadResizeNoEnlarge)] + [InlineData(CropMode.PadExtractNoShrink)] public void SerializationRoundtrip_Works(CropMode rawValue) { // force implicit conversion because Theory can't do that for us diff --git a/src/ImageKit.Tests/Models/VideoOverlayTest.cs b/src/ImageKit.Tests/Models/VideoOverlayTest.cs index 6147caf3..e201a09f 100644 --- a/src/ImageKit.Tests/Models/VideoOverlayTest.cs +++ b/src/ImageKit.Tests/Models/VideoOverlayTest.cs @@ -48,6 +48,7 @@ public void FieldRoundtrip_Works() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, @@ -169,6 +170,7 @@ public void FieldRoundtrip_Works() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, @@ -306,6 +308,7 @@ public void SerializationRoundtrip_Works() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, @@ -439,6 +442,7 @@ public void FieldRoundtripThroughSerialization_Works() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, @@ -567,6 +571,7 @@ public void FieldRoundtripThroughSerialization_Works() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, @@ -704,6 +709,7 @@ public void Validation_Works() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, @@ -901,6 +907,7 @@ public void CopyConstructor_Works() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, @@ -1017,6 +1024,7 @@ public void FieldRoundtrip_Works() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, @@ -1122,6 +1130,7 @@ public void FieldRoundtrip_Works() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, @@ -1240,6 +1249,7 @@ public void SerializationRoundtrip_Works() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, @@ -1357,6 +1367,7 @@ public void FieldRoundtripThroughSerialization_Works() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, @@ -1469,6 +1480,7 @@ public void FieldRoundtripThroughSerialization_Works() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, @@ -1587,6 +1599,7 @@ public void Validation_Works() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, @@ -1750,6 +1763,7 @@ public void CopyConstructor_Works() Background = "red", Blur = 10, Border = "5_FF0000", + Colorize = "colorize", ColorProfile = true, ColorReplace = "colorReplace", ContrastStretch = ContrastStretch.True, diff --git a/src/ImageKit/Models/Transformation.cs b/src/ImageKit/Models/Transformation.cs index 262cc84d..906adbaa 100644 --- a/src/ImageKit/Models/Transformation.cs +++ b/src/ImageKit/Models/Transformation.cs @@ -332,6 +332,30 @@ public string? Border } } + /// + /// Applies a color tint to the image. Accepts color and intensity as optional + /// parameters. - `co-color` - Color to apply (e.g., `red`, `blue`, `FF0022`). + /// Default is gray color. - `in-intensity` - Intensity of the color (0-100). + /// Default is 35. See [Colorize](https://imagekit.io/docs/effects-and-enhancements#colorize---e-colorize). + /// + public string? Colorize + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("colorize"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("colorize", value); + } + } + /// /// Indicates whether the output image should retain the original color profile. /// See [Color profile](https://imagekit.io/docs/image-optimization#color-profile---cp). @@ -1293,6 +1317,7 @@ public override void Validate() _ = this.Background; _ = this.Blur; _ = this.Border; + _ = this.Colorize; _ = this.ColorProfile; _ = this.ColorReplace; this.ContrastStretch?.Validate(); @@ -2282,6 +2307,7 @@ public enum Crop AtMaxEnlarge, AtLeast, MaintainRatio, + MaintainRatioNoEnlarge, } sealed class CropConverter : JsonConverter @@ -2299,6 +2325,7 @@ JsonSerializerOptions options "at_max_enlarge" => Crop.AtMaxEnlarge, "at_least" => Crop.AtLeast, "maintain_ratio" => Crop.MaintainRatio, + "maintain_ratio_no_enlarge" => Crop.MaintainRatioNoEnlarge, _ => (Crop)(-1), }; } @@ -2314,6 +2341,7 @@ public override void Write(Utf8JsonWriter writer, Crop value, JsonSerializerOpti Crop.AtMaxEnlarge => "at_max_enlarge", Crop.AtLeast => "at_least", Crop.MaintainRatio => "maintain_ratio", + Crop.MaintainRatioNoEnlarge => "maintain_ratio_no_enlarge", _ => throw new ImageKitInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -2332,6 +2360,8 @@ public enum CropMode PadResize, Extract, PadExtract, + PadResizeNoEnlarge, + PadExtractNoShrink, } sealed class CropModeConverter : JsonConverter @@ -2347,6 +2377,8 @@ JsonSerializerOptions options "pad_resize" => CropMode.PadResize, "extract" => CropMode.Extract, "pad_extract" => CropMode.PadExtract, + "pad_resize_no_enlarge" => CropMode.PadResizeNoEnlarge, + "pad_extract_no_shrink" => CropMode.PadExtractNoShrink, _ => (CropMode)(-1), }; } @@ -2360,6 +2392,8 @@ public override void Write(Utf8JsonWriter writer, CropMode value, JsonSerializer CropMode.PadResize => "pad_resize", CropMode.Extract => "extract", CropMode.PadExtract => "pad_extract", + CropMode.PadResizeNoEnlarge => "pad_resize_no_enlarge", + CropMode.PadExtractNoShrink => "pad_extract_no_shrink", _ => throw new ImageKitInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), From bf27fe1999bee95cfd4626dff26c0cfaea6cd746 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sun, 17 May 2026 02:36:37 +0000 Subject: [PATCH 118/129] build: change dotnet package name --- .stats.yml | 4 +- CONTRIBUTING.md | 2 +- ImageKit.sln => Imagekit.sln | 4 +- README.md | 30 +++++------ .../Accounts/Origins/OriginListParamsTest.cs | 1 - .../UrlEndpoints/UrlEndpointListParamsTest.cs | 1 - .../SavedExtensionListParamsTest.cs | 1 - .../Core/JsonDictionaryTest.cs | 6 +-- .../Core/MultipartJsonDictionaryTest.cs | 6 +-- .../Core/MultipartJsonElementTest.cs | 4 +- .../Imagekit.Tests.csproj} | 2 +- .../Origins/OriginCreateParamsTest.cs | 4 +- .../Origins/OriginDeleteParamsTest.cs | 4 +- .../Accounts/Origins/OriginGetParamsTest.cs | 4 +- .../Accounts/Origins/OriginListParamsTest.cs | 1 + .../Accounts/Origins/OriginRequestTest.cs | 6 +-- .../Accounts/Origins/OriginResponseTest.cs | 6 +-- .../Origins/OriginUpdateParamsTest.cs | 4 +- .../UrlEndpointCreateParamsTest.cs | 8 +-- .../UrlEndpointDeleteParamsTest.cs | 4 +- .../UrlEndpoints/UrlEndpointGetParamsTest.cs | 4 +- .../UrlEndpoints/UrlEndpointListParamsTest.cs | 1 + .../UrlEndpoints/UrlEndpointRequestTest.cs | 8 +-- .../UrlEndpoints/UrlEndpointResponseTest.cs | 8 +-- .../UrlEndpointUpdateParamsTest.cs | 8 +-- .../Accounts/Usage/UsageGetParamsTest.cs | 4 +- .../Accounts/Usage/UsageGetResponseTest.cs | 6 +-- .../Models/Assets/AssetListParamsTest.cs | 8 +-- .../Models/Assets/AssetListResponseTest.cs | 8 +-- .../Models/BaseOverlayTest.cs | 8 +-- .../Beta/V2/Files/FileUploadParamsTest.cs | 10 ++-- .../Beta/V2/Files/FileUploadResponseTest.cs | 10 ++-- .../InvalidationCreateParamsTest.cs | 4 +- .../InvalidationCreateResponseTest.cs | 6 +-- .../Invalidation/InvalidationGetParamsTest.cs | 4 +- .../InvalidationGetResponseTest.cs | 8 +-- .../CustomMetadataFieldCreateParamsTest.cs | 8 +-- .../CustomMetadataFieldDeleteParamsTest.cs | 4 +- .../CustomMetadataFieldDeleteResponseTest.cs | 6 +-- .../CustomMetadataFieldListParamsTest.cs | 4 +- .../CustomMetadataFieldTest.cs | 8 +-- .../CustomMetadataFieldUpdateParamsTest.cs | 6 +-- .../Models/ExtensionConfigTest.cs | 8 +-- .../Files/Bulk/BulkAddTagsParamsTest.cs | 4 +- .../Files/Bulk/BulkAddTagsResponseTest.cs | 6 +-- .../Models/Files/Bulk/BulkDeleteParamsTest.cs | 4 +- .../Files/Bulk/BulkDeleteResponseTest.cs | 6 +-- .../Files/Bulk/BulkRemoveAITagsParamsTest.cs | 4 +- .../Bulk/BulkRemoveAITagsResponseTest.cs | 6 +-- .../Files/Bulk/BulkRemoveTagsParamsTest.cs | 4 +- .../Files/Bulk/BulkRemoveTagsResponseTest.cs | 6 +-- .../Models/Files/FileCopyParamsTest.cs | 4 +- .../Models/Files/FileCopyResponseTest.cs | 6 +-- .../Models/Files/FileDeleteParamsTest.cs | 4 +- .../Models/Files/FileGetParamsTest.cs | 4 +- .../Models/Files/FileMetadataTest.cs | 6 +-- .../Models/Files/FileMoveParamsTest.cs | 4 +- .../Models/Files/FileMoveResponseTest.cs | 6 +-- .../Models/Files/FileRenameParamsTest.cs | 4 +- .../Models/Files/FileRenameResponseTest.cs | 6 +-- .../Models/Files/FileTest.cs | 8 +-- .../Models/Files/FileUpdateParamsTest.cs | 6 +-- .../Models/Files/FileUpdateResponseTest.cs | 8 +-- .../Models/Files/FileUploadParamsTest.cs | 10 ++-- .../Models/Files/FileUploadResponseTest.cs | 8 +-- .../Models/Files/FolderTest.cs | 8 +-- .../Metadata/MetadataGetFromUrlParamsTest.cs | 4 +- .../Files/Metadata/MetadataGetParamsTest.cs | 4 +- .../Models/Files/UpdateFileRequestTest.cs | 10 ++-- .../Files/Versions/VersionDeleteParamsTest.cs | 4 +- .../Versions/VersionDeleteResponseTest.cs | 6 +-- .../Files/Versions/VersionGetParamsTest.cs | 4 +- .../Files/Versions/VersionListParamsTest.cs | 4 +- .../Versions/VersionRestoreParamsTest.cs | 4 +- .../Models/Folders/FolderCopyParamsTest.cs | 4 +- .../Models/Folders/FolderCopyResponseTest.cs | 6 +-- .../Models/Folders/FolderCreateParamsTest.cs | 4 +- .../Folders/FolderCreateResponseTest.cs | 6 +-- .../Models/Folders/FolderDeleteParamsTest.cs | 4 +- .../Folders/FolderDeleteResponseTest.cs | 6 +-- .../Models/Folders/FolderMoveParamsTest.cs | 4 +- .../Models/Folders/FolderMoveResponseTest.cs | 6 +-- .../Models/Folders/FolderRenameParamsTest.cs | 4 +- .../Folders/FolderRenameResponseTest.cs | 6 +-- .../Models/Folders/Job/JobGetParamsTest.cs | 4 +- .../Models/Folders/Job/JobGetResponseTest.cs | 8 +-- .../Models/GetImageAttributesOptionsTest.cs | 6 +-- .../Models/ImageOverlayTest.cs | 8 +-- .../Models/OverlayPositionTest.cs | 8 +-- .../Models/OverlayTest.cs | 6 +-- .../Models/OverlayTimingTest.cs | 6 +-- .../Models/ResponsiveImageAttributesTest.cs | 6 +-- .../SavedExtensionCreateParamsTest.cs | 6 +-- .../SavedExtensionDeleteParamsTest.cs | 4 +- .../SavedExtensionGetParamsTest.cs | 4 +- .../SavedExtensionListParamsTest.cs | 1 + .../SavedExtensionUpdateParamsTest.cs | 6 +-- .../Models/SharedSavedExtensionTest.cs | 6 +-- .../Models/SolidColorOverlayTest.cs | 6 +-- .../SolidColorOverlayTransformationTest.cs | 8 +-- .../Models/SrcOptionsTest.cs | 6 +-- .../Models/StreamingResolutionTest.cs | 8 +-- .../Models/SubtitleOverlayTest.cs | 8 +-- .../SubtitleOverlayTransformationTest.cs | 8 +-- .../Models/TextOverlayTest.cs | 8 +-- .../Models/TextOverlayTransformationTest.cs | 8 +-- .../Models/TransformationPositionTest.cs | 8 +-- .../Models/TransformationTest.cs | 8 +-- .../UnnamedSchemaWithArrayParent0Test.cs | 8 +-- .../Models/VideoOverlayTest.cs | 8 +-- .../Models/Webhooks/BaseWebhookEventTest.cs | 6 +-- .../Models/Webhooks/FileCreateEventTest.cs | 8 +-- .../Models/Webhooks/FileDeleteEventTest.cs | 6 +-- .../Models/Webhooks/FileUpdateEventTest.cs | 8 +-- .../Webhooks/FileVersionCreateEventTest.cs | 8 +-- .../Webhooks/FileVersionDeleteEventTest.cs | 6 +-- .../Webhooks/UnsafeUnwrapWebhookEventTest.cs | 8 +-- .../Models/Webhooks/UnwrapWebhookEventTest.cs | 8 +-- .../UploadPostTransformErrorEventTest.cs | 8 +-- .../UploadPostTransformSuccessEventTest.cs | 8 +-- .../UploadPreTransformErrorEventTest.cs | 6 +-- .../UploadPreTransformSuccessEventTest.cs | 10 ++-- .../VideoTransformationAcceptedEventTest.cs | 8 +-- .../VideoTransformationErrorEventTest.cs | 8 +-- .../VideoTransformationReadyEventTest.cs | 8 +-- .../RetriesTest.cs | 6 +-- .../Services/Accounts/OriginServiceTest.cs | 4 +- .../Accounts/UrlEndpointServiceTest.cs | 2 +- .../Services/Accounts/UsageServiceTest.cs | 2 +- .../Services/AssetServiceTest.cs | 2 +- .../Services/Beta/V2/FileServiceTest.cs | 2 +- .../Services/Cache/InvalidationServiceTest.cs | 2 +- .../CustomMetadataFieldServiceTest.cs | 4 +- .../Services/FileServiceTest.cs | 6 +-- .../Services/Files/BulkServiceTest.cs | 2 +- .../Services/Files/MetadataServiceTest.cs | 2 +- .../Services/Files/VersionServiceTest.cs | 2 +- .../Services/FolderServiceTest.cs | 2 +- .../Services/Folders/JobServiceTest.cs | 2 +- .../Services/SavedExtensionServiceTest.cs | 4 +- .../TestBase.cs | 4 +- src/{ImageKit => Imagekit}/Core/ApiEnum.cs | 4 +- .../Core/BinaryContent.cs | 2 +- .../Core/ClientOptions.cs | 4 +- .../Core/DecompressionMethods.cs | 2 +- .../Core/EnvironmentUrl.cs | 2 +- .../Core/FriendlyJsonPrinter.cs | 2 +- .../Core/FrozenDictionaryConverterFactory.cs | 2 +- .../Core/HttpRequest.cs | 2 +- .../Core/HttpResponse.cs | 4 +- src/{ImageKit => Imagekit}/Core/IPage.cs | 4 +- .../Core/JsonDictionary.cs | 4 +- src/{ImageKit => Imagekit}/Core/JsonModel.cs | 2 +- .../Core/JsonModelConverter.cs | 2 +- src/{ImageKit => Imagekit}/Core/ModelBase.cs | 20 ++++---- .../Core/MultipartJsonDictionary.cs | 4 +- .../Core/MultipartJsonElement.cs | 2 +- .../Core/MultipartJsonModel.cs | 2 +- .../Core/MultipartJsonModelConverter.cs | 2 +- src/{ImageKit => Imagekit}/Core/ParamsBase.cs | 2 +- .../Core/WrappedJsonSerializer.cs | 4 +- .../Core/WrappedMultipartJsonSerializer.cs | 4 +- .../Exceptions/ImageKit4xxException.cs | 2 +- .../Exceptions/ImageKit5xxException.cs | 2 +- .../Exceptions/ImageKitApiException.cs | 2 +- .../Exceptions/ImageKitBadRequestException.cs | 2 +- .../Exceptions/ImageKitException.cs | 2 +- .../Exceptions/ImageKitExceptionFactory.cs | 2 +- .../Exceptions/ImageKitForbiddenException.cs | 2 +- .../Exceptions/ImageKitIOException.cs | 2 +- .../ImageKitInvalidDataException.cs | 2 +- .../Exceptions/ImageKitNotFoundException.cs | 2 +- .../Exceptions/ImageKitRateLimitException.cs | 2 +- .../ImageKitUnauthorizedException.cs | 2 +- .../ImageKitUnexpectedStatusCodeException.cs | 2 +- .../ImageKitUnprocessableEntityException.cs | 2 +- src/{ImageKit => Imagekit}/IImageKitClient.cs | 6 +-- src/{ImageKit => Imagekit}/IPageExtensions.cs | 4 +- src/{ImageKit => Imagekit}/ImageKitClient.cs | 8 +-- .../Imagekit.csproj} | 4 +- .../Accounts/Origins/OriginCreateParams.cs | 4 +- .../Accounts/Origins/OriginDeleteParams.cs | 4 +- .../Accounts/Origins/OriginGetParams.cs | 4 +- .../Accounts/Origins/OriginListParams.cs | 4 +- .../Models/Accounts/Origins/OriginRequest.cs | 6 +-- .../Models/Accounts/Origins/OriginResponse.cs | 6 +-- .../Accounts/Origins/OriginUpdateParams.cs | 4 +- .../UrlEndpoints/UrlEndpointCreateParams.cs | 6 +-- .../UrlEndpoints/UrlEndpointDeleteParams.cs | 4 +- .../UrlEndpoints/UrlEndpointGetParams.cs | 4 +- .../UrlEndpoints/UrlEndpointListParams.cs | 4 +- .../UrlEndpoints/UrlEndpointRequest.cs | 6 +-- .../UrlEndpoints/UrlEndpointResponse.cs | 6 +-- .../UrlEndpoints/UrlEndpointUpdateParams.cs | 6 +-- .../Models/Accounts/Usage/UsageGetParams.cs | 4 +- .../Models/Accounts/Usage/UsageGetResponse.cs | 4 +- .../Models/Assets/AssetListParams.cs | 34 ++++++------- .../Models/Assets/AssetListResponse.cs | 8 +-- .../Models/BaseOverlay.cs | 6 +-- .../Models/Beta/V2/Files/FileUploadParams.cs | 6 +-- .../Beta/V2/Files/FileUploadResponse.cs | 50 +++++++++---------- .../Invalidation/InvalidationCreateParams.cs | 4 +- .../InvalidationCreateResponse.cs | 4 +- .../Invalidation/InvalidationGetParams.cs | 4 +- .../Invalidation/InvalidationGetResponse.cs | 6 +-- .../CustomMetadataField.cs | 6 +-- .../CustomMetadataFieldCreateParams.cs | 48 +++++++++--------- .../CustomMetadataFieldDeleteParams.cs | 4 +- .../CustomMetadataFieldDeleteResponse.cs | 4 +- .../CustomMetadataFieldListParams.cs | 4 +- .../CustomMetadataFieldUpdateParams.cs | 6 +-- .../Models/ExtensionConfig.cs | 6 +-- .../Models/Files/Bulk/BulkAddTagsParams.cs | 4 +- .../Models/Files/Bulk/BulkAddTagsResponse.cs | 4 +- .../Models/Files/Bulk/BulkDeleteParams.cs | 4 +- .../Models/Files/Bulk/BulkDeleteResponse.cs | 4 +- .../Files/Bulk/BulkRemoveAITagsParams.cs | 4 +- .../Files/Bulk/BulkRemoveAITagsResponse.cs | 4 +- .../Models/Files/Bulk/BulkRemoveTagsParams.cs | 4 +- .../Files/Bulk/BulkRemoveTagsResponse.cs | 4 +- .../Models/Files/File.cs | 48 +++++++++--------- .../Models/Files/FileCopyParams.cs | 4 +- .../Models/Files/FileCopyResponse.cs | 4 +- .../Models/Files/FileDeleteParams.cs | 4 +- .../Models/Files/FileGetParams.cs | 4 +- .../Models/Files/FileMetadata.cs | 4 +- .../Models/Files/FileMoveParams.cs | 4 +- .../Models/Files/FileMoveResponse.cs | 4 +- .../Models/Files/FileRenameParams.cs | 4 +- .../Models/Files/FileRenameResponse.cs | 4 +- .../Models/Files/FileUpdateParams.cs | 4 +- .../Models/Files/FileUpdateResponse.cs | 6 +-- .../Models/Files/FileUploadParams.cs | 6 +-- .../Models/Files/FileUploadResponse.cs | 6 +-- .../Models/Files/Folder.cs | 6 +-- .../Metadata/MetadataGetFromUrlParams.cs | 4 +- .../Files/Metadata/MetadataGetParams.cs | 4 +- .../Models/Files/UpdateFileRequest.cs | 6 +-- .../Files/Versions/VersionDeleteParams.cs | 4 +- .../Files/Versions/VersionDeleteResponse.cs | 4 +- .../Models/Files/Versions/VersionGetParams.cs | 4 +- .../Files/Versions/VersionListParams.cs | 4 +- .../Files/Versions/VersionRestoreParams.cs | 4 +- .../Models/Folders/FolderCopyParams.cs | 4 +- .../Models/Folders/FolderCopyResponse.cs | 4 +- .../Models/Folders/FolderCreateParams.cs | 4 +- .../Models/Folders/FolderCreateResponse.cs | 4 +- .../Models/Folders/FolderDeleteParams.cs | 4 +- .../Models/Folders/FolderDeleteResponse.cs | 4 +- .../Models/Folders/FolderMoveParams.cs | 4 +- .../Models/Folders/FolderMoveResponse.cs | 4 +- .../Models/Folders/FolderRenameParams.cs | 4 +- .../Models/Folders/FolderRenameResponse.cs | 4 +- .../Models/Folders/Job/JobGetParams.cs | 4 +- .../Models/Folders/Job/JobGetResponse.cs | 30 +++++------ .../Models/GetImageAttributesOptions.cs | 4 +- .../Models/ImageOverlay.cs | 6 +-- src/{ImageKit => Imagekit}/Models/Overlay.cs | 6 +-- .../Models/OverlayPosition.cs | 6 +-- .../Models/OverlayTiming.cs | 6 +-- .../Models/ResponsiveImageAttributes.cs | 4 +- .../SavedExtensionCreateParams.cs | 4 +- .../SavedExtensionDeleteParams.cs | 4 +- .../SavedExtensionGetParams.cs | 4 +- .../SavedExtensionListParams.cs | 4 +- .../SavedExtensionUpdateParams.cs | 4 +- .../Models/SharedSavedExtension.cs | 4 +- .../Models/SolidColorOverlay.cs | 6 +-- .../Models/SolidColorOverlayTransformation.cs | 6 +-- .../Models/SrcOptions.cs | 4 +- .../Models/StreamingResolution.cs | 4 +- .../Models/SubtitleOverlay.cs | 6 +-- .../Models/SubtitleOverlayTransformation.cs | 6 +-- .../Models/TextOverlay.cs | 6 +-- .../Models/TextOverlayTransformation.cs | 6 +-- .../Models/Transformation.cs | 6 +-- .../Models/TransformationPosition.cs | 4 +- .../Models/UnnamedSchemaWithArrayParent0.cs | 6 +-- .../Models/VideoOverlay.cs | 6 +-- .../Models/Webhooks/BaseWebhookEvent.cs | 4 +- .../Models/Webhooks/FileCreateEvent.cs | 24 ++++----- .../Models/Webhooks/FileDeleteEvent.cs | 6 +-- .../Models/Webhooks/FileUpdateEvent.cs | 8 +-- .../Models/Webhooks/FileVersionCreateEvent.cs | 8 +-- .../Models/Webhooks/FileVersionDeleteEvent.cs | 6 +-- .../Webhooks/UnsafeUnwrapWebhookEvent.cs | 6 +-- .../Models/Webhooks/UnwrapWebhookEvent.cs | 6 +-- .../Webhooks/UploadPostTransformErrorEvent.cs | 36 ++++++------- .../UploadPostTransformSuccessEvent.cs | 6 +-- .../Webhooks/UploadPreTransformErrorEvent.cs | 6 +-- .../UploadPreTransformSuccessEvent.cs | 8 +-- .../VideoTransformationAcceptedEvent.cs | 6 +-- .../Webhooks/VideoTransformationErrorEvent.cs | 6 +-- .../Webhooks/VideoTransformationReadyEvent.cs | 6 +-- .../Services/AccountService.cs | 6 +-- .../Services/Accounts/IOriginService.cs | 6 +-- .../Services/Accounts/IUrlEndpointService.cs | 6 +-- .../Services/Accounts/IUsageService.cs | 6 +-- .../Services/Accounts/OriginService.cs | 8 +-- .../Services/Accounts/UrlEndpointService.cs | 8 +-- .../Services/Accounts/UsageService.cs | 6 +-- .../Services/AssetService.cs | 6 +-- .../Services/Beta/IV2Service.cs | 6 +-- .../Services/Beta/V2/FileService.cs | 6 +-- .../Services/Beta/V2/IFileService.cs | 6 +-- .../Services/Beta/V2Service.cs | 6 +-- .../Services/BetaService.cs | 6 +-- .../Services/Cache/IInvalidationService.cs | 6 +-- .../Services/Cache/InvalidationService.cs | 8 +-- .../Services/CacheService.cs | 6 +-- .../Services/CustomMetadataFieldService.cs | 8 +-- .../Services/FileService.cs | 10 ++-- .../Services/Files/BulkService.cs | 6 +-- .../Services/Files/IBulkService.cs | 6 +-- .../Services/Files/IMetadataService.cs | 8 +-- .../Services/Files/IVersionService.cs | 8 +-- .../Services/Files/MetadataService.cs | 10 ++-- .../Services/Files/VersionService.cs | 10 ++-- .../Services/FolderService.cs | 8 +-- .../Services/Folders/IJobService.cs | 6 +-- .../Services/Folders/JobService.cs | 8 +-- .../Services/IAccountService.cs | 6 +-- .../Services/IAssetService.cs | 6 +-- .../Services/IBetaService.cs | 6 +-- .../Services/ICacheService.cs | 6 +-- .../Services/ICustomMetadataFieldService.cs | 6 +-- .../Services/IFileService.cs | 8 +-- .../Services/IFolderService.cs | 8 +-- .../Services/ISavedExtensionService.cs | 8 +-- .../Services/IWebhookService.cs | 4 +- .../Services/SavedExtensionService.cs | 10 ++-- .../Services/WebhookService.cs | 4 +- src/{ImageKit => Imagekit}/Shims.cs | 0 333 files changed, 993 insertions(+), 993 deletions(-) rename ImageKit.sln => Imagekit.sln (85%) delete mode 100644 src/ImageKit.Tests/Models/Accounts/Origins/OriginListParamsTest.cs delete mode 100644 src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointListParamsTest.cs delete mode 100644 src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionListParamsTest.cs rename src/{ImageKit.Tests => Imagekit.Tests}/Core/JsonDictionaryTest.cs (95%) rename src/{ImageKit.Tests => Imagekit.Tests}/Core/MultipartJsonDictionaryTest.cs (95%) rename src/{ImageKit.Tests => Imagekit.Tests}/Core/MultipartJsonElementTest.cs (96%) rename src/{ImageKit.Tests/ImageKit.Tests.csproj => Imagekit.Tests/Imagekit.Tests.csproj} (93%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Accounts/Origins/OriginCreateParamsTest.cs (93%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Accounts/Origins/OriginDeleteParamsTest.cs (86%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Accounts/Origins/OriginGetParamsTest.cs (86%) create mode 100644 src/Imagekit.Tests/Models/Accounts/Origins/OriginListParamsTest.cs rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Accounts/Origins/OriginRequestTest.cs (97%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Accounts/Origins/OriginResponseTest.cs (96%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Accounts/Origins/OriginUpdateParamsTest.cs (93%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Accounts/UrlEndpoints/UrlEndpointCreateParamsTest.cs (95%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Accounts/UrlEndpoints/UrlEndpointDeleteParamsTest.cs (86%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Accounts/UrlEndpoints/UrlEndpointGetParamsTest.cs (86%) create mode 100644 src/Imagekit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointListParamsTest.cs rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Accounts/UrlEndpoints/UrlEndpointRequestTest.cs (96%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Accounts/UrlEndpoints/UrlEndpointResponseTest.cs (96%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParamsTest.cs (95%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Accounts/Usage/UsageGetParamsTest.cs (90%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Accounts/Usage/UsageGetResponseTest.cs (95%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Assets/AssetListParamsTest.cs (96%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Assets/AssetListResponseTest.cs (95%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/BaseOverlayTest.cs (95%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Beta/V2/Files/FileUploadParamsTest.cs (96%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Beta/V2/Files/FileUploadResponseTest.cs (97%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Cache/Invalidation/InvalidationCreateParamsTest.cs (89%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Cache/Invalidation/InvalidationCreateResponseTest.cs (92%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Cache/Invalidation/InvalidationGetParamsTest.cs (87%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Cache/Invalidation/InvalidationGetResponseTest.cs (93%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsTest.cs (96%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/CustomMetadataFields/CustomMetadataFieldDeleteParamsTest.cs (86%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/CustomMetadataFields/CustomMetadataFieldDeleteResponseTest.cs (89%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/CustomMetadataFields/CustomMetadataFieldListParamsTest.cs (92%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/CustomMetadataFields/CustomMetadataFieldTest.cs (96%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsTest.cs (96%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/ExtensionConfigTest.cs (96%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Files/Bulk/BulkAddTagsParamsTest.cs (92%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Files/Bulk/BulkAddTagsResponseTest.cs (94%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Files/Bulk/BulkDeleteParamsTest.cs (91%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Files/Bulk/BulkDeleteResponseTest.cs (94%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Files/Bulk/BulkRemoveAITagsParamsTest.cs (92%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Files/Bulk/BulkRemoveAITagsResponseTest.cs (94%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Files/Bulk/BulkRemoveTagsParamsTest.cs (92%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Files/Bulk/BulkRemoveTagsResponseTest.cs (94%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Files/FileCopyParamsTest.cs (94%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Files/FileCopyResponseTest.cs (89%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Files/FileDeleteParamsTest.cs (88%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Files/FileGetParamsTest.cs (88%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Files/FileMetadataTest.cs (97%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Files/FileMoveParamsTest.cs (91%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Files/FileMoveResponseTest.cs (89%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Files/FileRenameParamsTest.cs (93%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Files/FileRenameResponseTest.cs (93%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Files/FileTest.cs (97%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Files/FileUpdateParamsTest.cs (96%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Files/FileUpdateResponseTest.cs (97%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Files/FileUploadParamsTest.cs (96%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Files/FileUploadResponseTest.cs (97%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Files/FolderTest.cs (96%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Files/Metadata/MetadataGetFromUrlParamsTest.cs (89%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Files/Metadata/MetadataGetParamsTest.cs (87%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Files/UpdateFileRequestTest.cs (97%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Files/Versions/VersionDeleteParamsTest.cs (89%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Files/Versions/VersionDeleteResponseTest.cs (88%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Files/Versions/VersionGetParamsTest.cs (89%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Files/Versions/VersionListParamsTest.cs (87%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Files/Versions/VersionRestoreParamsTest.cs (89%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Folders/FolderCopyParamsTest.cs (94%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Folders/FolderCopyResponseTest.cs (90%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Folders/FolderCreateParamsTest.cs (91%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Folders/FolderCreateResponseTest.cs (89%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Folders/FolderDeleteParamsTest.cs (89%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Folders/FolderDeleteResponseTest.cs (89%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Folders/FolderMoveParamsTest.cs (91%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Folders/FolderMoveResponseTest.cs (90%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Folders/FolderRenameParamsTest.cs (93%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Folders/FolderRenameResponseTest.cs (90%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Folders/Job/JobGetParamsTest.cs (87%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Folders/Job/JobGetResponseTest.cs (95%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/GetImageAttributesOptionsTest.cs (97%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/ImageOverlayTest.cs (97%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/OverlayPositionTest.cs (95%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/OverlayTest.cs (96%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/OverlayTimingTest.cs (95%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/ResponsiveImageAttributesTest.cs (95%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/SavedExtensions/SavedExtensionCreateParamsTest.cs (93%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/SavedExtensions/SavedExtensionDeleteParamsTest.cs (87%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/SavedExtensions/SavedExtensionGetParamsTest.cs (87%) create mode 100644 src/Imagekit.Tests/Models/SavedExtensions/SavedExtensionListParamsTest.cs rename src/{ImageKit.Tests => Imagekit.Tests}/Models/SavedExtensions/SavedExtensionUpdateParamsTest.cs (93%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/SharedSavedExtensionTest.cs (96%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/SolidColorOverlayTest.cs (96%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/SolidColorOverlayTransformationTest.cs (95%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/SrcOptionsTest.cs (97%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/StreamingResolutionTest.cs (93%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/SubtitleOverlayTest.cs (96%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/SubtitleOverlayTransformationTest.cs (95%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/TextOverlayTest.cs (96%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/TextOverlayTransformationTest.cs (96%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/TransformationPositionTest.cs (92%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/TransformationTest.cs (96%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/UnnamedSchemaWithArrayParent0Test.cs (97%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/VideoOverlayTest.cs (97%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Webhooks/BaseWebhookEventTest.cs (91%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Webhooks/FileCreateEventTest.cs (97%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Webhooks/FileDeleteEventTest.cs (95%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Webhooks/FileUpdateEventTest.cs (97%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Webhooks/FileVersionCreateEventTest.cs (97%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Webhooks/FileVersionDeleteEventTest.cs (95%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs (97%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Webhooks/UnwrapWebhookEventTest.cs (97%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Webhooks/UploadPostTransformErrorEventTest.cs (96%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Webhooks/UploadPostTransformSuccessEventTest.cs (96%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Webhooks/UploadPreTransformErrorEventTest.cs (96%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Webhooks/UploadPreTransformSuccessEventTest.cs (97%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Webhooks/VideoTransformationAcceptedEventTest.cs (96%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Webhooks/VideoTransformationErrorEventTest.cs (97%) rename src/{ImageKit.Tests => Imagekit.Tests}/Models/Webhooks/VideoTransformationReadyEventTest.cs (97%) rename src/{ImageKit.Tests => Imagekit.Tests}/RetriesTest.cs (96%) rename src/{ImageKit.Tests => Imagekit.Tests}/Services/Accounts/OriginServiceTest.cs (93%) rename src/{ImageKit.Tests => Imagekit.Tests}/Services/Accounts/UrlEndpointServiceTest.cs (94%) rename src/{ImageKit.Tests => Imagekit.Tests}/Services/Accounts/UsageServiceTest.cs (86%) rename src/{ImageKit.Tests => Imagekit.Tests}/Services/AssetServiceTest.cs (87%) rename src/{ImageKit.Tests => Imagekit.Tests}/Services/Beta/V2/FileServiceTest.cs (88%) rename src/{ImageKit.Tests => Imagekit.Tests}/Services/Cache/InvalidationServiceTest.cs (91%) rename src/{ImageKit.Tests => Imagekit.Tests}/Services/CustomMetadataFieldServiceTest.cs (93%) rename src/{ImageKit.Tests => Imagekit.Tests}/Services/FileServiceTest.cs (95%) rename src/{ImageKit.Tests => Imagekit.Tests}/Services/Files/BulkServiceTest.cs (94%) rename src/{ImageKit.Tests => Imagekit.Tests}/Services/Files/MetadataServiceTest.cs (91%) rename src/{ImageKit.Tests => Imagekit.Tests}/Services/Files/VersionServiceTest.cs (93%) rename src/{ImageKit.Tests => Imagekit.Tests}/Services/FolderServiceTest.cs (95%) rename src/{ImageKit.Tests => Imagekit.Tests}/Services/Folders/JobServiceTest.cs (85%) rename src/{ImageKit.Tests => Imagekit.Tests}/Services/SavedExtensionServiceTest.cs (93%) rename src/{ImageKit.Tests => Imagekit.Tests}/TestBase.cs (93%) rename src/{ImageKit => Imagekit}/Core/ApiEnum.cs (96%) rename src/{ImageKit => Imagekit}/Core/BinaryContent.cs (93%) rename src/{ImageKit => Imagekit}/Core/ClientOptions.cs (96%) rename src/{ImageKit => Imagekit}/Core/DecompressionMethods.cs (94%) rename src/{ImageKit => Imagekit}/Core/EnvironmentUrl.cs (78%) rename src/{ImageKit => Imagekit}/Core/FriendlyJsonPrinter.cs (96%) rename src/{ImageKit => Imagekit}/Core/FrozenDictionaryConverterFactory.cs (95%) rename src/{ImageKit => Imagekit}/Core/HttpRequest.cs (92%) rename src/{ImageKit => Imagekit}/Core/HttpResponse.cs (95%) rename src/{ImageKit => Imagekit}/Core/IPage.cs (94%) rename src/{ImageKit => Imagekit}/Core/JsonDictionary.cs (95%) rename src/{ImageKit => Imagekit}/Core/JsonModel.cs (95%) rename src/{ImageKit => Imagekit}/Core/JsonModelConverter.cs (93%) rename src/{ImageKit => Imagekit}/Core/ModelBase.cs (93%) rename src/{ImageKit => Imagekit}/Core/MultipartJsonDictionary.cs (95%) rename src/{ImageKit => Imagekit}/Core/MultipartJsonElement.cs (97%) rename src/{ImageKit => Imagekit}/Core/MultipartJsonModel.cs (95%) rename src/{ImageKit => Imagekit}/Core/MultipartJsonModelConverter.cs (93%) rename src/{ImageKit => Imagekit}/Core/ParamsBase.cs (96%) rename src/{ImageKit => Imagekit}/Core/WrappedJsonSerializer.cs (94%) rename src/{ImageKit => Imagekit}/Core/WrappedMultipartJsonSerializer.cs (94%) rename src/{ImageKit => Imagekit}/Exceptions/ImageKit4xxException.cs (83%) rename src/{ImageKit => Imagekit}/Exceptions/ImageKit5xxException.cs (83%) rename src/{ImageKit => Imagekit}/Exceptions/ImageKitApiException.cs (93%) rename src/{ImageKit => Imagekit}/Exceptions/ImageKitBadRequestException.cs (84%) rename src/{ImageKit => Imagekit}/Exceptions/ImageKitException.cs (87%) rename src/{ImageKit => Imagekit}/Exceptions/ImageKitExceptionFactory.cs (95%) rename src/{ImageKit => Imagekit}/Exceptions/ImageKitForbiddenException.cs (84%) rename src/{ImageKit => Imagekit}/Exceptions/ImageKitIOException.cs (90%) rename src/{ImageKit => Imagekit}/Exceptions/ImageKitInvalidDataException.cs (84%) rename src/{ImageKit => Imagekit}/Exceptions/ImageKitNotFoundException.cs (83%) rename src/{ImageKit => Imagekit}/Exceptions/ImageKitRateLimitException.cs (84%) rename src/{ImageKit => Imagekit}/Exceptions/ImageKitUnauthorizedException.cs (84%) rename src/{ImageKit => Imagekit}/Exceptions/ImageKitUnexpectedStatusCodeException.cs (85%) rename src/{ImageKit => Imagekit}/Exceptions/ImageKitUnprocessableEntityException.cs (85%) rename src/{ImageKit => Imagekit}/IImageKitClient.cs (95%) rename src/{ImageKit => Imagekit}/IPageExtensions.cs (92%) rename src/{ImageKit => Imagekit}/ImageKitClient.cs (96%) rename src/{ImageKit/ImageKit.csproj => Imagekit/Imagekit.csproj} (89%) rename src/{ImageKit => Imagekit}/Models/Accounts/Origins/OriginCreateParams.cs (95%) rename src/{ImageKit => Imagekit}/Models/Accounts/Origins/OriginDeleteParams.cs (95%) rename src/{ImageKit => Imagekit}/Models/Accounts/Origins/OriginGetParams.cs (95%) rename src/{ImageKit => Imagekit}/Models/Accounts/Origins/OriginListParams.cs (95%) rename src/{ImageKit => Imagekit}/Models/Accounts/Origins/OriginRequest.cs (96%) rename src/{ImageKit => Imagekit}/Models/Accounts/Origins/OriginResponse.cs (96%) rename src/{ImageKit => Imagekit}/Models/Accounts/Origins/OriginUpdateParams.cs (95%) rename src/{ImageKit => Imagekit}/Models/Accounts/UrlEndpoints/UrlEndpointCreateParams.cs (96%) rename src/{ImageKit => Imagekit}/Models/Accounts/UrlEndpoints/UrlEndpointDeleteParams.cs (95%) rename src/{ImageKit => Imagekit}/Models/Accounts/UrlEndpoints/UrlEndpointGetParams.cs (95%) rename src/{ImageKit => Imagekit}/Models/Accounts/UrlEndpoints/UrlEndpointListParams.cs (95%) rename src/{ImageKit => Imagekit}/Models/Accounts/UrlEndpoints/UrlEndpointRequest.cs (96%) rename src/{ImageKit => Imagekit}/Models/Accounts/UrlEndpoints/UrlEndpointResponse.cs (96%) rename src/{ImageKit => Imagekit}/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParams.cs (96%) rename src/{ImageKit => Imagekit}/Models/Accounts/Usage/UsageGetParams.cs (95%) rename src/{ImageKit => Imagekit}/Models/Accounts/Usage/UsageGetResponse.cs (94%) rename src/{ImageKit => Imagekit}/Models/Assets/AssetListParams.cs (90%) rename src/{ImageKit => Imagekit}/Models/Assets/AssetListResponse.cs (95%) rename src/{ImageKit => Imagekit}/Models/BaseOverlay.cs (96%) rename src/{ImageKit => Imagekit}/Models/Beta/V2/Files/FileUploadParams.cs (96%) rename src/{ImageKit => Imagekit}/Models/Beta/V2/Files/FileUploadResponse.cs (94%) rename src/{ImageKit => Imagekit}/Models/Cache/Invalidation/InvalidationCreateParams.cs (95%) rename src/{ImageKit => Imagekit}/Models/Cache/Invalidation/InvalidationCreateResponse.cs (93%) rename src/{ImageKit => Imagekit}/Models/Cache/Invalidation/InvalidationGetParams.cs (95%) rename src/{ImageKit => Imagekit}/Models/Cache/Invalidation/InvalidationGetResponse.cs (93%) rename src/{ImageKit => Imagekit}/Models/CustomMetadataFields/CustomMetadataField.cs (96%) rename src/{ImageKit => Imagekit}/Models/CustomMetadataFields/CustomMetadataFieldCreateParams.cs (94%) rename src/{ImageKit => Imagekit}/Models/CustomMetadataFields/CustomMetadataFieldDeleteParams.cs (95%) rename src/{ImageKit => Imagekit}/Models/CustomMetadataFields/CustomMetadataFieldDeleteResponse.cs (93%) rename src/{ImageKit => Imagekit}/Models/CustomMetadataFields/CustomMetadataFieldListParams.cs (95%) rename src/{ImageKit => Imagekit}/Models/CustomMetadataFields/CustomMetadataFieldUpdateParams.cs (96%) rename src/{ImageKit => Imagekit}/Models/ExtensionConfig.cs (96%) rename src/{ImageKit => Imagekit}/Models/Files/Bulk/BulkAddTagsParams.cs (95%) rename src/{ImageKit => Imagekit}/Models/Files/Bulk/BulkAddTagsResponse.cs (94%) rename src/{ImageKit => Imagekit}/Models/Files/Bulk/BulkDeleteParams.cs (95%) rename src/{ImageKit => Imagekit}/Models/Files/Bulk/BulkDeleteResponse.cs (94%) rename src/{ImageKit => Imagekit}/Models/Files/Bulk/BulkRemoveAITagsParams.cs (95%) rename src/{ImageKit => Imagekit}/Models/Files/Bulk/BulkRemoveAITagsResponse.cs (94%) rename src/{ImageKit => Imagekit}/Models/Files/Bulk/BulkRemoveTagsParams.cs (95%) rename src/{ImageKit => Imagekit}/Models/Files/Bulk/BulkRemoveTagsResponse.cs (94%) rename src/{ImageKit => Imagekit}/Models/Files/File.cs (94%) rename src/{ImageKit => Imagekit}/Models/Files/FileCopyParams.cs (96%) rename src/{ImageKit => Imagekit}/Models/Files/FileCopyResponse.cs (93%) rename src/{ImageKit => Imagekit}/Models/Files/FileDeleteParams.cs (95%) rename src/{ImageKit => Imagekit}/Models/Files/FileGetParams.cs (95%) rename src/{ImageKit => Imagekit}/Models/Files/FileMetadata.cs (95%) rename src/{ImageKit => Imagekit}/Models/Files/FileMoveParams.cs (96%) rename src/{ImageKit => Imagekit}/Models/Files/FileMoveResponse.cs (93%) rename src/{ImageKit => Imagekit}/Models/Files/FileRenameParams.cs (96%) rename src/{ImageKit => Imagekit}/Models/Files/FileRenameResponse.cs (93%) rename src/{ImageKit => Imagekit}/Models/Files/FileUpdateParams.cs (95%) rename src/{ImageKit => Imagekit}/Models/Files/FileUpdateResponse.cs (95%) rename src/{ImageKit => Imagekit}/Models/Files/FileUploadParams.cs (96%) rename src/{ImageKit => Imagekit}/Models/Files/FileUploadResponse.cs (96%) rename src/{ImageKit => Imagekit}/Models/Files/Folder.cs (94%) rename src/{ImageKit => Imagekit}/Models/Files/Metadata/MetadataGetFromUrlParams.cs (95%) rename src/{ImageKit => Imagekit}/Models/Files/Metadata/MetadataGetParams.cs (95%) rename src/{ImageKit => Imagekit}/Models/Files/UpdateFileRequest.cs (96%) rename src/{ImageKit => Imagekit}/Models/Files/Versions/VersionDeleteParams.cs (95%) rename src/{ImageKit => Imagekit}/Models/Files/Versions/VersionDeleteResponse.cs (93%) rename src/{ImageKit => Imagekit}/Models/Files/Versions/VersionGetParams.cs (95%) rename src/{ImageKit => Imagekit}/Models/Files/Versions/VersionListParams.cs (95%) rename src/{ImageKit => Imagekit}/Models/Files/Versions/VersionRestoreParams.cs (95%) rename src/{ImageKit => Imagekit}/Models/Folders/FolderCopyParams.cs (96%) rename src/{ImageKit => Imagekit}/Models/Folders/FolderCopyResponse.cs (94%) rename src/{ImageKit => Imagekit}/Models/Folders/FolderCreateParams.cs (96%) rename src/{ImageKit => Imagekit}/Models/Folders/FolderCreateResponse.cs (93%) rename src/{ImageKit => Imagekit}/Models/Folders/FolderDeleteParams.cs (95%) rename src/{ImageKit => Imagekit}/Models/Folders/FolderDeleteResponse.cs (93%) rename src/{ImageKit => Imagekit}/Models/Folders/FolderMoveParams.cs (96%) rename src/{ImageKit => Imagekit}/Models/Folders/FolderMoveResponse.cs (94%) rename src/{ImageKit => Imagekit}/Models/Folders/FolderRenameParams.cs (96%) rename src/{ImageKit => Imagekit}/Models/Folders/FolderRenameResponse.cs (94%) rename src/{ImageKit => Imagekit}/Models/Folders/Job/JobGetParams.cs (95%) rename src/{ImageKit => Imagekit}/Models/Folders/Job/JobGetResponse.cs (83%) rename src/{ImageKit => Imagekit}/Models/GetImageAttributesOptions.cs (96%) rename src/{ImageKit => Imagekit}/Models/ImageOverlay.cs (96%) rename src/{ImageKit => Imagekit}/Models/Overlay.cs (96%) rename src/{ImageKit => Imagekit}/Models/OverlayPosition.cs (96%) rename src/{ImageKit => Imagekit}/Models/OverlayTiming.cs (96%) rename src/{ImageKit => Imagekit}/Models/ResponsiveImageAttributes.cs (95%) rename src/{ImageKit => Imagekit}/Models/SavedExtensions/SavedExtensionCreateParams.cs (95%) rename src/{ImageKit => Imagekit}/Models/SavedExtensions/SavedExtensionDeleteParams.cs (95%) rename src/{ImageKit => Imagekit}/Models/SavedExtensions/SavedExtensionGetParams.cs (95%) rename src/{ImageKit => Imagekit}/Models/SavedExtensions/SavedExtensionListParams.cs (95%) rename src/{ImageKit => Imagekit}/Models/SavedExtensions/SavedExtensionUpdateParams.cs (95%) rename src/{ImageKit => Imagekit}/Models/SharedSavedExtension.cs (94%) rename src/{ImageKit => Imagekit}/Models/SolidColorOverlay.cs (96%) rename src/{ImageKit => Imagekit}/Models/SolidColorOverlayTransformation.cs (96%) rename src/{ImageKit => Imagekit}/Models/SrcOptions.cs (96%) rename src/{ImageKit => Imagekit}/Models/StreamingResolution.cs (94%) rename src/{ImageKit => Imagekit}/Models/SubtitleOverlay.cs (96%) rename src/{ImageKit => Imagekit}/Models/SubtitleOverlayTransformation.cs (95%) rename src/{ImageKit => Imagekit}/Models/TextOverlay.cs (96%) rename src/{ImageKit => Imagekit}/Models/TextOverlayTransformation.cs (96%) rename src/{ImageKit => Imagekit}/Models/Transformation.cs (96%) rename src/{ImageKit => Imagekit}/Models/TransformationPosition.cs (93%) rename src/{ImageKit => Imagekit}/Models/UnnamedSchemaWithArrayParent0.cs (96%) rename src/{ImageKit => Imagekit}/Models/VideoOverlay.cs (96%) rename src/{ImageKit => Imagekit}/Models/Webhooks/BaseWebhookEvent.cs (93%) rename src/{ImageKit => Imagekit}/Models/Webhooks/FileCreateEvent.cs (87%) rename src/{ImageKit => Imagekit}/Models/Webhooks/FileDeleteEvent.cs (95%) rename src/{ImageKit => Imagekit}/Models/Webhooks/FileUpdateEvent.cs (94%) rename src/{ImageKit => Imagekit}/Models/Webhooks/FileVersionCreateEvent.cs (94%) rename src/{ImageKit => Imagekit}/Models/Webhooks/FileVersionDeleteEvent.cs (95%) rename src/{ImageKit => Imagekit}/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs (97%) rename src/{ImageKit => Imagekit}/Models/Webhooks/UnwrapWebhookEvent.cs (97%) rename src/{ImageKit => Imagekit}/Models/Webhooks/UploadPostTransformErrorEvent.cs (92%) rename src/{ImageKit => Imagekit}/Models/Webhooks/UploadPostTransformSuccessEvent.cs (96%) rename src/{ImageKit => Imagekit}/Models/Webhooks/UploadPreTransformErrorEvent.cs (96%) rename src/{ImageKit => Imagekit}/Models/Webhooks/UploadPreTransformSuccessEvent.cs (96%) rename src/{ImageKit => Imagekit}/Models/Webhooks/VideoTransformationAcceptedEvent.cs (96%) rename src/{ImageKit => Imagekit}/Models/Webhooks/VideoTransformationErrorEvent.cs (96%) rename src/{ImageKit => Imagekit}/Models/Webhooks/VideoTransformationReadyEvent.cs (96%) rename src/{ImageKit => Imagekit}/Services/AccountService.cs (93%) rename src/{ImageKit => Imagekit}/Services/Accounts/IOriginService.cs (95%) rename src/{ImageKit => Imagekit}/Services/Accounts/IUrlEndpointService.cs (95%) rename src/{ImageKit => Imagekit}/Services/Accounts/IUsageService.cs (92%) rename src/{ImageKit => Imagekit}/Services/Accounts/OriginService.cs (95%) rename src/{ImageKit => Imagekit}/Services/Accounts/UrlEndpointService.cs (95%) rename src/{ImageKit => Imagekit}/Services/Accounts/UsageService.cs (92%) rename src/{ImageKit => Imagekit}/Services/AssetService.cs (93%) rename src/{ImageKit => Imagekit}/Services/Beta/IV2Service.cs (90%) rename src/{ImageKit => Imagekit}/Services/Beta/V2/FileService.cs (93%) rename src/{ImageKit => Imagekit}/Services/Beta/V2/IFileService.cs (94%) rename src/{ImageKit => Imagekit}/Services/Beta/V2Service.cs (90%) rename src/{ImageKit => Imagekit}/Services/BetaService.cs (91%) rename src/{ImageKit => Imagekit}/Services/Cache/IInvalidationService.cs (94%) rename src/{ImageKit => Imagekit}/Services/Cache/InvalidationService.cs (94%) rename src/{ImageKit => Imagekit}/Services/CacheService.cs (92%) rename src/{ImageKit => Imagekit}/Services/CustomMetadataFieldService.cs (95%) rename src/{ImageKit => Imagekit}/Services/FileService.cs (95%) rename src/{ImageKit => Imagekit}/Services/Files/BulkService.cs (95%) rename src/{ImageKit => Imagekit}/Services/Files/IBulkService.cs (95%) rename src/{ImageKit => Imagekit}/Services/Files/IMetadataService.cs (93%) rename src/{ImageKit => Imagekit}/Services/Files/IVersionService.cs (95%) rename src/{ImageKit => Imagekit}/Services/Files/MetadataService.cs (93%) rename src/{ImageKit => Imagekit}/Services/Files/VersionService.cs (95%) rename src/{ImageKit => Imagekit}/Services/FolderService.cs (95%) rename src/{ImageKit => Imagekit}/Services/Folders/IJobService.cs (93%) rename src/{ImageKit => Imagekit}/Services/Folders/JobService.cs (93%) rename src/{ImageKit => Imagekit}/Services/IAccountService.cs (91%) rename src/{ImageKit => Imagekit}/Services/IAssetService.cs (93%) rename src/{ImageKit => Imagekit}/Services/IBetaService.cs (91%) rename src/{ImageKit => Imagekit}/Services/ICacheService.cs (91%) rename src/{ImageKit => Imagekit}/Services/ICustomMetadataFieldService.cs (96%) rename src/{ImageKit => Imagekit}/Services/IFileService.cs (96%) rename src/{ImageKit => Imagekit}/Services/IFolderService.cs (95%) rename src/{ImageKit => Imagekit}/Services/ISavedExtensionService.cs (95%) rename src/{ImageKit => Imagekit}/Services/IWebhookService.cs (93%) rename src/{ImageKit => Imagekit}/Services/SavedExtensionService.cs (95%) rename src/{ImageKit => Imagekit}/Services/WebhookService.cs (92%) rename src/{ImageKit => Imagekit}/Shims.cs (100%) diff --git a/.stats.yml b/.stats.yml index 278a536d..62ce5cf3 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc/imagekit-ad6dd3b4acf289708568a12574b997503059a47c4a4ca5ffefe64f40f3d3dbf3.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc/imagekit-a8f005109bd8f1fa42d080ed43b4f7b67eacad5aea113fe5223306c3f217556a.yml openapi_spec_hash: 7c103e2dff0edcbeea82057e62f58d4d -config_hash: 94f48fd13b7d41b8b6a203a3a8cee9ed +config_hash: 493cdeb6cf0935806c5f6a029774029d diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 23a511cd..c1a1bd76 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -20,7 +20,7 @@ modify the contents of the `examples/` directory. To use a local version of this library from source in another project, add it using a directory reference: ```sh -$ dotnet add reference /path/to/sdk/src/ImageKit +$ dotnet add reference /path/to/sdk/src/Imagekit ``` ## Formatting and linting diff --git a/ImageKit.sln b/Imagekit.sln similarity index 85% rename from ImageKit.sln rename to Imagekit.sln index 65ff0d6f..a0ecefd6 100644 --- a/ImageKit.sln +++ b/Imagekit.sln @@ -2,9 +2,9 @@ # Visual Studio Version 17 VisualStudioVersion = 17.0.31903.59 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageKit", "src\ImageKit\ImageKit.csproj", "{5816A0C1-3BA1-454E-8D08-85B23DEF309D}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Imagekit", "src\Imagekit\Imagekit.csproj", "{5816A0C1-3BA1-454E-8D08-85B23DEF309D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageKit.Tests", "src\ImageKit.Tests\ImageKit.Tests.csproj", "{0732C8A6-7313-4C33-AE2E-FFAA82EFB481}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Imagekit.Tests", "src\Imagekit.Tests\Imagekit.Tests.csproj", "{0732C8A6-7313-4C33-AE2E-FFAA82EFB481}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{93E58BA5-CEFE-447E-AC0C-F2C5BC4C411D}" ProjectSection(SolutionItems) = preProject diff --git a/README.md b/README.md index 124d940d..4fd8098c 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ The REST API documentation can be found on [imagekit.io](https://imagekit.io/doc ```bash git clone git@github.com:stainless-sdks/imagekit-csharp.git -dotnet add reference imagekit-csharp/src/ImageKit +dotnet add reference imagekit-csharp/src/Imagekit ``` ## Requirements @@ -22,8 +22,8 @@ See the [`examples`](examples) directory for complete and runnable examples. ```csharp using System; using System.Text; -using ImageKit; -using ImageKit.Models.Files; +using Imagekit; +using Imagekit.Models.Files; ImageKitClient client = new(); @@ -43,7 +43,7 @@ Console.WriteLine(response); Configure the client using environment variables: ```csharp -using ImageKit; +using Imagekit; // Configured using the IMAGEKIT_PRIVATE_KEY, OPTIONAL_IMAGEKIT_IGNORES_THIS, IMAGEKIT_WEBHOOK_SECRET and IMAGE_KIT_BASE_URL environment variables ImageKitClient client = new(); @@ -52,7 +52,7 @@ ImageKitClient client = new(); Or manually: ```csharp -using ImageKit; +using Imagekit; ImageKitClient client = new() { @@ -120,7 +120,7 @@ For non-streaming responses, you can deserialize the response into an instance o ```csharp using System; -using ImageKit.Models.Files; +using Imagekit.Models.Files; var response = await client.WithRawResponse.Files.Upload(parameters); FileUploadResponse deserialized = await response.Deserialize(); @@ -171,7 +171,7 @@ The API may also explicitly instruct the SDK to retry or not retry a request. To set a custom number of retries, configure the client using the `MaxRetries` method: ```csharp -using ImageKit; +using Imagekit; ImageKitClient client = new() { MaxRetries = 3 }; ``` @@ -198,7 +198,7 @@ To set a custom timeout, configure the client using the `Timeout` option: ```csharp using System; -using ImageKit; +using Imagekit; ImageKitClient client = new() { Timeout = TimeSpan.FromSeconds(42) }; ``` @@ -224,7 +224,7 @@ To route requests through a proxy, configure your client with a custom [`HttpCli ```csharp using System.Net; using System.Net.Http; -using ImageKit; +using Imagekit; var httpClient = new HttpClient ( @@ -248,8 +248,8 @@ To set undocumented parameters, a constructor exists that accepts dictionaries f ```csharp using System.Collections.Generic; using System.Text.Json; -using ImageKit.Core; -using ImageKit.Models.Files; +using Imagekit.Core; +using Imagekit.Models.Files; FileUploadParams parameters = new ( @@ -282,7 +282,7 @@ This can also be used to set a documented parameter to an undocumented or not ye ```csharp using System.Collections.Generic; using System.Text.Json; -using ImageKit.Models.Files; +using Imagekit.Models.Files; var parameters = FileUploadParams.FromRawUnchecked ( @@ -306,7 +306,7 @@ Undocumented properties, or undocumented values of documented properties, on nes ```csharp using System.Collections.Generic; using System.Text.Json; -using ImageKit.Models.Files; +using Imagekit.Models.Files; FileUploadParams parameters = new() { @@ -325,7 +325,7 @@ Required properties on the nested parameter can also be changed or omitted using ```csharp using System.Collections.Generic; using System.Text.Json; -using ImageKit.Models.Files; +using Imagekit.Models.Files; FileUploadParams parameters = new() { @@ -371,7 +371,7 @@ response.Validate(); Or configure the client using the `ResponseValidation` option: ```csharp -using ImageKit; +using Imagekit; ImageKitClient client = new() { ResponseValidation = true }; ``` diff --git a/src/ImageKit.Tests/Models/Accounts/Origins/OriginListParamsTest.cs b/src/ImageKit.Tests/Models/Accounts/Origins/OriginListParamsTest.cs deleted file mode 100644 index 775ccd44..00000000 --- a/src/ImageKit.Tests/Models/Accounts/Origins/OriginListParamsTest.cs +++ /dev/null @@ -1 +0,0 @@ -namespace ImageKit.Tests.Models.Accounts.Origins; diff --git a/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointListParamsTest.cs b/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointListParamsTest.cs deleted file mode 100644 index 3eac7fef..00000000 --- a/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointListParamsTest.cs +++ /dev/null @@ -1 +0,0 @@ -namespace ImageKit.Tests.Models.Accounts.UrlEndpoints; diff --git a/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionListParamsTest.cs b/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionListParamsTest.cs deleted file mode 100644 index 26d90cac..00000000 --- a/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionListParamsTest.cs +++ /dev/null @@ -1 +0,0 @@ -namespace ImageKit.Tests.Models.SavedExtensions; diff --git a/src/ImageKit.Tests/Core/JsonDictionaryTest.cs b/src/Imagekit.Tests/Core/JsonDictionaryTest.cs similarity index 95% rename from src/ImageKit.Tests/Core/JsonDictionaryTest.cs rename to src/Imagekit.Tests/Core/JsonDictionaryTest.cs index 45e37e97..ad185457 100644 --- a/src/ImageKit.Tests/Core/JsonDictionaryTest.cs +++ b/src/Imagekit.Tests/Core/JsonDictionaryTest.cs @@ -2,10 +2,10 @@ using System.Collections.Frozen; using System.Collections.Generic; using System.Text.Json; -using ImageKit.Core; -using ImageKit.Exceptions; +using Imagekit.Core; +using Imagekit.Exceptions; -namespace ImageKit.Tests.Core; +namespace Imagekit.Tests.Core; public class JsonDictionaryTest : TestBase { diff --git a/src/ImageKit.Tests/Core/MultipartJsonDictionaryTest.cs b/src/Imagekit.Tests/Core/MultipartJsonDictionaryTest.cs similarity index 95% rename from src/ImageKit.Tests/Core/MultipartJsonDictionaryTest.cs rename to src/Imagekit.Tests/Core/MultipartJsonDictionaryTest.cs index 8c5c130c..705ca35f 100644 --- a/src/ImageKit.Tests/Core/MultipartJsonDictionaryTest.cs +++ b/src/Imagekit.Tests/Core/MultipartJsonDictionaryTest.cs @@ -1,10 +1,10 @@ using System; using System.Collections.Frozen; using System.Collections.Generic; -using ImageKit.Core; -using ImageKit.Exceptions; +using Imagekit.Core; +using Imagekit.Exceptions; -namespace ImageKit.Tests.Core; +namespace Imagekit.Tests.Core; public class MultipartJsonDictionaryTest : TestBase { diff --git a/src/ImageKit.Tests/Core/MultipartJsonElementTest.cs b/src/Imagekit.Tests/Core/MultipartJsonElementTest.cs similarity index 96% rename from src/ImageKit.Tests/Core/MultipartJsonElementTest.cs rename to src/Imagekit.Tests/Core/MultipartJsonElementTest.cs index 9b09cd84..73545f05 100644 --- a/src/ImageKit.Tests/Core/MultipartJsonElementTest.cs +++ b/src/Imagekit.Tests/Core/MultipartJsonElementTest.cs @@ -1,9 +1,9 @@ using System.Collections.Generic; using System.Text; using System.Text.Json; -using ImageKit.Core; +using Imagekit.Core; -namespace ImageKit.Tests.Core; +namespace Imagekit.Tests.Core; public class MultipartJsonElementTest { diff --git a/src/ImageKit.Tests/ImageKit.Tests.csproj b/src/Imagekit.Tests/Imagekit.Tests.csproj similarity index 93% rename from src/ImageKit.Tests/ImageKit.Tests.csproj rename to src/Imagekit.Tests/Imagekit.Tests.csproj index 57d54f6e..d5c95e21 100644 --- a/src/ImageKit.Tests/ImageKit.Tests.csproj +++ b/src/Imagekit.Tests/Imagekit.Tests.csproj @@ -18,7 +18,7 @@ - + \ No newline at end of file diff --git a/src/ImageKit.Tests/Models/Accounts/Origins/OriginCreateParamsTest.cs b/src/Imagekit.Tests/Models/Accounts/Origins/OriginCreateParamsTest.cs similarity index 93% rename from src/ImageKit.Tests/Models/Accounts/Origins/OriginCreateParamsTest.cs rename to src/Imagekit.Tests/Models/Accounts/Origins/OriginCreateParamsTest.cs index 1f23bab3..9bba931b 100644 --- a/src/ImageKit.Tests/Models/Accounts/Origins/OriginCreateParamsTest.cs +++ b/src/Imagekit.Tests/Models/Accounts/Origins/OriginCreateParamsTest.cs @@ -1,7 +1,7 @@ using System; -using ImageKit.Models.Accounts.Origins; +using Imagekit.Models.Accounts.Origins; -namespace ImageKit.Tests.Models.Accounts.Origins; +namespace Imagekit.Tests.Models.Accounts.Origins; public class OriginCreateParamsTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Accounts/Origins/OriginDeleteParamsTest.cs b/src/Imagekit.Tests/Models/Accounts/Origins/OriginDeleteParamsTest.cs similarity index 86% rename from src/ImageKit.Tests/Models/Accounts/Origins/OriginDeleteParamsTest.cs rename to src/Imagekit.Tests/Models/Accounts/Origins/OriginDeleteParamsTest.cs index 25d61dee..7f5c61a1 100644 --- a/src/ImageKit.Tests/Models/Accounts/Origins/OriginDeleteParamsTest.cs +++ b/src/Imagekit.Tests/Models/Accounts/Origins/OriginDeleteParamsTest.cs @@ -1,7 +1,7 @@ using System; -using ImageKit.Models.Accounts.Origins; +using Imagekit.Models.Accounts.Origins; -namespace ImageKit.Tests.Models.Accounts.Origins; +namespace Imagekit.Tests.Models.Accounts.Origins; public class OriginDeleteParamsTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Accounts/Origins/OriginGetParamsTest.cs b/src/Imagekit.Tests/Models/Accounts/Origins/OriginGetParamsTest.cs similarity index 86% rename from src/ImageKit.Tests/Models/Accounts/Origins/OriginGetParamsTest.cs rename to src/Imagekit.Tests/Models/Accounts/Origins/OriginGetParamsTest.cs index 8abbdcea..8733b7f3 100644 --- a/src/ImageKit.Tests/Models/Accounts/Origins/OriginGetParamsTest.cs +++ b/src/Imagekit.Tests/Models/Accounts/Origins/OriginGetParamsTest.cs @@ -1,7 +1,7 @@ using System; -using ImageKit.Models.Accounts.Origins; +using Imagekit.Models.Accounts.Origins; -namespace ImageKit.Tests.Models.Accounts.Origins; +namespace Imagekit.Tests.Models.Accounts.Origins; public class OriginGetParamsTest : TestBase { diff --git a/src/Imagekit.Tests/Models/Accounts/Origins/OriginListParamsTest.cs b/src/Imagekit.Tests/Models/Accounts/Origins/OriginListParamsTest.cs new file mode 100644 index 00000000..a5690465 --- /dev/null +++ b/src/Imagekit.Tests/Models/Accounts/Origins/OriginListParamsTest.cs @@ -0,0 +1 @@ +namespace Imagekit.Tests.Models.Accounts.Origins; diff --git a/src/ImageKit.Tests/Models/Accounts/Origins/OriginRequestTest.cs b/src/Imagekit.Tests/Models/Accounts/Origins/OriginRequestTest.cs similarity index 97% rename from src/ImageKit.Tests/Models/Accounts/Origins/OriginRequestTest.cs rename to src/Imagekit.Tests/Models/Accounts/Origins/OriginRequestTest.cs index 724dd897..fb226ecf 100644 --- a/src/ImageKit.Tests/Models/Accounts/Origins/OriginRequestTest.cs +++ b/src/Imagekit.Tests/Models/Accounts/Origins/OriginRequestTest.cs @@ -1,8 +1,8 @@ using System.Text.Json; -using ImageKit.Core; -using ImageKit.Models.Accounts.Origins; +using Imagekit.Core; +using Imagekit.Models.Accounts.Origins; -namespace ImageKit.Tests.Models.Accounts.Origins; +namespace Imagekit.Tests.Models.Accounts.Origins; public class OriginRequestTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Accounts/Origins/OriginResponseTest.cs b/src/Imagekit.Tests/Models/Accounts/Origins/OriginResponseTest.cs similarity index 96% rename from src/ImageKit.Tests/Models/Accounts/Origins/OriginResponseTest.cs rename to src/Imagekit.Tests/Models/Accounts/Origins/OriginResponseTest.cs index 4d321a75..8f9e7720 100644 --- a/src/ImageKit.Tests/Models/Accounts/Origins/OriginResponseTest.cs +++ b/src/Imagekit.Tests/Models/Accounts/Origins/OriginResponseTest.cs @@ -1,8 +1,8 @@ using System.Text.Json; -using ImageKit.Core; -using ImageKit.Models.Accounts.Origins; +using Imagekit.Core; +using Imagekit.Models.Accounts.Origins; -namespace ImageKit.Tests.Models.Accounts.Origins; +namespace Imagekit.Tests.Models.Accounts.Origins; public class OriginResponseTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Accounts/Origins/OriginUpdateParamsTest.cs b/src/Imagekit.Tests/Models/Accounts/Origins/OriginUpdateParamsTest.cs similarity index 93% rename from src/ImageKit.Tests/Models/Accounts/Origins/OriginUpdateParamsTest.cs rename to src/Imagekit.Tests/Models/Accounts/Origins/OriginUpdateParamsTest.cs index c0d66ad5..8a287a05 100644 --- a/src/ImageKit.Tests/Models/Accounts/Origins/OriginUpdateParamsTest.cs +++ b/src/Imagekit.Tests/Models/Accounts/Origins/OriginUpdateParamsTest.cs @@ -1,7 +1,7 @@ using System; -using ImageKit.Models.Accounts.Origins; +using Imagekit.Models.Accounts.Origins; -namespace ImageKit.Tests.Models.Accounts.Origins; +namespace Imagekit.Tests.Models.Accounts.Origins; public class OriginUpdateParamsTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointCreateParamsTest.cs b/src/Imagekit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointCreateParamsTest.cs similarity index 95% rename from src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointCreateParamsTest.cs rename to src/Imagekit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointCreateParamsTest.cs index 9e04fce2..10b2002d 100644 --- a/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointCreateParamsTest.cs +++ b/src/Imagekit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointCreateParamsTest.cs @@ -1,11 +1,11 @@ using System; using System.Collections.Generic; using System.Text.Json; -using ImageKit.Core; -using ImageKit.Exceptions; -using ImageKit.Models.Accounts.UrlEndpoints; +using Imagekit.Core; +using Imagekit.Exceptions; +using Imagekit.Models.Accounts.UrlEndpoints; -namespace ImageKit.Tests.Models.Accounts.UrlEndpoints; +namespace Imagekit.Tests.Models.Accounts.UrlEndpoints; public class UrlEndpointCreateParamsTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointDeleteParamsTest.cs b/src/Imagekit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointDeleteParamsTest.cs similarity index 86% rename from src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointDeleteParamsTest.cs rename to src/Imagekit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointDeleteParamsTest.cs index 2fd7c37c..576af984 100644 --- a/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointDeleteParamsTest.cs +++ b/src/Imagekit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointDeleteParamsTest.cs @@ -1,7 +1,7 @@ using System; -using ImageKit.Models.Accounts.UrlEndpoints; +using Imagekit.Models.Accounts.UrlEndpoints; -namespace ImageKit.Tests.Models.Accounts.UrlEndpoints; +namespace Imagekit.Tests.Models.Accounts.UrlEndpoints; public class UrlEndpointDeleteParamsTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointGetParamsTest.cs b/src/Imagekit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointGetParamsTest.cs similarity index 86% rename from src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointGetParamsTest.cs rename to src/Imagekit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointGetParamsTest.cs index 32457d84..9a36e40e 100644 --- a/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointGetParamsTest.cs +++ b/src/Imagekit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointGetParamsTest.cs @@ -1,7 +1,7 @@ using System; -using ImageKit.Models.Accounts.UrlEndpoints; +using Imagekit.Models.Accounts.UrlEndpoints; -namespace ImageKit.Tests.Models.Accounts.UrlEndpoints; +namespace Imagekit.Tests.Models.Accounts.UrlEndpoints; public class UrlEndpointGetParamsTest : TestBase { diff --git a/src/Imagekit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointListParamsTest.cs b/src/Imagekit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointListParamsTest.cs new file mode 100644 index 00000000..8e3ae6d0 --- /dev/null +++ b/src/Imagekit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointListParamsTest.cs @@ -0,0 +1 @@ +namespace Imagekit.Tests.Models.Accounts.UrlEndpoints; diff --git a/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointRequestTest.cs b/src/Imagekit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointRequestTest.cs similarity index 96% rename from src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointRequestTest.cs rename to src/Imagekit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointRequestTest.cs index 53af2b8d..c8fe9ffe 100644 --- a/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointRequestTest.cs +++ b/src/Imagekit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointRequestTest.cs @@ -1,10 +1,10 @@ using System.Collections.Generic; using System.Text.Json; -using ImageKit.Core; -using ImageKit.Exceptions; -using ImageKit.Models.Accounts.UrlEndpoints; +using Imagekit.Core; +using Imagekit.Exceptions; +using Imagekit.Models.Accounts.UrlEndpoints; -namespace ImageKit.Tests.Models.Accounts.UrlEndpoints; +namespace Imagekit.Tests.Models.Accounts.UrlEndpoints; public class UrlEndpointRequestTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointResponseTest.cs b/src/Imagekit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointResponseTest.cs similarity index 96% rename from src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointResponseTest.cs rename to src/Imagekit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointResponseTest.cs index a55dec1a..efd7dc2d 100644 --- a/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointResponseTest.cs +++ b/src/Imagekit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointResponseTest.cs @@ -1,10 +1,10 @@ using System.Collections.Generic; using System.Text.Json; -using ImageKit.Core; -using ImageKit.Exceptions; -using ImageKit.Models.Accounts.UrlEndpoints; +using Imagekit.Core; +using Imagekit.Exceptions; +using Imagekit.Models.Accounts.UrlEndpoints; -namespace ImageKit.Tests.Models.Accounts.UrlEndpoints; +namespace Imagekit.Tests.Models.Accounts.UrlEndpoints; public class UrlEndpointResponseTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParamsTest.cs b/src/Imagekit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParamsTest.cs similarity index 95% rename from src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParamsTest.cs rename to src/Imagekit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParamsTest.cs index 63fdfdbc..0ac9405b 100644 --- a/src/ImageKit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParamsTest.cs +++ b/src/Imagekit.Tests/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParamsTest.cs @@ -1,11 +1,11 @@ using System; using System.Collections.Generic; using System.Text.Json; -using ImageKit.Core; -using ImageKit.Exceptions; -using ImageKit.Models.Accounts.UrlEndpoints; +using Imagekit.Core; +using Imagekit.Exceptions; +using Imagekit.Models.Accounts.UrlEndpoints; -namespace ImageKit.Tests.Models.Accounts.UrlEndpoints; +namespace Imagekit.Tests.Models.Accounts.UrlEndpoints; public class UrlEndpointUpdateParamsTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Accounts/Usage/UsageGetParamsTest.cs b/src/Imagekit.Tests/Models/Accounts/Usage/UsageGetParamsTest.cs similarity index 90% rename from src/ImageKit.Tests/Models/Accounts/Usage/UsageGetParamsTest.cs rename to src/Imagekit.Tests/Models/Accounts/Usage/UsageGetParamsTest.cs index 89c48fc7..d27db510 100644 --- a/src/ImageKit.Tests/Models/Accounts/Usage/UsageGetParamsTest.cs +++ b/src/Imagekit.Tests/Models/Accounts/Usage/UsageGetParamsTest.cs @@ -1,7 +1,7 @@ using System; -using ImageKit.Models.Accounts.Usage; +using Imagekit.Models.Accounts.Usage; -namespace ImageKit.Tests.Models.Accounts.Usage; +namespace Imagekit.Tests.Models.Accounts.Usage; public class UsageGetParamsTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Accounts/Usage/UsageGetResponseTest.cs b/src/Imagekit.Tests/Models/Accounts/Usage/UsageGetResponseTest.cs similarity index 95% rename from src/ImageKit.Tests/Models/Accounts/Usage/UsageGetResponseTest.cs rename to src/Imagekit.Tests/Models/Accounts/Usage/UsageGetResponseTest.cs index 50dd64d8..584f1962 100644 --- a/src/ImageKit.Tests/Models/Accounts/Usage/UsageGetResponseTest.cs +++ b/src/Imagekit.Tests/Models/Accounts/Usage/UsageGetResponseTest.cs @@ -1,8 +1,8 @@ using System.Text.Json; -using ImageKit.Core; -using ImageKit.Models.Accounts.Usage; +using Imagekit.Core; +using Imagekit.Models.Accounts.Usage; -namespace ImageKit.Tests.Models.Accounts.Usage; +namespace Imagekit.Tests.Models.Accounts.Usage; public class UsageGetResponseTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Assets/AssetListParamsTest.cs b/src/Imagekit.Tests/Models/Assets/AssetListParamsTest.cs similarity index 96% rename from src/ImageKit.Tests/Models/Assets/AssetListParamsTest.cs rename to src/Imagekit.Tests/Models/Assets/AssetListParamsTest.cs index c81eb7b3..e9c5c555 100644 --- a/src/ImageKit.Tests/Models/Assets/AssetListParamsTest.cs +++ b/src/Imagekit.Tests/Models/Assets/AssetListParamsTest.cs @@ -1,10 +1,10 @@ using System; using System.Text.Json; -using ImageKit.Core; -using ImageKit.Exceptions; -using Assets = ImageKit.Models.Assets; +using Imagekit.Core; +using Imagekit.Exceptions; +using Assets = Imagekit.Models.Assets; -namespace ImageKit.Tests.Models.Assets; +namespace Imagekit.Tests.Models.Assets; public class AssetListParamsTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Assets/AssetListResponseTest.cs b/src/Imagekit.Tests/Models/Assets/AssetListResponseTest.cs similarity index 95% rename from src/ImageKit.Tests/Models/Assets/AssetListResponseTest.cs rename to src/Imagekit.Tests/Models/Assets/AssetListResponseTest.cs index b517da39..f3447545 100644 --- a/src/ImageKit.Tests/Models/Assets/AssetListResponseTest.cs +++ b/src/Imagekit.Tests/Models/Assets/AssetListResponseTest.cs @@ -1,11 +1,11 @@ using System; using System.Collections.Generic; using System.Text.Json; -using ImageKit.Core; -using ImageKit.Models.Assets; -using Files = ImageKit.Models.Files; +using Imagekit.Core; +using Imagekit.Models.Assets; +using Files = Imagekit.Models.Files; -namespace ImageKit.Tests.Models.Assets; +namespace Imagekit.Tests.Models.Assets; public class AssetListResponseTest : TestBase { diff --git a/src/ImageKit.Tests/Models/BaseOverlayTest.cs b/src/Imagekit.Tests/Models/BaseOverlayTest.cs similarity index 95% rename from src/ImageKit.Tests/Models/BaseOverlayTest.cs rename to src/Imagekit.Tests/Models/BaseOverlayTest.cs index 03fa60af..6f0383dc 100644 --- a/src/ImageKit.Tests/Models/BaseOverlayTest.cs +++ b/src/Imagekit.Tests/Models/BaseOverlayTest.cs @@ -1,9 +1,9 @@ using System.Text.Json; -using ImageKit.Core; -using ImageKit.Exceptions; -using ImageKit.Models; +using Imagekit.Core; +using Imagekit.Exceptions; +using Imagekit.Models; -namespace ImageKit.Tests.Models; +namespace Imagekit.Tests.Models; public class BaseOverlayTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Beta/V2/Files/FileUploadParamsTest.cs b/src/Imagekit.Tests/Models/Beta/V2/Files/FileUploadParamsTest.cs similarity index 96% rename from src/ImageKit.Tests/Models/Beta/V2/Files/FileUploadParamsTest.cs rename to src/Imagekit.Tests/Models/Beta/V2/Files/FileUploadParamsTest.cs index ce314fff..19cfcc0c 100644 --- a/src/ImageKit.Tests/Models/Beta/V2/Files/FileUploadParamsTest.cs +++ b/src/Imagekit.Tests/Models/Beta/V2/Files/FileUploadParamsTest.cs @@ -2,12 +2,12 @@ using System.Collections.Generic; using System.Text; using System.Text.Json; -using ImageKit.Core; -using ImageKit.Exceptions; -using ImageKit.Models.Beta.V2.Files; -using Models = ImageKit.Models; +using Imagekit.Core; +using Imagekit.Exceptions; +using Imagekit.Models.Beta.V2.Files; +using Models = Imagekit.Models; -namespace ImageKit.Tests.Models.Beta.V2.Files; +namespace Imagekit.Tests.Models.Beta.V2.Files; public class FileUploadParamsTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Beta/V2/Files/FileUploadResponseTest.cs b/src/Imagekit.Tests/Models/Beta/V2/Files/FileUploadResponseTest.cs similarity index 97% rename from src/ImageKit.Tests/Models/Beta/V2/Files/FileUploadResponseTest.cs rename to src/Imagekit.Tests/Models/Beta/V2/Files/FileUploadResponseTest.cs index 6588cc9f..de103af1 100644 --- a/src/ImageKit.Tests/Models/Beta/V2/Files/FileUploadResponseTest.cs +++ b/src/Imagekit.Tests/Models/Beta/V2/Files/FileUploadResponseTest.cs @@ -1,11 +1,11 @@ using System.Collections.Generic; using System.Text.Json; -using ImageKit.Core; -using ImageKit.Exceptions; -using ImageKit.Models.Beta.V2.Files; -using Files = ImageKit.Models.Files; +using Imagekit.Core; +using Imagekit.Exceptions; +using Imagekit.Models.Beta.V2.Files; +using Files = Imagekit.Models.Files; -namespace ImageKit.Tests.Models.Beta.V2.Files; +namespace Imagekit.Tests.Models.Beta.V2.Files; public class FileUploadResponseTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationCreateParamsTest.cs b/src/Imagekit.Tests/Models/Cache/Invalidation/InvalidationCreateParamsTest.cs similarity index 89% rename from src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationCreateParamsTest.cs rename to src/Imagekit.Tests/Models/Cache/Invalidation/InvalidationCreateParamsTest.cs index 001f2d69..f3fe4260 100644 --- a/src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationCreateParamsTest.cs +++ b/src/Imagekit.Tests/Models/Cache/Invalidation/InvalidationCreateParamsTest.cs @@ -1,7 +1,7 @@ using System; -using ImageKit.Models.Cache.Invalidation; +using Imagekit.Models.Cache.Invalidation; -namespace ImageKit.Tests.Models.Cache.Invalidation; +namespace Imagekit.Tests.Models.Cache.Invalidation; public class InvalidationCreateParamsTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationCreateResponseTest.cs b/src/Imagekit.Tests/Models/Cache/Invalidation/InvalidationCreateResponseTest.cs similarity index 92% rename from src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationCreateResponseTest.cs rename to src/Imagekit.Tests/Models/Cache/Invalidation/InvalidationCreateResponseTest.cs index 6276f333..08f67e6b 100644 --- a/src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationCreateResponseTest.cs +++ b/src/Imagekit.Tests/Models/Cache/Invalidation/InvalidationCreateResponseTest.cs @@ -1,8 +1,8 @@ using System.Text.Json; -using ImageKit.Core; -using ImageKit.Models.Cache.Invalidation; +using Imagekit.Core; +using Imagekit.Models.Cache.Invalidation; -namespace ImageKit.Tests.Models.Cache.Invalidation; +namespace Imagekit.Tests.Models.Cache.Invalidation; public class InvalidationCreateResponseTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationGetParamsTest.cs b/src/Imagekit.Tests/Models/Cache/Invalidation/InvalidationGetParamsTest.cs similarity index 87% rename from src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationGetParamsTest.cs rename to src/Imagekit.Tests/Models/Cache/Invalidation/InvalidationGetParamsTest.cs index 3cd3f946..5d33a03b 100644 --- a/src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationGetParamsTest.cs +++ b/src/Imagekit.Tests/Models/Cache/Invalidation/InvalidationGetParamsTest.cs @@ -1,7 +1,7 @@ using System; -using ImageKit.Models.Cache.Invalidation; +using Imagekit.Models.Cache.Invalidation; -namespace ImageKit.Tests.Models.Cache.Invalidation; +namespace Imagekit.Tests.Models.Cache.Invalidation; public class InvalidationGetParamsTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationGetResponseTest.cs b/src/Imagekit.Tests/Models/Cache/Invalidation/InvalidationGetResponseTest.cs similarity index 93% rename from src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationGetResponseTest.cs rename to src/Imagekit.Tests/Models/Cache/Invalidation/InvalidationGetResponseTest.cs index fe4e6a01..5d8b540f 100644 --- a/src/ImageKit.Tests/Models/Cache/Invalidation/InvalidationGetResponseTest.cs +++ b/src/Imagekit.Tests/Models/Cache/Invalidation/InvalidationGetResponseTest.cs @@ -1,9 +1,9 @@ using System.Text.Json; -using ImageKit.Core; -using ImageKit.Exceptions; -using ImageKit.Models.Cache.Invalidation; +using Imagekit.Core; +using Imagekit.Exceptions; +using Imagekit.Models.Cache.Invalidation; -namespace ImageKit.Tests.Models.Cache.Invalidation; +namespace Imagekit.Tests.Models.Cache.Invalidation; public class InvalidationGetResponseTest : TestBase { diff --git a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsTest.cs b/src/Imagekit.Tests/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsTest.cs similarity index 96% rename from src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsTest.cs rename to src/Imagekit.Tests/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsTest.cs index 8ceb8b85..68fb4fa3 100644 --- a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsTest.cs +++ b/src/Imagekit.Tests/Models/CustomMetadataFields/CustomMetadataFieldCreateParamsTest.cs @@ -1,11 +1,11 @@ using System; using System.Collections.Generic; using System.Text.Json; -using ImageKit.Core; -using ImageKit.Exceptions; -using CustomMetadataFields = ImageKit.Models.CustomMetadataFields; +using Imagekit.Core; +using Imagekit.Exceptions; +using CustomMetadataFields = Imagekit.Models.CustomMetadataFields; -namespace ImageKit.Tests.Models.CustomMetadataFields; +namespace Imagekit.Tests.Models.CustomMetadataFields; public class CustomMetadataFieldCreateParamsTest : TestBase { diff --git a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldDeleteParamsTest.cs b/src/Imagekit.Tests/Models/CustomMetadataFields/CustomMetadataFieldDeleteParamsTest.cs similarity index 86% rename from src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldDeleteParamsTest.cs rename to src/Imagekit.Tests/Models/CustomMetadataFields/CustomMetadataFieldDeleteParamsTest.cs index 03b17b5e..f55ac27c 100644 --- a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldDeleteParamsTest.cs +++ b/src/Imagekit.Tests/Models/CustomMetadataFields/CustomMetadataFieldDeleteParamsTest.cs @@ -1,7 +1,7 @@ using System; -using ImageKit.Models.CustomMetadataFields; +using Imagekit.Models.CustomMetadataFields; -namespace ImageKit.Tests.Models.CustomMetadataFields; +namespace Imagekit.Tests.Models.CustomMetadataFields; public class CustomMetadataFieldDeleteParamsTest : TestBase { diff --git a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldDeleteResponseTest.cs b/src/Imagekit.Tests/Models/CustomMetadataFields/CustomMetadataFieldDeleteResponseTest.cs similarity index 89% rename from src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldDeleteResponseTest.cs rename to src/Imagekit.Tests/Models/CustomMetadataFields/CustomMetadataFieldDeleteResponseTest.cs index 43f35106..355807b5 100644 --- a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldDeleteResponseTest.cs +++ b/src/Imagekit.Tests/Models/CustomMetadataFields/CustomMetadataFieldDeleteResponseTest.cs @@ -1,8 +1,8 @@ using System.Text.Json; -using ImageKit.Core; -using ImageKit.Models.CustomMetadataFields; +using Imagekit.Core; +using Imagekit.Models.CustomMetadataFields; -namespace ImageKit.Tests.Models.CustomMetadataFields; +namespace Imagekit.Tests.Models.CustomMetadataFields; public class CustomMetadataFieldDeleteResponseTest : TestBase { diff --git a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldListParamsTest.cs b/src/Imagekit.Tests/Models/CustomMetadataFields/CustomMetadataFieldListParamsTest.cs similarity index 92% rename from src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldListParamsTest.cs rename to src/Imagekit.Tests/Models/CustomMetadataFields/CustomMetadataFieldListParamsTest.cs index 86cd2d8e..63cf7617 100644 --- a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldListParamsTest.cs +++ b/src/Imagekit.Tests/Models/CustomMetadataFields/CustomMetadataFieldListParamsTest.cs @@ -1,7 +1,7 @@ using System; -using ImageKit.Models.CustomMetadataFields; +using Imagekit.Models.CustomMetadataFields; -namespace ImageKit.Tests.Models.CustomMetadataFields; +namespace Imagekit.Tests.Models.CustomMetadataFields; public class CustomMetadataFieldListParamsTest : TestBase { diff --git a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldTest.cs b/src/Imagekit.Tests/Models/CustomMetadataFields/CustomMetadataFieldTest.cs similarity index 96% rename from src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldTest.cs rename to src/Imagekit.Tests/Models/CustomMetadataFields/CustomMetadataFieldTest.cs index 51098ace..adc8d707 100644 --- a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldTest.cs +++ b/src/Imagekit.Tests/Models/CustomMetadataFields/CustomMetadataFieldTest.cs @@ -1,10 +1,10 @@ using System.Collections.Generic; using System.Text.Json; -using ImageKit.Core; -using ImageKit.Exceptions; -using ImageKit.Models.CustomMetadataFields; +using Imagekit.Core; +using Imagekit.Exceptions; +using Imagekit.Models.CustomMetadataFields; -namespace ImageKit.Tests.Models.CustomMetadataFields; +namespace Imagekit.Tests.Models.CustomMetadataFields; public class CustomMetadataFieldTest : TestBase { diff --git a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsTest.cs b/src/Imagekit.Tests/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsTest.cs similarity index 96% rename from src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsTest.cs rename to src/Imagekit.Tests/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsTest.cs index 26218957..26dbc490 100644 --- a/src/ImageKit.Tests/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsTest.cs +++ b/src/Imagekit.Tests/Models/CustomMetadataFields/CustomMetadataFieldUpdateParamsTest.cs @@ -1,10 +1,10 @@ using System; using System.Collections.Generic; using System.Text.Json; -using ImageKit.Core; -using ImageKit.Models.CustomMetadataFields; +using Imagekit.Core; +using Imagekit.Models.CustomMetadataFields; -namespace ImageKit.Tests.Models.CustomMetadataFields; +namespace Imagekit.Tests.Models.CustomMetadataFields; public class CustomMetadataFieldUpdateParamsTest : TestBase { diff --git a/src/ImageKit.Tests/Models/ExtensionConfigTest.cs b/src/Imagekit.Tests/Models/ExtensionConfigTest.cs similarity index 96% rename from src/ImageKit.Tests/Models/ExtensionConfigTest.cs rename to src/Imagekit.Tests/Models/ExtensionConfigTest.cs index 3fbb1f11..9e825d37 100644 --- a/src/ImageKit.Tests/Models/ExtensionConfigTest.cs +++ b/src/Imagekit.Tests/Models/ExtensionConfigTest.cs @@ -1,10 +1,10 @@ using System.Collections.Generic; using System.Text.Json; -using ImageKit.Core; -using ImageKit.Exceptions; -using ImageKit.Models; +using Imagekit.Core; +using Imagekit.Exceptions; +using Imagekit.Models; -namespace ImageKit.Tests.Models; +namespace Imagekit.Tests.Models; public class ExtensionConfigTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Files/Bulk/BulkAddTagsParamsTest.cs b/src/Imagekit.Tests/Models/Files/Bulk/BulkAddTagsParamsTest.cs similarity index 92% rename from src/ImageKit.Tests/Models/Files/Bulk/BulkAddTagsParamsTest.cs rename to src/Imagekit.Tests/Models/Files/Bulk/BulkAddTagsParamsTest.cs index ea19f998..360fea0c 100644 --- a/src/ImageKit.Tests/Models/Files/Bulk/BulkAddTagsParamsTest.cs +++ b/src/Imagekit.Tests/Models/Files/Bulk/BulkAddTagsParamsTest.cs @@ -1,8 +1,8 @@ using System; using System.Collections.Generic; -using ImageKit.Models.Files.Bulk; +using Imagekit.Models.Files.Bulk; -namespace ImageKit.Tests.Models.Files.Bulk; +namespace Imagekit.Tests.Models.Files.Bulk; public class BulkAddTagsParamsTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Files/Bulk/BulkAddTagsResponseTest.cs b/src/Imagekit.Tests/Models/Files/Bulk/BulkAddTagsResponseTest.cs similarity index 94% rename from src/ImageKit.Tests/Models/Files/Bulk/BulkAddTagsResponseTest.cs rename to src/Imagekit.Tests/Models/Files/Bulk/BulkAddTagsResponseTest.cs index 04a9a306..493b50a2 100644 --- a/src/ImageKit.Tests/Models/Files/Bulk/BulkAddTagsResponseTest.cs +++ b/src/Imagekit.Tests/Models/Files/Bulk/BulkAddTagsResponseTest.cs @@ -1,9 +1,9 @@ using System.Collections.Generic; using System.Text.Json; -using ImageKit.Core; -using ImageKit.Models.Files.Bulk; +using Imagekit.Core; +using Imagekit.Models.Files.Bulk; -namespace ImageKit.Tests.Models.Files.Bulk; +namespace Imagekit.Tests.Models.Files.Bulk; public class BulkAddTagsResponseTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Files/Bulk/BulkDeleteParamsTest.cs b/src/Imagekit.Tests/Models/Files/Bulk/BulkDeleteParamsTest.cs similarity index 91% rename from src/ImageKit.Tests/Models/Files/Bulk/BulkDeleteParamsTest.cs rename to src/Imagekit.Tests/Models/Files/Bulk/BulkDeleteParamsTest.cs index 837c4b9d..a06cf8ad 100644 --- a/src/ImageKit.Tests/Models/Files/Bulk/BulkDeleteParamsTest.cs +++ b/src/Imagekit.Tests/Models/Files/Bulk/BulkDeleteParamsTest.cs @@ -1,8 +1,8 @@ using System; using System.Collections.Generic; -using ImageKit.Models.Files.Bulk; +using Imagekit.Models.Files.Bulk; -namespace ImageKit.Tests.Models.Files.Bulk; +namespace Imagekit.Tests.Models.Files.Bulk; public class BulkDeleteParamsTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Files/Bulk/BulkDeleteResponseTest.cs b/src/Imagekit.Tests/Models/Files/Bulk/BulkDeleteResponseTest.cs similarity index 94% rename from src/ImageKit.Tests/Models/Files/Bulk/BulkDeleteResponseTest.cs rename to src/Imagekit.Tests/Models/Files/Bulk/BulkDeleteResponseTest.cs index f3592a5c..710c28aa 100644 --- a/src/ImageKit.Tests/Models/Files/Bulk/BulkDeleteResponseTest.cs +++ b/src/Imagekit.Tests/Models/Files/Bulk/BulkDeleteResponseTest.cs @@ -1,9 +1,9 @@ using System.Collections.Generic; using System.Text.Json; -using ImageKit.Core; -using ImageKit.Models.Files.Bulk; +using Imagekit.Core; +using Imagekit.Models.Files.Bulk; -namespace ImageKit.Tests.Models.Files.Bulk; +namespace Imagekit.Tests.Models.Files.Bulk; public class BulkDeleteResponseTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveAITagsParamsTest.cs b/src/Imagekit.Tests/Models/Files/Bulk/BulkRemoveAITagsParamsTest.cs similarity index 92% rename from src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveAITagsParamsTest.cs rename to src/Imagekit.Tests/Models/Files/Bulk/BulkRemoveAITagsParamsTest.cs index cd052204..ec8fcfd8 100644 --- a/src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveAITagsParamsTest.cs +++ b/src/Imagekit.Tests/Models/Files/Bulk/BulkRemoveAITagsParamsTest.cs @@ -1,8 +1,8 @@ using System; using System.Collections.Generic; -using ImageKit.Models.Files.Bulk; +using Imagekit.Models.Files.Bulk; -namespace ImageKit.Tests.Models.Files.Bulk; +namespace Imagekit.Tests.Models.Files.Bulk; public class BulkRemoveAITagsParamsTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveAITagsResponseTest.cs b/src/Imagekit.Tests/Models/Files/Bulk/BulkRemoveAITagsResponseTest.cs similarity index 94% rename from src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveAITagsResponseTest.cs rename to src/Imagekit.Tests/Models/Files/Bulk/BulkRemoveAITagsResponseTest.cs index 495618da..ed0100fd 100644 --- a/src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveAITagsResponseTest.cs +++ b/src/Imagekit.Tests/Models/Files/Bulk/BulkRemoveAITagsResponseTest.cs @@ -1,9 +1,9 @@ using System.Collections.Generic; using System.Text.Json; -using ImageKit.Core; -using ImageKit.Models.Files.Bulk; +using Imagekit.Core; +using Imagekit.Models.Files.Bulk; -namespace ImageKit.Tests.Models.Files.Bulk; +namespace Imagekit.Tests.Models.Files.Bulk; public class BulkRemoveAITagsResponseTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveTagsParamsTest.cs b/src/Imagekit.Tests/Models/Files/Bulk/BulkRemoveTagsParamsTest.cs similarity index 92% rename from src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveTagsParamsTest.cs rename to src/Imagekit.Tests/Models/Files/Bulk/BulkRemoveTagsParamsTest.cs index 1a8a5d99..78171036 100644 --- a/src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveTagsParamsTest.cs +++ b/src/Imagekit.Tests/Models/Files/Bulk/BulkRemoveTagsParamsTest.cs @@ -1,8 +1,8 @@ using System; using System.Collections.Generic; -using ImageKit.Models.Files.Bulk; +using Imagekit.Models.Files.Bulk; -namespace ImageKit.Tests.Models.Files.Bulk; +namespace Imagekit.Tests.Models.Files.Bulk; public class BulkRemoveTagsParamsTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveTagsResponseTest.cs b/src/Imagekit.Tests/Models/Files/Bulk/BulkRemoveTagsResponseTest.cs similarity index 94% rename from src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveTagsResponseTest.cs rename to src/Imagekit.Tests/Models/Files/Bulk/BulkRemoveTagsResponseTest.cs index 49816be4..6592db32 100644 --- a/src/ImageKit.Tests/Models/Files/Bulk/BulkRemoveTagsResponseTest.cs +++ b/src/Imagekit.Tests/Models/Files/Bulk/BulkRemoveTagsResponseTest.cs @@ -1,9 +1,9 @@ using System.Collections.Generic; using System.Text.Json; -using ImageKit.Core; -using ImageKit.Models.Files.Bulk; +using Imagekit.Core; +using Imagekit.Models.Files.Bulk; -namespace ImageKit.Tests.Models.Files.Bulk; +namespace Imagekit.Tests.Models.Files.Bulk; public class BulkRemoveTagsResponseTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Files/FileCopyParamsTest.cs b/src/Imagekit.Tests/Models/Files/FileCopyParamsTest.cs similarity index 94% rename from src/ImageKit.Tests/Models/Files/FileCopyParamsTest.cs rename to src/Imagekit.Tests/Models/Files/FileCopyParamsTest.cs index c55eb81d..6bbfc391 100644 --- a/src/ImageKit.Tests/Models/Files/FileCopyParamsTest.cs +++ b/src/Imagekit.Tests/Models/Files/FileCopyParamsTest.cs @@ -1,7 +1,7 @@ using System; -using ImageKit.Models.Files; +using Imagekit.Models.Files; -namespace ImageKit.Tests.Models.Files; +namespace Imagekit.Tests.Models.Files; public class FileCopyParamsTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Files/FileCopyResponseTest.cs b/src/Imagekit.Tests/Models/Files/FileCopyResponseTest.cs similarity index 89% rename from src/ImageKit.Tests/Models/Files/FileCopyResponseTest.cs rename to src/Imagekit.Tests/Models/Files/FileCopyResponseTest.cs index b13c67e6..01cada79 100644 --- a/src/ImageKit.Tests/Models/Files/FileCopyResponseTest.cs +++ b/src/Imagekit.Tests/Models/Files/FileCopyResponseTest.cs @@ -1,8 +1,8 @@ using System.Text.Json; -using ImageKit.Core; -using ImageKit.Models.Files; +using Imagekit.Core; +using Imagekit.Models.Files; -namespace ImageKit.Tests.Models.Files; +namespace Imagekit.Tests.Models.Files; public class FileCopyResponseTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Files/FileDeleteParamsTest.cs b/src/Imagekit.Tests/Models/Files/FileDeleteParamsTest.cs similarity index 88% rename from src/ImageKit.Tests/Models/Files/FileDeleteParamsTest.cs rename to src/Imagekit.Tests/Models/Files/FileDeleteParamsTest.cs index 7d538015..d01b71ec 100644 --- a/src/ImageKit.Tests/Models/Files/FileDeleteParamsTest.cs +++ b/src/Imagekit.Tests/Models/Files/FileDeleteParamsTest.cs @@ -1,7 +1,7 @@ using System; -using ImageKit.Models.Files; +using Imagekit.Models.Files; -namespace ImageKit.Tests.Models.Files; +namespace Imagekit.Tests.Models.Files; public class FileDeleteParamsTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Files/FileGetParamsTest.cs b/src/Imagekit.Tests/Models/Files/FileGetParamsTest.cs similarity index 88% rename from src/ImageKit.Tests/Models/Files/FileGetParamsTest.cs rename to src/Imagekit.Tests/Models/Files/FileGetParamsTest.cs index 184e80ce..0cea1d34 100644 --- a/src/ImageKit.Tests/Models/Files/FileGetParamsTest.cs +++ b/src/Imagekit.Tests/Models/Files/FileGetParamsTest.cs @@ -1,7 +1,7 @@ using System; -using ImageKit.Models.Files; +using Imagekit.Models.Files; -namespace ImageKit.Tests.Models.Files; +namespace Imagekit.Tests.Models.Files; public class FileGetParamsTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Files/FileMetadataTest.cs b/src/Imagekit.Tests/Models/Files/FileMetadataTest.cs similarity index 97% rename from src/ImageKit.Tests/Models/Files/FileMetadataTest.cs rename to src/Imagekit.Tests/Models/Files/FileMetadataTest.cs index a81fec89..a296b95d 100644 --- a/src/ImageKit.Tests/Models/Files/FileMetadataTest.cs +++ b/src/Imagekit.Tests/Models/Files/FileMetadataTest.cs @@ -1,9 +1,9 @@ using System.Collections.Generic; using System.Text.Json; -using ImageKit.Core; -using ImageKit.Models.Files; +using Imagekit.Core; +using Imagekit.Models.Files; -namespace ImageKit.Tests.Models.Files; +namespace Imagekit.Tests.Models.Files; public class FileMetadataTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Files/FileMoveParamsTest.cs b/src/Imagekit.Tests/Models/Files/FileMoveParamsTest.cs similarity index 91% rename from src/ImageKit.Tests/Models/Files/FileMoveParamsTest.cs rename to src/Imagekit.Tests/Models/Files/FileMoveParamsTest.cs index 3953c9a8..37fee500 100644 --- a/src/ImageKit.Tests/Models/Files/FileMoveParamsTest.cs +++ b/src/Imagekit.Tests/Models/Files/FileMoveParamsTest.cs @@ -1,7 +1,7 @@ using System; -using ImageKit.Models.Files; +using Imagekit.Models.Files; -namespace ImageKit.Tests.Models.Files; +namespace Imagekit.Tests.Models.Files; public class FileMoveParamsTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Files/FileMoveResponseTest.cs b/src/Imagekit.Tests/Models/Files/FileMoveResponseTest.cs similarity index 89% rename from src/ImageKit.Tests/Models/Files/FileMoveResponseTest.cs rename to src/Imagekit.Tests/Models/Files/FileMoveResponseTest.cs index 52448343..31f1e3da 100644 --- a/src/ImageKit.Tests/Models/Files/FileMoveResponseTest.cs +++ b/src/Imagekit.Tests/Models/Files/FileMoveResponseTest.cs @@ -1,8 +1,8 @@ using System.Text.Json; -using ImageKit.Core; -using ImageKit.Models.Files; +using Imagekit.Core; +using Imagekit.Models.Files; -namespace ImageKit.Tests.Models.Files; +namespace Imagekit.Tests.Models.Files; public class FileMoveResponseTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Files/FileRenameParamsTest.cs b/src/Imagekit.Tests/Models/Files/FileRenameParamsTest.cs similarity index 93% rename from src/ImageKit.Tests/Models/Files/FileRenameParamsTest.cs rename to src/Imagekit.Tests/Models/Files/FileRenameParamsTest.cs index 5f207be4..a69220f8 100644 --- a/src/ImageKit.Tests/Models/Files/FileRenameParamsTest.cs +++ b/src/Imagekit.Tests/Models/Files/FileRenameParamsTest.cs @@ -1,7 +1,7 @@ using System; -using ImageKit.Models.Files; +using Imagekit.Models.Files; -namespace ImageKit.Tests.Models.Files; +namespace Imagekit.Tests.Models.Files; public class FileRenameParamsTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Files/FileRenameResponseTest.cs b/src/Imagekit.Tests/Models/Files/FileRenameResponseTest.cs similarity index 93% rename from src/ImageKit.Tests/Models/Files/FileRenameResponseTest.cs rename to src/Imagekit.Tests/Models/Files/FileRenameResponseTest.cs index 706bdc9b..49ae2d01 100644 --- a/src/ImageKit.Tests/Models/Files/FileRenameResponseTest.cs +++ b/src/Imagekit.Tests/Models/Files/FileRenameResponseTest.cs @@ -1,8 +1,8 @@ using System.Text.Json; -using ImageKit.Core; -using ImageKit.Models.Files; +using Imagekit.Core; +using Imagekit.Models.Files; -namespace ImageKit.Tests.Models.Files; +namespace Imagekit.Tests.Models.Files; public class FileRenameResponseTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Files/FileTest.cs b/src/Imagekit.Tests/Models/Files/FileTest.cs similarity index 97% rename from src/ImageKit.Tests/Models/Files/FileTest.cs rename to src/Imagekit.Tests/Models/Files/FileTest.cs index e87fa09b..c547d86c 100644 --- a/src/ImageKit.Tests/Models/Files/FileTest.cs +++ b/src/Imagekit.Tests/Models/Files/FileTest.cs @@ -1,11 +1,11 @@ using System; using System.Collections.Generic; using System.Text.Json; -using ImageKit.Core; -using ImageKit.Exceptions; -using Files = ImageKit.Models.Files; +using Imagekit.Core; +using Imagekit.Exceptions; +using Files = Imagekit.Models.Files; -namespace ImageKit.Tests.Models.Files; +namespace Imagekit.Tests.Models.Files; public class FileTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Files/FileUpdateParamsTest.cs b/src/Imagekit.Tests/Models/Files/FileUpdateParamsTest.cs similarity index 96% rename from src/ImageKit.Tests/Models/Files/FileUpdateParamsTest.cs rename to src/Imagekit.Tests/Models/Files/FileUpdateParamsTest.cs index 75dda865..9e31447f 100644 --- a/src/ImageKit.Tests/Models/Files/FileUpdateParamsTest.cs +++ b/src/Imagekit.Tests/Models/Files/FileUpdateParamsTest.cs @@ -1,10 +1,10 @@ using System; using System.Collections.Generic; using System.Text.Json; -using ImageKit.Models; -using ImageKit.Models.Files; +using Imagekit.Models; +using Imagekit.Models.Files; -namespace ImageKit.Tests.Models.Files; +namespace Imagekit.Tests.Models.Files; public class FileUpdateParamsTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Files/FileUpdateResponseTest.cs b/src/Imagekit.Tests/Models/Files/FileUpdateResponseTest.cs similarity index 97% rename from src/ImageKit.Tests/Models/Files/FileUpdateResponseTest.cs rename to src/Imagekit.Tests/Models/Files/FileUpdateResponseTest.cs index 4387211a..cca76654 100644 --- a/src/ImageKit.Tests/Models/Files/FileUpdateResponseTest.cs +++ b/src/Imagekit.Tests/Models/Files/FileUpdateResponseTest.cs @@ -1,11 +1,11 @@ using System; using System.Collections.Generic; using System.Text.Json; -using ImageKit.Core; -using ImageKit.Exceptions; -using Files = ImageKit.Models.Files; +using Imagekit.Core; +using Imagekit.Exceptions; +using Files = Imagekit.Models.Files; -namespace ImageKit.Tests.Models.Files; +namespace Imagekit.Tests.Models.Files; public class FileUpdateResponseTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Files/FileUploadParamsTest.cs b/src/Imagekit.Tests/Models/Files/FileUploadParamsTest.cs similarity index 96% rename from src/ImageKit.Tests/Models/Files/FileUploadParamsTest.cs rename to src/Imagekit.Tests/Models/Files/FileUploadParamsTest.cs index fabaa7ca..87787329 100644 --- a/src/ImageKit.Tests/Models/Files/FileUploadParamsTest.cs +++ b/src/Imagekit.Tests/Models/Files/FileUploadParamsTest.cs @@ -2,12 +2,12 @@ using System.Collections.Generic; using System.Text; using System.Text.Json; -using ImageKit.Core; -using ImageKit.Exceptions; -using ImageKit.Models.Files; -using Models = ImageKit.Models; +using Imagekit.Core; +using Imagekit.Exceptions; +using Imagekit.Models.Files; +using Models = Imagekit.Models; -namespace ImageKit.Tests.Models.Files; +namespace Imagekit.Tests.Models.Files; public class FileUploadParamsTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Files/FileUploadResponseTest.cs b/src/Imagekit.Tests/Models/Files/FileUploadResponseTest.cs similarity index 97% rename from src/ImageKit.Tests/Models/Files/FileUploadResponseTest.cs rename to src/Imagekit.Tests/Models/Files/FileUploadResponseTest.cs index be5b9c7c..1e5b87f4 100644 --- a/src/ImageKit.Tests/Models/Files/FileUploadResponseTest.cs +++ b/src/Imagekit.Tests/Models/Files/FileUploadResponseTest.cs @@ -1,10 +1,10 @@ using System.Collections.Generic; using System.Text.Json; -using ImageKit.Core; -using ImageKit.Exceptions; -using ImageKit.Models.Files; +using Imagekit.Core; +using Imagekit.Exceptions; +using Imagekit.Models.Files; -namespace ImageKit.Tests.Models.Files; +namespace Imagekit.Tests.Models.Files; public class FileUploadResponseTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Files/FolderTest.cs b/src/Imagekit.Tests/Models/Files/FolderTest.cs similarity index 96% rename from src/ImageKit.Tests/Models/Files/FolderTest.cs rename to src/Imagekit.Tests/Models/Files/FolderTest.cs index 132317df..895d7435 100644 --- a/src/ImageKit.Tests/Models/Files/FolderTest.cs +++ b/src/Imagekit.Tests/Models/Files/FolderTest.cs @@ -1,11 +1,11 @@ using System; using System.Collections.Generic; using System.Text.Json; -using ImageKit.Core; -using ImageKit.Exceptions; -using ImageKit.Models.Files; +using Imagekit.Core; +using Imagekit.Exceptions; +using Imagekit.Models.Files; -namespace ImageKit.Tests.Models.Files; +namespace Imagekit.Tests.Models.Files; public class FolderTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Files/Metadata/MetadataGetFromUrlParamsTest.cs b/src/Imagekit.Tests/Models/Files/Metadata/MetadataGetFromUrlParamsTest.cs similarity index 89% rename from src/ImageKit.Tests/Models/Files/Metadata/MetadataGetFromUrlParamsTest.cs rename to src/Imagekit.Tests/Models/Files/Metadata/MetadataGetFromUrlParamsTest.cs index 2404e6ec..d314a12e 100644 --- a/src/ImageKit.Tests/Models/Files/Metadata/MetadataGetFromUrlParamsTest.cs +++ b/src/Imagekit.Tests/Models/Files/Metadata/MetadataGetFromUrlParamsTest.cs @@ -1,7 +1,7 @@ using System; -using ImageKit.Models.Files.Metadata; +using Imagekit.Models.Files.Metadata; -namespace ImageKit.Tests.Models.Files.Metadata; +namespace Imagekit.Tests.Models.Files.Metadata; public class MetadataGetFromUrlParamsTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Files/Metadata/MetadataGetParamsTest.cs b/src/Imagekit.Tests/Models/Files/Metadata/MetadataGetParamsTest.cs similarity index 87% rename from src/ImageKit.Tests/Models/Files/Metadata/MetadataGetParamsTest.cs rename to src/Imagekit.Tests/Models/Files/Metadata/MetadataGetParamsTest.cs index f72914d6..4fd20ba8 100644 --- a/src/ImageKit.Tests/Models/Files/Metadata/MetadataGetParamsTest.cs +++ b/src/Imagekit.Tests/Models/Files/Metadata/MetadataGetParamsTest.cs @@ -1,7 +1,7 @@ using System; -using ImageKit.Models.Files.Metadata; +using Imagekit.Models.Files.Metadata; -namespace ImageKit.Tests.Models.Files.Metadata; +namespace Imagekit.Tests.Models.Files.Metadata; public class MetadataGetParamsTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Files/UpdateFileRequestTest.cs b/src/Imagekit.Tests/Models/Files/UpdateFileRequestTest.cs similarity index 97% rename from src/ImageKit.Tests/Models/Files/UpdateFileRequestTest.cs rename to src/Imagekit.Tests/Models/Files/UpdateFileRequestTest.cs index c5e6bd6e..fd3e8a16 100644 --- a/src/ImageKit.Tests/Models/Files/UpdateFileRequestTest.cs +++ b/src/Imagekit.Tests/Models/Files/UpdateFileRequestTest.cs @@ -1,11 +1,11 @@ using System.Collections.Generic; using System.Text.Json; -using ImageKit.Core; -using ImageKit.Exceptions; -using ImageKit.Models; -using Files = ImageKit.Models.Files; +using Imagekit.Core; +using Imagekit.Exceptions; +using Imagekit.Models; +using Files = Imagekit.Models.Files; -namespace ImageKit.Tests.Models.Files; +namespace Imagekit.Tests.Models.Files; public class UpdateFileRequestTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Files/Versions/VersionDeleteParamsTest.cs b/src/Imagekit.Tests/Models/Files/Versions/VersionDeleteParamsTest.cs similarity index 89% rename from src/ImageKit.Tests/Models/Files/Versions/VersionDeleteParamsTest.cs rename to src/Imagekit.Tests/Models/Files/Versions/VersionDeleteParamsTest.cs index f1c89b50..a1d5549e 100644 --- a/src/ImageKit.Tests/Models/Files/Versions/VersionDeleteParamsTest.cs +++ b/src/Imagekit.Tests/Models/Files/Versions/VersionDeleteParamsTest.cs @@ -1,7 +1,7 @@ using System; -using ImageKit.Models.Files.Versions; +using Imagekit.Models.Files.Versions; -namespace ImageKit.Tests.Models.Files.Versions; +namespace Imagekit.Tests.Models.Files.Versions; public class VersionDeleteParamsTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Files/Versions/VersionDeleteResponseTest.cs b/src/Imagekit.Tests/Models/Files/Versions/VersionDeleteResponseTest.cs similarity index 88% rename from src/ImageKit.Tests/Models/Files/Versions/VersionDeleteResponseTest.cs rename to src/Imagekit.Tests/Models/Files/Versions/VersionDeleteResponseTest.cs index 88378f09..64c279f0 100644 --- a/src/ImageKit.Tests/Models/Files/Versions/VersionDeleteResponseTest.cs +++ b/src/Imagekit.Tests/Models/Files/Versions/VersionDeleteResponseTest.cs @@ -1,8 +1,8 @@ using System.Text.Json; -using ImageKit.Core; -using ImageKit.Models.Files.Versions; +using Imagekit.Core; +using Imagekit.Models.Files.Versions; -namespace ImageKit.Tests.Models.Files.Versions; +namespace Imagekit.Tests.Models.Files.Versions; public class VersionDeleteResponseTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Files/Versions/VersionGetParamsTest.cs b/src/Imagekit.Tests/Models/Files/Versions/VersionGetParamsTest.cs similarity index 89% rename from src/ImageKit.Tests/Models/Files/Versions/VersionGetParamsTest.cs rename to src/Imagekit.Tests/Models/Files/Versions/VersionGetParamsTest.cs index 053cbc36..a60ccf03 100644 --- a/src/ImageKit.Tests/Models/Files/Versions/VersionGetParamsTest.cs +++ b/src/Imagekit.Tests/Models/Files/Versions/VersionGetParamsTest.cs @@ -1,7 +1,7 @@ using System; -using ImageKit.Models.Files.Versions; +using Imagekit.Models.Files.Versions; -namespace ImageKit.Tests.Models.Files.Versions; +namespace Imagekit.Tests.Models.Files.Versions; public class VersionGetParamsTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Files/Versions/VersionListParamsTest.cs b/src/Imagekit.Tests/Models/Files/Versions/VersionListParamsTest.cs similarity index 87% rename from src/ImageKit.Tests/Models/Files/Versions/VersionListParamsTest.cs rename to src/Imagekit.Tests/Models/Files/Versions/VersionListParamsTest.cs index 30c8b63f..4385106a 100644 --- a/src/ImageKit.Tests/Models/Files/Versions/VersionListParamsTest.cs +++ b/src/Imagekit.Tests/Models/Files/Versions/VersionListParamsTest.cs @@ -1,7 +1,7 @@ using System; -using ImageKit.Models.Files.Versions; +using Imagekit.Models.Files.Versions; -namespace ImageKit.Tests.Models.Files.Versions; +namespace Imagekit.Tests.Models.Files.Versions; public class VersionListParamsTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Files/Versions/VersionRestoreParamsTest.cs b/src/Imagekit.Tests/Models/Files/Versions/VersionRestoreParamsTest.cs similarity index 89% rename from src/ImageKit.Tests/Models/Files/Versions/VersionRestoreParamsTest.cs rename to src/Imagekit.Tests/Models/Files/Versions/VersionRestoreParamsTest.cs index bd411834..549da7b0 100644 --- a/src/ImageKit.Tests/Models/Files/Versions/VersionRestoreParamsTest.cs +++ b/src/Imagekit.Tests/Models/Files/Versions/VersionRestoreParamsTest.cs @@ -1,7 +1,7 @@ using System; -using ImageKit.Models.Files.Versions; +using Imagekit.Models.Files.Versions; -namespace ImageKit.Tests.Models.Files.Versions; +namespace Imagekit.Tests.Models.Files.Versions; public class VersionRestoreParamsTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Folders/FolderCopyParamsTest.cs b/src/Imagekit.Tests/Models/Folders/FolderCopyParamsTest.cs similarity index 94% rename from src/ImageKit.Tests/Models/Folders/FolderCopyParamsTest.cs rename to src/Imagekit.Tests/Models/Folders/FolderCopyParamsTest.cs index 2168c1a8..6869bc7b 100644 --- a/src/ImageKit.Tests/Models/Folders/FolderCopyParamsTest.cs +++ b/src/Imagekit.Tests/Models/Folders/FolderCopyParamsTest.cs @@ -1,7 +1,7 @@ using System; -using ImageKit.Models.Folders; +using Imagekit.Models.Folders; -namespace ImageKit.Tests.Models.Folders; +namespace Imagekit.Tests.Models.Folders; public class FolderCopyParamsTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Folders/FolderCopyResponseTest.cs b/src/Imagekit.Tests/Models/Folders/FolderCopyResponseTest.cs similarity index 90% rename from src/ImageKit.Tests/Models/Folders/FolderCopyResponseTest.cs rename to src/Imagekit.Tests/Models/Folders/FolderCopyResponseTest.cs index b2656bce..bb6952dd 100644 --- a/src/ImageKit.Tests/Models/Folders/FolderCopyResponseTest.cs +++ b/src/Imagekit.Tests/Models/Folders/FolderCopyResponseTest.cs @@ -1,8 +1,8 @@ using System.Text.Json; -using ImageKit.Core; -using ImageKit.Models.Folders; +using Imagekit.Core; +using Imagekit.Models.Folders; -namespace ImageKit.Tests.Models.Folders; +namespace Imagekit.Tests.Models.Folders; public class FolderCopyResponseTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Folders/FolderCreateParamsTest.cs b/src/Imagekit.Tests/Models/Folders/FolderCreateParamsTest.cs similarity index 91% rename from src/ImageKit.Tests/Models/Folders/FolderCreateParamsTest.cs rename to src/Imagekit.Tests/Models/Folders/FolderCreateParamsTest.cs index 8f6c081f..86c09c06 100644 --- a/src/ImageKit.Tests/Models/Folders/FolderCreateParamsTest.cs +++ b/src/Imagekit.Tests/Models/Folders/FolderCreateParamsTest.cs @@ -1,7 +1,7 @@ using System; -using ImageKit.Models.Folders; +using Imagekit.Models.Folders; -namespace ImageKit.Tests.Models.Folders; +namespace Imagekit.Tests.Models.Folders; public class FolderCreateParamsTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Folders/FolderCreateResponseTest.cs b/src/Imagekit.Tests/Models/Folders/FolderCreateResponseTest.cs similarity index 89% rename from src/ImageKit.Tests/Models/Folders/FolderCreateResponseTest.cs rename to src/Imagekit.Tests/Models/Folders/FolderCreateResponseTest.cs index 2eb390aa..a358a4be 100644 --- a/src/ImageKit.Tests/Models/Folders/FolderCreateResponseTest.cs +++ b/src/Imagekit.Tests/Models/Folders/FolderCreateResponseTest.cs @@ -1,8 +1,8 @@ using System.Text.Json; -using ImageKit.Core; -using ImageKit.Models.Folders; +using Imagekit.Core; +using Imagekit.Models.Folders; -namespace ImageKit.Tests.Models.Folders; +namespace Imagekit.Tests.Models.Folders; public class FolderCreateResponseTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Folders/FolderDeleteParamsTest.cs b/src/Imagekit.Tests/Models/Folders/FolderDeleteParamsTest.cs similarity index 89% rename from src/ImageKit.Tests/Models/Folders/FolderDeleteParamsTest.cs rename to src/Imagekit.Tests/Models/Folders/FolderDeleteParamsTest.cs index 973d471e..214fb04a 100644 --- a/src/ImageKit.Tests/Models/Folders/FolderDeleteParamsTest.cs +++ b/src/Imagekit.Tests/Models/Folders/FolderDeleteParamsTest.cs @@ -1,7 +1,7 @@ using System; -using ImageKit.Models.Folders; +using Imagekit.Models.Folders; -namespace ImageKit.Tests.Models.Folders; +namespace Imagekit.Tests.Models.Folders; public class FolderDeleteParamsTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Folders/FolderDeleteResponseTest.cs b/src/Imagekit.Tests/Models/Folders/FolderDeleteResponseTest.cs similarity index 89% rename from src/ImageKit.Tests/Models/Folders/FolderDeleteResponseTest.cs rename to src/Imagekit.Tests/Models/Folders/FolderDeleteResponseTest.cs index 6a952f2d..6a92f813 100644 --- a/src/ImageKit.Tests/Models/Folders/FolderDeleteResponseTest.cs +++ b/src/Imagekit.Tests/Models/Folders/FolderDeleteResponseTest.cs @@ -1,8 +1,8 @@ using System.Text.Json; -using ImageKit.Core; -using ImageKit.Models.Folders; +using Imagekit.Core; +using Imagekit.Models.Folders; -namespace ImageKit.Tests.Models.Folders; +namespace Imagekit.Tests.Models.Folders; public class FolderDeleteResponseTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Folders/FolderMoveParamsTest.cs b/src/Imagekit.Tests/Models/Folders/FolderMoveParamsTest.cs similarity index 91% rename from src/ImageKit.Tests/Models/Folders/FolderMoveParamsTest.cs rename to src/Imagekit.Tests/Models/Folders/FolderMoveParamsTest.cs index 66a8fe0b..911ef4a2 100644 --- a/src/ImageKit.Tests/Models/Folders/FolderMoveParamsTest.cs +++ b/src/Imagekit.Tests/Models/Folders/FolderMoveParamsTest.cs @@ -1,7 +1,7 @@ using System; -using ImageKit.Models.Folders; +using Imagekit.Models.Folders; -namespace ImageKit.Tests.Models.Folders; +namespace Imagekit.Tests.Models.Folders; public class FolderMoveParamsTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Folders/FolderMoveResponseTest.cs b/src/Imagekit.Tests/Models/Folders/FolderMoveResponseTest.cs similarity index 90% rename from src/ImageKit.Tests/Models/Folders/FolderMoveResponseTest.cs rename to src/Imagekit.Tests/Models/Folders/FolderMoveResponseTest.cs index f65cdd5d..ef446e4a 100644 --- a/src/ImageKit.Tests/Models/Folders/FolderMoveResponseTest.cs +++ b/src/Imagekit.Tests/Models/Folders/FolderMoveResponseTest.cs @@ -1,8 +1,8 @@ using System.Text.Json; -using ImageKit.Core; -using ImageKit.Models.Folders; +using Imagekit.Core; +using Imagekit.Models.Folders; -namespace ImageKit.Tests.Models.Folders; +namespace Imagekit.Tests.Models.Folders; public class FolderMoveResponseTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Folders/FolderRenameParamsTest.cs b/src/Imagekit.Tests/Models/Folders/FolderRenameParamsTest.cs similarity index 93% rename from src/ImageKit.Tests/Models/Folders/FolderRenameParamsTest.cs rename to src/Imagekit.Tests/Models/Folders/FolderRenameParamsTest.cs index 0d730804..c4a34d4f 100644 --- a/src/ImageKit.Tests/Models/Folders/FolderRenameParamsTest.cs +++ b/src/Imagekit.Tests/Models/Folders/FolderRenameParamsTest.cs @@ -1,7 +1,7 @@ using System; -using ImageKit.Models.Folders; +using Imagekit.Models.Folders; -namespace ImageKit.Tests.Models.Folders; +namespace Imagekit.Tests.Models.Folders; public class FolderRenameParamsTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Folders/FolderRenameResponseTest.cs b/src/Imagekit.Tests/Models/Folders/FolderRenameResponseTest.cs similarity index 90% rename from src/ImageKit.Tests/Models/Folders/FolderRenameResponseTest.cs rename to src/Imagekit.Tests/Models/Folders/FolderRenameResponseTest.cs index a1de9b35..3e194afd 100644 --- a/src/ImageKit.Tests/Models/Folders/FolderRenameResponseTest.cs +++ b/src/Imagekit.Tests/Models/Folders/FolderRenameResponseTest.cs @@ -1,8 +1,8 @@ using System.Text.Json; -using ImageKit.Core; -using ImageKit.Models.Folders; +using Imagekit.Core; +using Imagekit.Models.Folders; -namespace ImageKit.Tests.Models.Folders; +namespace Imagekit.Tests.Models.Folders; public class FolderRenameResponseTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Folders/Job/JobGetParamsTest.cs b/src/Imagekit.Tests/Models/Folders/Job/JobGetParamsTest.cs similarity index 87% rename from src/ImageKit.Tests/Models/Folders/Job/JobGetParamsTest.cs rename to src/Imagekit.Tests/Models/Folders/Job/JobGetParamsTest.cs index f6a398bb..b1ed45a2 100644 --- a/src/ImageKit.Tests/Models/Folders/Job/JobGetParamsTest.cs +++ b/src/Imagekit.Tests/Models/Folders/Job/JobGetParamsTest.cs @@ -1,7 +1,7 @@ using System; -using ImageKit.Models.Folders.Job; +using Imagekit.Models.Folders.Job; -namespace ImageKit.Tests.Models.Folders.Job; +namespace Imagekit.Tests.Models.Folders.Job; public class JobGetParamsTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Folders/Job/JobGetResponseTest.cs b/src/Imagekit.Tests/Models/Folders/Job/JobGetResponseTest.cs similarity index 95% rename from src/ImageKit.Tests/Models/Folders/Job/JobGetResponseTest.cs rename to src/Imagekit.Tests/Models/Folders/Job/JobGetResponseTest.cs index 90b968da..b70a022b 100644 --- a/src/ImageKit.Tests/Models/Folders/Job/JobGetResponseTest.cs +++ b/src/Imagekit.Tests/Models/Folders/Job/JobGetResponseTest.cs @@ -1,9 +1,9 @@ using System.Text.Json; -using ImageKit.Core; -using ImageKit.Exceptions; -using ImageKit.Models.Folders.Job; +using Imagekit.Core; +using Imagekit.Exceptions; +using Imagekit.Models.Folders.Job; -namespace ImageKit.Tests.Models.Folders.Job; +namespace Imagekit.Tests.Models.Folders.Job; public class JobGetResponseTest : TestBase { diff --git a/src/ImageKit.Tests/Models/GetImageAttributesOptionsTest.cs b/src/Imagekit.Tests/Models/GetImageAttributesOptionsTest.cs similarity index 97% rename from src/ImageKit.Tests/Models/GetImageAttributesOptionsTest.cs rename to src/Imagekit.Tests/Models/GetImageAttributesOptionsTest.cs index 55d2be97..7c3e0dcf 100644 --- a/src/ImageKit.Tests/Models/GetImageAttributesOptionsTest.cs +++ b/src/Imagekit.Tests/Models/GetImageAttributesOptionsTest.cs @@ -1,9 +1,9 @@ using System.Collections.Generic; using System.Text.Json; -using ImageKit.Core; -using ImageKit.Models; +using Imagekit.Core; +using Imagekit.Models; -namespace ImageKit.Tests.Models; +namespace Imagekit.Tests.Models; public class GetImageAttributesOptionsTest : TestBase { diff --git a/src/ImageKit.Tests/Models/ImageOverlayTest.cs b/src/Imagekit.Tests/Models/ImageOverlayTest.cs similarity index 97% rename from src/ImageKit.Tests/Models/ImageOverlayTest.cs rename to src/Imagekit.Tests/Models/ImageOverlayTest.cs index a1a520d8..db16767a 100644 --- a/src/ImageKit.Tests/Models/ImageOverlayTest.cs +++ b/src/Imagekit.Tests/Models/ImageOverlayTest.cs @@ -1,10 +1,10 @@ using System.Collections.Generic; using System.Text.Json; -using ImageKit.Core; -using ImageKit.Exceptions; -using ImageKit.Models; +using Imagekit.Core; +using Imagekit.Exceptions; +using Imagekit.Models; -namespace ImageKit.Tests.Models; +namespace Imagekit.Tests.Models; public class ImageOverlayTest : TestBase { diff --git a/src/ImageKit.Tests/Models/OverlayPositionTest.cs b/src/Imagekit.Tests/Models/OverlayPositionTest.cs similarity index 95% rename from src/ImageKit.Tests/Models/OverlayPositionTest.cs rename to src/Imagekit.Tests/Models/OverlayPositionTest.cs index 69ec6237..a262e996 100644 --- a/src/ImageKit.Tests/Models/OverlayPositionTest.cs +++ b/src/Imagekit.Tests/Models/OverlayPositionTest.cs @@ -1,9 +1,9 @@ using System.Text.Json; -using ImageKit.Core; -using ImageKit.Exceptions; -using ImageKit.Models; +using Imagekit.Core; +using Imagekit.Exceptions; +using Imagekit.Models; -namespace ImageKit.Tests.Models; +namespace Imagekit.Tests.Models; public class OverlayPositionTest : TestBase { diff --git a/src/ImageKit.Tests/Models/OverlayTest.cs b/src/Imagekit.Tests/Models/OverlayTest.cs similarity index 96% rename from src/ImageKit.Tests/Models/OverlayTest.cs rename to src/Imagekit.Tests/Models/OverlayTest.cs index f02149fb..4520c994 100644 --- a/src/ImageKit.Tests/Models/OverlayTest.cs +++ b/src/Imagekit.Tests/Models/OverlayTest.cs @@ -1,8 +1,8 @@ using System.Text.Json; -using ImageKit.Core; -using ImageKit.Models; +using Imagekit.Core; +using Imagekit.Models; -namespace ImageKit.Tests.Models; +namespace Imagekit.Tests.Models; public class OverlayTest : TestBase { diff --git a/src/ImageKit.Tests/Models/OverlayTimingTest.cs b/src/Imagekit.Tests/Models/OverlayTimingTest.cs similarity index 95% rename from src/ImageKit.Tests/Models/OverlayTimingTest.cs rename to src/Imagekit.Tests/Models/OverlayTimingTest.cs index 07c05f9b..30e0b1df 100644 --- a/src/ImageKit.Tests/Models/OverlayTimingTest.cs +++ b/src/Imagekit.Tests/Models/OverlayTimingTest.cs @@ -1,8 +1,8 @@ using System.Text.Json; -using ImageKit.Core; -using ImageKit.Models; +using Imagekit.Core; +using Imagekit.Models; -namespace ImageKit.Tests.Models; +namespace Imagekit.Tests.Models; public class OverlayTimingTest : TestBase { diff --git a/src/ImageKit.Tests/Models/ResponsiveImageAttributesTest.cs b/src/Imagekit.Tests/Models/ResponsiveImageAttributesTest.cs similarity index 95% rename from src/ImageKit.Tests/Models/ResponsiveImageAttributesTest.cs rename to src/Imagekit.Tests/Models/ResponsiveImageAttributesTest.cs index 8d983592..ff7a4c51 100644 --- a/src/ImageKit.Tests/Models/ResponsiveImageAttributesTest.cs +++ b/src/Imagekit.Tests/Models/ResponsiveImageAttributesTest.cs @@ -1,8 +1,8 @@ using System.Text.Json; -using ImageKit.Core; -using ImageKit.Models; +using Imagekit.Core; +using Imagekit.Models; -namespace ImageKit.Tests.Models; +namespace Imagekit.Tests.Models; public class ResponsiveImageAttributesTest : TestBase { diff --git a/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionCreateParamsTest.cs b/src/Imagekit.Tests/Models/SavedExtensions/SavedExtensionCreateParamsTest.cs similarity index 93% rename from src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionCreateParamsTest.cs rename to src/Imagekit.Tests/Models/SavedExtensions/SavedExtensionCreateParamsTest.cs index d55a5c5d..6592f141 100644 --- a/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionCreateParamsTest.cs +++ b/src/Imagekit.Tests/Models/SavedExtensions/SavedExtensionCreateParamsTest.cs @@ -1,8 +1,8 @@ using System; -using ImageKit.Models; -using ImageKit.Models.SavedExtensions; +using Imagekit.Models; +using Imagekit.Models.SavedExtensions; -namespace ImageKit.Tests.Models.SavedExtensions; +namespace Imagekit.Tests.Models.SavedExtensions; public class SavedExtensionCreateParamsTest : TestBase { diff --git a/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionDeleteParamsTest.cs b/src/Imagekit.Tests/Models/SavedExtensions/SavedExtensionDeleteParamsTest.cs similarity index 87% rename from src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionDeleteParamsTest.cs rename to src/Imagekit.Tests/Models/SavedExtensions/SavedExtensionDeleteParamsTest.cs index ad99ca25..348ea0de 100644 --- a/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionDeleteParamsTest.cs +++ b/src/Imagekit.Tests/Models/SavedExtensions/SavedExtensionDeleteParamsTest.cs @@ -1,7 +1,7 @@ using System; -using ImageKit.Models.SavedExtensions; +using Imagekit.Models.SavedExtensions; -namespace ImageKit.Tests.Models.SavedExtensions; +namespace Imagekit.Tests.Models.SavedExtensions; public class SavedExtensionDeleteParamsTest : TestBase { diff --git a/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionGetParamsTest.cs b/src/Imagekit.Tests/Models/SavedExtensions/SavedExtensionGetParamsTest.cs similarity index 87% rename from src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionGetParamsTest.cs rename to src/Imagekit.Tests/Models/SavedExtensions/SavedExtensionGetParamsTest.cs index 1a600f15..28ad9a62 100644 --- a/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionGetParamsTest.cs +++ b/src/Imagekit.Tests/Models/SavedExtensions/SavedExtensionGetParamsTest.cs @@ -1,7 +1,7 @@ using System; -using ImageKit.Models.SavedExtensions; +using Imagekit.Models.SavedExtensions; -namespace ImageKit.Tests.Models.SavedExtensions; +namespace Imagekit.Tests.Models.SavedExtensions; public class SavedExtensionGetParamsTest : TestBase { diff --git a/src/Imagekit.Tests/Models/SavedExtensions/SavedExtensionListParamsTest.cs b/src/Imagekit.Tests/Models/SavedExtensions/SavedExtensionListParamsTest.cs new file mode 100644 index 00000000..5fce38dc --- /dev/null +++ b/src/Imagekit.Tests/Models/SavedExtensions/SavedExtensionListParamsTest.cs @@ -0,0 +1 @@ +namespace Imagekit.Tests.Models.SavedExtensions; diff --git a/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionUpdateParamsTest.cs b/src/Imagekit.Tests/Models/SavedExtensions/SavedExtensionUpdateParamsTest.cs similarity index 93% rename from src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionUpdateParamsTest.cs rename to src/Imagekit.Tests/Models/SavedExtensions/SavedExtensionUpdateParamsTest.cs index 7fd9c38b..65da1173 100644 --- a/src/ImageKit.Tests/Models/SavedExtensions/SavedExtensionUpdateParamsTest.cs +++ b/src/Imagekit.Tests/Models/SavedExtensions/SavedExtensionUpdateParamsTest.cs @@ -1,8 +1,8 @@ using System; -using ImageKit.Models; -using ImageKit.Models.SavedExtensions; +using Imagekit.Models; +using Imagekit.Models.SavedExtensions; -namespace ImageKit.Tests.Models.SavedExtensions; +namespace Imagekit.Tests.Models.SavedExtensions; public class SavedExtensionUpdateParamsTest : TestBase { diff --git a/src/ImageKit.Tests/Models/SharedSavedExtensionTest.cs b/src/Imagekit.Tests/Models/SharedSavedExtensionTest.cs similarity index 96% rename from src/ImageKit.Tests/Models/SharedSavedExtensionTest.cs rename to src/Imagekit.Tests/Models/SharedSavedExtensionTest.cs index fde971c5..b513989e 100644 --- a/src/ImageKit.Tests/Models/SharedSavedExtensionTest.cs +++ b/src/Imagekit.Tests/Models/SharedSavedExtensionTest.cs @@ -1,9 +1,9 @@ using System; using System.Text.Json; -using ImageKit.Core; -using ImageKit.Models; +using Imagekit.Core; +using Imagekit.Models; -namespace ImageKit.Tests.Models; +namespace Imagekit.Tests.Models; public class SharedSavedExtensionTest : TestBase { diff --git a/src/ImageKit.Tests/Models/SolidColorOverlayTest.cs b/src/Imagekit.Tests/Models/SolidColorOverlayTest.cs similarity index 96% rename from src/ImageKit.Tests/Models/SolidColorOverlayTest.cs rename to src/Imagekit.Tests/Models/SolidColorOverlayTest.cs index 00961ad2..c30e8b2b 100644 --- a/src/ImageKit.Tests/Models/SolidColorOverlayTest.cs +++ b/src/Imagekit.Tests/Models/SolidColorOverlayTest.cs @@ -1,9 +1,9 @@ using System.Collections.Generic; using System.Text.Json; -using ImageKit.Core; -using ImageKit.Models; +using Imagekit.Core; +using Imagekit.Models; -namespace ImageKit.Tests.Models; +namespace Imagekit.Tests.Models; public class SolidColorOverlayTest : TestBase { diff --git a/src/ImageKit.Tests/Models/SolidColorOverlayTransformationTest.cs b/src/Imagekit.Tests/Models/SolidColorOverlayTransformationTest.cs similarity index 95% rename from src/ImageKit.Tests/Models/SolidColorOverlayTransformationTest.cs rename to src/Imagekit.Tests/Models/SolidColorOverlayTransformationTest.cs index d84a841b..89059491 100644 --- a/src/ImageKit.Tests/Models/SolidColorOverlayTransformationTest.cs +++ b/src/Imagekit.Tests/Models/SolidColorOverlayTransformationTest.cs @@ -1,9 +1,9 @@ using System.Text.Json; -using ImageKit.Core; -using ImageKit.Exceptions; -using ImageKit.Models; +using Imagekit.Core; +using Imagekit.Exceptions; +using Imagekit.Models; -namespace ImageKit.Tests.Models; +namespace Imagekit.Tests.Models; public class SolidColorOverlayTransformationTest : TestBase { diff --git a/src/ImageKit.Tests/Models/SrcOptionsTest.cs b/src/Imagekit.Tests/Models/SrcOptionsTest.cs similarity index 97% rename from src/ImageKit.Tests/Models/SrcOptionsTest.cs rename to src/Imagekit.Tests/Models/SrcOptionsTest.cs index 6d6fcc25..21c86761 100644 --- a/src/ImageKit.Tests/Models/SrcOptionsTest.cs +++ b/src/Imagekit.Tests/Models/SrcOptionsTest.cs @@ -1,9 +1,9 @@ using System.Collections.Generic; using System.Text.Json; -using ImageKit.Core; -using ImageKit.Models; +using Imagekit.Core; +using Imagekit.Models; -namespace ImageKit.Tests.Models; +namespace Imagekit.Tests.Models; public class SrcOptionsTest : TestBase { diff --git a/src/ImageKit.Tests/Models/StreamingResolutionTest.cs b/src/Imagekit.Tests/Models/StreamingResolutionTest.cs similarity index 93% rename from src/ImageKit.Tests/Models/StreamingResolutionTest.cs rename to src/Imagekit.Tests/Models/StreamingResolutionTest.cs index 9f127bb1..54ceb375 100644 --- a/src/ImageKit.Tests/Models/StreamingResolutionTest.cs +++ b/src/Imagekit.Tests/Models/StreamingResolutionTest.cs @@ -1,9 +1,9 @@ using System.Text.Json; -using ImageKit.Core; -using ImageKit.Exceptions; -using ImageKit.Models; +using Imagekit.Core; +using Imagekit.Exceptions; +using Imagekit.Models; -namespace ImageKit.Tests.Models; +namespace Imagekit.Tests.Models; public class StreamingResolutionTest : TestBase { diff --git a/src/ImageKit.Tests/Models/SubtitleOverlayTest.cs b/src/Imagekit.Tests/Models/SubtitleOverlayTest.cs similarity index 96% rename from src/ImageKit.Tests/Models/SubtitleOverlayTest.cs rename to src/Imagekit.Tests/Models/SubtitleOverlayTest.cs index 6aa3c431..b11577b3 100644 --- a/src/ImageKit.Tests/Models/SubtitleOverlayTest.cs +++ b/src/Imagekit.Tests/Models/SubtitleOverlayTest.cs @@ -1,10 +1,10 @@ using System.Collections.Generic; using System.Text.Json; -using ImageKit.Core; -using ImageKit.Exceptions; -using ImageKit.Models; +using Imagekit.Core; +using Imagekit.Exceptions; +using Imagekit.Models; -namespace ImageKit.Tests.Models; +namespace Imagekit.Tests.Models; public class SubtitleOverlayTest : TestBase { diff --git a/src/ImageKit.Tests/Models/SubtitleOverlayTransformationTest.cs b/src/Imagekit.Tests/Models/SubtitleOverlayTransformationTest.cs similarity index 95% rename from src/ImageKit.Tests/Models/SubtitleOverlayTransformationTest.cs rename to src/Imagekit.Tests/Models/SubtitleOverlayTransformationTest.cs index 81e75c92..5a962a02 100644 --- a/src/ImageKit.Tests/Models/SubtitleOverlayTransformationTest.cs +++ b/src/Imagekit.Tests/Models/SubtitleOverlayTransformationTest.cs @@ -1,9 +1,9 @@ using System.Text.Json; -using ImageKit.Core; -using ImageKit.Exceptions; -using ImageKit.Models; +using Imagekit.Core; +using Imagekit.Exceptions; +using Imagekit.Models; -namespace ImageKit.Tests.Models; +namespace Imagekit.Tests.Models; public class SubtitleOverlayTransformationTest : TestBase { diff --git a/src/ImageKit.Tests/Models/TextOverlayTest.cs b/src/Imagekit.Tests/Models/TextOverlayTest.cs similarity index 96% rename from src/ImageKit.Tests/Models/TextOverlayTest.cs rename to src/Imagekit.Tests/Models/TextOverlayTest.cs index 0c510d69..a708cabb 100644 --- a/src/ImageKit.Tests/Models/TextOverlayTest.cs +++ b/src/Imagekit.Tests/Models/TextOverlayTest.cs @@ -1,10 +1,10 @@ using System.Collections.Generic; using System.Text.Json; -using ImageKit.Core; -using ImageKit.Exceptions; -using ImageKit.Models; +using Imagekit.Core; +using Imagekit.Exceptions; +using Imagekit.Models; -namespace ImageKit.Tests.Models; +namespace Imagekit.Tests.Models; public class TextOverlayTest : TestBase { diff --git a/src/ImageKit.Tests/Models/TextOverlayTransformationTest.cs b/src/Imagekit.Tests/Models/TextOverlayTransformationTest.cs similarity index 96% rename from src/ImageKit.Tests/Models/TextOverlayTransformationTest.cs rename to src/Imagekit.Tests/Models/TextOverlayTransformationTest.cs index 1af130ca..a8471ed4 100644 --- a/src/ImageKit.Tests/Models/TextOverlayTransformationTest.cs +++ b/src/Imagekit.Tests/Models/TextOverlayTransformationTest.cs @@ -1,9 +1,9 @@ using System.Text.Json; -using ImageKit.Core; -using ImageKit.Exceptions; -using ImageKit.Models; +using Imagekit.Core; +using Imagekit.Exceptions; +using Imagekit.Models; -namespace ImageKit.Tests.Models; +namespace Imagekit.Tests.Models; public class TextOverlayTransformationTest : TestBase { diff --git a/src/ImageKit.Tests/Models/TransformationPositionTest.cs b/src/Imagekit.Tests/Models/TransformationPositionTest.cs similarity index 92% rename from src/ImageKit.Tests/Models/TransformationPositionTest.cs rename to src/Imagekit.Tests/Models/TransformationPositionTest.cs index 3e4b8b06..4528ed99 100644 --- a/src/ImageKit.Tests/Models/TransformationPositionTest.cs +++ b/src/Imagekit.Tests/Models/TransformationPositionTest.cs @@ -1,9 +1,9 @@ using System.Text.Json; -using ImageKit.Core; -using ImageKit.Exceptions; -using ImageKit.Models; +using Imagekit.Core; +using Imagekit.Exceptions; +using Imagekit.Models; -namespace ImageKit.Tests.Models; +namespace Imagekit.Tests.Models; public class TransformationPositionTest : TestBase { diff --git a/src/ImageKit.Tests/Models/TransformationTest.cs b/src/Imagekit.Tests/Models/TransformationTest.cs similarity index 96% rename from src/ImageKit.Tests/Models/TransformationTest.cs rename to src/Imagekit.Tests/Models/TransformationTest.cs index c1fb139c..ce63957e 100644 --- a/src/ImageKit.Tests/Models/TransformationTest.cs +++ b/src/Imagekit.Tests/Models/TransformationTest.cs @@ -1,10 +1,10 @@ using System.Collections.Generic; using System.Text.Json; -using ImageKit.Core; -using ImageKit.Exceptions; -using ImageKit.Models; +using Imagekit.Core; +using Imagekit.Exceptions; +using Imagekit.Models; -namespace ImageKit.Tests.Models; +namespace Imagekit.Tests.Models; public class TransformationTest : TestBase { diff --git a/src/ImageKit.Tests/Models/UnnamedSchemaWithArrayParent0Test.cs b/src/Imagekit.Tests/Models/UnnamedSchemaWithArrayParent0Test.cs similarity index 97% rename from src/ImageKit.Tests/Models/UnnamedSchemaWithArrayParent0Test.cs rename to src/Imagekit.Tests/Models/UnnamedSchemaWithArrayParent0Test.cs index 34c08047..4885b0e3 100644 --- a/src/ImageKit.Tests/Models/UnnamedSchemaWithArrayParent0Test.cs +++ b/src/Imagekit.Tests/Models/UnnamedSchemaWithArrayParent0Test.cs @@ -1,10 +1,10 @@ using System.Collections.Generic; using System.Text.Json; -using ImageKit.Core; -using ImageKit.Exceptions; -using ImageKit.Models; +using Imagekit.Core; +using Imagekit.Exceptions; +using Imagekit.Models; -namespace ImageKit.Tests.Models; +namespace Imagekit.Tests.Models; public class UnnamedSchemaWithArrayParent0Test : TestBase { diff --git a/src/ImageKit.Tests/Models/VideoOverlayTest.cs b/src/Imagekit.Tests/Models/VideoOverlayTest.cs similarity index 97% rename from src/ImageKit.Tests/Models/VideoOverlayTest.cs rename to src/Imagekit.Tests/Models/VideoOverlayTest.cs index e201a09f..63374317 100644 --- a/src/ImageKit.Tests/Models/VideoOverlayTest.cs +++ b/src/Imagekit.Tests/Models/VideoOverlayTest.cs @@ -1,10 +1,10 @@ using System.Collections.Generic; using System.Text.Json; -using ImageKit.Core; -using ImageKit.Exceptions; -using ImageKit.Models; +using Imagekit.Core; +using Imagekit.Exceptions; +using Imagekit.Models; -namespace ImageKit.Tests.Models; +namespace Imagekit.Tests.Models; public class VideoOverlayTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Webhooks/BaseWebhookEventTest.cs b/src/Imagekit.Tests/Models/Webhooks/BaseWebhookEventTest.cs similarity index 91% rename from src/ImageKit.Tests/Models/Webhooks/BaseWebhookEventTest.cs rename to src/Imagekit.Tests/Models/Webhooks/BaseWebhookEventTest.cs index a908a877..ed5b204c 100644 --- a/src/ImageKit.Tests/Models/Webhooks/BaseWebhookEventTest.cs +++ b/src/Imagekit.Tests/Models/Webhooks/BaseWebhookEventTest.cs @@ -1,8 +1,8 @@ using System.Text.Json; -using ImageKit.Core; -using ImageKit.Models.Webhooks; +using Imagekit.Core; +using Imagekit.Models.Webhooks; -namespace ImageKit.Tests.Models.Webhooks; +namespace Imagekit.Tests.Models.Webhooks; public class BaseWebhookEventTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Webhooks/FileCreateEventTest.cs b/src/Imagekit.Tests/Models/Webhooks/FileCreateEventTest.cs similarity index 97% rename from src/ImageKit.Tests/Models/Webhooks/FileCreateEventTest.cs rename to src/Imagekit.Tests/Models/Webhooks/FileCreateEventTest.cs index 8ec2e0fa..65edd2ba 100644 --- a/src/ImageKit.Tests/Models/Webhooks/FileCreateEventTest.cs +++ b/src/Imagekit.Tests/Models/Webhooks/FileCreateEventTest.cs @@ -1,11 +1,11 @@ using System; using System.Collections.Generic; using System.Text.Json; -using ImageKit.Core; -using ImageKit.Models.Webhooks; -using Files = ImageKit.Models.Files; +using Imagekit.Core; +using Imagekit.Models.Webhooks; +using Files = Imagekit.Models.Files; -namespace ImageKit.Tests.Models.Webhooks; +namespace Imagekit.Tests.Models.Webhooks; public class FileCreateEventTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Webhooks/FileDeleteEventTest.cs b/src/Imagekit.Tests/Models/Webhooks/FileDeleteEventTest.cs similarity index 95% rename from src/ImageKit.Tests/Models/Webhooks/FileDeleteEventTest.cs rename to src/Imagekit.Tests/Models/Webhooks/FileDeleteEventTest.cs index 46045359..f843d87f 100644 --- a/src/ImageKit.Tests/Models/Webhooks/FileDeleteEventTest.cs +++ b/src/Imagekit.Tests/Models/Webhooks/FileDeleteEventTest.cs @@ -1,9 +1,9 @@ using System; using System.Text.Json; -using ImageKit.Core; -using ImageKit.Models.Webhooks; +using Imagekit.Core; +using Imagekit.Models.Webhooks; -namespace ImageKit.Tests.Models.Webhooks; +namespace Imagekit.Tests.Models.Webhooks; public class FileDeleteEventTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Webhooks/FileUpdateEventTest.cs b/src/Imagekit.Tests/Models/Webhooks/FileUpdateEventTest.cs similarity index 97% rename from src/ImageKit.Tests/Models/Webhooks/FileUpdateEventTest.cs rename to src/Imagekit.Tests/Models/Webhooks/FileUpdateEventTest.cs index 71095754..3318797b 100644 --- a/src/ImageKit.Tests/Models/Webhooks/FileUpdateEventTest.cs +++ b/src/Imagekit.Tests/Models/Webhooks/FileUpdateEventTest.cs @@ -1,11 +1,11 @@ using System; using System.Collections.Generic; using System.Text.Json; -using ImageKit.Core; -using ImageKit.Models.Webhooks; -using Files = ImageKit.Models.Files; +using Imagekit.Core; +using Imagekit.Models.Webhooks; +using Files = Imagekit.Models.Files; -namespace ImageKit.Tests.Models.Webhooks; +namespace Imagekit.Tests.Models.Webhooks; public class FileUpdateEventTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Webhooks/FileVersionCreateEventTest.cs b/src/Imagekit.Tests/Models/Webhooks/FileVersionCreateEventTest.cs similarity index 97% rename from src/ImageKit.Tests/Models/Webhooks/FileVersionCreateEventTest.cs rename to src/Imagekit.Tests/Models/Webhooks/FileVersionCreateEventTest.cs index 9cf1785e..26e61a17 100644 --- a/src/ImageKit.Tests/Models/Webhooks/FileVersionCreateEventTest.cs +++ b/src/Imagekit.Tests/Models/Webhooks/FileVersionCreateEventTest.cs @@ -1,11 +1,11 @@ using System; using System.Collections.Generic; using System.Text.Json; -using ImageKit.Core; -using ImageKit.Models.Webhooks; -using Files = ImageKit.Models.Files; +using Imagekit.Core; +using Imagekit.Models.Webhooks; +using Files = Imagekit.Models.Files; -namespace ImageKit.Tests.Models.Webhooks; +namespace Imagekit.Tests.Models.Webhooks; public class FileVersionCreateEventTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Webhooks/FileVersionDeleteEventTest.cs b/src/Imagekit.Tests/Models/Webhooks/FileVersionDeleteEventTest.cs similarity index 95% rename from src/ImageKit.Tests/Models/Webhooks/FileVersionDeleteEventTest.cs rename to src/Imagekit.Tests/Models/Webhooks/FileVersionDeleteEventTest.cs index fac2ce1b..ed0dd3b2 100644 --- a/src/ImageKit.Tests/Models/Webhooks/FileVersionDeleteEventTest.cs +++ b/src/Imagekit.Tests/Models/Webhooks/FileVersionDeleteEventTest.cs @@ -1,9 +1,9 @@ using System; using System.Text.Json; -using ImageKit.Core; -using ImageKit.Models.Webhooks; +using Imagekit.Core; +using Imagekit.Models.Webhooks; -namespace ImageKit.Tests.Models.Webhooks; +namespace Imagekit.Tests.Models.Webhooks; public class FileVersionDeleteEventTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs b/src/Imagekit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs similarity index 97% rename from src/ImageKit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs rename to src/Imagekit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs index c8320a2e..2dc7c3f8 100644 --- a/src/ImageKit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs +++ b/src/Imagekit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs @@ -1,11 +1,11 @@ using System; using System.Collections.Generic; using System.Text.Json; -using ImageKit.Core; -using Files = ImageKit.Models.Files; -using Webhooks = ImageKit.Models.Webhooks; +using Imagekit.Core; +using Files = Imagekit.Models.Files; +using Webhooks = Imagekit.Models.Webhooks; -namespace ImageKit.Tests.Models.Webhooks; +namespace Imagekit.Tests.Models.Webhooks; public class UnsafeUnwrapWebhookEventTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs b/src/Imagekit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs similarity index 97% rename from src/ImageKit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs rename to src/Imagekit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs index d6dc519d..391f5300 100644 --- a/src/ImageKit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs +++ b/src/Imagekit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs @@ -1,11 +1,11 @@ using System; using System.Collections.Generic; using System.Text.Json; -using ImageKit.Core; -using Files = ImageKit.Models.Files; -using Webhooks = ImageKit.Models.Webhooks; +using Imagekit.Core; +using Files = Imagekit.Models.Files; +using Webhooks = Imagekit.Models.Webhooks; -namespace ImageKit.Tests.Models.Webhooks; +namespace Imagekit.Tests.Models.Webhooks; public class UnwrapWebhookEventTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Webhooks/UploadPostTransformErrorEventTest.cs b/src/Imagekit.Tests/Models/Webhooks/UploadPostTransformErrorEventTest.cs similarity index 96% rename from src/ImageKit.Tests/Models/Webhooks/UploadPostTransformErrorEventTest.cs rename to src/Imagekit.Tests/Models/Webhooks/UploadPostTransformErrorEventTest.cs index 43d93c31..f200f972 100644 --- a/src/ImageKit.Tests/Models/Webhooks/UploadPostTransformErrorEventTest.cs +++ b/src/Imagekit.Tests/Models/Webhooks/UploadPostTransformErrorEventTest.cs @@ -1,10 +1,10 @@ using System; using System.Text.Json; -using ImageKit.Core; -using ImageKit.Exceptions; -using Webhooks = ImageKit.Models.Webhooks; +using Imagekit.Core; +using Imagekit.Exceptions; +using Webhooks = Imagekit.Models.Webhooks; -namespace ImageKit.Tests.Models.Webhooks; +namespace Imagekit.Tests.Models.Webhooks; public class UploadPostTransformErrorEventTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Webhooks/UploadPostTransformSuccessEventTest.cs b/src/Imagekit.Tests/Models/Webhooks/UploadPostTransformSuccessEventTest.cs similarity index 96% rename from src/ImageKit.Tests/Models/Webhooks/UploadPostTransformSuccessEventTest.cs rename to src/Imagekit.Tests/Models/Webhooks/UploadPostTransformSuccessEventTest.cs index 1007f99c..31dd1ca6 100644 --- a/src/ImageKit.Tests/Models/Webhooks/UploadPostTransformSuccessEventTest.cs +++ b/src/Imagekit.Tests/Models/Webhooks/UploadPostTransformSuccessEventTest.cs @@ -1,10 +1,10 @@ using System; using System.Text.Json; -using ImageKit.Core; -using ImageKit.Exceptions; -using ImageKit.Models.Webhooks; +using Imagekit.Core; +using Imagekit.Exceptions; +using Imagekit.Models.Webhooks; -namespace ImageKit.Tests.Models.Webhooks; +namespace Imagekit.Tests.Models.Webhooks; public class UploadPostTransformSuccessEventTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Webhooks/UploadPreTransformErrorEventTest.cs b/src/Imagekit.Tests/Models/Webhooks/UploadPreTransformErrorEventTest.cs similarity index 96% rename from src/ImageKit.Tests/Models/Webhooks/UploadPreTransformErrorEventTest.cs rename to src/Imagekit.Tests/Models/Webhooks/UploadPreTransformErrorEventTest.cs index 5e282a35..96d722ee 100644 --- a/src/ImageKit.Tests/Models/Webhooks/UploadPreTransformErrorEventTest.cs +++ b/src/Imagekit.Tests/Models/Webhooks/UploadPreTransformErrorEventTest.cs @@ -1,9 +1,9 @@ using System; using System.Text.Json; -using ImageKit.Core; -using ImageKit.Models.Webhooks; +using Imagekit.Core; +using Imagekit.Models.Webhooks; -namespace ImageKit.Tests.Models.Webhooks; +namespace Imagekit.Tests.Models.Webhooks; public class UploadPreTransformErrorEventTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Webhooks/UploadPreTransformSuccessEventTest.cs b/src/Imagekit.Tests/Models/Webhooks/UploadPreTransformSuccessEventTest.cs similarity index 97% rename from src/ImageKit.Tests/Models/Webhooks/UploadPreTransformSuccessEventTest.cs rename to src/Imagekit.Tests/Models/Webhooks/UploadPreTransformSuccessEventTest.cs index b12e1285..0a8326ed 100644 --- a/src/ImageKit.Tests/Models/Webhooks/UploadPreTransformSuccessEventTest.cs +++ b/src/Imagekit.Tests/Models/Webhooks/UploadPreTransformSuccessEventTest.cs @@ -1,12 +1,12 @@ using System; using System.Collections.Generic; using System.Text.Json; -using ImageKit.Core; -using ImageKit.Exceptions; -using ImageKit.Models.Webhooks; -using Files = ImageKit.Models.Files; +using Imagekit.Core; +using Imagekit.Exceptions; +using Imagekit.Models.Webhooks; +using Files = Imagekit.Models.Files; -namespace ImageKit.Tests.Models.Webhooks; +namespace Imagekit.Tests.Models.Webhooks; public class UploadPreTransformSuccessEventTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Webhooks/VideoTransformationAcceptedEventTest.cs b/src/Imagekit.Tests/Models/Webhooks/VideoTransformationAcceptedEventTest.cs similarity index 96% rename from src/ImageKit.Tests/Models/Webhooks/VideoTransformationAcceptedEventTest.cs rename to src/Imagekit.Tests/Models/Webhooks/VideoTransformationAcceptedEventTest.cs index 9f85e687..346342ff 100644 --- a/src/ImageKit.Tests/Models/Webhooks/VideoTransformationAcceptedEventTest.cs +++ b/src/Imagekit.Tests/Models/Webhooks/VideoTransformationAcceptedEventTest.cs @@ -1,11 +1,11 @@ using System; using System.Collections.Generic; using System.Text.Json; -using ImageKit.Core; -using ImageKit.Exceptions; -using ImageKit.Models.Webhooks; +using Imagekit.Core; +using Imagekit.Exceptions; +using Imagekit.Models.Webhooks; -namespace ImageKit.Tests.Models.Webhooks; +namespace Imagekit.Tests.Models.Webhooks; public class VideoTransformationAcceptedEventTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Webhooks/VideoTransformationErrorEventTest.cs b/src/Imagekit.Tests/Models/Webhooks/VideoTransformationErrorEventTest.cs similarity index 97% rename from src/ImageKit.Tests/Models/Webhooks/VideoTransformationErrorEventTest.cs rename to src/Imagekit.Tests/Models/Webhooks/VideoTransformationErrorEventTest.cs index f3069341..418a5efe 100644 --- a/src/ImageKit.Tests/Models/Webhooks/VideoTransformationErrorEventTest.cs +++ b/src/Imagekit.Tests/Models/Webhooks/VideoTransformationErrorEventTest.cs @@ -1,11 +1,11 @@ using System; using System.Collections.Generic; using System.Text.Json; -using ImageKit.Core; -using ImageKit.Exceptions; -using ImageKit.Models.Webhooks; +using Imagekit.Core; +using Imagekit.Exceptions; +using Imagekit.Models.Webhooks; -namespace ImageKit.Tests.Models.Webhooks; +namespace Imagekit.Tests.Models.Webhooks; public class VideoTransformationErrorEventTest : TestBase { diff --git a/src/ImageKit.Tests/Models/Webhooks/VideoTransformationReadyEventTest.cs b/src/Imagekit.Tests/Models/Webhooks/VideoTransformationReadyEventTest.cs similarity index 97% rename from src/ImageKit.Tests/Models/Webhooks/VideoTransformationReadyEventTest.cs rename to src/Imagekit.Tests/Models/Webhooks/VideoTransformationReadyEventTest.cs index 7cd8086e..ffc6afd3 100644 --- a/src/ImageKit.Tests/Models/Webhooks/VideoTransformationReadyEventTest.cs +++ b/src/Imagekit.Tests/Models/Webhooks/VideoTransformationReadyEventTest.cs @@ -1,11 +1,11 @@ using System; using System.Collections.Generic; using System.Text.Json; -using ImageKit.Core; -using ImageKit.Exceptions; -using ImageKit.Models.Webhooks; +using Imagekit.Core; +using Imagekit.Exceptions; +using Imagekit.Models.Webhooks; -namespace ImageKit.Tests.Models.Webhooks; +namespace Imagekit.Tests.Models.Webhooks; public class VideoTransformationReadyEventTest : TestBase { diff --git a/src/ImageKit.Tests/RetriesTest.cs b/src/Imagekit.Tests/RetriesTest.cs similarity index 96% rename from src/ImageKit.Tests/RetriesTest.cs rename to src/Imagekit.Tests/RetriesTest.cs index f273257e..c60b4e7f 100644 --- a/src/ImageKit.Tests/RetriesTest.cs +++ b/src/Imagekit.Tests/RetriesTest.cs @@ -4,12 +4,12 @@ using System.Net.Http; using System.Threading; using System.Threading.Tasks; -using ImageKit; -using ImageKit.Core; +using Imagekit; +using Imagekit.Core; using Moq; using Moq.Protected; -namespace ImageKit.Tests; +namespace Imagekit.Tests; public class RetriesTest : TestBase { diff --git a/src/ImageKit.Tests/Services/Accounts/OriginServiceTest.cs b/src/Imagekit.Tests/Services/Accounts/OriginServiceTest.cs similarity index 93% rename from src/ImageKit.Tests/Services/Accounts/OriginServiceTest.cs rename to src/Imagekit.Tests/Services/Accounts/OriginServiceTest.cs index 2bab595d..c8a31cff 100644 --- a/src/ImageKit.Tests/Services/Accounts/OriginServiceTest.cs +++ b/src/Imagekit.Tests/Services/Accounts/OriginServiceTest.cs @@ -1,7 +1,7 @@ using System.Threading.Tasks; -using ImageKit.Models.Accounts.Origins; +using Imagekit.Models.Accounts.Origins; -namespace ImageKit.Tests.Services.Accounts; +namespace Imagekit.Tests.Services.Accounts; public class OriginServiceTest : TestBase { diff --git a/src/ImageKit.Tests/Services/Accounts/UrlEndpointServiceTest.cs b/src/Imagekit.Tests/Services/Accounts/UrlEndpointServiceTest.cs similarity index 94% rename from src/ImageKit.Tests/Services/Accounts/UrlEndpointServiceTest.cs rename to src/Imagekit.Tests/Services/Accounts/UrlEndpointServiceTest.cs index 77e8adfc..0b53ee12 100644 --- a/src/ImageKit.Tests/Services/Accounts/UrlEndpointServiceTest.cs +++ b/src/Imagekit.Tests/Services/Accounts/UrlEndpointServiceTest.cs @@ -1,6 +1,6 @@ using System.Threading.Tasks; -namespace ImageKit.Tests.Services.Accounts; +namespace Imagekit.Tests.Services.Accounts; public class UrlEndpointServiceTest : TestBase { diff --git a/src/ImageKit.Tests/Services/Accounts/UsageServiceTest.cs b/src/Imagekit.Tests/Services/Accounts/UsageServiceTest.cs similarity index 86% rename from src/ImageKit.Tests/Services/Accounts/UsageServiceTest.cs rename to src/Imagekit.Tests/Services/Accounts/UsageServiceTest.cs index 8637eded..ae97a44c 100644 --- a/src/ImageKit.Tests/Services/Accounts/UsageServiceTest.cs +++ b/src/Imagekit.Tests/Services/Accounts/UsageServiceTest.cs @@ -1,6 +1,6 @@ using System.Threading.Tasks; -namespace ImageKit.Tests.Services.Accounts; +namespace Imagekit.Tests.Services.Accounts; public class UsageServiceTest : TestBase { diff --git a/src/ImageKit.Tests/Services/AssetServiceTest.cs b/src/Imagekit.Tests/Services/AssetServiceTest.cs similarity index 87% rename from src/ImageKit.Tests/Services/AssetServiceTest.cs rename to src/Imagekit.Tests/Services/AssetServiceTest.cs index 74c9f150..8e9e585f 100644 --- a/src/ImageKit.Tests/Services/AssetServiceTest.cs +++ b/src/Imagekit.Tests/Services/AssetServiceTest.cs @@ -1,6 +1,6 @@ using System.Threading.Tasks; -namespace ImageKit.Tests.Services; +namespace Imagekit.Tests.Services; public class AssetServiceTest : TestBase { diff --git a/src/ImageKit.Tests/Services/Beta/V2/FileServiceTest.cs b/src/Imagekit.Tests/Services/Beta/V2/FileServiceTest.cs similarity index 88% rename from src/ImageKit.Tests/Services/Beta/V2/FileServiceTest.cs rename to src/Imagekit.Tests/Services/Beta/V2/FileServiceTest.cs index df377064..41119a76 100644 --- a/src/ImageKit.Tests/Services/Beta/V2/FileServiceTest.cs +++ b/src/Imagekit.Tests/Services/Beta/V2/FileServiceTest.cs @@ -1,7 +1,7 @@ using System.Text; using System.Threading.Tasks; -namespace ImageKit.Tests.Services.Beta.V2; +namespace Imagekit.Tests.Services.Beta.V2; public class FileServiceTest : TestBase { diff --git a/src/ImageKit.Tests/Services/Cache/InvalidationServiceTest.cs b/src/Imagekit.Tests/Services/Cache/InvalidationServiceTest.cs similarity index 91% rename from src/ImageKit.Tests/Services/Cache/InvalidationServiceTest.cs rename to src/Imagekit.Tests/Services/Cache/InvalidationServiceTest.cs index 42c4e0a6..30233526 100644 --- a/src/ImageKit.Tests/Services/Cache/InvalidationServiceTest.cs +++ b/src/Imagekit.Tests/Services/Cache/InvalidationServiceTest.cs @@ -1,6 +1,6 @@ using System.Threading.Tasks; -namespace ImageKit.Tests.Services.Cache; +namespace Imagekit.Tests.Services.Cache; public class InvalidationServiceTest : TestBase { diff --git a/src/ImageKit.Tests/Services/CustomMetadataFieldServiceTest.cs b/src/Imagekit.Tests/Services/CustomMetadataFieldServiceTest.cs similarity index 93% rename from src/ImageKit.Tests/Services/CustomMetadataFieldServiceTest.cs rename to src/Imagekit.Tests/Services/CustomMetadataFieldServiceTest.cs index 36001a81..d9e95236 100644 --- a/src/ImageKit.Tests/Services/CustomMetadataFieldServiceTest.cs +++ b/src/Imagekit.Tests/Services/CustomMetadataFieldServiceTest.cs @@ -1,7 +1,7 @@ using System.Threading.Tasks; -using ImageKit.Models.CustomMetadataFields; +using Imagekit.Models.CustomMetadataFields; -namespace ImageKit.Tests.Services; +namespace Imagekit.Tests.Services; public class CustomMetadataFieldServiceTest : TestBase { diff --git a/src/ImageKit.Tests/Services/FileServiceTest.cs b/src/Imagekit.Tests/Services/FileServiceTest.cs similarity index 95% rename from src/ImageKit.Tests/Services/FileServiceTest.cs rename to src/Imagekit.Tests/Services/FileServiceTest.cs index 278afa14..d6a64744 100644 --- a/src/ImageKit.Tests/Services/FileServiceTest.cs +++ b/src/Imagekit.Tests/Services/FileServiceTest.cs @@ -2,10 +2,10 @@ using System.Text; using System.Text.Json; using System.Threading.Tasks; -using ImageKit.Models.Files; -using Models = ImageKit.Models; +using Imagekit.Models.Files; +using Models = Imagekit.Models; -namespace ImageKit.Tests.Services; +namespace Imagekit.Tests.Services; public class FileServiceTest : TestBase { diff --git a/src/ImageKit.Tests/Services/Files/BulkServiceTest.cs b/src/Imagekit.Tests/Services/Files/BulkServiceTest.cs similarity index 94% rename from src/ImageKit.Tests/Services/Files/BulkServiceTest.cs rename to src/Imagekit.Tests/Services/Files/BulkServiceTest.cs index b5d3f578..4cf50d5c 100644 --- a/src/ImageKit.Tests/Services/Files/BulkServiceTest.cs +++ b/src/Imagekit.Tests/Services/Files/BulkServiceTest.cs @@ -1,6 +1,6 @@ using System.Threading.Tasks; -namespace ImageKit.Tests.Services.Files; +namespace Imagekit.Tests.Services.Files; public class BulkServiceTest : TestBase { diff --git a/src/ImageKit.Tests/Services/Files/MetadataServiceTest.cs b/src/Imagekit.Tests/Services/Files/MetadataServiceTest.cs similarity index 91% rename from src/ImageKit.Tests/Services/Files/MetadataServiceTest.cs rename to src/Imagekit.Tests/Services/Files/MetadataServiceTest.cs index f47cb544..b38204db 100644 --- a/src/ImageKit.Tests/Services/Files/MetadataServiceTest.cs +++ b/src/Imagekit.Tests/Services/Files/MetadataServiceTest.cs @@ -1,6 +1,6 @@ using System.Threading.Tasks; -namespace ImageKit.Tests.Services.Files; +namespace Imagekit.Tests.Services.Files; public class MetadataServiceTest : TestBase { diff --git a/src/ImageKit.Tests/Services/Files/VersionServiceTest.cs b/src/Imagekit.Tests/Services/Files/VersionServiceTest.cs similarity index 93% rename from src/ImageKit.Tests/Services/Files/VersionServiceTest.cs rename to src/Imagekit.Tests/Services/Files/VersionServiceTest.cs index 2318c8e8..e3594102 100644 --- a/src/ImageKit.Tests/Services/Files/VersionServiceTest.cs +++ b/src/Imagekit.Tests/Services/Files/VersionServiceTest.cs @@ -1,6 +1,6 @@ using System.Threading.Tasks; -namespace ImageKit.Tests.Services.Files; +namespace Imagekit.Tests.Services.Files; public class VersionServiceTest : TestBase { diff --git a/src/ImageKit.Tests/Services/FolderServiceTest.cs b/src/Imagekit.Tests/Services/FolderServiceTest.cs similarity index 95% rename from src/ImageKit.Tests/Services/FolderServiceTest.cs rename to src/Imagekit.Tests/Services/FolderServiceTest.cs index 3db9f864..f2a351f4 100644 --- a/src/ImageKit.Tests/Services/FolderServiceTest.cs +++ b/src/Imagekit.Tests/Services/FolderServiceTest.cs @@ -1,6 +1,6 @@ using System.Threading.Tasks; -namespace ImageKit.Tests.Services; +namespace Imagekit.Tests.Services; public class FolderServiceTest : TestBase { diff --git a/src/ImageKit.Tests/Services/Folders/JobServiceTest.cs b/src/Imagekit.Tests/Services/Folders/JobServiceTest.cs similarity index 85% rename from src/ImageKit.Tests/Services/Folders/JobServiceTest.cs rename to src/Imagekit.Tests/Services/Folders/JobServiceTest.cs index b3d76b7b..2864fabf 100644 --- a/src/ImageKit.Tests/Services/Folders/JobServiceTest.cs +++ b/src/Imagekit.Tests/Services/Folders/JobServiceTest.cs @@ -1,6 +1,6 @@ using System.Threading.Tasks; -namespace ImageKit.Tests.Services.Folders; +namespace Imagekit.Tests.Services.Folders; public class JobServiceTest : TestBase { diff --git a/src/ImageKit.Tests/Services/SavedExtensionServiceTest.cs b/src/Imagekit.Tests/Services/SavedExtensionServiceTest.cs similarity index 93% rename from src/ImageKit.Tests/Services/SavedExtensionServiceTest.cs rename to src/Imagekit.Tests/Services/SavedExtensionServiceTest.cs index b0c5adfc..150bf54d 100644 --- a/src/ImageKit.Tests/Services/SavedExtensionServiceTest.cs +++ b/src/Imagekit.Tests/Services/SavedExtensionServiceTest.cs @@ -1,7 +1,7 @@ using System.Threading.Tasks; -using Models = ImageKit.Models; +using Models = Imagekit.Models; -namespace ImageKit.Tests.Services; +namespace Imagekit.Tests.Services; public class SavedExtensionServiceTest : TestBase { diff --git a/src/ImageKit.Tests/TestBase.cs b/src/Imagekit.Tests/TestBase.cs similarity index 93% rename from src/ImageKit.Tests/TestBase.cs rename to src/Imagekit.Tests/TestBase.cs index e73e908c..e661d50f 100644 --- a/src/ImageKit.Tests/TestBase.cs +++ b/src/Imagekit.Tests/TestBase.cs @@ -1,9 +1,9 @@ using System; using System.Collections.Generic; using System.Linq; -using ImageKit; +using Imagekit; -namespace ImageKit.Tests; +namespace Imagekit.Tests; public class TestBase { diff --git a/src/ImageKit/Core/ApiEnum.cs b/src/Imagekit/Core/ApiEnum.cs similarity index 96% rename from src/ImageKit/Core/ApiEnum.cs rename to src/Imagekit/Core/ApiEnum.cs index 3c82b6fb..a3e25efe 100644 --- a/src/ImageKit/Core/ApiEnum.cs +++ b/src/Imagekit/Core/ApiEnum.cs @@ -1,9 +1,9 @@ using System; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Exceptions; +using Imagekit.Exceptions; -namespace ImageKit.Core; +namespace Imagekit.Core; /// /// A serializable and deserializable enum wrapper type that handles the possibility of values outside the diff --git a/src/ImageKit/Core/BinaryContent.cs b/src/Imagekit/Core/BinaryContent.cs similarity index 93% rename from src/ImageKit/Core/BinaryContent.cs rename to src/Imagekit/Core/BinaryContent.cs index a694d9e3..8e147178 100644 --- a/src/ImageKit/Core/BinaryContent.cs +++ b/src/Imagekit/Core/BinaryContent.cs @@ -1,7 +1,7 @@ using System.IO; using System.Net.Http.Headers; -namespace ImageKit.Core; +namespace Imagekit.Core; /// /// A class representing a binary stream of data with its associated (optional) file diff --git a/src/ImageKit/Core/ClientOptions.cs b/src/Imagekit/Core/ClientOptions.cs similarity index 96% rename from src/ImageKit/Core/ClientOptions.cs rename to src/Imagekit/Core/ClientOptions.cs index f9f29458..e5fa096e 100644 --- a/src/ImageKit/Core/ClientOptions.cs +++ b/src/Imagekit/Core/ClientOptions.cs @@ -1,8 +1,8 @@ using System; using System.Net.Http; -using ImageKit.Exceptions; +using Imagekit.Exceptions; -namespace ImageKit.Core; +namespace Imagekit.Core; /// /// A class representing the SDK client configuration. diff --git a/src/ImageKit/Core/DecompressionMethods.cs b/src/Imagekit/Core/DecompressionMethods.cs similarity index 94% rename from src/ImageKit/Core/DecompressionMethods.cs rename to src/Imagekit/Core/DecompressionMethods.cs index 187fe0ca..048568d0 100644 --- a/src/ImageKit/Core/DecompressionMethods.cs +++ b/src/Imagekit/Core/DecompressionMethods.cs @@ -2,7 +2,7 @@ using System.IO.Compression; using Net = System.Net; -namespace ImageKit.Core; +namespace Imagekit.Core; static class DecompressionMethods { diff --git a/src/ImageKit/Core/EnvironmentUrl.cs b/src/Imagekit/Core/EnvironmentUrl.cs similarity index 78% rename from src/ImageKit/Core/EnvironmentUrl.cs rename to src/Imagekit/Core/EnvironmentUrl.cs index 0e4da612..e3d88118 100644 --- a/src/ImageKit/Core/EnvironmentUrl.cs +++ b/src/Imagekit/Core/EnvironmentUrl.cs @@ -1,4 +1,4 @@ -namespace ImageKit.Core; +namespace Imagekit.Core; public static class EnvironmentUrl { diff --git a/src/ImageKit/Core/FriendlyJsonPrinter.cs b/src/Imagekit/Core/FriendlyJsonPrinter.cs similarity index 96% rename from src/ImageKit/Core/FriendlyJsonPrinter.cs rename to src/Imagekit/Core/FriendlyJsonPrinter.cs index 7ee1bfa7..afe5b60d 100644 --- a/src/ImageKit/Core/FriendlyJsonPrinter.cs +++ b/src/Imagekit/Core/FriendlyJsonPrinter.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Text.Json; -namespace ImageKit.Core; +namespace Imagekit.Core; static class FriendlyJsonPrinter { diff --git a/src/ImageKit/Core/FrozenDictionaryConverterFactory.cs b/src/Imagekit/Core/FrozenDictionaryConverterFactory.cs similarity index 95% rename from src/ImageKit/Core/FrozenDictionaryConverterFactory.cs rename to src/Imagekit/Core/FrozenDictionaryConverterFactory.cs index 186532d1..6bc82d86 100644 --- a/src/ImageKit/Core/FrozenDictionaryConverterFactory.cs +++ b/src/Imagekit/Core/FrozenDictionaryConverterFactory.cs @@ -4,7 +4,7 @@ using System.Text.Json; using System.Text.Json.Serialization; -namespace ImageKit.Core; +namespace Imagekit.Core; sealed class FrozenDictionaryConverterFactory : JsonConverterFactory { diff --git a/src/ImageKit/Core/HttpRequest.cs b/src/Imagekit/Core/HttpRequest.cs similarity index 92% rename from src/ImageKit/Core/HttpRequest.cs rename to src/Imagekit/Core/HttpRequest.cs index 5017e843..b5079abf 100644 --- a/src/ImageKit/Core/HttpRequest.cs +++ b/src/Imagekit/Core/HttpRequest.cs @@ -1,6 +1,6 @@ using System.Net.Http; -namespace ImageKit.Core; +namespace Imagekit.Core; public sealed class HttpRequest

where P : ParamsBase diff --git a/src/ImageKit/Core/HttpResponse.cs b/src/Imagekit/Core/HttpResponse.cs similarity index 95% rename from src/ImageKit/Core/HttpResponse.cs rename to src/Imagekit/Core/HttpResponse.cs index 478cbc91..535ae233 100644 --- a/src/ImageKit/Core/HttpResponse.cs +++ b/src/Imagekit/Core/HttpResponse.cs @@ -7,10 +7,10 @@ using System.Runtime.CompilerServices; using System.Text.Json; using System.Threading.Tasks; -using ImageKit.Exceptions; +using Imagekit.Exceptions; using Threading = System.Threading; -namespace ImageKit.Core; +namespace Imagekit.Core; public class HttpResponse : IDisposable { diff --git a/src/ImageKit/Core/IPage.cs b/src/Imagekit/Core/IPage.cs similarity index 94% rename from src/ImageKit/Core/IPage.cs rename to src/Imagekit/Core/IPage.cs index 3ebcacdb..fe38cf8c 100644 --- a/src/ImageKit/Core/IPage.cs +++ b/src/Imagekit/Core/IPage.cs @@ -1,9 +1,9 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using ImageKit.Exceptions; +using Imagekit.Exceptions; -namespace ImageKit.Core; +namespace Imagekit.Core; ///

/// An interface representing a single page, with items of type , from a diff --git a/src/ImageKit/Core/JsonDictionary.cs b/src/Imagekit/Core/JsonDictionary.cs similarity index 95% rename from src/ImageKit/Core/JsonDictionary.cs rename to src/Imagekit/Core/JsonDictionary.cs index b8fdaa69..6074a2bd 100644 --- a/src/ImageKit/Core/JsonDictionary.cs +++ b/src/Imagekit/Core/JsonDictionary.cs @@ -4,9 +4,9 @@ using System.Collections.Generic; using System.Linq; using System.Text.Json; -using ImageKit.Exceptions; +using Imagekit.Exceptions; -namespace ImageKit.Core; +namespace Imagekit.Core; /// /// A dictionary that holds JSON data. diff --git a/src/ImageKit/Core/JsonModel.cs b/src/Imagekit/Core/JsonModel.cs similarity index 95% rename from src/ImageKit/Core/JsonModel.cs rename to src/Imagekit/Core/JsonModel.cs index 5655c971..ed57a19f 100644 --- a/src/ImageKit/Core/JsonModel.cs +++ b/src/Imagekit/Core/JsonModel.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Text.Json; -namespace ImageKit.Core; +namespace Imagekit.Core; /// /// The base class for all API objects that are serialized as JSON objects. diff --git a/src/ImageKit/Core/JsonModelConverter.cs b/src/Imagekit/Core/JsonModelConverter.cs similarity index 93% rename from src/ImageKit/Core/JsonModelConverter.cs rename to src/Imagekit/Core/JsonModelConverter.cs index acb8ed50..882e5eca 100644 --- a/src/ImageKit/Core/JsonModelConverter.cs +++ b/src/Imagekit/Core/JsonModelConverter.cs @@ -3,7 +3,7 @@ using System.Text.Json; using System.Text.Json.Serialization; -namespace ImageKit.Core; +namespace Imagekit.Core; sealed class JsonModelConverter : JsonConverter where TModel : JsonModel diff --git a/src/ImageKit/Core/ModelBase.cs b/src/Imagekit/Core/ModelBase.cs similarity index 93% rename from src/ImageKit/Core/ModelBase.cs rename to src/Imagekit/Core/ModelBase.cs index 616e6674..d730b126 100644 --- a/src/ImageKit/Core/ModelBase.cs +++ b/src/Imagekit/Core/ModelBase.cs @@ -1,15 +1,15 @@ using System.Text.Json; -using ImageKit.Exceptions; -using ImageKit.Models; -using ImageKit.Models.Cache.Invalidation; -using ImageKit.Models.CustomMetadataFields; -using Assets = ImageKit.Models.Assets; -using Files = ImageKit.Models.Files; -using Job = ImageKit.Models.Folders.Job; -using V2Files = ImageKit.Models.Beta.V2.Files; -using Webhooks = ImageKit.Models.Webhooks; +using Imagekit.Exceptions; +using Imagekit.Models; +using Imagekit.Models.Cache.Invalidation; +using Imagekit.Models.CustomMetadataFields; +using Assets = Imagekit.Models.Assets; +using Files = Imagekit.Models.Files; +using Job = Imagekit.Models.Folders.Job; +using V2Files = Imagekit.Models.Beta.V2.Files; +using Webhooks = Imagekit.Models.Webhooks; -namespace ImageKit.Core; +namespace Imagekit.Core; /// /// The base class for all API objects with properties. diff --git a/src/ImageKit/Core/MultipartJsonDictionary.cs b/src/Imagekit/Core/MultipartJsonDictionary.cs similarity index 95% rename from src/ImageKit/Core/MultipartJsonDictionary.cs rename to src/Imagekit/Core/MultipartJsonDictionary.cs index fcde5210..296cc16d 100644 --- a/src/ImageKit/Core/MultipartJsonDictionary.cs +++ b/src/Imagekit/Core/MultipartJsonDictionary.cs @@ -4,9 +4,9 @@ using System.Collections.Generic; using System.Linq; using System.Text.Json; -using ImageKit.Exceptions; +using Imagekit.Exceptions; -namespace ImageKit.Core; +namespace Imagekit.Core; /// /// A dictionary that holds mixed JSON and binary content. diff --git a/src/ImageKit/Core/MultipartJsonElement.cs b/src/Imagekit/Core/MultipartJsonElement.cs similarity index 97% rename from src/ImageKit/Core/MultipartJsonElement.cs rename to src/Imagekit/Core/MultipartJsonElement.cs index ebacb7f7..ade91ec0 100644 --- a/src/ImageKit/Core/MultipartJsonElement.cs +++ b/src/Imagekit/Core/MultipartJsonElement.cs @@ -8,7 +8,7 @@ using System.Text.Json.Serialization; using System.Threading; -namespace ImageKit.Core; +namespace Imagekit.Core; /// /// A that can contain . diff --git a/src/ImageKit/Core/MultipartJsonModel.cs b/src/Imagekit/Core/MultipartJsonModel.cs similarity index 95% rename from src/ImageKit/Core/MultipartJsonModel.cs rename to src/Imagekit/Core/MultipartJsonModel.cs index 653ca580..bec29096 100644 --- a/src/ImageKit/Core/MultipartJsonModel.cs +++ b/src/Imagekit/Core/MultipartJsonModel.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace ImageKit.Core; +namespace Imagekit.Core; /// /// The base class for all API objects that are serialized as a mix of JSON objects diff --git a/src/ImageKit/Core/MultipartJsonModelConverter.cs b/src/Imagekit/Core/MultipartJsonModelConverter.cs similarity index 93% rename from src/ImageKit/Core/MultipartJsonModelConverter.cs rename to src/Imagekit/Core/MultipartJsonModelConverter.cs index c439d05f..0f25795d 100644 --- a/src/ImageKit/Core/MultipartJsonModelConverter.cs +++ b/src/Imagekit/Core/MultipartJsonModelConverter.cs @@ -3,7 +3,7 @@ using System.Text.Json; using System.Text.Json.Serialization; -namespace ImageKit.Core; +namespace Imagekit.Core; sealed class MultipartJsonModelConverter : JsonConverter where TModel : MultipartJsonModel diff --git a/src/ImageKit/Core/ParamsBase.cs b/src/Imagekit/Core/ParamsBase.cs similarity index 96% rename from src/ImageKit/Core/ParamsBase.cs rename to src/Imagekit/Core/ParamsBase.cs index 46913b04..ac106ae5 100644 --- a/src/ImageKit/Core/ParamsBase.cs +++ b/src/Imagekit/Core/ParamsBase.cs @@ -9,7 +9,7 @@ using System.Text.Json; using System.Web; -namespace ImageKit.Core; +namespace Imagekit.Core; public abstract record class ParamsBase { diff --git a/src/ImageKit/Core/WrappedJsonSerializer.cs b/src/Imagekit/Core/WrappedJsonSerializer.cs similarity index 94% rename from src/ImageKit/Core/WrappedJsonSerializer.cs rename to src/Imagekit/Core/WrappedJsonSerializer.cs index 07c93be8..0650aa66 100644 --- a/src/ImageKit/Core/WrappedJsonSerializer.cs +++ b/src/Imagekit/Core/WrappedJsonSerializer.cs @@ -1,7 +1,7 @@ using System.Text.Json; -using ImageKit.Exceptions; +using Imagekit.Exceptions; -namespace ImageKit.Core; +namespace Imagekit.Core; /// /// Helper class for deserializing <c>JsonElement</c> objects. This handles diff --git a/src/ImageKit/Core/WrappedMultipartJsonSerializer.cs b/src/Imagekit/Core/WrappedMultipartJsonSerializer.cs similarity index 94% rename from src/ImageKit/Core/WrappedMultipartJsonSerializer.cs rename to src/Imagekit/Core/WrappedMultipartJsonSerializer.cs index d9cb47df..8cf6787e 100644 --- a/src/ImageKit/Core/WrappedMultipartJsonSerializer.cs +++ b/src/Imagekit/Core/WrappedMultipartJsonSerializer.cs @@ -1,7 +1,7 @@ using System.Text.Json; -using ImageKit.Exceptions; +using Imagekit.Exceptions; -namespace ImageKit.Core; +namespace Imagekit.Core; /// /// Helper class for deserializing <c>MultipartJsonElement</c> objects. diff --git a/src/ImageKit/Exceptions/ImageKit4xxException.cs b/src/Imagekit/Exceptions/ImageKit4xxException.cs similarity index 83% rename from src/ImageKit/Exceptions/ImageKit4xxException.cs rename to src/Imagekit/Exceptions/ImageKit4xxException.cs index a331b083..fb904eee 100644 --- a/src/ImageKit/Exceptions/ImageKit4xxException.cs +++ b/src/Imagekit/Exceptions/ImageKit4xxException.cs @@ -1,6 +1,6 @@ using System.Net.Http; -namespace ImageKit.Exceptions; +namespace Imagekit.Exceptions; public class ImageKit4xxException : ImageKitApiException { diff --git a/src/ImageKit/Exceptions/ImageKit5xxException.cs b/src/Imagekit/Exceptions/ImageKit5xxException.cs similarity index 83% rename from src/ImageKit/Exceptions/ImageKit5xxException.cs rename to src/Imagekit/Exceptions/ImageKit5xxException.cs index ee25a2fb..5c3bf57b 100644 --- a/src/ImageKit/Exceptions/ImageKit5xxException.cs +++ b/src/Imagekit/Exceptions/ImageKit5xxException.cs @@ -1,6 +1,6 @@ using System.Net.Http; -namespace ImageKit.Exceptions; +namespace Imagekit.Exceptions; public class ImageKit5xxException : ImageKitApiException { diff --git a/src/ImageKit/Exceptions/ImageKitApiException.cs b/src/Imagekit/Exceptions/ImageKitApiException.cs similarity index 93% rename from src/ImageKit/Exceptions/ImageKitApiException.cs rename to src/Imagekit/Exceptions/ImageKitApiException.cs index b9ddce4e..9ff6b86b 100644 --- a/src/ImageKit/Exceptions/ImageKitApiException.cs +++ b/src/Imagekit/Exceptions/ImageKitApiException.cs @@ -2,7 +2,7 @@ using System.Net; using System.Net.Http; -namespace ImageKit.Exceptions; +namespace Imagekit.Exceptions; public class ImageKitApiException : ImageKitException { diff --git a/src/ImageKit/Exceptions/ImageKitBadRequestException.cs b/src/Imagekit/Exceptions/ImageKitBadRequestException.cs similarity index 84% rename from src/ImageKit/Exceptions/ImageKitBadRequestException.cs rename to src/Imagekit/Exceptions/ImageKitBadRequestException.cs index 31948462..5c95d8d4 100644 --- a/src/ImageKit/Exceptions/ImageKitBadRequestException.cs +++ b/src/Imagekit/Exceptions/ImageKitBadRequestException.cs @@ -1,6 +1,6 @@ using System.Net.Http; -namespace ImageKit.Exceptions; +namespace Imagekit.Exceptions; public class ImageKitBadRequestException : ImageKit4xxException { diff --git a/src/ImageKit/Exceptions/ImageKitException.cs b/src/Imagekit/Exceptions/ImageKitException.cs similarity index 87% rename from src/ImageKit/Exceptions/ImageKitException.cs rename to src/Imagekit/Exceptions/ImageKitException.cs index 10e2743c..bf964025 100644 --- a/src/ImageKit/Exceptions/ImageKitException.cs +++ b/src/Imagekit/Exceptions/ImageKitException.cs @@ -1,7 +1,7 @@ using System; using System.Net.Http; -namespace ImageKit.Exceptions; +namespace Imagekit.Exceptions; public class ImageKitException : Exception { diff --git a/src/ImageKit/Exceptions/ImageKitExceptionFactory.cs b/src/Imagekit/Exceptions/ImageKitExceptionFactory.cs similarity index 95% rename from src/ImageKit/Exceptions/ImageKitExceptionFactory.cs rename to src/Imagekit/Exceptions/ImageKitExceptionFactory.cs index 88c167e2..768f05e5 100644 --- a/src/ImageKit/Exceptions/ImageKitExceptionFactory.cs +++ b/src/Imagekit/Exceptions/ImageKitExceptionFactory.cs @@ -1,6 +1,6 @@ using System.Net; -namespace ImageKit.Exceptions; +namespace Imagekit.Exceptions; public class ImageKitExceptionFactory { diff --git a/src/ImageKit/Exceptions/ImageKitForbiddenException.cs b/src/Imagekit/Exceptions/ImageKitForbiddenException.cs similarity index 84% rename from src/ImageKit/Exceptions/ImageKitForbiddenException.cs rename to src/Imagekit/Exceptions/ImageKitForbiddenException.cs index 511d899d..fbd39380 100644 --- a/src/ImageKit/Exceptions/ImageKitForbiddenException.cs +++ b/src/Imagekit/Exceptions/ImageKitForbiddenException.cs @@ -1,6 +1,6 @@ using System.Net.Http; -namespace ImageKit.Exceptions; +namespace Imagekit.Exceptions; public class ImageKitForbiddenException : ImageKit4xxException { diff --git a/src/ImageKit/Exceptions/ImageKitIOException.cs b/src/Imagekit/Exceptions/ImageKitIOException.cs similarity index 90% rename from src/ImageKit/Exceptions/ImageKitIOException.cs rename to src/Imagekit/Exceptions/ImageKitIOException.cs index 82ca6b37..bcfb380a 100644 --- a/src/ImageKit/Exceptions/ImageKitIOException.cs +++ b/src/Imagekit/Exceptions/ImageKitIOException.cs @@ -1,7 +1,7 @@ using System; using System.Net.Http; -namespace ImageKit.Exceptions; +namespace Imagekit.Exceptions; public class ImageKitIOException : ImageKitException { diff --git a/src/ImageKit/Exceptions/ImageKitInvalidDataException.cs b/src/Imagekit/Exceptions/ImageKitInvalidDataException.cs similarity index 84% rename from src/ImageKit/Exceptions/ImageKitInvalidDataException.cs rename to src/Imagekit/Exceptions/ImageKitInvalidDataException.cs index d63552b6..eda54a08 100644 --- a/src/ImageKit/Exceptions/ImageKitInvalidDataException.cs +++ b/src/Imagekit/Exceptions/ImageKitInvalidDataException.cs @@ -1,6 +1,6 @@ using System; -namespace ImageKit.Exceptions; +namespace Imagekit.Exceptions; public class ImageKitInvalidDataException : ImageKitException { diff --git a/src/ImageKit/Exceptions/ImageKitNotFoundException.cs b/src/Imagekit/Exceptions/ImageKitNotFoundException.cs similarity index 83% rename from src/ImageKit/Exceptions/ImageKitNotFoundException.cs rename to src/Imagekit/Exceptions/ImageKitNotFoundException.cs index 43369339..70c81820 100644 --- a/src/ImageKit/Exceptions/ImageKitNotFoundException.cs +++ b/src/Imagekit/Exceptions/ImageKitNotFoundException.cs @@ -1,6 +1,6 @@ using System.Net.Http; -namespace ImageKit.Exceptions; +namespace Imagekit.Exceptions; public class ImageKitNotFoundException : ImageKit4xxException { diff --git a/src/ImageKit/Exceptions/ImageKitRateLimitException.cs b/src/Imagekit/Exceptions/ImageKitRateLimitException.cs similarity index 84% rename from src/ImageKit/Exceptions/ImageKitRateLimitException.cs rename to src/Imagekit/Exceptions/ImageKitRateLimitException.cs index 921e8a8b..b93fe95a 100644 --- a/src/ImageKit/Exceptions/ImageKitRateLimitException.cs +++ b/src/Imagekit/Exceptions/ImageKitRateLimitException.cs @@ -1,6 +1,6 @@ using System.Net.Http; -namespace ImageKit.Exceptions; +namespace Imagekit.Exceptions; public class ImageKitRateLimitException : ImageKit4xxException { diff --git a/src/ImageKit/Exceptions/ImageKitUnauthorizedException.cs b/src/Imagekit/Exceptions/ImageKitUnauthorizedException.cs similarity index 84% rename from src/ImageKit/Exceptions/ImageKitUnauthorizedException.cs rename to src/Imagekit/Exceptions/ImageKitUnauthorizedException.cs index acb82679..0d360cc0 100644 --- a/src/ImageKit/Exceptions/ImageKitUnauthorizedException.cs +++ b/src/Imagekit/Exceptions/ImageKitUnauthorizedException.cs @@ -1,6 +1,6 @@ using System.Net.Http; -namespace ImageKit.Exceptions; +namespace Imagekit.Exceptions; public class ImageKitUnauthorizedException : ImageKit4xxException { diff --git a/src/ImageKit/Exceptions/ImageKitUnexpectedStatusCodeException.cs b/src/Imagekit/Exceptions/ImageKitUnexpectedStatusCodeException.cs similarity index 85% rename from src/ImageKit/Exceptions/ImageKitUnexpectedStatusCodeException.cs rename to src/Imagekit/Exceptions/ImageKitUnexpectedStatusCodeException.cs index a0b0a24b..155b0053 100644 --- a/src/ImageKit/Exceptions/ImageKitUnexpectedStatusCodeException.cs +++ b/src/Imagekit/Exceptions/ImageKitUnexpectedStatusCodeException.cs @@ -1,6 +1,6 @@ using System.Net.Http; -namespace ImageKit.Exceptions; +namespace Imagekit.Exceptions; public class ImageKitUnexpectedStatusCodeException : ImageKitApiException { diff --git a/src/ImageKit/Exceptions/ImageKitUnprocessableEntityException.cs b/src/Imagekit/Exceptions/ImageKitUnprocessableEntityException.cs similarity index 85% rename from src/ImageKit/Exceptions/ImageKitUnprocessableEntityException.cs rename to src/Imagekit/Exceptions/ImageKitUnprocessableEntityException.cs index b4cb9bd1..bc4d6cb8 100644 --- a/src/ImageKit/Exceptions/ImageKitUnprocessableEntityException.cs +++ b/src/Imagekit/Exceptions/ImageKitUnprocessableEntityException.cs @@ -1,6 +1,6 @@ using System.Net.Http; -namespace ImageKit.Exceptions; +namespace Imagekit.Exceptions; public class ImageKitUnprocessableEntityException : ImageKit4xxException { diff --git a/src/ImageKit/IImageKitClient.cs b/src/Imagekit/IImageKitClient.cs similarity index 95% rename from src/ImageKit/IImageKitClient.cs rename to src/Imagekit/IImageKitClient.cs index 161fe068..42269338 100644 --- a/src/ImageKit/IImageKitClient.cs +++ b/src/Imagekit/IImageKitClient.cs @@ -2,10 +2,10 @@ using System.Net.Http; using System.Threading; using System.Threading.Tasks; -using ImageKit.Core; -using ImageKit.Services; +using Imagekit.Core; +using Imagekit.Services; -namespace ImageKit; +namespace Imagekit; /// /// A client for interacting with the Image Kit REST API. diff --git a/src/ImageKit/IPageExtensions.cs b/src/Imagekit/IPageExtensions.cs similarity index 92% rename from src/ImageKit/IPageExtensions.cs rename to src/Imagekit/IPageExtensions.cs index 50e2a12c..1a8221fc 100644 --- a/src/ImageKit/IPageExtensions.cs +++ b/src/Imagekit/IPageExtensions.cs @@ -1,9 +1,9 @@ using System.Collections.Generic; using System.Runtime.CompilerServices; using System.Threading; -using ImageKit.Core; +using Imagekit.Core; -namespace ImageKit; +namespace Imagekit; public static class IPageExtensions { diff --git a/src/ImageKit/ImageKitClient.cs b/src/Imagekit/ImageKitClient.cs similarity index 96% rename from src/ImageKit/ImageKitClient.cs rename to src/Imagekit/ImageKitClient.cs index 8a997026..5bd45f60 100644 --- a/src/ImageKit/ImageKitClient.cs +++ b/src/Imagekit/ImageKitClient.cs @@ -5,11 +5,11 @@ using System.Net.Http; using System.Threading; using System.Threading.Tasks; -using ImageKit.Core; -using ImageKit.Exceptions; -using ImageKit.Services; +using Imagekit.Core; +using Imagekit.Exceptions; +using Imagekit.Services; -namespace ImageKit; +namespace Imagekit; /// public sealed class ImageKitClient : IImageKitClient diff --git a/src/ImageKit/ImageKit.csproj b/src/Imagekit/Imagekit.csproj similarity index 89% rename from src/ImageKit/ImageKit.csproj rename to src/Imagekit/Imagekit.csproj index 9252fc47..c2071111 100644 --- a/src/ImageKit/ImageKit.csproj +++ b/src/Imagekit/Imagekit.csproj @@ -2,14 +2,14 @@ Image Kit C# - ImageKit + Imagekit 0.0.1 The official .NET library for the Image Kit API. Library README.md - + diff --git a/src/ImageKit/Models/Accounts/Origins/OriginCreateParams.cs b/src/Imagekit/Models/Accounts/Origins/OriginCreateParams.cs similarity index 95% rename from src/ImageKit/Models/Accounts/Origins/OriginCreateParams.cs rename to src/Imagekit/Models/Accounts/Origins/OriginCreateParams.cs index 19b8b6b5..602166ad 100644 --- a/src/ImageKit/Models/Accounts/Origins/OriginCreateParams.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginCreateParams.cs @@ -4,10 +4,10 @@ using System.Diagnostics.CodeAnalysis; using System.Net.Http; using System.Text.Json; -using ImageKit.Core; +using Imagekit.Core; using Text = System.Text; -namespace ImageKit.Models.Accounts.Origins; +namespace Imagekit.Models.Accounts.Origins; /// /// **Note:** This API is currently in beta. Creates a new origin and returns the diff --git a/src/ImageKit/Models/Accounts/Origins/OriginDeleteParams.cs b/src/Imagekit/Models/Accounts/Origins/OriginDeleteParams.cs similarity index 95% rename from src/ImageKit/Models/Accounts/Origins/OriginDeleteParams.cs rename to src/Imagekit/Models/Accounts/Origins/OriginDeleteParams.cs index 28bd610b..f7320bc0 100644 --- a/src/ImageKit/Models/Accounts/Origins/OriginDeleteParams.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginDeleteParams.cs @@ -4,9 +4,9 @@ using System.Diagnostics.CodeAnalysis; using System.Net.Http; using System.Text.Json; -using ImageKit.Core; +using Imagekit.Core; -namespace ImageKit.Models.Accounts.Origins; +namespace Imagekit.Models.Accounts.Origins; /// /// **Note:** This API is currently in beta. Permanently removes the origin identified diff --git a/src/ImageKit/Models/Accounts/Origins/OriginGetParams.cs b/src/Imagekit/Models/Accounts/Origins/OriginGetParams.cs similarity index 95% rename from src/ImageKit/Models/Accounts/Origins/OriginGetParams.cs rename to src/Imagekit/Models/Accounts/Origins/OriginGetParams.cs index da52e29c..25f16ec4 100644 --- a/src/ImageKit/Models/Accounts/Origins/OriginGetParams.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginGetParams.cs @@ -4,9 +4,9 @@ using System.Diagnostics.CodeAnalysis; using System.Net.Http; using System.Text.Json; -using ImageKit.Core; +using Imagekit.Core; -namespace ImageKit.Models.Accounts.Origins; +namespace Imagekit.Models.Accounts.Origins; /// /// **Note:** This API is currently in beta. Retrieves the origin identified by `id`. diff --git a/src/ImageKit/Models/Accounts/Origins/OriginListParams.cs b/src/Imagekit/Models/Accounts/Origins/OriginListParams.cs similarity index 95% rename from src/ImageKit/Models/Accounts/Origins/OriginListParams.cs rename to src/Imagekit/Models/Accounts/Origins/OriginListParams.cs index 86e74fd5..96cf9a55 100644 --- a/src/ImageKit/Models/Accounts/Origins/OriginListParams.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginListParams.cs @@ -4,9 +4,9 @@ using System.Diagnostics.CodeAnalysis; using System.Net.Http; using System.Text.Json; -using ImageKit.Core; +using Imagekit.Core; -namespace ImageKit.Models.Accounts.Origins; +namespace Imagekit.Models.Accounts.Origins; /// /// **Note:** This API is currently in beta. Returns an array of all configured diff --git a/src/ImageKit/Models/Accounts/Origins/OriginRequest.cs b/src/Imagekit/Models/Accounts/Origins/OriginRequest.cs similarity index 96% rename from src/ImageKit/Models/Accounts/Origins/OriginRequest.cs rename to src/Imagekit/Models/Accounts/Origins/OriginRequest.cs index ddf96a3a..52ebf0a2 100644 --- a/src/ImageKit/Models/Accounts/Origins/OriginRequest.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginRequest.cs @@ -4,10 +4,10 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; -using ImageKit.Exceptions; +using Imagekit.Core; +using Imagekit.Exceptions; -namespace ImageKit.Models.Accounts.Origins; +namespace Imagekit.Models.Accounts.Origins; /// /// Schema for origin request resources. diff --git a/src/ImageKit/Models/Accounts/Origins/OriginResponse.cs b/src/Imagekit/Models/Accounts/Origins/OriginResponse.cs similarity index 96% rename from src/ImageKit/Models/Accounts/Origins/OriginResponse.cs rename to src/Imagekit/Models/Accounts/Origins/OriginResponse.cs index c0cf4111..0ef6970e 100644 --- a/src/ImageKit/Models/Accounts/Origins/OriginResponse.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginResponse.cs @@ -4,10 +4,10 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; -using ImageKit.Exceptions; +using Imagekit.Core; +using Imagekit.Exceptions; -namespace ImageKit.Models.Accounts.Origins; +namespace Imagekit.Models.Accounts.Origins; /// /// Origin object as returned by the API (sensitive fields removed). diff --git a/src/ImageKit/Models/Accounts/Origins/OriginUpdateParams.cs b/src/Imagekit/Models/Accounts/Origins/OriginUpdateParams.cs similarity index 95% rename from src/ImageKit/Models/Accounts/Origins/OriginUpdateParams.cs rename to src/Imagekit/Models/Accounts/Origins/OriginUpdateParams.cs index c9ccac5e..6b4b4283 100644 --- a/src/ImageKit/Models/Accounts/Origins/OriginUpdateParams.cs +++ b/src/Imagekit/Models/Accounts/Origins/OriginUpdateParams.cs @@ -4,10 +4,10 @@ using System.Diagnostics.CodeAnalysis; using System.Net.Http; using System.Text.Json; -using ImageKit.Core; +using Imagekit.Core; using Text = System.Text; -namespace ImageKit.Models.Accounts.Origins; +namespace Imagekit.Models.Accounts.Origins; /// /// **Note:** This API is currently in beta. Updates the origin identified by `id` diff --git a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointCreateParams.cs b/src/Imagekit/Models/Accounts/UrlEndpoints/UrlEndpointCreateParams.cs similarity index 96% rename from src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointCreateParams.cs rename to src/Imagekit/Models/Accounts/UrlEndpoints/UrlEndpointCreateParams.cs index 321a6bad..ea89e6ed 100644 --- a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointCreateParams.cs +++ b/src/Imagekit/Models/Accounts/UrlEndpoints/UrlEndpointCreateParams.cs @@ -6,11 +6,11 @@ using System.Net.Http; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; -using ImageKit.Exceptions; +using Imagekit.Core; +using Imagekit.Exceptions; using Text = System.Text; -namespace ImageKit.Models.Accounts.UrlEndpoints; +namespace Imagekit.Models.Accounts.UrlEndpoints; /// /// **Note:** This API is currently in beta. Creates a new URL‑endpoint and returns diff --git a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointDeleteParams.cs b/src/Imagekit/Models/Accounts/UrlEndpoints/UrlEndpointDeleteParams.cs similarity index 95% rename from src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointDeleteParams.cs rename to src/Imagekit/Models/Accounts/UrlEndpoints/UrlEndpointDeleteParams.cs index 5efe9c26..3fd9ba3a 100644 --- a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointDeleteParams.cs +++ b/src/Imagekit/Models/Accounts/UrlEndpoints/UrlEndpointDeleteParams.cs @@ -4,9 +4,9 @@ using System.Diagnostics.CodeAnalysis; using System.Net.Http; using System.Text.Json; -using ImageKit.Core; +using Imagekit.Core; -namespace ImageKit.Models.Accounts.UrlEndpoints; +namespace Imagekit.Models.Accounts.UrlEndpoints; /// /// **Note:** This API is currently in beta. Deletes the URL‑endpoint identified diff --git a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointGetParams.cs b/src/Imagekit/Models/Accounts/UrlEndpoints/UrlEndpointGetParams.cs similarity index 95% rename from src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointGetParams.cs rename to src/Imagekit/Models/Accounts/UrlEndpoints/UrlEndpointGetParams.cs index b53bc26a..5429a7c0 100644 --- a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointGetParams.cs +++ b/src/Imagekit/Models/Accounts/UrlEndpoints/UrlEndpointGetParams.cs @@ -4,9 +4,9 @@ using System.Diagnostics.CodeAnalysis; using System.Net.Http; using System.Text.Json; -using ImageKit.Core; +using Imagekit.Core; -namespace ImageKit.Models.Accounts.UrlEndpoints; +namespace Imagekit.Models.Accounts.UrlEndpoints; /// /// **Note:** This API is currently in beta. Retrieves the URL‑endpoint identified diff --git a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointListParams.cs b/src/Imagekit/Models/Accounts/UrlEndpoints/UrlEndpointListParams.cs similarity index 95% rename from src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointListParams.cs rename to src/Imagekit/Models/Accounts/UrlEndpoints/UrlEndpointListParams.cs index 41ea3fc4..03a85f65 100644 --- a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointListParams.cs +++ b/src/Imagekit/Models/Accounts/UrlEndpoints/UrlEndpointListParams.cs @@ -4,9 +4,9 @@ using System.Diagnostics.CodeAnalysis; using System.Net.Http; using System.Text.Json; -using ImageKit.Core; +using Imagekit.Core; -namespace ImageKit.Models.Accounts.UrlEndpoints; +namespace Imagekit.Models.Accounts.UrlEndpoints; /// /// **Note:** This API is currently in beta. Returns an array of all URL‑endpoints diff --git a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointRequest.cs b/src/Imagekit/Models/Accounts/UrlEndpoints/UrlEndpointRequest.cs similarity index 96% rename from src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointRequest.cs rename to src/Imagekit/Models/Accounts/UrlEndpoints/UrlEndpointRequest.cs index 6f485a42..48233fbc 100644 --- a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointRequest.cs +++ b/src/Imagekit/Models/Accounts/UrlEndpoints/UrlEndpointRequest.cs @@ -5,10 +5,10 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; -using ImageKit.Exceptions; +using Imagekit.Core; +using Imagekit.Exceptions; -namespace ImageKit.Models.Accounts.UrlEndpoints; +namespace Imagekit.Models.Accounts.UrlEndpoints; /// /// Schema for URL endpoint resource. diff --git a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointResponse.cs b/src/Imagekit/Models/Accounts/UrlEndpoints/UrlEndpointResponse.cs similarity index 96% rename from src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointResponse.cs rename to src/Imagekit/Models/Accounts/UrlEndpoints/UrlEndpointResponse.cs index bd7f8eda..9f10853e 100644 --- a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointResponse.cs +++ b/src/Imagekit/Models/Accounts/UrlEndpoints/UrlEndpointResponse.cs @@ -5,10 +5,10 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; -using ImageKit.Exceptions; +using Imagekit.Core; +using Imagekit.Exceptions; -namespace ImageKit.Models.Accounts.UrlEndpoints; +namespace Imagekit.Models.Accounts.UrlEndpoints; /// /// URL‑endpoint object as returned by the API. diff --git a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParams.cs b/src/Imagekit/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParams.cs similarity index 96% rename from src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParams.cs rename to src/Imagekit/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParams.cs index 8103f8b2..3b246350 100644 --- a/src/ImageKit/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParams.cs +++ b/src/Imagekit/Models/Accounts/UrlEndpoints/UrlEndpointUpdateParams.cs @@ -6,11 +6,11 @@ using System.Net.Http; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; -using ImageKit.Exceptions; +using Imagekit.Core; +using Imagekit.Exceptions; using Text = System.Text; -namespace ImageKit.Models.Accounts.UrlEndpoints; +namespace Imagekit.Models.Accounts.UrlEndpoints; /// /// **Note:** This API is currently in beta. Updates the URL‑endpoint identified diff --git a/src/ImageKit/Models/Accounts/Usage/UsageGetParams.cs b/src/Imagekit/Models/Accounts/Usage/UsageGetParams.cs similarity index 95% rename from src/ImageKit/Models/Accounts/Usage/UsageGetParams.cs rename to src/Imagekit/Models/Accounts/Usage/UsageGetParams.cs index c48c1042..bea20afe 100644 --- a/src/ImageKit/Models/Accounts/Usage/UsageGetParams.cs +++ b/src/Imagekit/Models/Accounts/Usage/UsageGetParams.cs @@ -4,9 +4,9 @@ using System.Diagnostics.CodeAnalysis; using System.Net.Http; using System.Text.Json; -using ImageKit.Core; +using Imagekit.Core; -namespace ImageKit.Models.Accounts.Usage; +namespace Imagekit.Models.Accounts.Usage; /// /// Get the account usage information between two dates. Note that the API response diff --git a/src/ImageKit/Models/Accounts/Usage/UsageGetResponse.cs b/src/Imagekit/Models/Accounts/Usage/UsageGetResponse.cs similarity index 94% rename from src/ImageKit/Models/Accounts/Usage/UsageGetResponse.cs rename to src/Imagekit/Models/Accounts/Usage/UsageGetResponse.cs index b365a3b2..4481d2dd 100644 --- a/src/ImageKit/Models/Accounts/Usage/UsageGetResponse.cs +++ b/src/Imagekit/Models/Accounts/Usage/UsageGetResponse.cs @@ -3,9 +3,9 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; +using Imagekit.Core; -namespace ImageKit.Models.Accounts.Usage; +namespace Imagekit.Models.Accounts.Usage; [JsonConverter(typeof(JsonModelConverter))] public sealed record class UsageGetResponse : JsonModel diff --git a/src/ImageKit/Models/Assets/AssetListParams.cs b/src/Imagekit/Models/Assets/AssetListParams.cs similarity index 90% rename from src/ImageKit/Models/Assets/AssetListParams.cs rename to src/Imagekit/Models/Assets/AssetListParams.cs index 6828602b..7d458b5e 100644 --- a/src/ImageKit/Models/Assets/AssetListParams.cs +++ b/src/Imagekit/Models/Assets/AssetListParams.cs @@ -4,11 +4,11 @@ using System.Net.Http; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; -using ImageKit.Exceptions; +using Imagekit.Core; +using Imagekit.Exceptions; using System = System; -namespace ImageKit.Models.Assets; +namespace Imagekit.Models.Assets; /// /// This API can list all the uploaded files and folders in your ImageKit.io media @@ -173,13 +173,13 @@ public ApiEnum? Sort /// file versions - `folder` — returns only folders - `all` — returns both /// files and folders (excludes `file-version`) /// - public ApiEnum? Type + public ApiEnum? Type { get { this._rawQueryData.Freeze(); return this._rawQueryData.GetNullableClass< - ApiEnum + ApiEnum >("type"); } init @@ -427,9 +427,9 @@ public enum Type All, } -sealed class TypeConverter : JsonConverter +sealed class TypeConverter : JsonConverter { - public override global::ImageKit.Models.Assets.Type Read( + public override global::Imagekit.Models.Assets.Type Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -437,17 +437,17 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "file" => global::ImageKit.Models.Assets.Type.File, - "file-version" => global::ImageKit.Models.Assets.Type.FileVersion, - "folder" => global::ImageKit.Models.Assets.Type.Folder, - "all" => global::ImageKit.Models.Assets.Type.All, - _ => (global::ImageKit.Models.Assets.Type)(-1), + "file" => global::Imagekit.Models.Assets.Type.File, + "file-version" => global::Imagekit.Models.Assets.Type.FileVersion, + "folder" => global::Imagekit.Models.Assets.Type.Folder, + "all" => global::Imagekit.Models.Assets.Type.All, + _ => (global::Imagekit.Models.Assets.Type)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::ImageKit.Models.Assets.Type value, + global::Imagekit.Models.Assets.Type value, JsonSerializerOptions options ) { @@ -455,10 +455,10 @@ JsonSerializerOptions options writer, value switch { - global::ImageKit.Models.Assets.Type.File => "file", - global::ImageKit.Models.Assets.Type.FileVersion => "file-version", - global::ImageKit.Models.Assets.Type.Folder => "folder", - global::ImageKit.Models.Assets.Type.All => "all", + global::Imagekit.Models.Assets.Type.File => "file", + global::Imagekit.Models.Assets.Type.FileVersion => "file-version", + global::Imagekit.Models.Assets.Type.Folder => "folder", + global::Imagekit.Models.Assets.Type.All => "all", _ => throw new ImageKitInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/ImageKit/Models/Assets/AssetListResponse.cs b/src/Imagekit/Models/Assets/AssetListResponse.cs similarity index 95% rename from src/ImageKit/Models/Assets/AssetListResponse.cs rename to src/Imagekit/Models/Assets/AssetListResponse.cs index f8601ce4..5548d1f7 100644 --- a/src/ImageKit/Models/Assets/AssetListResponse.cs +++ b/src/Imagekit/Models/Assets/AssetListResponse.cs @@ -1,12 +1,12 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; -using ImageKit.Exceptions; -using ImageKit.Models.Files; +using Imagekit.Core; +using Imagekit.Exceptions; +using Imagekit.Models.Files; using System = System; -namespace ImageKit.Models.Assets; +namespace Imagekit.Models.Assets; /// /// Object containing details of a file or file version. diff --git a/src/ImageKit/Models/BaseOverlay.cs b/src/Imagekit/Models/BaseOverlay.cs similarity index 96% rename from src/ImageKit/Models/BaseOverlay.cs rename to src/Imagekit/Models/BaseOverlay.cs index bc50fe4f..bf618591 100644 --- a/src/ImageKit/Models/BaseOverlay.cs +++ b/src/Imagekit/Models/BaseOverlay.cs @@ -4,10 +4,10 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; -using ImageKit.Exceptions; +using Imagekit.Core; +using Imagekit.Exceptions; -namespace ImageKit.Models; +namespace Imagekit.Models; [JsonConverter(typeof(JsonModelConverter))] public sealed record class BaseOverlay : JsonModel diff --git a/src/ImageKit/Models/Beta/V2/Files/FileUploadParams.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParams.cs similarity index 96% rename from src/ImageKit/Models/Beta/V2/Files/FileUploadParams.cs rename to src/Imagekit/Models/Beta/V2/Files/FileUploadParams.cs index e956d593..bcd492ca 100644 --- a/src/ImageKit/Models/Beta/V2/Files/FileUploadParams.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParams.cs @@ -5,11 +5,11 @@ using System.Net.Http; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; -using ImageKit.Exceptions; +using Imagekit.Core; +using Imagekit.Exceptions; using System = System; -namespace ImageKit.Models.Beta.V2.Files; +namespace Imagekit.Models.Beta.V2.Files; /// /// The V2 API enhances security by verifying the entire payload using JWT. This API diff --git a/src/ImageKit/Models/Beta/V2/Files/FileUploadResponse.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponse.cs similarity index 94% rename from src/ImageKit/Models/Beta/V2/Files/FileUploadResponse.cs rename to src/Imagekit/Models/Beta/V2/Files/FileUploadResponse.cs index 0148fcc0..a888ea14 100644 --- a/src/ImageKit/Models/Beta/V2/Files/FileUploadResponse.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponse.cs @@ -4,12 +4,12 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; -using ImageKit.Exceptions; -using Files = ImageKit.Models.Files; +using Imagekit.Core; +using Imagekit.Exceptions; +using Files = Imagekit.Models.Files; using System = System; -namespace ImageKit.Models.Beta.V2.Files; +namespace Imagekit.Models.Beta.V2.Files; /// /// Object containing details of a successful upload. @@ -1154,13 +1154,13 @@ public sealed record class SelectedFieldsSchemaItem : JsonModel /// /// Type of the custom metadata field. /// - public required ApiEnum Type + public required ApiEnum Type { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("type"); } init { this._rawData.Set("type", value); } @@ -1415,7 +1415,7 @@ IReadOnlyDictionary rawData [SetsRequiredMembers] public SelectedFieldsSchemaItem( - ApiEnum type + ApiEnum type ) : this() { @@ -1446,9 +1446,9 @@ public enum Type MultiSelect, } -sealed class TypeConverter : JsonConverter +sealed class TypeConverter : JsonConverter { - public override global::ImageKit.Models.Beta.V2.Files.Type Read( + public override global::Imagekit.Models.Beta.V2.Files.Type Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -1456,20 +1456,20 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "Text" => global::ImageKit.Models.Beta.V2.Files.Type.Text, - "Textarea" => global::ImageKit.Models.Beta.V2.Files.Type.Textarea, - "Number" => global::ImageKit.Models.Beta.V2.Files.Type.Number, - "Date" => global::ImageKit.Models.Beta.V2.Files.Type.Date, - "Boolean" => global::ImageKit.Models.Beta.V2.Files.Type.Boolean, - "SingleSelect" => global::ImageKit.Models.Beta.V2.Files.Type.SingleSelect, - "MultiSelect" => global::ImageKit.Models.Beta.V2.Files.Type.MultiSelect, - _ => (global::ImageKit.Models.Beta.V2.Files.Type)(-1), + "Text" => global::Imagekit.Models.Beta.V2.Files.Type.Text, + "Textarea" => global::Imagekit.Models.Beta.V2.Files.Type.Textarea, + "Number" => global::Imagekit.Models.Beta.V2.Files.Type.Number, + "Date" => global::Imagekit.Models.Beta.V2.Files.Type.Date, + "Boolean" => global::Imagekit.Models.Beta.V2.Files.Type.Boolean, + "SingleSelect" => global::Imagekit.Models.Beta.V2.Files.Type.SingleSelect, + "MultiSelect" => global::Imagekit.Models.Beta.V2.Files.Type.MultiSelect, + _ => (global::Imagekit.Models.Beta.V2.Files.Type)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::ImageKit.Models.Beta.V2.Files.Type value, + global::Imagekit.Models.Beta.V2.Files.Type value, JsonSerializerOptions options ) { @@ -1477,13 +1477,13 @@ JsonSerializerOptions options writer, value switch { - global::ImageKit.Models.Beta.V2.Files.Type.Text => "Text", - global::ImageKit.Models.Beta.V2.Files.Type.Textarea => "Textarea", - global::ImageKit.Models.Beta.V2.Files.Type.Number => "Number", - global::ImageKit.Models.Beta.V2.Files.Type.Date => "Date", - global::ImageKit.Models.Beta.V2.Files.Type.Boolean => "Boolean", - global::ImageKit.Models.Beta.V2.Files.Type.SingleSelect => "SingleSelect", - global::ImageKit.Models.Beta.V2.Files.Type.MultiSelect => "MultiSelect", + global::Imagekit.Models.Beta.V2.Files.Type.Text => "Text", + global::Imagekit.Models.Beta.V2.Files.Type.Textarea => "Textarea", + global::Imagekit.Models.Beta.V2.Files.Type.Number => "Number", + global::Imagekit.Models.Beta.V2.Files.Type.Date => "Date", + global::Imagekit.Models.Beta.V2.Files.Type.Boolean => "Boolean", + global::Imagekit.Models.Beta.V2.Files.Type.SingleSelect => "SingleSelect", + global::Imagekit.Models.Beta.V2.Files.Type.MultiSelect => "MultiSelect", _ => throw new ImageKitInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/ImageKit/Models/Cache/Invalidation/InvalidationCreateParams.cs b/src/Imagekit/Models/Cache/Invalidation/InvalidationCreateParams.cs similarity index 95% rename from src/ImageKit/Models/Cache/Invalidation/InvalidationCreateParams.cs rename to src/Imagekit/Models/Cache/Invalidation/InvalidationCreateParams.cs index 5df6d94b..3b841086 100644 --- a/src/ImageKit/Models/Cache/Invalidation/InvalidationCreateParams.cs +++ b/src/Imagekit/Models/Cache/Invalidation/InvalidationCreateParams.cs @@ -4,10 +4,10 @@ using System.Diagnostics.CodeAnalysis; using System.Net.Http; using System.Text.Json; -using ImageKit.Core; +using Imagekit.Core; using Text = System.Text; -namespace ImageKit.Models.Cache.Invalidation; +namespace Imagekit.Models.Cache.Invalidation; /// /// This API will purge CDN cache and ImageKit.io's internal cache for a file. Note: diff --git a/src/ImageKit/Models/Cache/Invalidation/InvalidationCreateResponse.cs b/src/Imagekit/Models/Cache/Invalidation/InvalidationCreateResponse.cs similarity index 93% rename from src/ImageKit/Models/Cache/Invalidation/InvalidationCreateResponse.cs rename to src/Imagekit/Models/Cache/Invalidation/InvalidationCreateResponse.cs index c165154e..dece3abb 100644 --- a/src/ImageKit/Models/Cache/Invalidation/InvalidationCreateResponse.cs +++ b/src/Imagekit/Models/Cache/Invalidation/InvalidationCreateResponse.cs @@ -3,9 +3,9 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; +using Imagekit.Core; -namespace ImageKit.Models.Cache.Invalidation; +namespace Imagekit.Models.Cache.Invalidation; [JsonConverter( typeof(JsonModelConverter) diff --git a/src/ImageKit/Models/Cache/Invalidation/InvalidationGetParams.cs b/src/Imagekit/Models/Cache/Invalidation/InvalidationGetParams.cs similarity index 95% rename from src/ImageKit/Models/Cache/Invalidation/InvalidationGetParams.cs rename to src/Imagekit/Models/Cache/Invalidation/InvalidationGetParams.cs index 26ed9c65..1db6c24f 100644 --- a/src/ImageKit/Models/Cache/Invalidation/InvalidationGetParams.cs +++ b/src/Imagekit/Models/Cache/Invalidation/InvalidationGetParams.cs @@ -4,9 +4,9 @@ using System.Diagnostics.CodeAnalysis; using System.Net.Http; using System.Text.Json; -using ImageKit.Core; +using Imagekit.Core; -namespace ImageKit.Models.Cache.Invalidation; +namespace Imagekit.Models.Cache.Invalidation; /// /// This API returns the status of a purge cache request. diff --git a/src/ImageKit/Models/Cache/Invalidation/InvalidationGetResponse.cs b/src/Imagekit/Models/Cache/Invalidation/InvalidationGetResponse.cs similarity index 93% rename from src/ImageKit/Models/Cache/Invalidation/InvalidationGetResponse.cs rename to src/Imagekit/Models/Cache/Invalidation/InvalidationGetResponse.cs index 9ffe4940..13619b5f 100644 --- a/src/ImageKit/Models/Cache/Invalidation/InvalidationGetResponse.cs +++ b/src/Imagekit/Models/Cache/Invalidation/InvalidationGetResponse.cs @@ -4,10 +4,10 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; -using ImageKit.Exceptions; +using Imagekit.Core; +using Imagekit.Exceptions; -namespace ImageKit.Models.Cache.Invalidation; +namespace Imagekit.Models.Cache.Invalidation; [JsonConverter(typeof(JsonModelConverter))] public sealed record class InvalidationGetResponse : JsonModel diff --git a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataField.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataField.cs similarity index 96% rename from src/ImageKit/Models/CustomMetadataFields/CustomMetadataField.cs rename to src/Imagekit/Models/CustomMetadataFields/CustomMetadataField.cs index 367d9bb3..5ac68722 100644 --- a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataField.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataField.cs @@ -4,11 +4,11 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; -using ImageKit.Exceptions; +using Imagekit.Core; +using Imagekit.Exceptions; using System = System; -namespace ImageKit.Models.CustomMetadataFields; +namespace Imagekit.Models.CustomMetadataFields; /// /// Object containing details of a custom metadata field. diff --git a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldCreateParams.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParams.cs similarity index 94% rename from src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldCreateParams.cs rename to src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParams.cs index 328b55bb..018ffa18 100644 --- a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldCreateParams.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldCreateParams.cs @@ -5,12 +5,12 @@ using System.Net.Http; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; -using ImageKit.Exceptions; +using Imagekit.Core; +using Imagekit.Exceptions; using System = System; using Text = System.Text; -namespace ImageKit.Models.CustomMetadataFields; +namespace Imagekit.Models.CustomMetadataFields; /// /// This API creates a new custom metadata field. Once a custom metadata field is @@ -189,13 +189,13 @@ public sealed record class Schema : JsonModel /// /// Type of the custom metadata field. /// - public required ApiEnum Type + public required ApiEnum Type { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("type"); } init { this._rawData.Set("type", value); } @@ -406,7 +406,7 @@ public static Schema FromRawUnchecked(IReadOnlyDictionary r } [SetsRequiredMembers] - public Schema(ApiEnum type) + public Schema(ApiEnum type) : this() { this.Type = type; @@ -435,9 +435,9 @@ public enum Type MultiSelect, } -sealed class TypeConverter : JsonConverter +sealed class TypeConverter : JsonConverter { - public override global::ImageKit.Models.CustomMetadataFields.Type Read( + public override global::Imagekit.Models.CustomMetadataFields.Type Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -445,20 +445,20 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "Text" => global::ImageKit.Models.CustomMetadataFields.Type.Text, - "Textarea" => global::ImageKit.Models.CustomMetadataFields.Type.Textarea, - "Number" => global::ImageKit.Models.CustomMetadataFields.Type.Number, - "Date" => global::ImageKit.Models.CustomMetadataFields.Type.Date, - "Boolean" => global::ImageKit.Models.CustomMetadataFields.Type.Boolean, - "SingleSelect" => global::ImageKit.Models.CustomMetadataFields.Type.SingleSelect, - "MultiSelect" => global::ImageKit.Models.CustomMetadataFields.Type.MultiSelect, - _ => (global::ImageKit.Models.CustomMetadataFields.Type)(-1), + "Text" => global::Imagekit.Models.CustomMetadataFields.Type.Text, + "Textarea" => global::Imagekit.Models.CustomMetadataFields.Type.Textarea, + "Number" => global::Imagekit.Models.CustomMetadataFields.Type.Number, + "Date" => global::Imagekit.Models.CustomMetadataFields.Type.Date, + "Boolean" => global::Imagekit.Models.CustomMetadataFields.Type.Boolean, + "SingleSelect" => global::Imagekit.Models.CustomMetadataFields.Type.SingleSelect, + "MultiSelect" => global::Imagekit.Models.CustomMetadataFields.Type.MultiSelect, + _ => (global::Imagekit.Models.CustomMetadataFields.Type)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::ImageKit.Models.CustomMetadataFields.Type value, + global::Imagekit.Models.CustomMetadataFields.Type value, JsonSerializerOptions options ) { @@ -466,13 +466,13 @@ JsonSerializerOptions options writer, value switch { - global::ImageKit.Models.CustomMetadataFields.Type.Text => "Text", - global::ImageKit.Models.CustomMetadataFields.Type.Textarea => "Textarea", - global::ImageKit.Models.CustomMetadataFields.Type.Number => "Number", - global::ImageKit.Models.CustomMetadataFields.Type.Date => "Date", - global::ImageKit.Models.CustomMetadataFields.Type.Boolean => "Boolean", - global::ImageKit.Models.CustomMetadataFields.Type.SingleSelect => "SingleSelect", - global::ImageKit.Models.CustomMetadataFields.Type.MultiSelect => "MultiSelect", + global::Imagekit.Models.CustomMetadataFields.Type.Text => "Text", + global::Imagekit.Models.CustomMetadataFields.Type.Textarea => "Textarea", + global::Imagekit.Models.CustomMetadataFields.Type.Number => "Number", + global::Imagekit.Models.CustomMetadataFields.Type.Date => "Date", + global::Imagekit.Models.CustomMetadataFields.Type.Boolean => "Boolean", + global::Imagekit.Models.CustomMetadataFields.Type.SingleSelect => "SingleSelect", + global::Imagekit.Models.CustomMetadataFields.Type.MultiSelect => "MultiSelect", _ => throw new ImageKitInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldDeleteParams.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldDeleteParams.cs similarity index 95% rename from src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldDeleteParams.cs rename to src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldDeleteParams.cs index 4d005432..3d3f910d 100644 --- a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldDeleteParams.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldDeleteParams.cs @@ -4,9 +4,9 @@ using System.Diagnostics.CodeAnalysis; using System.Net.Http; using System.Text.Json; -using ImageKit.Core; +using Imagekit.Core; -namespace ImageKit.Models.CustomMetadataFields; +namespace Imagekit.Models.CustomMetadataFields; /// /// This API deletes a custom metadata field. Even after deleting a custom metadata diff --git a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldDeleteResponse.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldDeleteResponse.cs similarity index 93% rename from src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldDeleteResponse.cs rename to src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldDeleteResponse.cs index 25274811..e637f5a2 100644 --- a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldDeleteResponse.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldDeleteResponse.cs @@ -3,9 +3,9 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; +using Imagekit.Core; -namespace ImageKit.Models.CustomMetadataFields; +namespace Imagekit.Models.CustomMetadataFields; [JsonConverter( typeof(JsonModelConverter< diff --git a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldListParams.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldListParams.cs similarity index 95% rename from src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldListParams.cs rename to src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldListParams.cs index 70831d7d..aa30b423 100644 --- a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldListParams.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldListParams.cs @@ -4,9 +4,9 @@ using System.Diagnostics.CodeAnalysis; using System.Net.Http; using System.Text.Json; -using ImageKit.Core; +using Imagekit.Core; -namespace ImageKit.Models.CustomMetadataFields; +namespace Imagekit.Models.CustomMetadataFields; /// /// This API returns the array of created custom metadata field objects. By default diff --git a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParams.cs b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParams.cs similarity index 96% rename from src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParams.cs rename to src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParams.cs index 3dad5378..b9c75688 100644 --- a/src/ImageKit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParams.cs +++ b/src/Imagekit/Models/CustomMetadataFields/CustomMetadataFieldUpdateParams.cs @@ -5,12 +5,12 @@ using System.Net.Http; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; -using ImageKit.Exceptions; +using Imagekit.Core; +using Imagekit.Exceptions; using System = System; using Text = System.Text; -namespace ImageKit.Models.CustomMetadataFields; +namespace Imagekit.Models.CustomMetadataFields; /// /// This API updates the label or schema of an existing custom metadata field. diff --git a/src/ImageKit/Models/ExtensionConfig.cs b/src/Imagekit/Models/ExtensionConfig.cs similarity index 96% rename from src/ImageKit/Models/ExtensionConfig.cs rename to src/Imagekit/Models/ExtensionConfig.cs index 1200fbea..758d729f 100644 --- a/src/ImageKit/Models/ExtensionConfig.cs +++ b/src/Imagekit/Models/ExtensionConfig.cs @@ -5,10 +5,10 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; -using ImageKit.Exceptions; +using Imagekit.Core; +using Imagekit.Exceptions; -namespace ImageKit.Models; +namespace Imagekit.Models; /// /// Configuration object for an extension (base extensions only, not saved extension references). diff --git a/src/ImageKit/Models/Files/Bulk/BulkAddTagsParams.cs b/src/Imagekit/Models/Files/Bulk/BulkAddTagsParams.cs similarity index 95% rename from src/ImageKit/Models/Files/Bulk/BulkAddTagsParams.cs rename to src/Imagekit/Models/Files/Bulk/BulkAddTagsParams.cs index c7636f99..34861340 100644 --- a/src/ImageKit/Models/Files/Bulk/BulkAddTagsParams.cs +++ b/src/Imagekit/Models/Files/Bulk/BulkAddTagsParams.cs @@ -5,10 +5,10 @@ using System.Diagnostics.CodeAnalysis; using System.Net.Http; using System.Text.Json; -using ImageKit.Core; +using Imagekit.Core; using Text = System.Text; -namespace ImageKit.Models.Files.Bulk; +namespace Imagekit.Models.Files.Bulk; /// /// This API adds tags to multiple files in bulk. A maximum of 50 files can be specified diff --git a/src/ImageKit/Models/Files/Bulk/BulkAddTagsResponse.cs b/src/Imagekit/Models/Files/Bulk/BulkAddTagsResponse.cs similarity index 94% rename from src/ImageKit/Models/Files/Bulk/BulkAddTagsResponse.cs rename to src/Imagekit/Models/Files/Bulk/BulkAddTagsResponse.cs index 2d2b5a8d..8d60fee3 100644 --- a/src/ImageKit/Models/Files/Bulk/BulkAddTagsResponse.cs +++ b/src/Imagekit/Models/Files/Bulk/BulkAddTagsResponse.cs @@ -4,9 +4,9 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; +using Imagekit.Core; -namespace ImageKit.Models.Files.Bulk; +namespace Imagekit.Models.Files.Bulk; [JsonConverter(typeof(JsonModelConverter))] public sealed record class BulkAddTagsResponse : JsonModel diff --git a/src/ImageKit/Models/Files/Bulk/BulkDeleteParams.cs b/src/Imagekit/Models/Files/Bulk/BulkDeleteParams.cs similarity index 95% rename from src/ImageKit/Models/Files/Bulk/BulkDeleteParams.cs rename to src/Imagekit/Models/Files/Bulk/BulkDeleteParams.cs index b5bbb209..e63874c6 100644 --- a/src/ImageKit/Models/Files/Bulk/BulkDeleteParams.cs +++ b/src/Imagekit/Models/Files/Bulk/BulkDeleteParams.cs @@ -5,10 +5,10 @@ using System.Diagnostics.CodeAnalysis; using System.Net.Http; using System.Text.Json; -using ImageKit.Core; +using Imagekit.Core; using Text = System.Text; -namespace ImageKit.Models.Files.Bulk; +namespace Imagekit.Models.Files.Bulk; /// /// This API deletes multiple files and all their file versions permanently. diff --git a/src/ImageKit/Models/Files/Bulk/BulkDeleteResponse.cs b/src/Imagekit/Models/Files/Bulk/BulkDeleteResponse.cs similarity index 94% rename from src/ImageKit/Models/Files/Bulk/BulkDeleteResponse.cs rename to src/Imagekit/Models/Files/Bulk/BulkDeleteResponse.cs index 2c603499..6bf8060f 100644 --- a/src/ImageKit/Models/Files/Bulk/BulkDeleteResponse.cs +++ b/src/Imagekit/Models/Files/Bulk/BulkDeleteResponse.cs @@ -4,9 +4,9 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; +using Imagekit.Core; -namespace ImageKit.Models.Files.Bulk; +namespace Imagekit.Models.Files.Bulk; [JsonConverter(typeof(JsonModelConverter))] public sealed record class BulkDeleteResponse : JsonModel diff --git a/src/ImageKit/Models/Files/Bulk/BulkRemoveAITagsParams.cs b/src/Imagekit/Models/Files/Bulk/BulkRemoveAITagsParams.cs similarity index 95% rename from src/ImageKit/Models/Files/Bulk/BulkRemoveAITagsParams.cs rename to src/Imagekit/Models/Files/Bulk/BulkRemoveAITagsParams.cs index 817f5323..b423e281 100644 --- a/src/ImageKit/Models/Files/Bulk/BulkRemoveAITagsParams.cs +++ b/src/Imagekit/Models/Files/Bulk/BulkRemoveAITagsParams.cs @@ -5,10 +5,10 @@ using System.Diagnostics.CodeAnalysis; using System.Net.Http; using System.Text.Json; -using ImageKit.Core; +using Imagekit.Core; using Text = System.Text; -namespace ImageKit.Models.Files.Bulk; +namespace Imagekit.Models.Files.Bulk; /// /// This API removes AITags from multiple files in bulk. A maximum of 50 files can diff --git a/src/ImageKit/Models/Files/Bulk/BulkRemoveAITagsResponse.cs b/src/Imagekit/Models/Files/Bulk/BulkRemoveAITagsResponse.cs similarity index 94% rename from src/ImageKit/Models/Files/Bulk/BulkRemoveAITagsResponse.cs rename to src/Imagekit/Models/Files/Bulk/BulkRemoveAITagsResponse.cs index eab4bb25..3f9e6ee1 100644 --- a/src/ImageKit/Models/Files/Bulk/BulkRemoveAITagsResponse.cs +++ b/src/Imagekit/Models/Files/Bulk/BulkRemoveAITagsResponse.cs @@ -4,9 +4,9 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; +using Imagekit.Core; -namespace ImageKit.Models.Files.Bulk; +namespace Imagekit.Models.Files.Bulk; [JsonConverter( typeof(JsonModelConverter) diff --git a/src/ImageKit/Models/Files/Bulk/BulkRemoveTagsParams.cs b/src/Imagekit/Models/Files/Bulk/BulkRemoveTagsParams.cs similarity index 95% rename from src/ImageKit/Models/Files/Bulk/BulkRemoveTagsParams.cs rename to src/Imagekit/Models/Files/Bulk/BulkRemoveTagsParams.cs index 8a804308..4e814b41 100644 --- a/src/ImageKit/Models/Files/Bulk/BulkRemoveTagsParams.cs +++ b/src/Imagekit/Models/Files/Bulk/BulkRemoveTagsParams.cs @@ -5,10 +5,10 @@ using System.Diagnostics.CodeAnalysis; using System.Net.Http; using System.Text.Json; -using ImageKit.Core; +using Imagekit.Core; using Text = System.Text; -namespace ImageKit.Models.Files.Bulk; +namespace Imagekit.Models.Files.Bulk; /// /// This API removes tags from multiple files in bulk. A maximum of 50 files can be diff --git a/src/ImageKit/Models/Files/Bulk/BulkRemoveTagsResponse.cs b/src/Imagekit/Models/Files/Bulk/BulkRemoveTagsResponse.cs similarity index 94% rename from src/ImageKit/Models/Files/Bulk/BulkRemoveTagsResponse.cs rename to src/Imagekit/Models/Files/Bulk/BulkRemoveTagsResponse.cs index efbe5d08..a6bc15c6 100644 --- a/src/ImageKit/Models/Files/Bulk/BulkRemoveTagsResponse.cs +++ b/src/Imagekit/Models/Files/Bulk/BulkRemoveTagsResponse.cs @@ -4,9 +4,9 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; +using Imagekit.Core; -namespace ImageKit.Models.Files.Bulk; +namespace Imagekit.Models.Files.Bulk; [JsonConverter(typeof(JsonModelConverter))] public sealed record class BulkRemoveTagsResponse : JsonModel diff --git a/src/ImageKit/Models/Files/File.cs b/src/Imagekit/Models/Files/File.cs similarity index 94% rename from src/ImageKit/Models/Files/File.cs rename to src/Imagekit/Models/Files/File.cs index a940e867..665285cc 100644 --- a/src/ImageKit/Models/Files/File.cs +++ b/src/Imagekit/Models/Files/File.cs @@ -4,11 +4,11 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; -using ImageKit.Exceptions; +using Imagekit.Core; +using Imagekit.Exceptions; using System = System; -namespace ImageKit.Models.Files; +namespace Imagekit.Models.Files; /// /// Object containing details of a file or file version. @@ -821,13 +821,13 @@ public sealed record class SelectedFieldsSchemaItem : JsonModel /// /// Type of the custom metadata field. /// - public required ApiEnum Type + public required ApiEnum Type { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("type"); } init { this._rawData.Set("type", value); } @@ -1081,7 +1081,7 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public SelectedFieldsSchemaItem(ApiEnum type) + public SelectedFieldsSchemaItem(ApiEnum type) : this() { this.Type = type; @@ -1111,9 +1111,9 @@ public enum Type MultiSelect, } -sealed class TypeConverter : JsonConverter +sealed class TypeConverter : JsonConverter { - public override global::ImageKit.Models.Files.Type Read( + public override global::Imagekit.Models.Files.Type Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -1121,20 +1121,20 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "Text" => global::ImageKit.Models.Files.Type.Text, - "Textarea" => global::ImageKit.Models.Files.Type.Textarea, - "Number" => global::ImageKit.Models.Files.Type.Number, - "Date" => global::ImageKit.Models.Files.Type.Date, - "Boolean" => global::ImageKit.Models.Files.Type.Boolean, - "SingleSelect" => global::ImageKit.Models.Files.Type.SingleSelect, - "MultiSelect" => global::ImageKit.Models.Files.Type.MultiSelect, - _ => (global::ImageKit.Models.Files.Type)(-1), + "Text" => global::Imagekit.Models.Files.Type.Text, + "Textarea" => global::Imagekit.Models.Files.Type.Textarea, + "Number" => global::Imagekit.Models.Files.Type.Number, + "Date" => global::Imagekit.Models.Files.Type.Date, + "Boolean" => global::Imagekit.Models.Files.Type.Boolean, + "SingleSelect" => global::Imagekit.Models.Files.Type.SingleSelect, + "MultiSelect" => global::Imagekit.Models.Files.Type.MultiSelect, + _ => (global::Imagekit.Models.Files.Type)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::ImageKit.Models.Files.Type value, + global::Imagekit.Models.Files.Type value, JsonSerializerOptions options ) { @@ -1142,13 +1142,13 @@ JsonSerializerOptions options writer, value switch { - global::ImageKit.Models.Files.Type.Text => "Text", - global::ImageKit.Models.Files.Type.Textarea => "Textarea", - global::ImageKit.Models.Files.Type.Number => "Number", - global::ImageKit.Models.Files.Type.Date => "Date", - global::ImageKit.Models.Files.Type.Boolean => "Boolean", - global::ImageKit.Models.Files.Type.SingleSelect => "SingleSelect", - global::ImageKit.Models.Files.Type.MultiSelect => "MultiSelect", + global::Imagekit.Models.Files.Type.Text => "Text", + global::Imagekit.Models.Files.Type.Textarea => "Textarea", + global::Imagekit.Models.Files.Type.Number => "Number", + global::Imagekit.Models.Files.Type.Date => "Date", + global::Imagekit.Models.Files.Type.Boolean => "Boolean", + global::Imagekit.Models.Files.Type.SingleSelect => "SingleSelect", + global::Imagekit.Models.Files.Type.MultiSelect => "MultiSelect", _ => throw new ImageKitInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/ImageKit/Models/Files/FileCopyParams.cs b/src/Imagekit/Models/Files/FileCopyParams.cs similarity index 96% rename from src/ImageKit/Models/Files/FileCopyParams.cs rename to src/Imagekit/Models/Files/FileCopyParams.cs index b04dcf3f..38f45839 100644 --- a/src/ImageKit/Models/Files/FileCopyParams.cs +++ b/src/Imagekit/Models/Files/FileCopyParams.cs @@ -4,10 +4,10 @@ using System.Diagnostics.CodeAnalysis; using System.Net.Http; using System.Text.Json; -using ImageKit.Core; +using Imagekit.Core; using Text = System.Text; -namespace ImageKit.Models.Files; +namespace Imagekit.Models.Files; /// /// This will copy a file from one folder to another. diff --git a/src/ImageKit/Models/Files/FileCopyResponse.cs b/src/Imagekit/Models/Files/FileCopyResponse.cs similarity index 93% rename from src/ImageKit/Models/Files/FileCopyResponse.cs rename to src/Imagekit/Models/Files/FileCopyResponse.cs index d9045461..f484290b 100644 --- a/src/ImageKit/Models/Files/FileCopyResponse.cs +++ b/src/Imagekit/Models/Files/FileCopyResponse.cs @@ -3,9 +3,9 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; +using Imagekit.Core; -namespace ImageKit.Models.Files; +namespace Imagekit.Models.Files; [JsonConverter(typeof(JsonModelConverter))] public sealed record class FileCopyResponse : JsonModel diff --git a/src/ImageKit/Models/Files/FileDeleteParams.cs b/src/Imagekit/Models/Files/FileDeleteParams.cs similarity index 95% rename from src/ImageKit/Models/Files/FileDeleteParams.cs rename to src/Imagekit/Models/Files/FileDeleteParams.cs index 8ed7ed1f..ec41bc4d 100644 --- a/src/ImageKit/Models/Files/FileDeleteParams.cs +++ b/src/Imagekit/Models/Files/FileDeleteParams.cs @@ -4,9 +4,9 @@ using System.Diagnostics.CodeAnalysis; using System.Net.Http; using System.Text.Json; -using ImageKit.Core; +using Imagekit.Core; -namespace ImageKit.Models.Files; +namespace Imagekit.Models.Files; /// /// This API deletes the file and all its file versions permanently. diff --git a/src/ImageKit/Models/Files/FileGetParams.cs b/src/Imagekit/Models/Files/FileGetParams.cs similarity index 95% rename from src/ImageKit/Models/Files/FileGetParams.cs rename to src/Imagekit/Models/Files/FileGetParams.cs index 78e1fb0e..e23f53c8 100644 --- a/src/ImageKit/Models/Files/FileGetParams.cs +++ b/src/Imagekit/Models/Files/FileGetParams.cs @@ -4,9 +4,9 @@ using System.Diagnostics.CodeAnalysis; using System.Net.Http; using System.Text.Json; -using ImageKit.Core; +using Imagekit.Core; -namespace ImageKit.Models.Files; +namespace Imagekit.Models.Files; /// /// This API returns an object with details or attributes about the current version diff --git a/src/ImageKit/Models/Files/FileMetadata.cs b/src/Imagekit/Models/Files/FileMetadata.cs similarity index 95% rename from src/ImageKit/Models/Files/FileMetadata.cs rename to src/Imagekit/Models/Files/FileMetadata.cs index 9a202f7c..16367982 100644 --- a/src/ImageKit/Models/Files/FileMetadata.cs +++ b/src/Imagekit/Models/Files/FileMetadata.cs @@ -4,9 +4,9 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; +using Imagekit.Core; -namespace ImageKit.Models.Files; +namespace Imagekit.Models.Files; /// /// JSON object containing metadata. diff --git a/src/ImageKit/Models/Files/FileMoveParams.cs b/src/Imagekit/Models/Files/FileMoveParams.cs similarity index 96% rename from src/ImageKit/Models/Files/FileMoveParams.cs rename to src/Imagekit/Models/Files/FileMoveParams.cs index 01b7b2b8..ccd5c555 100644 --- a/src/ImageKit/Models/Files/FileMoveParams.cs +++ b/src/Imagekit/Models/Files/FileMoveParams.cs @@ -4,10 +4,10 @@ using System.Diagnostics.CodeAnalysis; using System.Net.Http; using System.Text.Json; -using ImageKit.Core; +using Imagekit.Core; using Text = System.Text; -namespace ImageKit.Models.Files; +namespace Imagekit.Models.Files; /// /// This will move a file and all its versions from one folder to another. diff --git a/src/ImageKit/Models/Files/FileMoveResponse.cs b/src/Imagekit/Models/Files/FileMoveResponse.cs similarity index 93% rename from src/ImageKit/Models/Files/FileMoveResponse.cs rename to src/Imagekit/Models/Files/FileMoveResponse.cs index e97c3318..6e6b75e7 100644 --- a/src/ImageKit/Models/Files/FileMoveResponse.cs +++ b/src/Imagekit/Models/Files/FileMoveResponse.cs @@ -3,9 +3,9 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; +using Imagekit.Core; -namespace ImageKit.Models.Files; +namespace Imagekit.Models.Files; [JsonConverter(typeof(JsonModelConverter))] public sealed record class FileMoveResponse : JsonModel diff --git a/src/ImageKit/Models/Files/FileRenameParams.cs b/src/Imagekit/Models/Files/FileRenameParams.cs similarity index 96% rename from src/ImageKit/Models/Files/FileRenameParams.cs rename to src/Imagekit/Models/Files/FileRenameParams.cs index 87fd5d31..24ab5f8e 100644 --- a/src/ImageKit/Models/Files/FileRenameParams.cs +++ b/src/Imagekit/Models/Files/FileRenameParams.cs @@ -4,10 +4,10 @@ using System.Diagnostics.CodeAnalysis; using System.Net.Http; using System.Text.Json; -using ImageKit.Core; +using Imagekit.Core; using Text = System.Text; -namespace ImageKit.Models.Files; +namespace Imagekit.Models.Files; /// /// You can rename an already existing file in the media library using rename file diff --git a/src/ImageKit/Models/Files/FileRenameResponse.cs b/src/Imagekit/Models/Files/FileRenameResponse.cs similarity index 93% rename from src/ImageKit/Models/Files/FileRenameResponse.cs rename to src/Imagekit/Models/Files/FileRenameResponse.cs index f1e0e367..a0d92c8f 100644 --- a/src/ImageKit/Models/Files/FileRenameResponse.cs +++ b/src/Imagekit/Models/Files/FileRenameResponse.cs @@ -3,9 +3,9 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; +using Imagekit.Core; -namespace ImageKit.Models.Files; +namespace Imagekit.Models.Files; [JsonConverter(typeof(JsonModelConverter))] public sealed record class FileRenameResponse : JsonModel diff --git a/src/ImageKit/Models/Files/FileUpdateParams.cs b/src/Imagekit/Models/Files/FileUpdateParams.cs similarity index 95% rename from src/ImageKit/Models/Files/FileUpdateParams.cs rename to src/Imagekit/Models/Files/FileUpdateParams.cs index 3d0deac5..d6de8c0d 100644 --- a/src/ImageKit/Models/Files/FileUpdateParams.cs +++ b/src/Imagekit/Models/Files/FileUpdateParams.cs @@ -4,10 +4,10 @@ using System.Diagnostics.CodeAnalysis; using System.Net.Http; using System.Text.Json; -using ImageKit.Core; +using Imagekit.Core; using Text = System.Text; -namespace ImageKit.Models.Files; +namespace Imagekit.Models.Files; /// /// This API updates the details or attributes of the current version of the file. diff --git a/src/ImageKit/Models/Files/FileUpdateResponse.cs b/src/Imagekit/Models/Files/FileUpdateResponse.cs similarity index 95% rename from src/ImageKit/Models/Files/FileUpdateResponse.cs rename to src/Imagekit/Models/Files/FileUpdateResponse.cs index 1453997f..329a6e6f 100644 --- a/src/ImageKit/Models/Files/FileUpdateResponse.cs +++ b/src/Imagekit/Models/Files/FileUpdateResponse.cs @@ -4,11 +4,11 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; -using ImageKit.Exceptions; +using Imagekit.Core; +using Imagekit.Exceptions; using System = System; -namespace ImageKit.Models.Files; +namespace Imagekit.Models.Files; /// /// Object containing details of a file or file version. diff --git a/src/ImageKit/Models/Files/FileUploadParams.cs b/src/Imagekit/Models/Files/FileUploadParams.cs similarity index 96% rename from src/ImageKit/Models/Files/FileUploadParams.cs rename to src/Imagekit/Models/Files/FileUploadParams.cs index 7f079878..49445f8b 100644 --- a/src/ImageKit/Models/Files/FileUploadParams.cs +++ b/src/Imagekit/Models/Files/FileUploadParams.cs @@ -5,11 +5,11 @@ using System.Net.Http; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; -using ImageKit.Exceptions; +using Imagekit.Core; +using Imagekit.Exceptions; using System = System; -namespace ImageKit.Models.Files; +namespace Imagekit.Models.Files; /// /// ImageKit.io allows you to upload files directly from both the server and client diff --git a/src/ImageKit/Models/Files/FileUploadResponse.cs b/src/Imagekit/Models/Files/FileUploadResponse.cs similarity index 96% rename from src/ImageKit/Models/Files/FileUploadResponse.cs rename to src/Imagekit/Models/Files/FileUploadResponse.cs index dc94cb9b..1c00d172 100644 --- a/src/ImageKit/Models/Files/FileUploadResponse.cs +++ b/src/Imagekit/Models/Files/FileUploadResponse.cs @@ -4,11 +4,11 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; -using ImageKit.Exceptions; +using Imagekit.Core; +using Imagekit.Exceptions; using System = System; -namespace ImageKit.Models.Files; +namespace Imagekit.Models.Files; /// /// Object containing details of a successful upload. diff --git a/src/ImageKit/Models/Files/Folder.cs b/src/Imagekit/Models/Files/Folder.cs similarity index 94% rename from src/ImageKit/Models/Files/Folder.cs rename to src/Imagekit/Models/Files/Folder.cs index 9b309071..a06eaf4d 100644 --- a/src/ImageKit/Models/Files/Folder.cs +++ b/src/Imagekit/Models/Files/Folder.cs @@ -3,11 +3,11 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; -using ImageKit.Exceptions; +using Imagekit.Core; +using Imagekit.Exceptions; using System = System; -namespace ImageKit.Models.Files; +namespace Imagekit.Models.Files; [JsonConverter(typeof(JsonModelConverter))] public sealed record class Folder : JsonModel diff --git a/src/ImageKit/Models/Files/Metadata/MetadataGetFromUrlParams.cs b/src/Imagekit/Models/Files/Metadata/MetadataGetFromUrlParams.cs similarity index 95% rename from src/ImageKit/Models/Files/Metadata/MetadataGetFromUrlParams.cs rename to src/Imagekit/Models/Files/Metadata/MetadataGetFromUrlParams.cs index 6260be3b..b1823fc5 100644 --- a/src/ImageKit/Models/Files/Metadata/MetadataGetFromUrlParams.cs +++ b/src/Imagekit/Models/Files/Metadata/MetadataGetFromUrlParams.cs @@ -4,9 +4,9 @@ using System.Diagnostics.CodeAnalysis; using System.Net.Http; using System.Text.Json; -using ImageKit.Core; +using Imagekit.Core; -namespace ImageKit.Models.Files.Metadata; +namespace Imagekit.Models.Files.Metadata; /// /// Get image EXIF, pHash, and other metadata from ImageKit.io powered remote URL diff --git a/src/ImageKit/Models/Files/Metadata/MetadataGetParams.cs b/src/Imagekit/Models/Files/Metadata/MetadataGetParams.cs similarity index 95% rename from src/ImageKit/Models/Files/Metadata/MetadataGetParams.cs rename to src/Imagekit/Models/Files/Metadata/MetadataGetParams.cs index 7352b408..93a4f7de 100644 --- a/src/ImageKit/Models/Files/Metadata/MetadataGetParams.cs +++ b/src/Imagekit/Models/Files/Metadata/MetadataGetParams.cs @@ -4,9 +4,9 @@ using System.Diagnostics.CodeAnalysis; using System.Net.Http; using System.Text.Json; -using ImageKit.Core; +using Imagekit.Core; -namespace ImageKit.Models.Files.Metadata; +namespace Imagekit.Models.Files.Metadata; /// /// You can programmatically get image EXIF, pHash, and other metadata for uploaded diff --git a/src/ImageKit/Models/Files/UpdateFileRequest.cs b/src/Imagekit/Models/Files/UpdateFileRequest.cs similarity index 96% rename from src/ImageKit/Models/Files/UpdateFileRequest.cs rename to src/Imagekit/Models/Files/UpdateFileRequest.cs index c99ace8c..866f8cb6 100644 --- a/src/ImageKit/Models/Files/UpdateFileRequest.cs +++ b/src/Imagekit/Models/Files/UpdateFileRequest.cs @@ -4,11 +4,11 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; -using ImageKit.Exceptions; +using Imagekit.Core; +using Imagekit.Exceptions; using System = System; -namespace ImageKit.Models.Files; +namespace Imagekit.Models.Files; /// /// Schema for update file update request. diff --git a/src/ImageKit/Models/Files/Versions/VersionDeleteParams.cs b/src/Imagekit/Models/Files/Versions/VersionDeleteParams.cs similarity index 95% rename from src/ImageKit/Models/Files/Versions/VersionDeleteParams.cs rename to src/Imagekit/Models/Files/Versions/VersionDeleteParams.cs index a2bf8f31..8c600393 100644 --- a/src/ImageKit/Models/Files/Versions/VersionDeleteParams.cs +++ b/src/Imagekit/Models/Files/Versions/VersionDeleteParams.cs @@ -4,9 +4,9 @@ using System.Diagnostics.CodeAnalysis; using System.Net.Http; using System.Text.Json; -using ImageKit.Core; +using Imagekit.Core; -namespace ImageKit.Models.Files.Versions; +namespace Imagekit.Models.Files.Versions; /// /// This API deletes a non-current file version permanently. The API returns an empty response. diff --git a/src/ImageKit/Models/Files/Versions/VersionDeleteResponse.cs b/src/Imagekit/Models/Files/Versions/VersionDeleteResponse.cs similarity index 93% rename from src/ImageKit/Models/Files/Versions/VersionDeleteResponse.cs rename to src/Imagekit/Models/Files/Versions/VersionDeleteResponse.cs index c1537f0e..6eef4640 100644 --- a/src/ImageKit/Models/Files/Versions/VersionDeleteResponse.cs +++ b/src/Imagekit/Models/Files/Versions/VersionDeleteResponse.cs @@ -3,9 +3,9 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; +using Imagekit.Core; -namespace ImageKit.Models.Files.Versions; +namespace Imagekit.Models.Files.Versions; [JsonConverter(typeof(JsonModelConverter))] public sealed record class VersionDeleteResponse : JsonModel diff --git a/src/ImageKit/Models/Files/Versions/VersionGetParams.cs b/src/Imagekit/Models/Files/Versions/VersionGetParams.cs similarity index 95% rename from src/ImageKit/Models/Files/Versions/VersionGetParams.cs rename to src/Imagekit/Models/Files/Versions/VersionGetParams.cs index 44fe8852..0f4ca1bf 100644 --- a/src/ImageKit/Models/Files/Versions/VersionGetParams.cs +++ b/src/Imagekit/Models/Files/Versions/VersionGetParams.cs @@ -4,9 +4,9 @@ using System.Diagnostics.CodeAnalysis; using System.Net.Http; using System.Text.Json; -using ImageKit.Core; +using Imagekit.Core; -namespace ImageKit.Models.Files.Versions; +namespace Imagekit.Models.Files.Versions; /// /// This API returns an object with details or attributes of a file version. diff --git a/src/ImageKit/Models/Files/Versions/VersionListParams.cs b/src/Imagekit/Models/Files/Versions/VersionListParams.cs similarity index 95% rename from src/ImageKit/Models/Files/Versions/VersionListParams.cs rename to src/Imagekit/Models/Files/Versions/VersionListParams.cs index 6a9dea2e..ecb7ac7f 100644 --- a/src/ImageKit/Models/Files/Versions/VersionListParams.cs +++ b/src/Imagekit/Models/Files/Versions/VersionListParams.cs @@ -4,9 +4,9 @@ using System.Diagnostics.CodeAnalysis; using System.Net.Http; using System.Text.Json; -using ImageKit.Core; +using Imagekit.Core; -namespace ImageKit.Models.Files.Versions; +namespace Imagekit.Models.Files.Versions; /// /// This API returns details of all versions of a file. diff --git a/src/ImageKit/Models/Files/Versions/VersionRestoreParams.cs b/src/Imagekit/Models/Files/Versions/VersionRestoreParams.cs similarity index 95% rename from src/ImageKit/Models/Files/Versions/VersionRestoreParams.cs rename to src/Imagekit/Models/Files/Versions/VersionRestoreParams.cs index ca4a4fd5..b12d3c89 100644 --- a/src/ImageKit/Models/Files/Versions/VersionRestoreParams.cs +++ b/src/Imagekit/Models/Files/Versions/VersionRestoreParams.cs @@ -4,9 +4,9 @@ using System.Diagnostics.CodeAnalysis; using System.Net.Http; using System.Text.Json; -using ImageKit.Core; +using Imagekit.Core; -namespace ImageKit.Models.Files.Versions; +namespace Imagekit.Models.Files.Versions; /// /// This API restores a file version as the current file version. diff --git a/src/ImageKit/Models/Folders/FolderCopyParams.cs b/src/Imagekit/Models/Folders/FolderCopyParams.cs similarity index 96% rename from src/ImageKit/Models/Folders/FolderCopyParams.cs rename to src/Imagekit/Models/Folders/FolderCopyParams.cs index 4a6961ad..54fee7eb 100644 --- a/src/ImageKit/Models/Folders/FolderCopyParams.cs +++ b/src/Imagekit/Models/Folders/FolderCopyParams.cs @@ -4,10 +4,10 @@ using System.Diagnostics.CodeAnalysis; using System.Net.Http; using System.Text.Json; -using ImageKit.Core; +using Imagekit.Core; using Text = System.Text; -namespace ImageKit.Models.Folders; +namespace Imagekit.Models.Folders; /// /// This will copy one folder into another. The selected folder, its nested folders, diff --git a/src/ImageKit/Models/Folders/FolderCopyResponse.cs b/src/Imagekit/Models/Folders/FolderCopyResponse.cs similarity index 94% rename from src/ImageKit/Models/Folders/FolderCopyResponse.cs rename to src/Imagekit/Models/Folders/FolderCopyResponse.cs index 8840cd5f..a8d78bf5 100644 --- a/src/ImageKit/Models/Folders/FolderCopyResponse.cs +++ b/src/Imagekit/Models/Folders/FolderCopyResponse.cs @@ -3,9 +3,9 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; +using Imagekit.Core; -namespace ImageKit.Models.Folders; +namespace Imagekit.Models.Folders; /// /// Job submitted successfully. A `jobId` will be returned. diff --git a/src/ImageKit/Models/Folders/FolderCreateParams.cs b/src/Imagekit/Models/Folders/FolderCreateParams.cs similarity index 96% rename from src/ImageKit/Models/Folders/FolderCreateParams.cs rename to src/Imagekit/Models/Folders/FolderCreateParams.cs index d693105b..43003cbc 100644 --- a/src/ImageKit/Models/Folders/FolderCreateParams.cs +++ b/src/Imagekit/Models/Folders/FolderCreateParams.cs @@ -4,10 +4,10 @@ using System.Diagnostics.CodeAnalysis; using System.Net.Http; using System.Text.Json; -using ImageKit.Core; +using Imagekit.Core; using Text = System.Text; -namespace ImageKit.Models.Folders; +namespace Imagekit.Models.Folders; /// /// This will create a new folder. You can specify the folder name and location of diff --git a/src/ImageKit/Models/Folders/FolderCreateResponse.cs b/src/Imagekit/Models/Folders/FolderCreateResponse.cs similarity index 93% rename from src/ImageKit/Models/Folders/FolderCreateResponse.cs rename to src/Imagekit/Models/Folders/FolderCreateResponse.cs index d03e0ba2..ccbd1f77 100644 --- a/src/ImageKit/Models/Folders/FolderCreateResponse.cs +++ b/src/Imagekit/Models/Folders/FolderCreateResponse.cs @@ -3,9 +3,9 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; +using Imagekit.Core; -namespace ImageKit.Models.Folders; +namespace Imagekit.Models.Folders; [JsonConverter(typeof(JsonModelConverter))] public sealed record class FolderCreateResponse : JsonModel diff --git a/src/ImageKit/Models/Folders/FolderDeleteParams.cs b/src/Imagekit/Models/Folders/FolderDeleteParams.cs similarity index 95% rename from src/ImageKit/Models/Folders/FolderDeleteParams.cs rename to src/Imagekit/Models/Folders/FolderDeleteParams.cs index 488a012b..31faef01 100644 --- a/src/ImageKit/Models/Folders/FolderDeleteParams.cs +++ b/src/Imagekit/Models/Folders/FolderDeleteParams.cs @@ -4,10 +4,10 @@ using System.Diagnostics.CodeAnalysis; using System.Net.Http; using System.Text.Json; -using ImageKit.Core; +using Imagekit.Core; using Text = System.Text; -namespace ImageKit.Models.Folders; +namespace Imagekit.Models.Folders; /// /// This will delete a folder and all its contents permanently. The API returns an diff --git a/src/ImageKit/Models/Folders/FolderDeleteResponse.cs b/src/Imagekit/Models/Folders/FolderDeleteResponse.cs similarity index 93% rename from src/ImageKit/Models/Folders/FolderDeleteResponse.cs rename to src/Imagekit/Models/Folders/FolderDeleteResponse.cs index 08e19303..14315872 100644 --- a/src/ImageKit/Models/Folders/FolderDeleteResponse.cs +++ b/src/Imagekit/Models/Folders/FolderDeleteResponse.cs @@ -3,9 +3,9 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; +using Imagekit.Core; -namespace ImageKit.Models.Folders; +namespace Imagekit.Models.Folders; [JsonConverter(typeof(JsonModelConverter))] public sealed record class FolderDeleteResponse : JsonModel diff --git a/src/ImageKit/Models/Folders/FolderMoveParams.cs b/src/Imagekit/Models/Folders/FolderMoveParams.cs similarity index 96% rename from src/ImageKit/Models/Folders/FolderMoveParams.cs rename to src/Imagekit/Models/Folders/FolderMoveParams.cs index bc0d0fe1..8d65ada2 100644 --- a/src/ImageKit/Models/Folders/FolderMoveParams.cs +++ b/src/Imagekit/Models/Folders/FolderMoveParams.cs @@ -4,10 +4,10 @@ using System.Diagnostics.CodeAnalysis; using System.Net.Http; using System.Text.Json; -using ImageKit.Core; +using Imagekit.Core; using Text = System.Text; -namespace ImageKit.Models.Folders; +namespace Imagekit.Models.Folders; /// /// This will move one folder into another. The selected folder, its nested folders, diff --git a/src/ImageKit/Models/Folders/FolderMoveResponse.cs b/src/Imagekit/Models/Folders/FolderMoveResponse.cs similarity index 94% rename from src/ImageKit/Models/Folders/FolderMoveResponse.cs rename to src/Imagekit/Models/Folders/FolderMoveResponse.cs index e9fc02c4..b4826761 100644 --- a/src/ImageKit/Models/Folders/FolderMoveResponse.cs +++ b/src/Imagekit/Models/Folders/FolderMoveResponse.cs @@ -3,9 +3,9 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; +using Imagekit.Core; -namespace ImageKit.Models.Folders; +namespace Imagekit.Models.Folders; /// /// Job submitted successfully. A `jobId` will be returned. diff --git a/src/ImageKit/Models/Folders/FolderRenameParams.cs b/src/Imagekit/Models/Folders/FolderRenameParams.cs similarity index 96% rename from src/ImageKit/Models/Folders/FolderRenameParams.cs rename to src/Imagekit/Models/Folders/FolderRenameParams.cs index 6e37368c..52180b32 100644 --- a/src/ImageKit/Models/Folders/FolderRenameParams.cs +++ b/src/Imagekit/Models/Folders/FolderRenameParams.cs @@ -4,10 +4,10 @@ using System.Diagnostics.CodeAnalysis; using System.Net.Http; using System.Text.Json; -using ImageKit.Core; +using Imagekit.Core; using Text = System.Text; -namespace ImageKit.Models.Folders; +namespace Imagekit.Models.Folders; /// /// This API allows you to rename an existing folder. The folder and all its nested diff --git a/src/ImageKit/Models/Folders/FolderRenameResponse.cs b/src/Imagekit/Models/Folders/FolderRenameResponse.cs similarity index 94% rename from src/ImageKit/Models/Folders/FolderRenameResponse.cs rename to src/Imagekit/Models/Folders/FolderRenameResponse.cs index c511f3c3..c330a60a 100644 --- a/src/ImageKit/Models/Folders/FolderRenameResponse.cs +++ b/src/Imagekit/Models/Folders/FolderRenameResponse.cs @@ -3,9 +3,9 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; +using Imagekit.Core; -namespace ImageKit.Models.Folders; +namespace Imagekit.Models.Folders; /// /// Job submitted successfully. A `jobId` will be returned. diff --git a/src/ImageKit/Models/Folders/Job/JobGetParams.cs b/src/Imagekit/Models/Folders/Job/JobGetParams.cs similarity index 95% rename from src/ImageKit/Models/Folders/Job/JobGetParams.cs rename to src/Imagekit/Models/Folders/Job/JobGetParams.cs index cf03c15b..35e5f68a 100644 --- a/src/ImageKit/Models/Folders/Job/JobGetParams.cs +++ b/src/Imagekit/Models/Folders/Job/JobGetParams.cs @@ -4,9 +4,9 @@ using System.Diagnostics.CodeAnalysis; using System.Net.Http; using System.Text.Json; -using ImageKit.Core; +using Imagekit.Core; -namespace ImageKit.Models.Folders.Job; +namespace Imagekit.Models.Folders.Job; /// /// This API returns the status of a bulk job like copy and move folder operations. diff --git a/src/ImageKit/Models/Folders/Job/JobGetResponse.cs b/src/Imagekit/Models/Folders/Job/JobGetResponse.cs similarity index 83% rename from src/ImageKit/Models/Folders/Job/JobGetResponse.cs rename to src/Imagekit/Models/Folders/Job/JobGetResponse.cs index 0dfa7b74..496692cc 100644 --- a/src/ImageKit/Models/Folders/Job/JobGetResponse.cs +++ b/src/Imagekit/Models/Folders/Job/JobGetResponse.cs @@ -3,11 +3,11 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; -using ImageKit.Exceptions; +using Imagekit.Core; +using Imagekit.Exceptions; using System = System; -namespace ImageKit.Models.Folders.Job; +namespace Imagekit.Models.Folders.Job; [JsonConverter(typeof(JsonModelConverter))] public sealed record class JobGetResponse : JsonModel @@ -79,13 +79,13 @@ public ApiEnum? Status /// /// Type of the bulk job. /// - public ApiEnum? Type + public ApiEnum? Type { get { this._rawData.Freeze(); return this._rawData.GetNullableClass< - ApiEnum + ApiEnum >("type"); } init @@ -197,9 +197,9 @@ public enum Type RenameFolder, } -sealed class TypeConverter : JsonConverter +sealed class TypeConverter : JsonConverter { - public override global::ImageKit.Models.Folders.Job.Type Read( + public override global::Imagekit.Models.Folders.Job.Type Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -207,16 +207,16 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "COPY_FOLDER" => global::ImageKit.Models.Folders.Job.Type.CopyFolder, - "MOVE_FOLDER" => global::ImageKit.Models.Folders.Job.Type.MoveFolder, - "RENAME_FOLDER" => global::ImageKit.Models.Folders.Job.Type.RenameFolder, - _ => (global::ImageKit.Models.Folders.Job.Type)(-1), + "COPY_FOLDER" => global::Imagekit.Models.Folders.Job.Type.CopyFolder, + "MOVE_FOLDER" => global::Imagekit.Models.Folders.Job.Type.MoveFolder, + "RENAME_FOLDER" => global::Imagekit.Models.Folders.Job.Type.RenameFolder, + _ => (global::Imagekit.Models.Folders.Job.Type)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::ImageKit.Models.Folders.Job.Type value, + global::Imagekit.Models.Folders.Job.Type value, JsonSerializerOptions options ) { @@ -224,9 +224,9 @@ JsonSerializerOptions options writer, value switch { - global::ImageKit.Models.Folders.Job.Type.CopyFolder => "COPY_FOLDER", - global::ImageKit.Models.Folders.Job.Type.MoveFolder => "MOVE_FOLDER", - global::ImageKit.Models.Folders.Job.Type.RenameFolder => "RENAME_FOLDER", + global::Imagekit.Models.Folders.Job.Type.CopyFolder => "COPY_FOLDER", + global::Imagekit.Models.Folders.Job.Type.MoveFolder => "MOVE_FOLDER", + global::Imagekit.Models.Folders.Job.Type.RenameFolder => "RENAME_FOLDER", _ => throw new ImageKitInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/ImageKit/Models/GetImageAttributesOptions.cs b/src/Imagekit/Models/GetImageAttributesOptions.cs similarity index 96% rename from src/ImageKit/Models/GetImageAttributesOptions.cs rename to src/Imagekit/Models/GetImageAttributesOptions.cs index a4e2ef4e..8b2e43d0 100644 --- a/src/ImageKit/Models/GetImageAttributesOptions.cs +++ b/src/Imagekit/Models/GetImageAttributesOptions.cs @@ -4,9 +4,9 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; +using Imagekit.Core; -namespace ImageKit.Models; +namespace Imagekit.Models; /// /// Options for generating responsive image attributes including `src`, `srcSet`, diff --git a/src/ImageKit/Models/ImageOverlay.cs b/src/Imagekit/Models/ImageOverlay.cs similarity index 96% rename from src/ImageKit/Models/ImageOverlay.cs rename to src/Imagekit/Models/ImageOverlay.cs index 91c5b716..3efe472f 100644 --- a/src/ImageKit/Models/ImageOverlay.cs +++ b/src/Imagekit/Models/ImageOverlay.cs @@ -5,10 +5,10 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; -using ImageKit.Exceptions; +using Imagekit.Core; +using Imagekit.Exceptions; -namespace ImageKit.Models; +namespace Imagekit.Models; [JsonConverter(typeof(JsonModelConverter))] public sealed record class ImageOverlay : JsonModel diff --git a/src/ImageKit/Models/Overlay.cs b/src/Imagekit/Models/Overlay.cs similarity index 96% rename from src/ImageKit/Models/Overlay.cs rename to src/Imagekit/Models/Overlay.cs index b24822b8..853be89f 100644 --- a/src/ImageKit/Models/Overlay.cs +++ b/src/Imagekit/Models/Overlay.cs @@ -2,10 +2,10 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; -using ImageKit.Exceptions; +using Imagekit.Core; +using Imagekit.Exceptions; -namespace ImageKit.Models; +namespace Imagekit.Models; /// /// Specifies an overlay to be applied on the parent image or video. ImageKit supports diff --git a/src/ImageKit/Models/OverlayPosition.cs b/src/Imagekit/Models/OverlayPosition.cs similarity index 96% rename from src/ImageKit/Models/OverlayPosition.cs rename to src/Imagekit/Models/OverlayPosition.cs index 33f724d8..3b37f6b6 100644 --- a/src/ImageKit/Models/OverlayPosition.cs +++ b/src/Imagekit/Models/OverlayPosition.cs @@ -4,10 +4,10 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; -using ImageKit.Exceptions; +using Imagekit.Core; +using Imagekit.Exceptions; -namespace ImageKit.Models; +namespace Imagekit.Models; [JsonConverter(typeof(JsonModelConverter))] public sealed record class OverlayPosition : JsonModel diff --git a/src/ImageKit/Models/OverlayTiming.cs b/src/Imagekit/Models/OverlayTiming.cs similarity index 96% rename from src/ImageKit/Models/OverlayTiming.cs rename to src/Imagekit/Models/OverlayTiming.cs index 7804df98..5326349d 100644 --- a/src/ImageKit/Models/OverlayTiming.cs +++ b/src/Imagekit/Models/OverlayTiming.cs @@ -4,10 +4,10 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; -using ImageKit.Exceptions; +using Imagekit.Core; +using Imagekit.Exceptions; -namespace ImageKit.Models; +namespace Imagekit.Models; [JsonConverter(typeof(JsonModelConverter))] public sealed record class OverlayTiming : JsonModel diff --git a/src/ImageKit/Models/ResponsiveImageAttributes.cs b/src/Imagekit/Models/ResponsiveImageAttributes.cs similarity index 95% rename from src/ImageKit/Models/ResponsiveImageAttributes.cs rename to src/Imagekit/Models/ResponsiveImageAttributes.cs index 840f18f4..b719168a 100644 --- a/src/ImageKit/Models/ResponsiveImageAttributes.cs +++ b/src/Imagekit/Models/ResponsiveImageAttributes.cs @@ -3,9 +3,9 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; +using Imagekit.Core; -namespace ImageKit.Models; +namespace Imagekit.Models; /// /// Resulting set of attributes suitable for an HTML `<img>` element. Useful diff --git a/src/ImageKit/Models/SavedExtensions/SavedExtensionCreateParams.cs b/src/Imagekit/Models/SavedExtensions/SavedExtensionCreateParams.cs similarity index 95% rename from src/ImageKit/Models/SavedExtensions/SavedExtensionCreateParams.cs rename to src/Imagekit/Models/SavedExtensions/SavedExtensionCreateParams.cs index f525e2a4..cbc65193 100644 --- a/src/ImageKit/Models/SavedExtensions/SavedExtensionCreateParams.cs +++ b/src/Imagekit/Models/SavedExtensions/SavedExtensionCreateParams.cs @@ -4,10 +4,10 @@ using System.Diagnostics.CodeAnalysis; using System.Net.Http; using System.Text.Json; -using ImageKit.Core; +using Imagekit.Core; using Text = System.Text; -namespace ImageKit.Models.SavedExtensions; +namespace Imagekit.Models.SavedExtensions; /// /// This API creates a new saved extension. Saved extensions allow you to save complex diff --git a/src/ImageKit/Models/SavedExtensions/SavedExtensionDeleteParams.cs b/src/Imagekit/Models/SavedExtensions/SavedExtensionDeleteParams.cs similarity index 95% rename from src/ImageKit/Models/SavedExtensions/SavedExtensionDeleteParams.cs rename to src/Imagekit/Models/SavedExtensions/SavedExtensionDeleteParams.cs index 6d9d0d97..065755e1 100644 --- a/src/ImageKit/Models/SavedExtensions/SavedExtensionDeleteParams.cs +++ b/src/Imagekit/Models/SavedExtensions/SavedExtensionDeleteParams.cs @@ -4,9 +4,9 @@ using System.Diagnostics.CodeAnalysis; using System.Net.Http; using System.Text.Json; -using ImageKit.Core; +using Imagekit.Core; -namespace ImageKit.Models.SavedExtensions; +namespace Imagekit.Models.SavedExtensions; /// /// This API deletes a saved extension permanently. diff --git a/src/ImageKit/Models/SavedExtensions/SavedExtensionGetParams.cs b/src/Imagekit/Models/SavedExtensions/SavedExtensionGetParams.cs similarity index 95% rename from src/ImageKit/Models/SavedExtensions/SavedExtensionGetParams.cs rename to src/Imagekit/Models/SavedExtensions/SavedExtensionGetParams.cs index 264db6bd..e72d7eae 100644 --- a/src/ImageKit/Models/SavedExtensions/SavedExtensionGetParams.cs +++ b/src/Imagekit/Models/SavedExtensions/SavedExtensionGetParams.cs @@ -4,9 +4,9 @@ using System.Diagnostics.CodeAnalysis; using System.Net.Http; using System.Text.Json; -using ImageKit.Core; +using Imagekit.Core; -namespace ImageKit.Models.SavedExtensions; +namespace Imagekit.Models.SavedExtensions; /// /// This API returns details of a specific saved extension by ID. diff --git a/src/ImageKit/Models/SavedExtensions/SavedExtensionListParams.cs b/src/Imagekit/Models/SavedExtensions/SavedExtensionListParams.cs similarity index 95% rename from src/ImageKit/Models/SavedExtensions/SavedExtensionListParams.cs rename to src/Imagekit/Models/SavedExtensions/SavedExtensionListParams.cs index 917c1108..3200e681 100644 --- a/src/ImageKit/Models/SavedExtensions/SavedExtensionListParams.cs +++ b/src/Imagekit/Models/SavedExtensions/SavedExtensionListParams.cs @@ -4,9 +4,9 @@ using System.Diagnostics.CodeAnalysis; using System.Net.Http; using System.Text.Json; -using ImageKit.Core; +using Imagekit.Core; -namespace ImageKit.Models.SavedExtensions; +namespace Imagekit.Models.SavedExtensions; /// /// This API returns an array of all saved extensions for your account. Saved extensions diff --git a/src/ImageKit/Models/SavedExtensions/SavedExtensionUpdateParams.cs b/src/Imagekit/Models/SavedExtensions/SavedExtensionUpdateParams.cs similarity index 95% rename from src/ImageKit/Models/SavedExtensions/SavedExtensionUpdateParams.cs rename to src/Imagekit/Models/SavedExtensions/SavedExtensionUpdateParams.cs index 081cc4b7..b08ea714 100644 --- a/src/ImageKit/Models/SavedExtensions/SavedExtensionUpdateParams.cs +++ b/src/Imagekit/Models/SavedExtensions/SavedExtensionUpdateParams.cs @@ -4,10 +4,10 @@ using System.Diagnostics.CodeAnalysis; using System.Net.Http; using System.Text.Json; -using ImageKit.Core; +using Imagekit.Core; using Text = System.Text; -namespace ImageKit.Models.SavedExtensions; +namespace Imagekit.Models.SavedExtensions; /// /// This API updates an existing saved extension. You can update the name, description, diff --git a/src/ImageKit/Models/SharedSavedExtension.cs b/src/Imagekit/Models/SharedSavedExtension.cs similarity index 94% rename from src/ImageKit/Models/SharedSavedExtension.cs rename to src/Imagekit/Models/SharedSavedExtension.cs index 3a79e38e..38daabfb 100644 --- a/src/ImageKit/Models/SharedSavedExtension.cs +++ b/src/Imagekit/Models/SharedSavedExtension.cs @@ -4,9 +4,9 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; +using Imagekit.Core; -namespace ImageKit.Models; +namespace Imagekit.Models; /// /// Saved extension object containing extension configuration. diff --git a/src/ImageKit/Models/SolidColorOverlay.cs b/src/Imagekit/Models/SolidColorOverlay.cs similarity index 96% rename from src/ImageKit/Models/SolidColorOverlay.cs rename to src/Imagekit/Models/SolidColorOverlay.cs index 23164e36..5c57ea8d 100644 --- a/src/ImageKit/Models/SolidColorOverlay.cs +++ b/src/Imagekit/Models/SolidColorOverlay.cs @@ -4,10 +4,10 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; -using ImageKit.Exceptions; +using Imagekit.Core; +using Imagekit.Exceptions; -namespace ImageKit.Models; +namespace Imagekit.Models; [JsonConverter(typeof(JsonModelConverter))] public sealed record class SolidColorOverlay : JsonModel diff --git a/src/ImageKit/Models/SolidColorOverlayTransformation.cs b/src/Imagekit/Models/SolidColorOverlayTransformation.cs similarity index 96% rename from src/ImageKit/Models/SolidColorOverlayTransformation.cs rename to src/Imagekit/Models/SolidColorOverlayTransformation.cs index c8e1e310..a4ff0bb5 100644 --- a/src/ImageKit/Models/SolidColorOverlayTransformation.cs +++ b/src/Imagekit/Models/SolidColorOverlayTransformation.cs @@ -4,10 +4,10 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; -using ImageKit.Exceptions; +using Imagekit.Core; +using Imagekit.Exceptions; -namespace ImageKit.Models; +namespace Imagekit.Models; [JsonConverter( typeof(JsonModelConverter< diff --git a/src/ImageKit/Models/SrcOptions.cs b/src/Imagekit/Models/SrcOptions.cs similarity index 96% rename from src/ImageKit/Models/SrcOptions.cs rename to src/Imagekit/Models/SrcOptions.cs index 808eed52..0c1821b2 100644 --- a/src/ImageKit/Models/SrcOptions.cs +++ b/src/Imagekit/Models/SrcOptions.cs @@ -4,9 +4,9 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; +using Imagekit.Core; -namespace ImageKit.Models; +namespace Imagekit.Models; /// /// Options for generating ImageKit URLs with transformations. See the [Transformations guide](https://imagekit.io/docs/transformations). diff --git a/src/ImageKit/Models/StreamingResolution.cs b/src/Imagekit/Models/StreamingResolution.cs similarity index 94% rename from src/ImageKit/Models/StreamingResolution.cs rename to src/Imagekit/Models/StreamingResolution.cs index f6d8879a..66591680 100644 --- a/src/ImageKit/Models/StreamingResolution.cs +++ b/src/Imagekit/Models/StreamingResolution.cs @@ -1,9 +1,9 @@ using System; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Exceptions; +using Imagekit.Exceptions; -namespace ImageKit.Models; +namespace Imagekit.Models; /// /// Available streaming resolutions for [adaptive bitrate streaming](https://imagekit.io/docs/adaptive-bitrate-streaming) diff --git a/src/ImageKit/Models/SubtitleOverlay.cs b/src/Imagekit/Models/SubtitleOverlay.cs similarity index 96% rename from src/ImageKit/Models/SubtitleOverlay.cs rename to src/Imagekit/Models/SubtitleOverlay.cs index 5facadaf..493c5426 100644 --- a/src/ImageKit/Models/SubtitleOverlay.cs +++ b/src/Imagekit/Models/SubtitleOverlay.cs @@ -5,10 +5,10 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; -using ImageKit.Exceptions; +using Imagekit.Core; +using Imagekit.Exceptions; -namespace ImageKit.Models; +namespace Imagekit.Models; [JsonConverter(typeof(JsonModelConverter))] public sealed record class SubtitleOverlay : JsonModel diff --git a/src/ImageKit/Models/SubtitleOverlayTransformation.cs b/src/Imagekit/Models/SubtitleOverlayTransformation.cs similarity index 95% rename from src/ImageKit/Models/SubtitleOverlayTransformation.cs rename to src/Imagekit/Models/SubtitleOverlayTransformation.cs index 9a012411..aaeb992e 100644 --- a/src/ImageKit/Models/SubtitleOverlayTransformation.cs +++ b/src/Imagekit/Models/SubtitleOverlayTransformation.cs @@ -4,10 +4,10 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; -using ImageKit.Exceptions; +using Imagekit.Core; +using Imagekit.Exceptions; -namespace ImageKit.Models; +namespace Imagekit.Models; /// /// Subtitle styling options. [Learn more](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) diff --git a/src/ImageKit/Models/TextOverlay.cs b/src/Imagekit/Models/TextOverlay.cs similarity index 96% rename from src/ImageKit/Models/TextOverlay.cs rename to src/Imagekit/Models/TextOverlay.cs index 5fbad196..6b4c9eb2 100644 --- a/src/ImageKit/Models/TextOverlay.cs +++ b/src/Imagekit/Models/TextOverlay.cs @@ -5,10 +5,10 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; -using ImageKit.Exceptions; +using Imagekit.Core; +using Imagekit.Exceptions; -namespace ImageKit.Models; +namespace Imagekit.Models; [JsonConverter(typeof(JsonModelConverter))] public sealed record class TextOverlay : JsonModel diff --git a/src/ImageKit/Models/TextOverlayTransformation.cs b/src/Imagekit/Models/TextOverlayTransformation.cs similarity index 96% rename from src/ImageKit/Models/TextOverlayTransformation.cs rename to src/Imagekit/Models/TextOverlayTransformation.cs index 7af21dad..b54e90d5 100644 --- a/src/ImageKit/Models/TextOverlayTransformation.cs +++ b/src/Imagekit/Models/TextOverlayTransformation.cs @@ -4,10 +4,10 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; -using ImageKit.Exceptions; +using Imagekit.Core; +using Imagekit.Exceptions; -namespace ImageKit.Models; +namespace Imagekit.Models; [JsonConverter( typeof(JsonModelConverter) diff --git a/src/ImageKit/Models/Transformation.cs b/src/Imagekit/Models/Transformation.cs similarity index 96% rename from src/ImageKit/Models/Transformation.cs rename to src/Imagekit/Models/Transformation.cs index 906adbaa..825715e1 100644 --- a/src/ImageKit/Models/Transformation.cs +++ b/src/Imagekit/Models/Transformation.cs @@ -5,10 +5,10 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; -using ImageKit.Exceptions; +using Imagekit.Core; +using Imagekit.Exceptions; -namespace ImageKit.Models; +namespace Imagekit.Models; /// /// The SDK provides easy-to-use names for transformations. These names are converted diff --git a/src/ImageKit/Models/TransformationPosition.cs b/src/Imagekit/Models/TransformationPosition.cs similarity index 93% rename from src/ImageKit/Models/TransformationPosition.cs rename to src/Imagekit/Models/TransformationPosition.cs index cc6dba91..c2079e12 100644 --- a/src/ImageKit/Models/TransformationPosition.cs +++ b/src/Imagekit/Models/TransformationPosition.cs @@ -1,9 +1,9 @@ using System; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Exceptions; +using Imagekit.Exceptions; -namespace ImageKit.Models; +namespace Imagekit.Models; /// /// By default, the transformation string is added as a query parameter in the URL, diff --git a/src/ImageKit/Models/UnnamedSchemaWithArrayParent0.cs b/src/Imagekit/Models/UnnamedSchemaWithArrayParent0.cs similarity index 96% rename from src/ImageKit/Models/UnnamedSchemaWithArrayParent0.cs rename to src/Imagekit/Models/UnnamedSchemaWithArrayParent0.cs index 0f451e90..ac3ddb4f 100644 --- a/src/ImageKit/Models/UnnamedSchemaWithArrayParent0.cs +++ b/src/Imagekit/Models/UnnamedSchemaWithArrayParent0.cs @@ -5,10 +5,10 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; -using ImageKit.Exceptions; +using Imagekit.Core; +using Imagekit.Exceptions; -namespace ImageKit.Models; +namespace Imagekit.Models; [JsonConverter(typeof(UnnamedSchemaWithArrayParent0Converter))] public record class UnnamedSchemaWithArrayParent0 : ModelBase diff --git a/src/ImageKit/Models/VideoOverlay.cs b/src/Imagekit/Models/VideoOverlay.cs similarity index 96% rename from src/ImageKit/Models/VideoOverlay.cs rename to src/Imagekit/Models/VideoOverlay.cs index 623b2ce0..102d8eb7 100644 --- a/src/ImageKit/Models/VideoOverlay.cs +++ b/src/Imagekit/Models/VideoOverlay.cs @@ -5,10 +5,10 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; -using ImageKit.Exceptions; +using Imagekit.Core; +using Imagekit.Exceptions; -namespace ImageKit.Models; +namespace Imagekit.Models; [JsonConverter(typeof(JsonModelConverter))] public sealed record class VideoOverlay : JsonModel diff --git a/src/ImageKit/Models/Webhooks/BaseWebhookEvent.cs b/src/Imagekit/Models/Webhooks/BaseWebhookEvent.cs similarity index 93% rename from src/ImageKit/Models/Webhooks/BaseWebhookEvent.cs rename to src/Imagekit/Models/Webhooks/BaseWebhookEvent.cs index 5e455cc1..10ca48d3 100644 --- a/src/ImageKit/Models/Webhooks/BaseWebhookEvent.cs +++ b/src/Imagekit/Models/Webhooks/BaseWebhookEvent.cs @@ -3,9 +3,9 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; +using Imagekit.Core; -namespace ImageKit.Models.Webhooks; +namespace Imagekit.Models.Webhooks; [JsonConverter(typeof(JsonModelConverter))] public sealed record class BaseWebhookEvent : JsonModel diff --git a/src/ImageKit/Models/Webhooks/FileCreateEvent.cs b/src/Imagekit/Models/Webhooks/FileCreateEvent.cs similarity index 87% rename from src/ImageKit/Models/Webhooks/FileCreateEvent.cs rename to src/Imagekit/Models/Webhooks/FileCreateEvent.cs index d912bd4f..a7266eb9 100644 --- a/src/ImageKit/Models/Webhooks/FileCreateEvent.cs +++ b/src/Imagekit/Models/Webhooks/FileCreateEvent.cs @@ -4,11 +4,11 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; -using ImageKit.Exceptions; -using ImageKit.Models.Files; +using Imagekit.Core; +using Imagekit.Exceptions; +using Imagekit.Models.Files; -namespace ImageKit.Models.Webhooks; +namespace Imagekit.Models.Webhooks; /// /// Triggered when a file is created. @@ -120,8 +120,8 @@ public FileCreateEvent FromRawUnchecked(IReadOnlyDictionary /// [JsonConverter( typeof(JsonModelConverter< - global::ImageKit.Models.Webhooks.IntersectionMember1, - global::ImageKit.Models.Webhooks.IntersectionMember1FromRaw + global::Imagekit.Models.Webhooks.IntersectionMember1, + global::Imagekit.Models.Webhooks.IntersectionMember1FromRaw >) )] public sealed record class IntersectionMember1 : JsonModel @@ -184,7 +184,7 @@ public IntersectionMember1() #pragma warning disable CS8618 [SetsRequiredMembers] public IntersectionMember1( - global::ImageKit.Models.Webhooks.IntersectionMember1 intersectionMember1 + global::Imagekit.Models.Webhooks.IntersectionMember1 intersectionMember1 ) : base(intersectionMember1) { } #pragma warning restore CS8618 @@ -204,8 +204,8 @@ public IntersectionMember1(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::ImageKit.Models.Webhooks.IntersectionMember1 FromRawUnchecked( + /// + public static global::Imagekit.Models.Webhooks.IntersectionMember1 FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -214,10 +214,10 @@ IReadOnlyDictionary rawData } class IntersectionMember1FromRaw - : IFromRawJson + : IFromRawJson { /// - public global::ImageKit.Models.Webhooks.IntersectionMember1 FromRawUnchecked( + public global::Imagekit.Models.Webhooks.IntersectionMember1 FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::ImageKit.Models.Webhooks.IntersectionMember1.FromRawUnchecked(rawData); + ) => global::Imagekit.Models.Webhooks.IntersectionMember1.FromRawUnchecked(rawData); } diff --git a/src/ImageKit/Models/Webhooks/FileDeleteEvent.cs b/src/Imagekit/Models/Webhooks/FileDeleteEvent.cs similarity index 95% rename from src/ImageKit/Models/Webhooks/FileDeleteEvent.cs rename to src/Imagekit/Models/Webhooks/FileDeleteEvent.cs index 625fbd82..e26a6890 100644 --- a/src/ImageKit/Models/Webhooks/FileDeleteEvent.cs +++ b/src/Imagekit/Models/Webhooks/FileDeleteEvent.cs @@ -4,10 +4,10 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; -using ImageKit.Exceptions; +using Imagekit.Core; +using Imagekit.Exceptions; -namespace ImageKit.Models.Webhooks; +namespace Imagekit.Models.Webhooks; /// /// Triggered when a file is deleted. diff --git a/src/ImageKit/Models/Webhooks/FileUpdateEvent.cs b/src/Imagekit/Models/Webhooks/FileUpdateEvent.cs similarity index 94% rename from src/ImageKit/Models/Webhooks/FileUpdateEvent.cs rename to src/Imagekit/Models/Webhooks/FileUpdateEvent.cs index 20691c46..2e6f58dd 100644 --- a/src/ImageKit/Models/Webhooks/FileUpdateEvent.cs +++ b/src/Imagekit/Models/Webhooks/FileUpdateEvent.cs @@ -4,11 +4,11 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; -using ImageKit.Exceptions; -using ImageKit.Models.Files; +using Imagekit.Core; +using Imagekit.Exceptions; +using Imagekit.Models.Files; -namespace ImageKit.Models.Webhooks; +namespace Imagekit.Models.Webhooks; /// /// Triggered when a file is updated. diff --git a/src/ImageKit/Models/Webhooks/FileVersionCreateEvent.cs b/src/Imagekit/Models/Webhooks/FileVersionCreateEvent.cs similarity index 94% rename from src/ImageKit/Models/Webhooks/FileVersionCreateEvent.cs rename to src/Imagekit/Models/Webhooks/FileVersionCreateEvent.cs index 4b935d9e..b8ad5f76 100644 --- a/src/ImageKit/Models/Webhooks/FileVersionCreateEvent.cs +++ b/src/Imagekit/Models/Webhooks/FileVersionCreateEvent.cs @@ -4,11 +4,11 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; -using ImageKit.Exceptions; -using ImageKit.Models.Files; +using Imagekit.Core; +using Imagekit.Exceptions; +using Imagekit.Models.Files; -namespace ImageKit.Models.Webhooks; +namespace Imagekit.Models.Webhooks; /// /// Triggered when a file version is created. diff --git a/src/ImageKit/Models/Webhooks/FileVersionDeleteEvent.cs b/src/Imagekit/Models/Webhooks/FileVersionDeleteEvent.cs similarity index 95% rename from src/ImageKit/Models/Webhooks/FileVersionDeleteEvent.cs rename to src/Imagekit/Models/Webhooks/FileVersionDeleteEvent.cs index 0eca65b3..e100bb75 100644 --- a/src/ImageKit/Models/Webhooks/FileVersionDeleteEvent.cs +++ b/src/Imagekit/Models/Webhooks/FileVersionDeleteEvent.cs @@ -4,10 +4,10 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; -using ImageKit.Exceptions; +using Imagekit.Core; +using Imagekit.Exceptions; -namespace ImageKit.Models.Webhooks; +namespace Imagekit.Models.Webhooks; /// /// Triggered when a file version is deleted. diff --git a/src/ImageKit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs b/src/Imagekit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs similarity index 97% rename from src/ImageKit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs rename to src/Imagekit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs index 856ebd1f..3f4c49b9 100644 --- a/src/ImageKit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs +++ b/src/Imagekit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs @@ -1,11 +1,11 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; -using ImageKit.Exceptions; +using Imagekit.Core; +using Imagekit.Exceptions; using System = System; -namespace ImageKit.Models.Webhooks; +namespace Imagekit.Models.Webhooks; /// /// Triggered when a new video transformation request is accepted for processing. diff --git a/src/ImageKit/Models/Webhooks/UnwrapWebhookEvent.cs b/src/Imagekit/Models/Webhooks/UnwrapWebhookEvent.cs similarity index 97% rename from src/ImageKit/Models/Webhooks/UnwrapWebhookEvent.cs rename to src/Imagekit/Models/Webhooks/UnwrapWebhookEvent.cs index d33477ad..d39b6671 100644 --- a/src/ImageKit/Models/Webhooks/UnwrapWebhookEvent.cs +++ b/src/Imagekit/Models/Webhooks/UnwrapWebhookEvent.cs @@ -1,11 +1,11 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; -using ImageKit.Exceptions; +using Imagekit.Core; +using Imagekit.Exceptions; using System = System; -namespace ImageKit.Models.Webhooks; +namespace Imagekit.Models.Webhooks; /// /// Triggered when a new video transformation request is accepted for processing. diff --git a/src/ImageKit/Models/Webhooks/UploadPostTransformErrorEvent.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEvent.cs similarity index 92% rename from src/ImageKit/Models/Webhooks/UploadPostTransformErrorEvent.cs rename to src/Imagekit/Models/Webhooks/UploadPostTransformErrorEvent.cs index ffa377f3..23b996e6 100644 --- a/src/ImageKit/Models/Webhooks/UploadPostTransformErrorEvent.cs +++ b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEvent.cs @@ -3,11 +3,11 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; -using ImageKit.Exceptions; +using Imagekit.Core; +using Imagekit.Exceptions; using System = System; -namespace ImageKit.Models.Webhooks; +namespace Imagekit.Models.Webhooks; /// /// Triggered when a post-transformation fails. The original file remains available, @@ -579,13 +579,13 @@ public sealed record class RequestTransformation : JsonModel /// /// Type of the requested post-transformation. /// - public required ApiEnum Type + public required ApiEnum Type { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("type"); } init { this._rawData.Set("type", value); } @@ -671,7 +671,7 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public RequestTransformation(ApiEnum type) + public RequestTransformation(ApiEnum type) : this() { this.Type = type; @@ -698,9 +698,9 @@ public enum Type Thumbnail, } -sealed class TypeConverter : JsonConverter +sealed class TypeConverter : JsonConverter { - public override global::ImageKit.Models.Webhooks.Type Read( + public override global::Imagekit.Models.Webhooks.Type Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -708,17 +708,17 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "transformation" => global::ImageKit.Models.Webhooks.Type.Transformation, - "abs" => global::ImageKit.Models.Webhooks.Type.Abs, - "gif-to-video" => global::ImageKit.Models.Webhooks.Type.GifToVideo, - "thumbnail" => global::ImageKit.Models.Webhooks.Type.Thumbnail, - _ => (global::ImageKit.Models.Webhooks.Type)(-1), + "transformation" => global::Imagekit.Models.Webhooks.Type.Transformation, + "abs" => global::Imagekit.Models.Webhooks.Type.Abs, + "gif-to-video" => global::Imagekit.Models.Webhooks.Type.GifToVideo, + "thumbnail" => global::Imagekit.Models.Webhooks.Type.Thumbnail, + _ => (global::Imagekit.Models.Webhooks.Type)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::ImageKit.Models.Webhooks.Type value, + global::Imagekit.Models.Webhooks.Type value, JsonSerializerOptions options ) { @@ -726,10 +726,10 @@ JsonSerializerOptions options writer, value switch { - global::ImageKit.Models.Webhooks.Type.Transformation => "transformation", - global::ImageKit.Models.Webhooks.Type.Abs => "abs", - global::ImageKit.Models.Webhooks.Type.GifToVideo => "gif-to-video", - global::ImageKit.Models.Webhooks.Type.Thumbnail => "thumbnail", + global::Imagekit.Models.Webhooks.Type.Transformation => "transformation", + global::Imagekit.Models.Webhooks.Type.Abs => "abs", + global::Imagekit.Models.Webhooks.Type.GifToVideo => "gif-to-video", + global::Imagekit.Models.Webhooks.Type.Thumbnail => "thumbnail", _ => throw new ImageKitInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/ImageKit/Models/Webhooks/UploadPostTransformSuccessEvent.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEvent.cs similarity index 96% rename from src/ImageKit/Models/Webhooks/UploadPostTransformSuccessEvent.cs rename to src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEvent.cs index fa66a659..faaa4acc 100644 --- a/src/ImageKit/Models/Webhooks/UploadPostTransformSuccessEvent.cs +++ b/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEvent.cs @@ -3,11 +3,11 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; -using ImageKit.Exceptions; +using Imagekit.Core; +using Imagekit.Exceptions; using System = System; -namespace ImageKit.Models.Webhooks; +namespace Imagekit.Models.Webhooks; /// /// Triggered when a post-transformation completes successfully. The transformed diff --git a/src/ImageKit/Models/Webhooks/UploadPreTransformErrorEvent.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEvent.cs similarity index 96% rename from src/ImageKit/Models/Webhooks/UploadPreTransformErrorEvent.cs rename to src/Imagekit/Models/Webhooks/UploadPreTransformErrorEvent.cs index f6a98a39..005f41b9 100644 --- a/src/ImageKit/Models/Webhooks/UploadPreTransformErrorEvent.cs +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEvent.cs @@ -4,10 +4,10 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; -using ImageKit.Exceptions; +using Imagekit.Core; +using Imagekit.Exceptions; -namespace ImageKit.Models.Webhooks; +namespace Imagekit.Models.Webhooks; /// /// Triggered when a pre-transformation fails. The file upload may have been accepted, diff --git a/src/ImageKit/Models/Webhooks/UploadPreTransformSuccessEvent.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEvent.cs similarity index 96% rename from src/ImageKit/Models/Webhooks/UploadPreTransformSuccessEvent.cs rename to src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEvent.cs index 25490531..ac9b721a 100644 --- a/src/ImageKit/Models/Webhooks/UploadPreTransformSuccessEvent.cs +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEvent.cs @@ -4,12 +4,12 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; -using ImageKit.Exceptions; -using Files = ImageKit.Models.Files; +using Imagekit.Core; +using Imagekit.Exceptions; +using Files = Imagekit.Models.Files; using System = System; -namespace ImageKit.Models.Webhooks; +namespace Imagekit.Models.Webhooks; /// /// Triggered when a pre-transformation completes successfully. The file has been diff --git a/src/ImageKit/Models/Webhooks/VideoTransformationAcceptedEvent.cs b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEvent.cs similarity index 96% rename from src/ImageKit/Models/Webhooks/VideoTransformationAcceptedEvent.cs rename to src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEvent.cs index d7df40bb..35ad026b 100644 --- a/src/ImageKit/Models/Webhooks/VideoTransformationAcceptedEvent.cs +++ b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEvent.cs @@ -4,11 +4,11 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; -using ImageKit.Exceptions; +using Imagekit.Core; +using Imagekit.Exceptions; using System = System; -namespace ImageKit.Models.Webhooks; +namespace Imagekit.Models.Webhooks; /// /// Triggered when a new video transformation request is accepted for processing. diff --git a/src/ImageKit/Models/Webhooks/VideoTransformationErrorEvent.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEvent.cs similarity index 96% rename from src/ImageKit/Models/Webhooks/VideoTransformationErrorEvent.cs rename to src/Imagekit/Models/Webhooks/VideoTransformationErrorEvent.cs index 5fb9a991..df2dbb7e 100644 --- a/src/ImageKit/Models/Webhooks/VideoTransformationErrorEvent.cs +++ b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEvent.cs @@ -4,11 +4,11 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; -using ImageKit.Exceptions; +using Imagekit.Core; +using Imagekit.Exceptions; using System = System; -namespace ImageKit.Models.Webhooks; +namespace Imagekit.Models.Webhooks; /// /// Triggered when an error occurs during video encoding. Listen to this webhook diff --git a/src/ImageKit/Models/Webhooks/VideoTransformationReadyEvent.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEvent.cs similarity index 96% rename from src/ImageKit/Models/Webhooks/VideoTransformationReadyEvent.cs rename to src/Imagekit/Models/Webhooks/VideoTransformationReadyEvent.cs index 4196f204..2518e463 100644 --- a/src/ImageKit/Models/Webhooks/VideoTransformationReadyEvent.cs +++ b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEvent.cs @@ -4,11 +4,11 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; -using ImageKit.Core; -using ImageKit.Exceptions; +using Imagekit.Core; +using Imagekit.Exceptions; using System = System; -namespace ImageKit.Models.Webhooks; +namespace Imagekit.Models.Webhooks; /// /// Triggered when video encoding is finished and the transformed resource is ready diff --git a/src/ImageKit/Services/AccountService.cs b/src/Imagekit/Services/AccountService.cs similarity index 93% rename from src/ImageKit/Services/AccountService.cs rename to src/Imagekit/Services/AccountService.cs index 0e7a99b0..cc3702ac 100644 --- a/src/ImageKit/Services/AccountService.cs +++ b/src/Imagekit/Services/AccountService.cs @@ -1,8 +1,8 @@ using System; -using ImageKit.Core; -using ImageKit.Services.Accounts; +using Imagekit.Core; +using Imagekit.Services.Accounts; -namespace ImageKit.Services; +namespace Imagekit.Services; /// public sealed class AccountService : IAccountService diff --git a/src/ImageKit/Services/Accounts/IOriginService.cs b/src/Imagekit/Services/Accounts/IOriginService.cs similarity index 95% rename from src/ImageKit/Services/Accounts/IOriginService.cs rename to src/Imagekit/Services/Accounts/IOriginService.cs index 50e50fd8..0e1a156e 100644 --- a/src/ImageKit/Services/Accounts/IOriginService.cs +++ b/src/Imagekit/Services/Accounts/IOriginService.cs @@ -2,10 +2,10 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using ImageKit.Core; -using ImageKit.Models.Accounts.Origins; +using Imagekit.Core; +using Imagekit.Models.Accounts.Origins; -namespace ImageKit.Services.Accounts; +namespace Imagekit.Services.Accounts; /// /// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking diff --git a/src/ImageKit/Services/Accounts/IUrlEndpointService.cs b/src/Imagekit/Services/Accounts/IUrlEndpointService.cs similarity index 95% rename from src/ImageKit/Services/Accounts/IUrlEndpointService.cs rename to src/Imagekit/Services/Accounts/IUrlEndpointService.cs index 4036ed48..f18fdb2e 100644 --- a/src/ImageKit/Services/Accounts/IUrlEndpointService.cs +++ b/src/Imagekit/Services/Accounts/IUrlEndpointService.cs @@ -2,10 +2,10 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using ImageKit.Core; -using ImageKit.Models.Accounts.UrlEndpoints; +using Imagekit.Core; +using Imagekit.Models.Accounts.UrlEndpoints; -namespace ImageKit.Services.Accounts; +namespace Imagekit.Services.Accounts; /// /// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking diff --git a/src/ImageKit/Services/Accounts/IUsageService.cs b/src/Imagekit/Services/Accounts/IUsageService.cs similarity index 92% rename from src/ImageKit/Services/Accounts/IUsageService.cs rename to src/Imagekit/Services/Accounts/IUsageService.cs index 4b330f69..8cdd7ea1 100644 --- a/src/ImageKit/Services/Accounts/IUsageService.cs +++ b/src/Imagekit/Services/Accounts/IUsageService.cs @@ -1,10 +1,10 @@ using System; using System.Threading; using System.Threading.Tasks; -using ImageKit.Core; -using ImageKit.Models.Accounts.Usage; +using Imagekit.Core; +using Imagekit.Models.Accounts.Usage; -namespace ImageKit.Services.Accounts; +namespace Imagekit.Services.Accounts; /// /// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking diff --git a/src/ImageKit/Services/Accounts/OriginService.cs b/src/Imagekit/Services/Accounts/OriginService.cs similarity index 95% rename from src/ImageKit/Services/Accounts/OriginService.cs rename to src/Imagekit/Services/Accounts/OriginService.cs index abb0fcd5..7fa88caa 100644 --- a/src/ImageKit/Services/Accounts/OriginService.cs +++ b/src/Imagekit/Services/Accounts/OriginService.cs @@ -3,11 +3,11 @@ using System.Net.Http; using System.Threading; using System.Threading.Tasks; -using ImageKit.Core; -using ImageKit.Exceptions; -using ImageKit.Models.Accounts.Origins; +using Imagekit.Core; +using Imagekit.Exceptions; +using Imagekit.Models.Accounts.Origins; -namespace ImageKit.Services.Accounts; +namespace Imagekit.Services.Accounts; /// public sealed class OriginService : IOriginService diff --git a/src/ImageKit/Services/Accounts/UrlEndpointService.cs b/src/Imagekit/Services/Accounts/UrlEndpointService.cs similarity index 95% rename from src/ImageKit/Services/Accounts/UrlEndpointService.cs rename to src/Imagekit/Services/Accounts/UrlEndpointService.cs index a80a3bec..eac81713 100644 --- a/src/ImageKit/Services/Accounts/UrlEndpointService.cs +++ b/src/Imagekit/Services/Accounts/UrlEndpointService.cs @@ -3,11 +3,11 @@ using System.Net.Http; using System.Threading; using System.Threading.Tasks; -using ImageKit.Core; -using ImageKit.Exceptions; -using ImageKit.Models.Accounts.UrlEndpoints; +using Imagekit.Core; +using Imagekit.Exceptions; +using Imagekit.Models.Accounts.UrlEndpoints; -namespace ImageKit.Services.Accounts; +namespace Imagekit.Services.Accounts; /// public sealed class UrlEndpointService : IUrlEndpointService diff --git a/src/ImageKit/Services/Accounts/UsageService.cs b/src/Imagekit/Services/Accounts/UsageService.cs similarity index 92% rename from src/ImageKit/Services/Accounts/UsageService.cs rename to src/Imagekit/Services/Accounts/UsageService.cs index 8fbec9c4..1f996022 100644 --- a/src/ImageKit/Services/Accounts/UsageService.cs +++ b/src/Imagekit/Services/Accounts/UsageService.cs @@ -2,10 +2,10 @@ using System.Net.Http; using System.Threading; using System.Threading.Tasks; -using ImageKit.Core; -using ImageKit.Models.Accounts.Usage; +using Imagekit.Core; +using Imagekit.Models.Accounts.Usage; -namespace ImageKit.Services.Accounts; +namespace Imagekit.Services.Accounts; /// public sealed class UsageService : IUsageService diff --git a/src/ImageKit/Services/AssetService.cs b/src/Imagekit/Services/AssetService.cs similarity index 93% rename from src/ImageKit/Services/AssetService.cs rename to src/Imagekit/Services/AssetService.cs index 870e8bd5..bc4c31f8 100644 --- a/src/ImageKit/Services/AssetService.cs +++ b/src/Imagekit/Services/AssetService.cs @@ -3,10 +3,10 @@ using System.Net.Http; using System.Threading; using System.Threading.Tasks; -using ImageKit.Core; -using ImageKit.Models.Assets; +using Imagekit.Core; +using Imagekit.Models.Assets; -namespace ImageKit.Services; +namespace Imagekit.Services; /// public sealed class AssetService : IAssetService diff --git a/src/ImageKit/Services/Beta/IV2Service.cs b/src/Imagekit/Services/Beta/IV2Service.cs similarity index 90% rename from src/ImageKit/Services/Beta/IV2Service.cs rename to src/Imagekit/Services/Beta/IV2Service.cs index cf83670d..5dae1527 100644 --- a/src/ImageKit/Services/Beta/IV2Service.cs +++ b/src/Imagekit/Services/Beta/IV2Service.cs @@ -1,8 +1,8 @@ using System; -using ImageKit.Core; -using V2 = ImageKit.Services.Beta.V2; +using Imagekit.Core; +using V2 = Imagekit.Services.Beta.V2; -namespace ImageKit.Services.Beta; +namespace Imagekit.Services.Beta; /// /// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking diff --git a/src/ImageKit/Services/Beta/V2/FileService.cs b/src/Imagekit/Services/Beta/V2/FileService.cs similarity index 93% rename from src/ImageKit/Services/Beta/V2/FileService.cs rename to src/Imagekit/Services/Beta/V2/FileService.cs index ccbe0a04..a683e530 100644 --- a/src/ImageKit/Services/Beta/V2/FileService.cs +++ b/src/Imagekit/Services/Beta/V2/FileService.cs @@ -2,10 +2,10 @@ using System.Net.Http; using System.Threading; using System.Threading.Tasks; -using ImageKit.Core; -using ImageKit.Models.Beta.V2.Files; +using Imagekit.Core; +using Imagekit.Models.Beta.V2.Files; -namespace ImageKit.Services.Beta.V2; +namespace Imagekit.Services.Beta.V2; /// public sealed class FileService : IFileService diff --git a/src/ImageKit/Services/Beta/V2/IFileService.cs b/src/Imagekit/Services/Beta/V2/IFileService.cs similarity index 94% rename from src/ImageKit/Services/Beta/V2/IFileService.cs rename to src/Imagekit/Services/Beta/V2/IFileService.cs index c87e0ddb..07d40cce 100644 --- a/src/ImageKit/Services/Beta/V2/IFileService.cs +++ b/src/Imagekit/Services/Beta/V2/IFileService.cs @@ -1,10 +1,10 @@ using System; using System.Threading; using System.Threading.Tasks; -using ImageKit.Core; -using ImageKit.Models.Beta.V2.Files; +using Imagekit.Core; +using Imagekit.Models.Beta.V2.Files; -namespace ImageKit.Services.Beta.V2; +namespace Imagekit.Services.Beta.V2; /// /// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking diff --git a/src/ImageKit/Services/Beta/V2Service.cs b/src/Imagekit/Services/Beta/V2Service.cs similarity index 90% rename from src/ImageKit/Services/Beta/V2Service.cs rename to src/Imagekit/Services/Beta/V2Service.cs index 7e9ad558..ae59d124 100644 --- a/src/ImageKit/Services/Beta/V2Service.cs +++ b/src/Imagekit/Services/Beta/V2Service.cs @@ -1,8 +1,8 @@ using System; -using ImageKit.Core; -using V2 = ImageKit.Services.Beta.V2; +using Imagekit.Core; +using V2 = Imagekit.Services.Beta.V2; -namespace ImageKit.Services.Beta; +namespace Imagekit.Services.Beta; /// public sealed class V2Service : IV2Service diff --git a/src/ImageKit/Services/BetaService.cs b/src/Imagekit/Services/BetaService.cs similarity index 91% rename from src/ImageKit/Services/BetaService.cs rename to src/Imagekit/Services/BetaService.cs index 0221246f..fe5ee4dc 100644 --- a/src/ImageKit/Services/BetaService.cs +++ b/src/Imagekit/Services/BetaService.cs @@ -1,8 +1,8 @@ using System; -using ImageKit.Core; -using ImageKit.Services.Beta; +using Imagekit.Core; +using Imagekit.Services.Beta; -namespace ImageKit.Services; +namespace Imagekit.Services; /// public sealed class BetaService : IBetaService diff --git a/src/ImageKit/Services/Cache/IInvalidationService.cs b/src/Imagekit/Services/Cache/IInvalidationService.cs similarity index 94% rename from src/ImageKit/Services/Cache/IInvalidationService.cs rename to src/Imagekit/Services/Cache/IInvalidationService.cs index edff0d9b..7bfc13d1 100644 --- a/src/ImageKit/Services/Cache/IInvalidationService.cs +++ b/src/Imagekit/Services/Cache/IInvalidationService.cs @@ -1,10 +1,10 @@ using System; using System.Threading; using System.Threading.Tasks; -using ImageKit.Core; -using ImageKit.Models.Cache.Invalidation; +using Imagekit.Core; +using Imagekit.Models.Cache.Invalidation; -namespace ImageKit.Services.Cache; +namespace Imagekit.Services.Cache; /// /// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking diff --git a/src/ImageKit/Services/Cache/InvalidationService.cs b/src/Imagekit/Services/Cache/InvalidationService.cs similarity index 94% rename from src/ImageKit/Services/Cache/InvalidationService.cs rename to src/Imagekit/Services/Cache/InvalidationService.cs index 592264a0..13ecbe85 100644 --- a/src/ImageKit/Services/Cache/InvalidationService.cs +++ b/src/Imagekit/Services/Cache/InvalidationService.cs @@ -2,11 +2,11 @@ using System.Net.Http; using System.Threading; using System.Threading.Tasks; -using ImageKit.Core; -using ImageKit.Exceptions; -using ImageKit.Models.Cache.Invalidation; +using Imagekit.Core; +using Imagekit.Exceptions; +using Imagekit.Models.Cache.Invalidation; -namespace ImageKit.Services.Cache; +namespace Imagekit.Services.Cache; /// public sealed class InvalidationService : IInvalidationService diff --git a/src/ImageKit/Services/CacheService.cs b/src/Imagekit/Services/CacheService.cs similarity index 92% rename from src/ImageKit/Services/CacheService.cs rename to src/Imagekit/Services/CacheService.cs index 84cf1d48..d66caaeb 100644 --- a/src/ImageKit/Services/CacheService.cs +++ b/src/Imagekit/Services/CacheService.cs @@ -1,8 +1,8 @@ using System; -using ImageKit.Core; -using ImageKit.Services.Cache; +using Imagekit.Core; +using Imagekit.Services.Cache; -namespace ImageKit.Services; +namespace Imagekit.Services; /// public sealed class CacheService : ICacheService diff --git a/src/ImageKit/Services/CustomMetadataFieldService.cs b/src/Imagekit/Services/CustomMetadataFieldService.cs similarity index 95% rename from src/ImageKit/Services/CustomMetadataFieldService.cs rename to src/Imagekit/Services/CustomMetadataFieldService.cs index 035bc598..b469196c 100644 --- a/src/ImageKit/Services/CustomMetadataFieldService.cs +++ b/src/Imagekit/Services/CustomMetadataFieldService.cs @@ -3,11 +3,11 @@ using System.Net.Http; using System.Threading; using System.Threading.Tasks; -using ImageKit.Core; -using ImageKit.Exceptions; -using ImageKit.Models.CustomMetadataFields; +using Imagekit.Core; +using Imagekit.Exceptions; +using Imagekit.Models.CustomMetadataFields; -namespace ImageKit.Services; +namespace Imagekit.Services; /// public sealed class CustomMetadataFieldService : ICustomMetadataFieldService diff --git a/src/ImageKit/Services/FileService.cs b/src/Imagekit/Services/FileService.cs similarity index 95% rename from src/ImageKit/Services/FileService.cs rename to src/Imagekit/Services/FileService.cs index a06231d4..e90eac93 100644 --- a/src/ImageKit/Services/FileService.cs +++ b/src/Imagekit/Services/FileService.cs @@ -2,12 +2,12 @@ using System.Net.Http; using System.Threading; using System.Threading.Tasks; -using ImageKit.Core; -using ImageKit.Exceptions; -using ImageKit.Models.Files; -using ImageKit.Services.Files; +using Imagekit.Core; +using Imagekit.Exceptions; +using Imagekit.Models.Files; +using Imagekit.Services.Files; -namespace ImageKit.Services; +namespace Imagekit.Services; /// public sealed class FileService : IFileService diff --git a/src/ImageKit/Services/Files/BulkService.cs b/src/Imagekit/Services/Files/BulkService.cs similarity index 95% rename from src/ImageKit/Services/Files/BulkService.cs rename to src/Imagekit/Services/Files/BulkService.cs index ef0d821e..288b2837 100644 --- a/src/ImageKit/Services/Files/BulkService.cs +++ b/src/Imagekit/Services/Files/BulkService.cs @@ -2,10 +2,10 @@ using System.Net.Http; using System.Threading; using System.Threading.Tasks; -using ImageKit.Core; -using ImageKit.Models.Files.Bulk; +using Imagekit.Core; +using Imagekit.Models.Files.Bulk; -namespace ImageKit.Services.Files; +namespace Imagekit.Services.Files; /// public sealed class BulkService : IBulkService diff --git a/src/ImageKit/Services/Files/IBulkService.cs b/src/Imagekit/Services/Files/IBulkService.cs similarity index 95% rename from src/ImageKit/Services/Files/IBulkService.cs rename to src/Imagekit/Services/Files/IBulkService.cs index eeb5cc83..83efe968 100644 --- a/src/ImageKit/Services/Files/IBulkService.cs +++ b/src/Imagekit/Services/Files/IBulkService.cs @@ -1,10 +1,10 @@ using System; using System.Threading; using System.Threading.Tasks; -using ImageKit.Core; -using ImageKit.Models.Files.Bulk; +using Imagekit.Core; +using Imagekit.Models.Files.Bulk; -namespace ImageKit.Services.Files; +namespace Imagekit.Services.Files; /// /// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking diff --git a/src/ImageKit/Services/Files/IMetadataService.cs b/src/Imagekit/Services/Files/IMetadataService.cs similarity index 93% rename from src/ImageKit/Services/Files/IMetadataService.cs rename to src/Imagekit/Services/Files/IMetadataService.cs index 9c88707c..3288448b 100644 --- a/src/ImageKit/Services/Files/IMetadataService.cs +++ b/src/Imagekit/Services/Files/IMetadataService.cs @@ -1,11 +1,11 @@ using System; using System.Threading; using System.Threading.Tasks; -using ImageKit.Core; -using ImageKit.Models.Files; -using ImageKit.Models.Files.Metadata; +using Imagekit.Core; +using Imagekit.Models.Files; +using Imagekit.Models.Files.Metadata; -namespace ImageKit.Services.Files; +namespace Imagekit.Services.Files; /// /// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking diff --git a/src/ImageKit/Services/Files/IVersionService.cs b/src/Imagekit/Services/Files/IVersionService.cs similarity index 95% rename from src/ImageKit/Services/Files/IVersionService.cs rename to src/Imagekit/Services/Files/IVersionService.cs index e8879cc6..f396d9f9 100644 --- a/src/ImageKit/Services/Files/IVersionService.cs +++ b/src/Imagekit/Services/Files/IVersionService.cs @@ -2,11 +2,11 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using ImageKit.Core; -using ImageKit.Models.Files; -using ImageKit.Models.Files.Versions; +using Imagekit.Core; +using Imagekit.Models.Files; +using Imagekit.Models.Files.Versions; -namespace ImageKit.Services.Files; +namespace Imagekit.Services.Files; /// /// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking diff --git a/src/ImageKit/Services/Files/MetadataService.cs b/src/Imagekit/Services/Files/MetadataService.cs similarity index 93% rename from src/ImageKit/Services/Files/MetadataService.cs rename to src/Imagekit/Services/Files/MetadataService.cs index bcae4d76..a0a7ffc2 100644 --- a/src/ImageKit/Services/Files/MetadataService.cs +++ b/src/Imagekit/Services/Files/MetadataService.cs @@ -2,12 +2,12 @@ using System.Net.Http; using System.Threading; using System.Threading.Tasks; -using ImageKit.Core; -using ImageKit.Exceptions; -using ImageKit.Models.Files; -using ImageKit.Models.Files.Metadata; +using Imagekit.Core; +using Imagekit.Exceptions; +using Imagekit.Models.Files; +using Imagekit.Models.Files.Metadata; -namespace ImageKit.Services.Files; +namespace Imagekit.Services.Files; /// public sealed class MetadataService : IMetadataService diff --git a/src/ImageKit/Services/Files/VersionService.cs b/src/Imagekit/Services/Files/VersionService.cs similarity index 95% rename from src/ImageKit/Services/Files/VersionService.cs rename to src/Imagekit/Services/Files/VersionService.cs index 5d4e68cd..7c7868ad 100644 --- a/src/ImageKit/Services/Files/VersionService.cs +++ b/src/Imagekit/Services/Files/VersionService.cs @@ -3,12 +3,12 @@ using System.Net.Http; using System.Threading; using System.Threading.Tasks; -using ImageKit.Core; -using ImageKit.Exceptions; -using ImageKit.Models.Files; -using ImageKit.Models.Files.Versions; +using Imagekit.Core; +using Imagekit.Exceptions; +using Imagekit.Models.Files; +using Imagekit.Models.Files.Versions; -namespace ImageKit.Services.Files; +namespace Imagekit.Services.Files; /// public sealed class VersionService : IVersionService diff --git a/src/ImageKit/Services/FolderService.cs b/src/Imagekit/Services/FolderService.cs similarity index 95% rename from src/ImageKit/Services/FolderService.cs rename to src/Imagekit/Services/FolderService.cs index 2c35a6e0..85b23d89 100644 --- a/src/ImageKit/Services/FolderService.cs +++ b/src/Imagekit/Services/FolderService.cs @@ -2,11 +2,11 @@ using System.Net.Http; using System.Threading; using System.Threading.Tasks; -using ImageKit.Core; -using ImageKit.Models.Folders; -using ImageKit.Services.Folders; +using Imagekit.Core; +using Imagekit.Models.Folders; +using Imagekit.Services.Folders; -namespace ImageKit.Services; +namespace Imagekit.Services; /// public sealed class FolderService : IFolderService diff --git a/src/ImageKit/Services/Folders/IJobService.cs b/src/Imagekit/Services/Folders/IJobService.cs similarity index 93% rename from src/ImageKit/Services/Folders/IJobService.cs rename to src/Imagekit/Services/Folders/IJobService.cs index 767564e3..7c2a7f75 100644 --- a/src/ImageKit/Services/Folders/IJobService.cs +++ b/src/Imagekit/Services/Folders/IJobService.cs @@ -1,10 +1,10 @@ using System; using System.Threading; using System.Threading.Tasks; -using ImageKit.Core; -using ImageKit.Models.Folders.Job; +using Imagekit.Core; +using Imagekit.Models.Folders.Job; -namespace ImageKit.Services.Folders; +namespace Imagekit.Services.Folders; /// /// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking diff --git a/src/ImageKit/Services/Folders/JobService.cs b/src/Imagekit/Services/Folders/JobService.cs similarity index 93% rename from src/ImageKit/Services/Folders/JobService.cs rename to src/Imagekit/Services/Folders/JobService.cs index 65aa1ec8..0ea7f61d 100644 --- a/src/ImageKit/Services/Folders/JobService.cs +++ b/src/Imagekit/Services/Folders/JobService.cs @@ -2,11 +2,11 @@ using System.Net.Http; using System.Threading; using System.Threading.Tasks; -using ImageKit.Core; -using ImageKit.Exceptions; -using ImageKit.Models.Folders.Job; +using Imagekit.Core; +using Imagekit.Exceptions; +using Imagekit.Models.Folders.Job; -namespace ImageKit.Services.Folders; +namespace Imagekit.Services.Folders; /// public sealed class JobService : IJobService diff --git a/src/ImageKit/Services/IAccountService.cs b/src/Imagekit/Services/IAccountService.cs similarity index 91% rename from src/ImageKit/Services/IAccountService.cs rename to src/Imagekit/Services/IAccountService.cs index 6925313c..9eaf50b2 100644 --- a/src/ImageKit/Services/IAccountService.cs +++ b/src/Imagekit/Services/IAccountService.cs @@ -1,8 +1,8 @@ using System; -using ImageKit.Core; -using ImageKit.Services.Accounts; +using Imagekit.Core; +using Imagekit.Services.Accounts; -namespace ImageKit.Services; +namespace Imagekit.Services; /// /// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking diff --git a/src/ImageKit/Services/IAssetService.cs b/src/Imagekit/Services/IAssetService.cs similarity index 93% rename from src/ImageKit/Services/IAssetService.cs rename to src/Imagekit/Services/IAssetService.cs index 930997b8..b58d0e48 100644 --- a/src/ImageKit/Services/IAssetService.cs +++ b/src/Imagekit/Services/IAssetService.cs @@ -2,10 +2,10 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using ImageKit.Core; -using ImageKit.Models.Assets; +using Imagekit.Core; +using Imagekit.Models.Assets; -namespace ImageKit.Services; +namespace Imagekit.Services; /// /// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking diff --git a/src/ImageKit/Services/IBetaService.cs b/src/Imagekit/Services/IBetaService.cs similarity index 91% rename from src/ImageKit/Services/IBetaService.cs rename to src/Imagekit/Services/IBetaService.cs index 81258ad6..dafe3f60 100644 --- a/src/ImageKit/Services/IBetaService.cs +++ b/src/Imagekit/Services/IBetaService.cs @@ -1,8 +1,8 @@ using System; -using ImageKit.Core; -using ImageKit.Services.Beta; +using Imagekit.Core; +using Imagekit.Services.Beta; -namespace ImageKit.Services; +namespace Imagekit.Services; /// /// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking diff --git a/src/ImageKit/Services/ICacheService.cs b/src/Imagekit/Services/ICacheService.cs similarity index 91% rename from src/ImageKit/Services/ICacheService.cs rename to src/Imagekit/Services/ICacheService.cs index 8834db75..e6f3b2dc 100644 --- a/src/ImageKit/Services/ICacheService.cs +++ b/src/Imagekit/Services/ICacheService.cs @@ -1,8 +1,8 @@ using System; -using ImageKit.Core; -using ImageKit.Services.Cache; +using Imagekit.Core; +using Imagekit.Services.Cache; -namespace ImageKit.Services; +namespace Imagekit.Services; /// /// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking diff --git a/src/ImageKit/Services/ICustomMetadataFieldService.cs b/src/Imagekit/Services/ICustomMetadataFieldService.cs similarity index 96% rename from src/ImageKit/Services/ICustomMetadataFieldService.cs rename to src/Imagekit/Services/ICustomMetadataFieldService.cs index 8e23395a..af822b15 100644 --- a/src/ImageKit/Services/ICustomMetadataFieldService.cs +++ b/src/Imagekit/Services/ICustomMetadataFieldService.cs @@ -2,10 +2,10 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using ImageKit.Core; -using ImageKit.Models.CustomMetadataFields; +using Imagekit.Core; +using Imagekit.Models.CustomMetadataFields; -namespace ImageKit.Services; +namespace Imagekit.Services; /// /// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking diff --git a/src/ImageKit/Services/IFileService.cs b/src/Imagekit/Services/IFileService.cs similarity index 96% rename from src/ImageKit/Services/IFileService.cs rename to src/Imagekit/Services/IFileService.cs index 50ced006..3b26433b 100644 --- a/src/ImageKit/Services/IFileService.cs +++ b/src/Imagekit/Services/IFileService.cs @@ -1,11 +1,11 @@ using System; using System.Threading; using System.Threading.Tasks; -using ImageKit.Core; -using ImageKit.Models.Files; -using ImageKit.Services.Files; +using Imagekit.Core; +using Imagekit.Models.Files; +using Imagekit.Services.Files; -namespace ImageKit.Services; +namespace Imagekit.Services; /// /// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking diff --git a/src/ImageKit/Services/IFolderService.cs b/src/Imagekit/Services/IFolderService.cs similarity index 95% rename from src/ImageKit/Services/IFolderService.cs rename to src/Imagekit/Services/IFolderService.cs index 947be4e2..ce3708d0 100644 --- a/src/ImageKit/Services/IFolderService.cs +++ b/src/Imagekit/Services/IFolderService.cs @@ -1,11 +1,11 @@ using System; using System.Threading; using System.Threading.Tasks; -using ImageKit.Core; -using ImageKit.Models.Folders; -using ImageKit.Services.Folders; +using Imagekit.Core; +using Imagekit.Models.Folders; +using Imagekit.Services.Folders; -namespace ImageKit.Services; +namespace Imagekit.Services; /// /// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking diff --git a/src/ImageKit/Services/ISavedExtensionService.cs b/src/Imagekit/Services/ISavedExtensionService.cs similarity index 95% rename from src/ImageKit/Services/ISavedExtensionService.cs rename to src/Imagekit/Services/ISavedExtensionService.cs index d8770f25..fca28849 100644 --- a/src/ImageKit/Services/ISavedExtensionService.cs +++ b/src/Imagekit/Services/ISavedExtensionService.cs @@ -2,11 +2,11 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using ImageKit.Core; -using ImageKit.Models.SavedExtensions; -using Models = ImageKit.Models; +using Imagekit.Core; +using Imagekit.Models.SavedExtensions; +using Models = Imagekit.Models; -namespace ImageKit.Services; +namespace Imagekit.Services; /// /// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking diff --git a/src/ImageKit/Services/IWebhookService.cs b/src/Imagekit/Services/IWebhookService.cs similarity index 93% rename from src/ImageKit/Services/IWebhookService.cs rename to src/Imagekit/Services/IWebhookService.cs index befb6524..aa79aac5 100644 --- a/src/ImageKit/Services/IWebhookService.cs +++ b/src/Imagekit/Services/IWebhookService.cs @@ -1,7 +1,7 @@ using System; -using ImageKit.Core; +using Imagekit.Core; -namespace ImageKit.Services; +namespace Imagekit.Services; /// /// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking diff --git a/src/ImageKit/Services/SavedExtensionService.cs b/src/Imagekit/Services/SavedExtensionService.cs similarity index 95% rename from src/ImageKit/Services/SavedExtensionService.cs rename to src/Imagekit/Services/SavedExtensionService.cs index 5ec770b5..f0ec69c1 100644 --- a/src/ImageKit/Services/SavedExtensionService.cs +++ b/src/Imagekit/Services/SavedExtensionService.cs @@ -3,12 +3,12 @@ using System.Net.Http; using System.Threading; using System.Threading.Tasks; -using ImageKit.Core; -using ImageKit.Exceptions; -using ImageKit.Models.SavedExtensions; -using Models = ImageKit.Models; +using Imagekit.Core; +using Imagekit.Exceptions; +using Imagekit.Models.SavedExtensions; +using Models = Imagekit.Models; -namespace ImageKit.Services; +namespace Imagekit.Services; /// public sealed class SavedExtensionService : ISavedExtensionService diff --git a/src/ImageKit/Services/WebhookService.cs b/src/Imagekit/Services/WebhookService.cs similarity index 92% rename from src/ImageKit/Services/WebhookService.cs rename to src/Imagekit/Services/WebhookService.cs index 15f7aa9f..e4f938c5 100644 --- a/src/ImageKit/Services/WebhookService.cs +++ b/src/Imagekit/Services/WebhookService.cs @@ -1,7 +1,7 @@ using System; -using ImageKit.Core; +using Imagekit.Core; -namespace ImageKit.Services; +namespace Imagekit.Services; /// public sealed class WebhookService : IWebhookService diff --git a/src/ImageKit/Shims.cs b/src/Imagekit/Shims.cs similarity index 100% rename from src/ImageKit/Shims.cs rename to src/Imagekit/Shims.cs From f081efef442577b59ba0fa266bdb057bb9104fcd Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sun, 17 May 2026 02:40:08 +0000 Subject: [PATCH 119/129] build: add ExtensionItem schema in csharp --- .stats.yml | 4 +- .../Models/Assets/AssetListResponseTest.cs | 12 +- .../Beta/V2/Files/FileUploadParamsTest.cs | 47 +- .../Beta/V2/Files/FileUploadResponseTest.cs | 140 +- ...rayParent0Test.cs => ExtensionItemTest.cs} | 1115 ++++++-------- src/Imagekit.Tests/Models/Files/FileTest.cs | 140 +- .../Models/Files/FileUpdateParamsTest.cs | 67 +- .../Models/Files/FileUpdateResponseTest.cs | 66 +- .../Models/Files/FileUploadParamsTest.cs | 47 +- .../Models/Files/FileUploadResponseTest.cs | 140 +- .../Models/Files/UpdateFileRequestTest.cs | 371 +++-- .../Models/Webhooks/FileCreateEventTest.cs | 84 +- .../Models/Webhooks/FileUpdateEventTest.cs | 84 +- .../Webhooks/FileVersionCreateEventTest.cs | 84 +- .../Webhooks/UnsafeUnwrapWebhookEventTest.cs | 48 +- .../Models/Webhooks/UnwrapWebhookEventTest.cs | 48 +- .../UploadPreTransformSuccessEventTest.cs | 224 +-- .../Services/FileServiceTest.cs | 18 +- src/Imagekit/Core/ModelBase.cs | 2 +- .../Models/Beta/V2/Files/FileUploadParams.cs | 8 +- .../Beta/V2/Files/FileUploadResponse.cs | 62 +- ...maWithArrayParent0.cs => ExtensionItem.cs} | 1357 ++++++++--------- src/Imagekit/Models/Files/File.cs | 62 +- src/Imagekit/Models/Files/FileUploadParams.cs | 8 +- .../Models/Files/FileUploadResponse.cs | 62 +- .../Models/Files/UpdateFileRequest.cs | 8 +- .../UploadPreTransformSuccessEvent.cs | 62 +- 27 files changed, 2043 insertions(+), 2327 deletions(-) rename src/Imagekit.Tests/Models/{UnnamedSchemaWithArrayParent0Test.cs => ExtensionItemTest.cs} (65%) rename src/Imagekit/Models/{UnnamedSchemaWithArrayParent0.cs => ExtensionItem.cs} (66%) diff --git a/.stats.yml b/.stats.yml index 62ce5cf3..6bae0823 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc/imagekit-a8f005109bd8f1fa42d080ed43b4f7b67eacad5aea113fe5223306c3f217556a.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc/imagekit-9daf3daa1db3813288c77c8777bfca85337e3512bdc83ee48fe0631e41c3650d.yml openapi_spec_hash: 7c103e2dff0edcbeea82057e62f58d4d -config_hash: 493cdeb6cf0935806c5f6a029774029d +config_hash: 34c788f0652c42a878adf62248426f1e diff --git a/src/Imagekit.Tests/Models/Assets/AssetListResponseTest.cs b/src/Imagekit.Tests/Models/Assets/AssetListResponseTest.cs index f3447545..1cc145e6 100644 --- a/src/Imagekit.Tests/Models/Assets/AssetListResponseTest.cs +++ b/src/Imagekit.Tests/Models/Assets/AssetListResponseTest.cs @@ -55,9 +55,9 @@ public void FileValidationWorks() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -149,9 +149,9 @@ public void FileSerializationRoundtripWorks() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, diff --git a/src/Imagekit.Tests/Models/Beta/V2/Files/FileUploadParamsTest.cs b/src/Imagekit.Tests/Models/Beta/V2/Files/FileUploadParamsTest.cs index 19cfcc0c..6da89b2b 100644 --- a/src/Imagekit.Tests/Models/Beta/V2/Files/FileUploadParamsTest.cs +++ b/src/Imagekit.Tests/Models/Beta/V2/Files/FileUploadParamsTest.cs @@ -31,7 +31,7 @@ public void FieldRoundtrip_Works() Description = "Running shoes", Extensions = [ - new Models::UnnamedSchemaWithArrayParent0RemoveBg() + new Models::ExtensionItemRemoveBg() { Options = new() { @@ -41,24 +41,23 @@ public void FieldRoundtrip_Works() Semitransparency = true, }, }, - new Models::UnnamedSchemaWithArrayParent0AutoTaggingExtension() + new Models::ExtensionItemAutoTaggingExtension() { MaxTags = 5, MinConfidence = 95, - Name = - Models::UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + Name = Models::ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, }, - new Models::UnnamedSchemaWithArrayParent0AIAutoDescription(), - new Models::UnnamedSchemaWithArrayParent0AITasks( + new Models::ExtensionItemAIAutoDescription(), + new Models::ExtensionItemAITasks( [ - new Models::UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + new Models::ExtensionItemAITasksTaskSelectTags() { Instruction = "What types of clothing items are visible in this image?", MaxSelections = 1, MinSelections = 0, Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], }, - new Models::UnnamedSchemaWithArrayParent0AITasksTaskYesNo() + new Models::ExtensionItemAITasksTaskYesNo() { Instruction = "Is this a luxury or high-end fashion item?", OnNo = new() @@ -125,9 +124,9 @@ public void FieldRoundtrip_Works() { "color", JsonSerializer.SerializeToElement("bar") }, }; string expectedDescription = "Running shoes"; - List expectedExtensions = + List expectedExtensions = [ - new Models::UnnamedSchemaWithArrayParent0RemoveBg() + new Models::ExtensionItemRemoveBg() { Options = new() { @@ -137,24 +136,23 @@ public void FieldRoundtrip_Works() Semitransparency = true, }, }, - new Models::UnnamedSchemaWithArrayParent0AutoTaggingExtension() + new Models::ExtensionItemAutoTaggingExtension() { MaxTags = 5, MinConfidence = 95, - Name = - Models::UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + Name = Models::ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, }, - new Models::UnnamedSchemaWithArrayParent0AIAutoDescription(), - new Models::UnnamedSchemaWithArrayParent0AITasks( + new Models::ExtensionItemAIAutoDescription(), + new Models::ExtensionItemAITasks( [ - new Models::UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + new Models::ExtensionItemAITasksTaskSelectTags() { Instruction = "What types of clothing items are visible in this image?", MaxSelections = 1, MinSelections = 0, Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], }, - new Models::UnnamedSchemaWithArrayParent0AITasksTaskYesNo() + new Models::ExtensionItemAITasksTaskYesNo() { Instruction = "Is this a luxury or high-end fashion item?", OnNo = new() @@ -401,7 +399,7 @@ public void CopyConstructor_Works() Description = "Running shoes", Extensions = [ - new Models::UnnamedSchemaWithArrayParent0RemoveBg() + new Models::ExtensionItemRemoveBg() { Options = new() { @@ -411,24 +409,23 @@ public void CopyConstructor_Works() Semitransparency = true, }, }, - new Models::UnnamedSchemaWithArrayParent0AutoTaggingExtension() + new Models::ExtensionItemAutoTaggingExtension() { MaxTags = 5, MinConfidence = 95, - Name = - Models::UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + Name = Models::ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, }, - new Models::UnnamedSchemaWithArrayParent0AIAutoDescription(), - new Models::UnnamedSchemaWithArrayParent0AITasks( + new Models::ExtensionItemAIAutoDescription(), + new Models::ExtensionItemAITasks( [ - new Models::UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + new Models::ExtensionItemAITasksTaskSelectTags() { Instruction = "What types of clothing items are visible in this image?", MaxSelections = 1, MinSelections = 0, Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], }, - new Models::UnnamedSchemaWithArrayParent0AITasksTaskYesNo() + new Models::ExtensionItemAITasksTaskYesNo() { Instruction = "Is this a luxury or high-end fashion item?", OnNo = new() diff --git a/src/Imagekit.Tests/Models/Beta/V2/Files/FileUploadResponseTest.cs b/src/Imagekit.Tests/Models/Beta/V2/Files/FileUploadResponseTest.cs index de103af1..d5150a31 100644 --- a/src/Imagekit.Tests/Models/Beta/V2/Files/FileUploadResponseTest.cs +++ b/src/Imagekit.Tests/Models/Beta/V2/Files/FileUploadResponseTest.cs @@ -141,9 +141,9 @@ public void FieldRoundtrip_Works() Type = Type.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), ] ), IsValueRequired = true, @@ -293,9 +293,9 @@ public void FieldRoundtrip_Works() Type = Type.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), ] ), IsValueRequired = true, @@ -507,9 +507,9 @@ public void SerializationRoundtrip_Works() Type = Type.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), ] ), IsValueRequired = true, @@ -673,9 +673,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Type.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), ] ), IsValueRequired = true, @@ -832,9 +832,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Type.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), ] ), IsValueRequired = true, @@ -1046,9 +1046,9 @@ public void Validation_Works() Type = Type.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), ] ), IsValueRequired = true, @@ -1414,9 +1414,9 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Type = Type.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), ] ), IsValueRequired = true, @@ -1568,9 +1568,9 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Type = Type.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), ] ), IsValueRequired = true, @@ -1717,9 +1717,9 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Type = Type.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), ] ), IsValueRequired = true, @@ -1875,9 +1875,9 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Type = Type.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), ] ), IsValueRequired = true, @@ -2038,9 +2038,9 @@ public void CopyConstructor_Works() Type = Type.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), ] ), IsValueRequired = true, @@ -2701,9 +2701,9 @@ public void FieldRoundtrip_Works() Type = Type.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), ] ), IsValueRequired = true, @@ -2719,9 +2719,9 @@ public void FieldRoundtrip_Works() ApiEnum expectedType = Type.Text; DefaultValue expectedDefaultValue = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), ] ); bool expectedIsValueRequired = true; @@ -2758,9 +2758,9 @@ public void SerializationRoundtrip_Works() Type = Type.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), ] ), IsValueRequired = true, @@ -2790,9 +2790,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Type.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), ] ), IsValueRequired = true, @@ -2815,9 +2815,9 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum expectedType = Type.Text; DefaultValue expectedDefaultValue = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), ] ); bool expectedIsValueRequired = true; @@ -2854,9 +2854,9 @@ public void Validation_Works() Type = Type.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), ] ), IsValueRequired = true, @@ -2974,9 +2974,9 @@ public void CopyConstructor_Works() Type = Type.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), ] ), IsValueRequired = true, @@ -3091,9 +3091,9 @@ public void MixedValidationWorks() { DefaultValue value = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), ] ); value.Validate(); @@ -3143,9 +3143,9 @@ public void MixedSerializationRoundtripWorks() { DefaultValue value = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new UnnamedSchemaWithArrayParent2(true), + new UnnamedSchemaWithArrayParent2(10), + new UnnamedSchemaWithArrayParent2("Hello"), ] ); string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3158,35 +3158,35 @@ public void MixedSerializationRoundtripWorks() } } -public class UnnamedSchemaWithArrayParent3Test : TestBase +public class UnnamedSchemaWithArrayParent2Test : TestBase { [Fact] public void StringValidationWorks() { - UnnamedSchemaWithArrayParent3 value = "string"; + UnnamedSchemaWithArrayParent2 value = "string"; value.Validate(); } [Fact] public void DoubleValidationWorks() { - UnnamedSchemaWithArrayParent3 value = 0; + UnnamedSchemaWithArrayParent2 value = 0; value.Validate(); } [Fact] public void BoolValidationWorks() { - UnnamedSchemaWithArrayParent3 value = true; + UnnamedSchemaWithArrayParent2 value = true; value.Validate(); } [Fact] public void StringSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent3 value = "string"; + UnnamedSchemaWithArrayParent2 value = "string"; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -3197,9 +3197,9 @@ public void StringSerializationRoundtripWorks() [Fact] public void DoubleSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent3 value = 0; + UnnamedSchemaWithArrayParent2 value = 0; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -3210,9 +3210,9 @@ public void DoubleSerializationRoundtripWorks() [Fact] public void BoolSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent3 value = true; + UnnamedSchemaWithArrayParent2 value = true; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); diff --git a/src/Imagekit.Tests/Models/UnnamedSchemaWithArrayParent0Test.cs b/src/Imagekit.Tests/Models/ExtensionItemTest.cs similarity index 65% rename from src/Imagekit.Tests/Models/UnnamedSchemaWithArrayParent0Test.cs rename to src/Imagekit.Tests/Models/ExtensionItemTest.cs index 4885b0e3..1c93edad 100644 --- a/src/Imagekit.Tests/Models/UnnamedSchemaWithArrayParent0Test.cs +++ b/src/Imagekit.Tests/Models/ExtensionItemTest.cs @@ -6,12 +6,12 @@ namespace Imagekit.Tests.Models; -public class UnnamedSchemaWithArrayParent0Test : TestBase +public class ExtensionItemTest : TestBase { [Fact] public void RemoveBgValidationWorks() { - UnnamedSchemaWithArrayParent0 value = new UnnamedSchemaWithArrayParent0RemoveBg() + ExtensionItem value = new ExtensionItemRemoveBg() { Options = new() { @@ -27,29 +27,28 @@ public void RemoveBgValidationWorks() [Fact] public void AutoTaggingExtensionValidationWorks() { - UnnamedSchemaWithArrayParent0 value = - new UnnamedSchemaWithArrayParent0AutoTaggingExtension() - { - MaxTags = 0, - MinConfidence = 0, - Name = UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, - }; + ExtensionItem value = new ExtensionItemAutoTaggingExtension() + { + MaxTags = 0, + MinConfidence = 0, + Name = ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, + }; value.Validate(); } [Fact] public void AIAutoDescriptionValidationWorks() { - UnnamedSchemaWithArrayParent0 value = new UnnamedSchemaWithArrayParent0AIAutoDescription(); + ExtensionItem value = new ExtensionItemAIAutoDescription(); value.Validate(); } [Fact] public void AITasksValidationWorks() { - UnnamedSchemaWithArrayParent0 value = new UnnamedSchemaWithArrayParent0AITasks( + ExtensionItem value = new ExtensionItemAITasks( [ - new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + new ExtensionItemAITasksTaskSelectTags() { Instruction = "What types of clothing items are visible in this image?", MaxSelections = 1, @@ -64,14 +63,14 @@ public void AITasksValidationWorks() [Fact] public void SavedExtensionValidationWorks() { - UnnamedSchemaWithArrayParent0 value = new SavedExtension("ext_abc123"); + ExtensionItem value = new SavedExtension("ext_abc123"); value.Validate(); } [Fact] public void RemoveBgSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent0 value = new UnnamedSchemaWithArrayParent0RemoveBg() + ExtensionItem value = new ExtensionItemRemoveBg() { Options = new() { @@ -82,7 +81,7 @@ public void RemoveBgSerializationRoundtripWorks() }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -93,15 +92,14 @@ public void RemoveBgSerializationRoundtripWorks() [Fact] public void AutoTaggingExtensionSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent0 value = - new UnnamedSchemaWithArrayParent0AutoTaggingExtension() - { - MaxTags = 0, - MinConfidence = 0, - Name = UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, - }; + ExtensionItem value = new ExtensionItemAutoTaggingExtension() + { + MaxTags = 0, + MinConfidence = 0, + Name = ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, + }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -112,9 +110,9 @@ public void AutoTaggingExtensionSerializationRoundtripWorks() [Fact] public void AIAutoDescriptionSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent0 value = new UnnamedSchemaWithArrayParent0AIAutoDescription(); + ExtensionItem value = new ExtensionItemAIAutoDescription(); string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -125,9 +123,9 @@ public void AIAutoDescriptionSerializationRoundtripWorks() [Fact] public void AITasksSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent0 value = new UnnamedSchemaWithArrayParent0AITasks( + ExtensionItem value = new ExtensionItemAITasks( [ - new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + new ExtensionItemAITasksTaskSelectTags() { Instruction = "What types of clothing items are visible in this image?", MaxSelections = 1, @@ -137,7 +135,7 @@ public void AITasksSerializationRoundtripWorks() ] ); string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -148,9 +146,9 @@ public void AITasksSerializationRoundtripWorks() [Fact] public void SavedExtensionSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent0 value = new SavedExtension("ext_abc123"); + ExtensionItem value = new SavedExtension("ext_abc123"); string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -159,12 +157,12 @@ public void SavedExtensionSerializationRoundtripWorks() } } -public class UnnamedSchemaWithArrayParent0RemoveBgTest : TestBase +public class ExtensionItemRemoveBgTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new UnnamedSchemaWithArrayParent0RemoveBg + var model = new ExtensionItemRemoveBg { Options = new() { @@ -176,7 +174,7 @@ public void FieldRoundtrip_Works() }; JsonElement expectedName = JsonSerializer.SerializeToElement("remove-bg"); - UnnamedSchemaWithArrayParent0RemoveBgOptions expectedOptions = new() + ExtensionItemRemoveBgOptions expectedOptions = new() { AddShadow = true, BgColor = "bg_color", @@ -191,7 +189,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new UnnamedSchemaWithArrayParent0RemoveBg + var model = new ExtensionItemRemoveBg { Options = new() { @@ -203,7 +201,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -214,7 +212,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new UnnamedSchemaWithArrayParent0RemoveBg + var model = new ExtensionItemRemoveBg { Options = new() { @@ -226,14 +224,14 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); JsonElement expectedName = JsonSerializer.SerializeToElement("remove-bg"); - UnnamedSchemaWithArrayParent0RemoveBgOptions expectedOptions = new() + ExtensionItemRemoveBgOptions expectedOptions = new() { AddShadow = true, BgColor = "bg_color", @@ -248,7 +246,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new UnnamedSchemaWithArrayParent0RemoveBg + var model = new ExtensionItemRemoveBg { Options = new() { @@ -265,7 +263,7 @@ public void Validation_Works() [Fact] public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new UnnamedSchemaWithArrayParent0RemoveBg { }; + var model = new ExtensionItemRemoveBg { }; Assert.Null(model.Options); Assert.False(model.RawData.ContainsKey("options")); @@ -274,7 +272,7 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = new UnnamedSchemaWithArrayParent0RemoveBg { }; + var model = new ExtensionItemRemoveBg { }; model.Validate(); } @@ -282,7 +280,7 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - var model = new UnnamedSchemaWithArrayParent0RemoveBg + var model = new ExtensionItemRemoveBg { // Null should be interpreted as omitted for these properties Options = null, @@ -295,7 +293,7 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - var model = new UnnamedSchemaWithArrayParent0RemoveBg + var model = new ExtensionItemRemoveBg { // Null should be interpreted as omitted for these properties Options = null, @@ -307,7 +305,7 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new UnnamedSchemaWithArrayParent0RemoveBg + var model = new ExtensionItemRemoveBg { Options = new() { @@ -318,18 +316,18 @@ public void CopyConstructor_Works() }, }; - UnnamedSchemaWithArrayParent0RemoveBg copied = new(model); + ExtensionItemRemoveBg copied = new(model); Assert.Equal(model, copied); } } -public class UnnamedSchemaWithArrayParent0RemoveBgOptionsTest : TestBase +public class ExtensionItemRemoveBgOptionsTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new UnnamedSchemaWithArrayParent0RemoveBgOptions + var model = new ExtensionItemRemoveBgOptions { AddShadow = true, BgColor = "bg_color", @@ -351,7 +349,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new UnnamedSchemaWithArrayParent0RemoveBgOptions + var model = new ExtensionItemRemoveBgOptions { AddShadow = true, BgColor = "bg_color", @@ -360,7 +358,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -371,7 +369,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new UnnamedSchemaWithArrayParent0RemoveBgOptions + var model = new ExtensionItemRemoveBgOptions { AddShadow = true, BgColor = "bg_color", @@ -380,7 +378,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -400,7 +398,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new UnnamedSchemaWithArrayParent0RemoveBgOptions + var model = new ExtensionItemRemoveBgOptions { AddShadow = true, BgColor = "bg_color", @@ -414,7 +412,7 @@ public void Validation_Works() [Fact] public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new UnnamedSchemaWithArrayParent0RemoveBgOptions { }; + var model = new ExtensionItemRemoveBgOptions { }; Assert.Null(model.AddShadow); Assert.False(model.RawData.ContainsKey("add_shadow")); @@ -429,7 +427,7 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = new UnnamedSchemaWithArrayParent0RemoveBgOptions { }; + var model = new ExtensionItemRemoveBgOptions { }; model.Validate(); } @@ -437,7 +435,7 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - var model = new UnnamedSchemaWithArrayParent0RemoveBgOptions + var model = new ExtensionItemRemoveBgOptions { // Null should be interpreted as omitted for these properties AddShadow = null, @@ -459,7 +457,7 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - var model = new UnnamedSchemaWithArrayParent0RemoveBgOptions + var model = new ExtensionItemRemoveBgOptions { // Null should be interpreted as omitted for these properties AddShadow = null, @@ -474,7 +472,7 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new UnnamedSchemaWithArrayParent0RemoveBgOptions + var model = new ExtensionItemRemoveBgOptions { AddShadow = true, BgColor = "bg_color", @@ -482,28 +480,28 @@ public void CopyConstructor_Works() Semitransparency = true, }; - UnnamedSchemaWithArrayParent0RemoveBgOptions copied = new(model); + ExtensionItemRemoveBgOptions copied = new(model); Assert.Equal(model, copied); } } -public class UnnamedSchemaWithArrayParent0AutoTaggingExtensionTest : TestBase +public class ExtensionItemAutoTaggingExtensionTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new UnnamedSchemaWithArrayParent0AutoTaggingExtension + var model = new ExtensionItemAutoTaggingExtension { MaxTags = 0, MinConfidence = 0, - Name = UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + Name = ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, }; long expectedMaxTags = 0; long expectedMinConfidence = 0; - ApiEnum expectedName = - UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging; + ApiEnum expectedName = + ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging; Assert.Equal(expectedMaxTags, model.MaxTags); Assert.Equal(expectedMinConfidence, model.MinConfidence); @@ -513,19 +511,18 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new UnnamedSchemaWithArrayParent0AutoTaggingExtension + var model = new ExtensionItemAutoTaggingExtension { MaxTags = 0, MinConfidence = 0, - Name = UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + Name = ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -533,25 +530,24 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new UnnamedSchemaWithArrayParent0AutoTaggingExtension + var model = new ExtensionItemAutoTaggingExtension { MaxTags = 0, MinConfidence = 0, - Name = UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + Name = ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.NotNull(deserialized); long expectedMaxTags = 0; long expectedMinConfidence = 0; - ApiEnum expectedName = - UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging; + ApiEnum expectedName = + ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging; Assert.Equal(expectedMaxTags, deserialized.MaxTags); Assert.Equal(expectedMinConfidence, deserialized.MinConfidence); @@ -561,11 +557,11 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new UnnamedSchemaWithArrayParent0AutoTaggingExtension + var model = new ExtensionItemAutoTaggingExtension { MaxTags = 0, MinConfidence = 0, - Name = UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + Name = ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, }; model.Validate(); @@ -574,28 +570,28 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new UnnamedSchemaWithArrayParent0AutoTaggingExtension + var model = new ExtensionItemAutoTaggingExtension { MaxTags = 0, MinConfidence = 0, - Name = UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + Name = ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, }; - UnnamedSchemaWithArrayParent0AutoTaggingExtension copied = new(model); + ExtensionItemAutoTaggingExtension copied = new(model); Assert.Equal(model, copied); } } -public class UnnamedSchemaWithArrayParent0AutoTaggingExtensionNameTest : TestBase +public class ExtensionItemAutoTaggingExtensionNameTest : TestBase { [Theory] - [InlineData(UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging)] - [InlineData(UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.AwsAutoTagging)] - public void Validation_Works(UnnamedSchemaWithArrayParent0AutoTaggingExtensionName rawValue) + [InlineData(ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging)] + [InlineData(ExtensionItemAutoTaggingExtensionName.AwsAutoTagging)] + public void Validation_Works(ExtensionItemAutoTaggingExtensionName rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } @@ -603,7 +599,7 @@ public void Validation_Works(UnnamedSchemaWithArrayParent0AutoTaggingExtensionNa public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -611,18 +607,16 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging)] - [InlineData(UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.AwsAutoTagging)] - public void SerializationRoundtrip_Works( - UnnamedSchemaWithArrayParent0AutoTaggingExtensionName rawValue - ) + [InlineData(ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging)] + [InlineData(ExtensionItemAutoTaggingExtensionName.AwsAutoTagging)] + public void SerializationRoundtrip_Works(ExtensionItemAutoTaggingExtensionName rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -632,30 +626,30 @@ UnnamedSchemaWithArrayParent0AutoTaggingExtensionName rawValue public void InvalidEnumSerializationRoundtrip_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class UnnamedSchemaWithArrayParent0AIAutoDescriptionTest : TestBase +public class ExtensionItemAIAutoDescriptionTest : TestBase { [Fact] public void DefaultValidation_Works() { - var constant = new UnnamedSchemaWithArrayParent0AIAutoDescription(); + var constant = new ExtensionItemAIAutoDescription(); constant.Validate(); } [Fact] public void ValidConstantValidation_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.Deserialize( """ { @@ -673,7 +667,7 @@ public void ValidConstantValidation_Works() [Fact] public void InvalidConstantValidationThrows_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); @@ -685,13 +679,12 @@ public void InvalidConstantValidationThrows_Works() [Fact] public void DefaultRoundtrip_Works() { - var constant = new UnnamedSchemaWithArrayParent0AIAutoDescription(); + var constant = new ExtensionItemAIAutoDescription(); string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(constant, deserialized); } @@ -699,7 +692,7 @@ public void DefaultRoundtrip_Works() [Fact] public void ValidConstantRoundtrip_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.Deserialize( """ { @@ -710,11 +703,10 @@ public void ValidConstantRoundtrip_Works() ModelBase.SerializerOptions ); string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(constant, deserialized); } @@ -722,31 +714,30 @@ public void ValidConstantRoundtrip_Works() [Fact] public void InvalidConstantRoundtrip_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(constant, deserialized); } } -public class UnnamedSchemaWithArrayParent0AITasksTest : TestBase +public class ExtensionItemAITasksTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasks + var model = new ExtensionItemAITasks { Tasks = [ - new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + new ExtensionItemAITasksTaskSelectTags() { Instruction = "What types of clothing items are visible in this image?", MaxSelections = 1, @@ -757,9 +748,9 @@ public void FieldRoundtrip_Works() }; JsonElement expectedName = JsonSerializer.SerializeToElement("ai-tasks"); - List expectedTasks = + List expectedTasks = [ - new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + new ExtensionItemAITasksTaskSelectTags() { Instruction = "What types of clothing items are visible in this image?", MaxSelections = 1, @@ -779,11 +770,11 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasks + var model = new ExtensionItemAITasks { Tasks = [ - new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + new ExtensionItemAITasksTaskSelectTags() { Instruction = "What types of clothing items are visible in this image?", MaxSelections = 1, @@ -794,7 +785,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -805,11 +796,11 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasks + var model = new ExtensionItemAITasks { Tasks = [ - new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + new ExtensionItemAITasksTaskSelectTags() { Instruction = "What types of clothing items are visible in this image?", MaxSelections = 1, @@ -820,16 +811,16 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); JsonElement expectedName = JsonSerializer.SerializeToElement("ai-tasks"); - List expectedTasks = + List expectedTasks = [ - new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + new ExtensionItemAITasksTaskSelectTags() { Instruction = "What types of clothing items are visible in this image?", MaxSelections = 1, @@ -849,11 +840,11 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasks + var model = new ExtensionItemAITasks { Tasks = [ - new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + new ExtensionItemAITasksTaskSelectTags() { Instruction = "What types of clothing items are visible in this image?", MaxSelections = 1, @@ -869,11 +860,11 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasks + var model = new ExtensionItemAITasks { Tasks = [ - new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + new ExtensionItemAITasksTaskSelectTags() { Instruction = "What types of clothing items are visible in this image?", MaxSelections = 1, @@ -883,88 +874,84 @@ public void CopyConstructor_Works() ], }; - UnnamedSchemaWithArrayParent0AITasks copied = new(model); + ExtensionItemAITasks copied = new(model); Assert.Equal(model, copied); } } -public class UnnamedSchemaWithArrayParent0AITasksTaskTest : TestBase +public class ExtensionItemAITasksTaskTest : TestBase { [Fact] public void SelectTagsValidationWorks() { - UnnamedSchemaWithArrayParent0AITasksTask value = - new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() - { - Instruction = "What types of clothing items are visible in this image?", - MaxSelections = 1, - MinSelections = 0, - Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], - }; + ExtensionItemAITasksTask value = new ExtensionItemAITasksTaskSelectTags() + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }; value.Validate(); } [Fact] public void SelectMetadataValidationWorks() { - UnnamedSchemaWithArrayParent0AITasksTask value = - new UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata() - { - Field = "primary_color", - Instruction = "What is the primary color of the clothing?", - MaxSelections = 1, - MinSelections = 0, - Vocabulary = ["red", "blue", "green", "black", "white"], - }; + ExtensionItemAITasksTask value = new ExtensionItemAITasksTaskSelectMetadata() + { + Field = "primary_color", + Instruction = "What is the primary color of the clothing?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["red", "blue", "green", "black", "white"], + }; value.Validate(); } [Fact] public void YesNoValidationWorks() { - UnnamedSchemaWithArrayParent0AITasksTask value = - new UnnamedSchemaWithArrayParent0AITasksTaskYesNo() + ExtensionItemAITasksTask value = new ExtensionItemAITasksTaskYesNo() + { + Instruction = "Is this a luxury or high-end fashion item?", + OnNo = new() { - Instruction = "Is this a luxury or high-end fashion item?", - OnNo = new() - { - AddTags = ["luxury", "premium"], - RemoveTags = ["budget", "affordable"], - SetMetadata = [new() { Field = "price_range", Value = "premium" }], - UnsetMetadata = [new("price_range")], - }, - OnUnknown = new() - { - AddTags = ["luxury", "premium"], - RemoveTags = ["budget", "affordable"], - SetMetadata = [new() { Field = "price_range", Value = "premium" }], - UnsetMetadata = [new("price_range")], - }, - OnYes = new() - { - AddTags = ["luxury", "premium"], - RemoveTags = ["budget", "affordable"], - SetMetadata = [new() { Field = "price_range", Value = "premium" }], - UnsetMetadata = [new("price_range")], - }, - }; + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnUnknown = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnYes = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + }; value.Validate(); } [Fact] public void SelectTagsSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent0AITasksTask value = - new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() - { - Instruction = "What types of clothing items are visible in this image?", - MaxSelections = 1, - MinSelections = 0, - Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], - }; + ExtensionItemAITasksTask value = new ExtensionItemAITasksTaskSelectTags() + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -975,17 +962,16 @@ public void SelectTagsSerializationRoundtripWorks() [Fact] public void SelectMetadataSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent0AITasksTask value = - new UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata() - { - Field = "primary_color", - Instruction = "What is the primary color of the clothing?", - MaxSelections = 1, - MinSelections = 0, - Vocabulary = ["red", "blue", "green", "black", "white"], - }; + ExtensionItemAITasksTask value = new ExtensionItemAITasksTaskSelectMetadata() + { + Field = "primary_color", + Instruction = "What is the primary color of the clothing?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["red", "blue", "green", "black", "white"], + }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -996,34 +982,33 @@ public void SelectMetadataSerializationRoundtripWorks() [Fact] public void YesNoSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent0AITasksTask value = - new UnnamedSchemaWithArrayParent0AITasksTaskYesNo() + ExtensionItemAITasksTask value = new ExtensionItemAITasksTaskYesNo() + { + Instruction = "Is this a luxury or high-end fashion item?", + OnNo = new() { - Instruction = "Is this a luxury or high-end fashion item?", - OnNo = new() - { - AddTags = ["luxury", "premium"], - RemoveTags = ["budget", "affordable"], - SetMetadata = [new() { Field = "price_range", Value = "premium" }], - UnsetMetadata = [new("price_range")], - }, - OnUnknown = new() - { - AddTags = ["luxury", "premium"], - RemoveTags = ["budget", "affordable"], - SetMetadata = [new() { Field = "price_range", Value = "premium" }], - UnsetMetadata = [new("price_range")], - }, - OnYes = new() - { - AddTags = ["luxury", "premium"], - RemoveTags = ["budget", "affordable"], - SetMetadata = [new() { Field = "price_range", Value = "premium" }], - UnsetMetadata = [new("price_range")], - }, - }; + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnUnknown = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnYes = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -1032,12 +1017,12 @@ public void YesNoSerializationRoundtripWorks() } } -public class UnnamedSchemaWithArrayParent0AITasksTaskSelectTagsTest : TestBase +public class ExtensionItemAITasksTaskSelectTagsTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags + var model = new ExtensionItemAITasksTaskSelectTags { Instruction = "What types of clothing items are visible in this image?", MaxSelections = 1, @@ -1066,7 +1051,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags + var model = new ExtensionItemAITasksTaskSelectTags { Instruction = "What types of clothing items are visible in this image?", MaxSelections = 1, @@ -1075,11 +1060,10 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -1087,7 +1071,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags + var model = new ExtensionItemAITasksTaskSelectTags { Instruction = "What types of clothing items are visible in this image?", MaxSelections = 1, @@ -1096,11 +1080,10 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.NotNull(deserialized); string expectedInstruction = "What types of clothing items are visible in this image?"; @@ -1124,7 +1107,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags + var model = new ExtensionItemAITasksTaskSelectTags { Instruction = "What types of clothing items are visible in this image?", MaxSelections = 1, @@ -1138,7 +1121,7 @@ public void Validation_Works() [Fact] public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags + var model = new ExtensionItemAITasksTaskSelectTags { Instruction = "What types of clothing items are visible in this image?", }; @@ -1154,7 +1137,7 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags + var model = new ExtensionItemAITasksTaskSelectTags { Instruction = "What types of clothing items are visible in this image?", }; @@ -1165,7 +1148,7 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags + var model = new ExtensionItemAITasksTaskSelectTags { Instruction = "What types of clothing items are visible in this image?", @@ -1186,7 +1169,7 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags + var model = new ExtensionItemAITasksTaskSelectTags { Instruction = "What types of clothing items are visible in this image?", @@ -1202,7 +1185,7 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags + var model = new ExtensionItemAITasksTaskSelectTags { Instruction = "What types of clothing items are visible in this image?", MaxSelections = 1, @@ -1210,18 +1193,18 @@ public void CopyConstructor_Works() Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], }; - UnnamedSchemaWithArrayParent0AITasksTaskSelectTags copied = new(model); + ExtensionItemAITasksTaskSelectTags copied = new(model); Assert.Equal(model, copied); } } -public class UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataTest : TestBase +public class ExtensionItemAITasksTaskSelectMetadataTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata + var model = new ExtensionItemAITasksTaskSelectMetadata { Field = "primary_color", Instruction = "What is the primary color of the clothing?", @@ -1235,7 +1218,7 @@ public void FieldRoundtrip_Works() JsonElement expectedType = JsonSerializer.SerializeToElement("select_metadata"); long expectedMaxSelections = 1; long expectedMinSelections = 0; - List expectedVocabulary = + List expectedVocabulary = [ "red", "blue", @@ -1260,7 +1243,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata + var model = new ExtensionItemAITasksTaskSelectMetadata { Field = "primary_color", Instruction = "What is the primary color of the clothing?", @@ -1270,11 +1253,10 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -1282,7 +1264,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata + var model = new ExtensionItemAITasksTaskSelectMetadata { Field = "primary_color", Instruction = "What is the primary color of the clothing?", @@ -1292,11 +1274,10 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.NotNull(deserialized); string expectedField = "primary_color"; @@ -1304,7 +1285,7 @@ public void FieldRoundtripThroughSerialization_Works() JsonElement expectedType = JsonSerializer.SerializeToElement("select_metadata"); long expectedMaxSelections = 1; long expectedMinSelections = 0; - List expectedVocabulary = + List expectedVocabulary = [ "red", "blue", @@ -1329,7 +1310,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata + var model = new ExtensionItemAITasksTaskSelectMetadata { Field = "primary_color", Instruction = "What is the primary color of the clothing?", @@ -1344,7 +1325,7 @@ public void Validation_Works() [Fact] public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata + var model = new ExtensionItemAITasksTaskSelectMetadata { Field = "primary_color", Instruction = "What is the primary color of the clothing?", @@ -1361,7 +1342,7 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata + var model = new ExtensionItemAITasksTaskSelectMetadata { Field = "primary_color", Instruction = "What is the primary color of the clothing?", @@ -1373,7 +1354,7 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata + var model = new ExtensionItemAITasksTaskSelectMetadata { Field = "primary_color", Instruction = "What is the primary color of the clothing?", @@ -1395,7 +1376,7 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata + var model = new ExtensionItemAITasksTaskSelectMetadata { Field = "primary_color", Instruction = "What is the primary color of the clothing?", @@ -1412,7 +1393,7 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata + var model = new ExtensionItemAITasksTaskSelectMetadata { Field = "primary_color", Instruction = "What is the primary color of the clothing?", @@ -1421,42 +1402,42 @@ public void CopyConstructor_Works() Vocabulary = ["red", "blue", "green", "black", "white"], }; - UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata copied = new(model); + ExtensionItemAITasksTaskSelectMetadata copied = new(model); Assert.Equal(model, copied); } } -public class UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabularyTest : TestBase +public class ExtensionItemAITasksTaskSelectMetadataVocabularyTest : TestBase { [Fact] public void StringValidationWorks() { - UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabulary value = "string"; + ExtensionItemAITasksTaskSelectMetadataVocabulary value = "string"; value.Validate(); } [Fact] public void DoubleValidationWorks() { - UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabulary value = 0; + ExtensionItemAITasksTaskSelectMetadataVocabulary value = 0; value.Validate(); } [Fact] public void BoolValidationWorks() { - UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabulary value = true; + ExtensionItemAITasksTaskSelectMetadataVocabulary value = true; value.Validate(); } [Fact] public void StringSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabulary value = "string"; + ExtensionItemAITasksTaskSelectMetadataVocabulary value = "string"; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -1467,10 +1448,10 @@ public void StringSerializationRoundtripWorks() [Fact] public void DoubleSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabulary value = 0; + ExtensionItemAITasksTaskSelectMetadataVocabulary value = 0; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -1481,10 +1462,10 @@ public void DoubleSerializationRoundtripWorks() [Fact] public void BoolSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabulary value = true; + ExtensionItemAITasksTaskSelectMetadataVocabulary value = true; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -1493,12 +1474,12 @@ public void BoolSerializationRoundtripWorks() } } -public class UnnamedSchemaWithArrayParent0AITasksTaskYesNoTest : TestBase +public class ExtensionItemAITasksTaskYesNoTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNo + var model = new ExtensionItemAITasksTaskYesNo { Instruction = "Is this a luxury or high-end fashion item?", OnNo = new() @@ -1526,21 +1507,21 @@ public void FieldRoundtrip_Works() string expectedInstruction = "Is this a luxury or high-end fashion item?"; JsonElement expectedType = JsonSerializer.SerializeToElement("yes_no"); - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo expectedOnNo = new() + ExtensionItemAITasksTaskYesNoOnNo expectedOnNo = new() { AddTags = ["luxury", "premium"], RemoveTags = ["budget", "affordable"], SetMetadata = [new() { Field = "price_range", Value = "premium" }], UnsetMetadata = [new("price_range")], }; - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown expectedOnUnknown = new() + ExtensionItemAITasksTaskYesNoOnUnknown expectedOnUnknown = new() { AddTags = ["luxury", "premium"], RemoveTags = ["budget", "affordable"], SetMetadata = [new() { Field = "price_range", Value = "premium" }], UnsetMetadata = [new("price_range")], }; - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYes expectedOnYes = new() + ExtensionItemAITasksTaskYesNoOnYes expectedOnYes = new() { AddTags = ["luxury", "premium"], RemoveTags = ["budget", "affordable"], @@ -1558,7 +1539,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNo + var model = new ExtensionItemAITasksTaskYesNo { Instruction = "Is this a luxury or high-end fashion item?", OnNo = new() @@ -1585,11 +1566,10 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -1597,7 +1577,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNo + var model = new ExtensionItemAITasksTaskYesNo { Instruction = "Is this a luxury or high-end fashion item?", OnNo = new() @@ -1624,30 +1604,29 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.NotNull(deserialized); string expectedInstruction = "Is this a luxury or high-end fashion item?"; JsonElement expectedType = JsonSerializer.SerializeToElement("yes_no"); - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo expectedOnNo = new() + ExtensionItemAITasksTaskYesNoOnNo expectedOnNo = new() { AddTags = ["luxury", "premium"], RemoveTags = ["budget", "affordable"], SetMetadata = [new() { Field = "price_range", Value = "premium" }], UnsetMetadata = [new("price_range")], }; - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown expectedOnUnknown = new() + ExtensionItemAITasksTaskYesNoOnUnknown expectedOnUnknown = new() { AddTags = ["luxury", "premium"], RemoveTags = ["budget", "affordable"], SetMetadata = [new() { Field = "price_range", Value = "premium" }], UnsetMetadata = [new("price_range")], }; - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYes expectedOnYes = new() + ExtensionItemAITasksTaskYesNoOnYes expectedOnYes = new() { AddTags = ["luxury", "premium"], RemoveTags = ["budget", "affordable"], @@ -1665,7 +1644,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNo + var model = new ExtensionItemAITasksTaskYesNo { Instruction = "Is this a luxury or high-end fashion item?", OnNo = new() @@ -1697,7 +1676,7 @@ public void Validation_Works() [Fact] public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNo + var model = new ExtensionItemAITasksTaskYesNo { Instruction = "Is this a luxury or high-end fashion item?", }; @@ -1713,7 +1692,7 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNo + var model = new ExtensionItemAITasksTaskYesNo { Instruction = "Is this a luxury or high-end fashion item?", }; @@ -1724,7 +1703,7 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNo + var model = new ExtensionItemAITasksTaskYesNo { Instruction = "Is this a luxury or high-end fashion item?", @@ -1745,7 +1724,7 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNo + var model = new ExtensionItemAITasksTaskYesNo { Instruction = "Is this a luxury or high-end fashion item?", @@ -1761,7 +1740,7 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNo + var model = new ExtensionItemAITasksTaskYesNo { Instruction = "Is this a luxury or high-end fashion item?", OnNo = new() @@ -1787,18 +1766,18 @@ public void CopyConstructor_Works() }, }; - UnnamedSchemaWithArrayParent0AITasksTaskYesNo copied = new(model); + ExtensionItemAITasksTaskYesNo copied = new(model); Assert.Equal(model, copied); } } -public class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoTest : TestBase +public class ExtensionItemAITasksTaskYesNoOnNoTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo + var model = new ExtensionItemAITasksTaskYesNoOnNo { AddTags = ["luxury", "premium"], RemoveTags = ["budget", "affordable"], @@ -1808,11 +1787,11 @@ public void FieldRoundtrip_Works() List expectedAddTags = ["luxury", "premium"]; List expectedRemoveTags = ["budget", "affordable"]; - List expectedSetMetadata = + List expectedSetMetadata = [ new() { Field = "price_range", Value = "premium" }, ]; - List expectedUnsetMetadata = + List expectedUnsetMetadata = [ new("price_range"), ]; @@ -1846,7 +1825,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo + var model = new ExtensionItemAITasksTaskYesNoOnNo { AddTags = ["luxury", "premium"], RemoveTags = ["budget", "affordable"], @@ -1855,11 +1834,10 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -1867,7 +1845,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo + var model = new ExtensionItemAITasksTaskYesNoOnNo { AddTags = ["luxury", "premium"], RemoveTags = ["budget", "affordable"], @@ -1876,20 +1854,19 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.NotNull(deserialized); List expectedAddTags = ["luxury", "premium"]; List expectedRemoveTags = ["budget", "affordable"]; - List expectedSetMetadata = + List expectedSetMetadata = [ new() { Field = "price_range", Value = "premium" }, ]; - List expectedUnsetMetadata = + List expectedUnsetMetadata = [ new("price_range"), ]; @@ -1923,7 +1900,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo + var model = new ExtensionItemAITasksTaskYesNoOnNo { AddTags = ["luxury", "premium"], RemoveTags = ["budget", "affordable"], @@ -1937,7 +1914,7 @@ public void Validation_Works() [Fact] public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo { }; + var model = new ExtensionItemAITasksTaskYesNoOnNo { }; Assert.Null(model.AddTags); Assert.False(model.RawData.ContainsKey("add_tags")); @@ -1952,7 +1929,7 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo { }; + var model = new ExtensionItemAITasksTaskYesNoOnNo { }; model.Validate(); } @@ -1960,7 +1937,7 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo + var model = new ExtensionItemAITasksTaskYesNoOnNo { // Null should be interpreted as omitted for these properties AddTags = null, @@ -1982,7 +1959,7 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo + var model = new ExtensionItemAITasksTaskYesNoOnNo { // Null should be interpreted as omitted for these properties AddTags = null, @@ -1997,7 +1974,7 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo + var model = new ExtensionItemAITasksTaskYesNoOnNo { AddTags = ["luxury", "premium"], RemoveTags = ["budget", "affordable"], @@ -2005,25 +1982,25 @@ public void CopyConstructor_Works() UnsetMetadata = [new("price_range")], }; - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo copied = new(model); + ExtensionItemAITasksTaskYesNoOnNo copied = new(model); Assert.Equal(model, copied); } } -public class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataTest : TestBase +public class ExtensionItemAITasksTaskYesNoOnNoSetMetadataTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadata + var model = new ExtensionItemAITasksTaskYesNoOnNoSetMetadata { Field = "field", Value = "string", }; string expectedField = "field"; - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue expectedValue = "string"; + ExtensionItemAITasksTaskYesNoOnNoSetMetadataValue expectedValue = "string"; Assert.Equal(expectedField, model.Field); Assert.Equal(expectedValue, model.Value); @@ -2032,18 +2009,17 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadata + var model = new ExtensionItemAITasksTaskYesNoOnNoSetMetadata { Field = "field", Value = "string", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -2051,22 +2027,21 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadata + var model = new ExtensionItemAITasksTaskYesNoOnNoSetMetadata { Field = "field", Value = "string", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.NotNull(deserialized); string expectedField = "field"; - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue expectedValue = "string"; + ExtensionItemAITasksTaskYesNoOnNoSetMetadataValue expectedValue = "string"; Assert.Equal(expectedField, deserialized.Field); Assert.Equal(expectedValue, deserialized.Value); @@ -2075,7 +2050,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadata + var model = new ExtensionItemAITasksTaskYesNoOnNoSetMetadata { Field = "field", Value = "string", @@ -2087,50 +2062,46 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadata + var model = new ExtensionItemAITasksTaskYesNoOnNoSetMetadata { Field = "field", Value = "string", }; - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadata copied = new(model); + ExtensionItemAITasksTaskYesNoOnNoSetMetadata copied = new(model); Assert.Equal(model, copied); } } -public class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueTest : TestBase +public class ExtensionItemAITasksTaskYesNoOnNoSetMetadataValueTest : TestBase { [Fact] public void StringValidationWorks() { - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue value = "string"; + ExtensionItemAITasksTaskYesNoOnNoSetMetadataValue value = "string"; value.Validate(); } [Fact] public void DoubleValidationWorks() { - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue value = 0; + ExtensionItemAITasksTaskYesNoOnNoSetMetadataValue value = 0; value.Validate(); } [Fact] public void BoolValidationWorks() { - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue value = true; + ExtensionItemAITasksTaskYesNoOnNoSetMetadataValue value = true; value.Validate(); } [Fact] public void MixedValidationWorks() { - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue value = new( - [ - new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem( - "string" - ), - ] + ExtensionItemAITasksTaskYesNoOnNoSetMetadataValue value = new( + [new ExtensionItemAITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem("string")] ); value.Validate(); } @@ -2138,10 +2109,10 @@ public void MixedValidationWorks() [Fact] public void StringSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue value = "string"; + ExtensionItemAITasksTaskYesNoOnNoSetMetadataValue value = "string"; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -2152,10 +2123,10 @@ public void StringSerializationRoundtripWorks() [Fact] public void DoubleSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue value = 0; + ExtensionItemAITasksTaskYesNoOnNoSetMetadataValue value = 0; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -2166,10 +2137,10 @@ public void DoubleSerializationRoundtripWorks() [Fact] public void BoolSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue value = true; + ExtensionItemAITasksTaskYesNoOnNoSetMetadataValue value = true; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -2180,16 +2151,12 @@ public void BoolSerializationRoundtripWorks() [Fact] public void MixedSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue value = new( - [ - new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem( - "string" - ), - ] + ExtensionItemAITasksTaskYesNoOnNoSetMetadataValue value = new( + [new ExtensionItemAITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem("string")] ); string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -2198,41 +2165,36 @@ public void MixedSerializationRoundtripWorks() } } -public class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItemTest - : TestBase +public class ExtensionItemAITasksTaskYesNoOnNoSetMetadataValueMetadataValueItemTest : TestBase { [Fact] public void StringValidationWorks() { - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem value = - "string"; + ExtensionItemAITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem value = "string"; value.Validate(); } [Fact] public void DoubleValidationWorks() { - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem value = - 0; + ExtensionItemAITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem value = 0; value.Validate(); } [Fact] public void BoolValidationWorks() { - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem value = - true; + ExtensionItemAITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem value = true; value.Validate(); } [Fact] public void StringSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem value = - "string"; + ExtensionItemAITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem value = "string"; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -2243,11 +2205,10 @@ public void StringSerializationRoundtripWorks() [Fact] public void DoubleSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem value = - 0; + ExtensionItemAITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem value = 0; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -2258,11 +2219,10 @@ public void DoubleSerializationRoundtripWorks() [Fact] public void BoolSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem value = - true; + ExtensionItemAITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem value = true; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -2271,15 +2231,12 @@ public void BoolSerializationRoundtripWorks() } } -public class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoUnsetMetadataTest : TestBase +public class ExtensionItemAITasksTaskYesNoOnNoUnsetMetadataTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoUnsetMetadata - { - Field = "field", - }; + var model = new ExtensionItemAITasksTaskYesNoOnNoUnsetMetadata { Field = "field" }; string expectedField = "field"; @@ -2289,14 +2246,11 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoUnsetMetadata - { - Field = "field", - }; + var model = new ExtensionItemAITasksTaskYesNoOnNoUnsetMetadata { Field = "field" }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -2307,14 +2261,11 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoUnsetMetadata - { - Field = "field", - }; + var model = new ExtensionItemAITasksTaskYesNoOnNoUnsetMetadata { Field = "field" }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -2328,10 +2279,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoUnsetMetadata - { - Field = "field", - }; + var model = new ExtensionItemAITasksTaskYesNoOnNoUnsetMetadata { Field = "field" }; model.Validate(); } @@ -2339,23 +2287,20 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoUnsetMetadata - { - Field = "field", - }; + var model = new ExtensionItemAITasksTaskYesNoOnNoUnsetMetadata { Field = "field" }; - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoUnsetMetadata copied = new(model); + ExtensionItemAITasksTaskYesNoOnNoUnsetMetadata copied = new(model); Assert.Equal(model, copied); } } -public class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownTest : TestBase +public class ExtensionItemAITasksTaskYesNoOnUnknownTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown + var model = new ExtensionItemAITasksTaskYesNoOnUnknown { AddTags = ["luxury", "premium"], RemoveTags = ["budget", "affordable"], @@ -2365,11 +2310,11 @@ public void FieldRoundtrip_Works() List expectedAddTags = ["luxury", "premium"]; List expectedRemoveTags = ["budget", "affordable"]; - List expectedSetMetadata = + List expectedSetMetadata = [ new() { Field = "price_range", Value = "premium" }, ]; - List expectedUnsetMetadata = + List expectedUnsetMetadata = [ new("price_range"), ]; @@ -2403,7 +2348,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown + var model = new ExtensionItemAITasksTaskYesNoOnUnknown { AddTags = ["luxury", "premium"], RemoveTags = ["budget", "affordable"], @@ -2412,11 +2357,10 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -2424,7 +2368,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown + var model = new ExtensionItemAITasksTaskYesNoOnUnknown { AddTags = ["luxury", "premium"], RemoveTags = ["budget", "affordable"], @@ -2433,20 +2377,19 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.NotNull(deserialized); List expectedAddTags = ["luxury", "premium"]; List expectedRemoveTags = ["budget", "affordable"]; - List expectedSetMetadata = + List expectedSetMetadata = [ new() { Field = "price_range", Value = "premium" }, ]; - List expectedUnsetMetadata = + List expectedUnsetMetadata = [ new("price_range"), ]; @@ -2480,7 +2423,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown + var model = new ExtensionItemAITasksTaskYesNoOnUnknown { AddTags = ["luxury", "premium"], RemoveTags = ["budget", "affordable"], @@ -2494,7 +2437,7 @@ public void Validation_Works() [Fact] public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown { }; + var model = new ExtensionItemAITasksTaskYesNoOnUnknown { }; Assert.Null(model.AddTags); Assert.False(model.RawData.ContainsKey("add_tags")); @@ -2509,7 +2452,7 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown { }; + var model = new ExtensionItemAITasksTaskYesNoOnUnknown { }; model.Validate(); } @@ -2517,7 +2460,7 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown + var model = new ExtensionItemAITasksTaskYesNoOnUnknown { // Null should be interpreted as omitted for these properties AddTags = null, @@ -2539,7 +2482,7 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown + var model = new ExtensionItemAITasksTaskYesNoOnUnknown { // Null should be interpreted as omitted for these properties AddTags = null, @@ -2554,7 +2497,7 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown + var model = new ExtensionItemAITasksTaskYesNoOnUnknown { AddTags = ["luxury", "premium"], RemoveTags = ["budget", "affordable"], @@ -2562,26 +2505,25 @@ public void CopyConstructor_Works() UnsetMetadata = [new("price_range")], }; - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown copied = new(model); + ExtensionItemAITasksTaskYesNoOnUnknown copied = new(model); Assert.Equal(model, copied); } } -public class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataTest : TestBase +public class ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadata + var model = new ExtensionItemAITasksTaskYesNoOnUnknownSetMetadata { Field = "field", Value = "string", }; string expectedField = "field"; - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue expectedValue = - "string"; + ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValue expectedValue = "string"; Assert.Equal(expectedField, model.Field); Assert.Equal(expectedValue, model.Value); @@ -2590,7 +2532,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadata + var model = new ExtensionItemAITasksTaskYesNoOnUnknownSetMetadata { Field = "field", Value = "string", @@ -2598,7 +2540,7 @@ public void SerializationRoundtrip_Works() string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -2609,7 +2551,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadata + var model = new ExtensionItemAITasksTaskYesNoOnUnknownSetMetadata { Field = "field", Value = "string", @@ -2617,15 +2559,14 @@ public void FieldRoundtripThroughSerialization_Works() string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); string expectedField = "field"; - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue expectedValue = - "string"; + ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValue expectedValue = "string"; Assert.Equal(expectedField, deserialized.Field); Assert.Equal(expectedValue, deserialized.Value); @@ -2634,7 +2575,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadata + var model = new ExtensionItemAITasksTaskYesNoOnUnknownSetMetadata { Field = "field", Value = "string", @@ -2646,50 +2587,46 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadata + var model = new ExtensionItemAITasksTaskYesNoOnUnknownSetMetadata { Field = "field", Value = "string", }; - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadata copied = new(model); + ExtensionItemAITasksTaskYesNoOnUnknownSetMetadata copied = new(model); Assert.Equal(model, copied); } } -public class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueTest : TestBase +public class ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValueTest : TestBase { [Fact] public void StringValidationWorks() { - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue value = "string"; + ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValue value = "string"; value.Validate(); } [Fact] public void DoubleValidationWorks() { - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue value = 0; + ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValue value = 0; value.Validate(); } [Fact] public void BoolValidationWorks() { - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue value = true; + ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValue value = true; value.Validate(); } [Fact] public void MixedValidationWorks() { - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue value = new( - [ - new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem( - "string" - ), - ] + ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValue value = new( + [new ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem("string")] ); value.Validate(); } @@ -2697,10 +2634,10 @@ public void MixedValidationWorks() [Fact] public void StringSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue value = "string"; + ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValue value = "string"; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -2711,10 +2648,10 @@ public void StringSerializationRoundtripWorks() [Fact] public void DoubleSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue value = 0; + ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValue value = 0; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -2725,10 +2662,10 @@ public void DoubleSerializationRoundtripWorks() [Fact] public void BoolSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue value = true; + ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValue value = true; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -2739,16 +2676,12 @@ public void BoolSerializationRoundtripWorks() [Fact] public void MixedSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue value = new( - [ - new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem( - "string" - ), - ] + ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValue value = new( + [new ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem("string")] ); string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -2757,41 +2690,36 @@ public void MixedSerializationRoundtripWorks() } } -public class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItemTest - : TestBase +public class ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItemTest : TestBase { [Fact] public void StringValidationWorks() { - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem value = - "string"; + ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem value = "string"; value.Validate(); } [Fact] public void DoubleValidationWorks() { - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem value = - 0; + ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem value = 0; value.Validate(); } [Fact] public void BoolValidationWorks() { - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem value = - true; + ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem value = true; value.Validate(); } [Fact] public void StringSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem value = - "string"; + ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem value = "string"; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -2802,11 +2730,10 @@ public void StringSerializationRoundtripWorks() [Fact] public void DoubleSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem value = - 0; + ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem value = 0; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -2817,11 +2744,10 @@ public void DoubleSerializationRoundtripWorks() [Fact] public void BoolSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem value = - true; + ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem value = true; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -2830,15 +2756,12 @@ public void BoolSerializationRoundtripWorks() } } -public class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownUnsetMetadataTest : TestBase +public class ExtensionItemAITasksTaskYesNoOnUnknownUnsetMetadataTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownUnsetMetadata - { - Field = "field", - }; + var model = new ExtensionItemAITasksTaskYesNoOnUnknownUnsetMetadata { Field = "field" }; string expectedField = "field"; @@ -2848,14 +2771,11 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownUnsetMetadata - { - Field = "field", - }; + var model = new ExtensionItemAITasksTaskYesNoOnUnknownUnsetMetadata { Field = "field" }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -2866,14 +2786,11 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownUnsetMetadata - { - Field = "field", - }; + var model = new ExtensionItemAITasksTaskYesNoOnUnknownUnsetMetadata { Field = "field" }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -2887,10 +2804,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownUnsetMetadata - { - Field = "field", - }; + var model = new ExtensionItemAITasksTaskYesNoOnUnknownUnsetMetadata { Field = "field" }; model.Validate(); } @@ -2898,23 +2812,20 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownUnsetMetadata - { - Field = "field", - }; + var model = new ExtensionItemAITasksTaskYesNoOnUnknownUnsetMetadata { Field = "field" }; - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownUnsetMetadata copied = new(model); + ExtensionItemAITasksTaskYesNoOnUnknownUnsetMetadata copied = new(model); Assert.Equal(model, copied); } } -public class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesTest : TestBase +public class ExtensionItemAITasksTaskYesNoOnYesTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYes + var model = new ExtensionItemAITasksTaskYesNoOnYes { AddTags = ["luxury", "premium"], RemoveTags = ["budget", "affordable"], @@ -2924,11 +2835,11 @@ public void FieldRoundtrip_Works() List expectedAddTags = ["luxury", "premium"]; List expectedRemoveTags = ["budget", "affordable"]; - List expectedSetMetadata = + List expectedSetMetadata = [ new() { Field = "price_range", Value = "premium" }, ]; - List expectedUnsetMetadata = + List expectedUnsetMetadata = [ new("price_range"), ]; @@ -2962,7 +2873,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYes + var model = new ExtensionItemAITasksTaskYesNoOnYes { AddTags = ["luxury", "premium"], RemoveTags = ["budget", "affordable"], @@ -2971,11 +2882,10 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -2983,7 +2893,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYes + var model = new ExtensionItemAITasksTaskYesNoOnYes { AddTags = ["luxury", "premium"], RemoveTags = ["budget", "affordable"], @@ -2992,20 +2902,19 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.NotNull(deserialized); List expectedAddTags = ["luxury", "premium"]; List expectedRemoveTags = ["budget", "affordable"]; - List expectedSetMetadata = + List expectedSetMetadata = [ new() { Field = "price_range", Value = "premium" }, ]; - List expectedUnsetMetadata = + List expectedUnsetMetadata = [ new("price_range"), ]; @@ -3039,7 +2948,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYes + var model = new ExtensionItemAITasksTaskYesNoOnYes { AddTags = ["luxury", "premium"], RemoveTags = ["budget", "affordable"], @@ -3053,7 +2962,7 @@ public void Validation_Works() [Fact] public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYes { }; + var model = new ExtensionItemAITasksTaskYesNoOnYes { }; Assert.Null(model.AddTags); Assert.False(model.RawData.ContainsKey("add_tags")); @@ -3068,7 +2977,7 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYes { }; + var model = new ExtensionItemAITasksTaskYesNoOnYes { }; model.Validate(); } @@ -3076,7 +2985,7 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYes + var model = new ExtensionItemAITasksTaskYesNoOnYes { // Null should be interpreted as omitted for these properties AddTags = null, @@ -3098,7 +3007,7 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYes + var model = new ExtensionItemAITasksTaskYesNoOnYes { // Null should be interpreted as omitted for these properties AddTags = null, @@ -3113,7 +3022,7 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYes + var model = new ExtensionItemAITasksTaskYesNoOnYes { AddTags = ["luxury", "premium"], RemoveTags = ["budget", "affordable"], @@ -3121,25 +3030,25 @@ public void CopyConstructor_Works() UnsetMetadata = [new("price_range")], }; - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYes copied = new(model); + ExtensionItemAITasksTaskYesNoOnYes copied = new(model); Assert.Equal(model, copied); } } -public class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataTest : TestBase +public class ExtensionItemAITasksTaskYesNoOnYesSetMetadataTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadata + var model = new ExtensionItemAITasksTaskYesNoOnYesSetMetadata { Field = "field", Value = "string", }; string expectedField = "field"; - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue expectedValue = "string"; + ExtensionItemAITasksTaskYesNoOnYesSetMetadataValue expectedValue = "string"; Assert.Equal(expectedField, model.Field); Assert.Equal(expectedValue, model.Value); @@ -3148,7 +3057,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadata + var model = new ExtensionItemAITasksTaskYesNoOnYesSetMetadata { Field = "field", Value = "string", @@ -3156,7 +3065,7 @@ public void SerializationRoundtrip_Works() string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -3167,7 +3076,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadata + var model = new ExtensionItemAITasksTaskYesNoOnYesSetMetadata { Field = "field", Value = "string", @@ -3175,14 +3084,14 @@ public void FieldRoundtripThroughSerialization_Works() string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); string expectedField = "field"; - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue expectedValue = "string"; + ExtensionItemAITasksTaskYesNoOnYesSetMetadataValue expectedValue = "string"; Assert.Equal(expectedField, deserialized.Field); Assert.Equal(expectedValue, deserialized.Value); @@ -3191,7 +3100,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadata + var model = new ExtensionItemAITasksTaskYesNoOnYesSetMetadata { Field = "field", Value = "string", @@ -3203,50 +3112,46 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadata + var model = new ExtensionItemAITasksTaskYesNoOnYesSetMetadata { Field = "field", Value = "string", }; - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadata copied = new(model); + ExtensionItemAITasksTaskYesNoOnYesSetMetadata copied = new(model); Assert.Equal(model, copied); } } -public class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueTest : TestBase +public class ExtensionItemAITasksTaskYesNoOnYesSetMetadataValueTest : TestBase { [Fact] public void StringValidationWorks() { - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue value = "string"; + ExtensionItemAITasksTaskYesNoOnYesSetMetadataValue value = "string"; value.Validate(); } [Fact] public void DoubleValidationWorks() { - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue value = 0; + ExtensionItemAITasksTaskYesNoOnYesSetMetadataValue value = 0; value.Validate(); } [Fact] public void BoolValidationWorks() { - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue value = true; + ExtensionItemAITasksTaskYesNoOnYesSetMetadataValue value = true; value.Validate(); } [Fact] public void MixedValidationWorks() { - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue value = new( - [ - new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem( - "string" - ), - ] + ExtensionItemAITasksTaskYesNoOnYesSetMetadataValue value = new( + [new ExtensionItemAITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem("string")] ); value.Validate(); } @@ -3254,10 +3159,10 @@ public void MixedValidationWorks() [Fact] public void StringSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue value = "string"; + ExtensionItemAITasksTaskYesNoOnYesSetMetadataValue value = "string"; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -3268,10 +3173,10 @@ public void StringSerializationRoundtripWorks() [Fact] public void DoubleSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue value = 0; + ExtensionItemAITasksTaskYesNoOnYesSetMetadataValue value = 0; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -3282,10 +3187,10 @@ public void DoubleSerializationRoundtripWorks() [Fact] public void BoolSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue value = true; + ExtensionItemAITasksTaskYesNoOnYesSetMetadataValue value = true; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -3296,16 +3201,12 @@ public void BoolSerializationRoundtripWorks() [Fact] public void MixedSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue value = new( - [ - new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem( - "string" - ), - ] + ExtensionItemAITasksTaskYesNoOnYesSetMetadataValue value = new( + [new ExtensionItemAITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem("string")] ); string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -3314,41 +3215,36 @@ public void MixedSerializationRoundtripWorks() } } -public class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItemTest - : TestBase +public class ExtensionItemAITasksTaskYesNoOnYesSetMetadataValueMetadataValueItemTest : TestBase { [Fact] public void StringValidationWorks() { - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem value = - "string"; + ExtensionItemAITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem value = "string"; value.Validate(); } [Fact] public void DoubleValidationWorks() { - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem value = - 0; + ExtensionItemAITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem value = 0; value.Validate(); } [Fact] public void BoolValidationWorks() { - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem value = - true; + ExtensionItemAITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem value = true; value.Validate(); } [Fact] public void StringSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem value = - "string"; + ExtensionItemAITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem value = "string"; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -3359,11 +3255,10 @@ public void StringSerializationRoundtripWorks() [Fact] public void DoubleSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem value = - 0; + ExtensionItemAITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem value = 0; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -3374,11 +3269,10 @@ public void DoubleSerializationRoundtripWorks() [Fact] public void BoolSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem value = - true; + ExtensionItemAITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem value = true; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -3387,15 +3281,12 @@ public void BoolSerializationRoundtripWorks() } } -public class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesUnsetMetadataTest : TestBase +public class ExtensionItemAITasksTaskYesNoOnYesUnsetMetadataTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesUnsetMetadata - { - Field = "field", - }; + var model = new ExtensionItemAITasksTaskYesNoOnYesUnsetMetadata { Field = "field" }; string expectedField = "field"; @@ -3405,14 +3296,11 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesUnsetMetadata - { - Field = "field", - }; + var model = new ExtensionItemAITasksTaskYesNoOnYesUnsetMetadata { Field = "field" }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -3423,14 +3311,11 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesUnsetMetadata - { - Field = "field", - }; + var model = new ExtensionItemAITasksTaskYesNoOnYesUnsetMetadata { Field = "field" }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -3444,10 +3329,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesUnsetMetadata - { - Field = "field", - }; + var model = new ExtensionItemAITasksTaskYesNoOnYesUnsetMetadata { Field = "field" }; model.Validate(); } @@ -3455,12 +3337,9 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesUnsetMetadata - { - Field = "field", - }; + var model = new ExtensionItemAITasksTaskYesNoOnYesUnsetMetadata { Field = "field" }; - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesUnsetMetadata copied = new(model); + ExtensionItemAITasksTaskYesNoOnYesUnsetMetadata copied = new(model); Assert.Equal(model, copied); } diff --git a/src/Imagekit.Tests/Models/Files/FileTest.cs b/src/Imagekit.Tests/Models/Files/FileTest.cs index c547d86c..40155136 100644 --- a/src/Imagekit.Tests/Models/Files/FileTest.cs +++ b/src/Imagekit.Tests/Models/Files/FileTest.cs @@ -55,9 +55,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -123,9 +123,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -256,9 +256,9 @@ public void SerializationRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -338,9 +338,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -413,9 +413,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -546,9 +546,9 @@ public void Validation_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -848,9 +848,9 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -918,9 +918,9 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -983,9 +983,9 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -1057,9 +1057,9 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -1136,9 +1136,9 @@ public void CopyConstructor_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -1328,9 +1328,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -1346,9 +1346,9 @@ public void FieldRoundtrip_Works() ApiEnum expectedType = Files::Type.Text; Files::DefaultValue expectedDefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ); bool expectedIsValueRequired = true; @@ -1393,9 +1393,9 @@ public void SerializationRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -1425,9 +1425,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -1450,9 +1450,9 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum expectedType = Files::Type.Text; Files::DefaultValue expectedDefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ); bool expectedIsValueRequired = true; @@ -1497,9 +1497,9 @@ public void Validation_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -1617,9 +1617,9 @@ public void CopyConstructor_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -1734,9 +1734,9 @@ public void MixedValidationWorks() { Files::DefaultValue value = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ); value.Validate(); @@ -1786,9 +1786,9 @@ public void MixedSerializationRoundtripWorks() { Files::DefaultValue value = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ); string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -1801,35 +1801,35 @@ public void MixedSerializationRoundtripWorks() } } -public class UnnamedSchemaWithArrayParent1Test : TestBase +public class UnnamedSchemaWithArrayParent0Test : TestBase { [Fact] public void StringValidationWorks() { - Files::UnnamedSchemaWithArrayParent1 value = "string"; + Files::UnnamedSchemaWithArrayParent0 value = "string"; value.Validate(); } [Fact] public void DoubleValidationWorks() { - Files::UnnamedSchemaWithArrayParent1 value = 0; + Files::UnnamedSchemaWithArrayParent0 value = 0; value.Validate(); } [Fact] public void BoolValidationWorks() { - Files::UnnamedSchemaWithArrayParent1 value = true; + Files::UnnamedSchemaWithArrayParent0 value = true; value.Validate(); } [Fact] public void StringSerializationRoundtripWorks() { - Files::UnnamedSchemaWithArrayParent1 value = "string"; + Files::UnnamedSchemaWithArrayParent0 value = "string"; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -1840,9 +1840,9 @@ public void StringSerializationRoundtripWorks() [Fact] public void DoubleSerializationRoundtripWorks() { - Files::UnnamedSchemaWithArrayParent1 value = 0; + Files::UnnamedSchemaWithArrayParent0 value = 0; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -1853,9 +1853,9 @@ public void DoubleSerializationRoundtripWorks() [Fact] public void BoolSerializationRoundtripWorks() { - Files::UnnamedSchemaWithArrayParent1 value = true; + Files::UnnamedSchemaWithArrayParent0 value = true; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); diff --git a/src/Imagekit.Tests/Models/Files/FileUpdateParamsTest.cs b/src/Imagekit.Tests/Models/Files/FileUpdateParamsTest.cs index 9e31447f..c78b95f8 100644 --- a/src/Imagekit.Tests/Models/Files/FileUpdateParamsTest.cs +++ b/src/Imagekit.Tests/Models/Files/FileUpdateParamsTest.cs @@ -25,7 +25,7 @@ public void FieldRoundtrip_Works() Description = "description", Extensions = [ - new UnnamedSchemaWithArrayParent0RemoveBg() + new ExtensionItemRemoveBg() { Options = new() { @@ -35,23 +35,22 @@ public void FieldRoundtrip_Works() Semitransparency = true, }, }, - new UnnamedSchemaWithArrayParent0AutoTaggingExtension() + new ExtensionItemAutoTaggingExtension() { MaxTags = 10, MinConfidence = 80, - Name = - UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + Name = ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, }, - new UnnamedSchemaWithArrayParent0AutoTaggingExtension() + new ExtensionItemAutoTaggingExtension() { MaxTags = 10, MinConfidence = 80, - Name = UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.AwsAutoTagging, + Name = ExtensionItemAutoTaggingExtensionName.AwsAutoTagging, }, - new UnnamedSchemaWithArrayParent0AIAutoDescription(), - new UnnamedSchemaWithArrayParent0AITasks( + new ExtensionItemAIAutoDescription(), + new ExtensionItemAITasks( [ - new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + new ExtensionItemAITasksTaskSelectTags() { Instruction = "What types of clothing items are visible?", MaxSelections = 1, @@ -80,7 +79,7 @@ public void FieldRoundtrip_Works() Description = "description", Extensions = [ - new UnnamedSchemaWithArrayParent0RemoveBg() + new ExtensionItemRemoveBg() { Options = new() { @@ -90,22 +89,22 @@ public void FieldRoundtrip_Works() Semitransparency = true, }, }, - new UnnamedSchemaWithArrayParent0AutoTaggingExtension() + new ExtensionItemAutoTaggingExtension() { MaxTags = 10, MinConfidence = 80, - Name = UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + Name = ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, }, - new UnnamedSchemaWithArrayParent0AutoTaggingExtension() + new ExtensionItemAutoTaggingExtension() { MaxTags = 10, MinConfidence = 80, - Name = UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.AwsAutoTagging, + Name = ExtensionItemAutoTaggingExtensionName.AwsAutoTagging, }, - new UnnamedSchemaWithArrayParent0AIAutoDescription(), - new UnnamedSchemaWithArrayParent0AITasks( + new ExtensionItemAIAutoDescription(), + new ExtensionItemAITasks( [ - new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + new ExtensionItemAITasksTaskSelectTags() { Instruction = "What types of clothing items are visible?", MaxSelections = 1, @@ -142,7 +141,7 @@ public void Url_Works() Description = "description", Extensions = [ - new UnnamedSchemaWithArrayParent0RemoveBg() + new ExtensionItemRemoveBg() { Options = new() { @@ -152,23 +151,22 @@ public void Url_Works() Semitransparency = true, }, }, - new UnnamedSchemaWithArrayParent0AutoTaggingExtension() + new ExtensionItemAutoTaggingExtension() { MaxTags = 10, MinConfidence = 80, - Name = - UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + Name = ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, }, - new UnnamedSchemaWithArrayParent0AutoTaggingExtension() + new ExtensionItemAutoTaggingExtension() { MaxTags = 10, MinConfidence = 80, - Name = UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.AwsAutoTagging, + Name = ExtensionItemAutoTaggingExtensionName.AwsAutoTagging, }, - new UnnamedSchemaWithArrayParent0AIAutoDescription(), - new UnnamedSchemaWithArrayParent0AITasks( + new ExtensionItemAIAutoDescription(), + new ExtensionItemAITasks( [ - new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + new ExtensionItemAITasksTaskSelectTags() { Instruction = "What types of clothing items are visible?", MaxSelections = 1, @@ -209,7 +207,7 @@ public void CopyConstructor_Works() Description = "description", Extensions = [ - new UnnamedSchemaWithArrayParent0RemoveBg() + new ExtensionItemRemoveBg() { Options = new() { @@ -219,23 +217,22 @@ public void CopyConstructor_Works() Semitransparency = true, }, }, - new UnnamedSchemaWithArrayParent0AutoTaggingExtension() + new ExtensionItemAutoTaggingExtension() { MaxTags = 10, MinConfidence = 80, - Name = - UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + Name = ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, }, - new UnnamedSchemaWithArrayParent0AutoTaggingExtension() + new ExtensionItemAutoTaggingExtension() { MaxTags = 10, MinConfidence = 80, - Name = UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.AwsAutoTagging, + Name = ExtensionItemAutoTaggingExtensionName.AwsAutoTagging, }, - new UnnamedSchemaWithArrayParent0AIAutoDescription(), - new UnnamedSchemaWithArrayParent0AITasks( + new ExtensionItemAIAutoDescription(), + new ExtensionItemAITasks( [ - new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + new ExtensionItemAITasksTaskSelectTags() { Instruction = "What types of clothing items are visible?", MaxSelections = 1, diff --git a/src/Imagekit.Tests/Models/Files/FileUpdateResponseTest.cs b/src/Imagekit.Tests/Models/Files/FileUpdateResponseTest.cs index cca76654..fedb1152 100644 --- a/src/Imagekit.Tests/Models/Files/FileUpdateResponseTest.cs +++ b/src/Imagekit.Tests/Models/Files/FileUpdateResponseTest.cs @@ -55,9 +55,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -131,9 +131,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -273,9 +273,9 @@ public void SerializationRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -363,9 +363,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -446,9 +446,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -588,9 +588,9 @@ public void Validation_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -904,9 +904,9 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -982,9 +982,9 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -1055,9 +1055,9 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -1137,9 +1137,9 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -1224,9 +1224,9 @@ public void CopyConstructor_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, diff --git a/src/Imagekit.Tests/Models/Files/FileUploadParamsTest.cs b/src/Imagekit.Tests/Models/Files/FileUploadParamsTest.cs index 87787329..452e8d79 100644 --- a/src/Imagekit.Tests/Models/Files/FileUploadParamsTest.cs +++ b/src/Imagekit.Tests/Models/Files/FileUploadParamsTest.cs @@ -32,7 +32,7 @@ public void FieldRoundtrip_Works() Expire = 0, Extensions = [ - new Models::UnnamedSchemaWithArrayParent0RemoveBg() + new Models::ExtensionItemRemoveBg() { Options = new() { @@ -42,24 +42,23 @@ public void FieldRoundtrip_Works() Semitransparency = true, }, }, - new Models::UnnamedSchemaWithArrayParent0AutoTaggingExtension() + new Models::ExtensionItemAutoTaggingExtension() { MaxTags = 5, MinConfidence = 95, - Name = - Models::UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + Name = Models::ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, }, - new Models::UnnamedSchemaWithArrayParent0AIAutoDescription(), - new Models::UnnamedSchemaWithArrayParent0AITasks( + new Models::ExtensionItemAIAutoDescription(), + new Models::ExtensionItemAITasks( [ - new Models::UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + new Models::ExtensionItemAITasksTaskSelectTags() { Instruction = "What types of clothing items are visible in this image?", MaxSelections = 1, MinSelections = 0, Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], }, - new Models::UnnamedSchemaWithArrayParent0AITasksTaskYesNo() + new Models::ExtensionItemAITasksTaskYesNo() { Instruction = "Is this a luxury or high-end fashion item?", OnNo = new() @@ -129,9 +128,9 @@ public void FieldRoundtrip_Works() }; string expectedDescription = "Running shoes"; long expectedExpire = 0; - List expectedExtensions = + List expectedExtensions = [ - new Models::UnnamedSchemaWithArrayParent0RemoveBg() + new Models::ExtensionItemRemoveBg() { Options = new() { @@ -141,24 +140,23 @@ public void FieldRoundtrip_Works() Semitransparency = true, }, }, - new Models::UnnamedSchemaWithArrayParent0AutoTaggingExtension() + new Models::ExtensionItemAutoTaggingExtension() { MaxTags = 5, MinConfidence = 95, - Name = - Models::UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + Name = Models::ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, }, - new Models::UnnamedSchemaWithArrayParent0AIAutoDescription(), - new Models::UnnamedSchemaWithArrayParent0AITasks( + new Models::ExtensionItemAIAutoDescription(), + new Models::ExtensionItemAITasks( [ - new Models::UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + new Models::ExtensionItemAITasksTaskSelectTags() { Instruction = "What types of clothing items are visible in this image?", MaxSelections = 1, MinSelections = 0, Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], }, - new Models::UnnamedSchemaWithArrayParent0AITasksTaskYesNo() + new Models::ExtensionItemAITasksTaskYesNo() { Instruction = "Is this a luxury or high-end fashion item?", OnNo = new() @@ -426,7 +424,7 @@ public void CopyConstructor_Works() Expire = 0, Extensions = [ - new Models::UnnamedSchemaWithArrayParent0RemoveBg() + new Models::ExtensionItemRemoveBg() { Options = new() { @@ -436,24 +434,23 @@ public void CopyConstructor_Works() Semitransparency = true, }, }, - new Models::UnnamedSchemaWithArrayParent0AutoTaggingExtension() + new Models::ExtensionItemAutoTaggingExtension() { MaxTags = 5, MinConfidence = 95, - Name = - Models::UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + Name = Models::ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, }, - new Models::UnnamedSchemaWithArrayParent0AIAutoDescription(), - new Models::UnnamedSchemaWithArrayParent0AITasks( + new Models::ExtensionItemAIAutoDescription(), + new Models::ExtensionItemAITasks( [ - new Models::UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + new Models::ExtensionItemAITasksTaskSelectTags() { Instruction = "What types of clothing items are visible in this image?", MaxSelections = 1, MinSelections = 0, Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], }, - new Models::UnnamedSchemaWithArrayParent0AITasksTaskYesNo() + new Models::ExtensionItemAITasksTaskYesNo() { Instruction = "Is this a luxury or high-end fashion item?", OnNo = new() diff --git a/src/Imagekit.Tests/Models/Files/FileUploadResponseTest.cs b/src/Imagekit.Tests/Models/Files/FileUploadResponseTest.cs index 1e5b87f4..803e90cf 100644 --- a/src/Imagekit.Tests/Models/Files/FileUploadResponseTest.cs +++ b/src/Imagekit.Tests/Models/Files/FileUploadResponseTest.cs @@ -143,9 +143,9 @@ public void FieldRoundtrip_Works() Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new UnnamedSchemaWithArrayParent1(true), + new UnnamedSchemaWithArrayParent1(10), + new UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -298,9 +298,9 @@ public void FieldRoundtrip_Works() Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new UnnamedSchemaWithArrayParent1(true), + new UnnamedSchemaWithArrayParent1(10), + new UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -515,9 +515,9 @@ public void SerializationRoundtrip_Works() Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new UnnamedSchemaWithArrayParent1(true), + new UnnamedSchemaWithArrayParent1(10), + new UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -684,9 +684,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new UnnamedSchemaWithArrayParent1(true), + new UnnamedSchemaWithArrayParent1(10), + new UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -846,9 +846,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new UnnamedSchemaWithArrayParent1(true), + new UnnamedSchemaWithArrayParent1(10), + new UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -1063,9 +1063,9 @@ public void Validation_Works() Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new UnnamedSchemaWithArrayParent1(true), + new UnnamedSchemaWithArrayParent1(10), + new UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -1434,9 +1434,9 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new UnnamedSchemaWithArrayParent1(true), + new UnnamedSchemaWithArrayParent1(10), + new UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -1591,9 +1591,9 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new UnnamedSchemaWithArrayParent1(true), + new UnnamedSchemaWithArrayParent1(10), + new UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -1743,9 +1743,9 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new UnnamedSchemaWithArrayParent1(true), + new UnnamedSchemaWithArrayParent1(10), + new UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -1904,9 +1904,9 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new UnnamedSchemaWithArrayParent1(true), + new UnnamedSchemaWithArrayParent1(10), + new UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -2070,9 +2070,9 @@ public void CopyConstructor_Works() Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new UnnamedSchemaWithArrayParent1(true), + new UnnamedSchemaWithArrayParent1(10), + new UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -2743,9 +2743,9 @@ public void FieldRoundtrip_Works() Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new UnnamedSchemaWithArrayParent1(true), + new UnnamedSchemaWithArrayParent1(10), + new UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -2762,9 +2762,9 @@ public void FieldRoundtrip_Works() FileUploadResponseSelectedFieldsSchemaItemType.Text; FileUploadResponseSelectedFieldsSchemaItemDefaultValue expectedDefaultValue = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new UnnamedSchemaWithArrayParent1(true), + new UnnamedSchemaWithArrayParent1(10), + new UnnamedSchemaWithArrayParent1("Hello"), ] ); bool expectedIsValueRequired = true; @@ -2809,9 +2809,9 @@ public void SerializationRoundtrip_Works() Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new UnnamedSchemaWithArrayParent1(true), + new UnnamedSchemaWithArrayParent1(10), + new UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -2841,9 +2841,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new UnnamedSchemaWithArrayParent1(true), + new UnnamedSchemaWithArrayParent1(10), + new UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -2867,9 +2867,9 @@ public void FieldRoundtripThroughSerialization_Works() FileUploadResponseSelectedFieldsSchemaItemType.Text; FileUploadResponseSelectedFieldsSchemaItemDefaultValue expectedDefaultValue = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new UnnamedSchemaWithArrayParent1(true), + new UnnamedSchemaWithArrayParent1(10), + new UnnamedSchemaWithArrayParent1("Hello"), ] ); bool expectedIsValueRequired = true; @@ -2914,9 +2914,9 @@ public void Validation_Works() Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new UnnamedSchemaWithArrayParent1(true), + new UnnamedSchemaWithArrayParent1(10), + new UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -3040,9 +3040,9 @@ public void CopyConstructor_Works() Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new UnnamedSchemaWithArrayParent1(true), + new UnnamedSchemaWithArrayParent1(10), + new UnnamedSchemaWithArrayParent1("Hello"), ] ), IsValueRequired = true, @@ -3155,9 +3155,9 @@ public void MixedValidationWorks() { FileUploadResponseSelectedFieldsSchemaItemDefaultValue value = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new UnnamedSchemaWithArrayParent1(true), + new UnnamedSchemaWithArrayParent1(10), + new UnnamedSchemaWithArrayParent1("Hello"), ] ); value.Validate(); @@ -3210,9 +3210,9 @@ public void MixedSerializationRoundtripWorks() { FileUploadResponseSelectedFieldsSchemaItemDefaultValue value = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new UnnamedSchemaWithArrayParent1(true), + new UnnamedSchemaWithArrayParent1(10), + new UnnamedSchemaWithArrayParent1("Hello"), ] ); string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3226,35 +3226,35 @@ public void MixedSerializationRoundtripWorks() } } -public class UnnamedSchemaWithArrayParent2Test : TestBase +public class UnnamedSchemaWithArrayParent1Test : TestBase { [Fact] public void StringValidationWorks() { - UnnamedSchemaWithArrayParent2 value = "string"; + UnnamedSchemaWithArrayParent1 value = "string"; value.Validate(); } [Fact] public void DoubleValidationWorks() { - UnnamedSchemaWithArrayParent2 value = 0; + UnnamedSchemaWithArrayParent1 value = 0; value.Validate(); } [Fact] public void BoolValidationWorks() { - UnnamedSchemaWithArrayParent2 value = true; + UnnamedSchemaWithArrayParent1 value = true; value.Validate(); } [Fact] public void StringSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent2 value = "string"; + UnnamedSchemaWithArrayParent1 value = "string"; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -3265,9 +3265,9 @@ public void StringSerializationRoundtripWorks() [Fact] public void DoubleSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent2 value = 0; + UnnamedSchemaWithArrayParent1 value = 0; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -3278,9 +3278,9 @@ public void DoubleSerializationRoundtripWorks() [Fact] public void BoolSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent2 value = true; + UnnamedSchemaWithArrayParent1 value = true; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); diff --git a/src/Imagekit.Tests/Models/Files/UpdateFileRequestTest.cs b/src/Imagekit.Tests/Models/Files/UpdateFileRequestTest.cs index fd3e8a16..8264215d 100644 --- a/src/Imagekit.Tests/Models/Files/UpdateFileRequestTest.cs +++ b/src/Imagekit.Tests/Models/Files/UpdateFileRequestTest.cs @@ -2,8 +2,8 @@ using System.Text.Json; using Imagekit.Core; using Imagekit.Exceptions; -using Imagekit.Models; -using Files = Imagekit.Models.Files; +using Imagekit.Models.Files; +using Models = Imagekit.Models; namespace Imagekit.Tests.Models.Files; @@ -12,7 +12,7 @@ public class UpdateFileRequestTest : TestBase [Fact] public void DetailsValidationWorks() { - Files::UpdateFileRequest value = new Files::UpdateFileDetails() + UpdateFileRequest value = new UpdateFileDetails() { CustomCoordinates = "customCoordinates", CustomMetadata = new Dictionary() @@ -22,7 +22,7 @@ public void DetailsValidationWorks() Description = "description", Extensions = [ - new UnnamedSchemaWithArrayParent0RemoveBg() + new Models::ExtensionItemRemoveBg() { Options = new() { @@ -32,23 +32,23 @@ public void DetailsValidationWorks() Semitransparency = true, }, }, - new UnnamedSchemaWithArrayParent0AutoTaggingExtension() + new Models::ExtensionItemAutoTaggingExtension() { MaxTags = 5, MinConfidence = 95, - Name = UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + Name = Models::ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, }, - new UnnamedSchemaWithArrayParent0AIAutoDescription(), - new UnnamedSchemaWithArrayParent0AITasks( + new Models::ExtensionItemAIAutoDescription(), + new Models::ExtensionItemAITasks( [ - new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + new Models::ExtensionItemAITasksTaskSelectTags() { Instruction = "What types of clothing items are visible in this image?", MaxSelections = 1, MinSelections = 0, Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], }, - new UnnamedSchemaWithArrayParent0AITasksTaskYesNo() + new Models::ExtensionItemAITasksTaskYesNo() { Instruction = "Is this a luxury or high-end fashion item?", OnNo = new() @@ -75,9 +75,9 @@ public void DetailsValidationWorks() }, ] ), - new SavedExtension("ext_abc123"), + new Models::SavedExtension("ext_abc123"), ], - RemoveAITags = new Files::UnionMember1(), + RemoveAITags = new UnionMember1(), Tags = ["tag1", "tag2"], WebhookUrl = "https://example.com", }; @@ -87,7 +87,7 @@ public void DetailsValidationWorks() [Fact] public void ChangePublicationStatusValidationWorks() { - Files::UpdateFileRequest value = new Files::ChangePublicationStatus() + UpdateFileRequest value = new ChangePublicationStatus() { Publish = new() { IsPublished = true, IncludeFileVersions = true }, }; @@ -97,7 +97,7 @@ public void ChangePublicationStatusValidationWorks() [Fact] public void DetailsSerializationRoundtripWorks() { - Files::UpdateFileRequest value = new Files::UpdateFileDetails() + UpdateFileRequest value = new UpdateFileDetails() { CustomCoordinates = "customCoordinates", CustomMetadata = new Dictionary() @@ -107,7 +107,7 @@ public void DetailsSerializationRoundtripWorks() Description = "description", Extensions = [ - new UnnamedSchemaWithArrayParent0RemoveBg() + new Models::ExtensionItemRemoveBg() { Options = new() { @@ -117,23 +117,23 @@ public void DetailsSerializationRoundtripWorks() Semitransparency = true, }, }, - new UnnamedSchemaWithArrayParent0AutoTaggingExtension() + new Models::ExtensionItemAutoTaggingExtension() { MaxTags = 5, MinConfidence = 95, - Name = UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + Name = Models::ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, }, - new UnnamedSchemaWithArrayParent0AIAutoDescription(), - new UnnamedSchemaWithArrayParent0AITasks( + new Models::ExtensionItemAIAutoDescription(), + new Models::ExtensionItemAITasks( [ - new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + new Models::ExtensionItemAITasksTaskSelectTags() { Instruction = "What types of clothing items are visible in this image?", MaxSelections = 1, MinSelections = 0, Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], }, - new UnnamedSchemaWithArrayParent0AITasksTaskYesNo() + new Models::ExtensionItemAITasksTaskYesNo() { Instruction = "Is this a luxury or high-end fashion item?", OnNo = new() @@ -160,14 +160,14 @@ public void DetailsSerializationRoundtripWorks() }, ] ), - new SavedExtension("ext_abc123"), + new Models::SavedExtension("ext_abc123"), ], - RemoveAITags = new Files::UnionMember1(), + RemoveAITags = new UnionMember1(), Tags = ["tag1", "tag2"], WebhookUrl = "https://example.com", }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -178,12 +178,12 @@ public void DetailsSerializationRoundtripWorks() [Fact] public void ChangePublicationStatusSerializationRoundtripWorks() { - Files::UpdateFileRequest value = new Files::ChangePublicationStatus() + UpdateFileRequest value = new ChangePublicationStatus() { Publish = new() { IsPublished = true, IncludeFileVersions = true }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -197,7 +197,7 @@ public class UpdateFileDetailsTest : TestBase [Fact] public void FieldRoundtrip_Works() { - var model = new Files::UpdateFileDetails + var model = new UpdateFileDetails { CustomCoordinates = "customCoordinates", CustomMetadata = new Dictionary() @@ -207,7 +207,7 @@ public void FieldRoundtrip_Works() Description = "description", Extensions = [ - new UnnamedSchemaWithArrayParent0RemoveBg() + new Models::ExtensionItemRemoveBg() { Options = new() { @@ -217,23 +217,23 @@ public void FieldRoundtrip_Works() Semitransparency = true, }, }, - new UnnamedSchemaWithArrayParent0AutoTaggingExtension() + new Models::ExtensionItemAutoTaggingExtension() { MaxTags = 5, MinConfidence = 95, - Name = UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + Name = Models::ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, }, - new UnnamedSchemaWithArrayParent0AIAutoDescription(), - new UnnamedSchemaWithArrayParent0AITasks( + new Models::ExtensionItemAIAutoDescription(), + new Models::ExtensionItemAITasks( [ - new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + new Models::ExtensionItemAITasksTaskSelectTags() { Instruction = "What types of clothing items are visible in this image?", MaxSelections = 1, MinSelections = 0, Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], }, - new UnnamedSchemaWithArrayParent0AITasksTaskYesNo() + new Models::ExtensionItemAITasksTaskYesNo() { Instruction = "Is this a luxury or high-end fashion item?", OnNo = new() @@ -260,9 +260,9 @@ public void FieldRoundtrip_Works() }, ] ), - new SavedExtension("ext_abc123"), + new Models::SavedExtension("ext_abc123"), ], - RemoveAITags = new Files::UnionMember1(), + RemoveAITags = new UnionMember1(), Tags = ["tag1", "tag2"], WebhookUrl = "https://example.com", }; @@ -273,9 +273,9 @@ public void FieldRoundtrip_Works() { "foo", JsonSerializer.SerializeToElement("bar") }, }; string expectedDescription = "description"; - List expectedExtensions = + List expectedExtensions = [ - new UnnamedSchemaWithArrayParent0RemoveBg() + new Models::ExtensionItemRemoveBg() { Options = new() { @@ -285,23 +285,23 @@ public void FieldRoundtrip_Works() Semitransparency = true, }, }, - new UnnamedSchemaWithArrayParent0AutoTaggingExtension() + new Models::ExtensionItemAutoTaggingExtension() { MaxTags = 5, MinConfidence = 95, - Name = UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + Name = Models::ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, }, - new UnnamedSchemaWithArrayParent0AIAutoDescription(), - new UnnamedSchemaWithArrayParent0AITasks( + new Models::ExtensionItemAIAutoDescription(), + new Models::ExtensionItemAITasks( [ - new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + new Models::ExtensionItemAITasksTaskSelectTags() { Instruction = "What types of clothing items are visible in this image?", MaxSelections = 1, MinSelections = 0, Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], }, - new UnnamedSchemaWithArrayParent0AITasksTaskYesNo() + new Models::ExtensionItemAITasksTaskYesNo() { Instruction = "Is this a luxury or high-end fashion item?", OnNo = new() @@ -328,9 +328,9 @@ public void FieldRoundtrip_Works() }, ] ), - new SavedExtension("ext_abc123"), + new Models::SavedExtension("ext_abc123"), ]; - Files::RemoveAITags expectedRemoveAITags = new Files::UnionMember1(); + RemoveAITags expectedRemoveAITags = new UnionMember1(); List expectedTags = ["tag1", "tag2"]; string expectedWebhookUrl = "https://example.com"; @@ -363,7 +363,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Files::UpdateFileDetails + var model = new UpdateFileDetails { CustomCoordinates = "customCoordinates", CustomMetadata = new Dictionary() @@ -373,7 +373,7 @@ public void SerializationRoundtrip_Works() Description = "description", Extensions = [ - new UnnamedSchemaWithArrayParent0RemoveBg() + new Models::ExtensionItemRemoveBg() { Options = new() { @@ -383,23 +383,23 @@ public void SerializationRoundtrip_Works() Semitransparency = true, }, }, - new UnnamedSchemaWithArrayParent0AutoTaggingExtension() + new Models::ExtensionItemAutoTaggingExtension() { MaxTags = 5, MinConfidence = 95, - Name = UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + Name = Models::ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, }, - new UnnamedSchemaWithArrayParent0AIAutoDescription(), - new UnnamedSchemaWithArrayParent0AITasks( + new Models::ExtensionItemAIAutoDescription(), + new Models::ExtensionItemAITasks( [ - new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + new Models::ExtensionItemAITasksTaskSelectTags() { Instruction = "What types of clothing items are visible in this image?", MaxSelections = 1, MinSelections = 0, Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], }, - new UnnamedSchemaWithArrayParent0AITasksTaskYesNo() + new Models::ExtensionItemAITasksTaskYesNo() { Instruction = "Is this a luxury or high-end fashion item?", OnNo = new() @@ -426,15 +426,15 @@ public void SerializationRoundtrip_Works() }, ] ), - new SavedExtension("ext_abc123"), + new Models::SavedExtension("ext_abc123"), ], - RemoveAITags = new Files::UnionMember1(), + RemoveAITags = new UnionMember1(), Tags = ["tag1", "tag2"], WebhookUrl = "https://example.com", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -445,7 +445,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Files::UpdateFileDetails + var model = new UpdateFileDetails { CustomCoordinates = "customCoordinates", CustomMetadata = new Dictionary() @@ -455,7 +455,7 @@ public void FieldRoundtripThroughSerialization_Works() Description = "description", Extensions = [ - new UnnamedSchemaWithArrayParent0RemoveBg() + new Models::ExtensionItemRemoveBg() { Options = new() { @@ -465,23 +465,23 @@ public void FieldRoundtripThroughSerialization_Works() Semitransparency = true, }, }, - new UnnamedSchemaWithArrayParent0AutoTaggingExtension() + new Models::ExtensionItemAutoTaggingExtension() { MaxTags = 5, MinConfidence = 95, - Name = UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + Name = Models::ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, }, - new UnnamedSchemaWithArrayParent0AIAutoDescription(), - new UnnamedSchemaWithArrayParent0AITasks( + new Models::ExtensionItemAIAutoDescription(), + new Models::ExtensionItemAITasks( [ - new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + new Models::ExtensionItemAITasksTaskSelectTags() { Instruction = "What types of clothing items are visible in this image?", MaxSelections = 1, MinSelections = 0, Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], }, - new UnnamedSchemaWithArrayParent0AITasksTaskYesNo() + new Models::ExtensionItemAITasksTaskYesNo() { Instruction = "Is this a luxury or high-end fashion item?", OnNo = new() @@ -508,15 +508,15 @@ public void FieldRoundtripThroughSerialization_Works() }, ] ), - new SavedExtension("ext_abc123"), + new Models::SavedExtension("ext_abc123"), ], - RemoveAITags = new Files::UnionMember1(), + RemoveAITags = new UnionMember1(), Tags = ["tag1", "tag2"], WebhookUrl = "https://example.com", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -528,9 +528,9 @@ public void FieldRoundtripThroughSerialization_Works() { "foo", JsonSerializer.SerializeToElement("bar") }, }; string expectedDescription = "description"; - List expectedExtensions = + List expectedExtensions = [ - new UnnamedSchemaWithArrayParent0RemoveBg() + new Models::ExtensionItemRemoveBg() { Options = new() { @@ -540,23 +540,23 @@ public void FieldRoundtripThroughSerialization_Works() Semitransparency = true, }, }, - new UnnamedSchemaWithArrayParent0AutoTaggingExtension() + new Models::ExtensionItemAutoTaggingExtension() { MaxTags = 5, MinConfidence = 95, - Name = UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + Name = Models::ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, }, - new UnnamedSchemaWithArrayParent0AIAutoDescription(), - new UnnamedSchemaWithArrayParent0AITasks( + new Models::ExtensionItemAIAutoDescription(), + new Models::ExtensionItemAITasks( [ - new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + new Models::ExtensionItemAITasksTaskSelectTags() { Instruction = "What types of clothing items are visible in this image?", MaxSelections = 1, MinSelections = 0, Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], }, - new UnnamedSchemaWithArrayParent0AITasksTaskYesNo() + new Models::ExtensionItemAITasksTaskYesNo() { Instruction = "Is this a luxury or high-end fashion item?", OnNo = new() @@ -583,9 +583,9 @@ public void FieldRoundtripThroughSerialization_Works() }, ] ), - new SavedExtension("ext_abc123"), + new Models::SavedExtension("ext_abc123"), ]; - Files::RemoveAITags expectedRemoveAITags = new Files::UnionMember1(); + RemoveAITags expectedRemoveAITags = new UnionMember1(); List expectedTags = ["tag1", "tag2"]; string expectedWebhookUrl = "https://example.com"; @@ -618,7 +618,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Files::UpdateFileDetails + var model = new UpdateFileDetails { CustomCoordinates = "customCoordinates", CustomMetadata = new Dictionary() @@ -628,7 +628,7 @@ public void Validation_Works() Description = "description", Extensions = [ - new UnnamedSchemaWithArrayParent0RemoveBg() + new Models::ExtensionItemRemoveBg() { Options = new() { @@ -638,23 +638,23 @@ public void Validation_Works() Semitransparency = true, }, }, - new UnnamedSchemaWithArrayParent0AutoTaggingExtension() + new Models::ExtensionItemAutoTaggingExtension() { MaxTags = 5, MinConfidence = 95, - Name = UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + Name = Models::ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, }, - new UnnamedSchemaWithArrayParent0AIAutoDescription(), - new UnnamedSchemaWithArrayParent0AITasks( + new Models::ExtensionItemAIAutoDescription(), + new Models::ExtensionItemAITasks( [ - new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + new Models::ExtensionItemAITasksTaskSelectTags() { Instruction = "What types of clothing items are visible in this image?", MaxSelections = 1, MinSelections = 0, Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], }, - new UnnamedSchemaWithArrayParent0AITasksTaskYesNo() + new Models::ExtensionItemAITasksTaskYesNo() { Instruction = "Is this a luxury or high-end fashion item?", OnNo = new() @@ -681,9 +681,9 @@ public void Validation_Works() }, ] ), - new SavedExtension("ext_abc123"), + new Models::SavedExtension("ext_abc123"), ], - RemoveAITags = new Files::UnionMember1(), + RemoveAITags = new UnionMember1(), Tags = ["tag1", "tag2"], WebhookUrl = "https://example.com", }; @@ -694,7 +694,7 @@ public void Validation_Works() [Fact] public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new Files::UpdateFileDetails + var model = new UpdateFileDetails { CustomCoordinates = "customCoordinates", Tags = ["tag1", "tag2"], @@ -715,7 +715,7 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = new Files::UpdateFileDetails + var model = new UpdateFileDetails { CustomCoordinates = "customCoordinates", Tags = ["tag1", "tag2"], @@ -727,7 +727,7 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - var model = new Files::UpdateFileDetails + var model = new UpdateFileDetails { CustomCoordinates = "customCoordinates", Tags = ["tag1", "tag2"], @@ -755,7 +755,7 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - var model = new Files::UpdateFileDetails + var model = new UpdateFileDetails { CustomCoordinates = "customCoordinates", Tags = ["tag1", "tag2"], @@ -774,7 +774,7 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Files::UpdateFileDetails + var model = new UpdateFileDetails { CustomMetadata = new Dictionary() { @@ -783,7 +783,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Description = "description", Extensions = [ - new UnnamedSchemaWithArrayParent0RemoveBg() + new Models::ExtensionItemRemoveBg() { Options = new() { @@ -793,23 +793,23 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Semitransparency = true, }, }, - new UnnamedSchemaWithArrayParent0AutoTaggingExtension() + new Models::ExtensionItemAutoTaggingExtension() { MaxTags = 5, MinConfidence = 95, - Name = UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + Name = Models::ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, }, - new UnnamedSchemaWithArrayParent0AIAutoDescription(), - new UnnamedSchemaWithArrayParent0AITasks( + new Models::ExtensionItemAIAutoDescription(), + new Models::ExtensionItemAITasks( [ - new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + new Models::ExtensionItemAITasksTaskSelectTags() { Instruction = "What types of clothing items are visible in this image?", MaxSelections = 1, MinSelections = 0, Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], }, - new UnnamedSchemaWithArrayParent0AITasksTaskYesNo() + new Models::ExtensionItemAITasksTaskYesNo() { Instruction = "Is this a luxury or high-end fashion item?", OnNo = new() @@ -836,9 +836,9 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ] ), - new SavedExtension("ext_abc123"), + new Models::SavedExtension("ext_abc123"), ], - RemoveAITags = new Files::UnionMember1(), + RemoveAITags = new UnionMember1(), WebhookUrl = "https://example.com", }; @@ -851,7 +851,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Files::UpdateFileDetails + var model = new UpdateFileDetails { CustomMetadata = new Dictionary() { @@ -860,7 +860,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Description = "description", Extensions = [ - new UnnamedSchemaWithArrayParent0RemoveBg() + new Models::ExtensionItemRemoveBg() { Options = new() { @@ -870,23 +870,23 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Semitransparency = true, }, }, - new UnnamedSchemaWithArrayParent0AutoTaggingExtension() + new Models::ExtensionItemAutoTaggingExtension() { MaxTags = 5, MinConfidence = 95, - Name = UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + Name = Models::ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, }, - new UnnamedSchemaWithArrayParent0AIAutoDescription(), - new UnnamedSchemaWithArrayParent0AITasks( + new Models::ExtensionItemAIAutoDescription(), + new Models::ExtensionItemAITasks( [ - new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + new Models::ExtensionItemAITasksTaskSelectTags() { Instruction = "What types of clothing items are visible in this image?", MaxSelections = 1, MinSelections = 0, Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], }, - new UnnamedSchemaWithArrayParent0AITasksTaskYesNo() + new Models::ExtensionItemAITasksTaskYesNo() { Instruction = "Is this a luxury or high-end fashion item?", OnNo = new() @@ -913,9 +913,9 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ] ), - new SavedExtension("ext_abc123"), + new Models::SavedExtension("ext_abc123"), ], - RemoveAITags = new Files::UnionMember1(), + RemoveAITags = new UnionMember1(), WebhookUrl = "https://example.com", }; @@ -925,7 +925,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Files::UpdateFileDetails + var model = new UpdateFileDetails { CustomMetadata = new Dictionary() { @@ -934,7 +934,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Description = "description", Extensions = [ - new UnnamedSchemaWithArrayParent0RemoveBg() + new Models::ExtensionItemRemoveBg() { Options = new() { @@ -944,23 +944,23 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Semitransparency = true, }, }, - new UnnamedSchemaWithArrayParent0AutoTaggingExtension() + new Models::ExtensionItemAutoTaggingExtension() { MaxTags = 5, MinConfidence = 95, - Name = UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + Name = Models::ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, }, - new UnnamedSchemaWithArrayParent0AIAutoDescription(), - new UnnamedSchemaWithArrayParent0AITasks( + new Models::ExtensionItemAIAutoDescription(), + new Models::ExtensionItemAITasks( [ - new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + new Models::ExtensionItemAITasksTaskSelectTags() { Instruction = "What types of clothing items are visible in this image?", MaxSelections = 1, MinSelections = 0, Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], }, - new UnnamedSchemaWithArrayParent0AITasksTaskYesNo() + new Models::ExtensionItemAITasksTaskYesNo() { Instruction = "Is this a luxury or high-end fashion item?", OnNo = new() @@ -987,9 +987,9 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ] ), - new SavedExtension("ext_abc123"), + new Models::SavedExtension("ext_abc123"), ], - RemoveAITags = new Files::UnionMember1(), + RemoveAITags = new UnionMember1(), WebhookUrl = "https://example.com", CustomCoordinates = null, @@ -1005,7 +1005,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Files::UpdateFileDetails + var model = new UpdateFileDetails { CustomMetadata = new Dictionary() { @@ -1014,7 +1014,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Description = "description", Extensions = [ - new UnnamedSchemaWithArrayParent0RemoveBg() + new Models::ExtensionItemRemoveBg() { Options = new() { @@ -1024,23 +1024,23 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Semitransparency = true, }, }, - new UnnamedSchemaWithArrayParent0AutoTaggingExtension() + new Models::ExtensionItemAutoTaggingExtension() { MaxTags = 5, MinConfidence = 95, - Name = UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + Name = Models::ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, }, - new UnnamedSchemaWithArrayParent0AIAutoDescription(), - new UnnamedSchemaWithArrayParent0AITasks( + new Models::ExtensionItemAIAutoDescription(), + new Models::ExtensionItemAITasks( [ - new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + new Models::ExtensionItemAITasksTaskSelectTags() { Instruction = "What types of clothing items are visible in this image?", MaxSelections = 1, MinSelections = 0, Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], }, - new UnnamedSchemaWithArrayParent0AITasksTaskYesNo() + new Models::ExtensionItemAITasksTaskYesNo() { Instruction = "Is this a luxury or high-end fashion item?", OnNo = new() @@ -1067,9 +1067,9 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ] ), - new SavedExtension("ext_abc123"), + new Models::SavedExtension("ext_abc123"), ], - RemoveAITags = new Files::UnionMember1(), + RemoveAITags = new UnionMember1(), WebhookUrl = "https://example.com", CustomCoordinates = null, @@ -1082,7 +1082,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new Files::UpdateFileDetails + var model = new UpdateFileDetails { CustomCoordinates = "customCoordinates", CustomMetadata = new Dictionary() @@ -1092,7 +1092,7 @@ public void CopyConstructor_Works() Description = "description", Extensions = [ - new UnnamedSchemaWithArrayParent0RemoveBg() + new Models::ExtensionItemRemoveBg() { Options = new() { @@ -1102,23 +1102,23 @@ public void CopyConstructor_Works() Semitransparency = true, }, }, - new UnnamedSchemaWithArrayParent0AutoTaggingExtension() + new Models::ExtensionItemAutoTaggingExtension() { MaxTags = 5, MinConfidence = 95, - Name = UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + Name = Models::ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, }, - new UnnamedSchemaWithArrayParent0AIAutoDescription(), - new UnnamedSchemaWithArrayParent0AITasks( + new Models::ExtensionItemAIAutoDescription(), + new Models::ExtensionItemAITasks( [ - new UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + new Models::ExtensionItemAITasksTaskSelectTags() { Instruction = "What types of clothing items are visible in this image?", MaxSelections = 1, MinSelections = 0, Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], }, - new UnnamedSchemaWithArrayParent0AITasksTaskYesNo() + new Models::ExtensionItemAITasksTaskYesNo() { Instruction = "Is this a luxury or high-end fashion item?", OnNo = new() @@ -1145,14 +1145,14 @@ public void CopyConstructor_Works() }, ] ), - new SavedExtension("ext_abc123"), + new Models::SavedExtension("ext_abc123"), ], - RemoveAITags = new Files::UnionMember1(), + RemoveAITags = new UnionMember1(), Tags = ["tag1", "tag2"], WebhookUrl = "https://example.com", }; - Files::UpdateFileDetails copied = new(model); + UpdateFileDetails copied = new(model); Assert.Equal(model, copied); } @@ -1163,23 +1163,23 @@ public class RemoveAITagsTest : TestBase [Fact] public void StringsValidationWorks() { - Files::RemoveAITags value = new(["string"]); + RemoveAITags value = new(["string"]); value.Validate(); } [Fact] public void AllValidationWorks() { - Files::RemoveAITags value = new Files::UnionMember1(); + RemoveAITags value = new UnionMember1(); value.Validate(); } [Fact] public void StringsSerializationRoundtripWorks() { - Files::RemoveAITags value = new(["string"]); + RemoveAITags value = new(["string"]); string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -1190,9 +1190,9 @@ public void StringsSerializationRoundtripWorks() [Fact] public void AllSerializationRoundtripWorks() { - Files::RemoveAITags value = new Files::UnionMember1(); + RemoveAITags value = new UnionMember1(); string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -1206,14 +1206,14 @@ public class UnionMember1Test : TestBase [Fact] public void DefaultValidation_Works() { - var constant = new Files::UnionMember1(); + var constant = new UnionMember1(); constant.Validate(); } [Fact] public void ValidConstantValidation_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.SerializeToElement("all"), ModelBase.SerializerOptions ); @@ -1225,7 +1225,7 @@ public void ValidConstantValidation_Works() [Fact] public void InvalidConstantValidationThrows_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); @@ -1237,9 +1237,9 @@ public void InvalidConstantValidationThrows_Works() [Fact] public void DefaultRoundtrip_Works() { - var constant = new Files::UnionMember1(); + var constant = new UnionMember1(); string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -1250,12 +1250,12 @@ public void DefaultRoundtrip_Works() [Fact] public void ValidConstantRoundtrip_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.SerializeToElement("all"), ModelBase.SerializerOptions ); string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -1266,12 +1266,12 @@ public void ValidConstantRoundtrip_Works() [Fact] public void InvalidConstantRoundtrip_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -1285,12 +1285,12 @@ public class ChangePublicationStatusTest : TestBase [Fact] public void FieldRoundtrip_Works() { - var model = new Files::ChangePublicationStatus + var model = new ChangePublicationStatus { Publish = new() { IsPublished = true, IncludeFileVersions = true }, }; - Files::Publish expectedPublish = new() { IsPublished = true, IncludeFileVersions = true }; + Publish expectedPublish = new() { IsPublished = true, IncludeFileVersions = true }; Assert.Equal(expectedPublish, model.Publish); } @@ -1298,13 +1298,13 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Files::ChangePublicationStatus + var model = new ChangePublicationStatus { Publish = new() { IsPublished = true, IncludeFileVersions = true }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -1315,19 +1315,19 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Files::ChangePublicationStatus + var model = new ChangePublicationStatus { Publish = new() { IsPublished = true, IncludeFileVersions = true }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - Files::Publish expectedPublish = new() { IsPublished = true, IncludeFileVersions = true }; + Publish expectedPublish = new() { IsPublished = true, IncludeFileVersions = true }; Assert.Equal(expectedPublish, deserialized.Publish); } @@ -1335,7 +1335,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Files::ChangePublicationStatus + var model = new ChangePublicationStatus { Publish = new() { IsPublished = true, IncludeFileVersions = true }, }; @@ -1346,7 +1346,7 @@ public void Validation_Works() [Fact] public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new Files::ChangePublicationStatus { }; + var model = new ChangePublicationStatus { }; Assert.Null(model.Publish); Assert.False(model.RawData.ContainsKey("publish")); @@ -1355,7 +1355,7 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = new Files::ChangePublicationStatus { }; + var model = new ChangePublicationStatus { }; model.Validate(); } @@ -1363,7 +1363,7 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - var model = new Files::ChangePublicationStatus + var model = new ChangePublicationStatus { // Null should be interpreted as omitted for these properties Publish = null, @@ -1376,7 +1376,7 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - var model = new Files::ChangePublicationStatus + var model = new ChangePublicationStatus { // Null should be interpreted as omitted for these properties Publish = null, @@ -1388,12 +1388,12 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new Files::ChangePublicationStatus + var model = new ChangePublicationStatus { Publish = new() { IsPublished = true, IncludeFileVersions = true }, }; - Files::ChangePublicationStatus copied = new(model); + ChangePublicationStatus copied = new(model); Assert.Equal(model, copied); } @@ -1404,7 +1404,7 @@ public class PublishTest : TestBase [Fact] public void FieldRoundtrip_Works() { - var model = new Files::Publish { IsPublished = true, IncludeFileVersions = true }; + var model = new Publish { IsPublished = true, IncludeFileVersions = true }; bool expectedIsPublished = true; bool expectedIncludeFileVersions = true; @@ -1416,13 +1416,10 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Files::Publish { IsPublished = true, IncludeFileVersions = true }; + var model = new Publish { IsPublished = true, IncludeFileVersions = true }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); Assert.Equal(model, deserialized); } @@ -1430,10 +1427,10 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Files::Publish { IsPublished = true, IncludeFileVersions = true }; + var model = new Publish { IsPublished = true, IncludeFileVersions = true }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -1449,7 +1446,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Files::Publish { IsPublished = true, IncludeFileVersions = true }; + var model = new Publish { IsPublished = true, IncludeFileVersions = true }; model.Validate(); } @@ -1457,7 +1454,7 @@ public void Validation_Works() [Fact] public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new Files::Publish { IsPublished = true }; + var model = new Publish { IsPublished = true }; Assert.Null(model.IncludeFileVersions); Assert.False(model.RawData.ContainsKey("includeFileVersions")); @@ -1466,7 +1463,7 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = new Files::Publish { IsPublished = true }; + var model = new Publish { IsPublished = true }; model.Validate(); } @@ -1474,7 +1471,7 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - var model = new Files::Publish + var model = new Publish { IsPublished = true, @@ -1489,7 +1486,7 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - var model = new Files::Publish + var model = new Publish { IsPublished = true, @@ -1503,9 +1500,9 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new Files::Publish { IsPublished = true, IncludeFileVersions = true }; + var model = new Publish { IsPublished = true, IncludeFileVersions = true }; - Files::Publish copied = new(model); + Publish copied = new(model); Assert.Equal(model, copied); } diff --git a/src/Imagekit.Tests/Models/Webhooks/FileCreateEventTest.cs b/src/Imagekit.Tests/Models/Webhooks/FileCreateEventTest.cs index 65edd2ba..f84039fb 100644 --- a/src/Imagekit.Tests/Models/Webhooks/FileCreateEventTest.cs +++ b/src/Imagekit.Tests/Models/Webhooks/FileCreateEventTest.cs @@ -60,9 +60,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -134,9 +134,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -218,9 +218,9 @@ public void SerializationRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -306,9 +306,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -387,9 +387,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -471,9 +471,9 @@ public void Validation_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -553,9 +553,9 @@ public void CopyConstructor_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -638,9 +638,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -710,9 +710,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -792,9 +792,9 @@ public void SerializationRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -878,9 +878,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -957,9 +957,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -1039,9 +1039,9 @@ public void Validation_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -1119,9 +1119,9 @@ public void CopyConstructor_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, diff --git a/src/Imagekit.Tests/Models/Webhooks/FileUpdateEventTest.cs b/src/Imagekit.Tests/Models/Webhooks/FileUpdateEventTest.cs index 3318797b..186bcc81 100644 --- a/src/Imagekit.Tests/Models/Webhooks/FileUpdateEventTest.cs +++ b/src/Imagekit.Tests/Models/Webhooks/FileUpdateEventTest.cs @@ -60,9 +60,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -134,9 +134,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -218,9 +218,9 @@ public void SerializationRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -306,9 +306,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -387,9 +387,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -471,9 +471,9 @@ public void Validation_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -553,9 +553,9 @@ public void CopyConstructor_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -638,9 +638,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -710,9 +710,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -792,9 +792,9 @@ public void SerializationRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -878,9 +878,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -957,9 +957,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -1039,9 +1039,9 @@ public void Validation_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -1119,9 +1119,9 @@ public void CopyConstructor_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, diff --git a/src/Imagekit.Tests/Models/Webhooks/FileVersionCreateEventTest.cs b/src/Imagekit.Tests/Models/Webhooks/FileVersionCreateEventTest.cs index 26e61a17..56c8c98c 100644 --- a/src/Imagekit.Tests/Models/Webhooks/FileVersionCreateEventTest.cs +++ b/src/Imagekit.Tests/Models/Webhooks/FileVersionCreateEventTest.cs @@ -60,9 +60,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -134,9 +134,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -218,9 +218,9 @@ public void SerializationRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -306,9 +306,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -387,9 +387,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -471,9 +471,9 @@ public void Validation_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -553,9 +553,9 @@ public void CopyConstructor_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -638,9 +638,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -710,9 +710,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -792,9 +792,9 @@ public void SerializationRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -878,9 +878,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -957,9 +957,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -1039,9 +1039,9 @@ public void Validation_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -1119,9 +1119,9 @@ public void CopyConstructor_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, diff --git a/src/Imagekit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs b/src/Imagekit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs index 2dc7c3f8..9edd05cf 100644 --- a/src/Imagekit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs +++ b/src/Imagekit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs @@ -278,9 +278,9 @@ public void UploadPreTransformSuccessValidationWorks() Type = Webhooks::SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new Webhooks::UnnamedSchemaWithArrayParent4(true), - new Webhooks::UnnamedSchemaWithArrayParent4(10), - new Webhooks::UnnamedSchemaWithArrayParent4("Hello"), + new Webhooks::UnnamedSchemaWithArrayParent3(true), + new Webhooks::UnnamedSchemaWithArrayParent3(10), + new Webhooks::UnnamedSchemaWithArrayParent3("Hello"), ] ), IsValueRequired = true, @@ -441,9 +441,9 @@ public void FileCreateValidationWorks() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -522,9 +522,9 @@ public void FileUpdateValidationWorks() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -616,9 +616,9 @@ public void FileVersionCreateValidationWorks() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -946,9 +946,9 @@ public void UploadPreTransformSuccessSerializationRoundtripWorks() Type = Webhooks::SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new Webhooks::UnnamedSchemaWithArrayParent4(true), - new Webhooks::UnnamedSchemaWithArrayParent4(10), - new Webhooks::UnnamedSchemaWithArrayParent4("Hello"), + new Webhooks::UnnamedSchemaWithArrayParent3(true), + new Webhooks::UnnamedSchemaWithArrayParent3(10), + new Webhooks::UnnamedSchemaWithArrayParent3("Hello"), ] ), IsValueRequired = true, @@ -1133,9 +1133,9 @@ public void FileCreateSerializationRoundtripWorks() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -1220,9 +1220,9 @@ public void FileUpdateSerializationRoundtripWorks() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -1326,9 +1326,9 @@ public void FileVersionCreateSerializationRoundtripWorks() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, diff --git a/src/Imagekit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs b/src/Imagekit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs index 391f5300..97b9f31b 100644 --- a/src/Imagekit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs +++ b/src/Imagekit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs @@ -278,9 +278,9 @@ public void UploadPreTransformSuccessValidationWorks() Type = Webhooks::SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new Webhooks::UnnamedSchemaWithArrayParent4(true), - new Webhooks::UnnamedSchemaWithArrayParent4(10), - new Webhooks::UnnamedSchemaWithArrayParent4("Hello"), + new Webhooks::UnnamedSchemaWithArrayParent3(true), + new Webhooks::UnnamedSchemaWithArrayParent3(10), + new Webhooks::UnnamedSchemaWithArrayParent3("Hello"), ] ), IsValueRequired = true, @@ -441,9 +441,9 @@ public void FileCreateValidationWorks() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -522,9 +522,9 @@ public void FileUpdateValidationWorks() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -616,9 +616,9 @@ public void FileVersionCreateValidationWorks() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -946,9 +946,9 @@ public void UploadPreTransformSuccessSerializationRoundtripWorks() Type = Webhooks::SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new Webhooks::UnnamedSchemaWithArrayParent4(true), - new Webhooks::UnnamedSchemaWithArrayParent4(10), - new Webhooks::UnnamedSchemaWithArrayParent4("Hello"), + new Webhooks::UnnamedSchemaWithArrayParent3(true), + new Webhooks::UnnamedSchemaWithArrayParent3(10), + new Webhooks::UnnamedSchemaWithArrayParent3("Hello"), ] ), IsValueRequired = true, @@ -1133,9 +1133,9 @@ public void FileCreateSerializationRoundtripWorks() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -1220,9 +1220,9 @@ public void FileUpdateSerializationRoundtripWorks() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, @@ -1326,9 +1326,9 @@ public void FileVersionCreateSerializationRoundtripWorks() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent1(true), - new Files::UnnamedSchemaWithArrayParent1(10), - new Files::UnnamedSchemaWithArrayParent1("Hello"), + new Files::UnnamedSchemaWithArrayParent0(true), + new Files::UnnamedSchemaWithArrayParent0(10), + new Files::UnnamedSchemaWithArrayParent0("Hello"), ] ), IsValueRequired = true, diff --git a/src/Imagekit.Tests/Models/Webhooks/UploadPreTransformSuccessEventTest.cs b/src/Imagekit.Tests/Models/Webhooks/UploadPreTransformSuccessEventTest.cs index 0a8326ed..35f11522 100644 --- a/src/Imagekit.Tests/Models/Webhooks/UploadPreTransformSuccessEventTest.cs +++ b/src/Imagekit.Tests/Models/Webhooks/UploadPreTransformSuccessEventTest.cs @@ -147,9 +147,9 @@ public void FieldRoundtrip_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent4(true), - new UnnamedSchemaWithArrayParent4(10), - new UnnamedSchemaWithArrayParent4("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ), IsValueRequired = true, @@ -306,9 +306,9 @@ public void FieldRoundtrip_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent4(true), - new UnnamedSchemaWithArrayParent4(10), - new UnnamedSchemaWithArrayParent4("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ), IsValueRequired = true, @@ -480,9 +480,9 @@ public void SerializationRoundtrip_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent4(true), - new UnnamedSchemaWithArrayParent4(10), - new UnnamedSchemaWithArrayParent4("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ), IsValueRequired = true, @@ -653,9 +653,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent4(true), - new UnnamedSchemaWithArrayParent4(10), - new UnnamedSchemaWithArrayParent4("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ), IsValueRequired = true, @@ -819,9 +819,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent4(true), - new UnnamedSchemaWithArrayParent4(10), - new UnnamedSchemaWithArrayParent4("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ), IsValueRequired = true, @@ -993,9 +993,9 @@ public void Validation_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent4(true), - new UnnamedSchemaWithArrayParent4(10), - new UnnamedSchemaWithArrayParent4("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ), IsValueRequired = true, @@ -1160,9 +1160,9 @@ public void CopyConstructor_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent4(true), - new UnnamedSchemaWithArrayParent4(10), - new UnnamedSchemaWithArrayParent4("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ), IsValueRequired = true, @@ -1330,9 +1330,9 @@ public void FieldRoundtrip_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent4(true), - new UnnamedSchemaWithArrayParent4(10), - new UnnamedSchemaWithArrayParent4("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ), IsValueRequired = true, @@ -1487,9 +1487,9 @@ public void FieldRoundtrip_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent4(true), - new UnnamedSchemaWithArrayParent4(10), - new UnnamedSchemaWithArrayParent4("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ), IsValueRequired = true, @@ -1661,9 +1661,9 @@ public void SerializationRoundtrip_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent4(true), - new UnnamedSchemaWithArrayParent4(10), - new UnnamedSchemaWithArrayParent4("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ), IsValueRequired = true, @@ -1833,9 +1833,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent4(true), - new UnnamedSchemaWithArrayParent4(10), - new UnnamedSchemaWithArrayParent4("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ), IsValueRequired = true, @@ -1998,9 +1998,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent4(true), - new UnnamedSchemaWithArrayParent4(10), - new UnnamedSchemaWithArrayParent4("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ), IsValueRequired = true, @@ -2172,9 +2172,9 @@ public void Validation_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent4(true), - new UnnamedSchemaWithArrayParent4(10), - new UnnamedSchemaWithArrayParent4("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ), IsValueRequired = true, @@ -2337,9 +2337,9 @@ public void CopyConstructor_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent4(true), - new UnnamedSchemaWithArrayParent4(10), - new UnnamedSchemaWithArrayParent4("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ), IsValueRequired = true, @@ -2504,9 +2504,9 @@ public void FieldRoundtrip_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent4(true), - new UnnamedSchemaWithArrayParent4(10), - new UnnamedSchemaWithArrayParent4("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ), IsValueRequired = true, @@ -2656,9 +2656,9 @@ public void FieldRoundtrip_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent4(true), - new UnnamedSchemaWithArrayParent4(10), - new UnnamedSchemaWithArrayParent4("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ), IsValueRequired = true, @@ -2870,9 +2870,9 @@ public void SerializationRoundtrip_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent4(true), - new UnnamedSchemaWithArrayParent4(10), - new UnnamedSchemaWithArrayParent4("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ), IsValueRequired = true, @@ -3037,9 +3037,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent4(true), - new UnnamedSchemaWithArrayParent4(10), - new UnnamedSchemaWithArrayParent4("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ), IsValueRequired = true, @@ -3197,9 +3197,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent4(true), - new UnnamedSchemaWithArrayParent4(10), - new UnnamedSchemaWithArrayParent4("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ), IsValueRequired = true, @@ -3411,9 +3411,9 @@ public void Validation_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent4(true), - new UnnamedSchemaWithArrayParent4(10), - new UnnamedSchemaWithArrayParent4("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ), IsValueRequired = true, @@ -3779,9 +3779,9 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent4(true), - new UnnamedSchemaWithArrayParent4(10), - new UnnamedSchemaWithArrayParent4("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ), IsValueRequired = true, @@ -3933,9 +3933,9 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent4(true), - new UnnamedSchemaWithArrayParent4(10), - new UnnamedSchemaWithArrayParent4("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ), IsValueRequired = true, @@ -4082,9 +4082,9 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent4(true), - new UnnamedSchemaWithArrayParent4(10), - new UnnamedSchemaWithArrayParent4("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ), IsValueRequired = true, @@ -4240,9 +4240,9 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent4(true), - new UnnamedSchemaWithArrayParent4(10), - new UnnamedSchemaWithArrayParent4("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ), IsValueRequired = true, @@ -4403,9 +4403,9 @@ public void CopyConstructor_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent4(true), - new UnnamedSchemaWithArrayParent4(10), - new UnnamedSchemaWithArrayParent4("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ), IsValueRequired = true, @@ -5066,9 +5066,9 @@ public void FieldRoundtrip_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent4(true), - new UnnamedSchemaWithArrayParent4(10), - new UnnamedSchemaWithArrayParent4("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ), IsValueRequired = true, @@ -5085,9 +5085,9 @@ public void FieldRoundtrip_Works() SelectedFieldsSchemaItemType.Text; DefaultValue expectedDefaultValue = new( [ - new UnnamedSchemaWithArrayParent4(true), - new UnnamedSchemaWithArrayParent4(10), - new UnnamedSchemaWithArrayParent4("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ); bool expectedIsValueRequired = true; @@ -5124,9 +5124,9 @@ public void SerializationRoundtrip_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent4(true), - new UnnamedSchemaWithArrayParent4(10), - new UnnamedSchemaWithArrayParent4("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ), IsValueRequired = true, @@ -5156,9 +5156,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent4(true), - new UnnamedSchemaWithArrayParent4(10), - new UnnamedSchemaWithArrayParent4("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ), IsValueRequired = true, @@ -5182,9 +5182,9 @@ public void FieldRoundtripThroughSerialization_Works() SelectedFieldsSchemaItemType.Text; DefaultValue expectedDefaultValue = new( [ - new UnnamedSchemaWithArrayParent4(true), - new UnnamedSchemaWithArrayParent4(10), - new UnnamedSchemaWithArrayParent4("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ); bool expectedIsValueRequired = true; @@ -5221,9 +5221,9 @@ public void Validation_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent4(true), - new UnnamedSchemaWithArrayParent4(10), - new UnnamedSchemaWithArrayParent4("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ), IsValueRequired = true, @@ -5341,9 +5341,9 @@ public void CopyConstructor_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent4(true), - new UnnamedSchemaWithArrayParent4(10), - new UnnamedSchemaWithArrayParent4("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ), IsValueRequired = true, @@ -5456,9 +5456,9 @@ public void MixedValidationWorks() { DefaultValue value = new( [ - new UnnamedSchemaWithArrayParent4(true), - new UnnamedSchemaWithArrayParent4(10), - new UnnamedSchemaWithArrayParent4("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ); value.Validate(); @@ -5508,9 +5508,9 @@ public void MixedSerializationRoundtripWorks() { DefaultValue value = new( [ - new UnnamedSchemaWithArrayParent4(true), - new UnnamedSchemaWithArrayParent4(10), - new UnnamedSchemaWithArrayParent4("Hello"), + new UnnamedSchemaWithArrayParent3(true), + new UnnamedSchemaWithArrayParent3(10), + new UnnamedSchemaWithArrayParent3("Hello"), ] ); string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -5523,35 +5523,35 @@ public void MixedSerializationRoundtripWorks() } } -public class UnnamedSchemaWithArrayParent4Test : TestBase +public class UnnamedSchemaWithArrayParent3Test : TestBase { [Fact] public void StringValidationWorks() { - UnnamedSchemaWithArrayParent4 value = "string"; + UnnamedSchemaWithArrayParent3 value = "string"; value.Validate(); } [Fact] public void DoubleValidationWorks() { - UnnamedSchemaWithArrayParent4 value = 0; + UnnamedSchemaWithArrayParent3 value = 0; value.Validate(); } [Fact] public void BoolValidationWorks() { - UnnamedSchemaWithArrayParent4 value = true; + UnnamedSchemaWithArrayParent3 value = true; value.Validate(); } [Fact] public void StringSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent4 value = "string"; + UnnamedSchemaWithArrayParent3 value = "string"; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -5562,9 +5562,9 @@ public void StringSerializationRoundtripWorks() [Fact] public void DoubleSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent4 value = 0; + UnnamedSchemaWithArrayParent3 value = 0; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -5575,9 +5575,9 @@ public void DoubleSerializationRoundtripWorks() [Fact] public void BoolSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent4 value = true; + UnnamedSchemaWithArrayParent3 value = true; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); diff --git a/src/Imagekit.Tests/Services/FileServiceTest.cs b/src/Imagekit.Tests/Services/FileServiceTest.cs index d6a64744..066bb71e 100644 --- a/src/Imagekit.Tests/Services/FileServiceTest.cs +++ b/src/Imagekit.Tests/Services/FileServiceTest.cs @@ -27,7 +27,7 @@ public async Task Update_Works() Description = "description", Extensions = [ - new Models::UnnamedSchemaWithArrayParent0RemoveBg() + new Models::ExtensionItemRemoveBg() { Options = new() { @@ -37,24 +37,22 @@ public async Task Update_Works() Semitransparency = true, }, }, - new Models::UnnamedSchemaWithArrayParent0AutoTaggingExtension() + new Models::ExtensionItemAutoTaggingExtension() { MaxTags = 10, MinConfidence = 80, - Name = - Models::UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, + Name = Models::ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, }, - new Models::UnnamedSchemaWithArrayParent0AutoTaggingExtension() + new Models::ExtensionItemAutoTaggingExtension() { MaxTags = 10, MinConfidence = 80, - Name = - Models::UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.AwsAutoTagging, + Name = Models::ExtensionItemAutoTaggingExtensionName.AwsAutoTagging, }, - new Models::UnnamedSchemaWithArrayParent0AIAutoDescription(), - new Models::UnnamedSchemaWithArrayParent0AITasks( + new Models::ExtensionItemAIAutoDescription(), + new Models::ExtensionItemAITasks( [ - new Models::UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + new Models::ExtensionItemAITasksTaskSelectTags() { Instruction = "What types of clothing items are visible?", MaxSelections = 1, diff --git a/src/Imagekit/Core/ModelBase.cs b/src/Imagekit/Core/ModelBase.cs index d730b126..1fc4ce80 100644 --- a/src/Imagekit/Core/ModelBase.cs +++ b/src/Imagekit/Core/ModelBase.cs @@ -30,7 +30,7 @@ protected ModelBase(ModelBase modelBase) new FrozenDictionaryConverterFactory(), new ApiEnumConverter(), new ApiEnumConverter(), - new ApiEnumConverter(), + new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadParams.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadParams.cs index bcd492ca..a767ed15 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadParams.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadParams.cs @@ -215,14 +215,12 @@ public string? Description /// Array of extensions to be applied to the asset. Each extension can be configured /// with specific parameters based on the extension type. /// - public IReadOnlyList? Extensions + public IReadOnlyList? Extensions { get { this._rawBodyData.Freeze(); - return this._rawBodyData.GetNullableStruct< - ImmutableArray - >("extensions"); + return this._rawBodyData.GetNullableStruct>("extensions"); } init { @@ -231,7 +229,7 @@ public IReadOnlyList? Extensions return; } - this._rawBodyData.Set?>( + this._rawBodyData.Set?>( "extensions", value == null ? null : ImmutableArray.ToImmutableArray(value) ); diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponse.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponse.cs index a888ea14..4e1afd88 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponse.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponse.cs @@ -1534,7 +1534,7 @@ public DefaultValue(bool value, JsonElement? element = null) } public DefaultValue( - IReadOnlyList value, + IReadOnlyList value, JsonElement? element = null ) { @@ -1612,24 +1612,24 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type where T is a UnnamedSchemaWithArrayParent3. + /// type where T is a UnnamedSchemaWithArrayParent2. /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickMixed(out var value)) { - /// // `value` is of type `IReadOnlyList<UnnamedSchemaWithArrayParent3>` + /// // `value` is of type `IReadOnlyList<UnnamedSchemaWithArrayParent2>` /// Console.WriteLine(value); /// } /// /// /// public bool TryPickMixed( - [NotNullWhen(true)] out IReadOnlyList? value + [NotNullWhen(true)] out IReadOnlyList? value ) { - value = this.Value as IReadOnlyList; + value = this.Value as IReadOnlyList; return value != null; } @@ -1650,7 +1650,7 @@ public bool TryPickMixed( /// (string value) => {...}, /// (double value) => {...}, /// (bool value) => {...}, - /// (IReadOnlyList<UnnamedSchemaWithArrayParent3> value) => {...} + /// (IReadOnlyList<UnnamedSchemaWithArrayParent2> value) => {...} /// ); /// /// @@ -1659,7 +1659,7 @@ public void Switch( System::Action @string, System::Action @double, System::Action @bool, - System::Action> mixed + System::Action> mixed ) { switch (this.Value) @@ -1673,7 +1673,7 @@ public void Switch( case bool value: @bool(value); break; - case IReadOnlyList value: + case IReadOnlyList value: mixed(value); break; default: @@ -1701,7 +1701,7 @@ public void Switch( /// (string value) => {...}, /// (double value) => {...}, /// (bool value) => {...}, - /// (IReadOnlyList<UnnamedSchemaWithArrayParent3> value) => {...} + /// (IReadOnlyList<UnnamedSchemaWithArrayParent2> value) => {...} /// ); /// /// @@ -1710,7 +1710,7 @@ public T Match( System::Func @string, System::Func @double, System::Func @bool, - System::Func, T> mixed + System::Func, T> mixed ) { return this.Value switch @@ -1718,7 +1718,7 @@ public T Match( string value => @string(value), double value => @double(value), bool value => @bool(value), - IReadOnlyList value => mixed(value), + IReadOnlyList value => mixed(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of DefaultValue" ), @@ -1731,8 +1731,8 @@ public T Match( public static implicit operator DefaultValue(bool value) => new(value); - public static implicit operator DefaultValue(List value) => - new((IReadOnlyList)value); + public static implicit operator DefaultValue(List value) => + new((IReadOnlyList)value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -1789,7 +1789,7 @@ int VariantIndex() string _ => 0, double _ => 1, bool _ => 2, - IReadOnlyList _ => 3, + IReadOnlyList _ => 3, _ => -1, }; } @@ -1837,7 +1837,7 @@ JsonSerializerOptions options try { - var deserialized = JsonSerializer.Deserialize>( + var deserialized = JsonSerializer.Deserialize>( element, options ); @@ -1868,8 +1868,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(UnnamedSchemaWithArrayParent3Converter))] -public record class UnnamedSchemaWithArrayParent3 : ModelBase +[JsonConverter(typeof(UnnamedSchemaWithArrayParent2Converter))] +public record class UnnamedSchemaWithArrayParent2 : ModelBase { public object? Value { get; } = null; @@ -1886,25 +1886,25 @@ public JsonElement Json } } - public UnnamedSchemaWithArrayParent3(string value, JsonElement? element = null) + public UnnamedSchemaWithArrayParent2(string value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent3(double value, JsonElement? element = null) + public UnnamedSchemaWithArrayParent2(double value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent3(bool value, JsonElement? element = null) + public UnnamedSchemaWithArrayParent2(bool value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent3(JsonElement element) + public UnnamedSchemaWithArrayParent2(JsonElement element) { this._element = element; } @@ -2012,7 +2012,7 @@ public void Switch( break; default: throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent3" + "Data did not match any variant of UnnamedSchemaWithArrayParent2" ); } } @@ -2051,16 +2051,16 @@ public T Match( double value => @double(value), bool value => @bool(value), _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent3" + "Data did not match any variant of UnnamedSchemaWithArrayParent2" ), }; } - public static implicit operator UnnamedSchemaWithArrayParent3(string value) => new(value); + public static implicit operator UnnamedSchemaWithArrayParent2(string value) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent3(double value) => new(value); + public static implicit operator UnnamedSchemaWithArrayParent2(double value) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent3(bool value) => new(value); + public static implicit operator UnnamedSchemaWithArrayParent2(bool value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -2077,12 +2077,12 @@ public override void Validate() if (this.Value == null) { throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent3" + "Data did not match any variant of UnnamedSchemaWithArrayParent2" ); } } - public virtual bool Equals(UnnamedSchemaWithArrayParent3? other) => + public virtual bool Equals(UnnamedSchemaWithArrayParent2? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -2110,9 +2110,9 @@ int VariantIndex() } } -sealed class UnnamedSchemaWithArrayParent3Converter : JsonConverter +sealed class UnnamedSchemaWithArrayParent2Converter : JsonConverter { - public override UnnamedSchemaWithArrayParent3? Read( + public override UnnamedSchemaWithArrayParent2? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -2155,7 +2155,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - UnnamedSchemaWithArrayParent3 value, + UnnamedSchemaWithArrayParent2 value, JsonSerializerOptions options ) { diff --git a/src/Imagekit/Models/UnnamedSchemaWithArrayParent0.cs b/src/Imagekit/Models/ExtensionItem.cs similarity index 66% rename from src/Imagekit/Models/UnnamedSchemaWithArrayParent0.cs rename to src/Imagekit/Models/ExtensionItem.cs index ac3ddb4f..fc29822c 100644 --- a/src/Imagekit/Models/UnnamedSchemaWithArrayParent0.cs +++ b/src/Imagekit/Models/ExtensionItem.cs @@ -10,8 +10,8 @@ namespace Imagekit.Models; -[JsonConverter(typeof(UnnamedSchemaWithArrayParent0Converter))] -public record class UnnamedSchemaWithArrayParent0 : ModelBase +[JsonConverter(typeof(ExtensionItemConverter))] +public record class ExtensionItem : ModelBase { public object? Value { get; } = null; @@ -28,140 +28,126 @@ public JsonElement Json } } - public UnnamedSchemaWithArrayParent0( - UnnamedSchemaWithArrayParent0RemoveBg value, - JsonElement? element = null - ) + public ExtensionItem(ExtensionItemRemoveBg value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent0( - UnnamedSchemaWithArrayParent0AutoTaggingExtension value, - JsonElement? element = null - ) + public ExtensionItem(ExtensionItemAutoTaggingExtension value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent0( - UnnamedSchemaWithArrayParent0AIAutoDescription value, - JsonElement? element = null - ) + public ExtensionItem(ExtensionItemAIAutoDescription value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent0( - UnnamedSchemaWithArrayParent0AITasks value, - JsonElement? element = null - ) + public ExtensionItem(ExtensionItemAITasks value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent0(SavedExtension value, JsonElement? element = null) + public ExtensionItem(SavedExtension value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent0(JsonElement element) + public ExtensionItem(JsonElement element) { this._element = element; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickRemoveBg(out var value)) { - /// // `value` is of type `UnnamedSchemaWithArrayParent0RemoveBg` + /// // `value` is of type `ExtensionItemRemoveBg` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickRemoveBg( - [NotNullWhen(true)] out UnnamedSchemaWithArrayParent0RemoveBg? value - ) + public bool TryPickRemoveBg([NotNullWhen(true)] out ExtensionItemRemoveBg? value) { - value = this.Value as UnnamedSchemaWithArrayParent0RemoveBg; + value = this.Value as ExtensionItemRemoveBg; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickAutoTaggingExtension(out var value)) { - /// // `value` is of type `UnnamedSchemaWithArrayParent0AutoTaggingExtension` + /// // `value` is of type `ExtensionItemAutoTaggingExtension` /// Console.WriteLine(value); /// } /// /// /// public bool TryPickAutoTaggingExtension( - [NotNullWhen(true)] out UnnamedSchemaWithArrayParent0AutoTaggingExtension? value + [NotNullWhen(true)] out ExtensionItemAutoTaggingExtension? value ) { - value = this.Value as UnnamedSchemaWithArrayParent0AutoTaggingExtension; + value = this.Value as ExtensionItemAutoTaggingExtension; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickAIAutoDescription(out var value)) { - /// // `value` is of type `UnnamedSchemaWithArrayParent0AIAutoDescription` + /// // `value` is of type `ExtensionItemAIAutoDescription` /// Console.WriteLine(value); /// } /// /// /// public bool TryPickAIAutoDescription( - [NotNullWhen(true)] out UnnamedSchemaWithArrayParent0AIAutoDescription? value + [NotNullWhen(true)] out ExtensionItemAIAutoDescription? value ) { - value = this.Value as UnnamedSchemaWithArrayParent0AIAutoDescription; + value = this.Value as ExtensionItemAIAutoDescription; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickAITasks(out var value)) { - /// // `value` is of type `UnnamedSchemaWithArrayParent0AITasks` + /// // `value` is of type `ExtensionItemAITasks` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickAITasks([NotNullWhen(true)] out UnnamedSchemaWithArrayParent0AITasks? value) + public bool TryPickAITasks([NotNullWhen(true)] out ExtensionItemAITasks? value) { - value = this.Value as UnnamedSchemaWithArrayParent0AITasks; + value = this.Value as ExtensionItemAITasks; return value != null; } @@ -200,35 +186,35 @@ public bool TryPickSavedExtension([NotNullWhen(true)] out SavedExtension? value) /// /// /// instance.Switch( - /// (UnnamedSchemaWithArrayParent0RemoveBg value) => {...}, - /// (UnnamedSchemaWithArrayParent0AutoTaggingExtension value) => {...}, - /// (UnnamedSchemaWithArrayParent0AIAutoDescription value) => {...}, - /// (UnnamedSchemaWithArrayParent0AITasks value) => {...}, + /// (ExtensionItemRemoveBg value) => {...}, + /// (ExtensionItemAutoTaggingExtension value) => {...}, + /// (ExtensionItemAIAutoDescription value) => {...}, + /// (ExtensionItemAITasks value) => {...}, /// (SavedExtension value) => {...} /// ); /// /// /// public void Switch( - Action removeBg, - Action autoTaggingExtension, - Action aiAutoDescription, - Action aiTasks, + Action removeBg, + Action autoTaggingExtension, + Action aiAutoDescription, + Action aiTasks, Action savedExtension ) { switch (this.Value) { - case UnnamedSchemaWithArrayParent0RemoveBg value: + case ExtensionItemRemoveBg value: removeBg(value); break; - case UnnamedSchemaWithArrayParent0AutoTaggingExtension value: + case ExtensionItemAutoTaggingExtension value: autoTaggingExtension(value); break; - case UnnamedSchemaWithArrayParent0AIAutoDescription value: + case ExtensionItemAIAutoDescription value: aiAutoDescription(value); break; - case UnnamedSchemaWithArrayParent0AITasks value: + case ExtensionItemAITasks value: aiTasks(value); break; case SavedExtension value: @@ -236,7 +222,7 @@ Action savedExtension break; default: throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent0" + "Data did not match any variant of ExtensionItem" ); } } @@ -256,54 +242,47 @@ Action savedExtension /// /// /// var result = instance.Match( - /// (UnnamedSchemaWithArrayParent0RemoveBg value) => {...}, - /// (UnnamedSchemaWithArrayParent0AutoTaggingExtension value) => {...}, - /// (UnnamedSchemaWithArrayParent0AIAutoDescription value) => {...}, - /// (UnnamedSchemaWithArrayParent0AITasks value) => {...}, + /// (ExtensionItemRemoveBg value) => {...}, + /// (ExtensionItemAutoTaggingExtension value) => {...}, + /// (ExtensionItemAIAutoDescription value) => {...}, + /// (ExtensionItemAITasks value) => {...}, /// (SavedExtension value) => {...} /// ); /// /// /// public T Match( - Func removeBg, - Func autoTaggingExtension, - Func aiAutoDescription, - Func aiTasks, + Func removeBg, + Func autoTaggingExtension, + Func aiAutoDescription, + Func aiTasks, Func savedExtension ) { return this.Value switch { - UnnamedSchemaWithArrayParent0RemoveBg value => removeBg(value), - UnnamedSchemaWithArrayParent0AutoTaggingExtension value => autoTaggingExtension(value), - UnnamedSchemaWithArrayParent0AIAutoDescription value => aiAutoDescription(value), - UnnamedSchemaWithArrayParent0AITasks value => aiTasks(value), + ExtensionItemRemoveBg value => removeBg(value), + ExtensionItemAutoTaggingExtension value => autoTaggingExtension(value), + ExtensionItemAIAutoDescription value => aiAutoDescription(value), + ExtensionItemAITasks value => aiTasks(value), SavedExtension value => savedExtension(value), _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent0" + "Data did not match any variant of ExtensionItem" ), }; } - public static implicit operator UnnamedSchemaWithArrayParent0( - UnnamedSchemaWithArrayParent0RemoveBg value - ) => new(value); + public static implicit operator ExtensionItem(ExtensionItemRemoveBg value) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent0( - UnnamedSchemaWithArrayParent0AutoTaggingExtension value - ) => new(value); + public static implicit operator ExtensionItem(ExtensionItemAutoTaggingExtension value) => + new(value); - public static implicit operator UnnamedSchemaWithArrayParent0( - UnnamedSchemaWithArrayParent0AIAutoDescription value - ) => new(value); + public static implicit operator ExtensionItem(ExtensionItemAIAutoDescription value) => + new(value); - public static implicit operator UnnamedSchemaWithArrayParent0( - UnnamedSchemaWithArrayParent0AITasks value - ) => new(value); + public static implicit operator ExtensionItem(ExtensionItemAITasks value) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent0(SavedExtension value) => - new(value); + public static implicit operator ExtensionItem(SavedExtension value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -320,7 +299,7 @@ public override void Validate() if (this.Value == null) { throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent0" + "Data did not match any variant of ExtensionItem" ); } this.Switch( @@ -332,7 +311,7 @@ public override void Validate() ); } - public virtual bool Equals(UnnamedSchemaWithArrayParent0? other) => + public virtual bool Equals(ExtensionItem? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -352,19 +331,19 @@ int VariantIndex() { return this.Value switch { - UnnamedSchemaWithArrayParent0RemoveBg _ => 0, - UnnamedSchemaWithArrayParent0AutoTaggingExtension _ => 1, - UnnamedSchemaWithArrayParent0AIAutoDescription _ => 2, - UnnamedSchemaWithArrayParent0AITasks _ => 3, + ExtensionItemRemoveBg _ => 0, + ExtensionItemAutoTaggingExtension _ => 1, + ExtensionItemAIAutoDescription _ => 2, + ExtensionItemAITasks _ => 3, SavedExtension _ => 4, _ => -1, }; } } -sealed class UnnamedSchemaWithArrayParent0Converter : JsonConverter +sealed class ExtensionItemConverter : JsonConverter { - public override UnnamedSchemaWithArrayParent0? Read( + public override ExtensionItem? Read( ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options @@ -387,11 +366,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { return new(deserialized, element); @@ -408,11 +386,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { return new(deserialized, element); @@ -429,11 +406,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { return new(deserialized, element); @@ -468,7 +444,7 @@ JsonSerializerOptions options try { var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, options ); @@ -489,7 +465,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - UnnamedSchemaWithArrayParent0 value, + ExtensionItem value, JsonSerializerOptions options ) { @@ -497,13 +473,8 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - UnnamedSchemaWithArrayParent0RemoveBg, - UnnamedSchemaWithArrayParent0RemoveBgFromRaw - >) -)] -public sealed record class UnnamedSchemaWithArrayParent0RemoveBg : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class ExtensionItemRemoveBg : JsonModel { /// /// Specifies the background removal extension. @@ -518,14 +489,12 @@ public JsonElement Name init { this._rawData.Set("name", value); } } - public UnnamedSchemaWithArrayParent0RemoveBgOptions? Options + public ExtensionItemRemoveBgOptions? Options { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "options" - ); + return this._rawData.GetNullableClass("options"); } init { @@ -548,20 +517,18 @@ public override void Validate() this.Options?.Validate(); } - public UnnamedSchemaWithArrayParent0RemoveBg() + public ExtensionItemRemoveBg() { this.Name = JsonSerializer.SerializeToElement("remove-bg"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public UnnamedSchemaWithArrayParent0RemoveBg( - UnnamedSchemaWithArrayParent0RemoveBg unnamedSchemaWithArrayParent0RemoveBg - ) - : base(unnamedSchemaWithArrayParent0RemoveBg) { } + public ExtensionItemRemoveBg(ExtensionItemRemoveBg extensionItemRemoveBg) + : base(extensionItemRemoveBg) { } #pragma warning restore CS8618 - public UnnamedSchemaWithArrayParent0RemoveBg(IReadOnlyDictionary rawData) + public ExtensionItemRemoveBg(IReadOnlyDictionary rawData) { this._rawData = new(rawData); @@ -570,14 +537,14 @@ public UnnamedSchemaWithArrayParent0RemoveBg(IReadOnlyDictionary rawData) + ExtensionItemRemoveBg(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static UnnamedSchemaWithArrayParent0RemoveBg FromRawUnchecked( + /// + public static ExtensionItemRemoveBg FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -585,22 +552,18 @@ IReadOnlyDictionary rawData } } -class UnnamedSchemaWithArrayParent0RemoveBgFromRaw - : IFromRawJson +class ExtensionItemRemoveBgFromRaw : IFromRawJson { /// - public UnnamedSchemaWithArrayParent0RemoveBg FromRawUnchecked( + public ExtensionItemRemoveBg FromRawUnchecked( IReadOnlyDictionary rawData - ) => UnnamedSchemaWithArrayParent0RemoveBg.FromRawUnchecked(rawData); + ) => ExtensionItemRemoveBg.FromRawUnchecked(rawData); } [JsonConverter( - typeof(JsonModelConverter< - UnnamedSchemaWithArrayParent0RemoveBgOptions, - UnnamedSchemaWithArrayParent0RemoveBgOptionsFromRaw - >) + typeof(JsonModelConverter) )] -public sealed record class UnnamedSchemaWithArrayParent0RemoveBgOptions : JsonModel +public sealed record class ExtensionItemRemoveBgOptions : JsonModel { /// /// Whether to add an artificial shadow to the result. Default is false. Note: @@ -700,33 +663,29 @@ public override void Validate() _ = this.Semitransparency; } - public UnnamedSchemaWithArrayParent0RemoveBgOptions() { } + public ExtensionItemRemoveBgOptions() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public UnnamedSchemaWithArrayParent0RemoveBgOptions( - UnnamedSchemaWithArrayParent0RemoveBgOptions unnamedSchemaWithArrayParent0RemoveBgOptions - ) - : base(unnamedSchemaWithArrayParent0RemoveBgOptions) { } + public ExtensionItemRemoveBgOptions(ExtensionItemRemoveBgOptions extensionItemRemoveBgOptions) + : base(extensionItemRemoveBgOptions) { } #pragma warning restore CS8618 - public UnnamedSchemaWithArrayParent0RemoveBgOptions( - IReadOnlyDictionary rawData - ) + public ExtensionItemRemoveBgOptions(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - UnnamedSchemaWithArrayParent0RemoveBgOptions(FrozenDictionary rawData) + ExtensionItemRemoveBgOptions(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static UnnamedSchemaWithArrayParent0RemoveBgOptions FromRawUnchecked( + /// + public static ExtensionItemRemoveBgOptions FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -734,22 +693,21 @@ IReadOnlyDictionary rawData } } -class UnnamedSchemaWithArrayParent0RemoveBgOptionsFromRaw - : IFromRawJson +class ExtensionItemRemoveBgOptionsFromRaw : IFromRawJson { /// - public UnnamedSchemaWithArrayParent0RemoveBgOptions FromRawUnchecked( + public ExtensionItemRemoveBgOptions FromRawUnchecked( IReadOnlyDictionary rawData - ) => UnnamedSchemaWithArrayParent0RemoveBgOptions.FromRawUnchecked(rawData); + ) => ExtensionItemRemoveBgOptions.FromRawUnchecked(rawData); } [JsonConverter( typeof(JsonModelConverter< - UnnamedSchemaWithArrayParent0AutoTaggingExtension, - UnnamedSchemaWithArrayParent0AutoTaggingExtensionFromRaw + ExtensionItemAutoTaggingExtension, + ExtensionItemAutoTaggingExtensionFromRaw >) )] -public sealed record class UnnamedSchemaWithArrayParent0AutoTaggingExtension : JsonModel +public sealed record class ExtensionItemAutoTaggingExtension : JsonModel { /// /// Maximum number of tags to attach to the asset. @@ -780,13 +738,13 @@ public required long MinConfidence /// /// Specifies the auto-tagging extension used. /// - public required ApiEnum Name + public required ApiEnum Name { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("name"); } init { this._rawData.Set("name", value); } @@ -800,33 +758,31 @@ public override void Validate() this.Name.Validate(); } - public UnnamedSchemaWithArrayParent0AutoTaggingExtension() { } + public ExtensionItemAutoTaggingExtension() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public UnnamedSchemaWithArrayParent0AutoTaggingExtension( - UnnamedSchemaWithArrayParent0AutoTaggingExtension unnamedSchemaWithArrayParent0AutoTaggingExtension + public ExtensionItemAutoTaggingExtension( + ExtensionItemAutoTaggingExtension extensionItemAutoTaggingExtension ) - : base(unnamedSchemaWithArrayParent0AutoTaggingExtension) { } + : base(extensionItemAutoTaggingExtension) { } #pragma warning restore CS8618 - public UnnamedSchemaWithArrayParent0AutoTaggingExtension( - IReadOnlyDictionary rawData - ) + public ExtensionItemAutoTaggingExtension(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - UnnamedSchemaWithArrayParent0AutoTaggingExtension(FrozenDictionary rawData) + ExtensionItemAutoTaggingExtension(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static UnnamedSchemaWithArrayParent0AutoTaggingExtension FromRawUnchecked( + /// + public static ExtensionItemAutoTaggingExtension FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -834,29 +790,28 @@ IReadOnlyDictionary rawData } } -class UnnamedSchemaWithArrayParent0AutoTaggingExtensionFromRaw - : IFromRawJson +class ExtensionItemAutoTaggingExtensionFromRaw : IFromRawJson { /// - public UnnamedSchemaWithArrayParent0AutoTaggingExtension FromRawUnchecked( + public ExtensionItemAutoTaggingExtension FromRawUnchecked( IReadOnlyDictionary rawData - ) => UnnamedSchemaWithArrayParent0AutoTaggingExtension.FromRawUnchecked(rawData); + ) => ExtensionItemAutoTaggingExtension.FromRawUnchecked(rawData); } /// /// Specifies the auto-tagging extension used. /// -[JsonConverter(typeof(UnnamedSchemaWithArrayParent0AutoTaggingExtensionNameConverter))] -public enum UnnamedSchemaWithArrayParent0AutoTaggingExtensionName +[JsonConverter(typeof(ExtensionItemAutoTaggingExtensionNameConverter))] +public enum ExtensionItemAutoTaggingExtensionName { GoogleAutoTagging, AwsAutoTagging, } -sealed class UnnamedSchemaWithArrayParent0AutoTaggingExtensionNameConverter - : JsonConverter +sealed class ExtensionItemAutoTaggingExtensionNameConverter + : JsonConverter { - public override UnnamedSchemaWithArrayParent0AutoTaggingExtensionName Read( + public override ExtensionItemAutoTaggingExtensionName Read( ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options @@ -864,17 +819,15 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "google-auto-tagging" => - UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging, - "aws-auto-tagging" => - UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.AwsAutoTagging, - _ => (UnnamedSchemaWithArrayParent0AutoTaggingExtensionName)(-1), + "google-auto-tagging" => ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, + "aws-auto-tagging" => ExtensionItemAutoTaggingExtensionName.AwsAutoTagging, + _ => (ExtensionItemAutoTaggingExtensionName)(-1), }; } public override void Write( Utf8JsonWriter writer, - UnnamedSchemaWithArrayParent0AutoTaggingExtensionName value, + ExtensionItemAutoTaggingExtensionName value, JsonSerializerOptions options ) { @@ -882,10 +835,8 @@ JsonSerializerOptions options writer, value switch { - UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.GoogleAutoTagging => - "google-auto-tagging", - UnnamedSchemaWithArrayParent0AutoTaggingExtensionName.AwsAutoTagging => - "aws-auto-tagging", + ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging => "google-auto-tagging", + ExtensionItemAutoTaggingExtensionName.AwsAutoTagging => "aws-auto-tagging", _ => throw new ImageKitInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -895,12 +846,12 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(UnnamedSchemaWithArrayParent0AIAutoDescriptionConverter))] -public record class UnnamedSchemaWithArrayParent0AIAutoDescription +[JsonConverter(typeof(ExtensionItemAIAutoDescriptionConverter))] +public record class ExtensionItemAIAutoDescription { public JsonElement Element { get; private init; } - public UnnamedSchemaWithArrayParent0AIAutoDescription() + public ExtensionItemAIAutoDescription() { Element = JsonSerializer.Deserialize( """ @@ -911,7 +862,7 @@ public UnnamedSchemaWithArrayParent0AIAutoDescription() ); } - internal UnnamedSchemaWithArrayParent0AIAutoDescription(JsonElement element) + internal ExtensionItemAIAutoDescription(JsonElement element) { Element = element; } @@ -927,10 +878,10 @@ internal UnnamedSchemaWithArrayParent0AIAutoDescription(JsonElement element) /// public void Validate() { - if (this != new UnnamedSchemaWithArrayParent0AIAutoDescription()) + if (this != new ExtensionItemAIAutoDescription()) { throw new ImageKitInvalidDataException( - "Invalid value given for 'UnnamedSchemaWithArrayParent0AIAutoDescription'" + "Invalid value given for 'ExtensionItemAIAutoDescription'" ); } } @@ -940,7 +891,7 @@ public override int GetHashCode() return 0; } - public virtual bool Equals(UnnamedSchemaWithArrayParent0AIAutoDescription? other) + public virtual bool Equals(ExtensionItemAIAutoDescription? other) { if (other == null) { @@ -951,10 +902,9 @@ public virtual bool Equals(UnnamedSchemaWithArrayParent0AIAutoDescription? other } } -class UnnamedSchemaWithArrayParent0AIAutoDescriptionConverter - : JsonConverter +class ExtensionItemAIAutoDescriptionConverter : JsonConverter { - public override UnnamedSchemaWithArrayParent0AIAutoDescription? Read( + public override ExtensionItemAIAutoDescription? Read( ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options @@ -965,7 +915,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - UnnamedSchemaWithArrayParent0AIAutoDescription value, + ExtensionItemAIAutoDescription value, JsonSerializerOptions options ) { @@ -973,13 +923,8 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - UnnamedSchemaWithArrayParent0AITasks, - UnnamedSchemaWithArrayParent0AITasksFromRaw - >) -)] -public sealed record class UnnamedSchemaWithArrayParent0AITasks : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class ExtensionItemAITasks : JsonModel { /// /// Specifies the AI tasks extension for automated image analysis using AI models. @@ -997,18 +942,18 @@ public JsonElement Name /// /// Array of task objects defining AI operations to perform on the asset. /// - public required IReadOnlyList Tasks + public required IReadOnlyList Tasks { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("tasks"); + return this._rawData.GetNotNullStruct>( + "tasks" + ); } init { - this._rawData.Set>( + this._rawData.Set>( "tasks", ImmutableArray.ToImmutableArray(value) ); @@ -1028,20 +973,18 @@ public override void Validate() } } - public UnnamedSchemaWithArrayParent0AITasks() + public ExtensionItemAITasks() { this.Name = JsonSerializer.SerializeToElement("ai-tasks"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public UnnamedSchemaWithArrayParent0AITasks( - UnnamedSchemaWithArrayParent0AITasks unnamedSchemaWithArrayParent0AITasks - ) - : base(unnamedSchemaWithArrayParent0AITasks) { } + public ExtensionItemAITasks(ExtensionItemAITasks extensionItemAITasks) + : base(extensionItemAITasks) { } #pragma warning restore CS8618 - public UnnamedSchemaWithArrayParent0AITasks(IReadOnlyDictionary rawData) + public ExtensionItemAITasks(IReadOnlyDictionary rawData) { this._rawData = new(rawData); @@ -1050,14 +993,14 @@ public UnnamedSchemaWithArrayParent0AITasks(IReadOnlyDictionary rawData) + ExtensionItemAITasks(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static UnnamedSchemaWithArrayParent0AITasks FromRawUnchecked( + /// + public static ExtensionItemAITasks FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -1065,26 +1008,23 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public UnnamedSchemaWithArrayParent0AITasks( - IReadOnlyList tasks - ) + public ExtensionItemAITasks(IReadOnlyList tasks) : this() { this.Tasks = tasks; } } -class UnnamedSchemaWithArrayParent0AITasksFromRaw - : IFromRawJson +class ExtensionItemAITasksFromRaw : IFromRawJson { /// - public UnnamedSchemaWithArrayParent0AITasks FromRawUnchecked( + public ExtensionItemAITasks FromRawUnchecked( IReadOnlyDictionary rawData - ) => UnnamedSchemaWithArrayParent0AITasks.FromRawUnchecked(rawData); + ) => ExtensionItemAITasks.FromRawUnchecked(rawData); } -[JsonConverter(typeof(UnnamedSchemaWithArrayParent0AITasksTaskConverter))] -public record class UnnamedSchemaWithArrayParent0AITasksTask : ModelBase +[JsonConverter(typeof(ExtensionItemAITasksTaskConverter))] +public record class ExtensionItemAITasksTask : ModelBase { public object? Value { get; } = null; @@ -1149,8 +1089,8 @@ public long? MinSelections } } - public UnnamedSchemaWithArrayParent0AITasksTask( - UnnamedSchemaWithArrayParent0AITasksTaskSelectTags value, + public ExtensionItemAITasksTask( + ExtensionItemAITasksTaskSelectTags value, JsonElement? element = null ) { @@ -1158,8 +1098,8 @@ public UnnamedSchemaWithArrayParent0AITasksTask( this._element = element; } - public UnnamedSchemaWithArrayParent0AITasksTask( - UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata value, + public ExtensionItemAITasksTask( + ExtensionItemAITasksTaskSelectMetadata value, JsonElement? element = null ) { @@ -1167,8 +1107,8 @@ public UnnamedSchemaWithArrayParent0AITasksTask( this._element = element; } - public UnnamedSchemaWithArrayParent0AITasksTask( - UnnamedSchemaWithArrayParent0AITasksTaskYesNo value, + public ExtensionItemAITasksTask( + ExtensionItemAITasksTaskYesNo value, JsonElement? element = null ) { @@ -1176,77 +1116,73 @@ public UnnamedSchemaWithArrayParent0AITasksTask( this._element = element; } - public UnnamedSchemaWithArrayParent0AITasksTask(JsonElement element) + public ExtensionItemAITasksTask(JsonElement element) { this._element = element; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickSelectTags(out var value)) { - /// // `value` is of type `UnnamedSchemaWithArrayParent0AITasksTaskSelectTags` + /// // `value` is of type `ExtensionItemAITasksTaskSelectTags` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickSelectTags( - [NotNullWhen(true)] out UnnamedSchemaWithArrayParent0AITasksTaskSelectTags? value - ) + public bool TryPickSelectTags([NotNullWhen(true)] out ExtensionItemAITasksTaskSelectTags? value) { - value = this.Value as UnnamedSchemaWithArrayParent0AITasksTaskSelectTags; + value = this.Value as ExtensionItemAITasksTaskSelectTags; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickSelectMetadata(out var value)) { - /// // `value` is of type `UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata` + /// // `value` is of type `ExtensionItemAITasksTaskSelectMetadata` /// Console.WriteLine(value); /// } /// /// /// public bool TryPickSelectMetadata( - [NotNullWhen(true)] out UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata? value + [NotNullWhen(true)] out ExtensionItemAITasksTaskSelectMetadata? value ) { - value = this.Value as UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata; + value = this.Value as ExtensionItemAITasksTaskSelectMetadata; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickYesNo(out var value)) { - /// // `value` is of type `UnnamedSchemaWithArrayParent0AITasksTaskYesNo` + /// // `value` is of type `ExtensionItemAITasksTaskYesNo` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickYesNo( - [NotNullWhen(true)] out UnnamedSchemaWithArrayParent0AITasksTaskYesNo? value - ) + public bool TryPickYesNo([NotNullWhen(true)] out ExtensionItemAITasksTaskYesNo? value) { - value = this.Value as UnnamedSchemaWithArrayParent0AITasksTaskYesNo; + value = this.Value as ExtensionItemAITasksTaskYesNo; return value != null; } @@ -1264,33 +1200,33 @@ public bool TryPickYesNo( /// /// /// instance.Switch( - /// (UnnamedSchemaWithArrayParent0AITasksTaskSelectTags value) => {...}, - /// (UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata value) => {...}, - /// (UnnamedSchemaWithArrayParent0AITasksTaskYesNo value) => {...} + /// (ExtensionItemAITasksTaskSelectTags value) => {...}, + /// (ExtensionItemAITasksTaskSelectMetadata value) => {...}, + /// (ExtensionItemAITasksTaskYesNo value) => {...} /// ); /// /// /// public void Switch( - Action selectTags, - Action selectMetadata, - Action yesNo + Action selectTags, + Action selectMetadata, + Action yesNo ) { switch (this.Value) { - case UnnamedSchemaWithArrayParent0AITasksTaskSelectTags value: + case ExtensionItemAITasksTaskSelectTags value: selectTags(value); break; - case UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata value: + case ExtensionItemAITasksTaskSelectMetadata value: selectMetadata(value); break; - case UnnamedSchemaWithArrayParent0AITasksTaskYesNo value: + case ExtensionItemAITasksTaskYesNo value: yesNo(value); break; default: throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTask" + "Data did not match any variant of ExtensionItemAITasksTask" ); } } @@ -1310,41 +1246,40 @@ Action yesNo /// /// /// var result = instance.Match( - /// (UnnamedSchemaWithArrayParent0AITasksTaskSelectTags value) => {...}, - /// (UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata value) => {...}, - /// (UnnamedSchemaWithArrayParent0AITasksTaskYesNo value) => {...} + /// (ExtensionItemAITasksTaskSelectTags value) => {...}, + /// (ExtensionItemAITasksTaskSelectMetadata value) => {...}, + /// (ExtensionItemAITasksTaskYesNo value) => {...} /// ); /// /// /// public T Match( - Func selectTags, - Func selectMetadata, - Func yesNo + Func selectTags, + Func selectMetadata, + Func yesNo ) { return this.Value switch { - UnnamedSchemaWithArrayParent0AITasksTaskSelectTags value => selectTags(value), - UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata value => selectMetadata(value), - UnnamedSchemaWithArrayParent0AITasksTaskYesNo value => yesNo(value), + ExtensionItemAITasksTaskSelectTags value => selectTags(value), + ExtensionItemAITasksTaskSelectMetadata value => selectMetadata(value), + ExtensionItemAITasksTaskYesNo value => yesNo(value), _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTask" + "Data did not match any variant of ExtensionItemAITasksTask" ), }; } - public static implicit operator UnnamedSchemaWithArrayParent0AITasksTask( - UnnamedSchemaWithArrayParent0AITasksTaskSelectTags value + public static implicit operator ExtensionItemAITasksTask( + ExtensionItemAITasksTaskSelectTags value ) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent0AITasksTask( - UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata value + public static implicit operator ExtensionItemAITasksTask( + ExtensionItemAITasksTaskSelectMetadata value ) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent0AITasksTask( - UnnamedSchemaWithArrayParent0AITasksTaskYesNo value - ) => new(value); + public static implicit operator ExtensionItemAITasksTask(ExtensionItemAITasksTaskYesNo value) => + new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -1361,7 +1296,7 @@ public override void Validate() if (this.Value == null) { throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTask" + "Data did not match any variant of ExtensionItemAITasksTask" ); } this.Switch( @@ -1371,7 +1306,7 @@ public override void Validate() ); } - public virtual bool Equals(UnnamedSchemaWithArrayParent0AITasksTask? other) => + public virtual bool Equals(ExtensionItemAITasksTask? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -1391,18 +1326,17 @@ int VariantIndex() { return this.Value switch { - UnnamedSchemaWithArrayParent0AITasksTaskSelectTags _ => 0, - UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata _ => 1, - UnnamedSchemaWithArrayParent0AITasksTaskYesNo _ => 2, + ExtensionItemAITasksTaskSelectTags _ => 0, + ExtensionItemAITasksTaskSelectMetadata _ => 1, + ExtensionItemAITasksTaskYesNo _ => 2, _ => -1, }; } } -sealed class UnnamedSchemaWithArrayParent0AITasksTaskConverter - : JsonConverter +sealed class ExtensionItemAITasksTaskConverter : JsonConverter { - public override UnnamedSchemaWithArrayParent0AITasksTask? Read( + public override ExtensionItemAITasksTask? Read( ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options @@ -1426,7 +1360,7 @@ JsonSerializerOptions options try { var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, options ); @@ -1447,7 +1381,7 @@ JsonSerializerOptions options try { var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, options ); @@ -1467,11 +1401,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { return new(deserialized, element); @@ -1486,14 +1419,14 @@ JsonSerializerOptions options } default: { - return new UnnamedSchemaWithArrayParent0AITasksTask(element); + return new ExtensionItemAITasksTask(element); } } } public override void Write( Utf8JsonWriter writer, - UnnamedSchemaWithArrayParent0AITasksTask value, + ExtensionItemAITasksTask value, JsonSerializerOptions options ) { @@ -1503,11 +1436,11 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - UnnamedSchemaWithArrayParent0AITasksTaskSelectTags, - UnnamedSchemaWithArrayParent0AITasksTaskSelectTagsFromRaw + ExtensionItemAITasksTaskSelectTags, + ExtensionItemAITasksTaskSelectTagsFromRaw >) )] -public sealed record class UnnamedSchemaWithArrayParent0AITasksTaskSelectTags : JsonModel +public sealed record class ExtensionItemAITasksTaskSelectTags : JsonModel { /// /// The question or instruction for the AI to analyze the image. @@ -1617,22 +1550,20 @@ public override void Validate() _ = this.Vocabulary; } - public UnnamedSchemaWithArrayParent0AITasksTaskSelectTags() + public ExtensionItemAITasksTaskSelectTags() { this.Type = JsonSerializer.SerializeToElement("select_tags"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public UnnamedSchemaWithArrayParent0AITasksTaskSelectTags( - UnnamedSchemaWithArrayParent0AITasksTaskSelectTags unnamedSchemaWithArrayParent0AITasksTaskSelectTags + public ExtensionItemAITasksTaskSelectTags( + ExtensionItemAITasksTaskSelectTags extensionItemAITasksTaskSelectTags ) - : base(unnamedSchemaWithArrayParent0AITasksTaskSelectTags) { } + : base(extensionItemAITasksTaskSelectTags) { } #pragma warning restore CS8618 - public UnnamedSchemaWithArrayParent0AITasksTaskSelectTags( - IReadOnlyDictionary rawData - ) + public ExtensionItemAITasksTaskSelectTags(IReadOnlyDictionary rawData) { this._rawData = new(rawData); @@ -1641,16 +1572,14 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - UnnamedSchemaWithArrayParent0AITasksTaskSelectTags( - FrozenDictionary rawData - ) + ExtensionItemAITasksTaskSelectTags(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static UnnamedSchemaWithArrayParent0AITasksTaskSelectTags FromRawUnchecked( + /// + public static ExtensionItemAITasksTaskSelectTags FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -1658,29 +1587,28 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public UnnamedSchemaWithArrayParent0AITasksTaskSelectTags(string instruction) + public ExtensionItemAITasksTaskSelectTags(string instruction) : this() { this.Instruction = instruction; } } -class UnnamedSchemaWithArrayParent0AITasksTaskSelectTagsFromRaw - : IFromRawJson +class ExtensionItemAITasksTaskSelectTagsFromRaw : IFromRawJson { /// - public UnnamedSchemaWithArrayParent0AITasksTaskSelectTags FromRawUnchecked( + public ExtensionItemAITasksTaskSelectTags FromRawUnchecked( IReadOnlyDictionary rawData - ) => UnnamedSchemaWithArrayParent0AITasksTaskSelectTags.FromRawUnchecked(rawData); + ) => ExtensionItemAITasksTaskSelectTags.FromRawUnchecked(rawData); } [JsonConverter( typeof(JsonModelConverter< - UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata, - UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataFromRaw + ExtensionItemAITasksTaskSelectMetadata, + ExtensionItemAITasksTaskSelectMetadataFromRaw >) )] -public sealed record class UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata : JsonModel +public sealed record class ExtensionItemAITasksTaskSelectMetadata : JsonModel { /// /// Name of the custom metadata field to set. The field must exist in your account. @@ -1770,13 +1698,13 @@ public long? MinSelections /// custom metadata field definition will be used. When providing large vocabularies /// (above 30 items), the AI may not strictly adhere to the list. /// - public IReadOnlyList? Vocabulary + public IReadOnlyList? Vocabulary { get { this._rawData.Freeze(); return this._rawData.GetNullableStruct< - ImmutableArray + ImmutableArray >("vocabulary"); } init @@ -1786,7 +1714,7 @@ public IReadOnlyList?>( + this._rawData.Set?>( "vocabulary", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -1812,22 +1740,20 @@ public override void Validate() } } - public UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata() + public ExtensionItemAITasksTaskSelectMetadata() { this.Type = JsonSerializer.SerializeToElement("select_metadata"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata( - UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata unnamedSchemaWithArrayParent0AITasksTaskSelectMetadata + public ExtensionItemAITasksTaskSelectMetadata( + ExtensionItemAITasksTaskSelectMetadata extensionItemAITasksTaskSelectMetadata ) - : base(unnamedSchemaWithArrayParent0AITasksTaskSelectMetadata) { } + : base(extensionItemAITasksTaskSelectMetadata) { } #pragma warning restore CS8618 - public UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata( - IReadOnlyDictionary rawData - ) + public ExtensionItemAITasksTaskSelectMetadata(IReadOnlyDictionary rawData) { this._rawData = new(rawData); @@ -1836,16 +1762,14 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata( - FrozenDictionary rawData - ) + ExtensionItemAITasksTaskSelectMetadata(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata FromRawUnchecked( + /// + public static ExtensionItemAITasksTaskSelectMetadata FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -1853,17 +1777,17 @@ IReadOnlyDictionary rawData } } -class UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataFromRaw - : IFromRawJson +class ExtensionItemAITasksTaskSelectMetadataFromRaw + : IFromRawJson { /// - public UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata FromRawUnchecked( + public ExtensionItemAITasksTaskSelectMetadata FromRawUnchecked( IReadOnlyDictionary rawData - ) => UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadata.FromRawUnchecked(rawData); + ) => ExtensionItemAITasksTaskSelectMetadata.FromRawUnchecked(rawData); } -[JsonConverter(typeof(UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabularyConverter))] -public record class UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabulary : ModelBase +[JsonConverter(typeof(ExtensionItemAITasksTaskSelectMetadataVocabularyConverter))] +public record class ExtensionItemAITasksTaskSelectMetadataVocabulary : ModelBase { public object? Value { get; } = null; @@ -1880,7 +1804,7 @@ public JsonElement Json } } - public UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabulary( + public ExtensionItemAITasksTaskSelectMetadataVocabulary( string value, JsonElement? element = null ) @@ -1889,7 +1813,7 @@ public UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabulary( this._element = element; } - public UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabulary( + public ExtensionItemAITasksTaskSelectMetadataVocabulary( double value, JsonElement? element = null ) @@ -1898,16 +1822,13 @@ public UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabulary( this._element = element; } - public UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabulary( - bool value, - JsonElement? element = null - ) + public ExtensionItemAITasksTaskSelectMetadataVocabulary(bool value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabulary(JsonElement element) + public ExtensionItemAITasksTaskSelectMetadataVocabulary(JsonElement element) { this._element = element; } @@ -2011,7 +1932,7 @@ public void Switch(Action @string, Action @double, Action break; default: throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabulary" + "Data did not match any variant of ExtensionItemAITasksTaskSelectMetadataVocabulary" ); } } @@ -2046,22 +1967,21 @@ public T Match(Func @string, Func @double, Func @double(value), bool value => @bool(value), _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabulary" + "Data did not match any variant of ExtensionItemAITasksTaskSelectMetadataVocabulary" ), }; } - public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabulary( + public static implicit operator ExtensionItemAITasksTaskSelectMetadataVocabulary( string value ) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabulary( + public static implicit operator ExtensionItemAITasksTaskSelectMetadataVocabulary( double value ) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabulary( - bool value - ) => new(value); + public static implicit operator ExtensionItemAITasksTaskSelectMetadataVocabulary(bool value) => + new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -2078,14 +1998,12 @@ public override void Validate() if (this.Value == null) { throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabulary" + "Data did not match any variant of ExtensionItemAITasksTaskSelectMetadataVocabulary" ); } } - public virtual bool Equals( - UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabulary? other - ) => + public virtual bool Equals(ExtensionItemAITasksTaskSelectMetadataVocabulary? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -2113,10 +2031,10 @@ int VariantIndex() } } -sealed class UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabularyConverter - : JsonConverter +sealed class ExtensionItemAITasksTaskSelectMetadataVocabularyConverter + : JsonConverter { - public override UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabulary? Read( + public override ExtensionItemAITasksTaskSelectMetadataVocabulary? Read( ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options @@ -2159,7 +2077,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - UnnamedSchemaWithArrayParent0AITasksTaskSelectMetadataVocabulary value, + ExtensionItemAITasksTaskSelectMetadataVocabulary value, JsonSerializerOptions options ) { @@ -2168,12 +2086,9 @@ JsonSerializerOptions options } [JsonConverter( - typeof(JsonModelConverter< - UnnamedSchemaWithArrayParent0AITasksTaskYesNo, - UnnamedSchemaWithArrayParent0AITasksTaskYesNoFromRaw - >) + typeof(JsonModelConverter) )] -public sealed record class UnnamedSchemaWithArrayParent0AITasksTaskYesNo : JsonModel +public sealed record class ExtensionItemAITasksTaskYesNo : JsonModel { /// /// The yes/no question for the AI to answer about the image. @@ -2204,14 +2119,12 @@ public JsonElement Type /// /// Actions to execute if the AI answers no. /// - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo? OnNo + public ExtensionItemAITasksTaskYesNoOnNo? OnNo { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "on_no" - ); + return this._rawData.GetNullableClass("on_no"); } init { @@ -2227,12 +2140,12 @@ public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo? OnNo /// /// Actions to execute if the AI cannot determine the answer. /// - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown? OnUnknown + public ExtensionItemAITasksTaskYesNoOnUnknown? OnUnknown { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "on_unknown" ); } @@ -2250,14 +2163,12 @@ public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown? OnUnknown /// /// Actions to execute if the AI answers yes. /// - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYes? OnYes + public ExtensionItemAITasksTaskYesNoOnYes? OnYes { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "on_yes" - ); + return this._rawData.GetNullableClass("on_yes"); } init { @@ -2283,22 +2194,20 @@ public override void Validate() this.OnYes?.Validate(); } - public UnnamedSchemaWithArrayParent0AITasksTaskYesNo() + public ExtensionItemAITasksTaskYesNo() { this.Type = JsonSerializer.SerializeToElement("yes_no"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public UnnamedSchemaWithArrayParent0AITasksTaskYesNo( - UnnamedSchemaWithArrayParent0AITasksTaskYesNo unnamedSchemaWithArrayParent0AITasksTaskYesNo + public ExtensionItemAITasksTaskYesNo( + ExtensionItemAITasksTaskYesNo extensionItemAITasksTaskYesNo ) - : base(unnamedSchemaWithArrayParent0AITasksTaskYesNo) { } + : base(extensionItemAITasksTaskYesNo) { } #pragma warning restore CS8618 - public UnnamedSchemaWithArrayParent0AITasksTaskYesNo( - IReadOnlyDictionary rawData - ) + public ExtensionItemAITasksTaskYesNo(IReadOnlyDictionary rawData) { this._rawData = new(rawData); @@ -2307,14 +2216,14 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - UnnamedSchemaWithArrayParent0AITasksTaskYesNo(FrozenDictionary rawData) + ExtensionItemAITasksTaskYesNo(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static UnnamedSchemaWithArrayParent0AITasksTaskYesNo FromRawUnchecked( + /// + public static ExtensionItemAITasksTaskYesNo FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -2322,20 +2231,19 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public UnnamedSchemaWithArrayParent0AITasksTaskYesNo(string instruction) + public ExtensionItemAITasksTaskYesNo(string instruction) : this() { this.Instruction = instruction; } } -class UnnamedSchemaWithArrayParent0AITasksTaskYesNoFromRaw - : IFromRawJson +class ExtensionItemAITasksTaskYesNoFromRaw : IFromRawJson { /// - public UnnamedSchemaWithArrayParent0AITasksTaskYesNo FromRawUnchecked( + public ExtensionItemAITasksTaskYesNo FromRawUnchecked( IReadOnlyDictionary rawData - ) => UnnamedSchemaWithArrayParent0AITasksTaskYesNo.FromRawUnchecked(rawData); + ) => ExtensionItemAITasksTaskYesNo.FromRawUnchecked(rawData); } /// @@ -2343,11 +2251,11 @@ IReadOnlyDictionary rawData /// [JsonConverter( typeof(JsonModelConverter< - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo, - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoFromRaw + ExtensionItemAITasksTaskYesNoOnNo, + ExtensionItemAITasksTaskYesNoOnNoFromRaw >) )] -public sealed record class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo : JsonModel +public sealed record class ExtensionItemAITasksTaskYesNoOnNo : JsonModel { /// /// Array of tag strings to add to the asset. @@ -2400,13 +2308,13 @@ public IReadOnlyList? RemoveTags /// /// Array of custom metadata field updates. /// - public IReadOnlyList? SetMetadata + public IReadOnlyList? SetMetadata { get { this._rawData.Freeze(); return this._rawData.GetNullableStruct< - ImmutableArray + ImmutableArray >("set_metadata"); } init @@ -2416,7 +2324,7 @@ public IReadOnlyList?>( + this._rawData.Set?>( "set_metadata", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -2426,13 +2334,13 @@ public IReadOnlyList /// Array of custom metadata fields to remove. /// - public IReadOnlyList? UnsetMetadata + public IReadOnlyList? UnsetMetadata { get { this._rawData.Freeze(); return this._rawData.GetNullableStruct< - ImmutableArray + ImmutableArray >("unset_metadata"); } init @@ -2442,7 +2350,7 @@ public IReadOnlyList?>( + this._rawData.Set?>( "unset_metadata", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -2464,33 +2372,31 @@ public override void Validate() } } - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo() { } + public ExtensionItemAITasksTaskYesNoOnNo() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo( - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo unnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo + public ExtensionItemAITasksTaskYesNoOnNo( + ExtensionItemAITasksTaskYesNoOnNo extensionItemAITasksTaskYesNoOnNo ) - : base(unnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo) { } + : base(extensionItemAITasksTaskYesNoOnNo) { } #pragma warning restore CS8618 - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo( - IReadOnlyDictionary rawData - ) + public ExtensionItemAITasksTaskYesNoOnNo(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo(FrozenDictionary rawData) + ExtensionItemAITasksTaskYesNoOnNo(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo FromRawUnchecked( + /// + public static ExtensionItemAITasksTaskYesNoOnNo FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -2498,22 +2404,21 @@ IReadOnlyDictionary rawData } } -class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoFromRaw - : IFromRawJson +class ExtensionItemAITasksTaskYesNoOnNoFromRaw : IFromRawJson { /// - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo FromRawUnchecked( + public ExtensionItemAITasksTaskYesNoOnNo FromRawUnchecked( IReadOnlyDictionary rawData - ) => UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNo.FromRawUnchecked(rawData); + ) => ExtensionItemAITasksTaskYesNoOnNo.FromRawUnchecked(rawData); } [JsonConverter( typeof(JsonModelConverter< - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadata, - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataFromRaw + ExtensionItemAITasksTaskYesNoOnNoSetMetadata, + ExtensionItemAITasksTaskYesNoOnNoSetMetadataFromRaw >) )] -public sealed record class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadata : JsonModel +public sealed record class ExtensionItemAITasksTaskYesNoOnNoSetMetadata : JsonModel { /// /// Name of the custom metadata field to set. @@ -2532,12 +2437,12 @@ public required string Field /// Value to set for the custom metadata field. The value type should match the /// custom metadata field type. /// - public required UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue Value + public required ExtensionItemAITasksTaskYesNoOnNoSetMetadataValue Value { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "value" ); } @@ -2551,17 +2456,17 @@ public override void Validate() this.Value.Validate(); } - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadata() { } + public ExtensionItemAITasksTaskYesNoOnNoSetMetadata() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadata( - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadata unnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadata + public ExtensionItemAITasksTaskYesNoOnNoSetMetadata( + ExtensionItemAITasksTaskYesNoOnNoSetMetadata extensionItemAITasksTaskYesNoOnNoSetMetadata ) - : base(unnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadata) { } + : base(extensionItemAITasksTaskYesNoOnNoSetMetadata) { } #pragma warning restore CS8618 - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadata( + public ExtensionItemAITasksTaskYesNoOnNoSetMetadata( IReadOnlyDictionary rawData ) { @@ -2570,16 +2475,14 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadata( - FrozenDictionary rawData - ) + ExtensionItemAITasksTaskYesNoOnNoSetMetadata(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadata FromRawUnchecked( + /// + public static ExtensionItemAITasksTaskYesNoOnNoSetMetadata FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -2587,21 +2490,21 @@ IReadOnlyDictionary rawData } } -class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataFromRaw - : IFromRawJson +class ExtensionItemAITasksTaskYesNoOnNoSetMetadataFromRaw + : IFromRawJson { /// - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadata FromRawUnchecked( + public ExtensionItemAITasksTaskYesNoOnNoSetMetadata FromRawUnchecked( IReadOnlyDictionary rawData - ) => UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadata.FromRawUnchecked(rawData); + ) => ExtensionItemAITasksTaskYesNoOnNoSetMetadata.FromRawUnchecked(rawData); } /// /// Value to set for the custom metadata field. The value type should match the custom /// metadata field type. /// -[JsonConverter(typeof(UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueConverter))] -public record class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue : ModelBase +[JsonConverter(typeof(ExtensionItemAITasksTaskYesNoOnNoSetMetadataValueConverter))] +public record class ExtensionItemAITasksTaskYesNoOnNoSetMetadataValue : ModelBase { public object? Value { get; } = null; @@ -2618,7 +2521,7 @@ public JsonElement Json } } - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue( + public ExtensionItemAITasksTaskYesNoOnNoSetMetadataValue( string value, JsonElement? element = null ) @@ -2627,7 +2530,7 @@ public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue( this._element = element; } - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue( + public ExtensionItemAITasksTaskYesNoOnNoSetMetadataValue( double value, JsonElement? element = null ) @@ -2636,7 +2539,7 @@ public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue( this._element = element; } - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue( + public ExtensionItemAITasksTaskYesNoOnNoSetMetadataValue( bool value, JsonElement? element = null ) @@ -2645,8 +2548,8 @@ public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue( this._element = element; } - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue( - IReadOnlyList value, + public ExtensionItemAITasksTaskYesNoOnNoSetMetadataValue( + IReadOnlyList value, JsonElement? element = null ) { @@ -2654,7 +2557,7 @@ public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue( this._element = element; } - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue(JsonElement element) + public ExtensionItemAITasksTaskYesNoOnNoSetMetadataValue(JsonElement element) { this._element = element; } @@ -2724,14 +2627,14 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type where T is a UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem. + /// type where T is a ExtensionItemAITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem. /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickMixed(out var value)) { - /// // `value` is of type `IReadOnlyList<UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem>` + /// // `value` is of type `IReadOnlyList<ExtensionItemAITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem>` /// Console.WriteLine(value); /// } /// @@ -2739,12 +2642,12 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// public bool TryPickMixed( [NotNullWhen(true)] - out IReadOnlyList? value + out IReadOnlyList? value ) { value = this.Value - as IReadOnlyList; + as IReadOnlyList; return value != null; } @@ -2765,7 +2668,7 @@ out IReadOnlyList /// @@ -2775,7 +2678,7 @@ public void Switch( Action @double, Action @bool, Action< - IReadOnlyList + IReadOnlyList > mixed ) { @@ -2790,12 +2693,12 @@ public void Switch( case bool value: @bool(value); break; - case IReadOnlyList value: + case IReadOnlyList value: mixed(value); break; default: throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue" + "Data did not match any variant of ExtensionItemAITasksTaskYesNoOnNoSetMetadataValue" ); } } @@ -2818,7 +2721,7 @@ public void Switch( /// (string value) => {...}, /// (double value) => {...}, /// (bool value) => {...}, - /// (IReadOnlyList<UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem> value) => {...} + /// (IReadOnlyList<ExtensionItemAITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem> value) => {...} /// ); /// /// @@ -2828,7 +2731,7 @@ public T Match( Func @double, Func @bool, Func< - IReadOnlyList, + IReadOnlyList, T > mixed ) @@ -2838,32 +2741,30 @@ public T Match( string value => @string(value), double value => @double(value), bool value => @bool(value), - IReadOnlyList value => + IReadOnlyList value => mixed(value), _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue" + "Data did not match any variant of ExtensionItemAITasksTaskYesNoOnNoSetMetadataValue" ), }; } - public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue( + public static implicit operator ExtensionItemAITasksTaskYesNoOnNoSetMetadataValue( string value ) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue( + public static implicit operator ExtensionItemAITasksTaskYesNoOnNoSetMetadataValue( double value ) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue( - bool value - ) => new(value); + public static implicit operator ExtensionItemAITasksTaskYesNoOnNoSetMetadataValue(bool value) => + new(value); - public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue( - List value + public static implicit operator ExtensionItemAITasksTaskYesNoOnNoSetMetadataValue( + List value ) => new( - (IReadOnlyList) - value + (IReadOnlyList)value ); /// @@ -2881,7 +2782,7 @@ public override void Validate() if (this.Value == null) { throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue" + "Data did not match any variant of ExtensionItemAITasksTaskYesNoOnNoSetMetadataValue" ); } this.Switch( @@ -2898,9 +2799,7 @@ public override void Validate() ); } - public virtual bool Equals( - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue? other - ) => + public virtual bool Equals(ExtensionItemAITasksTaskYesNoOnNoSetMetadataValue? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -2923,17 +2822,17 @@ int VariantIndex() string _ => 0, double _ => 1, bool _ => 2, - IReadOnlyList _ => + IReadOnlyList _ => 3, _ => -1, }; } } -sealed class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueConverter - : JsonConverter +sealed class ExtensionItemAITasksTaskYesNoOnNoSetMetadataValueConverter + : JsonConverter { - public override UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue? Read( + public override ExtensionItemAITasksTaskYesNoOnNoSetMetadataValue? Read( ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options @@ -2974,7 +2873,7 @@ JsonSerializerOptions options try { var deserialized = JsonSerializer.Deserialize< - List + List >(element, options); if (deserialized != null) { @@ -2995,7 +2894,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValue value, + ExtensionItemAITasksTaskYesNoOnNoSetMetadataValue value, JsonSerializerOptions options ) { @@ -3003,11 +2902,8 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItemConverter) -)] -public record class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem - : ModelBase +[JsonConverter(typeof(ExtensionItemAITasksTaskYesNoOnNoSetMetadataValueMetadataValueItemConverter))] +public record class ExtensionItemAITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem : ModelBase { public object? Value { get; } = null; @@ -3024,7 +2920,7 @@ public JsonElement Json } } - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem( + public ExtensionItemAITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem( string value, JsonElement? element = null ) @@ -3033,7 +2929,7 @@ public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadata this._element = element; } - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem( + public ExtensionItemAITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem( double value, JsonElement? element = null ) @@ -3042,7 +2938,7 @@ public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadata this._element = element; } - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem( + public ExtensionItemAITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem( bool value, JsonElement? element = null ) @@ -3051,9 +2947,7 @@ public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadata this._element = element; } - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem( - JsonElement element - ) + public ExtensionItemAITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem(JsonElement element) { this._element = element; } @@ -3157,7 +3051,7 @@ public void Switch(Action @string, Action @double, Action break; default: throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem" + "Data did not match any variant of ExtensionItemAITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem" ); } } @@ -3192,20 +3086,20 @@ public T Match(Func @string, Func @double, Func @double(value), bool value => @bool(value), _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem" + "Data did not match any variant of ExtensionItemAITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem" ), }; } - public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem( + public static implicit operator ExtensionItemAITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem( string value ) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem( + public static implicit operator ExtensionItemAITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem( double value ) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem( + public static implicit operator ExtensionItemAITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem( bool value ) => new(value); @@ -3224,13 +3118,13 @@ public override void Validate() if (this.Value == null) { throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem" + "Data did not match any variant of ExtensionItemAITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem" ); } } public virtual bool Equals( - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem? other + ExtensionItemAITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem? other ) => other != null && this.VariantIndex() == other.VariantIndex() @@ -3259,10 +3153,10 @@ int VariantIndex() } } -sealed class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItemConverter - : JsonConverter +sealed class ExtensionItemAITasksTaskYesNoOnNoSetMetadataValueMetadataValueItemConverter + : JsonConverter { - public override UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem? Read( + public override ExtensionItemAITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem? Read( ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options @@ -3305,7 +3199,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem value, + ExtensionItemAITasksTaskYesNoOnNoSetMetadataValueMetadataValueItem value, JsonSerializerOptions options ) { @@ -3315,12 +3209,11 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoUnsetMetadata, - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoUnsetMetadataFromRaw + ExtensionItemAITasksTaskYesNoOnNoUnsetMetadata, + ExtensionItemAITasksTaskYesNoOnNoUnsetMetadataFromRaw >) )] -public sealed record class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoUnsetMetadata - : JsonModel +public sealed record class ExtensionItemAITasksTaskYesNoOnNoUnsetMetadata : JsonModel { /// /// Name of the custom metadata field to remove. @@ -3341,17 +3234,17 @@ public override void Validate() _ = this.Field; } - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoUnsetMetadata() { } + public ExtensionItemAITasksTaskYesNoOnNoUnsetMetadata() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoUnsetMetadata( - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoUnsetMetadata unnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoUnsetMetadata + public ExtensionItemAITasksTaskYesNoOnNoUnsetMetadata( + ExtensionItemAITasksTaskYesNoOnNoUnsetMetadata extensionItemAITasksTaskYesNoOnNoUnsetMetadata ) - : base(unnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoUnsetMetadata) { } + : base(extensionItemAITasksTaskYesNoOnNoUnsetMetadata) { } #pragma warning restore CS8618 - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoUnsetMetadata( + public ExtensionItemAITasksTaskYesNoOnNoUnsetMetadata( IReadOnlyDictionary rawData ) { @@ -3360,16 +3253,14 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoUnsetMetadata( - FrozenDictionary rawData - ) + ExtensionItemAITasksTaskYesNoOnNoUnsetMetadata(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoUnsetMetadata FromRawUnchecked( + /// + public static ExtensionItemAITasksTaskYesNoOnNoUnsetMetadata FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -3377,20 +3268,20 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoUnsetMetadata(string field) + public ExtensionItemAITasksTaskYesNoOnNoUnsetMetadata(string field) : this() { this.Field = field; } } -class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoUnsetMetadataFromRaw - : IFromRawJson +class ExtensionItemAITasksTaskYesNoOnNoUnsetMetadataFromRaw + : IFromRawJson { /// - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoUnsetMetadata FromRawUnchecked( + public ExtensionItemAITasksTaskYesNoOnNoUnsetMetadata FromRawUnchecked( IReadOnlyDictionary rawData - ) => UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnNoUnsetMetadata.FromRawUnchecked(rawData); + ) => ExtensionItemAITasksTaskYesNoOnNoUnsetMetadata.FromRawUnchecked(rawData); } /// @@ -3398,11 +3289,11 @@ IReadOnlyDictionary rawData /// [JsonConverter( typeof(JsonModelConverter< - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown, - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownFromRaw + ExtensionItemAITasksTaskYesNoOnUnknown, + ExtensionItemAITasksTaskYesNoOnUnknownFromRaw >) )] -public sealed record class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown : JsonModel +public sealed record class ExtensionItemAITasksTaskYesNoOnUnknown : JsonModel { /// /// Array of tag strings to add to the asset. @@ -3455,13 +3346,13 @@ public IReadOnlyList? RemoveTags /// /// Array of custom metadata field updates. /// - public IReadOnlyList? SetMetadata + public IReadOnlyList? SetMetadata { get { this._rawData.Freeze(); return this._rawData.GetNullableStruct< - ImmutableArray + ImmutableArray >("set_metadata"); } init @@ -3471,7 +3362,7 @@ public IReadOnlyList?>( + this._rawData.Set?>( "set_metadata", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -3481,13 +3372,13 @@ public IReadOnlyList /// Array of custom metadata fields to remove. /// - public IReadOnlyList? UnsetMetadata + public IReadOnlyList? UnsetMetadata { get { this._rawData.Freeze(); return this._rawData.GetNullableStruct< - ImmutableArray + ImmutableArray >("unset_metadata"); } init @@ -3497,7 +3388,7 @@ public IReadOnlyList?>( + this._rawData.Set?>( "unset_metadata", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -3519,35 +3410,31 @@ public override void Validate() } } - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown() { } + public ExtensionItemAITasksTaskYesNoOnUnknown() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown( - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown unnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown + public ExtensionItemAITasksTaskYesNoOnUnknown( + ExtensionItemAITasksTaskYesNoOnUnknown extensionItemAITasksTaskYesNoOnUnknown ) - : base(unnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown) { } + : base(extensionItemAITasksTaskYesNoOnUnknown) { } #pragma warning restore CS8618 - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown( - IReadOnlyDictionary rawData - ) + public ExtensionItemAITasksTaskYesNoOnUnknown(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown( - FrozenDictionary rawData - ) + ExtensionItemAITasksTaskYesNoOnUnknown(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown FromRawUnchecked( + /// + public static ExtensionItemAITasksTaskYesNoOnUnknown FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -3555,23 +3442,22 @@ IReadOnlyDictionary rawData } } -class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownFromRaw - : IFromRawJson +class ExtensionItemAITasksTaskYesNoOnUnknownFromRaw + : IFromRawJson { /// - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown FromRawUnchecked( + public ExtensionItemAITasksTaskYesNoOnUnknown FromRawUnchecked( IReadOnlyDictionary rawData - ) => UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknown.FromRawUnchecked(rawData); + ) => ExtensionItemAITasksTaskYesNoOnUnknown.FromRawUnchecked(rawData); } [JsonConverter( typeof(JsonModelConverter< - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadata, - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataFromRaw + ExtensionItemAITasksTaskYesNoOnUnknownSetMetadata, + ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataFromRaw >) )] -public sealed record class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadata - : JsonModel +public sealed record class ExtensionItemAITasksTaskYesNoOnUnknownSetMetadata : JsonModel { /// /// Name of the custom metadata field to set. @@ -3590,12 +3476,12 @@ public required string Field /// Value to set for the custom metadata field. The value type should match the /// custom metadata field type. /// - public required UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue Value + public required ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValue Value { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "value" ); } @@ -3609,17 +3495,17 @@ public override void Validate() this.Value.Validate(); } - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadata() { } + public ExtensionItemAITasksTaskYesNoOnUnknownSetMetadata() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadata( - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadata unnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadata + public ExtensionItemAITasksTaskYesNoOnUnknownSetMetadata( + ExtensionItemAITasksTaskYesNoOnUnknownSetMetadata extensionItemAITasksTaskYesNoOnUnknownSetMetadata ) - : base(unnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadata) { } + : base(extensionItemAITasksTaskYesNoOnUnknownSetMetadata) { } #pragma warning restore CS8618 - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadata( + public ExtensionItemAITasksTaskYesNoOnUnknownSetMetadata( IReadOnlyDictionary rawData ) { @@ -3628,16 +3514,14 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadata( - FrozenDictionary rawData - ) + ExtensionItemAITasksTaskYesNoOnUnknownSetMetadata(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadata FromRawUnchecked( + /// + public static ExtensionItemAITasksTaskYesNoOnUnknownSetMetadata FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -3645,25 +3529,21 @@ IReadOnlyDictionary rawData } } -class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataFromRaw - : IFromRawJson +class ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataFromRaw + : IFromRawJson { /// - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadata FromRawUnchecked( + public ExtensionItemAITasksTaskYesNoOnUnknownSetMetadata FromRawUnchecked( IReadOnlyDictionary rawData - ) => - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadata.FromRawUnchecked(rawData); + ) => ExtensionItemAITasksTaskYesNoOnUnknownSetMetadata.FromRawUnchecked(rawData); } /// /// Value to set for the custom metadata field. The value type should match the custom /// metadata field type. /// -[JsonConverter( - typeof(UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueConverter) -)] -public record class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue - : ModelBase +[JsonConverter(typeof(ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValueConverter))] +public record class ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValue : ModelBase { public object? Value { get; } = null; @@ -3680,7 +3560,7 @@ public JsonElement Json } } - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue( + public ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValue( string value, JsonElement? element = null ) @@ -3689,7 +3569,7 @@ public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue( this._element = element; } - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue( + public ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValue( double value, JsonElement? element = null ) @@ -3698,7 +3578,7 @@ public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue( this._element = element; } - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue( + public ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValue( bool value, JsonElement? element = null ) @@ -3707,8 +3587,8 @@ public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue( this._element = element; } - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue( - IReadOnlyList value, + public ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValue( + IReadOnlyList value, JsonElement? element = null ) { @@ -3716,9 +3596,7 @@ public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue( this._element = element; } - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue( - JsonElement element - ) + public ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValue(JsonElement element) { this._element = element; } @@ -3788,14 +3666,14 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type where T is a UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem. + /// type where T is a ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem. /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickMixed(out var value)) { - /// // `value` is of type `IReadOnlyList<UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem>` + /// // `value` is of type `IReadOnlyList<ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem>` /// Console.WriteLine(value); /// } /// @@ -3803,12 +3681,12 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// public bool TryPickMixed( [NotNullWhen(true)] - out IReadOnlyList? value + out IReadOnlyList? value ) { value = this.Value - as IReadOnlyList; + as IReadOnlyList; return value != null; } @@ -3829,7 +3707,7 @@ out IReadOnlyList /// @@ -3839,7 +3717,7 @@ public void Switch( Action @double, Action @bool, Action< - IReadOnlyList + IReadOnlyList > mixed ) { @@ -3854,12 +3732,12 @@ public void Switch( case bool value: @bool(value); break; - case IReadOnlyList value: + case IReadOnlyList value: mixed(value); break; default: throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue" + "Data did not match any variant of ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValue" ); } } @@ -3882,7 +3760,7 @@ public void Switch( /// (string value) => {...}, /// (double value) => {...}, /// (bool value) => {...}, - /// (IReadOnlyList<UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem> value) => {...} + /// (IReadOnlyList<ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem> value) => {...} /// ); /// /// @@ -3892,7 +3770,7 @@ public T Match( Func @double, Func @bool, Func< - IReadOnlyList, + IReadOnlyList, T > mixed ) @@ -3902,31 +3780,31 @@ public T Match( string value => @string(value), double value => @double(value), bool value => @bool(value), - IReadOnlyList value => + IReadOnlyList value => mixed(value), _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue" + "Data did not match any variant of ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValue" ), }; } - public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue( + public static implicit operator ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValue( string value ) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue( + public static implicit operator ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValue( double value ) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue( + public static implicit operator ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValue( bool value ) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue( - List value + public static implicit operator ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValue( + List value ) => new( - (IReadOnlyList) + (IReadOnlyList) value ); @@ -3945,7 +3823,7 @@ public override void Validate() if (this.Value == null) { throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue" + "Data did not match any variant of ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValue" ); } this.Switch( @@ -3962,9 +3840,7 @@ public override void Validate() ); } - public virtual bool Equals( - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue? other - ) => + public virtual bool Equals(ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValue? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -3987,17 +3863,17 @@ int VariantIndex() string _ => 0, double _ => 1, bool _ => 2, - IReadOnlyList _ => + IReadOnlyList _ => 3, _ => -1, }; } } -sealed class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueConverter - : JsonConverter +sealed class ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValueConverter + : JsonConverter { - public override UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue? Read( + public override ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValue? Read( ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options @@ -4038,7 +3914,7 @@ JsonSerializerOptions options try { var deserialized = JsonSerializer.Deserialize< - List + List >(element, options); if (deserialized != null) { @@ -4059,7 +3935,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValue value, + ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValue value, JsonSerializerOptions options ) { @@ -4068,9 +3944,9 @@ JsonSerializerOptions options } [JsonConverter( - typeof(UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItemConverter) + typeof(ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItemConverter) )] -public record class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem +public record class ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem : ModelBase { public object? Value { get; } = null; @@ -4088,7 +3964,7 @@ public JsonElement Json } } - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem( + public ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem( string value, JsonElement? element = null ) @@ -4097,7 +3973,7 @@ public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMet this._element = element; } - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem( + public ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem( double value, JsonElement? element = null ) @@ -4106,7 +3982,7 @@ public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMet this._element = element; } - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem( + public ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem( bool value, JsonElement? element = null ) @@ -4115,7 +3991,7 @@ public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMet this._element = element; } - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem( + public ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem( JsonElement element ) { @@ -4221,7 +4097,7 @@ public void Switch(Action @string, Action @double, Action break; default: throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem" + "Data did not match any variant of ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem" ); } } @@ -4256,20 +4132,20 @@ public T Match(Func @string, Func @double, Func @double(value), bool value => @bool(value), _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem" + "Data did not match any variant of ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem" ), }; } - public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem( + public static implicit operator ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem( string value ) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem( + public static implicit operator ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem( double value ) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem( + public static implicit operator ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem( bool value ) => new(value); @@ -4288,13 +4164,13 @@ public override void Validate() if (this.Value == null) { throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem" + "Data did not match any variant of ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem" ); } } public virtual bool Equals( - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem? other + ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem? other ) => other != null && this.VariantIndex() == other.VariantIndex() @@ -4323,10 +4199,10 @@ int VariantIndex() } } -sealed class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItemConverter - : JsonConverter +sealed class ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItemConverter + : JsonConverter { - public override UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem? Read( + public override ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem? Read( ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options @@ -4369,7 +4245,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem value, + ExtensionItemAITasksTaskYesNoOnUnknownSetMetadataValueMetadataValueItem value, JsonSerializerOptions options ) { @@ -4379,12 +4255,11 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownUnsetMetadata, - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownUnsetMetadataFromRaw + ExtensionItemAITasksTaskYesNoOnUnknownUnsetMetadata, + ExtensionItemAITasksTaskYesNoOnUnknownUnsetMetadataFromRaw >) )] -public sealed record class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownUnsetMetadata - : JsonModel +public sealed record class ExtensionItemAITasksTaskYesNoOnUnknownUnsetMetadata : JsonModel { /// /// Name of the custom metadata field to remove. @@ -4405,17 +4280,17 @@ public override void Validate() _ = this.Field; } - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownUnsetMetadata() { } + public ExtensionItemAITasksTaskYesNoOnUnknownUnsetMetadata() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownUnsetMetadata( - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownUnsetMetadata unnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownUnsetMetadata + public ExtensionItemAITasksTaskYesNoOnUnknownUnsetMetadata( + ExtensionItemAITasksTaskYesNoOnUnknownUnsetMetadata extensionItemAITasksTaskYesNoOnUnknownUnsetMetadata ) - : base(unnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownUnsetMetadata) { } + : base(extensionItemAITasksTaskYesNoOnUnknownUnsetMetadata) { } #pragma warning restore CS8618 - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownUnsetMetadata( + public ExtensionItemAITasksTaskYesNoOnUnknownUnsetMetadata( IReadOnlyDictionary rawData ) { @@ -4424,7 +4299,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownUnsetMetadata( + ExtensionItemAITasksTaskYesNoOnUnknownUnsetMetadata( FrozenDictionary rawData ) { @@ -4432,8 +4307,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownUnsetMetadata FromRawUnchecked( + /// + public static ExtensionItemAITasksTaskYesNoOnUnknownUnsetMetadata FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -4441,23 +4316,20 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownUnsetMetadata(string field) + public ExtensionItemAITasksTaskYesNoOnUnknownUnsetMetadata(string field) : this() { this.Field = field; } } -class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownUnsetMetadataFromRaw - : IFromRawJson +class ExtensionItemAITasksTaskYesNoOnUnknownUnsetMetadataFromRaw + : IFromRawJson { /// - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownUnsetMetadata FromRawUnchecked( + public ExtensionItemAITasksTaskYesNoOnUnknownUnsetMetadata FromRawUnchecked( IReadOnlyDictionary rawData - ) => - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnUnknownUnsetMetadata.FromRawUnchecked( - rawData - ); + ) => ExtensionItemAITasksTaskYesNoOnUnknownUnsetMetadata.FromRawUnchecked(rawData); } /// @@ -4465,11 +4337,11 @@ IReadOnlyDictionary rawData /// [JsonConverter( typeof(JsonModelConverter< - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYes, - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesFromRaw + ExtensionItemAITasksTaskYesNoOnYes, + ExtensionItemAITasksTaskYesNoOnYesFromRaw >) )] -public sealed record class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYes : JsonModel +public sealed record class ExtensionItemAITasksTaskYesNoOnYes : JsonModel { /// /// Array of tag strings to add to the asset. @@ -4522,13 +4394,13 @@ public IReadOnlyList? RemoveTags /// /// Array of custom metadata field updates. /// - public IReadOnlyList? SetMetadata + public IReadOnlyList? SetMetadata { get { this._rawData.Freeze(); return this._rawData.GetNullableStruct< - ImmutableArray + ImmutableArray >("set_metadata"); } init @@ -4538,7 +4410,7 @@ public IReadOnlyList?>( + this._rawData.Set?>( "set_metadata", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -4548,13 +4420,13 @@ public IReadOnlyList /// Array of custom metadata fields to remove. /// - public IReadOnlyList? UnsetMetadata + public IReadOnlyList? UnsetMetadata { get { this._rawData.Freeze(); return this._rawData.GetNullableStruct< - ImmutableArray + ImmutableArray >("unset_metadata"); } init @@ -4564,7 +4436,7 @@ public IReadOnlyList?>( + this._rawData.Set?>( "unset_metadata", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -4586,35 +4458,31 @@ public override void Validate() } } - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYes() { } + public ExtensionItemAITasksTaskYesNoOnYes() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYes( - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYes unnamedSchemaWithArrayParent0AITasksTaskYesNoOnYes + public ExtensionItemAITasksTaskYesNoOnYes( + ExtensionItemAITasksTaskYesNoOnYes extensionItemAITasksTaskYesNoOnYes ) - : base(unnamedSchemaWithArrayParent0AITasksTaskYesNoOnYes) { } + : base(extensionItemAITasksTaskYesNoOnYes) { } #pragma warning restore CS8618 - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYes( - IReadOnlyDictionary rawData - ) + public ExtensionItemAITasksTaskYesNoOnYes(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYes( - FrozenDictionary rawData - ) + ExtensionItemAITasksTaskYesNoOnYes(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYes FromRawUnchecked( + /// + public static ExtensionItemAITasksTaskYesNoOnYes FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -4622,22 +4490,21 @@ IReadOnlyDictionary rawData } } -class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesFromRaw - : IFromRawJson +class ExtensionItemAITasksTaskYesNoOnYesFromRaw : IFromRawJson { /// - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYes FromRawUnchecked( + public ExtensionItemAITasksTaskYesNoOnYes FromRawUnchecked( IReadOnlyDictionary rawData - ) => UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYes.FromRawUnchecked(rawData); + ) => ExtensionItemAITasksTaskYesNoOnYes.FromRawUnchecked(rawData); } [JsonConverter( typeof(JsonModelConverter< - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadata, - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataFromRaw + ExtensionItemAITasksTaskYesNoOnYesSetMetadata, + ExtensionItemAITasksTaskYesNoOnYesSetMetadataFromRaw >) )] -public sealed record class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadata : JsonModel +public sealed record class ExtensionItemAITasksTaskYesNoOnYesSetMetadata : JsonModel { /// /// Name of the custom metadata field to set. @@ -4656,12 +4523,12 @@ public required string Field /// Value to set for the custom metadata field. The value type should match the /// custom metadata field type. /// - public required UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue Value + public required ExtensionItemAITasksTaskYesNoOnYesSetMetadataValue Value { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "value" ); } @@ -4675,17 +4542,17 @@ public override void Validate() this.Value.Validate(); } - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadata() { } + public ExtensionItemAITasksTaskYesNoOnYesSetMetadata() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadata( - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadata unnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadata + public ExtensionItemAITasksTaskYesNoOnYesSetMetadata( + ExtensionItemAITasksTaskYesNoOnYesSetMetadata extensionItemAITasksTaskYesNoOnYesSetMetadata ) - : base(unnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadata) { } + : base(extensionItemAITasksTaskYesNoOnYesSetMetadata) { } #pragma warning restore CS8618 - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadata( + public ExtensionItemAITasksTaskYesNoOnYesSetMetadata( IReadOnlyDictionary rawData ) { @@ -4694,16 +4561,14 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadata( - FrozenDictionary rawData - ) + ExtensionItemAITasksTaskYesNoOnYesSetMetadata(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadata FromRawUnchecked( + /// + public static ExtensionItemAITasksTaskYesNoOnYesSetMetadata FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -4711,21 +4576,21 @@ IReadOnlyDictionary rawData } } -class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataFromRaw - : IFromRawJson +class ExtensionItemAITasksTaskYesNoOnYesSetMetadataFromRaw + : IFromRawJson { /// - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadata FromRawUnchecked( + public ExtensionItemAITasksTaskYesNoOnYesSetMetadata FromRawUnchecked( IReadOnlyDictionary rawData - ) => UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadata.FromRawUnchecked(rawData); + ) => ExtensionItemAITasksTaskYesNoOnYesSetMetadata.FromRawUnchecked(rawData); } /// /// Value to set for the custom metadata field. The value type should match the custom /// metadata field type. /// -[JsonConverter(typeof(UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueConverter))] -public record class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue : ModelBase +[JsonConverter(typeof(ExtensionItemAITasksTaskYesNoOnYesSetMetadataValueConverter))] +public record class ExtensionItemAITasksTaskYesNoOnYesSetMetadataValue : ModelBase { public object? Value { get; } = null; @@ -4742,7 +4607,7 @@ public JsonElement Json } } - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue( + public ExtensionItemAITasksTaskYesNoOnYesSetMetadataValue( string value, JsonElement? element = null ) @@ -4751,7 +4616,7 @@ public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue( this._element = element; } - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue( + public ExtensionItemAITasksTaskYesNoOnYesSetMetadataValue( double value, JsonElement? element = null ) @@ -4760,7 +4625,7 @@ public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue( this._element = element; } - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue( + public ExtensionItemAITasksTaskYesNoOnYesSetMetadataValue( bool value, JsonElement? element = null ) @@ -4769,8 +4634,8 @@ public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue( this._element = element; } - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue( - IReadOnlyList value, + public ExtensionItemAITasksTaskYesNoOnYesSetMetadataValue( + IReadOnlyList value, JsonElement? element = null ) { @@ -4778,7 +4643,7 @@ public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue( this._element = element; } - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue(JsonElement element) + public ExtensionItemAITasksTaskYesNoOnYesSetMetadataValue(JsonElement element) { this._element = element; } @@ -4848,14 +4713,14 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type where T is a UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem. + /// type where T is a ExtensionItemAITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem. /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickMixed(out var value)) { - /// // `value` is of type `IReadOnlyList<UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem>` + /// // `value` is of type `IReadOnlyList<ExtensionItemAITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem>` /// Console.WriteLine(value); /// } /// @@ -4863,12 +4728,12 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// public bool TryPickMixed( [NotNullWhen(true)] - out IReadOnlyList? value + out IReadOnlyList? value ) { value = this.Value - as IReadOnlyList; + as IReadOnlyList; return value != null; } @@ -4889,7 +4754,7 @@ out IReadOnlyList /// @@ -4899,7 +4764,7 @@ public void Switch( Action @double, Action @bool, Action< - IReadOnlyList + IReadOnlyList > mixed ) { @@ -4914,12 +4779,12 @@ public void Switch( case bool value: @bool(value); break; - case IReadOnlyList value: + case IReadOnlyList value: mixed(value); break; default: throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue" + "Data did not match any variant of ExtensionItemAITasksTaskYesNoOnYesSetMetadataValue" ); } } @@ -4942,7 +4807,7 @@ public void Switch( /// (string value) => {...}, /// (double value) => {...}, /// (bool value) => {...}, - /// (IReadOnlyList<UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem> value) => {...} + /// (IReadOnlyList<ExtensionItemAITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem> value) => {...} /// ); /// /// @@ -4952,7 +4817,7 @@ public T Match( Func @double, Func @bool, Func< - IReadOnlyList, + IReadOnlyList, T > mixed ) @@ -4962,31 +4827,31 @@ public T Match( string value => @string(value), double value => @double(value), bool value => @bool(value), - IReadOnlyList value => + IReadOnlyList value => mixed(value), _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue" + "Data did not match any variant of ExtensionItemAITasksTaskYesNoOnYesSetMetadataValue" ), }; } - public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue( + public static implicit operator ExtensionItemAITasksTaskYesNoOnYesSetMetadataValue( string value ) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue( + public static implicit operator ExtensionItemAITasksTaskYesNoOnYesSetMetadataValue( double value ) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue( + public static implicit operator ExtensionItemAITasksTaskYesNoOnYesSetMetadataValue( bool value ) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue( - List value + public static implicit operator ExtensionItemAITasksTaskYesNoOnYesSetMetadataValue( + List value ) => new( - (IReadOnlyList) + (IReadOnlyList) value ); @@ -5005,7 +4870,7 @@ public override void Validate() if (this.Value == null) { throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue" + "Data did not match any variant of ExtensionItemAITasksTaskYesNoOnYesSetMetadataValue" ); } this.Switch( @@ -5022,9 +4887,7 @@ public override void Validate() ); } - public virtual bool Equals( - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue? other - ) => + public virtual bool Equals(ExtensionItemAITasksTaskYesNoOnYesSetMetadataValue? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -5047,17 +4910,17 @@ int VariantIndex() string _ => 0, double _ => 1, bool _ => 2, - IReadOnlyList _ => + IReadOnlyList _ => 3, _ => -1, }; } } -sealed class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueConverter - : JsonConverter +sealed class ExtensionItemAITasksTaskYesNoOnYesSetMetadataValueConverter + : JsonConverter { - public override UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue? Read( + public override ExtensionItemAITasksTaskYesNoOnYesSetMetadataValue? Read( ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options @@ -5098,7 +4961,7 @@ JsonSerializerOptions options try { var deserialized = JsonSerializer.Deserialize< - List + List >(element, options); if (deserialized != null) { @@ -5119,7 +4982,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValue value, + ExtensionItemAITasksTaskYesNoOnYesSetMetadataValue value, JsonSerializerOptions options ) { @@ -5128,10 +4991,9 @@ JsonSerializerOptions options } [JsonConverter( - typeof(UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItemConverter) + typeof(ExtensionItemAITasksTaskYesNoOnYesSetMetadataValueMetadataValueItemConverter) )] -public record class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem - : ModelBase +public record class ExtensionItemAITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem : ModelBase { public object? Value { get; } = null; @@ -5148,7 +5010,7 @@ public JsonElement Json } } - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem( + public ExtensionItemAITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem( string value, JsonElement? element = null ) @@ -5157,7 +5019,7 @@ public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadat this._element = element; } - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem( + public ExtensionItemAITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem( double value, JsonElement? element = null ) @@ -5166,7 +5028,7 @@ public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadat this._element = element; } - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem( + public ExtensionItemAITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem( bool value, JsonElement? element = null ) @@ -5175,9 +5037,7 @@ public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadat this._element = element; } - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem( - JsonElement element - ) + public ExtensionItemAITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem(JsonElement element) { this._element = element; } @@ -5281,7 +5141,7 @@ public void Switch(Action @string, Action @double, Action break; default: throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem" + "Data did not match any variant of ExtensionItemAITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem" ); } } @@ -5316,20 +5176,20 @@ public T Match(Func @string, Func @double, Func @double(value), bool value => @bool(value), _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem" + "Data did not match any variant of ExtensionItemAITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem" ), }; } - public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem( + public static implicit operator ExtensionItemAITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem( string value ) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem( + public static implicit operator ExtensionItemAITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem( double value ) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem( + public static implicit operator ExtensionItemAITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem( bool value ) => new(value); @@ -5348,13 +5208,13 @@ public override void Validate() if (this.Value == null) { throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem" + "Data did not match any variant of ExtensionItemAITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem" ); } } public virtual bool Equals( - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem? other + ExtensionItemAITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem? other ) => other != null && this.VariantIndex() == other.VariantIndex() @@ -5383,10 +5243,10 @@ int VariantIndex() } } -sealed class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItemConverter - : JsonConverter +sealed class ExtensionItemAITasksTaskYesNoOnYesSetMetadataValueMetadataValueItemConverter + : JsonConverter { - public override UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem? Read( + public override ExtensionItemAITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem? Read( ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options @@ -5429,7 +5289,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem value, + ExtensionItemAITasksTaskYesNoOnYesSetMetadataValueMetadataValueItem value, JsonSerializerOptions options ) { @@ -5439,12 +5299,11 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesUnsetMetadata, - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesUnsetMetadataFromRaw + ExtensionItemAITasksTaskYesNoOnYesUnsetMetadata, + ExtensionItemAITasksTaskYesNoOnYesUnsetMetadataFromRaw >) )] -public sealed record class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesUnsetMetadata - : JsonModel +public sealed record class ExtensionItemAITasksTaskYesNoOnYesUnsetMetadata : JsonModel { /// /// Name of the custom metadata field to remove. @@ -5465,17 +5324,17 @@ public override void Validate() _ = this.Field; } - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesUnsetMetadata() { } + public ExtensionItemAITasksTaskYesNoOnYesUnsetMetadata() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesUnsetMetadata( - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesUnsetMetadata unnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesUnsetMetadata + public ExtensionItemAITasksTaskYesNoOnYesUnsetMetadata( + ExtensionItemAITasksTaskYesNoOnYesUnsetMetadata extensionItemAITasksTaskYesNoOnYesUnsetMetadata ) - : base(unnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesUnsetMetadata) { } + : base(extensionItemAITasksTaskYesNoOnYesUnsetMetadata) { } #pragma warning restore CS8618 - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesUnsetMetadata( + public ExtensionItemAITasksTaskYesNoOnYesUnsetMetadata( IReadOnlyDictionary rawData ) { @@ -5484,16 +5343,14 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesUnsetMetadata( - FrozenDictionary rawData - ) + ExtensionItemAITasksTaskYesNoOnYesUnsetMetadata(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesUnsetMetadata FromRawUnchecked( + /// + public static ExtensionItemAITasksTaskYesNoOnYesUnsetMetadata FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5501,20 +5358,20 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesUnsetMetadata(string field) + public ExtensionItemAITasksTaskYesNoOnYesUnsetMetadata(string field) : this() { this.Field = field; } } -class UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesUnsetMetadataFromRaw - : IFromRawJson +class ExtensionItemAITasksTaskYesNoOnYesUnsetMetadataFromRaw + : IFromRawJson { /// - public UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesUnsetMetadata FromRawUnchecked( + public ExtensionItemAITasksTaskYesNoOnYesUnsetMetadata FromRawUnchecked( IReadOnlyDictionary rawData - ) => UnnamedSchemaWithArrayParent0AITasksTaskYesNoOnYesUnsetMetadata.FromRawUnchecked(rawData); + ) => ExtensionItemAITasksTaskYesNoOnYesUnsetMetadata.FromRawUnchecked(rawData); } [JsonConverter(typeof(JsonModelConverter))] diff --git a/src/Imagekit/Models/Files/File.cs b/src/Imagekit/Models/Files/File.cs index 665285cc..760786c0 100644 --- a/src/Imagekit/Models/Files/File.cs +++ b/src/Imagekit/Models/Files/File.cs @@ -1199,7 +1199,7 @@ public DefaultValue(bool value, JsonElement? element = null) } public DefaultValue( - IReadOnlyList value, + IReadOnlyList value, JsonElement? element = null ) { @@ -1277,24 +1277,24 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type where T is a UnnamedSchemaWithArrayParent1. + /// type where T is a UnnamedSchemaWithArrayParent0. /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickMixed(out var value)) { - /// // `value` is of type `IReadOnlyList<UnnamedSchemaWithArrayParent1>` + /// // `value` is of type `IReadOnlyList<UnnamedSchemaWithArrayParent0>` /// Console.WriteLine(value); /// } /// /// /// public bool TryPickMixed( - [NotNullWhen(true)] out IReadOnlyList? value + [NotNullWhen(true)] out IReadOnlyList? value ) { - value = this.Value as IReadOnlyList; + value = this.Value as IReadOnlyList; return value != null; } @@ -1315,7 +1315,7 @@ public bool TryPickMixed( /// (string value) => {...}, /// (double value) => {...}, /// (bool value) => {...}, - /// (IReadOnlyList<UnnamedSchemaWithArrayParent1> value) => {...} + /// (IReadOnlyList<UnnamedSchemaWithArrayParent0> value) => {...} /// ); /// /// @@ -1324,7 +1324,7 @@ public void Switch( System::Action @string, System::Action @double, System::Action @bool, - System::Action> mixed + System::Action> mixed ) { switch (this.Value) @@ -1338,7 +1338,7 @@ public void Switch( case bool value: @bool(value); break; - case IReadOnlyList value: + case IReadOnlyList value: mixed(value); break; default: @@ -1366,7 +1366,7 @@ public void Switch( /// (string value) => {...}, /// (double value) => {...}, /// (bool value) => {...}, - /// (IReadOnlyList<UnnamedSchemaWithArrayParent1> value) => {...} + /// (IReadOnlyList<UnnamedSchemaWithArrayParent0> value) => {...} /// ); /// /// @@ -1375,7 +1375,7 @@ public T Match( System::Func @string, System::Func @double, System::Func @bool, - System::Func, T> mixed + System::Func, T> mixed ) { return this.Value switch @@ -1383,7 +1383,7 @@ public T Match( string value => @string(value), double value => @double(value), bool value => @bool(value), - IReadOnlyList value => mixed(value), + IReadOnlyList value => mixed(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of DefaultValue" ), @@ -1396,8 +1396,8 @@ public T Match( public static implicit operator DefaultValue(bool value) => new(value); - public static implicit operator DefaultValue(List value) => - new((IReadOnlyList)value); + public static implicit operator DefaultValue(List value) => + new((IReadOnlyList)value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -1454,7 +1454,7 @@ int VariantIndex() string _ => 0, double _ => 1, bool _ => 2, - IReadOnlyList _ => 3, + IReadOnlyList _ => 3, _ => -1, }; } @@ -1502,7 +1502,7 @@ JsonSerializerOptions options try { - var deserialized = JsonSerializer.Deserialize>( + var deserialized = JsonSerializer.Deserialize>( element, options ); @@ -1533,8 +1533,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(UnnamedSchemaWithArrayParent1Converter))] -public record class UnnamedSchemaWithArrayParent1 : ModelBase +[JsonConverter(typeof(UnnamedSchemaWithArrayParent0Converter))] +public record class UnnamedSchemaWithArrayParent0 : ModelBase { public object? Value { get; } = null; @@ -1551,25 +1551,25 @@ public JsonElement Json } } - public UnnamedSchemaWithArrayParent1(string value, JsonElement? element = null) + public UnnamedSchemaWithArrayParent0(string value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent1(double value, JsonElement? element = null) + public UnnamedSchemaWithArrayParent0(double value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent1(bool value, JsonElement? element = null) + public UnnamedSchemaWithArrayParent0(bool value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent1(JsonElement element) + public UnnamedSchemaWithArrayParent0(JsonElement element) { this._element = element; } @@ -1677,7 +1677,7 @@ public void Switch( break; default: throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent1" + "Data did not match any variant of UnnamedSchemaWithArrayParent0" ); } } @@ -1716,16 +1716,16 @@ public T Match( double value => @double(value), bool value => @bool(value), _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent1" + "Data did not match any variant of UnnamedSchemaWithArrayParent0" ), }; } - public static implicit operator UnnamedSchemaWithArrayParent1(string value) => new(value); + public static implicit operator UnnamedSchemaWithArrayParent0(string value) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent1(double value) => new(value); + public static implicit operator UnnamedSchemaWithArrayParent0(double value) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent1(bool value) => new(value); + public static implicit operator UnnamedSchemaWithArrayParent0(bool value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -1742,12 +1742,12 @@ public override void Validate() if (this.Value == null) { throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent1" + "Data did not match any variant of UnnamedSchemaWithArrayParent0" ); } } - public virtual bool Equals(UnnamedSchemaWithArrayParent1? other) => + public virtual bool Equals(UnnamedSchemaWithArrayParent0? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -1775,9 +1775,9 @@ int VariantIndex() } } -sealed class UnnamedSchemaWithArrayParent1Converter : JsonConverter +sealed class UnnamedSchemaWithArrayParent0Converter : JsonConverter { - public override UnnamedSchemaWithArrayParent1? Read( + public override UnnamedSchemaWithArrayParent0? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -1820,7 +1820,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - UnnamedSchemaWithArrayParent1 value, + UnnamedSchemaWithArrayParent0 value, JsonSerializerOptions options ) { diff --git a/src/Imagekit/Models/Files/FileUploadParams.cs b/src/Imagekit/Models/Files/FileUploadParams.cs index 49445f8b..09a16f0d 100644 --- a/src/Imagekit/Models/Files/FileUploadParams.cs +++ b/src/Imagekit/Models/Files/FileUploadParams.cs @@ -239,14 +239,12 @@ public long? Expire /// Array of extensions to be applied to the asset. Each extension can be configured /// with specific parameters based on the extension type. /// - public IReadOnlyList? Extensions + public IReadOnlyList? Extensions { get { this._rawBodyData.Freeze(); - return this._rawBodyData.GetNullableStruct< - ImmutableArray - >("extensions"); + return this._rawBodyData.GetNullableStruct>("extensions"); } init { @@ -255,7 +253,7 @@ public IReadOnlyList? Extensions return; } - this._rawBodyData.Set?>( + this._rawBodyData.Set?>( "extensions", value == null ? null : ImmutableArray.ToImmutableArray(value) ); diff --git a/src/Imagekit/Models/Files/FileUploadResponse.cs b/src/Imagekit/Models/Files/FileUploadResponse.cs index 1c00d172..31dbbfcf 100644 --- a/src/Imagekit/Models/Files/FileUploadResponse.cs +++ b/src/Imagekit/Models/Files/FileUploadResponse.cs @@ -1599,7 +1599,7 @@ public FileUploadResponseSelectedFieldsSchemaItemDefaultValue( } public FileUploadResponseSelectedFieldsSchemaItemDefaultValue( - IReadOnlyList value, + IReadOnlyList value, JsonElement? element = null ) { @@ -1677,24 +1677,24 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type where T is a UnnamedSchemaWithArrayParent2. + /// type where T is a UnnamedSchemaWithArrayParent1. /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickMixed(out var value)) { - /// // `value` is of type `IReadOnlyList<UnnamedSchemaWithArrayParent2>` + /// // `value` is of type `IReadOnlyList<UnnamedSchemaWithArrayParent1>` /// Console.WriteLine(value); /// } /// /// /// public bool TryPickMixed( - [NotNullWhen(true)] out IReadOnlyList? value + [NotNullWhen(true)] out IReadOnlyList? value ) { - value = this.Value as IReadOnlyList; + value = this.Value as IReadOnlyList; return value != null; } @@ -1715,7 +1715,7 @@ public bool TryPickMixed( /// (string value) => {...}, /// (double value) => {...}, /// (bool value) => {...}, - /// (IReadOnlyList<UnnamedSchemaWithArrayParent2> value) => {...} + /// (IReadOnlyList<UnnamedSchemaWithArrayParent1> value) => {...} /// ); /// /// @@ -1724,7 +1724,7 @@ public void Switch( System::Action @string, System::Action @double, System::Action @bool, - System::Action> mixed + System::Action> mixed ) { switch (this.Value) @@ -1738,7 +1738,7 @@ public void Switch( case bool value: @bool(value); break; - case IReadOnlyList value: + case IReadOnlyList value: mixed(value); break; default: @@ -1766,7 +1766,7 @@ public void Switch( /// (string value) => {...}, /// (double value) => {...}, /// (bool value) => {...}, - /// (IReadOnlyList<UnnamedSchemaWithArrayParent2> value) => {...} + /// (IReadOnlyList<UnnamedSchemaWithArrayParent1> value) => {...} /// ); /// /// @@ -1775,7 +1775,7 @@ public T Match( System::Func @string, System::Func @double, System::Func @bool, - System::Func, T> mixed + System::Func, T> mixed ) { return this.Value switch @@ -1783,7 +1783,7 @@ public T Match( string value => @string(value), double value => @double(value), bool value => @bool(value), - IReadOnlyList value => mixed(value), + IReadOnlyList value => mixed(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of FileUploadResponseSelectedFieldsSchemaItemDefaultValue" ), @@ -1803,8 +1803,8 @@ bool value ) => new(value); public static implicit operator FileUploadResponseSelectedFieldsSchemaItemDefaultValue( - List value - ) => new((IReadOnlyList)value); + List value + ) => new((IReadOnlyList)value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -1861,7 +1861,7 @@ int VariantIndex() string _ => 0, double _ => 1, bool _ => 2, - IReadOnlyList _ => 3, + IReadOnlyList _ => 3, _ => -1, }; } @@ -1910,7 +1910,7 @@ JsonSerializerOptions options try { - var deserialized = JsonSerializer.Deserialize>( + var deserialized = JsonSerializer.Deserialize>( element, options ); @@ -1941,8 +1941,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(UnnamedSchemaWithArrayParent2Converter))] -public record class UnnamedSchemaWithArrayParent2 : ModelBase +[JsonConverter(typeof(UnnamedSchemaWithArrayParent1Converter))] +public record class UnnamedSchemaWithArrayParent1 : ModelBase { public object? Value { get; } = null; @@ -1959,25 +1959,25 @@ public JsonElement Json } } - public UnnamedSchemaWithArrayParent2(string value, JsonElement? element = null) + public UnnamedSchemaWithArrayParent1(string value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent2(double value, JsonElement? element = null) + public UnnamedSchemaWithArrayParent1(double value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent2(bool value, JsonElement? element = null) + public UnnamedSchemaWithArrayParent1(bool value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent2(JsonElement element) + public UnnamedSchemaWithArrayParent1(JsonElement element) { this._element = element; } @@ -2085,7 +2085,7 @@ public void Switch( break; default: throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent2" + "Data did not match any variant of UnnamedSchemaWithArrayParent1" ); } } @@ -2124,16 +2124,16 @@ public T Match( double value => @double(value), bool value => @bool(value), _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent2" + "Data did not match any variant of UnnamedSchemaWithArrayParent1" ), }; } - public static implicit operator UnnamedSchemaWithArrayParent2(string value) => new(value); + public static implicit operator UnnamedSchemaWithArrayParent1(string value) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent2(double value) => new(value); + public static implicit operator UnnamedSchemaWithArrayParent1(double value) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent2(bool value) => new(value); + public static implicit operator UnnamedSchemaWithArrayParent1(bool value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -2150,12 +2150,12 @@ public override void Validate() if (this.Value == null) { throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent2" + "Data did not match any variant of UnnamedSchemaWithArrayParent1" ); } } - public virtual bool Equals(UnnamedSchemaWithArrayParent2? other) => + public virtual bool Equals(UnnamedSchemaWithArrayParent1? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -2183,9 +2183,9 @@ int VariantIndex() } } -sealed class UnnamedSchemaWithArrayParent2Converter : JsonConverter +sealed class UnnamedSchemaWithArrayParent1Converter : JsonConverter { - public override UnnamedSchemaWithArrayParent2? Read( + public override UnnamedSchemaWithArrayParent1? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -2228,7 +2228,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - UnnamedSchemaWithArrayParent2 value, + UnnamedSchemaWithArrayParent1 value, JsonSerializerOptions options ) { diff --git a/src/Imagekit/Models/Files/UpdateFileRequest.cs b/src/Imagekit/Models/Files/UpdateFileRequest.cs index 866f8cb6..6933afb4 100644 --- a/src/Imagekit/Models/Files/UpdateFileRequest.cs +++ b/src/Imagekit/Models/Files/UpdateFileRequest.cs @@ -346,14 +346,12 @@ public string? Description /// Array of extensions to be applied to the asset. Each extension can be configured /// with specific parameters based on the extension type. /// - public IReadOnlyList? Extensions + public IReadOnlyList? Extensions { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct>( - "extensions" - ); + return this._rawData.GetNullableStruct>("extensions"); } init { @@ -362,7 +360,7 @@ public IReadOnlyList? Extensions return; } - this._rawData.Set?>( + this._rawData.Set?>( "extensions", value == null ? null : ImmutableArray.ToImmutableArray(value) ); diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEvent.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEvent.cs index ac9b721a..11e7c70c 100644 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEvent.cs +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEvent.cs @@ -1811,7 +1811,7 @@ public DefaultValue(bool value, JsonElement? element = null) } public DefaultValue( - IReadOnlyList value, + IReadOnlyList value, JsonElement? element = null ) { @@ -1889,24 +1889,24 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type where T is a UnnamedSchemaWithArrayParent4. + /// type where T is a UnnamedSchemaWithArrayParent3. /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickMixed(out var value)) { - /// // `value` is of type `IReadOnlyList<UnnamedSchemaWithArrayParent4>` + /// // `value` is of type `IReadOnlyList<UnnamedSchemaWithArrayParent3>` /// Console.WriteLine(value); /// } /// /// /// public bool TryPickMixed( - [NotNullWhen(true)] out IReadOnlyList? value + [NotNullWhen(true)] out IReadOnlyList? value ) { - value = this.Value as IReadOnlyList; + value = this.Value as IReadOnlyList; return value != null; } @@ -1927,7 +1927,7 @@ public bool TryPickMixed( /// (string value) => {...}, /// (double value) => {...}, /// (bool value) => {...}, - /// (IReadOnlyList<UnnamedSchemaWithArrayParent4> value) => {...} + /// (IReadOnlyList<UnnamedSchemaWithArrayParent3> value) => {...} /// ); /// /// @@ -1936,7 +1936,7 @@ public void Switch( System::Action @string, System::Action @double, System::Action @bool, - System::Action> mixed + System::Action> mixed ) { switch (this.Value) @@ -1950,7 +1950,7 @@ public void Switch( case bool value: @bool(value); break; - case IReadOnlyList value: + case IReadOnlyList value: mixed(value); break; default: @@ -1978,7 +1978,7 @@ public void Switch( /// (string value) => {...}, /// (double value) => {...}, /// (bool value) => {...}, - /// (IReadOnlyList<UnnamedSchemaWithArrayParent4> value) => {...} + /// (IReadOnlyList<UnnamedSchemaWithArrayParent3> value) => {...} /// ); /// /// @@ -1987,7 +1987,7 @@ public T Match( System::Func @string, System::Func @double, System::Func @bool, - System::Func, T> mixed + System::Func, T> mixed ) { return this.Value switch @@ -1995,7 +1995,7 @@ public T Match( string value => @string(value), double value => @double(value), bool value => @bool(value), - IReadOnlyList value => mixed(value), + IReadOnlyList value => mixed(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of DefaultValue" ), @@ -2008,8 +2008,8 @@ public T Match( public static implicit operator DefaultValue(bool value) => new(value); - public static implicit operator DefaultValue(List value) => - new((IReadOnlyList)value); + public static implicit operator DefaultValue(List value) => + new((IReadOnlyList)value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -2066,7 +2066,7 @@ int VariantIndex() string _ => 0, double _ => 1, bool _ => 2, - IReadOnlyList _ => 3, + IReadOnlyList _ => 3, _ => -1, }; } @@ -2114,7 +2114,7 @@ JsonSerializerOptions options try { - var deserialized = JsonSerializer.Deserialize>( + var deserialized = JsonSerializer.Deserialize>( element, options ); @@ -2145,8 +2145,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(UnnamedSchemaWithArrayParent4Converter))] -public record class UnnamedSchemaWithArrayParent4 : ModelBase +[JsonConverter(typeof(UnnamedSchemaWithArrayParent3Converter))] +public record class UnnamedSchemaWithArrayParent3 : ModelBase { public object? Value { get; } = null; @@ -2163,25 +2163,25 @@ public JsonElement Json } } - public UnnamedSchemaWithArrayParent4(string value, JsonElement? element = null) + public UnnamedSchemaWithArrayParent3(string value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent4(double value, JsonElement? element = null) + public UnnamedSchemaWithArrayParent3(double value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent4(bool value, JsonElement? element = null) + public UnnamedSchemaWithArrayParent3(bool value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent4(JsonElement element) + public UnnamedSchemaWithArrayParent3(JsonElement element) { this._element = element; } @@ -2289,7 +2289,7 @@ public void Switch( break; default: throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent4" + "Data did not match any variant of UnnamedSchemaWithArrayParent3" ); } } @@ -2328,16 +2328,16 @@ public T Match( double value => @double(value), bool value => @bool(value), _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent4" + "Data did not match any variant of UnnamedSchemaWithArrayParent3" ), }; } - public static implicit operator UnnamedSchemaWithArrayParent4(string value) => new(value); + public static implicit operator UnnamedSchemaWithArrayParent3(string value) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent4(double value) => new(value); + public static implicit operator UnnamedSchemaWithArrayParent3(double value) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent4(bool value) => new(value); + public static implicit operator UnnamedSchemaWithArrayParent3(bool value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -2354,12 +2354,12 @@ public override void Validate() if (this.Value == null) { throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent4" + "Data did not match any variant of UnnamedSchemaWithArrayParent3" ); } } - public virtual bool Equals(UnnamedSchemaWithArrayParent4? other) => + public virtual bool Equals(UnnamedSchemaWithArrayParent3? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -2387,9 +2387,9 @@ int VariantIndex() } } -sealed class UnnamedSchemaWithArrayParent4Converter : JsonConverter +sealed class UnnamedSchemaWithArrayParent3Converter : JsonConverter { - public override UnnamedSchemaWithArrayParent4? Read( + public override UnnamedSchemaWithArrayParent3? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -2432,7 +2432,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - UnnamedSchemaWithArrayParent4 value, + UnnamedSchemaWithArrayParent3 value, JsonSerializerOptions options ) { From 8d2e780de5c4e2d03eb7e9ada8747307cbd6e634 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sun, 17 May 2026 02:44:22 +0000 Subject: [PATCH 120/129] chore: update SDK settings --- .release-please-manifest.json | 3 ++ .stats.yml | 4 +- README.md | 6 +-- release-please-config.json | 71 +++++++++++++++++++++++++++++++++++ src/Directory.Build.props | 2 +- 5 files changed, 80 insertions(+), 6 deletions(-) create mode 100644 .release-please-manifest.json create mode 100644 release-please-config.json diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 00000000..1332969b --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "0.0.1" +} \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 6bae0823..02b09bcf 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc/imagekit-9daf3daa1db3813288c77c8777bfca85337e3512bdc83ee48fe0631e41c3650d.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc/imagekit-59ecd0e32aaade3cf2b31e6f757697c0a4f1c4c8ed3e52fb25b1071f592db509.yml openapi_spec_hash: 7c103e2dff0edcbeea82057e62f58d4d -config_hash: 34c788f0652c42a878adf62248426f1e +config_hash: c5a7aed248c5d9ad5cd42e56fdd62c12 diff --git a/README.md b/README.md index 4fd8098c..8432d35d 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,8 @@ The REST API documentation can be found on [imagekit.io](https://imagekit.io/doc ## Installation ```bash -git clone git@github.com:stainless-sdks/imagekit-csharp.git -dotnet add reference imagekit-csharp/src/Imagekit +git clone git@github.com:imagekit-developer/imagekit-dotnet.git +dotnet add reference imagekit-dotnet/src/Imagekit ``` ## Requirements @@ -399,4 +399,4 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience. -We are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/imagekit-csharp/issues) with questions, bugs, or suggestions. +We are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-dotnet/issues) with questions, bugs, or suggestions. diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 00000000..59759611 --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,71 @@ +{ + "packages": { + ".": {} + }, + "$schema": "https://raw.githubusercontent.com/stainless-api/release-please/main/schemas/config.json", + "include-v-in-tag": true, + "include-component-in-tag": false, + "versioning": "prerelease", + "prerelease": true, + "bump-minor-pre-major": true, + "bump-patch-for-minor-pre-major": false, + "pull-request-header": "Automated Release PR", + "pull-request-title-pattern": "release: ${version}", + "changelog-sections": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "perf", + "section": "Performance Improvements" + }, + { + "type": "revert", + "section": "Reverts" + }, + { + "type": "chore", + "section": "Chores" + }, + { + "type": "docs", + "section": "Documentation" + }, + { + "type": "style", + "section": "Styles" + }, + { + "type": "refactor", + "section": "Refactors" + }, + { + "type": "test", + "section": "Tests", + "hidden": true + }, + { + "type": "build", + "section": "Build System" + }, + { + "type": "ci", + "section": "Continuous Integration", + "hidden": true + } + ], + "release-type": "simple", + "extra-files": [ + { + "type": "xml", + "path": "**/*.csproj", + "xpath": "//Project/PropertyGroup/VersionPrefix", + "glob": true + } + ] +} \ No newline at end of file diff --git a/src/Directory.Build.props b/src/Directory.Build.props index e5417938..37a85233 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -6,7 +6,7 @@ Apache-2.0 Copyright 2026 Image Kit https://imagekit.io/docs/api-reference - https://www.github.com/stainless-sdks/imagekit-csharp + https://www.github.com/imagekit-developer/imagekit-dotnet git From 5a116f4f38bbde8ead67229cbe55299359a0a7bd Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sun, 17 May 2026 03:12:23 +0000 Subject: [PATCH 121/129] build: give explicit titles to fix build warnings --- .stats.yml | 4 +- .../Models/GetImageAttributesOptionsTest.cs | 54 +- src/Imagekit.Tests/Models/ImageOverlayTest.cs | 54 +- src/Imagekit.Tests/Models/OverlayTest.cs | 20 +- .../Models/SolidColorOverlayTest.cs | 26 +- src/Imagekit.Tests/Models/SrcOptionsTest.cs | 14 +- .../Models/SubtitleOverlayTest.cs | 92 +- src/Imagekit.Tests/Models/TextOverlayTest.cs | 102 +- .../Models/TransformationTest.cs | 14 +- src/Imagekit.Tests/Models/VideoOverlayTest.cs | 130 +-- .../Models/Webhooks/FileCreateEventTest.cs | 18 +- .../Models/Webhooks/FileDeleteEventTest.cs | 18 +- .../Models/Webhooks/FileUpdateEventTest.cs | 18 +- .../Webhooks/FileVersionCreateEventTest.cs | 18 +- .../Webhooks/FileVersionDeleteEventTest.cs | 44 +- .../Webhooks/UnsafeUnwrapWebhookEventTest.cs | 56 +- .../Models/Webhooks/UnwrapWebhookEventTest.cs | 56 +- .../UploadPostTransformErrorEventTest.cs | 106 +- .../UploadPostTransformSuccessEventTest.cs | 457 ++++----- .../UploadPreTransformErrorEventTest.cs | 202 ++-- .../UploadPreTransformSuccessEventTest.cs | 86 +- .../VideoTransformationAcceptedEventTest.cs | 413 ++++---- .../VideoTransformationErrorEventTest.cs | 905 +++++++++-------- .../VideoTransformationReadyEventTest.cs | 928 +++++++++--------- src/Imagekit/Core/ModelBase.cs | 32 +- .../Models/GetImageAttributesOptions.cs | 37 +- src/Imagekit/Models/ImageOverlay.cs | 31 +- src/Imagekit/Models/SolidColorOverlay.cs | 31 +- src/Imagekit/Models/SubtitleOverlay.cs | 64 +- src/Imagekit/Models/TextOverlay.cs | 74 +- src/Imagekit/Models/VideoOverlay.cs | 65 +- .../Models/Webhooks/FileCreateEvent.cs | 29 +- .../Models/Webhooks/FileDeleteEvent.cs | 28 +- .../Models/Webhooks/FileUpdateEvent.cs | 28 +- .../Models/Webhooks/FileVersionCreateEvent.cs | 30 +- .../Models/Webhooks/FileVersionDeleteEvent.cs | 68 +- .../Webhooks/UploadPostTransformErrorEvent.cs | 71 +- .../UploadPostTransformSuccessEvent.cs | 222 +++-- .../Webhooks/UploadPreTransformErrorEvent.cs | 187 ++-- .../UploadPreTransformSuccessEvent.cs | 113 ++- .../VideoTransformationAcceptedEvent.cs | 187 ++-- .../Webhooks/VideoTransformationErrorEvent.cs | 421 ++++---- .../Webhooks/VideoTransformationReadyEvent.cs | 384 ++++---- 43 files changed, 3061 insertions(+), 2876 deletions(-) diff --git a/.stats.yml b/.stats.yml index 02b09bcf..364b12b5 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc/imagekit-59ecd0e32aaade3cf2b31e6f757697c0a4f1c4c8ed3e52fb25b1071f592db509.yml -openapi_spec_hash: 7c103e2dff0edcbeea82057e62f58d4d +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc/imagekit-4df977cf1706b48f9d9f15d7e134d5bb062607bcf206a406a239ff6691852e7d.yml +openapi_spec_hash: fd7c931960b5d8a4c1072a69a5a3e6a1 config_hash: c5a7aed248c5d9ad5cd42e56fdd62c12 diff --git a/src/Imagekit.Tests/Models/GetImageAttributesOptionsTest.cs b/src/Imagekit.Tests/Models/GetImageAttributesOptionsTest.cs index 7c3e0dcf..ac42de8f 100644 --- a/src/Imagekit.Tests/Models/GetImageAttributesOptionsTest.cs +++ b/src/Imagekit.Tests/Models/GetImageAttributesOptionsTest.cs @@ -75,7 +75,7 @@ public void FieldRoundtrip_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -187,7 +187,7 @@ public void FieldRoundtrip_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -339,7 +339,7 @@ public void SerializationRoundtrip_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -465,7 +465,7 @@ public void FieldRoundtripThroughSerialization_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -584,7 +584,7 @@ public void FieldRoundtripThroughSerialization_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -736,7 +736,7 @@ public void Validation_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -960,7 +960,7 @@ public void CopyConstructor_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -1015,12 +1015,12 @@ public void CopyConstructor_Works() } } -public class IntersectionMember1Test : TestBase +public class GetImageAttributesOptionsGetImageAttributesOptionsTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new IntersectionMember1 + var model = new GetImageAttributesOptionsGetImageAttributesOptions { DeviceBreakpoints = [640, 750, 828, 1080, 1200, 1920, 2048, 3840], ImageBreakpoints = [16, 32, 48, 64, 96, 128, 256, 384], @@ -1052,7 +1052,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new IntersectionMember1 + var model = new GetImageAttributesOptionsGetImageAttributesOptions { DeviceBreakpoints = [640, 750, 828, 1080, 1200, 1920, 2048, 3840], ImageBreakpoints = [16, 32, 48, 64, 96, 128, 256, 384], @@ -1061,10 +1061,11 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -1072,7 +1073,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new IntersectionMember1 + var model = new GetImageAttributesOptionsGetImageAttributesOptions { DeviceBreakpoints = [640, 750, 828, 1080, 1200, 1920, 2048, 3840], ImageBreakpoints = [16, 32, 48, 64, 96, 128, 256, 384], @@ -1081,10 +1082,11 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.NotNull(deserialized); List expectedDeviceBreakpoints = [640, 750, 828, 1080, 1200, 1920, 2048, 3840]; @@ -1111,7 +1113,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new IntersectionMember1 + var model = new GetImageAttributesOptionsGetImageAttributesOptions { DeviceBreakpoints = [640, 750, 828, 1080, 1200, 1920, 2048, 3840], ImageBreakpoints = [16, 32, 48, 64, 96, 128, 256, 384], @@ -1125,7 +1127,7 @@ public void Validation_Works() [Fact] public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new IntersectionMember1 { }; + var model = new GetImageAttributesOptionsGetImageAttributesOptions { }; Assert.Null(model.DeviceBreakpoints); Assert.False(model.RawData.ContainsKey("deviceBreakpoints")); @@ -1140,7 +1142,7 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = new IntersectionMember1 { }; + var model = new GetImageAttributesOptionsGetImageAttributesOptions { }; model.Validate(); } @@ -1148,7 +1150,7 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - var model = new IntersectionMember1 + var model = new GetImageAttributesOptionsGetImageAttributesOptions { // Null should be interpreted as omitted for these properties DeviceBreakpoints = null, @@ -1170,7 +1172,7 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - var model = new IntersectionMember1 + var model = new GetImageAttributesOptionsGetImageAttributesOptions { // Null should be interpreted as omitted for these properties DeviceBreakpoints = null, @@ -1185,7 +1187,7 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new IntersectionMember1 + var model = new GetImageAttributesOptionsGetImageAttributesOptions { DeviceBreakpoints = [640, 750, 828, 1080, 1200, 1920, 2048, 3840], ImageBreakpoints = [16, 32, 48, 64, 96, 128, 256, 384], @@ -1193,7 +1195,7 @@ public void CopyConstructor_Works() Width = 400, }; - IntersectionMember1 copied = new(model); + GetImageAttributesOptionsGetImageAttributesOptions copied = new(model); Assert.Equal(model, copied); } diff --git a/src/Imagekit.Tests/Models/ImageOverlayTest.cs b/src/Imagekit.Tests/Models/ImageOverlayTest.cs index db16767a..6d14526b 100644 --- a/src/Imagekit.Tests/Models/ImageOverlayTest.cs +++ b/src/Imagekit.Tests/Models/ImageOverlayTest.cs @@ -89,7 +89,7 @@ public void FieldRoundtrip_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -210,7 +210,7 @@ public void FieldRoundtrip_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -348,7 +348,7 @@ public void SerializationRoundtrip_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -482,7 +482,7 @@ public void FieldRoundtripThroughSerialization_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -610,7 +610,7 @@ public void FieldRoundtripThroughSerialization_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -748,7 +748,7 @@ public void Validation_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -946,7 +946,7 @@ public void CopyConstructor_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -996,12 +996,12 @@ public void CopyConstructor_Works() } } -public class ImageOverlayIntersectionMember1Test : TestBase +public class ImageOverlayImageOverlayTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new ImageOverlayIntersectionMember1 + var model = new ImageOverlayImageOverlay { Input = "input", Encoding = Encoding.Auto, @@ -1063,7 +1063,7 @@ public void FieldRoundtrip_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -1168,7 +1168,7 @@ public void FieldRoundtrip_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -1225,7 +1225,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new ImageOverlayIntersectionMember1 + var model = new ImageOverlayImageOverlay { Input = "input", Encoding = Encoding.Auto, @@ -1287,7 +1287,7 @@ public void SerializationRoundtrip_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -1332,7 +1332,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -1343,7 +1343,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new ImageOverlayIntersectionMember1 + var model = new ImageOverlayImageOverlay { Input = "input", Encoding = Encoding.Auto, @@ -1405,7 +1405,7 @@ public void FieldRoundtripThroughSerialization_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -1450,7 +1450,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -1517,7 +1517,7 @@ public void FieldRoundtripThroughSerialization_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -1574,7 +1574,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new ImageOverlayIntersectionMember1 + var model = new ImageOverlayImageOverlay { Input = "input", Encoding = Encoding.Auto, @@ -1636,7 +1636,7 @@ public void Validation_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -1686,7 +1686,7 @@ public void Validation_Works() [Fact] public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new ImageOverlayIntersectionMember1 { Input = "input" }; + var model = new ImageOverlayImageOverlay { Input = "input" }; Assert.Null(model.Encoding); Assert.False(model.RawData.ContainsKey("encoding")); @@ -1697,7 +1697,7 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = new ImageOverlayIntersectionMember1 { Input = "input" }; + var model = new ImageOverlayImageOverlay { Input = "input" }; model.Validate(); } @@ -1705,7 +1705,7 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - var model = new ImageOverlayIntersectionMember1 + var model = new ImageOverlayImageOverlay { Input = "input", @@ -1723,7 +1723,7 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - var model = new ImageOverlayIntersectionMember1 + var model = new ImageOverlayImageOverlay { Input = "input", @@ -1738,7 +1738,7 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new ImageOverlayIntersectionMember1 + var model = new ImageOverlayImageOverlay { Input = "input", Encoding = Encoding.Auto, @@ -1800,7 +1800,7 @@ public void CopyConstructor_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -1844,7 +1844,7 @@ public void CopyConstructor_Works() ], }; - ImageOverlayIntersectionMember1 copied = new(model); + ImageOverlayImageOverlay copied = new(model); Assert.Equal(model, copied); } diff --git a/src/Imagekit.Tests/Models/OverlayTest.cs b/src/Imagekit.Tests/Models/OverlayTest.cs index 4520c994..40372ca7 100644 --- a/src/Imagekit.Tests/Models/OverlayTest.cs +++ b/src/Imagekit.Tests/Models/OverlayTest.cs @@ -28,7 +28,7 @@ public void TextValidationWorks() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -133,7 +133,7 @@ public void ImageValidationWorks() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -201,7 +201,7 @@ public void VideoValidationWorks() Start = 0, }, Input = "input", - Encoding = VideoOverlayIntersectionMember1Encoding.Auto, + Encoding = VideoOverlayVideoOverlayEncoding.Auto, Transformation = [ new() @@ -260,7 +260,7 @@ public void VideoValidationWorks() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -328,7 +328,7 @@ public void SubtitleValidationWorks() Start = 0, }, Input = "input", - Encoding = SubtitleOverlayIntersectionMember1Encoding.Auto, + Encoding = SubtitleOverlaySubtitleOverlayEncoding.Auto, Transformation = [ new() @@ -406,7 +406,7 @@ public void TextSerializationRoundtripWorks() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -517,7 +517,7 @@ public void ImageSerializationRoundtripWorks() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -591,7 +591,7 @@ public void VideoSerializationRoundtripWorks() Start = 0, }, Input = "input", - Encoding = VideoOverlayIntersectionMember1Encoding.Auto, + Encoding = VideoOverlayVideoOverlayEncoding.Auto, Transformation = [ new() @@ -650,7 +650,7 @@ public void VideoSerializationRoundtripWorks() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -724,7 +724,7 @@ public void SubtitleSerializationRoundtripWorks() Start = 0, }, Input = "input", - Encoding = SubtitleOverlayIntersectionMember1Encoding.Auto, + Encoding = SubtitleOverlaySubtitleOverlayEncoding.Auto, Transformation = [ new() diff --git a/src/Imagekit.Tests/Models/SolidColorOverlayTest.cs b/src/Imagekit.Tests/Models/SolidColorOverlayTest.cs index c30e8b2b..3a9306a3 100644 --- a/src/Imagekit.Tests/Models/SolidColorOverlayTest.cs +++ b/src/Imagekit.Tests/Models/SolidColorOverlayTest.cs @@ -364,12 +364,12 @@ public void CopyConstructor_Works() } } -public class SolidColorOverlayIntersectionMember1Test : TestBase +public class SolidColorOverlaySolidColorOverlayTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new SolidColorOverlayIntersectionMember1 + var model = new SolidColorOverlaySolidColorOverlay { Color = "color", Transformation = @@ -414,7 +414,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new SolidColorOverlayIntersectionMember1 + var model = new SolidColorOverlaySolidColorOverlay { Color = "color", Transformation = @@ -432,7 +432,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -443,7 +443,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new SolidColorOverlayIntersectionMember1 + var model = new SolidColorOverlaySolidColorOverlay { Color = "color", Transformation = @@ -461,7 +461,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -495,7 +495,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new SolidColorOverlayIntersectionMember1 + var model = new SolidColorOverlaySolidColorOverlay { Color = "color", Transformation = @@ -518,7 +518,7 @@ public void Validation_Works() [Fact] public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new SolidColorOverlayIntersectionMember1 { Color = "color" }; + var model = new SolidColorOverlaySolidColorOverlay { Color = "color" }; Assert.Null(model.Transformation); Assert.False(model.RawData.ContainsKey("transformation")); @@ -527,7 +527,7 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = new SolidColorOverlayIntersectionMember1 { Color = "color" }; + var model = new SolidColorOverlaySolidColorOverlay { Color = "color" }; model.Validate(); } @@ -535,7 +535,7 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - var model = new SolidColorOverlayIntersectionMember1 + var model = new SolidColorOverlaySolidColorOverlay { Color = "color", @@ -550,7 +550,7 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - var model = new SolidColorOverlayIntersectionMember1 + var model = new SolidColorOverlaySolidColorOverlay { Color = "color", @@ -564,7 +564,7 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new SolidColorOverlayIntersectionMember1 + var model = new SolidColorOverlaySolidColorOverlay { Color = "color", Transformation = @@ -581,7 +581,7 @@ public void CopyConstructor_Works() ], }; - SolidColorOverlayIntersectionMember1 copied = new(model); + SolidColorOverlaySolidColorOverlay copied = new(model); Assert.Equal(model, copied); } diff --git a/src/Imagekit.Tests/Models/SrcOptionsTest.cs b/src/Imagekit.Tests/Models/SrcOptionsTest.cs index 21c86761..221c484b 100644 --- a/src/Imagekit.Tests/Models/SrcOptionsTest.cs +++ b/src/Imagekit.Tests/Models/SrcOptionsTest.cs @@ -75,7 +75,7 @@ public void FieldRoundtrip_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -183,7 +183,7 @@ public void FieldRoundtrip_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -317,7 +317,7 @@ public void SerializationRoundtrip_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -439,7 +439,7 @@ public void FieldRoundtripThroughSerialization_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -554,7 +554,7 @@ public void FieldRoundtripThroughSerialization_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -688,7 +688,7 @@ public void Validation_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -884,7 +884,7 @@ public void CopyConstructor_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() diff --git a/src/Imagekit.Tests/Models/SubtitleOverlayTest.cs b/src/Imagekit.Tests/Models/SubtitleOverlayTest.cs index b11577b3..210029ac 100644 --- a/src/Imagekit.Tests/Models/SubtitleOverlayTest.cs +++ b/src/Imagekit.Tests/Models/SubtitleOverlayTest.cs @@ -30,7 +30,7 @@ public void FieldRoundtrip_Works() Start = 0, }, Input = "input", - Encoding = SubtitleOverlayIntersectionMember1Encoding.Auto, + Encoding = SubtitleOverlaySubtitleOverlayEncoding.Auto, Transformation = [ new() @@ -64,8 +64,8 @@ public void FieldRoundtrip_Works() }; string expectedInput = "input"; JsonElement expectedType = JsonSerializer.SerializeToElement("subtitle"); - ApiEnum expectedEncoding = - SubtitleOverlayIntersectionMember1Encoding.Auto; + ApiEnum expectedEncoding = + SubtitleOverlaySubtitleOverlayEncoding.Auto; List expectedTransformation = [ new() @@ -116,7 +116,7 @@ public void SerializationRoundtrip_Works() Start = 0, }, Input = "input", - Encoding = SubtitleOverlayIntersectionMember1Encoding.Auto, + Encoding = SubtitleOverlaySubtitleOverlayEncoding.Auto, Transformation = [ new() @@ -163,7 +163,7 @@ public void FieldRoundtripThroughSerialization_Works() Start = 0, }, Input = "input", - Encoding = SubtitleOverlayIntersectionMember1Encoding.Auto, + Encoding = SubtitleOverlaySubtitleOverlayEncoding.Auto, Transformation = [ new() @@ -204,8 +204,8 @@ public void FieldRoundtripThroughSerialization_Works() }; string expectedInput = "input"; JsonElement expectedType = JsonSerializer.SerializeToElement("subtitle"); - ApiEnum expectedEncoding = - SubtitleOverlayIntersectionMember1Encoding.Auto; + ApiEnum expectedEncoding = + SubtitleOverlaySubtitleOverlayEncoding.Auto; List expectedTransformation = [ new() @@ -256,7 +256,7 @@ public void Validation_Works() Start = 0, }, Input = "input", - Encoding = SubtitleOverlayIntersectionMember1Encoding.Auto, + Encoding = SubtitleOverlaySubtitleOverlayEncoding.Auto, Transformation = [ new() @@ -367,7 +367,7 @@ public void CopyConstructor_Works() Start = 0, }, Input = "input", - Encoding = SubtitleOverlayIntersectionMember1Encoding.Auto, + Encoding = SubtitleOverlaySubtitleOverlayEncoding.Auto, Transformation = [ new() @@ -389,15 +389,15 @@ public void CopyConstructor_Works() } } -public class SubtitleOverlayIntersectionMember1Test : TestBase +public class SubtitleOverlaySubtitleOverlayTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new SubtitleOverlayIntersectionMember1 + var model = new SubtitleOverlaySubtitleOverlay { Input = "input", - Encoding = SubtitleOverlayIntersectionMember1Encoding.Auto, + Encoding = SubtitleOverlaySubtitleOverlayEncoding.Auto, Transformation = [ new() @@ -415,8 +415,8 @@ public void FieldRoundtrip_Works() string expectedInput = "input"; JsonElement expectedType = JsonSerializer.SerializeToElement("subtitle"); - ApiEnum expectedEncoding = - SubtitleOverlayIntersectionMember1Encoding.Auto; + ApiEnum expectedEncoding = + SubtitleOverlaySubtitleOverlayEncoding.Auto; List expectedTransformation = [ new() @@ -445,10 +445,10 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new SubtitleOverlayIntersectionMember1 + var model = new SubtitleOverlaySubtitleOverlay { Input = "input", - Encoding = SubtitleOverlayIntersectionMember1Encoding.Auto, + Encoding = SubtitleOverlaySubtitleOverlayEncoding.Auto, Transformation = [ new() @@ -465,7 +465,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -476,10 +476,10 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new SubtitleOverlayIntersectionMember1 + var model = new SubtitleOverlaySubtitleOverlay { Input = "input", - Encoding = SubtitleOverlayIntersectionMember1Encoding.Auto, + Encoding = SubtitleOverlaySubtitleOverlayEncoding.Auto, Transformation = [ new() @@ -496,7 +496,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -504,8 +504,8 @@ public void FieldRoundtripThroughSerialization_Works() string expectedInput = "input"; JsonElement expectedType = JsonSerializer.SerializeToElement("subtitle"); - ApiEnum expectedEncoding = - SubtitleOverlayIntersectionMember1Encoding.Auto; + ApiEnum expectedEncoding = + SubtitleOverlaySubtitleOverlayEncoding.Auto; List expectedTransformation = [ new() @@ -534,10 +534,10 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new SubtitleOverlayIntersectionMember1 + var model = new SubtitleOverlaySubtitleOverlay { Input = "input", - Encoding = SubtitleOverlayIntersectionMember1Encoding.Auto, + Encoding = SubtitleOverlaySubtitleOverlayEncoding.Auto, Transformation = [ new() @@ -559,7 +559,7 @@ public void Validation_Works() [Fact] public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new SubtitleOverlayIntersectionMember1 { Input = "input" }; + var model = new SubtitleOverlaySubtitleOverlay { Input = "input" }; Assert.Null(model.Encoding); Assert.False(model.RawData.ContainsKey("encoding")); @@ -570,7 +570,7 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = new SubtitleOverlayIntersectionMember1 { Input = "input" }; + var model = new SubtitleOverlaySubtitleOverlay { Input = "input" }; model.Validate(); } @@ -578,7 +578,7 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - var model = new SubtitleOverlayIntersectionMember1 + var model = new SubtitleOverlaySubtitleOverlay { Input = "input", @@ -596,7 +596,7 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - var model = new SubtitleOverlayIntersectionMember1 + var model = new SubtitleOverlaySubtitleOverlay { Input = "input", @@ -611,10 +611,10 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new SubtitleOverlayIntersectionMember1 + var model = new SubtitleOverlaySubtitleOverlay { Input = "input", - Encoding = SubtitleOverlayIntersectionMember1Encoding.Auto, + Encoding = SubtitleOverlaySubtitleOverlayEncoding.Auto, Transformation = [ new() @@ -630,22 +630,22 @@ public void CopyConstructor_Works() ], }; - SubtitleOverlayIntersectionMember1 copied = new(model); + SubtitleOverlaySubtitleOverlay copied = new(model); Assert.Equal(model, copied); } } -public class SubtitleOverlayIntersectionMember1EncodingTest : TestBase +public class SubtitleOverlaySubtitleOverlayEncodingTest : TestBase { [Theory] - [InlineData(SubtitleOverlayIntersectionMember1Encoding.Auto)] - [InlineData(SubtitleOverlayIntersectionMember1Encoding.Plain)] - [InlineData(SubtitleOverlayIntersectionMember1Encoding.Base64)] - public void Validation_Works(SubtitleOverlayIntersectionMember1Encoding rawValue) + [InlineData(SubtitleOverlaySubtitleOverlayEncoding.Auto)] + [InlineData(SubtitleOverlaySubtitleOverlayEncoding.Plain)] + [InlineData(SubtitleOverlaySubtitleOverlayEncoding.Base64)] + public void Validation_Works(SubtitleOverlaySubtitleOverlayEncoding rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } @@ -653,7 +653,7 @@ public void Validation_Works(SubtitleOverlayIntersectionMember1Encoding rawValue public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -661,17 +661,17 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(SubtitleOverlayIntersectionMember1Encoding.Auto)] - [InlineData(SubtitleOverlayIntersectionMember1Encoding.Plain)] - [InlineData(SubtitleOverlayIntersectionMember1Encoding.Base64)] - public void SerializationRoundtrip_Works(SubtitleOverlayIntersectionMember1Encoding rawValue) + [InlineData(SubtitleOverlaySubtitleOverlayEncoding.Auto)] + [InlineData(SubtitleOverlaySubtitleOverlayEncoding.Plain)] + [InlineData(SubtitleOverlaySubtitleOverlayEncoding.Base64)] + public void SerializationRoundtrip_Works(SubtitleOverlaySubtitleOverlayEncoding rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -681,11 +681,11 @@ public void SerializationRoundtrip_Works(SubtitleOverlayIntersectionMember1Encod public void InvalidEnumSerializationRoundtrip_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); diff --git a/src/Imagekit.Tests/Models/TextOverlayTest.cs b/src/Imagekit.Tests/Models/TextOverlayTest.cs index a708cabb..5923b815 100644 --- a/src/Imagekit.Tests/Models/TextOverlayTest.cs +++ b/src/Imagekit.Tests/Models/TextOverlayTest.cs @@ -30,7 +30,7 @@ public void FieldRoundtrip_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -70,8 +70,8 @@ public void FieldRoundtrip_Works() }; string expectedText = "text"; JsonElement expectedType = JsonSerializer.SerializeToElement("text"); - ApiEnum expectedEncoding = - TextOverlayIntersectionMember1Encoding.Auto; + ApiEnum expectedEncoding = + TextOverlayTextOverlayEncoding.Auto; List expectedTransformation = [ new() @@ -128,7 +128,7 @@ public void SerializationRoundtrip_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -181,7 +181,7 @@ public void FieldRoundtripThroughSerialization_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -228,8 +228,8 @@ public void FieldRoundtripThroughSerialization_Works() }; string expectedText = "text"; JsonElement expectedType = JsonSerializer.SerializeToElement("text"); - ApiEnum expectedEncoding = - TextOverlayIntersectionMember1Encoding.Auto; + ApiEnum expectedEncoding = + TextOverlayTextOverlayEncoding.Auto; List expectedTransformation = [ new() @@ -286,7 +286,7 @@ public void Validation_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -403,7 +403,7 @@ public void CopyConstructor_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -431,15 +431,15 @@ public void CopyConstructor_Works() } } -public class TextOverlayIntersectionMember1Test : TestBase +public class TextOverlayTextOverlayTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new TextOverlayIntersectionMember1 + var model = new TextOverlayTextOverlay { Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -463,8 +463,8 @@ public void FieldRoundtrip_Works() string expectedText = "text"; JsonElement expectedType = JsonSerializer.SerializeToElement("text"); - ApiEnum expectedEncoding = - TextOverlayIntersectionMember1Encoding.Auto; + ApiEnum expectedEncoding = + TextOverlayTextOverlayEncoding.Auto; List expectedTransformation = [ new() @@ -499,10 +499,10 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new TextOverlayIntersectionMember1 + var model = new TextOverlayTextOverlay { Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -525,7 +525,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -536,10 +536,10 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new TextOverlayIntersectionMember1 + var model = new TextOverlayTextOverlay { Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -562,7 +562,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -570,8 +570,8 @@ public void FieldRoundtripThroughSerialization_Works() string expectedText = "text"; JsonElement expectedType = JsonSerializer.SerializeToElement("text"); - ApiEnum expectedEncoding = - TextOverlayIntersectionMember1Encoding.Auto; + ApiEnum expectedEncoding = + TextOverlayTextOverlayEncoding.Auto; List expectedTransformation = [ new() @@ -606,10 +606,10 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new TextOverlayIntersectionMember1 + var model = new TextOverlayTextOverlay { Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -637,7 +637,7 @@ public void Validation_Works() [Fact] public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new TextOverlayIntersectionMember1 { Text = "text" }; + var model = new TextOverlayTextOverlay { Text = "text" }; Assert.Null(model.Encoding); Assert.False(model.RawData.ContainsKey("encoding")); @@ -648,7 +648,7 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = new TextOverlayIntersectionMember1 { Text = "text" }; + var model = new TextOverlayTextOverlay { Text = "text" }; model.Validate(); } @@ -656,7 +656,7 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - var model = new TextOverlayIntersectionMember1 + var model = new TextOverlayTextOverlay { Text = "text", @@ -674,7 +674,7 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - var model = new TextOverlayIntersectionMember1 + var model = new TextOverlayTextOverlay { Text = "text", @@ -689,10 +689,10 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new TextOverlayIntersectionMember1 + var model = new TextOverlayTextOverlay { Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -714,48 +714,49 @@ public void CopyConstructor_Works() ], }; - TextOverlayIntersectionMember1 copied = new(model); + TextOverlayTextOverlay copied = new(model); Assert.Equal(model, copied); } } -public class TextOverlayIntersectionMember1EncodingTest : TestBase +public class TextOverlayTextOverlayEncodingTest : TestBase { [Theory] - [InlineData(TextOverlayIntersectionMember1Encoding.Auto)] - [InlineData(TextOverlayIntersectionMember1Encoding.Plain)] - [InlineData(TextOverlayIntersectionMember1Encoding.Base64)] - public void Validation_Works(TextOverlayIntersectionMember1Encoding rawValue) + [InlineData(TextOverlayTextOverlayEncoding.Auto)] + [InlineData(TextOverlayTextOverlayEncoding.Plain)] + [InlineData(TextOverlayTextOverlayEncoding.Base64)] + public void Validation_Works(TextOverlayTextOverlayEncoding rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } [Fact] public void InvalidEnumValidationThrows_Works() { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); Assert.NotNull(value); Assert.Throws(() => value.Validate()); } [Theory] - [InlineData(TextOverlayIntersectionMember1Encoding.Auto)] - [InlineData(TextOverlayIntersectionMember1Encoding.Plain)] - [InlineData(TextOverlayIntersectionMember1Encoding.Base64)] - public void SerializationRoundtrip_Works(TextOverlayIntersectionMember1Encoding rawValue) + [InlineData(TextOverlayTextOverlayEncoding.Auto)] + [InlineData(TextOverlayTextOverlayEncoding.Plain)] + [InlineData(TextOverlayTextOverlayEncoding.Base64)] + public void SerializationRoundtrip_Works(TextOverlayTextOverlayEncoding rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -764,12 +765,13 @@ public void SerializationRoundtrip_Works(TextOverlayIntersectionMember1Encoding [Fact] public void InvalidEnumSerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); diff --git a/src/Imagekit.Tests/Models/TransformationTest.cs b/src/Imagekit.Tests/Models/TransformationTest.cs index ce63957e..2a6e7889 100644 --- a/src/Imagekit.Tests/Models/TransformationTest.cs +++ b/src/Imagekit.Tests/Models/TransformationTest.cs @@ -67,7 +67,7 @@ public void FieldRoundtrip_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -164,7 +164,7 @@ public void FieldRoundtrip_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -329,7 +329,7 @@ public void SerializationRoundtrip_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -439,7 +439,7 @@ public void FieldRoundtripThroughSerialization_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -543,7 +543,7 @@ public void FieldRoundtripThroughSerialization_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -708,7 +708,7 @@ public void Validation_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -1178,7 +1178,7 @@ public void CopyConstructor_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() diff --git a/src/Imagekit.Tests/Models/VideoOverlayTest.cs b/src/Imagekit.Tests/Models/VideoOverlayTest.cs index 63374317..4f5c6e57 100644 --- a/src/Imagekit.Tests/Models/VideoOverlayTest.cs +++ b/src/Imagekit.Tests/Models/VideoOverlayTest.cs @@ -30,7 +30,7 @@ public void FieldRoundtrip_Works() Start = 0, }, Input = "input", - Encoding = VideoOverlayIntersectionMember1Encoding.Auto, + Encoding = VideoOverlayVideoOverlayEncoding.Auto, Transformation = [ new() @@ -89,7 +89,7 @@ public void FieldRoundtrip_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -151,8 +151,8 @@ public void FieldRoundtrip_Works() }; string expectedInput = "input"; JsonElement expectedType = JsonSerializer.SerializeToElement("video"); - ApiEnum expectedEncoding = - VideoOverlayIntersectionMember1Encoding.Auto; + ApiEnum expectedEncoding = + VideoOverlayVideoOverlayEncoding.Auto; List expectedTransformation = [ new() @@ -211,7 +211,7 @@ public void FieldRoundtrip_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -290,7 +290,7 @@ public void SerializationRoundtrip_Works() Start = 0, }, Input = "input", - Encoding = VideoOverlayIntersectionMember1Encoding.Auto, + Encoding = VideoOverlayVideoOverlayEncoding.Auto, Transformation = [ new() @@ -349,7 +349,7 @@ public void SerializationRoundtrip_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -424,7 +424,7 @@ public void FieldRoundtripThroughSerialization_Works() Start = 0, }, Input = "input", - Encoding = VideoOverlayIntersectionMember1Encoding.Auto, + Encoding = VideoOverlayVideoOverlayEncoding.Auto, Transformation = [ new() @@ -483,7 +483,7 @@ public void FieldRoundtripThroughSerialization_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -552,8 +552,8 @@ public void FieldRoundtripThroughSerialization_Works() }; string expectedInput = "input"; JsonElement expectedType = JsonSerializer.SerializeToElement("video"); - ApiEnum expectedEncoding = - VideoOverlayIntersectionMember1Encoding.Auto; + ApiEnum expectedEncoding = + VideoOverlayVideoOverlayEncoding.Auto; List expectedTransformation = [ new() @@ -612,7 +612,7 @@ public void FieldRoundtripThroughSerialization_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -691,7 +691,7 @@ public void Validation_Works() Start = 0, }, Input = "input", - Encoding = VideoOverlayIntersectionMember1Encoding.Auto, + Encoding = VideoOverlayVideoOverlayEncoding.Auto, Transformation = [ new() @@ -750,7 +750,7 @@ public void Validation_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -889,7 +889,7 @@ public void CopyConstructor_Works() Start = 0, }, Input = "input", - Encoding = VideoOverlayIntersectionMember1Encoding.Auto, + Encoding = VideoOverlayVideoOverlayEncoding.Auto, Transformation = [ new() @@ -948,7 +948,7 @@ public void CopyConstructor_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -998,15 +998,15 @@ public void CopyConstructor_Works() } } -public class VideoOverlayIntersectionMember1Test : TestBase +public class VideoOverlayVideoOverlayTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new VideoOverlayIntersectionMember1 + var model = new VideoOverlayVideoOverlay { Input = "input", - Encoding = VideoOverlayIntersectionMember1Encoding.Auto, + Encoding = VideoOverlayVideoOverlayEncoding.Auto, Transformation = [ new() @@ -1065,7 +1065,7 @@ public void FieldRoundtrip_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -1111,8 +1111,8 @@ public void FieldRoundtrip_Works() string expectedInput = "input"; JsonElement expectedType = JsonSerializer.SerializeToElement("video"); - ApiEnum expectedEncoding = - VideoOverlayIntersectionMember1Encoding.Auto; + ApiEnum expectedEncoding = + VideoOverlayVideoOverlayEncoding.Auto; List expectedTransformation = [ new() @@ -1171,7 +1171,7 @@ public void FieldRoundtrip_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -1228,10 +1228,10 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new VideoOverlayIntersectionMember1 + var model = new VideoOverlayVideoOverlay { Input = "input", - Encoding = VideoOverlayIntersectionMember1Encoding.Auto, + Encoding = VideoOverlayVideoOverlayEncoding.Auto, Transformation = [ new() @@ -1290,7 +1290,7 @@ public void SerializationRoundtrip_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -1335,7 +1335,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -1346,10 +1346,10 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new VideoOverlayIntersectionMember1 + var model = new VideoOverlayVideoOverlay { Input = "input", - Encoding = VideoOverlayIntersectionMember1Encoding.Auto, + Encoding = VideoOverlayVideoOverlayEncoding.Auto, Transformation = [ new() @@ -1408,7 +1408,7 @@ public void FieldRoundtripThroughSerialization_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -1453,7 +1453,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -1461,8 +1461,8 @@ public void FieldRoundtripThroughSerialization_Works() string expectedInput = "input"; JsonElement expectedType = JsonSerializer.SerializeToElement("video"); - ApiEnum expectedEncoding = - VideoOverlayIntersectionMember1Encoding.Auto; + ApiEnum expectedEncoding = + VideoOverlayVideoOverlayEncoding.Auto; List expectedTransformation = [ new() @@ -1521,7 +1521,7 @@ public void FieldRoundtripThroughSerialization_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -1578,10 +1578,10 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new VideoOverlayIntersectionMember1 + var model = new VideoOverlayVideoOverlay { Input = "input", - Encoding = VideoOverlayIntersectionMember1Encoding.Auto, + Encoding = VideoOverlayVideoOverlayEncoding.Auto, Transformation = [ new() @@ -1640,7 +1640,7 @@ public void Validation_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -1690,7 +1690,7 @@ public void Validation_Works() [Fact] public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new VideoOverlayIntersectionMember1 { Input = "input" }; + var model = new VideoOverlayVideoOverlay { Input = "input" }; Assert.Null(model.Encoding); Assert.False(model.RawData.ContainsKey("encoding")); @@ -1701,7 +1701,7 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = new VideoOverlayIntersectionMember1 { Input = "input" }; + var model = new VideoOverlayVideoOverlay { Input = "input" }; model.Validate(); } @@ -1709,7 +1709,7 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - var model = new VideoOverlayIntersectionMember1 + var model = new VideoOverlayVideoOverlay { Input = "input", @@ -1727,7 +1727,7 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - var model = new VideoOverlayIntersectionMember1 + var model = new VideoOverlayVideoOverlay { Input = "input", @@ -1742,10 +1742,10 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new VideoOverlayIntersectionMember1 + var model = new VideoOverlayVideoOverlay { Input = "input", - Encoding = VideoOverlayIntersectionMember1Encoding.Auto, + Encoding = VideoOverlayVideoOverlayEncoding.Auto, Transformation = [ new() @@ -1804,7 +1804,7 @@ public void CopyConstructor_Works() Start = 0, }, Text = "text", - Encoding = TextOverlayIntersectionMember1Encoding.Auto, + Encoding = TextOverlayTextOverlayEncoding.Auto, Transformation = [ new() @@ -1848,48 +1848,49 @@ public void CopyConstructor_Works() ], }; - VideoOverlayIntersectionMember1 copied = new(model); + VideoOverlayVideoOverlay copied = new(model); Assert.Equal(model, copied); } } -public class VideoOverlayIntersectionMember1EncodingTest : TestBase +public class VideoOverlayVideoOverlayEncodingTest : TestBase { [Theory] - [InlineData(VideoOverlayIntersectionMember1Encoding.Auto)] - [InlineData(VideoOverlayIntersectionMember1Encoding.Plain)] - [InlineData(VideoOverlayIntersectionMember1Encoding.Base64)] - public void Validation_Works(VideoOverlayIntersectionMember1Encoding rawValue) + [InlineData(VideoOverlayVideoOverlayEncoding.Auto)] + [InlineData(VideoOverlayVideoOverlayEncoding.Plain)] + [InlineData(VideoOverlayVideoOverlayEncoding.Base64)] + public void Validation_Works(VideoOverlayVideoOverlayEncoding rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } [Fact] public void InvalidEnumValidationThrows_Works() { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); Assert.NotNull(value); Assert.Throws(() => value.Validate()); } [Theory] - [InlineData(VideoOverlayIntersectionMember1Encoding.Auto)] - [InlineData(VideoOverlayIntersectionMember1Encoding.Plain)] - [InlineData(VideoOverlayIntersectionMember1Encoding.Base64)] - public void SerializationRoundtrip_Works(VideoOverlayIntersectionMember1Encoding rawValue) + [InlineData(VideoOverlayVideoOverlayEncoding.Auto)] + [InlineData(VideoOverlayVideoOverlayEncoding.Plain)] + [InlineData(VideoOverlayVideoOverlayEncoding.Base64)] + public void SerializationRoundtrip_Works(VideoOverlayVideoOverlayEncoding rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -1898,12 +1899,13 @@ public void SerializationRoundtrip_Works(VideoOverlayIntersectionMember1Encoding [Fact] public void InvalidEnumSerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); diff --git a/src/Imagekit.Tests/Models/Webhooks/FileCreateEventTest.cs b/src/Imagekit.Tests/Models/Webhooks/FileCreateEventTest.cs index f84039fb..6606afdd 100644 --- a/src/Imagekit.Tests/Models/Webhooks/FileCreateEventTest.cs +++ b/src/Imagekit.Tests/Models/Webhooks/FileCreateEventTest.cs @@ -587,12 +587,12 @@ public void CopyConstructor_Works() } } -public class IntersectionMember1Test : TestBase +public class FileCreateEventFileCreateEventTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new IntersectionMember1 + var model = new FileCreateEventFileCreateEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -746,7 +746,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new IntersectionMember1 + var model = new FileCreateEventFileCreateEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -821,7 +821,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -832,7 +832,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new IntersectionMember1 + var model = new FileCreateEventFileCreateEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -907,7 +907,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -993,7 +993,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new IntersectionMember1 + var model = new FileCreateEventFileCreateEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -1073,7 +1073,7 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new IntersectionMember1 + var model = new FileCreateEventFileCreateEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -1147,7 +1147,7 @@ public void CopyConstructor_Works() }, }; - IntersectionMember1 copied = new(model); + FileCreateEventFileCreateEvent copied = new(model); Assert.Equal(model, copied); } diff --git a/src/Imagekit.Tests/Models/Webhooks/FileDeleteEventTest.cs b/src/Imagekit.Tests/Models/Webhooks/FileDeleteEventTest.cs index f843d87f..57c3433c 100644 --- a/src/Imagekit.Tests/Models/Webhooks/FileDeleteEventTest.cs +++ b/src/Imagekit.Tests/Models/Webhooks/FileDeleteEventTest.cs @@ -109,12 +109,12 @@ public void CopyConstructor_Works() } } -public class FileDeleteEventIntersectionMember1Test : TestBase +public class FileDeleteEventFileDeleteEventTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new FileDeleteEventIntersectionMember1 + var model = new FileDeleteEventFileDeleteEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new("fileId"), @@ -132,14 +132,14 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new FileDeleteEventIntersectionMember1 + var model = new FileDeleteEventFileDeleteEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new("fileId"), }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -150,14 +150,14 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new FileDeleteEventIntersectionMember1 + var model = new FileDeleteEventFileDeleteEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new("fileId"), }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -175,7 +175,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new FileDeleteEventIntersectionMember1 + var model = new FileDeleteEventFileDeleteEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new("fileId"), @@ -187,13 +187,13 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new FileDeleteEventIntersectionMember1 + var model = new FileDeleteEventFileDeleteEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new("fileId"), }; - FileDeleteEventIntersectionMember1 copied = new(model); + FileDeleteEventFileDeleteEvent copied = new(model); Assert.Equal(model, copied); } diff --git a/src/Imagekit.Tests/Models/Webhooks/FileUpdateEventTest.cs b/src/Imagekit.Tests/Models/Webhooks/FileUpdateEventTest.cs index 186bcc81..aede4945 100644 --- a/src/Imagekit.Tests/Models/Webhooks/FileUpdateEventTest.cs +++ b/src/Imagekit.Tests/Models/Webhooks/FileUpdateEventTest.cs @@ -587,12 +587,12 @@ public void CopyConstructor_Works() } } -public class FileUpdateEventIntersectionMember1Test : TestBase +public class FileUpdateEventFileUpdateEventTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new FileUpdateEventIntersectionMember1 + var model = new FileUpdateEventFileUpdateEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -746,7 +746,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new FileUpdateEventIntersectionMember1 + var model = new FileUpdateEventFileUpdateEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -821,7 +821,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -832,7 +832,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new FileUpdateEventIntersectionMember1 + var model = new FileUpdateEventFileUpdateEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -907,7 +907,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -993,7 +993,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new FileUpdateEventIntersectionMember1 + var model = new FileUpdateEventFileUpdateEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -1073,7 +1073,7 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new FileUpdateEventIntersectionMember1 + var model = new FileUpdateEventFileUpdateEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -1147,7 +1147,7 @@ public void CopyConstructor_Works() }, }; - FileUpdateEventIntersectionMember1 copied = new(model); + FileUpdateEventFileUpdateEvent copied = new(model); Assert.Equal(model, copied); } diff --git a/src/Imagekit.Tests/Models/Webhooks/FileVersionCreateEventTest.cs b/src/Imagekit.Tests/Models/Webhooks/FileVersionCreateEventTest.cs index 56c8c98c..60d694dc 100644 --- a/src/Imagekit.Tests/Models/Webhooks/FileVersionCreateEventTest.cs +++ b/src/Imagekit.Tests/Models/Webhooks/FileVersionCreateEventTest.cs @@ -587,12 +587,12 @@ public void CopyConstructor_Works() } } -public class FileVersionCreateEventIntersectionMember1Test : TestBase +public class FileVersionCreateEventFileVersionCreateEventTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new FileVersionCreateEventIntersectionMember1 + var model = new FileVersionCreateEventFileVersionCreateEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -746,7 +746,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new FileVersionCreateEventIntersectionMember1 + var model = new FileVersionCreateEventFileVersionCreateEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -821,7 +821,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -832,7 +832,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new FileVersionCreateEventIntersectionMember1 + var model = new FileVersionCreateEventFileVersionCreateEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -907,7 +907,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -993,7 +993,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new FileVersionCreateEventIntersectionMember1 + var model = new FileVersionCreateEventFileVersionCreateEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -1073,7 +1073,7 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new FileVersionCreateEventIntersectionMember1 + var model = new FileVersionCreateEventFileVersionCreateEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -1147,7 +1147,7 @@ public void CopyConstructor_Works() }, }; - FileVersionCreateEventIntersectionMember1 copied = new(model); + FileVersionCreateEventFileVersionCreateEvent copied = new(model); Assert.Equal(model, copied); } diff --git a/src/Imagekit.Tests/Models/Webhooks/FileVersionDeleteEventTest.cs b/src/Imagekit.Tests/Models/Webhooks/FileVersionDeleteEventTest.cs index ed0dd3b2..ad5eb109 100644 --- a/src/Imagekit.Tests/Models/Webhooks/FileVersionDeleteEventTest.cs +++ b/src/Imagekit.Tests/Models/Webhooks/FileVersionDeleteEventTest.cs @@ -21,7 +21,7 @@ public void FieldRoundtrip_Works() string expectedID = "id"; string expectedType = "type"; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - FileVersionDeleteEventIntersectionMember1Data expectedData = new() + FileVersionDeleteEventFileVersionDeleteEventData expectedData = new() { FileID = "fileId", VersionID = "versionId", @@ -74,7 +74,7 @@ public void FieldRoundtripThroughSerialization_Works() string expectedID = "id"; string expectedType = "type"; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - FileVersionDeleteEventIntersectionMember1Data expectedData = new() + FileVersionDeleteEventFileVersionDeleteEventData expectedData = new() { FileID = "fileId", VersionID = "versionId", @@ -117,19 +117,19 @@ public void CopyConstructor_Works() } } -public class FileVersionDeleteEventIntersectionMember1Test : TestBase +public class FileVersionDeleteEventFileVersionDeleteEventTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new FileVersionDeleteEventIntersectionMember1 + var model = new FileVersionDeleteEventFileVersionDeleteEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() { FileID = "fileId", VersionID = "versionId" }, }; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - FileVersionDeleteEventIntersectionMember1Data expectedData = new() + FileVersionDeleteEventFileVersionDeleteEventData expectedData = new() { FileID = "fileId", VersionID = "versionId", @@ -144,14 +144,14 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new FileVersionDeleteEventIntersectionMember1 + var model = new FileVersionDeleteEventFileVersionDeleteEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() { FileID = "fileId", VersionID = "versionId" }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -162,21 +162,21 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new FileVersionDeleteEventIntersectionMember1 + var model = new FileVersionDeleteEventFileVersionDeleteEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() { FileID = "fileId", VersionID = "versionId" }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - FileVersionDeleteEventIntersectionMember1Data expectedData = new() + FileVersionDeleteEventFileVersionDeleteEventData expectedData = new() { FileID = "fileId", VersionID = "versionId", @@ -191,7 +191,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new FileVersionDeleteEventIntersectionMember1 + var model = new FileVersionDeleteEventFileVersionDeleteEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() { FileID = "fileId", VersionID = "versionId" }, @@ -203,24 +203,24 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new FileVersionDeleteEventIntersectionMember1 + var model = new FileVersionDeleteEventFileVersionDeleteEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() { FileID = "fileId", VersionID = "versionId" }, }; - FileVersionDeleteEventIntersectionMember1 copied = new(model); + FileVersionDeleteEventFileVersionDeleteEvent copied = new(model); Assert.Equal(model, copied); } } -public class FileVersionDeleteEventIntersectionMember1DataTest : TestBase +public class FileVersionDeleteEventFileVersionDeleteEventDataTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new FileVersionDeleteEventIntersectionMember1Data + var model = new FileVersionDeleteEventFileVersionDeleteEventData { FileID = "fileId", VersionID = "versionId", @@ -236,7 +236,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new FileVersionDeleteEventIntersectionMember1Data + var model = new FileVersionDeleteEventFileVersionDeleteEventData { FileID = "fileId", VersionID = "versionId", @@ -244,7 +244,7 @@ public void SerializationRoundtrip_Works() string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -255,7 +255,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new FileVersionDeleteEventIntersectionMember1Data + var model = new FileVersionDeleteEventFileVersionDeleteEventData { FileID = "fileId", VersionID = "versionId", @@ -263,7 +263,7 @@ public void FieldRoundtripThroughSerialization_Works() string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -279,7 +279,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new FileVersionDeleteEventIntersectionMember1Data + var model = new FileVersionDeleteEventFileVersionDeleteEventData { FileID = "fileId", VersionID = "versionId", @@ -291,13 +291,13 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new FileVersionDeleteEventIntersectionMember1Data + var model = new FileVersionDeleteEventFileVersionDeleteEventData { FileID = "fileId", VersionID = "versionId", }; - FileVersionDeleteEventIntersectionMember1Data copied = new(model); + FileVersionDeleteEventFileVersionDeleteEventData copied = new(model); Assert.Equal(model, copied); } diff --git a/src/Imagekit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs b/src/Imagekit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs index 9edd05cf..43b56e9e 100644 --- a/src/Imagekit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs +++ b/src/Imagekit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs @@ -23,7 +23,7 @@ public void VideoTransformationAcceptedValidationWorks() Transformation = new() { Type = - Webhooks::VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + Webhooks::VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = Webhooks::AudioCodec.Aac, @@ -60,20 +60,20 @@ public void VideoTransformationReadyValidationWorks() Transformation = new() { Type = - Webhooks::VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - Webhooks::VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - Webhooks::VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - Webhooks::VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - Webhooks::VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -113,21 +113,21 @@ public void VideoTransformationErrorValidationWorks() Transformation = new() { Type = - Webhooks::VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + Webhooks::VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType.VideoTransformation, Error = new(Webhooks::Reason.EncodingFailed), Options = new() { AudioCodec = - Webhooks::VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + Webhooks::VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - Webhooks::VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Webhooks::VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - Webhooks::VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Webhooks::VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - Webhooks::VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + Webhooks::VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.H264, }, }, }, @@ -320,7 +320,7 @@ public void UploadPreTransformErrorValidationWorks() Name = "name", Path = "path", Transformation = new( - new Webhooks::UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + new Webhooks::UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationError( "encoding_failed" ) ), @@ -349,9 +349,9 @@ public void UploadPostTransformSuccessValidationWorks() Transformation = new() { Type = - Webhooks::UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + Webhooks::UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.Transformation, Protocol = - Webhooks::UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + Webhooks::UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol.Hls, Value = "value", }, XRequestID = "x_request_id", @@ -673,7 +673,7 @@ public void VideoTransformationAcceptedSerializationRoundtripWorks() Transformation = new() { Type = - Webhooks::VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + Webhooks::VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = Webhooks::AudioCodec.Aac, @@ -716,20 +716,20 @@ public void VideoTransformationReadySerializationRoundtripWorks() Transformation = new() { Type = - Webhooks::VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - Webhooks::VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - Webhooks::VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - Webhooks::VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - Webhooks::VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -775,21 +775,21 @@ public void VideoTransformationErrorSerializationRoundtripWorks() Transformation = new() { Type = - Webhooks::VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + Webhooks::VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType.VideoTransformation, Error = new(Webhooks::Reason.EncodingFailed), Options = new() { AudioCodec = - Webhooks::VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + Webhooks::VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - Webhooks::VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Webhooks::VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - Webhooks::VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Webhooks::VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - Webhooks::VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + Webhooks::VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.H264, }, }, }, @@ -994,7 +994,7 @@ public void UploadPreTransformErrorSerializationRoundtripWorks() Name = "name", Path = "path", Transformation = new( - new Webhooks::UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + new Webhooks::UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationError( "encoding_failed" ) ), @@ -1029,9 +1029,9 @@ public void UploadPostTransformSuccessSerializationRoundtripWorks() Transformation = new() { Type = - Webhooks::UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + Webhooks::UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.Transformation, Protocol = - Webhooks::UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + Webhooks::UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol.Hls, Value = "value", }, XRequestID = "x_request_id", diff --git a/src/Imagekit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs b/src/Imagekit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs index 97b9f31b..8b7de059 100644 --- a/src/Imagekit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs +++ b/src/Imagekit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs @@ -23,7 +23,7 @@ public void VideoTransformationAcceptedValidationWorks() Transformation = new() { Type = - Webhooks::VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + Webhooks::VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = Webhooks::AudioCodec.Aac, @@ -60,20 +60,20 @@ public void VideoTransformationReadyValidationWorks() Transformation = new() { Type = - Webhooks::VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - Webhooks::VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - Webhooks::VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - Webhooks::VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - Webhooks::VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -113,21 +113,21 @@ public void VideoTransformationErrorValidationWorks() Transformation = new() { Type = - Webhooks::VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + Webhooks::VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType.VideoTransformation, Error = new(Webhooks::Reason.EncodingFailed), Options = new() { AudioCodec = - Webhooks::VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + Webhooks::VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - Webhooks::VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Webhooks::VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - Webhooks::VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Webhooks::VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - Webhooks::VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + Webhooks::VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.H264, }, }, }, @@ -320,7 +320,7 @@ public void UploadPreTransformErrorValidationWorks() Name = "name", Path = "path", Transformation = new( - new Webhooks::UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + new Webhooks::UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationError( "encoding_failed" ) ), @@ -349,9 +349,9 @@ public void UploadPostTransformSuccessValidationWorks() Transformation = new() { Type = - Webhooks::UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + Webhooks::UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.Transformation, Protocol = - Webhooks::UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + Webhooks::UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol.Hls, Value = "value", }, XRequestID = "x_request_id", @@ -673,7 +673,7 @@ public void VideoTransformationAcceptedSerializationRoundtripWorks() Transformation = new() { Type = - Webhooks::VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + Webhooks::VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = Webhooks::AudioCodec.Aac, @@ -716,20 +716,20 @@ public void VideoTransformationReadySerializationRoundtripWorks() Transformation = new() { Type = - Webhooks::VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - Webhooks::VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - Webhooks::VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - Webhooks::VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - Webhooks::VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -775,21 +775,21 @@ public void VideoTransformationErrorSerializationRoundtripWorks() Transformation = new() { Type = - Webhooks::VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + Webhooks::VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType.VideoTransformation, Error = new(Webhooks::Reason.EncodingFailed), Options = new() { AudioCodec = - Webhooks::VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + Webhooks::VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - Webhooks::VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + Webhooks::VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - Webhooks::VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + Webhooks::VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - Webhooks::VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + Webhooks::VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.H264, }, }, }, @@ -994,7 +994,7 @@ public void UploadPreTransformErrorSerializationRoundtripWorks() Name = "name", Path = "path", Transformation = new( - new Webhooks::UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + new Webhooks::UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationError( "encoding_failed" ) ), @@ -1029,9 +1029,9 @@ public void UploadPostTransformSuccessSerializationRoundtripWorks() Transformation = new() { Type = - Webhooks::UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + Webhooks::UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.Transformation, Protocol = - Webhooks::UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + Webhooks::UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol.Hls, Value = "value", }, XRequestID = "x_request_id", diff --git a/src/Imagekit.Tests/Models/Webhooks/UploadPostTransformErrorEventTest.cs b/src/Imagekit.Tests/Models/Webhooks/UploadPostTransformErrorEventTest.cs index f200f972..bc318e7f 100644 --- a/src/Imagekit.Tests/Models/Webhooks/UploadPostTransformErrorEventTest.cs +++ b/src/Imagekit.Tests/Models/Webhooks/UploadPostTransformErrorEventTest.cs @@ -39,14 +39,15 @@ public void FieldRoundtrip_Works() string expectedID = "id"; string expectedType = "type"; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - Webhooks::UploadPostTransformErrorEventIntersectionMember1Data expectedData = new() - { - FileID = "fileId", - Name = "name", - Path = "path", - Transformation = new(new Webhooks::Error("encoding_failed")), - Url = "https://example.com", - }; + Webhooks::UploadPostTransformErrorEventUploadPostTransformErrorEventData expectedData = + new() + { + FileID = "fileId", + Name = "name", + Path = "path", + Transformation = new(new Webhooks::Error("encoding_failed")), + Url = "https://example.com", + }; Webhooks::Request expectedRequest = new() { Transformation = new() @@ -140,14 +141,15 @@ public void FieldRoundtripThroughSerialization_Works() string expectedID = "id"; string expectedType = "type"; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - Webhooks::UploadPostTransformErrorEventIntersectionMember1Data expectedData = new() - { - FileID = "fileId", - Name = "name", - Path = "path", - Transformation = new(new Webhooks::Error("encoding_failed")), - Url = "https://example.com", - }; + Webhooks::UploadPostTransformErrorEventUploadPostTransformErrorEventData expectedData = + new() + { + FileID = "fileId", + Name = "name", + Path = "path", + Transformation = new(new Webhooks::Error("encoding_failed")), + Url = "https://example.com", + }; Webhooks::Request expectedRequest = new() { Transformation = new() @@ -231,12 +233,12 @@ public void CopyConstructor_Works() } } -public class UploadPostTransformErrorEventIntersectionMember1Test : TestBase +public class UploadPostTransformErrorEventUploadPostTransformErrorEventTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Webhooks::UploadPostTransformErrorEventIntersectionMember1 + var model = new Webhooks::UploadPostTransformErrorEventUploadPostTransformErrorEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -260,14 +262,15 @@ public void FieldRoundtrip_Works() }; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - Webhooks::UploadPostTransformErrorEventIntersectionMember1Data expectedData = new() - { - FileID = "fileId", - Name = "name", - Path = "path", - Transformation = new(new Webhooks::Error("encoding_failed")), - Url = "https://example.com", - }; + Webhooks::UploadPostTransformErrorEventUploadPostTransformErrorEventData expectedData = + new() + { + FileID = "fileId", + Name = "name", + Path = "path", + Transformation = new(new Webhooks::Error("encoding_failed")), + Url = "https://example.com", + }; Webhooks::Request expectedRequest = new() { Transformation = new() @@ -289,7 +292,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Webhooks::UploadPostTransformErrorEventIntersectionMember1 + var model = new Webhooks::UploadPostTransformErrorEventUploadPostTransformErrorEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -314,7 +317,7 @@ public void SerializationRoundtrip_Works() string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -325,7 +328,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Webhooks::UploadPostTransformErrorEventIntersectionMember1 + var model = new Webhooks::UploadPostTransformErrorEventUploadPostTransformErrorEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -350,21 +353,22 @@ public void FieldRoundtripThroughSerialization_Works() string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - Webhooks::UploadPostTransformErrorEventIntersectionMember1Data expectedData = new() - { - FileID = "fileId", - Name = "name", - Path = "path", - Transformation = new(new Webhooks::Error("encoding_failed")), - Url = "https://example.com", - }; + Webhooks::UploadPostTransformErrorEventUploadPostTransformErrorEventData expectedData = + new() + { + FileID = "fileId", + Name = "name", + Path = "path", + Transformation = new(new Webhooks::Error("encoding_failed")), + Url = "https://example.com", + }; Webhooks::Request expectedRequest = new() { Transformation = new() @@ -386,7 +390,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Webhooks::UploadPostTransformErrorEventIntersectionMember1 + var model = new Webhooks::UploadPostTransformErrorEventUploadPostTransformErrorEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -415,7 +419,7 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new Webhooks::UploadPostTransformErrorEventIntersectionMember1 + var model = new Webhooks::UploadPostTransformErrorEventUploadPostTransformErrorEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -438,18 +442,18 @@ public void CopyConstructor_Works() }, }; - Webhooks::UploadPostTransformErrorEventIntersectionMember1 copied = new(model); + Webhooks::UploadPostTransformErrorEventUploadPostTransformErrorEvent copied = new(model); Assert.Equal(model, copied); } } -public class UploadPostTransformErrorEventIntersectionMember1DataTest : TestBase +public class UploadPostTransformErrorEventUploadPostTransformErrorEventDataTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Webhooks::UploadPostTransformErrorEventIntersectionMember1Data + var model = new Webhooks::UploadPostTransformErrorEventUploadPostTransformErrorEventData { FileID = "fileId", Name = "name", @@ -476,7 +480,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Webhooks::UploadPostTransformErrorEventIntersectionMember1Data + var model = new Webhooks::UploadPostTransformErrorEventUploadPostTransformErrorEventData { FileID = "fileId", Name = "name", @@ -487,7 +491,7 @@ public void SerializationRoundtrip_Works() string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -498,7 +502,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Webhooks::UploadPostTransformErrorEventIntersectionMember1Data + var model = new Webhooks::UploadPostTransformErrorEventUploadPostTransformErrorEventData { FileID = "fileId", Name = "name", @@ -509,7 +513,7 @@ public void FieldRoundtripThroughSerialization_Works() string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -533,7 +537,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Webhooks::UploadPostTransformErrorEventIntersectionMember1Data + var model = new Webhooks::UploadPostTransformErrorEventUploadPostTransformErrorEventData { FileID = "fileId", Name = "name", @@ -548,7 +552,7 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new Webhooks::UploadPostTransformErrorEventIntersectionMember1Data + var model = new Webhooks::UploadPostTransformErrorEventUploadPostTransformErrorEventData { FileID = "fileId", Name = "name", @@ -557,7 +561,9 @@ public void CopyConstructor_Works() Url = "https://example.com", }; - Webhooks::UploadPostTransformErrorEventIntersectionMember1Data copied = new(model); + Webhooks::UploadPostTransformErrorEventUploadPostTransformErrorEventData copied = new( + model + ); Assert.Equal(model, copied); } diff --git a/src/Imagekit.Tests/Models/Webhooks/UploadPostTransformSuccessEventTest.cs b/src/Imagekit.Tests/Models/Webhooks/UploadPostTransformSuccessEventTest.cs index 31dd1ca6..f7f2b644 100644 --- a/src/Imagekit.Tests/Models/Webhooks/UploadPostTransformSuccessEventTest.cs +++ b/src/Imagekit.Tests/Models/Webhooks/UploadPostTransformSuccessEventTest.cs @@ -27,9 +27,9 @@ public void FieldRoundtrip_Works() Transformation = new() { Type = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.Transformation, Protocol = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol.Hls, Value = "value", }, XRequestID = "x_request_id", @@ -39,24 +39,25 @@ public void FieldRoundtrip_Works() string expectedID = "id"; string expectedType = "type"; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - UploadPostTransformSuccessEventIntersectionMember1Data expectedData = new() + UploadPostTransformSuccessEventUploadPostTransformSuccessEventData expectedData = new() { FileID = "fileId", Name = "name", Url = "https://example.com", }; - UploadPostTransformSuccessEventIntersectionMember1Request expectedRequest = new() - { - Transformation = new() + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequest expectedRequest = + new() { - Type = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, - Protocol = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, - Value = "value", - }, - XRequestID = "x_request_id", - }; + Transformation = new() + { + Type = + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.Transformation, + Protocol = + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol.Hls, + Value = "value", + }, + XRequestID = "x_request_id", + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedType, model.Type); @@ -84,9 +85,9 @@ public void SerializationRoundtrip_Works() Transformation = new() { Type = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.Transformation, Protocol = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol.Hls, Value = "value", }, XRequestID = "x_request_id", @@ -121,9 +122,9 @@ public void FieldRoundtripThroughSerialization_Works() Transformation = new() { Type = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.Transformation, Protocol = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol.Hls, Value = "value", }, XRequestID = "x_request_id", @@ -140,24 +141,25 @@ public void FieldRoundtripThroughSerialization_Works() string expectedID = "id"; string expectedType = "type"; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - UploadPostTransformSuccessEventIntersectionMember1Data expectedData = new() + UploadPostTransformSuccessEventUploadPostTransformSuccessEventData expectedData = new() { FileID = "fileId", Name = "name", Url = "https://example.com", }; - UploadPostTransformSuccessEventIntersectionMember1Request expectedRequest = new() - { - Transformation = new() + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequest expectedRequest = + new() { - Type = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, - Protocol = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, - Value = "value", - }, - XRequestID = "x_request_id", - }; + Transformation = new() + { + Type = + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.Transformation, + Protocol = + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol.Hls, + Value = "value", + }, + XRequestID = "x_request_id", + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedType, deserialized.Type); @@ -185,9 +187,9 @@ public void Validation_Works() Transformation = new() { Type = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.Transformation, Protocol = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol.Hls, Value = "value", }, XRequestID = "x_request_id", @@ -216,9 +218,9 @@ public void CopyConstructor_Works() Transformation = new() { Type = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.Transformation, Protocol = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol.Hls, Value = "value", }, XRequestID = "x_request_id", @@ -231,12 +233,12 @@ public void CopyConstructor_Works() } } -public class UploadPostTransformSuccessEventIntersectionMember1Test : TestBase +public class UploadPostTransformSuccessEventUploadPostTransformSuccessEventTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new UploadPostTransformSuccessEventIntersectionMember1 + var model = new UploadPostTransformSuccessEventUploadPostTransformSuccessEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -250,9 +252,9 @@ public void FieldRoundtrip_Works() Transformation = new() { Type = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.Transformation, Protocol = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol.Hls, Value = "value", }, XRequestID = "x_request_id", @@ -260,24 +262,25 @@ public void FieldRoundtrip_Works() }; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - UploadPostTransformSuccessEventIntersectionMember1Data expectedData = new() + UploadPostTransformSuccessEventUploadPostTransformSuccessEventData expectedData = new() { FileID = "fileId", Name = "name", Url = "https://example.com", }; - UploadPostTransformSuccessEventIntersectionMember1Request expectedRequest = new() - { - Transformation = new() + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequest expectedRequest = + new() { - Type = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, - Protocol = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, - Value = "value", - }, - XRequestID = "x_request_id", - }; + Transformation = new() + { + Type = + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.Transformation, + Protocol = + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol.Hls, + Value = "value", + }, + XRequestID = "x_request_id", + }; JsonElement expectedType = JsonSerializer.SerializeToElement( "upload.post-transform.success" ); @@ -291,7 +294,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new UploadPostTransformSuccessEventIntersectionMember1 + var model = new UploadPostTransformSuccessEventUploadPostTransformSuccessEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -305,9 +308,9 @@ public void SerializationRoundtrip_Works() Transformation = new() { Type = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.Transformation, Protocol = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol.Hls, Value = "value", }, XRequestID = "x_request_id", @@ -316,7 +319,7 @@ public void SerializationRoundtrip_Works() string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -327,7 +330,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new UploadPostTransformSuccessEventIntersectionMember1 + var model = new UploadPostTransformSuccessEventUploadPostTransformSuccessEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -341,9 +344,9 @@ public void FieldRoundtripThroughSerialization_Works() Transformation = new() { Type = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.Transformation, Protocol = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol.Hls, Value = "value", }, XRequestID = "x_request_id", @@ -352,31 +355,32 @@ public void FieldRoundtripThroughSerialization_Works() string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - UploadPostTransformSuccessEventIntersectionMember1Data expectedData = new() + UploadPostTransformSuccessEventUploadPostTransformSuccessEventData expectedData = new() { FileID = "fileId", Name = "name", Url = "https://example.com", }; - UploadPostTransformSuccessEventIntersectionMember1Request expectedRequest = new() - { - Transformation = new() + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequest expectedRequest = + new() { - Type = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, - Protocol = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, - Value = "value", - }, - XRequestID = "x_request_id", - }; + Transformation = new() + { + Type = + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.Transformation, + Protocol = + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol.Hls, + Value = "value", + }, + XRequestID = "x_request_id", + }; JsonElement expectedType = JsonSerializer.SerializeToElement( "upload.post-transform.success" ); @@ -390,7 +394,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new UploadPostTransformSuccessEventIntersectionMember1 + var model = new UploadPostTransformSuccessEventUploadPostTransformSuccessEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -404,9 +408,9 @@ public void Validation_Works() Transformation = new() { Type = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.Transformation, Protocol = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol.Hls, Value = "value", }, XRequestID = "x_request_id", @@ -419,7 +423,7 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new UploadPostTransformSuccessEventIntersectionMember1 + var model = new UploadPostTransformSuccessEventUploadPostTransformSuccessEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -433,27 +437,27 @@ public void CopyConstructor_Works() Transformation = new() { Type = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.Transformation, Protocol = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol.Hls, Value = "value", }, XRequestID = "x_request_id", }, }; - UploadPostTransformSuccessEventIntersectionMember1 copied = new(model); + UploadPostTransformSuccessEventUploadPostTransformSuccessEvent copied = new(model); Assert.Equal(model, copied); } } -public class UploadPostTransformSuccessEventIntersectionMember1DataTest : TestBase +public class UploadPostTransformSuccessEventUploadPostTransformSuccessEventDataTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new UploadPostTransformSuccessEventIntersectionMember1Data + var model = new UploadPostTransformSuccessEventUploadPostTransformSuccessEventData { FileID = "fileId", Name = "name", @@ -472,7 +476,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new UploadPostTransformSuccessEventIntersectionMember1Data + var model = new UploadPostTransformSuccessEventUploadPostTransformSuccessEventData { FileID = "fileId", Name = "name", @@ -481,7 +485,7 @@ public void SerializationRoundtrip_Works() string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -492,7 +496,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new UploadPostTransformSuccessEventIntersectionMember1Data + var model = new UploadPostTransformSuccessEventUploadPostTransformSuccessEventData { FileID = "fileId", Name = "name", @@ -501,7 +505,7 @@ public void FieldRoundtripThroughSerialization_Works() string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -519,7 +523,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new UploadPostTransformSuccessEventIntersectionMember1Data + var model = new UploadPostTransformSuccessEventUploadPostTransformSuccessEventData { FileID = "fileId", Name = "name", @@ -532,44 +536,44 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new UploadPostTransformSuccessEventIntersectionMember1Data + var model = new UploadPostTransformSuccessEventUploadPostTransformSuccessEventData { FileID = "fileId", Name = "name", Url = "https://example.com", }; - UploadPostTransformSuccessEventIntersectionMember1Data copied = new(model); + UploadPostTransformSuccessEventUploadPostTransformSuccessEventData copied = new(model); Assert.Equal(model, copied); } } -public class UploadPostTransformSuccessEventIntersectionMember1RequestTest : TestBase +public class UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new UploadPostTransformSuccessEventIntersectionMember1Request + var model = new UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequest { Transformation = new() { Type = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.Transformation, Protocol = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol.Hls, Value = "value", }, XRequestID = "x_request_id", }; - UploadPostTransformSuccessEventIntersectionMember1RequestTransformation expectedTransformation = + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformation expectedTransformation = new() { Type = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.Transformation, Protocol = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol.Hls, Value = "value", }; string expectedXRequestID = "x_request_id"; @@ -581,14 +585,14 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new UploadPostTransformSuccessEventIntersectionMember1Request + var model = new UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequest { Transformation = new() { Type = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.Transformation, Protocol = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol.Hls, Value = "value", }, XRequestID = "x_request_id", @@ -596,7 +600,7 @@ public void SerializationRoundtrip_Works() string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -607,14 +611,14 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new UploadPostTransformSuccessEventIntersectionMember1Request + var model = new UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequest { Transformation = new() { Type = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.Transformation, Protocol = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol.Hls, Value = "value", }, XRequestID = "x_request_id", @@ -622,19 +626,19 @@ public void FieldRoundtripThroughSerialization_Works() string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - UploadPostTransformSuccessEventIntersectionMember1RequestTransformation expectedTransformation = + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformation expectedTransformation = new() { Type = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.Transformation, Protocol = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol.Hls, Value = "value", }; string expectedXRequestID = "x_request_id"; @@ -646,14 +650,14 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new UploadPostTransformSuccessEventIntersectionMember1Request + var model = new UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequest { Transformation = new() { Type = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.Transformation, Protocol = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol.Hls, Value = "value", }, XRequestID = "x_request_id", @@ -665,49 +669,51 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new UploadPostTransformSuccessEventIntersectionMember1Request + var model = new UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequest { Transformation = new() { Type = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.Transformation, Protocol = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol.Hls, Value = "value", }, XRequestID = "x_request_id", }; - UploadPostTransformSuccessEventIntersectionMember1Request copied = new(model); + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequest copied = new(model); Assert.Equal(model, copied); } } -public class UploadPostTransformSuccessEventIntersectionMember1RequestTransformationTest : TestBase +public class UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationTest + : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new UploadPostTransformSuccessEventIntersectionMember1RequestTransformation - { - Type = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, - Protocol = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, - Value = "value", - }; + var model = + new UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformation + { + Type = + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.Transformation, + Protocol = + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol.Hls, + Value = "value", + }; ApiEnum< string, - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType > expectedType = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation; + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.Transformation; ApiEnum< string, - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol > expectedProtocol = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls; + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol.Hls; string expectedValue = "value"; Assert.Equal(expectedType, model.Type); @@ -718,18 +724,19 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new UploadPostTransformSuccessEventIntersectionMember1RequestTransformation - { - Type = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, - Protocol = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, - Value = "value", - }; + var model = + new UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformation + { + Type = + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.Transformation, + Protocol = + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol.Hls, + Value = "value", + }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -740,18 +747,19 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new UploadPostTransformSuccessEventIntersectionMember1RequestTransformation - { - Type = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, - Protocol = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, - Value = "value", - }; + var model = + new UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformation + { + Type = + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.Transformation, + Protocol = + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol.Hls, + Value = "value", + }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -759,14 +767,14 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum< string, - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType > expectedType = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation; + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.Transformation; ApiEnum< string, - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol > expectedProtocol = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls; + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol.Hls; string expectedValue = "value"; Assert.Equal(expectedType, deserialized.Type); @@ -777,14 +785,15 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new UploadPostTransformSuccessEventIntersectionMember1RequestTransformation - { - Type = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, - Protocol = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, - Value = "value", - }; + var model = + new UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformation + { + Type = + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.Transformation, + Protocol = + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol.Hls, + Value = "value", + }; model.Validate(); } @@ -792,11 +801,12 @@ public void Validation_Works() [Fact] public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new UploadPostTransformSuccessEventIntersectionMember1RequestTransformation - { - Type = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, - }; + var model = + new UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformation + { + Type = + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.Transformation, + }; Assert.Null(model.Protocol); Assert.False(model.RawData.ContainsKey("protocol")); @@ -807,11 +817,12 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = new UploadPostTransformSuccessEventIntersectionMember1RequestTransformation - { - Type = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, - }; + var model = + new UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformation + { + Type = + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.Transformation, + }; model.Validate(); } @@ -819,15 +830,16 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - var model = new UploadPostTransformSuccessEventIntersectionMember1RequestTransformation - { - Type = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + var model = + new UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformation + { + Type = + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.Transformation, - // Null should be interpreted as omitted for these properties - Protocol = null, - Value = null, - }; + // Null should be interpreted as omitted for these properties + Protocol = null, + Value = null, + }; Assert.Null(model.Protocol); Assert.False(model.RawData.ContainsKey("protocol")); @@ -838,15 +850,16 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - var model = new UploadPostTransformSuccessEventIntersectionMember1RequestTransformation - { - Type = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + var model = + new UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformation + { + Type = + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.Transformation, - // Null should be interpreted as omitted for these properties - Protocol = null, - Value = null, - }; + // Null should be interpreted as omitted for these properties + Protocol = null, + Value = null, + }; model.Validate(); } @@ -854,43 +867,47 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new UploadPostTransformSuccessEventIntersectionMember1RequestTransformation - { - Type = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, - Protocol = - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, - Value = "value", - }; + var model = + new UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformation + { + Type = + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.Transformation, + Protocol = + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol.Hls, + Value = "value", + }; - UploadPostTransformSuccessEventIntersectionMember1RequestTransformation copied = new(model); + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformation copied = + new(model); Assert.Equal(model, copied); } } -public class UploadPostTransformSuccessEventIntersectionMember1RequestTransformationTypeTest +public class UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationTypeTest : TestBase { [Theory] [InlineData( - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.Transformation )] - [InlineData(UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Abs)] [InlineData( - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.GifToVideo + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.Abs )] [InlineData( - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Thumbnail + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.GifToVideo + )] + [InlineData( + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.Thumbnail )] public void Validation_Works( - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType rawValue + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType > value = rawValue; value.Validate(); } @@ -901,7 +918,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -911,30 +928,32 @@ public void InvalidEnumValidationThrows_Works() [Theory] [InlineData( - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.Transformation + )] + [InlineData( + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.Abs )] - [InlineData(UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Abs)] [InlineData( - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.GifToVideo + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.GifToVideo )] [InlineData( - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Thumbnail + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.Thumbnail )] public void SerializationRoundtrip_Works( - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType rawValue + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType > >(json, ModelBase.SerializerOptions); @@ -947,14 +966,14 @@ public void InvalidEnumSerializationRoundtrip_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType > >(json, ModelBase.SerializerOptions); @@ -962,24 +981,24 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocolTest +public class UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocolTest : TestBase { [Theory] [InlineData( - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol.Hls )] [InlineData( - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Dash + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol.Dash )] public void Validation_Works( - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol rawValue + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol > value = rawValue; value.Validate(); } @@ -990,7 +1009,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -1000,26 +1019,26 @@ public void InvalidEnumValidationThrows_Works() [Theory] [InlineData( - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol.Hls )] [InlineData( - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Dash + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol.Dash )] public void SerializationRoundtrip_Works( - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol rawValue + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol > >(json, ModelBase.SerializerOptions); @@ -1032,14 +1051,14 @@ public void InvalidEnumSerializationRoundtrip_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol > >(json, ModelBase.SerializerOptions); diff --git a/src/Imagekit.Tests/Models/Webhooks/UploadPreTransformErrorEventTest.cs b/src/Imagekit.Tests/Models/Webhooks/UploadPreTransformErrorEventTest.cs index 96d722ee..ff28093e 100644 --- a/src/Imagekit.Tests/Models/Webhooks/UploadPreTransformErrorEventTest.cs +++ b/src/Imagekit.Tests/Models/Webhooks/UploadPreTransformErrorEventTest.cs @@ -20,7 +20,7 @@ public void FieldRoundtrip_Works() Name = "name", Path = "path", Transformation = new( - new UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + new UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationError( "encoding_failed" ) ), @@ -31,17 +31,17 @@ public void FieldRoundtrip_Works() string expectedID = "id"; string expectedType = "type"; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - UploadPreTransformErrorEventIntersectionMember1Data expectedData = new() + UploadPreTransformErrorEventUploadPreTransformErrorEventData expectedData = new() { Name = "name", Path = "path", Transformation = new( - new UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + new UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationError( "encoding_failed" ) ), }; - UploadPreTransformErrorEventIntersectionMember1Request expectedRequest = new() + UploadPreTransformErrorEventUploadPreTransformErrorEventRequest expectedRequest = new() { Transformation = "transformation", XRequestID = "x_request_id", @@ -67,7 +67,7 @@ public void SerializationRoundtrip_Works() Name = "name", Path = "path", Transformation = new( - new UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + new UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationError( "encoding_failed" ) ), @@ -97,7 +97,7 @@ public void FieldRoundtripThroughSerialization_Works() Name = "name", Path = "path", Transformation = new( - new UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + new UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationError( "encoding_failed" ) ), @@ -115,17 +115,17 @@ public void FieldRoundtripThroughSerialization_Works() string expectedID = "id"; string expectedType = "type"; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - UploadPreTransformErrorEventIntersectionMember1Data expectedData = new() + UploadPreTransformErrorEventUploadPreTransformErrorEventData expectedData = new() { Name = "name", Path = "path", Transformation = new( - new UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + new UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationError( "encoding_failed" ) ), }; - UploadPreTransformErrorEventIntersectionMember1Request expectedRequest = new() + UploadPreTransformErrorEventUploadPreTransformErrorEventRequest expectedRequest = new() { Transformation = "transformation", XRequestID = "x_request_id", @@ -151,7 +151,7 @@ public void Validation_Works() Name = "name", Path = "path", Transformation = new( - new UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + new UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationError( "encoding_failed" ) ), @@ -175,7 +175,7 @@ public void CopyConstructor_Works() Name = "name", Path = "path", Transformation = new( - new UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + new UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationError( "encoding_failed" ) ), @@ -189,12 +189,12 @@ public void CopyConstructor_Works() } } -public class UploadPreTransformErrorEventIntersectionMember1Test : TestBase +public class UploadPreTransformErrorEventUploadPreTransformErrorEventTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new UploadPreTransformErrorEventIntersectionMember1 + var model = new UploadPreTransformErrorEventUploadPreTransformErrorEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -202,7 +202,7 @@ public void FieldRoundtrip_Works() Name = "name", Path = "path", Transformation = new( - new UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + new UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationError( "encoding_failed" ) ), @@ -211,17 +211,17 @@ public void FieldRoundtrip_Works() }; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - UploadPreTransformErrorEventIntersectionMember1Data expectedData = new() + UploadPreTransformErrorEventUploadPreTransformErrorEventData expectedData = new() { Name = "name", Path = "path", Transformation = new( - new UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + new UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationError( "encoding_failed" ) ), }; - UploadPreTransformErrorEventIntersectionMember1Request expectedRequest = new() + UploadPreTransformErrorEventUploadPreTransformErrorEventRequest expectedRequest = new() { Transformation = "transformation", XRequestID = "x_request_id", @@ -237,7 +237,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new UploadPreTransformErrorEventIntersectionMember1 + var model = new UploadPreTransformErrorEventUploadPreTransformErrorEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -245,7 +245,7 @@ public void SerializationRoundtrip_Works() Name = "name", Path = "path", Transformation = new( - new UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + new UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationError( "encoding_failed" ) ), @@ -255,7 +255,7 @@ public void SerializationRoundtrip_Works() string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -266,7 +266,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new UploadPreTransformErrorEventIntersectionMember1 + var model = new UploadPreTransformErrorEventUploadPreTransformErrorEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -274,7 +274,7 @@ public void FieldRoundtripThroughSerialization_Works() Name = "name", Path = "path", Transformation = new( - new UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + new UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationError( "encoding_failed" ) ), @@ -284,24 +284,24 @@ public void FieldRoundtripThroughSerialization_Works() string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - UploadPreTransformErrorEventIntersectionMember1Data expectedData = new() + UploadPreTransformErrorEventUploadPreTransformErrorEventData expectedData = new() { Name = "name", Path = "path", Transformation = new( - new UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + new UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationError( "encoding_failed" ) ), }; - UploadPreTransformErrorEventIntersectionMember1Request expectedRequest = new() + UploadPreTransformErrorEventUploadPreTransformErrorEventRequest expectedRequest = new() { Transformation = "transformation", XRequestID = "x_request_id", @@ -317,7 +317,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new UploadPreTransformErrorEventIntersectionMember1 + var model = new UploadPreTransformErrorEventUploadPreTransformErrorEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -325,7 +325,7 @@ public void Validation_Works() Name = "name", Path = "path", Transformation = new( - new UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + new UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationError( "encoding_failed" ) ), @@ -339,7 +339,7 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new UploadPreTransformErrorEventIntersectionMember1 + var model = new UploadPreTransformErrorEventUploadPreTransformErrorEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -347,7 +347,7 @@ public void CopyConstructor_Works() Name = "name", Path = "path", Transformation = new( - new UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + new UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationError( "encoding_failed" ) ), @@ -355,23 +355,23 @@ public void CopyConstructor_Works() Request = new() { Transformation = "transformation", XRequestID = "x_request_id" }, }; - UploadPreTransformErrorEventIntersectionMember1 copied = new(model); + UploadPreTransformErrorEventUploadPreTransformErrorEvent copied = new(model); Assert.Equal(model, copied); } } -public class UploadPreTransformErrorEventIntersectionMember1DataTest : TestBase +public class UploadPreTransformErrorEventUploadPreTransformErrorEventDataTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new UploadPreTransformErrorEventIntersectionMember1Data + var model = new UploadPreTransformErrorEventUploadPreTransformErrorEventData { Name = "name", Path = "path", Transformation = new( - new UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + new UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationError( "encoding_failed" ) ), @@ -379,9 +379,9 @@ public void FieldRoundtrip_Works() string expectedName = "name"; string expectedPath = "path"; - UploadPreTransformErrorEventIntersectionMember1DataTransformation expectedTransformation = + UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformation expectedTransformation = new( - new UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + new UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationError( "encoding_failed" ) ); @@ -394,12 +394,12 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new UploadPreTransformErrorEventIntersectionMember1Data + var model = new UploadPreTransformErrorEventUploadPreTransformErrorEventData { Name = "name", Path = "path", Transformation = new( - new UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + new UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationError( "encoding_failed" ) ), @@ -407,7 +407,7 @@ public void SerializationRoundtrip_Works() string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -418,12 +418,12 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new UploadPreTransformErrorEventIntersectionMember1Data + var model = new UploadPreTransformErrorEventUploadPreTransformErrorEventData { Name = "name", Path = "path", Transformation = new( - new UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + new UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationError( "encoding_failed" ) ), @@ -431,7 +431,7 @@ public void FieldRoundtripThroughSerialization_Works() string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -439,9 +439,9 @@ public void FieldRoundtripThroughSerialization_Works() string expectedName = "name"; string expectedPath = "path"; - UploadPreTransformErrorEventIntersectionMember1DataTransformation expectedTransformation = + UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformation expectedTransformation = new( - new UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + new UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationError( "encoding_failed" ) ); @@ -454,12 +454,12 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new UploadPreTransformErrorEventIntersectionMember1Data + var model = new UploadPreTransformErrorEventUploadPreTransformErrorEventData { Name = "name", Path = "path", Transformation = new( - new UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + new UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationError( "encoding_failed" ) ), @@ -471,36 +471,36 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new UploadPreTransformErrorEventIntersectionMember1Data + var model = new UploadPreTransformErrorEventUploadPreTransformErrorEventData { Name = "name", Path = "path", Transformation = new( - new UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + new UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationError( "encoding_failed" ) ), }; - UploadPreTransformErrorEventIntersectionMember1Data copied = new(model); + UploadPreTransformErrorEventUploadPreTransformErrorEventData copied = new(model); Assert.Equal(model, copied); } } -public class UploadPreTransformErrorEventIntersectionMember1DataTransformationTest : TestBase +public class UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationTest + : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new UploadPreTransformErrorEventIntersectionMember1DataTransformation + var model = new UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformation { Error = new("encoding_failed"), }; - UploadPreTransformErrorEventIntersectionMember1DataTransformationError expectedError = new( - "encoding_failed" - ); + UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationError expectedError = + new("encoding_failed"); Assert.Equal(expectedError, model.Error); } @@ -508,14 +508,14 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new UploadPreTransformErrorEventIntersectionMember1DataTransformation + var model = new UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformation { Error = new("encoding_failed"), }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -526,22 +526,21 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new UploadPreTransformErrorEventIntersectionMember1DataTransformation + var model = new UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformation { Error = new("encoding_failed"), }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - UploadPreTransformErrorEventIntersectionMember1DataTransformationError expectedError = new( - "encoding_failed" - ); + UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationError expectedError = + new("encoding_failed"); Assert.Equal(expectedError, deserialized.Error); } @@ -549,7 +548,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new UploadPreTransformErrorEventIntersectionMember1DataTransformation + var model = new UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformation { Error = new("encoding_failed"), }; @@ -560,26 +559,30 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new UploadPreTransformErrorEventIntersectionMember1DataTransformation + var model = new UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformation { Error = new("encoding_failed"), }; - UploadPreTransformErrorEventIntersectionMember1DataTransformation copied = new(model); + UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformation copied = new( + model + ); Assert.Equal(model, copied); } } -public class UploadPreTransformErrorEventIntersectionMember1DataTransformationErrorTest : TestBase +public class UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationErrorTest + : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new UploadPreTransformErrorEventIntersectionMember1DataTransformationError - { - Reason = "encoding_failed", - }; + var model = + new UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationError + { + Reason = "encoding_failed", + }; string expectedReason = "encoding_failed"; @@ -589,14 +592,15 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new UploadPreTransformErrorEventIntersectionMember1DataTransformationError - { - Reason = "encoding_failed", - }; + var model = + new UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationError + { + Reason = "encoding_failed", + }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -607,14 +611,15 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new UploadPreTransformErrorEventIntersectionMember1DataTransformationError - { - Reason = "encoding_failed", - }; + var model = + new UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationError + { + Reason = "encoding_failed", + }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -628,10 +633,11 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new UploadPreTransformErrorEventIntersectionMember1DataTransformationError - { - Reason = "encoding_failed", - }; + var model = + new UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationError + { + Reason = "encoding_failed", + }; model.Validate(); } @@ -639,23 +645,25 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new UploadPreTransformErrorEventIntersectionMember1DataTransformationError - { - Reason = "encoding_failed", - }; + var model = + new UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationError + { + Reason = "encoding_failed", + }; - UploadPreTransformErrorEventIntersectionMember1DataTransformationError copied = new(model); + UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationError copied = + new(model); Assert.Equal(model, copied); } } -public class UploadPreTransformErrorEventIntersectionMember1RequestTest : TestBase +public class UploadPreTransformErrorEventUploadPreTransformErrorEventRequestTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new UploadPreTransformErrorEventIntersectionMember1Request + var model = new UploadPreTransformErrorEventUploadPreTransformErrorEventRequest { Transformation = "transformation", XRequestID = "x_request_id", @@ -671,7 +679,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new UploadPreTransformErrorEventIntersectionMember1Request + var model = new UploadPreTransformErrorEventUploadPreTransformErrorEventRequest { Transformation = "transformation", XRequestID = "x_request_id", @@ -679,7 +687,7 @@ public void SerializationRoundtrip_Works() string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -690,7 +698,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new UploadPreTransformErrorEventIntersectionMember1Request + var model = new UploadPreTransformErrorEventUploadPreTransformErrorEventRequest { Transformation = "transformation", XRequestID = "x_request_id", @@ -698,7 +706,7 @@ public void FieldRoundtripThroughSerialization_Works() string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -714,7 +722,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new UploadPreTransformErrorEventIntersectionMember1Request + var model = new UploadPreTransformErrorEventUploadPreTransformErrorEventRequest { Transformation = "transformation", XRequestID = "x_request_id", @@ -726,13 +734,13 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new UploadPreTransformErrorEventIntersectionMember1Request + var model = new UploadPreTransformErrorEventUploadPreTransformErrorEventRequest { Transformation = "transformation", XRequestID = "x_request_id", }; - UploadPreTransformErrorEventIntersectionMember1Request copied = new(model); + UploadPreTransformErrorEventUploadPreTransformErrorEventRequest copied = new(model); Assert.Equal(model, copied); } diff --git a/src/Imagekit.Tests/Models/Webhooks/UploadPreTransformSuccessEventTest.cs b/src/Imagekit.Tests/Models/Webhooks/UploadPreTransformSuccessEventTest.cs index 35f11522..dd00b1be 100644 --- a/src/Imagekit.Tests/Models/Webhooks/UploadPreTransformSuccessEventTest.cs +++ b/src/Imagekit.Tests/Models/Webhooks/UploadPreTransformSuccessEventTest.cs @@ -177,7 +177,7 @@ public void FieldRoundtrip_Works() string expectedID = "id"; string expectedType = "type"; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - UploadPreTransformSuccessEventIntersectionMember1Data expectedData = new() + UploadPreTransformSuccessEventUploadPreTransformSuccessEventData expectedData = new() { AITags = [ @@ -330,7 +330,7 @@ public void FieldRoundtrip_Works() VideoCodec = "videoCodec", Width = 0, }; - UploadPreTransformSuccessEventIntersectionMember1Request expectedRequest = new() + UploadPreTransformSuccessEventUploadPreTransformSuccessEventRequest expectedRequest = new() { Transformation = "transformation", XRequestID = "x_request_id", @@ -690,7 +690,7 @@ public void FieldRoundtripThroughSerialization_Works() string expectedID = "id"; string expectedType = "type"; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - UploadPreTransformSuccessEventIntersectionMember1Data expectedData = new() + UploadPreTransformSuccessEventUploadPreTransformSuccessEventData expectedData = new() { AITags = [ @@ -843,7 +843,7 @@ public void FieldRoundtripThroughSerialization_Works() VideoCodec = "videoCodec", Width = 0, }; - UploadPreTransformSuccessEventIntersectionMember1Request expectedRequest = new() + UploadPreTransformSuccessEventUploadPreTransformSuccessEventRequest expectedRequest = new() { Transformation = "transformation", XRequestID = "x_request_id", @@ -1193,12 +1193,12 @@ public void CopyConstructor_Works() } } -public class UploadPreTransformSuccessEventIntersectionMember1Test : TestBase +public class UploadPreTransformSuccessEventUploadPreTransformSuccessEventTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new UploadPreTransformSuccessEventIntersectionMember1 + var model = new UploadPreTransformSuccessEventUploadPreTransformSuccessEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -1358,7 +1358,7 @@ public void FieldRoundtrip_Works() }; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - UploadPreTransformSuccessEventIntersectionMember1Data expectedData = new() + UploadPreTransformSuccessEventUploadPreTransformSuccessEventData expectedData = new() { AITags = [ @@ -1511,7 +1511,7 @@ public void FieldRoundtrip_Works() VideoCodec = "videoCodec", Width = 0, }; - UploadPreTransformSuccessEventIntersectionMember1Request expectedRequest = new() + UploadPreTransformSuccessEventUploadPreTransformSuccessEventRequest expectedRequest = new() { Transformation = "transformation", XRequestID = "x_request_id", @@ -1529,7 +1529,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new UploadPreTransformSuccessEventIntersectionMember1 + var model = new UploadPreTransformSuccessEventUploadPreTransformSuccessEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -1690,7 +1690,7 @@ public void SerializationRoundtrip_Works() string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -1701,7 +1701,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new UploadPreTransformSuccessEventIntersectionMember1 + var model = new UploadPreTransformSuccessEventUploadPreTransformSuccessEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -1862,14 +1862,14 @@ public void FieldRoundtripThroughSerialization_Works() string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - UploadPreTransformSuccessEventIntersectionMember1Data expectedData = new() + UploadPreTransformSuccessEventUploadPreTransformSuccessEventData expectedData = new() { AITags = [ @@ -2022,7 +2022,7 @@ public void FieldRoundtripThroughSerialization_Works() VideoCodec = "videoCodec", Width = 0, }; - UploadPreTransformSuccessEventIntersectionMember1Request expectedRequest = new() + UploadPreTransformSuccessEventUploadPreTransformSuccessEventRequest expectedRequest = new() { Transformation = "transformation", XRequestID = "x_request_id", @@ -2040,7 +2040,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new UploadPreTransformSuccessEventIntersectionMember1 + var model = new UploadPreTransformSuccessEventUploadPreTransformSuccessEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -2205,7 +2205,7 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new UploadPreTransformSuccessEventIntersectionMember1 + var model = new UploadPreTransformSuccessEventUploadPreTransformSuccessEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -2364,18 +2364,18 @@ public void CopyConstructor_Works() Request = new() { Transformation = "transformation", XRequestID = "x_request_id" }, }; - UploadPreTransformSuccessEventIntersectionMember1 copied = new(model); + UploadPreTransformSuccessEventUploadPreTransformSuccessEvent copied = new(model); Assert.Equal(model, copied); } } -public class UploadPreTransformSuccessEventIntersectionMember1DataTest : TestBase +public class UploadPreTransformSuccessEventUploadPreTransformSuccessEventDataTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new UploadPreTransformSuccessEventIntersectionMember1Data + var model = new UploadPreTransformSuccessEventUploadPreTransformSuccessEventData { AITags = [ @@ -2741,7 +2741,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new UploadPreTransformSuccessEventIntersectionMember1Data + var model = new UploadPreTransformSuccessEventUploadPreTransformSuccessEventData { AITags = [ @@ -2897,7 +2897,7 @@ public void SerializationRoundtrip_Works() string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -2908,7 +2908,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new UploadPreTransformSuccessEventIntersectionMember1Data + var model = new UploadPreTransformSuccessEventUploadPreTransformSuccessEventData { AITags = [ @@ -3064,7 +3064,7 @@ public void FieldRoundtripThroughSerialization_Works() string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -3282,7 +3282,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new UploadPreTransformSuccessEventIntersectionMember1Data + var model = new UploadPreTransformSuccessEventUploadPreTransformSuccessEventData { AITags = [ @@ -3442,7 +3442,7 @@ public void Validation_Works() [Fact] public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new UploadPreTransformSuccessEventIntersectionMember1Data + var model = new UploadPreTransformSuccessEventUploadPreTransformSuccessEventData { AITags = [ @@ -3506,7 +3506,7 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = new UploadPreTransformSuccessEventIntersectionMember1Data + var model = new UploadPreTransformSuccessEventUploadPreTransformSuccessEventData { AITags = [ @@ -3527,7 +3527,7 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - var model = new UploadPreTransformSuccessEventIntersectionMember1Data + var model = new UploadPreTransformSuccessEventUploadPreTransformSuccessEventData { AITags = [ @@ -3615,7 +3615,7 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - var model = new UploadPreTransformSuccessEventIntersectionMember1Data + var model = new UploadPreTransformSuccessEventUploadPreTransformSuccessEventData { AITags = [ @@ -3660,7 +3660,7 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new UploadPreTransformSuccessEventIntersectionMember1Data + var model = new UploadPreTransformSuccessEventUploadPreTransformSuccessEventData { AudioCodec = "audioCodec", BitRate = 0, @@ -3814,7 +3814,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new UploadPreTransformSuccessEventIntersectionMember1Data + var model = new UploadPreTransformSuccessEventUploadPreTransformSuccessEventData { AudioCodec = "audioCodec", BitRate = 0, @@ -3963,7 +3963,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new UploadPreTransformSuccessEventIntersectionMember1Data + var model = new UploadPreTransformSuccessEventUploadPreTransformSuccessEventData { AudioCodec = "audioCodec", BitRate = 0, @@ -4121,7 +4121,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new UploadPreTransformSuccessEventIntersectionMember1Data + var model = new UploadPreTransformSuccessEventUploadPreTransformSuccessEventData { AudioCodec = "audioCodec", BitRate = 0, @@ -4274,7 +4274,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new UploadPreTransformSuccessEventIntersectionMember1Data + var model = new UploadPreTransformSuccessEventUploadPreTransformSuccessEventData { AITags = [ @@ -4428,7 +4428,7 @@ public void CopyConstructor_Works() Width = 0, }; - UploadPreTransformSuccessEventIntersectionMember1Data copied = new(model); + UploadPreTransformSuccessEventUploadPreTransformSuccessEventData copied = new(model); Assert.Equal(model, copied); } @@ -5849,12 +5849,12 @@ public void CopyConstructor_Works() } } -public class UploadPreTransformSuccessEventIntersectionMember1RequestTest : TestBase +public class UploadPreTransformSuccessEventUploadPreTransformSuccessEventRequestTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new UploadPreTransformSuccessEventIntersectionMember1Request + var model = new UploadPreTransformSuccessEventUploadPreTransformSuccessEventRequest { Transformation = "transformation", XRequestID = "x_request_id", @@ -5870,7 +5870,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new UploadPreTransformSuccessEventIntersectionMember1Request + var model = new UploadPreTransformSuccessEventUploadPreTransformSuccessEventRequest { Transformation = "transformation", XRequestID = "x_request_id", @@ -5878,7 +5878,7 @@ public void SerializationRoundtrip_Works() string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -5889,7 +5889,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new UploadPreTransformSuccessEventIntersectionMember1Request + var model = new UploadPreTransformSuccessEventUploadPreTransformSuccessEventRequest { Transformation = "transformation", XRequestID = "x_request_id", @@ -5897,7 +5897,7 @@ public void FieldRoundtripThroughSerialization_Works() string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -5913,7 +5913,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new UploadPreTransformSuccessEventIntersectionMember1Request + var model = new UploadPreTransformSuccessEventUploadPreTransformSuccessEventRequest { Transformation = "transformation", XRequestID = "x_request_id", @@ -5925,13 +5925,13 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new UploadPreTransformSuccessEventIntersectionMember1Request + var model = new UploadPreTransformSuccessEventUploadPreTransformSuccessEventRequest { Transformation = "transformation", XRequestID = "x_request_id", }; - UploadPreTransformSuccessEventIntersectionMember1Request copied = new(model); + UploadPreTransformSuccessEventUploadPreTransformSuccessEventRequest copied = new(model); Assert.Equal(model, copied); } diff --git a/src/Imagekit.Tests/Models/Webhooks/VideoTransformationAcceptedEventTest.cs b/src/Imagekit.Tests/Models/Webhooks/VideoTransformationAcceptedEventTest.cs index 346342ff..6d8f11ac 100644 --- a/src/Imagekit.Tests/Models/Webhooks/VideoTransformationAcceptedEventTest.cs +++ b/src/Imagekit.Tests/Models/Webhooks/VideoTransformationAcceptedEventTest.cs @@ -23,7 +23,7 @@ public void FieldRoundtrip_Works() Transformation = new() { Type = - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = AudioCodec.Aac, @@ -47,13 +47,13 @@ public void FieldRoundtrip_Works() string expectedID = "id"; string expectedType = "type"; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - VideoTransformationAcceptedEventIntersectionMember1Data expectedData = new() + VideoTransformationAcceptedEventVideoTransformationAcceptedEventData expectedData = new() { Asset = new("https://example.com"), Transformation = new() { Type = - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = AudioCodec.Aac, @@ -66,12 +66,13 @@ public void FieldRoundtrip_Works() }, }, }; - VideoTransformationAcceptedEventIntersectionMember1Request expectedRequest = new() - { - Url = "https://example.com", - XRequestID = "x_request_id", - UserAgent = "user_agent", - }; + VideoTransformationAcceptedEventVideoTransformationAcceptedEventRequest expectedRequest = + new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedType, model.Type); @@ -94,7 +95,7 @@ public void SerializationRoundtrip_Works() Transformation = new() { Type = - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = AudioCodec.Aac, @@ -138,7 +139,7 @@ public void FieldRoundtripThroughSerialization_Works() Transformation = new() { Type = - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = AudioCodec.Aac, @@ -169,13 +170,13 @@ public void FieldRoundtripThroughSerialization_Works() string expectedID = "id"; string expectedType = "type"; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - VideoTransformationAcceptedEventIntersectionMember1Data expectedData = new() + VideoTransformationAcceptedEventVideoTransformationAcceptedEventData expectedData = new() { Asset = new("https://example.com"), Transformation = new() { Type = - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = AudioCodec.Aac, @@ -188,12 +189,13 @@ public void FieldRoundtripThroughSerialization_Works() }, }, }; - VideoTransformationAcceptedEventIntersectionMember1Request expectedRequest = new() - { - Url = "https://example.com", - XRequestID = "x_request_id", - UserAgent = "user_agent", - }; + VideoTransformationAcceptedEventVideoTransformationAcceptedEventRequest expectedRequest = + new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedType, deserialized.Type); @@ -216,7 +218,7 @@ public void Validation_Works() Transformation = new() { Type = - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = AudioCodec.Aac, @@ -254,7 +256,7 @@ public void CopyConstructor_Works() Transformation = new() { Type = - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = AudioCodec.Aac, @@ -281,12 +283,12 @@ public void CopyConstructor_Works() } } -public class VideoTransformationAcceptedEventIntersectionMember1Test : TestBase +public class VideoTransformationAcceptedEventVideoTransformationAcceptedEventTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new VideoTransformationAcceptedEventIntersectionMember1 + var model = new VideoTransformationAcceptedEventVideoTransformationAcceptedEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -295,7 +297,7 @@ public void FieldRoundtrip_Works() Transformation = new() { Type = - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = AudioCodec.Aac, @@ -317,13 +319,13 @@ public void FieldRoundtrip_Works() }; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - VideoTransformationAcceptedEventIntersectionMember1Data expectedData = new() + VideoTransformationAcceptedEventVideoTransformationAcceptedEventData expectedData = new() { Asset = new("https://example.com"), Transformation = new() { Type = - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = AudioCodec.Aac, @@ -336,12 +338,13 @@ public void FieldRoundtrip_Works() }, }, }; - VideoTransformationAcceptedEventIntersectionMember1Request expectedRequest = new() - { - Url = "https://example.com", - XRequestID = "x_request_id", - UserAgent = "user_agent", - }; + VideoTransformationAcceptedEventVideoTransformationAcceptedEventRequest expectedRequest = + new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }; JsonElement expectedType = JsonSerializer.SerializeToElement( "video.transformation.accepted" ); @@ -355,7 +358,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new VideoTransformationAcceptedEventIntersectionMember1 + var model = new VideoTransformationAcceptedEventVideoTransformationAcceptedEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -364,7 +367,7 @@ public void SerializationRoundtrip_Works() Transformation = new() { Type = - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = AudioCodec.Aac, @@ -387,7 +390,7 @@ public void SerializationRoundtrip_Works() string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -398,7 +401,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new VideoTransformationAcceptedEventIntersectionMember1 + var model = new VideoTransformationAcceptedEventVideoTransformationAcceptedEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -407,7 +410,7 @@ public void FieldRoundtripThroughSerialization_Works() Transformation = new() { Type = - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = AudioCodec.Aac, @@ -430,20 +433,20 @@ public void FieldRoundtripThroughSerialization_Works() string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - VideoTransformationAcceptedEventIntersectionMember1Data expectedData = new() + VideoTransformationAcceptedEventVideoTransformationAcceptedEventData expectedData = new() { Asset = new("https://example.com"), Transformation = new() { Type = - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = AudioCodec.Aac, @@ -456,12 +459,13 @@ public void FieldRoundtripThroughSerialization_Works() }, }, }; - VideoTransformationAcceptedEventIntersectionMember1Request expectedRequest = new() - { - Url = "https://example.com", - XRequestID = "x_request_id", - UserAgent = "user_agent", - }; + VideoTransformationAcceptedEventVideoTransformationAcceptedEventRequest expectedRequest = + new() + { + Url = "https://example.com", + XRequestID = "x_request_id", + UserAgent = "user_agent", + }; JsonElement expectedType = JsonSerializer.SerializeToElement( "video.transformation.accepted" ); @@ -475,7 +479,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new VideoTransformationAcceptedEventIntersectionMember1 + var model = new VideoTransformationAcceptedEventVideoTransformationAcceptedEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -484,7 +488,7 @@ public void Validation_Works() Transformation = new() { Type = - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = AudioCodec.Aac, @@ -511,7 +515,7 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new VideoTransformationAcceptedEventIntersectionMember1 + var model = new VideoTransformationAcceptedEventVideoTransformationAcceptedEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -520,7 +524,7 @@ public void CopyConstructor_Works() Transformation = new() { Type = - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = AudioCodec.Aac, @@ -541,24 +545,24 @@ public void CopyConstructor_Works() }, }; - VideoTransformationAcceptedEventIntersectionMember1 copied = new(model); + VideoTransformationAcceptedEventVideoTransformationAcceptedEvent copied = new(model); Assert.Equal(model, copied); } } -public class VideoTransformationAcceptedEventIntersectionMember1DataTest : TestBase +public class VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new VideoTransformationAcceptedEventIntersectionMember1Data + var model = new VideoTransformationAcceptedEventVideoTransformationAcceptedEventData { Asset = new("https://example.com"), Transformation = new() { Type = - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = AudioCodec.Aac, @@ -573,11 +577,11 @@ public void FieldRoundtrip_Works() }; Asset expectedAsset = new("https://example.com"); - VideoTransformationAcceptedEventIntersectionMember1DataTransformation expectedTransformation = + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformation expectedTransformation = new() { Type = - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = AudioCodec.Aac, @@ -597,13 +601,13 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new VideoTransformationAcceptedEventIntersectionMember1Data + var model = new VideoTransformationAcceptedEventVideoTransformationAcceptedEventData { Asset = new("https://example.com"), Transformation = new() { Type = - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = AudioCodec.Aac, @@ -619,7 +623,7 @@ public void SerializationRoundtrip_Works() string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -630,13 +634,13 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new VideoTransformationAcceptedEventIntersectionMember1Data + var model = new VideoTransformationAcceptedEventVideoTransformationAcceptedEventData { Asset = new("https://example.com"), Transformation = new() { Type = - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = AudioCodec.Aac, @@ -652,18 +656,18 @@ public void FieldRoundtripThroughSerialization_Works() string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); Asset expectedAsset = new("https://example.com"); - VideoTransformationAcceptedEventIntersectionMember1DataTransformation expectedTransformation = + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformation expectedTransformation = new() { Type = - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = AudioCodec.Aac, @@ -683,13 +687,13 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new VideoTransformationAcceptedEventIntersectionMember1Data + var model = new VideoTransformationAcceptedEventVideoTransformationAcceptedEventData { Asset = new("https://example.com"), Transformation = new() { Type = - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = AudioCodec.Aac, @@ -709,13 +713,13 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new VideoTransformationAcceptedEventIntersectionMember1Data + var model = new VideoTransformationAcceptedEventVideoTransformationAcceptedEventData { Asset = new("https://example.com"), Transformation = new() { Type = - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = AudioCodec.Aac, @@ -729,7 +733,7 @@ public void CopyConstructor_Works() }, }; - VideoTransformationAcceptedEventIntersectionMember1Data copied = new(model); + VideoTransformationAcceptedEventVideoTransformationAcceptedEventData copied = new(model); Assert.Equal(model, copied); } @@ -791,32 +795,34 @@ public void CopyConstructor_Works() } } -public class VideoTransformationAcceptedEventIntersectionMember1DataTransformationTest : TestBase +public class VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationTest + : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new VideoTransformationAcceptedEventIntersectionMember1DataTransformation - { - Type = - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, - Options = new() + var model = + new VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformation { - AudioCodec = AudioCodec.Aac, - AutoRotate = true, - Format = Format.Mp4, - Quality = 0, - StreamProtocol = StreamProtocol.Hls, - Variants = ["string"], - VideoCodec = VideoCodec.H264, - }, - }; + Type = + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = AudioCodec.Aac, + AutoRotate = true, + Format = Format.Mp4, + Quality = 0, + StreamProtocol = StreamProtocol.Hls, + Variants = ["string"], + VideoCodec = VideoCodec.H264, + }, + }; ApiEnum< string, - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType > expectedType = - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation; + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType.VideoTransformation; Options expectedOptions = new() { AudioCodec = AudioCodec.Aac, @@ -835,25 +841,26 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new VideoTransformationAcceptedEventIntersectionMember1DataTransformation - { - Type = - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, - Options = new() + var model = + new VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformation { - AudioCodec = AudioCodec.Aac, - AutoRotate = true, - Format = Format.Mp4, - Quality = 0, - StreamProtocol = StreamProtocol.Hls, - Variants = ["string"], - VideoCodec = VideoCodec.H264, - }, - }; + Type = + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = AudioCodec.Aac, + AutoRotate = true, + Format = Format.Mp4, + Quality = 0, + StreamProtocol = StreamProtocol.Hls, + Variants = ["string"], + VideoCodec = VideoCodec.H264, + }, + }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -864,25 +871,26 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new VideoTransformationAcceptedEventIntersectionMember1DataTransformation - { - Type = - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, - Options = new() + var model = + new VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformation { - AudioCodec = AudioCodec.Aac, - AutoRotate = true, - Format = Format.Mp4, - Quality = 0, - StreamProtocol = StreamProtocol.Hls, - Variants = ["string"], - VideoCodec = VideoCodec.H264, - }, - }; + Type = + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = AudioCodec.Aac, + AutoRotate = true, + Format = Format.Mp4, + Quality = 0, + StreamProtocol = StreamProtocol.Hls, + Variants = ["string"], + VideoCodec = VideoCodec.H264, + }, + }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -890,9 +898,9 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum< string, - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType > expectedType = - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation; + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType.VideoTransformation; Options expectedOptions = new() { AudioCodec = AudioCodec.Aac, @@ -911,21 +919,22 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new VideoTransformationAcceptedEventIntersectionMember1DataTransformation - { - Type = - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, - Options = new() + var model = + new VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformation { - AudioCodec = AudioCodec.Aac, - AutoRotate = true, - Format = Format.Mp4, - Quality = 0, - StreamProtocol = StreamProtocol.Hls, - Variants = ["string"], - VideoCodec = VideoCodec.H264, - }, - }; + Type = + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = AudioCodec.Aac, + AutoRotate = true, + Format = Format.Mp4, + Quality = 0, + StreamProtocol = StreamProtocol.Hls, + Variants = ["string"], + VideoCodec = VideoCodec.H264, + }, + }; model.Validate(); } @@ -933,11 +942,12 @@ public void Validation_Works() [Fact] public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new VideoTransformationAcceptedEventIntersectionMember1DataTransformation - { - Type = - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, - }; + var model = + new VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformation + { + Type = + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType.VideoTransformation, + }; Assert.Null(model.Options); Assert.False(model.RawData.ContainsKey("options")); @@ -946,11 +956,12 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = new VideoTransformationAcceptedEventIntersectionMember1DataTransformation - { - Type = - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, - }; + var model = + new VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformation + { + Type = + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType.VideoTransformation, + }; model.Validate(); } @@ -958,14 +969,15 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - var model = new VideoTransformationAcceptedEventIntersectionMember1DataTransformation - { - Type = - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + var model = + new VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformation + { + Type = + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType.VideoTransformation, - // Null should be interpreted as omitted for these properties - Options = null, - }; + // Null should be interpreted as omitted for these properties + Options = null, + }; Assert.Null(model.Options); Assert.False(model.RawData.ContainsKey("options")); @@ -974,14 +986,15 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - var model = new VideoTransformationAcceptedEventIntersectionMember1DataTransformation - { - Type = - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + var model = + new VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformation + { + Type = + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType.VideoTransformation, - // Null should be interpreted as omitted for these properties - Options = null, - }; + // Null should be interpreted as omitted for these properties + Options = null, + }; model.Validate(); } @@ -989,49 +1002,51 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new VideoTransformationAcceptedEventIntersectionMember1DataTransformation - { - Type = - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, - Options = new() + var model = + new VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformation { - AudioCodec = AudioCodec.Aac, - AutoRotate = true, - Format = Format.Mp4, - Quality = 0, - StreamProtocol = StreamProtocol.Hls, - Variants = ["string"], - VideoCodec = VideoCodec.H264, - }, - }; + Type = + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType.VideoTransformation, + Options = new() + { + AudioCodec = AudioCodec.Aac, + AutoRotate = true, + Format = Format.Mp4, + Quality = 0, + StreamProtocol = StreamProtocol.Hls, + Variants = ["string"], + VideoCodec = VideoCodec.H264, + }, + }; - VideoTransformationAcceptedEventIntersectionMember1DataTransformation copied = new(model); + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformation copied = + new(model); Assert.Equal(model, copied); } } -public class VideoTransformationAcceptedEventIntersectionMember1DataTransformationTypeTest +public class VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationTypeTest : TestBase { [Theory] [InlineData( - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType.VideoTransformation )] [InlineData( - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.GifToVideo + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType.GifToVideo )] [InlineData( - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoThumbnail + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType.VideoThumbnail )] public void Validation_Works( - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType rawValue + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType > value = rawValue; value.Validate(); } @@ -1042,7 +1057,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -1052,29 +1067,29 @@ public void InvalidEnumValidationThrows_Works() [Theory] [InlineData( - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType.VideoTransformation )] [InlineData( - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.GifToVideo + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType.GifToVideo )] [InlineData( - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoThumbnail + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType.VideoThumbnail )] public void SerializationRoundtrip_Works( - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType rawValue + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType > >(json, ModelBase.SerializerOptions); @@ -1087,14 +1102,14 @@ public void InvalidEnumSerializationRoundtrip_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType > >(json, ModelBase.SerializerOptions); @@ -1558,12 +1573,12 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class VideoTransformationAcceptedEventIntersectionMember1RequestTest : TestBase +public class VideoTransformationAcceptedEventVideoTransformationAcceptedEventRequestTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new VideoTransformationAcceptedEventIntersectionMember1Request + var model = new VideoTransformationAcceptedEventVideoTransformationAcceptedEventRequest { Url = "https://example.com", XRequestID = "x_request_id", @@ -1582,7 +1597,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new VideoTransformationAcceptedEventIntersectionMember1Request + var model = new VideoTransformationAcceptedEventVideoTransformationAcceptedEventRequest { Url = "https://example.com", XRequestID = "x_request_id", @@ -1591,7 +1606,7 @@ public void SerializationRoundtrip_Works() string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -1602,7 +1617,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new VideoTransformationAcceptedEventIntersectionMember1Request + var model = new VideoTransformationAcceptedEventVideoTransformationAcceptedEventRequest { Url = "https://example.com", XRequestID = "x_request_id", @@ -1611,7 +1626,7 @@ public void FieldRoundtripThroughSerialization_Works() string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -1629,7 +1644,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new VideoTransformationAcceptedEventIntersectionMember1Request + var model = new VideoTransformationAcceptedEventVideoTransformationAcceptedEventRequest { Url = "https://example.com", XRequestID = "x_request_id", @@ -1642,7 +1657,7 @@ public void Validation_Works() [Fact] public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new VideoTransformationAcceptedEventIntersectionMember1Request + var model = new VideoTransformationAcceptedEventVideoTransformationAcceptedEventRequest { Url = "https://example.com", XRequestID = "x_request_id", @@ -1655,7 +1670,7 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = new VideoTransformationAcceptedEventIntersectionMember1Request + var model = new VideoTransformationAcceptedEventVideoTransformationAcceptedEventRequest { Url = "https://example.com", XRequestID = "x_request_id", @@ -1667,7 +1682,7 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - var model = new VideoTransformationAcceptedEventIntersectionMember1Request + var model = new VideoTransformationAcceptedEventVideoTransformationAcceptedEventRequest { Url = "https://example.com", XRequestID = "x_request_id", @@ -1683,7 +1698,7 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - var model = new VideoTransformationAcceptedEventIntersectionMember1Request + var model = new VideoTransformationAcceptedEventVideoTransformationAcceptedEventRequest { Url = "https://example.com", XRequestID = "x_request_id", @@ -1698,14 +1713,14 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new VideoTransformationAcceptedEventIntersectionMember1Request + var model = new VideoTransformationAcceptedEventVideoTransformationAcceptedEventRequest { Url = "https://example.com", XRequestID = "x_request_id", UserAgent = "user_agent", }; - VideoTransformationAcceptedEventIntersectionMember1Request copied = new(model); + VideoTransformationAcceptedEventVideoTransformationAcceptedEventRequest copied = new(model); Assert.Equal(model, copied); } diff --git a/src/Imagekit.Tests/Models/Webhooks/VideoTransformationErrorEventTest.cs b/src/Imagekit.Tests/Models/Webhooks/VideoTransformationErrorEventTest.cs index 418a5efe..2785a40f 100644 --- a/src/Imagekit.Tests/Models/Webhooks/VideoTransformationErrorEventTest.cs +++ b/src/Imagekit.Tests/Models/Webhooks/VideoTransformationErrorEventTest.cs @@ -23,21 +23,21 @@ public void FieldRoundtrip_Works() Transformation = new() { Type = - VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType.VideoTransformation, Error = new(Reason.EncodingFailed), Options = new() { AudioCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.H264, }, }, }, @@ -52,31 +52,31 @@ public void FieldRoundtrip_Works() string expectedID = "id"; string expectedType = "type"; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - VideoTransformationErrorEventIntersectionMember1Data expectedData = new() + VideoTransformationErrorEventVideoTransformationErrorEventData expectedData = new() { Asset = new("https://example.com"), Transformation = new() { Type = - VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType.VideoTransformation, Error = new(Reason.EncodingFailed), Options = new() { AudioCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.H264, }, }, }; - VideoTransformationErrorEventIntersectionMember1Request expectedRequest = new() + VideoTransformationErrorEventVideoTransformationErrorEventRequest expectedRequest = new() { Url = "https://example.com", XRequestID = "x_request_id", @@ -104,21 +104,21 @@ public void SerializationRoundtrip_Works() Transformation = new() { Type = - VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType.VideoTransformation, Error = new(Reason.EncodingFailed), Options = new() { AudioCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.H264, }, }, }, @@ -153,21 +153,21 @@ public void FieldRoundtripThroughSerialization_Works() Transformation = new() { Type = - VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType.VideoTransformation, Error = new(Reason.EncodingFailed), Options = new() { AudioCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.H264, }, }, }, @@ -189,31 +189,31 @@ public void FieldRoundtripThroughSerialization_Works() string expectedID = "id"; string expectedType = "type"; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - VideoTransformationErrorEventIntersectionMember1Data expectedData = new() + VideoTransformationErrorEventVideoTransformationErrorEventData expectedData = new() { Asset = new("https://example.com"), Transformation = new() { Type = - VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType.VideoTransformation, Error = new(Reason.EncodingFailed), Options = new() { AudioCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.H264, }, }, }; - VideoTransformationErrorEventIntersectionMember1Request expectedRequest = new() + VideoTransformationErrorEventVideoTransformationErrorEventRequest expectedRequest = new() { Url = "https://example.com", XRequestID = "x_request_id", @@ -241,21 +241,21 @@ public void Validation_Works() Transformation = new() { Type = - VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType.VideoTransformation, Error = new(Reason.EncodingFailed), Options = new() { AudioCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.H264, }, }, }, @@ -284,21 +284,21 @@ public void CopyConstructor_Works() Transformation = new() { Type = - VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType.VideoTransformation, Error = new(Reason.EncodingFailed), Options = new() { AudioCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.H264, }, }, }, @@ -316,12 +316,12 @@ public void CopyConstructor_Works() } } -public class VideoTransformationErrorEventIntersectionMember1Test : TestBase +public class VideoTransformationErrorEventVideoTransformationErrorEventTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new VideoTransformationErrorEventIntersectionMember1 + var model = new VideoTransformationErrorEventVideoTransformationErrorEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -330,21 +330,21 @@ public void FieldRoundtrip_Works() Transformation = new() { Type = - VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType.VideoTransformation, Error = new(Reason.EncodingFailed), Options = new() { AudioCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.H264, }, }, }, @@ -357,31 +357,31 @@ public void FieldRoundtrip_Works() }; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - VideoTransformationErrorEventIntersectionMember1Data expectedData = new() + VideoTransformationErrorEventVideoTransformationErrorEventData expectedData = new() { Asset = new("https://example.com"), Transformation = new() { Type = - VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType.VideoTransformation, Error = new(Reason.EncodingFailed), Options = new() { AudioCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.H264, }, }, }; - VideoTransformationErrorEventIntersectionMember1Request expectedRequest = new() + VideoTransformationErrorEventVideoTransformationErrorEventRequest expectedRequest = new() { Url = "https://example.com", XRequestID = "x_request_id", @@ -398,7 +398,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new VideoTransformationErrorEventIntersectionMember1 + var model = new VideoTransformationErrorEventVideoTransformationErrorEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -407,21 +407,21 @@ public void SerializationRoundtrip_Works() Transformation = new() { Type = - VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType.VideoTransformation, Error = new(Reason.EncodingFailed), Options = new() { AudioCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.H264, }, }, }, @@ -435,7 +435,7 @@ public void SerializationRoundtrip_Works() string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -446,7 +446,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new VideoTransformationErrorEventIntersectionMember1 + var model = new VideoTransformationErrorEventVideoTransformationErrorEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -455,21 +455,21 @@ public void FieldRoundtripThroughSerialization_Works() Transformation = new() { Type = - VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType.VideoTransformation, Error = new(Reason.EncodingFailed), Options = new() { AudioCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.H264, }, }, }, @@ -483,38 +483,38 @@ public void FieldRoundtripThroughSerialization_Works() string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - VideoTransformationErrorEventIntersectionMember1Data expectedData = new() + VideoTransformationErrorEventVideoTransformationErrorEventData expectedData = new() { Asset = new("https://example.com"), Transformation = new() { Type = - VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType.VideoTransformation, Error = new(Reason.EncodingFailed), Options = new() { AudioCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.H264, }, }, }; - VideoTransformationErrorEventIntersectionMember1Request expectedRequest = new() + VideoTransformationErrorEventVideoTransformationErrorEventRequest expectedRequest = new() { Url = "https://example.com", XRequestID = "x_request_id", @@ -531,7 +531,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new VideoTransformationErrorEventIntersectionMember1 + var model = new VideoTransformationErrorEventVideoTransformationErrorEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -540,21 +540,21 @@ public void Validation_Works() Transformation = new() { Type = - VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType.VideoTransformation, Error = new(Reason.EncodingFailed), Options = new() { AudioCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.H264, }, }, }, @@ -572,7 +572,7 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new VideoTransformationErrorEventIntersectionMember1 + var model = new VideoTransformationErrorEventVideoTransformationErrorEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -581,21 +581,21 @@ public void CopyConstructor_Works() Transformation = new() { Type = - VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType.VideoTransformation, Error = new(Reason.EncodingFailed), Options = new() { AudioCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.H264, }, }, }, @@ -607,64 +607,64 @@ public void CopyConstructor_Works() }, }; - VideoTransformationErrorEventIntersectionMember1 copied = new(model); + VideoTransformationErrorEventVideoTransformationErrorEvent copied = new(model); Assert.Equal(model, copied); } } -public class VideoTransformationErrorEventIntersectionMember1DataTest : TestBase +public class VideoTransformationErrorEventVideoTransformationErrorEventDataTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new VideoTransformationErrorEventIntersectionMember1Data + var model = new VideoTransformationErrorEventVideoTransformationErrorEventData { Asset = new("https://example.com"), Transformation = new() { Type = - VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType.VideoTransformation, Error = new(Reason.EncodingFailed), Options = new() { AudioCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.H264, }, }, }; - VideoTransformationErrorEventIntersectionMember1DataAsset expectedAsset = new( + VideoTransformationErrorEventVideoTransformationErrorEventDataAsset expectedAsset = new( "https://example.com" ); - VideoTransformationErrorEventIntersectionMember1DataTransformation expectedTransformation = + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformation expectedTransformation = new() { Type = - VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType.VideoTransformation, Error = new(Reason.EncodingFailed), Options = new() { AudioCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.H264, }, }; @@ -675,34 +675,34 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new VideoTransformationErrorEventIntersectionMember1Data + var model = new VideoTransformationErrorEventVideoTransformationErrorEventData { Asset = new("https://example.com"), Transformation = new() { Type = - VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType.VideoTransformation, Error = new(Reason.EncodingFailed), Options = new() { AudioCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.H264, }, }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -713,61 +713,61 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new VideoTransformationErrorEventIntersectionMember1Data + var model = new VideoTransformationErrorEventVideoTransformationErrorEventData { Asset = new("https://example.com"), Transformation = new() { Type = - VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType.VideoTransformation, Error = new(Reason.EncodingFailed), Options = new() { AudioCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.H264, }, }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - VideoTransformationErrorEventIntersectionMember1DataAsset expectedAsset = new( + VideoTransformationErrorEventVideoTransformationErrorEventDataAsset expectedAsset = new( "https://example.com" ); - VideoTransformationErrorEventIntersectionMember1DataTransformation expectedTransformation = + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformation expectedTransformation = new() { Type = - VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType.VideoTransformation, Error = new(Reason.EncodingFailed), Options = new() { AudioCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.H264, }, }; @@ -778,27 +778,27 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new VideoTransformationErrorEventIntersectionMember1Data + var model = new VideoTransformationErrorEventVideoTransformationErrorEventData { Asset = new("https://example.com"), Transformation = new() { Type = - VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType.VideoTransformation, Error = new(Reason.EncodingFailed), Options = new() { AudioCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.H264, }, }, }; @@ -809,43 +809,43 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new VideoTransformationErrorEventIntersectionMember1Data + var model = new VideoTransformationErrorEventVideoTransformationErrorEventData { Asset = new("https://example.com"), Transformation = new() { Type = - VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType.VideoTransformation, Error = new(Reason.EncodingFailed), Options = new() { AudioCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.H264, }, }, }; - VideoTransformationErrorEventIntersectionMember1Data copied = new(model); + VideoTransformationErrorEventVideoTransformationErrorEventData copied = new(model); Assert.Equal(model, copied); } } -public class VideoTransformationErrorEventIntersectionMember1DataAssetTest : TestBase +public class VideoTransformationErrorEventVideoTransformationErrorEventDataAssetTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new VideoTransformationErrorEventIntersectionMember1DataAsset + var model = new VideoTransformationErrorEventVideoTransformationErrorEventDataAsset { Url = "https://example.com", }; @@ -858,14 +858,14 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new VideoTransformationErrorEventIntersectionMember1DataAsset + var model = new VideoTransformationErrorEventVideoTransformationErrorEventDataAsset { Url = "https://example.com", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -876,14 +876,14 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new VideoTransformationErrorEventIntersectionMember1DataAsset + var model = new VideoTransformationErrorEventVideoTransformationErrorEventDataAsset { Url = "https://example.com", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -897,7 +897,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new VideoTransformationErrorEventIntersectionMember1DataAsset + var model = new VideoTransformationErrorEventVideoTransformationErrorEventDataAsset { Url = "https://example.com", }; @@ -908,65 +908,65 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new VideoTransformationErrorEventIntersectionMember1DataAsset + var model = new VideoTransformationErrorEventVideoTransformationErrorEventDataAsset { Url = "https://example.com", }; - VideoTransformationErrorEventIntersectionMember1DataAsset copied = new(model); + VideoTransformationErrorEventVideoTransformationErrorEventDataAsset copied = new(model); Assert.Equal(model, copied); } } -public class VideoTransformationErrorEventIntersectionMember1DataTransformationTest : TestBase +public class VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationTest + : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new VideoTransformationErrorEventIntersectionMember1DataTransformation + var model = new VideoTransformationErrorEventVideoTransformationErrorEventDataTransformation { Type = - VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType.VideoTransformation, Error = new(Reason.EncodingFailed), Options = new() { AudioCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.H264, }, }; ApiEnum< string, - VideoTransformationErrorEventIntersectionMember1DataTransformationType + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType > expectedType = - VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation; - VideoTransformationErrorEventIntersectionMember1DataTransformationError expectedError = new( - Reason.EncodingFailed - ); - VideoTransformationErrorEventIntersectionMember1DataTransformationOptions expectedOptions = + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType.VideoTransformation; + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationError expectedError = + new(Reason.EncodingFailed); + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptions expectedOptions = new() { AudioCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.H264, }; Assert.Equal(expectedType, model.Type); @@ -977,30 +977,30 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new VideoTransformationErrorEventIntersectionMember1DataTransformation + var model = new VideoTransformationErrorEventVideoTransformationErrorEventDataTransformation { Type = - VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType.VideoTransformation, Error = new(Reason.EncodingFailed), Options = new() { AudioCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.H264, }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -1011,30 +1011,30 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new VideoTransformationErrorEventIntersectionMember1DataTransformation + var model = new VideoTransformationErrorEventVideoTransformationErrorEventDataTransformation { Type = - VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType.VideoTransformation, Error = new(Reason.EncodingFailed), Options = new() { AudioCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.H264, }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -1042,26 +1042,25 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum< string, - VideoTransformationErrorEventIntersectionMember1DataTransformationType + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType > expectedType = - VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation; - VideoTransformationErrorEventIntersectionMember1DataTransformationError expectedError = new( - Reason.EncodingFailed - ); - VideoTransformationErrorEventIntersectionMember1DataTransformationOptions expectedOptions = + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType.VideoTransformation; + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationError expectedError = + new(Reason.EncodingFailed); + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptions expectedOptions = new() { AudioCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.H264, }; Assert.Equal(expectedType, deserialized.Type); @@ -1072,24 +1071,24 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new VideoTransformationErrorEventIntersectionMember1DataTransformation + var model = new VideoTransformationErrorEventVideoTransformationErrorEventDataTransformation { Type = - VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType.VideoTransformation, Error = new(Reason.EncodingFailed), Options = new() { AudioCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.H264, }, }; @@ -1099,10 +1098,10 @@ public void Validation_Works() [Fact] public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new VideoTransformationErrorEventIntersectionMember1DataTransformation + var model = new VideoTransformationErrorEventVideoTransformationErrorEventDataTransformation { Type = - VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType.VideoTransformation, }; Assert.Null(model.Error); @@ -1114,10 +1113,10 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = new VideoTransformationErrorEventIntersectionMember1DataTransformation + var model = new VideoTransformationErrorEventVideoTransformationErrorEventDataTransformation { Type = - VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType.VideoTransformation, }; model.Validate(); @@ -1126,10 +1125,10 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - var model = new VideoTransformationErrorEventIntersectionMember1DataTransformation + var model = new VideoTransformationErrorEventVideoTransformationErrorEventDataTransformation { Type = - VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType.VideoTransformation, // Null should be interpreted as omitted for these properties Error = null, @@ -1145,10 +1144,10 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - var model = new VideoTransformationErrorEventIntersectionMember1DataTransformation + var model = new VideoTransformationErrorEventVideoTransformationErrorEventDataTransformation { Type = - VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType.VideoTransformation, // Null should be interpreted as omitted for these properties Error = null, @@ -1161,51 +1160,56 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new VideoTransformationErrorEventIntersectionMember1DataTransformation + var model = new VideoTransformationErrorEventVideoTransformationErrorEventDataTransformation { Type = - VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType.VideoTransformation, Error = new(Reason.EncodingFailed), Options = new() { AudioCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.H264, }, }; - VideoTransformationErrorEventIntersectionMember1DataTransformation copied = new(model); + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformation copied = new( + model + ); Assert.Equal(model, copied); } } -public class VideoTransformationErrorEventIntersectionMember1DataTransformationTypeTest : TestBase +public class VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationTypeTest + : TestBase { [Theory] [InlineData( - VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType.VideoTransformation + )] + [InlineData( + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType.GifToVideo )] - [InlineData(VideoTransformationErrorEventIntersectionMember1DataTransformationType.GifToVideo)] [InlineData( - VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoThumbnail + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType.VideoThumbnail )] public void Validation_Works( - VideoTransformationErrorEventIntersectionMember1DataTransformationType rawValue + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - VideoTransformationErrorEventIntersectionMember1DataTransformationType + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType > value = rawValue; value.Validate(); } @@ -1214,7 +1218,10 @@ VideoTransformationErrorEventIntersectionMember1DataTransformationType rawValue public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum< + string, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType + > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -1223,25 +1230,30 @@ public void InvalidEnumValidationThrows_Works() [Theory] [InlineData( - VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType.VideoTransformation )] - [InlineData(VideoTransformationErrorEventIntersectionMember1DataTransformationType.GifToVideo)] [InlineData( - VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoThumbnail + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType.GifToVideo + )] + [InlineData( + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType.VideoThumbnail )] public void SerializationRoundtrip_Works( - VideoTransformationErrorEventIntersectionMember1DataTransformationType rawValue + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - VideoTransformationErrorEventIntersectionMember1DataTransformationType + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum< + string, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType + > >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -1251,26 +1263,34 @@ VideoTransformationErrorEventIntersectionMember1DataTransformationType rawValue public void InvalidEnumSerializationRoundtrip_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum< + string, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType + > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum< + string, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType + > >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class VideoTransformationErrorEventIntersectionMember1DataTransformationErrorTest : TestBase +public class VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationErrorTest + : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new VideoTransformationErrorEventIntersectionMember1DataTransformationError - { - Reason = Reason.EncodingFailed, - }; + var model = + new VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationError + { + Reason = Reason.EncodingFailed, + }; ApiEnum expectedReason = Reason.EncodingFailed; @@ -1280,14 +1300,15 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new VideoTransformationErrorEventIntersectionMember1DataTransformationError - { - Reason = Reason.EncodingFailed, - }; + var model = + new VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationError + { + Reason = Reason.EncodingFailed, + }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -1298,14 +1319,15 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new VideoTransformationErrorEventIntersectionMember1DataTransformationError - { - Reason = Reason.EncodingFailed, - }; + var model = + new VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationError + { + Reason = Reason.EncodingFailed, + }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -1319,10 +1341,11 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new VideoTransformationErrorEventIntersectionMember1DataTransformationError - { - Reason = Reason.EncodingFailed, - }; + var model = + new VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationError + { + Reason = Reason.EncodingFailed, + }; model.Validate(); } @@ -1330,12 +1353,14 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new VideoTransformationErrorEventIntersectionMember1DataTransformationError - { - Reason = Reason.EncodingFailed, - }; + var model = + new VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationError + { + Reason = Reason.EncodingFailed, + }; - VideoTransformationErrorEventIntersectionMember1DataTransformationError copied = new(model); + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationError copied = + new(model); Assert.Equal(model, copied); } @@ -1401,50 +1426,51 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsTest +public class VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new VideoTransformationErrorEventIntersectionMember1DataTransformationOptions - { - AudioCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, - AutoRotate = true, - Format = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, - Quality = 0, - StreamProtocol = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, - Variants = ["string"], - VideoCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, - }; + var model = + new VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptions + { + AudioCodec = + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.H264, + }; ApiEnum< string, - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec > expectedAudioCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac; + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec.Aac; bool expectedAutoRotate = true; ApiEnum< string, - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat > expectedFormat = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4; + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Mp4; long expectedQuality = 0; ApiEnum< string, - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol > expectedStreamProtocol = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls; + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol.Hls; List expectedVariants = ["string"]; ApiEnum< string, - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec > expectedVideoCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264; + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.H264; Assert.Equal(expectedAudioCodec, model.AudioCodec); Assert.Equal(expectedAutoRotate, model.AutoRotate); @@ -1463,24 +1489,25 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new VideoTransformationErrorEventIntersectionMember1DataTransformationOptions - { - AudioCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, - AutoRotate = true, - Format = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, - Quality = 0, - StreamProtocol = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, - Variants = ["string"], - VideoCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, - }; + var model = + new VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptions + { + AudioCodec = + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.H264, + }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -1491,24 +1518,25 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new VideoTransformationErrorEventIntersectionMember1DataTransformationOptions - { - AudioCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, - AutoRotate = true, - Format = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, - Quality = 0, - StreamProtocol = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, - Variants = ["string"], - VideoCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, - }; + var model = + new VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptions + { + AudioCodec = + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.H264, + }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -1516,27 +1544,27 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum< string, - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec > expectedAudioCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac; + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec.Aac; bool expectedAutoRotate = true; ApiEnum< string, - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat > expectedFormat = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4; + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Mp4; long expectedQuality = 0; ApiEnum< string, - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol > expectedStreamProtocol = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls; + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol.Hls; List expectedVariants = ["string"]; ApiEnum< string, - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec > expectedVideoCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264; + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.H264; Assert.Equal(expectedAudioCodec, deserialized.AudioCodec); Assert.Equal(expectedAutoRotate, deserialized.AutoRotate); @@ -1555,20 +1583,21 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new VideoTransformationErrorEventIntersectionMember1DataTransformationOptions - { - AudioCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, - AutoRotate = true, - Format = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, - Quality = 0, - StreamProtocol = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, - Variants = ["string"], - VideoCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, - }; + var model = + new VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptions + { + AudioCodec = + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.H264, + }; model.Validate(); } @@ -1576,8 +1605,9 @@ public void Validation_Works() [Fact] public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new VideoTransformationErrorEventIntersectionMember1DataTransformationOptions - { }; + var model = + new VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptions + { }; Assert.Null(model.AudioCodec); Assert.False(model.RawData.ContainsKey("audio_codec")); @@ -1598,8 +1628,9 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = new VideoTransformationErrorEventIntersectionMember1DataTransformationOptions - { }; + var model = + new VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptions + { }; model.Validate(); } @@ -1607,17 +1638,18 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - var model = new VideoTransformationErrorEventIntersectionMember1DataTransformationOptions - { - // Null should be interpreted as omitted for these properties - AudioCodec = null, - AutoRotate = null, - Format = null, - Quality = null, - StreamProtocol = null, - Variants = null, - VideoCodec = null, - }; + var model = + new VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptions + { + // Null should be interpreted as omitted for these properties + AudioCodec = null, + AutoRotate = null, + Format = null, + Quality = null, + StreamProtocol = null, + Variants = null, + VideoCodec = null, + }; Assert.Null(model.AudioCodec); Assert.False(model.RawData.ContainsKey("audio_codec")); @@ -1638,17 +1670,18 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - var model = new VideoTransformationErrorEventIntersectionMember1DataTransformationOptions - { - // Null should be interpreted as omitted for these properties - AudioCodec = null, - AutoRotate = null, - Format = null, - Quality = null, - StreamProtocol = null, - Variants = null, - VideoCodec = null, - }; + var model = + new VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptions + { + // Null should be interpreted as omitted for these properties + AudioCodec = null, + AutoRotate = null, + Format = null, + Quality = null, + StreamProtocol = null, + Variants = null, + VideoCodec = null, + }; model.Validate(); } @@ -1656,47 +1689,47 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new VideoTransformationErrorEventIntersectionMember1DataTransformationOptions - { - AudioCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, - AutoRotate = true, - Format = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, - Quality = 0, - StreamProtocol = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, - Variants = ["string"], - VideoCodec = - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, - }; + var model = + new VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptions + { + AudioCodec = + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.H264, + }; - VideoTransformationErrorEventIntersectionMember1DataTransformationOptions copied = new( - model - ); + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptions copied = + new(model); Assert.Equal(model, copied); } } -public class VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodecTest +public class VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodecTest : TestBase { [Theory] [InlineData( - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec.Aac )] [InlineData( - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Opus + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec.Opus )] public void Validation_Works( - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec rawValue + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec > value = rawValue; value.Validate(); } @@ -1707,7 +1740,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -1717,26 +1750,26 @@ public void InvalidEnumValidationThrows_Works() [Theory] [InlineData( - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec.Aac )] [InlineData( - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Opus + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec.Opus )] public void SerializationRoundtrip_Works( - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec rawValue + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec > >(json, ModelBase.SerializerOptions); @@ -1749,14 +1782,14 @@ public void InvalidEnumSerializationRoundtrip_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec > >(json, ModelBase.SerializerOptions); @@ -1764,33 +1797,33 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormatTest +public class VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormatTest : TestBase { [Theory] [InlineData( - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4 + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Mp4 )] [InlineData( - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Webm + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Webm )] [InlineData( - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Jpg + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Jpg )] [InlineData( - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Png + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Png )] [InlineData( - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Webp + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Webp )] public void Validation_Works( - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat rawValue + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat > value = rawValue; value.Validate(); } @@ -1801,7 +1834,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -1811,35 +1844,35 @@ public void InvalidEnumValidationThrows_Works() [Theory] [InlineData( - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4 + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Mp4 )] [InlineData( - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Webm + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Webm )] [InlineData( - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Jpg + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Jpg )] [InlineData( - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Png + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Png )] [InlineData( - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Webp + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Webp )] public void SerializationRoundtrip_Works( - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat rawValue + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat > >(json, ModelBase.SerializerOptions); @@ -1852,14 +1885,14 @@ public void InvalidEnumSerializationRoundtrip_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat > >(json, ModelBase.SerializerOptions); @@ -1867,24 +1900,24 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocolTest +public class VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocolTest : TestBase { [Theory] [InlineData( - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol.Hls )] [InlineData( - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Dash + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol.Dash )] public void Validation_Works( - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol rawValue + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol > value = rawValue; value.Validate(); } @@ -1895,7 +1928,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -1905,26 +1938,26 @@ public void InvalidEnumValidationThrows_Works() [Theory] [InlineData( - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol.Hls )] [InlineData( - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Dash + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol.Dash )] public void SerializationRoundtrip_Works( - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol rawValue + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol > >(json, ModelBase.SerializerOptions); @@ -1937,14 +1970,14 @@ public void InvalidEnumSerializationRoundtrip_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol > >(json, ModelBase.SerializerOptions); @@ -1952,27 +1985,27 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodecTest +public class VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodecTest : TestBase { [Theory] [InlineData( - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264 + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.H264 )] [InlineData( - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.Vp9 + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.Vp9 )] [InlineData( - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.Av1 + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.Av1 )] public void Validation_Works( - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec rawValue + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec > value = rawValue; value.Validate(); } @@ -1983,7 +2016,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -1993,29 +2026,29 @@ public void InvalidEnumValidationThrows_Works() [Theory] [InlineData( - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264 + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.H264 )] [InlineData( - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.Vp9 + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.Vp9 )] [InlineData( - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.Av1 + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.Av1 )] public void SerializationRoundtrip_Works( - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec rawValue + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec > >(json, ModelBase.SerializerOptions); @@ -2028,14 +2061,14 @@ public void InvalidEnumSerializationRoundtrip_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec > >(json, ModelBase.SerializerOptions); @@ -2043,12 +2076,12 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class VideoTransformationErrorEventIntersectionMember1RequestTest : TestBase +public class VideoTransformationErrorEventVideoTransformationErrorEventRequestTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new VideoTransformationErrorEventIntersectionMember1Request + var model = new VideoTransformationErrorEventVideoTransformationErrorEventRequest { Url = "https://example.com", XRequestID = "x_request_id", @@ -2067,7 +2100,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new VideoTransformationErrorEventIntersectionMember1Request + var model = new VideoTransformationErrorEventVideoTransformationErrorEventRequest { Url = "https://example.com", XRequestID = "x_request_id", @@ -2076,7 +2109,7 @@ public void SerializationRoundtrip_Works() string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -2087,7 +2120,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new VideoTransformationErrorEventIntersectionMember1Request + var model = new VideoTransformationErrorEventVideoTransformationErrorEventRequest { Url = "https://example.com", XRequestID = "x_request_id", @@ -2096,7 +2129,7 @@ public void FieldRoundtripThroughSerialization_Works() string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -2114,7 +2147,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new VideoTransformationErrorEventIntersectionMember1Request + var model = new VideoTransformationErrorEventVideoTransformationErrorEventRequest { Url = "https://example.com", XRequestID = "x_request_id", @@ -2127,7 +2160,7 @@ public void Validation_Works() [Fact] public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new VideoTransformationErrorEventIntersectionMember1Request + var model = new VideoTransformationErrorEventVideoTransformationErrorEventRequest { Url = "https://example.com", XRequestID = "x_request_id", @@ -2140,7 +2173,7 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = new VideoTransformationErrorEventIntersectionMember1Request + var model = new VideoTransformationErrorEventVideoTransformationErrorEventRequest { Url = "https://example.com", XRequestID = "x_request_id", @@ -2152,7 +2185,7 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - var model = new VideoTransformationErrorEventIntersectionMember1Request + var model = new VideoTransformationErrorEventVideoTransformationErrorEventRequest { Url = "https://example.com", XRequestID = "x_request_id", @@ -2168,7 +2201,7 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - var model = new VideoTransformationErrorEventIntersectionMember1Request + var model = new VideoTransformationErrorEventVideoTransformationErrorEventRequest { Url = "https://example.com", XRequestID = "x_request_id", @@ -2183,14 +2216,14 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new VideoTransformationErrorEventIntersectionMember1Request + var model = new VideoTransformationErrorEventVideoTransformationErrorEventRequest { Url = "https://example.com", XRequestID = "x_request_id", UserAgent = "user_agent", }; - VideoTransformationErrorEventIntersectionMember1Request copied = new(model); + VideoTransformationErrorEventVideoTransformationErrorEventRequest copied = new(model); Assert.Equal(model, copied); } diff --git a/src/Imagekit.Tests/Models/Webhooks/VideoTransformationReadyEventTest.cs b/src/Imagekit.Tests/Models/Webhooks/VideoTransformationReadyEventTest.cs index ffc6afd3..3fd282ac 100644 --- a/src/Imagekit.Tests/Models/Webhooks/VideoTransformationReadyEventTest.cs +++ b/src/Imagekit.Tests/Models/Webhooks/VideoTransformationReadyEventTest.cs @@ -23,20 +23,20 @@ public void FieldRoundtrip_Works() Transformation = new() { Type = - VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -63,26 +63,26 @@ public void FieldRoundtrip_Works() string expectedID = "id"; string expectedType = "type"; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - VideoTransformationReadyEventIntersectionMember1Data expectedData = new() + VideoTransformationReadyEventVideoTransformationReadyEventData expectedData = new() { Asset = new("https://example.com"), Transformation = new() { Type = - VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -97,7 +97,7 @@ public void FieldRoundtrip_Works() }, }, }; - VideoTransformationReadyEventIntersectionMember1Request expectedRequest = new() + VideoTransformationReadyEventVideoTransformationReadyEventRequest expectedRequest = new() { Url = "https://example.com", XRequestID = "x_request_id", @@ -127,20 +127,20 @@ public void SerializationRoundtrip_Works() Transformation = new() { Type = - VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -187,20 +187,20 @@ public void FieldRoundtripThroughSerialization_Works() Transformation = new() { Type = - VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -234,26 +234,26 @@ public void FieldRoundtripThroughSerialization_Works() string expectedID = "id"; string expectedType = "type"; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - VideoTransformationReadyEventIntersectionMember1Data expectedData = new() + VideoTransformationReadyEventVideoTransformationReadyEventData expectedData = new() { Asset = new("https://example.com"), Transformation = new() { Type = - VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -268,7 +268,7 @@ public void FieldRoundtripThroughSerialization_Works() }, }, }; - VideoTransformationReadyEventIntersectionMember1Request expectedRequest = new() + VideoTransformationReadyEventVideoTransformationReadyEventRequest expectedRequest = new() { Url = "https://example.com", XRequestID = "x_request_id", @@ -298,20 +298,20 @@ public void Validation_Works() Transformation = new() { Type = - VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -352,20 +352,20 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() Transformation = new() { Type = - VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -406,20 +406,20 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() Transformation = new() { Type = - VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -459,20 +459,20 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() Transformation = new() { Type = - VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -516,20 +516,20 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() Transformation = new() { Type = - VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -572,20 +572,20 @@ public void CopyConstructor_Works() Transformation = new() { Type = - VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -615,12 +615,12 @@ public void CopyConstructor_Works() } } -public class VideoTransformationReadyEventIntersectionMember1Test : TestBase +public class VideoTransformationReadyEventVideoTransformationReadyEventTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new VideoTransformationReadyEventIntersectionMember1 + var model = new VideoTransformationReadyEventVideoTransformationReadyEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -629,20 +629,20 @@ public void FieldRoundtrip_Works() Transformation = new() { Type = - VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -667,26 +667,26 @@ public void FieldRoundtrip_Works() }; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - VideoTransformationReadyEventIntersectionMember1Data expectedData = new() + VideoTransformationReadyEventVideoTransformationReadyEventData expectedData = new() { Asset = new("https://example.com"), Transformation = new() { Type = - VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -701,7 +701,7 @@ public void FieldRoundtrip_Works() }, }, }; - VideoTransformationReadyEventIntersectionMember1Request expectedRequest = new() + VideoTransformationReadyEventVideoTransformationReadyEventRequest expectedRequest = new() { Url = "https://example.com", XRequestID = "x_request_id", @@ -720,7 +720,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new VideoTransformationReadyEventIntersectionMember1 + var model = new VideoTransformationReadyEventVideoTransformationReadyEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -729,20 +729,20 @@ public void SerializationRoundtrip_Works() Transformation = new() { Type = - VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -768,7 +768,7 @@ public void SerializationRoundtrip_Works() string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -779,7 +779,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new VideoTransformationReadyEventIntersectionMember1 + var model = new VideoTransformationReadyEventVideoTransformationReadyEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -788,20 +788,20 @@ public void FieldRoundtripThroughSerialization_Works() Transformation = new() { Type = - VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -827,33 +827,33 @@ public void FieldRoundtripThroughSerialization_Works() string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - VideoTransformationReadyEventIntersectionMember1Data expectedData = new() + VideoTransformationReadyEventVideoTransformationReadyEventData expectedData = new() { Asset = new("https://example.com"), Transformation = new() { Type = - VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -868,7 +868,7 @@ public void FieldRoundtripThroughSerialization_Works() }, }, }; - VideoTransformationReadyEventIntersectionMember1Request expectedRequest = new() + VideoTransformationReadyEventVideoTransformationReadyEventRequest expectedRequest = new() { Url = "https://example.com", XRequestID = "x_request_id", @@ -887,7 +887,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new VideoTransformationReadyEventIntersectionMember1 + var model = new VideoTransformationReadyEventVideoTransformationReadyEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -896,20 +896,20 @@ public void Validation_Works() Transformation = new() { Type = - VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -939,7 +939,7 @@ public void Validation_Works() [Fact] public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new VideoTransformationReadyEventIntersectionMember1 + var model = new VideoTransformationReadyEventVideoTransformationReadyEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -948,20 +948,20 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() Transformation = new() { Type = - VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -991,7 +991,7 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = new VideoTransformationReadyEventIntersectionMember1 + var model = new VideoTransformationReadyEventVideoTransformationReadyEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -1000,20 +1000,20 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() Transformation = new() { Type = - VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -1042,7 +1042,7 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - var model = new VideoTransformationReadyEventIntersectionMember1 + var model = new VideoTransformationReadyEventVideoTransformationReadyEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -1051,20 +1051,20 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() Transformation = new() { Type = - VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -1097,7 +1097,7 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - var model = new VideoTransformationReadyEventIntersectionMember1 + var model = new VideoTransformationReadyEventVideoTransformationReadyEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -1106,20 +1106,20 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() Transformation = new() { Type = - VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -1151,7 +1151,7 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new VideoTransformationReadyEventIntersectionMember1 + var model = new VideoTransformationReadyEventVideoTransformationReadyEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -1160,20 +1160,20 @@ public void CopyConstructor_Works() Transformation = new() { Type = - VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -1197,37 +1197,37 @@ public void CopyConstructor_Works() Timings = new() { DownloadDuration = 0, EncodingDuration = 0 }, }; - VideoTransformationReadyEventIntersectionMember1 copied = new(model); + VideoTransformationReadyEventVideoTransformationReadyEvent copied = new(model); Assert.Equal(model, copied); } } -public class VideoTransformationReadyEventIntersectionMember1DataTest : TestBase +public class VideoTransformationReadyEventVideoTransformationReadyEventDataTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new VideoTransformationReadyEventIntersectionMember1Data + var model = new VideoTransformationReadyEventVideoTransformationReadyEventData { Asset = new("https://example.com"), Transformation = new() { Type = - VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -1243,27 +1243,27 @@ public void FieldRoundtrip_Works() }, }; - VideoTransformationReadyEventIntersectionMember1DataAsset expectedAsset = new( + VideoTransformationReadyEventVideoTransformationReadyEventDataAsset expectedAsset = new( "https://example.com" ); - VideoTransformationReadyEventIntersectionMember1DataTransformation expectedTransformation = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation expectedTransformation = new() { Type = - VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -1285,26 +1285,26 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new VideoTransformationReadyEventIntersectionMember1Data + var model = new VideoTransformationReadyEventVideoTransformationReadyEventData { Asset = new("https://example.com"), Transformation = new() { Type = - VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -1322,7 +1322,7 @@ public void SerializationRoundtrip_Works() string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -1333,26 +1333,26 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new VideoTransformationReadyEventIntersectionMember1Data + var model = new VideoTransformationReadyEventVideoTransformationReadyEventData { Asset = new("https://example.com"), Transformation = new() { Type = - VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -1370,33 +1370,33 @@ public void FieldRoundtripThroughSerialization_Works() string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - VideoTransformationReadyEventIntersectionMember1DataAsset expectedAsset = new( + VideoTransformationReadyEventVideoTransformationReadyEventDataAsset expectedAsset = new( "https://example.com" ); - VideoTransformationReadyEventIntersectionMember1DataTransformation expectedTransformation = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation expectedTransformation = new() { Type = - VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -1418,26 +1418,26 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new VideoTransformationReadyEventIntersectionMember1Data + var model = new VideoTransformationReadyEventVideoTransformationReadyEventData { Asset = new("https://example.com"), Transformation = new() { Type = - VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -1459,26 +1459,26 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new VideoTransformationReadyEventIntersectionMember1Data + var model = new VideoTransformationReadyEventVideoTransformationReadyEventData { Asset = new("https://example.com"), Transformation = new() { Type = - VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -1494,18 +1494,18 @@ public void CopyConstructor_Works() }, }; - VideoTransformationReadyEventIntersectionMember1Data copied = new(model); + VideoTransformationReadyEventVideoTransformationReadyEventData copied = new(model); Assert.Equal(model, copied); } } -public class VideoTransformationReadyEventIntersectionMember1DataAssetTest : TestBase +public class VideoTransformationReadyEventVideoTransformationReadyEventDataAssetTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new VideoTransformationReadyEventIntersectionMember1DataAsset + var model = new VideoTransformationReadyEventVideoTransformationReadyEventDataAsset { Url = "https://example.com", }; @@ -1518,14 +1518,14 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new VideoTransformationReadyEventIntersectionMember1DataAsset + var model = new VideoTransformationReadyEventVideoTransformationReadyEventDataAsset { Url = "https://example.com", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -1536,14 +1536,14 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new VideoTransformationReadyEventIntersectionMember1DataAsset + var model = new VideoTransformationReadyEventVideoTransformationReadyEventDataAsset { Url = "https://example.com", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -1557,7 +1557,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new VideoTransformationReadyEventIntersectionMember1DataAsset + var model = new VideoTransformationReadyEventVideoTransformationReadyEventDataAsset { Url = "https://example.com", }; @@ -1568,39 +1568,40 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new VideoTransformationReadyEventIntersectionMember1DataAsset + var model = new VideoTransformationReadyEventVideoTransformationReadyEventDataAsset { Url = "https://example.com", }; - VideoTransformationReadyEventIntersectionMember1DataAsset copied = new(model); + VideoTransformationReadyEventVideoTransformationReadyEventDataAsset copied = new(model); Assert.Equal(model, copied); } } -public class VideoTransformationReadyEventIntersectionMember1DataTransformationTest : TestBase +public class VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationTest + : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new VideoTransformationReadyEventIntersectionMember1DataTransformation + var model = new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation { Type = - VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -1617,23 +1618,23 @@ public void FieldRoundtrip_Works() ApiEnum< string, - VideoTransformationReadyEventIntersectionMember1DataTransformationType + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType > expectedType = - VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation; - VideoTransformationReadyEventIntersectionMember1DataTransformationOptions expectedOptions = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation; + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions expectedOptions = new() { AudioCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }; Output expectedOutput = new() { @@ -1655,23 +1656,23 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new VideoTransformationReadyEventIntersectionMember1DataTransformation + var model = new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation { Type = - VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -1688,7 +1689,7 @@ public void SerializationRoundtrip_Works() string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -1699,23 +1700,23 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new VideoTransformationReadyEventIntersectionMember1DataTransformation + var model = new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation { Type = - VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -1732,7 +1733,7 @@ public void FieldRoundtripThroughSerialization_Works() string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -1740,23 +1741,23 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum< string, - VideoTransformationReadyEventIntersectionMember1DataTransformationType + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType > expectedType = - VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation; - VideoTransformationReadyEventIntersectionMember1DataTransformationOptions expectedOptions = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation; + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions expectedOptions = new() { AudioCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }; Output expectedOutput = new() { @@ -1778,23 +1779,23 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new VideoTransformationReadyEventIntersectionMember1DataTransformation + var model = new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation { Type = - VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -1815,10 +1816,10 @@ public void Validation_Works() [Fact] public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new VideoTransformationReadyEventIntersectionMember1DataTransformation + var model = new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation { Type = - VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, }; Assert.Null(model.Options); @@ -1830,10 +1831,10 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = new VideoTransformationReadyEventIntersectionMember1DataTransformation + var model = new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation { Type = - VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, }; model.Validate(); @@ -1842,10 +1843,10 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - var model = new VideoTransformationReadyEventIntersectionMember1DataTransformation + var model = new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation { Type = - VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, // Null should be interpreted as omitted for these properties Options = null, @@ -1861,10 +1862,10 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - var model = new VideoTransformationReadyEventIntersectionMember1DataTransformation + var model = new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation { Type = - VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, // Null should be interpreted as omitted for these properties Options = null, @@ -1877,23 +1878,23 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new VideoTransformationReadyEventIntersectionMember1DataTransformation + var model = new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation { Type = - VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -1908,30 +1909,35 @@ public void CopyConstructor_Works() }, }; - VideoTransformationReadyEventIntersectionMember1DataTransformation copied = new(model); + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation copied = new( + model + ); Assert.Equal(model, copied); } } -public class VideoTransformationReadyEventIntersectionMember1DataTransformationTypeTest : TestBase +public class VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationTypeTest + : TestBase { [Theory] [InlineData( - VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation + )] + [InlineData( + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.GifToVideo )] - [InlineData(VideoTransformationReadyEventIntersectionMember1DataTransformationType.GifToVideo)] [InlineData( - VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoThumbnail + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoThumbnail )] public void Validation_Works( - VideoTransformationReadyEventIntersectionMember1DataTransformationType rawValue + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - VideoTransformationReadyEventIntersectionMember1DataTransformationType + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType > value = rawValue; value.Validate(); } @@ -1940,7 +1946,10 @@ VideoTransformationReadyEventIntersectionMember1DataTransformationType rawValue public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum< + string, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType + > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -1949,25 +1958,30 @@ public void InvalidEnumValidationThrows_Works() [Theory] [InlineData( - VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation + )] + [InlineData( + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.GifToVideo )] - [InlineData(VideoTransformationReadyEventIntersectionMember1DataTransformationType.GifToVideo)] [InlineData( - VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoThumbnail + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoThumbnail )] public void SerializationRoundtrip_Works( - VideoTransformationReadyEventIntersectionMember1DataTransformationType rawValue + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - VideoTransformationReadyEventIntersectionMember1DataTransformationType + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum< + string, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType + > >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -1977,61 +1991,68 @@ VideoTransformationReadyEventIntersectionMember1DataTransformationType rawValue public void InvalidEnumSerializationRoundtrip_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum< + string, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType + > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum< + string, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType + > >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsTest +public class VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new VideoTransformationReadyEventIntersectionMember1DataTransformationOptions - { - AudioCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, - AutoRotate = true, - Format = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, - Quality = 0, - StreamProtocol = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, - Variants = ["string"], - VideoCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, - }; + var model = + new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions + { + AudioCodec = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, + }; ApiEnum< string, - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec > expectedAudioCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac; + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac; bool expectedAutoRotate = true; ApiEnum< string, - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat > expectedFormat = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4; + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4; long expectedQuality = 0; ApiEnum< string, - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol > expectedStreamProtocol = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls; + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls; List expectedVariants = ["string"]; ApiEnum< string, - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec > expectedVideoCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264; + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264; Assert.Equal(expectedAudioCodec, model.AudioCodec); Assert.Equal(expectedAutoRotate, model.AutoRotate); @@ -2050,24 +2071,25 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new VideoTransformationReadyEventIntersectionMember1DataTransformationOptions - { - AudioCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, - AutoRotate = true, - Format = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, - Quality = 0, - StreamProtocol = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, - Variants = ["string"], - VideoCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, - }; + var model = + new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions + { + AudioCodec = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, + }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -2078,24 +2100,25 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new VideoTransformationReadyEventIntersectionMember1DataTransformationOptions - { - AudioCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, - AutoRotate = true, - Format = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, - Quality = 0, - StreamProtocol = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, - Variants = ["string"], - VideoCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, - }; + var model = + new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions + { + AudioCodec = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, + }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -2103,27 +2126,27 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum< string, - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec > expectedAudioCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac; + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac; bool expectedAutoRotate = true; ApiEnum< string, - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat > expectedFormat = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4; + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4; long expectedQuality = 0; ApiEnum< string, - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol > expectedStreamProtocol = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls; + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls; List expectedVariants = ["string"]; ApiEnum< string, - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec > expectedVideoCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264; + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264; Assert.Equal(expectedAudioCodec, deserialized.AudioCodec); Assert.Equal(expectedAutoRotate, deserialized.AutoRotate); @@ -2142,20 +2165,21 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new VideoTransformationReadyEventIntersectionMember1DataTransformationOptions - { - AudioCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, - AutoRotate = true, - Format = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, - Quality = 0, - StreamProtocol = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, - Variants = ["string"], - VideoCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, - }; + var model = + new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions + { + AudioCodec = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, + }; model.Validate(); } @@ -2163,8 +2187,9 @@ public void Validation_Works() [Fact] public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new VideoTransformationReadyEventIntersectionMember1DataTransformationOptions - { }; + var model = + new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions + { }; Assert.Null(model.AudioCodec); Assert.False(model.RawData.ContainsKey("audio_codec")); @@ -2185,8 +2210,9 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = new VideoTransformationReadyEventIntersectionMember1DataTransformationOptions - { }; + var model = + new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions + { }; model.Validate(); } @@ -2194,17 +2220,18 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - var model = new VideoTransformationReadyEventIntersectionMember1DataTransformationOptions - { - // Null should be interpreted as omitted for these properties - AudioCodec = null, - AutoRotate = null, - Format = null, - Quality = null, - StreamProtocol = null, - Variants = null, - VideoCodec = null, - }; + var model = + new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions + { + // Null should be interpreted as omitted for these properties + AudioCodec = null, + AutoRotate = null, + Format = null, + Quality = null, + StreamProtocol = null, + Variants = null, + VideoCodec = null, + }; Assert.Null(model.AudioCodec); Assert.False(model.RawData.ContainsKey("audio_codec")); @@ -2225,17 +2252,18 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - var model = new VideoTransformationReadyEventIntersectionMember1DataTransformationOptions - { - // Null should be interpreted as omitted for these properties - AudioCodec = null, - AutoRotate = null, - Format = null, - Quality = null, - StreamProtocol = null, - Variants = null, - VideoCodec = null, - }; + var model = + new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions + { + // Null should be interpreted as omitted for these properties + AudioCodec = null, + AutoRotate = null, + Format = null, + Quality = null, + StreamProtocol = null, + Variants = null, + VideoCodec = null, + }; model.Validate(); } @@ -2243,47 +2271,47 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new VideoTransformationReadyEventIntersectionMember1DataTransformationOptions - { - AudioCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, - AutoRotate = true, - Format = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, - Quality = 0, - StreamProtocol = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, - Variants = ["string"], - VideoCodec = - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, - }; + var model = + new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions + { + AudioCodec = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, + }; - VideoTransformationReadyEventIntersectionMember1DataTransformationOptions copied = new( - model - ); + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions copied = + new(model); Assert.Equal(model, copied); } } -public class VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodecTest +public class VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodecTest : TestBase { [Theory] [InlineData( - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac )] [InlineData( - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Opus + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Opus )] public void Validation_Works( - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec rawValue + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec > value = rawValue; value.Validate(); } @@ -2294,7 +2322,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -2304,26 +2332,26 @@ public void InvalidEnumValidationThrows_Works() [Theory] [InlineData( - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac )] [InlineData( - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Opus + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Opus )] public void SerializationRoundtrip_Works( - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec rawValue + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec > >(json, ModelBase.SerializerOptions); @@ -2336,14 +2364,14 @@ public void InvalidEnumSerializationRoundtrip_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec > >(json, ModelBase.SerializerOptions); @@ -2351,33 +2379,33 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormatTest +public class VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormatTest : TestBase { [Theory] [InlineData( - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4 + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4 )] [InlineData( - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Webm + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Webm )] [InlineData( - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Jpg + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Jpg )] [InlineData( - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Png + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Png )] [InlineData( - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Webp + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Webp )] public void Validation_Works( - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat rawValue + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat > value = rawValue; value.Validate(); } @@ -2388,7 +2416,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -2398,35 +2426,35 @@ public void InvalidEnumValidationThrows_Works() [Theory] [InlineData( - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4 + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4 )] [InlineData( - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Webm + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Webm )] [InlineData( - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Jpg + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Jpg )] [InlineData( - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Png + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Png )] [InlineData( - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Webp + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Webp )] public void SerializationRoundtrip_Works( - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat rawValue + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat > >(json, ModelBase.SerializerOptions); @@ -2439,14 +2467,14 @@ public void InvalidEnumSerializationRoundtrip_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat > >(json, ModelBase.SerializerOptions); @@ -2454,24 +2482,24 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocolTest +public class VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocolTest : TestBase { [Theory] [InlineData( - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls )] [InlineData( - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Dash + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Dash )] public void Validation_Works( - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol rawValue + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol > value = rawValue; value.Validate(); } @@ -2482,7 +2510,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -2492,26 +2520,26 @@ public void InvalidEnumValidationThrows_Works() [Theory] [InlineData( - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls )] [InlineData( - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Dash + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Dash )] public void SerializationRoundtrip_Works( - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol rawValue + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol > >(json, ModelBase.SerializerOptions); @@ -2524,14 +2552,14 @@ public void InvalidEnumSerializationRoundtrip_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol > >(json, ModelBase.SerializerOptions); @@ -2539,27 +2567,27 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodecTest +public class VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodecTest : TestBase { [Theory] [InlineData( - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264 + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264 )] [InlineData( - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.Vp9 + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.Vp9 )] [InlineData( - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.Av1 + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.Av1 )] public void Validation_Works( - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec rawValue + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec > value = rawValue; value.Validate(); } @@ -2570,7 +2598,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -2580,29 +2608,29 @@ public void InvalidEnumValidationThrows_Works() [Theory] [InlineData( - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264 + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264 )] [InlineData( - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.Vp9 + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.Vp9 )] [InlineData( - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.Av1 + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.Av1 )] public void SerializationRoundtrip_Works( - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec rawValue + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec > >(json, ModelBase.SerializerOptions); @@ -2615,14 +2643,14 @@ public void InvalidEnumSerializationRoundtrip_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec > >(json, ModelBase.SerializerOptions); @@ -2902,12 +2930,12 @@ public void CopyConstructor_Works() } } -public class VideoTransformationReadyEventIntersectionMember1RequestTest : TestBase +public class VideoTransformationReadyEventVideoTransformationReadyEventRequestTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new VideoTransformationReadyEventIntersectionMember1Request + var model = new VideoTransformationReadyEventVideoTransformationReadyEventRequest { Url = "https://example.com", XRequestID = "x_request_id", @@ -2926,7 +2954,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new VideoTransformationReadyEventIntersectionMember1Request + var model = new VideoTransformationReadyEventVideoTransformationReadyEventRequest { Url = "https://example.com", XRequestID = "x_request_id", @@ -2935,7 +2963,7 @@ public void SerializationRoundtrip_Works() string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -2946,7 +2974,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new VideoTransformationReadyEventIntersectionMember1Request + var model = new VideoTransformationReadyEventVideoTransformationReadyEventRequest { Url = "https://example.com", XRequestID = "x_request_id", @@ -2955,7 +2983,7 @@ public void FieldRoundtripThroughSerialization_Works() string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -2973,7 +3001,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new VideoTransformationReadyEventIntersectionMember1Request + var model = new VideoTransformationReadyEventVideoTransformationReadyEventRequest { Url = "https://example.com", XRequestID = "x_request_id", @@ -2986,7 +3014,7 @@ public void Validation_Works() [Fact] public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new VideoTransformationReadyEventIntersectionMember1Request + var model = new VideoTransformationReadyEventVideoTransformationReadyEventRequest { Url = "https://example.com", XRequestID = "x_request_id", @@ -2999,7 +3027,7 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = new VideoTransformationReadyEventIntersectionMember1Request + var model = new VideoTransformationReadyEventVideoTransformationReadyEventRequest { Url = "https://example.com", XRequestID = "x_request_id", @@ -3011,7 +3039,7 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - var model = new VideoTransformationReadyEventIntersectionMember1Request + var model = new VideoTransformationReadyEventVideoTransformationReadyEventRequest { Url = "https://example.com", XRequestID = "x_request_id", @@ -3027,7 +3055,7 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - var model = new VideoTransformationReadyEventIntersectionMember1Request + var model = new VideoTransformationReadyEventVideoTransformationReadyEventRequest { Url = "https://example.com", XRequestID = "x_request_id", @@ -3042,14 +3070,14 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new VideoTransformationReadyEventIntersectionMember1Request + var model = new VideoTransformationReadyEventVideoTransformationReadyEventRequest { Url = "https://example.com", XRequestID = "x_request_id", UserAgent = "user_agent", }; - VideoTransformationReadyEventIntersectionMember1Request copied = new(model); + VideoTransformationReadyEventVideoTransformationReadyEventRequest copied = new(model); Assert.Equal(model, copied); } diff --git a/src/Imagekit/Core/ModelBase.cs b/src/Imagekit/Core/ModelBase.cs index 1fc4ce80..941432ed 100644 --- a/src/Imagekit/Core/ModelBase.cs +++ b/src/Imagekit/Core/ModelBase.cs @@ -35,9 +35,9 @@ protected ModelBase(ModelBase modelBase) new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), - new ApiEnumConverter(), + new ApiEnumConverter(), new ApiEnumConverter(), - new ApiEnumConverter(), + new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), @@ -54,7 +54,7 @@ protected ModelBase(ModelBase modelBase) new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), - new ApiEnumConverter(), + new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), @@ -97,11 +97,11 @@ protected ModelBase(ModelBase modelBase) new ApiEnumConverter(), new ApiEnumConverter< string, - Webhooks::UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType + Webhooks::UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType >(), new ApiEnumConverter< string, - Webhooks::UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol + Webhooks::UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol >(), new ApiEnumConverter(), new ApiEnumConverter(), @@ -111,7 +111,7 @@ protected ModelBase(ModelBase modelBase) new ApiEnumConverter(), new ApiEnumConverter< string, - Webhooks::VideoTransformationAcceptedEventIntersectionMember1DataTransformationType + Webhooks::VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType >(), new ApiEnumConverter(), new ApiEnumConverter(), @@ -119,44 +119,44 @@ protected ModelBase(ModelBase modelBase) new ApiEnumConverter(), new ApiEnumConverter< string, - Webhooks::VideoTransformationErrorEventIntersectionMember1DataTransformationType + Webhooks::VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType >(), new ApiEnumConverter(), new ApiEnumConverter< string, - Webhooks::VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec + Webhooks::VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec >(), new ApiEnumConverter< string, - Webhooks::VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat + Webhooks::VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat >(), new ApiEnumConverter< string, - Webhooks::VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol + Webhooks::VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol >(), new ApiEnumConverter< string, - Webhooks::VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec + Webhooks::VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec >(), new ApiEnumConverter< string, - Webhooks::VideoTransformationReadyEventIntersectionMember1DataTransformationType + Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType >(), new ApiEnumConverter< string, - Webhooks::VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec + Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec >(), new ApiEnumConverter< string, - Webhooks::VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat + Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat >(), new ApiEnumConverter< string, - Webhooks::VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol + Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol >(), new ApiEnumConverter< string, - Webhooks::VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec + Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec >(), }, }; diff --git a/src/Imagekit/Models/GetImageAttributesOptions.cs b/src/Imagekit/Models/GetImageAttributesOptions.cs index 8b2e43d0..3ac6dc3e 100644 --- a/src/Imagekit/Models/GetImageAttributesOptions.cs +++ b/src/Imagekit/Models/GetImageAttributesOptions.cs @@ -366,8 +366,13 @@ IReadOnlyDictionary rawData ) => GetImageAttributesOptions.FromRawUnchecked(rawData); } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class IntersectionMember1 : JsonModel +[JsonConverter( + typeof(JsonModelConverter< + GetImageAttributesOptionsGetImageAttributesOptions, + GetImageAttributesOptionsGetImageAttributesOptionsFromRaw + >) +)] +public sealed record class GetImageAttributesOptionsGetImageAttributesOptions : JsonModel { /// /// Custom list of **device-width breakpoints** in pixels. These define common @@ -489,29 +494,35 @@ public override void Validate() _ = this.Width; } - public IntersectionMember1() { } + public GetImageAttributesOptionsGetImageAttributesOptions() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public IntersectionMember1(IntersectionMember1 intersectionMember1) - : base(intersectionMember1) { } + public GetImageAttributesOptionsGetImageAttributesOptions( + GetImageAttributesOptionsGetImageAttributesOptions getImageAttributesOptionsGetImageAttributesOptions + ) + : base(getImageAttributesOptionsGetImageAttributesOptions) { } #pragma warning restore CS8618 - public IntersectionMember1(IReadOnlyDictionary rawData) + public GetImageAttributesOptionsGetImageAttributesOptions( + IReadOnlyDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - IntersectionMember1(FrozenDictionary rawData) + GetImageAttributesOptionsGetImageAttributesOptions( + FrozenDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static IntersectionMember1 FromRawUnchecked( + /// + public static GetImageAttributesOptionsGetImageAttributesOptions FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -519,9 +530,11 @@ IReadOnlyDictionary rawData } } -class IntersectionMember1FromRaw : IFromRawJson +class GetImageAttributesOptionsGetImageAttributesOptionsFromRaw + : IFromRawJson { /// - public IntersectionMember1 FromRawUnchecked(IReadOnlyDictionary rawData) => - IntersectionMember1.FromRawUnchecked(rawData); + public GetImageAttributesOptionsGetImageAttributesOptions FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GetImageAttributesOptionsGetImageAttributesOptions.FromRawUnchecked(rawData); } diff --git a/src/Imagekit/Models/ImageOverlay.cs b/src/Imagekit/Models/ImageOverlay.cs index 3efe472f..88ea0975 100644 --- a/src/Imagekit/Models/ImageOverlay.cs +++ b/src/Imagekit/Models/ImageOverlay.cs @@ -238,12 +238,9 @@ public ImageOverlay FromRawUnchecked(IReadOnlyDictionary ra } [JsonConverter( - typeof(JsonModelConverter< - ImageOverlayIntersectionMember1, - ImageOverlayIntersectionMember1FromRaw - >) + typeof(JsonModelConverter) )] -public sealed record class ImageOverlayIntersectionMember1 : JsonModel +public sealed record class ImageOverlayImageOverlay : JsonModel { /// /// Specifies the relative path to the image used as an overlay. @@ -339,20 +336,18 @@ public override void Validate() } } - public ImageOverlayIntersectionMember1() + public ImageOverlayImageOverlay() { this.Type = JsonSerializer.SerializeToElement("image"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public ImageOverlayIntersectionMember1( - ImageOverlayIntersectionMember1 imageOverlayIntersectionMember1 - ) - : base(imageOverlayIntersectionMember1) { } + public ImageOverlayImageOverlay(ImageOverlayImageOverlay imageOverlayImageOverlay) + : base(imageOverlayImageOverlay) { } #pragma warning restore CS8618 - public ImageOverlayIntersectionMember1(IReadOnlyDictionary rawData) + public ImageOverlayImageOverlay(IReadOnlyDictionary rawData) { this._rawData = new(rawData); @@ -361,14 +356,14 @@ public ImageOverlayIntersectionMember1(IReadOnlyDictionary #pragma warning disable CS8618 [SetsRequiredMembers] - ImageOverlayIntersectionMember1(FrozenDictionary rawData) + ImageOverlayImageOverlay(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ImageOverlayIntersectionMember1 FromRawUnchecked( + /// + public static ImageOverlayImageOverlay FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -376,19 +371,19 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public ImageOverlayIntersectionMember1(string input) + public ImageOverlayImageOverlay(string input) : this() { this.Input = input; } } -class ImageOverlayIntersectionMember1FromRaw : IFromRawJson +class ImageOverlayImageOverlayFromRaw : IFromRawJson { /// - public ImageOverlayIntersectionMember1 FromRawUnchecked( + public ImageOverlayImageOverlay FromRawUnchecked( IReadOnlyDictionary rawData - ) => ImageOverlayIntersectionMember1.FromRawUnchecked(rawData); + ) => ImageOverlayImageOverlay.FromRawUnchecked(rawData); } /// diff --git a/src/Imagekit/Models/SolidColorOverlay.cs b/src/Imagekit/Models/SolidColorOverlay.cs index 5c57ea8d..ffa89050 100644 --- a/src/Imagekit/Models/SolidColorOverlay.cs +++ b/src/Imagekit/Models/SolidColorOverlay.cs @@ -214,11 +214,11 @@ public SolidColorOverlay FromRawUnchecked(IReadOnlyDictionary) )] -public sealed record class SolidColorOverlayIntersectionMember1 : JsonModel +public sealed record class SolidColorOverlaySolidColorOverlay : JsonModel { /// /// Specifies the color of the block using an RGB hex code (e.g., `FF0000`), an @@ -288,20 +288,20 @@ public override void Validate() } } - public SolidColorOverlayIntersectionMember1() + public SolidColorOverlaySolidColorOverlay() { this.Type = JsonSerializer.SerializeToElement("solidColor"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public SolidColorOverlayIntersectionMember1( - SolidColorOverlayIntersectionMember1 solidColorOverlayIntersectionMember1 + public SolidColorOverlaySolidColorOverlay( + SolidColorOverlaySolidColorOverlay solidColorOverlaySolidColorOverlay ) - : base(solidColorOverlayIntersectionMember1) { } + : base(solidColorOverlaySolidColorOverlay) { } #pragma warning restore CS8618 - public SolidColorOverlayIntersectionMember1(IReadOnlyDictionary rawData) + public SolidColorOverlaySolidColorOverlay(IReadOnlyDictionary rawData) { this._rawData = new(rawData); @@ -310,14 +310,14 @@ public SolidColorOverlayIntersectionMember1(IReadOnlyDictionary rawData) + SolidColorOverlaySolidColorOverlay(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static SolidColorOverlayIntersectionMember1 FromRawUnchecked( + /// + public static SolidColorOverlaySolidColorOverlay FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -325,18 +325,17 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public SolidColorOverlayIntersectionMember1(string color) + public SolidColorOverlaySolidColorOverlay(string color) : this() { this.Color = color; } } -class SolidColorOverlayIntersectionMember1FromRaw - : IFromRawJson +class SolidColorOverlaySolidColorOverlayFromRaw : IFromRawJson { /// - public SolidColorOverlayIntersectionMember1 FromRawUnchecked( + public SolidColorOverlaySolidColorOverlay FromRawUnchecked( IReadOnlyDictionary rawData - ) => SolidColorOverlayIntersectionMember1.FromRawUnchecked(rawData); + ) => SolidColorOverlaySolidColorOverlay.FromRawUnchecked(rawData); } diff --git a/src/Imagekit/Models/SubtitleOverlay.cs b/src/Imagekit/Models/SubtitleOverlay.cs index 493c5426..9ab58521 100644 --- a/src/Imagekit/Models/SubtitleOverlay.cs +++ b/src/Imagekit/Models/SubtitleOverlay.cs @@ -118,13 +118,13 @@ public JsonElement Type /// removed. - Remaining slashes within the path are replaced with `@@` when using /// plain text. /// - public ApiEnum? Encoding + public ApiEnum? Encoding { get { this._rawData.Freeze(); return this._rawData.GetNullableClass< - ApiEnum + ApiEnum >("encoding"); } init @@ -239,11 +239,11 @@ public SubtitleOverlay FromRawUnchecked(IReadOnlyDictionary [JsonConverter( typeof(JsonModelConverter< - SubtitleOverlayIntersectionMember1, - SubtitleOverlayIntersectionMember1FromRaw + SubtitleOverlaySubtitleOverlay, + SubtitleOverlaySubtitleOverlayFromRaw >) )] -public sealed record class SubtitleOverlayIntersectionMember1 : JsonModel +public sealed record class SubtitleOverlaySubtitleOverlay : JsonModel { /// /// Specifies the relative path to the subtitle file used as an overlay. @@ -278,13 +278,13 @@ public JsonElement Type /// removed. - Remaining slashes within the path are replaced with `@@` when using /// plain text. /// - public ApiEnum? Encoding + public ApiEnum? Encoding { get { this._rawData.Freeze(); return this._rawData.GetNullableClass< - ApiEnum + ApiEnum >("encoding"); } init @@ -339,20 +339,20 @@ public override void Validate() } } - public SubtitleOverlayIntersectionMember1() + public SubtitleOverlaySubtitleOverlay() { this.Type = JsonSerializer.SerializeToElement("subtitle"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public SubtitleOverlayIntersectionMember1( - SubtitleOverlayIntersectionMember1 subtitleOverlayIntersectionMember1 + public SubtitleOverlaySubtitleOverlay( + SubtitleOverlaySubtitleOverlay subtitleOverlaySubtitleOverlay ) - : base(subtitleOverlayIntersectionMember1) { } + : base(subtitleOverlaySubtitleOverlay) { } #pragma warning restore CS8618 - public SubtitleOverlayIntersectionMember1(IReadOnlyDictionary rawData) + public SubtitleOverlaySubtitleOverlay(IReadOnlyDictionary rawData) { this._rawData = new(rawData); @@ -361,14 +361,14 @@ public SubtitleOverlayIntersectionMember1(IReadOnlyDictionary rawData) + SubtitleOverlaySubtitleOverlay(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static SubtitleOverlayIntersectionMember1 FromRawUnchecked( + /// + public static SubtitleOverlaySubtitleOverlay FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -376,19 +376,19 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public SubtitleOverlayIntersectionMember1(string input) + public SubtitleOverlaySubtitleOverlay(string input) : this() { this.Input = input; } } -class SubtitleOverlayIntersectionMember1FromRaw : IFromRawJson +class SubtitleOverlaySubtitleOverlayFromRaw : IFromRawJson { /// - public SubtitleOverlayIntersectionMember1 FromRawUnchecked( + public SubtitleOverlaySubtitleOverlay FromRawUnchecked( IReadOnlyDictionary rawData - ) => SubtitleOverlayIntersectionMember1.FromRawUnchecked(rawData); + ) => SubtitleOverlaySubtitleOverlay.FromRawUnchecked(rawData); } /// @@ -400,18 +400,18 @@ IReadOnlyDictionary rawData /// Regardless of the encoding method: - Leading and trailing slashes are removed. /// - Remaining slashes within the path are replaced with `@@` when using plain text. /// -[JsonConverter(typeof(SubtitleOverlayIntersectionMember1EncodingConverter))] -public enum SubtitleOverlayIntersectionMember1Encoding +[JsonConverter(typeof(SubtitleOverlaySubtitleOverlayEncodingConverter))] +public enum SubtitleOverlaySubtitleOverlayEncoding { Auto, Plain, Base64, } -sealed class SubtitleOverlayIntersectionMember1EncodingConverter - : JsonConverter +sealed class SubtitleOverlaySubtitleOverlayEncodingConverter + : JsonConverter { - public override SubtitleOverlayIntersectionMember1Encoding Read( + public override SubtitleOverlaySubtitleOverlayEncoding Read( ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options @@ -419,16 +419,16 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "auto" => SubtitleOverlayIntersectionMember1Encoding.Auto, - "plain" => SubtitleOverlayIntersectionMember1Encoding.Plain, - "base64" => SubtitleOverlayIntersectionMember1Encoding.Base64, - _ => (SubtitleOverlayIntersectionMember1Encoding)(-1), + "auto" => SubtitleOverlaySubtitleOverlayEncoding.Auto, + "plain" => SubtitleOverlaySubtitleOverlayEncoding.Plain, + "base64" => SubtitleOverlaySubtitleOverlayEncoding.Base64, + _ => (SubtitleOverlaySubtitleOverlayEncoding)(-1), }; } public override void Write( Utf8JsonWriter writer, - SubtitleOverlayIntersectionMember1Encoding value, + SubtitleOverlaySubtitleOverlayEncoding value, JsonSerializerOptions options ) { @@ -436,9 +436,9 @@ JsonSerializerOptions options writer, value switch { - SubtitleOverlayIntersectionMember1Encoding.Auto => "auto", - SubtitleOverlayIntersectionMember1Encoding.Plain => "plain", - SubtitleOverlayIntersectionMember1Encoding.Base64 => "base64", + SubtitleOverlaySubtitleOverlayEncoding.Auto => "auto", + SubtitleOverlaySubtitleOverlayEncoding.Plain => "plain", + SubtitleOverlaySubtitleOverlayEncoding.Base64 => "base64", _ => throw new ImageKitInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/Imagekit/Models/TextOverlay.cs b/src/Imagekit/Models/TextOverlay.cs index 6b4c9eb2..85b308ff 100644 --- a/src/Imagekit/Models/TextOverlay.cs +++ b/src/Imagekit/Models/TextOverlay.cs @@ -118,14 +118,14 @@ public JsonElement Type /// Regardless of the encoding method, the input text is always percent-encoded /// to ensure it is URL-safe. /// - public ApiEnum? Encoding + public ApiEnum? Encoding { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass< - ApiEnum - >("encoding"); + return this._rawData.GetNullableClass>( + "encoding" + ); } init { @@ -237,13 +237,8 @@ public TextOverlay FromRawUnchecked(IReadOnlyDictionary raw TextOverlay.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(JsonModelConverter< - TextOverlayIntersectionMember1, - TextOverlayIntersectionMember1FromRaw - >) -)] -public sealed record class TextOverlayIntersectionMember1 : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class TextOverlayTextOverlay : JsonModel { /// /// Specifies the text to be displayed in the overlay. The SDK automatically @@ -278,14 +273,14 @@ public JsonElement Type /// Regardless of the encoding method, the input text is always percent-encoded /// to ensure it is URL-safe. /// - public ApiEnum? Encoding + public ApiEnum? Encoding { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass< - ApiEnum - >("encoding"); + return this._rawData.GetNullableClass>( + "encoding" + ); } init { @@ -339,20 +334,18 @@ public override void Validate() } } - public TextOverlayIntersectionMember1() + public TextOverlayTextOverlay() { this.Type = JsonSerializer.SerializeToElement("text"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public TextOverlayIntersectionMember1( - TextOverlayIntersectionMember1 textOverlayIntersectionMember1 - ) - : base(textOverlayIntersectionMember1) { } + public TextOverlayTextOverlay(TextOverlayTextOverlay textOverlayTextOverlay) + : base(textOverlayTextOverlay) { } #pragma warning restore CS8618 - public TextOverlayIntersectionMember1(IReadOnlyDictionary rawData) + public TextOverlayTextOverlay(IReadOnlyDictionary rawData) { this._rawData = new(rawData); @@ -361,14 +354,14 @@ public TextOverlayIntersectionMember1(IReadOnlyDictionary r #pragma warning disable CS8618 [SetsRequiredMembers] - TextOverlayIntersectionMember1(FrozenDictionary rawData) + TextOverlayTextOverlay(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static TextOverlayIntersectionMember1 FromRawUnchecked( + /// + public static TextOverlayTextOverlay FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -376,19 +369,19 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public TextOverlayIntersectionMember1(string text) + public TextOverlayTextOverlay(string text) : this() { this.Text = text; } } -class TextOverlayIntersectionMember1FromRaw : IFromRawJson +class TextOverlayTextOverlayFromRaw : IFromRawJson { /// - public TextOverlayIntersectionMember1 FromRawUnchecked( + public TextOverlayTextOverlay FromRawUnchecked( IReadOnlyDictionary rawData - ) => TextOverlayIntersectionMember1.FromRawUnchecked(rawData); + ) => TextOverlayTextOverlay.FromRawUnchecked(rawData); } /// @@ -400,18 +393,17 @@ IReadOnlyDictionary rawData /// Regardless of the encoding method, the input text is always percent-encoded /// to ensure it is URL-safe. /// -[JsonConverter(typeof(TextOverlayIntersectionMember1EncodingConverter))] -public enum TextOverlayIntersectionMember1Encoding +[JsonConverter(typeof(TextOverlayTextOverlayEncodingConverter))] +public enum TextOverlayTextOverlayEncoding { Auto, Plain, Base64, } -sealed class TextOverlayIntersectionMember1EncodingConverter - : JsonConverter +sealed class TextOverlayTextOverlayEncodingConverter : JsonConverter { - public override TextOverlayIntersectionMember1Encoding Read( + public override TextOverlayTextOverlayEncoding Read( ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options @@ -419,16 +411,16 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "auto" => TextOverlayIntersectionMember1Encoding.Auto, - "plain" => TextOverlayIntersectionMember1Encoding.Plain, - "base64" => TextOverlayIntersectionMember1Encoding.Base64, - _ => (TextOverlayIntersectionMember1Encoding)(-1), + "auto" => TextOverlayTextOverlayEncoding.Auto, + "plain" => TextOverlayTextOverlayEncoding.Plain, + "base64" => TextOverlayTextOverlayEncoding.Base64, + _ => (TextOverlayTextOverlayEncoding)(-1), }; } public override void Write( Utf8JsonWriter writer, - TextOverlayIntersectionMember1Encoding value, + TextOverlayTextOverlayEncoding value, JsonSerializerOptions options ) { @@ -436,9 +428,9 @@ JsonSerializerOptions options writer, value switch { - TextOverlayIntersectionMember1Encoding.Auto => "auto", - TextOverlayIntersectionMember1Encoding.Plain => "plain", - TextOverlayIntersectionMember1Encoding.Base64 => "base64", + TextOverlayTextOverlayEncoding.Auto => "auto", + TextOverlayTextOverlayEncoding.Plain => "plain", + TextOverlayTextOverlayEncoding.Base64 => "base64", _ => throw new ImageKitInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/Imagekit/Models/VideoOverlay.cs b/src/Imagekit/Models/VideoOverlay.cs index 102d8eb7..91cc3c58 100644 --- a/src/Imagekit/Models/VideoOverlay.cs +++ b/src/Imagekit/Models/VideoOverlay.cs @@ -118,13 +118,13 @@ public JsonElement Type /// removed. - Remaining slashes within the path are replaced with `@@` when using /// plain text. /// - public ApiEnum? Encoding + public ApiEnum? Encoding { get { this._rawData.Freeze(); return this._rawData.GetNullableClass< - ApiEnum + ApiEnum >("encoding"); } init @@ -239,12 +239,9 @@ public VideoOverlay FromRawUnchecked(IReadOnlyDictionary ra } [JsonConverter( - typeof(JsonModelConverter< - VideoOverlayIntersectionMember1, - VideoOverlayIntersectionMember1FromRaw - >) + typeof(JsonModelConverter) )] -public sealed record class VideoOverlayIntersectionMember1 : JsonModel +public sealed record class VideoOverlayVideoOverlay : JsonModel { /// /// Specifies the relative path to the video used as an overlay. @@ -279,13 +276,13 @@ public JsonElement Type /// removed. - Remaining slashes within the path are replaced with `@@` when using /// plain text. /// - public ApiEnum? Encoding + public ApiEnum? Encoding { get { this._rawData.Freeze(); return this._rawData.GetNullableClass< - ApiEnum + ApiEnum >("encoding"); } init @@ -341,20 +338,18 @@ public override void Validate() } } - public VideoOverlayIntersectionMember1() + public VideoOverlayVideoOverlay() { this.Type = JsonSerializer.SerializeToElement("video"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public VideoOverlayIntersectionMember1( - VideoOverlayIntersectionMember1 videoOverlayIntersectionMember1 - ) - : base(videoOverlayIntersectionMember1) { } + public VideoOverlayVideoOverlay(VideoOverlayVideoOverlay videoOverlayVideoOverlay) + : base(videoOverlayVideoOverlay) { } #pragma warning restore CS8618 - public VideoOverlayIntersectionMember1(IReadOnlyDictionary rawData) + public VideoOverlayVideoOverlay(IReadOnlyDictionary rawData) { this._rawData = new(rawData); @@ -363,14 +358,14 @@ public VideoOverlayIntersectionMember1(IReadOnlyDictionary #pragma warning disable CS8618 [SetsRequiredMembers] - VideoOverlayIntersectionMember1(FrozenDictionary rawData) + VideoOverlayVideoOverlay(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static VideoOverlayIntersectionMember1 FromRawUnchecked( + /// + public static VideoOverlayVideoOverlay FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -378,19 +373,19 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public VideoOverlayIntersectionMember1(string input) + public VideoOverlayVideoOverlay(string input) : this() { this.Input = input; } } -class VideoOverlayIntersectionMember1FromRaw : IFromRawJson +class VideoOverlayVideoOverlayFromRaw : IFromRawJson { /// - public VideoOverlayIntersectionMember1 FromRawUnchecked( + public VideoOverlayVideoOverlay FromRawUnchecked( IReadOnlyDictionary rawData - ) => VideoOverlayIntersectionMember1.FromRawUnchecked(rawData); + ) => VideoOverlayVideoOverlay.FromRawUnchecked(rawData); } /// @@ -402,18 +397,18 @@ IReadOnlyDictionary rawData /// Regardless of the encoding method: - Leading and trailing slashes are removed. /// - Remaining slashes within the path are replaced with `@@` when using plain text. /// -[JsonConverter(typeof(VideoOverlayIntersectionMember1EncodingConverter))] -public enum VideoOverlayIntersectionMember1Encoding +[JsonConverter(typeof(VideoOverlayVideoOverlayEncodingConverter))] +public enum VideoOverlayVideoOverlayEncoding { Auto, Plain, Base64, } -sealed class VideoOverlayIntersectionMember1EncodingConverter - : JsonConverter +sealed class VideoOverlayVideoOverlayEncodingConverter + : JsonConverter { - public override VideoOverlayIntersectionMember1Encoding Read( + public override VideoOverlayVideoOverlayEncoding Read( ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options @@ -421,16 +416,16 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "auto" => VideoOverlayIntersectionMember1Encoding.Auto, - "plain" => VideoOverlayIntersectionMember1Encoding.Plain, - "base64" => VideoOverlayIntersectionMember1Encoding.Base64, - _ => (VideoOverlayIntersectionMember1Encoding)(-1), + "auto" => VideoOverlayVideoOverlayEncoding.Auto, + "plain" => VideoOverlayVideoOverlayEncoding.Plain, + "base64" => VideoOverlayVideoOverlayEncoding.Base64, + _ => (VideoOverlayVideoOverlayEncoding)(-1), }; } public override void Write( Utf8JsonWriter writer, - VideoOverlayIntersectionMember1Encoding value, + VideoOverlayVideoOverlayEncoding value, JsonSerializerOptions options ) { @@ -438,9 +433,9 @@ JsonSerializerOptions options writer, value switch { - VideoOverlayIntersectionMember1Encoding.Auto => "auto", - VideoOverlayIntersectionMember1Encoding.Plain => "plain", - VideoOverlayIntersectionMember1Encoding.Base64 => "base64", + VideoOverlayVideoOverlayEncoding.Auto => "auto", + VideoOverlayVideoOverlayEncoding.Plain => "plain", + VideoOverlayVideoOverlayEncoding.Base64 => "base64", _ => throw new ImageKitInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/Imagekit/Models/Webhooks/FileCreateEvent.cs b/src/Imagekit/Models/Webhooks/FileCreateEvent.cs index a7266eb9..4a3a2fbb 100644 --- a/src/Imagekit/Models/Webhooks/FileCreateEvent.cs +++ b/src/Imagekit/Models/Webhooks/FileCreateEvent.cs @@ -120,11 +120,11 @@ public FileCreateEvent FromRawUnchecked(IReadOnlyDictionary /// [JsonConverter( typeof(JsonModelConverter< - global::Imagekit.Models.Webhooks.IntersectionMember1, - global::Imagekit.Models.Webhooks.IntersectionMember1FromRaw + FileCreateEventFileCreateEvent, + FileCreateEventFileCreateEventFromRaw >) )] -public sealed record class IntersectionMember1 : JsonModel +public sealed record class FileCreateEventFileCreateEvent : JsonModel { /// /// Timestamp of when the event occurred in ISO8601 format. @@ -176,20 +176,20 @@ public override void Validate() } } - public IntersectionMember1() + public FileCreateEventFileCreateEvent() { this.Type = JsonSerializer.SerializeToElement("file.created"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public IntersectionMember1( - global::Imagekit.Models.Webhooks.IntersectionMember1 intersectionMember1 + public FileCreateEventFileCreateEvent( + FileCreateEventFileCreateEvent fileCreateEventFileCreateEvent ) - : base(intersectionMember1) { } + : base(fileCreateEventFileCreateEvent) { } #pragma warning restore CS8618 - public IntersectionMember1(IReadOnlyDictionary rawData) + public FileCreateEventFileCreateEvent(IReadOnlyDictionary rawData) { this._rawData = new(rawData); @@ -198,14 +198,14 @@ public IntersectionMember1(IReadOnlyDictionary rawData) #pragma warning disable CS8618 [SetsRequiredMembers] - IntersectionMember1(FrozenDictionary rawData) + FileCreateEventFileCreateEvent(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Imagekit.Models.Webhooks.IntersectionMember1 FromRawUnchecked( + /// + public static FileCreateEventFileCreateEvent FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -213,11 +213,10 @@ IReadOnlyDictionary rawData } } -class IntersectionMember1FromRaw - : IFromRawJson +class FileCreateEventFileCreateEventFromRaw : IFromRawJson { /// - public global::Imagekit.Models.Webhooks.IntersectionMember1 FromRawUnchecked( + public FileCreateEventFileCreateEvent FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Imagekit.Models.Webhooks.IntersectionMember1.FromRawUnchecked(rawData); + ) => FileCreateEventFileCreateEvent.FromRawUnchecked(rawData); } diff --git a/src/Imagekit/Models/Webhooks/FileDeleteEvent.cs b/src/Imagekit/Models/Webhooks/FileDeleteEvent.cs index e26a6890..35e2d5f6 100644 --- a/src/Imagekit/Models/Webhooks/FileDeleteEvent.cs +++ b/src/Imagekit/Models/Webhooks/FileDeleteEvent.cs @@ -116,11 +116,11 @@ public FileDeleteEvent FromRawUnchecked(IReadOnlyDictionary /// [JsonConverter( typeof(JsonModelConverter< - FileDeleteEventIntersectionMember1, - FileDeleteEventIntersectionMember1FromRaw + FileDeleteEventFileDeleteEvent, + FileDeleteEventFileDeleteEventFromRaw >) )] -public sealed record class FileDeleteEventIntersectionMember1 : JsonModel +public sealed record class FileDeleteEventFileDeleteEvent : JsonModel { /// /// Timestamp of when the event occurred in ISO8601 format. @@ -169,20 +169,20 @@ public override void Validate() } } - public FileDeleteEventIntersectionMember1() + public FileDeleteEventFileDeleteEvent() { this.Type = JsonSerializer.SerializeToElement("file.deleted"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public FileDeleteEventIntersectionMember1( - FileDeleteEventIntersectionMember1 fileDeleteEventIntersectionMember1 + public FileDeleteEventFileDeleteEvent( + FileDeleteEventFileDeleteEvent fileDeleteEventFileDeleteEvent ) - : base(fileDeleteEventIntersectionMember1) { } + : base(fileDeleteEventFileDeleteEvent) { } #pragma warning restore CS8618 - public FileDeleteEventIntersectionMember1(IReadOnlyDictionary rawData) + public FileDeleteEventFileDeleteEvent(IReadOnlyDictionary rawData) { this._rawData = new(rawData); @@ -191,14 +191,14 @@ public FileDeleteEventIntersectionMember1(IReadOnlyDictionary rawData) + FileDeleteEventFileDeleteEvent(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static FileDeleteEventIntersectionMember1 FromRawUnchecked( + /// + public static FileDeleteEventFileDeleteEvent FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -206,12 +206,12 @@ IReadOnlyDictionary rawData } } -class FileDeleteEventIntersectionMember1FromRaw : IFromRawJson +class FileDeleteEventFileDeleteEventFromRaw : IFromRawJson { /// - public FileDeleteEventIntersectionMember1 FromRawUnchecked( + public FileDeleteEventFileDeleteEvent FromRawUnchecked( IReadOnlyDictionary rawData - ) => FileDeleteEventIntersectionMember1.FromRawUnchecked(rawData); + ) => FileDeleteEventFileDeleteEvent.FromRawUnchecked(rawData); } [JsonConverter(typeof(JsonModelConverter))] diff --git a/src/Imagekit/Models/Webhooks/FileUpdateEvent.cs b/src/Imagekit/Models/Webhooks/FileUpdateEvent.cs index 2e6f58dd..0614fe9a 100644 --- a/src/Imagekit/Models/Webhooks/FileUpdateEvent.cs +++ b/src/Imagekit/Models/Webhooks/FileUpdateEvent.cs @@ -120,11 +120,11 @@ public FileUpdateEvent FromRawUnchecked(IReadOnlyDictionary /// [JsonConverter( typeof(JsonModelConverter< - FileUpdateEventIntersectionMember1, - FileUpdateEventIntersectionMember1FromRaw + FileUpdateEventFileUpdateEvent, + FileUpdateEventFileUpdateEventFromRaw >) )] -public sealed record class FileUpdateEventIntersectionMember1 : JsonModel +public sealed record class FileUpdateEventFileUpdateEvent : JsonModel { /// /// Timestamp of when the event occurred in ISO8601 format. @@ -176,20 +176,20 @@ public override void Validate() } } - public FileUpdateEventIntersectionMember1() + public FileUpdateEventFileUpdateEvent() { this.Type = JsonSerializer.SerializeToElement("file.updated"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public FileUpdateEventIntersectionMember1( - FileUpdateEventIntersectionMember1 fileUpdateEventIntersectionMember1 + public FileUpdateEventFileUpdateEvent( + FileUpdateEventFileUpdateEvent fileUpdateEventFileUpdateEvent ) - : base(fileUpdateEventIntersectionMember1) { } + : base(fileUpdateEventFileUpdateEvent) { } #pragma warning restore CS8618 - public FileUpdateEventIntersectionMember1(IReadOnlyDictionary rawData) + public FileUpdateEventFileUpdateEvent(IReadOnlyDictionary rawData) { this._rawData = new(rawData); @@ -198,14 +198,14 @@ public FileUpdateEventIntersectionMember1(IReadOnlyDictionary rawData) + FileUpdateEventFileUpdateEvent(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static FileUpdateEventIntersectionMember1 FromRawUnchecked( + /// + public static FileUpdateEventFileUpdateEvent FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -213,10 +213,10 @@ IReadOnlyDictionary rawData } } -class FileUpdateEventIntersectionMember1FromRaw : IFromRawJson +class FileUpdateEventFileUpdateEventFromRaw : IFromRawJson { /// - public FileUpdateEventIntersectionMember1 FromRawUnchecked( + public FileUpdateEventFileUpdateEvent FromRawUnchecked( IReadOnlyDictionary rawData - ) => FileUpdateEventIntersectionMember1.FromRawUnchecked(rawData); + ) => FileUpdateEventFileUpdateEvent.FromRawUnchecked(rawData); } diff --git a/src/Imagekit/Models/Webhooks/FileVersionCreateEvent.cs b/src/Imagekit/Models/Webhooks/FileVersionCreateEvent.cs index b8ad5f76..e01435c7 100644 --- a/src/Imagekit/Models/Webhooks/FileVersionCreateEvent.cs +++ b/src/Imagekit/Models/Webhooks/FileVersionCreateEvent.cs @@ -124,11 +124,11 @@ IReadOnlyDictionary rawData /// [JsonConverter( typeof(JsonModelConverter< - FileVersionCreateEventIntersectionMember1, - FileVersionCreateEventIntersectionMember1FromRaw + FileVersionCreateEventFileVersionCreateEvent, + FileVersionCreateEventFileVersionCreateEventFromRaw >) )] -public sealed record class FileVersionCreateEventIntersectionMember1 : JsonModel +public sealed record class FileVersionCreateEventFileVersionCreateEvent : JsonModel { /// /// Timestamp of when the event occurred in ISO8601 format. @@ -185,20 +185,20 @@ public override void Validate() } } - public FileVersionCreateEventIntersectionMember1() + public FileVersionCreateEventFileVersionCreateEvent() { this.Type = JsonSerializer.SerializeToElement("file-version.created"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public FileVersionCreateEventIntersectionMember1( - FileVersionCreateEventIntersectionMember1 fileVersionCreateEventIntersectionMember1 + public FileVersionCreateEventFileVersionCreateEvent( + FileVersionCreateEventFileVersionCreateEvent fileVersionCreateEventFileVersionCreateEvent ) - : base(fileVersionCreateEventIntersectionMember1) { } + : base(fileVersionCreateEventFileVersionCreateEvent) { } #pragma warning restore CS8618 - public FileVersionCreateEventIntersectionMember1( + public FileVersionCreateEventFileVersionCreateEvent( IReadOnlyDictionary rawData ) { @@ -209,14 +209,14 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - FileVersionCreateEventIntersectionMember1(FrozenDictionary rawData) + FileVersionCreateEventFileVersionCreateEvent(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static FileVersionCreateEventIntersectionMember1 FromRawUnchecked( + /// + public static FileVersionCreateEventFileVersionCreateEvent FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -224,11 +224,11 @@ IReadOnlyDictionary rawData } } -class FileVersionCreateEventIntersectionMember1FromRaw - : IFromRawJson +class FileVersionCreateEventFileVersionCreateEventFromRaw + : IFromRawJson { /// - public FileVersionCreateEventIntersectionMember1 FromRawUnchecked( + public FileVersionCreateEventFileVersionCreateEvent FromRawUnchecked( IReadOnlyDictionary rawData - ) => FileVersionCreateEventIntersectionMember1.FromRawUnchecked(rawData); + ) => FileVersionCreateEventFileVersionCreateEvent.FromRawUnchecked(rawData); } diff --git a/src/Imagekit/Models/Webhooks/FileVersionDeleteEvent.cs b/src/Imagekit/Models/Webhooks/FileVersionDeleteEvent.cs index e100bb75..ba2c5073 100644 --- a/src/Imagekit/Models/Webhooks/FileVersionDeleteEvent.cs +++ b/src/Imagekit/Models/Webhooks/FileVersionDeleteEvent.cs @@ -54,12 +54,12 @@ public required DateTimeOffset CreatedAt init { this._rawData.Set("created_at", value); } } - public required FileVersionDeleteEventIntersectionMember1Data Data + public required FileVersionDeleteEventFileVersionDeleteEventData Data { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "data" ); } @@ -122,11 +122,11 @@ IReadOnlyDictionary rawData /// [JsonConverter( typeof(JsonModelConverter< - FileVersionDeleteEventIntersectionMember1, - FileVersionDeleteEventIntersectionMember1FromRaw + FileVersionDeleteEventFileVersionDeleteEvent, + FileVersionDeleteEventFileVersionDeleteEventFromRaw >) )] -public sealed record class FileVersionDeleteEventIntersectionMember1 : JsonModel +public sealed record class FileVersionDeleteEventFileVersionDeleteEvent : JsonModel { /// /// Timestamp of when the event occurred in ISO8601 format. @@ -141,12 +141,12 @@ public required DateTimeOffset CreatedAt init { this._rawData.Set("created_at", value); } } - public required FileVersionDeleteEventIntersectionMember1Data Data + public required FileVersionDeleteEventFileVersionDeleteEventData Data { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "data" ); } @@ -182,20 +182,20 @@ public override void Validate() } } - public FileVersionDeleteEventIntersectionMember1() + public FileVersionDeleteEventFileVersionDeleteEvent() { this.Type = JsonSerializer.SerializeToElement("file-version.deleted"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public FileVersionDeleteEventIntersectionMember1( - FileVersionDeleteEventIntersectionMember1 fileVersionDeleteEventIntersectionMember1 + public FileVersionDeleteEventFileVersionDeleteEvent( + FileVersionDeleteEventFileVersionDeleteEvent fileVersionDeleteEventFileVersionDeleteEvent ) - : base(fileVersionDeleteEventIntersectionMember1) { } + : base(fileVersionDeleteEventFileVersionDeleteEvent) { } #pragma warning restore CS8618 - public FileVersionDeleteEventIntersectionMember1( + public FileVersionDeleteEventFileVersionDeleteEvent( IReadOnlyDictionary rawData ) { @@ -206,14 +206,14 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - FileVersionDeleteEventIntersectionMember1(FrozenDictionary rawData) + FileVersionDeleteEventFileVersionDeleteEvent(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static FileVersionDeleteEventIntersectionMember1 FromRawUnchecked( + /// + public static FileVersionDeleteEventFileVersionDeleteEvent FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -221,22 +221,22 @@ IReadOnlyDictionary rawData } } -class FileVersionDeleteEventIntersectionMember1FromRaw - : IFromRawJson +class FileVersionDeleteEventFileVersionDeleteEventFromRaw + : IFromRawJson { /// - public FileVersionDeleteEventIntersectionMember1 FromRawUnchecked( + public FileVersionDeleteEventFileVersionDeleteEvent FromRawUnchecked( IReadOnlyDictionary rawData - ) => FileVersionDeleteEventIntersectionMember1.FromRawUnchecked(rawData); + ) => FileVersionDeleteEventFileVersionDeleteEvent.FromRawUnchecked(rawData); } [JsonConverter( typeof(JsonModelConverter< - FileVersionDeleteEventIntersectionMember1Data, - FileVersionDeleteEventIntersectionMember1DataFromRaw + FileVersionDeleteEventFileVersionDeleteEventData, + FileVersionDeleteEventFileVersionDeleteEventDataFromRaw >) )] -public sealed record class FileVersionDeleteEventIntersectionMember1Data : JsonModel +public sealed record class FileVersionDeleteEventFileVersionDeleteEventData : JsonModel { /// /// The unique `fileId` of the deleted file. @@ -271,17 +271,17 @@ public override void Validate() _ = this.VersionID; } - public FileVersionDeleteEventIntersectionMember1Data() { } + public FileVersionDeleteEventFileVersionDeleteEventData() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public FileVersionDeleteEventIntersectionMember1Data( - FileVersionDeleteEventIntersectionMember1Data fileVersionDeleteEventIntersectionMember1Data + public FileVersionDeleteEventFileVersionDeleteEventData( + FileVersionDeleteEventFileVersionDeleteEventData fileVersionDeleteEventFileVersionDeleteEventData ) - : base(fileVersionDeleteEventIntersectionMember1Data) { } + : base(fileVersionDeleteEventFileVersionDeleteEventData) { } #pragma warning restore CS8618 - public FileVersionDeleteEventIntersectionMember1Data( + public FileVersionDeleteEventFileVersionDeleteEventData( IReadOnlyDictionary rawData ) { @@ -290,14 +290,14 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - FileVersionDeleteEventIntersectionMember1Data(FrozenDictionary rawData) + FileVersionDeleteEventFileVersionDeleteEventData(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static FileVersionDeleteEventIntersectionMember1Data FromRawUnchecked( + /// + public static FileVersionDeleteEventFileVersionDeleteEventData FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -305,11 +305,11 @@ IReadOnlyDictionary rawData } } -class FileVersionDeleteEventIntersectionMember1DataFromRaw - : IFromRawJson +class FileVersionDeleteEventFileVersionDeleteEventDataFromRaw + : IFromRawJson { /// - public FileVersionDeleteEventIntersectionMember1Data FromRawUnchecked( + public FileVersionDeleteEventFileVersionDeleteEventData FromRawUnchecked( IReadOnlyDictionary rawData - ) => FileVersionDeleteEventIntersectionMember1Data.FromRawUnchecked(rawData); + ) => FileVersionDeleteEventFileVersionDeleteEventData.FromRawUnchecked(rawData); } diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEvent.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEvent.cs index 23b996e6..eb772f73 100644 --- a/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEvent.cs +++ b/src/Imagekit/Models/Webhooks/UploadPostTransformErrorEvent.cs @@ -57,12 +57,12 @@ public required string Type init { this._rawData.Set("created_at", value); } } - public required UploadPostTransformErrorEventIntersectionMember1Data Data + public required UploadPostTransformErrorEventUploadPostTransformErrorEventData Data { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "data" ); } @@ -139,11 +139,11 @@ IReadOnlyDictionary rawData /// [JsonConverter( typeof(JsonModelConverter< - UploadPostTransformErrorEventIntersectionMember1, - UploadPostTransformErrorEventIntersectionMember1FromRaw + UploadPostTransformErrorEventUploadPostTransformErrorEvent, + UploadPostTransformErrorEventUploadPostTransformErrorEventFromRaw >) )] -public sealed record class UploadPostTransformErrorEventIntersectionMember1 : JsonModel +public sealed record class UploadPostTransformErrorEventUploadPostTransformErrorEvent : JsonModel { /// /// Timestamp of when the event occurred in ISO8601 format. @@ -158,12 +158,12 @@ public sealed record class UploadPostTransformErrorEventIntersectionMember1 : Js init { this._rawData.Set("created_at", value); } } - public required UploadPostTransformErrorEventIntersectionMember1Data Data + public required UploadPostTransformErrorEventUploadPostTransformErrorEventData Data { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "data" ); } @@ -207,20 +207,20 @@ public override void Validate() } } - public UploadPostTransformErrorEventIntersectionMember1() + public UploadPostTransformErrorEventUploadPostTransformErrorEvent() { this.Type = JsonSerializer.SerializeToElement("upload.post-transform.error"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public UploadPostTransformErrorEventIntersectionMember1( - UploadPostTransformErrorEventIntersectionMember1 uploadPostTransformErrorEventIntersectionMember1 + public UploadPostTransformErrorEventUploadPostTransformErrorEvent( + UploadPostTransformErrorEventUploadPostTransformErrorEvent uploadPostTransformErrorEventUploadPostTransformErrorEvent ) - : base(uploadPostTransformErrorEventIntersectionMember1) { } + : base(uploadPostTransformErrorEventUploadPostTransformErrorEvent) { } #pragma warning restore CS8618 - public UploadPostTransformErrorEventIntersectionMember1( + public UploadPostTransformErrorEventUploadPostTransformErrorEvent( IReadOnlyDictionary rawData ) { @@ -231,14 +231,16 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - UploadPostTransformErrorEventIntersectionMember1(FrozenDictionary rawData) + UploadPostTransformErrorEventUploadPostTransformErrorEvent( + FrozenDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static UploadPostTransformErrorEventIntersectionMember1 FromRawUnchecked( + /// + public static UploadPostTransformErrorEventUploadPostTransformErrorEvent FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -246,22 +248,23 @@ IReadOnlyDictionary rawData } } -class UploadPostTransformErrorEventIntersectionMember1FromRaw - : IFromRawJson +class UploadPostTransformErrorEventUploadPostTransformErrorEventFromRaw + : IFromRawJson { /// - public UploadPostTransformErrorEventIntersectionMember1 FromRawUnchecked( + public UploadPostTransformErrorEventUploadPostTransformErrorEvent FromRawUnchecked( IReadOnlyDictionary rawData - ) => UploadPostTransformErrorEventIntersectionMember1.FromRawUnchecked(rawData); + ) => UploadPostTransformErrorEventUploadPostTransformErrorEvent.FromRawUnchecked(rawData); } [JsonConverter( typeof(JsonModelConverter< - UploadPostTransformErrorEventIntersectionMember1Data, - UploadPostTransformErrorEventIntersectionMember1DataFromRaw + UploadPostTransformErrorEventUploadPostTransformErrorEventData, + UploadPostTransformErrorEventUploadPostTransformErrorEventDataFromRaw >) )] -public sealed record class UploadPostTransformErrorEventIntersectionMember1Data : JsonModel +public sealed record class UploadPostTransformErrorEventUploadPostTransformErrorEventData + : JsonModel { /// /// Unique identifier of the originally uploaded file. @@ -335,17 +338,17 @@ public override void Validate() _ = this.Url; } - public UploadPostTransformErrorEventIntersectionMember1Data() { } + public UploadPostTransformErrorEventUploadPostTransformErrorEventData() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public UploadPostTransformErrorEventIntersectionMember1Data( - UploadPostTransformErrorEventIntersectionMember1Data uploadPostTransformErrorEventIntersectionMember1Data + public UploadPostTransformErrorEventUploadPostTransformErrorEventData( + UploadPostTransformErrorEventUploadPostTransformErrorEventData uploadPostTransformErrorEventUploadPostTransformErrorEventData ) - : base(uploadPostTransformErrorEventIntersectionMember1Data) { } + : base(uploadPostTransformErrorEventUploadPostTransformErrorEventData) { } #pragma warning restore CS8618 - public UploadPostTransformErrorEventIntersectionMember1Data( + public UploadPostTransformErrorEventUploadPostTransformErrorEventData( IReadOnlyDictionary rawData ) { @@ -354,7 +357,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - UploadPostTransformErrorEventIntersectionMember1Data( + UploadPostTransformErrorEventUploadPostTransformErrorEventData( FrozenDictionary rawData ) { @@ -362,8 +365,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static UploadPostTransformErrorEventIntersectionMember1Data FromRawUnchecked( + /// + public static UploadPostTransformErrorEventUploadPostTransformErrorEventData FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -371,13 +374,13 @@ IReadOnlyDictionary rawData } } -class UploadPostTransformErrorEventIntersectionMember1DataFromRaw - : IFromRawJson +class UploadPostTransformErrorEventUploadPostTransformErrorEventDataFromRaw + : IFromRawJson { /// - public UploadPostTransformErrorEventIntersectionMember1Data FromRawUnchecked( + public UploadPostTransformErrorEventUploadPostTransformErrorEventData FromRawUnchecked( IReadOnlyDictionary rawData - ) => UploadPostTransformErrorEventIntersectionMember1Data.FromRawUnchecked(rawData); + ) => UploadPostTransformErrorEventUploadPostTransformErrorEventData.FromRawUnchecked(rawData); } [JsonConverter(typeof(JsonModelConverter))] diff --git a/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEvent.cs b/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEvent.cs index faaa4acc..1671ec6f 100644 --- a/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEvent.cs +++ b/src/Imagekit/Models/Webhooks/UploadPostTransformSuccessEvent.cs @@ -61,24 +61,24 @@ public required string Type init { this._rawData.Set("created_at", value); } } - public required UploadPostTransformSuccessEventIntersectionMember1Data Data + public required UploadPostTransformSuccessEventUploadPostTransformSuccessEventData Data { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "data" ); } init { this._rawData.Set("data", value); } } - public required UploadPostTransformSuccessEventIntersectionMember1Request Request + public required UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequest Request { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "request" ); } @@ -151,11 +151,12 @@ IReadOnlyDictionary rawData /// [JsonConverter( typeof(JsonModelConverter< - UploadPostTransformSuccessEventIntersectionMember1, - UploadPostTransformSuccessEventIntersectionMember1FromRaw + UploadPostTransformSuccessEventUploadPostTransformSuccessEvent, + UploadPostTransformSuccessEventUploadPostTransformSuccessEventFromRaw >) )] -public sealed record class UploadPostTransformSuccessEventIntersectionMember1 : JsonModel +public sealed record class UploadPostTransformSuccessEventUploadPostTransformSuccessEvent + : JsonModel { /// /// Timestamp of when the event occurred in ISO8601 format. @@ -170,24 +171,24 @@ public sealed record class UploadPostTransformSuccessEventIntersectionMember1 : init { this._rawData.Set("created_at", value); } } - public required UploadPostTransformSuccessEventIntersectionMember1Data Data + public required UploadPostTransformSuccessEventUploadPostTransformSuccessEventData Data { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "data" ); } init { this._rawData.Set("data", value); } } - public required UploadPostTransformSuccessEventIntersectionMember1Request Request + public required UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequest Request { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "request" ); } @@ -221,20 +222,20 @@ public override void Validate() } } - public UploadPostTransformSuccessEventIntersectionMember1() + public UploadPostTransformSuccessEventUploadPostTransformSuccessEvent() { this.Type = JsonSerializer.SerializeToElement("upload.post-transform.success"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public UploadPostTransformSuccessEventIntersectionMember1( - UploadPostTransformSuccessEventIntersectionMember1 uploadPostTransformSuccessEventIntersectionMember1 + public UploadPostTransformSuccessEventUploadPostTransformSuccessEvent( + UploadPostTransformSuccessEventUploadPostTransformSuccessEvent uploadPostTransformSuccessEventUploadPostTransformSuccessEvent ) - : base(uploadPostTransformSuccessEventIntersectionMember1) { } + : base(uploadPostTransformSuccessEventUploadPostTransformSuccessEvent) { } #pragma warning restore CS8618 - public UploadPostTransformSuccessEventIntersectionMember1( + public UploadPostTransformSuccessEventUploadPostTransformSuccessEvent( IReadOnlyDictionary rawData ) { @@ -245,7 +246,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - UploadPostTransformSuccessEventIntersectionMember1( + UploadPostTransformSuccessEventUploadPostTransformSuccessEvent( FrozenDictionary rawData ) { @@ -253,8 +254,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static UploadPostTransformSuccessEventIntersectionMember1 FromRawUnchecked( + /// + public static UploadPostTransformSuccessEventUploadPostTransformSuccessEvent FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -262,22 +263,23 @@ IReadOnlyDictionary rawData } } -class UploadPostTransformSuccessEventIntersectionMember1FromRaw - : IFromRawJson +class UploadPostTransformSuccessEventUploadPostTransformSuccessEventFromRaw + : IFromRawJson { /// - public UploadPostTransformSuccessEventIntersectionMember1 FromRawUnchecked( + public UploadPostTransformSuccessEventUploadPostTransformSuccessEvent FromRawUnchecked( IReadOnlyDictionary rawData - ) => UploadPostTransformSuccessEventIntersectionMember1.FromRawUnchecked(rawData); + ) => UploadPostTransformSuccessEventUploadPostTransformSuccessEvent.FromRawUnchecked(rawData); } [JsonConverter( typeof(JsonModelConverter< - UploadPostTransformSuccessEventIntersectionMember1Data, - UploadPostTransformSuccessEventIntersectionMember1DataFromRaw + UploadPostTransformSuccessEventUploadPostTransformSuccessEventData, + UploadPostTransformSuccessEventUploadPostTransformSuccessEventDataFromRaw >) )] -public sealed record class UploadPostTransformSuccessEventIntersectionMember1Data : JsonModel +public sealed record class UploadPostTransformSuccessEventUploadPostTransformSuccessEventData + : JsonModel { /// /// Unique identifier of the originally uploaded file. @@ -326,17 +328,17 @@ public override void Validate() _ = this.Url; } - public UploadPostTransformSuccessEventIntersectionMember1Data() { } + public UploadPostTransformSuccessEventUploadPostTransformSuccessEventData() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public UploadPostTransformSuccessEventIntersectionMember1Data( - UploadPostTransformSuccessEventIntersectionMember1Data uploadPostTransformSuccessEventIntersectionMember1Data + public UploadPostTransformSuccessEventUploadPostTransformSuccessEventData( + UploadPostTransformSuccessEventUploadPostTransformSuccessEventData uploadPostTransformSuccessEventUploadPostTransformSuccessEventData ) - : base(uploadPostTransformSuccessEventIntersectionMember1Data) { } + : base(uploadPostTransformSuccessEventUploadPostTransformSuccessEventData) { } #pragma warning restore CS8618 - public UploadPostTransformSuccessEventIntersectionMember1Data( + public UploadPostTransformSuccessEventUploadPostTransformSuccessEventData( IReadOnlyDictionary rawData ) { @@ -345,7 +347,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - UploadPostTransformSuccessEventIntersectionMember1Data( + UploadPostTransformSuccessEventUploadPostTransformSuccessEventData( FrozenDictionary rawData ) { @@ -353,8 +355,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static UploadPostTransformSuccessEventIntersectionMember1Data FromRawUnchecked( + /// + public static UploadPostTransformSuccessEventUploadPostTransformSuccessEventData FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -362,29 +364,33 @@ IReadOnlyDictionary rawData } } -class UploadPostTransformSuccessEventIntersectionMember1DataFromRaw - : IFromRawJson +class UploadPostTransformSuccessEventUploadPostTransformSuccessEventDataFromRaw + : IFromRawJson { /// - public UploadPostTransformSuccessEventIntersectionMember1Data FromRawUnchecked( + public UploadPostTransformSuccessEventUploadPostTransformSuccessEventData FromRawUnchecked( IReadOnlyDictionary rawData - ) => UploadPostTransformSuccessEventIntersectionMember1Data.FromRawUnchecked(rawData); + ) => + UploadPostTransformSuccessEventUploadPostTransformSuccessEventData.FromRawUnchecked( + rawData + ); } [JsonConverter( typeof(JsonModelConverter< - UploadPostTransformSuccessEventIntersectionMember1Request, - UploadPostTransformSuccessEventIntersectionMember1RequestFromRaw + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequest, + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestFromRaw >) )] -public sealed record class UploadPostTransformSuccessEventIntersectionMember1Request : JsonModel +public sealed record class UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequest + : JsonModel { - public required UploadPostTransformSuccessEventIntersectionMember1RequestTransformation Transformation + public required UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformation Transformation { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "transformation" ); } @@ -411,17 +417,17 @@ public override void Validate() _ = this.XRequestID; } - public UploadPostTransformSuccessEventIntersectionMember1Request() { } + public UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequest() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public UploadPostTransformSuccessEventIntersectionMember1Request( - UploadPostTransformSuccessEventIntersectionMember1Request uploadPostTransformSuccessEventIntersectionMember1Request + public UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequest( + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequest uploadPostTransformSuccessEventUploadPostTransformSuccessEventRequest ) - : base(uploadPostTransformSuccessEventIntersectionMember1Request) { } + : base(uploadPostTransformSuccessEventUploadPostTransformSuccessEventRequest) { } #pragma warning restore CS8618 - public UploadPostTransformSuccessEventIntersectionMember1Request( + public UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequest( IReadOnlyDictionary rawData ) { @@ -430,7 +436,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - UploadPostTransformSuccessEventIntersectionMember1Request( + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequest( FrozenDictionary rawData ) { @@ -438,8 +444,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static UploadPostTransformSuccessEventIntersectionMember1Request FromRawUnchecked( + /// + public static UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequest FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -447,22 +453,25 @@ IReadOnlyDictionary rawData } } -class UploadPostTransformSuccessEventIntersectionMember1RequestFromRaw - : IFromRawJson +class UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestFromRaw + : IFromRawJson { /// - public UploadPostTransformSuccessEventIntersectionMember1Request FromRawUnchecked( + public UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequest FromRawUnchecked( IReadOnlyDictionary rawData - ) => UploadPostTransformSuccessEventIntersectionMember1Request.FromRawUnchecked(rawData); + ) => + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequest.FromRawUnchecked( + rawData + ); } [JsonConverter( typeof(JsonModelConverter< - UploadPostTransformSuccessEventIntersectionMember1RequestTransformation, - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationFromRaw + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformation, + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationFromRaw >) )] -public sealed record class UploadPostTransformSuccessEventIntersectionMember1RequestTransformation +public sealed record class UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformation : JsonModel { /// @@ -470,7 +479,7 @@ public sealed record class UploadPostTransformSuccessEventIntersectionMember1Req /// public required ApiEnum< string, - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType > Type { get @@ -479,7 +488,7 @@ public required ApiEnum< return this._rawData.GetNotNullClass< ApiEnum< string, - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType > >("type"); } @@ -491,7 +500,7 @@ public required ApiEnum< /// public ApiEnum< string, - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol >? Protocol { get @@ -500,7 +509,7 @@ public ApiEnum< return this._rawData.GetNullableClass< ApiEnum< string, - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol > >("protocol"); } @@ -544,17 +553,18 @@ public override void Validate() _ = this.Value; } - public UploadPostTransformSuccessEventIntersectionMember1RequestTransformation() { } + public UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformation() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public UploadPostTransformSuccessEventIntersectionMember1RequestTransformation( - UploadPostTransformSuccessEventIntersectionMember1RequestTransformation uploadPostTransformSuccessEventIntersectionMember1RequestTransformation + public UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformation( + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformation uploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformation ) - : base(uploadPostTransformSuccessEventIntersectionMember1RequestTransformation) { } + : base(uploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformation) + { } #pragma warning restore CS8618 - public UploadPostTransformSuccessEventIntersectionMember1RequestTransformation( + public UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformation( IReadOnlyDictionary rawData ) { @@ -563,7 +573,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - UploadPostTransformSuccessEventIntersectionMember1RequestTransformation( + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformation( FrozenDictionary rawData ) { @@ -571,8 +581,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static UploadPostTransformSuccessEventIntersectionMember1RequestTransformation FromRawUnchecked( + /// + public static UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -580,10 +590,10 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public UploadPostTransformSuccessEventIntersectionMember1RequestTransformation( + public UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformation( ApiEnum< string, - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType > type ) : this() @@ -592,14 +602,14 @@ public UploadPostTransformSuccessEventIntersectionMember1RequestTransformation( } } -class UploadPostTransformSuccessEventIntersectionMember1RequestTransformationFromRaw - : IFromRawJson +class UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationFromRaw + : IFromRawJson { /// - public UploadPostTransformSuccessEventIntersectionMember1RequestTransformation FromRawUnchecked( + public UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformation FromRawUnchecked( IReadOnlyDictionary rawData ) => - UploadPostTransformSuccessEventIntersectionMember1RequestTransformation.FromRawUnchecked( + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformation.FromRawUnchecked( rawData ); } @@ -608,9 +618,9 @@ IReadOnlyDictionary rawData /// Type of the requested post-transformation. /// [JsonConverter( - typeof(UploadPostTransformSuccessEventIntersectionMember1RequestTransformationTypeConverter) + typeof(UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationTypeConverter) )] -public enum UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType +public enum UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType { Transformation, Abs, @@ -618,10 +628,10 @@ public enum UploadPostTransformSuccessEventIntersectionMember1RequestTransformat Thumbnail, } -sealed class UploadPostTransformSuccessEventIntersectionMember1RequestTransformationTypeConverter - : JsonConverter +sealed class UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationTypeConverter + : JsonConverter { - public override UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType Read( + public override UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -630,20 +640,23 @@ JsonSerializerOptions options return JsonSerializer.Deserialize(ref reader, options) switch { "transformation" => - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation, + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.Transformation, "abs" => - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Abs, + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.Abs, "gif-to-video" => - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.GifToVideo, + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.GifToVideo, "thumbnail" => - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Thumbnail, - _ => (UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType)(-1), + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.Thumbnail, + _ => + (UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType)( + -1 + ), }; } public override void Write( Utf8JsonWriter writer, - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType value, + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType value, JsonSerializerOptions options ) { @@ -651,13 +664,13 @@ JsonSerializerOptions options writer, value switch { - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Transformation => + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.Transformation => "transformation", - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Abs => + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.Abs => "abs", - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.GifToVideo => + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.GifToVideo => "gif-to-video", - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationType.Thumbnail => + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationType.Thumbnail => "thumbnail", _ => throw new ImageKitInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) @@ -672,18 +685,18 @@ JsonSerializerOptions options /// Only applicable if transformation type is 'abs'. Streaming protocol used. /// [JsonConverter( - typeof(UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocolConverter) + typeof(UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocolConverter) )] -public enum UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol +public enum UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol { Hls, Dash, } -sealed class UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocolConverter - : JsonConverter +sealed class UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocolConverter + : JsonConverter { - public override UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol Read( + public override UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -692,18 +705,19 @@ JsonSerializerOptions options return JsonSerializer.Deserialize(ref reader, options) switch { "hls" => - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls, + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol.Hls, "dash" => - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Dash, - _ => (UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol)( - -1 - ), + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol.Dash, + _ => + (UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol)( + -1 + ), }; } public override void Write( Utf8JsonWriter writer, - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol value, + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol value, JsonSerializerOptions options ) { @@ -711,9 +725,9 @@ JsonSerializerOptions options writer, value switch { - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Hls => + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol.Hls => "hls", - UploadPostTransformSuccessEventIntersectionMember1RequestTransformationProtocol.Dash => + UploadPostTransformSuccessEventUploadPostTransformSuccessEventRequestTransformationProtocol.Dash => "dash", _ => throw new ImageKitInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEvent.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEvent.cs index 005f41b9..07bb775e 100644 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEvent.cs +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformErrorEvent.cs @@ -57,24 +57,24 @@ public required DateTimeOffset CreatedAt init { this._rawData.Set("created_at", value); } } - public required UploadPreTransformErrorEventIntersectionMember1Data Data + public required UploadPreTransformErrorEventUploadPreTransformErrorEventData Data { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "data" ); } init { this._rawData.Set("data", value); } } - public required UploadPreTransformErrorEventIntersectionMember1Request Request + public required UploadPreTransformErrorEventUploadPreTransformErrorEventRequest Request { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "request" ); } @@ -139,11 +139,11 @@ IReadOnlyDictionary rawData /// [JsonConverter( typeof(JsonModelConverter< - UploadPreTransformErrorEventIntersectionMember1, - UploadPreTransformErrorEventIntersectionMember1FromRaw + UploadPreTransformErrorEventUploadPreTransformErrorEvent, + UploadPreTransformErrorEventUploadPreTransformErrorEventFromRaw >) )] -public sealed record class UploadPreTransformErrorEventIntersectionMember1 : JsonModel +public sealed record class UploadPreTransformErrorEventUploadPreTransformErrorEvent : JsonModel { /// /// Timestamp of when the event occurred in ISO8601 format. @@ -158,24 +158,24 @@ public required DateTimeOffset CreatedAt init { this._rawData.Set("created_at", value); } } - public required UploadPreTransformErrorEventIntersectionMember1Data Data + public required UploadPreTransformErrorEventUploadPreTransformErrorEventData Data { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "data" ); } init { this._rawData.Set("data", value); } } - public required UploadPreTransformErrorEventIntersectionMember1Request Request + public required UploadPreTransformErrorEventUploadPreTransformErrorEventRequest Request { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "request" ); } @@ -209,20 +209,20 @@ public override void Validate() } } - public UploadPreTransformErrorEventIntersectionMember1() + public UploadPreTransformErrorEventUploadPreTransformErrorEvent() { this.Type = JsonSerializer.SerializeToElement("upload.pre-transform.error"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public UploadPreTransformErrorEventIntersectionMember1( - UploadPreTransformErrorEventIntersectionMember1 uploadPreTransformErrorEventIntersectionMember1 + public UploadPreTransformErrorEventUploadPreTransformErrorEvent( + UploadPreTransformErrorEventUploadPreTransformErrorEvent uploadPreTransformErrorEventUploadPreTransformErrorEvent ) - : base(uploadPreTransformErrorEventIntersectionMember1) { } + : base(uploadPreTransformErrorEventUploadPreTransformErrorEvent) { } #pragma warning restore CS8618 - public UploadPreTransformErrorEventIntersectionMember1( + public UploadPreTransformErrorEventUploadPreTransformErrorEvent( IReadOnlyDictionary rawData ) { @@ -233,14 +233,16 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - UploadPreTransformErrorEventIntersectionMember1(FrozenDictionary rawData) + UploadPreTransformErrorEventUploadPreTransformErrorEvent( + FrozenDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static UploadPreTransformErrorEventIntersectionMember1 FromRawUnchecked( + /// + public static UploadPreTransformErrorEventUploadPreTransformErrorEvent FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -248,22 +250,22 @@ IReadOnlyDictionary rawData } } -class UploadPreTransformErrorEventIntersectionMember1FromRaw - : IFromRawJson +class UploadPreTransformErrorEventUploadPreTransformErrorEventFromRaw + : IFromRawJson { /// - public UploadPreTransformErrorEventIntersectionMember1 FromRawUnchecked( + public UploadPreTransformErrorEventUploadPreTransformErrorEvent FromRawUnchecked( IReadOnlyDictionary rawData - ) => UploadPreTransformErrorEventIntersectionMember1.FromRawUnchecked(rawData); + ) => UploadPreTransformErrorEventUploadPreTransformErrorEvent.FromRawUnchecked(rawData); } [JsonConverter( typeof(JsonModelConverter< - UploadPreTransformErrorEventIntersectionMember1Data, - UploadPreTransformErrorEventIntersectionMember1DataFromRaw + UploadPreTransformErrorEventUploadPreTransformErrorEventData, + UploadPreTransformErrorEventUploadPreTransformErrorEventDataFromRaw >) )] -public sealed record class UploadPreTransformErrorEventIntersectionMember1Data : JsonModel +public sealed record class UploadPreTransformErrorEventUploadPreTransformErrorEventData : JsonModel { /// /// Name of the file. @@ -291,12 +293,12 @@ public required string Path init { this._rawData.Set("path", value); } } - public required UploadPreTransformErrorEventIntersectionMember1DataTransformation Transformation + public required UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformation Transformation { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "transformation" ); } @@ -311,17 +313,17 @@ public override void Validate() this.Transformation.Validate(); } - public UploadPreTransformErrorEventIntersectionMember1Data() { } + public UploadPreTransformErrorEventUploadPreTransformErrorEventData() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public UploadPreTransformErrorEventIntersectionMember1Data( - UploadPreTransformErrorEventIntersectionMember1Data uploadPreTransformErrorEventIntersectionMember1Data + public UploadPreTransformErrorEventUploadPreTransformErrorEventData( + UploadPreTransformErrorEventUploadPreTransformErrorEventData uploadPreTransformErrorEventUploadPreTransformErrorEventData ) - : base(uploadPreTransformErrorEventIntersectionMember1Data) { } + : base(uploadPreTransformErrorEventUploadPreTransformErrorEventData) { } #pragma warning restore CS8618 - public UploadPreTransformErrorEventIntersectionMember1Data( + public UploadPreTransformErrorEventUploadPreTransformErrorEventData( IReadOnlyDictionary rawData ) { @@ -330,7 +332,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - UploadPreTransformErrorEventIntersectionMember1Data( + UploadPreTransformErrorEventUploadPreTransformErrorEventData( FrozenDictionary rawData ) { @@ -338,8 +340,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static UploadPreTransformErrorEventIntersectionMember1Data FromRawUnchecked( + /// + public static UploadPreTransformErrorEventUploadPreTransformErrorEventData FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -347,30 +349,30 @@ IReadOnlyDictionary rawData } } -class UploadPreTransformErrorEventIntersectionMember1DataFromRaw - : IFromRawJson +class UploadPreTransformErrorEventUploadPreTransformErrorEventDataFromRaw + : IFromRawJson { /// - public UploadPreTransformErrorEventIntersectionMember1Data FromRawUnchecked( + public UploadPreTransformErrorEventUploadPreTransformErrorEventData FromRawUnchecked( IReadOnlyDictionary rawData - ) => UploadPreTransformErrorEventIntersectionMember1Data.FromRawUnchecked(rawData); + ) => UploadPreTransformErrorEventUploadPreTransformErrorEventData.FromRawUnchecked(rawData); } [JsonConverter( typeof(JsonModelConverter< - UploadPreTransformErrorEventIntersectionMember1DataTransformation, - UploadPreTransformErrorEventIntersectionMember1DataTransformationFromRaw + UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformation, + UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationFromRaw >) )] -public sealed record class UploadPreTransformErrorEventIntersectionMember1DataTransformation +public sealed record class UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformation : JsonModel { - public required UploadPreTransformErrorEventIntersectionMember1DataTransformationError Error + public required UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationError Error { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "error" ); } @@ -383,17 +385,17 @@ public override void Validate() this.Error.Validate(); } - public UploadPreTransformErrorEventIntersectionMember1DataTransformation() { } + public UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformation() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public UploadPreTransformErrorEventIntersectionMember1DataTransformation( - UploadPreTransformErrorEventIntersectionMember1DataTransformation uploadPreTransformErrorEventIntersectionMember1DataTransformation + public UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformation( + UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformation uploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformation ) - : base(uploadPreTransformErrorEventIntersectionMember1DataTransformation) { } + : base(uploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformation) { } #pragma warning restore CS8618 - public UploadPreTransformErrorEventIntersectionMember1DataTransformation( + public UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformation( IReadOnlyDictionary rawData ) { @@ -402,7 +404,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - UploadPreTransformErrorEventIntersectionMember1DataTransformation( + UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformation( FrozenDictionary rawData ) { @@ -410,8 +412,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static UploadPreTransformErrorEventIntersectionMember1DataTransformation FromRawUnchecked( + /// + public static UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -419,8 +421,8 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public UploadPreTransformErrorEventIntersectionMember1DataTransformation( - UploadPreTransformErrorEventIntersectionMember1DataTransformationError error + public UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformation( + UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationError error ) : this() { @@ -428,23 +430,25 @@ UploadPreTransformErrorEventIntersectionMember1DataTransformationError error } } -class UploadPreTransformErrorEventIntersectionMember1DataTransformationFromRaw - : IFromRawJson +class UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationFromRaw + : IFromRawJson { /// - public UploadPreTransformErrorEventIntersectionMember1DataTransformation FromRawUnchecked( + public UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformation FromRawUnchecked( IReadOnlyDictionary rawData ) => - UploadPreTransformErrorEventIntersectionMember1DataTransformation.FromRawUnchecked(rawData); + UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformation.FromRawUnchecked( + rawData + ); } [JsonConverter( typeof(JsonModelConverter< - UploadPreTransformErrorEventIntersectionMember1DataTransformationError, - UploadPreTransformErrorEventIntersectionMember1DataTransformationErrorFromRaw + UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationError, + UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationErrorFromRaw >) )] -public sealed record class UploadPreTransformErrorEventIntersectionMember1DataTransformationError +public sealed record class UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationError : JsonModel { /// @@ -466,17 +470,17 @@ public override void Validate() _ = this.Reason; } - public UploadPreTransformErrorEventIntersectionMember1DataTransformationError() { } + public UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationError() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public UploadPreTransformErrorEventIntersectionMember1DataTransformationError( - UploadPreTransformErrorEventIntersectionMember1DataTransformationError uploadPreTransformErrorEventIntersectionMember1DataTransformationError + public UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationError( + UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationError uploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationError ) - : base(uploadPreTransformErrorEventIntersectionMember1DataTransformationError) { } + : base(uploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationError) { } #pragma warning restore CS8618 - public UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + public UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationError( IReadOnlyDictionary rawData ) { @@ -485,7 +489,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - UploadPreTransformErrorEventIntersectionMember1DataTransformationError( + UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationError( FrozenDictionary rawData ) { @@ -493,8 +497,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static UploadPreTransformErrorEventIntersectionMember1DataTransformationError FromRawUnchecked( + /// + public static UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationError FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -502,32 +506,35 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public UploadPreTransformErrorEventIntersectionMember1DataTransformationError(string reason) + public UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationError( + string reason + ) : this() { this.Reason = reason; } } -class UploadPreTransformErrorEventIntersectionMember1DataTransformationErrorFromRaw - : IFromRawJson +class UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationErrorFromRaw + : IFromRawJson { /// - public UploadPreTransformErrorEventIntersectionMember1DataTransformationError FromRawUnchecked( + public UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationError FromRawUnchecked( IReadOnlyDictionary rawData ) => - UploadPreTransformErrorEventIntersectionMember1DataTransformationError.FromRawUnchecked( + UploadPreTransformErrorEventUploadPreTransformErrorEventDataTransformationError.FromRawUnchecked( rawData ); } [JsonConverter( typeof(JsonModelConverter< - UploadPreTransformErrorEventIntersectionMember1Request, - UploadPreTransformErrorEventIntersectionMember1RequestFromRaw + UploadPreTransformErrorEventUploadPreTransformErrorEventRequest, + UploadPreTransformErrorEventUploadPreTransformErrorEventRequestFromRaw >) )] -public sealed record class UploadPreTransformErrorEventIntersectionMember1Request : JsonModel +public sealed record class UploadPreTransformErrorEventUploadPreTransformErrorEventRequest + : JsonModel { /// /// The requested pre-transformation string. @@ -562,17 +569,17 @@ public override void Validate() _ = this.XRequestID; } - public UploadPreTransformErrorEventIntersectionMember1Request() { } + public UploadPreTransformErrorEventUploadPreTransformErrorEventRequest() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public UploadPreTransformErrorEventIntersectionMember1Request( - UploadPreTransformErrorEventIntersectionMember1Request uploadPreTransformErrorEventIntersectionMember1Request + public UploadPreTransformErrorEventUploadPreTransformErrorEventRequest( + UploadPreTransformErrorEventUploadPreTransformErrorEventRequest uploadPreTransformErrorEventUploadPreTransformErrorEventRequest ) - : base(uploadPreTransformErrorEventIntersectionMember1Request) { } + : base(uploadPreTransformErrorEventUploadPreTransformErrorEventRequest) { } #pragma warning restore CS8618 - public UploadPreTransformErrorEventIntersectionMember1Request( + public UploadPreTransformErrorEventUploadPreTransformErrorEventRequest( IReadOnlyDictionary rawData ) { @@ -581,7 +588,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - UploadPreTransformErrorEventIntersectionMember1Request( + UploadPreTransformErrorEventUploadPreTransformErrorEventRequest( FrozenDictionary rawData ) { @@ -589,8 +596,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static UploadPreTransformErrorEventIntersectionMember1Request FromRawUnchecked( + /// + public static UploadPreTransformErrorEventUploadPreTransformErrorEventRequest FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -598,11 +605,11 @@ IReadOnlyDictionary rawData } } -class UploadPreTransformErrorEventIntersectionMember1RequestFromRaw - : IFromRawJson +class UploadPreTransformErrorEventUploadPreTransformErrorEventRequestFromRaw + : IFromRawJson { /// - public UploadPreTransformErrorEventIntersectionMember1Request FromRawUnchecked( + public UploadPreTransformErrorEventUploadPreTransformErrorEventRequest FromRawUnchecked( IReadOnlyDictionary rawData - ) => UploadPreTransformErrorEventIntersectionMember1Request.FromRawUnchecked(rawData); + ) => UploadPreTransformErrorEventUploadPreTransformErrorEventRequest.FromRawUnchecked(rawData); } diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEvent.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEvent.cs index 11e7c70c..1b8e7f70 100644 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEvent.cs +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEvent.cs @@ -66,24 +66,24 @@ public required string Type /// /// Object containing details of a successful upload. /// - public required UploadPreTransformSuccessEventIntersectionMember1Data Data + public required UploadPreTransformSuccessEventUploadPreTransformSuccessEventData Data { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "data" ); } init { this._rawData.Set("data", value); } } - public required UploadPreTransformSuccessEventIntersectionMember1Request Request + public required UploadPreTransformSuccessEventUploadPreTransformSuccessEventRequest Request { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "request" ); } @@ -156,11 +156,11 @@ IReadOnlyDictionary rawData /// [JsonConverter( typeof(JsonModelConverter< - UploadPreTransformSuccessEventIntersectionMember1, - UploadPreTransformSuccessEventIntersectionMember1FromRaw + UploadPreTransformSuccessEventUploadPreTransformSuccessEvent, + UploadPreTransformSuccessEventUploadPreTransformSuccessEventFromRaw >) )] -public sealed record class UploadPreTransformSuccessEventIntersectionMember1 : JsonModel +public sealed record class UploadPreTransformSuccessEventUploadPreTransformSuccessEvent : JsonModel { /// /// Timestamp of when the event occurred in ISO8601 format. @@ -178,24 +178,24 @@ public sealed record class UploadPreTransformSuccessEventIntersectionMember1 : J /// /// Object containing details of a successful upload. /// - public required UploadPreTransformSuccessEventIntersectionMember1Data Data + public required UploadPreTransformSuccessEventUploadPreTransformSuccessEventData Data { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "data" ); } init { this._rawData.Set("data", value); } } - public required UploadPreTransformSuccessEventIntersectionMember1Request Request + public required UploadPreTransformSuccessEventUploadPreTransformSuccessEventRequest Request { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "request" ); } @@ -229,20 +229,20 @@ public override void Validate() } } - public UploadPreTransformSuccessEventIntersectionMember1() + public UploadPreTransformSuccessEventUploadPreTransformSuccessEvent() { this.Type = JsonSerializer.SerializeToElement("upload.pre-transform.success"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public UploadPreTransformSuccessEventIntersectionMember1( - UploadPreTransformSuccessEventIntersectionMember1 uploadPreTransformSuccessEventIntersectionMember1 + public UploadPreTransformSuccessEventUploadPreTransformSuccessEvent( + UploadPreTransformSuccessEventUploadPreTransformSuccessEvent uploadPreTransformSuccessEventUploadPreTransformSuccessEvent ) - : base(uploadPreTransformSuccessEventIntersectionMember1) { } + : base(uploadPreTransformSuccessEventUploadPreTransformSuccessEvent) { } #pragma warning restore CS8618 - public UploadPreTransformSuccessEventIntersectionMember1( + public UploadPreTransformSuccessEventUploadPreTransformSuccessEvent( IReadOnlyDictionary rawData ) { @@ -253,14 +253,16 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - UploadPreTransformSuccessEventIntersectionMember1(FrozenDictionary rawData) + UploadPreTransformSuccessEventUploadPreTransformSuccessEvent( + FrozenDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static UploadPreTransformSuccessEventIntersectionMember1 FromRawUnchecked( + /// + public static UploadPreTransformSuccessEventUploadPreTransformSuccessEvent FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -268,13 +270,13 @@ IReadOnlyDictionary rawData } } -class UploadPreTransformSuccessEventIntersectionMember1FromRaw - : IFromRawJson +class UploadPreTransformSuccessEventUploadPreTransformSuccessEventFromRaw + : IFromRawJson { /// - public UploadPreTransformSuccessEventIntersectionMember1 FromRawUnchecked( + public UploadPreTransformSuccessEventUploadPreTransformSuccessEvent FromRawUnchecked( IReadOnlyDictionary rawData - ) => UploadPreTransformSuccessEventIntersectionMember1.FromRawUnchecked(rawData); + ) => UploadPreTransformSuccessEventUploadPreTransformSuccessEvent.FromRawUnchecked(rawData); } /// @@ -282,11 +284,12 @@ IReadOnlyDictionary rawData /// [JsonConverter( typeof(JsonModelConverter< - UploadPreTransformSuccessEventIntersectionMember1Data, - UploadPreTransformSuccessEventIntersectionMember1DataFromRaw + UploadPreTransformSuccessEventUploadPreTransformSuccessEventData, + UploadPreTransformSuccessEventUploadPreTransformSuccessEventDataFromRaw >) )] -public sealed record class UploadPreTransformSuccessEventIntersectionMember1Data : JsonModel +public sealed record class UploadPreTransformSuccessEventUploadPreTransformSuccessEventData + : JsonModel { /// /// An array of tags assigned to the uploaded file by auto tagging. @@ -885,17 +888,17 @@ public override void Validate() _ = this.Width; } - public UploadPreTransformSuccessEventIntersectionMember1Data() { } + public UploadPreTransformSuccessEventUploadPreTransformSuccessEventData() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public UploadPreTransformSuccessEventIntersectionMember1Data( - UploadPreTransformSuccessEventIntersectionMember1Data uploadPreTransformSuccessEventIntersectionMember1Data + public UploadPreTransformSuccessEventUploadPreTransformSuccessEventData( + UploadPreTransformSuccessEventUploadPreTransformSuccessEventData uploadPreTransformSuccessEventUploadPreTransformSuccessEventData ) - : base(uploadPreTransformSuccessEventIntersectionMember1Data) { } + : base(uploadPreTransformSuccessEventUploadPreTransformSuccessEventData) { } #pragma warning restore CS8618 - public UploadPreTransformSuccessEventIntersectionMember1Data( + public UploadPreTransformSuccessEventUploadPreTransformSuccessEventData( IReadOnlyDictionary rawData ) { @@ -904,7 +907,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - UploadPreTransformSuccessEventIntersectionMember1Data( + UploadPreTransformSuccessEventUploadPreTransformSuccessEventData( FrozenDictionary rawData ) { @@ -912,8 +915,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static UploadPreTransformSuccessEventIntersectionMember1Data FromRawUnchecked( + /// + public static UploadPreTransformSuccessEventUploadPreTransformSuccessEventData FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -921,13 +924,13 @@ IReadOnlyDictionary rawData } } -class UploadPreTransformSuccessEventIntersectionMember1DataFromRaw - : IFromRawJson +class UploadPreTransformSuccessEventUploadPreTransformSuccessEventDataFromRaw + : IFromRawJson { /// - public UploadPreTransformSuccessEventIntersectionMember1Data FromRawUnchecked( + public UploadPreTransformSuccessEventUploadPreTransformSuccessEventData FromRawUnchecked( IReadOnlyDictionary rawData - ) => UploadPreTransformSuccessEventIntersectionMember1Data.FromRawUnchecked(rawData); + ) => UploadPreTransformSuccessEventUploadPreTransformSuccessEventData.FromRawUnchecked(rawData); } /// @@ -3309,11 +3312,12 @@ public VersionInfo FromRawUnchecked(IReadOnlyDictionary raw [JsonConverter( typeof(JsonModelConverter< - UploadPreTransformSuccessEventIntersectionMember1Request, - UploadPreTransformSuccessEventIntersectionMember1RequestFromRaw + UploadPreTransformSuccessEventUploadPreTransformSuccessEventRequest, + UploadPreTransformSuccessEventUploadPreTransformSuccessEventRequestFromRaw >) )] -public sealed record class UploadPreTransformSuccessEventIntersectionMember1Request : JsonModel +public sealed record class UploadPreTransformSuccessEventUploadPreTransformSuccessEventRequest + : JsonModel { /// /// The requested pre-transformation string. @@ -3348,17 +3352,17 @@ public override void Validate() _ = this.XRequestID; } - public UploadPreTransformSuccessEventIntersectionMember1Request() { } + public UploadPreTransformSuccessEventUploadPreTransformSuccessEventRequest() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public UploadPreTransformSuccessEventIntersectionMember1Request( - UploadPreTransformSuccessEventIntersectionMember1Request uploadPreTransformSuccessEventIntersectionMember1Request + public UploadPreTransformSuccessEventUploadPreTransformSuccessEventRequest( + UploadPreTransformSuccessEventUploadPreTransformSuccessEventRequest uploadPreTransformSuccessEventUploadPreTransformSuccessEventRequest ) - : base(uploadPreTransformSuccessEventIntersectionMember1Request) { } + : base(uploadPreTransformSuccessEventUploadPreTransformSuccessEventRequest) { } #pragma warning restore CS8618 - public UploadPreTransformSuccessEventIntersectionMember1Request( + public UploadPreTransformSuccessEventUploadPreTransformSuccessEventRequest( IReadOnlyDictionary rawData ) { @@ -3367,7 +3371,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - UploadPreTransformSuccessEventIntersectionMember1Request( + UploadPreTransformSuccessEventUploadPreTransformSuccessEventRequest( FrozenDictionary rawData ) { @@ -3375,8 +3379,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static UploadPreTransformSuccessEventIntersectionMember1Request FromRawUnchecked( + /// + public static UploadPreTransformSuccessEventUploadPreTransformSuccessEventRequest FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -3384,11 +3388,14 @@ IReadOnlyDictionary rawData } } -class UploadPreTransformSuccessEventIntersectionMember1RequestFromRaw - : IFromRawJson +class UploadPreTransformSuccessEventUploadPreTransformSuccessEventRequestFromRaw + : IFromRawJson { /// - public UploadPreTransformSuccessEventIntersectionMember1Request FromRawUnchecked( + public UploadPreTransformSuccessEventUploadPreTransformSuccessEventRequest FromRawUnchecked( IReadOnlyDictionary rawData - ) => UploadPreTransformSuccessEventIntersectionMember1Request.FromRawUnchecked(rawData); + ) => + UploadPreTransformSuccessEventUploadPreTransformSuccessEventRequest.FromRawUnchecked( + rawData + ); } diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEvent.cs b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEvent.cs index 35ad026b..861649a2 100644 --- a/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEvent.cs +++ b/src/Imagekit/Models/Webhooks/VideoTransformationAcceptedEvent.cs @@ -62,12 +62,12 @@ public required string Type init { this._rawData.Set("created_at", value); } } - public required VideoTransformationAcceptedEventIntersectionMember1Data Data + public required VideoTransformationAcceptedEventVideoTransformationAcceptedEventData Data { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "data" ); } @@ -77,12 +77,12 @@ public required VideoTransformationAcceptedEventIntersectionMember1Data Data /// /// Information about the original request that triggered the video transformation. /// - public required VideoTransformationAcceptedEventIntersectionMember1Request Request + public required VideoTransformationAcceptedEventVideoTransformationAcceptedEventRequest Request { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "request" ); } @@ -155,11 +155,12 @@ IReadOnlyDictionary rawData /// [JsonConverter( typeof(JsonModelConverter< - VideoTransformationAcceptedEventIntersectionMember1, - VideoTransformationAcceptedEventIntersectionMember1FromRaw + VideoTransformationAcceptedEventVideoTransformationAcceptedEvent, + VideoTransformationAcceptedEventVideoTransformationAcceptedEventFromRaw >) )] -public sealed record class VideoTransformationAcceptedEventIntersectionMember1 : JsonModel +public sealed record class VideoTransformationAcceptedEventVideoTransformationAcceptedEvent + : JsonModel { /// /// Timestamp when the event was created in ISO8601 format. @@ -174,12 +175,12 @@ public sealed record class VideoTransformationAcceptedEventIntersectionMember1 : init { this._rawData.Set("created_at", value); } } - public required VideoTransformationAcceptedEventIntersectionMember1Data Data + public required VideoTransformationAcceptedEventVideoTransformationAcceptedEventData Data { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "data" ); } @@ -189,12 +190,12 @@ public required VideoTransformationAcceptedEventIntersectionMember1Data Data /// /// Information about the original request that triggered the video transformation. /// - public required VideoTransformationAcceptedEventIntersectionMember1Request Request + public required VideoTransformationAcceptedEventVideoTransformationAcceptedEventRequest Request { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "request" ); } @@ -228,20 +229,20 @@ public override void Validate() } } - public VideoTransformationAcceptedEventIntersectionMember1() + public VideoTransformationAcceptedEventVideoTransformationAcceptedEvent() { this.Type = JsonSerializer.SerializeToElement("video.transformation.accepted"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public VideoTransformationAcceptedEventIntersectionMember1( - VideoTransformationAcceptedEventIntersectionMember1 videoTransformationAcceptedEventIntersectionMember1 + public VideoTransformationAcceptedEventVideoTransformationAcceptedEvent( + VideoTransformationAcceptedEventVideoTransformationAcceptedEvent videoTransformationAcceptedEventVideoTransformationAcceptedEvent ) - : base(videoTransformationAcceptedEventIntersectionMember1) { } + : base(videoTransformationAcceptedEventVideoTransformationAcceptedEvent) { } #pragma warning restore CS8618 - public VideoTransformationAcceptedEventIntersectionMember1( + public VideoTransformationAcceptedEventVideoTransformationAcceptedEvent( IReadOnlyDictionary rawData ) { @@ -252,7 +253,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - VideoTransformationAcceptedEventIntersectionMember1( + VideoTransformationAcceptedEventVideoTransformationAcceptedEvent( FrozenDictionary rawData ) { @@ -260,8 +261,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static VideoTransformationAcceptedEventIntersectionMember1 FromRawUnchecked( + /// + public static VideoTransformationAcceptedEventVideoTransformationAcceptedEvent FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -269,22 +270,23 @@ IReadOnlyDictionary rawData } } -class VideoTransformationAcceptedEventIntersectionMember1FromRaw - : IFromRawJson +class VideoTransformationAcceptedEventVideoTransformationAcceptedEventFromRaw + : IFromRawJson { /// - public VideoTransformationAcceptedEventIntersectionMember1 FromRawUnchecked( + public VideoTransformationAcceptedEventVideoTransformationAcceptedEvent FromRawUnchecked( IReadOnlyDictionary rawData - ) => VideoTransformationAcceptedEventIntersectionMember1.FromRawUnchecked(rawData); + ) => VideoTransformationAcceptedEventVideoTransformationAcceptedEvent.FromRawUnchecked(rawData); } [JsonConverter( typeof(JsonModelConverter< - VideoTransformationAcceptedEventIntersectionMember1Data, - VideoTransformationAcceptedEventIntersectionMember1DataFromRaw + VideoTransformationAcceptedEventVideoTransformationAcceptedEventData, + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataFromRaw >) )] -public sealed record class VideoTransformationAcceptedEventIntersectionMember1Data : JsonModel +public sealed record class VideoTransformationAcceptedEventVideoTransformationAcceptedEventData + : JsonModel { /// /// Information about the source video asset being transformed. @@ -302,12 +304,12 @@ public required Asset Asset /// /// Base information about a video transformation request. /// - public required VideoTransformationAcceptedEventIntersectionMember1DataTransformation Transformation + public required VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformation Transformation { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "transformation" ); } @@ -321,17 +323,17 @@ public override void Validate() this.Transformation.Validate(); } - public VideoTransformationAcceptedEventIntersectionMember1Data() { } + public VideoTransformationAcceptedEventVideoTransformationAcceptedEventData() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public VideoTransformationAcceptedEventIntersectionMember1Data( - VideoTransformationAcceptedEventIntersectionMember1Data videoTransformationAcceptedEventIntersectionMember1Data + public VideoTransformationAcceptedEventVideoTransformationAcceptedEventData( + VideoTransformationAcceptedEventVideoTransformationAcceptedEventData videoTransformationAcceptedEventVideoTransformationAcceptedEventData ) - : base(videoTransformationAcceptedEventIntersectionMember1Data) { } + : base(videoTransformationAcceptedEventVideoTransformationAcceptedEventData) { } #pragma warning restore CS8618 - public VideoTransformationAcceptedEventIntersectionMember1Data( + public VideoTransformationAcceptedEventVideoTransformationAcceptedEventData( IReadOnlyDictionary rawData ) { @@ -340,7 +342,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - VideoTransformationAcceptedEventIntersectionMember1Data( + VideoTransformationAcceptedEventVideoTransformationAcceptedEventData( FrozenDictionary rawData ) { @@ -348,8 +350,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static VideoTransformationAcceptedEventIntersectionMember1Data FromRawUnchecked( + /// + public static VideoTransformationAcceptedEventVideoTransformationAcceptedEventData FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -357,13 +359,16 @@ IReadOnlyDictionary rawData } } -class VideoTransformationAcceptedEventIntersectionMember1DataFromRaw - : IFromRawJson +class VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataFromRaw + : IFromRawJson { /// - public VideoTransformationAcceptedEventIntersectionMember1Data FromRawUnchecked( + public VideoTransformationAcceptedEventVideoTransformationAcceptedEventData FromRawUnchecked( IReadOnlyDictionary rawData - ) => VideoTransformationAcceptedEventIntersectionMember1Data.FromRawUnchecked(rawData); + ) => + VideoTransformationAcceptedEventVideoTransformationAcceptedEventData.FromRawUnchecked( + rawData + ); } /// @@ -438,11 +443,11 @@ public Asset FromRawUnchecked(IReadOnlyDictionary rawData) /// [JsonConverter( typeof(JsonModelConverter< - VideoTransformationAcceptedEventIntersectionMember1DataTransformation, - VideoTransformationAcceptedEventIntersectionMember1DataTransformationFromRaw + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformation, + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationFromRaw >) )] -public sealed record class VideoTransformationAcceptedEventIntersectionMember1DataTransformation +public sealed record class VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformation : JsonModel { /// @@ -452,7 +457,7 @@ public sealed record class VideoTransformationAcceptedEventIntersectionMember1Da /// public required ApiEnum< string, - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType > Type { get @@ -461,7 +466,7 @@ public required ApiEnum< return this._rawData.GetNotNullClass< ApiEnum< string, - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType > >("type"); } @@ -496,17 +501,18 @@ public override void Validate() this.Options?.Validate(); } - public VideoTransformationAcceptedEventIntersectionMember1DataTransformation() { } + public VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformation() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public VideoTransformationAcceptedEventIntersectionMember1DataTransformation( - VideoTransformationAcceptedEventIntersectionMember1DataTransformation videoTransformationAcceptedEventIntersectionMember1DataTransformation + public VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformation( + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformation videoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformation ) - : base(videoTransformationAcceptedEventIntersectionMember1DataTransformation) { } + : base(videoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformation) + { } #pragma warning restore CS8618 - public VideoTransformationAcceptedEventIntersectionMember1DataTransformation( + public VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformation( IReadOnlyDictionary rawData ) { @@ -515,7 +521,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - VideoTransformationAcceptedEventIntersectionMember1DataTransformation( + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformation( FrozenDictionary rawData ) { @@ -523,8 +529,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static VideoTransformationAcceptedEventIntersectionMember1DataTransformation FromRawUnchecked( + /// + public static VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -532,10 +538,10 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public VideoTransformationAcceptedEventIntersectionMember1DataTransformation( + public VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformation( ApiEnum< string, - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType > type ) : this() @@ -544,14 +550,14 @@ public VideoTransformationAcceptedEventIntersectionMember1DataTransformation( } } -class VideoTransformationAcceptedEventIntersectionMember1DataTransformationFromRaw - : IFromRawJson +class VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationFromRaw + : IFromRawJson { /// - public VideoTransformationAcceptedEventIntersectionMember1DataTransformation FromRawUnchecked( + public VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformation FromRawUnchecked( IReadOnlyDictionary rawData ) => - VideoTransformationAcceptedEventIntersectionMember1DataTransformation.FromRawUnchecked( + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformation.FromRawUnchecked( rawData ); } @@ -562,19 +568,19 @@ IReadOnlyDictionary rawData /// format - `video-thumbnail`: Generate thumbnail image from video /// [JsonConverter( - typeof(VideoTransformationAcceptedEventIntersectionMember1DataTransformationTypeConverter) + typeof(VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationTypeConverter) )] -public enum VideoTransformationAcceptedEventIntersectionMember1DataTransformationType +public enum VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType { VideoTransformation, GifToVideo, VideoThumbnail, } -sealed class VideoTransformationAcceptedEventIntersectionMember1DataTransformationTypeConverter - : JsonConverter +sealed class VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationTypeConverter + : JsonConverter { - public override VideoTransformationAcceptedEventIntersectionMember1DataTransformationType Read( + public override VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -583,18 +589,21 @@ JsonSerializerOptions options return JsonSerializer.Deserialize(ref reader, options) switch { "video-transformation" => - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType.VideoTransformation, "gif-to-video" => - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.GifToVideo, + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType.GifToVideo, "video-thumbnail" => - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoThumbnail, - _ => (VideoTransformationAcceptedEventIntersectionMember1DataTransformationType)(-1), + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType.VideoThumbnail, + _ => + (VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType)( + -1 + ), }; } public override void Write( Utf8JsonWriter writer, - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType value, + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType value, JsonSerializerOptions options ) { @@ -602,11 +611,11 @@ JsonSerializerOptions options writer, value switch { - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoTransformation => + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType.VideoTransformation => "video-transformation", - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.GifToVideo => + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType.GifToVideo => "gif-to-video", - VideoTransformationAcceptedEventIntersectionMember1DataTransformationType.VideoThumbnail => + VideoTransformationAcceptedEventVideoTransformationAcceptedEventDataTransformationType.VideoThumbnail => "video-thumbnail", _ => throw new ImageKitInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) @@ -1023,11 +1032,12 @@ JsonSerializerOptions options /// [JsonConverter( typeof(JsonModelConverter< - VideoTransformationAcceptedEventIntersectionMember1Request, - VideoTransformationAcceptedEventIntersectionMember1RequestFromRaw + VideoTransformationAcceptedEventVideoTransformationAcceptedEventRequest, + VideoTransformationAcceptedEventVideoTransformationAcceptedEventRequestFromRaw >) )] -public sealed record class VideoTransformationAcceptedEventIntersectionMember1Request : JsonModel +public sealed record class VideoTransformationAcceptedEventVideoTransformationAcceptedEventRequest + : JsonModel { /// /// Full URL of the transformation request that was submitted. @@ -1084,17 +1094,17 @@ public override void Validate() _ = this.UserAgent; } - public VideoTransformationAcceptedEventIntersectionMember1Request() { } + public VideoTransformationAcceptedEventVideoTransformationAcceptedEventRequest() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public VideoTransformationAcceptedEventIntersectionMember1Request( - VideoTransformationAcceptedEventIntersectionMember1Request videoTransformationAcceptedEventIntersectionMember1Request + public VideoTransformationAcceptedEventVideoTransformationAcceptedEventRequest( + VideoTransformationAcceptedEventVideoTransformationAcceptedEventRequest videoTransformationAcceptedEventVideoTransformationAcceptedEventRequest ) - : base(videoTransformationAcceptedEventIntersectionMember1Request) { } + : base(videoTransformationAcceptedEventVideoTransformationAcceptedEventRequest) { } #pragma warning restore CS8618 - public VideoTransformationAcceptedEventIntersectionMember1Request( + public VideoTransformationAcceptedEventVideoTransformationAcceptedEventRequest( IReadOnlyDictionary rawData ) { @@ -1103,7 +1113,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - VideoTransformationAcceptedEventIntersectionMember1Request( + VideoTransformationAcceptedEventVideoTransformationAcceptedEventRequest( FrozenDictionary rawData ) { @@ -1111,8 +1121,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static VideoTransformationAcceptedEventIntersectionMember1Request FromRawUnchecked( + /// + public static VideoTransformationAcceptedEventVideoTransformationAcceptedEventRequest FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -1120,11 +1130,14 @@ IReadOnlyDictionary rawData } } -class VideoTransformationAcceptedEventIntersectionMember1RequestFromRaw - : IFromRawJson +class VideoTransformationAcceptedEventVideoTransformationAcceptedEventRequestFromRaw + : IFromRawJson { /// - public VideoTransformationAcceptedEventIntersectionMember1Request FromRawUnchecked( + public VideoTransformationAcceptedEventVideoTransformationAcceptedEventRequest FromRawUnchecked( IReadOnlyDictionary rawData - ) => VideoTransformationAcceptedEventIntersectionMember1Request.FromRawUnchecked(rawData); + ) => + VideoTransformationAcceptedEventVideoTransformationAcceptedEventRequest.FromRawUnchecked( + rawData + ); } diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEvent.cs b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEvent.cs index df2dbb7e..8ffa0ff4 100644 --- a/src/Imagekit/Models/Webhooks/VideoTransformationErrorEvent.cs +++ b/src/Imagekit/Models/Webhooks/VideoTransformationErrorEvent.cs @@ -60,12 +60,12 @@ public required string Type init { this._rawData.Set("created_at", value); } } - public required VideoTransformationErrorEventIntersectionMember1Data Data + public required VideoTransformationErrorEventVideoTransformationErrorEventData Data { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "data" ); } @@ -75,12 +75,12 @@ public required VideoTransformationErrorEventIntersectionMember1Data Data /// /// Information about the original request that triggered the video transformation. /// - public required VideoTransformationErrorEventIntersectionMember1Request Request + public required VideoTransformationErrorEventVideoTransformationErrorEventRequest Request { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "request" ); } @@ -149,11 +149,11 @@ IReadOnlyDictionary rawData /// [JsonConverter( typeof(JsonModelConverter< - VideoTransformationErrorEventIntersectionMember1, - VideoTransformationErrorEventIntersectionMember1FromRaw + VideoTransformationErrorEventVideoTransformationErrorEvent, + VideoTransformationErrorEventVideoTransformationErrorEventFromRaw >) )] -public sealed record class VideoTransformationErrorEventIntersectionMember1 : JsonModel +public sealed record class VideoTransformationErrorEventVideoTransformationErrorEvent : JsonModel { /// /// Timestamp when the event was created in ISO8601 format. @@ -168,12 +168,12 @@ public sealed record class VideoTransformationErrorEventIntersectionMember1 : Js init { this._rawData.Set("created_at", value); } } - public required VideoTransformationErrorEventIntersectionMember1Data Data + public required VideoTransformationErrorEventVideoTransformationErrorEventData Data { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "data" ); } @@ -183,12 +183,12 @@ public required VideoTransformationErrorEventIntersectionMember1Data Data /// /// Information about the original request that triggered the video transformation. /// - public required VideoTransformationErrorEventIntersectionMember1Request Request + public required VideoTransformationErrorEventVideoTransformationErrorEventRequest Request { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "request" ); } @@ -222,20 +222,20 @@ public override void Validate() } } - public VideoTransformationErrorEventIntersectionMember1() + public VideoTransformationErrorEventVideoTransformationErrorEvent() { this.Type = JsonSerializer.SerializeToElement("video.transformation.error"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public VideoTransformationErrorEventIntersectionMember1( - VideoTransformationErrorEventIntersectionMember1 videoTransformationErrorEventIntersectionMember1 + public VideoTransformationErrorEventVideoTransformationErrorEvent( + VideoTransformationErrorEventVideoTransformationErrorEvent videoTransformationErrorEventVideoTransformationErrorEvent ) - : base(videoTransformationErrorEventIntersectionMember1) { } + : base(videoTransformationErrorEventVideoTransformationErrorEvent) { } #pragma warning restore CS8618 - public VideoTransformationErrorEventIntersectionMember1( + public VideoTransformationErrorEventVideoTransformationErrorEvent( IReadOnlyDictionary rawData ) { @@ -246,14 +246,16 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - VideoTransformationErrorEventIntersectionMember1(FrozenDictionary rawData) + VideoTransformationErrorEventVideoTransformationErrorEvent( + FrozenDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static VideoTransformationErrorEventIntersectionMember1 FromRawUnchecked( + /// + public static VideoTransformationErrorEventVideoTransformationErrorEvent FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -261,44 +263,45 @@ IReadOnlyDictionary rawData } } -class VideoTransformationErrorEventIntersectionMember1FromRaw - : IFromRawJson +class VideoTransformationErrorEventVideoTransformationErrorEventFromRaw + : IFromRawJson { /// - public VideoTransformationErrorEventIntersectionMember1 FromRawUnchecked( + public VideoTransformationErrorEventVideoTransformationErrorEvent FromRawUnchecked( IReadOnlyDictionary rawData - ) => VideoTransformationErrorEventIntersectionMember1.FromRawUnchecked(rawData); + ) => VideoTransformationErrorEventVideoTransformationErrorEvent.FromRawUnchecked(rawData); } [JsonConverter( typeof(JsonModelConverter< - VideoTransformationErrorEventIntersectionMember1Data, - VideoTransformationErrorEventIntersectionMember1DataFromRaw + VideoTransformationErrorEventVideoTransformationErrorEventData, + VideoTransformationErrorEventVideoTransformationErrorEventDataFromRaw >) )] -public sealed record class VideoTransformationErrorEventIntersectionMember1Data : JsonModel +public sealed record class VideoTransformationErrorEventVideoTransformationErrorEventData + : JsonModel { /// /// Information about the source video asset being transformed. /// - public required VideoTransformationErrorEventIntersectionMember1DataAsset Asset + public required VideoTransformationErrorEventVideoTransformationErrorEventDataAsset Asset { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "asset" ); } init { this._rawData.Set("asset", value); } } - public required VideoTransformationErrorEventIntersectionMember1DataTransformation Transformation + public required VideoTransformationErrorEventVideoTransformationErrorEventDataTransformation Transformation { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "transformation" ); } @@ -312,17 +315,17 @@ public override void Validate() this.Transformation.Validate(); } - public VideoTransformationErrorEventIntersectionMember1Data() { } + public VideoTransformationErrorEventVideoTransformationErrorEventData() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public VideoTransformationErrorEventIntersectionMember1Data( - VideoTransformationErrorEventIntersectionMember1Data videoTransformationErrorEventIntersectionMember1Data + public VideoTransformationErrorEventVideoTransformationErrorEventData( + VideoTransformationErrorEventVideoTransformationErrorEventData videoTransformationErrorEventVideoTransformationErrorEventData ) - : base(videoTransformationErrorEventIntersectionMember1Data) { } + : base(videoTransformationErrorEventVideoTransformationErrorEventData) { } #pragma warning restore CS8618 - public VideoTransformationErrorEventIntersectionMember1Data( + public VideoTransformationErrorEventVideoTransformationErrorEventData( IReadOnlyDictionary rawData ) { @@ -331,7 +334,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - VideoTransformationErrorEventIntersectionMember1Data( + VideoTransformationErrorEventVideoTransformationErrorEventData( FrozenDictionary rawData ) { @@ -339,8 +342,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static VideoTransformationErrorEventIntersectionMember1Data FromRawUnchecked( + /// + public static VideoTransformationErrorEventVideoTransformationErrorEventData FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -348,13 +351,13 @@ IReadOnlyDictionary rawData } } -class VideoTransformationErrorEventIntersectionMember1DataFromRaw - : IFromRawJson +class VideoTransformationErrorEventVideoTransformationErrorEventDataFromRaw + : IFromRawJson { /// - public VideoTransformationErrorEventIntersectionMember1Data FromRawUnchecked( + public VideoTransformationErrorEventVideoTransformationErrorEventData FromRawUnchecked( IReadOnlyDictionary rawData - ) => VideoTransformationErrorEventIntersectionMember1Data.FromRawUnchecked(rawData); + ) => VideoTransformationErrorEventVideoTransformationErrorEventData.FromRawUnchecked(rawData); } /// @@ -362,11 +365,12 @@ IReadOnlyDictionary rawData /// [JsonConverter( typeof(JsonModelConverter< - VideoTransformationErrorEventIntersectionMember1DataAsset, - VideoTransformationErrorEventIntersectionMember1DataAssetFromRaw + VideoTransformationErrorEventVideoTransformationErrorEventDataAsset, + VideoTransformationErrorEventVideoTransformationErrorEventDataAssetFromRaw >) )] -public sealed record class VideoTransformationErrorEventIntersectionMember1DataAsset : JsonModel +public sealed record class VideoTransformationErrorEventVideoTransformationErrorEventDataAsset + : JsonModel { /// /// URL to download or access the source video file. @@ -387,17 +391,17 @@ public override void Validate() _ = this.Url; } - public VideoTransformationErrorEventIntersectionMember1DataAsset() { } + public VideoTransformationErrorEventVideoTransformationErrorEventDataAsset() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public VideoTransformationErrorEventIntersectionMember1DataAsset( - VideoTransformationErrorEventIntersectionMember1DataAsset videoTransformationErrorEventIntersectionMember1DataAsset + public VideoTransformationErrorEventVideoTransformationErrorEventDataAsset( + VideoTransformationErrorEventVideoTransformationErrorEventDataAsset videoTransformationErrorEventVideoTransformationErrorEventDataAsset ) - : base(videoTransformationErrorEventIntersectionMember1DataAsset) { } + : base(videoTransformationErrorEventVideoTransformationErrorEventDataAsset) { } #pragma warning restore CS8618 - public VideoTransformationErrorEventIntersectionMember1DataAsset( + public VideoTransformationErrorEventVideoTransformationErrorEventDataAsset( IReadOnlyDictionary rawData ) { @@ -406,7 +410,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - VideoTransformationErrorEventIntersectionMember1DataAsset( + VideoTransformationErrorEventVideoTransformationErrorEventDataAsset( FrozenDictionary rawData ) { @@ -414,8 +418,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static VideoTransformationErrorEventIntersectionMember1DataAsset FromRawUnchecked( + /// + public static VideoTransformationErrorEventVideoTransformationErrorEventDataAsset FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -423,29 +427,32 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public VideoTransformationErrorEventIntersectionMember1DataAsset(string url) + public VideoTransformationErrorEventVideoTransformationErrorEventDataAsset(string url) : this() { this.Url = url; } } -class VideoTransformationErrorEventIntersectionMember1DataAssetFromRaw - : IFromRawJson +class VideoTransformationErrorEventVideoTransformationErrorEventDataAssetFromRaw + : IFromRawJson { /// - public VideoTransformationErrorEventIntersectionMember1DataAsset FromRawUnchecked( + public VideoTransformationErrorEventVideoTransformationErrorEventDataAsset FromRawUnchecked( IReadOnlyDictionary rawData - ) => VideoTransformationErrorEventIntersectionMember1DataAsset.FromRawUnchecked(rawData); + ) => + VideoTransformationErrorEventVideoTransformationErrorEventDataAsset.FromRawUnchecked( + rawData + ); } [JsonConverter( typeof(JsonModelConverter< - VideoTransformationErrorEventIntersectionMember1DataTransformation, - VideoTransformationErrorEventIntersectionMember1DataTransformationFromRaw + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformation, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationFromRaw >) )] -public sealed record class VideoTransformationErrorEventIntersectionMember1DataTransformation +public sealed record class VideoTransformationErrorEventVideoTransformationErrorEventDataTransformation : JsonModel { /// @@ -455,7 +462,7 @@ public sealed record class VideoTransformationErrorEventIntersectionMember1DataT /// public required ApiEnum< string, - VideoTransformationErrorEventIntersectionMember1DataTransformationType + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType > Type { get @@ -464,7 +471,7 @@ public required ApiEnum< return this._rawData.GetNotNullClass< ApiEnum< string, - VideoTransformationErrorEventIntersectionMember1DataTransformationType + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType > >("type"); } @@ -474,12 +481,12 @@ public required ApiEnum< /// /// Details about the transformation error. /// - public VideoTransformationErrorEventIntersectionMember1DataTransformationError? Error + public VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationError? Error { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "error" ); } @@ -497,12 +504,12 @@ public VideoTransformationErrorEventIntersectionMember1DataTransformationError? /// /// Configuration options for video transformations. /// - public VideoTransformationErrorEventIntersectionMember1DataTransformationOptions? Options + public VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptions? Options { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "options" ); } @@ -525,17 +532,17 @@ public override void Validate() this.Options?.Validate(); } - public VideoTransformationErrorEventIntersectionMember1DataTransformation() { } + public VideoTransformationErrorEventVideoTransformationErrorEventDataTransformation() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public VideoTransformationErrorEventIntersectionMember1DataTransformation( - VideoTransformationErrorEventIntersectionMember1DataTransformation videoTransformationErrorEventIntersectionMember1DataTransformation + public VideoTransformationErrorEventVideoTransformationErrorEventDataTransformation( + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformation videoTransformationErrorEventVideoTransformationErrorEventDataTransformation ) - : base(videoTransformationErrorEventIntersectionMember1DataTransformation) { } + : base(videoTransformationErrorEventVideoTransformationErrorEventDataTransformation) { } #pragma warning restore CS8618 - public VideoTransformationErrorEventIntersectionMember1DataTransformation( + public VideoTransformationErrorEventVideoTransformationErrorEventDataTransformation( IReadOnlyDictionary rawData ) { @@ -544,7 +551,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - VideoTransformationErrorEventIntersectionMember1DataTransformation( + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformation( FrozenDictionary rawData ) { @@ -552,8 +559,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static VideoTransformationErrorEventIntersectionMember1DataTransformation FromRawUnchecked( + /// + public static VideoTransformationErrorEventVideoTransformationErrorEventDataTransformation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -561,8 +568,11 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public VideoTransformationErrorEventIntersectionMember1DataTransformation( - ApiEnum type + public VideoTransformationErrorEventVideoTransformationErrorEventDataTransformation( + ApiEnum< + string, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType + > type ) : this() { @@ -570,14 +580,14 @@ ApiEnum +class VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationFromRaw + : IFromRawJson { /// - public VideoTransformationErrorEventIntersectionMember1DataTransformation FromRawUnchecked( + public VideoTransformationErrorEventVideoTransformationErrorEventDataTransformation FromRawUnchecked( IReadOnlyDictionary rawData ) => - VideoTransformationErrorEventIntersectionMember1DataTransformation.FromRawUnchecked( + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformation.FromRawUnchecked( rawData ); } @@ -588,19 +598,19 @@ IReadOnlyDictionary rawData /// format - `video-thumbnail`: Generate thumbnail image from video /// [JsonConverter( - typeof(VideoTransformationErrorEventIntersectionMember1DataTransformationTypeConverter) + typeof(VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationTypeConverter) )] -public enum VideoTransformationErrorEventIntersectionMember1DataTransformationType +public enum VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType { VideoTransformation, GifToVideo, VideoThumbnail, } -sealed class VideoTransformationErrorEventIntersectionMember1DataTransformationTypeConverter - : JsonConverter +sealed class VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationTypeConverter + : JsonConverter { - public override VideoTransformationErrorEventIntersectionMember1DataTransformationType Read( + public override VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -609,18 +619,20 @@ JsonSerializerOptions options return JsonSerializer.Deserialize(ref reader, options) switch { "video-transformation" => - VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType.VideoTransformation, "gif-to-video" => - VideoTransformationErrorEventIntersectionMember1DataTransformationType.GifToVideo, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType.GifToVideo, "video-thumbnail" => - VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoThumbnail, - _ => (VideoTransformationErrorEventIntersectionMember1DataTransformationType)(-1), + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType.VideoThumbnail, + _ => (VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType)( + -1 + ), }; } public override void Write( Utf8JsonWriter writer, - VideoTransformationErrorEventIntersectionMember1DataTransformationType value, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType value, JsonSerializerOptions options ) { @@ -628,11 +640,11 @@ JsonSerializerOptions options writer, value switch { - VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoTransformation => + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType.VideoTransformation => "video-transformation", - VideoTransformationErrorEventIntersectionMember1DataTransformationType.GifToVideo => + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType.GifToVideo => "gif-to-video", - VideoTransformationErrorEventIntersectionMember1DataTransformationType.VideoThumbnail => + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationType.VideoThumbnail => "video-thumbnail", _ => throw new ImageKitInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) @@ -648,11 +660,11 @@ JsonSerializerOptions options /// [JsonConverter( typeof(JsonModelConverter< - VideoTransformationErrorEventIntersectionMember1DataTransformationError, - VideoTransformationErrorEventIntersectionMember1DataTransformationErrorFromRaw + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationError, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationErrorFromRaw >) )] -public sealed record class VideoTransformationErrorEventIntersectionMember1DataTransformationError +public sealed record class VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationError : JsonModel { /// @@ -676,17 +688,18 @@ public override void Validate() this.Reason.Validate(); } - public VideoTransformationErrorEventIntersectionMember1DataTransformationError() { } + public VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationError() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public VideoTransformationErrorEventIntersectionMember1DataTransformationError( - VideoTransformationErrorEventIntersectionMember1DataTransformationError videoTransformationErrorEventIntersectionMember1DataTransformationError + public VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationError( + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationError videoTransformationErrorEventVideoTransformationErrorEventDataTransformationError ) - : base(videoTransformationErrorEventIntersectionMember1DataTransformationError) { } + : base(videoTransformationErrorEventVideoTransformationErrorEventDataTransformationError) + { } #pragma warning restore CS8618 - public VideoTransformationErrorEventIntersectionMember1DataTransformationError( + public VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationError( IReadOnlyDictionary rawData ) { @@ -695,7 +708,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - VideoTransformationErrorEventIntersectionMember1DataTransformationError( + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationError( FrozenDictionary rawData ) { @@ -703,8 +716,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static VideoTransformationErrorEventIntersectionMember1DataTransformationError FromRawUnchecked( + /// + public static VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationError FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -712,7 +725,7 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public VideoTransformationErrorEventIntersectionMember1DataTransformationError( + public VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationError( ApiEnum reason ) : this() @@ -721,14 +734,14 @@ ApiEnum reason } } -class VideoTransformationErrorEventIntersectionMember1DataTransformationErrorFromRaw - : IFromRawJson +class VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationErrorFromRaw + : IFromRawJson { /// - public VideoTransformationErrorEventIntersectionMember1DataTransformationError FromRawUnchecked( + public VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationError FromRawUnchecked( IReadOnlyDictionary rawData ) => - VideoTransformationErrorEventIntersectionMember1DataTransformationError.FromRawUnchecked( + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationError.FromRawUnchecked( rawData ); } @@ -786,11 +799,11 @@ public override void Write(Utf8JsonWriter writer, Reason value, JsonSerializerOp /// [JsonConverter( typeof(JsonModelConverter< - VideoTransformationErrorEventIntersectionMember1DataTransformationOptions, - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFromRaw + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptions, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFromRaw >) )] -public sealed record class VideoTransformationErrorEventIntersectionMember1DataTransformationOptions +public sealed record class VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptions : JsonModel { /// @@ -798,7 +811,7 @@ public sealed record class VideoTransformationErrorEventIntersectionMember1DataT /// public ApiEnum< string, - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec >? AudioCodec { get @@ -807,7 +820,7 @@ public ApiEnum< return this._rawData.GetNullableClass< ApiEnum< string, - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec > >("audio_codec"); } @@ -848,7 +861,7 @@ public bool? AutoRotate /// public ApiEnum< string, - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat >? Format { get @@ -857,7 +870,7 @@ public ApiEnum< return this._rawData.GetNullableClass< ApiEnum< string, - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat > >("format"); } @@ -898,7 +911,7 @@ public long? Quality /// public ApiEnum< string, - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol >? StreamProtocol { get @@ -907,7 +920,7 @@ public ApiEnum< return this._rawData.GetNullableClass< ApiEnum< string, - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol > >("stream_protocol"); } @@ -951,7 +964,7 @@ public IReadOnlyList? Variants /// public ApiEnum< string, - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec >? VideoCodec { get @@ -960,7 +973,7 @@ public ApiEnum< return this._rawData.GetNullableClass< ApiEnum< string, - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec > >("video_codec"); } @@ -987,17 +1000,18 @@ public override void Validate() this.VideoCodec?.Validate(); } - public VideoTransformationErrorEventIntersectionMember1DataTransformationOptions() { } + public VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptions() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public VideoTransformationErrorEventIntersectionMember1DataTransformationOptions( - VideoTransformationErrorEventIntersectionMember1DataTransformationOptions videoTransformationErrorEventIntersectionMember1DataTransformationOptions + public VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptions( + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptions videoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptions ) - : base(videoTransformationErrorEventIntersectionMember1DataTransformationOptions) { } + : base(videoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptions) + { } #pragma warning restore CS8618 - public VideoTransformationErrorEventIntersectionMember1DataTransformationOptions( + public VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptions( IReadOnlyDictionary rawData ) { @@ -1006,7 +1020,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - VideoTransformationErrorEventIntersectionMember1DataTransformationOptions( + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptions( FrozenDictionary rawData ) { @@ -1014,8 +1028,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static VideoTransformationErrorEventIntersectionMember1DataTransformationOptions FromRawUnchecked( + /// + public static VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptions FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -1023,14 +1037,14 @@ IReadOnlyDictionary rawData } } -class VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFromRaw - : IFromRawJson +class VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFromRaw + : IFromRawJson { /// - public VideoTransformationErrorEventIntersectionMember1DataTransformationOptions FromRawUnchecked( + public VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptions FromRawUnchecked( IReadOnlyDictionary rawData ) => - VideoTransformationErrorEventIntersectionMember1DataTransformationOptions.FromRawUnchecked( + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptions.FromRawUnchecked( rawData ); } @@ -1039,18 +1053,18 @@ IReadOnlyDictionary rawData /// Audio codec used for encoding (aac or opus). /// [JsonConverter( - typeof(VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodecConverter) + typeof(VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodecConverter) )] -public enum VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec +public enum VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec { Aac, Opus, } -sealed class VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodecConverter - : JsonConverter +sealed class VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodecConverter + : JsonConverter { - public override VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec Read( + public override VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -1059,11 +1073,11 @@ JsonSerializerOptions options return JsonSerializer.Deserialize(ref reader, options) switch { "aac" => - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec.Aac, "opus" => - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Opus, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec.Opus, _ => - (VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec)( + (VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec)( -1 ), }; @@ -1071,7 +1085,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec value, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec value, JsonSerializerOptions options ) { @@ -1079,9 +1093,9 @@ JsonSerializerOptions options writer, value switch { - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac => + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec.Aac => "aac", - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsAudioCodec.Opus => + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsAudioCodec.Opus => "opus", _ => throw new ImageKitInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) @@ -1096,9 +1110,9 @@ JsonSerializerOptions options /// Output format for the transformed video or thumbnail. /// [JsonConverter( - typeof(VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormatConverter) + typeof(VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormatConverter) )] -public enum VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat +public enum VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat { Mp4, Webm, @@ -1107,10 +1121,10 @@ public enum VideoTransformationErrorEventIntersectionMember1DataTransformationOp Webp, } -sealed class VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormatConverter - : JsonConverter +sealed class VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormatConverter + : JsonConverter { - public override VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat Read( + public override VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -1119,24 +1133,25 @@ JsonSerializerOptions options return JsonSerializer.Deserialize(ref reader, options) switch { "mp4" => - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Mp4, "webm" => - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Webm, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Webm, "jpg" => - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Jpg, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Jpg, "png" => - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Png, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Png, "webp" => - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Webp, - _ => (VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat)( - -1 - ), + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Webp, + _ => + (VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat)( + -1 + ), }; } public override void Write( Utf8JsonWriter writer, - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat value, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat value, JsonSerializerOptions options ) { @@ -1144,15 +1159,15 @@ JsonSerializerOptions options writer, value switch { - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Mp4 => + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Mp4 => "mp4", - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Webm => + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Webm => "webm", - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Jpg => + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Jpg => "jpg", - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Png => + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Png => "png", - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsFormat.Webp => + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsFormat.Webp => "webp", _ => throw new ImageKitInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) @@ -1167,18 +1182,18 @@ JsonSerializerOptions options /// Streaming protocol for adaptive bitrate streaming. /// [JsonConverter( - typeof(VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocolConverter) + typeof(VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocolConverter) )] -public enum VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol +public enum VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol { Hls, Dash, } -sealed class VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocolConverter - : JsonConverter +sealed class VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocolConverter + : JsonConverter { - public override VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol Read( + public override VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -1187,11 +1202,11 @@ JsonSerializerOptions options return JsonSerializer.Deserialize(ref reader, options) switch { "HLS" => - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol.Hls, "DASH" => - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Dash, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol.Dash, _ => - (VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol)( + (VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol)( -1 ), }; @@ -1199,7 +1214,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol value, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol value, JsonSerializerOptions options ) { @@ -1207,9 +1222,9 @@ JsonSerializerOptions options writer, value switch { - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls => + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol.Hls => "HLS", - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsStreamProtocol.Dash => + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsStreamProtocol.Dash => "DASH", _ => throw new ImageKitInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) @@ -1224,19 +1239,19 @@ JsonSerializerOptions options /// Video codec used for encoding (h264, vp9, or av1). /// [JsonConverter( - typeof(VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodecConverter) + typeof(VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodecConverter) )] -public enum VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec +public enum VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec { H264, Vp9, Av1, } -sealed class VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodecConverter - : JsonConverter +sealed class VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodecConverter + : JsonConverter { - public override VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec Read( + public override VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -1245,13 +1260,13 @@ JsonSerializerOptions options return JsonSerializer.Deserialize(ref reader, options) switch { "h264" => - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.H264, "vp9" => - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.Vp9, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.Vp9, "av1" => - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.Av1, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.Av1, _ => - (VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec)( + (VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec)( -1 ), }; @@ -1259,7 +1274,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec value, + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec value, JsonSerializerOptions options ) { @@ -1267,11 +1282,11 @@ JsonSerializerOptions options writer, value switch { - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.H264 => + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.H264 => "h264", - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.Vp9 => + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.Vp9 => "vp9", - VideoTransformationErrorEventIntersectionMember1DataTransformationOptionsVideoCodec.Av1 => + VideoTransformationErrorEventVideoTransformationErrorEventDataTransformationOptionsVideoCodec.Av1 => "av1", _ => throw new ImageKitInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) @@ -1287,11 +1302,12 @@ JsonSerializerOptions options /// [JsonConverter( typeof(JsonModelConverter< - VideoTransformationErrorEventIntersectionMember1Request, - VideoTransformationErrorEventIntersectionMember1RequestFromRaw + VideoTransformationErrorEventVideoTransformationErrorEventRequest, + VideoTransformationErrorEventVideoTransformationErrorEventRequestFromRaw >) )] -public sealed record class VideoTransformationErrorEventIntersectionMember1Request : JsonModel +public sealed record class VideoTransformationErrorEventVideoTransformationErrorEventRequest + : JsonModel { /// /// Full URL of the transformation request that was submitted. @@ -1348,17 +1364,17 @@ public override void Validate() _ = this.UserAgent; } - public VideoTransformationErrorEventIntersectionMember1Request() { } + public VideoTransformationErrorEventVideoTransformationErrorEventRequest() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public VideoTransformationErrorEventIntersectionMember1Request( - VideoTransformationErrorEventIntersectionMember1Request videoTransformationErrorEventIntersectionMember1Request + public VideoTransformationErrorEventVideoTransformationErrorEventRequest( + VideoTransformationErrorEventVideoTransformationErrorEventRequest videoTransformationErrorEventVideoTransformationErrorEventRequest ) - : base(videoTransformationErrorEventIntersectionMember1Request) { } + : base(videoTransformationErrorEventVideoTransformationErrorEventRequest) { } #pragma warning restore CS8618 - public VideoTransformationErrorEventIntersectionMember1Request( + public VideoTransformationErrorEventVideoTransformationErrorEventRequest( IReadOnlyDictionary rawData ) { @@ -1367,7 +1383,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - VideoTransformationErrorEventIntersectionMember1Request( + VideoTransformationErrorEventVideoTransformationErrorEventRequest( FrozenDictionary rawData ) { @@ -1375,8 +1391,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static VideoTransformationErrorEventIntersectionMember1Request FromRawUnchecked( + /// + public static VideoTransformationErrorEventVideoTransformationErrorEventRequest FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -1384,11 +1400,12 @@ IReadOnlyDictionary rawData } } -class VideoTransformationErrorEventIntersectionMember1RequestFromRaw - : IFromRawJson +class VideoTransformationErrorEventVideoTransformationErrorEventRequestFromRaw + : IFromRawJson { /// - public VideoTransformationErrorEventIntersectionMember1Request FromRawUnchecked( + public VideoTransformationErrorEventVideoTransformationErrorEventRequest FromRawUnchecked( IReadOnlyDictionary rawData - ) => VideoTransformationErrorEventIntersectionMember1Request.FromRawUnchecked(rawData); + ) => + VideoTransformationErrorEventVideoTransformationErrorEventRequest.FromRawUnchecked(rawData); } diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEvent.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEvent.cs index 2518e463..a3dffdaa 100644 --- a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEvent.cs +++ b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEvent.cs @@ -60,12 +60,12 @@ public required string Type init { this._rawData.Set("created_at", value); } } - public required VideoTransformationReadyEventIntersectionMember1Data Data + public required VideoTransformationReadyEventVideoTransformationReadyEventData Data { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "data" ); } @@ -75,12 +75,12 @@ public required VideoTransformationReadyEventIntersectionMember1Data Data /// /// Information about the original request that triggered the video transformation. /// - public required VideoTransformationReadyEventIntersectionMember1Request Request + public required VideoTransformationReadyEventVideoTransformationReadyEventRequest Request { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "request" ); } @@ -171,11 +171,11 @@ IReadOnlyDictionary rawData /// [JsonConverter( typeof(JsonModelConverter< - VideoTransformationReadyEventIntersectionMember1, - VideoTransformationReadyEventIntersectionMember1FromRaw + VideoTransformationReadyEventVideoTransformationReadyEvent, + VideoTransformationReadyEventVideoTransformationReadyEventFromRaw >) )] -public sealed record class VideoTransformationReadyEventIntersectionMember1 : JsonModel +public sealed record class VideoTransformationReadyEventVideoTransformationReadyEvent : JsonModel { /// /// Timestamp when the event was created in ISO8601 format. @@ -190,12 +190,12 @@ public sealed record class VideoTransformationReadyEventIntersectionMember1 : Js init { this._rawData.Set("created_at", value); } } - public required VideoTransformationReadyEventIntersectionMember1Data Data + public required VideoTransformationReadyEventVideoTransformationReadyEventData Data { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "data" ); } @@ -205,12 +205,12 @@ public required VideoTransformationReadyEventIntersectionMember1Data Data /// /// Information about the original request that triggered the video transformation. /// - public required VideoTransformationReadyEventIntersectionMember1Request Request + public required VideoTransformationReadyEventVideoTransformationReadyEventRequest Request { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "request" ); } @@ -266,20 +266,20 @@ public override void Validate() this.Timings?.Validate(); } - public VideoTransformationReadyEventIntersectionMember1() + public VideoTransformationReadyEventVideoTransformationReadyEvent() { this.Type = JsonSerializer.SerializeToElement("video.transformation.ready"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public VideoTransformationReadyEventIntersectionMember1( - VideoTransformationReadyEventIntersectionMember1 videoTransformationReadyEventIntersectionMember1 + public VideoTransformationReadyEventVideoTransformationReadyEvent( + VideoTransformationReadyEventVideoTransformationReadyEvent videoTransformationReadyEventVideoTransformationReadyEvent ) - : base(videoTransformationReadyEventIntersectionMember1) { } + : base(videoTransformationReadyEventVideoTransformationReadyEvent) { } #pragma warning restore CS8618 - public VideoTransformationReadyEventIntersectionMember1( + public VideoTransformationReadyEventVideoTransformationReadyEvent( IReadOnlyDictionary rawData ) { @@ -290,14 +290,16 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - VideoTransformationReadyEventIntersectionMember1(FrozenDictionary rawData) + VideoTransformationReadyEventVideoTransformationReadyEvent( + FrozenDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static VideoTransformationReadyEventIntersectionMember1 FromRawUnchecked( + /// + public static VideoTransformationReadyEventVideoTransformationReadyEvent FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -305,44 +307,45 @@ IReadOnlyDictionary rawData } } -class VideoTransformationReadyEventIntersectionMember1FromRaw - : IFromRawJson +class VideoTransformationReadyEventVideoTransformationReadyEventFromRaw + : IFromRawJson { /// - public VideoTransformationReadyEventIntersectionMember1 FromRawUnchecked( + public VideoTransformationReadyEventVideoTransformationReadyEvent FromRawUnchecked( IReadOnlyDictionary rawData - ) => VideoTransformationReadyEventIntersectionMember1.FromRawUnchecked(rawData); + ) => VideoTransformationReadyEventVideoTransformationReadyEvent.FromRawUnchecked(rawData); } [JsonConverter( typeof(JsonModelConverter< - VideoTransformationReadyEventIntersectionMember1Data, - VideoTransformationReadyEventIntersectionMember1DataFromRaw + VideoTransformationReadyEventVideoTransformationReadyEventData, + VideoTransformationReadyEventVideoTransformationReadyEventDataFromRaw >) )] -public sealed record class VideoTransformationReadyEventIntersectionMember1Data : JsonModel +public sealed record class VideoTransformationReadyEventVideoTransformationReadyEventData + : JsonModel { /// /// Information about the source video asset being transformed. /// - public required VideoTransformationReadyEventIntersectionMember1DataAsset Asset + public required VideoTransformationReadyEventVideoTransformationReadyEventDataAsset Asset { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "asset" ); } init { this._rawData.Set("asset", value); } } - public required VideoTransformationReadyEventIntersectionMember1DataTransformation Transformation + public required VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation Transformation { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "transformation" ); } @@ -356,17 +359,17 @@ public override void Validate() this.Transformation.Validate(); } - public VideoTransformationReadyEventIntersectionMember1Data() { } + public VideoTransformationReadyEventVideoTransformationReadyEventData() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public VideoTransformationReadyEventIntersectionMember1Data( - VideoTransformationReadyEventIntersectionMember1Data videoTransformationReadyEventIntersectionMember1Data + public VideoTransformationReadyEventVideoTransformationReadyEventData( + VideoTransformationReadyEventVideoTransformationReadyEventData videoTransformationReadyEventVideoTransformationReadyEventData ) - : base(videoTransformationReadyEventIntersectionMember1Data) { } + : base(videoTransformationReadyEventVideoTransformationReadyEventData) { } #pragma warning restore CS8618 - public VideoTransformationReadyEventIntersectionMember1Data( + public VideoTransformationReadyEventVideoTransformationReadyEventData( IReadOnlyDictionary rawData ) { @@ -375,7 +378,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - VideoTransformationReadyEventIntersectionMember1Data( + VideoTransformationReadyEventVideoTransformationReadyEventData( FrozenDictionary rawData ) { @@ -383,8 +386,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static VideoTransformationReadyEventIntersectionMember1Data FromRawUnchecked( + /// + public static VideoTransformationReadyEventVideoTransformationReadyEventData FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -392,13 +395,13 @@ IReadOnlyDictionary rawData } } -class VideoTransformationReadyEventIntersectionMember1DataFromRaw - : IFromRawJson +class VideoTransformationReadyEventVideoTransformationReadyEventDataFromRaw + : IFromRawJson { /// - public VideoTransformationReadyEventIntersectionMember1Data FromRawUnchecked( + public VideoTransformationReadyEventVideoTransformationReadyEventData FromRawUnchecked( IReadOnlyDictionary rawData - ) => VideoTransformationReadyEventIntersectionMember1Data.FromRawUnchecked(rawData); + ) => VideoTransformationReadyEventVideoTransformationReadyEventData.FromRawUnchecked(rawData); } /// @@ -406,11 +409,12 @@ IReadOnlyDictionary rawData /// [JsonConverter( typeof(JsonModelConverter< - VideoTransformationReadyEventIntersectionMember1DataAsset, - VideoTransformationReadyEventIntersectionMember1DataAssetFromRaw + VideoTransformationReadyEventVideoTransformationReadyEventDataAsset, + VideoTransformationReadyEventVideoTransformationReadyEventDataAssetFromRaw >) )] -public sealed record class VideoTransformationReadyEventIntersectionMember1DataAsset : JsonModel +public sealed record class VideoTransformationReadyEventVideoTransformationReadyEventDataAsset + : JsonModel { /// /// URL to download or access the source video file. @@ -431,17 +435,17 @@ public override void Validate() _ = this.Url; } - public VideoTransformationReadyEventIntersectionMember1DataAsset() { } + public VideoTransformationReadyEventVideoTransformationReadyEventDataAsset() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public VideoTransformationReadyEventIntersectionMember1DataAsset( - VideoTransformationReadyEventIntersectionMember1DataAsset videoTransformationReadyEventIntersectionMember1DataAsset + public VideoTransformationReadyEventVideoTransformationReadyEventDataAsset( + VideoTransformationReadyEventVideoTransformationReadyEventDataAsset videoTransformationReadyEventVideoTransformationReadyEventDataAsset ) - : base(videoTransformationReadyEventIntersectionMember1DataAsset) { } + : base(videoTransformationReadyEventVideoTransformationReadyEventDataAsset) { } #pragma warning restore CS8618 - public VideoTransformationReadyEventIntersectionMember1DataAsset( + public VideoTransformationReadyEventVideoTransformationReadyEventDataAsset( IReadOnlyDictionary rawData ) { @@ -450,7 +454,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - VideoTransformationReadyEventIntersectionMember1DataAsset( + VideoTransformationReadyEventVideoTransformationReadyEventDataAsset( FrozenDictionary rawData ) { @@ -458,8 +462,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static VideoTransformationReadyEventIntersectionMember1DataAsset FromRawUnchecked( + /// + public static VideoTransformationReadyEventVideoTransformationReadyEventDataAsset FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -467,29 +471,32 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public VideoTransformationReadyEventIntersectionMember1DataAsset(string url) + public VideoTransformationReadyEventVideoTransformationReadyEventDataAsset(string url) : this() { this.Url = url; } } -class VideoTransformationReadyEventIntersectionMember1DataAssetFromRaw - : IFromRawJson +class VideoTransformationReadyEventVideoTransformationReadyEventDataAssetFromRaw + : IFromRawJson { /// - public VideoTransformationReadyEventIntersectionMember1DataAsset FromRawUnchecked( + public VideoTransformationReadyEventVideoTransformationReadyEventDataAsset FromRawUnchecked( IReadOnlyDictionary rawData - ) => VideoTransformationReadyEventIntersectionMember1DataAsset.FromRawUnchecked(rawData); + ) => + VideoTransformationReadyEventVideoTransformationReadyEventDataAsset.FromRawUnchecked( + rawData + ); } [JsonConverter( typeof(JsonModelConverter< - VideoTransformationReadyEventIntersectionMember1DataTransformation, - VideoTransformationReadyEventIntersectionMember1DataTransformationFromRaw + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationFromRaw >) )] -public sealed record class VideoTransformationReadyEventIntersectionMember1DataTransformation +public sealed record class VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation : JsonModel { /// @@ -499,7 +506,7 @@ public sealed record class VideoTransformationReadyEventIntersectionMember1DataT /// public required ApiEnum< string, - VideoTransformationReadyEventIntersectionMember1DataTransformationType + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType > Type { get @@ -508,7 +515,7 @@ public required ApiEnum< return this._rawData.GetNotNullClass< ApiEnum< string, - VideoTransformationReadyEventIntersectionMember1DataTransformationType + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType > >("type"); } @@ -518,12 +525,12 @@ public required ApiEnum< /// /// Configuration options for video transformations. /// - public VideoTransformationReadyEventIntersectionMember1DataTransformationOptions? Options + public VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions? Options { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "options" ); } @@ -567,17 +574,17 @@ public override void Validate() this.Output?.Validate(); } - public VideoTransformationReadyEventIntersectionMember1DataTransformation() { } + public VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public VideoTransformationReadyEventIntersectionMember1DataTransformation( - VideoTransformationReadyEventIntersectionMember1DataTransformation videoTransformationReadyEventIntersectionMember1DataTransformation + public VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation( + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation videoTransformationReadyEventVideoTransformationReadyEventDataTransformation ) - : base(videoTransformationReadyEventIntersectionMember1DataTransformation) { } + : base(videoTransformationReadyEventVideoTransformationReadyEventDataTransformation) { } #pragma warning restore CS8618 - public VideoTransformationReadyEventIntersectionMember1DataTransformation( + public VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation( IReadOnlyDictionary rawData ) { @@ -586,7 +593,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - VideoTransformationReadyEventIntersectionMember1DataTransformation( + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation( FrozenDictionary rawData ) { @@ -594,8 +601,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static VideoTransformationReadyEventIntersectionMember1DataTransformation FromRawUnchecked( + /// + public static VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -603,8 +610,11 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public VideoTransformationReadyEventIntersectionMember1DataTransformation( - ApiEnum type + public VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation( + ApiEnum< + string, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType + > type ) : this() { @@ -612,14 +622,14 @@ ApiEnum +class VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationFromRaw + : IFromRawJson { /// - public VideoTransformationReadyEventIntersectionMember1DataTransformation FromRawUnchecked( + public VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation FromRawUnchecked( IReadOnlyDictionary rawData ) => - VideoTransformationReadyEventIntersectionMember1DataTransformation.FromRawUnchecked( + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation.FromRawUnchecked( rawData ); } @@ -630,19 +640,19 @@ IReadOnlyDictionary rawData /// format - `video-thumbnail`: Generate thumbnail image from video /// [JsonConverter( - typeof(VideoTransformationReadyEventIntersectionMember1DataTransformationTypeConverter) + typeof(VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationTypeConverter) )] -public enum VideoTransformationReadyEventIntersectionMember1DataTransformationType +public enum VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType { VideoTransformation, GifToVideo, VideoThumbnail, } -sealed class VideoTransformationReadyEventIntersectionMember1DataTransformationTypeConverter - : JsonConverter +sealed class VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationTypeConverter + : JsonConverter { - public override VideoTransformationReadyEventIntersectionMember1DataTransformationType Read( + public override VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -651,18 +661,20 @@ JsonSerializerOptions options return JsonSerializer.Deserialize(ref reader, options) switch { "video-transformation" => - VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, "gif-to-video" => - VideoTransformationReadyEventIntersectionMember1DataTransformationType.GifToVideo, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.GifToVideo, "video-thumbnail" => - VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoThumbnail, - _ => (VideoTransformationReadyEventIntersectionMember1DataTransformationType)(-1), + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoThumbnail, + _ => (VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType)( + -1 + ), }; } public override void Write( Utf8JsonWriter writer, - VideoTransformationReadyEventIntersectionMember1DataTransformationType value, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType value, JsonSerializerOptions options ) { @@ -670,11 +682,11 @@ JsonSerializerOptions options writer, value switch { - VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoTransformation => + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation => "video-transformation", - VideoTransformationReadyEventIntersectionMember1DataTransformationType.GifToVideo => + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.GifToVideo => "gif-to-video", - VideoTransformationReadyEventIntersectionMember1DataTransformationType.VideoThumbnail => + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoThumbnail => "video-thumbnail", _ => throw new ImageKitInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) @@ -690,11 +702,11 @@ JsonSerializerOptions options /// [JsonConverter( typeof(JsonModelConverter< - VideoTransformationReadyEventIntersectionMember1DataTransformationOptions, - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFromRaw + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFromRaw >) )] -public sealed record class VideoTransformationReadyEventIntersectionMember1DataTransformationOptions +public sealed record class VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions : JsonModel { /// @@ -702,7 +714,7 @@ public sealed record class VideoTransformationReadyEventIntersectionMember1DataT /// public ApiEnum< string, - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec >? AudioCodec { get @@ -711,7 +723,7 @@ public ApiEnum< return this._rawData.GetNullableClass< ApiEnum< string, - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec > >("audio_codec"); } @@ -752,7 +764,7 @@ public bool? AutoRotate /// public ApiEnum< string, - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat >? Format { get @@ -761,7 +773,7 @@ public ApiEnum< return this._rawData.GetNullableClass< ApiEnum< string, - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat > >("format"); } @@ -802,7 +814,7 @@ public long? Quality /// public ApiEnum< string, - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol >? StreamProtocol { get @@ -811,7 +823,7 @@ public ApiEnum< return this._rawData.GetNullableClass< ApiEnum< string, - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol > >("stream_protocol"); } @@ -855,7 +867,7 @@ public IReadOnlyList? Variants /// public ApiEnum< string, - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec >? VideoCodec { get @@ -864,7 +876,7 @@ public ApiEnum< return this._rawData.GetNullableClass< ApiEnum< string, - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec > >("video_codec"); } @@ -891,17 +903,18 @@ public override void Validate() this.VideoCodec?.Validate(); } - public VideoTransformationReadyEventIntersectionMember1DataTransformationOptions() { } + public VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public VideoTransformationReadyEventIntersectionMember1DataTransformationOptions( - VideoTransformationReadyEventIntersectionMember1DataTransformationOptions videoTransformationReadyEventIntersectionMember1DataTransformationOptions + public VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions( + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions videoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions ) - : base(videoTransformationReadyEventIntersectionMember1DataTransformationOptions) { } + : base(videoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions) + { } #pragma warning restore CS8618 - public VideoTransformationReadyEventIntersectionMember1DataTransformationOptions( + public VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions( IReadOnlyDictionary rawData ) { @@ -910,7 +923,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - VideoTransformationReadyEventIntersectionMember1DataTransformationOptions( + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions( FrozenDictionary rawData ) { @@ -918,8 +931,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static VideoTransformationReadyEventIntersectionMember1DataTransformationOptions FromRawUnchecked( + /// + public static VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -927,14 +940,14 @@ IReadOnlyDictionary rawData } } -class VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFromRaw - : IFromRawJson +class VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFromRaw + : IFromRawJson { /// - public VideoTransformationReadyEventIntersectionMember1DataTransformationOptions FromRawUnchecked( + public VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions FromRawUnchecked( IReadOnlyDictionary rawData ) => - VideoTransformationReadyEventIntersectionMember1DataTransformationOptions.FromRawUnchecked( + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions.FromRawUnchecked( rawData ); } @@ -943,18 +956,18 @@ IReadOnlyDictionary rawData /// Audio codec used for encoding (aac or opus). /// [JsonConverter( - typeof(VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodecConverter) + typeof(VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodecConverter) )] -public enum VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec +public enum VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec { Aac, Opus, } -sealed class VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodecConverter - : JsonConverter +sealed class VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodecConverter + : JsonConverter { - public override VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec Read( + public override VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -963,11 +976,11 @@ JsonSerializerOptions options return JsonSerializer.Deserialize(ref reader, options) switch { "aac" => - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, "opus" => - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Opus, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Opus, _ => - (VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec)( + (VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec)( -1 ), }; @@ -975,7 +988,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec value, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec value, JsonSerializerOptions options ) { @@ -983,9 +996,9 @@ JsonSerializerOptions options writer, value switch { - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Aac => + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac => "aac", - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsAudioCodec.Opus => + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Opus => "opus", _ => throw new ImageKitInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) @@ -1000,9 +1013,9 @@ JsonSerializerOptions options /// Output format for the transformed video or thumbnail. /// [JsonConverter( - typeof(VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormatConverter) + typeof(VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormatConverter) )] -public enum VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat +public enum VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat { Mp4, Webm, @@ -1011,10 +1024,10 @@ public enum VideoTransformationReadyEventIntersectionMember1DataTransformationOp Webp, } -sealed class VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormatConverter - : JsonConverter +sealed class VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormatConverter + : JsonConverter { - public override VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat Read( + public override VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -1023,24 +1036,25 @@ JsonSerializerOptions options return JsonSerializer.Deserialize(ref reader, options) switch { "mp4" => - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, "webm" => - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Webm, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Webm, "jpg" => - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Jpg, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Jpg, "png" => - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Png, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Png, "webp" => - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Webp, - _ => (VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat)( - -1 - ), + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Webp, + _ => + (VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat)( + -1 + ), }; } public override void Write( Utf8JsonWriter writer, - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat value, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat value, JsonSerializerOptions options ) { @@ -1048,15 +1062,15 @@ JsonSerializerOptions options writer, value switch { - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Mp4 => + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4 => "mp4", - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Webm => + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Webm => "webm", - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Jpg => + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Jpg => "jpg", - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Png => + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Png => "png", - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsFormat.Webp => + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Webp => "webp", _ => throw new ImageKitInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) @@ -1071,18 +1085,18 @@ JsonSerializerOptions options /// Streaming protocol for adaptive bitrate streaming. /// [JsonConverter( - typeof(VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocolConverter) + typeof(VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocolConverter) )] -public enum VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol +public enum VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol { Hls, Dash, } -sealed class VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocolConverter - : JsonConverter +sealed class VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocolConverter + : JsonConverter { - public override VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol Read( + public override VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -1091,11 +1105,11 @@ JsonSerializerOptions options return JsonSerializer.Deserialize(ref reader, options) switch { "HLS" => - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, "DASH" => - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Dash, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Dash, _ => - (VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol)( + (VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol)( -1 ), }; @@ -1103,7 +1117,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol value, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol value, JsonSerializerOptions options ) { @@ -1111,9 +1125,9 @@ JsonSerializerOptions options writer, value switch { - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Hls => + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls => "HLS", - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsStreamProtocol.Dash => + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Dash => "DASH", _ => throw new ImageKitInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) @@ -1128,19 +1142,19 @@ JsonSerializerOptions options /// Video codec used for encoding (h264, vp9, or av1). /// [JsonConverter( - typeof(VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodecConverter) + typeof(VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodecConverter) )] -public enum VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec +public enum VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec { H264, Vp9, Av1, } -sealed class VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodecConverter - : JsonConverter +sealed class VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodecConverter + : JsonConverter { - public override VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec Read( + public override VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -1149,13 +1163,13 @@ JsonSerializerOptions options return JsonSerializer.Deserialize(ref reader, options) switch { "h264" => - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, "vp9" => - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.Vp9, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.Vp9, "av1" => - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.Av1, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.Av1, _ => - (VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec)( + (VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec)( -1 ), }; @@ -1163,7 +1177,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec value, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec value, JsonSerializerOptions options ) { @@ -1171,11 +1185,11 @@ JsonSerializerOptions options writer, value switch { - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.H264 => + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264 => "h264", - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.Vp9 => + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.Vp9 => "vp9", - VideoTransformationReadyEventIntersectionMember1DataTransformationOptionsVideoCodec.Av1 => + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.Av1 => "av1", _ => throw new ImageKitInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) @@ -1382,11 +1396,12 @@ public VideoMetadata FromRawUnchecked(IReadOnlyDictionary r /// [JsonConverter( typeof(JsonModelConverter< - VideoTransformationReadyEventIntersectionMember1Request, - VideoTransformationReadyEventIntersectionMember1RequestFromRaw + VideoTransformationReadyEventVideoTransformationReadyEventRequest, + VideoTransformationReadyEventVideoTransformationReadyEventRequestFromRaw >) )] -public sealed record class VideoTransformationReadyEventIntersectionMember1Request : JsonModel +public sealed record class VideoTransformationReadyEventVideoTransformationReadyEventRequest + : JsonModel { /// /// Full URL of the transformation request that was submitted. @@ -1443,17 +1458,17 @@ public override void Validate() _ = this.UserAgent; } - public VideoTransformationReadyEventIntersectionMember1Request() { } + public VideoTransformationReadyEventVideoTransformationReadyEventRequest() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public VideoTransformationReadyEventIntersectionMember1Request( - VideoTransformationReadyEventIntersectionMember1Request videoTransformationReadyEventIntersectionMember1Request + public VideoTransformationReadyEventVideoTransformationReadyEventRequest( + VideoTransformationReadyEventVideoTransformationReadyEventRequest videoTransformationReadyEventVideoTransformationReadyEventRequest ) - : base(videoTransformationReadyEventIntersectionMember1Request) { } + : base(videoTransformationReadyEventVideoTransformationReadyEventRequest) { } #pragma warning restore CS8618 - public VideoTransformationReadyEventIntersectionMember1Request( + public VideoTransformationReadyEventVideoTransformationReadyEventRequest( IReadOnlyDictionary rawData ) { @@ -1462,7 +1477,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - VideoTransformationReadyEventIntersectionMember1Request( + VideoTransformationReadyEventVideoTransformationReadyEventRequest( FrozenDictionary rawData ) { @@ -1470,8 +1485,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static VideoTransformationReadyEventIntersectionMember1Request FromRawUnchecked( + /// + public static VideoTransformationReadyEventVideoTransformationReadyEventRequest FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -1479,13 +1494,14 @@ IReadOnlyDictionary rawData } } -class VideoTransformationReadyEventIntersectionMember1RequestFromRaw - : IFromRawJson +class VideoTransformationReadyEventVideoTransformationReadyEventRequestFromRaw + : IFromRawJson { /// - public VideoTransformationReadyEventIntersectionMember1Request FromRawUnchecked( + public VideoTransformationReadyEventVideoTransformationReadyEventRequest FromRawUnchecked( IReadOnlyDictionary rawData - ) => VideoTransformationReadyEventIntersectionMember1Request.FromRawUnchecked(rawData); + ) => + VideoTransformationReadyEventVideoTransformationReadyEventRequest.FromRawUnchecked(rawData); } /// From dcf392311a628e6375fb667c36037da772585158 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sun, 17 May 2026 03:24:19 +0000 Subject: [PATCH 122/129] chore: trigger build --- .stats.yml | 4 +- .../Webhooks/UnsafeUnwrapWebhookEventTest.cs | 20 +- .../Models/Webhooks/UnwrapWebhookEventTest.cs | 20 +- .../VideoTransformationReadyEventTest.cs | 1217 +++++++---------- src/Imagekit/Core/ModelBase.cs | 10 +- .../Webhooks/VideoTransformationReadyEvent.cs | 438 +++--- 6 files changed, 726 insertions(+), 983 deletions(-) diff --git a/.stats.yml b/.stats.yml index 364b12b5..1497247c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc/imagekit-4df977cf1706b48f9d9f15d7e134d5bb062607bcf206a406a239ff6691852e7d.yml -openapi_spec_hash: fd7c931960b5d8a4c1072a69a5a3e6a1 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc/imagekit-406b71ea98caac24889265c5b4371961c784912e543ade88e7e6917f9a31a951.yml +openapi_spec_hash: 462b973437dd6b2659654881e9a0e5c1 config_hash: c5a7aed248c5d9ad5cd42e56fdd62c12 diff --git a/src/Imagekit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs b/src/Imagekit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs index 43b56e9e..5a71ec34 100644 --- a/src/Imagekit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs +++ b/src/Imagekit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs @@ -60,20 +60,20 @@ public void VideoTransformationReadyValidationWorks() Transformation = new() { Type = - Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, + Webhooks::VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + Webhooks::VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + Webhooks::VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + Webhooks::VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, + Webhooks::VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -716,20 +716,20 @@ public void VideoTransformationReadySerializationRoundtripWorks() Transformation = new() { Type = - Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, + Webhooks::VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + Webhooks::VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + Webhooks::VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + Webhooks::VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, + Webhooks::VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, }, Output = new() { diff --git a/src/Imagekit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs b/src/Imagekit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs index 8b7de059..783d9f66 100644 --- a/src/Imagekit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs +++ b/src/Imagekit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs @@ -60,20 +60,20 @@ public void VideoTransformationReadyValidationWorks() Transformation = new() { Type = - Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, + Webhooks::VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + Webhooks::VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + Webhooks::VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + Webhooks::VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, + Webhooks::VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -716,20 +716,20 @@ public void VideoTransformationReadySerializationRoundtripWorks() Transformation = new() { Type = - Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, + Webhooks::VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + Webhooks::VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + Webhooks::VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + Webhooks::VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, + Webhooks::VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, }, Output = new() { diff --git a/src/Imagekit.Tests/Models/Webhooks/VideoTransformationReadyEventTest.cs b/src/Imagekit.Tests/Models/Webhooks/VideoTransformationReadyEventTest.cs index 3fd282ac..dcc2b8d9 100644 --- a/src/Imagekit.Tests/Models/Webhooks/VideoTransformationReadyEventTest.cs +++ b/src/Imagekit.Tests/Models/Webhooks/VideoTransformationReadyEventTest.cs @@ -23,20 +23,20 @@ public void FieldRoundtrip_Works() Transformation = new() { Type = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, + VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -63,26 +63,26 @@ public void FieldRoundtrip_Works() string expectedID = "id"; string expectedType = "type"; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - VideoTransformationReadyEventVideoTransformationReadyEventData expectedData = new() + VideoTransformationReadyEventChangedData expectedData = new() { Asset = new("https://example.com"), Transformation = new() { Type = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, + VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -97,7 +97,7 @@ public void FieldRoundtrip_Works() }, }, }; - VideoTransformationReadyEventVideoTransformationReadyEventRequest expectedRequest = new() + VideoTransformationReadyEventChangedRequest expectedRequest = new() { Url = "https://example.com", XRequestID = "x_request_id", @@ -127,20 +127,20 @@ public void SerializationRoundtrip_Works() Transformation = new() { Type = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, + VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -187,20 +187,20 @@ public void FieldRoundtripThroughSerialization_Works() Transformation = new() { Type = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, + VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -234,26 +234,26 @@ public void FieldRoundtripThroughSerialization_Works() string expectedID = "id"; string expectedType = "type"; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - VideoTransformationReadyEventVideoTransformationReadyEventData expectedData = new() + VideoTransformationReadyEventChangedData expectedData = new() { Asset = new("https://example.com"), Transformation = new() { Type = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, + VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -268,7 +268,7 @@ public void FieldRoundtripThroughSerialization_Works() }, }, }; - VideoTransformationReadyEventVideoTransformationReadyEventRequest expectedRequest = new() + VideoTransformationReadyEventChangedRequest expectedRequest = new() { Url = "https://example.com", XRequestID = "x_request_id", @@ -298,20 +298,20 @@ public void Validation_Works() Transformation = new() { Type = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, + VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -352,20 +352,20 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() Transformation = new() { Type = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, + VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -406,20 +406,20 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() Transformation = new() { Type = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, + VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -459,20 +459,20 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() Transformation = new() { Type = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, + VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -516,20 +516,20 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() Transformation = new() { Type = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, + VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -572,20 +572,20 @@ public void CopyConstructor_Works() Transformation = new() { Type = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, + VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -615,12 +615,12 @@ public void CopyConstructor_Works() } } -public class VideoTransformationReadyEventVideoTransformationReadyEventTest : TestBase +public class VideoTransformationReadyEventChangedTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new VideoTransformationReadyEventVideoTransformationReadyEvent + var model = new VideoTransformationReadyEventChanged { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -629,20 +629,20 @@ public void FieldRoundtrip_Works() Transformation = new() { Type = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, + VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -667,26 +667,26 @@ public void FieldRoundtrip_Works() }; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - VideoTransformationReadyEventVideoTransformationReadyEventData expectedData = new() + VideoTransformationReadyEventChangedData expectedData = new() { Asset = new("https://example.com"), Transformation = new() { Type = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, + VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -701,7 +701,7 @@ public void FieldRoundtrip_Works() }, }, }; - VideoTransformationReadyEventVideoTransformationReadyEventRequest expectedRequest = new() + VideoTransformationReadyEventChangedRequest expectedRequest = new() { Url = "https://example.com", XRequestID = "x_request_id", @@ -720,7 +720,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new VideoTransformationReadyEventVideoTransformationReadyEvent + var model = new VideoTransformationReadyEventChanged { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -729,20 +729,20 @@ public void SerializationRoundtrip_Works() Transformation = new() { Type = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, + VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -767,11 +767,10 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -779,7 +778,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new VideoTransformationReadyEventVideoTransformationReadyEvent + var model = new VideoTransformationReadyEventChanged { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -788,20 +787,20 @@ public void FieldRoundtripThroughSerialization_Works() Transformation = new() { Type = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, + VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -826,34 +825,33 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.NotNull(deserialized); DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - VideoTransformationReadyEventVideoTransformationReadyEventData expectedData = new() + VideoTransformationReadyEventChangedData expectedData = new() { Asset = new("https://example.com"), Transformation = new() { Type = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, + VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -868,7 +866,7 @@ public void FieldRoundtripThroughSerialization_Works() }, }, }; - VideoTransformationReadyEventVideoTransformationReadyEventRequest expectedRequest = new() + VideoTransformationReadyEventChangedRequest expectedRequest = new() { Url = "https://example.com", XRequestID = "x_request_id", @@ -887,7 +885,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new VideoTransformationReadyEventVideoTransformationReadyEvent + var model = new VideoTransformationReadyEventChanged { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -896,20 +894,20 @@ public void Validation_Works() Transformation = new() { Type = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, + VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -939,7 +937,7 @@ public void Validation_Works() [Fact] public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new VideoTransformationReadyEventVideoTransformationReadyEvent + var model = new VideoTransformationReadyEventChanged { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -948,20 +946,20 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() Transformation = new() { Type = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, + VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -991,7 +989,7 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = new VideoTransformationReadyEventVideoTransformationReadyEvent + var model = new VideoTransformationReadyEventChanged { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -1000,20 +998,20 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() Transformation = new() { Type = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, + VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -1042,7 +1040,7 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - var model = new VideoTransformationReadyEventVideoTransformationReadyEvent + var model = new VideoTransformationReadyEventChanged { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -1051,20 +1049,20 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() Transformation = new() { Type = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, + VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -1097,7 +1095,7 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - var model = new VideoTransformationReadyEventVideoTransformationReadyEvent + var model = new VideoTransformationReadyEventChanged { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -1106,20 +1104,20 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() Transformation = new() { Type = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, + VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -1151,7 +1149,7 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new VideoTransformationReadyEventVideoTransformationReadyEvent + var model = new VideoTransformationReadyEventChanged { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -1160,20 +1158,20 @@ public void CopyConstructor_Works() Transformation = new() { Type = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, + VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -1197,37 +1195,37 @@ public void CopyConstructor_Works() Timings = new() { DownloadDuration = 0, EncodingDuration = 0 }, }; - VideoTransformationReadyEventVideoTransformationReadyEvent copied = new(model); + VideoTransformationReadyEventChanged copied = new(model); Assert.Equal(model, copied); } } -public class VideoTransformationReadyEventVideoTransformationReadyEventDataTest : TestBase +public class VideoTransformationReadyEventChangedDataTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new VideoTransformationReadyEventVideoTransformationReadyEventData + var model = new VideoTransformationReadyEventChangedData { Asset = new("https://example.com"), Transformation = new() { Type = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, + VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -1243,40 +1241,35 @@ public void FieldRoundtrip_Works() }, }; - VideoTransformationReadyEventVideoTransformationReadyEventDataAsset expectedAsset = new( - "https://example.com" - ); - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation expectedTransformation = - new() + VideoTransformationReadyEventChangedDataAsset expectedAsset = new("https://example.com"); + VideoTransformationReadyEventChangedDataTransformation expectedTransformation = new() + { + Type = VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, + Options = new() { - Type = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, - Options = new() - { - AudioCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, - AutoRotate = true, - Format = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, - Quality = 0, - StreamProtocol = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, - Variants = ["string"], - VideoCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, - }, - Output = new() + AudioCodec = + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, + }, + Output = new() + { + Url = "https://example.com", + VideoMetadata = new() { - Url = "https://example.com", - VideoMetadata = new() - { - Bitrate = 0, - Duration = 0, - Height = 0, - Width = 0, - }, + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, }, - }; + }, + }; Assert.Equal(expectedAsset, model.Asset); Assert.Equal(expectedTransformation, model.Transformation); @@ -1285,26 +1278,26 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new VideoTransformationReadyEventVideoTransformationReadyEventData + var model = new VideoTransformationReadyEventChangedData { Asset = new("https://example.com"), Transformation = new() { Type = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, + VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -1321,11 +1314,10 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -1333,26 +1325,26 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new VideoTransformationReadyEventVideoTransformationReadyEventData + var model = new VideoTransformationReadyEventChangedData { Asset = new("https://example.com"), Transformation = new() { Type = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, + VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -1369,47 +1361,41 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.NotNull(deserialized); - VideoTransformationReadyEventVideoTransformationReadyEventDataAsset expectedAsset = new( - "https://example.com" - ); - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation expectedTransformation = - new() + VideoTransformationReadyEventChangedDataAsset expectedAsset = new("https://example.com"); + VideoTransformationReadyEventChangedDataTransformation expectedTransformation = new() + { + Type = VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, + Options = new() { - Type = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, - Options = new() - { - AudioCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, - AutoRotate = true, - Format = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, - Quality = 0, - StreamProtocol = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, - Variants = ["string"], - VideoCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, - }, - Output = new() + AudioCodec = + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, + }, + Output = new() + { + Url = "https://example.com", + VideoMetadata = new() { - Url = "https://example.com", - VideoMetadata = new() - { - Bitrate = 0, - Duration = 0, - Height = 0, - Width = 0, - }, + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, }, - }; + }, + }; Assert.Equal(expectedAsset, deserialized.Asset); Assert.Equal(expectedTransformation, deserialized.Transformation); @@ -1418,26 +1404,26 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new VideoTransformationReadyEventVideoTransformationReadyEventData + var model = new VideoTransformationReadyEventChangedData { Asset = new("https://example.com"), Transformation = new() { Type = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, + VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -1459,26 +1445,26 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new VideoTransformationReadyEventVideoTransformationReadyEventData + var model = new VideoTransformationReadyEventChangedData { Asset = new("https://example.com"), Transformation = new() { Type = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, + VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -1494,18 +1480,18 @@ public void CopyConstructor_Works() }, }; - VideoTransformationReadyEventVideoTransformationReadyEventData copied = new(model); + VideoTransformationReadyEventChangedData copied = new(model); Assert.Equal(model, copied); } } -public class VideoTransformationReadyEventVideoTransformationReadyEventDataAssetTest : TestBase +public class VideoTransformationReadyEventChangedDataAssetTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new VideoTransformationReadyEventVideoTransformationReadyEventDataAsset + var model = new VideoTransformationReadyEventChangedDataAsset { Url = "https://example.com", }; @@ -1518,14 +1504,14 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new VideoTransformationReadyEventVideoTransformationReadyEventDataAsset + var model = new VideoTransformationReadyEventChangedDataAsset { Url = "https://example.com", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -1536,14 +1522,14 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new VideoTransformationReadyEventVideoTransformationReadyEventDataAsset + var model = new VideoTransformationReadyEventChangedDataAsset { Url = "https://example.com", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -1557,7 +1543,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new VideoTransformationReadyEventVideoTransformationReadyEventDataAsset + var model = new VideoTransformationReadyEventChangedDataAsset { Url = "https://example.com", }; @@ -1568,40 +1554,37 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new VideoTransformationReadyEventVideoTransformationReadyEventDataAsset + var model = new VideoTransformationReadyEventChangedDataAsset { Url = "https://example.com", }; - VideoTransformationReadyEventVideoTransformationReadyEventDataAsset copied = new(model); + VideoTransformationReadyEventChangedDataAsset copied = new(model); Assert.Equal(model, copied); } } -public class VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationTest - : TestBase +public class VideoTransformationReadyEventChangedDataTransformationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation + var model = new VideoTransformationReadyEventChangedDataTransformation { - Type = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, + Type = VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, - Format = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + Format = VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -1616,26 +1599,21 @@ public void FieldRoundtrip_Works() }, }; - ApiEnum< - string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType - > expectedType = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation; - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions expectedOptions = - new() - { - AudioCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, - AutoRotate = true, - Format = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, - Quality = 0, - StreamProtocol = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, - Variants = ["string"], - VideoCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, - }; + ApiEnum expectedType = + VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation; + VideoTransformationReadyEventChangedDataTransformationOptions expectedOptions = new() + { + AudioCodec = + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, + }; Output expectedOutput = new() { Url = "https://example.com", @@ -1656,23 +1634,21 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation + var model = new VideoTransformationReadyEventChangedDataTransformation { - Type = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, + Type = VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, - Format = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + Format = VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -1689,7 +1665,7 @@ public void SerializationRoundtrip_Works() string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -1700,23 +1676,21 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation + var model = new VideoTransformationReadyEventChangedDataTransformation { - Type = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, + Type = VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, - Format = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + Format = VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -1733,32 +1707,27 @@ public void FieldRoundtripThroughSerialization_Works() string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - ApiEnum< - string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType - > expectedType = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation; - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions expectedOptions = - new() - { - AudioCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, - AutoRotate = true, - Format = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, - Quality = 0, - StreamProtocol = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, - Variants = ["string"], - VideoCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, - }; + ApiEnum expectedType = + VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation; + VideoTransformationReadyEventChangedDataTransformationOptions expectedOptions = new() + { + AudioCodec = + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, + }; Output expectedOutput = new() { Url = "https://example.com", @@ -1779,23 +1748,21 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation + var model = new VideoTransformationReadyEventChangedDataTransformation { - Type = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, + Type = VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, - Format = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + Format = VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -1816,10 +1783,9 @@ public void Validation_Works() [Fact] public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation + var model = new VideoTransformationReadyEventChangedDataTransformation { - Type = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, + Type = VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, }; Assert.Null(model.Options); @@ -1831,10 +1797,9 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation + var model = new VideoTransformationReadyEventChangedDataTransformation { - Type = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, + Type = VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, }; model.Validate(); @@ -1843,10 +1808,9 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - var model = new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation + var model = new VideoTransformationReadyEventChangedDataTransformation { - Type = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, + Type = VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, // Null should be interpreted as omitted for these properties Options = null, @@ -1862,10 +1826,9 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - var model = new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation + var model = new VideoTransformationReadyEventChangedDataTransformation { - Type = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, + Type = VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, // Null should be interpreted as omitted for these properties Options = null, @@ -1878,23 +1841,21 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation + var model = new VideoTransformationReadyEventChangedDataTransformation { - Type = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, + Type = VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, - Format = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + Format = VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -1909,36 +1870,25 @@ public void CopyConstructor_Works() }, }; - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation copied = new( - model - ); + VideoTransformationReadyEventChangedDataTransformation copied = new(model); Assert.Equal(model, copied); } } -public class VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationTypeTest - : TestBase +public class VideoTransformationReadyEventChangedDataTransformationTypeTest : TestBase { [Theory] - [InlineData( - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation - )] - [InlineData( - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.GifToVideo - )] - [InlineData( - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoThumbnail - )] + [InlineData(VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation)] + [InlineData(VideoTransformationReadyEventChangedDataTransformationType.GifToVideo)] + [InlineData(VideoTransformationReadyEventChangedDataTransformationType.VideoThumbnail)] public void Validation_Works( - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType rawValue + VideoTransformationReadyEventChangedDataTransformationType rawValue ) { // force implicit conversion because Theory can't do that for us - ApiEnum< - string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType - > value = rawValue; + ApiEnum value = + rawValue; value.Validate(); } @@ -1946,10 +1896,7 @@ VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum< - string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType - > + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -1957,31 +1904,20 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData( - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation - )] - [InlineData( - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.GifToVideo - )] - [InlineData( - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoThumbnail - )] + [InlineData(VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation)] + [InlineData(VideoTransformationReadyEventChangedDataTransformationType.GifToVideo)] + [InlineData(VideoTransformationReadyEventChangedDataTransformationType.VideoThumbnail)] public void SerializationRoundtrip_Works( - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType rawValue + VideoTransformationReadyEventChangedDataTransformationType rawValue ) { // force implicit conversion because Theory can't do that for us - ApiEnum< - string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType - > value = rawValue; + ApiEnum value = + rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum< - string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType - > + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -1991,68 +1927,58 @@ VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType public void InvalidEnumSerializationRoundtrip_Works() { var value = JsonSerializer.Deserialize< - ApiEnum< - string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType - > + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum< - string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType - > + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsTest - : TestBase +public class VideoTransformationReadyEventChangedDataTransformationOptionsTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = - new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions - { - AudioCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, - AutoRotate = true, - Format = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, - Quality = 0, - StreamProtocol = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, - Variants = ["string"], - VideoCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, - }; + var model = new VideoTransformationReadyEventChangedDataTransformationOptions + { + AudioCodec = + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, + }; ApiEnum< string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec > expectedAudioCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac; + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac; bool expectedAutoRotate = true; ApiEnum< string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat - > expectedFormat = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4; + VideoTransformationReadyEventChangedDataTransformationOptionsFormat + > expectedFormat = VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4; long expectedQuality = 0; ApiEnum< string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol > expectedStreamProtocol = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls; + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls; List expectedVariants = ["string"]; ApiEnum< string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec > expectedVideoCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264; + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264; Assert.Equal(expectedAudioCodec, model.AudioCodec); Assert.Equal(expectedAutoRotate, model.AutoRotate); @@ -2071,25 +1997,23 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = - new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions - { - AudioCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, - AutoRotate = true, - Format = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, - Quality = 0, - StreamProtocol = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, - Variants = ["string"], - VideoCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, - }; + var model = new VideoTransformationReadyEventChangedDataTransformationOptions + { + AudioCodec = + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, + }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -2100,25 +2024,23 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = - new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions - { - AudioCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, - AutoRotate = true, - Format = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, - Quality = 0, - StreamProtocol = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, - Variants = ["string"], - VideoCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, - }; + var model = new VideoTransformationReadyEventChangedDataTransformationOptions + { + AudioCodec = + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, + }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -2126,27 +2048,26 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum< string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec > expectedAudioCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac; + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac; bool expectedAutoRotate = true; ApiEnum< string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat - > expectedFormat = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4; + VideoTransformationReadyEventChangedDataTransformationOptionsFormat + > expectedFormat = VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4; long expectedQuality = 0; ApiEnum< string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol > expectedStreamProtocol = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls; + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls; List expectedVariants = ["string"]; ApiEnum< string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec > expectedVideoCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264; + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264; Assert.Equal(expectedAudioCodec, deserialized.AudioCodec); Assert.Equal(expectedAutoRotate, deserialized.AutoRotate); @@ -2165,21 +2086,19 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = - new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions - { - AudioCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, - AutoRotate = true, - Format = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, - Quality = 0, - StreamProtocol = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, - Variants = ["string"], - VideoCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, - }; + var model = new VideoTransformationReadyEventChangedDataTransformationOptions + { + AudioCodec = + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, + }; model.Validate(); } @@ -2187,9 +2106,7 @@ public void Validation_Works() [Fact] public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = - new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions - { }; + var model = new VideoTransformationReadyEventChangedDataTransformationOptions { }; Assert.Null(model.AudioCodec); Assert.False(model.RawData.ContainsKey("audio_codec")); @@ -2210,9 +2127,7 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = - new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions - { }; + var model = new VideoTransformationReadyEventChangedDataTransformationOptions { }; model.Validate(); } @@ -2220,18 +2135,17 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - var model = - new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions - { - // Null should be interpreted as omitted for these properties - AudioCodec = null, - AutoRotate = null, - Format = null, - Quality = null, - StreamProtocol = null, - Variants = null, - VideoCodec = null, - }; + var model = new VideoTransformationReadyEventChangedDataTransformationOptions + { + // Null should be interpreted as omitted for these properties + AudioCodec = null, + AutoRotate = null, + Format = null, + Quality = null, + StreamProtocol = null, + Variants = null, + VideoCodec = null, + }; Assert.Null(model.AudioCodec); Assert.False(model.RawData.ContainsKey("audio_codec")); @@ -2252,18 +2166,17 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - var model = - new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions - { - // Null should be interpreted as omitted for these properties - AudioCodec = null, - AutoRotate = null, - Format = null, - Quality = null, - StreamProtocol = null, - Variants = null, - VideoCodec = null, - }; + var model = new VideoTransformationReadyEventChangedDataTransformationOptions + { + // Null should be interpreted as omitted for these properties + AudioCodec = null, + AutoRotate = null, + Format = null, + Quality = null, + StreamProtocol = null, + Variants = null, + VideoCodec = null, + }; model.Validate(); } @@ -2271,47 +2184,39 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = - new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions - { - AudioCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, - AutoRotate = true, - Format = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, - Quality = 0, - StreamProtocol = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, - Variants = ["string"], - VideoCodec = - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, - }; + var model = new VideoTransformationReadyEventChangedDataTransformationOptions + { + AudioCodec = + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, + }; - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions copied = - new(model); + VideoTransformationReadyEventChangedDataTransformationOptions copied = new(model); Assert.Equal(model, copied); } } -public class VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodecTest - : TestBase +public class VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodecTest : TestBase { [Theory] - [InlineData( - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac - )] - [InlineData( - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Opus - )] + [InlineData(VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac)] + [InlineData(VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Opus)] public void Validation_Works( - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec rawValue + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec > value = rawValue; value.Validate(); } @@ -2320,10 +2225,7 @@ VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOpti public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum< - string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec - > + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -2331,28 +2233,21 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData( - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac - )] - [InlineData( - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Opus - )] + [InlineData(VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac)] + [InlineData(VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Opus)] public void SerializationRoundtrip_Works( - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec rawValue + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum< - string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec - > + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -2362,51 +2257,32 @@ VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOpti public void InvalidEnumSerializationRoundtrip_Works() { var value = JsonSerializer.Deserialize< - ApiEnum< - string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec - > + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum< - string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec - > + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormatTest - : TestBase +public class VideoTransformationReadyEventChangedDataTransformationOptionsFormatTest : TestBase { [Theory] - [InlineData( - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4 - )] - [InlineData( - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Webm - )] - [InlineData( - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Jpg - )] - [InlineData( - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Png - )] - [InlineData( - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Webp - )] + [InlineData(VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4)] + [InlineData(VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Webm)] + [InlineData(VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Jpg)] + [InlineData(VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Png)] + [InlineData(VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Webp)] public void Validation_Works( - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat rawValue + VideoTransformationReadyEventChangedDataTransformationOptionsFormat rawValue ) { // force implicit conversion because Theory can't do that for us - ApiEnum< - string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat - > value = rawValue; + ApiEnum value = + rawValue; value.Validate(); } @@ -2414,10 +2290,7 @@ VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOpti public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum< - string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat - > + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -2425,37 +2298,22 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData( - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4 - )] - [InlineData( - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Webm - )] - [InlineData( - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Jpg - )] - [InlineData( - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Png - )] - [InlineData( - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Webp - )] + [InlineData(VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4)] + [InlineData(VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Webm)] + [InlineData(VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Jpg)] + [InlineData(VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Png)] + [InlineData(VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Webp)] public void SerializationRoundtrip_Works( - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat rawValue + VideoTransformationReadyEventChangedDataTransformationOptionsFormat rawValue ) { // force implicit conversion because Theory can't do that for us - ApiEnum< - string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat - > value = rawValue; + ApiEnum value = + rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum< - string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat - > + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -2465,41 +2323,31 @@ VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOpti public void InvalidEnumSerializationRoundtrip_Works() { var value = JsonSerializer.Deserialize< - ApiEnum< - string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat - > + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum< - string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat - > + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocolTest +public class VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocolTest : TestBase { [Theory] - [InlineData( - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls - )] - [InlineData( - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Dash - )] + [InlineData(VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls)] + [InlineData(VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Dash)] public void Validation_Works( - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol rawValue + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol > value = rawValue; value.Validate(); } @@ -2510,7 +2358,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -2519,27 +2367,23 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData( - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls - )] - [InlineData( - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Dash - )] + [InlineData(VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls)] + [InlineData(VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Dash)] public void SerializationRoundtrip_Works( - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol rawValue + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol > >(json, ModelBase.SerializerOptions); @@ -2552,14 +2396,14 @@ public void InvalidEnumSerializationRoundtrip_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol > >(json, ModelBase.SerializerOptions); @@ -2567,27 +2411,20 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodecTest - : TestBase +public class VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodecTest : TestBase { [Theory] - [InlineData( - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264 - )] - [InlineData( - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.Vp9 - )] - [InlineData( - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.Av1 - )] + [InlineData(VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264)] + [InlineData(VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.Vp9)] + [InlineData(VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.Av1)] public void Validation_Works( - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec rawValue + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec > value = rawValue; value.Validate(); } @@ -2596,10 +2433,7 @@ VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOpti public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum< - string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec - > + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -2607,31 +2441,22 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData( - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264 - )] - [InlineData( - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.Vp9 - )] - [InlineData( - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.Av1 - )] + [InlineData(VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264)] + [InlineData(VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.Vp9)] + [InlineData(VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.Av1)] public void SerializationRoundtrip_Works( - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec rawValue + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum< - string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec - > + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -2641,17 +2466,11 @@ VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOpti public void InvalidEnumSerializationRoundtrip_Works() { var value = JsonSerializer.Deserialize< - ApiEnum< - string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec - > + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum< - string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec - > + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -2930,12 +2749,12 @@ public void CopyConstructor_Works() } } -public class VideoTransformationReadyEventVideoTransformationReadyEventRequestTest : TestBase +public class VideoTransformationReadyEventChangedRequestTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new VideoTransformationReadyEventVideoTransformationReadyEventRequest + var model = new VideoTransformationReadyEventChangedRequest { Url = "https://example.com", XRequestID = "x_request_id", @@ -2954,7 +2773,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new VideoTransformationReadyEventVideoTransformationReadyEventRequest + var model = new VideoTransformationReadyEventChangedRequest { Url = "https://example.com", XRequestID = "x_request_id", @@ -2962,11 +2781,10 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -2974,7 +2792,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new VideoTransformationReadyEventVideoTransformationReadyEventRequest + var model = new VideoTransformationReadyEventChangedRequest { Url = "https://example.com", XRequestID = "x_request_id", @@ -2982,11 +2800,10 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.NotNull(deserialized); string expectedUrl = "https://example.com"; @@ -3001,7 +2818,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new VideoTransformationReadyEventVideoTransformationReadyEventRequest + var model = new VideoTransformationReadyEventChangedRequest { Url = "https://example.com", XRequestID = "x_request_id", @@ -3014,7 +2831,7 @@ public void Validation_Works() [Fact] public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new VideoTransformationReadyEventVideoTransformationReadyEventRequest + var model = new VideoTransformationReadyEventChangedRequest { Url = "https://example.com", XRequestID = "x_request_id", @@ -3027,7 +2844,7 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = new VideoTransformationReadyEventVideoTransformationReadyEventRequest + var model = new VideoTransformationReadyEventChangedRequest { Url = "https://example.com", XRequestID = "x_request_id", @@ -3039,7 +2856,7 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - var model = new VideoTransformationReadyEventVideoTransformationReadyEventRequest + var model = new VideoTransformationReadyEventChangedRequest { Url = "https://example.com", XRequestID = "x_request_id", @@ -3055,7 +2872,7 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - var model = new VideoTransformationReadyEventVideoTransformationReadyEventRequest + var model = new VideoTransformationReadyEventChangedRequest { Url = "https://example.com", XRequestID = "x_request_id", @@ -3070,14 +2887,14 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new VideoTransformationReadyEventVideoTransformationReadyEventRequest + var model = new VideoTransformationReadyEventChangedRequest { Url = "https://example.com", XRequestID = "x_request_id", UserAgent = "user_agent", }; - VideoTransformationReadyEventVideoTransformationReadyEventRequest copied = new(model); + VideoTransformationReadyEventChangedRequest copied = new(model); Assert.Equal(model, copied); } diff --git a/src/Imagekit/Core/ModelBase.cs b/src/Imagekit/Core/ModelBase.cs index 941432ed..bbcf4b60 100644 --- a/src/Imagekit/Core/ModelBase.cs +++ b/src/Imagekit/Core/ModelBase.cs @@ -140,23 +140,23 @@ protected ModelBase(ModelBase modelBase) >(), new ApiEnumConverter< string, - Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType + Webhooks::VideoTransformationReadyEventChangedDataTransformationType >(), new ApiEnumConverter< string, - Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec + Webhooks::VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec >(), new ApiEnumConverter< string, - Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat + Webhooks::VideoTransformationReadyEventChangedDataTransformationOptionsFormat >(), new ApiEnumConverter< string, - Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol + Webhooks::VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol >(), new ApiEnumConverter< string, - Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec + Webhooks::VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec >(), }, }; diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEvent.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEvent.cs index a3dffdaa..69e871e9 100644 --- a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEvent.cs +++ b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEvent.cs @@ -60,14 +60,12 @@ public required string Type init { this._rawData.Set("created_at", value); } } - public required VideoTransformationReadyEventVideoTransformationReadyEventData Data + public required VideoTransformationReadyEventChangedData Data { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "data" - ); + return this._rawData.GetNotNullClass("data"); } init { this._rawData.Set("data", value); } } @@ -75,12 +73,12 @@ public required VideoTransformationReadyEventVideoTransformationReadyEventData D /// /// Information about the original request that triggered the video transformation. /// - public required VideoTransformationReadyEventVideoTransformationReadyEventRequest Request + public required VideoTransformationReadyEventChangedRequest Request { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "request" ); } @@ -171,11 +169,11 @@ IReadOnlyDictionary rawData /// [JsonConverter( typeof(JsonModelConverter< - VideoTransformationReadyEventVideoTransformationReadyEvent, - VideoTransformationReadyEventVideoTransformationReadyEventFromRaw + VideoTransformationReadyEventChanged, + VideoTransformationReadyEventChangedFromRaw >) )] -public sealed record class VideoTransformationReadyEventVideoTransformationReadyEvent : JsonModel +public sealed record class VideoTransformationReadyEventChanged : JsonModel { /// /// Timestamp when the event was created in ISO8601 format. @@ -190,14 +188,12 @@ public sealed record class VideoTransformationReadyEventVideoTransformationReady init { this._rawData.Set("created_at", value); } } - public required VideoTransformationReadyEventVideoTransformationReadyEventData Data + public required VideoTransformationReadyEventChangedData Data { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "data" - ); + return this._rawData.GetNotNullClass("data"); } init { this._rawData.Set("data", value); } } @@ -205,12 +201,12 @@ public required VideoTransformationReadyEventVideoTransformationReadyEventData D /// /// Information about the original request that triggered the video transformation. /// - public required VideoTransformationReadyEventVideoTransformationReadyEventRequest Request + public required VideoTransformationReadyEventChangedRequest Request { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "request" ); } @@ -266,22 +262,20 @@ public override void Validate() this.Timings?.Validate(); } - public VideoTransformationReadyEventVideoTransformationReadyEvent() + public VideoTransformationReadyEventChanged() { this.Type = JsonSerializer.SerializeToElement("video.transformation.ready"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public VideoTransformationReadyEventVideoTransformationReadyEvent( - VideoTransformationReadyEventVideoTransformationReadyEvent videoTransformationReadyEventVideoTransformationReadyEvent + public VideoTransformationReadyEventChanged( + VideoTransformationReadyEventChanged videoTransformationReadyEventChanged ) - : base(videoTransformationReadyEventVideoTransformationReadyEvent) { } + : base(videoTransformationReadyEventChanged) { } #pragma warning restore CS8618 - public VideoTransformationReadyEventVideoTransformationReadyEvent( - IReadOnlyDictionary rawData - ) + public VideoTransformationReadyEventChanged(IReadOnlyDictionary rawData) { this._rawData = new(rawData); @@ -290,16 +284,14 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - VideoTransformationReadyEventVideoTransformationReadyEvent( - FrozenDictionary rawData - ) + VideoTransformationReadyEventChanged(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static VideoTransformationReadyEventVideoTransformationReadyEvent FromRawUnchecked( + /// + public static VideoTransformationReadyEventChanged FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -307,45 +299,44 @@ IReadOnlyDictionary rawData } } -class VideoTransformationReadyEventVideoTransformationReadyEventFromRaw - : IFromRawJson +class VideoTransformationReadyEventChangedFromRaw + : IFromRawJson { /// - public VideoTransformationReadyEventVideoTransformationReadyEvent FromRawUnchecked( + public VideoTransformationReadyEventChanged FromRawUnchecked( IReadOnlyDictionary rawData - ) => VideoTransformationReadyEventVideoTransformationReadyEvent.FromRawUnchecked(rawData); + ) => VideoTransformationReadyEventChanged.FromRawUnchecked(rawData); } [JsonConverter( typeof(JsonModelConverter< - VideoTransformationReadyEventVideoTransformationReadyEventData, - VideoTransformationReadyEventVideoTransformationReadyEventDataFromRaw + VideoTransformationReadyEventChangedData, + VideoTransformationReadyEventChangedDataFromRaw >) )] -public sealed record class VideoTransformationReadyEventVideoTransformationReadyEventData - : JsonModel +public sealed record class VideoTransformationReadyEventChangedData : JsonModel { /// /// Information about the source video asset being transformed. /// - public required VideoTransformationReadyEventVideoTransformationReadyEventDataAsset Asset + public required VideoTransformationReadyEventChangedDataAsset Asset { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "asset" ); } init { this._rawData.Set("asset", value); } } - public required VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation Transformation + public required VideoTransformationReadyEventChangedDataTransformation Transformation { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "transformation" ); } @@ -359,17 +350,17 @@ public override void Validate() this.Transformation.Validate(); } - public VideoTransformationReadyEventVideoTransformationReadyEventData() { } + public VideoTransformationReadyEventChangedData() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public VideoTransformationReadyEventVideoTransformationReadyEventData( - VideoTransformationReadyEventVideoTransformationReadyEventData videoTransformationReadyEventVideoTransformationReadyEventData + public VideoTransformationReadyEventChangedData( + VideoTransformationReadyEventChangedData videoTransformationReadyEventChangedData ) - : base(videoTransformationReadyEventVideoTransformationReadyEventData) { } + : base(videoTransformationReadyEventChangedData) { } #pragma warning restore CS8618 - public VideoTransformationReadyEventVideoTransformationReadyEventData( + public VideoTransformationReadyEventChangedData( IReadOnlyDictionary rawData ) { @@ -378,16 +369,14 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - VideoTransformationReadyEventVideoTransformationReadyEventData( - FrozenDictionary rawData - ) + VideoTransformationReadyEventChangedData(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static VideoTransformationReadyEventVideoTransformationReadyEventData FromRawUnchecked( + /// + public static VideoTransformationReadyEventChangedData FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -395,13 +384,13 @@ IReadOnlyDictionary rawData } } -class VideoTransformationReadyEventVideoTransformationReadyEventDataFromRaw - : IFromRawJson +class VideoTransformationReadyEventChangedDataFromRaw + : IFromRawJson { /// - public VideoTransformationReadyEventVideoTransformationReadyEventData FromRawUnchecked( + public VideoTransformationReadyEventChangedData FromRawUnchecked( IReadOnlyDictionary rawData - ) => VideoTransformationReadyEventVideoTransformationReadyEventData.FromRawUnchecked(rawData); + ) => VideoTransformationReadyEventChangedData.FromRawUnchecked(rawData); } /// @@ -409,12 +398,11 @@ IReadOnlyDictionary rawData /// [JsonConverter( typeof(JsonModelConverter< - VideoTransformationReadyEventVideoTransformationReadyEventDataAsset, - VideoTransformationReadyEventVideoTransformationReadyEventDataAssetFromRaw + VideoTransformationReadyEventChangedDataAsset, + VideoTransformationReadyEventChangedDataAssetFromRaw >) )] -public sealed record class VideoTransformationReadyEventVideoTransformationReadyEventDataAsset - : JsonModel +public sealed record class VideoTransformationReadyEventChangedDataAsset : JsonModel { /// /// URL to download or access the source video file. @@ -435,17 +423,17 @@ public override void Validate() _ = this.Url; } - public VideoTransformationReadyEventVideoTransformationReadyEventDataAsset() { } + public VideoTransformationReadyEventChangedDataAsset() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public VideoTransformationReadyEventVideoTransformationReadyEventDataAsset( - VideoTransformationReadyEventVideoTransformationReadyEventDataAsset videoTransformationReadyEventVideoTransformationReadyEventDataAsset + public VideoTransformationReadyEventChangedDataAsset( + VideoTransformationReadyEventChangedDataAsset videoTransformationReadyEventChangedDataAsset ) - : base(videoTransformationReadyEventVideoTransformationReadyEventDataAsset) { } + : base(videoTransformationReadyEventChangedDataAsset) { } #pragma warning restore CS8618 - public VideoTransformationReadyEventVideoTransformationReadyEventDataAsset( + public VideoTransformationReadyEventChangedDataAsset( IReadOnlyDictionary rawData ) { @@ -454,16 +442,14 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - VideoTransformationReadyEventVideoTransformationReadyEventDataAsset( - FrozenDictionary rawData - ) + VideoTransformationReadyEventChangedDataAsset(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static VideoTransformationReadyEventVideoTransformationReadyEventDataAsset FromRawUnchecked( + /// + public static VideoTransformationReadyEventChangedDataAsset FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -471,52 +457,42 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public VideoTransformationReadyEventVideoTransformationReadyEventDataAsset(string url) + public VideoTransformationReadyEventChangedDataAsset(string url) : this() { this.Url = url; } } -class VideoTransformationReadyEventVideoTransformationReadyEventDataAssetFromRaw - : IFromRawJson +class VideoTransformationReadyEventChangedDataAssetFromRaw + : IFromRawJson { /// - public VideoTransformationReadyEventVideoTransformationReadyEventDataAsset FromRawUnchecked( + public VideoTransformationReadyEventChangedDataAsset FromRawUnchecked( IReadOnlyDictionary rawData - ) => - VideoTransformationReadyEventVideoTransformationReadyEventDataAsset.FromRawUnchecked( - rawData - ); + ) => VideoTransformationReadyEventChangedDataAsset.FromRawUnchecked(rawData); } [JsonConverter( typeof(JsonModelConverter< - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationFromRaw + VideoTransformationReadyEventChangedDataTransformation, + VideoTransformationReadyEventChangedDataTransformationFromRaw >) )] -public sealed record class VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation - : JsonModel +public sealed record class VideoTransformationReadyEventChangedDataTransformation : JsonModel { /// /// Type of video transformation: - `video-transformation`: Standard video processing /// (resize, format conversion, etc.) - `gif-to-video`: Convert animated GIF /// to video format - `video-thumbnail`: Generate thumbnail image from video /// - public required ApiEnum< - string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType - > Type + public required ApiEnum Type { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum< - string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType - > + ApiEnum >("type"); } init { this._rawData.Set("type", value); } @@ -525,12 +501,12 @@ public required ApiEnum< /// /// Configuration options for video transformations. /// - public VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions? Options + public VideoTransformationReadyEventChangedDataTransformationOptions? Options { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "options" ); } @@ -574,17 +550,17 @@ public override void Validate() this.Output?.Validate(); } - public VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation() { } + public VideoTransformationReadyEventChangedDataTransformation() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation( - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation videoTransformationReadyEventVideoTransformationReadyEventDataTransformation + public VideoTransformationReadyEventChangedDataTransformation( + VideoTransformationReadyEventChangedDataTransformation videoTransformationReadyEventChangedDataTransformation ) - : base(videoTransformationReadyEventVideoTransformationReadyEventDataTransformation) { } + : base(videoTransformationReadyEventChangedDataTransformation) { } #pragma warning restore CS8618 - public VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation( + public VideoTransformationReadyEventChangedDataTransformation( IReadOnlyDictionary rawData ) { @@ -593,7 +569,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation( + VideoTransformationReadyEventChangedDataTransformation( FrozenDictionary rawData ) { @@ -601,8 +577,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation FromRawUnchecked( + /// + public static VideoTransformationReadyEventChangedDataTransformation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -610,11 +586,8 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation( - ApiEnum< - string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType - > type + public VideoTransformationReadyEventChangedDataTransformation( + ApiEnum type ) : this() { @@ -622,16 +595,13 @@ public VideoTransformationReadyEventVideoTransformationReadyEventDataTransformat } } -class VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationFromRaw - : IFromRawJson +class VideoTransformationReadyEventChangedDataTransformationFromRaw + : IFromRawJson { /// - public VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation FromRawUnchecked( + public VideoTransformationReadyEventChangedDataTransformation FromRawUnchecked( IReadOnlyDictionary rawData - ) => - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation.FromRawUnchecked( - rawData - ); + ) => VideoTransformationReadyEventChangedDataTransformation.FromRawUnchecked(rawData); } /// @@ -639,20 +609,18 @@ IReadOnlyDictionary rawData /// (resize, format conversion, etc.) - `gif-to-video`: Convert animated GIF to video /// format - `video-thumbnail`: Generate thumbnail image from video /// -[JsonConverter( - typeof(VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationTypeConverter) -)] -public enum VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType +[JsonConverter(typeof(VideoTransformationReadyEventChangedDataTransformationTypeConverter))] +public enum VideoTransformationReadyEventChangedDataTransformationType { VideoTransformation, GifToVideo, VideoThumbnail, } -sealed class VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationTypeConverter - : JsonConverter +sealed class VideoTransformationReadyEventChangedDataTransformationTypeConverter + : JsonConverter { - public override VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType Read( + public override VideoTransformationReadyEventChangedDataTransformationType Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -661,20 +629,17 @@ JsonSerializerOptions options return JsonSerializer.Deserialize(ref reader, options) switch { "video-transformation" => - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, - "gif-to-video" => - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.GifToVideo, + VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, + "gif-to-video" => VideoTransformationReadyEventChangedDataTransformationType.GifToVideo, "video-thumbnail" => - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoThumbnail, - _ => (VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType)( - -1 - ), + VideoTransformationReadyEventChangedDataTransformationType.VideoThumbnail, + _ => (VideoTransformationReadyEventChangedDataTransformationType)(-1), }; } public override void Write( Utf8JsonWriter writer, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType value, + VideoTransformationReadyEventChangedDataTransformationType value, JsonSerializerOptions options ) { @@ -682,11 +647,11 @@ JsonSerializerOptions options writer, value switch { - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation => + VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation => "video-transformation", - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.GifToVideo => + VideoTransformationReadyEventChangedDataTransformationType.GifToVideo => "gif-to-video", - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoThumbnail => + VideoTransformationReadyEventChangedDataTransformationType.VideoThumbnail => "video-thumbnail", _ => throw new ImageKitInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) @@ -702,19 +667,18 @@ JsonSerializerOptions options /// [JsonConverter( typeof(JsonModelConverter< - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFromRaw + VideoTransformationReadyEventChangedDataTransformationOptions, + VideoTransformationReadyEventChangedDataTransformationOptionsFromRaw >) )] -public sealed record class VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions - : JsonModel +public sealed record class VideoTransformationReadyEventChangedDataTransformationOptions : JsonModel { /// /// Audio codec used for encoding (aac or opus). /// public ApiEnum< string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec >? AudioCodec { get @@ -723,7 +687,7 @@ public ApiEnum< return this._rawData.GetNullableClass< ApiEnum< string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec > >("audio_codec"); } @@ -764,17 +728,14 @@ public bool? AutoRotate /// public ApiEnum< string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat + VideoTransformationReadyEventChangedDataTransformationOptionsFormat >? Format { get { this._rawData.Freeze(); return this._rawData.GetNullableClass< - ApiEnum< - string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat - > + ApiEnum >("format"); } init @@ -814,7 +775,7 @@ public long? Quality /// public ApiEnum< string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol >? StreamProtocol { get @@ -823,7 +784,7 @@ public ApiEnum< return this._rawData.GetNullableClass< ApiEnum< string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol > >("stream_protocol"); } @@ -867,7 +828,7 @@ public IReadOnlyList? Variants /// public ApiEnum< string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec >? VideoCodec { get @@ -876,7 +837,7 @@ public ApiEnum< return this._rawData.GetNullableClass< ApiEnum< string, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec > >("video_codec"); } @@ -903,18 +864,17 @@ public override void Validate() this.VideoCodec?.Validate(); } - public VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions() { } + public VideoTransformationReadyEventChangedDataTransformationOptions() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions( - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions videoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions + public VideoTransformationReadyEventChangedDataTransformationOptions( + VideoTransformationReadyEventChangedDataTransformationOptions videoTransformationReadyEventChangedDataTransformationOptions ) - : base(videoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions) - { } + : base(videoTransformationReadyEventChangedDataTransformationOptions) { } #pragma warning restore CS8618 - public VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions( + public VideoTransformationReadyEventChangedDataTransformationOptions( IReadOnlyDictionary rawData ) { @@ -923,7 +883,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions( + VideoTransformationReadyEventChangedDataTransformationOptions( FrozenDictionary rawData ) { @@ -931,8 +891,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions FromRawUnchecked( + /// + public static VideoTransformationReadyEventChangedDataTransformationOptions FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -940,34 +900,31 @@ IReadOnlyDictionary rawData } } -class VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFromRaw - : IFromRawJson +class VideoTransformationReadyEventChangedDataTransformationOptionsFromRaw + : IFromRawJson { /// - public VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions FromRawUnchecked( + public VideoTransformationReadyEventChangedDataTransformationOptions FromRawUnchecked( IReadOnlyDictionary rawData - ) => - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions.FromRawUnchecked( - rawData - ); + ) => VideoTransformationReadyEventChangedDataTransformationOptions.FromRawUnchecked(rawData); } /// /// Audio codec used for encoding (aac or opus). /// [JsonConverter( - typeof(VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodecConverter) + typeof(VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodecConverter) )] -public enum VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec +public enum VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec { Aac, Opus, } -sealed class VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodecConverter - : JsonConverter +sealed class VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodecConverter + : JsonConverter { - public override VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec Read( + public override VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -975,20 +932,15 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "aac" => - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, - "opus" => - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Opus, - _ => - (VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec)( - -1 - ), + "aac" => VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, + "opus" => VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Opus, + _ => (VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec)(-1), }; } public override void Write( Utf8JsonWriter writer, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec value, + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec value, JsonSerializerOptions options ) { @@ -996,9 +948,9 @@ JsonSerializerOptions options writer, value switch { - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac => + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac => "aac", - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Opus => + VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Opus => "opus", _ => throw new ImageKitInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) @@ -1013,9 +965,9 @@ JsonSerializerOptions options /// Output format for the transformed video or thumbnail. /// [JsonConverter( - typeof(VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormatConverter) + typeof(VideoTransformationReadyEventChangedDataTransformationOptionsFormatConverter) )] -public enum VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat +public enum VideoTransformationReadyEventChangedDataTransformationOptionsFormat { Mp4, Webm, @@ -1024,10 +976,10 @@ public enum VideoTransformationReadyEventVideoTransformationReadyEventDataTransf Webp, } -sealed class VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormatConverter - : JsonConverter +sealed class VideoTransformationReadyEventChangedDataTransformationOptionsFormatConverter + : JsonConverter { - public override VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat Read( + public override VideoTransformationReadyEventChangedDataTransformationOptionsFormat Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -1035,26 +987,18 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "mp4" => - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, - "webm" => - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Webm, - "jpg" => - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Jpg, - "png" => - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Png, - "webp" => - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Webp, - _ => - (VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat)( - -1 - ), + "mp4" => VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, + "webm" => VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Webm, + "jpg" => VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Jpg, + "png" => VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Png, + "webp" => VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Webp, + _ => (VideoTransformationReadyEventChangedDataTransformationOptionsFormat)(-1), }; } public override void Write( Utf8JsonWriter writer, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat value, + VideoTransformationReadyEventChangedDataTransformationOptionsFormat value, JsonSerializerOptions options ) { @@ -1062,16 +1006,11 @@ JsonSerializerOptions options writer, value switch { - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4 => - "mp4", - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Webm => - "webm", - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Jpg => - "jpg", - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Png => - "png", - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Webp => - "webp", + VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4 => "mp4", + VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Webm => "webm", + VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Jpg => "jpg", + VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Png => "png", + VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Webp => "webp", _ => throw new ImageKitInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -1085,18 +1024,18 @@ JsonSerializerOptions options /// Streaming protocol for adaptive bitrate streaming. /// [JsonConverter( - typeof(VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocolConverter) + typeof(VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocolConverter) )] -public enum VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol +public enum VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol { Hls, Dash, } -sealed class VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocolConverter - : JsonConverter +sealed class VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocolConverter + : JsonConverter { - public override VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol Read( + public override VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -1105,19 +1044,16 @@ JsonSerializerOptions options return JsonSerializer.Deserialize(ref reader, options) switch { "HLS" => - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, "DASH" => - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Dash, - _ => - (VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol)( - -1 - ), + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Dash, + _ => (VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol)(-1), }; } public override void Write( Utf8JsonWriter writer, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol value, + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol value, JsonSerializerOptions options ) { @@ -1125,9 +1061,9 @@ JsonSerializerOptions options writer, value switch { - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls => + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls => "HLS", - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Dash => + VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Dash => "DASH", _ => throw new ImageKitInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) @@ -1142,19 +1078,19 @@ JsonSerializerOptions options /// Video codec used for encoding (h264, vp9, or av1). /// [JsonConverter( - typeof(VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodecConverter) + typeof(VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodecConverter) )] -public enum VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec +public enum VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec { H264, Vp9, Av1, } -sealed class VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodecConverter - : JsonConverter +sealed class VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodecConverter + : JsonConverter { - public override VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec Read( + public override VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -1162,22 +1098,16 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "h264" => - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, - "vp9" => - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.Vp9, - "av1" => - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.Av1, - _ => - (VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec)( - -1 - ), + "h264" => VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, + "vp9" => VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.Vp9, + "av1" => VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.Av1, + _ => (VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec)(-1), }; } public override void Write( Utf8JsonWriter writer, - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec value, + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec value, JsonSerializerOptions options ) { @@ -1185,11 +1115,11 @@ JsonSerializerOptions options writer, value switch { - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264 => + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264 => "h264", - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.Vp9 => + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.Vp9 => "vp9", - VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.Av1 => + VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.Av1 => "av1", _ => throw new ImageKitInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) @@ -1396,12 +1326,11 @@ public VideoMetadata FromRawUnchecked(IReadOnlyDictionary r /// [JsonConverter( typeof(JsonModelConverter< - VideoTransformationReadyEventVideoTransformationReadyEventRequest, - VideoTransformationReadyEventVideoTransformationReadyEventRequestFromRaw + VideoTransformationReadyEventChangedRequest, + VideoTransformationReadyEventChangedRequestFromRaw >) )] -public sealed record class VideoTransformationReadyEventVideoTransformationReadyEventRequest - : JsonModel +public sealed record class VideoTransformationReadyEventChangedRequest : JsonModel { /// /// Full URL of the transformation request that was submitted. @@ -1458,17 +1387,17 @@ public override void Validate() _ = this.UserAgent; } - public VideoTransformationReadyEventVideoTransformationReadyEventRequest() { } + public VideoTransformationReadyEventChangedRequest() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public VideoTransformationReadyEventVideoTransformationReadyEventRequest( - VideoTransformationReadyEventVideoTransformationReadyEventRequest videoTransformationReadyEventVideoTransformationReadyEventRequest + public VideoTransformationReadyEventChangedRequest( + VideoTransformationReadyEventChangedRequest videoTransformationReadyEventChangedRequest ) - : base(videoTransformationReadyEventVideoTransformationReadyEventRequest) { } + : base(videoTransformationReadyEventChangedRequest) { } #pragma warning restore CS8618 - public VideoTransformationReadyEventVideoTransformationReadyEventRequest( + public VideoTransformationReadyEventChangedRequest( IReadOnlyDictionary rawData ) { @@ -1477,16 +1406,14 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - VideoTransformationReadyEventVideoTransformationReadyEventRequest( - FrozenDictionary rawData - ) + VideoTransformationReadyEventChangedRequest(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static VideoTransformationReadyEventVideoTransformationReadyEventRequest FromRawUnchecked( + /// + public static VideoTransformationReadyEventChangedRequest FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -1494,14 +1421,13 @@ IReadOnlyDictionary rawData } } -class VideoTransformationReadyEventVideoTransformationReadyEventRequestFromRaw - : IFromRawJson +class VideoTransformationReadyEventChangedRequestFromRaw + : IFromRawJson { /// - public VideoTransformationReadyEventVideoTransformationReadyEventRequest FromRawUnchecked( + public VideoTransformationReadyEventChangedRequest FromRawUnchecked( IReadOnlyDictionary rawData - ) => - VideoTransformationReadyEventVideoTransformationReadyEventRequest.FromRawUnchecked(rawData); + ) => VideoTransformationReadyEventChangedRequest.FromRawUnchecked(rawData); } /// From 6527394d36ea7c98a7ed263aecbd69295c2e3a1f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sun, 17 May 2026 03:35:13 +0000 Subject: [PATCH 123/129] chore: add titles for dotnet build --- .stats.yml | 4 +- .../Models/Assets/AssetListResponseTest.cs | 12 +- .../Beta/V2/Files/FileUploadResponseTest.cs | 140 +- src/Imagekit.Tests/Models/Files/FileTest.cs | 140 +- .../Models/Files/FileUpdateResponseTest.cs | 92 +- .../Models/Files/FileUploadResponseTest.cs | 276 ++-- .../Models/Webhooks/FileCreateEventTest.cs | 84 +- .../Models/Webhooks/FileUpdateEventTest.cs | 84 +- .../Webhooks/FileVersionCreateEventTest.cs | 84 +- .../Webhooks/UnsafeUnwrapWebhookEventTest.cs | 68 +- .../Models/Webhooks/UnwrapWebhookEventTest.cs | 68 +- .../UploadPreTransformSuccessEventTest.cs | 224 +-- .../VideoTransformationReadyEventTest.cs | 1217 ++++++++++------- src/Imagekit/Core/ModelBase.cs | 10 +- .../Beta/V2/Files/FileUploadResponse.cs | 67 +- src/Imagekit/Models/Files/File.cs | 67 +- .../Models/Files/FileUpdateResponse.cs | 33 +- .../Models/Files/FileUploadResponse.cs | 104 +- .../UploadPreTransformSuccessEvent.cs | 67 +- .../Webhooks/VideoTransformationReadyEvent.cs | 438 +++--- 20 files changed, 1842 insertions(+), 1437 deletions(-) diff --git a/.stats.yml b/.stats.yml index 1497247c..88ec6965 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc/imagekit-406b71ea98caac24889265c5b4371961c784912e543ade88e7e6917f9a31a951.yml -openapi_spec_hash: 462b973437dd6b2659654881e9a0e5c1 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc/imagekit-b9cc1f62fca41c286295001551cbe902d6b2f30ab775d84e549eb5affc0186ec.yml +openapi_spec_hash: f3790446521a8f846e2e7249313de100 config_hash: c5a7aed248c5d9ad5cd42e56fdd62c12 diff --git a/src/Imagekit.Tests/Models/Assets/AssetListResponseTest.cs b/src/Imagekit.Tests/Models/Assets/AssetListResponseTest.cs index 1cc145e6..936de613 100644 --- a/src/Imagekit.Tests/Models/Assets/AssetListResponseTest.cs +++ b/src/Imagekit.Tests/Models/Assets/AssetListResponseTest.cs @@ -55,9 +55,9 @@ public void FileValidationWorks() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -149,9 +149,9 @@ public void FileSerializationRoundtripWorks() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, diff --git a/src/Imagekit.Tests/Models/Beta/V2/Files/FileUploadResponseTest.cs b/src/Imagekit.Tests/Models/Beta/V2/Files/FileUploadResponseTest.cs index d5150a31..c16cdc1f 100644 --- a/src/Imagekit.Tests/Models/Beta/V2/Files/FileUploadResponseTest.cs +++ b/src/Imagekit.Tests/Models/Beta/V2/Files/FileUploadResponseTest.cs @@ -141,9 +141,9 @@ public void FieldRoundtrip_Works() Type = Type.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -293,9 +293,9 @@ public void FieldRoundtrip_Works() Type = Type.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -507,9 +507,9 @@ public void SerializationRoundtrip_Works() Type = Type.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -673,9 +673,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Type.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -832,9 +832,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Type.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -1046,9 +1046,9 @@ public void Validation_Works() Type = Type.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -1414,9 +1414,9 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Type = Type.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -1568,9 +1568,9 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Type = Type.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -1717,9 +1717,9 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Type = Type.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -1875,9 +1875,9 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Type = Type.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -2038,9 +2038,9 @@ public void CopyConstructor_Works() Type = Type.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -2701,9 +2701,9 @@ public void FieldRoundtrip_Works() Type = Type.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -2719,9 +2719,9 @@ public void FieldRoundtrip_Works() ApiEnum expectedType = Type.Text; DefaultValue expectedDefaultValue = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ); bool expectedIsValueRequired = true; @@ -2758,9 +2758,9 @@ public void SerializationRoundtrip_Works() Type = Type.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -2790,9 +2790,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Type.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -2815,9 +2815,9 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum expectedType = Type.Text; DefaultValue expectedDefaultValue = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ); bool expectedIsValueRequired = true; @@ -2854,9 +2854,9 @@ public void Validation_Works() Type = Type.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -2974,9 +2974,9 @@ public void CopyConstructor_Works() Type = Type.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -3091,9 +3091,9 @@ public void MixedValidationWorks() { DefaultValue value = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ); value.Validate(); @@ -3143,9 +3143,9 @@ public void MixedSerializationRoundtripWorks() { DefaultValue value = new( [ - new UnnamedSchemaWithArrayParent2(true), - new UnnamedSchemaWithArrayParent2(10), - new UnnamedSchemaWithArrayParent2("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ); string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3158,35 +3158,35 @@ public void MixedSerializationRoundtripWorks() } } -public class UnnamedSchemaWithArrayParent2Test : TestBase +public class DefaultValueArrayItemTest : TestBase { [Fact] public void StringValidationWorks() { - UnnamedSchemaWithArrayParent2 value = "string"; + DefaultValueArrayItem value = "string"; value.Validate(); } [Fact] public void DoubleValidationWorks() { - UnnamedSchemaWithArrayParent2 value = 0; + DefaultValueArrayItem value = 0; value.Validate(); } [Fact] public void BoolValidationWorks() { - UnnamedSchemaWithArrayParent2 value = true; + DefaultValueArrayItem value = true; value.Validate(); } [Fact] public void StringSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent2 value = "string"; + DefaultValueArrayItem value = "string"; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -3197,9 +3197,9 @@ public void StringSerializationRoundtripWorks() [Fact] public void DoubleSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent2 value = 0; + DefaultValueArrayItem value = 0; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -3210,9 +3210,9 @@ public void DoubleSerializationRoundtripWorks() [Fact] public void BoolSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent2 value = true; + DefaultValueArrayItem value = true; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); diff --git a/src/Imagekit.Tests/Models/Files/FileTest.cs b/src/Imagekit.Tests/Models/Files/FileTest.cs index 40155136..7ff69003 100644 --- a/src/Imagekit.Tests/Models/Files/FileTest.cs +++ b/src/Imagekit.Tests/Models/Files/FileTest.cs @@ -55,9 +55,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -123,9 +123,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -256,9 +256,9 @@ public void SerializationRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -338,9 +338,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -413,9 +413,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -546,9 +546,9 @@ public void Validation_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -848,9 +848,9 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -918,9 +918,9 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -983,9 +983,9 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -1057,9 +1057,9 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -1136,9 +1136,9 @@ public void CopyConstructor_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -1328,9 +1328,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -1346,9 +1346,9 @@ public void FieldRoundtrip_Works() ApiEnum expectedType = Files::Type.Text; Files::DefaultValue expectedDefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ); bool expectedIsValueRequired = true; @@ -1393,9 +1393,9 @@ public void SerializationRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -1425,9 +1425,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -1450,9 +1450,9 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum expectedType = Files::Type.Text; Files::DefaultValue expectedDefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ); bool expectedIsValueRequired = true; @@ -1497,9 +1497,9 @@ public void Validation_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -1617,9 +1617,9 @@ public void CopyConstructor_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -1734,9 +1734,9 @@ public void MixedValidationWorks() { Files::DefaultValue value = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ); value.Validate(); @@ -1786,9 +1786,9 @@ public void MixedSerializationRoundtripWorks() { Files::DefaultValue value = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ); string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -1801,35 +1801,35 @@ public void MixedSerializationRoundtripWorks() } } -public class UnnamedSchemaWithArrayParent0Test : TestBase +public class DefaultValueArrayItemTest : TestBase { [Fact] public void StringValidationWorks() { - Files::UnnamedSchemaWithArrayParent0 value = "string"; + Files::DefaultValueArrayItem value = "string"; value.Validate(); } [Fact] public void DoubleValidationWorks() { - Files::UnnamedSchemaWithArrayParent0 value = 0; + Files::DefaultValueArrayItem value = 0; value.Validate(); } [Fact] public void BoolValidationWorks() { - Files::UnnamedSchemaWithArrayParent0 value = true; + Files::DefaultValueArrayItem value = true; value.Validate(); } [Fact] public void StringSerializationRoundtripWorks() { - Files::UnnamedSchemaWithArrayParent0 value = "string"; + Files::DefaultValueArrayItem value = "string"; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -1840,9 +1840,9 @@ public void StringSerializationRoundtripWorks() [Fact] public void DoubleSerializationRoundtripWorks() { - Files::UnnamedSchemaWithArrayParent0 value = 0; + Files::DefaultValueArrayItem value = 0; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -1853,9 +1853,9 @@ public void DoubleSerializationRoundtripWorks() [Fact] public void BoolSerializationRoundtripWorks() { - Files::UnnamedSchemaWithArrayParent0 value = true; + Files::DefaultValueArrayItem value = true; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); diff --git a/src/Imagekit.Tests/Models/Files/FileUpdateResponseTest.cs b/src/Imagekit.Tests/Models/Files/FileUpdateResponseTest.cs index fedb1152..5340422a 100644 --- a/src/Imagekit.Tests/Models/Files/FileUpdateResponseTest.cs +++ b/src/Imagekit.Tests/Models/Files/FileUpdateResponseTest.cs @@ -55,9 +55,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -131,9 +131,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -273,9 +273,9 @@ public void SerializationRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -363,9 +363,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -446,9 +446,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -588,9 +588,9 @@ public void Validation_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -904,9 +904,9 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -982,9 +982,9 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -1055,9 +1055,9 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -1137,9 +1137,9 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -1224,9 +1224,9 @@ public void CopyConstructor_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -1265,12 +1265,12 @@ public void CopyConstructor_Works() } } -public class IntersectionMember1Test : TestBase +public class FileUpdateResponseFileUpdateResponseTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Files::IntersectionMember1 + var model = new Files::FileUpdateResponseFileUpdateResponse { ExtensionStatus = new() { @@ -1297,7 +1297,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Files::IntersectionMember1 + var model = new Files::FileUpdateResponseFileUpdateResponse { ExtensionStatus = new() { @@ -1310,7 +1310,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -1321,7 +1321,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Files::IntersectionMember1 + var model = new Files::FileUpdateResponseFileUpdateResponse { ExtensionStatus = new() { @@ -1334,7 +1334,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -1355,7 +1355,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Files::IntersectionMember1 + var model = new Files::FileUpdateResponseFileUpdateResponse { ExtensionStatus = new() { @@ -1373,7 +1373,7 @@ public void Validation_Works() [Fact] public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new Files::IntersectionMember1 { }; + var model = new Files::FileUpdateResponseFileUpdateResponse { }; Assert.Null(model.ExtensionStatus); Assert.False(model.RawData.ContainsKey("extensionStatus")); @@ -1382,7 +1382,7 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = new Files::IntersectionMember1 { }; + var model = new Files::FileUpdateResponseFileUpdateResponse { }; model.Validate(); } @@ -1390,7 +1390,7 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - var model = new Files::IntersectionMember1 + var model = new Files::FileUpdateResponseFileUpdateResponse { // Null should be interpreted as omitted for these properties ExtensionStatus = null, @@ -1403,7 +1403,7 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - var model = new Files::IntersectionMember1 + var model = new Files::FileUpdateResponseFileUpdateResponse { // Null should be interpreted as omitted for these properties ExtensionStatus = null, @@ -1415,7 +1415,7 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new Files::IntersectionMember1 + var model = new Files::FileUpdateResponseFileUpdateResponse { ExtensionStatus = new() { @@ -1427,7 +1427,7 @@ public void CopyConstructor_Works() }, }; - Files::IntersectionMember1 copied = new(model); + Files::FileUpdateResponseFileUpdateResponse copied = new(model); Assert.Equal(model, copied); } diff --git a/src/Imagekit.Tests/Models/Files/FileUploadResponseTest.cs b/src/Imagekit.Tests/Models/Files/FileUploadResponseTest.cs index 803e90cf..88b2984c 100644 --- a/src/Imagekit.Tests/Models/Files/FileUploadResponseTest.cs +++ b/src/Imagekit.Tests/Models/Files/FileUploadResponseTest.cs @@ -143,9 +143,15 @@ public void FieldRoundtrip_Works() Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent1(true), - new UnnamedSchemaWithArrayParent1(10), - new UnnamedSchemaWithArrayParent1("Hello"), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + true + ), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + 10 + ), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + "Hello" + ), ] ), IsValueRequired = true, @@ -298,9 +304,15 @@ public void FieldRoundtrip_Works() Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent1(true), - new UnnamedSchemaWithArrayParent1(10), - new UnnamedSchemaWithArrayParent1("Hello"), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + true + ), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + 10 + ), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + "Hello" + ), ] ), IsValueRequired = true, @@ -515,9 +527,15 @@ public void SerializationRoundtrip_Works() Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent1(true), - new UnnamedSchemaWithArrayParent1(10), - new UnnamedSchemaWithArrayParent1("Hello"), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + true + ), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + 10 + ), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + "Hello" + ), ] ), IsValueRequired = true, @@ -684,9 +702,15 @@ public void FieldRoundtripThroughSerialization_Works() Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent1(true), - new UnnamedSchemaWithArrayParent1(10), - new UnnamedSchemaWithArrayParent1("Hello"), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + true + ), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + 10 + ), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + "Hello" + ), ] ), IsValueRequired = true, @@ -846,9 +870,15 @@ public void FieldRoundtripThroughSerialization_Works() Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent1(true), - new UnnamedSchemaWithArrayParent1(10), - new UnnamedSchemaWithArrayParent1("Hello"), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + true + ), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + 10 + ), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + "Hello" + ), ] ), IsValueRequired = true, @@ -1063,9 +1093,15 @@ public void Validation_Works() Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent1(true), - new UnnamedSchemaWithArrayParent1(10), - new UnnamedSchemaWithArrayParent1("Hello"), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + true + ), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + 10 + ), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + "Hello" + ), ] ), IsValueRequired = true, @@ -1434,9 +1470,15 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent1(true), - new UnnamedSchemaWithArrayParent1(10), - new UnnamedSchemaWithArrayParent1("Hello"), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + true + ), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + 10 + ), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + "Hello" + ), ] ), IsValueRequired = true, @@ -1591,9 +1633,15 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent1(true), - new UnnamedSchemaWithArrayParent1(10), - new UnnamedSchemaWithArrayParent1("Hello"), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + true + ), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + 10 + ), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + "Hello" + ), ] ), IsValueRequired = true, @@ -1743,9 +1791,15 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent1(true), - new UnnamedSchemaWithArrayParent1(10), - new UnnamedSchemaWithArrayParent1("Hello"), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + true + ), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + 10 + ), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + "Hello" + ), ] ), IsValueRequired = true, @@ -1904,9 +1958,15 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent1(true), - new UnnamedSchemaWithArrayParent1(10), - new UnnamedSchemaWithArrayParent1("Hello"), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + true + ), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + 10 + ), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + "Hello" + ), ] ), IsValueRequired = true, @@ -2070,9 +2130,15 @@ public void CopyConstructor_Works() Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent1(true), - new UnnamedSchemaWithArrayParent1(10), - new UnnamedSchemaWithArrayParent1("Hello"), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + true + ), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + 10 + ), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + "Hello" + ), ] ), IsValueRequired = true, @@ -2743,9 +2809,15 @@ public void FieldRoundtrip_Works() Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent1(true), - new UnnamedSchemaWithArrayParent1(10), - new UnnamedSchemaWithArrayParent1("Hello"), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + true + ), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + 10 + ), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + "Hello" + ), ] ), IsValueRequired = true, @@ -2762,9 +2834,13 @@ public void FieldRoundtrip_Works() FileUploadResponseSelectedFieldsSchemaItemType.Text; FileUploadResponseSelectedFieldsSchemaItemDefaultValue expectedDefaultValue = new( [ - new UnnamedSchemaWithArrayParent1(true), - new UnnamedSchemaWithArrayParent1(10), - new UnnamedSchemaWithArrayParent1("Hello"), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + true + ), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem(10), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + "Hello" + ), ] ); bool expectedIsValueRequired = true; @@ -2809,9 +2885,15 @@ public void SerializationRoundtrip_Works() Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent1(true), - new UnnamedSchemaWithArrayParent1(10), - new UnnamedSchemaWithArrayParent1("Hello"), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + true + ), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + 10 + ), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + "Hello" + ), ] ), IsValueRequired = true, @@ -2841,9 +2923,15 @@ public void FieldRoundtripThroughSerialization_Works() Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent1(true), - new UnnamedSchemaWithArrayParent1(10), - new UnnamedSchemaWithArrayParent1("Hello"), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + true + ), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + 10 + ), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + "Hello" + ), ] ), IsValueRequired = true, @@ -2867,9 +2955,13 @@ public void FieldRoundtripThroughSerialization_Works() FileUploadResponseSelectedFieldsSchemaItemType.Text; FileUploadResponseSelectedFieldsSchemaItemDefaultValue expectedDefaultValue = new( [ - new UnnamedSchemaWithArrayParent1(true), - new UnnamedSchemaWithArrayParent1(10), - new UnnamedSchemaWithArrayParent1("Hello"), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + true + ), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem(10), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + "Hello" + ), ] ); bool expectedIsValueRequired = true; @@ -2914,9 +3006,15 @@ public void Validation_Works() Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent1(true), - new UnnamedSchemaWithArrayParent1(10), - new UnnamedSchemaWithArrayParent1("Hello"), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + true + ), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + 10 + ), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + "Hello" + ), ] ), IsValueRequired = true, @@ -3040,9 +3138,15 @@ public void CopyConstructor_Works() Type = FileUploadResponseSelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent1(true), - new UnnamedSchemaWithArrayParent1(10), - new UnnamedSchemaWithArrayParent1("Hello"), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + true + ), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + 10 + ), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + "Hello" + ), ] ), IsValueRequired = true, @@ -3155,9 +3259,13 @@ public void MixedValidationWorks() { FileUploadResponseSelectedFieldsSchemaItemDefaultValue value = new( [ - new UnnamedSchemaWithArrayParent1(true), - new UnnamedSchemaWithArrayParent1(10), - new UnnamedSchemaWithArrayParent1("Hello"), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + true + ), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem(10), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + "Hello" + ), ] ); value.Validate(); @@ -3210,9 +3318,13 @@ public void MixedSerializationRoundtripWorks() { FileUploadResponseSelectedFieldsSchemaItemDefaultValue value = new( [ - new UnnamedSchemaWithArrayParent1(true), - new UnnamedSchemaWithArrayParent1(10), - new UnnamedSchemaWithArrayParent1("Hello"), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + true + ), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem(10), + new FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + "Hello" + ), ] ); string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3226,38 +3338,42 @@ public void MixedSerializationRoundtripWorks() } } -public class UnnamedSchemaWithArrayParent1Test : TestBase +public class FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItemTest + : TestBase { [Fact] public void StringValidationWorks() { - UnnamedSchemaWithArrayParent1 value = "string"; + FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem value = + "string"; value.Validate(); } [Fact] public void DoubleValidationWorks() { - UnnamedSchemaWithArrayParent1 value = 0; + FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem value = 0; value.Validate(); } [Fact] public void BoolValidationWorks() { - UnnamedSchemaWithArrayParent1 value = true; + FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem value = true; value.Validate(); } [Fact] public void StringSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent1 value = "string"; + FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem value = + "string"; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } @@ -3265,12 +3381,13 @@ public void StringSerializationRoundtripWorks() [Fact] public void DoubleSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent1 value = 0; + FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem value = 0; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } @@ -3278,12 +3395,13 @@ public void DoubleSerializationRoundtripWorks() [Fact] public void BoolSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent1 value = true; + FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem value = true; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } diff --git a/src/Imagekit.Tests/Models/Webhooks/FileCreateEventTest.cs b/src/Imagekit.Tests/Models/Webhooks/FileCreateEventTest.cs index 6606afdd..ae6a3ab9 100644 --- a/src/Imagekit.Tests/Models/Webhooks/FileCreateEventTest.cs +++ b/src/Imagekit.Tests/Models/Webhooks/FileCreateEventTest.cs @@ -60,9 +60,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -134,9 +134,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -218,9 +218,9 @@ public void SerializationRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -306,9 +306,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -387,9 +387,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -471,9 +471,9 @@ public void Validation_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -553,9 +553,9 @@ public void CopyConstructor_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -638,9 +638,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -710,9 +710,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -792,9 +792,9 @@ public void SerializationRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -878,9 +878,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -957,9 +957,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -1039,9 +1039,9 @@ public void Validation_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -1119,9 +1119,9 @@ public void CopyConstructor_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, diff --git a/src/Imagekit.Tests/Models/Webhooks/FileUpdateEventTest.cs b/src/Imagekit.Tests/Models/Webhooks/FileUpdateEventTest.cs index aede4945..b34d3a95 100644 --- a/src/Imagekit.Tests/Models/Webhooks/FileUpdateEventTest.cs +++ b/src/Imagekit.Tests/Models/Webhooks/FileUpdateEventTest.cs @@ -60,9 +60,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -134,9 +134,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -218,9 +218,9 @@ public void SerializationRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -306,9 +306,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -387,9 +387,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -471,9 +471,9 @@ public void Validation_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -553,9 +553,9 @@ public void CopyConstructor_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -638,9 +638,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -710,9 +710,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -792,9 +792,9 @@ public void SerializationRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -878,9 +878,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -957,9 +957,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -1039,9 +1039,9 @@ public void Validation_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -1119,9 +1119,9 @@ public void CopyConstructor_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, diff --git a/src/Imagekit.Tests/Models/Webhooks/FileVersionCreateEventTest.cs b/src/Imagekit.Tests/Models/Webhooks/FileVersionCreateEventTest.cs index 60d694dc..e7f66b62 100644 --- a/src/Imagekit.Tests/Models/Webhooks/FileVersionCreateEventTest.cs +++ b/src/Imagekit.Tests/Models/Webhooks/FileVersionCreateEventTest.cs @@ -60,9 +60,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -134,9 +134,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -218,9 +218,9 @@ public void SerializationRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -306,9 +306,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -387,9 +387,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -471,9 +471,9 @@ public void Validation_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -553,9 +553,9 @@ public void CopyConstructor_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -638,9 +638,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -710,9 +710,9 @@ public void FieldRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -792,9 +792,9 @@ public void SerializationRoundtrip_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -878,9 +878,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -957,9 +957,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -1039,9 +1039,9 @@ public void Validation_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -1119,9 +1119,9 @@ public void CopyConstructor_Works() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, diff --git a/src/Imagekit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs b/src/Imagekit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs index 5a71ec34..d3d4f2dd 100644 --- a/src/Imagekit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs +++ b/src/Imagekit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs @@ -60,20 +60,20 @@ public void VideoTransformationReadyValidationWorks() Transformation = new() { Type = - Webhooks::VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, + Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - Webhooks::VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, + Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - Webhooks::VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, + Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - Webhooks::VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, + Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - Webhooks::VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, + Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -278,9 +278,9 @@ public void UploadPreTransformSuccessValidationWorks() Type = Webhooks::SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new Webhooks::UnnamedSchemaWithArrayParent3(true), - new Webhooks::UnnamedSchemaWithArrayParent3(10), - new Webhooks::UnnamedSchemaWithArrayParent3("Hello"), + new Webhooks::DefaultValueArrayItem(true), + new Webhooks::DefaultValueArrayItem(10), + new Webhooks::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -441,9 +441,9 @@ public void FileCreateValidationWorks() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -522,9 +522,9 @@ public void FileUpdateValidationWorks() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -616,9 +616,9 @@ public void FileVersionCreateValidationWorks() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -716,20 +716,20 @@ public void VideoTransformationReadySerializationRoundtripWorks() Transformation = new() { Type = - Webhooks::VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, + Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - Webhooks::VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, + Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - Webhooks::VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, + Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - Webhooks::VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, + Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - Webhooks::VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, + Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -946,9 +946,9 @@ public void UploadPreTransformSuccessSerializationRoundtripWorks() Type = Webhooks::SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new Webhooks::UnnamedSchemaWithArrayParent3(true), - new Webhooks::UnnamedSchemaWithArrayParent3(10), - new Webhooks::UnnamedSchemaWithArrayParent3("Hello"), + new Webhooks::DefaultValueArrayItem(true), + new Webhooks::DefaultValueArrayItem(10), + new Webhooks::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -1133,9 +1133,9 @@ public void FileCreateSerializationRoundtripWorks() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -1220,9 +1220,9 @@ public void FileUpdateSerializationRoundtripWorks() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -1326,9 +1326,9 @@ public void FileVersionCreateSerializationRoundtripWorks() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, diff --git a/src/Imagekit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs b/src/Imagekit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs index 783d9f66..a99d5566 100644 --- a/src/Imagekit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs +++ b/src/Imagekit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs @@ -60,20 +60,20 @@ public void VideoTransformationReadyValidationWorks() Transformation = new() { Type = - Webhooks::VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, + Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - Webhooks::VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, + Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - Webhooks::VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, + Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - Webhooks::VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, + Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - Webhooks::VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, + Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -278,9 +278,9 @@ public void UploadPreTransformSuccessValidationWorks() Type = Webhooks::SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new Webhooks::UnnamedSchemaWithArrayParent3(true), - new Webhooks::UnnamedSchemaWithArrayParent3(10), - new Webhooks::UnnamedSchemaWithArrayParent3("Hello"), + new Webhooks::DefaultValueArrayItem(true), + new Webhooks::DefaultValueArrayItem(10), + new Webhooks::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -441,9 +441,9 @@ public void FileCreateValidationWorks() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -522,9 +522,9 @@ public void FileUpdateValidationWorks() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -616,9 +616,9 @@ public void FileVersionCreateValidationWorks() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -716,20 +716,20 @@ public void VideoTransformationReadySerializationRoundtripWorks() Transformation = new() { Type = - Webhooks::VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, + Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - Webhooks::VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, + Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - Webhooks::VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, + Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - Webhooks::VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, + Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - Webhooks::VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, + Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -946,9 +946,9 @@ public void UploadPreTransformSuccessSerializationRoundtripWorks() Type = Webhooks::SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new Webhooks::UnnamedSchemaWithArrayParent3(true), - new Webhooks::UnnamedSchemaWithArrayParent3(10), - new Webhooks::UnnamedSchemaWithArrayParent3("Hello"), + new Webhooks::DefaultValueArrayItem(true), + new Webhooks::DefaultValueArrayItem(10), + new Webhooks::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -1133,9 +1133,9 @@ public void FileCreateSerializationRoundtripWorks() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -1220,9 +1220,9 @@ public void FileUpdateSerializationRoundtripWorks() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -1326,9 +1326,9 @@ public void FileVersionCreateSerializationRoundtripWorks() Type = Files::Type.Text, DefaultValue = new( [ - new Files::UnnamedSchemaWithArrayParent0(true), - new Files::UnnamedSchemaWithArrayParent0(10), - new Files::UnnamedSchemaWithArrayParent0("Hello"), + new Files::DefaultValueArrayItem(true), + new Files::DefaultValueArrayItem(10), + new Files::DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, diff --git a/src/Imagekit.Tests/Models/Webhooks/UploadPreTransformSuccessEventTest.cs b/src/Imagekit.Tests/Models/Webhooks/UploadPreTransformSuccessEventTest.cs index dd00b1be..40969e08 100644 --- a/src/Imagekit.Tests/Models/Webhooks/UploadPreTransformSuccessEventTest.cs +++ b/src/Imagekit.Tests/Models/Webhooks/UploadPreTransformSuccessEventTest.cs @@ -147,9 +147,9 @@ public void FieldRoundtrip_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -306,9 +306,9 @@ public void FieldRoundtrip_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -480,9 +480,9 @@ public void SerializationRoundtrip_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -653,9 +653,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -819,9 +819,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -993,9 +993,9 @@ public void Validation_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -1160,9 +1160,9 @@ public void CopyConstructor_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -1330,9 +1330,9 @@ public void FieldRoundtrip_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -1487,9 +1487,9 @@ public void FieldRoundtrip_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -1661,9 +1661,9 @@ public void SerializationRoundtrip_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -1833,9 +1833,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -1998,9 +1998,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -2172,9 +2172,9 @@ public void Validation_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -2337,9 +2337,9 @@ public void CopyConstructor_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -2504,9 +2504,9 @@ public void FieldRoundtrip_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -2656,9 +2656,9 @@ public void FieldRoundtrip_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -2870,9 +2870,9 @@ public void SerializationRoundtrip_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -3037,9 +3037,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -3197,9 +3197,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -3411,9 +3411,9 @@ public void Validation_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -3779,9 +3779,9 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -3933,9 +3933,9 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -4082,9 +4082,9 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -4240,9 +4240,9 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -4403,9 +4403,9 @@ public void CopyConstructor_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -5066,9 +5066,9 @@ public void FieldRoundtrip_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -5085,9 +5085,9 @@ public void FieldRoundtrip_Works() SelectedFieldsSchemaItemType.Text; DefaultValue expectedDefaultValue = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ); bool expectedIsValueRequired = true; @@ -5124,9 +5124,9 @@ public void SerializationRoundtrip_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -5156,9 +5156,9 @@ public void FieldRoundtripThroughSerialization_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -5182,9 +5182,9 @@ public void FieldRoundtripThroughSerialization_Works() SelectedFieldsSchemaItemType.Text; DefaultValue expectedDefaultValue = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ); bool expectedIsValueRequired = true; @@ -5221,9 +5221,9 @@ public void Validation_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -5341,9 +5341,9 @@ public void CopyConstructor_Works() Type = SelectedFieldsSchemaItemType.Text, DefaultValue = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ), IsValueRequired = true, @@ -5456,9 +5456,9 @@ public void MixedValidationWorks() { DefaultValue value = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ); value.Validate(); @@ -5508,9 +5508,9 @@ public void MixedSerializationRoundtripWorks() { DefaultValue value = new( [ - new UnnamedSchemaWithArrayParent3(true), - new UnnamedSchemaWithArrayParent3(10), - new UnnamedSchemaWithArrayParent3("Hello"), + new DefaultValueArrayItem(true), + new DefaultValueArrayItem(10), + new DefaultValueArrayItem("Hello"), ] ); string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -5523,35 +5523,35 @@ public void MixedSerializationRoundtripWorks() } } -public class UnnamedSchemaWithArrayParent3Test : TestBase +public class DefaultValueArrayItemTest : TestBase { [Fact] public void StringValidationWorks() { - UnnamedSchemaWithArrayParent3 value = "string"; + DefaultValueArrayItem value = "string"; value.Validate(); } [Fact] public void DoubleValidationWorks() { - UnnamedSchemaWithArrayParent3 value = 0; + DefaultValueArrayItem value = 0; value.Validate(); } [Fact] public void BoolValidationWorks() { - UnnamedSchemaWithArrayParent3 value = true; + DefaultValueArrayItem value = true; value.Validate(); } [Fact] public void StringSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent3 value = "string"; + DefaultValueArrayItem value = "string"; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -5562,9 +5562,9 @@ public void StringSerializationRoundtripWorks() [Fact] public void DoubleSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent3 value = 0; + DefaultValueArrayItem value = 0; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -5575,9 +5575,9 @@ public void DoubleSerializationRoundtripWorks() [Fact] public void BoolSerializationRoundtripWorks() { - UnnamedSchemaWithArrayParent3 value = true; + DefaultValueArrayItem value = true; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); diff --git a/src/Imagekit.Tests/Models/Webhooks/VideoTransformationReadyEventTest.cs b/src/Imagekit.Tests/Models/Webhooks/VideoTransformationReadyEventTest.cs index dcc2b8d9..3fd282ac 100644 --- a/src/Imagekit.Tests/Models/Webhooks/VideoTransformationReadyEventTest.cs +++ b/src/Imagekit.Tests/Models/Webhooks/VideoTransformationReadyEventTest.cs @@ -23,20 +23,20 @@ public void FieldRoundtrip_Works() Transformation = new() { Type = - VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -63,26 +63,26 @@ public void FieldRoundtrip_Works() string expectedID = "id"; string expectedType = "type"; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - VideoTransformationReadyEventChangedData expectedData = new() + VideoTransformationReadyEventVideoTransformationReadyEventData expectedData = new() { Asset = new("https://example.com"), Transformation = new() { Type = - VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -97,7 +97,7 @@ public void FieldRoundtrip_Works() }, }, }; - VideoTransformationReadyEventChangedRequest expectedRequest = new() + VideoTransformationReadyEventVideoTransformationReadyEventRequest expectedRequest = new() { Url = "https://example.com", XRequestID = "x_request_id", @@ -127,20 +127,20 @@ public void SerializationRoundtrip_Works() Transformation = new() { Type = - VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -187,20 +187,20 @@ public void FieldRoundtripThroughSerialization_Works() Transformation = new() { Type = - VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -234,26 +234,26 @@ public void FieldRoundtripThroughSerialization_Works() string expectedID = "id"; string expectedType = "type"; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - VideoTransformationReadyEventChangedData expectedData = new() + VideoTransformationReadyEventVideoTransformationReadyEventData expectedData = new() { Asset = new("https://example.com"), Transformation = new() { Type = - VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -268,7 +268,7 @@ public void FieldRoundtripThroughSerialization_Works() }, }, }; - VideoTransformationReadyEventChangedRequest expectedRequest = new() + VideoTransformationReadyEventVideoTransformationReadyEventRequest expectedRequest = new() { Url = "https://example.com", XRequestID = "x_request_id", @@ -298,20 +298,20 @@ public void Validation_Works() Transformation = new() { Type = - VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -352,20 +352,20 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() Transformation = new() { Type = - VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -406,20 +406,20 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() Transformation = new() { Type = - VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -459,20 +459,20 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() Transformation = new() { Type = - VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -516,20 +516,20 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() Transformation = new() { Type = - VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -572,20 +572,20 @@ public void CopyConstructor_Works() Transformation = new() { Type = - VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -615,12 +615,12 @@ public void CopyConstructor_Works() } } -public class VideoTransformationReadyEventChangedTest : TestBase +public class VideoTransformationReadyEventVideoTransformationReadyEventTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new VideoTransformationReadyEventChanged + var model = new VideoTransformationReadyEventVideoTransformationReadyEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -629,20 +629,20 @@ public void FieldRoundtrip_Works() Transformation = new() { Type = - VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -667,26 +667,26 @@ public void FieldRoundtrip_Works() }; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - VideoTransformationReadyEventChangedData expectedData = new() + VideoTransformationReadyEventVideoTransformationReadyEventData expectedData = new() { Asset = new("https://example.com"), Transformation = new() { Type = - VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -701,7 +701,7 @@ public void FieldRoundtrip_Works() }, }, }; - VideoTransformationReadyEventChangedRequest expectedRequest = new() + VideoTransformationReadyEventVideoTransformationReadyEventRequest expectedRequest = new() { Url = "https://example.com", XRequestID = "x_request_id", @@ -720,7 +720,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new VideoTransformationReadyEventChanged + var model = new VideoTransformationReadyEventVideoTransformationReadyEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -729,20 +729,20 @@ public void SerializationRoundtrip_Works() Transformation = new() { Type = - VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -767,10 +767,11 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -778,7 +779,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new VideoTransformationReadyEventChanged + var model = new VideoTransformationReadyEventVideoTransformationReadyEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -787,20 +788,20 @@ public void FieldRoundtripThroughSerialization_Works() Transformation = new() { Type = - VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -825,33 +826,34 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.NotNull(deserialized); DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - VideoTransformationReadyEventChangedData expectedData = new() + VideoTransformationReadyEventVideoTransformationReadyEventData expectedData = new() { Asset = new("https://example.com"), Transformation = new() { Type = - VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -866,7 +868,7 @@ public void FieldRoundtripThroughSerialization_Works() }, }, }; - VideoTransformationReadyEventChangedRequest expectedRequest = new() + VideoTransformationReadyEventVideoTransformationReadyEventRequest expectedRequest = new() { Url = "https://example.com", XRequestID = "x_request_id", @@ -885,7 +887,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new VideoTransformationReadyEventChanged + var model = new VideoTransformationReadyEventVideoTransformationReadyEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -894,20 +896,20 @@ public void Validation_Works() Transformation = new() { Type = - VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -937,7 +939,7 @@ public void Validation_Works() [Fact] public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new VideoTransformationReadyEventChanged + var model = new VideoTransformationReadyEventVideoTransformationReadyEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -946,20 +948,20 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() Transformation = new() { Type = - VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -989,7 +991,7 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = new VideoTransformationReadyEventChanged + var model = new VideoTransformationReadyEventVideoTransformationReadyEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -998,20 +1000,20 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() Transformation = new() { Type = - VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -1040,7 +1042,7 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - var model = new VideoTransformationReadyEventChanged + var model = new VideoTransformationReadyEventVideoTransformationReadyEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -1049,20 +1051,20 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() Transformation = new() { Type = - VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -1095,7 +1097,7 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - var model = new VideoTransformationReadyEventChanged + var model = new VideoTransformationReadyEventVideoTransformationReadyEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -1104,20 +1106,20 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() Transformation = new() { Type = - VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -1149,7 +1151,7 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new VideoTransformationReadyEventChanged + var model = new VideoTransformationReadyEventVideoTransformationReadyEvent { CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Data = new() @@ -1158,20 +1160,20 @@ public void CopyConstructor_Works() Transformation = new() { Type = - VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -1195,37 +1197,37 @@ public void CopyConstructor_Works() Timings = new() { DownloadDuration = 0, EncodingDuration = 0 }, }; - VideoTransformationReadyEventChanged copied = new(model); + VideoTransformationReadyEventVideoTransformationReadyEvent copied = new(model); Assert.Equal(model, copied); } } -public class VideoTransformationReadyEventChangedDataTest : TestBase +public class VideoTransformationReadyEventVideoTransformationReadyEventDataTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new VideoTransformationReadyEventChangedData + var model = new VideoTransformationReadyEventVideoTransformationReadyEventData { Asset = new("https://example.com"), Transformation = new() { Type = - VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -1241,35 +1243,40 @@ public void FieldRoundtrip_Works() }, }; - VideoTransformationReadyEventChangedDataAsset expectedAsset = new("https://example.com"); - VideoTransformationReadyEventChangedDataTransformation expectedTransformation = new() - { - Type = VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, - Options = new() - { - AudioCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, - AutoRotate = true, - Format = VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, - Quality = 0, - StreamProtocol = - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, - Variants = ["string"], - VideoCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, - }, - Output = new() + VideoTransformationReadyEventVideoTransformationReadyEventDataAsset expectedAsset = new( + "https://example.com" + ); + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation expectedTransformation = + new() { - Url = "https://example.com", - VideoMetadata = new() + Type = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, + Options = new() { - Bitrate = 0, - Duration = 0, - Height = 0, - Width = 0, + AudioCodec = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, - }, - }; + Output = new() + { + Url = "https://example.com", + VideoMetadata = new() + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }, + }, + }; Assert.Equal(expectedAsset, model.Asset); Assert.Equal(expectedTransformation, model.Transformation); @@ -1278,26 +1285,26 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new VideoTransformationReadyEventChangedData + var model = new VideoTransformationReadyEventVideoTransformationReadyEventData { Asset = new("https://example.com"), Transformation = new() { Type = - VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -1314,10 +1321,11 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -1325,26 +1333,26 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new VideoTransformationReadyEventChangedData + var model = new VideoTransformationReadyEventVideoTransformationReadyEventData { Asset = new("https://example.com"), Transformation = new() { Type = - VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -1361,41 +1369,47 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.NotNull(deserialized); - VideoTransformationReadyEventChangedDataAsset expectedAsset = new("https://example.com"); - VideoTransformationReadyEventChangedDataTransformation expectedTransformation = new() - { - Type = VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, - Options = new() - { - AudioCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, - AutoRotate = true, - Format = VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, - Quality = 0, - StreamProtocol = - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, - Variants = ["string"], - VideoCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, - }, - Output = new() + VideoTransformationReadyEventVideoTransformationReadyEventDataAsset expectedAsset = new( + "https://example.com" + ); + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation expectedTransformation = + new() { - Url = "https://example.com", - VideoMetadata = new() + Type = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, + Options = new() { - Bitrate = 0, - Duration = 0, - Height = 0, - Width = 0, + AudioCodec = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, - }, - }; + Output = new() + { + Url = "https://example.com", + VideoMetadata = new() + { + Bitrate = 0, + Duration = 0, + Height = 0, + Width = 0, + }, + }, + }; Assert.Equal(expectedAsset, deserialized.Asset); Assert.Equal(expectedTransformation, deserialized.Transformation); @@ -1404,26 +1418,26 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new VideoTransformationReadyEventChangedData + var model = new VideoTransformationReadyEventVideoTransformationReadyEventData { Asset = new("https://example.com"), Transformation = new() { Type = - VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -1445,26 +1459,26 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new VideoTransformationReadyEventChangedData + var model = new VideoTransformationReadyEventVideoTransformationReadyEventData { Asset = new("https://example.com"), Transformation = new() { Type = - VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, Format = - VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -1480,18 +1494,18 @@ public void CopyConstructor_Works() }, }; - VideoTransformationReadyEventChangedData copied = new(model); + VideoTransformationReadyEventVideoTransformationReadyEventData copied = new(model); Assert.Equal(model, copied); } } -public class VideoTransformationReadyEventChangedDataAssetTest : TestBase +public class VideoTransformationReadyEventVideoTransformationReadyEventDataAssetTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new VideoTransformationReadyEventChangedDataAsset + var model = new VideoTransformationReadyEventVideoTransformationReadyEventDataAsset { Url = "https://example.com", }; @@ -1504,14 +1518,14 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new VideoTransformationReadyEventChangedDataAsset + var model = new VideoTransformationReadyEventVideoTransformationReadyEventDataAsset { Url = "https://example.com", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -1522,14 +1536,14 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new VideoTransformationReadyEventChangedDataAsset + var model = new VideoTransformationReadyEventVideoTransformationReadyEventDataAsset { Url = "https://example.com", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -1543,7 +1557,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new VideoTransformationReadyEventChangedDataAsset + var model = new VideoTransformationReadyEventVideoTransformationReadyEventDataAsset { Url = "https://example.com", }; @@ -1554,37 +1568,40 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new VideoTransformationReadyEventChangedDataAsset + var model = new VideoTransformationReadyEventVideoTransformationReadyEventDataAsset { Url = "https://example.com", }; - VideoTransformationReadyEventChangedDataAsset copied = new(model); + VideoTransformationReadyEventVideoTransformationReadyEventDataAsset copied = new(model); Assert.Equal(model, copied); } } -public class VideoTransformationReadyEventChangedDataTransformationTest : TestBase +public class VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationTest + : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new VideoTransformationReadyEventChangedDataTransformation + var model = new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation { - Type = VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, + Type = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, - Format = VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, + Format = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -1599,21 +1616,26 @@ public void FieldRoundtrip_Works() }, }; - ApiEnum expectedType = - VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation; - VideoTransformationReadyEventChangedDataTransformationOptions expectedOptions = new() - { - AudioCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, - AutoRotate = true, - Format = VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, - Quality = 0, - StreamProtocol = - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, - Variants = ["string"], - VideoCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, - }; + ApiEnum< + string, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType + > expectedType = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation; + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions expectedOptions = + new() + { + AudioCodec = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, + }; Output expectedOutput = new() { Url = "https://example.com", @@ -1634,21 +1656,23 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new VideoTransformationReadyEventChangedDataTransformation + var model = new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation { - Type = VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, + Type = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, - Format = VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, + Format = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -1665,7 +1689,7 @@ public void SerializationRoundtrip_Works() string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -1676,21 +1700,23 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new VideoTransformationReadyEventChangedDataTransformation + var model = new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation { - Type = VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, + Type = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, - Format = VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, + Format = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -1707,27 +1733,32 @@ public void FieldRoundtripThroughSerialization_Works() string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - ApiEnum expectedType = - VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation; - VideoTransformationReadyEventChangedDataTransformationOptions expectedOptions = new() - { - AudioCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, - AutoRotate = true, - Format = VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, - Quality = 0, - StreamProtocol = - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, - Variants = ["string"], - VideoCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, - }; + ApiEnum< + string, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType + > expectedType = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation; + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions expectedOptions = + new() + { + AudioCodec = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, + }; Output expectedOutput = new() { Url = "https://example.com", @@ -1748,21 +1779,23 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new VideoTransformationReadyEventChangedDataTransformation + var model = new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation { - Type = VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, + Type = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, - Format = VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, + Format = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -1783,9 +1816,10 @@ public void Validation_Works() [Fact] public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new VideoTransformationReadyEventChangedDataTransformation + var model = new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation { - Type = VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, + Type = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, }; Assert.Null(model.Options); @@ -1797,9 +1831,10 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = new VideoTransformationReadyEventChangedDataTransformation + var model = new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation { - Type = VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, + Type = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, }; model.Validate(); @@ -1808,9 +1843,10 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - var model = new VideoTransformationReadyEventChangedDataTransformation + var model = new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation { - Type = VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, + Type = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, // Null should be interpreted as omitted for these properties Options = null, @@ -1826,9 +1862,10 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - var model = new VideoTransformationReadyEventChangedDataTransformation + var model = new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation { - Type = VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, + Type = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, // Null should be interpreted as omitted for these properties Options = null, @@ -1841,21 +1878,23 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new VideoTransformationReadyEventChangedDataTransformation + var model = new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation { - Type = VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, + Type = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, Options = new() { AudioCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, AutoRotate = true, - Format = VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, + Format = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, Quality = 0, StreamProtocol = - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, Variants = ["string"], VideoCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, }, Output = new() { @@ -1870,25 +1909,36 @@ public void CopyConstructor_Works() }, }; - VideoTransformationReadyEventChangedDataTransformation copied = new(model); + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation copied = new( + model + ); Assert.Equal(model, copied); } } -public class VideoTransformationReadyEventChangedDataTransformationTypeTest : TestBase +public class VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationTypeTest + : TestBase { [Theory] - [InlineData(VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation)] - [InlineData(VideoTransformationReadyEventChangedDataTransformationType.GifToVideo)] - [InlineData(VideoTransformationReadyEventChangedDataTransformationType.VideoThumbnail)] + [InlineData( + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation + )] + [InlineData( + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.GifToVideo + )] + [InlineData( + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoThumbnail + )] public void Validation_Works( - VideoTransformationReadyEventChangedDataTransformationType rawValue + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType rawValue ) { // force implicit conversion because Theory can't do that for us - ApiEnum value = - rawValue; + ApiEnum< + string, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType + > value = rawValue; value.Validate(); } @@ -1896,7 +1946,10 @@ VideoTransformationReadyEventChangedDataTransformationType rawValue public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum< + string, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType + > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -1904,20 +1957,31 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation)] - [InlineData(VideoTransformationReadyEventChangedDataTransformationType.GifToVideo)] - [InlineData(VideoTransformationReadyEventChangedDataTransformationType.VideoThumbnail)] + [InlineData( + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation + )] + [InlineData( + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.GifToVideo + )] + [InlineData( + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoThumbnail + )] public void SerializationRoundtrip_Works( - VideoTransformationReadyEventChangedDataTransformationType rawValue + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType rawValue ) { // force implicit conversion because Theory can't do that for us - ApiEnum value = - rawValue; + ApiEnum< + string, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType + > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum< + string, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType + > >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -1927,58 +1991,68 @@ VideoTransformationReadyEventChangedDataTransformationType rawValue public void InvalidEnumSerializationRoundtrip_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum< + string, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType + > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum< + string, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType + > >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class VideoTransformationReadyEventChangedDataTransformationOptionsTest : TestBase +public class VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsTest + : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new VideoTransformationReadyEventChangedDataTransformationOptions - { - AudioCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, - AutoRotate = true, - Format = VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, - Quality = 0, - StreamProtocol = - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, - Variants = ["string"], - VideoCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, - }; + var model = + new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions + { + AudioCodec = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, + }; ApiEnum< string, - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec > expectedAudioCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac; + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac; bool expectedAutoRotate = true; ApiEnum< string, - VideoTransformationReadyEventChangedDataTransformationOptionsFormat - > expectedFormat = VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4; + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat + > expectedFormat = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4; long expectedQuality = 0; ApiEnum< string, - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol > expectedStreamProtocol = - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls; + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls; List expectedVariants = ["string"]; ApiEnum< string, - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec > expectedVideoCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264; + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264; Assert.Equal(expectedAudioCodec, model.AudioCodec); Assert.Equal(expectedAutoRotate, model.AutoRotate); @@ -1997,23 +2071,25 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new VideoTransformationReadyEventChangedDataTransformationOptions - { - AudioCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, - AutoRotate = true, - Format = VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, - Quality = 0, - StreamProtocol = - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, - Variants = ["string"], - VideoCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, - }; + var model = + new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions + { + AudioCodec = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, + }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -2024,23 +2100,25 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new VideoTransformationReadyEventChangedDataTransformationOptions - { - AudioCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, - AutoRotate = true, - Format = VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, - Quality = 0, - StreamProtocol = - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, - Variants = ["string"], - VideoCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, - }; + var model = + new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions + { + AudioCodec = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, + }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -2048,26 +2126,27 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum< string, - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec > expectedAudioCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac; + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac; bool expectedAutoRotate = true; ApiEnum< string, - VideoTransformationReadyEventChangedDataTransformationOptionsFormat - > expectedFormat = VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4; + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat + > expectedFormat = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4; long expectedQuality = 0; ApiEnum< string, - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol > expectedStreamProtocol = - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls; + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls; List expectedVariants = ["string"]; ApiEnum< string, - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec > expectedVideoCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264; + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264; Assert.Equal(expectedAudioCodec, deserialized.AudioCodec); Assert.Equal(expectedAutoRotate, deserialized.AutoRotate); @@ -2086,19 +2165,21 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new VideoTransformationReadyEventChangedDataTransformationOptions - { - AudioCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, - AutoRotate = true, - Format = VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, - Quality = 0, - StreamProtocol = - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, - Variants = ["string"], - VideoCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, - }; + var model = + new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions + { + AudioCodec = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, + }; model.Validate(); } @@ -2106,7 +2187,9 @@ public void Validation_Works() [Fact] public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new VideoTransformationReadyEventChangedDataTransformationOptions { }; + var model = + new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions + { }; Assert.Null(model.AudioCodec); Assert.False(model.RawData.ContainsKey("audio_codec")); @@ -2127,7 +2210,9 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = new VideoTransformationReadyEventChangedDataTransformationOptions { }; + var model = + new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions + { }; model.Validate(); } @@ -2135,17 +2220,18 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - var model = new VideoTransformationReadyEventChangedDataTransformationOptions - { - // Null should be interpreted as omitted for these properties - AudioCodec = null, - AutoRotate = null, - Format = null, - Quality = null, - StreamProtocol = null, - Variants = null, - VideoCodec = null, - }; + var model = + new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions + { + // Null should be interpreted as omitted for these properties + AudioCodec = null, + AutoRotate = null, + Format = null, + Quality = null, + StreamProtocol = null, + Variants = null, + VideoCodec = null, + }; Assert.Null(model.AudioCodec); Assert.False(model.RawData.ContainsKey("audio_codec")); @@ -2166,17 +2252,18 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - var model = new VideoTransformationReadyEventChangedDataTransformationOptions - { - // Null should be interpreted as omitted for these properties - AudioCodec = null, - AutoRotate = null, - Format = null, - Quality = null, - StreamProtocol = null, - Variants = null, - VideoCodec = null, - }; + var model = + new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions + { + // Null should be interpreted as omitted for these properties + AudioCodec = null, + AutoRotate = null, + Format = null, + Quality = null, + StreamProtocol = null, + Variants = null, + VideoCodec = null, + }; model.Validate(); } @@ -2184,39 +2271,47 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new VideoTransformationReadyEventChangedDataTransformationOptions - { - AudioCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, - AutoRotate = true, - Format = VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, - Quality = 0, - StreamProtocol = - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, - Variants = ["string"], - VideoCodec = - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, - }; + var model = + new VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions + { + AudioCodec = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + AutoRotate = true, + Format = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + Quality = 0, + StreamProtocol = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, + Variants = ["string"], + VideoCodec = + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, + }; - VideoTransformationReadyEventChangedDataTransformationOptions copied = new(model); + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions copied = + new(model); Assert.Equal(model, copied); } } -public class VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodecTest : TestBase +public class VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodecTest + : TestBase { [Theory] - [InlineData(VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac)] - [InlineData(VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Opus)] + [InlineData( + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac + )] + [InlineData( + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Opus + )] public void Validation_Works( - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec rawValue + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec > value = rawValue; value.Validate(); } @@ -2225,7 +2320,10 @@ VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec rawValue public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum< + string, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec + > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -2233,21 +2331,28 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac)] - [InlineData(VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Opus)] + [InlineData( + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac + )] + [InlineData( + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Opus + )] public void SerializationRoundtrip_Works( - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec rawValue + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum< + string, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec + > >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -2257,32 +2362,51 @@ VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec rawValue public void InvalidEnumSerializationRoundtrip_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum< + string, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec + > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum< + string, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec + > >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class VideoTransformationReadyEventChangedDataTransformationOptionsFormatTest : TestBase +public class VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormatTest + : TestBase { [Theory] - [InlineData(VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4)] - [InlineData(VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Webm)] - [InlineData(VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Jpg)] - [InlineData(VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Png)] - [InlineData(VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Webp)] + [InlineData( + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4 + )] + [InlineData( + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Webm + )] + [InlineData( + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Jpg + )] + [InlineData( + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Png + )] + [InlineData( + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Webp + )] public void Validation_Works( - VideoTransformationReadyEventChangedDataTransformationOptionsFormat rawValue + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat rawValue ) { // force implicit conversion because Theory can't do that for us - ApiEnum value = - rawValue; + ApiEnum< + string, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat + > value = rawValue; value.Validate(); } @@ -2290,7 +2414,10 @@ VideoTransformationReadyEventChangedDataTransformationOptionsFormat rawValue public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum< + string, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat + > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -2298,22 +2425,37 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4)] - [InlineData(VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Webm)] - [InlineData(VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Jpg)] - [InlineData(VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Png)] - [InlineData(VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Webp)] + [InlineData( + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4 + )] + [InlineData( + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Webm + )] + [InlineData( + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Jpg + )] + [InlineData( + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Png + )] + [InlineData( + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Webp + )] public void SerializationRoundtrip_Works( - VideoTransformationReadyEventChangedDataTransformationOptionsFormat rawValue + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat rawValue ) { // force implicit conversion because Theory can't do that for us - ApiEnum value = - rawValue; + ApiEnum< + string, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat + > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum< + string, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat + > >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -2323,31 +2465,41 @@ VideoTransformationReadyEventChangedDataTransformationOptionsFormat rawValue public void InvalidEnumSerializationRoundtrip_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum< + string, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat + > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum< + string, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat + > >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocolTest +public class VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocolTest : TestBase { [Theory] - [InlineData(VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls)] - [InlineData(VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Dash)] + [InlineData( + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls + )] + [InlineData( + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Dash + )] public void Validation_Works( - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol rawValue + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol > value = rawValue; value.Validate(); } @@ -2358,7 +2510,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -2367,23 +2519,27 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls)] - [InlineData(VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Dash)] + [InlineData( + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls + )] + [InlineData( + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Dash + )] public void SerializationRoundtrip_Works( - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol rawValue + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol > >(json, ModelBase.SerializerOptions); @@ -2396,14 +2552,14 @@ public void InvalidEnumSerializationRoundtrip_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol > >(json, ModelBase.SerializerOptions); @@ -2411,20 +2567,27 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodecTest : TestBase +public class VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodecTest + : TestBase { [Theory] - [InlineData(VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264)] - [InlineData(VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.Vp9)] - [InlineData(VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.Av1)] + [InlineData( + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264 + )] + [InlineData( + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.Vp9 + )] + [InlineData( + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.Av1 + )] public void Validation_Works( - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec rawValue + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec > value = rawValue; value.Validate(); } @@ -2433,7 +2596,10 @@ VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec rawValue public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum< + string, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec + > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -2441,22 +2607,31 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264)] - [InlineData(VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.Vp9)] - [InlineData(VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.Av1)] + [InlineData( + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264 + )] + [InlineData( + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.Vp9 + )] + [InlineData( + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.Av1 + )] public void SerializationRoundtrip_Works( - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec rawValue + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum< + string, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec + > >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -2466,11 +2641,17 @@ VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec rawValue public void InvalidEnumSerializationRoundtrip_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum< + string, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec + > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum< + string, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec + > >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -2749,12 +2930,12 @@ public void CopyConstructor_Works() } } -public class VideoTransformationReadyEventChangedRequestTest : TestBase +public class VideoTransformationReadyEventVideoTransformationReadyEventRequestTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new VideoTransformationReadyEventChangedRequest + var model = new VideoTransformationReadyEventVideoTransformationReadyEventRequest { Url = "https://example.com", XRequestID = "x_request_id", @@ -2773,7 +2954,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new VideoTransformationReadyEventChangedRequest + var model = new VideoTransformationReadyEventVideoTransformationReadyEventRequest { Url = "https://example.com", XRequestID = "x_request_id", @@ -2781,10 +2962,11 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -2792,7 +2974,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new VideoTransformationReadyEventChangedRequest + var model = new VideoTransformationReadyEventVideoTransformationReadyEventRequest { Url = "https://example.com", XRequestID = "x_request_id", @@ -2800,10 +2982,11 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.NotNull(deserialized); string expectedUrl = "https://example.com"; @@ -2818,7 +3001,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new VideoTransformationReadyEventChangedRequest + var model = new VideoTransformationReadyEventVideoTransformationReadyEventRequest { Url = "https://example.com", XRequestID = "x_request_id", @@ -2831,7 +3014,7 @@ public void Validation_Works() [Fact] public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new VideoTransformationReadyEventChangedRequest + var model = new VideoTransformationReadyEventVideoTransformationReadyEventRequest { Url = "https://example.com", XRequestID = "x_request_id", @@ -2844,7 +3027,7 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = new VideoTransformationReadyEventChangedRequest + var model = new VideoTransformationReadyEventVideoTransformationReadyEventRequest { Url = "https://example.com", XRequestID = "x_request_id", @@ -2856,7 +3039,7 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - var model = new VideoTransformationReadyEventChangedRequest + var model = new VideoTransformationReadyEventVideoTransformationReadyEventRequest { Url = "https://example.com", XRequestID = "x_request_id", @@ -2872,7 +3055,7 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - var model = new VideoTransformationReadyEventChangedRequest + var model = new VideoTransformationReadyEventVideoTransformationReadyEventRequest { Url = "https://example.com", XRequestID = "x_request_id", @@ -2887,14 +3070,14 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new VideoTransformationReadyEventChangedRequest + var model = new VideoTransformationReadyEventVideoTransformationReadyEventRequest { Url = "https://example.com", XRequestID = "x_request_id", UserAgent = "user_agent", }; - VideoTransformationReadyEventChangedRequest copied = new(model); + VideoTransformationReadyEventVideoTransformationReadyEventRequest copied = new(model); Assert.Equal(model, copied); } diff --git a/src/Imagekit/Core/ModelBase.cs b/src/Imagekit/Core/ModelBase.cs index bbcf4b60..941432ed 100644 --- a/src/Imagekit/Core/ModelBase.cs +++ b/src/Imagekit/Core/ModelBase.cs @@ -140,23 +140,23 @@ protected ModelBase(ModelBase modelBase) >(), new ApiEnumConverter< string, - Webhooks::VideoTransformationReadyEventChangedDataTransformationType + Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType >(), new ApiEnumConverter< string, - Webhooks::VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec + Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec >(), new ApiEnumConverter< string, - Webhooks::VideoTransformationReadyEventChangedDataTransformationOptionsFormat + Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat >(), new ApiEnumConverter< string, - Webhooks::VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol + Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol >(), new ApiEnumConverter< string, - Webhooks::VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec + Webhooks::VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec >(), }, }; diff --git a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponse.cs b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponse.cs index 4e1afd88..c6ededc4 100644 --- a/src/Imagekit/Models/Beta/V2/Files/FileUploadResponse.cs +++ b/src/Imagekit/Models/Beta/V2/Files/FileUploadResponse.cs @@ -1533,10 +1533,7 @@ public DefaultValue(bool value, JsonElement? element = null) this._element = element; } - public DefaultValue( - IReadOnlyList value, - JsonElement? element = null - ) + public DefaultValue(IReadOnlyList value, JsonElement? element = null) { this.Value = ImmutableArray.ToImmutableArray(value); this._element = element; @@ -1612,24 +1609,22 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type where T is a UnnamedSchemaWithArrayParent2. + /// type where T is a DefaultValueArrayItem. /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickMixed(out var value)) { - /// // `value` is of type `IReadOnlyList<UnnamedSchemaWithArrayParent2>` + /// // `value` is of type `IReadOnlyList<DefaultValueArrayItem>` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickMixed( - [NotNullWhen(true)] out IReadOnlyList? value - ) + public bool TryPickMixed([NotNullWhen(true)] out IReadOnlyList? value) { - value = this.Value as IReadOnlyList; + value = this.Value as IReadOnlyList; return value != null; } @@ -1650,7 +1645,7 @@ public bool TryPickMixed( /// (string value) => {...}, /// (double value) => {...}, /// (bool value) => {...}, - /// (IReadOnlyList<UnnamedSchemaWithArrayParent2> value) => {...} + /// (IReadOnlyList<DefaultValueArrayItem> value) => {...} /// ); /// /// @@ -1659,7 +1654,7 @@ public void Switch( System::Action @string, System::Action @double, System::Action @bool, - System::Action> mixed + System::Action> mixed ) { switch (this.Value) @@ -1673,7 +1668,7 @@ public void Switch( case bool value: @bool(value); break; - case IReadOnlyList value: + case IReadOnlyList value: mixed(value); break; default: @@ -1701,7 +1696,7 @@ public void Switch( /// (string value) => {...}, /// (double value) => {...}, /// (bool value) => {...}, - /// (IReadOnlyList<UnnamedSchemaWithArrayParent2> value) => {...} + /// (IReadOnlyList<DefaultValueArrayItem> value) => {...} /// ); /// /// @@ -1710,7 +1705,7 @@ public T Match( System::Func @string, System::Func @double, System::Func @bool, - System::Func, T> mixed + System::Func, T> mixed ) { return this.Value switch @@ -1718,7 +1713,7 @@ public T Match( string value => @string(value), double value => @double(value), bool value => @bool(value), - IReadOnlyList value => mixed(value), + IReadOnlyList value => mixed(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of DefaultValue" ), @@ -1731,8 +1726,8 @@ public T Match( public static implicit operator DefaultValue(bool value) => new(value); - public static implicit operator DefaultValue(List value) => - new((IReadOnlyList)value); + public static implicit operator DefaultValue(List value) => + new((IReadOnlyList)value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -1789,7 +1784,7 @@ int VariantIndex() string _ => 0, double _ => 1, bool _ => 2, - IReadOnlyList _ => 3, + IReadOnlyList _ => 3, _ => -1, }; } @@ -1837,7 +1832,7 @@ JsonSerializerOptions options try { - var deserialized = JsonSerializer.Deserialize>( + var deserialized = JsonSerializer.Deserialize>( element, options ); @@ -1868,8 +1863,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(UnnamedSchemaWithArrayParent2Converter))] -public record class UnnamedSchemaWithArrayParent2 : ModelBase +[JsonConverter(typeof(DefaultValueArrayItemConverter))] +public record class DefaultValueArrayItem : ModelBase { public object? Value { get; } = null; @@ -1886,25 +1881,25 @@ public JsonElement Json } } - public UnnamedSchemaWithArrayParent2(string value, JsonElement? element = null) + public DefaultValueArrayItem(string value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent2(double value, JsonElement? element = null) + public DefaultValueArrayItem(double value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent2(bool value, JsonElement? element = null) + public DefaultValueArrayItem(bool value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent2(JsonElement element) + public DefaultValueArrayItem(JsonElement element) { this._element = element; } @@ -2012,7 +2007,7 @@ public void Switch( break; default: throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent2" + "Data did not match any variant of DefaultValueArrayItem" ); } } @@ -2051,16 +2046,16 @@ public T Match( double value => @double(value), bool value => @bool(value), _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent2" + "Data did not match any variant of DefaultValueArrayItem" ), }; } - public static implicit operator UnnamedSchemaWithArrayParent2(string value) => new(value); + public static implicit operator DefaultValueArrayItem(string value) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent2(double value) => new(value); + public static implicit operator DefaultValueArrayItem(double value) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent2(bool value) => new(value); + public static implicit operator DefaultValueArrayItem(bool value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -2077,12 +2072,12 @@ public override void Validate() if (this.Value == null) { throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent2" + "Data did not match any variant of DefaultValueArrayItem" ); } } - public virtual bool Equals(UnnamedSchemaWithArrayParent2? other) => + public virtual bool Equals(DefaultValueArrayItem? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -2110,9 +2105,9 @@ int VariantIndex() } } -sealed class UnnamedSchemaWithArrayParent2Converter : JsonConverter +sealed class DefaultValueArrayItemConverter : JsonConverter { - public override UnnamedSchemaWithArrayParent2? Read( + public override DefaultValueArrayItem? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -2155,7 +2150,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - UnnamedSchemaWithArrayParent2 value, + DefaultValueArrayItem value, JsonSerializerOptions options ) { diff --git a/src/Imagekit/Models/Files/File.cs b/src/Imagekit/Models/Files/File.cs index 760786c0..d9dd50f1 100644 --- a/src/Imagekit/Models/Files/File.cs +++ b/src/Imagekit/Models/Files/File.cs @@ -1198,10 +1198,7 @@ public DefaultValue(bool value, JsonElement? element = null) this._element = element; } - public DefaultValue( - IReadOnlyList value, - JsonElement? element = null - ) + public DefaultValue(IReadOnlyList value, JsonElement? element = null) { this.Value = ImmutableArray.ToImmutableArray(value); this._element = element; @@ -1277,24 +1274,22 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type where T is a UnnamedSchemaWithArrayParent0. + /// type where T is a DefaultValueArrayItem. /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickMixed(out var value)) { - /// // `value` is of type `IReadOnlyList<UnnamedSchemaWithArrayParent0>` + /// // `value` is of type `IReadOnlyList<DefaultValueArrayItem>` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickMixed( - [NotNullWhen(true)] out IReadOnlyList? value - ) + public bool TryPickMixed([NotNullWhen(true)] out IReadOnlyList? value) { - value = this.Value as IReadOnlyList; + value = this.Value as IReadOnlyList; return value != null; } @@ -1315,7 +1310,7 @@ public bool TryPickMixed( /// (string value) => {...}, /// (double value) => {...}, /// (bool value) => {...}, - /// (IReadOnlyList<UnnamedSchemaWithArrayParent0> value) => {...} + /// (IReadOnlyList<DefaultValueArrayItem> value) => {...} /// ); /// /// @@ -1324,7 +1319,7 @@ public void Switch( System::Action @string, System::Action @double, System::Action @bool, - System::Action> mixed + System::Action> mixed ) { switch (this.Value) @@ -1338,7 +1333,7 @@ public void Switch( case bool value: @bool(value); break; - case IReadOnlyList value: + case IReadOnlyList value: mixed(value); break; default: @@ -1366,7 +1361,7 @@ public void Switch( /// (string value) => {...}, /// (double value) => {...}, /// (bool value) => {...}, - /// (IReadOnlyList<UnnamedSchemaWithArrayParent0> value) => {...} + /// (IReadOnlyList<DefaultValueArrayItem> value) => {...} /// ); /// /// @@ -1375,7 +1370,7 @@ public T Match( System::Func @string, System::Func @double, System::Func @bool, - System::Func, T> mixed + System::Func, T> mixed ) { return this.Value switch @@ -1383,7 +1378,7 @@ public T Match( string value => @string(value), double value => @double(value), bool value => @bool(value), - IReadOnlyList value => mixed(value), + IReadOnlyList value => mixed(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of DefaultValue" ), @@ -1396,8 +1391,8 @@ public T Match( public static implicit operator DefaultValue(bool value) => new(value); - public static implicit operator DefaultValue(List value) => - new((IReadOnlyList)value); + public static implicit operator DefaultValue(List value) => + new((IReadOnlyList)value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -1454,7 +1449,7 @@ int VariantIndex() string _ => 0, double _ => 1, bool _ => 2, - IReadOnlyList _ => 3, + IReadOnlyList _ => 3, _ => -1, }; } @@ -1502,7 +1497,7 @@ JsonSerializerOptions options try { - var deserialized = JsonSerializer.Deserialize>( + var deserialized = JsonSerializer.Deserialize>( element, options ); @@ -1533,8 +1528,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(UnnamedSchemaWithArrayParent0Converter))] -public record class UnnamedSchemaWithArrayParent0 : ModelBase +[JsonConverter(typeof(DefaultValueArrayItemConverter))] +public record class DefaultValueArrayItem : ModelBase { public object? Value { get; } = null; @@ -1551,25 +1546,25 @@ public JsonElement Json } } - public UnnamedSchemaWithArrayParent0(string value, JsonElement? element = null) + public DefaultValueArrayItem(string value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent0(double value, JsonElement? element = null) + public DefaultValueArrayItem(double value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent0(bool value, JsonElement? element = null) + public DefaultValueArrayItem(bool value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent0(JsonElement element) + public DefaultValueArrayItem(JsonElement element) { this._element = element; } @@ -1677,7 +1672,7 @@ public void Switch( break; default: throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent0" + "Data did not match any variant of DefaultValueArrayItem" ); } } @@ -1716,16 +1711,16 @@ public T Match( double value => @double(value), bool value => @bool(value), _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent0" + "Data did not match any variant of DefaultValueArrayItem" ), }; } - public static implicit operator UnnamedSchemaWithArrayParent0(string value) => new(value); + public static implicit operator DefaultValueArrayItem(string value) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent0(double value) => new(value); + public static implicit operator DefaultValueArrayItem(double value) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent0(bool value) => new(value); + public static implicit operator DefaultValueArrayItem(bool value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -1742,12 +1737,12 @@ public override void Validate() if (this.Value == null) { throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent0" + "Data did not match any variant of DefaultValueArrayItem" ); } } - public virtual bool Equals(UnnamedSchemaWithArrayParent0? other) => + public virtual bool Equals(DefaultValueArrayItem? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -1775,9 +1770,9 @@ int VariantIndex() } } -sealed class UnnamedSchemaWithArrayParent0Converter : JsonConverter +sealed class DefaultValueArrayItemConverter : JsonConverter { - public override UnnamedSchemaWithArrayParent0? Read( + public override DefaultValueArrayItem? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -1820,7 +1815,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - UnnamedSchemaWithArrayParent0 value, + DefaultValueArrayItem value, JsonSerializerOptions options ) { diff --git a/src/Imagekit/Models/Files/FileUpdateResponse.cs b/src/Imagekit/Models/Files/FileUpdateResponse.cs index 329a6e6f..cb472fda 100644 --- a/src/Imagekit/Models/Files/FileUpdateResponse.cs +++ b/src/Imagekit/Models/Files/FileUpdateResponse.cs @@ -754,8 +754,13 @@ public FileUpdateResponse FromRawUnchecked(IReadOnlyDictionary))] -public sealed record class IntersectionMember1 : JsonModel +[JsonConverter( + typeof(JsonModelConverter< + FileUpdateResponseFileUpdateResponse, + FileUpdateResponseFileUpdateResponseFromRaw + >) +)] +public sealed record class FileUpdateResponseFileUpdateResponse : JsonModel { public ExtensionStatus? ExtensionStatus { @@ -781,29 +786,31 @@ public override void Validate() this.ExtensionStatus?.Validate(); } - public IntersectionMember1() { } + public FileUpdateResponseFileUpdateResponse() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public IntersectionMember1(IntersectionMember1 intersectionMember1) - : base(intersectionMember1) { } + public FileUpdateResponseFileUpdateResponse( + FileUpdateResponseFileUpdateResponse fileUpdateResponseFileUpdateResponse + ) + : base(fileUpdateResponseFileUpdateResponse) { } #pragma warning restore CS8618 - public IntersectionMember1(IReadOnlyDictionary rawData) + public FileUpdateResponseFileUpdateResponse(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - IntersectionMember1(FrozenDictionary rawData) + FileUpdateResponseFileUpdateResponse(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static IntersectionMember1 FromRawUnchecked( + /// + public static FileUpdateResponseFileUpdateResponse FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -811,11 +818,13 @@ IReadOnlyDictionary rawData } } -class IntersectionMember1FromRaw : IFromRawJson +class FileUpdateResponseFileUpdateResponseFromRaw + : IFromRawJson { /// - public IntersectionMember1 FromRawUnchecked(IReadOnlyDictionary rawData) => - IntersectionMember1.FromRawUnchecked(rawData); + public FileUpdateResponseFileUpdateResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) => FileUpdateResponseFileUpdateResponse.FromRawUnchecked(rawData); } [JsonConverter(typeof(JsonModelConverter))] diff --git a/src/Imagekit/Models/Files/FileUploadResponse.cs b/src/Imagekit/Models/Files/FileUploadResponse.cs index 31dbbfcf..02f65343 100644 --- a/src/Imagekit/Models/Files/FileUploadResponse.cs +++ b/src/Imagekit/Models/Files/FileUploadResponse.cs @@ -1599,7 +1599,7 @@ public FileUploadResponseSelectedFieldsSchemaItemDefaultValue( } public FileUploadResponseSelectedFieldsSchemaItemDefaultValue( - IReadOnlyList value, + IReadOnlyList value, JsonElement? element = null ) { @@ -1677,24 +1677,27 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type where T is a UnnamedSchemaWithArrayParent1. + /// type where T is a FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem. /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickMixed(out var value)) { - /// // `value` is of type `IReadOnlyList<UnnamedSchemaWithArrayParent1>` + /// // `value` is of type `IReadOnlyList<FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem>` /// Console.WriteLine(value); /// } /// /// /// public bool TryPickMixed( - [NotNullWhen(true)] out IReadOnlyList? value + [NotNullWhen(true)] + out IReadOnlyList? value ) { - value = this.Value as IReadOnlyList; + value = + this.Value + as IReadOnlyList; return value != null; } @@ -1715,7 +1718,7 @@ public bool TryPickMixed( /// (string value) => {...}, /// (double value) => {...}, /// (bool value) => {...}, - /// (IReadOnlyList<UnnamedSchemaWithArrayParent1> value) => {...} + /// (IReadOnlyList<FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem> value) => {...} /// ); /// /// @@ -1724,7 +1727,9 @@ public void Switch( System::Action @string, System::Action @double, System::Action @bool, - System::Action> mixed + System::Action< + IReadOnlyList + > mixed ) { switch (this.Value) @@ -1738,7 +1743,7 @@ public void Switch( case bool value: @bool(value); break; - case IReadOnlyList value: + case IReadOnlyList value: mixed(value); break; default: @@ -1766,7 +1771,7 @@ public void Switch( /// (string value) => {...}, /// (double value) => {...}, /// (bool value) => {...}, - /// (IReadOnlyList<UnnamedSchemaWithArrayParent1> value) => {...} + /// (IReadOnlyList<FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem> value) => {...} /// ); /// /// @@ -1775,7 +1780,10 @@ public T Match( System::Func @string, System::Func @double, System::Func @bool, - System::Func, T> mixed + System::Func< + IReadOnlyList, + T + > mixed ) { return this.Value switch @@ -1783,7 +1791,8 @@ public T Match( string value => @string(value), double value => @double(value), bool value => @bool(value), - IReadOnlyList value => mixed(value), + IReadOnlyList value => + mixed(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of FileUploadResponseSelectedFieldsSchemaItemDefaultValue" ), @@ -1803,8 +1812,12 @@ bool value ) => new(value); public static implicit operator FileUploadResponseSelectedFieldsSchemaItemDefaultValue( - List value - ) => new((IReadOnlyList)value); + List value + ) => + new( + (IReadOnlyList) + value + ); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -1861,7 +1874,8 @@ int VariantIndex() string _ => 0, double _ => 1, bool _ => 2, - IReadOnlyList _ => 3, + IReadOnlyList _ => + 3, _ => -1, }; } @@ -1910,10 +1924,9 @@ JsonSerializerOptions options try { - var deserialized = JsonSerializer.Deserialize>( - element, - options - ); + var deserialized = JsonSerializer.Deserialize< + List + >(element, options); if (deserialized != null) { foreach (var item in deserialized) @@ -1941,8 +1954,11 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(UnnamedSchemaWithArrayParent1Converter))] -public record class UnnamedSchemaWithArrayParent1 : ModelBase +[JsonConverter( + typeof(FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItemConverter) +)] +public record class FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem + : ModelBase { public object? Value { get; } = null; @@ -1959,25 +1975,36 @@ public JsonElement Json } } - public UnnamedSchemaWithArrayParent1(string value, JsonElement? element = null) + public FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + string value, + JsonElement? element = null + ) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent1(double value, JsonElement? element = null) + public FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + double value, + JsonElement? element = null + ) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent1(bool value, JsonElement? element = null) + public FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + bool value, + JsonElement? element = null + ) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent1(JsonElement element) + public FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + JsonElement element + ) { this._element = element; } @@ -2085,7 +2112,7 @@ public void Switch( break; default: throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent1" + "Data did not match any variant of FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem" ); } } @@ -2124,16 +2151,22 @@ public T Match( double value => @double(value), bool value => @bool(value), _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent1" + "Data did not match any variant of FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem" ), }; } - public static implicit operator UnnamedSchemaWithArrayParent1(string value) => new(value); + public static implicit operator FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + string value + ) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent1(double value) => new(value); + public static implicit operator FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + double value + ) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent1(bool value) => new(value); + public static implicit operator FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem( + bool value + ) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -2150,12 +2183,14 @@ public override void Validate() if (this.Value == null) { throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent1" + "Data did not match any variant of FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem" ); } } - public virtual bool Equals(UnnamedSchemaWithArrayParent1? other) => + public virtual bool Equals( + FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem? other + ) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -2183,9 +2218,10 @@ int VariantIndex() } } -sealed class UnnamedSchemaWithArrayParent1Converter : JsonConverter +sealed class FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItemConverter + : JsonConverter { - public override UnnamedSchemaWithArrayParent1? Read( + public override FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -2228,7 +2264,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - UnnamedSchemaWithArrayParent1 value, + FileUploadResponseSelectedFieldsSchemaItemDefaultValueDefaultValueArrayItem value, JsonSerializerOptions options ) { diff --git a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEvent.cs b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEvent.cs index 1b8e7f70..884c4bf5 100644 --- a/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEvent.cs +++ b/src/Imagekit/Models/Webhooks/UploadPreTransformSuccessEvent.cs @@ -1813,10 +1813,7 @@ public DefaultValue(bool value, JsonElement? element = null) this._element = element; } - public DefaultValue( - IReadOnlyList value, - JsonElement? element = null - ) + public DefaultValue(IReadOnlyList value, JsonElement? element = null) { this.Value = ImmutableArray.ToImmutableArray(value); this._element = element; @@ -1892,24 +1889,22 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type where T is a UnnamedSchemaWithArrayParent3. + /// type where T is a DefaultValueArrayItem. /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickMixed(out var value)) { - /// // `value` is of type `IReadOnlyList<UnnamedSchemaWithArrayParent3>` + /// // `value` is of type `IReadOnlyList<DefaultValueArrayItem>` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickMixed( - [NotNullWhen(true)] out IReadOnlyList? value - ) + public bool TryPickMixed([NotNullWhen(true)] out IReadOnlyList? value) { - value = this.Value as IReadOnlyList; + value = this.Value as IReadOnlyList; return value != null; } @@ -1930,7 +1925,7 @@ public bool TryPickMixed( /// (string value) => {...}, /// (double value) => {...}, /// (bool value) => {...}, - /// (IReadOnlyList<UnnamedSchemaWithArrayParent3> value) => {...} + /// (IReadOnlyList<DefaultValueArrayItem> value) => {...} /// ); /// /// @@ -1939,7 +1934,7 @@ public void Switch( System::Action @string, System::Action @double, System::Action @bool, - System::Action> mixed + System::Action> mixed ) { switch (this.Value) @@ -1953,7 +1948,7 @@ public void Switch( case bool value: @bool(value); break; - case IReadOnlyList value: + case IReadOnlyList value: mixed(value); break; default: @@ -1981,7 +1976,7 @@ public void Switch( /// (string value) => {...}, /// (double value) => {...}, /// (bool value) => {...}, - /// (IReadOnlyList<UnnamedSchemaWithArrayParent3> value) => {...} + /// (IReadOnlyList<DefaultValueArrayItem> value) => {...} /// ); /// /// @@ -1990,7 +1985,7 @@ public T Match( System::Func @string, System::Func @double, System::Func @bool, - System::Func, T> mixed + System::Func, T> mixed ) { return this.Value switch @@ -1998,7 +1993,7 @@ public T Match( string value => @string(value), double value => @double(value), bool value => @bool(value), - IReadOnlyList value => mixed(value), + IReadOnlyList value => mixed(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of DefaultValue" ), @@ -2011,8 +2006,8 @@ public T Match( public static implicit operator DefaultValue(bool value) => new(value); - public static implicit operator DefaultValue(List value) => - new((IReadOnlyList)value); + public static implicit operator DefaultValue(List value) => + new((IReadOnlyList)value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -2069,7 +2064,7 @@ int VariantIndex() string _ => 0, double _ => 1, bool _ => 2, - IReadOnlyList _ => 3, + IReadOnlyList _ => 3, _ => -1, }; } @@ -2117,7 +2112,7 @@ JsonSerializerOptions options try { - var deserialized = JsonSerializer.Deserialize>( + var deserialized = JsonSerializer.Deserialize>( element, options ); @@ -2148,8 +2143,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(UnnamedSchemaWithArrayParent3Converter))] -public record class UnnamedSchemaWithArrayParent3 : ModelBase +[JsonConverter(typeof(DefaultValueArrayItemConverter))] +public record class DefaultValueArrayItem : ModelBase { public object? Value { get; } = null; @@ -2166,25 +2161,25 @@ public JsonElement Json } } - public UnnamedSchemaWithArrayParent3(string value, JsonElement? element = null) + public DefaultValueArrayItem(string value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent3(double value, JsonElement? element = null) + public DefaultValueArrayItem(double value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent3(bool value, JsonElement? element = null) + public DefaultValueArrayItem(bool value, JsonElement? element = null) { this.Value = value; this._element = element; } - public UnnamedSchemaWithArrayParent3(JsonElement element) + public DefaultValueArrayItem(JsonElement element) { this._element = element; } @@ -2292,7 +2287,7 @@ public void Switch( break; default: throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent3" + "Data did not match any variant of DefaultValueArrayItem" ); } } @@ -2331,16 +2326,16 @@ public T Match( double value => @double(value), bool value => @bool(value), _ => throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent3" + "Data did not match any variant of DefaultValueArrayItem" ), }; } - public static implicit operator UnnamedSchemaWithArrayParent3(string value) => new(value); + public static implicit operator DefaultValueArrayItem(string value) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent3(double value) => new(value); + public static implicit operator DefaultValueArrayItem(double value) => new(value); - public static implicit operator UnnamedSchemaWithArrayParent3(bool value) => new(value); + public static implicit operator DefaultValueArrayItem(bool value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -2357,12 +2352,12 @@ public override void Validate() if (this.Value == null) { throw new ImageKitInvalidDataException( - "Data did not match any variant of UnnamedSchemaWithArrayParent3" + "Data did not match any variant of DefaultValueArrayItem" ); } } - public virtual bool Equals(UnnamedSchemaWithArrayParent3? other) => + public virtual bool Equals(DefaultValueArrayItem? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -2390,9 +2385,9 @@ int VariantIndex() } } -sealed class UnnamedSchemaWithArrayParent3Converter : JsonConverter +sealed class DefaultValueArrayItemConverter : JsonConverter { - public override UnnamedSchemaWithArrayParent3? Read( + public override DefaultValueArrayItem? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -2435,7 +2430,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - UnnamedSchemaWithArrayParent3 value, + DefaultValueArrayItem value, JsonSerializerOptions options ) { diff --git a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEvent.cs b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEvent.cs index 69e871e9..a3dffdaa 100644 --- a/src/Imagekit/Models/Webhooks/VideoTransformationReadyEvent.cs +++ b/src/Imagekit/Models/Webhooks/VideoTransformationReadyEvent.cs @@ -60,12 +60,14 @@ public required string Type init { this._rawData.Set("created_at", value); } } - public required VideoTransformationReadyEventChangedData Data + public required VideoTransformationReadyEventVideoTransformationReadyEventData Data { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("data"); + return this._rawData.GetNotNullClass( + "data" + ); } init { this._rawData.Set("data", value); } } @@ -73,12 +75,12 @@ public required VideoTransformationReadyEventChangedData Data /// /// Information about the original request that triggered the video transformation. /// - public required VideoTransformationReadyEventChangedRequest Request + public required VideoTransformationReadyEventVideoTransformationReadyEventRequest Request { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "request" ); } @@ -169,11 +171,11 @@ IReadOnlyDictionary rawData /// [JsonConverter( typeof(JsonModelConverter< - VideoTransformationReadyEventChanged, - VideoTransformationReadyEventChangedFromRaw + VideoTransformationReadyEventVideoTransformationReadyEvent, + VideoTransformationReadyEventVideoTransformationReadyEventFromRaw >) )] -public sealed record class VideoTransformationReadyEventChanged : JsonModel +public sealed record class VideoTransformationReadyEventVideoTransformationReadyEvent : JsonModel { /// /// Timestamp when the event was created in ISO8601 format. @@ -188,12 +190,14 @@ public sealed record class VideoTransformationReadyEventChanged : JsonModel init { this._rawData.Set("created_at", value); } } - public required VideoTransformationReadyEventChangedData Data + public required VideoTransformationReadyEventVideoTransformationReadyEventData Data { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("data"); + return this._rawData.GetNotNullClass( + "data" + ); } init { this._rawData.Set("data", value); } } @@ -201,12 +205,12 @@ public required VideoTransformationReadyEventChangedData Data /// /// Information about the original request that triggered the video transformation. /// - public required VideoTransformationReadyEventChangedRequest Request + public required VideoTransformationReadyEventVideoTransformationReadyEventRequest Request { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "request" ); } @@ -262,20 +266,22 @@ public override void Validate() this.Timings?.Validate(); } - public VideoTransformationReadyEventChanged() + public VideoTransformationReadyEventVideoTransformationReadyEvent() { this.Type = JsonSerializer.SerializeToElement("video.transformation.ready"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public VideoTransformationReadyEventChanged( - VideoTransformationReadyEventChanged videoTransformationReadyEventChanged + public VideoTransformationReadyEventVideoTransformationReadyEvent( + VideoTransformationReadyEventVideoTransformationReadyEvent videoTransformationReadyEventVideoTransformationReadyEvent ) - : base(videoTransformationReadyEventChanged) { } + : base(videoTransformationReadyEventVideoTransformationReadyEvent) { } #pragma warning restore CS8618 - public VideoTransformationReadyEventChanged(IReadOnlyDictionary rawData) + public VideoTransformationReadyEventVideoTransformationReadyEvent( + IReadOnlyDictionary rawData + ) { this._rawData = new(rawData); @@ -284,14 +290,16 @@ public VideoTransformationReadyEventChanged(IReadOnlyDictionary rawData) + VideoTransformationReadyEventVideoTransformationReadyEvent( + FrozenDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static VideoTransformationReadyEventChanged FromRawUnchecked( + /// + public static VideoTransformationReadyEventVideoTransformationReadyEvent FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -299,44 +307,45 @@ IReadOnlyDictionary rawData } } -class VideoTransformationReadyEventChangedFromRaw - : IFromRawJson +class VideoTransformationReadyEventVideoTransformationReadyEventFromRaw + : IFromRawJson { /// - public VideoTransformationReadyEventChanged FromRawUnchecked( + public VideoTransformationReadyEventVideoTransformationReadyEvent FromRawUnchecked( IReadOnlyDictionary rawData - ) => VideoTransformationReadyEventChanged.FromRawUnchecked(rawData); + ) => VideoTransformationReadyEventVideoTransformationReadyEvent.FromRawUnchecked(rawData); } [JsonConverter( typeof(JsonModelConverter< - VideoTransformationReadyEventChangedData, - VideoTransformationReadyEventChangedDataFromRaw + VideoTransformationReadyEventVideoTransformationReadyEventData, + VideoTransformationReadyEventVideoTransformationReadyEventDataFromRaw >) )] -public sealed record class VideoTransformationReadyEventChangedData : JsonModel +public sealed record class VideoTransformationReadyEventVideoTransformationReadyEventData + : JsonModel { /// /// Information about the source video asset being transformed. /// - public required VideoTransformationReadyEventChangedDataAsset Asset + public required VideoTransformationReadyEventVideoTransformationReadyEventDataAsset Asset { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "asset" ); } init { this._rawData.Set("asset", value); } } - public required VideoTransformationReadyEventChangedDataTransformation Transformation + public required VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation Transformation { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "transformation" ); } @@ -350,17 +359,17 @@ public override void Validate() this.Transformation.Validate(); } - public VideoTransformationReadyEventChangedData() { } + public VideoTransformationReadyEventVideoTransformationReadyEventData() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public VideoTransformationReadyEventChangedData( - VideoTransformationReadyEventChangedData videoTransformationReadyEventChangedData + public VideoTransformationReadyEventVideoTransformationReadyEventData( + VideoTransformationReadyEventVideoTransformationReadyEventData videoTransformationReadyEventVideoTransformationReadyEventData ) - : base(videoTransformationReadyEventChangedData) { } + : base(videoTransformationReadyEventVideoTransformationReadyEventData) { } #pragma warning restore CS8618 - public VideoTransformationReadyEventChangedData( + public VideoTransformationReadyEventVideoTransformationReadyEventData( IReadOnlyDictionary rawData ) { @@ -369,14 +378,16 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - VideoTransformationReadyEventChangedData(FrozenDictionary rawData) + VideoTransformationReadyEventVideoTransformationReadyEventData( + FrozenDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static VideoTransformationReadyEventChangedData FromRawUnchecked( + /// + public static VideoTransformationReadyEventVideoTransformationReadyEventData FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -384,13 +395,13 @@ IReadOnlyDictionary rawData } } -class VideoTransformationReadyEventChangedDataFromRaw - : IFromRawJson +class VideoTransformationReadyEventVideoTransformationReadyEventDataFromRaw + : IFromRawJson { /// - public VideoTransformationReadyEventChangedData FromRawUnchecked( + public VideoTransformationReadyEventVideoTransformationReadyEventData FromRawUnchecked( IReadOnlyDictionary rawData - ) => VideoTransformationReadyEventChangedData.FromRawUnchecked(rawData); + ) => VideoTransformationReadyEventVideoTransformationReadyEventData.FromRawUnchecked(rawData); } /// @@ -398,11 +409,12 @@ IReadOnlyDictionary rawData /// [JsonConverter( typeof(JsonModelConverter< - VideoTransformationReadyEventChangedDataAsset, - VideoTransformationReadyEventChangedDataAssetFromRaw + VideoTransformationReadyEventVideoTransformationReadyEventDataAsset, + VideoTransformationReadyEventVideoTransformationReadyEventDataAssetFromRaw >) )] -public sealed record class VideoTransformationReadyEventChangedDataAsset : JsonModel +public sealed record class VideoTransformationReadyEventVideoTransformationReadyEventDataAsset + : JsonModel { /// /// URL to download or access the source video file. @@ -423,17 +435,17 @@ public override void Validate() _ = this.Url; } - public VideoTransformationReadyEventChangedDataAsset() { } + public VideoTransformationReadyEventVideoTransformationReadyEventDataAsset() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public VideoTransformationReadyEventChangedDataAsset( - VideoTransformationReadyEventChangedDataAsset videoTransformationReadyEventChangedDataAsset + public VideoTransformationReadyEventVideoTransformationReadyEventDataAsset( + VideoTransformationReadyEventVideoTransformationReadyEventDataAsset videoTransformationReadyEventVideoTransformationReadyEventDataAsset ) - : base(videoTransformationReadyEventChangedDataAsset) { } + : base(videoTransformationReadyEventVideoTransformationReadyEventDataAsset) { } #pragma warning restore CS8618 - public VideoTransformationReadyEventChangedDataAsset( + public VideoTransformationReadyEventVideoTransformationReadyEventDataAsset( IReadOnlyDictionary rawData ) { @@ -442,14 +454,16 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - VideoTransformationReadyEventChangedDataAsset(FrozenDictionary rawData) + VideoTransformationReadyEventVideoTransformationReadyEventDataAsset( + FrozenDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static VideoTransformationReadyEventChangedDataAsset FromRawUnchecked( + /// + public static VideoTransformationReadyEventVideoTransformationReadyEventDataAsset FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -457,42 +471,52 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public VideoTransformationReadyEventChangedDataAsset(string url) + public VideoTransformationReadyEventVideoTransformationReadyEventDataAsset(string url) : this() { this.Url = url; } } -class VideoTransformationReadyEventChangedDataAssetFromRaw - : IFromRawJson +class VideoTransformationReadyEventVideoTransformationReadyEventDataAssetFromRaw + : IFromRawJson { /// - public VideoTransformationReadyEventChangedDataAsset FromRawUnchecked( + public VideoTransformationReadyEventVideoTransformationReadyEventDataAsset FromRawUnchecked( IReadOnlyDictionary rawData - ) => VideoTransformationReadyEventChangedDataAsset.FromRawUnchecked(rawData); + ) => + VideoTransformationReadyEventVideoTransformationReadyEventDataAsset.FromRawUnchecked( + rawData + ); } [JsonConverter( typeof(JsonModelConverter< - VideoTransformationReadyEventChangedDataTransformation, - VideoTransformationReadyEventChangedDataTransformationFromRaw + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationFromRaw >) )] -public sealed record class VideoTransformationReadyEventChangedDataTransformation : JsonModel +public sealed record class VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation + : JsonModel { /// /// Type of video transformation: - `video-transformation`: Standard video processing /// (resize, format conversion, etc.) - `gif-to-video`: Convert animated GIF /// to video format - `video-thumbnail`: Generate thumbnail image from video /// - public required ApiEnum Type + public required ApiEnum< + string, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType + > Type { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum< + string, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType + > >("type"); } init { this._rawData.Set("type", value); } @@ -501,12 +525,12 @@ public required ApiEnum /// Configuration options for video transformations. /// - public VideoTransformationReadyEventChangedDataTransformationOptions? Options + public VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions? Options { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "options" ); } @@ -550,17 +574,17 @@ public override void Validate() this.Output?.Validate(); } - public VideoTransformationReadyEventChangedDataTransformation() { } + public VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public VideoTransformationReadyEventChangedDataTransformation( - VideoTransformationReadyEventChangedDataTransformation videoTransformationReadyEventChangedDataTransformation + public VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation( + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation videoTransformationReadyEventVideoTransformationReadyEventDataTransformation ) - : base(videoTransformationReadyEventChangedDataTransformation) { } + : base(videoTransformationReadyEventVideoTransformationReadyEventDataTransformation) { } #pragma warning restore CS8618 - public VideoTransformationReadyEventChangedDataTransformation( + public VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation( IReadOnlyDictionary rawData ) { @@ -569,7 +593,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - VideoTransformationReadyEventChangedDataTransformation( + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation( FrozenDictionary rawData ) { @@ -577,8 +601,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static VideoTransformationReadyEventChangedDataTransformation FromRawUnchecked( + /// + public static VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -586,8 +610,11 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public VideoTransformationReadyEventChangedDataTransformation( - ApiEnum type + public VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation( + ApiEnum< + string, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType + > type ) : this() { @@ -595,13 +622,16 @@ ApiEnum type } } -class VideoTransformationReadyEventChangedDataTransformationFromRaw - : IFromRawJson +class VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationFromRaw + : IFromRawJson { /// - public VideoTransformationReadyEventChangedDataTransformation FromRawUnchecked( + public VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation FromRawUnchecked( IReadOnlyDictionary rawData - ) => VideoTransformationReadyEventChangedDataTransformation.FromRawUnchecked(rawData); + ) => + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformation.FromRawUnchecked( + rawData + ); } /// @@ -609,18 +639,20 @@ IReadOnlyDictionary rawData /// (resize, format conversion, etc.) - `gif-to-video`: Convert animated GIF to video /// format - `video-thumbnail`: Generate thumbnail image from video /// -[JsonConverter(typeof(VideoTransformationReadyEventChangedDataTransformationTypeConverter))] -public enum VideoTransformationReadyEventChangedDataTransformationType +[JsonConverter( + typeof(VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationTypeConverter) +)] +public enum VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType { VideoTransformation, GifToVideo, VideoThumbnail, } -sealed class VideoTransformationReadyEventChangedDataTransformationTypeConverter - : JsonConverter +sealed class VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationTypeConverter + : JsonConverter { - public override VideoTransformationReadyEventChangedDataTransformationType Read( + public override VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -629,17 +661,20 @@ JsonSerializerOptions options return JsonSerializer.Deserialize(ref reader, options) switch { "video-transformation" => - VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation, - "gif-to-video" => VideoTransformationReadyEventChangedDataTransformationType.GifToVideo, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation, + "gif-to-video" => + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.GifToVideo, "video-thumbnail" => - VideoTransformationReadyEventChangedDataTransformationType.VideoThumbnail, - _ => (VideoTransformationReadyEventChangedDataTransformationType)(-1), + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoThumbnail, + _ => (VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType)( + -1 + ), }; } public override void Write( Utf8JsonWriter writer, - VideoTransformationReadyEventChangedDataTransformationType value, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType value, JsonSerializerOptions options ) { @@ -647,11 +682,11 @@ JsonSerializerOptions options writer, value switch { - VideoTransformationReadyEventChangedDataTransformationType.VideoTransformation => + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoTransformation => "video-transformation", - VideoTransformationReadyEventChangedDataTransformationType.GifToVideo => + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.GifToVideo => "gif-to-video", - VideoTransformationReadyEventChangedDataTransformationType.VideoThumbnail => + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationType.VideoThumbnail => "video-thumbnail", _ => throw new ImageKitInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) @@ -667,18 +702,19 @@ JsonSerializerOptions options /// [JsonConverter( typeof(JsonModelConverter< - VideoTransformationReadyEventChangedDataTransformationOptions, - VideoTransformationReadyEventChangedDataTransformationOptionsFromRaw + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFromRaw >) )] -public sealed record class VideoTransformationReadyEventChangedDataTransformationOptions : JsonModel +public sealed record class VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions + : JsonModel { /// /// Audio codec used for encoding (aac or opus). /// public ApiEnum< string, - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec >? AudioCodec { get @@ -687,7 +723,7 @@ public ApiEnum< return this._rawData.GetNullableClass< ApiEnum< string, - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec > >("audio_codec"); } @@ -728,14 +764,17 @@ public bool? AutoRotate /// public ApiEnum< string, - VideoTransformationReadyEventChangedDataTransformationOptionsFormat + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat >? Format { get { this._rawData.Freeze(); return this._rawData.GetNullableClass< - ApiEnum + ApiEnum< + string, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat + > >("format"); } init @@ -775,7 +814,7 @@ public long? Quality /// public ApiEnum< string, - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol >? StreamProtocol { get @@ -784,7 +823,7 @@ public ApiEnum< return this._rawData.GetNullableClass< ApiEnum< string, - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol > >("stream_protocol"); } @@ -828,7 +867,7 @@ public IReadOnlyList? Variants /// public ApiEnum< string, - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec >? VideoCodec { get @@ -837,7 +876,7 @@ public ApiEnum< return this._rawData.GetNullableClass< ApiEnum< string, - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec > >("video_codec"); } @@ -864,17 +903,18 @@ public override void Validate() this.VideoCodec?.Validate(); } - public VideoTransformationReadyEventChangedDataTransformationOptions() { } + public VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public VideoTransformationReadyEventChangedDataTransformationOptions( - VideoTransformationReadyEventChangedDataTransformationOptions videoTransformationReadyEventChangedDataTransformationOptions + public VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions( + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions videoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions ) - : base(videoTransformationReadyEventChangedDataTransformationOptions) { } + : base(videoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions) + { } #pragma warning restore CS8618 - public VideoTransformationReadyEventChangedDataTransformationOptions( + public VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions( IReadOnlyDictionary rawData ) { @@ -883,7 +923,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - VideoTransformationReadyEventChangedDataTransformationOptions( + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions( FrozenDictionary rawData ) { @@ -891,8 +931,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static VideoTransformationReadyEventChangedDataTransformationOptions FromRawUnchecked( + /// + public static VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -900,31 +940,34 @@ IReadOnlyDictionary rawData } } -class VideoTransformationReadyEventChangedDataTransformationOptionsFromRaw - : IFromRawJson +class VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFromRaw + : IFromRawJson { /// - public VideoTransformationReadyEventChangedDataTransformationOptions FromRawUnchecked( + public VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions FromRawUnchecked( IReadOnlyDictionary rawData - ) => VideoTransformationReadyEventChangedDataTransformationOptions.FromRawUnchecked(rawData); + ) => + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptions.FromRawUnchecked( + rawData + ); } /// /// Audio codec used for encoding (aac or opus). /// [JsonConverter( - typeof(VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodecConverter) + typeof(VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodecConverter) )] -public enum VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec +public enum VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec { Aac, Opus, } -sealed class VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodecConverter - : JsonConverter +sealed class VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodecConverter + : JsonConverter { - public override VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec Read( + public override VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -932,15 +975,20 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "aac" => VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac, - "opus" => VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Opus, - _ => (VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec)(-1), + "aac" => + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac, + "opus" => + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Opus, + _ => + (VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec)( + -1 + ), }; } public override void Write( Utf8JsonWriter writer, - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec value, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec value, JsonSerializerOptions options ) { @@ -948,9 +996,9 @@ JsonSerializerOptions options writer, value switch { - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Aac => + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Aac => "aac", - VideoTransformationReadyEventChangedDataTransformationOptionsAudioCodec.Opus => + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsAudioCodec.Opus => "opus", _ => throw new ImageKitInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) @@ -965,9 +1013,9 @@ JsonSerializerOptions options /// Output format for the transformed video or thumbnail. /// [JsonConverter( - typeof(VideoTransformationReadyEventChangedDataTransformationOptionsFormatConverter) + typeof(VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormatConverter) )] -public enum VideoTransformationReadyEventChangedDataTransformationOptionsFormat +public enum VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat { Mp4, Webm, @@ -976,10 +1024,10 @@ public enum VideoTransformationReadyEventChangedDataTransformationOptionsFormat Webp, } -sealed class VideoTransformationReadyEventChangedDataTransformationOptionsFormatConverter - : JsonConverter +sealed class VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormatConverter + : JsonConverter { - public override VideoTransformationReadyEventChangedDataTransformationOptionsFormat Read( + public override VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -987,18 +1035,26 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "mp4" => VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4, - "webm" => VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Webm, - "jpg" => VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Jpg, - "png" => VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Png, - "webp" => VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Webp, - _ => (VideoTransformationReadyEventChangedDataTransformationOptionsFormat)(-1), + "mp4" => + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4, + "webm" => + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Webm, + "jpg" => + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Jpg, + "png" => + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Png, + "webp" => + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Webp, + _ => + (VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat)( + -1 + ), }; } public override void Write( Utf8JsonWriter writer, - VideoTransformationReadyEventChangedDataTransformationOptionsFormat value, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat value, JsonSerializerOptions options ) { @@ -1006,11 +1062,16 @@ JsonSerializerOptions options writer, value switch { - VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Mp4 => "mp4", - VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Webm => "webm", - VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Jpg => "jpg", - VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Png => "png", - VideoTransformationReadyEventChangedDataTransformationOptionsFormat.Webp => "webp", + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Mp4 => + "mp4", + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Webm => + "webm", + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Jpg => + "jpg", + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Png => + "png", + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsFormat.Webp => + "webp", _ => throw new ImageKitInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -1024,18 +1085,18 @@ JsonSerializerOptions options /// Streaming protocol for adaptive bitrate streaming. /// [JsonConverter( - typeof(VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocolConverter) + typeof(VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocolConverter) )] -public enum VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol +public enum VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol { Hls, Dash, } -sealed class VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocolConverter - : JsonConverter +sealed class VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocolConverter + : JsonConverter { - public override VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol Read( + public override VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -1044,16 +1105,19 @@ JsonSerializerOptions options return JsonSerializer.Deserialize(ref reader, options) switch { "HLS" => - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls, "DASH" => - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Dash, - _ => (VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol)(-1), + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Dash, + _ => + (VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol)( + -1 + ), }; } public override void Write( Utf8JsonWriter writer, - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol value, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol value, JsonSerializerOptions options ) { @@ -1061,9 +1125,9 @@ JsonSerializerOptions options writer, value switch { - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Hls => + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Hls => "HLS", - VideoTransformationReadyEventChangedDataTransformationOptionsStreamProtocol.Dash => + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsStreamProtocol.Dash => "DASH", _ => throw new ImageKitInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) @@ -1078,19 +1142,19 @@ JsonSerializerOptions options /// Video codec used for encoding (h264, vp9, or av1). /// [JsonConverter( - typeof(VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodecConverter) + typeof(VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodecConverter) )] -public enum VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec +public enum VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec { H264, Vp9, Av1, } -sealed class VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodecConverter - : JsonConverter +sealed class VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodecConverter + : JsonConverter { - public override VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec Read( + public override VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -1098,16 +1162,22 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "h264" => VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264, - "vp9" => VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.Vp9, - "av1" => VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.Av1, - _ => (VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec)(-1), + "h264" => + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264, + "vp9" => + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.Vp9, + "av1" => + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.Av1, + _ => + (VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec)( + -1 + ), }; } public override void Write( Utf8JsonWriter writer, - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec value, + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec value, JsonSerializerOptions options ) { @@ -1115,11 +1185,11 @@ JsonSerializerOptions options writer, value switch { - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.H264 => + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.H264 => "h264", - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.Vp9 => + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.Vp9 => "vp9", - VideoTransformationReadyEventChangedDataTransformationOptionsVideoCodec.Av1 => + VideoTransformationReadyEventVideoTransformationReadyEventDataTransformationOptionsVideoCodec.Av1 => "av1", _ => throw new ImageKitInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) @@ -1326,11 +1396,12 @@ public VideoMetadata FromRawUnchecked(IReadOnlyDictionary r /// [JsonConverter( typeof(JsonModelConverter< - VideoTransformationReadyEventChangedRequest, - VideoTransformationReadyEventChangedRequestFromRaw + VideoTransformationReadyEventVideoTransformationReadyEventRequest, + VideoTransformationReadyEventVideoTransformationReadyEventRequestFromRaw >) )] -public sealed record class VideoTransformationReadyEventChangedRequest : JsonModel +public sealed record class VideoTransformationReadyEventVideoTransformationReadyEventRequest + : JsonModel { /// /// Full URL of the transformation request that was submitted. @@ -1387,17 +1458,17 @@ public override void Validate() _ = this.UserAgent; } - public VideoTransformationReadyEventChangedRequest() { } + public VideoTransformationReadyEventVideoTransformationReadyEventRequest() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public VideoTransformationReadyEventChangedRequest( - VideoTransformationReadyEventChangedRequest videoTransformationReadyEventChangedRequest + public VideoTransformationReadyEventVideoTransformationReadyEventRequest( + VideoTransformationReadyEventVideoTransformationReadyEventRequest videoTransformationReadyEventVideoTransformationReadyEventRequest ) - : base(videoTransformationReadyEventChangedRequest) { } + : base(videoTransformationReadyEventVideoTransformationReadyEventRequest) { } #pragma warning restore CS8618 - public VideoTransformationReadyEventChangedRequest( + public VideoTransformationReadyEventVideoTransformationReadyEventRequest( IReadOnlyDictionary rawData ) { @@ -1406,14 +1477,16 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - VideoTransformationReadyEventChangedRequest(FrozenDictionary rawData) + VideoTransformationReadyEventVideoTransformationReadyEventRequest( + FrozenDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static VideoTransformationReadyEventChangedRequest FromRawUnchecked( + /// + public static VideoTransformationReadyEventVideoTransformationReadyEventRequest FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -1421,13 +1494,14 @@ IReadOnlyDictionary rawData } } -class VideoTransformationReadyEventChangedRequestFromRaw - : IFromRawJson +class VideoTransformationReadyEventVideoTransformationReadyEventRequestFromRaw + : IFromRawJson { /// - public VideoTransformationReadyEventChangedRequest FromRawUnchecked( + public VideoTransformationReadyEventVideoTransformationReadyEventRequest FromRawUnchecked( IReadOnlyDictionary rawData - ) => VideoTransformationReadyEventChangedRequest.FromRawUnchecked(rawData); + ) => + VideoTransformationReadyEventVideoTransformationReadyEventRequest.FromRawUnchecked(rawData); } /// From d34c86442e9179d300c1ca77e565a8dc1c0f8552 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sun, 17 May 2026 03:48:17 +0000 Subject: [PATCH 124/129] build: enable dummy endpoint in csharp --- .stats.yml | 6 +- .../Models/Dummy/DummyCreateParamsTest.cs | 2810 +++++++++++++++++ .../Services/DummyServiceTest.cs | 12 + src/Imagekit/IImageKitClient.cs | 4 + src/Imagekit/ImageKitClient.cs | 14 + .../Models/Dummy/DummyCreateParams.cs | 581 ++++ src/Imagekit/Services/DummyService.cs | 77 + src/Imagekit/Services/IDummyService.cs | 61 + 8 files changed, 3562 insertions(+), 3 deletions(-) create mode 100644 src/Imagekit.Tests/Models/Dummy/DummyCreateParamsTest.cs create mode 100644 src/Imagekit.Tests/Services/DummyServiceTest.cs create mode 100644 src/Imagekit/Models/Dummy/DummyCreateParams.cs create mode 100644 src/Imagekit/Services/DummyService.cs create mode 100644 src/Imagekit/Services/IDummyService.cs diff --git a/.stats.yml b/.stats.yml index 88ec6965..0c1672a7 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 47 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc/imagekit-b9cc1f62fca41c286295001551cbe902d6b2f30ab775d84e549eb5affc0186ec.yml +configured_endpoints: 48 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc/imagekit-14c145ce7a0b8660a0228fb7ec2499d8e5f6c057be2750da408af8b0513f1df5.yml openapi_spec_hash: f3790446521a8f846e2e7249313de100 -config_hash: c5a7aed248c5d9ad5cd42e56fdd62c12 +config_hash: ea9d73f82c079f2c34302ff663f2aa56 diff --git a/src/Imagekit.Tests/Models/Dummy/DummyCreateParamsTest.cs b/src/Imagekit.Tests/Models/Dummy/DummyCreateParamsTest.cs new file mode 100644 index 00000000..85c03032 --- /dev/null +++ b/src/Imagekit.Tests/Models/Dummy/DummyCreateParamsTest.cs @@ -0,0 +1,2810 @@ +using System; +using System.Collections.Generic; +using Imagekit.Core; +using Imagekit.Models; +using Imagekit.Models.Dummy; + +namespace Imagekit.Tests.Models.Dummy; + +public class DummyCreateParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new DummyCreateParams + { + BaseOverlay = new() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + AnchorPoint = AnchorPoint.Top, + Focus = Focus.Center, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + }, + ExtensionConfig = new RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }, + Extensions = + [ + new ExtensionItemRemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }, + new ExtensionItemAutoTaggingExtension() + { + MaxTags = 5, + MinConfidence = 95, + Name = ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, + }, + new ExtensionItemAIAutoDescription(), + new ExtensionItemAITasks( + [ + new ExtensionItemAITasksTaskSelectTags() + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }, + new ExtensionItemAITasksTaskYesNo() + { + Instruction = "Is this a luxury or high-end fashion item?", + OnNo = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnUnknown = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnYes = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + }, + ] + ), + new SavedExtension("ext_abc123"), + ], + GetImageAttributesOptions = new() + { + Src = "/my-image.jpg", + UrlEndpoint = "https://ik.imagekit.io/demo", + ExpiresIn = 0, + QueryParameters = new Dictionary() { { "foo", "string" } }, + Signed = true, + Transformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + Colorize = "colorize", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + AnchorPoint = AnchorPoint.Top, + Focus = Focus.Center, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayTextOverlayEncoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ], + TransformationPosition = TransformationPosition.Path, + DeviceBreakpoints = [640, 750, 828, 1080, 1200, 1920, 2048, 3840], + ImageBreakpoints = [16, 32, 48, 64, 96, 128, 256, 384], + Sizes = "(min-width: 768px) 50vw, 100vw", + Width = 400, + }, + ImageOverlay = new() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + AnchorPoint = AnchorPoint.Top, + Focus = Focus.Center, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Input = "input", + Encoding = Encoding.Auto, + Transformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + Colorize = "colorize", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + AnchorPoint = AnchorPoint.Top, + Focus = Focus.Center, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayTextOverlayEncoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ], + }, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + AnchorPoint = AnchorPoint.Top, + Focus = Focus.Center, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayTextOverlayEncoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + OverlayPosition = new() + { + AnchorPoint = AnchorPoint.Top, + Focus = Focus.Center, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + }, + OverlayTiming = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + ResponsiveImageAttributes = new() + { + Src = "https://ik.imagekit.io/demo/image.jpg?tr=w-3840", + Sizes = "100vw", + SrcSet = + "https://ik.imagekit.io/demo/image.jpg?tr=w-640 640w, https://ik.imagekit.io/demo/image.jpg?tr=w-1080 1080w, https://ik.imagekit.io/demo/image.jpg?tr=w-1920 1920w", + Width = 400, + }, + SavedExtensions = new() + { + ID = "ext_abc123", + Config = new RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Description = "Analyzes vehicle images for type, condition, and quality assessment", + Name = "Car Quality Analysis", + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + SolidColorOverlay = new() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + AnchorPoint = AnchorPoint.Top, + Focus = Focus.Center, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Color = "color", + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Gradient = new UnionMember0(), + Height = 0, + Radius = new UnionMember1(), + Width = 0, + }, + ], + }, + SolidColorOverlayTransformation = new() + { + Alpha = 1, + Background = "background", + Gradient = new UnionMember0(), + Height = 0, + Radius = new UnionMember1(), + Width = 0, + }, + SrcOptions = new() + { + Src = "/my-image.jpg", + UrlEndpoint = "https://ik.imagekit.io/demo", + ExpiresIn = 0, + QueryParameters = new Dictionary() { { "foo", "string" } }, + Signed = true, + Transformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + Colorize = "colorize", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + AnchorPoint = AnchorPoint.Top, + Focus = Focus.Center, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayTextOverlayEncoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ], + TransformationPosition = TransformationPosition.Path, + }, + StreamingResolution = StreamingResolution.V240, + SubtitleOverlay = new() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + AnchorPoint = AnchorPoint.Top, + Focus = Focus.Center, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Input = "input", + Encoding = SubtitleOverlaySubtitleOverlayEncoding.Auto, + Transformation = + [ + new() + { + Background = "background", + Color = "color", + FontFamily = "fontFamily", + FontOutline = "fontOutline", + FontShadow = "fontShadow", + FontSize = 0, + Typography = Typography.B, + }, + ], + }, + SubtitleOverlayTransformation = new() + { + Background = "background", + Color = "color", + FontFamily = "fontFamily", + FontOutline = "fontOutline", + FontShadow = "fontShadow", + FontSize = 0, + Typography = Typography.B, + }, + TextOverlay = new() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + AnchorPoint = AnchorPoint.Top, + Focus = Focus.Center, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayTextOverlayEncoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + TextOverlayTransformation = new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), + Rotation = 0, + Typography = "typography", + Width = 0, + }, + Transformation = new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + Colorize = "colorize", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + AnchorPoint = AnchorPoint.Top, + Focus = Focus.Center, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayTextOverlayEncoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + TransformationPosition = TransformationPosition.Path, + VideoOverlay = new() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + AnchorPoint = AnchorPoint.Top, + Focus = Focus.Center, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Input = "input", + Encoding = VideoOverlayVideoOverlayEncoding.Auto, + Transformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + Colorize = "colorize", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + AnchorPoint = AnchorPoint.Top, + Focus = Focus.Center, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayTextOverlayEncoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ], + }, + }; + + BaseOverlay expectedBaseOverlay = new() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + AnchorPoint = AnchorPoint.Top, + Focus = Focus.Center, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + }; + ExtensionConfig expectedExtensionConfig = new RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }; + List expectedExtensions = + [ + new ExtensionItemRemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }, + new ExtensionItemAutoTaggingExtension() + { + MaxTags = 5, + MinConfidence = 95, + Name = ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, + }, + new ExtensionItemAIAutoDescription(), + new ExtensionItemAITasks( + [ + new ExtensionItemAITasksTaskSelectTags() + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }, + new ExtensionItemAITasksTaskYesNo() + { + Instruction = "Is this a luxury or high-end fashion item?", + OnNo = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnUnknown = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnYes = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + }, + ] + ), + new SavedExtension("ext_abc123"), + ]; + GetImageAttributesOptions expectedGetImageAttributesOptions = new() + { + Src = "/my-image.jpg", + UrlEndpoint = "https://ik.imagekit.io/demo", + ExpiresIn = 0, + QueryParameters = new Dictionary() { { "foo", "string" } }, + Signed = true, + Transformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + Colorize = "colorize", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + AnchorPoint = AnchorPoint.Top, + Focus = Focus.Center, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayTextOverlayEncoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ], + TransformationPosition = TransformationPosition.Path, + DeviceBreakpoints = [640, 750, 828, 1080, 1200, 1920, 2048, 3840], + ImageBreakpoints = [16, 32, 48, 64, 96, 128, 256, 384], + Sizes = "(min-width: 768px) 50vw, 100vw", + Width = 400, + }; + ImageOverlay expectedImageOverlay = new() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + AnchorPoint = AnchorPoint.Top, + Focus = Focus.Center, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Input = "input", + Encoding = Encoding.Auto, + Transformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + Colorize = "colorize", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + AnchorPoint = AnchorPoint.Top, + Focus = Focus.Center, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayTextOverlayEncoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ], + }; + Overlay expectedOverlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + AnchorPoint = AnchorPoint.Top, + Focus = Focus.Center, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayTextOverlayEncoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }; + OverlayPosition expectedOverlayPosition = new() + { + AnchorPoint = AnchorPoint.Top, + Focus = Focus.Center, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + }; + OverlayTiming expectedOverlayTiming = new() + { + Duration = 0, + End = 0, + Start = 0, + }; + ResponsiveImageAttributes expectedResponsiveImageAttributes = new() + { + Src = "https://ik.imagekit.io/demo/image.jpg?tr=w-3840", + Sizes = "100vw", + SrcSet = + "https://ik.imagekit.io/demo/image.jpg?tr=w-640 640w, https://ik.imagekit.io/demo/image.jpg?tr=w-1080 1080w, https://ik.imagekit.io/demo/image.jpg?tr=w-1920 1920w", + Width = 400, + }; + SharedSavedExtension expectedSavedExtensions = new() + { + ID = "ext_abc123", + Config = new RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Description = "Analyzes vehicle images for type, condition, and quality assessment", + Name = "Car Quality Analysis", + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + SolidColorOverlay expectedSolidColorOverlay = new() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + AnchorPoint = AnchorPoint.Top, + Focus = Focus.Center, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Color = "color", + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Gradient = new UnionMember0(), + Height = 0, + Radius = new UnionMember1(), + Width = 0, + }, + ], + }; + SolidColorOverlayTransformation expectedSolidColorOverlayTransformation = new() + { + Alpha = 1, + Background = "background", + Gradient = new UnionMember0(), + Height = 0, + Radius = new UnionMember1(), + Width = 0, + }; + SrcOptions expectedSrcOptions = new() + { + Src = "/my-image.jpg", + UrlEndpoint = "https://ik.imagekit.io/demo", + ExpiresIn = 0, + QueryParameters = new Dictionary() { { "foo", "string" } }, + Signed = true, + Transformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + Colorize = "colorize", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + AnchorPoint = AnchorPoint.Top, + Focus = Focus.Center, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayTextOverlayEncoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ], + TransformationPosition = TransformationPosition.Path, + }; + ApiEnum expectedStreamingResolution = StreamingResolution.V240; + SubtitleOverlay expectedSubtitleOverlay = new() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + AnchorPoint = AnchorPoint.Top, + Focus = Focus.Center, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Input = "input", + Encoding = SubtitleOverlaySubtitleOverlayEncoding.Auto, + Transformation = + [ + new() + { + Background = "background", + Color = "color", + FontFamily = "fontFamily", + FontOutline = "fontOutline", + FontShadow = "fontShadow", + FontSize = 0, + Typography = Typography.B, + }, + ], + }; + SubtitleOverlayTransformation expectedSubtitleOverlayTransformation = new() + { + Background = "background", + Color = "color", + FontFamily = "fontFamily", + FontOutline = "fontOutline", + FontShadow = "fontShadow", + FontSize = 0, + Typography = Typography.B, + }; + TextOverlay expectedTextOverlay = new() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + AnchorPoint = AnchorPoint.Top, + Focus = Focus.Center, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayTextOverlayEncoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }; + TextOverlayTransformation expectedTextOverlayTransformation = new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), + Rotation = 0, + Typography = "typography", + Width = 0, + }; + Transformation expectedTransformation = new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + Colorize = "colorize", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + AnchorPoint = AnchorPoint.Top, + Focus = Focus.Center, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayTextOverlayEncoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }; + ApiEnum expectedTransformationPosition = + TransformationPosition.Path; + VideoOverlay expectedVideoOverlay = new() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + AnchorPoint = AnchorPoint.Top, + Focus = Focus.Center, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Input = "input", + Encoding = VideoOverlayVideoOverlayEncoding.Auto, + Transformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + Colorize = "colorize", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + AnchorPoint = AnchorPoint.Top, + Focus = Focus.Center, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayTextOverlayEncoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ], + }; + + Assert.Equal(expectedBaseOverlay, parameters.BaseOverlay); + Assert.Equal(expectedExtensionConfig, parameters.ExtensionConfig); + Assert.NotNull(parameters.Extensions); + Assert.Equal(expectedExtensions.Count, parameters.Extensions.Count); + for (int i = 0; i < expectedExtensions.Count; i++) + { + Assert.Equal(expectedExtensions[i], parameters.Extensions[i]); + } + Assert.Equal(expectedGetImageAttributesOptions, parameters.GetImageAttributesOptions); + Assert.Equal(expectedImageOverlay, parameters.ImageOverlay); + Assert.Equal(expectedOverlay, parameters.Overlay); + Assert.Equal(expectedOverlayPosition, parameters.OverlayPosition); + Assert.Equal(expectedOverlayTiming, parameters.OverlayTiming); + Assert.Equal(expectedResponsiveImageAttributes, parameters.ResponsiveImageAttributes); + Assert.Equal(expectedSavedExtensions, parameters.SavedExtensions); + Assert.Equal(expectedSolidColorOverlay, parameters.SolidColorOverlay); + Assert.Equal( + expectedSolidColorOverlayTransformation, + parameters.SolidColorOverlayTransformation + ); + Assert.Equal(expectedSrcOptions, parameters.SrcOptions); + Assert.Equal(expectedStreamingResolution, parameters.StreamingResolution); + Assert.Equal(expectedSubtitleOverlay, parameters.SubtitleOverlay); + Assert.Equal( + expectedSubtitleOverlayTransformation, + parameters.SubtitleOverlayTransformation + ); + Assert.Equal(expectedTextOverlay, parameters.TextOverlay); + Assert.Equal(expectedTextOverlayTransformation, parameters.TextOverlayTransformation); + Assert.Equal(expectedTransformation, parameters.Transformation); + Assert.Equal(expectedTransformationPosition, parameters.TransformationPosition); + Assert.Equal(expectedVideoOverlay, parameters.VideoOverlay); + } + + [Fact] + public void OptionalNonNullableParamsUnsetAreNotSet_Works() + { + var parameters = new DummyCreateParams { }; + + Assert.Null(parameters.BaseOverlay); + Assert.False(parameters.RawBodyData.ContainsKey("baseOverlay")); + Assert.Null(parameters.ExtensionConfig); + Assert.False(parameters.RawBodyData.ContainsKey("extensionConfig")); + Assert.Null(parameters.Extensions); + Assert.False(parameters.RawBodyData.ContainsKey("extensions")); + Assert.Null(parameters.GetImageAttributesOptions); + Assert.False(parameters.RawBodyData.ContainsKey("getImageAttributesOptions")); + Assert.Null(parameters.ImageOverlay); + Assert.False(parameters.RawBodyData.ContainsKey("imageOverlay")); + Assert.Null(parameters.Overlay); + Assert.False(parameters.RawBodyData.ContainsKey("overlay")); + Assert.Null(parameters.OverlayPosition); + Assert.False(parameters.RawBodyData.ContainsKey("overlayPosition")); + Assert.Null(parameters.OverlayTiming); + Assert.False(parameters.RawBodyData.ContainsKey("overlayTiming")); + Assert.Null(parameters.ResponsiveImageAttributes); + Assert.False(parameters.RawBodyData.ContainsKey("responsiveImageAttributes")); + Assert.Null(parameters.SavedExtensions); + Assert.False(parameters.RawBodyData.ContainsKey("savedExtensions")); + Assert.Null(parameters.SolidColorOverlay); + Assert.False(parameters.RawBodyData.ContainsKey("solidColorOverlay")); + Assert.Null(parameters.SolidColorOverlayTransformation); + Assert.False(parameters.RawBodyData.ContainsKey("solidColorOverlayTransformation")); + Assert.Null(parameters.SrcOptions); + Assert.False(parameters.RawBodyData.ContainsKey("srcOptions")); + Assert.Null(parameters.StreamingResolution); + Assert.False(parameters.RawBodyData.ContainsKey("streamingResolution")); + Assert.Null(parameters.SubtitleOverlay); + Assert.False(parameters.RawBodyData.ContainsKey("subtitleOverlay")); + Assert.Null(parameters.SubtitleOverlayTransformation); + Assert.False(parameters.RawBodyData.ContainsKey("subtitleOverlayTransformation")); + Assert.Null(parameters.TextOverlay); + Assert.False(parameters.RawBodyData.ContainsKey("textOverlay")); + Assert.Null(parameters.TextOverlayTransformation); + Assert.False(parameters.RawBodyData.ContainsKey("textOverlayTransformation")); + Assert.Null(parameters.Transformation); + Assert.False(parameters.RawBodyData.ContainsKey("transformation")); + Assert.Null(parameters.TransformationPosition); + Assert.False(parameters.RawBodyData.ContainsKey("transformationPosition")); + Assert.Null(parameters.VideoOverlay); + Assert.False(parameters.RawBodyData.ContainsKey("videoOverlay")); + } + + [Fact] + public void OptionalNonNullableParamsSetToNullAreNotSet_Works() + { + var parameters = new DummyCreateParams + { + // Null should be interpreted as omitted for these properties + BaseOverlay = null, + ExtensionConfig = null, + Extensions = null, + GetImageAttributesOptions = null, + ImageOverlay = null, + Overlay = null, + OverlayPosition = null, + OverlayTiming = null, + ResponsiveImageAttributes = null, + SavedExtensions = null, + SolidColorOverlay = null, + SolidColorOverlayTransformation = null, + SrcOptions = null, + StreamingResolution = null, + SubtitleOverlay = null, + SubtitleOverlayTransformation = null, + TextOverlay = null, + TextOverlayTransformation = null, + Transformation = null, + TransformationPosition = null, + VideoOverlay = null, + }; + + Assert.Null(parameters.BaseOverlay); + Assert.False(parameters.RawBodyData.ContainsKey("baseOverlay")); + Assert.Null(parameters.ExtensionConfig); + Assert.False(parameters.RawBodyData.ContainsKey("extensionConfig")); + Assert.Null(parameters.Extensions); + Assert.False(parameters.RawBodyData.ContainsKey("extensions")); + Assert.Null(parameters.GetImageAttributesOptions); + Assert.False(parameters.RawBodyData.ContainsKey("getImageAttributesOptions")); + Assert.Null(parameters.ImageOverlay); + Assert.False(parameters.RawBodyData.ContainsKey("imageOverlay")); + Assert.Null(parameters.Overlay); + Assert.False(parameters.RawBodyData.ContainsKey("overlay")); + Assert.Null(parameters.OverlayPosition); + Assert.False(parameters.RawBodyData.ContainsKey("overlayPosition")); + Assert.Null(parameters.OverlayTiming); + Assert.False(parameters.RawBodyData.ContainsKey("overlayTiming")); + Assert.Null(parameters.ResponsiveImageAttributes); + Assert.False(parameters.RawBodyData.ContainsKey("responsiveImageAttributes")); + Assert.Null(parameters.SavedExtensions); + Assert.False(parameters.RawBodyData.ContainsKey("savedExtensions")); + Assert.Null(parameters.SolidColorOverlay); + Assert.False(parameters.RawBodyData.ContainsKey("solidColorOverlay")); + Assert.Null(parameters.SolidColorOverlayTransformation); + Assert.False(parameters.RawBodyData.ContainsKey("solidColorOverlayTransformation")); + Assert.Null(parameters.SrcOptions); + Assert.False(parameters.RawBodyData.ContainsKey("srcOptions")); + Assert.Null(parameters.StreamingResolution); + Assert.False(parameters.RawBodyData.ContainsKey("streamingResolution")); + Assert.Null(parameters.SubtitleOverlay); + Assert.False(parameters.RawBodyData.ContainsKey("subtitleOverlay")); + Assert.Null(parameters.SubtitleOverlayTransformation); + Assert.False(parameters.RawBodyData.ContainsKey("subtitleOverlayTransformation")); + Assert.Null(parameters.TextOverlay); + Assert.False(parameters.RawBodyData.ContainsKey("textOverlay")); + Assert.Null(parameters.TextOverlayTransformation); + Assert.False(parameters.RawBodyData.ContainsKey("textOverlayTransformation")); + Assert.Null(parameters.Transformation); + Assert.False(parameters.RawBodyData.ContainsKey("transformation")); + Assert.Null(parameters.TransformationPosition); + Assert.False(parameters.RawBodyData.ContainsKey("transformationPosition")); + Assert.Null(parameters.VideoOverlay); + Assert.False(parameters.RawBodyData.ContainsKey("videoOverlay")); + } + + [Fact] + public void Url_Works() + { + DummyCreateParams parameters = new(); + + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + + Assert.True(TestBase.UrisEqual(new Uri("https://api.imagekit.io/v1/dummy/test"), url)); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new DummyCreateParams + { + BaseOverlay = new() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + AnchorPoint = AnchorPoint.Top, + Focus = Focus.Center, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + }, + ExtensionConfig = new RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }, + Extensions = + [ + new ExtensionItemRemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }, + new ExtensionItemAutoTaggingExtension() + { + MaxTags = 5, + MinConfidence = 95, + Name = ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, + }, + new ExtensionItemAIAutoDescription(), + new ExtensionItemAITasks( + [ + new ExtensionItemAITasksTaskSelectTags() + { + Instruction = "What types of clothing items are visible in this image?", + MaxSelections = 1, + MinSelections = 0, + Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], + }, + new ExtensionItemAITasksTaskYesNo() + { + Instruction = "Is this a luxury or high-end fashion item?", + OnNo = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnUnknown = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + OnYes = new() + { + AddTags = ["luxury", "premium"], + RemoveTags = ["budget", "affordable"], + SetMetadata = [new() { Field = "price_range", Value = "premium" }], + UnsetMetadata = [new("price_range")], + }, + }, + ] + ), + new SavedExtension("ext_abc123"), + ], + GetImageAttributesOptions = new() + { + Src = "/my-image.jpg", + UrlEndpoint = "https://ik.imagekit.io/demo", + ExpiresIn = 0, + QueryParameters = new Dictionary() { { "foo", "string" } }, + Signed = true, + Transformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + Colorize = "colorize", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + AnchorPoint = AnchorPoint.Top, + Focus = Focus.Center, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayTextOverlayEncoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ], + TransformationPosition = TransformationPosition.Path, + DeviceBreakpoints = [640, 750, 828, 1080, 1200, 1920, 2048, 3840], + ImageBreakpoints = [16, 32, 48, 64, 96, 128, 256, 384], + Sizes = "(min-width: 768px) 50vw, 100vw", + Width = 400, + }, + ImageOverlay = new() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + AnchorPoint = AnchorPoint.Top, + Focus = Focus.Center, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Input = "input", + Encoding = Encoding.Auto, + Transformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + Colorize = "colorize", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + AnchorPoint = AnchorPoint.Top, + Focus = Focus.Center, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayTextOverlayEncoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ], + }, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + AnchorPoint = AnchorPoint.Top, + Focus = Focus.Center, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayTextOverlayEncoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + OverlayPosition = new() + { + AnchorPoint = AnchorPoint.Top, + Focus = Focus.Center, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + }, + OverlayTiming = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + ResponsiveImageAttributes = new() + { + Src = "https://ik.imagekit.io/demo/image.jpg?tr=w-3840", + Sizes = "100vw", + SrcSet = + "https://ik.imagekit.io/demo/image.jpg?tr=w-640 640w, https://ik.imagekit.io/demo/image.jpg?tr=w-1080 1080w, https://ik.imagekit.io/demo/image.jpg?tr=w-1920 1920w", + Width = 400, + }, + SavedExtensions = new() + { + ID = "ext_abc123", + Config = new RemoveBg() + { + Options = new() + { + AddShadow = true, + BgColor = "bg_color", + BgImageUrl = "bg_image_url", + Semitransparency = true, + }, + }, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Description = "Analyzes vehicle images for type, condition, and quality assessment", + Name = "Car Quality Analysis", + UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + SolidColorOverlay = new() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + AnchorPoint = AnchorPoint.Top, + Focus = Focus.Center, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Color = "color", + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Gradient = new UnionMember0(), + Height = 0, + Radius = new UnionMember1(), + Width = 0, + }, + ], + }, + SolidColorOverlayTransformation = new() + { + Alpha = 1, + Background = "background", + Gradient = new UnionMember0(), + Height = 0, + Radius = new UnionMember1(), + Width = 0, + }, + SrcOptions = new() + { + Src = "/my-image.jpg", + UrlEndpoint = "https://ik.imagekit.io/demo", + ExpiresIn = 0, + QueryParameters = new Dictionary() { { "foo", "string" } }, + Signed = true, + Transformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + Colorize = "colorize", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + AnchorPoint = AnchorPoint.Top, + Focus = Focus.Center, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayTextOverlayEncoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ], + TransformationPosition = TransformationPosition.Path, + }, + StreamingResolution = StreamingResolution.V240, + SubtitleOverlay = new() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + AnchorPoint = AnchorPoint.Top, + Focus = Focus.Center, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Input = "input", + Encoding = SubtitleOverlaySubtitleOverlayEncoding.Auto, + Transformation = + [ + new() + { + Background = "background", + Color = "color", + FontFamily = "fontFamily", + FontOutline = "fontOutline", + FontShadow = "fontShadow", + FontSize = 0, + Typography = Typography.B, + }, + ], + }, + SubtitleOverlayTransformation = new() + { + Background = "background", + Color = "color", + FontFamily = "fontFamily", + FontOutline = "fontOutline", + FontShadow = "fontShadow", + FontSize = 0, + Typography = Typography.B, + }, + TextOverlay = new() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + AnchorPoint = AnchorPoint.Top, + Focus = Focus.Center, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayTextOverlayEncoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + TextOverlayTransformation = new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), + Rotation = 0, + Typography = "typography", + Width = 0, + }, + Transformation = new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + Colorize = "colorize", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + AnchorPoint = AnchorPoint.Top, + Focus = Focus.Center, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayTextOverlayEncoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + TransformationPosition = TransformationPosition.Path, + VideoOverlay = new() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + AnchorPoint = AnchorPoint.Top, + Focus = Focus.Center, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Input = "input", + Encoding = VideoOverlayVideoOverlayEncoding.Auto, + Transformation = + [ + new() + { + AIChangeBackground = "aiChangeBackground", + AIDropShadow = new AIDropShadowUnionMember0(), + AIEdit = "aiEdit", + AIRemoveBackground = AIRemoveBackground.True, + AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, + AIRetouch = AIRetouch.True, + AIUpscale = AIUpscale.True, + AIVariation = AIVariation.True, + AspectRatio = "4:3", + AudioCodec = AudioCodec.Aac, + Background = "red", + Blur = 10, + Border = "5_FF0000", + Colorize = "colorize", + ColorProfile = true, + ColorReplace = "colorReplace", + ContrastStretch = ContrastStretch.True, + Crop = Crop.Force, + CropMode = CropMode.PadResize, + DefaultImage = "defaultImage", + Distort = "distort", + Dpr = 2, + Duration = 0, + EndOffset = 0, + Flip = TransformationFlip.H, + Focus = "center", + Format = Format.Auto, + Gradient = new TransformationGradientUnionMember0(), + Grayscale = Grayscale.True, + Height = 200, + Lossless = true, + Metadata = true, + Named = "named", + Opacity = 0, + Original = true, + Overlay = new TextOverlay() + { + LayerMode = LayerMode.Multiply, + Position = new() + { + AnchorPoint = AnchorPoint.Top, + Focus = Focus.Center, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + }, + Timing = new() + { + Duration = 0, + End = 0, + Start = 0, + }, + Text = "text", + Encoding = TextOverlayTextOverlayEncoding.Auto, + Transformation = + [ + new() + { + Alpha = 1, + Background = "background", + Flip = Flip.H, + FontColor = "fontColor", + FontFamily = "fontFamily", + FontSize = 0, + InnerAlignment = InnerAlignment.Left, + LineHeight = 0, + Padding = 0, + Radius = new TextOverlayTransformationRadiusUnionMember1(), + Rotation = 0, + Typography = "typography", + Width = 0, + }, + ], + }, + Page = 0, + Progressive = true, + Quality = 80, + Radius = 20, + Raw = "raw", + Rotation = 90, + Shadow = new ShadowUnionMember0(), + Sharpen = new SharpenUnionMember0(), + StartOffset = 0, + StreamingResolutions = [StreamingResolution.V240], + Trim = new TrimUnionMember0(), + UnsharpMask = new UnsharpMaskUnionMember0(), + VideoCodec = VideoCodec.H264, + Width = 300, + X = 0, + XCenter = 0, + Y = 0, + YCenter = 0, + Zoom = 0, + }, + ], + }, + }; + + DummyCreateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/Imagekit.Tests/Services/DummyServiceTest.cs b/src/Imagekit.Tests/Services/DummyServiceTest.cs new file mode 100644 index 00000000..135026e8 --- /dev/null +++ b/src/Imagekit.Tests/Services/DummyServiceTest.cs @@ -0,0 +1,12 @@ +using System.Threading.Tasks; + +namespace Imagekit.Tests.Services; + +public class DummyServiceTest : TestBase +{ + [Fact(Skip = "Mock server tests are disabled")] + public async Task Create_Works() + { + await this.client.Dummy.Create(new(), TestContext.Current.CancellationToken); + } +} diff --git a/src/Imagekit/IImageKitClient.cs b/src/Imagekit/IImageKitClient.cs index 42269338..f8d31b37 100644 --- a/src/Imagekit/IImageKitClient.cs +++ b/src/Imagekit/IImageKitClient.cs @@ -68,6 +68,8 @@ public interface IImageKitClient : IDisposable /// IImageKitClient WithOptions(Func modifier); + IDummyService Dummy { get; } + ICustomMetadataFieldService CustomMetadataFields { get; } IFileService Files { get; } @@ -133,6 +135,8 @@ public interface IImageKitClientWithRawResponse : IDisposable /// IImageKitClientWithRawResponse WithOptions(Func modifier); + IDummyServiceWithRawResponse Dummy { get; } + ICustomMetadataFieldServiceWithRawResponse CustomMetadataFields { get; } IFileServiceWithRawResponse Files { get; } diff --git a/src/Imagekit/ImageKitClient.cs b/src/Imagekit/ImageKitClient.cs index 5bd45f60..341e705a 100644 --- a/src/Imagekit/ImageKitClient.cs +++ b/src/Imagekit/ImageKitClient.cs @@ -86,6 +86,12 @@ public IImageKitClient WithOptions(Func modifier) return new ImageKitClient(modifier(this._options)); } + readonly Lazy _dummy; + public IDummyService Dummy + { + get { return _dummy.Value; } + } + readonly Lazy _customMetadataFields; public ICustomMetadataFieldService CustomMetadataFields { @@ -147,6 +153,7 @@ public ImageKitClient() _options = new(); _withRawResponse = new(() => new ImageKitClientWithRawResponse(this._options)); + _dummy = new(() => new DummyService(this)); _customMetadataFields = new(() => new CustomMetadataFieldService(this)); _files = new(() => new FileService(this)); _savedExtensions = new(() => new SavedExtensionService(this)); @@ -245,6 +252,12 @@ public IImageKitClientWithRawResponse WithOptions(Func _dummy; + public IDummyServiceWithRawResponse Dummy + { + get { return _dummy.Value; } + } + readonly Lazy _customMetadataFields; public ICustomMetadataFieldServiceWithRawResponse CustomMetadataFields { @@ -497,6 +510,7 @@ public ImageKitClientWithRawResponse() { _options = new(); + _dummy = new(() => new DummyServiceWithRawResponse(this)); _customMetadataFields = new(() => new CustomMetadataFieldServiceWithRawResponse(this)); _files = new(() => new FileServiceWithRawResponse(this)); _savedExtensions = new(() => new SavedExtensionServiceWithRawResponse(this)); diff --git a/src/Imagekit/Models/Dummy/DummyCreateParams.cs b/src/Imagekit/Models/Dummy/DummyCreateParams.cs new file mode 100644 index 00000000..e7a2e7a0 --- /dev/null +++ b/src/Imagekit/Models/Dummy/DummyCreateParams.cs @@ -0,0 +1,581 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using Imagekit.Core; +using Text = System.Text; + +namespace Imagekit.Models.Dummy; + +/// +/// Internal test endpoint for SDK generation purposes only. This endpoint demonstrates +/// usage of all shared models defined in the Stainless configuration and is not +/// intended for public consumption. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class DummyCreateParams : ParamsBase +{ + readonly JsonDictionary _rawBodyData = new(); + public IReadOnlyDictionary RawBodyData + { + get { return this._rawBodyData.Freeze(); } + } + + public BaseOverlay? BaseOverlay + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass("baseOverlay"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("baseOverlay", value); + } + } + + /// + /// Configuration object for an extension (base extensions only, not saved extension references). + /// + public ExtensionConfig? ExtensionConfig + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass("extensionConfig"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("extensionConfig", value); + } + } + + /// + /// Array of extensions to be applied to the asset. Each extension can be configured + /// with specific parameters based on the extension type. + /// + public IReadOnlyList? Extensions + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableStruct>("extensions"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set?>( + "extensions", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Options for generating responsive image attributes including `src`, `srcSet`, + /// and `sizes` for HTML `<img>` elements. This schema extends `SrcOptions` + /// to add support for responsive image generation with breakpoints. + /// + public GetImageAttributesOptions? GetImageAttributesOptions + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass( + "getImageAttributesOptions" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("getImageAttributesOptions", value); + } + } + + public ImageOverlay? ImageOverlay + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass("imageOverlay"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("imageOverlay", value); + } + } + + /// + /// Specifies an overlay to be applied on the parent image or video. ImageKit + /// supports overlays including images, text, videos, subtitles, and solid colors. + /// See [Overlay using layers](https://imagekit.io/docs/transformations#overlay-using-layers). + /// + public Overlay? Overlay + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass("overlay"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("overlay", value); + } + } + + public OverlayPosition? OverlayPosition + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass("overlayPosition"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("overlayPosition", value); + } + } + + public OverlayTiming? OverlayTiming + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass("overlayTiming"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("overlayTiming", value); + } + } + + /// + /// Resulting set of attributes suitable for an HTML `<img>` element. Useful + /// for enabling responsive image loading with `srcSet` and `sizes`. + /// + public ResponsiveImageAttributes? ResponsiveImageAttributes + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass( + "responsiveImageAttributes" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("responsiveImageAttributes", value); + } + } + + /// + /// Saved extension object containing extension configuration. + /// + public SharedSavedExtension? SavedExtensions + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass("savedExtensions"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("savedExtensions", value); + } + } + + public SolidColorOverlay? SolidColorOverlay + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass("solidColorOverlay"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("solidColorOverlay", value); + } + } + + public SolidColorOverlayTransformation? SolidColorOverlayTransformation + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass( + "solidColorOverlayTransformation" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("solidColorOverlayTransformation", value); + } + } + + /// + /// Options for generating ImageKit URLs with transformations. See the [Transformations guide](https://imagekit.io/docs/transformations). + /// + public SrcOptions? SrcOptions + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass("srcOptions"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("srcOptions", value); + } + } + + /// + /// Available streaming resolutions for [adaptive bitrate streaming](https://imagekit.io/docs/adaptive-bitrate-streaming) + /// + public ApiEnum? StreamingResolution + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass>( + "streamingResolution" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("streamingResolution", value); + } + } + + public SubtitleOverlay? SubtitleOverlay + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass("subtitleOverlay"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("subtitleOverlay", value); + } + } + + /// + /// Subtitle styling options. [Learn more](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + /// from the docs. + /// + public SubtitleOverlayTransformation? SubtitleOverlayTransformation + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass( + "subtitleOverlayTransformation" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("subtitleOverlayTransformation", value); + } + } + + public TextOverlay? TextOverlay + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass("textOverlay"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("textOverlay", value); + } + } + + public TextOverlayTransformation? TextOverlayTransformation + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass( + "textOverlayTransformation" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("textOverlayTransformation", value); + } + } + + /// + /// The SDK provides easy-to-use names for transformations. These names are converted + /// to the corresponding transformation string before being added to the URL. + /// SDKs are updated regularly to support new transformations. If you want to + /// use a transformation that is not supported by the SDK, You can use the `raw` + /// parameter to pass the transformation string directly. See the [Transformations + /// documentation](https://imagekit.io/docs/transformations). + /// + public Transformation? Transformation + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass("transformation"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("transformation", value); + } + } + + /// + /// By default, the transformation string is added as a query parameter in the + /// URL, e.g., `?tr=w-100,h-100`. If you want to add the transformation string + /// in the path of the URL, set this to `path`. Learn more in the [Transformations + /// guide](https://imagekit.io/docs/transformations). + /// + public ApiEnum? TransformationPosition + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass>( + "transformationPosition" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("transformationPosition", value); + } + } + + public VideoOverlay? VideoOverlay + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass("videoOverlay"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("videoOverlay", value); + } + } + + public DummyCreateParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public DummyCreateParams(DummyCreateParams dummyCreateParams) + : base(dummyCreateParams) + { + this._rawBodyData = new(dummyCreateParams._rawBodyData); + } +#pragma warning restore CS8618 + + public DummyCreateParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + DummyCreateParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData, + FrozenDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } +#pragma warning restore CS8618 + + /// + public static DummyCreateParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData), + FrozenDictionary.ToFrozenDictionary(rawBodyData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(DummyCreateParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/v1/dummy/test") + { + Query = this.QueryString(options), + }.Uri; + } + + internal override HttpContent? BodyContent() + { + return new StringContent( + JsonSerializer.Serialize(this.RawBodyData, ModelBase.SerializerOptions), + Text::Encoding.UTF8, + "application/json" + ); + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/Imagekit/Services/DummyService.cs b/src/Imagekit/Services/DummyService.cs new file mode 100644 index 00000000..26d40dec --- /dev/null +++ b/src/Imagekit/Services/DummyService.cs @@ -0,0 +1,77 @@ +using System; +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; +using Imagekit.Core; +using Imagekit.Models.Dummy; + +namespace Imagekit.Services; + +/// +public sealed class DummyService : IDummyService +{ + readonly Lazy _withRawResponse; + + /// + public IDummyServiceWithRawResponse WithRawResponse + { + get { return _withRawResponse.Value; } + } + + readonly IImageKitClient _client; + + /// + public IDummyService WithOptions(Func modifier) + { + return new DummyService(this._client.WithOptions(modifier)); + } + + public DummyService(IImageKitClient client) + { + _client = client; + + _withRawResponse = new(() => new DummyServiceWithRawResponse(client.WithRawResponse)); + } + + /// + public Task Create( + DummyCreateParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + return this.WithRawResponse.Create(parameters, cancellationToken); + } +} + +/// +public sealed class DummyServiceWithRawResponse : IDummyServiceWithRawResponse +{ + readonly IImageKitClientWithRawResponse _client; + + /// + public IDummyServiceWithRawResponse WithOptions(Func modifier) + { + return new DummyServiceWithRawResponse(this._client.WithOptions(modifier)); + } + + public DummyServiceWithRawResponse(IImageKitClientWithRawResponse client) + { + _client = client; + } + + /// + public Task Create( + DummyCreateParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + HttpRequest request = new() + { + Method = HttpMethod.Post, + Params = parameters, + }; + return this._client.Execute(request, cancellationToken); + } +} diff --git a/src/Imagekit/Services/IDummyService.cs b/src/Imagekit/Services/IDummyService.cs new file mode 100644 index 00000000..bf9147df --- /dev/null +++ b/src/Imagekit/Services/IDummyService.cs @@ -0,0 +1,61 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using Imagekit.Core; +using Imagekit.Models.Dummy; + +namespace Imagekit.Services; + +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking +/// changes in non-major versions. We may add new methods in the future that cause +/// existing derived classes to break. +/// +public interface IDummyService +{ + /// + /// Returns a view of this service that provides access to raw HTTP responses + /// for each method. + /// + IDummyServiceWithRawResponse WithRawResponse { get; } + + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + IDummyService WithOptions(Func modifier); + + /// + /// Internal test endpoint for SDK generation purposes only. This endpoint + /// demonstrates usage of all shared models defined in the Stainless configuration + /// and is not intended for public consumption. + /// + Task Create( + DummyCreateParams? parameters = null, + CancellationToken cancellationToken = default + ); +} + +/// +/// A view of that provides access to raw +/// HTTP responses for each method. +/// +public interface IDummyServiceWithRawResponse +{ + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + IDummyServiceWithRawResponse WithOptions(Func modifier); + + /// + /// Returns a raw HTTP response for post /v1/dummy/test, but is otherwise the + /// same as . + /// + Task Create( + DummyCreateParams? parameters = null, + CancellationToken cancellationToken = default + ); +} From 6e3bcf1f35a20efd82793349a9f752b3efc9b85f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sun, 17 May 2026 04:39:46 +0000 Subject: [PATCH 125/129] build(dotnet): adding variant name for build warnings cannot infer union variant name --- .stats.yml | 4 +- .../Models/Dummy/DummyCreateParamsTest.cs | 252 ++++++------ .../Models/Files/UpdateFileRequestTest.cs | 214 +++++----- .../Models/GetImageAttributesOptionsTest.cs | 98 ++--- src/Imagekit.Tests/Models/ImageOverlayTest.cs | 196 ++++----- src/Imagekit.Tests/Models/OverlayTest.cs | 68 +-- .../Models/SolidColorOverlayTest.cs | 56 +-- .../SolidColorOverlayTransformationTest.cs | 89 ++-- src/Imagekit.Tests/Models/SrcOptionsTest.cs | 98 ++--- src/Imagekit.Tests/Models/TextOverlayTest.cs | 28 +- .../Models/TextOverlayTransformationTest.cs | 40 +- .../Models/TransformationTest.cs | 290 ++++++------- src/Imagekit.Tests/Models/VideoOverlayTest.cs | 196 ++++----- .../Models/SolidColorOverlayTransformation.cs | 110 +++-- .../Models/TextOverlayTransformation.cs | 59 ++- src/Imagekit/Models/Transformation.cs | 389 +++++++++--------- 16 files changed, 1075 insertions(+), 1112 deletions(-) diff --git a/.stats.yml b/.stats.yml index 0c1672a7..67b90e9c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 48 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc/imagekit-14c145ce7a0b8660a0228fb7ec2499d8e5f6c057be2750da408af8b0513f1df5.yml -openapi_spec_hash: f3790446521a8f846e2e7249313de100 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc/imagekit-219cd09f920d87469cda8b4d45b74dbfcac5352281e240e78230934ceb5b19a4.yml +openapi_spec_hash: 790e2ebbfb462a5f38999ec543e6124e config_hash: ea9d73f82c079f2c34302ff663f2aa56 diff --git a/src/Imagekit.Tests/Models/Dummy/DummyCreateParamsTest.cs b/src/Imagekit.Tests/Models/Dummy/DummyCreateParamsTest.cs index 85c03032..ee2f576b 100644 --- a/src/Imagekit.Tests/Models/Dummy/DummyCreateParamsTest.cs +++ b/src/Imagekit.Tests/Models/Dummy/DummyCreateParamsTest.cs @@ -111,7 +111,7 @@ public void FieldRoundtrip_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -137,7 +137,7 @@ public void FieldRoundtrip_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -178,7 +178,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -191,12 +191,12 @@ public void FieldRoundtrip_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -237,7 +237,7 @@ public void FieldRoundtrip_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -263,7 +263,7 @@ public void FieldRoundtrip_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -304,7 +304,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -317,12 +317,12 @@ public void FieldRoundtrip_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -366,7 +366,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -439,9 +439,9 @@ public void FieldRoundtrip_Works() { Alpha = 1, Background = "background", - Gradient = new UnionMember0(), + Gradient = new Default(), Height = 0, - Radius = new UnionMember1(), + Radius = new Max(), Width = 0, }, ], @@ -450,9 +450,9 @@ public void FieldRoundtrip_Works() { Alpha = 1, Background = "background", - Gradient = new UnionMember0(), + Gradient = new Default(), Height = 0, - Radius = new UnionMember1(), + Radius = new Max(), Width = 0, }, SrcOptions = new() @@ -467,7 +467,7 @@ public void FieldRoundtrip_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -493,7 +493,7 @@ public void FieldRoundtrip_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -534,7 +534,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -547,12 +547,12 @@ public void FieldRoundtrip_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -642,7 +642,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -660,7 +660,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -668,7 +668,7 @@ public void FieldRoundtrip_Works() Transformation = new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -694,7 +694,7 @@ public void FieldRoundtrip_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -735,7 +735,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -748,12 +748,12 @@ public void FieldRoundtrip_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -788,7 +788,7 @@ public void FieldRoundtrip_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -814,7 +814,7 @@ public void FieldRoundtrip_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -855,7 +855,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -868,12 +868,12 @@ public void FieldRoundtrip_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -984,7 +984,7 @@ public void FieldRoundtrip_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -1010,7 +1010,7 @@ public void FieldRoundtrip_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -1051,7 +1051,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -1064,12 +1064,12 @@ public void FieldRoundtrip_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -1110,7 +1110,7 @@ public void FieldRoundtrip_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -1136,7 +1136,7 @@ public void FieldRoundtrip_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -1177,7 +1177,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -1190,12 +1190,12 @@ public void FieldRoundtrip_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -1239,7 +1239,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -1312,9 +1312,9 @@ public void FieldRoundtrip_Works() { Alpha = 1, Background = "background", - Gradient = new UnionMember0(), + Gradient = new Default(), Height = 0, - Radius = new UnionMember1(), + Radius = new Max(), Width = 0, }, ], @@ -1323,9 +1323,9 @@ public void FieldRoundtrip_Works() { Alpha = 1, Background = "background", - Gradient = new UnionMember0(), + Gradient = new Default(), Height = 0, - Radius = new UnionMember1(), + Radius = new Max(), Width = 0, }; SrcOptions expectedSrcOptions = new() @@ -1340,7 +1340,7 @@ public void FieldRoundtrip_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -1366,7 +1366,7 @@ public void FieldRoundtrip_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -1407,7 +1407,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -1420,12 +1420,12 @@ public void FieldRoundtrip_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -1515,7 +1515,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -1533,7 +1533,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -1541,7 +1541,7 @@ public void FieldRoundtrip_Works() Transformation expectedTransformation = new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -1567,7 +1567,7 @@ public void FieldRoundtrip_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -1608,7 +1608,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -1621,12 +1621,12 @@ public void FieldRoundtrip_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -1662,7 +1662,7 @@ public void FieldRoundtrip_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -1688,7 +1688,7 @@ public void FieldRoundtrip_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -1729,7 +1729,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -1742,12 +1742,12 @@ public void FieldRoundtrip_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -2028,7 +2028,7 @@ public void CopyConstructor_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -2054,7 +2054,7 @@ public void CopyConstructor_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -2095,7 +2095,7 @@ public void CopyConstructor_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -2108,12 +2108,12 @@ public void CopyConstructor_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -2154,7 +2154,7 @@ public void CopyConstructor_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -2180,7 +2180,7 @@ public void CopyConstructor_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -2221,7 +2221,7 @@ public void CopyConstructor_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -2234,12 +2234,12 @@ public void CopyConstructor_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -2283,7 +2283,7 @@ public void CopyConstructor_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -2356,9 +2356,9 @@ public void CopyConstructor_Works() { Alpha = 1, Background = "background", - Gradient = new UnionMember0(), + Gradient = new Default(), Height = 0, - Radius = new UnionMember1(), + Radius = new Max(), Width = 0, }, ], @@ -2367,9 +2367,9 @@ public void CopyConstructor_Works() { Alpha = 1, Background = "background", - Gradient = new UnionMember0(), + Gradient = new Default(), Height = 0, - Radius = new UnionMember1(), + Radius = new Max(), Width = 0, }, SrcOptions = new() @@ -2384,7 +2384,7 @@ public void CopyConstructor_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -2410,7 +2410,7 @@ public void CopyConstructor_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -2451,7 +2451,7 @@ public void CopyConstructor_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -2464,12 +2464,12 @@ public void CopyConstructor_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -2559,7 +2559,7 @@ public void CopyConstructor_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -2577,7 +2577,7 @@ public void CopyConstructor_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -2585,7 +2585,7 @@ public void CopyConstructor_Works() Transformation = new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -2611,7 +2611,7 @@ public void CopyConstructor_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -2652,7 +2652,7 @@ public void CopyConstructor_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -2665,12 +2665,12 @@ public void CopyConstructor_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -2705,7 +2705,7 @@ public void CopyConstructor_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -2731,7 +2731,7 @@ public void CopyConstructor_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -2772,7 +2772,7 @@ public void CopyConstructor_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -2785,12 +2785,12 @@ public void CopyConstructor_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, diff --git a/src/Imagekit.Tests/Models/Files/UpdateFileRequestTest.cs b/src/Imagekit.Tests/Models/Files/UpdateFileRequestTest.cs index 8264215d..f09a146b 100644 --- a/src/Imagekit.Tests/Models/Files/UpdateFileRequestTest.cs +++ b/src/Imagekit.Tests/Models/Files/UpdateFileRequestTest.cs @@ -2,8 +2,8 @@ using System.Text.Json; using Imagekit.Core; using Imagekit.Exceptions; +using Imagekit.Models; using Imagekit.Models.Files; -using Models = Imagekit.Models; namespace Imagekit.Tests.Models.Files; @@ -22,7 +22,7 @@ public void DetailsValidationWorks() Description = "description", Extensions = [ - new Models::ExtensionItemRemoveBg() + new ExtensionItemRemoveBg() { Options = new() { @@ -32,23 +32,23 @@ public void DetailsValidationWorks() Semitransparency = true, }, }, - new Models::ExtensionItemAutoTaggingExtension() + new ExtensionItemAutoTaggingExtension() { MaxTags = 5, MinConfidence = 95, - Name = Models::ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, + Name = ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, }, - new Models::ExtensionItemAIAutoDescription(), - new Models::ExtensionItemAITasks( + new ExtensionItemAIAutoDescription(), + new ExtensionItemAITasks( [ - new Models::ExtensionItemAITasksTaskSelectTags() + new ExtensionItemAITasksTaskSelectTags() { Instruction = "What types of clothing items are visible in this image?", MaxSelections = 1, MinSelections = 0, Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], }, - new Models::ExtensionItemAITasksTaskYesNo() + new ExtensionItemAITasksTaskYesNo() { Instruction = "Is this a luxury or high-end fashion item?", OnNo = new() @@ -75,7 +75,7 @@ public void DetailsValidationWorks() }, ] ), - new Models::SavedExtension("ext_abc123"), + new SavedExtension("ext_abc123"), ], RemoveAITags = new UnionMember1(), Tags = ["tag1", "tag2"], @@ -107,7 +107,7 @@ public void DetailsSerializationRoundtripWorks() Description = "description", Extensions = [ - new Models::ExtensionItemRemoveBg() + new ExtensionItemRemoveBg() { Options = new() { @@ -117,23 +117,23 @@ public void DetailsSerializationRoundtripWorks() Semitransparency = true, }, }, - new Models::ExtensionItemAutoTaggingExtension() + new ExtensionItemAutoTaggingExtension() { MaxTags = 5, MinConfidence = 95, - Name = Models::ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, + Name = ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, }, - new Models::ExtensionItemAIAutoDescription(), - new Models::ExtensionItemAITasks( + new ExtensionItemAIAutoDescription(), + new ExtensionItemAITasks( [ - new Models::ExtensionItemAITasksTaskSelectTags() + new ExtensionItemAITasksTaskSelectTags() { Instruction = "What types of clothing items are visible in this image?", MaxSelections = 1, MinSelections = 0, Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], }, - new Models::ExtensionItemAITasksTaskYesNo() + new ExtensionItemAITasksTaskYesNo() { Instruction = "Is this a luxury or high-end fashion item?", OnNo = new() @@ -160,7 +160,7 @@ public void DetailsSerializationRoundtripWorks() }, ] ), - new Models::SavedExtension("ext_abc123"), + new SavedExtension("ext_abc123"), ], RemoveAITags = new UnionMember1(), Tags = ["tag1", "tag2"], @@ -207,7 +207,7 @@ public void FieldRoundtrip_Works() Description = "description", Extensions = [ - new Models::ExtensionItemRemoveBg() + new ExtensionItemRemoveBg() { Options = new() { @@ -217,23 +217,23 @@ public void FieldRoundtrip_Works() Semitransparency = true, }, }, - new Models::ExtensionItemAutoTaggingExtension() + new ExtensionItemAutoTaggingExtension() { MaxTags = 5, MinConfidence = 95, - Name = Models::ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, + Name = ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, }, - new Models::ExtensionItemAIAutoDescription(), - new Models::ExtensionItemAITasks( + new ExtensionItemAIAutoDescription(), + new ExtensionItemAITasks( [ - new Models::ExtensionItemAITasksTaskSelectTags() + new ExtensionItemAITasksTaskSelectTags() { Instruction = "What types of clothing items are visible in this image?", MaxSelections = 1, MinSelections = 0, Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], }, - new Models::ExtensionItemAITasksTaskYesNo() + new ExtensionItemAITasksTaskYesNo() { Instruction = "Is this a luxury or high-end fashion item?", OnNo = new() @@ -260,7 +260,7 @@ public void FieldRoundtrip_Works() }, ] ), - new Models::SavedExtension("ext_abc123"), + new SavedExtension("ext_abc123"), ], RemoveAITags = new UnionMember1(), Tags = ["tag1", "tag2"], @@ -273,9 +273,9 @@ public void FieldRoundtrip_Works() { "foo", JsonSerializer.SerializeToElement("bar") }, }; string expectedDescription = "description"; - List expectedExtensions = + List expectedExtensions = [ - new Models::ExtensionItemRemoveBg() + new ExtensionItemRemoveBg() { Options = new() { @@ -285,23 +285,23 @@ public void FieldRoundtrip_Works() Semitransparency = true, }, }, - new Models::ExtensionItemAutoTaggingExtension() + new ExtensionItemAutoTaggingExtension() { MaxTags = 5, MinConfidence = 95, - Name = Models::ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, + Name = ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, }, - new Models::ExtensionItemAIAutoDescription(), - new Models::ExtensionItemAITasks( + new ExtensionItemAIAutoDescription(), + new ExtensionItemAITasks( [ - new Models::ExtensionItemAITasksTaskSelectTags() + new ExtensionItemAITasksTaskSelectTags() { Instruction = "What types of clothing items are visible in this image?", MaxSelections = 1, MinSelections = 0, Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], }, - new Models::ExtensionItemAITasksTaskYesNo() + new ExtensionItemAITasksTaskYesNo() { Instruction = "Is this a luxury or high-end fashion item?", OnNo = new() @@ -328,7 +328,7 @@ public void FieldRoundtrip_Works() }, ] ), - new Models::SavedExtension("ext_abc123"), + new SavedExtension("ext_abc123"), ]; RemoveAITags expectedRemoveAITags = new UnionMember1(); List expectedTags = ["tag1", "tag2"]; @@ -373,7 +373,7 @@ public void SerializationRoundtrip_Works() Description = "description", Extensions = [ - new Models::ExtensionItemRemoveBg() + new ExtensionItemRemoveBg() { Options = new() { @@ -383,23 +383,23 @@ public void SerializationRoundtrip_Works() Semitransparency = true, }, }, - new Models::ExtensionItemAutoTaggingExtension() + new ExtensionItemAutoTaggingExtension() { MaxTags = 5, MinConfidence = 95, - Name = Models::ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, + Name = ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, }, - new Models::ExtensionItemAIAutoDescription(), - new Models::ExtensionItemAITasks( + new ExtensionItemAIAutoDescription(), + new ExtensionItemAITasks( [ - new Models::ExtensionItemAITasksTaskSelectTags() + new ExtensionItemAITasksTaskSelectTags() { Instruction = "What types of clothing items are visible in this image?", MaxSelections = 1, MinSelections = 0, Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], }, - new Models::ExtensionItemAITasksTaskYesNo() + new ExtensionItemAITasksTaskYesNo() { Instruction = "Is this a luxury or high-end fashion item?", OnNo = new() @@ -426,7 +426,7 @@ public void SerializationRoundtrip_Works() }, ] ), - new Models::SavedExtension("ext_abc123"), + new SavedExtension("ext_abc123"), ], RemoveAITags = new UnionMember1(), Tags = ["tag1", "tag2"], @@ -455,7 +455,7 @@ public void FieldRoundtripThroughSerialization_Works() Description = "description", Extensions = [ - new Models::ExtensionItemRemoveBg() + new ExtensionItemRemoveBg() { Options = new() { @@ -465,23 +465,23 @@ public void FieldRoundtripThroughSerialization_Works() Semitransparency = true, }, }, - new Models::ExtensionItemAutoTaggingExtension() + new ExtensionItemAutoTaggingExtension() { MaxTags = 5, MinConfidence = 95, - Name = Models::ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, + Name = ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, }, - new Models::ExtensionItemAIAutoDescription(), - new Models::ExtensionItemAITasks( + new ExtensionItemAIAutoDescription(), + new ExtensionItemAITasks( [ - new Models::ExtensionItemAITasksTaskSelectTags() + new ExtensionItemAITasksTaskSelectTags() { Instruction = "What types of clothing items are visible in this image?", MaxSelections = 1, MinSelections = 0, Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], }, - new Models::ExtensionItemAITasksTaskYesNo() + new ExtensionItemAITasksTaskYesNo() { Instruction = "Is this a luxury or high-end fashion item?", OnNo = new() @@ -508,7 +508,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ] ), - new Models::SavedExtension("ext_abc123"), + new SavedExtension("ext_abc123"), ], RemoveAITags = new UnionMember1(), Tags = ["tag1", "tag2"], @@ -528,9 +528,9 @@ public void FieldRoundtripThroughSerialization_Works() { "foo", JsonSerializer.SerializeToElement("bar") }, }; string expectedDescription = "description"; - List expectedExtensions = + List expectedExtensions = [ - new Models::ExtensionItemRemoveBg() + new ExtensionItemRemoveBg() { Options = new() { @@ -540,23 +540,23 @@ public void FieldRoundtripThroughSerialization_Works() Semitransparency = true, }, }, - new Models::ExtensionItemAutoTaggingExtension() + new ExtensionItemAutoTaggingExtension() { MaxTags = 5, MinConfidence = 95, - Name = Models::ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, + Name = ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, }, - new Models::ExtensionItemAIAutoDescription(), - new Models::ExtensionItemAITasks( + new ExtensionItemAIAutoDescription(), + new ExtensionItemAITasks( [ - new Models::ExtensionItemAITasksTaskSelectTags() + new ExtensionItemAITasksTaskSelectTags() { Instruction = "What types of clothing items are visible in this image?", MaxSelections = 1, MinSelections = 0, Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], }, - new Models::ExtensionItemAITasksTaskYesNo() + new ExtensionItemAITasksTaskYesNo() { Instruction = "Is this a luxury or high-end fashion item?", OnNo = new() @@ -583,7 +583,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ] ), - new Models::SavedExtension("ext_abc123"), + new SavedExtension("ext_abc123"), ]; RemoveAITags expectedRemoveAITags = new UnionMember1(); List expectedTags = ["tag1", "tag2"]; @@ -628,7 +628,7 @@ public void Validation_Works() Description = "description", Extensions = [ - new Models::ExtensionItemRemoveBg() + new ExtensionItemRemoveBg() { Options = new() { @@ -638,23 +638,23 @@ public void Validation_Works() Semitransparency = true, }, }, - new Models::ExtensionItemAutoTaggingExtension() + new ExtensionItemAutoTaggingExtension() { MaxTags = 5, MinConfidence = 95, - Name = Models::ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, + Name = ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, }, - new Models::ExtensionItemAIAutoDescription(), - new Models::ExtensionItemAITasks( + new ExtensionItemAIAutoDescription(), + new ExtensionItemAITasks( [ - new Models::ExtensionItemAITasksTaskSelectTags() + new ExtensionItemAITasksTaskSelectTags() { Instruction = "What types of clothing items are visible in this image?", MaxSelections = 1, MinSelections = 0, Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], }, - new Models::ExtensionItemAITasksTaskYesNo() + new ExtensionItemAITasksTaskYesNo() { Instruction = "Is this a luxury or high-end fashion item?", OnNo = new() @@ -681,7 +681,7 @@ public void Validation_Works() }, ] ), - new Models::SavedExtension("ext_abc123"), + new SavedExtension("ext_abc123"), ], RemoveAITags = new UnionMember1(), Tags = ["tag1", "tag2"], @@ -783,7 +783,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Description = "description", Extensions = [ - new Models::ExtensionItemRemoveBg() + new ExtensionItemRemoveBg() { Options = new() { @@ -793,23 +793,23 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Semitransparency = true, }, }, - new Models::ExtensionItemAutoTaggingExtension() + new ExtensionItemAutoTaggingExtension() { MaxTags = 5, MinConfidence = 95, - Name = Models::ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, + Name = ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, }, - new Models::ExtensionItemAIAutoDescription(), - new Models::ExtensionItemAITasks( + new ExtensionItemAIAutoDescription(), + new ExtensionItemAITasks( [ - new Models::ExtensionItemAITasksTaskSelectTags() + new ExtensionItemAITasksTaskSelectTags() { Instruction = "What types of clothing items are visible in this image?", MaxSelections = 1, MinSelections = 0, Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], }, - new Models::ExtensionItemAITasksTaskYesNo() + new ExtensionItemAITasksTaskYesNo() { Instruction = "Is this a luxury or high-end fashion item?", OnNo = new() @@ -836,7 +836,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ] ), - new Models::SavedExtension("ext_abc123"), + new SavedExtension("ext_abc123"), ], RemoveAITags = new UnionMember1(), WebhookUrl = "https://example.com", @@ -860,7 +860,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Description = "description", Extensions = [ - new Models::ExtensionItemRemoveBg() + new ExtensionItemRemoveBg() { Options = new() { @@ -870,23 +870,23 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Semitransparency = true, }, }, - new Models::ExtensionItemAutoTaggingExtension() + new ExtensionItemAutoTaggingExtension() { MaxTags = 5, MinConfidence = 95, - Name = Models::ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, + Name = ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, }, - new Models::ExtensionItemAIAutoDescription(), - new Models::ExtensionItemAITasks( + new ExtensionItemAIAutoDescription(), + new ExtensionItemAITasks( [ - new Models::ExtensionItemAITasksTaskSelectTags() + new ExtensionItemAITasksTaskSelectTags() { Instruction = "What types of clothing items are visible in this image?", MaxSelections = 1, MinSelections = 0, Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], }, - new Models::ExtensionItemAITasksTaskYesNo() + new ExtensionItemAITasksTaskYesNo() { Instruction = "Is this a luxury or high-end fashion item?", OnNo = new() @@ -913,7 +913,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ] ), - new Models::SavedExtension("ext_abc123"), + new SavedExtension("ext_abc123"), ], RemoveAITags = new UnionMember1(), WebhookUrl = "https://example.com", @@ -934,7 +934,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Description = "description", Extensions = [ - new Models::ExtensionItemRemoveBg() + new ExtensionItemRemoveBg() { Options = new() { @@ -944,23 +944,23 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Semitransparency = true, }, }, - new Models::ExtensionItemAutoTaggingExtension() + new ExtensionItemAutoTaggingExtension() { MaxTags = 5, MinConfidence = 95, - Name = Models::ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, + Name = ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, }, - new Models::ExtensionItemAIAutoDescription(), - new Models::ExtensionItemAITasks( + new ExtensionItemAIAutoDescription(), + new ExtensionItemAITasks( [ - new Models::ExtensionItemAITasksTaskSelectTags() + new ExtensionItemAITasksTaskSelectTags() { Instruction = "What types of clothing items are visible in this image?", MaxSelections = 1, MinSelections = 0, Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], }, - new Models::ExtensionItemAITasksTaskYesNo() + new ExtensionItemAITasksTaskYesNo() { Instruction = "Is this a luxury or high-end fashion item?", OnNo = new() @@ -987,7 +987,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ] ), - new Models::SavedExtension("ext_abc123"), + new SavedExtension("ext_abc123"), ], RemoveAITags = new UnionMember1(), WebhookUrl = "https://example.com", @@ -1014,7 +1014,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Description = "description", Extensions = [ - new Models::ExtensionItemRemoveBg() + new ExtensionItemRemoveBg() { Options = new() { @@ -1024,23 +1024,23 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Semitransparency = true, }, }, - new Models::ExtensionItemAutoTaggingExtension() + new ExtensionItemAutoTaggingExtension() { MaxTags = 5, MinConfidence = 95, - Name = Models::ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, + Name = ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, }, - new Models::ExtensionItemAIAutoDescription(), - new Models::ExtensionItemAITasks( + new ExtensionItemAIAutoDescription(), + new ExtensionItemAITasks( [ - new Models::ExtensionItemAITasksTaskSelectTags() + new ExtensionItemAITasksTaskSelectTags() { Instruction = "What types of clothing items are visible in this image?", MaxSelections = 1, MinSelections = 0, Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], }, - new Models::ExtensionItemAITasksTaskYesNo() + new ExtensionItemAITasksTaskYesNo() { Instruction = "Is this a luxury or high-end fashion item?", OnNo = new() @@ -1067,7 +1067,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ] ), - new Models::SavedExtension("ext_abc123"), + new SavedExtension("ext_abc123"), ], RemoveAITags = new UnionMember1(), WebhookUrl = "https://example.com", @@ -1092,7 +1092,7 @@ public void CopyConstructor_Works() Description = "description", Extensions = [ - new Models::ExtensionItemRemoveBg() + new ExtensionItemRemoveBg() { Options = new() { @@ -1102,23 +1102,23 @@ public void CopyConstructor_Works() Semitransparency = true, }, }, - new Models::ExtensionItemAutoTaggingExtension() + new ExtensionItemAutoTaggingExtension() { MaxTags = 5, MinConfidence = 95, - Name = Models::ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, + Name = ExtensionItemAutoTaggingExtensionName.GoogleAutoTagging, }, - new Models::ExtensionItemAIAutoDescription(), - new Models::ExtensionItemAITasks( + new ExtensionItemAIAutoDescription(), + new ExtensionItemAITasks( [ - new Models::ExtensionItemAITasksTaskSelectTags() + new ExtensionItemAITasksTaskSelectTags() { Instruction = "What types of clothing items are visible in this image?", MaxSelections = 1, MinSelections = 0, Vocabulary = ["shirt", "tshirt", "dress", "trousers", "jacket"], }, - new Models::ExtensionItemAITasksTaskYesNo() + new ExtensionItemAITasksTaskYesNo() { Instruction = "Is this a luxury or high-end fashion item?", OnNo = new() @@ -1145,7 +1145,7 @@ public void CopyConstructor_Works() }, ] ), - new Models::SavedExtension("ext_abc123"), + new SavedExtension("ext_abc123"), ], RemoveAITags = new UnionMember1(), Tags = ["tag1", "tag2"], diff --git a/src/Imagekit.Tests/Models/GetImageAttributesOptionsTest.cs b/src/Imagekit.Tests/Models/GetImageAttributesOptionsTest.cs index ac42de8f..255c0336 100644 --- a/src/Imagekit.Tests/Models/GetImageAttributesOptionsTest.cs +++ b/src/Imagekit.Tests/Models/GetImageAttributesOptionsTest.cs @@ -22,7 +22,7 @@ public void FieldRoundtrip_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -48,7 +48,7 @@ public void FieldRoundtrip_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -89,7 +89,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -102,12 +102,12 @@ public void FieldRoundtrip_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -134,7 +134,7 @@ public void FieldRoundtrip_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -160,7 +160,7 @@ public void FieldRoundtrip_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -201,7 +201,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -214,12 +214,12 @@ public void FieldRoundtrip_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -286,7 +286,7 @@ public void SerializationRoundtrip_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -312,7 +312,7 @@ public void SerializationRoundtrip_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -353,7 +353,7 @@ public void SerializationRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -366,12 +366,12 @@ public void SerializationRoundtrip_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -412,7 +412,7 @@ public void FieldRoundtripThroughSerialization_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -438,7 +438,7 @@ public void FieldRoundtripThroughSerialization_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -479,7 +479,7 @@ public void FieldRoundtripThroughSerialization_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -492,12 +492,12 @@ public void FieldRoundtripThroughSerialization_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -531,7 +531,7 @@ public void FieldRoundtripThroughSerialization_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -557,7 +557,7 @@ public void FieldRoundtripThroughSerialization_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -598,7 +598,7 @@ public void FieldRoundtripThroughSerialization_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -611,12 +611,12 @@ public void FieldRoundtripThroughSerialization_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -683,7 +683,7 @@ public void Validation_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -709,7 +709,7 @@ public void Validation_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -750,7 +750,7 @@ public void Validation_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -763,12 +763,12 @@ public void Validation_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -907,7 +907,7 @@ public void CopyConstructor_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -933,7 +933,7 @@ public void CopyConstructor_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -974,7 +974,7 @@ public void CopyConstructor_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -987,12 +987,12 @@ public void CopyConstructor_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, diff --git a/src/Imagekit.Tests/Models/ImageOverlayTest.cs b/src/Imagekit.Tests/Models/ImageOverlayTest.cs index 6d14526b..de087a1d 100644 --- a/src/Imagekit.Tests/Models/ImageOverlayTest.cs +++ b/src/Imagekit.Tests/Models/ImageOverlayTest.cs @@ -36,7 +36,7 @@ public void FieldRoundtrip_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -62,7 +62,7 @@ public void FieldRoundtrip_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -103,7 +103,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -116,12 +116,12 @@ public void FieldRoundtrip_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -157,7 +157,7 @@ public void FieldRoundtrip_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -183,7 +183,7 @@ public void FieldRoundtrip_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -224,7 +224,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -237,12 +237,12 @@ public void FieldRoundtrip_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -295,7 +295,7 @@ public void SerializationRoundtrip_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -321,7 +321,7 @@ public void SerializationRoundtrip_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -362,7 +362,7 @@ public void SerializationRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -375,12 +375,12 @@ public void SerializationRoundtrip_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -429,7 +429,7 @@ public void FieldRoundtripThroughSerialization_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -455,7 +455,7 @@ public void FieldRoundtripThroughSerialization_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -496,7 +496,7 @@ public void FieldRoundtripThroughSerialization_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -509,12 +509,12 @@ public void FieldRoundtripThroughSerialization_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -557,7 +557,7 @@ public void FieldRoundtripThroughSerialization_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -583,7 +583,7 @@ public void FieldRoundtripThroughSerialization_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -624,7 +624,7 @@ public void FieldRoundtripThroughSerialization_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -637,12 +637,12 @@ public void FieldRoundtripThroughSerialization_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -695,7 +695,7 @@ public void Validation_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -721,7 +721,7 @@ public void Validation_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -762,7 +762,7 @@ public void Validation_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -775,12 +775,12 @@ public void Validation_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -893,7 +893,7 @@ public void CopyConstructor_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -919,7 +919,7 @@ public void CopyConstructor_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -960,7 +960,7 @@ public void CopyConstructor_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -973,12 +973,12 @@ public void CopyConstructor_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -1010,7 +1010,7 @@ public void FieldRoundtrip_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -1036,7 +1036,7 @@ public void FieldRoundtrip_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -1077,7 +1077,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -1090,12 +1090,12 @@ public void FieldRoundtrip_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -1115,7 +1115,7 @@ public void FieldRoundtrip_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -1141,7 +1141,7 @@ public void FieldRoundtrip_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -1182,7 +1182,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -1195,12 +1195,12 @@ public void FieldRoundtrip_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -1234,7 +1234,7 @@ public void SerializationRoundtrip_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -1260,7 +1260,7 @@ public void SerializationRoundtrip_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -1301,7 +1301,7 @@ public void SerializationRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -1314,12 +1314,12 @@ public void SerializationRoundtrip_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -1352,7 +1352,7 @@ public void FieldRoundtripThroughSerialization_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -1378,7 +1378,7 @@ public void FieldRoundtripThroughSerialization_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -1419,7 +1419,7 @@ public void FieldRoundtripThroughSerialization_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -1432,12 +1432,12 @@ public void FieldRoundtripThroughSerialization_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -1464,7 +1464,7 @@ public void FieldRoundtripThroughSerialization_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -1490,7 +1490,7 @@ public void FieldRoundtripThroughSerialization_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -1531,7 +1531,7 @@ public void FieldRoundtripThroughSerialization_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -1544,12 +1544,12 @@ public void FieldRoundtripThroughSerialization_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -1583,7 +1583,7 @@ public void Validation_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -1609,7 +1609,7 @@ public void Validation_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -1650,7 +1650,7 @@ public void Validation_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -1663,12 +1663,12 @@ public void Validation_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -1747,7 +1747,7 @@ public void CopyConstructor_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -1773,7 +1773,7 @@ public void CopyConstructor_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -1814,7 +1814,7 @@ public void CopyConstructor_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -1827,12 +1827,12 @@ public void CopyConstructor_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, diff --git a/src/Imagekit.Tests/Models/OverlayTest.cs b/src/Imagekit.Tests/Models/OverlayTest.cs index 40372ca7..3153fcff 100644 --- a/src/Imagekit.Tests/Models/OverlayTest.cs +++ b/src/Imagekit.Tests/Models/OverlayTest.cs @@ -42,7 +42,7 @@ public void TextValidationWorks() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -80,7 +80,7 @@ public void ImageValidationWorks() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -106,7 +106,7 @@ public void ImageValidationWorks() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -147,7 +147,7 @@ public void ImageValidationWorks() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -160,12 +160,12 @@ public void ImageValidationWorks() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -207,7 +207,7 @@ public void VideoValidationWorks() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -233,7 +233,7 @@ public void VideoValidationWorks() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -274,7 +274,7 @@ public void VideoValidationWorks() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -287,12 +287,12 @@ public void VideoValidationWorks() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -374,9 +374,9 @@ public void SolidColorValidationWorks() { Alpha = 1, Background = "background", - Gradient = new UnionMember0(), + Gradient = new Default(), Height = 0, - Radius = new UnionMember1(), + Radius = new Max(), Width = 0, }, ], @@ -420,7 +420,7 @@ public void TextSerializationRoundtripWorks() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -464,7 +464,7 @@ public void ImageSerializationRoundtripWorks() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -490,7 +490,7 @@ public void ImageSerializationRoundtripWorks() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -531,7 +531,7 @@ public void ImageSerializationRoundtripWorks() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -544,12 +544,12 @@ public void ImageSerializationRoundtripWorks() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -597,7 +597,7 @@ public void VideoSerializationRoundtripWorks() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -623,7 +623,7 @@ public void VideoSerializationRoundtripWorks() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -664,7 +664,7 @@ public void VideoSerializationRoundtripWorks() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -677,12 +677,12 @@ public void VideoSerializationRoundtripWorks() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -776,9 +776,9 @@ public void SolidColorSerializationRoundtripWorks() { Alpha = 1, Background = "background", - Gradient = new UnionMember0(), + Gradient = new Default(), Height = 0, - Radius = new UnionMember1(), + Radius = new Max(), Width = 0, }, ], diff --git a/src/Imagekit.Tests/Models/SolidColorOverlayTest.cs b/src/Imagekit.Tests/Models/SolidColorOverlayTest.cs index 3a9306a3..8996acac 100644 --- a/src/Imagekit.Tests/Models/SolidColorOverlayTest.cs +++ b/src/Imagekit.Tests/Models/SolidColorOverlayTest.cs @@ -35,9 +35,9 @@ public void FieldRoundtrip_Works() { Alpha = 1, Background = "background", - Gradient = new UnionMember0(), + Gradient = new Default(), Height = 0, - Radius = new UnionMember1(), + Radius = new Max(), Width = 0, }, ], @@ -67,9 +67,9 @@ public void FieldRoundtrip_Works() { Alpha = 1, Background = "background", - Gradient = new UnionMember0(), + Gradient = new Default(), Height = 0, - Radius = new UnionMember1(), + Radius = new Max(), Width = 0, }, ]; @@ -115,9 +115,9 @@ public void SerializationRoundtrip_Works() { Alpha = 1, Background = "background", - Gradient = new UnionMember0(), + Gradient = new Default(), Height = 0, - Radius = new UnionMember1(), + Radius = new Max(), Width = 0, }, ], @@ -160,9 +160,9 @@ public void FieldRoundtripThroughSerialization_Works() { Alpha = 1, Background = "background", - Gradient = new UnionMember0(), + Gradient = new Default(), Height = 0, - Radius = new UnionMember1(), + Radius = new Max(), Width = 0, }, ], @@ -199,9 +199,9 @@ public void FieldRoundtripThroughSerialization_Works() { Alpha = 1, Background = "background", - Gradient = new UnionMember0(), + Gradient = new Default(), Height = 0, - Radius = new UnionMember1(), + Radius = new Max(), Width = 0, }, ]; @@ -247,9 +247,9 @@ public void Validation_Works() { Alpha = 1, Background = "background", - Gradient = new UnionMember0(), + Gradient = new Default(), Height = 0, - Radius = new UnionMember1(), + Radius = new Max(), Width = 0, }, ], @@ -350,9 +350,9 @@ public void CopyConstructor_Works() { Alpha = 1, Background = "background", - Gradient = new UnionMember0(), + Gradient = new Default(), Height = 0, - Radius = new UnionMember1(), + Radius = new Max(), Width = 0, }, ], @@ -378,9 +378,9 @@ public void FieldRoundtrip_Works() { Alpha = 1, Background = "background", - Gradient = new UnionMember0(), + Gradient = new Default(), Height = 0, - Radius = new UnionMember1(), + Radius = new Max(), Width = 0, }, ], @@ -394,9 +394,9 @@ public void FieldRoundtrip_Works() { Alpha = 1, Background = "background", - Gradient = new UnionMember0(), + Gradient = new Default(), Height = 0, - Radius = new UnionMember1(), + Radius = new Max(), Width = 0, }, ]; @@ -423,9 +423,9 @@ public void SerializationRoundtrip_Works() { Alpha = 1, Background = "background", - Gradient = new UnionMember0(), + Gradient = new Default(), Height = 0, - Radius = new UnionMember1(), + Radius = new Max(), Width = 0, }, ], @@ -452,9 +452,9 @@ public void FieldRoundtripThroughSerialization_Works() { Alpha = 1, Background = "background", - Gradient = new UnionMember0(), + Gradient = new Default(), Height = 0, - Radius = new UnionMember1(), + Radius = new Max(), Width = 0, }, ], @@ -475,9 +475,9 @@ public void FieldRoundtripThroughSerialization_Works() { Alpha = 1, Background = "background", - Gradient = new UnionMember0(), + Gradient = new Default(), Height = 0, - Radius = new UnionMember1(), + Radius = new Max(), Width = 0, }, ]; @@ -504,9 +504,9 @@ public void Validation_Works() { Alpha = 1, Background = "background", - Gradient = new UnionMember0(), + Gradient = new Default(), Height = 0, - Radius = new UnionMember1(), + Radius = new Max(), Width = 0, }, ], @@ -573,9 +573,9 @@ public void CopyConstructor_Works() { Alpha = 1, Background = "background", - Gradient = new UnionMember0(), + Gradient = new Default(), Height = 0, - Radius = new UnionMember1(), + Radius = new Max(), Width = 0, }, ], diff --git a/src/Imagekit.Tests/Models/SolidColorOverlayTransformationTest.cs b/src/Imagekit.Tests/Models/SolidColorOverlayTransformationTest.cs index 89059491..0eb81d83 100644 --- a/src/Imagekit.Tests/Models/SolidColorOverlayTransformationTest.cs +++ b/src/Imagekit.Tests/Models/SolidColorOverlayTransformationTest.cs @@ -14,17 +14,17 @@ public void FieldRoundtrip_Works() { Alpha = 1, Background = "background", - Gradient = new UnionMember0(), + Gradient = new Default(), Height = 0, - Radius = new UnionMember1(), + Radius = new Max(), Width = 0, }; double expectedAlpha = 1; string expectedBackground = "background"; - Gradient expectedGradient = new UnionMember0(); + Gradient expectedGradient = new Default(); Height expectedHeight = 0; - Radius expectedRadius = new UnionMember1(); + Radius expectedRadius = new Max(); Width expectedWidth = 0; Assert.Equal(expectedAlpha, model.Alpha); @@ -42,9 +42,9 @@ public void SerializationRoundtrip_Works() { Alpha = 1, Background = "background", - Gradient = new UnionMember0(), + Gradient = new Default(), Height = 0, - Radius = new UnionMember1(), + Radius = new Max(), Width = 0, }; @@ -64,9 +64,9 @@ public void FieldRoundtripThroughSerialization_Works() { Alpha = 1, Background = "background", - Gradient = new UnionMember0(), + Gradient = new Default(), Height = 0, - Radius = new UnionMember1(), + Radius = new Max(), Width = 0, }; @@ -79,9 +79,9 @@ public void FieldRoundtripThroughSerialization_Works() double expectedAlpha = 1; string expectedBackground = "background"; - Gradient expectedGradient = new UnionMember0(); + Gradient expectedGradient = new Default(); Height expectedHeight = 0; - Radius expectedRadius = new UnionMember1(); + Radius expectedRadius = new Max(); Width expectedWidth = 0; Assert.Equal(expectedAlpha, deserialized.Alpha); @@ -99,9 +99,9 @@ public void Validation_Works() { Alpha = 1, Background = "background", - Gradient = new UnionMember0(), + Gradient = new Default(), Height = 0, - Radius = new UnionMember1(), + Radius = new Max(), Width = 0, }; @@ -187,9 +187,9 @@ public void CopyConstructor_Works() { Alpha = 1, Background = "background", - Gradient = new UnionMember0(), + Gradient = new Default(), Height = 0, - Radius = new UnionMember1(), + Radius = new Max(), Width = 0, }; @@ -202,9 +202,9 @@ public void CopyConstructor_Works() public class GradientTest : TestBase { [Fact] - public void TrueValidationWorks() + public void DefaultValidationWorks() { - Gradient value = new UnionMember0(); + Gradient value = new Default(); value.Validate(); } @@ -216,9 +216,9 @@ public void StringValidationWorks() } [Fact] - public void TrueSerializationRoundtripWorks() + public void DefaultSerializationRoundtripWorks() { - Gradient value = new UnionMember0(); + Gradient value = new Default(); string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize( element, @@ -242,19 +242,19 @@ public void StringSerializationRoundtripWorks() } } -public class UnionMember0Test : TestBase +public class DefaultTest : TestBase { [Fact] public void DefaultValidation_Works() { - var constant = new UnionMember0(); + var constant = new Default(); constant.Validate(); } [Fact] public void ValidConstantValidation_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.SerializeToElement(true), ModelBase.SerializerOptions ); @@ -266,7 +266,7 @@ public void ValidConstantValidation_Works() [Fact] public void InvalidConstantValidationThrows_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); @@ -278,9 +278,9 @@ public void InvalidConstantValidationThrows_Works() [Fact] public void DefaultRoundtrip_Works() { - var constant = new UnionMember0(); + var constant = new Default(); string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -291,12 +291,12 @@ public void DefaultRoundtrip_Works() [Fact] public void ValidConstantRoundtrip_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.SerializeToElement(true), ModelBase.SerializerOptions ); string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -307,12 +307,12 @@ public void ValidConstantRoundtrip_Works() [Fact] public void InvalidConstantRoundtrip_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -370,7 +370,7 @@ public void DoubleValidationWorks() [Fact] public void MaxValidationWorks() { - Radius value = new UnionMember1(); + Radius value = new Max(); value.Validate(); } @@ -394,7 +394,7 @@ public void DoubleSerializationRoundtripWorks() [Fact] public void MaxSerializationRoundtripWorks() { - Radius value = new UnionMember1(); + Radius value = new Max(); string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -412,19 +412,19 @@ public void StringSerializationRoundtripWorks() } } -public class UnionMember1Test : TestBase +public class MaxTest : TestBase { [Fact] public void DefaultValidation_Works() { - var constant = new UnionMember1(); + var constant = new Max(); constant.Validate(); } [Fact] public void ValidConstantValidation_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.SerializeToElement("max"), ModelBase.SerializerOptions ); @@ -436,7 +436,7 @@ public void ValidConstantValidation_Works() [Fact] public void InvalidConstantValidationThrows_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); @@ -448,12 +448,9 @@ public void InvalidConstantValidationThrows_Works() [Fact] public void DefaultRoundtrip_Works() { - var constant = new UnionMember1(); + var constant = new Max(); string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); Assert.Equal(constant, deserialized); } @@ -461,15 +458,12 @@ public void DefaultRoundtrip_Works() [Fact] public void ValidConstantRoundtrip_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.SerializeToElement("max"), ModelBase.SerializerOptions ); string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); Assert.Equal(constant, deserialized); } @@ -477,15 +471,12 @@ public void ValidConstantRoundtrip_Works() [Fact] public void InvalidConstantRoundtrip_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); Assert.Equal(constant, deserialized); } diff --git a/src/Imagekit.Tests/Models/SrcOptionsTest.cs b/src/Imagekit.Tests/Models/SrcOptionsTest.cs index 221c484b..330caf5a 100644 --- a/src/Imagekit.Tests/Models/SrcOptionsTest.cs +++ b/src/Imagekit.Tests/Models/SrcOptionsTest.cs @@ -22,7 +22,7 @@ public void FieldRoundtrip_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -48,7 +48,7 @@ public void FieldRoundtrip_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -89,7 +89,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -102,12 +102,12 @@ public void FieldRoundtrip_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -130,7 +130,7 @@ public void FieldRoundtrip_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -156,7 +156,7 @@ public void FieldRoundtrip_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -197,7 +197,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -210,12 +210,12 @@ public void FieldRoundtrip_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -264,7 +264,7 @@ public void SerializationRoundtrip_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -290,7 +290,7 @@ public void SerializationRoundtrip_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -331,7 +331,7 @@ public void SerializationRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -344,12 +344,12 @@ public void SerializationRoundtrip_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -386,7 +386,7 @@ public void FieldRoundtripThroughSerialization_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -412,7 +412,7 @@ public void FieldRoundtripThroughSerialization_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -453,7 +453,7 @@ public void FieldRoundtripThroughSerialization_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -466,12 +466,12 @@ public void FieldRoundtripThroughSerialization_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -501,7 +501,7 @@ public void FieldRoundtripThroughSerialization_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -527,7 +527,7 @@ public void FieldRoundtripThroughSerialization_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -568,7 +568,7 @@ public void FieldRoundtripThroughSerialization_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -581,12 +581,12 @@ public void FieldRoundtripThroughSerialization_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -635,7 +635,7 @@ public void Validation_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -661,7 +661,7 @@ public void Validation_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -702,7 +702,7 @@ public void Validation_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -715,12 +715,12 @@ public void Validation_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -831,7 +831,7 @@ public void CopyConstructor_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -857,7 +857,7 @@ public void CopyConstructor_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -898,7 +898,7 @@ public void CopyConstructor_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -911,12 +911,12 @@ public void CopyConstructor_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, diff --git a/src/Imagekit.Tests/Models/TextOverlayTest.cs b/src/Imagekit.Tests/Models/TextOverlayTest.cs index 5923b815..da810df4 100644 --- a/src/Imagekit.Tests/Models/TextOverlayTest.cs +++ b/src/Imagekit.Tests/Models/TextOverlayTest.cs @@ -44,7 +44,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -85,7 +85,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -142,7 +142,7 @@ public void SerializationRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -195,7 +195,7 @@ public void FieldRoundtripThroughSerialization_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -243,7 +243,7 @@ public void FieldRoundtripThroughSerialization_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -300,7 +300,7 @@ public void Validation_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -417,7 +417,7 @@ public void CopyConstructor_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -453,7 +453,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -478,7 +478,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -516,7 +516,7 @@ public void SerializationRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -553,7 +553,7 @@ public void FieldRoundtripThroughSerialization_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -585,7 +585,7 @@ public void FieldRoundtripThroughSerialization_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -623,7 +623,7 @@ public void Validation_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -706,7 +706,7 @@ public void CopyConstructor_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, diff --git a/src/Imagekit.Tests/Models/TextOverlayTransformationTest.cs b/src/Imagekit.Tests/Models/TextOverlayTransformationTest.cs index a8471ed4..1fd10b4a 100644 --- a/src/Imagekit.Tests/Models/TextOverlayTransformationTest.cs +++ b/src/Imagekit.Tests/Models/TextOverlayTransformationTest.cs @@ -21,7 +21,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -36,8 +36,7 @@ public void FieldRoundtrip_Works() ApiEnum expectedInnerAlignment = InnerAlignment.Left; LineHeight expectedLineHeight = 0; Padding expectedPadding = 0; - TextOverlayTransformationRadius expectedRadius = - new TextOverlayTransformationRadiusUnionMember1(); + TextOverlayTransformationRadius expectedRadius = new TextOverlayTransformationRadiusMax(); Rotation expectedRotation = 0; string expectedTypography = "typography"; TextOverlayTransformationWidth expectedWidth = 0; @@ -71,7 +70,7 @@ public void SerializationRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -100,7 +99,7 @@ public void FieldRoundtripThroughSerialization_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -122,8 +121,7 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum expectedInnerAlignment = InnerAlignment.Left; LineHeight expectedLineHeight = 0; Padding expectedPadding = 0; - TextOverlayTransformationRadius expectedRadius = - new TextOverlayTransformationRadiusUnionMember1(); + TextOverlayTransformationRadius expectedRadius = new TextOverlayTransformationRadiusMax(); Rotation expectedRotation = 0; string expectedTypography = "typography"; TextOverlayTransformationWidth expectedWidth = 0; @@ -157,7 +155,7 @@ public void Validation_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -294,7 +292,7 @@ public void CopyConstructor_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -569,7 +567,7 @@ public void DoubleValidationWorks() [Fact] public void MaxValidationWorks() { - TextOverlayTransformationRadius value = new TextOverlayTransformationRadiusUnionMember1(); + TextOverlayTransformationRadius value = new TextOverlayTransformationRadiusMax(); value.Validate(); } @@ -596,7 +594,7 @@ public void DoubleSerializationRoundtripWorks() [Fact] public void MaxSerializationRoundtripWorks() { - TextOverlayTransformationRadius value = new TextOverlayTransformationRadiusUnionMember1(); + TextOverlayTransformationRadius value = new TextOverlayTransformationRadiusMax(); string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize( element, @@ -620,19 +618,19 @@ public void StringSerializationRoundtripWorks() } } -public class TextOverlayTransformationRadiusUnionMember1Test : TestBase +public class TextOverlayTransformationRadiusMaxTest : TestBase { [Fact] public void DefaultValidation_Works() { - var constant = new TextOverlayTransformationRadiusUnionMember1(); + var constant = new TextOverlayTransformationRadiusMax(); constant.Validate(); } [Fact] public void ValidConstantValidation_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.SerializeToElement("max"), ModelBase.SerializerOptions ); @@ -644,7 +642,7 @@ public void ValidConstantValidation_Works() [Fact] public void InvalidConstantValidationThrows_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); @@ -656,9 +654,9 @@ public void InvalidConstantValidationThrows_Works() [Fact] public void DefaultRoundtrip_Works() { - var constant = new TextOverlayTransformationRadiusUnionMember1(); + var constant = new TextOverlayTransformationRadiusMax(); string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -669,12 +667,12 @@ public void DefaultRoundtrip_Works() [Fact] public void ValidConstantRoundtrip_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.SerializeToElement("max"), ModelBase.SerializerOptions ); string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -685,12 +683,12 @@ public void ValidConstantRoundtrip_Works() [Fact] public void InvalidConstantRoundtrip_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); diff --git a/src/Imagekit.Tests/Models/TransformationTest.cs b/src/Imagekit.Tests/Models/TransformationTest.cs index 2a6e7889..06b0ed93 100644 --- a/src/Imagekit.Tests/Models/TransformationTest.cs +++ b/src/Imagekit.Tests/Models/TransformationTest.cs @@ -14,7 +14,7 @@ public void FieldRoundtrip_Works() var model = new Transformation { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -40,7 +40,7 @@ public void FieldRoundtrip_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -81,7 +81,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -94,12 +94,12 @@ public void FieldRoundtrip_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -110,7 +110,7 @@ public void FieldRoundtrip_Works() }; string expectedAIChangeBackground = "aiChangeBackground"; - AIDropShadow expectedAIDropShadow = new AIDropShadowUnionMember0(); + AIDropShadow expectedAIDropShadow = new AIDropShadowDefault(); string expectedAIEdit = "aiEdit"; ApiEnum expectedAIRemoveBackground = AIRemoveBackground.True; ApiEnum expectedAIRemoveBackgroundExternal = @@ -137,7 +137,7 @@ public void FieldRoundtrip_Works() ApiEnum expectedFlip = TransformationFlip.H; string expectedFocus = "center"; ApiEnum expectedFormat = Format.Auto; - TransformationGradient expectedGradient = new TransformationGradientUnionMember0(); + TransformationGradient expectedGradient = new TransformationGradientDefault(); ApiEnum expectedGrayscale = Grayscale.True; TransformationHeight expectedHeight = 200; bool expectedLossless = true; @@ -178,7 +178,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -191,15 +191,15 @@ public void FieldRoundtrip_Works() TransformationRadius expectedRadius = 20; string expectedRaw = "raw"; TransformationRotation expectedRotation = 90; - Shadow expectedShadow = new ShadowUnionMember0(); - Sharpen expectedSharpen = new SharpenUnionMember0(); + Shadow expectedShadow = new ShadowDefault(); + Sharpen expectedSharpen = new SharpenDefault(); StartOffset expectedStartOffset = 0; List> expectedStreamingResolutions = [ StreamingResolution.V240, ]; - Trim expectedTrim = new TrimUnionMember0(); - UnsharpMask expectedUnsharpMask = new UnsharpMaskUnionMember0(); + Trim expectedTrim = new TrimDefault(); + UnsharpMask expectedUnsharpMask = new UnsharpMaskDefault(); ApiEnum expectedVideoCodec = VideoCodec.H264; TransformationWidth expectedWidth = 300; TransformationX expectedX = 0; @@ -276,7 +276,7 @@ public void SerializationRoundtrip_Works() var model = new Transformation { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -302,7 +302,7 @@ public void SerializationRoundtrip_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -343,7 +343,7 @@ public void SerializationRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -356,12 +356,12 @@ public void SerializationRoundtrip_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -386,7 +386,7 @@ public void FieldRoundtripThroughSerialization_Works() var model = new Transformation { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -412,7 +412,7 @@ public void FieldRoundtripThroughSerialization_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -453,7 +453,7 @@ public void FieldRoundtripThroughSerialization_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -466,12 +466,12 @@ public void FieldRoundtripThroughSerialization_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -489,7 +489,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.NotNull(deserialized); string expectedAIChangeBackground = "aiChangeBackground"; - AIDropShadow expectedAIDropShadow = new AIDropShadowUnionMember0(); + AIDropShadow expectedAIDropShadow = new AIDropShadowDefault(); string expectedAIEdit = "aiEdit"; ApiEnum expectedAIRemoveBackground = AIRemoveBackground.True; ApiEnum expectedAIRemoveBackgroundExternal = @@ -516,7 +516,7 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum expectedFlip = TransformationFlip.H; string expectedFocus = "center"; ApiEnum expectedFormat = Format.Auto; - TransformationGradient expectedGradient = new TransformationGradientUnionMember0(); + TransformationGradient expectedGradient = new TransformationGradientDefault(); ApiEnum expectedGrayscale = Grayscale.True; TransformationHeight expectedHeight = 200; bool expectedLossless = true; @@ -557,7 +557,7 @@ public void FieldRoundtripThroughSerialization_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -570,15 +570,15 @@ public void FieldRoundtripThroughSerialization_Works() TransformationRadius expectedRadius = 20; string expectedRaw = "raw"; TransformationRotation expectedRotation = 90; - Shadow expectedShadow = new ShadowUnionMember0(); - Sharpen expectedSharpen = new SharpenUnionMember0(); + Shadow expectedShadow = new ShadowDefault(); + Sharpen expectedSharpen = new SharpenDefault(); StartOffset expectedStartOffset = 0; List> expectedStreamingResolutions = [ StreamingResolution.V240, ]; - Trim expectedTrim = new TrimUnionMember0(); - UnsharpMask expectedUnsharpMask = new UnsharpMaskUnionMember0(); + Trim expectedTrim = new TrimDefault(); + UnsharpMask expectedUnsharpMask = new UnsharpMaskDefault(); ApiEnum expectedVideoCodec = VideoCodec.H264; TransformationWidth expectedWidth = 300; TransformationX expectedX = 0; @@ -655,7 +655,7 @@ public void Validation_Works() var model = new Transformation { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -681,7 +681,7 @@ public void Validation_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -722,7 +722,7 @@ public void Validation_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -735,12 +735,12 @@ public void Validation_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -1125,7 +1125,7 @@ public void CopyConstructor_Works() var model = new Transformation { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -1151,7 +1151,7 @@ public void CopyConstructor_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -1192,7 +1192,7 @@ public void CopyConstructor_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -1205,12 +1205,12 @@ public void CopyConstructor_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -1229,9 +1229,9 @@ public void CopyConstructor_Works() public class AIDropShadowTest : TestBase { [Fact] - public void TrueValidationWorks() + public void DefaultValidationWorks() { - AIDropShadow value = new AIDropShadowUnionMember0(); + AIDropShadow value = new AIDropShadowDefault(); value.Validate(); } @@ -1243,9 +1243,9 @@ public void StringValidationWorks() } [Fact] - public void TrueSerializationRoundtripWorks() + public void DefaultSerializationRoundtripWorks() { - AIDropShadow value = new AIDropShadowUnionMember0(); + AIDropShadow value = new AIDropShadowDefault(); string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize( element, @@ -1269,19 +1269,19 @@ public void StringSerializationRoundtripWorks() } } -public class AIDropShadowUnionMember0Test : TestBase +public class AIDropShadowDefaultTest : TestBase { [Fact] public void DefaultValidation_Works() { - var constant = new AIDropShadowUnionMember0(); + var constant = new AIDropShadowDefault(); constant.Validate(); } [Fact] public void ValidConstantValidation_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.SerializeToElement(true), ModelBase.SerializerOptions ); @@ -1293,7 +1293,7 @@ public void ValidConstantValidation_Works() [Fact] public void InvalidConstantValidationThrows_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); @@ -1305,9 +1305,9 @@ public void InvalidConstantValidationThrows_Works() [Fact] public void DefaultRoundtrip_Works() { - var constant = new AIDropShadowUnionMember0(); + var constant = new AIDropShadowDefault(); string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -1318,12 +1318,12 @@ public void DefaultRoundtrip_Works() [Fact] public void ValidConstantRoundtrip_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.SerializeToElement(true), ModelBase.SerializerOptions ); string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -1334,12 +1334,12 @@ public void ValidConstantRoundtrip_Works() [Fact] public void InvalidConstantRoundtrip_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -2144,9 +2144,9 @@ public void InvalidEnumSerializationRoundtrip_Works() public class TransformationGradientTest : TestBase { [Fact] - public void TrueValidationWorks() + public void DefaultValidationWorks() { - TransformationGradient value = new TransformationGradientUnionMember0(); + TransformationGradient value = new TransformationGradientDefault(); value.Validate(); } @@ -2158,9 +2158,9 @@ public void StringValidationWorks() } [Fact] - public void TrueSerializationRoundtripWorks() + public void DefaultSerializationRoundtripWorks() { - TransformationGradient value = new TransformationGradientUnionMember0(); + TransformationGradient value = new TransformationGradientDefault(); string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize( element, @@ -2184,19 +2184,19 @@ public void StringSerializationRoundtripWorks() } } -public class TransformationGradientUnionMember0Test : TestBase +public class TransformationGradientDefaultTest : TestBase { [Fact] public void DefaultValidation_Works() { - var constant = new TransformationGradientUnionMember0(); + var constant = new TransformationGradientDefault(); constant.Validate(); } [Fact] public void ValidConstantValidation_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.SerializeToElement(true), ModelBase.SerializerOptions ); @@ -2208,7 +2208,7 @@ public void ValidConstantValidation_Works() [Fact] public void InvalidConstantValidationThrows_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); @@ -2220,9 +2220,9 @@ public void InvalidConstantValidationThrows_Works() [Fact] public void DefaultRoundtrip_Works() { - var constant = new TransformationGradientUnionMember0(); + var constant = new TransformationGradientDefault(); string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -2233,12 +2233,12 @@ public void DefaultRoundtrip_Works() [Fact] public void ValidConstantRoundtrip_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.SerializeToElement(true), ModelBase.SerializerOptions ); string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -2249,12 +2249,12 @@ public void ValidConstantRoundtrip_Works() [Fact] public void InvalidConstantRoundtrip_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -2411,7 +2411,7 @@ public void DoubleValidationWorks() [Fact] public void MaxValidationWorks() { - TransformationRadius value = new TransformationRadiusUnionMember1(); + TransformationRadius value = new TransformationRadiusMax(); value.Validate(); } @@ -2438,7 +2438,7 @@ public void DoubleSerializationRoundtripWorks() [Fact] public void MaxSerializationRoundtripWorks() { - TransformationRadius value = new TransformationRadiusUnionMember1(); + TransformationRadius value = new TransformationRadiusMax(); string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize( element, @@ -2462,19 +2462,19 @@ public void StringSerializationRoundtripWorks() } } -public class TransformationRadiusUnionMember1Test : TestBase +public class TransformationRadiusMaxTest : TestBase { [Fact] public void DefaultValidation_Works() { - var constant = new TransformationRadiusUnionMember1(); + var constant = new TransformationRadiusMax(); constant.Validate(); } [Fact] public void ValidConstantValidation_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.SerializeToElement("max"), ModelBase.SerializerOptions ); @@ -2486,7 +2486,7 @@ public void ValidConstantValidation_Works() [Fact] public void InvalidConstantValidationThrows_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); @@ -2498,9 +2498,9 @@ public void InvalidConstantValidationThrows_Works() [Fact] public void DefaultRoundtrip_Works() { - var constant = new TransformationRadiusUnionMember1(); + var constant = new TransformationRadiusMax(); string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -2511,12 +2511,12 @@ public void DefaultRoundtrip_Works() [Fact] public void ValidConstantRoundtrip_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.SerializeToElement("max"), ModelBase.SerializerOptions ); string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -2527,12 +2527,12 @@ public void ValidConstantRoundtrip_Works() [Fact] public void InvalidConstantRoundtrip_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -2587,9 +2587,9 @@ public void StringSerializationRoundtripWorks() public class ShadowTest : TestBase { [Fact] - public void TrueValidationWorks() + public void DefaultValidationWorks() { - Shadow value = new ShadowUnionMember0(); + Shadow value = new ShadowDefault(); value.Validate(); } @@ -2601,9 +2601,9 @@ public void StringValidationWorks() } [Fact] - public void TrueSerializationRoundtripWorks() + public void DefaultSerializationRoundtripWorks() { - Shadow value = new ShadowUnionMember0(); + Shadow value = new ShadowDefault(); string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -2621,19 +2621,19 @@ public void StringSerializationRoundtripWorks() } } -public class ShadowUnionMember0Test : TestBase +public class ShadowDefaultTest : TestBase { [Fact] public void DefaultValidation_Works() { - var constant = new ShadowUnionMember0(); + var constant = new ShadowDefault(); constant.Validate(); } [Fact] public void ValidConstantValidation_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.SerializeToElement(true), ModelBase.SerializerOptions ); @@ -2645,7 +2645,7 @@ public void ValidConstantValidation_Works() [Fact] public void InvalidConstantValidationThrows_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); @@ -2657,9 +2657,9 @@ public void InvalidConstantValidationThrows_Works() [Fact] public void DefaultRoundtrip_Works() { - var constant = new ShadowUnionMember0(); + var constant = new ShadowDefault(); string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -2670,12 +2670,12 @@ public void DefaultRoundtrip_Works() [Fact] public void ValidConstantRoundtrip_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.SerializeToElement(true), ModelBase.SerializerOptions ); string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -2686,12 +2686,12 @@ public void ValidConstantRoundtrip_Works() [Fact] public void InvalidConstantRoundtrip_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -2703,9 +2703,9 @@ public void InvalidConstantRoundtrip_Works() public class SharpenTest : TestBase { [Fact] - public void TrueValidationWorks() + public void DefaultValidationWorks() { - Sharpen value = new SharpenUnionMember0(); + Sharpen value = new SharpenDefault(); value.Validate(); } @@ -2717,9 +2717,9 @@ public void DoubleValidationWorks() } [Fact] - public void TrueSerializationRoundtripWorks() + public void DefaultSerializationRoundtripWorks() { - Sharpen value = new SharpenUnionMember0(); + Sharpen value = new SharpenDefault(); string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize( element, @@ -2743,19 +2743,19 @@ public void DoubleSerializationRoundtripWorks() } } -public class SharpenUnionMember0Test : TestBase +public class SharpenDefaultTest : TestBase { [Fact] public void DefaultValidation_Works() { - var constant = new SharpenUnionMember0(); + var constant = new SharpenDefault(); constant.Validate(); } [Fact] public void ValidConstantValidation_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.SerializeToElement(true), ModelBase.SerializerOptions ); @@ -2767,7 +2767,7 @@ public void ValidConstantValidation_Works() [Fact] public void InvalidConstantValidationThrows_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); @@ -2779,9 +2779,9 @@ public void InvalidConstantValidationThrows_Works() [Fact] public void DefaultRoundtrip_Works() { - var constant = new SharpenUnionMember0(); + var constant = new SharpenDefault(); string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -2792,12 +2792,12 @@ public void DefaultRoundtrip_Works() [Fact] public void ValidConstantRoundtrip_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.SerializeToElement(true), ModelBase.SerializerOptions ); string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -2808,12 +2808,12 @@ public void ValidConstantRoundtrip_Works() [Fact] public void InvalidConstantRoundtrip_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -2868,9 +2868,9 @@ public void StringSerializationRoundtripWorks() public class TrimTest : TestBase { [Fact] - public void TrueValidationWorks() + public void DefaultValidationWorks() { - Trim value = new TrimUnionMember0(); + Trim value = new TrimDefault(); value.Validate(); } @@ -2882,9 +2882,9 @@ public void DoubleValidationWorks() } [Fact] - public void TrueSerializationRoundtripWorks() + public void DefaultSerializationRoundtripWorks() { - Trim value = new TrimUnionMember0(); + Trim value = new TrimDefault(); string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -2902,19 +2902,19 @@ public void DoubleSerializationRoundtripWorks() } } -public class TrimUnionMember0Test : TestBase +public class TrimDefaultTest : TestBase { [Fact] public void DefaultValidation_Works() { - var constant = new TrimUnionMember0(); + var constant = new TrimDefault(); constant.Validate(); } [Fact] public void ValidConstantValidation_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.SerializeToElement(true), ModelBase.SerializerOptions ); @@ -2926,7 +2926,7 @@ public void ValidConstantValidation_Works() [Fact] public void InvalidConstantValidationThrows_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); @@ -2938,9 +2938,9 @@ public void InvalidConstantValidationThrows_Works() [Fact] public void DefaultRoundtrip_Works() { - var constant = new TrimUnionMember0(); + var constant = new TrimDefault(); string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -2951,12 +2951,12 @@ public void DefaultRoundtrip_Works() [Fact] public void ValidConstantRoundtrip_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.SerializeToElement(true), ModelBase.SerializerOptions ); string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -2967,12 +2967,12 @@ public void ValidConstantRoundtrip_Works() [Fact] public void InvalidConstantRoundtrip_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -2984,9 +2984,9 @@ public void InvalidConstantRoundtrip_Works() public class UnsharpMaskTest : TestBase { [Fact] - public void TrueValidationWorks() + public void DefaultValidationWorks() { - UnsharpMask value = new UnsharpMaskUnionMember0(); + UnsharpMask value = new UnsharpMaskDefault(); value.Validate(); } @@ -2998,9 +2998,9 @@ public void StringValidationWorks() } [Fact] - public void TrueSerializationRoundtripWorks() + public void DefaultSerializationRoundtripWorks() { - UnsharpMask value = new UnsharpMaskUnionMember0(); + UnsharpMask value = new UnsharpMaskDefault(); string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize( element, @@ -3024,19 +3024,19 @@ public void StringSerializationRoundtripWorks() } } -public class UnsharpMaskUnionMember0Test : TestBase +public class UnsharpMaskDefaultTest : TestBase { [Fact] public void DefaultValidation_Works() { - var constant = new UnsharpMaskUnionMember0(); + var constant = new UnsharpMaskDefault(); constant.Validate(); } [Fact] public void ValidConstantValidation_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.SerializeToElement(true), ModelBase.SerializerOptions ); @@ -3048,7 +3048,7 @@ public void ValidConstantValidation_Works() [Fact] public void InvalidConstantValidationThrows_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); @@ -3060,9 +3060,9 @@ public void InvalidConstantValidationThrows_Works() [Fact] public void DefaultRoundtrip_Works() { - var constant = new UnsharpMaskUnionMember0(); + var constant = new UnsharpMaskDefault(); string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -3073,12 +3073,12 @@ public void DefaultRoundtrip_Works() [Fact] public void ValidConstantRoundtrip_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.SerializeToElement(true), ModelBase.SerializerOptions ); string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -3089,12 +3089,12 @@ public void ValidConstantRoundtrip_Works() [Fact] public void InvalidConstantRoundtrip_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); diff --git a/src/Imagekit.Tests/Models/VideoOverlayTest.cs b/src/Imagekit.Tests/Models/VideoOverlayTest.cs index 4f5c6e57..0219bb68 100644 --- a/src/Imagekit.Tests/Models/VideoOverlayTest.cs +++ b/src/Imagekit.Tests/Models/VideoOverlayTest.cs @@ -36,7 +36,7 @@ public void FieldRoundtrip_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -62,7 +62,7 @@ public void FieldRoundtrip_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -103,7 +103,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -116,12 +116,12 @@ public void FieldRoundtrip_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -158,7 +158,7 @@ public void FieldRoundtrip_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -184,7 +184,7 @@ public void FieldRoundtrip_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -225,7 +225,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -238,12 +238,12 @@ public void FieldRoundtrip_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -296,7 +296,7 @@ public void SerializationRoundtrip_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -322,7 +322,7 @@ public void SerializationRoundtrip_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -363,7 +363,7 @@ public void SerializationRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -376,12 +376,12 @@ public void SerializationRoundtrip_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -430,7 +430,7 @@ public void FieldRoundtripThroughSerialization_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -456,7 +456,7 @@ public void FieldRoundtripThroughSerialization_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -497,7 +497,7 @@ public void FieldRoundtripThroughSerialization_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -510,12 +510,12 @@ public void FieldRoundtripThroughSerialization_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -559,7 +559,7 @@ public void FieldRoundtripThroughSerialization_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -585,7 +585,7 @@ public void FieldRoundtripThroughSerialization_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -626,7 +626,7 @@ public void FieldRoundtripThroughSerialization_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -639,12 +639,12 @@ public void FieldRoundtripThroughSerialization_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -697,7 +697,7 @@ public void Validation_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -723,7 +723,7 @@ public void Validation_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -764,7 +764,7 @@ public void Validation_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -777,12 +777,12 @@ public void Validation_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -895,7 +895,7 @@ public void CopyConstructor_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -921,7 +921,7 @@ public void CopyConstructor_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -962,7 +962,7 @@ public void CopyConstructor_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -975,12 +975,12 @@ public void CopyConstructor_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -1012,7 +1012,7 @@ public void FieldRoundtrip_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -1038,7 +1038,7 @@ public void FieldRoundtrip_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -1079,7 +1079,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -1092,12 +1092,12 @@ public void FieldRoundtrip_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -1118,7 +1118,7 @@ public void FieldRoundtrip_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -1144,7 +1144,7 @@ public void FieldRoundtrip_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -1185,7 +1185,7 @@ public void FieldRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -1198,12 +1198,12 @@ public void FieldRoundtrip_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -1237,7 +1237,7 @@ public void SerializationRoundtrip_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -1263,7 +1263,7 @@ public void SerializationRoundtrip_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -1304,7 +1304,7 @@ public void SerializationRoundtrip_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -1317,12 +1317,12 @@ public void SerializationRoundtrip_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -1355,7 +1355,7 @@ public void FieldRoundtripThroughSerialization_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -1381,7 +1381,7 @@ public void FieldRoundtripThroughSerialization_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -1422,7 +1422,7 @@ public void FieldRoundtripThroughSerialization_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -1435,12 +1435,12 @@ public void FieldRoundtripThroughSerialization_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -1468,7 +1468,7 @@ public void FieldRoundtripThroughSerialization_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -1494,7 +1494,7 @@ public void FieldRoundtripThroughSerialization_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -1535,7 +1535,7 @@ public void FieldRoundtripThroughSerialization_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -1548,12 +1548,12 @@ public void FieldRoundtripThroughSerialization_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -1587,7 +1587,7 @@ public void Validation_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -1613,7 +1613,7 @@ public void Validation_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -1654,7 +1654,7 @@ public void Validation_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -1667,12 +1667,12 @@ public void Validation_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, @@ -1751,7 +1751,7 @@ public void CopyConstructor_Works() new() { AIChangeBackground = "aiChangeBackground", - AIDropShadow = new AIDropShadowUnionMember0(), + AIDropShadow = new AIDropShadowDefault(), AIEdit = "aiEdit", AIRemoveBackground = AIRemoveBackground.True, AIRemoveBackgroundExternal = AIRemoveBackgroundExternal.True, @@ -1777,7 +1777,7 @@ public void CopyConstructor_Works() Flip = TransformationFlip.H, Focus = "center", Format = Format.Auto, - Gradient = new TransformationGradientUnionMember0(), + Gradient = new TransformationGradientDefault(), Grayscale = Grayscale.True, Height = 200, Lossless = true, @@ -1818,7 +1818,7 @@ public void CopyConstructor_Works() InnerAlignment = InnerAlignment.Left, LineHeight = 0, Padding = 0, - Radius = new TextOverlayTransformationRadiusUnionMember1(), + Radius = new TextOverlayTransformationRadiusMax(), Rotation = 0, Typography = "typography", Width = 0, @@ -1831,12 +1831,12 @@ public void CopyConstructor_Works() Radius = 20, Raw = "raw", Rotation = 90, - Shadow = new ShadowUnionMember0(), - Sharpen = new SharpenUnionMember0(), + Shadow = new ShadowDefault(), + Sharpen = new SharpenDefault(), StartOffset = 0, StreamingResolutions = [StreamingResolution.V240], - Trim = new TrimUnionMember0(), - UnsharpMask = new UnsharpMaskUnionMember0(), + Trim = new TrimDefault(), + UnsharpMask = new UnsharpMaskDefault(), VideoCodec = VideoCodec.H264, Width = 300, X = 0, diff --git a/src/Imagekit/Models/SolidColorOverlayTransformation.cs b/src/Imagekit/Models/SolidColorOverlayTransformation.cs index a4ff0bb5..a52d08a6 100644 --- a/src/Imagekit/Models/SolidColorOverlayTransformation.cs +++ b/src/Imagekit/Models/SolidColorOverlayTransformation.cs @@ -228,7 +228,7 @@ public JsonElement Json } } - public Gradient(UnionMember0 value, JsonElement? element = null) + public Gradient(Default value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -247,22 +247,22 @@ public Gradient(JsonElement element) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickTrue(out var value)) { - /// // `value` is of type `UnionMember0` + /// if (instance.TryPickDefault(out var value)) { + /// // `value` is of type `Default` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickTrue([NotNullWhen(true)] out UnionMember0? value) + public bool TryPickDefault([NotNullWhen(true)] out Default? value) { - value = this.Value as UnionMember0; + value = this.Value as Default; return value != null; } @@ -301,18 +301,18 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// /// instance.Switch( - /// (UnionMember0 value) => {...}, + /// (Default value) => {...}, /// (string value) => {...} /// ); /// /// /// - public void Switch(Action true_, Action @string) + public void Switch(Action default_, Action @string) { switch (this.Value) { - case UnionMember0 value: - true_(value); + case Default value: + default_(value); break; case string value: @string(value); @@ -339,17 +339,17 @@ public void Switch(Action true_, Action @string) /// /// /// var result = instance.Match( - /// (UnionMember0 value) => {...}, + /// (Default value) => {...}, /// (string value) => {...} /// ); /// /// /// - public T Match(Func true_, Func @string) + public T Match(Func default_, Func @string) { return this.Value switch { - UnionMember0 value => true_(value), + Default value => default_(value), string value => @string(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of Gradient" @@ -357,7 +357,7 @@ public T Match(Func true_, Func @string) }; } - public static implicit operator Gradient(UnionMember0 value) => new(value); + public static implicit operator Gradient(Default value) => new(value); public static implicit operator Gradient(string value) => new(value); @@ -377,7 +377,7 @@ public override void Validate() { throw new ImageKitInvalidDataException("Data did not match any variant of Gradient"); } - this.Switch((true_) => true_.Validate(), (_) => { }); + this.Switch((default_) => default_.Validate(), (_) => { }); } public virtual bool Equals(Gradient? other) => @@ -400,7 +400,7 @@ int VariantIndex() { return this.Value switch { - UnionMember0 _ => 0, + Default _ => 0, string _ => 1, _ => -1, }; @@ -418,7 +418,7 @@ JsonSerializerOptions options var element = JsonSerializer.Deserialize(ref reader, options); try { - var deserialized = JsonSerializer.Deserialize(element, options); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -452,17 +452,17 @@ public override void Write(Utf8JsonWriter writer, Gradient value, JsonSerializer } } -[JsonConverter(typeof(UnionMember0Converter))] -public record class UnionMember0 +[JsonConverter(typeof(DefaultConverter))] +public record class Default { public JsonElement Element { get; private init; } - public UnionMember0() + public Default() { Element = JsonSerializer.SerializeToElement(true); } - internal UnionMember0(JsonElement element) + internal Default(JsonElement element) { Element = element; } @@ -478,9 +478,9 @@ internal UnionMember0(JsonElement element) /// public void Validate() { - if (this != new UnionMember0()) + if (this != new Default()) { - throw new ImageKitInvalidDataException("Invalid value given for 'UnionMember0'"); + throw new ImageKitInvalidDataException("Invalid value given for 'Default'"); } } @@ -489,7 +489,7 @@ public override int GetHashCode() return 0; } - public virtual bool Equals(UnionMember0? other) + public virtual bool Equals(Default? other) { if (other == null) { @@ -500,9 +500,9 @@ public virtual bool Equals(UnionMember0? other) } } -class UnionMember0Converter : JsonConverter +class DefaultConverter : JsonConverter { - public override UnionMember0? Read( + public override Default? Read( ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options @@ -511,11 +511,7 @@ JsonSerializerOptions options return new(JsonSerializer.Deserialize(ref reader, options)); } - public override void Write( - Utf8JsonWriter writer, - UnionMember0 value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Default value, JsonSerializerOptions options) { JsonSerializer.Serialize(writer, value.Element, options); } @@ -788,7 +784,7 @@ public Radius(double value, JsonElement? element = null) this._element = element; } - public Radius(UnionMember1 value, JsonElement? element = null) + public Radius(Max value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -828,22 +824,22 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickMax(out var value)) { - /// // `value` is of type `UnionMember1` + /// // `value` is of type `Max` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickMax([NotNullWhen(true)] out UnionMember1? value) + public bool TryPickMax([NotNullWhen(true)] out Max? value) { - value = this.Value as UnionMember1; + value = this.Value as Max; return value != null; } @@ -883,20 +879,20 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// instance.Switch( /// (double value) => {...}, - /// (UnionMember1 value) => {...}, + /// (Max value) => {...}, /// (string value) => {...} /// ); /// /// /// - public void Switch(Action @double, Action max, Action @string) + public void Switch(Action @double, Action max, Action @string) { switch (this.Value) { case double value: @double(value); break; - case UnionMember1 value: + case Max value: max(value); break; case string value: @@ -923,18 +919,18 @@ public void Switch(Action @double, Action max, Action /// var result = instance.Match( /// (double value) => {...}, - /// (UnionMember1 value) => {...}, + /// (Max value) => {...}, /// (string value) => {...} /// ); /// /// /// - public T Match(Func @double, Func max, Func @string) + public T Match(Func @double, Func max, Func @string) { return this.Value switch { double value => @double(value), - UnionMember1 value => max(value), + Max value => max(value), string value => @string(value), _ => throw new ImageKitInvalidDataException("Data did not match any variant of Radius"), }; @@ -942,7 +938,7 @@ public T Match(Func @double, Func max, Func new(value); - public static implicit operator Radius(UnionMember1 value) => new(value); + public static implicit operator Radius(Max value) => new(value); public static implicit operator Radius(string value) => new(value); @@ -986,7 +982,7 @@ int VariantIndex() return this.Value switch { double _ => 0, - UnionMember1 _ => 1, + Max _ => 1, string _ => 2, _ => -1, }; @@ -1004,7 +1000,7 @@ JsonSerializerOptions options var element = JsonSerializer.Deserialize(ref reader, options); try { - var deserialized = JsonSerializer.Deserialize(element, options); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -1047,17 +1043,17 @@ public override void Write(Utf8JsonWriter writer, Radius value, JsonSerializerOp } } -[JsonConverter(typeof(UnionMember1Converter))] -public record class UnionMember1 +[JsonConverter(typeof(MaxConverter))] +public record class Max { public JsonElement Element { get; private init; } - public UnionMember1() + public Max() { Element = JsonSerializer.SerializeToElement("max"); } - internal UnionMember1(JsonElement element) + internal Max(JsonElement element) { Element = element; } @@ -1073,9 +1069,9 @@ internal UnionMember1(JsonElement element) /// public void Validate() { - if (this != new UnionMember1()) + if (this != new Max()) { - throw new ImageKitInvalidDataException("Invalid value given for 'UnionMember1'"); + throw new ImageKitInvalidDataException("Invalid value given for 'Max'"); } } @@ -1084,7 +1080,7 @@ public override int GetHashCode() return 0; } - public virtual bool Equals(UnionMember1? other) + public virtual bool Equals(Max? other) { if (other == null) { @@ -1095,9 +1091,9 @@ public virtual bool Equals(UnionMember1? other) } } -class UnionMember1Converter : JsonConverter +class MaxConverter : JsonConverter { - public override UnionMember1? Read( + public override Max? Read( ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options @@ -1106,11 +1102,7 @@ JsonSerializerOptions options return new(JsonSerializer.Deserialize(ref reader, options)); } - public override void Write( - Utf8JsonWriter writer, - UnionMember1 value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Max value, JsonSerializerOptions options) { JsonSerializer.Serialize(writer, value.Element, options); } diff --git a/src/Imagekit/Models/TextOverlayTransformation.cs b/src/Imagekit/Models/TextOverlayTransformation.cs index b54e90d5..42dca347 100644 --- a/src/Imagekit/Models/TextOverlayTransformation.cs +++ b/src/Imagekit/Models/TextOverlayTransformation.cs @@ -1225,7 +1225,7 @@ public TextOverlayTransformationRadius(double value, JsonElement? element = null } public TextOverlayTransformationRadius( - TextOverlayTransformationRadiusUnionMember1 value, + TextOverlayTransformationRadiusMax value, JsonElement? element = null ) { @@ -1267,24 +1267,22 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickMax(out var value)) { - /// // `value` is of type `TextOverlayTransformationRadiusUnionMember1` + /// // `value` is of type `TextOverlayTransformationRadiusMax` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickMax( - [NotNullWhen(true)] out TextOverlayTransformationRadiusUnionMember1? value - ) + public bool TryPickMax([NotNullWhen(true)] out TextOverlayTransformationRadiusMax? value) { - value = this.Value as TextOverlayTransformationRadiusUnionMember1; + value = this.Value as TextOverlayTransformationRadiusMax; return value != null; } @@ -1324,7 +1322,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// instance.Switch( /// (double value) => {...}, - /// (TextOverlayTransformationRadiusUnionMember1 value) => {...}, + /// (TextOverlayTransformationRadiusMax value) => {...}, /// (string value) => {...} /// ); /// @@ -1332,7 +1330,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// public void Switch( Action @double, - Action max, + Action max, Action @string ) { @@ -1341,7 +1339,7 @@ Action @string case double value: @double(value); break; - case TextOverlayTransformationRadiusUnionMember1 value: + case TextOverlayTransformationRadiusMax value: max(value); break; case string value: @@ -1370,7 +1368,7 @@ Action @string /// /// var result = instance.Match( /// (double value) => {...}, - /// (TextOverlayTransformationRadiusUnionMember1 value) => {...}, + /// (TextOverlayTransformationRadiusMax value) => {...}, /// (string value) => {...} /// ); /// @@ -1378,14 +1376,14 @@ Action @string /// public T Match( Func @double, - Func max, + Func max, Func @string ) { return this.Value switch { double value => @double(value), - TextOverlayTransformationRadiusUnionMember1 value => max(value), + TextOverlayTransformationRadiusMax value => max(value), string value => @string(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of TextOverlayTransformationRadius" @@ -1396,7 +1394,7 @@ Func @string public static implicit operator TextOverlayTransformationRadius(double value) => new(value); public static implicit operator TextOverlayTransformationRadius( - TextOverlayTransformationRadiusUnionMember1 value + TextOverlayTransformationRadiusMax value ) => new(value); public static implicit operator TextOverlayTransformationRadius(string value) => new(value); @@ -1443,7 +1441,7 @@ int VariantIndex() return this.Value switch { double _ => 0, - TextOverlayTransformationRadiusUnionMember1 _ => 1, + TextOverlayTransformationRadiusMax _ => 1, string _ => 2, _ => -1, }; @@ -1462,11 +1460,10 @@ JsonSerializerOptions options var element = JsonSerializer.Deserialize(ref reader, options); try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -1513,17 +1510,17 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(TextOverlayTransformationRadiusUnionMember1Converter))] -public record class TextOverlayTransformationRadiusUnionMember1 +[JsonConverter(typeof(TextOverlayTransformationRadiusMaxConverter))] +public record class TextOverlayTransformationRadiusMax { public JsonElement Element { get; private init; } - public TextOverlayTransformationRadiusUnionMember1() + public TextOverlayTransformationRadiusMax() { Element = JsonSerializer.SerializeToElement("max"); } - internal TextOverlayTransformationRadiusUnionMember1(JsonElement element) + internal TextOverlayTransformationRadiusMax(JsonElement element) { Element = element; } @@ -1539,10 +1536,10 @@ internal TextOverlayTransformationRadiusUnionMember1(JsonElement element) /// public void Validate() { - if (this != new TextOverlayTransformationRadiusUnionMember1()) + if (this != new TextOverlayTransformationRadiusMax()) { throw new ImageKitInvalidDataException( - "Invalid value given for 'TextOverlayTransformationRadiusUnionMember1'" + "Invalid value given for 'TextOverlayTransformationRadiusMax'" ); } } @@ -1552,7 +1549,7 @@ public override int GetHashCode() return 0; } - public virtual bool Equals(TextOverlayTransformationRadiusUnionMember1? other) + public virtual bool Equals(TextOverlayTransformationRadiusMax? other) { if (other == null) { @@ -1563,10 +1560,10 @@ public virtual bool Equals(TextOverlayTransformationRadiusUnionMember1? other) } } -class TextOverlayTransformationRadiusUnionMember1Converter - : JsonConverter +class TextOverlayTransformationRadiusMaxConverter + : JsonConverter { - public override TextOverlayTransformationRadiusUnionMember1? Read( + public override TextOverlayTransformationRadiusMax? Read( ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options @@ -1577,7 +1574,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - TextOverlayTransformationRadiusUnionMember1 value, + TextOverlayTransformationRadiusMax value, JsonSerializerOptions options ) { diff --git a/src/Imagekit/Models/Transformation.cs b/src/Imagekit/Models/Transformation.cs index 825715e1..2eed1395 100644 --- a/src/Imagekit/Models/Transformation.cs +++ b/src/Imagekit/Models/Transformation.cs @@ -1424,7 +1424,7 @@ public JsonElement Json } } - public AIDropShadow(AIDropShadowUnionMember0 value, JsonElement? element = null) + public AIDropShadow(AIDropShadowDefault value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -1443,22 +1443,22 @@ public AIDropShadow(JsonElement element) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickTrue(out var value)) { - /// // `value` is of type `AIDropShadowUnionMember0` + /// if (instance.TryPickDefault(out var value)) { + /// // `value` is of type `AIDropShadowDefault` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickTrue([NotNullWhen(true)] out AIDropShadowUnionMember0? value) + public bool TryPickDefault([NotNullWhen(true)] out AIDropShadowDefault? value) { - value = this.Value as AIDropShadowUnionMember0; + value = this.Value as AIDropShadowDefault; return value != null; } @@ -1497,18 +1497,18 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// /// instance.Switch( - /// (AIDropShadowUnionMember0 value) => {...}, + /// (AIDropShadowDefault value) => {...}, /// (string value) => {...} /// ); /// /// /// - public void Switch(Action true_, Action @string) + public void Switch(Action default_, Action @string) { switch (this.Value) { - case AIDropShadowUnionMember0 value: - true_(value); + case AIDropShadowDefault value: + default_(value); break; case string value: @string(value); @@ -1535,17 +1535,17 @@ public void Switch(Action true_, Action @strin /// /// /// var result = instance.Match( - /// (AIDropShadowUnionMember0 value) => {...}, + /// (AIDropShadowDefault value) => {...}, /// (string value) => {...} /// ); /// /// /// - public T Match(Func true_, Func @string) + public T Match(Func default_, Func @string) { return this.Value switch { - AIDropShadowUnionMember0 value => true_(value), + AIDropShadowDefault value => default_(value), string value => @string(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of AIDropShadow" @@ -1553,7 +1553,7 @@ public T Match(Func true_, Func @stri }; } - public static implicit operator AIDropShadow(AIDropShadowUnionMember0 value) => new(value); + public static implicit operator AIDropShadow(AIDropShadowDefault value) => new(value); public static implicit operator AIDropShadow(string value) => new(value); @@ -1575,7 +1575,7 @@ public override void Validate() "Data did not match any variant of AIDropShadow" ); } - this.Switch((true_) => true_.Validate(), (_) => { }); + this.Switch((default_) => default_.Validate(), (_) => { }); } public virtual bool Equals(AIDropShadow? other) => @@ -1598,7 +1598,7 @@ int VariantIndex() { return this.Value switch { - AIDropShadowUnionMember0 _ => 0, + AIDropShadowDefault _ => 0, string _ => 1, _ => -1, }; @@ -1616,10 +1616,7 @@ JsonSerializerOptions options var element = JsonSerializer.Deserialize(ref reader, options); try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -1657,17 +1654,17 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(AIDropShadowUnionMember0Converter))] -public record class AIDropShadowUnionMember0 +[JsonConverter(typeof(AIDropShadowDefaultConverter))] +public record class AIDropShadowDefault { public JsonElement Element { get; private init; } - public AIDropShadowUnionMember0() + public AIDropShadowDefault() { Element = JsonSerializer.SerializeToElement(true); } - internal AIDropShadowUnionMember0(JsonElement element) + internal AIDropShadowDefault(JsonElement element) { Element = element; } @@ -1683,11 +1680,9 @@ internal AIDropShadowUnionMember0(JsonElement element) /// public void Validate() { - if (this != new AIDropShadowUnionMember0()) + if (this != new AIDropShadowDefault()) { - throw new ImageKitInvalidDataException( - "Invalid value given for 'AIDropShadowUnionMember0'" - ); + throw new ImageKitInvalidDataException("Invalid value given for 'AIDropShadowDefault'"); } } @@ -1696,7 +1691,7 @@ public override int GetHashCode() return 0; } - public virtual bool Equals(AIDropShadowUnionMember0? other) + public virtual bool Equals(AIDropShadowDefault? other) { if (other == null) { @@ -1707,9 +1702,9 @@ public virtual bool Equals(AIDropShadowUnionMember0? other) } } -class AIDropShadowUnionMember0Converter : JsonConverter +class AIDropShadowDefaultConverter : JsonConverter { - public override AIDropShadowUnionMember0? Read( + public override AIDropShadowDefault? Read( ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options @@ -1720,7 +1715,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - AIDropShadowUnionMember0 value, + AIDropShadowDefault value, JsonSerializerOptions options ) { @@ -3047,10 +3042,7 @@ public JsonElement Json } } - public TransformationGradient( - TransformationGradientUnionMember0 value, - JsonElement? element = null - ) + public TransformationGradient(TransformationGradientDefault value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -3069,22 +3061,22 @@ public TransformationGradient(JsonElement element) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickTrue(out var value)) { - /// // `value` is of type `TransformationGradientUnionMember0` + /// if (instance.TryPickDefault(out var value)) { + /// // `value` is of type `TransformationGradientDefault` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickTrue([NotNullWhen(true)] out TransformationGradientUnionMember0? value) + public bool TryPickDefault([NotNullWhen(true)] out TransformationGradientDefault? value) { - value = this.Value as TransformationGradientUnionMember0; + value = this.Value as TransformationGradientDefault; return value != null; } @@ -3123,18 +3115,18 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// /// instance.Switch( - /// (TransformationGradientUnionMember0 value) => {...}, + /// (TransformationGradientDefault value) => {...}, /// (string value) => {...} /// ); /// /// /// - public void Switch(Action true_, Action @string) + public void Switch(Action default_, Action @string) { switch (this.Value) { - case TransformationGradientUnionMember0 value: - true_(value); + case TransformationGradientDefault value: + default_(value); break; case string value: @string(value); @@ -3161,17 +3153,17 @@ public void Switch(Action true_, Action /// /// var result = instance.Match( - /// (TransformationGradientUnionMember0 value) => {...}, + /// (TransformationGradientDefault value) => {...}, /// (string value) => {...} /// ); /// /// /// - public T Match(Func true_, Func @string) + public T Match(Func default_, Func @string) { return this.Value switch { - TransformationGradientUnionMember0 value => true_(value), + TransformationGradientDefault value => default_(value), string value => @string(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of TransformationGradient" @@ -3179,9 +3171,8 @@ public T Match(Func true_, Func new(value); + public static implicit operator TransformationGradient(TransformationGradientDefault value) => + new(value); public static implicit operator TransformationGradient(string value) => new(value); @@ -3203,7 +3194,7 @@ public override void Validate() "Data did not match any variant of TransformationGradient" ); } - this.Switch((true_) => true_.Validate(), (_) => { }); + this.Switch((default_) => default_.Validate(), (_) => { }); } public virtual bool Equals(TransformationGradient? other) => @@ -3226,7 +3217,7 @@ int VariantIndex() { return this.Value switch { - TransformationGradientUnionMember0 _ => 0, + TransformationGradientDefault _ => 0, string _ => 1, _ => -1, }; @@ -3244,7 +3235,7 @@ JsonSerializerOptions options var element = JsonSerializer.Deserialize(ref reader, options); try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -3285,17 +3276,17 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(TransformationGradientUnionMember0Converter))] -public record class TransformationGradientUnionMember0 +[JsonConverter(typeof(TransformationGradientDefaultConverter))] +public record class TransformationGradientDefault { public JsonElement Element { get; private init; } - public TransformationGradientUnionMember0() + public TransformationGradientDefault() { Element = JsonSerializer.SerializeToElement(true); } - internal TransformationGradientUnionMember0(JsonElement element) + internal TransformationGradientDefault(JsonElement element) { Element = element; } @@ -3311,10 +3302,10 @@ internal TransformationGradientUnionMember0(JsonElement element) /// public void Validate() { - if (this != new TransformationGradientUnionMember0()) + if (this != new TransformationGradientDefault()) { throw new ImageKitInvalidDataException( - "Invalid value given for 'TransformationGradientUnionMember0'" + "Invalid value given for 'TransformationGradientDefault'" ); } } @@ -3324,7 +3315,7 @@ public override int GetHashCode() return 0; } - public virtual bool Equals(TransformationGradientUnionMember0? other) + public virtual bool Equals(TransformationGradientDefault? other) { if (other == null) { @@ -3335,10 +3326,9 @@ public virtual bool Equals(TransformationGradientUnionMember0? other) } } -class TransformationGradientUnionMember0Converter - : JsonConverter +class TransformationGradientDefaultConverter : JsonConverter { - public override TransformationGradientUnionMember0? Read( + public override TransformationGradientDefault? Read( ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options @@ -3349,7 +3339,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - TransformationGradientUnionMember0 value, + TransformationGradientDefault value, JsonSerializerOptions options ) { @@ -3918,7 +3908,7 @@ public TransformationRadius(double value, JsonElement? element = null) this._element = element; } - public TransformationRadius(TransformationRadiusUnionMember1 value, JsonElement? element = null) + public TransformationRadius(TransformationRadiusMax value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -3958,22 +3948,22 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickMax(out var value)) { - /// // `value` is of type `TransformationRadiusUnionMember1` + /// // `value` is of type `TransformationRadiusMax` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickMax([NotNullWhen(true)] out TransformationRadiusUnionMember1? value) + public bool TryPickMax([NotNullWhen(true)] out TransformationRadiusMax? value) { - value = this.Value as TransformationRadiusUnionMember1; + value = this.Value as TransformationRadiusMax; return value != null; } @@ -4013,7 +4003,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// instance.Switch( /// (double value) => {...}, - /// (TransformationRadiusUnionMember1 value) => {...}, + /// (TransformationRadiusMax value) => {...}, /// (string value) => {...} /// ); /// @@ -4021,7 +4011,7 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// public void Switch( Action @double, - Action max, + Action max, Action @string ) { @@ -4030,7 +4020,7 @@ Action @string case double value: @double(value); break; - case TransformationRadiusUnionMember1 value: + case TransformationRadiusMax value: max(value); break; case string value: @@ -4059,7 +4049,7 @@ Action @string /// /// var result = instance.Match( /// (double value) => {...}, - /// (TransformationRadiusUnionMember1 value) => {...}, + /// (TransformationRadiusMax value) => {...}, /// (string value) => {...} /// ); /// @@ -4067,14 +4057,14 @@ Action @string /// public T Match( Func @double, - Func max, + Func max, Func @string ) { return this.Value switch { double value => @double(value), - TransformationRadiusUnionMember1 value => max(value), + TransformationRadiusMax value => max(value), string value => @string(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of TransformationRadius" @@ -4084,7 +4074,7 @@ Func @string public static implicit operator TransformationRadius(double value) => new(value); - public static implicit operator TransformationRadius(TransformationRadiusUnionMember1 value) => + public static implicit operator TransformationRadius(TransformationRadiusMax value) => new(value); public static implicit operator TransformationRadius(string value) => new(value); @@ -4131,7 +4121,7 @@ int VariantIndex() return this.Value switch { double _ => 0, - TransformationRadiusUnionMember1 _ => 1, + TransformationRadiusMax _ => 1, string _ => 2, _ => -1, }; @@ -4149,7 +4139,7 @@ JsonSerializerOptions options var element = JsonSerializer.Deserialize(ref reader, options); try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -4199,17 +4189,17 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(TransformationRadiusUnionMember1Converter))] -public record class TransformationRadiusUnionMember1 +[JsonConverter(typeof(TransformationRadiusMaxConverter))] +public record class TransformationRadiusMax { public JsonElement Element { get; private init; } - public TransformationRadiusUnionMember1() + public TransformationRadiusMax() { Element = JsonSerializer.SerializeToElement("max"); } - internal TransformationRadiusUnionMember1(JsonElement element) + internal TransformationRadiusMax(JsonElement element) { Element = element; } @@ -4225,10 +4215,10 @@ internal TransformationRadiusUnionMember1(JsonElement element) /// public void Validate() { - if (this != new TransformationRadiusUnionMember1()) + if (this != new TransformationRadiusMax()) { throw new ImageKitInvalidDataException( - "Invalid value given for 'TransformationRadiusUnionMember1'" + "Invalid value given for 'TransformationRadiusMax'" ); } } @@ -4238,7 +4228,7 @@ public override int GetHashCode() return 0; } - public virtual bool Equals(TransformationRadiusUnionMember1? other) + public virtual bool Equals(TransformationRadiusMax? other) { if (other == null) { @@ -4249,9 +4239,9 @@ public virtual bool Equals(TransformationRadiusUnionMember1? other) } } -class TransformationRadiusUnionMember1Converter : JsonConverter +class TransformationRadiusMaxConverter : JsonConverter { - public override TransformationRadiusUnionMember1? Read( + public override TransformationRadiusMax? Read( ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options @@ -4262,7 +4252,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - TransformationRadiusUnionMember1 value, + TransformationRadiusMax value, JsonSerializerOptions options ) { @@ -4541,7 +4531,7 @@ public JsonElement Json } } - public Shadow(ShadowUnionMember0 value, JsonElement? element = null) + public Shadow(ShadowDefault value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -4560,22 +4550,22 @@ public Shadow(JsonElement element) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickTrue(out var value)) { - /// // `value` is of type `ShadowUnionMember0` + /// if (instance.TryPickDefault(out var value)) { + /// // `value` is of type `ShadowDefault` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickTrue([NotNullWhen(true)] out ShadowUnionMember0? value) + public bool TryPickDefault([NotNullWhen(true)] out ShadowDefault? value) { - value = this.Value as ShadowUnionMember0; + value = this.Value as ShadowDefault; return value != null; } @@ -4614,18 +4604,18 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// /// instance.Switch( - /// (ShadowUnionMember0 value) => {...}, + /// (ShadowDefault value) => {...}, /// (string value) => {...} /// ); /// /// /// - public void Switch(Action true_, Action @string) + public void Switch(Action default_, Action @string) { switch (this.Value) { - case ShadowUnionMember0 value: - true_(value); + case ShadowDefault value: + default_(value); break; case string value: @string(value); @@ -4650,23 +4640,23 @@ public void Switch(Action true_, Action @string) /// /// /// var result = instance.Match( - /// (ShadowUnionMember0 value) => {...}, + /// (ShadowDefault value) => {...}, /// (string value) => {...} /// ); /// /// /// - public T Match(Func true_, Func @string) + public T Match(Func default_, Func @string) { return this.Value switch { - ShadowUnionMember0 value => true_(value), + ShadowDefault value => default_(value), string value => @string(value), _ => throw new ImageKitInvalidDataException("Data did not match any variant of Shadow"), }; } - public static implicit operator Shadow(ShadowUnionMember0 value) => new(value); + public static implicit operator Shadow(ShadowDefault value) => new(value); public static implicit operator Shadow(string value) => new(value); @@ -4686,7 +4676,7 @@ public override void Validate() { throw new ImageKitInvalidDataException("Data did not match any variant of Shadow"); } - this.Switch((true_) => true_.Validate(), (_) => { }); + this.Switch((default_) => default_.Validate(), (_) => { }); } public virtual bool Equals(Shadow? other) => @@ -4709,7 +4699,7 @@ int VariantIndex() { return this.Value switch { - ShadowUnionMember0 _ => 0, + ShadowDefault _ => 0, string _ => 1, _ => -1, }; @@ -4727,7 +4717,7 @@ JsonSerializerOptions options var element = JsonSerializer.Deserialize(ref reader, options); try { - var deserialized = JsonSerializer.Deserialize(element, options); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -4761,17 +4751,17 @@ public override void Write(Utf8JsonWriter writer, Shadow value, JsonSerializerOp } } -[JsonConverter(typeof(ShadowUnionMember0Converter))] -public record class ShadowUnionMember0 +[JsonConverter(typeof(ShadowDefaultConverter))] +public record class ShadowDefault { public JsonElement Element { get; private init; } - public ShadowUnionMember0() + public ShadowDefault() { Element = JsonSerializer.SerializeToElement(true); } - internal ShadowUnionMember0(JsonElement element) + internal ShadowDefault(JsonElement element) { Element = element; } @@ -4787,9 +4777,9 @@ internal ShadowUnionMember0(JsonElement element) /// public void Validate() { - if (this != new ShadowUnionMember0()) + if (this != new ShadowDefault()) { - throw new ImageKitInvalidDataException("Invalid value given for 'ShadowUnionMember0'"); + throw new ImageKitInvalidDataException("Invalid value given for 'ShadowDefault'"); } } @@ -4798,7 +4788,7 @@ public override int GetHashCode() return 0; } - public virtual bool Equals(ShadowUnionMember0? other) + public virtual bool Equals(ShadowDefault? other) { if (other == null) { @@ -4809,9 +4799,9 @@ public virtual bool Equals(ShadowUnionMember0? other) } } -class ShadowUnionMember0Converter : JsonConverter +class ShadowDefaultConverter : JsonConverter { - public override ShadowUnionMember0? Read( + public override ShadowDefault? Read( ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options @@ -4822,7 +4812,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - ShadowUnionMember0 value, + ShadowDefault value, JsonSerializerOptions options ) { @@ -4852,7 +4842,7 @@ public JsonElement Json } } - public Sharpen(SharpenUnionMember0 value, JsonElement? element = null) + public Sharpen(SharpenDefault value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -4871,22 +4861,22 @@ public Sharpen(JsonElement element) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickTrue(out var value)) { - /// // `value` is of type `SharpenUnionMember0` + /// if (instance.TryPickDefault(out var value)) { + /// // `value` is of type `SharpenDefault` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickTrue([NotNullWhen(true)] out SharpenUnionMember0? value) + public bool TryPickDefault([NotNullWhen(true)] out SharpenDefault? value) { - value = this.Value as SharpenUnionMember0; + value = this.Value as SharpenDefault; return value != null; } @@ -4925,18 +4915,18 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// /// /// instance.Switch( - /// (SharpenUnionMember0 value) => {...}, + /// (SharpenDefault value) => {...}, /// (double value) => {...} /// ); /// /// /// - public void Switch(Action true_, Action @double) + public void Switch(Action default_, Action @double) { switch (this.Value) { - case SharpenUnionMember0 value: - true_(value); + case SharpenDefault value: + default_(value); break; case double value: @double(value); @@ -4961,17 +4951,17 @@ public void Switch(Action true_, Action @double) /// /// /// var result = instance.Match( - /// (SharpenUnionMember0 value) => {...}, + /// (SharpenDefault value) => {...}, /// (double value) => {...} /// ); /// /// /// - public T Match(Func true_, Func @double) + public T Match(Func default_, Func @double) { return this.Value switch { - SharpenUnionMember0 value => true_(value), + SharpenDefault value => default_(value), double value => @double(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of Sharpen" @@ -4979,7 +4969,7 @@ public T Match(Func true_, Func @double) }; } - public static implicit operator Sharpen(SharpenUnionMember0 value) => new(value); + public static implicit operator Sharpen(SharpenDefault value) => new(value); public static implicit operator Sharpen(double value) => new(value); @@ -4999,7 +4989,7 @@ public override void Validate() { throw new ImageKitInvalidDataException("Data did not match any variant of Sharpen"); } - this.Switch((true_) => true_.Validate(), (_) => { }); + this.Switch((default_) => default_.Validate(), (_) => { }); } public virtual bool Equals(Sharpen? other) => @@ -5022,7 +5012,7 @@ int VariantIndex() { return this.Value switch { - SharpenUnionMember0 _ => 0, + SharpenDefault _ => 0, double _ => 1, _ => -1, }; @@ -5040,7 +5030,7 @@ JsonSerializerOptions options var element = JsonSerializer.Deserialize(ref reader, options); try { - var deserialized = JsonSerializer.Deserialize(element, options); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -5070,17 +5060,17 @@ public override void Write(Utf8JsonWriter writer, Sharpen value, JsonSerializerO } } -[JsonConverter(typeof(SharpenUnionMember0Converter))] -public record class SharpenUnionMember0 +[JsonConverter(typeof(SharpenDefaultConverter))] +public record class SharpenDefault { public JsonElement Element { get; private init; } - public SharpenUnionMember0() + public SharpenDefault() { Element = JsonSerializer.SerializeToElement(true); } - internal SharpenUnionMember0(JsonElement element) + internal SharpenDefault(JsonElement element) { Element = element; } @@ -5096,9 +5086,9 @@ internal SharpenUnionMember0(JsonElement element) /// public void Validate() { - if (this != new SharpenUnionMember0()) + if (this != new SharpenDefault()) { - throw new ImageKitInvalidDataException("Invalid value given for 'SharpenUnionMember0'"); + throw new ImageKitInvalidDataException("Invalid value given for 'SharpenDefault'"); } } @@ -5107,7 +5097,7 @@ public override int GetHashCode() return 0; } - public virtual bool Equals(SharpenUnionMember0? other) + public virtual bool Equals(SharpenDefault? other) { if (other == null) { @@ -5118,9 +5108,9 @@ public virtual bool Equals(SharpenUnionMember0? other) } } -class SharpenUnionMember0Converter : JsonConverter +class SharpenDefaultConverter : JsonConverter { - public override SharpenUnionMember0? Read( + public override SharpenDefault? Read( ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options @@ -5131,7 +5121,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SharpenUnionMember0 value, + SharpenDefault value, JsonSerializerOptions options ) { @@ -5406,7 +5396,7 @@ public JsonElement Json } } - public Trim(TrimUnionMember0 value, JsonElement? element = null) + public Trim(TrimDefault value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -5425,22 +5415,22 @@ public Trim(JsonElement element) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickTrue(out var value)) { - /// // `value` is of type `TrimUnionMember0` + /// if (instance.TryPickDefault(out var value)) { + /// // `value` is of type `TrimDefault` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickTrue([NotNullWhen(true)] out TrimUnionMember0? value) + public bool TryPickDefault([NotNullWhen(true)] out TrimDefault? value) { - value = this.Value as TrimUnionMember0; + value = this.Value as TrimDefault; return value != null; } @@ -5479,18 +5469,18 @@ public bool TryPickDouble([NotNullWhen(true)] out double? value) /// /// /// instance.Switch( - /// (TrimUnionMember0 value) => {...}, + /// (TrimDefault value) => {...}, /// (double value) => {...} /// ); /// /// /// - public void Switch(Action true_, Action @double) + public void Switch(Action default_, Action @double) { switch (this.Value) { - case TrimUnionMember0 value: - true_(value); + case TrimDefault value: + default_(value); break; case double value: @double(value); @@ -5515,23 +5505,23 @@ public void Switch(Action true_, Action @double) /// /// /// var result = instance.Match( - /// (TrimUnionMember0 value) => {...}, + /// (TrimDefault value) => {...}, /// (double value) => {...} /// ); /// /// /// - public T Match(Func true_, Func @double) + public T Match(Func default_, Func @double) { return this.Value switch { - TrimUnionMember0 value => true_(value), + TrimDefault value => default_(value), double value => @double(value), _ => throw new ImageKitInvalidDataException("Data did not match any variant of Trim"), }; } - public static implicit operator Trim(TrimUnionMember0 value) => new(value); + public static implicit operator Trim(TrimDefault value) => new(value); public static implicit operator Trim(double value) => new(value); @@ -5551,7 +5541,7 @@ public override void Validate() { throw new ImageKitInvalidDataException("Data did not match any variant of Trim"); } - this.Switch((true_) => true_.Validate(), (_) => { }); + this.Switch((default_) => default_.Validate(), (_) => { }); } public virtual bool Equals(Trim? other) => @@ -5574,7 +5564,7 @@ int VariantIndex() { return this.Value switch { - TrimUnionMember0 _ => 0, + TrimDefault _ => 0, double _ => 1, _ => -1, }; @@ -5592,7 +5582,7 @@ JsonSerializerOptions options var element = JsonSerializer.Deserialize(ref reader, options); try { - var deserialized = JsonSerializer.Deserialize(element, options); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -5622,17 +5612,17 @@ public override void Write(Utf8JsonWriter writer, Trim value, JsonSerializerOpti } } -[JsonConverter(typeof(TrimUnionMember0Converter))] -public record class TrimUnionMember0 +[JsonConverter(typeof(TrimDefaultConverter))] +public record class TrimDefault { public JsonElement Element { get; private init; } - public TrimUnionMember0() + public TrimDefault() { Element = JsonSerializer.SerializeToElement(true); } - internal TrimUnionMember0(JsonElement element) + internal TrimDefault(JsonElement element) { Element = element; } @@ -5648,9 +5638,9 @@ internal TrimUnionMember0(JsonElement element) /// public void Validate() { - if (this != new TrimUnionMember0()) + if (this != new TrimDefault()) { - throw new ImageKitInvalidDataException("Invalid value given for 'TrimUnionMember0'"); + throw new ImageKitInvalidDataException("Invalid value given for 'TrimDefault'"); } } @@ -5659,7 +5649,7 @@ public override int GetHashCode() return 0; } - public virtual bool Equals(TrimUnionMember0? other) + public virtual bool Equals(TrimDefault? other) { if (other == null) { @@ -5670,9 +5660,9 @@ public virtual bool Equals(TrimUnionMember0? other) } } -class TrimUnionMember0Converter : JsonConverter +class TrimDefaultConverter : JsonConverter { - public override TrimUnionMember0? Read( + public override TrimDefault? Read( ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options @@ -5683,7 +5673,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - TrimUnionMember0 value, + TrimDefault value, JsonSerializerOptions options ) { @@ -5714,7 +5704,7 @@ public JsonElement Json } } - public UnsharpMask(UnsharpMaskUnionMember0 value, JsonElement? element = null) + public UnsharpMask(UnsharpMaskDefault value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -5733,22 +5723,22 @@ public UnsharpMask(JsonElement element) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickTrue(out var value)) { - /// // `value` is of type `UnsharpMaskUnionMember0` + /// if (instance.TryPickDefault(out var value)) { + /// // `value` is of type `UnsharpMaskDefault` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickTrue([NotNullWhen(true)] out UnsharpMaskUnionMember0? value) + public bool TryPickDefault([NotNullWhen(true)] out UnsharpMaskDefault? value) { - value = this.Value as UnsharpMaskUnionMember0; + value = this.Value as UnsharpMaskDefault; return value != null; } @@ -5787,18 +5777,18 @@ public bool TryPickString([NotNullWhen(true)] out string? value) /// /// /// instance.Switch( - /// (UnsharpMaskUnionMember0 value) => {...}, + /// (UnsharpMaskDefault value) => {...}, /// (string value) => {...} /// ); /// /// /// - public void Switch(Action true_, Action @string) + public void Switch(Action default_, Action @string) { switch (this.Value) { - case UnsharpMaskUnionMember0 value: - true_(value); + case UnsharpMaskDefault value: + default_(value); break; case string value: @string(value); @@ -5825,17 +5815,17 @@ public void Switch(Action true_, Action @string /// /// /// var result = instance.Match( - /// (UnsharpMaskUnionMember0 value) => {...}, + /// (UnsharpMaskDefault value) => {...}, /// (string value) => {...} /// ); /// /// /// - public T Match(Func true_, Func @string) + public T Match(Func default_, Func @string) { return this.Value switch { - UnsharpMaskUnionMember0 value => true_(value), + UnsharpMaskDefault value => default_(value), string value => @string(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of UnsharpMask" @@ -5843,7 +5833,7 @@ public T Match(Func true_, Func @strin }; } - public static implicit operator UnsharpMask(UnsharpMaskUnionMember0 value) => new(value); + public static implicit operator UnsharpMask(UnsharpMaskDefault value) => new(value); public static implicit operator UnsharpMask(string value) => new(value); @@ -5863,7 +5853,7 @@ public override void Validate() { throw new ImageKitInvalidDataException("Data did not match any variant of UnsharpMask"); } - this.Switch((true_) => true_.Validate(), (_) => { }); + this.Switch((default_) => default_.Validate(), (_) => { }); } public virtual bool Equals(UnsharpMask? other) => @@ -5886,7 +5876,7 @@ int VariantIndex() { return this.Value switch { - UnsharpMaskUnionMember0 _ => 0, + UnsharpMaskDefault _ => 0, string _ => 1, _ => -1, }; @@ -5904,10 +5894,7 @@ JsonSerializerOptions options var element = JsonSerializer.Deserialize(ref reader, options); try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -5945,17 +5932,17 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(UnsharpMaskUnionMember0Converter))] -public record class UnsharpMaskUnionMember0 +[JsonConverter(typeof(UnsharpMaskDefaultConverter))] +public record class UnsharpMaskDefault { public JsonElement Element { get; private init; } - public UnsharpMaskUnionMember0() + public UnsharpMaskDefault() { Element = JsonSerializer.SerializeToElement(true); } - internal UnsharpMaskUnionMember0(JsonElement element) + internal UnsharpMaskDefault(JsonElement element) { Element = element; } @@ -5971,11 +5958,9 @@ internal UnsharpMaskUnionMember0(JsonElement element) /// public void Validate() { - if (this != new UnsharpMaskUnionMember0()) + if (this != new UnsharpMaskDefault()) { - throw new ImageKitInvalidDataException( - "Invalid value given for 'UnsharpMaskUnionMember0'" - ); + throw new ImageKitInvalidDataException("Invalid value given for 'UnsharpMaskDefault'"); } } @@ -5984,7 +5969,7 @@ public override int GetHashCode() return 0; } - public virtual bool Equals(UnsharpMaskUnionMember0? other) + public virtual bool Equals(UnsharpMaskDefault? other) { if (other == null) { @@ -5995,9 +5980,9 @@ public virtual bool Equals(UnsharpMaskUnionMember0? other) } } -class UnsharpMaskUnionMember0Converter : JsonConverter +class UnsharpMaskDefaultConverter : JsonConverter { - public override UnsharpMaskUnionMember0? Read( + public override UnsharpMaskDefault? Read( ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options @@ -6008,7 +5993,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - UnsharpMaskUnionMember0 value, + UnsharpMaskDefault value, JsonSerializerOptions options ) { From 820139a79a6c36134ad8b56e1a6612e343aca4d5 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sun, 17 May 2026 04:42:38 +0000 Subject: [PATCH 126/129] chore: trigger build for test --- .stats.yml | 4 +-- .../Models/Dummy/DummyCreateParamsTest.cs | 36 ------------------- .../Models/Dummy/DummyCreateParams.cs | 20 ----------- 3 files changed, 2 insertions(+), 58 deletions(-) diff --git a/.stats.yml b/.stats.yml index 67b90e9c..3cd1899a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 48 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc/imagekit-219cd09f920d87469cda8b4d45b74dbfcac5352281e240e78230934ceb5b19a4.yml -openapi_spec_hash: 790e2ebbfb462a5f38999ec543e6124e +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc/imagekit-af1d84da7e0b7c07c32d0cdf0423f40a55b4aab339cbad65e495bee483d0e3cd.yml +openapi_spec_hash: 333878ccaade1f9d0186530386bff8c5 config_hash: ea9d73f82c079f2c34302ff663f2aa56 diff --git a/src/Imagekit.Tests/Models/Dummy/DummyCreateParamsTest.cs b/src/Imagekit.Tests/Models/Dummy/DummyCreateParamsTest.cs index ee2f576b..f2bf23ed 100644 --- a/src/Imagekit.Tests/Models/Dummy/DummyCreateParamsTest.cs +++ b/src/Imagekit.Tests/Models/Dummy/DummyCreateParamsTest.cs @@ -446,15 +446,6 @@ public void FieldRoundtrip_Works() }, ], }, - SolidColorOverlayTransformation = new() - { - Alpha = 1, - Background = "background", - Gradient = new Default(), - Height = 0, - Radius = new Max(), - Width = 0, - }, SrcOptions = new() { Src = "/my-image.jpg", @@ -1319,15 +1310,6 @@ public void FieldRoundtrip_Works() }, ], }; - SolidColorOverlayTransformation expectedSolidColorOverlayTransformation = new() - { - Alpha = 1, - Background = "background", - Gradient = new Default(), - Height = 0, - Radius = new Max(), - Width = 0, - }; SrcOptions expectedSrcOptions = new() { Src = "/my-image.jpg", @@ -1775,10 +1757,6 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedResponsiveImageAttributes, parameters.ResponsiveImageAttributes); Assert.Equal(expectedSavedExtensions, parameters.SavedExtensions); Assert.Equal(expectedSolidColorOverlay, parameters.SolidColorOverlay); - Assert.Equal( - expectedSolidColorOverlayTransformation, - parameters.SolidColorOverlayTransformation - ); Assert.Equal(expectedSrcOptions, parameters.SrcOptions); Assert.Equal(expectedStreamingResolution, parameters.StreamingResolution); Assert.Equal(expectedSubtitleOverlay, parameters.SubtitleOverlay); @@ -1820,8 +1798,6 @@ public void OptionalNonNullableParamsUnsetAreNotSet_Works() Assert.False(parameters.RawBodyData.ContainsKey("savedExtensions")); Assert.Null(parameters.SolidColorOverlay); Assert.False(parameters.RawBodyData.ContainsKey("solidColorOverlay")); - Assert.Null(parameters.SolidColorOverlayTransformation); - Assert.False(parameters.RawBodyData.ContainsKey("solidColorOverlayTransformation")); Assert.Null(parameters.SrcOptions); Assert.False(parameters.RawBodyData.ContainsKey("srcOptions")); Assert.Null(parameters.StreamingResolution); @@ -1859,7 +1835,6 @@ public void OptionalNonNullableParamsSetToNullAreNotSet_Works() ResponsiveImageAttributes = null, SavedExtensions = null, SolidColorOverlay = null, - SolidColorOverlayTransformation = null, SrcOptions = null, StreamingResolution = null, SubtitleOverlay = null, @@ -1893,8 +1868,6 @@ public void OptionalNonNullableParamsSetToNullAreNotSet_Works() Assert.False(parameters.RawBodyData.ContainsKey("savedExtensions")); Assert.Null(parameters.SolidColorOverlay); Assert.False(parameters.RawBodyData.ContainsKey("solidColorOverlay")); - Assert.Null(parameters.SolidColorOverlayTransformation); - Assert.False(parameters.RawBodyData.ContainsKey("solidColorOverlayTransformation")); Assert.Null(parameters.SrcOptions); Assert.False(parameters.RawBodyData.ContainsKey("srcOptions")); Assert.Null(parameters.StreamingResolution); @@ -2363,15 +2336,6 @@ public void CopyConstructor_Works() }, ], }, - SolidColorOverlayTransformation = new() - { - Alpha = 1, - Background = "background", - Gradient = new Default(), - Height = 0, - Radius = new Max(), - Width = 0, - }, SrcOptions = new() { Src = "/my-image.jpg", diff --git a/src/Imagekit/Models/Dummy/DummyCreateParams.cs b/src/Imagekit/Models/Dummy/DummyCreateParams.cs index e7a2e7a0..2391ec44 100644 --- a/src/Imagekit/Models/Dummy/DummyCreateParams.cs +++ b/src/Imagekit/Models/Dummy/DummyCreateParams.cs @@ -256,26 +256,6 @@ public SolidColorOverlay? SolidColorOverlay } } - public SolidColorOverlayTransformation? SolidColorOverlayTransformation - { - get - { - this._rawBodyData.Freeze(); - return this._rawBodyData.GetNullableClass( - "solidColorOverlayTransformation" - ); - } - init - { - if (value == null) - { - return; - } - - this._rawBodyData.Set("solidColorOverlayTransformation", value); - } - } - /// /// Options for generating ImageKit URLs with transformations. See the [Transformations guide](https://imagekit.io/docs/transformations). /// From 1f7df7f201d88147fc61be52fe3ca12b7845ecbe Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sun, 17 May 2026 04:47:43 +0000 Subject: [PATCH 127/129] chore: trigger build --- .stats.yml | 4 +-- .../Models/Dummy/DummyCreateParamsTest.cs | 36 +++++++++++++++++++ .../Models/Dummy/DummyCreateParams.cs | 20 +++++++++++ 3 files changed, 58 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 3cd1899a..67b90e9c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 48 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc/imagekit-af1d84da7e0b7c07c32d0cdf0423f40a55b4aab339cbad65e495bee483d0e3cd.yml -openapi_spec_hash: 333878ccaade1f9d0186530386bff8c5 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc/imagekit-219cd09f920d87469cda8b4d45b74dbfcac5352281e240e78230934ceb5b19a4.yml +openapi_spec_hash: 790e2ebbfb462a5f38999ec543e6124e config_hash: ea9d73f82c079f2c34302ff663f2aa56 diff --git a/src/Imagekit.Tests/Models/Dummy/DummyCreateParamsTest.cs b/src/Imagekit.Tests/Models/Dummy/DummyCreateParamsTest.cs index f2bf23ed..ee2f576b 100644 --- a/src/Imagekit.Tests/Models/Dummy/DummyCreateParamsTest.cs +++ b/src/Imagekit.Tests/Models/Dummy/DummyCreateParamsTest.cs @@ -446,6 +446,15 @@ public void FieldRoundtrip_Works() }, ], }, + SolidColorOverlayTransformation = new() + { + Alpha = 1, + Background = "background", + Gradient = new Default(), + Height = 0, + Radius = new Max(), + Width = 0, + }, SrcOptions = new() { Src = "/my-image.jpg", @@ -1310,6 +1319,15 @@ public void FieldRoundtrip_Works() }, ], }; + SolidColorOverlayTransformation expectedSolidColorOverlayTransformation = new() + { + Alpha = 1, + Background = "background", + Gradient = new Default(), + Height = 0, + Radius = new Max(), + Width = 0, + }; SrcOptions expectedSrcOptions = new() { Src = "/my-image.jpg", @@ -1757,6 +1775,10 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedResponsiveImageAttributes, parameters.ResponsiveImageAttributes); Assert.Equal(expectedSavedExtensions, parameters.SavedExtensions); Assert.Equal(expectedSolidColorOverlay, parameters.SolidColorOverlay); + Assert.Equal( + expectedSolidColorOverlayTransformation, + parameters.SolidColorOverlayTransformation + ); Assert.Equal(expectedSrcOptions, parameters.SrcOptions); Assert.Equal(expectedStreamingResolution, parameters.StreamingResolution); Assert.Equal(expectedSubtitleOverlay, parameters.SubtitleOverlay); @@ -1798,6 +1820,8 @@ public void OptionalNonNullableParamsUnsetAreNotSet_Works() Assert.False(parameters.RawBodyData.ContainsKey("savedExtensions")); Assert.Null(parameters.SolidColorOverlay); Assert.False(parameters.RawBodyData.ContainsKey("solidColorOverlay")); + Assert.Null(parameters.SolidColorOverlayTransformation); + Assert.False(parameters.RawBodyData.ContainsKey("solidColorOverlayTransformation")); Assert.Null(parameters.SrcOptions); Assert.False(parameters.RawBodyData.ContainsKey("srcOptions")); Assert.Null(parameters.StreamingResolution); @@ -1835,6 +1859,7 @@ public void OptionalNonNullableParamsSetToNullAreNotSet_Works() ResponsiveImageAttributes = null, SavedExtensions = null, SolidColorOverlay = null, + SolidColorOverlayTransformation = null, SrcOptions = null, StreamingResolution = null, SubtitleOverlay = null, @@ -1868,6 +1893,8 @@ public void OptionalNonNullableParamsSetToNullAreNotSet_Works() Assert.False(parameters.RawBodyData.ContainsKey("savedExtensions")); Assert.Null(parameters.SolidColorOverlay); Assert.False(parameters.RawBodyData.ContainsKey("solidColorOverlay")); + Assert.Null(parameters.SolidColorOverlayTransformation); + Assert.False(parameters.RawBodyData.ContainsKey("solidColorOverlayTransformation")); Assert.Null(parameters.SrcOptions); Assert.False(parameters.RawBodyData.ContainsKey("srcOptions")); Assert.Null(parameters.StreamingResolution); @@ -2336,6 +2363,15 @@ public void CopyConstructor_Works() }, ], }, + SolidColorOverlayTransformation = new() + { + Alpha = 1, + Background = "background", + Gradient = new Default(), + Height = 0, + Radius = new Max(), + Width = 0, + }, SrcOptions = new() { Src = "/my-image.jpg", diff --git a/src/Imagekit/Models/Dummy/DummyCreateParams.cs b/src/Imagekit/Models/Dummy/DummyCreateParams.cs index 2391ec44..e7a2e7a0 100644 --- a/src/Imagekit/Models/Dummy/DummyCreateParams.cs +++ b/src/Imagekit/Models/Dummy/DummyCreateParams.cs @@ -256,6 +256,26 @@ public SolidColorOverlay? SolidColorOverlay } } + public SolidColorOverlayTransformation? SolidColorOverlayTransformation + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass( + "solidColorOverlayTransformation" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("solidColorOverlayTransformation", value); + } + } + /// /// Options for generating ImageKit URLs with transformations. See the [Transformations guide](https://imagekit.io/docs/transformations). /// From 3e6c2dfecca7c01f8c867f00f8bdd8afcf3517d5 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sun, 17 May 2026 04:51:07 +0000 Subject: [PATCH 128/129] build(dotnet): add x-stainless-variantName to cannot infer union variant name warning --- .stats.yml | 4 +- .../Models/Files/UpdateFileRequestTest.cs | 59 ++++++++----------- .../Models/Files/UpdateFileRequest.cs | 58 ++++++++---------- 3 files changed, 51 insertions(+), 70 deletions(-) diff --git a/.stats.yml b/.stats.yml index 67b90e9c..73bb96c5 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 48 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc/imagekit-219cd09f920d87469cda8b4d45b74dbfcac5352281e240e78230934ceb5b19a4.yml -openapi_spec_hash: 790e2ebbfb462a5f38999ec543e6124e +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc/imagekit-cda882cdb87edc69cffe5feacc2eaa5936d5264109668f434c575bba99eabdd3.yml +openapi_spec_hash: 964672a4901296fe54bf272bbdca0166 config_hash: ea9d73f82c079f2c34302ff663f2aa56 diff --git a/src/Imagekit.Tests/Models/Files/UpdateFileRequestTest.cs b/src/Imagekit.Tests/Models/Files/UpdateFileRequestTest.cs index f09a146b..6686a8a1 100644 --- a/src/Imagekit.Tests/Models/Files/UpdateFileRequestTest.cs +++ b/src/Imagekit.Tests/Models/Files/UpdateFileRequestTest.cs @@ -77,7 +77,7 @@ public void DetailsValidationWorks() ), new SavedExtension("ext_abc123"), ], - RemoveAITags = new UnionMember1(), + RemoveAITags = new All(), Tags = ["tag1", "tag2"], WebhookUrl = "https://example.com", }; @@ -162,7 +162,7 @@ public void DetailsSerializationRoundtripWorks() ), new SavedExtension("ext_abc123"), ], - RemoveAITags = new UnionMember1(), + RemoveAITags = new All(), Tags = ["tag1", "tag2"], WebhookUrl = "https://example.com", }; @@ -262,7 +262,7 @@ public void FieldRoundtrip_Works() ), new SavedExtension("ext_abc123"), ], - RemoveAITags = new UnionMember1(), + RemoveAITags = new All(), Tags = ["tag1", "tag2"], WebhookUrl = "https://example.com", }; @@ -330,7 +330,7 @@ public void FieldRoundtrip_Works() ), new SavedExtension("ext_abc123"), ]; - RemoveAITags expectedRemoveAITags = new UnionMember1(); + RemoveAITags expectedRemoveAITags = new All(); List expectedTags = ["tag1", "tag2"]; string expectedWebhookUrl = "https://example.com"; @@ -428,7 +428,7 @@ public void SerializationRoundtrip_Works() ), new SavedExtension("ext_abc123"), ], - RemoveAITags = new UnionMember1(), + RemoveAITags = new All(), Tags = ["tag1", "tag2"], WebhookUrl = "https://example.com", }; @@ -510,7 +510,7 @@ public void FieldRoundtripThroughSerialization_Works() ), new SavedExtension("ext_abc123"), ], - RemoveAITags = new UnionMember1(), + RemoveAITags = new All(), Tags = ["tag1", "tag2"], WebhookUrl = "https://example.com", }; @@ -585,7 +585,7 @@ public void FieldRoundtripThroughSerialization_Works() ), new SavedExtension("ext_abc123"), ]; - RemoveAITags expectedRemoveAITags = new UnionMember1(); + RemoveAITags expectedRemoveAITags = new All(); List expectedTags = ["tag1", "tag2"]; string expectedWebhookUrl = "https://example.com"; @@ -683,7 +683,7 @@ public void Validation_Works() ), new SavedExtension("ext_abc123"), ], - RemoveAITags = new UnionMember1(), + RemoveAITags = new All(), Tags = ["tag1", "tag2"], WebhookUrl = "https://example.com", }; @@ -838,7 +838,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() ), new SavedExtension("ext_abc123"), ], - RemoveAITags = new UnionMember1(), + RemoveAITags = new All(), WebhookUrl = "https://example.com", }; @@ -915,7 +915,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() ), new SavedExtension("ext_abc123"), ], - RemoveAITags = new UnionMember1(), + RemoveAITags = new All(), WebhookUrl = "https://example.com", }; @@ -989,7 +989,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() ), new SavedExtension("ext_abc123"), ], - RemoveAITags = new UnionMember1(), + RemoveAITags = new All(), WebhookUrl = "https://example.com", CustomCoordinates = null, @@ -1069,7 +1069,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ), new SavedExtension("ext_abc123"), ], - RemoveAITags = new UnionMember1(), + RemoveAITags = new All(), WebhookUrl = "https://example.com", CustomCoordinates = null, @@ -1147,7 +1147,7 @@ public void CopyConstructor_Works() ), new SavedExtension("ext_abc123"), ], - RemoveAITags = new UnionMember1(), + RemoveAITags = new All(), Tags = ["tag1", "tag2"], WebhookUrl = "https://example.com", }; @@ -1170,7 +1170,7 @@ public void StringsValidationWorks() [Fact] public void AllValidationWorks() { - RemoveAITags value = new UnionMember1(); + RemoveAITags value = new All(); value.Validate(); } @@ -1190,7 +1190,7 @@ public void StringsSerializationRoundtripWorks() [Fact] public void AllSerializationRoundtripWorks() { - RemoveAITags value = new UnionMember1(); + RemoveAITags value = new All(); string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize( element, @@ -1201,19 +1201,19 @@ public void AllSerializationRoundtripWorks() } } -public class UnionMember1Test : TestBase +public class AllTest : TestBase { [Fact] public void DefaultValidation_Works() { - var constant = new UnionMember1(); + var constant = new All(); constant.Validate(); } [Fact] public void ValidConstantValidation_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.SerializeToElement("all"), ModelBase.SerializerOptions ); @@ -1225,7 +1225,7 @@ public void ValidConstantValidation_Works() [Fact] public void InvalidConstantValidationThrows_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); @@ -1237,12 +1237,9 @@ public void InvalidConstantValidationThrows_Works() [Fact] public void DefaultRoundtrip_Works() { - var constant = new UnionMember1(); + var constant = new All(); string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); Assert.Equal(constant, deserialized); } @@ -1250,15 +1247,12 @@ public void DefaultRoundtrip_Works() [Fact] public void ValidConstantRoundtrip_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.SerializeToElement("all"), ModelBase.SerializerOptions ); string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); Assert.Equal(constant, deserialized); } @@ -1266,15 +1260,12 @@ public void ValidConstantRoundtrip_Works() [Fact] public void InvalidConstantRoundtrip_Works() { - var constant = JsonSerializer.Deserialize( + var constant = JsonSerializer.Deserialize( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); string element = JsonSerializer.Serialize(constant, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); Assert.Equal(constant, deserialized); } diff --git a/src/Imagekit/Models/Files/UpdateFileRequest.cs b/src/Imagekit/Models/Files/UpdateFileRequest.cs index 6933afb4..a56ec874 100644 --- a/src/Imagekit/Models/Files/UpdateFileRequest.cs +++ b/src/Imagekit/Models/Files/UpdateFileRequest.cs @@ -524,7 +524,7 @@ public RemoveAITags(IReadOnlyList value, JsonElement? element = null) this._element = element; } - public RemoveAITags(UnionMember1 value, JsonElement? element = null) + public RemoveAITags(All value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -558,22 +558,22 @@ public bool TryPickStrings([NotNullWhen(true)] out IReadOnlyList? value) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickAll(out var value)) { - /// // `value` is of type `UnionMember1` + /// // `value` is of type `All` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickAll([NotNullWhen(true)] out UnionMember1? value) + public bool TryPickAll([NotNullWhen(true)] out All? value) { - value = this.Value as UnionMember1; + value = this.Value as All; return value != null; } @@ -592,22 +592,19 @@ public bool TryPickAll([NotNullWhen(true)] out UnionMember1? value) /// /// instance.Switch( /// (IReadOnlyList<string> value) => {...}, - /// (UnionMember1 value) => {...} + /// (All value) => {...} /// ); /// /// /// - public void Switch( - System::Action> strings, - System::Action all - ) + public void Switch(System::Action> strings, System::Action all) { switch (this.Value) { case IReadOnlyList value: strings(value); break; - case UnionMember1 value: + case All value: all(value); break; default: @@ -633,20 +630,17 @@ public void Switch( /// /// var result = instance.Match( /// (IReadOnlyList<string> value) => {...}, - /// (UnionMember1 value) => {...} + /// (All value) => {...} /// ); /// /// /// - public T Match( - System::Func, T> strings, - System::Func all - ) + public T Match(System::Func, T> strings, System::Func all) { return this.Value switch { IReadOnlyList value => strings(value), - UnionMember1 value => all(value), + All value => all(value), _ => throw new ImageKitInvalidDataException( "Data did not match any variant of RemoveAITags" ), @@ -656,7 +650,7 @@ public T Match( public static implicit operator RemoveAITags(List value) => new((IReadOnlyList)value); - public static implicit operator RemoveAITags(UnionMember1 value) => new(value); + public static implicit operator RemoveAITags(All value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -700,7 +694,7 @@ int VariantIndex() return this.Value switch { IReadOnlyList _ => 0, - UnionMember1 _ => 1, + All _ => 1, _ => -1, }; } @@ -717,7 +711,7 @@ JsonSerializerOptions options var element = JsonSerializer.Deserialize(ref reader, options); try { - var deserialized = JsonSerializer.Deserialize(element, options); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -755,17 +749,17 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(UnionMember1Converter))] -public record class UnionMember1 +[JsonConverter(typeof(AllConverter))] +public record class All { public JsonElement Element { get; private init; } - public UnionMember1() + public All() { Element = JsonSerializer.SerializeToElement("all"); } - internal UnionMember1(JsonElement element) + internal All(JsonElement element) { Element = element; } @@ -781,9 +775,9 @@ internal UnionMember1(JsonElement element) /// public void Validate() { - if (this != new UnionMember1()) + if (this != new All()) { - throw new ImageKitInvalidDataException("Invalid value given for 'UnionMember1'"); + throw new ImageKitInvalidDataException("Invalid value given for 'All'"); } } @@ -792,7 +786,7 @@ public override int GetHashCode() return 0; } - public virtual bool Equals(UnionMember1? other) + public virtual bool Equals(All? other) { if (other == null) { @@ -803,9 +797,9 @@ public virtual bool Equals(UnionMember1? other) } } -class UnionMember1Converter : JsonConverter +class AllConverter : JsonConverter { - public override UnionMember1? Read( + public override All? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -814,11 +808,7 @@ JsonSerializerOptions options return new(JsonSerializer.Deserialize(ref reader, options)); } - public override void Write( - Utf8JsonWriter writer, - UnionMember1 value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, All value, JsonSerializerOptions options) { JsonSerializer.Serialize(writer, value.Element, options); } From ab2ac5a2ed5b8183a463b55b0805ab4a485129cb Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sun, 17 May 2026 04:52:43 +0000 Subject: [PATCH 129/129] release: 0.1.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 126 ++++++++++++++++++++++++++++++++++ src/Imagekit/Imagekit.csproj | 12 ++-- 3 files changed, 133 insertions(+), 7 deletions(-) create mode 100644 CHANGELOG.md diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 1332969b..3d2ac0bd 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.0.1" + ".": "0.1.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..b9a4d22b --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,126 @@ +# Changelog + +## 0.1.0 (2026-05-17) + +Full Changelog: [v0.0.1...v0.1.0](https://github.com/imagekit-developer/imagekit-dotnet/compare/v0.0.1...v0.1.0) + +### Features + +* **api:** add BaseWebhookEvent ([4fd9859](https://github.com/imagekit-developer/imagekit-dotnet/commit/4fd98595c03f4ba256e80d5c85ca7919c5d981f8)) +* **api:** add customMetadata property to folder schema ([3b87d89](https://github.com/imagekit-developer/imagekit-dotnet/commit/3b87d89bcd3d121b3d2168a4c8673c14da628662)) +* **api:** add GetImageAttributesOptions and ResponsiveImageAttributes schemas; update resource references in main.yaml; remove dummy endpoint ([490b933](https://github.com/imagekit-developer/imagekit-dotnet/commit/490b9336d427b06dbd912e11af1538c067766f06)) +* **api:** add no-enlarge crop modes and colorize transformation ([1b0cef3](https://github.com/imagekit-developer/imagekit-dotnet/commit/1b0cef3420a8ba0ef0e9fd70b6a2f117c51b1e76)) +* **api:** add path policy related non-breaking changes ([7ef8fbc](https://github.com/imagekit-developer/imagekit-dotnet/commit/7ef8fbc6749320ddb5e9bcfb872039d58b13526c)) +* **api:** add selectedFieldsSchema in upload and list API response ([00a9878](https://github.com/imagekit-developer/imagekit-dotnet/commit/00a9878283bbbedff0ec20b428b1b95eb49f3b68)) +* **api:** dam related webhook events ([5c34c3e](https://github.com/imagekit-developer/imagekit-dotnet/commit/5c34c3e882a78631bd7d724809fa43723e5c7422)) +* **api:** dpr type update ([9dee001](https://github.com/imagekit-developer/imagekit-dotnet/commit/9dee001f1baf7776413872bb2c118adcb7027cea)) +* **api:** extract UpdateFileDetailsRequest to model ([4958ee3](https://github.com/imagekit-developer/imagekit-dotnet/commit/4958ee3f016ed279619ce85a2fcf2631a70dd48c)) +* **api:** fix spec indentation ([8efe42d](https://github.com/imagekit-developer/imagekit-dotnet/commit/8efe42de25549c94f7ad779c3f0f1438b2431ad7)) +* **api:** fix upload API request params ([351bd8b](https://github.com/imagekit-developer/imagekit-dotnet/commit/351bd8b5257ef15e730a4d6d75a3376bd0e6ec88)) +* **api:** indentation fix ([c5c541a](https://github.com/imagekit-developer/imagekit-dotnet/commit/c5c541a4f1badafe327688cd8a93a6d088cdc08a)) +* **api:** Introduce lxc, lyc, lap parameters in overlays. ([c78c870](https://github.com/imagekit-developer/imagekit-dotnet/commit/c78c8706445418d3ff8888c9665d3d62eb7d8dd8)) +* **api:** manual updates ([3692348](https://github.com/imagekit-developer/imagekit-dotnet/commit/3692348fb7fb0233b9e56029fb617f34a8aaf0b2)) +* **api:** manual updates ([e5be541](https://github.com/imagekit-developer/imagekit-dotnet/commit/e5be541283d8c3fa0c54109c1a21a0ec044c2c1b)) +* **api:** manual updates ([a5aa019](https://github.com/imagekit-developer/imagekit-dotnet/commit/a5aa0191ba84c42d6427904e0b84a55b8504e5e5)) +* **api:** manual updates ([8f803dc](https://github.com/imagekit-developer/imagekit-dotnet/commit/8f803dc6a878ba5b16c68f16e8d84e507e1a95dd)) +* **api:** manual updates ([18c4aa6](https://github.com/imagekit-developer/imagekit-dotnet/commit/18c4aa6a58f084886562d0a3b4237cacaaf81881)) +* **api:** manual updates ([ccc0a10](https://github.com/imagekit-developer/imagekit-dotnet/commit/ccc0a10db64ebe3a81990503390bfb991ff401f2)) +* **api:** manual updates ([fb27300](https://github.com/imagekit-developer/imagekit-dotnet/commit/fb27300dabd8f706901ecdb3375c893968d58198)) +* **api:** manual updates ([6e57b6f](https://github.com/imagekit-developer/imagekit-dotnet/commit/6e57b6f0d596828bb289ab651ec388398511e2ea)) +* **api:** manual updates ([63483cc](https://github.com/imagekit-developer/imagekit-dotnet/commit/63483ccdb648667fbdb97bb000852d9437d9e710)) +* **api:** manual updates ([9a9015d](https://github.com/imagekit-developer/imagekit-dotnet/commit/9a9015da3bf6746e1a29374124b2e7079a6d4715)) +* **api:** manual updates ([465abaa](https://github.com/imagekit-developer/imagekit-dotnet/commit/465abaaa4fa857aefb0d25bd1bfa5f5938841350)) +* **api:** manual updates ([1d0ef2c](https://github.com/imagekit-developer/imagekit-dotnet/commit/1d0ef2c5d92c060278cf3a78744b0656fe5afc44)) +* **api:** manual updates ([3101896](https://github.com/imagekit-developer/imagekit-dotnet/commit/3101896649dbd245ce572e34882675540953406e)) +* **api:** manual updates ([1bb691b](https://github.com/imagekit-developer/imagekit-dotnet/commit/1bb691ba1c7bd346d5f9b43f83bf661f27f23767)) +* **api:** manual updates ([a1a7ff4](https://github.com/imagekit-developer/imagekit-dotnet/commit/a1a7ff4d748d705978d0f48f382780dd1eaa3c8f)) +* **api:** manual updates ([255025e](https://github.com/imagekit-developer/imagekit-dotnet/commit/255025ede629cc2a6a12462a12e82f99a4e88047)) +* **api:** manual updates ([aec4884](https://github.com/imagekit-developer/imagekit-dotnet/commit/aec488450d0b633c965719590fa554d32e377a1c)) +* **api:** merge with main to bring back missing parameters ([371c058](https://github.com/imagekit-developer/imagekit-dotnet/commit/371c05839627af8ca90c92f206dcd6c4eab2acbc)) +* **api:** remove Stainless attribution from readme ([ad83528](https://github.com/imagekit-developer/imagekit-dotnet/commit/ad835287843cf028cd20018636e10dccacf2ba91)) +* **api:** revert dpr breaking change ([be0481d](https://github.com/imagekit-developer/imagekit-dotnet/commit/be0481db26eba8a068d312791d11f4a2cb10d15e)) +* **api:** update api docs link ([73f6625](https://github.com/imagekit-developer/imagekit-dotnet/commit/73f6625fa7a36186824fd9252d95428a798c1ba1)) +* **api:** Update env var name ([07bd820](https://github.com/imagekit-developer/imagekit-dotnet/commit/07bd820f7ad0352f08c574bbec421b147ec04095)) +* **api:** update webhook event names and remove DAM prefix ([9b4782b](https://github.com/imagekit-developer/imagekit-dotnet/commit/9b4782b93b8c25c9f4d8860d77fef233df03a556)) +* **api:** updated docs ([b5174e6](https://github.com/imagekit-developer/imagekit-dotnet/commit/b5174e6035410537160d0273de0e1d762de7b041)) +* **client:** add equality and tostring for multipart data ([cc0e490](https://github.com/imagekit-developer/imagekit-dotnet/commit/cc0e490a123ae36a56b95fb607daeba1d0b2ed51)) +* **client:** add response validation option ([cbba006](https://github.com/imagekit-developer/imagekit-dotnet/commit/cbba006a767b6e1f34bbacd1a22b032fbb27f69a)) +* **client:** enable gzip decompression ([5816325](https://github.com/imagekit-developer/imagekit-dotnet/commit/581632583d310ac6a67be73a6b019fef3637ebc1)) +* **client:** refactor exceptions ([0a7ef58](https://github.com/imagekit-developer/imagekit-dotnet/commit/0a7ef589948993f75c1ef55cde0cf328e4045a23)) +* **client:** refactor unions ([bc48acb](https://github.com/imagekit-developer/imagekit-dotnet/commit/bc48acbdaad71dff524ec71d788988d8120d11bc)) +* **client:** support request timeout ([73a7359](https://github.com/imagekit-developer/imagekit-dotnet/commit/73a7359c4d76a55eb62c5caca49bbef68c5d3561)) +* **internal:** add dev container ([0079482](https://github.com/imagekit-developer/imagekit-dotnet/commit/0079482ed996fb0a98bdf1f67fe0cd5f3b6e51d0)) +* support setting headers via env ([bba6a4a](https://github.com/imagekit-developer/imagekit-dotnet/commit/bba6a4ac127a0099237b6d25e1de569d3e7ac031)) + + +### Bug Fixes + +* **api:** add missing embeddedMetadata and video properties to FileDetails ([c11c19a](https://github.com/imagekit-developer/imagekit-dotnet/commit/c11c19adf164e16d9444fb4cff29d1ad7e5aa20a)) +* **api:** extract shared schemas to prevent Go webhook union breaking changes ([edde1fb](https://github.com/imagekit-developer/imagekit-dotnet/commit/edde1fb32d9c70580500de0595a2705d52381411)) +* **api:** rename DamFile events to File for consistency ([5476320](https://github.com/imagekit-developer/imagekit-dotnet/commit/547632077b3d8b927d08be2a7de882ce7b14e29d)) +* **client:** allow cancelling when enumerating over an http response ([fce341d](https://github.com/imagekit-developer/imagekit-dotnet/commit/fce341d12058b8fdaa4673cf94b8f63972baa769)) +* **client:** don't overzealously validate union variants when deserializing ([d240560](https://github.com/imagekit-developer/imagekit-dotnet/commit/d240560a6ea9a06d2dc454a8c4c04ad34ef2bd41)) +* **client:** handle edge case with renamed variable ([e833bbe](https://github.com/imagekit-developer/imagekit-dotnet/commit/e833bbe77e182f8fd59eaf888bbb4b3240bf1389)) +* **client:** handle path params correctly in `FromRawUnchecked` ([87f9421](https://github.com/imagekit-developer/imagekit-dotnet/commit/87f94216c76365266eaee43c4e47833506a7841b)) +* **client:** handle root bodies in requests properly ([dab469d](https://github.com/imagekit-developer/imagekit-dotnet/commit/dab469ddca42227808aa6dbef3cbe75b0d3b6f69)) +* **client:** improve behaviour for comma-delimited binary content in multipart requests ([5b492ec](https://github.com/imagekit-developer/imagekit-dotnet/commit/5b492eced226446eabf45eabcf86eb5c3077e61c)) +* **client:** improve union equality method ([e78fc46](https://github.com/imagekit-developer/imagekit-dotnet/commit/e78fc4603cbacc6282ca00e2fcb55eef3190955e)) +* **client:** validate unions properly ([f051a13](https://github.com/imagekit-developer/imagekit-dotnet/commit/f051a136ea8e267c7de0e39721312f9b6bcc1001)) +* **docs:** make xml syntactically correct ([8db05ed](https://github.com/imagekit-developer/imagekit-dotnet/commit/8db05ede91cd8e2742b365f13cc432e4856f5b09)) +* **internal:** build fixes ([29ee45d](https://github.com/imagekit-developer/imagekit-dotnet/commit/29ee45db5046c5ba5dcf2518b8940901831d2ccc)) +* **internal:** disable default HttpClient timeout as we have our own ([7a339f0](https://github.com/imagekit-developer/imagekit-dotnet/commit/7a339f0e7d011a747f1417cc0c14def30064b976)) +* **internal:** minor bug fixes on model instantiation and union validation ([8a55035](https://github.com/imagekit-developer/imagekit-dotnet/commit/8a550353bea0544017cdcd3ca28b07e72fb82f71)) +* **internal:** remove example csproj ([35baab0](https://github.com/imagekit-developer/imagekit-dotnet/commit/35baab00edb0c48b67292fdafd03649f3fb676c8)) +* **tests:** round-trip urls correctly ([b1928aa](https://github.com/imagekit-developer/imagekit-dotnet/commit/b1928aa69e2bbe51e6c653dca980fd35f8378dcc)) + + +### Chores + +* add titles for dotnet build ([6527394](https://github.com/imagekit-developer/imagekit-dotnet/commit/6527394d36ea7c98a7ed263aecbd69295c2e3a1f)) +* **ci:** skip lint on metadata-only changes ([9b8f476](https://github.com/imagekit-developer/imagekit-dotnet/commit/9b8f4768182dfde1955cde7e65afd6457c0b31ee)) +* **client:** simplify field validations ([cbba006](https://github.com/imagekit-developer/imagekit-dotnet/commit/cbba006a767b6e1f34bbacd1a22b032fbb27f69a)) +* **client:** update formatting ([9b33529](https://github.com/imagekit-developer/imagekit-dotnet/commit/9b3352912b92f706d5a99f6abbe579f22a43ab77)) +* **docs:** add proxy documentation to readme ([c6c1b1e](https://github.com/imagekit-developer/imagekit-dotnet/commit/c6c1b1e5676edb381459d6a28fd0d395515b17d8)) +* **docs:** add undocumented parameters to readme ([808b9c7](https://github.com/imagekit-developer/imagekit-dotnet/commit/808b9c7ce1f6c50a2f221bbe645900a1d422540b)) +* improve example values ([11c74cc](https://github.com/imagekit-developer/imagekit-dotnet/commit/11c74cca1bf612f470f91445006867addf0c31cb)) +* **internal:** codegen related update ([824969b](https://github.com/imagekit-developer/imagekit-dotnet/commit/824969b0ce6f8e1fb89b055f56dfe4ccc2c356dd)) +* **internal:** codegen related update ([9fcf3b3](https://github.com/imagekit-developer/imagekit-dotnet/commit/9fcf3b3f18b8450f12c48f904406e74cbbc12ccb)) +* **internal:** extract `ClientOptions` struct ([c657ba4](https://github.com/imagekit-developer/imagekit-dotnet/commit/c657ba48590fe74014a263188f32145b6489bd04)) +* **internal:** full qualify some references ([315b8a7](https://github.com/imagekit-developer/imagekit-dotnet/commit/315b8a7aeffa8f014d489de9fd41973064037fc9)) +* **internal:** ignore stainless-internal artifacts ([3c4946a](https://github.com/imagekit-developer/imagekit-dotnet/commit/3c4946a3d9fe40fa8c4fec7ce8a86032a89d8da4)) +* **internal:** remove mock server code ([0db5603](https://github.com/imagekit-developer/imagekit-dotnet/commit/0db5603b89957482070fd32814f0982ace6dfc49)) +* **internal:** tweak CI branches ([7378ffa](https://github.com/imagekit-developer/imagekit-dotnet/commit/7378ffadddfa96764d27d774e4ba8cf3c920d67a)) +* **internal:** update gitignore ([34b3e44](https://github.com/imagekit-developer/imagekit-dotnet/commit/34b3e4442c80d16f6028a6424d305f448f22e6e1)) +* revert custom code ([1eaf250](https://github.com/imagekit-developer/imagekit-dotnet/commit/1eaf25047baf52e19b4a7d4650f725095e234857)) +* sync repo ([22d3567](https://github.com/imagekit-developer/imagekit-dotnet/commit/22d3567b5fdf988260a9c62f791c391c759e04b1)) +* **tests:** add tests for retry logic ([5b1b23e](https://github.com/imagekit-developer/imagekit-dotnet/commit/5b1b23ef47d15ad1d73633a1feb8b532b5befd5a)) +* trigger build ([1f7df7f](https://github.com/imagekit-developer/imagekit-dotnet/commit/1f7df7f201d88147fc61be52fe3ca12b7845ecbe)) +* trigger build ([dcf3923](https://github.com/imagekit-developer/imagekit-dotnet/commit/dcf392311a628e6375fb667c36037da772585158)) +* trigger build for test ([820139a](https://github.com/imagekit-developer/imagekit-dotnet/commit/820139a79a6c36134ad8b56e1a6612e343aca4d5)) +* update mock server docs ([eda7488](https://github.com/imagekit-developer/imagekit-dotnet/commit/eda74887bad3b66bdc9bbda95f31873a5f6f43d8)) +* update placeholder string ([9151f2f](https://github.com/imagekit-developer/imagekit-dotnet/commit/9151f2f26e15ca5309bb49c85b030119f3043df9)) +* update SDK settings ([8d2e780](https://github.com/imagekit-developer/imagekit-dotnet/commit/8d2e780de5c4e2d03eb7e9ada8747307cbd6e634)) +* update SDK settings ([64c1feb](https://github.com/imagekit-developer/imagekit-dotnet/commit/64c1feb98cc33c0ae56760cd9045b64c92269a16)) + + +### Documentation + +* correct typo in default value description for custom metadata field ([a376187](https://github.com/imagekit-developer/imagekit-dotnet/commit/a37618772b40763b5191e0ab4713465bd3eb296d)) +* improve examples ([a7ba71e](https://github.com/imagekit-developer/imagekit-dotnet/commit/a7ba71eb4a00bfb04ea2c7adaa3b223e37f273d9)) +* remove typo in README.md ([53a5f51](https://github.com/imagekit-developer/imagekit-dotnet/commit/53a5f5102ba217fb7fea972832d2554054d8281a)) + + +### Refactors + +* AITags to singular AITag schema with array items pattern ([f131bc5](https://github.com/imagekit-developer/imagekit-dotnet/commit/f131bc5feaa7a3a8159f0a02f61a5693d70d3a41)) +* **internal:** default headers ([5864f17](https://github.com/imagekit-developer/imagekit-dotnet/commit/5864f17fd98fb3d6b8cacfd2e8d69bd8c311f0ff)) + + +### Build System + +* add ExtensionItem schema in csharp ([f081efe](https://github.com/imagekit-developer/imagekit-dotnet/commit/f081efef442577b59ba0fa266bdb057bb9104fcd)) +* change dotnet package name ([bf27fe1](https://github.com/imagekit-developer/imagekit-dotnet/commit/bf27fe1999bee95cfd4626dff26c0cfaea6cd746)) +* **dotnet:** add x-stainless-variantName to cannot infer union variant name warning ([3e6c2df](https://github.com/imagekit-developer/imagekit-dotnet/commit/3e6c2dfecca7c01f8c867f00f8bdd8afcf3517d5)) +* **dotnet:** adding variant name for build warnings cannot infer union variant name ([6e3bcf1](https://github.com/imagekit-developer/imagekit-dotnet/commit/6e3bcf1f35a20efd82793349a9f752b3efc9b85f)) +* enable dummy endpoint in csharp ([d34c864](https://github.com/imagekit-developer/imagekit-dotnet/commit/d34c86442e9179d300c1ca77e565a8dc1c0f8552)) +* give explicit titles to fix build warnings ([5a116f4](https://github.com/imagekit-developer/imagekit-dotnet/commit/5a116f4f38bbde8ead67229cbe55299359a0a7bd)) diff --git a/src/Imagekit/Imagekit.csproj b/src/Imagekit/Imagekit.csproj index c2071111..d91f5861 100644 --- a/src/Imagekit/Imagekit.csproj +++ b/src/Imagekit/Imagekit.csproj @@ -3,18 +3,18 @@ Image Kit C# Imagekit - 0.0.1 + 0.1.0 The official .NET library for the Image Kit API. Library README.md - - - - + + + + - + \ No newline at end of file